mistralrs_core/xlora_models/
config.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use std::collections::HashMap;

use either::Either;
use serde::Deserialize;

fn true_default() -> bool {
    true
}

fn false_default() -> bool {
    false
}
fn default_1() -> usize {
    1
}

fn default_2048() -> usize {
    1
}
fn default_dropout() -> f32 {
    0.2
}
fn default_1f64() -> f64 {
    1.0
}
fn default_0f64() -> f64 {
    0.0
}

#[derive(Clone, Debug, Deserialize)]
pub struct XLoraConfig {
    pub hidden_size: usize,
    pub base_model_id: String,
    #[serde(rename = "adapters")]
    #[serde(with = "either::serde_untagged")]
    pub _adapters: Either<Vec<String>, HashMap<String, String>>,
    #[serde(default = "false_default")]
    pub layerwise_scalings: bool,
    #[serde(default = "false_default")]
    pub enable_relu_and_dropout: bool,
    #[serde(default = "default_1")]
    pub xlora_depth: usize,
    #[serde(default = "default_2048")]
    pub xlora_size: usize,
    #[serde(default = "default_dropout")]
    pub xlora_dropout_p: f32,
    #[serde(default = "true_default")]
    pub enable_softmax: bool,
    #[serde(default = "default_1f64")]
    pub softmax_temperature: f64,
    #[serde(default = "default_0f64")]
    pub scaling_pass_value: f64,
    #[serde(default = "false_default", rename = "use_trainable_adapters")]
    pub _use_trainable_adapters: bool,
    #[serde(default = "true_default")]
    pub use_bias: bool,
    #[serde(default = "default_1f64")]
    pub global_scaling_weight: f64,
    pub top_k_lora: Option<usize>,
    #[serde(default = "false_default")]
    pub enable_softmax_topk: bool,
}