Skip to content

perf(rdna2): batch expert copies and reduce cache planning overhead - #147

Merged
BlivionIaG merged 19 commits into
rdna_extrasfrom
codex/rdna2-moe-offload-improvements
Oct 29, 2026
Merged

BlivionIaG merged 19 commits into
rdna_extrasfrom
codex/rdna2-moe-offload-improvements

Conversation

@BlivionIaG

@BlivionIaG BlivionIaG commented Oct 28, 2026 •

Copy link
Copy Markdown

Change

First bounded optimization pass after #146: submit missed experts' six persistent SoA payloads through one native C++ call, using HIP 7.14 hipMemcpyBatchAsync when available and a native per-copy loop otherwise. Update the existing pinned int32 slot map through a persistent zero-copy NumPy view to remove scalar Tensor dispatch. Preserve payload addresses, pool budgets, LFU/LRU semantics, leases and consumer/DMA fences.

Fix a reproducible GDN Q32 squared-sum overflow with fixed-order FP32 tile partials, without another kernel launch. Reject invalid accepted-state indices before reads, and extend the post-step fail-stop to the offloaded-expert workspace. Device diagnostics and quiescent inspection controls remain development-only.

Tensor copies remain the default. Enable the tested native path explicitly with rocm_mono_decode.expert_cache_copy="native". Keep the K2 gate at 8; wide-kernel work belongs to #110. This follows the merged core in #146 and does not duplicate either PR. Prefetch, slot rebalancing and further profiling remain later passes in the roadmap.

Validation

  • HIP 7.14 / gfx1030: 147 focused host/GPU tests passed, including real CT packing, overflow and cross-stream parity for both backends. Client failure/cold-prefix gates: 28 passed. Failure-monitor CPU contracts: 14 passed. GDN diagnostic suite: 17 passed; default GDN regression/parity: 49 passed, four diagnostics-only skips. The tested native binary hash is retained.
  • Full TP2/EP2 Flash-Next AWQ text serving, MTP2, segmented FULL_AND_PIECEWISE graphs, GPUs 6–7: 16 ABBA arms, 72 exact-length requests and 55,296 output tokens. Both backends passed greedy, perplexity (native 4.82 / tensor 4.83), prefix reuse and 48 normal-EOS concurrency checks each, with zero hard failures. Post-load greedy passed; no numeric or new GPU fault markers.
  • Eager native-copy fallback (enforce_eager=True, graph mode NONE): greedy, PPL 4.84, prefix reuse, 48 normal-EOS concurrency checks with zero hard failures, exact-length 1k/512 and 16k/1k c1 workloads, and post-load greedy passed without numeric or new GPU fault markers.
  • Local commit hooks passed. Hosted checks were skipped by the repository workflows; they are not represented as GPU validation.

Reproduction: GPU=7 bash tools/rdna/mono/test_offload.sh; .venv/bin/python -m pytest --noconftest tests/models/qwen4_exp/test_offload_long_probe.py; the exact graph/eager launch and load-hook scripts, raw results, pool/copy counters and source hashes are under bench_results/2026-10-29-moe-offload-first-pass/.

Measured scope and limits

  • Matched actual CPU cache control-path benchmark, ten active experts: 83.42 → 37.73 µs median (30 ABBA samples per arm). This excludes GPU event/DMA time. Matched native-copy byte/order tests and submission/completion timings are retained in the earlier receipts.
  • Cold 16k/c1 TTFT: tensor 17.10–17.66 s, native 16.06–16.12 s. Cold 16k/c8 aggregate output: tensor 24.17–25.10 tok/s, native 31.91–32.63 tok/s. Short c1 decode was mixed. All four cells' prefill/decode/TTFT/ITL ranges are in graph-performance-summary.txt and JSON.
  • The A/B now resets both GPU and external CPU prefixes and rejects measured hits or missing hit counters. Expert histories, transferred bytes and MTP acceptance still differ; these model observations are not a causal or universal backend speedup claim. Defaults and memory budgets stay unchanged.
  • An earlier pre-fix run failed at 810/1,024 tokens. The isolated GDN overflow is fixed, but that earlier serving failure has not been causally attributed. Its receipt remains preserved; later diagnostic replay and final graph/eager qualification passed without recurrence. Older-HIP fallback has no older-runtime qualification.

AI assistance was used. The change is limited to this first pass; the remaining optimization backlog is not a merge requirement for it.

BlivionIaG and others added 4 commits October 28, 2026 13:34
Co-authored-by: Codex <noreply@openai.com>
Signed-off-by: BlivionIaG <kev29lt@gmail.com>
Exercise 12- and 24-row split K2 with changing routes and capacity-three eviction passes for TP2/EP2 and TP4/EP4 geometry.

Co-authored-by: Codex <noreply@openai.com>
Signed-off-by: BlivionIaG <kev29lt@gmail.com>
Preserve the six persistent payload pools and cache fencing while submitting misses in one native call. Keep tensor copies as the default pending model-level qualification.

Co-authored-by: Codex <noreply@openai.com>
Signed-off-by: BlivionIaG <kev29lt@gmail.com>
@BlivionIaG BlivionIaG changed the title [backlog] perf(rdna2): improve MoE offloading transfers, graphs and memory budgets perf(rdna2): batch expert-cache copies and qualify offload improvements Oct 28, 2026
BlivionIaG and others added 15 commits October 28, 2026 18:58
Alternate quiescent backend switches in one server, reset prefix state before each cell and retain cache demand, miss and submission counters alongside performance results.

