pub struct ModelConfig {Show 38 fields
pub architecture: ModelArchitecture,
pub model_type: String,
pub version: u32,
pub hidden_size: usize,
pub num_hidden_layers: usize,
pub num_attention_heads: usize,
pub num_key_value_heads: usize,
pub head_dim: usize,
pub intermediate_size: usize,
pub vocab_size: usize,
pub max_position_embeddings: usize,
pub rope_theta: f32,
pub rope_scaling: Option<RopeScaling>,
pub sliding_window: Option<usize>,
pub rope_local_base_freq: Option<f32>,
pub rms_norm_eps: f32,
pub layer_norm_eps: Option<f32>,
pub hidden_activation: String,
pub use_qk_norm: bool,
pub scale_embeddings: bool,
pub query_pre_attn_scalar: Option<f32>,
pub dtype: String,
pub use_flash_attention: bool,
pub use_kv_cache: bool,
pub partial_rotary_factor: Option<f32>,
pub layer_types: Vec<String>,
pub linear_conv_kernel_dim: usize,
pub linear_key_head_dim: usize,
pub linear_value_head_dim: usize,
pub linear_num_key_heads: usize,
pub linear_num_value_heads: usize,
pub is_moe: bool,
pub num_experts: usize,
pub num_experts_per_tok: usize,
pub moe_intermediate_size: usize,
pub shared_expert_intermediate_size: usize,
pub has_vision: bool,
pub vision_out_hidden_size: usize,
}Expand description
Unified model configuration that combines all sources
Fields§
§architecture: ModelArchitecture§model_type: String§version: u32§num_attention_heads: usize§num_key_value_heads: usize§head_dim: usize§intermediate_size: usize§vocab_size: usize§max_position_embeddings: usize§rope_theta: f32§rope_scaling: Option<RopeScaling>§sliding_window: Option<usize>§rope_local_base_freq: Option<f32>§rms_norm_eps: f32§layer_norm_eps: Option<f32>§use_qk_norm: bool§scale_embeddings: bool§query_pre_attn_scalar: Option<f32>§dtype: String§use_flash_attention: bool§use_kv_cache: bool§partial_rotary_factor: Option<f32>§layer_types: Vec<String>§linear_conv_kernel_dim: usize§linear_key_head_dim: usize§linear_value_head_dim: usize§linear_num_key_heads: usize§linear_num_value_heads: usize§is_moe: bool§num_experts: usize§num_experts_per_tok: usize§moe_intermediate_size: usize§has_vision: boolImplementations§
Source§impl ModelConfig
impl ModelConfig
Sourcepub fn load(
model_path: &Path,
weights: &HashMap<String, Tensor>,
) -> Result<ModelConfig, Error>
pub fn load( model_path: &Path, weights: &HashMap<String, Tensor>, ) -> Result<ModelConfig, Error>
Load configuration, treating the model’s own config.json as authoritative.
No-fragile-fallbacks (#315): config.json is required by default. If it
is absent, loading is a hard error — a silently-guessed config can corrupt a
pipeline split (e.g. a wrong layer count). The legacy weight-name-scan
heuristic remains available only behind the explicit
HYPRSTREAM_ALLOW_WEIGHT_DETECT=1 opt-in.
When model.safetensors.index.json is present, num_hidden_layers is
cross-checked against the shard manifest’s weight_map; a mismatch is a
hard error rather than a silent corruption.
Sourcepub fn detect_architecture(model_path: &Path) -> ModelArchitecture
pub fn detect_architecture(model_path: &Path) -> ModelArchitecture
Detect the model architecture from a model directory’s config.json.
Returns ModelArchitecture::Unknown if the file is missing or unparseable.
This is a lightweight operation (reads only config.json, not weights).
Source§impl ModelConfig
impl ModelConfig
Sourcepub fn load_training_config(
model_path: &Path,
) -> Option<HyprstreamTrainingConfig>
pub fn load_training_config( model_path: &Path, ) -> Option<HyprstreamTrainingConfig>
Load hyprstream training config from the model’s config.json
Extracts the hyprstream_training section if present, otherwise returns None.
Sourcepub fn save_training_config(
model_path: &Path,
training_config: &HyprstreamTrainingConfig,
) -> Result<(), Error>
pub fn save_training_config( model_path: &Path, training_config: &HyprstreamTrainingConfig, ) -> Result<(), Error>
Save hyprstream training config to the model’s config.json
Preserves all other fields in config.json, only updates/inserts hyprstream_training.
Trait Implementations§
Source§impl Clone for ModelConfig
impl Clone for ModelConfig
Source§fn clone(&self) -> ModelConfig
fn clone(&self) -> ModelConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ModelConfig
impl Debug for ModelConfig
Source§impl Default for ModelConfig
impl Default for ModelConfig
Source§fn default() -> ModelConfig
fn default() -> ModelConfig
Source§impl<'de> Deserialize<'de> for ModelConfig
impl<'de> Deserialize<'de> for ModelConfig
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ModelConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ModelConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for ModelConfig
impl Serialize for ModelConfig
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for ModelConfig
impl RefUnwindSafe for ModelConfig
impl Send for ModelConfig
impl Sync for ModelConfig
impl Unpin for ModelConfig
impl UnsafeUnpin for ModelConfig
impl UnwindSafe for ModelConfig
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request