[PR #5120] [CLOSED] [Engine] cpu/experts: the 512-bit VNNI rows on a CPU without AVX-512-VBMI #5315

Closed
opened 2026-11-07 16:34:17 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/5120
Author: @buserror
Created: 11/3/2026
Status: ❌ Closed

Base: main ← Head: pr/avx512-vnni-tier


📝 Commits (1)

  • 2775063 cpu/experts: the 512-bit VNNI rows on a CPU without AVX-512-VBMI

📊 Changes

6 files changed (+125 additions, -11 deletions)

View changed files

📝 include/strata/kernels/cpu/expert_layout.hpp (+10 -0)
📝 src/kernels/cpu/expert.cpp (+49 -1)
📝 src/kernels/cpu/expert_layout.cpp (+60 -4)
📝 src/kernels/cpu/native_expert.cpp (+2 -2)
📝 src/kernels/native_expert_parity.cpp (+2 -2)
📝 src/program/generate.cpp (+2 -2)

📄 Description

Problem and result

A Cascade Lake Xeon (AVX-512 F/BW/VL/DQ/VNNI, no VBMI) was treated as having no AVX-512 by
cpu_avx512_ok(), because that probe required every AVX-512 feature including VBMI. A native pack's
Q2_0 rows therefore used the AVX-2 fallback and the q8 activation quantizer its AVX-2 form, even
though only the q2 unpack's VPMULTISHIFTQB needs VBMI. After this change the same CPU selects the
512-bit VNNI rows and the q2 row dot, with a byte-for-byte substitute unpack for the multishift.

None: a focused ISA-usability fix. No default changes; the new tier only replaces a fallback.

Approach

  • cpu_vnni_ok() = AVX-512F + BW + VL + VNNI; cpu_vbmi_ok() = F + VL + VBMI; q2_rows_512_ok()
    says whether the q2 row dot may run (VNNI and not STRATA_CPU_YMM=1).
  • The q2 unpack uses a bit-shifting substitute when VBMI is absent: VPERMW source select + VPSRLVD +
    mask, four rounds in order, byte for byte the multishift's result. STRATA_CPU_YMM=1 still
    selects the 256-bit rows, whose unpack keeps the multishift.
  • act_quant_any uses cpu_vnni_ok; the IQ-512 gate in native_expert.cpp uses
    cpu_avx512bw_ok (F/BW/VL/DQ), which is what those kernels need. The legacy/parity paths use the
    same probe.
  • The CPUID bits are explicit: VBMI is leaf 7.0 ECX bit 1, not EBX bit 16 (F); VNNI also needs BW
    (EBX bit 30). Reading F for VBMI would have chosen the multishift on this CPU.
  • The canonical Q2_0 pack still requires VBMI in cpu_require_expert_support; this tier is for
    native packs whose Q2_0 layers have an AVX-2 rung. No CUDA/HIP/SYCL path changed.

Validation

Passed:

  • cmake ... -DCMAKE_CUDA_ARCHITECTURES=70 ... && ninja -C build strata on this branch (52346f0b),
    2x V100-PCIE-32GB, CUDA 12.9, gcc-12: builds.
  • A linked probe against the built libstrata_kernels_cpu.a on the affected Cascade Lake prints:
    avx512_ok=0 avx512bw_ok=1 vnni_ok=1 vbmi_ok=0 q2_rows_512_ok=1.

Failed:

  • None observed.

Not run:

  • A canonical Q2_0 pack end-to-end: the pack on this machine is the native UD-Q4_K_XL, and the
    canonical refusal is intentionally unchanged. The linked probe is the direct check of the tier.
  • A controlled before/after decode measurement: the end-to-end change is inside the session spread on
    this machine (the CPU experts are a small share of the decode); no speed claim is made.
  • CUDA/HIP/SYCL builds other than the 2x V100 CUDA build; the change is CPU-only.
  • An automated test for the CPU probes: they read this CPU's CPUID; the linked probe on the affected
    CPU is the regression check. A test that only restates the bit extraction would not cover hardware.

Limits

  • The canonical Q2_0 pack still needs VBMI; this only unpins native packs.
  • The substitute unpack is chosen per process; no runtime toggle.
  • The tier is an ISA-usability change, not a measured monoclock gain on this machine.

🔄 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/5120 **Author:** [@buserror](https://github.com/buserror) **Created:** 11/3/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/avx512-vnni-tier` --- ### 📝 Commits (1) - [`2775063`](https://github.com/Niko1221/Strata/commit/2775063a8c1bc6cb424099e28b10940f1791f8cd) cpu/experts: the 512-bit VNNI rows on a CPU without AVX-512-VBMI ### 📊 Changes **6 files changed** (+125 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/kernels/cpu/expert_layout.hpp` (+10 -0) 📝 `src/kernels/cpu/expert.cpp` (+49 -1) 📝 `src/kernels/cpu/expert_layout.cpp` (+60 -4) 📝 `src/kernels/cpu/native_expert.cpp` (+2 -2) 📝 `src/kernels/native_expert_parity.cpp` (+2 -2) 📝 `src/program/generate.cpp` (+2 -2) </details> ### 📄 Description ## Problem and result A Cascade Lake Xeon (AVX-512 F/BW/VL/DQ/VNNI, no VBMI) was treated as having no AVX-512 by `cpu_avx512_ok()`, because that probe required every AVX-512 feature including VBMI. A native pack's Q2_0 rows therefore used the AVX-2 fallback and the q8 activation quantizer its AVX-2 form, even though only the q2 unpack's VPMULTISHIFTQB needs VBMI. After this change the same CPU selects the 512-bit VNNI rows and the q2 row dot, with a byte-for-byte substitute unpack for the multishift. ## Related discussion None: a focused ISA-usability fix. No default changes; the new tier only replaces a fallback. ## Approach - `cpu_vnni_ok()` = AVX-512F + BW + VL + VNNI; `cpu_vbmi_ok()` = F + VL + VBMI; `q2_rows_512_ok()` says whether the q2 row dot may run (VNNI and not `STRATA_CPU_YMM=1`). - The q2 unpack uses a bit-shifting substitute when VBMI is absent: VPERMW source select + VPSRLVD + mask, four rounds in order, byte for byte the multishift's result. `STRATA_CPU_YMM=1` still selects the 256-bit rows, whose unpack keeps the multishift. - `act_quant_any` uses `cpu_vnni_ok`; the IQ-512 gate in `native_expert.cpp` uses `cpu_avx512bw_ok` (F/BW/VL/DQ), which is what those kernels need. The legacy/parity paths use the same probe. - The CPUID bits are explicit: VBMI is leaf 7.0 ECX bit 1, not EBX bit 16 (F); VNNI also needs BW (EBX bit 30). Reading F for VBMI would have chosen the multishift on this CPU. - The canonical Q2_0 pack still requires VBMI in `cpu_require_expert_support`; this tier is for native packs whose Q2_0 layers have an AVX-2 rung. No CUDA/HIP/SYCL path changed. ## Validation **Passed:** - `cmake ... -DCMAKE_CUDA_ARCHITECTURES=70 ... && ninja -C build strata` on this branch (52346f0b), 2x V100-PCIE-32GB, CUDA 12.9, gcc-12: builds. - A linked probe against the built `libstrata_kernels_cpu.a` on the affected Cascade Lake prints: `avx512_ok=0 avx512bw_ok=1 vnni_ok=1 vbmi_ok=0 q2_rows_512_ok=1`. **Failed:** - None observed. **Not run:** - A canonical Q2_0 pack end-to-end: the pack on this machine is the native UD-Q4_K_XL, and the canonical refusal is intentionally unchanged. The linked probe is the direct check of the tier. - A controlled before/after decode measurement: the end-to-end change is inside the session spread on this machine (the CPU experts are a small share of the decode); no speed claim is made. - CUDA/HIP/SYCL builds other than the 2x V100 CUDA build; the change is CPU-only. - An automated test for the CPU probes: they read this CPU's CPUID; the linked probe on the affected CPU is the regression check. A test that only restates the bit extraction would not cover hardware. ## Limits - The canonical Q2_0 pack still needs VBMI; this only unpins native packs. - The substitute unpack is chosen per process; no runtime toggle. - The tier is an ISA-usability change, not a measured monoclock gain on this machine. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 16:34:17 +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#5315
No description provided.