Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions catgrad-llm/examples/siglip/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,10 +575,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {

let interp = Interpreter::new(backend, env, parameters);

let results = interp.eval(
interp.environment.to_core(typed_term.term),
vec![input_tensor, image_tensor],
)?;
let results = interp.run(typed_term.term, vec![input_tensor, image_tensor])?;
let result_tensor = match &results[1] {
interpreter::Value::Tensor(t) => t,
_ => panic!("Expected tensor output"),
Expand Down
1 change: 1 addition & 0 deletions catgrad-llm/src/models/gemma3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub enum GemmaConfig {
VLM {
text_config: GemmaTextConfig,
image_token_index: usize,
#[serde(default)]
mm_tokens_per_image: usize,
},
#[serde(untagged)]
Expand Down
10 changes: 8 additions & 2 deletions catgrad-llm/src/models/llama.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use catgrad::prelude::ops::*;
use catgrad::prelude::*;
use nn::*;
pub struct LlamaModel {
pub root: String,
pub config: Config,
pub max_sequence_length: usize,
}
Expand Down Expand Up @@ -65,8 +66,8 @@ impl LlamaModel {

let sh = shape!(builder, b, s, num_kv_heads, head_dim);
let k = reshape(builder, sh.clone(), k);

let v = reshape(builder, sh, v);

let sh = shape!(builder, b, s, num_heads, head_dim);
let q = reshape(builder, sh, q);

Expand Down Expand Up @@ -157,7 +158,12 @@ impl Module<1, 1> for LlamaModel {
}

fn def(&self, builder: &Builder, [x]: [Var; 1]) -> [Var; 1] {
let root = self.path();
let mut root = self.path();
if !self.root.is_empty() {
root = root
.extend(self.root.split('.').collect::<Vec<&str>>())
.unwrap();
}

let mut cache = Cache::init(builder, &self.config, self.max_sequence_length);

Expand Down
1 change: 1 addition & 0 deletions catgrad-llm/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ pub fn get_model(
))
}
"MistralForCausalLM" | "LlamaForCausalLM" => Box::new(llama::LlamaModel {
root: "".to_string(),
config: config.clone(),
max_sequence_length,
}),
Expand Down