Skip to content

Flash-Next MTP: draft from part of the vocabulary - #269

Merged
bong-water-water-bong merged 3 commits into
mainfrom
1bit/flash-next-draft-vocab
Oct 1, 2026
Merged

bong-water-water-bong merged 3 commits into
mainfrom
1bit/flash-next-draft-vocab

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Qwen3.8-Flash-Next's MTP head computes logits over all 248,320 tokens for every drafted token, which means reading the model's 644 MiB Q8_0 output matrix three times per decode step. The draft only proposes and the model checks every token, so the head can be cut down to the tokens it is likely to propose. Only the acceptance rate can change.

Idea and id list: dime-online/qwen3.8-Flash-DGX-UltraFast (vLLM on a DGX Spark, Apache-2.0); credited in NOTICE.

Changes

  • tools/mtp_draft_vocab.py writes a reduced head. It takes Unsloth's shared MTP head plus the target's output rows for the listed ids, and adds:
    • blk.<L>.nextn.shared_head_head (K rows)
    • d2t (I64)
    • onebit.draft_vocab
  • config/draft-vocab/qwen38-en-code-65536.txt is dime-online's 65,536-id English + code list.
    • Unchanged apart from comment lines; NOTICE carries their notice text.
    • Exempt from our header in tools/copyright.py, because it is their work.
  • third_party/llama.cpp-vulkan cecf3ee -> fd16437: fork #56, the qwen4exp MTP graph for such heads.
  • tests/mtp_draft_vocab_test.py, in CI: on a made-up target and head, checks the head rows, d2t, and every other tensor and key. Bad inputs are refused.
  • Docs: docs/serve.md (usage, numbers, caveats); docs/vulkan.md (the carried commit).

Measured

Strix Halo, fork llama-server (Vulkan). UD-Q4_K_XL, greedy, draft length 3. Decode tok/s, median of rounds 2-3 of 3.

Prompt Full head 65,536-id head
code, 256 tokens 47.8 52.1
prose, 256 tokens 38.6 42.2
code, 768 tokens 45.8 48.3
French, 26 tokens 46.4 39.6
  • Acceptance is unchanged on English and code (code 186/207 both). A step takes about 6 ms less (76 -> 70 ms).
  • French loses because its tokens are outside the list.
  • Output text: with a draft, output is not token-identical to decoding without one, even with the full head. Batched verification flips near-ties. The cut head gives the full head's text in rounds 2-3.
  • Not done: wiring into 1bit serve. It passes --mtp through, but Flash-Next also needs -lm mmap, which serve does not set yet; measured with llama-server directly.

🤖 Generated with Claude Code

…cab.py)

Qwen3.8-Flash-Next's MTP head computes logits over all 248,320 tokens per drafted token, which
is the model's 644 MiB Q8_0 output matrix read three times per decode step. The draft only
proposes and the model checks every token, so the head can be cut to the tokens it is likely to
propose.

- tools/mtp_draft_vocab.py writes such a head from Unsloth's shared MTP head and the target's
  output rows: blk.<L>.nextn.shared_head_head (K rows) + d2t (I64) + onebit.draft_vocab.
- config/draft-vocab/qwen38-en-code-65536.txt is dime-online's 65,536-id English + code list
  (qwen3.8-Flash-DGX-UltraFast, Apache-2.0), credited in NOTICE with its own notice text;
  exempt from our header in tools/copyright.py, since it is their work.
- third_party/llama.cpp-vulkan cecf3ee -> fd16437 (fork #56): the qwen4exp MTP graph runs the
  K-row head and scatters its logits back to the full vocabulary.
- tests/mtp_draft_vocab_test.py (CI): rows, d2t and every other tensor and key checked on a
  made-up target and head; bad inputs refused.
- docs/serve.md: usage and numbers; docs/vulkan.md: the carried commit.

Strix Halo, Vulkan, UD-Q4_K_XL, greedy, draft length 3, rounds 2-3 of 3: code 47.8 -> 52.1
tok/s, prose 38.6 -> 42.2, 768-token code 45.8 -> 48.3, the same acceptance; French 46.4 ->
39.6 (its tokens are outside the list).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@context7

context7 Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Docs7 for 1bit-monster/engine

Result Status Action
Deployment ➖ Not used —
Content review ➖ Did not run. This site has no agent runs available this month. Wait for the monthly reset or check your Docs7 plan. —

Commit c4e4581

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit c4e4581)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

56 - Partially compliant

Compliant requirements:

  • The PR introduces the os/mini/mkimage.sh script for creating the bootable image
  • Includes necessary kernel modules and firmware as specified
  • Contains BusyBox, Mesa RADV, XRT + XDNA plugin
  • Outputs 1bit-os.efi and 1bit-os.img as described
  • Includes os/mini/init script for mounting and loading drivers
  • The image is tested to boot in QEMU and pass 1bit.check

Non-compliant requirements:

  • Not yet tested on actual Strix Halo hardware

