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

File diff suppressed because it is too large Load Diff

View File

@@ -301,10 +301,6 @@ impl DeepSeekExecutor {
self.tokens = tokens;
self.logits = logits;
self.checkpoint_tag = checkpoint_tag;
if let Some(mtp) = &mut self.legacy_mtp {
mtp.draft_token = None;
mtp.raw_rows = 0;
}
if let Some(dspark) = &mut self.dspark {
dspark.capture_mask = 0;
dspark.cache_start = 0;

View File

@@ -398,8 +398,6 @@ impl GlmExecutor {
quality,
ssd,
EngineSpeculativeSettings {
mtp_draft_tokens: 1,
mtp_margin: 3.0,
glm_mtp: false,
glm_mtp_timing: false,
dspark: false,
@@ -3243,8 +3241,7 @@ mod tests {
use crate::settings::EngineSsdSettings;
fn installed_glm_path() -> std::path::PathBuf {
crate::model::engine_artifacts(ModelChoice::Glm52, false, false, &crate::app::models_path())
.model
crate::model::engine_artifacts(ModelChoice::Glm52, false, &crate::app::models_path()).model
}
#[test]
@@ -3433,8 +3430,6 @@ mod tests {
preload_experts: 0,
},
EngineSpeculativeSettings {
mtp_draft_tokens: 2,
mtp_margin: 3.0,
glm_mtp: enabled,
glm_mtp_timing: false,
dspark: false,

View File

@@ -288,9 +288,10 @@ mod tests {
std::process::id(),
std::thread::current().name().unwrap_or("test")
));
let mut profile = ExpertProfile::new(path.to_str(), ModelChoice::DeepSeekV4Flash, 1, 8, 2)
.unwrap()
.unwrap();
let mut profile =
ExpertProfile::new(path.to_str(), ModelChoice::DeepSeekV4Flash0731, 1, 8, 2)
.unwrap()
.unwrap();
profile
.record_row(0, 10, &[1, 2], &[0.6, 0.4], false)
.unwrap();

View File

@@ -8,7 +8,6 @@ pub(crate) fn validate_model_artifact(
if support {
let model = Gguf::open(path)?;
let shape = match expected {
ModelChoice::DeepSeekV4Flash => FLASH,
ModelChoice::DeepSeekV4Flash0731 => FLASH_0731,
ModelChoice::DeepSeekV4Pro | ModelChoice::Glm52 => {
return Err(format!("{expected} does not use an external support GGUF"));
@@ -38,7 +37,6 @@ pub(crate) fn validate_model_artifact(
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(super) enum SupportKind {
LegacyMtp,
DSpark,
}
@@ -106,122 +104,17 @@ pub(super) fn dspark_config(model: &Gguf) -> Result<DsparkConfig, String> {
}
pub(super) fn validate_support(model: &Gguf, shape: &Shape) -> Result<SupportKind, String> {
if model.tensors.contains_key("mtp.0.e_proj.weight")
&& model.tensors.contains_key("mtp.0.h_proj.weight")
&& model.tensors.contains_key("mtp.0.hc_head_base.weight")
{
validate_legacy_mtp(model, shape)?;
Ok(SupportKind::LegacyMtp)
} else if model.metadata.contains_key("deepseek4.dspark.block_size")
if model.metadata.contains_key("deepseek4.dspark.block_size")
|| model.metadata.contains_key("deepseek4.dspark_block_size")
|| model.metadata.contains_key("dspark.block_size")
{
validate_dspark(model, shape)?;
Ok(SupportKind::DSpark)
} else {
Err("support GGUF is neither legacy MTP nor DSpark".into())
Err("support GGUF is not a DSpark artifact".into())
}
}
fn validate_legacy_mtp(model: &Gguf, shape: &Shape) -> Result<(), String> {
if shape.model != ModelChoice::DeepSeekV4Flash {
return Err("legacy MTP support is available only for DeepSeek V4 Flash".into());
}
let prefix = "mtp.0";
let hc_dim = shape.embd * shape.hc;
let hc_mix = 2 * shape.hc + shape.hc * shape.hc;
let q_dim = shape.heads * shape.head_dim;
let output_low = shape.out_groups * shape.lora_o;
for (suffix, types, dims) in [
("hc_head_base.weight", &[F32][..], vec![shape.hc]),
("hc_head_fn.weight", PLAIN, vec![hc_dim, shape.hc]),
("hc_head_scale.weight", &[F32][..], vec![1]),
("e_proj.weight", &[Q8_0][..], vec![shape.embd, shape.embd]),
("h_proj.weight", &[Q8_0][..], vec![shape.embd, shape.embd]),
("enorm.weight", &[F32][..], vec![shape.embd]),
("hnorm.weight", &[F32][..], vec![shape.embd]),
("norm.weight", &[F32][..], vec![shape.embd]),
("hc_attn_fn.weight", PLAIN, vec![hc_dim, hc_mix]),
("hc_attn_scale.weight", &[F32][..], vec![3]),
("hc_attn_base.weight", &[F32][..], vec![hc_mix]),
("attn_norm.weight", &[F32][..], vec![shape.embd]),
(
"attn_q_a.weight",
&[Q8_0][..],
vec![shape.embd, shape.lora_q],
),
("attn_q_a_norm.weight", &[F32][..], vec![shape.lora_q]),
("attn_q_b.weight", &[Q8_0][..], vec![shape.lora_q, q_dim]),
(
"attn_kv.weight",
&[Q8_0][..],
vec![shape.embd, shape.head_dim],
),
("attn_kv_a_norm.weight", &[F32][..], vec![shape.head_dim]),
("attn_sinks.weight", &[F32][..], vec![shape.heads]),
(
"attn_output_a.weight",
&[Q8_0][..],
vec![
shape.head_dim * (shape.heads / shape.out_groups),
output_low,
],
),
(
"attn_output_b.weight",
&[Q8_0][..],
vec![output_low, shape.embd],
),
("hc_ffn_fn.weight", PLAIN, vec![hc_dim, hc_mix]),
("hc_ffn_scale.weight", &[F32][..], vec![3]),
("hc_ffn_base.weight", &[F32][..], vec![hc_mix]),
("ffn_norm.weight", &[F32][..], vec![shape.embd]),
(
"ffn_gate_inp.weight",
PLAIN,
vec![shape.embd, shape.experts],
),
("exp_probs_b.bias", &[F32][..], vec![shape.experts]),
(
"ffn_gate_exps.weight",
ROUTED,
vec![shape.embd, shape.ff_expert, shape.experts],
),
(
"ffn_up_exps.weight",
ROUTED,
vec![shape.embd, shape.ff_expert, shape.experts],
),
(
"ffn_down_exps.weight",
ROUTED,
vec![shape.ff_expert, shape.embd, shape.experts],
),
(
"ffn_gate_shexp.weight",
&[Q8_0][..],
vec![shape.embd, shape.ff_expert],
),
(
"ffn_up_shexp.weight",
&[Q8_0][..],
vec![shape.embd, shape.ff_expert],
),
(
"ffn_down_shexp.weight",
&[Q8_0][..],
vec![shape.ff_expert, shape.embd],
),
] {
expect(model, &format!("{prefix}.{suffix}"), types, &dims)?;
}
same_type(
model,
"mtp.0.ffn_gate_exps.weight",
"mtp.0.ffn_up_exps.weight",
)
}
pub(super) fn validate_main(model: &Gguf, expected: ModelChoice) -> Result<Shape, String> {
let family = if model.bytes("general.architecture").ok() == Some(b"glm-dsa") {
ModelFamily::Glm
@@ -232,7 +125,7 @@ pub(super) fn validate_main(model: &Gguf, expected: ModelChoice) -> Result<Shape
ModelFamily::Glm => GLM,
ModelFamily::DeepSeek => match (model.u32("deepseek4.block_count")?, expected) {
(43, ModelChoice::DeepSeekV4Flash0731) => FLASH_0731,
(43, _) => FLASH,
(43, _) => FLASH_0731,
(61, _) => PRO,
(layers, _) => return Err(format!("unsupported DeepSeek layer count: {layers}")),
},
@@ -766,10 +659,7 @@ fn validate_glm_tensors(model: &Gguf, shape: &Shape) -> Result<(), String> {
}
pub(super) fn validate_dspark(model: &Gguf, shape: &Shape) -> Result<(), String> {
if !matches!(
shape.model,
ModelChoice::DeepSeekV4Flash | ModelChoice::DeepSeekV4Flash0731
) {
if !matches!(shape.model, ModelChoice::DeepSeekV4Flash0731) {
return Err("DSpark support is available only for DeepSeek V4 Flash".into());
}
let DsparkConfig {
@@ -1004,18 +894,14 @@ fn float_eq(actual: f32, expected: f32) -> bool {
fn compression_ratio(shape: &Shape, layer: u32) -> u32 {
match shape.model {
ModelChoice::DeepSeekV4Flash | ModelChoice::DeepSeekV4Flash0731 if layer < 2 => 0,
ModelChoice::DeepSeekV4Flash0731 if layer < 2 => 0,
ModelChoice::DeepSeekV4Pro if layer < 2 => 128,
ModelChoice::DeepSeekV4Flash
| ModelChoice::DeepSeekV4Flash0731
| ModelChoice::DeepSeekV4Pro
ModelChoice::DeepSeekV4Flash0731 | ModelChoice::DeepSeekV4Pro
if layer.is_multiple_of(2) =>
{
4
}
ModelChoice::DeepSeekV4Flash
| ModelChoice::DeepSeekV4Flash0731
| ModelChoice::DeepSeekV4Pro => 128,
ModelChoice::DeepSeekV4Flash0731 | ModelChoice::DeepSeekV4Pro => 128,
ModelChoice::Glm52 => 0,
}
}
@@ -1054,8 +940,7 @@ mod tests {
#[test]
fn installed_ds4_fixture_opens_and_renders_a_prompt() {
let path = crate::model::engine_artifacts(
ModelChoice::DeepSeekV4Flash,
false,
ModelChoice::DeepSeekV4Flash0731,
false,
&crate::app::models_path(),
)
@@ -1063,9 +948,9 @@ mod tests {
if !path.exists() {
return;
}
let model = Model::open_main(&path, ModelChoice::DeepSeekV4Flash).unwrap();
let model = Model::open_main(&path, ModelChoice::DeepSeekV4Flash0731).unwrap();
let summary = model.summary();
assert_eq!(summary.model, ModelChoice::DeepSeekV4Flash);
assert_eq!(summary.model, ModelChoice::DeepSeekV4Flash0731);
assert_eq!(summary.vocabulary_size, 129_280);
assert_eq!(
model.tokenize("Hello, world! 1234\nint café = 7;\n中文テスト"),
@@ -1262,33 +1147,14 @@ mod tests {
#[test]
fn installed_dspark_fixture_passes_the_target_layout() {
let path = crate::model::engine_artifacts(
ModelChoice::DeepSeekV4Flash,
false,
ModelChoice::DeepSeekV4Flash0731,
true,
&crate::app::models_path(),
)
.mtp
.support
.unwrap();
if path.exists() {
validate_model_artifact(&path, ModelChoice::DeepSeekV4Flash, true).unwrap();
}
}
#[test]
fn installed_legacy_mtp_fixture_passes_the_target_layout() {
let path = crate::model::engine_artifacts(
ModelChoice::DeepSeekV4Flash,
true,
false,
&crate::app::models_path(),
)
.mtp
.unwrap();
if path.exists() {
assert_eq!(
validate_support(&Gguf::open(&path).unwrap(), &FLASH).unwrap(),
SupportKind::LegacyMtp
);
validate_model_artifact(&path, ModelChoice::DeepSeekV4Flash0731, true).unwrap();
}
}
}