[PR #592] HIP: automatically select exact TP2 prefill transport at startup #615

Open
opened 2026-10-29 21:27:31 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/592
Author: @LostVector
Created: 10/28/2026
Status: 🔄 Open

Base: main ← Head: upstream/hip-peer-prefill


📝 Commits (5)

  • 56141a4 HIP: add opt-in exact peer-VRAM prefill reductions with steady deadlines
  • 51b4c1d HIP: auto-select exact TP2 prefill transport with bounded startup calibration
  • 0ce3d7f Keep expected not-ready polling status out of launch-error checks
  • c32c221 Document automatic HIP prompt transport selection and overrides
  • d6aab91 Record current-base model startup and transport smoke validation

📊 Changes

8 files changed (+803 additions, -0 deletions)

View changed files

📝 CMakeLists.txt (+5 -0)
➕ docs/HIP_PEER_PREFILL.md (+48 -0)
📝 docs/SETTINGS.md (+1 -0)
📝 src/ds4/ds4_kernels.cu (+65 -0)
📝 src/ds4/ds4_kernels.cuh (+40 -0)
📝 src/ds4/ds4_model.cu (+222 -0)
➕ src/ds4/ds4_peer_calibrate.cu (+175 -0)
➕ tests/ds4_peer_allreduce_test.cu (+247 -0)

📄 Description

Earlier full-model tests measured 9.2% lower warm-prefill latency by letting a two-GPU tensor-parallel group exchange its partial sums directly through peer VRAM instead of detouring through system RAM. This PR now automatically compares the compatible exact-F32 transports at startup and picks the fastest measured option, preserving the same addition order.

The 9.2% result comes from an earlier experimental EXL3 stack, not a fresh end-to-end benchmark of this current-upstream port. The new startup comparison measures collective latency, not total model throughput.

Automatic selection and controls

  • MAYA_DS4_HIP_PEER_AR=auto (default/unset): benchmark ordinary host, exact-F32 AR2 when AR2 is unset, and compatible peer VRAM once during model loading. Pick the lowest median GPU time at the configured full prompt-chunk size.
  • 0: preserve the existing transport without peer allocation or a timing probe.
  • 1: force compatible P2P without calibration.
  • Native launches accept DS4_HIP_PEER_AR or STRATA_DS4_HIP_PEER_AR; serving configs use MAYA_DS4_HIP_PEER_AR in env.
  • HIP batch-loader TP2 groups only, requiring bidirectional peer access, fine-grained allocations, a steady wall clock and sufficient spare VRAM. GPU IDs and payload sizes come from the group; no card-specific defaults.
  • Single-GPU runs perform no peer queries, allocation or timing. Larger groups and explicit AR2/flow configurations retain their existing paths. Explicit AR2 0 excludes AR2 from the comparison; FP16 AR2 is never an automatic candidate. Decode/verification, logits gathering, pipeline handoffs and AR2_DECODE are unchanged.

Startup cost and memory

The probe uses private synthetic inputs, checks every result exactly, warms each candidate and collects up to six rotated timing rounds (minimum three). It resets all transport flags before inference and never changes expert placement. A PEER_AR_AUTO line reports candidate medians, the selected path and duration.

A shared three-second submission/polling budget covers all eligible groups. Incomplete but safely drained calibration keeps the existing transport. A validation failure or undrained work refuses model loading. Driver calls cannot be forcibly interrupted, so the budget is not a hard recovery guarantee for driver hangs.

At chunk 4096/dimension 5120, P2P retains 160 MiB per rank; calibration temporarily needs another 80 MiB per rank, with 64 MiB free headroom. Allocation occurs after expert placement, without evicting experts to fit the probe. Peer buffers are freed if host or AR2 wins. Partial initialization failures retain the previous transport.

Validation on upstream v1.1.36 / f031a23

  • Release HIP/gfx1201 engine and standalone test build/link passed.

  • Two R9700s: 256 chained variable-size collectives matched the existing host transport bit for bit, including signed zeros, extreme finite values, subnormals, guarded outputs, sequence wraparound and payloads through 8192 x 5120 floats.

  • Actual auto calibration: six samples each, host 18.16 ms, AR2 7.14 ms, peer 3.46 ms. Selected peer; 237 ms probe duration. These are reduction-only timings.

  • Zero-budget fallback, exclusion of AR2, and exact first-sequence reuse after calibration passed.

  • A deliberately absent peer with a 50 ms deadline timed out in 50.300 ms; 32 poisoned calls drained in 0.102 ms, preserving the first error record.

  • Full-model startup passed in automatic, disabled, explicit AR2=1, and single-GPU modes. Automatic selection chose peer in 222 ms (host 17.35 ms, AR2 7.13 ms, peer 3.46 ms).

  • Auto/off/AR2 each completed the same 1,213-token prompt with identical short greedy text. Disabled/explicit-AR2/single-GPU runs emitted no calibration or peer-enable line. This is a functional smoke check, not full-logit parity or a broad quality evaluation.

CUDA, Windows and other AMD architectures were not hardware-tested. Current-base end-to-end performance, cancellation followed by reuse, and model-level failure injection remain separate validation work.

Runtime failure handling

The peer kernel uses HIP's wall_clock64() and queried wall-clock rate for a two-second physical deadline. This fixes a previously observed negative GPU core-counter interval that became a false immediate timeout after unsigned conversion. Unsupported clock queries retain host transport.

A real timeout records the first failing rank/sequence/block and elapsed/budget ticks. Subsequent queued peer calls drain. Errors are checked before accepting the prompt result; the model stays invalid across reset and requires reload. The integration preserves upstream's batched step_runs entry point and coordinated chunk-boundary cancellation.

Historical full-model evidence

Six balanced blocks / 24 warm trials measured 9.2332% lower latency (block-based 95% interval 8.9991–9.4673%), with medians 7456.793 → 6758.643 ms. Cold results were inconclusive and no decode speedup was established. Scratch stayed allocated in both arms, holding expert placement fixed. Cold/warm/repeated logits and 80 greedy tokens matched independent references exactly.

That older stack also included scalar EXL3 tiling, host packing, predecode, copy-wait and transfer-pruning changes. Its model-level fault-injection test checked request rejection and poison persistence after reset; these historical results do not validate the new integration points. Sources and protocols: fork #15, primitive #14, diagnostics #35, clock fix #38.

Reproduction and settings: docs/HIP_PEER_PREFILL.md.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/mw00/project-maya/pull/592 **Author:** [@LostVector](https://github.com/LostVector) **Created:** 10/28/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `upstream/hip-peer-prefill` --- ### 📝 Commits (5) - [`56141a4`](https://github.com/mw00/project-maya/commit/56141a45a2cce4fe87fc5d72200cc56efcc10106) HIP: add opt-in exact peer-VRAM prefill reductions with steady deadlines - [`51b4c1d`](https://github.com/mw00/project-maya/commit/51b4c1d82e34ba4d60a8b306d1b566a7606eb1c7) HIP: auto-select exact TP2 prefill transport with bounded startup calibration - [`0ce3d7f`](https://github.com/mw00/project-maya/commit/0ce3d7f64b89780f796644f58189e8a33b4bcb3a) Keep expected not-ready polling status out of launch-error checks - [`c32c221`](https://github.com/mw00/project-maya/commit/c32c2212c8061671539e495f0fa6af24fce3f31a) Document automatic HIP prompt transport selection and overrides - [`d6aab91`](https://github.com/mw00/project-maya/commit/d6aab91cbafb87b1bc716a8054f435affdc9c00c) Record current-base model startup and transport smoke validation ### 📊 Changes **8 files changed** (+803 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+5 -0) ➕ `docs/HIP_PEER_PREFILL.md` (+48 -0) 📝 `docs/SETTINGS.md` (+1 -0) 📝 `src/ds4/ds4_kernels.cu` (+65 -0) 📝 `src/ds4/ds4_kernels.cuh` (+40 -0) 📝 `src/ds4/ds4_model.cu` (+222 -0) ➕ `src/ds4/ds4_peer_calibrate.cu` (+175 -0) ➕ `tests/ds4_peer_allreduce_test.cu` (+247 -0) </details> ### 📄 Description **Earlier full-model tests measured 9.2% lower warm-prefill latency by letting a two-GPU tensor-parallel group exchange its partial sums directly through peer VRAM instead of detouring through system RAM. This PR now automatically compares the compatible exact-F32 transports at startup and picks the fastest measured option, preserving the same addition order.** The 9.2% result comes from an earlier experimental EXL3 stack, not a fresh end-to-end benchmark of this current-upstream port. The new startup comparison measures collective latency, not total model throughput. ### Automatic selection and controls - `MAYA_DS4_HIP_PEER_AR=auto` (default/unset): benchmark ordinary host, exact-F32 AR2 when AR2 is unset, and compatible peer VRAM once during model loading. Pick the lowest median GPU time at the configured full prompt-chunk size. - `0`: preserve the existing transport without peer allocation or a timing probe. - `1`: force compatible P2P without calibration. - Native launches accept `DS4_HIP_PEER_AR` or `STRATA_DS4_HIP_PEER_AR`; serving configs use `MAYA_DS4_HIP_PEER_AR` in `env`. - HIP batch-loader TP2 groups only, requiring bidirectional peer access, fine-grained allocations, a steady wall clock and sufficient spare VRAM. GPU IDs and payload sizes come from the group; no card-specific defaults. - Single-GPU runs perform no peer queries, allocation or timing. Larger groups and explicit AR2/flow configurations retain their existing paths. Explicit AR2 `0` excludes AR2 from the comparison; FP16 AR2 is never an automatic candidate. Decode/verification, logits gathering, pipeline handoffs and `AR2_DECODE` are unchanged. ### Startup cost and memory The probe uses private synthetic inputs, checks every result exactly, warms each candidate and collects up to six rotated timing rounds (minimum three). It resets all transport flags before inference and never changes expert placement. A `PEER_AR_AUTO` line reports candidate medians, the selected path and duration. A shared three-second submission/polling budget covers all eligible groups. Incomplete but safely drained calibration keeps the existing transport. A validation failure or undrained work refuses model loading. Driver calls cannot be forcibly interrupted, so the budget is not a hard recovery guarantee for driver hangs. At chunk 4096/dimension 5120, P2P retains 160 MiB per rank; calibration temporarily needs another 80 MiB per rank, with 64 MiB free headroom. Allocation occurs after expert placement, without evicting experts to fit the probe. Peer buffers are freed if host or AR2 wins. Partial initialization failures retain the previous transport. ### Validation on upstream v1.1.36 / `f031a23` - Release HIP/gfx1201 engine and standalone test build/link passed. - Two R9700s: **256 chained variable-size collectives matched the existing host transport bit for bit**, including signed zeros, extreme finite values, subnormals, guarded outputs, sequence wraparound and payloads through 8192 x 5120 floats. - Actual auto calibration: six samples each, host **18.16 ms**, AR2 **7.14 ms**, peer **3.46 ms**. Selected peer; **237 ms** probe duration. These are reduction-only timings. - Zero-budget fallback, exclusion of AR2, and exact first-sequence reuse after calibration passed. - A deliberately absent peer with a 50 ms deadline timed out in **50.300 ms**; **32 poisoned calls drained in 0.102 ms**, preserving the first error record. - Full-model startup passed in automatic, disabled, explicit AR2=1, and single-GPU modes. Automatic selection chose peer in **222 ms** (host 17.35 ms, AR2 7.13 ms, peer 3.46 ms). - Auto/off/AR2 each completed the same 1,213-token prompt with identical short greedy text. Disabled/explicit-AR2/single-GPU runs emitted no calibration or peer-enable line. This is a functional smoke check, not full-logit parity or a broad quality evaluation. CUDA, Windows and other AMD architectures were not hardware-tested. Current-base end-to-end performance, cancellation followed by reuse, and model-level failure injection remain separate validation work. ### Runtime failure handling The peer kernel uses HIP's `wall_clock64()` and queried wall-clock rate for a two-second physical deadline. This fixes a previously observed negative GPU core-counter interval that became a false immediate timeout after unsigned conversion. Unsupported clock queries retain host transport. A real timeout records the first failing rank/sequence/block and elapsed/budget ticks. Subsequent queued peer calls drain. Errors are checked before accepting the prompt result; the model stays invalid across reset and requires reload. The integration preserves upstream's batched `step_runs` entry point and coordinated chunk-boundary cancellation. ### Historical full-model evidence Six balanced blocks / 24 warm trials measured **9.2332% lower latency** (block-based 95% interval **8.9991–9.4673%**), with medians **7456.793 → 6758.643 ms**. Cold results were inconclusive and no decode speedup was established. Scratch stayed allocated in both arms, holding expert placement fixed. Cold/warm/repeated logits and 80 greedy tokens matched independent references exactly. That older stack also included scalar EXL3 tiling, host packing, predecode, copy-wait and transfer-pruning changes. Its model-level fault-injection test checked request rejection and poison persistence after reset; these historical results do not validate the new integration points. Sources and protocols: [fork #15](https://github.com/LostVector/project-maya/pull/15), primitive [#14](https://github.com/LostVector/project-maya/pull/14), diagnostics [#35](https://github.com/LostVector/project-maya/pull/35), clock fix [#38](https://github.com/LostVector/project-maya/pull/38). Reproduction and settings: [`docs/HIP_PEER_PREFILL.md`](https://github.com/LostVector/project-maya/blob/upstream/hip-peer-prefill/docs/HIP_PEER_PREFILL.md). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mw00/project-maya#615
No description provided.