From d1ff767ccd00a5608503207db75f85130c850ce6 Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Thu, 12 Nov 2026 16:29:07 +0100 Subject: [PATCH] K7/K7a closed as parity (GDN role and mixer phases equal vanilla in the current profile); critical_path_report.py gets --mode VANL; ledger Co-Authored-By: Claude Sonnet 5.5 --- docs/experiments/step-ledger.md | 6 +++--- scripts/e2e/codex/speed/critical_path_report.py | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/experiments/step-ledger.md b/docs/experiments/step-ledger.md index 5b3c67ee..82695c88 100644 --- a/docs/experiments/step-ledger.md +++ b/docs/experiments/step-ledger.md @@ -79,7 +79,7 @@ Round-level totals first (they are the sum of the steps below). **Verdict of `decode-stage-group-ab-profile-set-pb-vs-pg-rerun` (2026-11-12, PB = profile set before the prelude, PG = the set with prelude, fused commit, combine vec4, D1, D2; 5 paired blocks PB/PG, 3 twin blocks PH = PG; A/A guard `ok` on all 13 arms: PB 6, PG 11, PH 11 keys; 27 requests per block after warm-up).** PG against PB: decode tok/s 182.67 -> 187.41 (+2.59 %, CI +1.91..+3.27), end-to-end 164.72 -> 168.20 (+2.11 %, CI +0.85..+3.38), tokens/round 3.61 -> 3.69 (+2.14 %, CI +0.07..+4.20), **ms/round 19.77 -> 19.68 (-0.09 ms, -0.45 %, CI -2.54..+1.65)**, VRAM share +0.14 % (CI -0.49..+0.77). The twin PH against PG (n=3, same conditions, same switches): decode +0.29 % (CI -1.62..+2.19), tokens/round +4.19 % (CI +1.09..+7.28), ms/round 19.04 against 19.78 (+0.74 ms, +3.89 %, CI +1.38..+6.39); PH against PB (n=3) ms/round -0.84 ms (-4.21 %). Reading: the A/A spread of ms/round between two identical arms (0.74 ms, even with a CI that excludes zero) is larger than the whole PB->PG delta and about the size of the 0.7 ms the CUPTI sections add up to, and the tokens/round spread of the twin (4.2 %) is about twice the tokens/round gain between PB and PG (2.1 %); the decode tok/s gain follows the acceptance, not the round time (the adaptive tier makes the runs not bitwise: byte-identical requests 14/150 PB/PG, 6/90 PH/PG). So the end-to-end A/B resolves neither the 0.7 ms nor a positive end-to-end effect of the section deltas: the point estimate of the round is -0.09 ms (13 % of the 0.7 ms), inside the noise. The section deltas are real device time (CUPTI), but the evidence that they sit on the round's critical path is NOT there; the stage stays closed by section delta plus identity as the owner rule says, with no end-to-end claim. Consequence for K7: do not write the GDN step kernel (+0.155 ms) on the strength of device deltas; it needs a critical-path measurement first (a window with the host side visible: does the round wait for the device at the point K7 shortens, `cupti_flag_waits.py` / `cupti_doorbell_latency.py`), or a paired A/B with enough pairs (n>=10) and the twin in every block. -**Critical path of the verify graph, first read (plan 6b, tool `scripts/e2e/codex/speed/critical_path_report.py`, evidence `/data/leleka-e2e/spd-gap/runs/critical-path-67k-existing-windows/`, 2026-11-12; existing 67k replay windows r29 of `verify-tail-head-chain-cupti-windows-rerun`, about 750 graphs each, no new GPU time).** Per graph of QP (twin QQ in brackets): round (graph start to the next graph start) 17.93 ms (18.25), graph 13.20 ms (13.53), between graphs 4.74 ms (4.72; host: draft, accept, answer); inside the graph the mixer phases (end of the FFN chain to the next doorbell: GDN step, attention, router) 5.75 ms (5.77) and the FFN phases (doorbell to the end of the combine) 6.85 ms (7.16); the host/tier wait inside the FFN phases (A, B, M waits above their floor) 3.81 ms (4.13), of which the first 16 layers 1.98 ms (2.14); only 31 % (32 %) of the layers are not host-bound (22 % (23 %) in layers 0-15), the first layers wait longest (layer 0: 100 % host-bound, M wait mean 104 us, B wait 156 us, M end 358 us after the doorbell). The twins agree within 0.3 ms, so the numbers are not noise. Reading: (1) a device saving in the FFN phase reaches the round in at most 31 % of the layers (the rest is absorbed by the wait); (2) a saving in the mixer phase (K7 GDN step +0.155 ms, K7a, the QSA prelude and attention) moves the doorbell earlier and the CPU leg starts at the doorbell, so it reaches the round in full by construction (5.75 ms of the 13.2 ms graph, 32 % of the round, are mixer phases); (3) the earlier statement that the section deltas 'do not reach the round' is NOT supported: the stage A/B (PB against PG, ms/round -0.09 ms, twin spread 0.74 ms) was too noisy to see 0.7 ms (3.5 % of the round), it did not show their absence; (4) the host leg is 4.74 ms between graphs plus 3.81 ms of waiting inside them (8.55 ms of 17.93, 48 %), which is what hex-finish's host/tier work shortens. The QT window (HEAD_CHAIN_BATCH on) shows round 15.48 ms and 47.5 % of layers not host-bound against 17.93 / 31 % for QP and QQ: different sessions have different tier states, so one window per arm cannot compare placement; this is the reason to take the candidate profile in the same way (3 windows, twin). Not claimed: any end-to-end gain; the reach is an upper bound without the cascade into the next layer. Next: 256k windows of the default and the candidate profile (needs a CUPTI watcher in the q245 Codex job). +**Critical path of the verify graph, first read (plan 6b, tool `scripts/e2e/codex/speed/critical_path_report.py`, evidence `/data/leleka-e2e/spd-gap/runs/critical-path-67k-existing-windows/`, 2026-11-12; existing 67k replay windows r29 of `verify-tail-head-chain-cupti-windows-rerun`, about 750 graphs each, no new GPU time).** Per graph of QP (twin QQ in brackets): round (graph start to the next graph start) 17.93 ms (18.25), graph 13.20 ms (13.53), between graphs 4.74 ms (4.72; host: draft, accept, answer); inside the graph the mixer phases (end of the FFN chain to the next doorbell: GDN step, attention, router) 5.75 ms (5.77) and the FFN phases (doorbell to the end of the combine) 6.85 ms (7.16); the host/tier wait inside the FFN phases (A, B, M waits above their floor) 3.81 ms (4.13), of which the first 16 layers 1.98 ms (2.14); only 31 % (32 %) of the layers are not host-bound (22 % (23 %) in layers 0-15), the first layers wait longest (layer 0: 100 % host-bound, M wait mean 104 us, B wait 156 us, M end 358 us after the doorbell). The twins agree within 0.3 ms, so the numbers are not noise. Reading: (1) a device saving in the FFN phase reaches the round in at most 31 % of the layers (the rest is absorbed by the wait); (2) a saving in the mixer phase (K7 GDN step +0.155 ms, K7a, the QSA prelude and attention) moves the doorbell earlier and the CPU leg starts at the doorbell, so it reaches the round in full by construction (5.75 ms of the 13.2 ms graph, 32 % of the round, are mixer phases); (3) the earlier statement that the section deltas 'do not reach the round' is NOT supported: the stage A/B (PB against PG, ms/round -0.09 ms, twin spread 0.74 ms) was too noisy to see 0.7 ms (3.5 % of the round), it did not show their absence; (4) the host leg is 4.74 ms between graphs plus 3.81 ms of waiting inside them (8.55 ms of 17.93, 48 %), which is what hex-finish's host/tier work shortens. The QT window (HEAD_CHAIN_BATCH on) shows round 15.48 ms and 47.5 % of layers not host-bound against 17.93 / 31 % for QP and QQ: different sessions have different tier states, so one window per arm cannot compare placement; this is the reason to take the candidate profile in the same way (3 windows, twin). Against the vanilla window of the same replay cell (`report-qp-vs-vanl.md`, separate session, so the tier state differs): round 16.23 ms against 17.93, graph 11.54 against 13.20, **between graphs 4.70 against 4.74 (equal)**, **mixer phases 5.89 against 5.75 (LEL is not behind)**, FFN phases 5.12 against 6.85 (+1.73 ms), host/tier wait inside the graph 0.80 against 3.81 ms, layers not host-bound 62 % against 31 %. So the whole gap to vanilla in this pair sits in the FFN phases and is the host/tier wait; the mixer phases (K7, K7a, prelude, attention) and the host leg between graphs are at parity, which is why K7 was dropped (see the K7 row). Not claimed: any end-to-end gain; the reach is an upper bound without the cascade into the next layer. Next: 256k windows of the default and the candidate profile (needs a CUPTI watcher in the q245 Codex job). Structure first, then the layer steps in graph order: embed (R7), mixer half (V3 and the kernels in it), FFN half (V2/V4 and the kernels in it), tail (R8). @@ -101,8 +101,8 @@ Structure first, then the layer steps in graph order: embed (R7), mixer half (V3 | K3 | block top-k cluster (17.3 us against 18.0 us) | 0.208 | 0.216 | -0.008 | CUPTI | device | proved-equal (LEL ahead) | | K4 | KV miss copy / copy kernel (11.1 us against 11.6 us) | 0.133 | 0.139 | -0.006 | CUPTI | device | proved-equal (LEL ahead) | | K5 | KV resolve (7.8 us against 8.4 us) | 0.094 | 0.100 | -0.006 | CUPTI | device | proved-equal (LEL ahead) | -| K7 | GDN role in total (step, conv, ab, commit) | 0.914 | 0.759 | +0.155 | CUPTI role table | device | open (switch `LELEKA_SM120_FUSED_GDN` built, identity PASS (P4, P5, P8: `verify-new-switches-identity`: top-16 rows 2057/2057 identical, draft trace 1036/1036 identical, argmax flips 0, A/A identical), OFF in the profiles. Section `verify-new-switches-cupti-windows` (2026-11-10, windows of request 29, 15 s, new binary `bin-verify-switches`, per-T within one variant: T 2..6 have 77-376 graphs; the control CL.2 and each variant ran in separate sessions, so the expert-tier (FFN) phase differs between them and is NOT compared): without side streams (CG.1 against CL.2) GDN kernel time per graph -78 / -74 / -82 / -70 / -60 us at T 2..6, launches 108 -> 36, mixer phase -1.6 / -1.3 / -1.6 / -1.3 / -0.8 us per layer (-0.04..-0.075 ms per graph). With the profile's SIDE_MIXER (CY.1) the a/b projection stays a separate `chain_gdn_ab_multi_kernel` on the side stream (10.1 us x 36) and the fused kernel is step+norm+conv only: 7.18 us against `verify_gdn_step_norm_multi_kernel` 5.66 + `verify_gdn_conv_l2_multi_kernel` 1.34 = 7.00 us, so no gain on the profile's critical path. The remaining +0.155 ms of the GDN role is the step kernel itself: next step is the step kernel's own time, not launch count) | -| K7a | GDN step/norm in the verify graph (`verify_gdn_step_norm_multi` 6.1 us against `gdn_step_norm_multi` 6.2 us, but 36 against 30.9 launches) | 0.220 | 0.191 | +0.029 | CUPTI | device | open (as K7: the step/norm kernel stays 7.18 us fused against 7.00 us separate under SIDE_MIXER, so the gap to `gdn_step_norm_multi` 6.1 us is in the kernel body) | +| K7 | GDN role in total (step, conv, ab, commit) | 0.914 | 0.759 | +0.155 | CUPTI role table | device | open (switch `LELEKA_SM120_FUSED_GDN` built, identity PASS (P4, P5, P8: `verify-new-switches-identity`: top-16 rows 2057/2057 identical, draft trace 1036/1036 identical, argmax flips 0, A/A identical), OFF in the profiles. Section `verify-new-switches-cupti-windows` (2026-11-10, windows of request 29, 15 s, new binary `bin-verify-switches`, per-T within one variant: T 2..6 have 77-376 graphs; the control CL.2 and each variant ran in separate sessions, so the expert-tier (FFN) phase differs between them and is NOT compared): without side streams (CG.1 against CL.2) GDN kernel time per graph -78 / -74 / -82 / -70 / -60 us at T 2..6, launches 108 -> 36, mixer phase -1.6 / -1.3 / -1.6 / -1.3 / -0.8 us per layer (-0.04..-0.075 ms per graph). With the profile's SIDE_MIXER (CY.1) the a/b projection stays a separate `chain_gdn_ab_multi_kernel` on the side stream (10.1 us x 36) and the fused kernel is step+norm+conv only: 7.18 us against `verify_gdn_step_norm_multi_kernel` 5.66 + `verify_gdn_conv_l2_multi_kernel` 1.34 = 7.00 us, so no gain on the profile's critical path. The remaining +0.155 ms of the GDN role is the step kernel itself: next step is the step kernel's own time, not launch count) UPDATE 2026-11-12 (windows QP.1 against VANL, same replay cell, current profile set with SIDE_MIXER; `/data/leleka-e2e/spd-gap/runs/critical-path-67k-existing-windows/`): GDN kernel time per graph is at parity, not +0.155 ms: step LEL 36 launches x 6.22 us against vanilla 30.9 x 6.19 + 5.1 x 5.16; per graph at T 2/3/4/6 step LEL 171/207/240/308 us against 166/200/235/304 (+4..+6 us), conv LEL 51-54 us against 85-99 us (-35..-45 us), a/b LEL 299/373/435/573 us against 286/343/379/521 us (+13..+57 us, on the side stream). The mixer phases of the whole graph are 5.75 ms (LEL) against 5.89 ms (vanilla): no mixer-phase gap is left. The +0.155 ms of the older role table was the three-kernel, single-stream configuration. Residual of the step kernel itself: about +0.006 ms (0.03 % of the round); NO kernel is written (nothing to win against vanilla in the mixer phase). The gap is in the FFN phases and the host leg (see the critical path paragraph). | +| K7a | GDN step/norm in the verify graph (`verify_gdn_step_norm_multi` 6.1 us against `gdn_step_norm_multi` 6.2 us, but 36 against 30.9 launches) | 0.220 | 0.191 | +0.029 | CUPTI | device | open (as K7: the step/norm kernel stays 7.18 us fused against 7.00 us separate under SIDE_MIXER, so the gap to `gdn_step_norm_multi` 6.1 us is in the kernel body) UPDATE 2026-11-12 (windows QP.1 against VANL, same replay cell, current profile set with SIDE_MIXER; `/data/leleka-e2e/spd-gap/runs/critical-path-67k-existing-windows/`): GDN kernel time per graph is at parity, not +0.155 ms: step LEL 36 launches x 6.22 us against vanilla 30.9 x 6.19 + 5.1 x 5.16; per graph at T 2/3/4/6 step LEL 171/207/240/308 us against 166/200/235/304 (+4..+6 us), conv LEL 51-54 us against 85-99 us (-35..-45 us), a/b LEL 299/373/435/573 us against 286/343/379/521 us (+13..+57 us, on the side stream). The mixer phases of the whole graph are 5.75 ms (LEL) against 5.89 ms (vanilla): no mixer-phase gap is left. The +0.155 ms of the older role table was the three-kernel, single-stream configuration. Residual of the step kernel itself: about +0.006 ms (0.03 % of the round); NO kernel is written (nothing to win against vanilla in the mixer phase). The gap is in the FFN phases and the host leg (see the critical path paragraph). | | K7b | GDN alpha/beta (`chain_gdn_ab_multi` 36 x 8.5 us against `gdn_ab_multi` 22.9 x 10.5 us plus the rest) | 0.307 | 0.344 | -0.037 | CUPTI | device | proved-equal (LEL ahead) | | K12 | dense projections, lm head, MMVQ/MMVF role (`head_n*`, `bf16_f32_mmvf_multi`) | 3.892 | 4.589 | -0.697 | CUPTI | device | proved-equal (LEL ahead) | | S1 | `ATTN_DAILY` (decode attention) | on since lever 1 | on | paired decode +1.85 % with S2 (CI excludes zero), identity PASS (teacher-forced, 2057 of 2057 rows); no section delta of its own | gap doc lever 1 | device | fixing (needs a CUPTI section delta) | diff --git a/scripts/e2e/codex/speed/critical_path_report.py b/scripts/e2e/codex/speed/critical_path_report.py index b8fa4a26..fd0865ee 100644 --- a/scripts/e2e/codex/speed/critical_path_report.py +++ b/scripts/e2e/codex/speed/critical_path_report.py @@ -55,7 +55,7 @@ def add_phases(name_of, record, segment, bell, next_bell_start): return record -def graph_layers(name_of, kernels, tokens): +def graph_layers(name_of, kernels, tokens, mode): """The 48 layer records of one verify graph, or None when it does not have 48 doorbells or T differs.""" bells = [k for k in kernels if "doorbell_publish" in name_of(k)] if len(bells) != LAYERS: @@ -64,7 +64,7 @@ def graph_layers(name_of, kernels, tokens): for index, bell in enumerate(bells): next_start = bells[index + 1].start if index + 1 < LAYERS else 0 segment = [k for k in kernels if bell.start <= k.start < (next_start or bell.start + 400000)] - record = flag_waits.layer_record(name_of, segment, bell, "LEL") + record = flag_waits.layer_record(name_of, segment, bell, mode) if record is None or (tokens is not None and record["tokens"] != tokens): return None layers.append(add_phases(name_of, record, segment, bell, next_start)) @@ -86,12 +86,12 @@ def round_periods(spans): return periods, rests -def extract(trace_dir, label, tokens): +def extract(trace_dir, label, tokens, mode): trace, graphs = flag_waits.load(trace_dir) name_of = lambda k: trace.names.get(k.name, "") # noqa: E731 spans, per_graph = [], [] for kernels in graphs: - layers = graph_layers(name_of, kernels, tokens) + layers = graph_layers(name_of, kernels, tokens, mode) spans.append((min(k.start for k in kernels), max(k.end for k in kernels))) if layers is not None: per_graph.append((spans[-1], layers)) @@ -177,13 +177,14 @@ def main(): one.add_argument("label") one.add_argument("--lct", default="/data/leleka-e2e/decode/tools") one.add_argument("--tokens", type=int, default=None) + one.add_argument("--mode", choices=("LEL", "VANL"), default="LEL", help="engine of the trace") many = sub.add_parser("report") many.add_argument("files", nargs="+") many.add_argument("--first-layers", type=int, default=16) args = parser.parse_args() if args.cmd == "extract": sys.path.insert(0, args.lct) - json.dump(extract(args.trace, args.label, args.tokens), sys.stdout) + json.dump(extract(args.trace, args.label, args.tokens, args.mode), sys.stdout) else: report(args.files, args.first_layers)