Skip to content

Moonshot P4: primary metric at exactly 128 running requests (follow-up to #94) - #96

Merged
SamMausberg merged 3 commits into
mainfrom
moonshot/p4-primary-window
Oct 1, 2026
Merged

SamMausberg merged 3 commits into
mainfrom
moonshot/p4-primary-window

Conversation

@SamMausberg

Copy link
Copy Markdown
Owner

Follow-up to #94, made before P4b runs: the declared primary metric did not measure what it
claimed. Codex found this on #95 (app_stack.tex:191). Bench's logged_gen_tps_full_batch
averages decode windows with at least 0.9 x the peak running count, so 116-128 of 128, which is
not a full-batch rate.

Change

  • validate_p4_ab.py computes the primary metric itself, as the server's decode rate at exactly
    128 running requests in the measured phase.
    • The scheduler logs one gen throughput per 40 decode passes. A window counts when it shows
      #running-req: 128 and both it and the previous decode line fall inside the AIPerf
      profiling phase (first request start to last request end, from profile_export_raw). This
      excludes the AIPerf warm-up wave and the ramp and drain.
    • Windows carry equal token counts (128 per pass, no speculation), so the rate is the
      harmonic mean of the window rates.
    • Fewer than 8 such windows in any arm fails the run.
    • The window count and bench's rate (now a diagnostic) are recorded per arm.
  • README 2c records the amendment and its time, before the run. The supported-result wording
    becomes "served decode throughput at 128 running requests". The derived 1.08x reads "per
    decode step" (lines 196 and 340).
  • The run script's header comment matches.

The statistic, the 1.10x decision rule, the probe and all validity checks are unchanged.

Testing

  • tests/test_validate_p4_ab.py: synthetic logs where windows outside the phase run at a third
    of the rate, and the primary metric ignores them. A run with 127 running in the phase fails.
    26 tests pass, including tests/test_output_probe.py.
  • pre-commit run passes on the changed files.

…hase

Bench's logged_gen_tps_full_batch averages windows with >= 0.9 x the peak running count
(116-128 of 128), so it is not a full-batch rate. validate_p4_ab.py now computes the
primary metric itself: the harmonic mean of the server's decode-log window rates with
#running-req exactly 128, counting a window only when it and the previous decode line fall
inside the AIPerf profiling phase (from profile_export_raw), so the warm-up wave and the
ramp and drain are excluded. Fewer than 8 such windows in any arm fails the run; the
window count and bench's rate are recorded. README 2c records the amendment (before the run)
and reads 'per decode step' for the derived 1.08x. Tests: 26 passed.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 1, 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-01T10:04:37.751010Z e67feb1 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.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

Reviewed head 17c71f4, committed 08:18:52 UTC, on main 65a0a23. P4b has not started: p4b.log is empty (mtime 08:19:11).

What checks out

  • The amendment is recorded honestly. README 2c says the first version used bench's ≥ 0.9 × peak windows, and that the change was made at 08:19, before the run.
  • The window rule matches the engine's log lines.
    • The regex matches the scheduler's real lines. I tested it on today's confirm/dflash-tuned-b4 log: 197 windows, 8 of them at 128.
    • The AIPerf request_start_ns and request_end_ns fields are epoch nanoseconds, and the server log timestamps are UTC on this box, so the phase comparison is valid.
    • Bench's directory layout (r0/c128/aiperf/profile_export_raw.jsonl.gz) matches.
  • The rest of the PR is right. The harmonic mean is the token-weighted rate for equal-token windows. Fewer than 8 windows voids the run. Bench's rate is kept as a diagnostic. README lines 196 and 340 now say "per decode step".
  • Checks. The tests pass (26), pre-commit passes, and the job's checkout is at 17c71f4 with a clean tree.

Blocking

B1. A window that ends at 128 running can still include a prefill. A decode line's gen throughput covers the time since the previous decode line. The first decode line after a prefill burst shows #running-req: 128, but its rate includes the prefill time. The same dflash-tuned-b4 log shows this at 07:12:11: lines 78–113 are prefill batches totalling 128 new sequences, then line 209 reports a decode window at 128 running with 1,249.7 tok/s, against about 10,000 in steady state.

P4b will hit this at least once per wave, after the 2,048-token prefills of each batch of 128. The harmonic mean is very sensitive to such a low value: 20 windows at 10,000 and one at 1,250 give 7,500, a 25% bias. The bias need not be the same in both arms, so it could move the 1.10 decision.

Count a window only if:

  • the previous decode line also shows 128 running; and
  • no Prefill batch line appears between the two.

In other words, count only pure decode at full batch. Record how many windows were excluded, and add a test with a post-prefill low window that must be excluded.

This has to land before the run starts, so the declaration stays ahead of the data.

…no prefill between

The first decode line after a prefill burst can show 128 running while its window contains
the prefill time (1,250 against ~10k tok/s in a bench log), and the harmonic mean is
sensitive to it. A window now counts only when the previous decode line also showed 128
and no Prefill batch line lies between them; excluded windows at 128 are counted and
recorded. On bench's tune-plain and tune-plain-noradix c=128 logs this keeps 46 windows,
excludes 3, and gives 14,466 and 14,720 tok/s against bench's 14,478 and 14,749. README 2c
updated; a test with a post-prefill low window added (27 passed with the probe tests).

@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: 17c71f4004

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

meta = json.loads(line).get('metadata') or {}
if meta.get('benchmark_phase') == 'profiling':
starts.append(int(meta['request_start_ns']))
ends.append(int(meta['request_end_ns']))

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 Derive the phase end from emitted AIPerf fields

With the pinned AIPerf artifact schema, raw-record metadata contains request_start_ns but not request_end_ns (the existing harness parser obtains completion duration from request_latency in profile_export.jsonl). Consequently every real run_p4b.sh result raises KeyError here and the required validation step cannot produce a verdict; compute each end from the metrics export's start plus request latency, or from the raw response timing, instead of requiring this synthetic field.

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.

This does not apply to the installed AIPerf (0.13.0, the version bench records in sweep.json as aiperf_version). Its raw export carries both fields in the record metadata. In today's bench run, ~/vp-data/bench/confirm/dflash-tuned-b4/20261001-071103/r0/c128/aiperf/profile_export_raw.jsonl.gz, all 1,152 records (128 warmup, 1,024 profiling) have metadata.request_start_ns and metadata.request_end_ns. My earlier moonshot exports (sweeps_host, 02:15 UTC) do too, for example 'request_start_ns': 1790820990395817604, 'request_ack_ns': ..., 'request_end_ns': 1790820991511442320. If a future AIPerf dropped the field, the validator would stop with a KeyError and exit non-zero, so the run would be reported FAILED, not mis-measured. No change made.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Fixed in 462fcdb (README time corrected in e67feb1), before the run started. I cancelled the waiting job and requeued it at its original priority arrival on e67feb1.

  • A window now counts only when the previous decode line also showed 128 running and no Prefill batch line lies between the two. Otherwise a post-prefill window at 128 running, like your 1,249.7 tok/s example, would carry prefill time.
  • Excluded windows at 128 are counted and recorded per arm (*_windows_excluded).
  • Test added: a prefill burst followed by a 128-running window at an eighth of the rate. It is excluded and the rate is unchanged (27 passed with the probe tests).
  • On bench's real c=128 logs (tune-plain, tune-plain-noradix: 512 requests, 4 waves) the rule keeps 46 windows and excludes 3. It gives 14,466 and 14,720 tok/s, against bench's 14,478 and 14,749.
  • README 2c records both amendments (08:19 and 08:22 UTC) as made before the run.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional until Codex runs on e67feb1; I'll re-check before merge)

Re-reviewed e67feb1 (462fcdb and e67feb1, committed 08:21:43 and 08:21:57 UTC). P4b has not started: p4b.log is empty (mtime 08:21:59).

  • B1 is fixed. A window at 128 now counts only if the previous decode line was also at 128 and no Prefill batch line lies between them. Windows excluded at 128 are counted and recorded. I ran exact_batch_rate on today's real confirm/dflash-tuned-b4 log: 2 windows kept and 5 excluded, and the post-prefill 1,249.7 tok/s window at 07:12:11 is among the excluded. On the plain c = 128 logs, the agent reports 46 windows kept and 3 excluded, with a rate within 0.2% of bench's.
  • The README records both amendments. 2c names 08:19 and 08:22 UTC, before the run, and states the rule.
  • Codex's P1 on 17c71f4 does not hold for this AIPerf. It says raw-record metadata lacks request_end_ns. The raw export from today's bench run (profile_export_raw.jsonl.gz, AIPerf as installed) has both request_start_ns and request_end_ns in its metadata, as epoch nanoseconds. profiling_span therefore works on real artifacts, so I'm not counting it as blocking. Please reply on the thread with this evidence.
  • Checks.
    • tests/test_validate_p4_ab.py and tests/test_output_probe.py pass (27), and pre-commit passes.
    • The commits are Sam's, with no AI attribution.
    • The job's checkout is at e67feb1 with a clean tree.

@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: e67feb188b

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

@SamMausberg

Copy link
Copy Markdown
Owner Author

Codex finished on e67feb1 with no comments, so my provisional approval at e67feb1 (#96 (comment)) now stands without conditions. P4b's run used exactly this head (p4b.log: repo at e67feb1, clean).

@SamMausberg
SamMausberg merged commit 55a45eb into main Oct 1, 2026
SamMausberg added a commit that referenced this pull request Oct 1, 2026
Review B1 / Codex P1 on #95. The primary metric is now worded as
declared in the moonshot README after #96: the server's decode rate at
exactly 128 running requests in the measured phase. A window counts
only at 128 with the previous decode line also at 128, no prefill in
between, and inside the AIPerf profiling phase. The rate is the harmonic
mean of the window rates, fewer than 8 windows void the run, and the
amendment preceded the run. A supported result is a served decode
throughput at 128 running requests. No result is stated.
@SamMausberg
SamMausberg deleted the moonshot/p4-primary-window branch October 1, 2026 14:35
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