Co-authored-by: Codex <noreply@openai.com>
Signed-off-by: BlivionIaG <kev29lt@gmail.com>
Preserve both serving arms, quality gates and forced-output warnings. Gate 24 regressed both c8 cells; leave the default at 8. Record native copy and forced-fallback receipts without claiming a model speedup.

Co-authored-by: Codex <noreply@openai.com>
Signed-off-by: BlivionIaG <kev29lt@gmail.com>
Check readiness through worker RPC and require a successful prefix-reset acknowledgement before measuring requests. Existing long-probe defaults retain their initial client ready check.

Co-authored-by: Codex <noreply@openai.com>
Signed-off-by: BlivionIaG <kev29lt@gmail.com>
Keep strict transfer-counter requirements for KV-boundary qualification. Expert-copy A/B retains missing KV transfer counters as unavailable, while still requiring server metric boundaries and preemption accounting.

Co-authored-by: Codex <noreply@openai.com>
Signed-off-by: BlivionIaG <kev29lt@gmail.com>
Preserve 119 focused GPU test results, full-model native quality gates and per-rank pool/copy counters. Explicitly retain the failed client-hook receipt without claiming completed A/B performance.

Co-authored-by: Codex <noreply@openai.com>
Signed-off-by: BlivionIaG <kev29lt@gmail.com>
Reject the native long response at 810 of 1024 tokens after NaN logits. Preserve short observed results with cache/MTP caveats and isolated actual-copy distributions; keep native copies opt-in and qualification blocked.

Co-authored-by: Codex <noreply@openai.com>
Signed-off-by: BlivionIaG <kev29lt@gmail.com>
The isolated offload launcher accepted zero but still selected a connector without its required CPU byte budget. Omit both KV options at zero and preserve positive-budget flags. Dry-run zero/16 GiB checks and shell hooks passed.

Co-authored-by: Codex <noreply@openai.com>
Signed-off-by: BlivionIaG <kev29lt@gmail.com>
Reuse TP-wide async fail-stop for the shared model-offload arena, preserving resident routes and MTP fallback behavior. Read detailed local headers only on error. Add quiescent debug toggling and external-prefix counter receipts for joint expert/KV diagnosis. All 153 focused remote tests passed.

Co-authored-by: Codex <noreply@openai.com>
Signed-off-by: BlivionIaG <kev29lt@gmail.com>
Replace overflowing Q32 squared sums with fixed-order FP32 tile partials. Add opt-in device diagnostics and reject invalid accepted indices before state reads. Validate default recurrence/state repeatability and diagnostic graph replay on HIP GPU 7.

Co-authored-by: Codex <noreply@openai.com>
Signed-off-by: BlivionIaG <kev29lt@gmail.com>
Expose development-only collective, wait and off controls for post-step fault monitoring. Restrict the offload launcher to the current GPU 6–7 allocation and record current NaN investigation limits.

Co-authored-by: Codex <noreply@openai.com>
Signed-off-by: BlivionIaG <kev29lt@gmail.com>
Preserve completed KV-disabled and KV-enabled long-request diagnostic receipts. These passing controls do not establish the cause of the earlier failure because completion pacing changed.

Co-authored-by: Codex <noreply@openai.com>
Signed-off-by: BlivionIaG <kev29lt@gmail.com>
Record 58 exact-length requests and 40960 output tokens across copy backends and post-step guard modes, including long concurrency-8 tests. Greedy, perplexity, prefix reuse and post-load checks passed without numeric or GPU fault markers. Preserve the limit that the original serving NaN has not been causally attributed.

Co-authored-by: Codex <noreply@openai.com>
Signed-off-by: BlivionIaG <kev29lt@gmail.com>
…patch

Use a persistent NumPy view of the same pinned int32 map, retaining the previous DMA completion fence and stable upload addresses. Extend real CT overflow/stream parity to both copy backends. The server CPU control-path benchmark reduces a ten-expert resident-hit pass from 83.4 to 37.7 us; 147 focused GPU tests pass.

Co-authored-by: Codex <noreply@openai.com>
Signed-off-by: BlivionIaG <kev29lt@gmail.com>
Reset connector-managed CPU prefixes as well as GPU prefixes before each measured arm. Reject warm or unavailable hit counters so retained CPU KV cannot masquerade as a copy-backend prefill speedup. Validate reset retry and fail-closed counter gates.

Co-authored-by: Codex <noreply@openai.com>
Signed-off-by: BlivionIaG <kev29lt@gmail.com>
…load pass

Preserve cold-prefix ABBA metrics, exact-length and normal-EOS release gates, source hashes and reproduction scripts. All 147 focused host/GPU and 28 client tests pass; graph mode completes 72 requests and eager fallback completes both workloads without numeric/GPU faults. Keep tensor copies default and distinguish observed MTP-dependent throughput from causal CPU-control improvements.

Co-authored-by: Codex <noreply@openai.com>
Signed-off-by: BlivionIaG <kev29lt@gmail.com>
@BlivionIaG BlivionIaG changed the title perf(rdna2): batch expert-cache copies and qualify offload improvements perf(rdna2): batch expert copies and reduce cache planning overhead Oct 29, 2026
@BlivionIaG
BlivionIaG marked this pull request as ready for review October 29, 2026 00:23
@BlivionIaG
BlivionIaG merged commit b740289 into rdna_extras Oct 29, 2026
5 checks passed
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