Implement DS4 model intake
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use crate::model::ModelChoice;
|
||||
use crate::model::{self, EngineArtifacts, ModelChoice};
|
||||
use std::fmt;
|
||||
use std::path::Path;
|
||||
|
||||
pub(crate) const REASONING_MODES: [ReasoningMode; 3] = [
|
||||
ReasoningMode::High,
|
||||
@@ -247,7 +248,7 @@ pub(crate) struct RuntimePreferences {
|
||||
}
|
||||
|
||||
impl RuntimePreferences {
|
||||
pub(crate) fn engine_settings(&self, model: ModelChoice) -> Result<EngineSettings, String> {
|
||||
pub(crate) fn validate(&self, model: ModelChoice) -> Result<(), String> {
|
||||
self.execution.validate(model)?;
|
||||
self.speculative.validate(model)?;
|
||||
self.ssd.validate(model)?;
|
||||
@@ -256,8 +257,20 @@ impl RuntimePreferences {
|
||||
if self.ssd.enabled && self.speculative.dspark_enabled {
|
||||
return Err("SSD streaming is not compatible with DSpark support.".into());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn engine_settings(
|
||||
&self,
|
||||
model: ModelChoice,
|
||||
context_tokens: i32,
|
||||
models_path: &Path,
|
||||
) -> Result<EngineSettings, String> {
|
||||
self.validate(model)?;
|
||||
Ok(EngineSettings {
|
||||
model,
|
||||
artifacts: model::engine_artifacts(model, self.speculative.dspark_enabled, models_path),
|
||||
context_tokens,
|
||||
execution: self.execution.engine_settings(),
|
||||
speculative: self.speculative.engine_settings(),
|
||||
ssd: self.ssd.engine_settings(),
|
||||
@@ -270,6 +283,8 @@ impl RuntimePreferences {
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub(crate) struct EngineSettings {
|
||||
pub(crate) model: ModelChoice,
|
||||
pub(crate) artifacts: EngineArtifacts,
|
||||
pub(crate) context_tokens: i32,
|
||||
pub(crate) execution: EngineExecutionSettings,
|
||||
pub(crate) speculative: EngineSpeculativeSettings,
|
||||
pub(crate) ssd: EngineSsdSettings,
|
||||
@@ -478,6 +493,25 @@ pub(crate) struct TurnSettings {
|
||||
pub(crate) reasoning_mode: ReasoningMode,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub(crate) struct EffectiveSettings {
|
||||
pub(crate) engine: EngineSettings,
|
||||
pub(crate) turn: TurnSettings,
|
||||
}
|
||||
|
||||
pub(crate) fn effective_settings(
|
||||
model: ModelChoice,
|
||||
generation: &GenerationPreferences,
|
||||
runtime: &RuntimePreferences,
|
||||
models_path: &Path,
|
||||
) -> Result<EffectiveSettings, String> {
|
||||
generation.validate()?;
|
||||
Ok(EffectiveSettings {
|
||||
engine: runtime.engine_settings(model, generation.context_tokens, models_path)?,
|
||||
turn: generation.turn_settings(model),
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -576,9 +610,16 @@ mod tests {
|
||||
},
|
||||
..RuntimePreferences::default()
|
||||
};
|
||||
let engine = runtime
|
||||
.engine_settings(ModelChoice::DeepSeekV4Flash)
|
||||
.unwrap();
|
||||
let effective = effective_settings(
|
||||
ModelChoice::DeepSeekV4Flash,
|
||||
&GenerationPreferences::default(),
|
||||
&runtime,
|
||||
Path::new("/models"),
|
||||
)
|
||||
.unwrap();
|
||||
let engine = effective.engine;
|
||||
assert_eq!(engine.context_tokens, 32_768);
|
||||
assert!(engine.artifacts.mtp.is_none());
|
||||
assert_eq!(engine.ssd.cache_bytes, 64 * GIB);
|
||||
assert!(engine.ssd.full_layers_set);
|
||||
assert_eq!(engine.ssd.full_layers, 0);
|
||||
@@ -592,11 +633,38 @@ mod tests {
|
||||
},
|
||||
..runtime
|
||||
};
|
||||
assert!(
|
||||
incompatible
|
||||
.engine_settings(ModelChoice::DeepSeekV4Flash)
|
||||
.is_err()
|
||||
assert!(incompatible.validate(ModelChoice::DeepSeekV4Flash).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn effective_settings_build_one_engine_and_turn_configuration() {
|
||||
let generation = GenerationPreferences {
|
||||
context_tokens: 65_536,
|
||||
temperature: Some(0.25),
|
||||
..GenerationPreferences::default()
|
||||
};
|
||||
let runtime = RuntimePreferences {
|
||||
speculative: SpeculativePreferences {
|
||||
dspark_enabled: true,
|
||||
..SpeculativePreferences::default()
|
||||
},
|
||||
..RuntimePreferences::default()
|
||||
};
|
||||
let effective = effective_settings(
|
||||
ModelChoice::DeepSeekV4Flash,
|
||||
&generation,
|
||||
&runtime,
|
||||
Path::new("/models"),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(effective.engine.context_tokens, 65_536);
|
||||
assert_eq!(
|
||||
effective.engine.artifacts.model.parent(),
|
||||
Some(Path::new("/models/deepseek-v4-flash"))
|
||||
);
|
||||
assert!(effective.engine.artifacts.mtp.is_some());
|
||||
assert_eq!(effective.turn.temperature, 0.25);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user