fix: correct BitNetForCausalLM model registration and tokenizer type#442
Open
goodcomm74 wants to merge 1 commit intomicrosoft:mainfrom
Open
fix: correct BitNetForCausalLM model registration and tokenizer type#442goodcomm74 wants to merge 1 commit intomicrosoft:mainfrom
goodcomm74 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
…itNet-b1.58-2B-4T Two bugs prevent BitNet-b1.58-2B-4T from being converted on Apple Silicon: 1. Architecture name mismatch: Model was registered as "BitnetForCausalLM" (lowercase 'n') but the actual architecture in config.json is "BitNetForCausalLM" (capital 'N'). This caused: NotImplementedError: Architecture 'BitNetForCausalLM' not supported! 2. Wrong tokenizer type: BitNet-b1.58-2B-4T uses a GPT-2 style tokenizer (tokenizer.json) not SentencePiece (tokenizer.model). Using _set_vocab_sentencepiece() caused: FileNotFoundError: File not found: models/BitNet-b1.58-2B-4T/tokenizer.model Tested on Apple Silicon M4 Max (macOS 25.3) using mlx-lm as the inference backend after conversion. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two bugs in
utils/convert-hf-to-gguf-bitnet.pyprevent themicrosoft/BitNet-b1.58-2B-4Tmodel from being converted on Apple Silicon (and likely other platforms):Bug 1: Architecture name mismatch (capital 'N')
The
config.jsonofmicrosoft/BitNet-b1.58-2B-4Tdeclares:This mismatch caused:
Bug 2: Wrong tokenizer type
microsoft/BitNet-b1.58-2B-4Tuses a GPT-2 style tokenizer (tokenizer.json), not SentencePiece (tokenizer.model). This caused:Testing
Tested on Apple Silicon M4 Max (macOS 15.3, arm64).
After this fix, the model converts successfully and runs via mlx-lm:
Note:
tl1quantization still requires preset kernels forBitNet-b1.58-2B-4T(not included in this PR).i2_sconversion works after this fix.Related Issues