Requires further human verification:

  • Verification of booting on actual Strix Halo hardware
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Incorrect tensor data writing

The tensor data for blk.<L>.nextn.shared_head_head.weight and d2t is written using write_tensor_data without ensuring the data is properly aligned or formatted for the GGUF format. This could lead to incorrect tensor data being written to the output file, especially if the data types or shapes are not handled correctly.

w.write_tensor_data(head)
w.write_tensor_data(ids)
Potential memory issue with large vocabularies

The script loads the entire output.weight tensor into memory at once (rows = np.asarray(out_t.data).reshape(n_vocab, -1)). For very large vocabularies, this could lead to memory issues, especially if the system has limited RAM. This is a potential concern for systems with constrained resources.

rows = np.asarray(out_t.data).reshape(n_vocab, -1)

⚠️ Review coverage: The following files were not included in this review because of the token budget:

  • config/draft-vocab/qwen38-en-code-65536.txt

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Re the PR-Agent notes on rows = np.asarray(out_t.data).reshape(n_vocab, -1): GGUFReader tensor data is a numpy memmap view of the file, and GGUF stores each tensor contiguously, so the reshape is a view: nothing is read or copied until rows[ids] copies the K selected rows (170 MiB for Flash-Next, not 644). tests/mtp_draft_vocab_test.py reads the written head back and checks it byte for byte against the source rows. No change. (Ticket #56 in the guide is this repo's 1bit OS issue, unrelated; the PR refers to llama.cpp fork #56.)

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit c4e4581

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Blocking (PR-Agent duty): llama.cpp #56 merged without the d2t value check the review asked for. qwen4exp_draft_vocab_rows validates d2t's type, rank and length, but not its values. A draft GGUF with a d2t id < 0 or >= n_vocab makes ggml_set_rows write outside the full-vocabulary logits row, and duplicate ids silently drop rows. d2t is K int64s, so it can be checked once after tensor data is loaded (0 <= id < n_vocab, no duplicates) and the load failed with a clear error.

Please land that check in the fork, in our qwen4exp-draft-vocab.cpp, and move this pin to it before merging. Everything else here looks fine: the reduced head only applies when the draft GGUF carries it. Also note the non-English cost (French 46.4 -> 39.6 tok/s) in the docs, and the provenance and license of the 65,536-id list before any reduced-head GGUF is published.

@bong-water-water-bong
bong-water-water-bong merged commit a188926 into main Oct 1, 2026
10 of 11 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/flash-next-draft-vocab branch October 1, 2026 20:02
bong-water-water-bong added a commit that referenced this pull request Oct 1, 2026
…bad d2t ids (llama.cpp #57) (#272)

#269 pinned llama.cpp #56 (Flash-Next MTP drafting from part of the
vocabulary) before its d2t ids were validated: set_rows scatters the draft
logits to those ids, so an id outside the vocabulary or a repeated one could
write outside the logits row. #57 reads the ids at load and refuses the file.
Registry: pin line only (--check-pins ok).

Co-authored-by: bong-water-water-bong <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
bong-water-water-bong added a commit that referenced this pull request Nov 10, 2026
…fixes engine #1417) (#1759)

Moves third_party/llama.cpp 60ae4c9358 -> 831629fe9a. Two commits matter for #1417 and both
are the ones this issue asked for:

  58cadcf  hrx: the LIVE pool check takes the host term too (engine #1502)     <- fork #259
  831629f  hrx: print the two storages and the view's layout for a refused alias node

With #259 the live check answers min(GTT free, MemAvailable) - the same two-term model the
open-time budget has had since #256 - so the issue's reported shape is the case it now
refuses: a 15.35 GiB request, a GTT counter showing room, ~15 GiB of host memory left. Before
this, the live check used the GTT figure alone, which is exactly the over-promise #256 removed
at open time.

What #1417 has now, across the three bumps:
  #254 + 8f124f9   the live check is ON by default, margin 256 MiB, pool_live_fits pure,
                   and a typo can no longer switch the guardrail off  (bumped in #1736)
  #256 + #269      the pool budget is min(GTT term, host term), and the host-weight arena is
                   charged to the pool before it grows
  #259             the live check reads the same two terms

Verified: registry regenerated at the new pin (only the sources sha moves; counts stay
298/9/298/298), registry_build.py --check-pins passes, check_pins.py says
'60ae4c935 -> 831629fe9 is ahead'.

Not claimed by this bump, stated so a merged pin is not over-read: the allocator-side case
(an allocation that fails although the live figures say it fits) is #1502's slab-provider
class, and the fork's own review of #259 left one line open - a raw 0 from
host_memory_available_bytes() is mapped to kHostUnknown by both callers, so a genuinely
exhausted host reads as 'unreadable' and the term is dropped. That is the extreme case, and
it is written in the #259 thread rather than fixed here.

Co-authored-by: pi-hrx-sched <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant