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

Implement I-quants (IQ4XS, IQ4NL) #2785

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

EricLBuehler
Copy link
Member

This PR refactors the quantization parts of candle-core a bit and integrates some new I-quants!

There is no CUDA or Metal support yet; perhaps we could add that in a later PR. I have added Metal support on a local branch, and I'm working on syncing the latest GGML CUDA kernels, which should also give a nice performance boost!

Copy link
Member

@ivarflakstad ivarflakstad left a comment

Choose a reason for hiding this comment

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

Reviewing in chunks. Around half way there.

Comment on lines +17 to +23
let expected_blocks = xs.len() / block_size;
let actual_blocks = ys.len();

// Validate that the input is the right size
if expected_blocks != actual_blocks {
crate::bail!("quantize {dtype:?}: expected {expected_blocks} blocks but only {actual_blocks} were provided!")
}
Copy link
Member

Choose a reason for hiding this comment

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

I am not opposed to doing this check every time, as that is safest, but this may be a decent case for debug_assert. What do you think @LaurentMazare?

assert_eq!(diff, 0.);
assert!(diff < 0.96);
Copy link
Member

Choose a reason for hiding this comment

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

The assert_eq version actually passes on my machine for both the neon and default impl. Is this increase in tolerance because of the avx impl perhaps?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, I think that was a remnant from when I did the other neon/default impls. I undid this change (I'm still working out a bug in the iq4xs avx impl, iq4nl works nicely).

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