[PR #353] [CLOSED] NVFP4 routed experts on 0.1.35 (experimental): 120a only for the W4A4 unit (rebase of #292) #2592

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/353
Author: @sergqwer
Created: 10/1/2026
Status: ❌ Closed

Base: main ← Head: pr/nvfp4-on-0.1.31


📝 Commits (1)

  • 78c5705 NVFP4 routed experts: converter, pack, decode, prompt path, AVX-512 CPU rows

📊 Changes

24 files changed (+2101 additions, -59 deletions)

View changed files

📝 CMakeLists.txt (+30 -3)
➕ docs/NVFP4.md (+147 -0)
📝 include/strata/artifact/gguf_reader.hpp (+4 -0)
📝 include/strata/kernels/cpu/native_expert.hpp (+7 -0)
➕ include/strata/kernels/cpu/nvfp4_avx512.hpp (+28 -0)
📝 include/strata/kernels/iq_kernels.hpp (+8 -4)
📝 include/strata/prefill/kernels.hpp (+1 -1)
📝 include/strata/prefill/moe_mmq.hpp (+30 -4)
📝 src/kernels/cpu/native_expert.cpp (+38 -3)
➕ src/kernels/cpu/nvfp4_avx512.cpp (+186 -0)
➕ src/kernels/cpu/nvfp4_avx512_parity.cpp (+320 -0)
📝 src/kernels/cuda/iq_kernels.cu (+93 -14)
➕ src/kernels/nvfp4_expert_gpu_parity.cpp (+107 -0)
📝 src/prefill/kernels.cu (+9 -4)
➕ src/prefill/mmq_nvfp4_parity.cpp (+350 -0)
➕ src/prefill/mmq_nvfp4_w4a4.cu (+53 -0)
➕ src/prefill/mmq_nvfp4_w4a8.cu (+24 -0)
📝 src/prefill/moe_mmq.cu (+149 -9)
📝 src/prefill/prefill.cpp (+56 -12)
📝 src/program/generate.cpp (+6 -1)

...and 4 more files

📄 Description

The rebase asked for in #292, for 0.1.33 as experimental. One commit on 0.1.31 (9259cad).

What changed against #292

  • Rebased on 0.1.31.
    • NVFP4 is type 40 in the per-role format lists (STRATA_GU_FMTS / STRATA_D_FMTS / STRATA_MMVQ_FMTS), next to Q4_K/Q5_K/Q5_1/Q8_0. It goes through the same launch_* dispatch.
    • 0.1.31's dq_q8_0 serves the Q8_0 token embedding as well; #292 had its own copy, which is gone.
    • tools/iq_pack.py: expert_layout() gives NVFP4 blobs their 16-byte scale tail. An NVFP4 pack always writes experts.bin, because the GGUF has no tails and so the in-place GGUF read does not apply.
  • 120a is limited to the W4A4 unit. CMake no longer rewrites CMAKE_CUDA_ARCHITECTURES.
    • src/prefill/mmq_nvfp4_w4a4.cu is the only unit built with 12x -> 12xa, in its own static library strata_mmq_w4a4. It holds the FP4 x FP4 kernel, its FP4 activation quantizer and a probe, with their symbols renamed so they cannot fold with the plain-arch copies.
    • Everything else, the default W4A8 path included, keeps the architectures as given. strata.exe from -DCMAKE_CUDA_ARCHITECTURES=120 holds 55 sm_120 cubins and 1 sm_120a.
    • When the probe has no image for the running card (another architecture, or sm_121 against a 120a build), STRATA_PREFILL_NVFP4=w4a4 falls back to W4A8 with a note.
    • The stock mmq-instance-nvfp4.cu is no longer built.
    • HIP builds never reference the W4A4 unit.

Checked on this rebase (RTX 5090, Windows)

  • Parity tools:
    • nvfp4_expert_gpu_parity: decode experts 1.09-1.16%.
    • nvfp4_avx512_parity: OK.
    • mmq_nvfp4_parity: W4A8 0.53%, W4A4 8.6%. These are bit for bit the numbers of the old 120a-everywhere build.
  • IQ2_XS: 128 greedy tokens identical to 0.1.31 main and to 0.1.29.
  • NVFP4 pack against the 0.1.29-based #292 build, same --expert-cache size: identical tokens on a 24-token prompt and on an 8K prompt, both in W4A8 and in W4A4. Prefill on 8K is 4,231 tok/s in W4A8 and 4,583 in W4A4; decode is the same.
  • --expert-cache auto gives slightly different slot counts on 0.1.31 (8,498 against 8,472 on 0.1.29). That changes which misses the CPU pool computes. For NVFP4 the AVX-512 rows equal the GPU's only to a relative tolerance (other float summation order), not bit for bit. The identity gate should therefore compare NVFP4 at a fixed --expert-cache N.
  • Run-to-run variation: once in five runs, an NVFP4 run diverged from the others late in a low-confidence stretch. This is presumably the same effect: the CPU/GPU split of the misses depends on timing. The IQ formats are unaffected, since their CPU rows are bit-exact.

Not run here: Linux, AMD (HIP), sm_121.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VZy1yKaDDiA8a7svdwaHio


🔄 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/353 **Author:** [@sergqwer](https://github.com/sergqwer) **Created:** 10/1/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/nvfp4-on-0.1.31` --- ### 📝 Commits (1) - [`78c5705`](https://github.com/Niko1221/Strata/commit/78c57053512695d6bdd3a8857a64d5b605d2a20c) NVFP4 routed experts: converter, pack, decode, prompt path, AVX-512 CPU rows ### 📊 Changes **24 files changed** (+2101 additions, -59 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+30 -3) ➕ `docs/NVFP4.md` (+147 -0) 📝 `include/strata/artifact/gguf_reader.hpp` (+4 -0) 📝 `include/strata/kernels/cpu/native_expert.hpp` (+7 -0) ➕ `include/strata/kernels/cpu/nvfp4_avx512.hpp` (+28 -0) 📝 `include/strata/kernels/iq_kernels.hpp` (+8 -4) 📝 `include/strata/prefill/kernels.hpp` (+1 -1) 📝 `include/strata/prefill/moe_mmq.hpp` (+30 -4) 📝 `src/kernels/cpu/native_expert.cpp` (+38 -3) ➕ `src/kernels/cpu/nvfp4_avx512.cpp` (+186 -0) ➕ `src/kernels/cpu/nvfp4_avx512_parity.cpp` (+320 -0) 📝 `src/kernels/cuda/iq_kernels.cu` (+93 -14) ➕ `src/kernels/nvfp4_expert_gpu_parity.cpp` (+107 -0) 📝 `src/prefill/kernels.cu` (+9 -4) ➕ `src/prefill/mmq_nvfp4_parity.cpp` (+350 -0) ➕ `src/prefill/mmq_nvfp4_w4a4.cu` (+53 -0) ➕ `src/prefill/mmq_nvfp4_w4a8.cu` (+24 -0) 📝 `src/prefill/moe_mmq.cu` (+149 -9) 📝 `src/prefill/prefill.cpp` (+56 -12) 📝 `src/program/generate.cpp` (+6 -1) _...and 4 more files_ </details> ### 📄 Description The rebase asked for in #292, for 0.1.33 as experimental. One commit on 0.1.31 (9259cad). ## What changed against #292 - **Rebased on 0.1.31.** - NVFP4 is type 40 in the per-role format lists (`STRATA_GU_FMTS` / `STRATA_D_FMTS` / `STRATA_MMVQ_FMTS`), next to Q4_K/Q5_K/Q5_1/Q8_0. It goes through the same `launch_*` dispatch. - 0.1.31's `dq_q8_0` serves the Q8_0 token embedding as well; #292 had its own copy, which is gone. - `tools/iq_pack.py`: `expert_layout()` gives NVFP4 blobs their 16-byte scale tail. An NVFP4 pack always writes `experts.bin`, because the GGUF has no tails and so the in-place GGUF read does not apply. - **120a is limited to the W4A4 unit.** CMake no longer rewrites `CMAKE_CUDA_ARCHITECTURES`. - `src/prefill/mmq_nvfp4_w4a4.cu` is the only unit built with `12x` -> `12xa`, in its own static library `strata_mmq_w4a4`. It holds the FP4 x FP4 kernel, its FP4 activation quantizer and a probe, with their symbols renamed so they cannot fold with the plain-arch copies. - Everything else, the default W4A8 path included, keeps the architectures as given. `strata.exe` from `-DCMAKE_CUDA_ARCHITECTURES=120` holds 55 sm_120 cubins and 1 sm_120a. - When the probe has no image for the running card (another architecture, or sm_121 against a 120a build), `STRATA_PREFILL_NVFP4=w4a4` falls back to W4A8 with a note. - The stock `mmq-instance-nvfp4.cu` is no longer built. - HIP builds never reference the W4A4 unit. ## Checked on this rebase (RTX 5090, Windows) - **Parity tools:** - `nvfp4_expert_gpu_parity`: decode experts 1.09-1.16%. - `nvfp4_avx512_parity`: OK. - `mmq_nvfp4_parity`: W4A8 0.53%, W4A4 8.6%. These are bit for bit the numbers of the old 120a-everywhere build. - **IQ2_XS:** 128 greedy tokens identical to 0.1.31 main and to 0.1.29. - **NVFP4 pack against the 0.1.29-based #292 build, same `--expert-cache` size:** identical tokens on a 24-token prompt and on an 8K prompt, both in W4A8 and in W4A4. Prefill on 8K is 4,231 tok/s in W4A8 and 4,583 in W4A4; decode is the same. - **`--expert-cache auto` gives slightly different slot counts on 0.1.31** (8,498 against 8,472 on 0.1.29). That changes which misses the CPU pool computes. For NVFP4 the AVX-512 rows equal the GPU's only to a relative tolerance (other float summation order), not bit for bit. The identity gate should therefore compare NVFP4 at a fixed `--expert-cache N`. - **Run-to-run variation:** once in five runs, an NVFP4 run diverged from the others late in a low-confidence stretch. This is presumably the same effect: the CPU/GPU split of the misses depends on timing. The IQ formats are unaffected, since their CPU rows are bit-exact. Not run here: Linux, AMD (HIP), sm_121. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01VZy1yKaDDiA8a7svdwaHio --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:01:36 +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#2592
No description provided.