[PR #2995] [CLOSED] [Engine] prefill: per-expert NVFP4 scales on the peer-prefill route (opt-in) #4387

Closed
opened 2026-11-07 15:35:21 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2995
Author: @florian862-art
Created: 10/18/2026
Status: ❌ Closed

Base: main ← Head: f-nvfp4-peer


📝 Commits (3)

  • 70d6f94 prefill: wire per-expert NVFP4 scales through the peer-prefill route (config C)
  • 0b69db5 prefill: opt-in sums mode on the P2P peer route (STRATA_PF_PEER_SUMS_P2P)
  • 17f93f4 docs: generation-path P2P micro-bench - the direct host ring wins at every decode row size (10 KB..2.6 MB), 1.7-3x

📊 Changes

3 files changed (+450 additions, -19 deletions)

View changed files

➕ src/prefill/README-nvfp4-peer.md (+350 -0)
📝 src/prefill/prefill.cpp (+96 -18)
📝 src/program/generate.cpp (+4 -1)

📄 Description

Problem and result

On a --peer-device setup the peer GPU computes its experts' MoE rows for every prompt chunk, but on NVFP4 packs its MMQ products ran without any per-expert scales (grp_tail null, no s_gate/s_up, no s_down, no y_scale) - so every peer-computed row was numerically wrong and set_peer refused the combination. Before: the peer-prefill route was unusable on NVFP4; opening it by env alone recites a long prompt but cannot recall it (silent KV corruption, 0 non-finite). After this change, with STRATA_PF_PEER_NVFP4=1 the route carries the scales end to end: a cold ~25k-token recall prompt finds both needles, 0 non-finite logits, and prefill runs ~2.7k tok/s vs ~2.4k without the peer tier (+12.5 % measured, decode +27 %).

none - focused bug fix, opt-in behind an env gate, no default path touched.

Approach

gather_native carries the tail scales, swiglu_scaled applies s_gate/s_up, scale_down_rows scales Dm rows in place on both GPUs (this also fixes the sums-mode path where s_down was dropped and row_sd read OOB behind the 31 non-finite logits seen earlier), and y_scale feeds the w4a4 dequant. The whole route stays behind STRATA_PF_PEER_NVFP4=1 (prefill.cpp refusal gate + generate.cpp rows==0 skip), so nothing changes unless the env is set. A second, separate and droppable commit adds STRATA_PF_PEER_SUMS_P2P=1 (sums over the P2P link): correct but slower than the host route on this box (5.5 vs 14.3 GB/s), documented in src/prefill/README-nvfp4-peer.md for boxes where P2P beats PCIe. Design + measurement notes live in that README.

Validation

Revision tested: branch head e7580cca, rebased onto main @ cbfd5b92 (v0.2.1.3). Environment: 2x RTX 5070 Ti 16 GB (PCIe, no NVLink), Ubuntu, kernel 7.0.0-38, driver 595.99.02, CUDA build via CMake/Ninja.

Passed:

  • cmake --build build -j4 on v0.2.1.3: 331/331 targets, 0 errors (binary md5 1059259999e587d492da5272e8a840f4).
  • recall-test.py (cold ~25k-token prompt, two needles, greedy): both needles found, 0 non-finite - the gate that the earlier scale-less route failed.
  • pfmeasure.py (unique ~21k-token prompts, max_tokens=1): median ~2.7k tok/s, GPU1 rx ~20 GB/s confirms the peer streams; route banner names "no P2P: through mapped host memory in FP16, one weighted sum per token back". Exact per-run numbers are posted as a comment on this PR.

Failed: none observed on this revision.

Not run: HIP / SYCL / Metal builds (no hardware available); the route is CUDA-only code behind the same env gate. Non-NVFP4 packs: untouched code path, not re-validated. Multi-GPU topologies other than this PCIe pair not tested.

Limits

Opt-in only (STRATA_PF_PEER_NVFP4=1); performance numbers are for this PCIe-only box and will differ on NVLink systems. The sums-P2P commit is independently droppable. The P2P-vs-host route analysis and the generation-path micro-bench in the README apply to consumer GeForce BAR1 P2P.


🔄 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/2995 **Author:** [@florian862-art](https://github.com/florian862-art) **Created:** 10/18/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `f-nvfp4-peer` --- ### 📝 Commits (3) - [`70d6f94`](https://github.com/Niko1221/Strata/commit/70d6f941272e78561b10e6e37949988f81e0e91c) prefill: wire per-expert NVFP4 scales through the peer-prefill route (config C) - [`0b69db5`](https://github.com/Niko1221/Strata/commit/0b69db536950da184ebc1b0a687bea37e615195e) prefill: opt-in sums mode on the P2P peer route (STRATA_PF_PEER_SUMS_P2P) - [`17f93f4`](https://github.com/Niko1221/Strata/commit/17f93f4f1ac1bf95d88b2a5961f48ba6bd771d04) docs: generation-path P2P micro-bench - the direct host ring wins at every decode row size (10 KB..2.6 MB), 1.7-3x ### 📊 Changes **3 files changed** (+450 additions, -19 deletions) <details> <summary>View changed files</summary> ➕ `src/prefill/README-nvfp4-peer.md` (+350 -0) 📝 `src/prefill/prefill.cpp` (+96 -18) 📝 `src/program/generate.cpp` (+4 -1) </details> ### 📄 Description ## Problem and result On a `--peer-device` setup the peer GPU computes its experts' MoE rows for every prompt chunk, but on NVFP4 packs its MMQ products ran **without any per-expert scales** (`grp_tail` null, no `s_gate/s_up`, no `s_down`, no `y_scale`) - so every peer-computed row was numerically wrong and `set_peer` refused the combination. Before: the peer-prefill route was unusable on NVFP4; opening it by env alone recites a long prompt but cannot recall it (silent KV corruption, 0 non-finite). After this change, with `STRATA_PF_PEER_NVFP4=1` the route carries the scales end to end: a cold ~25k-token recall prompt finds both needles, 0 non-finite logits, and prefill runs ~2.7k tok/s vs ~2.4k without the peer tier (+12.5 % measured, decode +27 %). ## Related discussion none - focused bug fix, opt-in behind an env gate, no default path touched. ## Approach `gather_native` carries the tail scales, `swiglu_scaled` applies `s_gate/s_up`, `scale_down_rows` scales Dm rows in place on both GPUs (this also fixes the sums-mode path where `s_down` was dropped and `row_sd` read OOB behind the 31 non-finite logits seen earlier), and `y_scale` feeds the w4a4 dequant. The whole route stays behind `STRATA_PF_PEER_NVFP4=1` (prefill.cpp refusal gate + generate.cpp rows==0 skip), so nothing changes unless the env is set. A second, separate and droppable commit adds `STRATA_PF_PEER_SUMS_P2P=1` (sums over the P2P link): correct but slower than the host route on this box (5.5 vs 14.3 GB/s), documented in `src/prefill/README-nvfp4-peer.md` for boxes where P2P beats PCIe. Design + measurement notes live in that README. ## Validation Revision tested: branch head `e7580cca`, rebased onto main @ `cbfd5b92` (**v0.2.1.3**). Environment: 2x RTX 5070 Ti 16 GB (PCIe, no NVLink), Ubuntu, kernel 7.0.0-38, driver 595.99.02, CUDA build via CMake/Ninja. **Passed:** - `cmake --build build -j4` on v0.2.1.3: 331/331 targets, 0 errors (binary md5 `1059259999e587d492da5272e8a840f4`). - `recall-test.py` (cold ~25k-token prompt, two needles, greedy): both needles found, 0 non-finite - the gate that the earlier scale-less route failed. - `pfmeasure.py` (unique ~21k-token prompts, max_tokens=1): median ~2.7k tok/s, GPU1 rx ~20 GB/s confirms the peer streams; route banner names "no P2P: through mapped host memory in FP16, one weighted sum per token back". Exact per-run numbers are posted as a comment on this PR. **Failed:** none observed on this revision. **Not run:** HIP / SYCL / Metal builds (no hardware available); the route is CUDA-only code behind the same env gate. Non-NVFP4 packs: untouched code path, not re-validated. Multi-GPU topologies other than this PCIe pair not tested. ## Limits Opt-in only (`STRATA_PF_PEER_NVFP4=1`); performance numbers are for this PCIe-only box and will differ on NVLink systems. The sums-P2P commit is independently droppable. The P2P-vs-host route analysis and the generation-path micro-bench in the README apply to consumer GeForce BAR1 P2P. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:35:21 +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#4387
No description provided.