Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metal GGML Q40 support #1643

Merged
merged 15 commits into from
Feb 14, 2025
Merged

Metal GGML Q40 support #1643

merged 15 commits into from
Feb 14, 2025

Conversation

LouisChourakiSonos
Copy link
Collaborator

@LouisChourakiSonos LouisChourakiSonos commented Feb 14, 2025

No description provided.

&& matches!(facts[0].datum_type, DatumType::F16 | DatumType::F32))
|| ((facts[1].datum_type == DatumType::F32) && (facts[0].datum_type == DatumType::F32))
|| ((facts[1].datum_type == DatumType::F16)
&& matches!(facts[0].datum_type, DatumType::F32 | DatumType::F16))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, this is very hard to parse :) maybe we could split the tricky q40 case apart then do somethings like

use DatumType::*;
match (facts[0].datum_type, facts[1].datum_type) {
  (F32, F32) => true,
  (F16, F16) => true,
  (F16, F32) => true,
  _ => false
}

a_dt: DatumType,
b_dt: DatumType,
) -> TractResult<TVec<TypedFact>> {
let out_dt = self.matmul.output_dt(a_dt, b_dt)?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about something that respect the symmetry more ?

ensure!([DatumType::F16, DatumType::F32].contains(out_dt));
Ok(tvec!(out_dt.fact(shape))

};

let mut rng = rand::thread_rng();
let lhs_data: Vec<F> = (0..b * m * k) // Create a vector with 10 elements
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i suspect we have a lying comment here.


let mut rng = rand::thread_rng();
let lhs_data: Vec<F> = (0..b * m * k) // Create a vector with 10 elements
.map(|_| F::from(rng.gen_range(0.0..1.0)).unwrap()) // Generate a random float in [0.0, 1.0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm... this is not good. we should not rand() ourselves, but let the proptest strategies do it in predictable and simplifiable manner. The idea is to use proptest::collections::vec() or something like that.

@LouisChourakiSonos LouisChourakiSonos merged commit dc2b30b into metal_ggml_matmul Feb 14, 2025
67 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants