Repository navigation
feat(engine): flag-gated single-trip Scan inline dual-path (27B Scan-capture slice 1a) - #564
Conversation
A Scan whose RUNTIME trip_count == 1 (a single decode step) runs its body once straight-line instead of the generic exec_scan loop, while prefill (trip_count = prompt_len > 1) keeps the unchanged loop. Selection is keyed on the observed trip_count at execution time — NOT a graph rewrite — because prefill and decode share one executor/plan, so a static single-trip bake would corrupt prefill. Gated by ONNX_GENAI_SCAN_INLINE_SINGLE_TRIP (default OFF): flag OFF is zero behavior change. Both the loop and the inline path drive the body through a shared run_scan_body_step helper and share the finishing code, so the inline path is byte-exact with a one-iteration loop by construction (DRY, general — no op/model special-casing). Correctness-only foundation; no capture changes (slice 1b will let the inlined body enter CUDA-graph capture). No changes to plan_capture_region / node_capture_reason / StructuralCaptureDecline. Evidence: - CPU test scan_single_trip_inline_is_byte_exact_and_runtime_keyed: byte-exact vs loop over both outputs, engages only at trip_count==1, count==0 on prefill (runtime-keyed). Mutation-checked non-vacuous. - CUDA-gated regression cuda_scan_single_trip_inline_is_byte_exact_and_runtime_keyed (device 4): same on real ORT-CUDA, via scan_inline_single_trip_count. - On-model 27B (qwen3.6-27b int4, device 4, greedy 48 tok): token ids IDENTICAL flag OFF vs ON across prefill + 48 decode steps. - Re-ran #554 (recurrent-state reset) and #544 (weight page-in WAR) green. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
VERDICT: APPROVE Independent review (Melina) — author Mary locked out on rejection; reviewer modified no product code (mutations reverted, tree clean).
Non-vacuity (mutations run, all FAILED as required):
Regressions (device 0) all PASS: session-reuse #554, prefetch-WAR #544, cuda_control_flow_safety, CPU lib 105 / control_flow 23. fmt --check clean, clippy clean. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #564 +/- ##
==========================================
- Coverage 81.17% 80.60% -0.58%
==========================================
Files 315 315
Lines 123528 123574 +46
Branches 123528 123574 +46
==========================================
- Hits 100276 99606 -670
- Misses 19194 19916 +722
+ Partials 4058 4052 -6
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
🔴 Benchmark Regression DetectedComparison of criterion micro-benchmarks: PR head vs merge-base, measured on the same runner in the same job (base first → PR second).
Visual flags: Host infoWhat this cannot catch
|
#568) (#569) Consolidates the accumulated GAP-3 native-paged-decode decision inbox (7 notes) into the canonical `.squad/decisions.md`, clearing the drop-box. Folds in the decisions from the 4 merged GAP-3 PRs plus the Scan-capture deferral: - **#565** Inc-A — native multi-component pipeline construction - **#566** Inc-C — host present-KV mirroring → paged native decode - **#567** Inc-D — device-resident f32 CUDA present-KV read-out → paged - **#568** Inc-D.1 — f16 device present-KV read-out → paged - Inc-C test-rigor fix (byte-equality oracle pattern) - Scan-capture slice-1b **deferral** (needs per-EP device-graph handle-keyed registry; resumption trigger recorded) - Scan slice-1a (#564) decisions.md 20465 → 28227 bytes (under the 30KB healthy threshold; no archiving needed). Inbox now README-only. Docs-only change under `.squad/`. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
27B decode: flag-gated single-trip Scan inline dual-path (slice 1a of Scan→CUDA-capture)
First slice of the Justin-approved 27B Scan→CUDA-capture workstream (root-cause: eager
Scan/LinearAttention recurrence = 56.5% of 27B decode, structurally un-capturable; ~15-30× lever). Slice 1a is correctness-only — NO capture changes yet.What
A runtime-conditional dual-path in
exec_scan: whenONNX_GENAI_SCAN_INLINE_SINGLE_TRIPis ON and the runtime trip_count==1, the Scan body runs once straight-line via a sharedrun_scan_body_stephelper; otherwise the unchanged loop. Selection is runtime-keyed (not a graph rewrite) because prefill (trip_count>1) and decode (trip_count==1) share one executor/plan — a static seq=1 inline would corrupt prefill.Evidence
Review
Independent review by Melina (author Mary locked out on rejection) — APPROVE with full non-vacuity evidence.
1b handoff
Let the single-trip inlined body enter CUDA-graph capture (blast radius
provider.rs:458+executor/capture.rs); assert captures/replays counters rise and 27B tokens stay byte-identical to this 1a reference.Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com