[Engine] gfx906 (Instinct MI50 32 GB) & UD-IQ4_XS: sub-8 Q5_0 down kernel, 1-dp4a i-quant sign negation, and multi-row wave64 MMVQ (+20% c1 / +18.5% c4)

オープン
#7,271 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 4 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
1/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
cpp

調査の方向性

The issue reports kernel work in iq_kernels.cu and native_mmvq.cu, with three follow-up pull requests (#7272, #7273, and #7274) covering the changes. Read those pull requests and their benchmarks first; this issue’s work is already split into active implementation efforts. Completion is described by the reported MI50 kernel timings, throughput gains, and 128K needle checks.

索引モデルが issue の本文から書いたものです。

説明

Problem and result

On Qwen3.8-Flash-Next (UD-IQ4_XS, 131,072 context) served on an AMD Instinct MI50 32 GB (gfx906, 100 W power cap, ROCm 7.2.4), profiling the verify and batch-4 decode windows showed three kernel bottlenecks and one host-exchange bottleneck:

  1. Q5_0 down projections (31 of 48 layers in UD-IQ4_XS) had no Split<6> / S27<6> trait and were excluded from lds_down_ok (native_down_lds_kernel). Even under STRATA_EXP_MODE=7 or 8, 31 of 48 layers fell back to native_down_kernel<6>, which neither stages hq in LDS nor reuses unpacked weights across verify/batch tokens (166 GB/s at T=1, dropping to 58 GB/s at T=4).
  2. gfx906 has no hardware byte-SIMD instructions (__vcmpne4, __vsub4). strata_hip.h emulates each call with ~12 word operations. While DotG<*, 1> (modes 5–7) avoided this via nib_mask + two dp4a calls, Split<16/17/18/21/22> (used by STRATA_EXP_MODE=8's native_gu_fused_kernel and native_gu_multi_kernel) and vec_dot_iq2/3_* still used the emulated __vcmpne4/__vsub4 path whenever STAGE_GRID was false or not applicable (IQ2_S layer 8 gate/up ran at 158.8 us / 106 GB/s at T=1).
  3. native_mmvq_wave_kernel<F, NCOLS, R> (gfx906 wave64 dense GEMV) was hardcoded to R = 1 in wave_launch_n, reading activation blocks from L1/LDS once per single row and launching 4x more wavefronts than R = 4 or 2x more than R = 2.

With the bit-exact kernel changes in iq_kernels.cu and native_mmvq.cu plus STRATA_EXCHANGE_ROTATE=1 and STRATA_EXP_MODE=8:

  • Q5_0 down (native_expert_bench, Layer 0, G=16, Mode 8):
    • T=1: 107.5–128.8 us -> 75.1 us (240 GB/s)
    • T=2: 154.9–172.3 us -> 81.6 us (221 GB/s)
    • T=4: 218.8–308.2 us -> 94.1 us (191 GB/s, up from 58–82 GB/s)
  • IQ4_NL down (row_dot2_40_sub8 at cn > 1, Layer 7, G=16, Mode 8):
    • T=2: 68.9 us -> 60.4 us (244 GB/s)
    • T=4: 84.2 us -> 70.1 us (210 GB/s)
  • IQ2_S gate/up (Layer 8, G=16, Mode 8, 1-dp4a carry-free sign negation):
    • T=1: 158.8 us -> 89.1 us (189 GB/s, -43.9%)
  • End-to-end throughput on MI50 32 GB (100 W cap, 131K context, --batch 4 --vram-reserve-mib 576 --prefill 8192):
    • Single-stream decode (c1, 6x512 tokens, temp 0.6, thinking on): 34.5 -> 41.59 tok/s (+20.6%)
    • 4-client aggregate decode (c4, 3 rounds x 4x512 tokens): 38.6 -> 45.73 tok/s (+18.5%)
    • 8-client aggregate decode (c8, 3 rounds x 8x512 tokens): 38.65 -> 48.32 tok/s (+25.0%)
    • Greedy code probe (probe.py, 6x256 tokens, temp 0, thinking off): 41.8 -> 50.75 tok/s (+21.4%)
    • 128K needles at 50% (65,535 tokens) and 93.75% (122,862 tokens): 3/3 exact, peak VRAM 31.43–31.46 GiB (under 31.5 GiB guardrail).

We split the changes into three small PRs:

  1. #7272 [Engine] gfx906: add missing P2P hip_compat macros
  2. #7273 [Engine] iq_kernels: sub-8 Q5_0 down, dual-row IQ4_NL down, and 1-dp4a gfx906 i-quant signs
  3. #7274 [Engine] native_mmvq: opt-in multi-row wave64 GEMV (STRATA_MMVQ_WAVE_R) on gfx906
主要言語
C++
スター
11.6k
フォーク
1k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Niko1221/Strata のほかの issue

Niko1221/Strata の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。