Skip to content

Drafter: ring tile sweep pre-registration (declared threshold rule, rotated tile order, failed runs to sweep.failed.json; #167 README rounding) - #185

Merged
SamMausberg merged 3 commits into
mainfrom
drafter/ring-tile-sweep-prereg
Oct 2, 2026
Merged

SamMausberg merged 3 commits into
mainfrom
drafter/ring-tile-sweep-prereg

Conversation

@SamMausberg

@SamMausberg SamMausberg commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

The reviewer's optional items on #180, made before the sweep runs (its exclusive ticket is still queued). This commit is the pre-registration: it declares how the batch threshold N* will be read, so a restricted version of patch 0005 cannot be tuned on noise.

Declared reading (evidence/drafter/README.md, "Ring-writing verify tiles by batch: declared reading"; applied by the script as declared_threshold, written to threshold in sweep.json):

  1. Tile 4 wins at (T, N) when it is faster than tile 32 in every repeat and the gap between their medians exceeds the larger of the two tiles' repeat ranges.
  2. N*_T is the largest grid batch at which tile 4 wins and also wins at every smaller batch; it is 0 if tile 4 loses at N = 1.
  3. N* = min(N*_16, N*_8), because the launch-config selection sees the batch, not the block length. The rule applies only on the declared grid (blocks 16 and 8, batches 1, 2, 3, 4, 5, 6, 8, 12, 16, 24, 32, 48, 64); any other grid gets n_star null with the reason.
  4. A restricted 0005 would use tile 4 for N ≤ N* and tile 32 above. Tiles 8 and 16 are reported but not used, because they have not been through the served exactness checks.
  5. If N* = 0, no restricted patch is built. If N* ≥ 8, the kernel timing contradicts Drafter: narrow value tiles for the fold's ring-writing verify (patch 0005): exact; removes the c <= 4 loss but costs the c = 8 gain (record of the trade-off) #167's served A/B, and no restricted patch is built until the difference is explained.
  6. No served-throughput claim follows from the sweep. Any restricted patch still needs the parity check and a served session, which wait for main's go.

Sweep changes (gdn_ring_tile_sweep.py, run_ring_tile_sweep.sh):

  • Order: the bitwise gate now runs for all tiles before any timing (tile 32 first). The timing order within each point rotates with the repeat, and there are now four repeats by default (about 13 minutes instead of 10), so every tile takes every position once. The stock reference alternates between the first and the last slot. Drift within a point, from clock or temperature, therefore no longer folds into the tile comparison.
  • Failed runs: a sweep whose bitwise gate fails writes sweep.failed.json instead of sweep.json and still exits non-zero. The hold script refuses to run over either file.
  • Rounding fix: the Drafter: narrow value tiles for the fold's ring-writing verify (patch 0005): exact; removes the c <= 4 loss but costs the c = 8 gain (record of the trade-off) #167 README table's two double-rounded cells (reviewer's nit) are now rounded once from check.json: block 16, c = 1, stock/fold y 870/887 (was 871/888); block 16, c = 2, ratio 1.011 (was 1.012). A note under the table says where the values come from.

Run. The hold's worktree ~/vp-wt/drafter-run3 is re-pinned to the PR head (d9d2e02) while the ticket is still queued; the hold has not started. Engine: engine/drafter 9292abd874.

Testing.

  • pre-commit on the changed files.
  • tests/test_drafter_tools.py in the repository venv (the new test skips there without torch) and in the SGLang venv. The new test covers the threshold rule: a win must hold in every repeat and exceed the spread, and the threshold must be a prefix of wins and the minimum over the blocks.
  • --help in the SGLang venv.
  • The sweep itself has not run on the GPU yet.

Review comments.

  • Codex (bb96359), P2, declared_threshold read tile 4 unconditionally, so --tiles 8 16 32 (accepted by the parser) would lose a finished sweep to a KeyError before any report was written. The reviewer raised the same item. Fixed in a3413f9: the parser requires tiles 4 and 32. The commit job checked that the subset is refused; tests pass (21 in the SGLang venv).
  • Codex (a3413f9), P2, an incomplete grid (--blocks 16, or batches without 1) still produced n_star. The reviewer raised the same item. Fixed in d9d2e02: the threshold is computed only on the declared grid, and other grids get n_star null with the reason (threshold_for_grid, with a test). Tests: 19 passed + 3 skipped in the repo venv, 22 passed in the SGLang venv.
  • Codex (d9d2e02), P2, the declared grid with a different repeat count (e.g. --repeats 1) would still produce n_star. The reviewer asked to close every such variant. This does not change this sweep's data or decision: the hold calls the script with no overrides, so it runs the declared configuration (four repeats, 24 layers, 50 iterations, all four tiles). Per the integrator's policy it is folded into the results PR, which will (a) check that sweep.json records exactly the declared configuration before reading N*, and (b) compute the threshold only when every declared parameter matches, writing n_star null listing the differences, with the full configuration in the README section.

… declared_threshold in sweep.json), tile order rotated across four repeats with the stock reference alternating ends, a failed bitwise gate writes sweep.failed.json; #167 README cells rounded once from check.json
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 2, 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-02T04:40:06.812746Z d9d2e02 Manual request
ℹ️ 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: bb96359317

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

by_bv = {
r['BV']: r for r in rows if r['T'] == T and r['N'] == n and r['path'] == 'ring'
}
narrow, wide = by_bv[4], by_bv[32]

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 Require tile 4 before computing the threshold

When the documented CLI is invoked with an otherwise accepted subset such as --tiles 8 16 32, the parser permits it because validation only requires tile 32, but this unconditional lookup raises KeyError: 4 after the entire GPU sweep has completed. As a result, neither the normal nor failed report is written; either require tile 4 during argument validation or omit threshold calculation when it was not measured.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Valid; fixed in a3413f9: the parser now requires tiles 4 and 32 (the declared threshold compares them), so a subset such as --tiles 8 16 32 is refused at startup, before any GPU work, instead of losing the finished sweep to a KeyError. The commit job checked that --tiles 8 16 32 exits non-zero; the default run (4, 8, 16, 32) was never affected. The hold's worktree is re-pinned to a3413f9 while its ticket is still queued.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES at bb96359

One blocking item, and it is Codex's. Everything else is right; details below.

Blocking

  1. experiments/drafter/gdn_ring_tile_sweep.py:101 (Codex 4162744621, unanswered). declared_threshold looks up by_bv[4] unconditionally, but the parser only requires tile 32. A run with --tiles 8 16 32 therefore finishes the whole GPU sweep and then raises KeyError before the report is written, losing the data. Fix: make the parser require 4 as well (the declared reading needs it), or skip threshold with a note when 4 is absent. Then reply on the thread. The declared hold uses the default tiles, so this does not change the pre-registered run.

Checked at bb96359

  • Tile order. The tiles sort to [32, 16, 8, 4], and the timing order rotates by repeat % 4. With the new default of 4 repeats, each tile takes each position once, and the stock reference alternates between first and last. The bitwise gate now runs for every tile at repeat 0 before that point is timed.
  • Declared reading. declared_threshold implements the README's section "Ring-writing verify tiles by batch: declared reading" exactly:
  • Failed gate. A failed bitwise gate writes sweep.failed.json and exits non-zero, and the hold refuses to run over either file.
  • Pre-registration is genuine. ~/vp-data/drafter/ring-tile-sweep/ does not exist yet, ticket 5-1790911906346759734-x-78383 is still queued, and the hold worktree ~/vp-wt/drafter-run3 is clean at bb96359.
  • Drafter: narrow value tiles for the fold's ring-writing verify (patch 0005): exact; removes the c <= 4 loss but costs the c = 8 gain (record of the trade-off) #167 cells. Block 16, c = 1 now reads 870/887 and c = 2 reads 1.011, rounded once from check.json's unrounded means, with a note explaining why.

…e declared threshold compares them (Codex on #185)
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@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: a3413f96b1

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

'fastest_tile': min(by_bv, key=lambda bv: by_bv[bv]),
'bv4_over_bv32': by_bv[4] / by_bv[32] if 4 in by_bv else None,
}
threshold = declared_threshold(rows, args.blocks, sorted(args.batches))

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 Reject incomplete grids before computing the threshold

Accepted invocations such as --blocks 16 or --batches 2 4 8 still produce threshold.n_star, even though the declared rule requires the minimum of N*_16 and N*_8 and explicitly makes the N=1 result determine whether the threshold is zero. The former invocation silently omits N*_8, while the latter treats N=2 as the start of the winning prefix, so either can report a cutoff unsupported by the pre-registered measurements. Require both declared blocks and batch 1, or withhold the declared threshold when they are absent.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Valid; fixed in d9d2e02. The declared threshold is now computed only on the declared grid (blocks 16 and 8, batches 1, 2, 3, 4, 5, 6, 8, 12, 16, 24, 32, 48 and 64; threshold_for_grid). Any other grid, such as --blocks 16 or batches without 1, gets threshold: {n_star: null, reason: ...}, so a smoke run on a subset still writes its report but no cutoff. The README's declared-reading section lists the exact grid and says so, and a new test covers both incomplete grids. The hold's worktree is re-pinned to d9d2e02 while its ticket is still queued.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES at a3413f9

My blocking item from bb96359 is fixed: the parser now requires tiles 4 and 32, so a grid without them is refused before any GPU work, and the Codex thread has a reply. The hold worktree is re-pinned to a3413f9, and no sweep output exists yet.

Blocking

  1. Codex 4162785329 (gdn_ring_tile_sweep.py:309), new on this head and unanswered. With an accepted but non-declared grid (--blocks 16, or --batches without 1), threshold.n_star is still reported. In the first case N*_8 is silently missing from the minimum; in the second the winning prefix starts at N = 2, so N* = 0 cannot occur. Either cutoff would carry the "declared" label without the declared measurements. Fix: compute threshold only when the grid contains blocks 16 and 8 and batch 1, as the README's rule needs, and otherwise write threshold: null with the reason (or refuse such grids at parsing, as for the tiles). Then reply on the thread. The declared hold uses the default grid, so this does not change the pre-registered run.

Everything else from my bb96359 review stands: the rotation, the rule against the README and its test, sweep.failed.json and the #167 cells.

…ocks 16 and 8, batches 1-64 as listed); other grids get n_star null with the reason (Codex on #185)
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@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: d9d2e02009

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

'fastest_tile': min(by_bv, key=lambda bv: by_bv[bv]),
'bv4_over_bv32': by_bv[4] / by_bv[32] if 4 in by_bv else None,
}
threshold = threshold_for_grid(rows, args.blocks, args.batches)

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 Withhold the threshold when repeat count is not four

When the declared blocks and batches are used with an accepted override such as --repeats 1, this call still emits a declared n_star. With one repeat, each range is zero and “faster in every repeat” reduces to a single timing comparison; with other counts, the rotation may also be unbalanced. This no longer follows the pre-registered four-repeat protocol and can turn noise into the cutoff used for the restricted patch, so threshold eligibility should require four repeats (or such runs should get n_star: null).

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Valid in general, but it does not change this sweep's data or decision, so per the integrator's policy it is folded into the results PR instead of moving the queued hold again. The hold (run_ring_tile_sweep.sh) calls the script with no overrides, so it runs the declared configuration: blocks 16 and 8, the declared batches, tiles 4/8/16/32, four repeats, 24 layers, 50 iterations. sweep.json records repeats, iters and shape.layers, and the rows record blocks, batches and tiles, so the results PR will check that the run used exactly that configuration before reading N*. The results PR will also extend threshold_for_grid to every declared parameter: blocks, batches, tiles 4 and 32, repeats = 4, layers = 24, iters = 50, with n_star: null listing the parameters that differ. The README's declared-reading section will then list the full configuration.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES at d9d2e02

The grid fix for Codex 4162785329 is correct and answered. threshold_for_grid computes N* only when the blocks and the sorted batches equal the declared grid, and otherwise writes n_star: null with the reason. The README lists the grid, and the new test covers --blocks 16 and batches without 1. The hold worktree is re-pinned to d9d2e02, and no sweep output exists.

