[PR #492] [CLOSED] Heterogeneous multi-GPU roles: whole model on one GPU, the MTP draft head on the other #2666

Closed
opened 2026-11-04 02:02:13 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/492
Author: @hireymage
Created: 10/2/2026
Status: ❌ Closed

Base: main ← Head: hetero-roles-pr


📝 Commits (10+)

  • 1bd572f docs: heterogeneous multi-GPU MAIN+DRAFT design (Fase 1 analysis)
  • 3a48cbe core: per-device DeviceCaps discovery + the peer matrix in strata-device
  • 41cb550 core: one shared device_cc_major accessor under the kernel-selection sites
  • 97b824d generate: --main-device / --draft-device flags, validation, roles banner
  • 302820d mtp: the drafter's device follows the role, own RoPE when it crosses devices
  • c967f99 mtp: the draft head crosses devices on its own, no peer access assumed
  • 4c7261f mtp: honest cross-device errors, the roles validation follows the real constraint
  • 0679e5a verify: the window hand-off rides a mapped host mirror; no peer access needed
  • e66030f expert_cache: rebuild layer_next_ in open_sized; per-layer admission read out of slot 0
  • 4b07e90 mtp: the drafter's gr_read scratch runs on its own device in roles mode

📊 Changes

12 files changed (+1479 additions, -36 deletions)

View changed files

➕ docs/HETERO_MGPU_PLAN.md (+597 -0)
📝 include/strata/core/device.hpp (+38 -0)
📝 include/strata/core/mtp.hpp (+23 -2)
📝 include/strata/core/verify.hpp (+11 -0)
📝 src/core/conversation_snapshot.cpp (+14 -0)
📝 src/core/device.cu (+89 -0)
📝 src/core/device_main.cpp (+34 -0)
📝 src/core/mtp.cpp (+214 -12)
📝 src/core/verify.cpp (+16 -1)
📝 src/kernels/cuda/qsa_select.cu (+7 -12)
📝 src/program/generate.cpp (+229 -9)
➕ tools/hetero-test.sh (+207 -0)

📄 Description

Closes/addresses discussion in #490.

What this adds

Heterogeneous multi-GPU roles — a different way to use two (not necessarily equal) GPUs than --split-device: the whole model (KV + verify) stays on the main GPU, only the MTP draft head runs on the second one. No P2P required, no layer split. The drafter is tiny next to the main model, so moving it off the main GPU returns its VRAM (~870 MiB + the draft head) to the main GPU's expert cache, while the drafter gets its own device entirely.

New (all opt-in, no behavior change when none are passed):

  • --main-device N --draft-device M — explicit role placement; both directions work. The drafter's K/V, ring restore, gr workspace and graph captures are re-homed on the draft device; the verify window's hand-off rides a mapped host mirror, so no peer access is ever assumed;
  • --auto-roles — pick the roles from the capability records (main = device 0, draft = the best free remaining; refuses when < 2 CUDA devices or no --mtp is loaded);
  • --draft-prefill-parallel — the prompt fill queues and overlaps the decode instead of blocking it;
  • --draft-chain-batch — the draft chain's step graphs launch back to back with ONE wait per round instead of one per step (drafting 4.63 → 4.14 ms/round on the source rig, ~11 %);
  • per-device DeviceCaps discovery + the peer matrix in strata-device, and a per-role VRAM report after binding, so the trade is visible at start.

The discipline: placement never changes the output, only the measured time

All claims are on greedy token streams compared bit-exactly across repeated runs, compared under equal expert residency (equal auto slot counts, or a forced --expert-cache N shared by both runs) — because when the roles split, the drafter's VRAM frees up on the main GPU, the expert cache there grows, and a different expert-cache size legitimately decodes differently today. Under that rule the roles 0→1, 1→0, reversed, batched and pipelined all reproduce the same-device stream token for token.

The plan, the measurements and the step record live in docs/HETERO_MGPU_PLAN.md (sections 10–12 hold the Fase-7/8/9/12/13 numbers and the gate rule).

How to reproduce on your own rig

tools/hetero-test.sh <build-dir> "<your model-load flags>" /tmp/het 60 2

runs the variant matrix (single- and two-GPU rigs; the harness detects the rig itself), extracts the greedy stream md5s, picks bit-exactness references by residency, and writes /tmp/het/report.md — the full run table, verdicts and the residency-dividend note. Any report pasted into #490 is exactly the evidence this feature still needs from non-Pascal rigs.

Source-rig validation (2× GTX 1080 Ti, cc 6.1, 125B Q2_0 pack, 16 runs): 20 PASS / 0 FAIL, stream md5 clusters by residency (V0=V1f=V2 c1c2827c7571; V1=V3–V6 dc295284ab30), V1f vs V0 bit-identical — the placement-exactness proof.

Review notes

  • This PR deliberately carries no sm_61/Pascal build work — it was developed on that rig (and the full branch is on my fork as hetero-roles), but only the role/flags/harness features are proposed here.
  • Default-off everywhere; the existing --split-device path is untouched.

🔄 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/Niko1221/Strata/pull/492 **Author:** [@hireymage](https://github.com/hireymage) **Created:** 10/2/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `hetero-roles-pr` --- ### 📝 Commits (10+) - [`1bd572f`](https://github.com/Niko1221/Strata/commit/1bd572f9a60bbe427ac69221b3bc9a28886535fe) docs: heterogeneous multi-GPU MAIN+DRAFT design (Fase 1 analysis) - [`3a48cbe`](https://github.com/Niko1221/Strata/commit/3a48cbe3dd9f6519851845499e7d112c935ffdec) core: per-device DeviceCaps discovery + the peer matrix in strata-device - [`41cb550`](https://github.com/Niko1221/Strata/commit/41cb5502d4033079f7e300095e64d7f0fa738203) core: one shared device_cc_major accessor under the kernel-selection sites - [`97b824d`](https://github.com/Niko1221/Strata/commit/97b824d9f2b9a8d861271ffe6925925383a32070) generate: --main-device / --draft-device flags, validation, roles banner - [`302820d`](https://github.com/Niko1221/Strata/commit/302820d43a6fc408098b13a170f2054b956de199) mtp: the drafter's device follows the role, own RoPE when it crosses devices - [`c967f99`](https://github.com/Niko1221/Strata/commit/c967f997267f3bc3a4e7ab988100be20f17e8482) mtp: the draft head crosses devices on its own, no peer access assumed - [`4c7261f`](https://github.com/Niko1221/Strata/commit/4c7261ffa5ffcfcd6ae2416a99d6c14b2aeba791) mtp: honest cross-device errors, the roles validation follows the real constraint - [`0679e5a`](https://github.com/Niko1221/Strata/commit/0679e5af40dc9b6697f64c2829d3549562da5a2d) verify: the window hand-off rides a mapped host mirror; no peer access needed - [`e66030f`](https://github.com/Niko1221/Strata/commit/e66030fdc818a77d26bd30f7edb8633dc2f1087d) expert_cache: rebuild layer_next_ in open_sized; per-layer admission read out of slot 0 - [`4b07e90`](https://github.com/Niko1221/Strata/commit/4b07e905ace3877b0fd9a6524884d2dedb70e25f) mtp: the drafter's gr_read scratch runs on its own device in roles mode ### 📊 Changes **12 files changed** (+1479 additions, -36 deletions) <details> <summary>View changed files</summary> ➕ `docs/HETERO_MGPU_PLAN.md` (+597 -0) 📝 `include/strata/core/device.hpp` (+38 -0) 📝 `include/strata/core/mtp.hpp` (+23 -2) 📝 `include/strata/core/verify.hpp` (+11 -0) 📝 `src/core/conversation_snapshot.cpp` (+14 -0) 📝 `src/core/device.cu` (+89 -0) 📝 `src/core/device_main.cpp` (+34 -0) 📝 `src/core/mtp.cpp` (+214 -12) 📝 `src/core/verify.cpp` (+16 -1) 📝 `src/kernels/cuda/qsa_select.cu` (+7 -12) 📝 `src/program/generate.cpp` (+229 -9) ➕ `tools/hetero-test.sh` (+207 -0) </details> ### 📄 Description Closes/addresses discussion in #490. ## What this adds **Heterogeneous multi-GPU roles** — a different way to use two (not necessarily equal) GPUs than `--split-device`: the whole model (KV + verify) stays on the **main** GPU, only the **MTP draft head** runs on the second one. No P2P required, no layer split. The drafter is tiny next to the main model, so moving it off the main GPU returns its VRAM (~870 MiB + the draft head) to the main GPU's expert cache, while the drafter gets its own device entirely. New (all opt-in, **no behavior change when none are passed**): - `--main-device N --draft-device M` — explicit role placement; both directions work. The drafter's K/V, ring restore, gr workspace and graph captures are re-homed on the draft device; the verify window's hand-off rides a mapped host mirror, so no peer access is ever assumed; - `--auto-roles` — pick the roles from the capability records (`main` = device 0, draft = the best free remaining; refuses when < 2 CUDA devices or no `--mtp` is loaded); - `--draft-prefill-parallel` — the prompt fill queues and overlaps the decode instead of blocking it; - `--draft-chain-batch` — the draft chain's step graphs launch back to back with ONE wait per round instead of one per step (drafting 4.63 → 4.14 ms/round on the source rig, ~11 %); - `per-device DeviceCaps` discovery + the peer matrix in `strata-device`, and a per-role VRAM report after binding, so the trade is visible at start. ## The discipline: placement never changes the output, only the measured time All claims are on greedy token streams compared bit-exactly across repeated runs, compared **under equal expert residency** (equal auto slot counts, or a forced `--expert-cache N` shared by both runs) — because when the roles split, the drafter's VRAM frees up on the main GPU, the expert cache there grows, and a different expert-cache size legitimately decodes differently today. Under that rule the roles 0→1, 1→0, reversed, batched and pipelined all reproduce the same-device stream token for token. The plan, the measurements and the step record live in `docs/HETERO_MGPU_PLAN.md` (sections 10–12 hold the Fase-7/8/9/12/13 numbers and the gate rule). ## How to reproduce on your own rig ``` tools/hetero-test.sh <build-dir> "<your model-load flags>" /tmp/het 60 2 ``` runs the variant matrix (single- and two-GPU rigs; the harness detects the rig itself), extracts the greedy stream md5s, picks bit-exactness references by residency, and writes `/tmp/het/report.md` — the full run table, verdicts and the residency-dividend note. Any report pasted into #490 is exactly the evidence this feature still needs from non-Pascal rigs. Source-rig validation (2× GTX 1080 Ti, cc 6.1, 125B Q2_0 pack, 16 runs): **20 PASS / 0 FAIL**, stream md5 clusters by residency (V0=V1f=V2 `c1c2827c7571`; V1=V3–V6 `dc295284ab30`), V1f vs V0 bit-identical — the placement-exactness proof. ## Review notes - This PR deliberately carries **no sm_61/Pascal build work** — it was developed on that rig (and the full branch is on my fork as `hetero-roles`), but only the role/flags/harness features are proposed here. - Default-off everywhere; the existing `--split-device` path is untouched. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:02:13 +07:00
Sign in to join this conversation.
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
Niko1221/Strata#2666
No description provided.