Skip to content

Add DCP8 direct peer context gather for MLA and indexer rows - #26

Open
YukioZzz wants to merge 11 commits into
Inferact:mainfrom
YukioZzz:dcp8-context-gather
Open

YukioZzz wants to merge 11 commits into
Inferact:mainfrom
YukioZzz:dcp8-context-gather

Conversation

@YukioZzz

@YukioZzz YukioZzz commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Adds a byte-preserving FlyDSL direct-peer gather for DCP8 MLA/indexer context on eight gfx950 GPUs. It supports production block-major KV page strides and packed indexer scales without extra KV padding or copies.

  • Explicit vector loads for lane-varying scale offsets; compiler fences preserve the peer-write/wait/ticket ordering.
  • Collective workspace lifecycle, device/layout checks and graph-replay coverage.
  • Checked API by default. Trusted callers can use validate=False after pool-binding and per-batch validation, removing repeated per-layer checks without a tensor-identity cache. This opt-in integration is in vLLM #71055; existing callers remain compatible.

Correctness

Current head ff54227: four eight-rank byte-exact tests pass, covering checked/prevalidated calls, padded and typed storage, page boundaries, packed scales, 32 changing-data graph replays, delayed ranks, immediate consumption, invalid metadata and teardown. Three compile tests and six companion vLLM boundary tests pass. The final V2-runner dummy K31 + DSpark integration initializes and completes 5/5 requests (2K-32K, up to c4). Dummy tests do not establish model accuracy.

Real-weight c48 GSM8K at 6c79dfb: 1319/1319 responses; strict 1291/1319 (97.88%), flexible 1290/1319 (97.80%), real draft acceptance 70.02%, accepted length including bonus 3.80087. The historical reference scored 1292/1319 with 70.09% acceptance, but source/config differences prevent an isolated no-loss claim. These results predate the host-validation changes.

Performance

Real K31 + DSpark, 8x MI355X, TP8/DCP8, EP/shared experts, ShardQ/576B, K4, 18432/48, main1024/large4096, GMU 0.95/H5, autoKV, 96 MiB hipBLASLt workspace. Same image and JIT; only gather changes. Production: image sha256:722f6795dc2734ba5d9a95b60df55337611032bae320c302adc7eea8c1eccebb, vLLM 278c367a, AKR 659c9067; candidate 6c79dfb. Fixed-length requests, 128 output tokens, zero prefix hits:

Workload Total tok/s, production / PR P90 TTFT, production / PR P90 TPOT, production / PR
32K, c4, 8 requests (repeat) 14,150 / 14,205 4.676 / 4.666 s 66.82 / 64.56 ms
8K, c48, 96 requests 17,038 / 17,306 13.688 / 13.671 s 189.09 / 179.27 ms

The 32K repeat reuses the production baseline. The first candidate run measured 14,320 tok/s, P90 TTFT 4.972 s and TPOT 59.06 ms; the variation limits conclusions from eight requests. P90 uses linear percentiles of per-request results. All original 104/104 requests per variant completed; measured-window allocator retries/OOMs were zero, KV stayed 44.19 GiB on rank0 and peak reserved memory was unchanged. Warmup retries are excluded. These sequential tests show comparable performance, not a proven throughput gain.

For the latest validation-boundary change, paired real vLLM gather calls against 13614d3 include two batch checks amortized over 20 layer calls. Eight-rank maximum p50, microseconds:

Context CPU submit, before / after GPU-complete wall, before / after
Eight mixed requests 24.98 / 22.52 27.85 / 24.82
18432 / 4096 query 24.27 / 21.58 56.45 / 56.73
4 x 32768 24.24 / 21.84 327.94 / 328.67

CPU submission drops about 10%; long-context completion remains comparable. This does not establish a full-model TTFT gain at the latest head.

CI

The test manifest assigns gather tests eight GPUs and compilation tests the compile lane. At ff54227, GitHub reports no GPU check runs. The sole successful status is Devin Review, whose description says the review was skipped for exhausted credits; it is not GPU validation or reviewer approval. Local GPU evidence above is separate from hosted CI.

@benenzhu

benenzhu commented Dec 1, 2026

Copy link
Copy Markdown
Member

Static gfx950 ISA Hazard & Race Check (FlyDSL 0.5.0)

Compiled all 5 kernels (barrier_0 and dcp8_context_push for {linear, fp4} x {sync, nosync}) and checked the generated gfx950 assembly for instruction hazards, wait-counter coverage, and synchronization / data races.

Summary

  • Hazards & wait counters: Clean across all 5 kernels — 0 inline asm, 0 hazard violations, 0 missing waits (exhaustive path check).
  • Multi-rank protocol: Entry FREE_OFF barrier + exit READY_OFF barrier on the last CTA (old + 1 == total_ctas), followed by state[1] = 0 and state[0] = epoch + 1, prevents overwriting the workspace while a peer is still consuming it. In the compiled ISA, s_waitcnt vmcnt(0) + s_barrier stay right after all buffer_store ... sc0 sc1 and before global_atomic_add ... sc0 -> s_waitcnt vmcnt(0) -> READY_OFF stores, so no active race was observed in the current build.

Non-blocking findings (fine for a follow-up PR)

  1. is_scalar=True used on per-lane divergent offsets in tiled_fp4 (kernel.py:353-355)

    src_word = _load_i32(
        index_src, scale_offset // 4 + group * 16 + row % 16
    )

    _load_i32 passes is_scalar=True (llvm.amdgcn.s.buffer.load.i32, which requires wave-uniform offsets), whereas group = tx // 2 and row = row0 + (tx % 2) + 2 * quarter vary across lanes tx = 0..7.

    • In this build LLVM's divergence analysis demoted all 4 calls back to vector buffer_load_dword, avoiding silent corruption, but this violates buffer_load(is_scalar=True)'s wave-uniform contract. Switching to a normal vector buffer_load (matching L378 in the non-tiled_fp4 branch) makes it explicit.
  2. Memory-ordering hardening (kernel.py:101-139, 399-415)

    • _flag_store, _flag_load, and _ticket_add all use AtomicOrdering.monotonic, and L399 uses bare fx.rocdl.s_waitcnt(vmcnt=0) without syncscope("singlethread") compiler fences.
    • Although the current compiled ISA kept the expected order, bracketing s_waitcnt with singlethread compiler fences (and/or using release/acquire ordering on _ticket_add and flags) prevents a future LLVM pass from reordering stores across the wait or ticket increment.
  3. Range / test notes

    • dst_byte (kernel.py:298, 332, 360, 384) is computed in signed 32-bit Int32 (caps workspace byte offsets at 2 GiB).
    • Once multi-rank tests are added, covering both linear and tiled_fp4 (including ragged num_index < 8, num_mla == 0, and multi-epoch replay) will validate these paths end to end.

@YukioZzz
YukioZzz marked this pull request as ready for review December 2, 2026 04:17
@YukioZzz
YukioZzz marked this pull request as draft December 2, 2026 04:50
@YukioZzz
YukioZzz marked this pull request as ready for review December 2, 2026 05:04
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.

2 participants