Skip to content

model : Beam applies its attention-gate and FFN scales; converter loads the tokenizer on transformers 4.x - #317

Open
danielhanchen wants to merge 1 commit into
base/upstream-0682a576afrom
fix/beam-scales
Open

danielhanchen wants to merge 1 commit into
base/upstream-0682a576afrom
fix/beam-scales

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Beam (Reflection) loads its scale tensors but the graph does not use them, so any Beam GGUF with non-unit scales produces wrong logits:

  • the attention gate multiplies by wqkv_gate without wqkv_gate_s;
  • the dense FFN and the expert FFN pass no up / gate / down scales to build_ffn / build_moe_ffn.

The original pin (#281) had the FFN scales; they were lost when Beam landed upstream, and the attention-gate scale was missing in both. Upstream master has the same code.

Conversion also fails with transformers 4.57.6 on the official Beam tokenizer metadata (Tokenizer class TokenizersBackend does not exist, then 'list' object has no attribute 'keys' for extra_special_tokens: []). The converter now loads the tokenizer as PreTrainedTokenizerFast with the list normalised.

CPU repro on a generated 2-layer Beam model (one dense layer, one 3-expert layer, F32), comparing scale 0.25 (experts [0.25, 0.5, 0.75]) against the same factors baked into the weights:

scale before: max logit change from the scale before: max error vs baked after: max error vs baked
attention gate 0 0.2516 0
dense FFN up / gate / down 0 0.269 / 0.332 / 0.269 0
expert FFN up / gate / down 0 0.279 / 0.290 / 0.279 1.3e-7 / 1.2e-7 / 2.4e-7
attention output (control, already applied) 0.3173 0 0

Unit-scale outputs are bit-identical before and after. --vocab-only conversion passes with transformers 4.57.6.

Pin PR on upstream b11806 (base/upstream-0682a576a); the pin-set change adds it.

@danielhanchen
danielhanchen requested a review from CISC as a code owner October 22, 2026 13:56
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T13:58:50.222883Z 837305b PR opened
🔒 Security Review ✅ Completed 2026-10-22T13:58:46.210873Z 837305b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch has not been deployed

No deployments
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