Support Linux refactoring checks
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
mod gguf;
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(any(target_os = "macos", test))]
|
||||
mod kvstore;
|
||||
#[cfg(target_os = "macos")]
|
||||
mod metal;
|
||||
@@ -9,6 +9,7 @@ mod validation;
|
||||
#[cfg(target_os = "macos")]
|
||||
use crate::metrics::{KvLookup, Metrics};
|
||||
use crate::model::ModelChoice;
|
||||
#[cfg(target_os = "macos")]
|
||||
use crate::settings::TurnSettings;
|
||||
use crate::settings::{EngineSettings, ReasoningMode};
|
||||
use gguf::{F16, F32, Gguf, I32, IQ2_XXS, Q2_K, Q4_0, Q4_K, Q5_K, Q6_K, Q8_0, Tensor, Value};
|
||||
@@ -17,9 +18,12 @@ use kvstore::{KvStore, StoreReason};
|
||||
use sha2::{Digest, Sha256};
|
||||
#[cfg(target_os = "macos")]
|
||||
use std::collections::HashMap;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::path::Path;
|
||||
#[cfg(target_os = "macos")]
|
||||
use std::path::PathBuf;
|
||||
#[cfg(target_os = "macos")]
|
||||
use std::sync::Arc;
|
||||
#[cfg(target_os = "macos")]
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
#[cfg(target_os = "macos")]
|
||||
use std::time::Instant;
|
||||
@@ -1386,7 +1390,7 @@ impl Generator {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(any(target_os = "macos", test))]
|
||||
fn append_generated_bytes(
|
||||
generated: &mut ChatTurn,
|
||||
reasoning: bool,
|
||||
@@ -1449,7 +1453,7 @@ fn flush_generated(
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(any(target_os = "macos", test))]
|
||||
fn emit_safe_text(
|
||||
text: &mut String,
|
||||
emitted: &mut usize,
|
||||
@@ -1494,7 +1498,7 @@ fn emit_safe_text(
|
||||
false
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(any(target_os = "macos", test))]
|
||||
fn conversation_key(system: &str, reasoning: ReasoningMode, messages: &[ChatTurn]) -> Vec<u8> {
|
||||
fn text(output: &mut Vec<u8>, value: &str) {
|
||||
output.extend_from_slice(&(value.len() as u64).to_le_bytes());
|
||||
@@ -1526,12 +1530,12 @@ fn conversation_key(system: &str, reasoning: ReasoningMode, messages: &[ChatTurn
|
||||
output
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(any(target_os = "macos", test))]
|
||||
fn conversation_tag(system: &str, reasoning: ReasoningMode, messages: &[ChatTurn]) -> [u8; 32] {
|
||||
Sha256::digest(conversation_key(system, reasoning, messages)).into()
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(any(target_os = "macos", test))]
|
||||
fn checkpoint_matches_prefix(
|
||||
checkpoint: [u8; 32],
|
||||
system: &str,
|
||||
@@ -1555,7 +1559,7 @@ fn resident_key(directory: &Path, tag: [u8; 32]) -> PathBuf {
|
||||
directory.join("resident").join(name)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(any(target_os = "macos", test))]
|
||||
fn sample(
|
||||
logits: &[f32],
|
||||
temperature: f32,
|
||||
@@ -1631,10 +1635,10 @@ fn sample(
|
||||
probabilities.last().map_or(0, |(token, _)| *token as i32)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(any(target_os = "macos", test))]
|
||||
struct Rng(u64);
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(any(target_os = "macos", test))]
|
||||
impl Rng {
|
||||
fn new(seed: u64) -> Self {
|
||||
Self(seed.max(1))
|
||||
@@ -1654,7 +1658,7 @@ impl Rng {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(test, target_os = "macos"))]
|
||||
#[cfg(test)]
|
||||
mod sampling_tests {
|
||||
use super::*;
|
||||
|
||||
@@ -1835,6 +1839,7 @@ mod sampling_tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "macos")]
|
||||
#[ignore = "requires the 80 GiB Flash checkpoint and Apple Metal"]
|
||||
fn metal_executes_real_flash_token() {
|
||||
configure_metal_sources().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user