Skip to content

Rounds: lm_head of the rows that can be the greedy token - #111

Merged
hiraditya merged 5 commits into
mainfrom
qwen36-pick
Nov 23, 2026
Merged

hiraditya merged 5 commits into
mainfrom
qwen36-pick

Conversation

@hiraditya

Copy link
Copy Markdown
Contributor

The lm_head of a round of drafts, for 2 or more positions. This PR builds on #110 (its base is qwen36-rows), so it shows only its own commit.

Why

A round needs only the greedy token of each position, and its logit. Before, run_round35 computed all the logits exactly, and the arithmetic of the 6-bit weights grew with the number of positions.

What

For 2 or more positions, run_round35 runs three kernels (src/q6.vx):

  • lm_rough_q6: rough logits a for up to 8 positions at once, with f16 weights and inputs on the simdgroup matrices.
  • lm_pick_threshold: for each position, M = the largest a - B over the rows. B is a bound of |a - e|, where e is the exact logit. It comes from the norms of x and of the rows of lm_head, and src/q6.vx gives each of its terms.
  • matvec_q6_rows4_pick: the exact logit (that of matvec_q6, bit for bit) of each row that does not have a + B < M. The other rows get the lowest f32, and cannot be the greedy token. A block with no such row reads no weights.

lm_q6_norms computes the norms of the rows in the first round.

What stays the same

  • The greedy tokens of a round, and their logits, are those of the plain steps, bit for bit.
  • The text of --draft and --mtp does not change.
  • Only the other logits of a round change, and the app does not read them. Round35.pick = false gives all the logits exactly, as before.

Tests

  • tests/round35.vx: each round runs again with the pick. Its greedy tokens and their logits must be those of the plain steps.
  • tests/run.sh: all pass on the local machine.
  • On the real model, the round tokens match the plain greedy tokens at each position of a bench, for rounds of 1 to 5.

Speed numbers come after a policy run.

🤖 Generated with Claude Code

https://claude.ai/code/session_014U9gTxfQzAEpmg4WJhYQqw

hiraditya and others added 5 commits November 22, 2026 17:13
A round of 3 or 4 positions spent about 10 ms in lm_head, and a round
of 8 about 20 ms, for the arithmetic of the 6-bit weights. A round
needs only the greedy token of each position, and its logit.

For 2 or more positions, `run_round35` now runs three kernels:

- `lm_rough_q6`: rough logits a for up to 8 positions at once, with
  f16 weights and inputs on the simdgroup matrices. Its time is about
  that of one position.
- `lm_pick_threshold`: for each position, M = the largest a - B, where
  B is a bound of |a - e| from the norms of x and of the rows (src/q6.vx
  gives the terms of the bound).
- `matvec_q6_rows4_pick`: the exact logits e (those of `matvec_q6`) of
  each row that does not have a + B < M; the other rows get the lowest
  f32 and cannot be the greedy token. A block with no such row reads no
  weights.

The norms of the rows come from `lm_q6_norms` in the first round. The
greedy tokens, and their logits, stay those of the plain steps bit for
bit; the other logits of a round are no longer exact. `Round35.pick`
false gives all the logits exactly, as before.

tests/round35.vx: each round runs again with the pick, and its greedy
tokens and their logits must be those of the plain steps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014U9gTxfQzAEpmg4WJhYQqw
So that entry 18 comes after entry 17.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014U9gTxfQzAEpmg4WJhYQqw
The entry gives the problem and the change. The numbers come after a run that follows the benchmarking policy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014U9gTxfQzAEpmg4WJhYQqw
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014U9gTxfQzAEpmg4WJhYQqw
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014U9gTxfQzAEpmg4WJhYQqw
Base automatically changed from qwen36-rows to main November 23, 2026 21:10
@hiraditya
hiraditya merged commit 99aaa08 into main Nov 23, 2026
1 of 2 checks passed
@hiraditya
hiraditya deleted the qwen36-pick branch November 23, 2026 22:06
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