Blocking

  1. Codex 4162912791 (new on this head, unanswered): on the declared grid, --repeats 1 still yields a declared N*. With one repeat the ranges are 0, so the rule's "faster in every repeat and the gap exceeds the larger range" reduces to "faster once", and that is not the declared reading, which specifies four repeats. To close the remaining variants in one step, gate threshold_for_grid on the whole declared configuration: blocks, batches, tiles including 4 and 32, --repeats 4, --layers 24 and --iters 50. Otherwise write n_star: null with the parameters that differ, and list them in the README's declared-reading section. Then reply on the thread. The declared hold uses the defaults, so the pre-registered run is unchanged; re-pin drafter-run3 if the ticket has not started.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE at d9d2e02

This supersedes my REQUEST CHANGES at this head (issuecomment-5945719868). Codex 4162912791 (a repeat count other than 4 still yields N*) has a scoped reply (4162918988), recorded in the PR body, and I verified the scope:

  • run_ring_tile_sweep.sh:25 calls the sweep with no overrides, so the queued hold runs exactly the declared configuration: the declared blocks and batches, tiles 4/8/16/32, 4 repeats, 24 layers and 50 iterations.
  • sweep.json records repeats, iters and shape.layers, and its rows record blocks, batches and tiles, so the configuration can be checked after the run.
  • The hold worktree drafter-run3 is clean at d9d2e02, the ticket is still queued, and no sweep output exists, so the pre-registration stands.

The deferral cannot change this sweep's data or decision. The results PR has committed to two things, and I will check both there:

  1. Before reading N*, check that sweep.json shows exactly the declared configuration.
  2. Extend threshold_for_grid to every declared parameter (blocks, batches, tiles 4 and 32, repeats 4, layers 24, iters 50), writing n_star: null that lists the differing parameters, and put the full configuration in the README's declared-reading section.

Everything else from my earlier reviews of #185 stands.

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