Keep runtime files inside application support
This commit is contained in:
@@ -2687,7 +2687,7 @@ impl Session {
|
||||
// `session` must release every Buffer before `_context` calls ds4_gpu_cleanup(),
|
||||
// and `_context` must drop before `model` unmaps memory wrapped without copying
|
||||
// by native/metal/ds4_metal.m:10329. This intentionally differs from
|
||||
// ../ds4/ds4.c:56287-56288; do not reorder these fields to match it.
|
||||
// DS4's `ds4.c` consumes this exact field order; do not reorder it.
|
||||
#[derive(Clone, Copy, Default)]
|
||||
pub(super) struct ExecutionStats {
|
||||
pub(super) speculative_mode: u8,
|
||||
@@ -7068,6 +7068,14 @@ mod tests {
|
||||
};
|
||||
use crate::engine::{FLASH, PRO};
|
||||
|
||||
fn installed_artifacts(
|
||||
model: crate::model::ModelChoice,
|
||||
legacy_mtp: bool,
|
||||
dspark: bool,
|
||||
) -> crate::model::EngineArtifacts {
|
||||
crate::model::engine_artifacts(model, legacy_mtp, dspark, &crate::app::models_path())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compression_schedule_tracks_the_deepseek_model_shape() {
|
||||
assert_eq!(compression_ratio(FLASH, 0), 0);
|
||||
@@ -7165,16 +7173,14 @@ mod tests {
|
||||
use crate::settings::{
|
||||
EngineSpeculativeSettings, EngineSsdSettings, EngineSteeringSettings,
|
||||
};
|
||||
use std::path::Path;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
|
||||
let main_path = Path::new(
|
||||
"../ds4/gguf/DeepSeek-V4-Flash-IQ2XXS-w2Q2K-AProjQ8-SExpQ8-OutQ8-chat-v2-imatrix.gguf",
|
||||
);
|
||||
let artifacts = installed_artifacts(ModelChoice::DeepSeekV4Flash, true, false);
|
||||
let main_path = artifacts.model;
|
||||
configure_sources().unwrap();
|
||||
let support_path = Path::new("../ds4/gguf/DeepSeek-V4-Flash-MTP-Q4K-Q8_0-F32.gguf");
|
||||
let mut model = Model::open_main(main_path, ModelChoice::DeepSeekV4Flash).unwrap();
|
||||
let support = Gguf::open(support_path).unwrap();
|
||||
let support_path = artifacts.mtp.unwrap();
|
||||
let mut model = Model::open_main(&main_path, ModelChoice::DeepSeekV4Flash).unwrap();
|
||||
let support = Gguf::open(&support_path).unwrap();
|
||||
model.support_kind = Some(validate_support(&support, &model.shape).unwrap());
|
||||
model.support = Some(support);
|
||||
let prompt = model.render_conversation(
|
||||
@@ -7304,16 +7310,14 @@ mod tests {
|
||||
use crate::settings::{
|
||||
EngineSpeculativeSettings, EngineSsdSettings, EngineSteeringSettings,
|
||||
};
|
||||
use std::path::Path;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
|
||||
configure_sources().unwrap();
|
||||
let main_path = Path::new(
|
||||
"../ds4/gguf/DeepSeek-V4-Flash-IQ2XXS-w2Q2K-AProjQ8-SExpQ8-OutQ8-chat-v2-imatrix.gguf",
|
||||
);
|
||||
let support_path = Path::new("../ds4/gguf/DeepSeek-V4-Flash-DSpark-support.gguf");
|
||||
let mut model = Model::open_main(main_path, ModelChoice::DeepSeekV4Flash).unwrap();
|
||||
let support = Gguf::open(support_path).unwrap();
|
||||
let artifacts = installed_artifacts(ModelChoice::DeepSeekV4Flash, false, true);
|
||||
let main_path = artifacts.model;
|
||||
let support_path = artifacts.mtp.unwrap();
|
||||
let mut model = Model::open_main(&main_path, ModelChoice::DeepSeekV4Flash).unwrap();
|
||||
let support = Gguf::open(&support_path).unwrap();
|
||||
model.support_kind = Some(validate_support(&support, &model.shape).unwrap());
|
||||
model.support = Some(support);
|
||||
let prompt = model.render_conversation(
|
||||
@@ -7446,24 +7450,19 @@ mod tests {
|
||||
use crate::settings::{
|
||||
EngineSpeculativeSettings, EngineSsdSettings, EngineSteeringSettings,
|
||||
};
|
||||
use std::path::Path;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
|
||||
configure_sources().unwrap();
|
||||
let main_path = Path::new(
|
||||
"../ds4/gguf/DeepSeek-V4-Flash-IQ2XXS-w2Q2K-AProjQ8-SExpQ8-OutQ8-chat-v2-imatrix.gguf",
|
||||
);
|
||||
let legacy = installed_artifacts(ModelChoice::DeepSeekV4Flash, true, false);
|
||||
let dspark_artifacts = installed_artifacts(ModelChoice::DeepSeekV4Flash, false, true);
|
||||
let main_path = legacy.model;
|
||||
let cases = [
|
||||
(
|
||||
"../ds4/gguf/DeepSeek-V4-Flash-MTP-Q4K-Q8_0-F32.gguf",
|
||||
false,
|
||||
4,
|
||||
),
|
||||
("../ds4/gguf/DeepSeek-V4-Flash-DSpark-support.gguf", true, 1),
|
||||
(legacy.mtp.unwrap(), false, 4),
|
||||
(dspark_artifacts.mtp.unwrap(), true, 1),
|
||||
];
|
||||
for (support_path, dspark, draft_tokens) in cases {
|
||||
let mut model = Model::open_main(main_path, ModelChoice::DeepSeekV4Flash).unwrap();
|
||||
let support = Gguf::open(Path::new(support_path)).unwrap();
|
||||
let mut model = Model::open_main(&main_path, ModelChoice::DeepSeekV4Flash).unwrap();
|
||||
let support = Gguf::open(&support_path).unwrap();
|
||||
model.support_kind = Some(validate_support(&support, &model.shape).unwrap());
|
||||
model.support = Some(support);
|
||||
let prompt = model.render_conversation(
|
||||
@@ -7528,7 +7527,8 @@ mod tests {
|
||||
assert_eq!(
|
||||
generated,
|
||||
[19_923, 3, 1_730, 588, 342, 1_694, 440, 4_316],
|
||||
"SSD speculative output differed for {support_path}"
|
||||
"SSD speculative output differed for {}",
|
||||
support_path.display()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -7604,12 +7604,10 @@ mod tests {
|
||||
}
|
||||
|
||||
configure_sources().unwrap();
|
||||
let path = Path::new(
|
||||
"../ds4/gguf/DeepSeek-V4-Flash-IQ2XXS-w2Q2K-AProjQ8-SExpQ8-OutQ8-chat-v2-imatrix.gguf",
|
||||
);
|
||||
let resident = run(path, false);
|
||||
let path = installed_artifacts(ModelChoice::DeepSeekV4Flash, false, false).model;
|
||||
let resident = run(&path, false);
|
||||
assert_eq!(resident, [19_923, 3, 1_730, 588]);
|
||||
assert_eq!(resident, run(path, true));
|
||||
assert_eq!(resident, run(&path, true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -7621,16 +7619,10 @@ mod tests {
|
||||
use crate::settings::{
|
||||
EngineSpeculativeSettings, EngineSsdSettings, EngineSteeringSettings,
|
||||
};
|
||||
use std::path::Path;
|
||||
|
||||
configure_sources().unwrap();
|
||||
let model = Model::open_main(
|
||||
Path::new(
|
||||
"../ds4/gguf/DeepSeek-V4-Flash-IQ2XXS-w2Q2K-AProjQ8-SExpQ8-OutQ8-chat-v2-imatrix.gguf",
|
||||
),
|
||||
ModelChoice::DeepSeekV4Flash,
|
||||
)
|
||||
.unwrap();
|
||||
let path = installed_artifacts(ModelChoice::DeepSeekV4Flash, false, false).model;
|
||||
let model = Model::open_main(&path, ModelChoice::DeepSeekV4Flash).unwrap();
|
||||
let prompt = model.render_conversation(
|
||||
"",
|
||||
&[crate::engine::ChatTurn {
|
||||
@@ -7690,16 +7682,10 @@ mod tests {
|
||||
use crate::settings::{
|
||||
EngineSpeculativeSettings, EngineSsdSettings, EngineSteeringSettings, ReasoningMode,
|
||||
};
|
||||
use std::path::Path;
|
||||
|
||||
configure_sources().unwrap();
|
||||
let model = Model::open_main(
|
||||
Path::new(
|
||||
"../ds4/gguf/DeepSeek-V4-Flash-IQ2XXS-w2Q2K-AProjQ8-SExpQ8-OutQ8-chat-v2-imatrix.gguf",
|
||||
),
|
||||
ModelChoice::DeepSeekV4Flash,
|
||||
)
|
||||
.unwrap();
|
||||
let path = installed_artifacts(ModelChoice::DeepSeekV4Flash, false, false).model;
|
||||
let model = Model::open_main(&path, ModelChoice::DeepSeekV4Flash).unwrap();
|
||||
let prompts = ["Reply with A.", "Reply with B."].map(|content| {
|
||||
model.render_conversation(
|
||||
"",
|
||||
@@ -7775,19 +7761,17 @@ mod tests {
|
||||
use crate::settings::{
|
||||
EngineSpeculativeSettings, EngineSsdSettings, EngineSteeringSettings,
|
||||
};
|
||||
use std::path::Path;
|
||||
|
||||
configure_sources().unwrap();
|
||||
let model_path = Path::new(
|
||||
"../ds4/gguf/DeepSeek-V4-Flash-IQ2XXS-w2Q2K-AProjQ8-SExpQ8-OutQ8-chat-v2-imatrix.gguf",
|
||||
);
|
||||
let steering_path = "../ds4/dir-steering/out/verbosity.f32";
|
||||
let model_path = installed_artifacts(ModelChoice::DeepSeekV4Flash, false, false).model;
|
||||
let steering_path = std::env::var("DS4_STEERING_FILE")
|
||||
.expect("set DS4_STEERING_FILE to the DS4 verbosity direction fixture");
|
||||
let cases = [
|
||||
(1.0, 0.0, [19_923, 3, 1_730, 588, 342, 8_233, 440, 4_316]),
|
||||
(0.0, 1.0, [19_923, 3, 1_730, 588, 342, 1_694, 440, 4_316]),
|
||||
];
|
||||
for (ffn_scale, attention_scale, expected) in cases {
|
||||
let model = Model::open_main(model_path, ModelChoice::DeepSeekV4Flash).unwrap();
|
||||
let model = Model::open_main(&model_path, ModelChoice::DeepSeekV4Flash).unwrap();
|
||||
let prompt = model.render_conversation(
|
||||
"",
|
||||
&[crate::engine::ChatTurn {
|
||||
@@ -7827,7 +7811,7 @@ mod tests {
|
||||
preload_experts: 0,
|
||||
},
|
||||
EngineSteeringSettings {
|
||||
file: Some(steering_path.into()),
|
||||
file: Some(steering_path.clone()),
|
||||
ffn_scale,
|
||||
attention_scale,
|
||||
},
|
||||
@@ -7853,18 +7837,15 @@ mod tests {
|
||||
use crate::settings::{
|
||||
EngineSpeculativeSettings, EngineSsdSettings, EngineSteeringSettings,
|
||||
};
|
||||
use std::path::Path;
|
||||
|
||||
configure_sources().unwrap();
|
||||
let path = std::env::var("DS4_PRO_MODEL").unwrap_or_else(|_| {
|
||||
"../ds4/models/DeepSeek-V4-Pro-IQ2XXS-w2Q2K-AProjQ8-SExpQ8-OutQ8-Instruct-imatrix.gguf".into()
|
||||
});
|
||||
if !Path::new(&path).is_file() {
|
||||
eprintln!("skipping unavailable Pro fixture: {path}");
|
||||
let path = installed_artifacts(ModelChoice::DeepSeekV4Pro, false, false).model;
|
||||
if !path.is_file() {
|
||||
eprintln!("skipping unavailable Pro fixture: {}", path.display());
|
||||
return;
|
||||
}
|
||||
let run = |cache_experts| {
|
||||
let model = Model::open_main(Path::new(&path), ModelChoice::DeepSeekV4Pro).unwrap();
|
||||
let model = Model::open_main(&path, ModelChoice::DeepSeekV4Pro).unwrap();
|
||||
let prompt = model.render_conversation(
|
||||
"",
|
||||
&[crate::engine::ChatTurn {
|
||||
|
||||
Reference in New Issue
Block a user