Skip to content

Drafter: public DFlash-4B on GH200, acceptance by position, fine-tuning tools - #22

Merged
SamMausberg merged 8 commits into
mainfrom
drafter/block-drafter
Sep 30, 2026
Merged

SamMausberg merged 8 commits into
mainfrom
drafter/block-drafter

Conversation

@SamMausberg

Copy link
Copy Markdown
Owner

Moonshot M3 (drafter): serve the public DFlash drafter for Qwen3.5-4B on this GH200, measure where it is limited, and fine-tune it only against measured limitations. Work in progress; this PR will grow as results land, and the description will be updated.

What is here so far

  • experiments/drafter/: a launcher that records every server's command and resolved settings (serve_run.py), a greedy acceptance probe that turns SGLang's per-request histograms into acceptance by block position (accept_probe.py, summarize_acceptance.py), a trace analysis, an output-equality comparison, the panel shared with the repair workstream, a training-prompt builder disjoint from every bench split, a target-response generator, and a SpecForge-based fine-tuner for DFlash and DFlash 2 (warm start from the public checkpoint) with an optional auxiliary loss on the drift ratio rho.
  • engine/sglang/patches/drafter-0001-dflash-cycle-trace.patch: an opt-in per-cycle trace of DFlash verification (off unless SGLANG_DFLASH_TRACE_PATH is set). Timed runs use the stock engine.
  • evidence/drafter/: acceptance by block position for z-lab/Qwen3.5-4B-DFlash@9a1996c at blocks 16 and 8 on the panel (correctness runs, no timings).

First measurements

Block 16, concurrency 1, greedy, thinking on, natural stop at up to 2,048 tokens: 6.18 tokens per verify cycle overall; chat 3.98, code 7.63, GSM8K 6.72, MATH-500 7.55. Conditional acceptance is 0.86 at position 1 and 0.80 at position 2, rising to about 0.90 by position 12. Block 8: 5.04. --cuda-graph-backend-prefill tc_piecewise from the model card crashes prefill graph capture for this target at the pin and is dropped.

Still to come

Card-reproduction gate on MT-Bench, output equality against plain decoding, MTP on the same panel, the fine-tuned arms (data-only and DFlash 2 selector), and end-to-end speed against tuned MTP and the public drafter through the bench harness.

Installed outside the repository

fla-core==0.5.2 and flash-linear-attention==0.5.2 into ~/vp-data/drafter/pylib (pip --target, not the venv), SpecForge at 3cb0510 cloned to ~/vp-data/drafter/src/; both only on PYTHONPATH for training.

serve_run.py starts one SGLang server per arm (plain, MTP, public DFlash-4B)
and records the launch; accept_probe.py measures acceptance by block position
from SGLang's per-request histograms; build_panel.py fixes the panel shared
with the repair workstream; build_train_prompts.py and gen_targets.py build
target-generated training data disjoint from every bench split;
train_dflash.py fine-tunes a DFlash or DFlash 2 drafter with SpecForge's
objective in resumable segments.
transformers 5.12 returns a BatchEncoding (not a dict) from
apply_chat_template(tokenize=True), so the probe and generator sent the key
names instead of token ids and the prompt-length filter never fired. Probe
requests now carry the row id as SGLang rid so the DFlash trace can name them.
Adds run_equality.sh (plain-decoding reference and comparison).
First served run of the public z-lab drafter on this GH200 (blocks 16 and 8,
concurrency 1, greedy thinking): tokens per verify cycle 6.18 and 5.04, with chat
at 3.98 against 6.7-7.6 for code and maths, and alpha_2 below alpha_1 in every
domain. Adds the trace analysis (thinking versus answer text, offset buckets,
first-rejection classes), rho_pairs.py for teacher-forced head-input pairs, the
card-reproduction gate, and the shared-slot job scripts.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 30, 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-09-30T20:20:06.790234Z c592fe9 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c592fe9b22

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

def main() -> None:
parser = argparse.ArgumentParser(description=__doc__.split('\n\n')[0])
parser.add_argument('--per-domain', type=int, default=6000)
parser.add_argument('--exclude', type=Path, nargs='+', default=[])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve every repeated exclusion group

The documented command supplies --exclude twice, but an argparse option with nargs='+' and no accumulating action retains only the final occurrence. Consequently the bench warmup/tune/confirm paths expanded for the first occurrence are discarded and only panel-v1.jsonl is excluded, so generated training data can overlap evaluation splits and invalidate downstream fine-tuning measurements. Use an accumulating action such as extend, or document a single --exclude followed by all paths.

Useful? React with 👍 / 👎.

Comment on lines +56 to +58
if index is None:
compared += n
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Treat unequal output lengths as divergence

When two greedy outputs share all tokens up to the shorter length but one stops while the other continues, index remains None and this branch records the sequence as equal. This understates sequences_diverged and the divergence rate precisely for termination differences, which are part of output equality; after comparing the shared prefix, unequal lengths need to be recorded as a divergence at the end-of-sequence boundary.

Useful? React with 👍 / 👎.

support_screen.py recomputes the drafter's top-K candidates at every traced
verify cycle and reports the support bound U_K (the longest prefix of the
realized greedy continuation inside the candidate sets), an upper bound on any
selector over frozen candidates, next to the engine's accepted length.
train_selector.py trains a DFlash 2 candidate selector on the frozen public
backbone with the exact expected-accepted-length objective or the matched
position-weighted cross-entropy and D-PACE controls, and exports a
DFlash2DraftModel checkpoint.
@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

