Support DeepSeek V4 Flash 0731
This commit is contained in:
@@ -30,6 +30,7 @@ pub(crate) struct SpeculativePreferences {
|
||||
pub(crate) dspark_enabled: bool,
|
||||
pub(crate) dspark_confidence_threshold: Option<f32>,
|
||||
pub(crate) dspark_strict: bool,
|
||||
pub(crate) dspark_exact_sampling: bool,
|
||||
}
|
||||
|
||||
impl Default for SpeculativePreferences {
|
||||
@@ -43,6 +44,7 @@ impl Default for SpeculativePreferences {
|
||||
dspark_enabled: false,
|
||||
dspark_confidence_threshold: None,
|
||||
dspark_strict: false,
|
||||
dspark_exact_sampling: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,13 +64,15 @@ 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_dspark() {
|
||||
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)
|
||||
if (self.dspark_confidence_threshold.is_some()
|
||||
|| self.dspark_strict
|
||||
|| self.dspark_exact_sampling)
|
||||
&& !self.dspark_enabled
|
||||
{
|
||||
return Err("DSpark tuning requires DSpark to be enabled.".into());
|
||||
@@ -86,9 +90,10 @@ impl SpeculativePreferences {
|
||||
glm_mtp: self.glm_mtp,
|
||||
glm_mtp_timing: self.glm_mtp_timing,
|
||||
dspark: self.dspark_enabled,
|
||||
dspark_confidence_threshold: self.dspark_confidence_threshold.unwrap_or(0.9),
|
||||
dspark_confidence_threshold: self.dspark_confidence_threshold.unwrap_or(0.6),
|
||||
dspark_confidence_threshold_set: self.dspark_confidence_threshold.is_some(),
|
||||
dspark_strict: self.dspark_strict,
|
||||
dspark_exact_sampling: self.dspark_exact_sampling,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,6 +108,7 @@ pub(crate) struct EngineSpeculativeSettings {
|
||||
pub(crate) dspark_confidence_threshold: f32,
|
||||
pub(crate) dspark_confidence_threshold_set: bool,
|
||||
pub(crate) dspark_strict: bool,
|
||||
pub(crate) dspark_exact_sampling: bool,
|
||||
}
|
||||
|
||||
/// An expert count, or a whole GiB budget. Written as `4` or `64GB`, the same
|
||||
@@ -785,7 +791,7 @@ mod tests {
|
||||
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.9);
|
||||
assert_eq!(engine.dspark_confidence_threshold, 0.6);
|
||||
assert!(!engine.dspark_confidence_threshold_set);
|
||||
|
||||
let tuned = SpeculativePreferences {
|
||||
@@ -793,6 +799,7 @@ mod tests {
|
||||
dspark_enabled: true,
|
||||
dspark_confidence_threshold: Some(0.7),
|
||||
dspark_strict: true,
|
||||
dspark_exact_sampling: true,
|
||||
..defaults
|
||||
};
|
||||
assert!(tuned.validate(ModelChoice::DeepSeekV4Flash).is_ok());
|
||||
@@ -812,6 +819,7 @@ mod tests {
|
||||
..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 {
|
||||
@@ -821,6 +829,14 @@ mod tests {
|
||||
.validate(ModelChoice::DeepSeekV4Flash)
|
||||
.is_err()
|
||||
);
|
||||
assert!(
|
||||
SpeculativePreferences {
|
||||
dspark_exact_sampling: true,
|
||||
..SpeculativePreferences::default()
|
||||
}
|
||||
.validate(ModelChoice::DeepSeekV4Flash0731)
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user