-
Notifications
You must be signed in to change notification settings - Fork 973
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
Add Support for BitNet Architecture Inference #2664
base: main
Are you sure you want to change the base?
Add Support for BitNet Architecture Inference #2664
Conversation
Signed-off-by: José Carlos García <[email protected]>
Signed-off-by: José Carlos García <[email protected]>
Signed-off-by: José Carlos García <[email protected]>
The bit-linear tests that you added seem to be broken, would you mind having a look? |
Signed-off-by: José Carlos García <[email protected]>
Done! @LaurentMazare |
Thanks, could you also provide details on how the model results were lined up with the python implementation? Did you ensure that the logits generated by the candle version are somewhat in line? |
@LaurentMazare Everything stems from: The Era of 1-bit LLMs - Training Tips, Code, FAQ Since the inference for Llama and Linear was already implemented in this project, I used the existing Llama implementation as a foundation and applied the following changes, based on the paper and as seen here:
In principle, unless I’m mistaken, everything seems consistent with the Python implementation. You can test it in situ as follows: cargo run --example llama-bitnet --features metal Thank you so much for reviewing! |
In order to check the consistency, the best would be to generate the logits for the same prompt on the candle and python side and check that they are reasonably close. That's what we do for most models before adding them, would you mind giving it a try? |
Since this is my first contribution, I don't have much experience with this, but it seems that the logits from the Python implementation and my implementation are similar: I used the code from this link in Python, and in the code I created, I added a print of the logits (in Candle) and a print of the Here’s what I observed: Candle: Python: They seem equivalent, except for numerical error. |
Introduction
Hello! My name is José Carlos, and I hold a degree in Mathematics. Alongside other talented individuals, I co-founded a company where we focus on AI and infrastructure solutions.
I’ve always believed that BitNet is one of the most significant breakthroughs of the past year. I have a personal obsession with this architecture, as it embodies the potential to balance performance and efficiency in language models—a pursuit that deeply motivates me.
Changes Made
Added Support for BitNet Architecture Inference:
New Example Added:
Supported HF Models:
The following models were tested successfully:
"1bitLLM/bitnet_b1_58-large"
: BitNet B1 58 Large."1bitLLM/bitnet_b1_58-3B"
: BitNet B1 58 3B.Future support will be added for:
"HF1BitLLM/Llama3-8B-1.58-100B-tokens"
: Llama 3 (8B, 1.58).Known Limitations
I plan to address these in future updates and prepare a PR with:
Roadmap
Thank you for considering this PR! Feedback is welcome, and I’m excited to continue contributing to this amazing project. 😊