Reviewed at e7700a5, whole diff (this is a work-in-progress PR; I reviewed what is committed).

What I checked

  • Hooks. A merge with current main is clean, and pre-commit passes on the changed files (ruff, mypy, shellcheck). There are no private files and nothing over 1 MB.
  • Trace patch. drafter-0001-dflash-cycle-trace.patch applies with git apply --check to bd66ce343e. It is inert unless SGLANG_DFLASH_TRACE_PATH is set, and the README says that traced runs synchronize every cycle and give no timings.
  • sm_90 substitutions are disclosed. FlashInfer replaces the card's TRT-LLM/FA4 backends for target and draft attention, and the card's tc_piecewise prefill graph is dropped because it crashes capture at the pin. The launch records in evidence/drafter/launch/*.json give the exact commands.
  • Training claims. None are made yet; the fine-tuners are tools only.
  • Numbers. The acceptance numbers match acceptance_summary.csv (tau 6.18 at block 16 and 5.04 at block 8 overall), and the correctness-run label is stated.

Blocking

1. The built training set contains bench evaluation prompts.

  • The problem. build_train_prompts.py excludes only ~/vp-wt/bench/.../mixed-v1/*.jsonl and the panel. The bench merged mixed-v2, whose maths prompts are GSM8K train, and GSM8K train is one of your maths sources.
  • The measurement. I compared the built set ~/vp-data/drafter/data/prompts-v1.jsonl (18,000 prompts) with bench/workloads/mixed-v2/ by normalized text and id. It contains 172 of the 384 GSM8K prompts in confirm.jsonl, 72 of tune's and 20 of warmup's.
  • Consequence. A drafter fine-tuned on it would be tuned and confirmed partly on its own training prompts.
  • Fix.
    • Exclude bench/workloads/mixed-v2/*.jsonl, using the repository path now that bench is on main, together with the panel. Rebuild the set.
    • Record the excluded files and their hashes in the prompts manifest.
    • If any run already used prompts-v1, say so and keep it out of bench confirm numbers.

2. Accept length is pooled, not per turn as the card computes it.

  • The problem. accept_probe.summarize computes tau as Σ completion tokens / Σ verify cycles per domain, which weights long requests more. The card's "mean accept length" is per turn: completion tokens over verify count for each request, then averaged.
  • Fix. Report the per-turn mean, using the spec_accept_length or completion_tokens / spec_verify_ct already recorded per request. Keep the pooled ratio as a second, labelled column. The card-reproduction gate must use the card's definition.

3. The panel is built from a workload that is no longer on main, and it overlaps the quality set.

  • The problem. build_panel.py and panel-v1.jsonl take their chat, code and maths prompts from bench/workloads/mixed-v1/confirm.jsonl, which main has replaced (it remains in history at 8b4b7ab). Its 16 maths prompts are GSM8K test problems, which are in the GSM8K quality set.
  • Why it matters. This is harmless for acceptance measurements. But the README describes the panel as "the first 16 ... of the bench confirm split", which is now false, and the panel should never be used for quality.
  • Fix. Name mixed-v1 at 8b4b7ab as the source, and state that the panel is for acceptance only. Alternatively, rebuild it from mixed-v2.

Suggestions (non-blocking)

  • The panel caps outputs at 2,048 tokens, and the card uses 4,096 and other workloads. Say so next to any comparison with the card's accept lengths.

The prompt builder now excludes both bench workload versions (mixed-v2 draws
its maths prompts from GSM8K train, one of our sources), both panels, the
MT-Bench gate prompts, GSM8K test and MATH-500, and fails the build unless
no training prompt matches any of them by id or by the hash of its normalised
text; the counts (all zero) are committed with the data manifest. Adds
panel-v2 from mixed-v2's confirm split as the evaluation panel, reports the
card's per-request accept length next to pooled tau, documents the panel's
provenance (acceptance only, never quality), and serializes server start-up
with other jobs.
@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE

Re-reviewed at 867e77f. All three blocking items are resolved.

  1. Training data. The rebuilt prompts-v2 has zero overlap with every evaluation set.
    • I checked ~/vp-data/drafter/data/prompts-v2.jsonl (18,000 prompts) independently by normalized text and id: 0 matches with mixed-v2 confirm, tune and warmup, and with panel-v1 and panel-v2.
    • The committed evidence/drafter/data/prompts-v2.manifest.json records each excluded file with its SHA-256 and zero hash or id matches. The excluded files are mixed-v2 and mixed-v1, both panels, the MT-Bench gate prompts, GSM8K test and MATH-500.
    • The builder now fails unless the sets are disjoint.
    • The README records that prompts-v1 overlapped mixed-v2 and fed only a 64-row code smoke test.
  2. Accept length. acceptance_summary.csv now has tau_mean_per_request (the card's per-turn definition) and tau_pooled as labelled columns (6.98 against 6.18 at block 16 overall). The README says the per-position table is pooled by construction.
  3. Panel. Its provenance is stated (mixed-v1 confirm at 8b4b7ab, maths = GSM8K test), and it is marked "acceptance only, never quality". Trained drafters are to be evaluated on panel-v2 from mixed-v2.

The branch merges into main without conflicts, and hooks pass on the changed files (ruff, mypy, shellcheck).

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