Skip to content

Fix transformers 5.14+ compatibility and remove dead import - #5

Open
bwilfley wants to merge 4 commits into
exo-explore:mainfrom
bwilfley:fix/transformers-compat-and-dead-import
Open

Fix transformers 5.14+ compatibility and remove dead import#5
bwilfley wants to merge 4 commits into
exo-explore:mainfrom
bwilfley:fix/transformers-compat-and-dead-import

Conversation

@bwilfley

Copy link
Copy Markdown

Summary

  • torch_bitnet.py: Changed _tied_weights_keys from a list to a dict ({"lm_head.weight": "model.embed_tokens.weight"}). Transformers 5.14+ requires this to be a mapping rather than just a list of key names, and raises a ValueError with the old format.
  • test_interop.py: Removed a dead import of weight_quant from training.bit_linear. The symbol was imported but never used in the test file, and the import itself fails in environments where the training module is not present.

Test plan

  • python convert.py completes without error
  • python test_interop.py passes all 17 tests (6 skipped as expected for long-running tests)

bwilfley and others added 4 commits July 22, 2026 16:44
- torch_bitnet.py: change _tied_weights_keys from a list to a dict
  mapping lm_head.weight to model.embed_tokens.weight, required by
  the updated API in transformers 5.14+
- test_interop.py: remove unused import of training.bit_linear which
  does not exist in the repo and caused an immediate ModuleNotFoundError

Closes exo-explore#2

Co-Authored-By: Claude <noreply@anthropic.com>
Removed the incorrect ("lm_head.", "lm_head.linear.") replacement pattern
from convert.py — it was a leftover from another model's converter and
caused load_causal_model to fail with "no parameter named linear".

Added run_mlx.py to run text generation with the converted MLX model,
with streaming output and correct SentencePiece token decoding.

Co-Authored-By: Claude <noreply@anthropic.com>
num_hidden_layers was missing from sanitize_config, so it always
defaulted to 24 — causing load_causal_model to fail for models with
a different layer count (e.g. the 3B model has 26 layers).

Co-Authored-By: Claude <noreply@anthropic.com>
Used tokenizer.decode(tokens) as the baseline for delta computation
instead of the raw prompt string — the two can differ at token
boundaries in SentencePiece, causing the last word of the prompt
to appear duplicated in the first generated token.

Co-Authored-By: Claude <noreply@anthropic.com>
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.

1 participant