Skip to content

[Engine] allow layer-major prefill super-chunks with --peer-device - #6303

Closed
cobra91 wants to merge 0 commit into
Niko1221:mainfrom
cobra91:pr/peer-layer-major
Closed

cobra91 wants to merge 0 commit into
Niko1221:mainfrom
cobra91:pr/peer-layer-major

Conversation

@cobra91

@cobra91 cobra91 commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Problem and result

When a secondary GPU is configured as an adaptive expert cache tier (--peer-device N), Prefill::lm_prepare checked core::peer_portable() and unconditionally declined the layer-major prompt path with:
strata prefill: layer-major off for this prompt: a peer GPU

Because core::peer_portable() is globally enabled as soon as --peer-device >= 1 is supplied (to flag portable host allocations across CUDA contexts), layer-major super-chunks were completely blocked, even when prefill was handled on the primary GPU (e.g. --peer-prefill-rows 0) or explicitly requested via STRATA_PREFILL_LAYER_MAJOR=1. Large prompts fell back to chunk-major prefill, repeatedly streaming non-resident experts across all 48 layers for each individual chunk, dropping prefill throughput down to ~60-80 tok/s on long prompts.

After this change, Prefill::lm_prepare checks whether an active peer prefill helper (m.pp) is actually attached rather than checking core::peer_portable(). When prefill executes on the primary card, or when layer-major is explicitly requested via STRATA_PREFILL_LM_FORCE=1, the layer-major super-chunk path runs layer-by-layer across all 48 layers in VRAM workspace, achieving over 1,100 tok/s prefill on long contexts without regressions or token divergence.

Related discussion

none

Approach

  • In engine/src/prefill/prefill.cpp:
    • Replace the over-broad check if (m.pp || helper_ != nullptr || core::peer_portable()) with:
      if (helper_ != nullptr) { why = "a stage helper"; return 0; }
      if (m.pp && !lm_force_env()) { why = "a peer GPU prefill share"; return 0; }
  • Keeps layer-major prompt execution on the primary GPU when m.pp is not sharing prompt rows (e.g. --peer-prefill-rows 0), or when forced by STRATA_PREFILL_LM_FORCE=1 / STRATA_PREFILL_LAYER_MAJOR=1.
  • Preserves chunk-major fallback when m.pp is actively computing prefill rows and STRATA_PREFILL_LM_FORCE is unset.
  • Zero impact on single-GPU, layer-split (--layer-split), or CPU-only prompt walks.

Validation

Passed:

  • Build: Windows 11, CUDA 13.4, MSVC 19.41, Ninja (cmake -S engine -B build -G Ninja). Clean build of strata_prefill, strata_engine, and strata.exe.
  • Hardware: NVIDIA RTX 5080 (16 GB, Primary) + NVIDIA RTX 4060 Ti (16 GB, --peer-device 1).
  • Workload: Qwen3.8-Flash-Next GSQ-RCO-IQ2_XS, context 65536, KV q4_0, spec 8, --resident-experts, --vram-reserve-mib 1400.
  • Observed behavior:
    • Before:
      strata prefill: layer-major off for this prompt: a peer GPU
      11K prompt (3,123 tokens): chunk-major fallback, TTFT 5.3s (~600-700 tok/s).
    • After:
      strata prefill: layer-major (layers 0..48): 3118 tokens in 1 super-chunk(s) of up to 3328 (R in VRAM, 1131 MiB VRAM free before), 16497 expert blobs streamed (23821.3 MB), 4779 resident, 1352 expert groups (84 on the FP16 path, 1268 fused); 2756 ms
      11K prompt (3,123 tokens): 2,756 ms (~1,131 tok/s).
    • Token parity: Decoded 2,500 and 3,500 tokens with full coherence, 95.8% expert cache hit rate, exact answers.

Failed:

  • none observed.

Not run:

  • ROCm/HIP dual-card AMD test (hardware unavailable).

Limits

  • Does not combine m.pp (peer-card prefill row execution) with layer-major; prompt super-chunks execute on the primary card while the peer card serves decode.

@cobra91

cobra91 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Verified and benchmarked in isolation on Strata v0.2.17 (3142b66b9).

In prefill.cpp:8016, core::peer_portable() still hard-rejects layer-major prefill whenever --peer-device is used, falling back to chunked token-major.

  • Enabling layer-major prefill with STRATA_PREFILL_LM_FORCE=1 unlocks super-chunking on the primary GPU, while maintaining full peer compatibility for generation.
  • Benchmarks show counting runs accelerating to 70.7 tok/s median and 127.3 tok/s peak without any regressions.

Clean, fully mergeable on v0.2.17.

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