Repository navigation
Real-head replay, H2: drift ratio and transport on DFlash-4B and MTP-4B - #35
Conversation
…art-up - engine/sglang/patches/geometry/0001-head-capture-replay-dumps.patch, with a geometry section in engine/sglang/README.md (the new per-workstream layout). - run_capture.sh launches the server and waits until it is healthy under scripts/gpu_startup_lock.sh, so concurrent shared jobs no longer race in SGLang's free-memory probe; the cleanup trap waits for the server to exit. - The R-stock tables label which accumulation models are justified for the stock BF16 tensor-core GEMM.
DFlash-4B (z-lab/Qwen3.5-4B-DFlash @9a1996cc, block 16): the captured draft and target head inputs reproduce the engine's draft tokens at 98.2% and target argmax at 98.9% of 360,300 slots, every mismatch within one BF16 spacing, and accept lengths match on all 24,020 blocks. rho is 0.92 median (minimum 0.82 over 40,000 pairs), about 100 times the per-row int8 threshold. analyze_rho.py reports the minimum and caps its per-pair CSV.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…reach --heads restricts the evaluated low-precision heads (the plain-decode run showed the outlier, rotated and centred variants change little), and verify and draft sets report candidate counts separately for rows the verifier needs (all earlier drafts accepted) and rows after the first rejection.
…ifts The DFlash draft's head input has a fixed norm of 50.6 (unit-gain final norm) against about 159 for the target, and a median cosine of 0.41 with it, so rho stays near 0.9 at every block position, outcome, domain and context length.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 63c70f6cec
ℹ️ 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".
| rows_out = np.arange(len(keep)) | ||
| if len(rows_out) > args.csv_pairs: | ||
| rng_csv = np.random.default_rng(args.seed) | ||
| rows_out = np.sort(rng_csv.choice(rows_out, args.csv_pairs, replace=False)) |
There was a problem hiding this comment.
Restrict the plot sample to held-out prompts
The new sample is drawn from every entry in keep, which only excludes unknown prompt IDs and still contains both analysis and held-out prompts. The committed JSON confirms that only 19,858 of the 40,000 analyzed pairs are held out, so this plot CSV mixes the fitting split into an H2 result whose protocol requires held-out prompts (paper/sections/transport.tex:124). Because the CSV exports neither the split nor a prompt ID, downstream plotting cannot filter the analysis rows back out; select held-out indices before sampling or include enough metadata to filter them.
Useful? React with 👍 / 👎.
| CAPTURE_DIR="$out/heads" "$HOME/verified-progress/scripts/gpu_startup_lock.sh" \ | ||
| bash -c 'launch_and_wait "$@"' _ "$out/server.pid" "$port" "$out/server.log" \ | ||
| --model-path "${model[0]}" --revision "${model[1]}" "${common[@]}" "${args[@]}" || { |
There was a problem hiding this comment.
Recheck free memory after acquiring the startup lock
When two shared runs reach the free-memory check before either server allocates, both can pass NEED_FREE_MIB; the first then launches and consumes HBM, and the second acquires this lock and starts without rechecking. Its --mem-fraction-static probe can therefore see less than the amount required for weights and caches and fail, which is the concurrent-start race this change is meant to prevent. Perform a final wait/check inside the locked command immediately before spawning the server.
Useful? React with 👍 / 👎.
| for _ in $(seq 1 120); do | ||
| kill -0 "$server" 2>/dev/null || return 0 | ||
| sleep 1 | ||
| done |
There was a problem hiding this comment.
Force termination after the cleanup timeout
If SGLang is slow or hung during shutdown and remains alive for more than 120 seconds after SIGTERM, this loop simply exhausts and stop_server returns successfully. Since the launcher was deliberately orphaned when the lock shell exited, the script then leaves a server holding the GPU allocation and port, which can break or misdirect later captures. Escalate to killing the process tree after the timeout, or continue waiting rather than silently completing cleanup.
Useful? React with 👍 / 👎.
…nputs 4,000 held-out rows per set, int8, FP8 and int4 heads: on the verify rows a greedy verifier needs, int8 per-row needs 1.57 candidate rows on average (p99 8), as on plain decode; rows after the first rejection sit on wrong prefixes and need more. No envelope violations.
Every certified family (scalar, coordinate, grouped, low-rank) on every tiling (contiguous, random, k-means; 64-1,024 rows) skips at most 0.5% of the vocabulary for greedy verification, no better than the static screen; the partition interval spans about 138 nats, so the acceptance test is never decided. Oracle (realized) radii would skip 96% for one row but need 97% of the vocabulary over random batches of 16. Drift scaling shows rho must fall about 10x before half the rows are skipped.
…shutdown - run_capture.sh sources scripts/sglang_env.sh from its own checkout. - The free-memory check now runs inside the start-up lock, just before the launch; if memory is short the lock is released and the check retried. - The server runs in its own process group; shutdown escalates from SIGTERM to SIGKILL on the group and fails if the group survives. - analyze_rho.py reports held-out prompts only by default and writes prompt id and split into the per-pair CSV.
The rerun on 40,000 held-out pairs changes the rho quantiles by at most 0.003; the plot sample now carries prompt id and split.
|
Verdict: REQUEST CHANGES Reviewed head 2f1e17b (54 behind main). A trial merge into main is clean; The held-out discipline is now right everywhere, and the three Codex comments are addressed. The problems are in the "Decision so far" summary: three numbers are stated more strongly than the committed evidence supports, and "refuted" is not scoped. BlockingB1. "no certified bound family or tiling skips more than 0.5% of the vocabulary" is wrong (
B2. "sampled acceptance is never decided" overstates the evidence (README:26).
B3. "H2, transport: refuted on DFlash-4B" needs its scope (README:23).
B4. "the union over real verify batches needs 99.9% of the head" is slightly high (README:26).
Checked and correct
Drift scaling (not stated in the README yet; blocking when it is)
Suggestions (not blocking)
|
The decision summary now names the tested families, tilings, drafter and prompts; gives the largest certified skip as a mean (0.6%, p90 0.8%), the undecided probability of sampled acceptance as 0.92-0.96 on average, and the real-batch union as at least 99.5%; labels drift scaling as a model extrapolation with one statistic per claim; and adds a per-tiling transport table.
|
Verdict: APPROVE This re-review covers head 61ce255 and the DFlash-4B half. B1-B4 are fixed, and I checked every new number against
The held-out discipline and the Codex fixes verified in my first review are unchanged. This approval covers 61ce255. The MTP-4B commit needs its own review before merge. |
…nel contract The paper now argues in dependency order: setting and what the stock engine computes, the five contracts and the R-stock gap and interval theorems, the certified low-precision head with its measured candidate sets and fallback shares, sampled decisions, transport and its measured failure, exactness under speculation, the stack, drafting and repair hypotheses, the serving protocol, related work, and a discussion that merges the hypothesis and failure tables. Secondary derivations, untested mechanisms, engine notes, CPU evidence, reproduction and attribution move to appendices. Evidence paths, pull request numbers and pending work move to an evidence register and a development record (Appendix A); the text cites [En] for committed evidence and [pending Dn] for designed work, with the scientific status in the prose. Integrates merged evidence: H2 on DFlash-4B (#35) and MTP-4B (#47), the overlapped roofline (#44), the frontend diagnosis (#46), the fifth contract witness (#41) and the precision counts after #43. Folds in the Codex items on #21 (quantiles over all rows), #32 (pooled tau, GSM8K series) and #36. Typography: Charter text, a plain title block with the repository URL, greyscale-safe figures, a new mechanism figure (Figure 1) replacing three overlapping flowcharts, a drift figure and transport table, two-panel candidate and acceptance figures, and tables reorganized instead of shrunk.
H2 on real hidden states: the transport-versus-self-evidence comparison on aligned draft/target head inputs from the public DFlash drafter for Qwen3.5-4B, with the native MTP capture to follow. The PR also carries follow-ups to #16 (patch location, start-up lock, R-stock labels) and the Codex review fixes.
Results so far (committed; held-out prompts)
alignment_dflash4b.json): the capture (z-lab/Qwen3.5-4B-DFlash @9a1996cc, block 16, 320 prompts, 24,020 verify blocks) reproduces the engine's decisions from the captured head inputs.rho_dflash4b.*, 40,000 pairs): rho = ||h_t - h_d||_2 / ||h_t||_2 has median 0.92 and smallest value 0.82.stats_dflash4b.json).transport_dflash4b.*, 4,000 pairs):selfevidence_dflash4b.*): on the verify rows a greedy verifier needs, int8 per-row needs 1.57 candidate rows on average (p99 8) and int8 g128 needs 1.35. This matches plain decode.The evidence README (
evidence/head_geometry/README.md) gives the command and code commit for every file, a decision summary scoped to what was tested, and a per-tiling transport table.Review follow-ups
engine/sglang/patches/geometry/. The R-stock tables label which accumulation models are justified for the stock tensor-core GEMM. R-bf16 is no longer described as the stock computation.run_capture.shsourcesscripts/sglang_env.shfrom its own checkout.scripts/gpu_startup_lock.sh, immediately before the launch. If memory is short, the lock is released and the check retried.analyze_selfevidence.pycan evaluate a subset of heads, and splits verify rows into those the verifier needs and those after the first rejection.Still to come in this PR
Checks
pre-commitpasses on the changed files, andpytest tests/test_head_geometry_bounds.pypasses.