Remove deprecated Flash preview and legacy MTP

This commit is contained in:
Georg Bauer
2026-08-31 08:04:20 +02:00
parent 7f88e23884
commit 0fa15bb68b
24 changed files with 246 additions and 1200 deletions

View File

@@ -11,7 +11,6 @@ pub(crate) const REASONING_MODES: [ReasoningMode; 3] = [
const STANDARD_REASONING_MODES: [ReasoningMode; 2] = [ReasoningMode::High, ReasoningMode::Direct];
const THINK_MAX_MIN_CONTEXT: i32 = 393_216;
const MAX_CPU_THREADS: u32 = 32;
const MAX_MTP_DRAFT_TOKENS: i32 = 16;
pub(crate) const GIB: u64 = 1024 * 1024 * 1024;
/// DS4 disk KV cache defaults, from `ds4_kvstore.h` and `--kv-disk-space-mb`.
pub(crate) const DEFAULT_KV_BUDGET_GIB: u64 = 4;
@@ -19,12 +18,9 @@ const DEFAULT_KV_MIN_TOKENS: u32 = 512;
const DEFAULT_KV_COLD_MAX_TOKENS: u32 = 30_000;
const DEFAULT_KV_CONTINUED_INTERVAL_TOKENS: u32 = 10_000;
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
#[serde(default, deny_unknown_fields)]
pub(crate) struct SpeculativePreferences {
pub(crate) mtp_draft_tokens: i32,
pub(crate) mtp_margin: f32,
pub(crate) legacy_mtp_enabled: bool,
pub(crate) glm_mtp: bool,
pub(crate) glm_mtp_timing: bool,
pub(crate) dspark_enabled: bool,
@@ -33,28 +29,8 @@ pub(crate) struct SpeculativePreferences {
pub(crate) dspark_exact_sampling: bool,
}
impl Default for SpeculativePreferences {
fn default() -> Self {
Self {
mtp_draft_tokens: 1,
mtp_margin: 3.0,
legacy_mtp_enabled: false,
glm_mtp: false,
glm_mtp_timing: false,
dspark_enabled: false,
dspark_confidence_threshold: None,
dspark_strict: false,
dspark_exact_sampling: false,
}
}
}
impl SpeculativePreferences {
pub(crate) fn validate(&self, model: ModelChoice) -> Result<(), String> {
if self.mtp_draft_tokens <= 0 {
return Err("MTP draft tokens must be a positive whole number.".into());
}
validate_float("MTP margin", self.mtp_margin, 0.0, 1000.0)?;
if self.glm_mtp_timing && !self.glm_mtp {
return Err("GLM MTP timing requires GLM MTP.".into());
}
@@ -64,12 +40,6 @@ impl SpeculativePreferences {
if self.dspark_enabled && !model.supports_dspark() {
return Err("DSpark is not available for the selected model.".into());
}
if self.legacy_mtp_enabled && !model.supports_legacy_mtp() {
return Err("Legacy MTP is not available for the selected model.".into());
}
if self.legacy_mtp_enabled && self.dspark_enabled {
return Err("Legacy MTP and DSpark use different support artifacts.".into());
}
if (self.dspark_confidence_threshold.is_some()
|| self.dspark_strict
|| self.dspark_exact_sampling)
@@ -85,8 +55,6 @@ impl SpeculativePreferences {
pub(crate) fn engine_settings(&self) -> EngineSpeculativeSettings {
EngineSpeculativeSettings {
mtp_draft_tokens: self.mtp_draft_tokens.min(MAX_MTP_DRAFT_TOKENS),
mtp_margin: self.mtp_margin,
glm_mtp: self.glm_mtp,
glm_mtp_timing: self.glm_mtp_timing,
dspark: self.dspark_enabled,
@@ -100,8 +68,6 @@ impl SpeculativePreferences {
#[derive(Clone, Copy, Debug, PartialEq)]
pub(crate) struct EngineSpeculativeSettings {
pub(crate) mtp_draft_tokens: i32,
pub(crate) mtp_margin: f32,
pub(crate) glm_mtp: bool,
pub(crate) glm_mtp_timing: bool,
pub(crate) dspark: bool,
@@ -415,12 +381,7 @@ impl RuntimePreferences {
self.validate(model)?;
Ok(EngineSettings {
model,
artifacts: model::engine_artifacts(
model,
self.speculative.legacy_mtp_enabled,
self.speculative.dspark_enabled,
models_path,
),
artifacts: model::engine_artifacts(model, self.speculative.dspark_enabled, models_path),
context_tokens,
execution: self.execution.engine_settings(),
speculative: self.speculative.engine_settings(),
@@ -698,7 +659,7 @@ mod tests {
assert_eq!(defaults.system_prompt, DEFAULT_SYSTEM_PROMPT);
assert!(defaults.system_prompt.contains("\n\nGuidelines:\n-"));
let cache = KvCachePreferences::default().settings();
let deepseek = defaults.turn_settings(ModelChoice::DeepSeekV4Flash, cache);
let deepseek = defaults.turn_settings(ModelChoice::DeepSeekV4Flash0731, cache);
assert_eq!(
(deepseek.temperature, deepseek.top_p, deepseek.min_p),
(1.0, 1.0, 0.05)
@@ -773,7 +734,7 @@ mod tests {
};
assert!(
unsupported_threads
.validate(ModelChoice::DeepSeekV4Flash)
.validate(ModelChoice::DeepSeekV4Flash0731)
.is_err()
);
@@ -782,7 +743,7 @@ mod tests {
prefill_chunk: Some(4096),
..ExecutionPreferences::default()
};
assert!(tuned.validate(ModelChoice::DeepSeekV4Flash).is_ok());
assert!(tuned.validate(ModelChoice::DeepSeekV4Flash0731).is_ok());
assert!(tuned.validate(ModelChoice::Glm52).is_err());
}
@@ -790,21 +751,18 @@ mod tests {
fn speculative_settings_match_acceleration_defaults_and_dependencies() {
let defaults = SpeculativePreferences::default();
let engine = defaults.engine_settings();
assert_eq!((engine.mtp_draft_tokens, engine.mtp_margin), (1, 3.0));
assert_eq!(engine.dspark_confidence_threshold, 0.8);
assert!(!engine.dspark_confidence_threshold_set);
let tuned = SpeculativePreferences {
mtp_draft_tokens: 20,
dspark_enabled: true,
dspark_confidence_threshold: Some(0.7),
dspark_strict: true,
dspark_exact_sampling: true,
..defaults
};
assert!(tuned.validate(ModelChoice::DeepSeekV4Flash).is_ok());
assert!(tuned.validate(ModelChoice::DeepSeekV4Flash0731).is_ok());
assert!(tuned.validate(ModelChoice::Glm52).is_err());
assert_eq!(tuned.engine_settings().mtp_draft_tokens, 16);
let glm = SpeculativePreferences {
glm_mtp: true,
@@ -814,21 +772,6 @@ mod tests {
assert!(glm.validate(ModelChoice::Glm52).is_ok());
assert!(glm.validate(ModelChoice::DeepSeekV4Pro).is_err());
let legacy = SpeculativePreferences {
legacy_mtp_enabled: true,
..SpeculativePreferences::default()
};
assert!(legacy.validate(ModelChoice::DeepSeekV4Flash).is_ok());
assert!(legacy.validate(ModelChoice::DeepSeekV4Flash0731).is_err());
assert!(legacy.validate(ModelChoice::DeepSeekV4Pro).is_err());
assert!(
SpeculativePreferences {
dspark_enabled: true,
..legacy
}
.validate(ModelChoice::DeepSeekV4Flash)
.is_err()
);
assert!(
SpeculativePreferences {
dspark_exact_sampling: true,
@@ -892,7 +835,7 @@ mod tests {
..RuntimePreferences::default()
};
let effective = effective_settings(
ModelChoice::DeepSeekV4Flash,
ModelChoice::DeepSeekV4Flash0731,
&GenerationPreferences::default(),
&runtime,
Path::new("/models"),
@@ -900,7 +843,7 @@ mod tests {
.unwrap();
let engine = effective.engine;
assert_eq!(engine.context_tokens, 32_768);
assert!(engine.artifacts.mtp.is_none());
assert!(engine.artifacts.support.is_none());
assert_eq!(engine.ssd.cache_bytes, 64 * GIB);
assert!(engine.ssd.full_layers_set);
assert_eq!(engine.ssd.full_layers, 0);
@@ -914,7 +857,7 @@ mod tests {
},
..runtime
};
assert!(combined.validate(ModelChoice::DeepSeekV4Flash).is_ok());
assert!(combined.validate(ModelChoice::DeepSeekV4Flash0731).is_ok());
}
#[test]
@@ -932,7 +875,7 @@ mod tests {
..RuntimePreferences::default()
};
let effective = effective_settings(
ModelChoice::DeepSeekV4Flash,
ModelChoice::DeepSeekV4Flash0731,
&generation,
&runtime,
Path::new("/models"),
@@ -942,9 +885,9 @@ mod tests {
assert_eq!(effective.engine.context_tokens, 65_536);
assert_eq!(
effective.engine.artifacts.model.parent(),
Some(Path::new("/models/deepseek-v4-flash"))
Some(Path::new("/models/deepseek-v4-flash-0731"))
);
assert!(effective.engine.artifacts.mtp.is_some());
assert!(effective.engine.artifacts.support.is_some());
assert_eq!(effective.turn.temperature, 0.25);
}
@@ -967,9 +910,6 @@ mod tests {
"--kv-disk-space-mb",
"--min-p",
"--model",
"--mtp",
"--mtp-draft",
"--mtp-margin",
"--nothink",
"--power",
"--prefill-chunk",