mistralrs_core/vision_models/qwen2_5_vl/
config.rs

1// https://github.com/huggingface/transformers/blob/f2c388e3f946862f657acc1e21b272ec946fc66c/src/transformers/models/qwen2_vl/configuration_qwen2_vl.py
2
3use mistralrs_quant::QuantizedConfig;
4
5use crate::layers::Activation;
6
7use crate::serde_default_fn;
8
9serde_default_fn!(Activation, default_vision_hidden_act, Activation::QuickGelu);
10serde_default_fn!(usize, default_in_channels, 3);
11
12#[derive(Debug, Clone, serde::Deserialize)]
13pub struct VisionConfig {
14    pub depth: usize,
15    pub hidden_size: usize,
16    pub out_hidden_size: usize,
17    #[serde(default = "default_vision_hidden_act")]
18    pub hidden_act: Activation,
19    pub intermediate_size: usize,
20    pub num_heads: usize,
21    #[serde(default = "default_in_channels")]
22    pub in_chans: usize,
23    pub patch_size: usize,
24    pub spatial_merge_size: usize,
25    pub temporal_patch_size: usize,
26    pub window_size: usize,
27    pub fullatt_block_indexes: Vec<usize>,
28}
29
30#[derive(Debug, Clone, serde::Deserialize)]
31pub struct MRopeScaling {
32    pub mrope_section: Vec<usize>,
33}
34
35#[derive(Debug, Clone, serde::Deserialize)]
36pub struct Config {
37    pub vocab_size: usize,
38    pub hidden_size: usize,
39    pub intermediate_size: usize,
40    pub num_hidden_layers: usize,
41    pub num_attention_heads: usize,
42    pub num_key_value_heads: usize,
43    pub hidden_act: Activation,
44    pub max_position_embeddings: usize,
45    pub rms_norm_eps: f64,
46    pub tie_word_embeddings: bool,
47    pub rope_theta: f64,
48    pub use_sliding_window: bool,
49    pub sliding_window: Option<usize>,
50    pub vision_config: VisionConfig,
51    pub rope_scaling: MRopeScaling,
52    pub quantization_config: Option<QuantizedConfig>,
53    pub image_token_id: u32,
54    pub video_token_id: u32,
55    // pub vision_start_token_id: usize,
56    // pub max_window_layers: usize,
57}