mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 07:48:45 +00:00
prefill: STRATA_PF_FUSED_Q6K=1 on gfx12 - Q6_K gate/up + Q8_0 down on the fused kernels (HIP, opt-in)
UD-Q6_K_XL's 47 layers (and UD-Q5_K_XL's one Q6_K layer) have a Q6_K gate/up with a Q8_0 down. On gfx1200 / gfx1201 they
ran on MMQ (the K-quant library, STRATA_MMQ_KQ=1). STRATA_PF_FUSED_Q6K, CUDA's switch for the same layers, now means the
same there: a Q6_K gate/up with a Q8_0 down takes native_w11_kernel's new Q6_K gate/up instance.
Kernel: none edited. load_unit / convert<T_Q6_K> are the shared decode (CUDA's bits), 256-value superblocks with an int8
scale per 16 values, native_w11's existing per-16 path; the unit / sub lambdas need no change. Host (HIP only):
q6k_hip_requested(), gu_covered and d_covered_on take the pair on gfx12 when it is set, native_supported pairs a Q6_K
gate/up with a Q8_0 down only, experts_native launches native_w11_kernel<T_Q6_K, true> (the plain launch). Off by
default; gfx11 unchanged (the instance is compiled for gfx1151 but no host rule reaches it there).
Test: hip_prefill_fused_iq_q6k (--only="Q6_K + Q8_0" --edge --no-timing, STRATA_PF_FUSED_Q6K=1, STRATA_MMQ_KQ=1); the
trellis skip rule of the test also skips the Q6_K pair on a card that is not gfx12. Settings register: STRATA_PF_FUSED_Q6K
lists the HIP read (note marked [DRAFT], status research).
R9700 (p620, gfx1201), base f3608ce31 vs this tree, same folders and flags:
- build commands identical, warnings 4,454 / 4,454
- device code: one new function (native_w11_kernel<Q6_K, true>) in the engine (3,936 -> 3,937), moe_fused_iq.cu.o
(91 -> 92) and hip_prefill_fused_iq (1,349 -> 1,350); hip_prefill_decode_golden identical; 38 existing functions differ
in 62 lines, all 62 are the PC-relative address constants of a table, none other
- new instance: 227 VGPRs, 0 scratch instructions on gfx1201 (no spill); gfx1151: 256 VGPRs, 7 scratch instructions
(not reached by any host rule)
- decode digests 136 / 136
- Q6K entry PASS: fused vs the int8 model <= 7.1e-5 rel RMS, fused vs MMQ <= 3.2e-4 (limit 1e-3), fused and MMQ the same
distance from FP32 (1.4-1.6e-2); not covered without the switch or under Q8GU alone (rc 1); the Q8GU and Q8D entries
still PASS
- default run: all 12 output hashes equal the base's; hashes repeat over two runs
- one layer, fused / MMQ path: 3.32x / 2.74x / 2.30x at 2,048 / 3,584 / 8,192 tokens
- CUDA side (l620, RTX PRO 5000 sm_120, CUDA 13.2, same folder and flags): compile command identical; moe_fused_iq.cu.o
SASS identical (70 functions), decode test SASS identical (20), prefill_fused_iq_test SASS identical (1,209); decode
digests 136 / 136; the CUDA Q8GU and Q6K entries pass; warnings 6 / 6
This commit is contained in:
1 parent
f3608ce31c
commit
e14d4e3708
4 files changed
+33
-7
No files matched your search
@@ -110,6 +110,9 @@ macro(strata_hip_mmq)
|
||||
# STRATA_PF_FUSED_Q8GU=1 (gfx12, opt-in): the Q8_0 set's Q8_0 / Q8_0 pair (UD-Q6_K_XL's one Q8_0 layer), as CUDA's _q8gu; --no-kq: the K-quant switch stays unset
|
||||
add_test(NAME hip_prefill_fused_iq_q8gu COMMAND hip_prefill_fused_iq "--only=Q8_0 / Q8_0" --edge --no-timing --no-kq)
|
||||
set_tests_properties(hip_prefill_fused_iq_q8gu PROPERTIES SKIP_RETURN_CODE 77 TIMEOUT 600 ENVIRONMENT "STRATA_PF_FUSED_Q8GU=1")
|
||||
# STRATA_PF_FUSED_Q6K=1 (gfx12, opt-in): UD-Q6_K_XL's Q6_K gate/up + Q8_0 down, as CUDA's _q6k; MMQ for Q6_K on HIP is the K-quant library (STRATA_MMQ_KQ=1)
|
||||
add_test(NAME hip_prefill_fused_iq_q6k COMMAND hip_prefill_fused_iq "--only=Q6_K + Q8_0" --edge --no-timing)
|
||||
set_tests_properties(hip_prefill_fused_iq_q6k PROPERTIES SKIP_RETURN_CODE 77 TIMEOUT 600 ENVIRONMENT "STRATA_PF_FUSED_Q6K=1;STRATA_MMQ_KQ=1")
|
||||
# STRATA_PF_FUSED_TQ=1 (gfx12, opt-in): the Gyro trellis pairs (TQK6 + TQK7, TQ2_T + TQ2_T), plain and Hadamard-folded (--folded), as CUDA's _tq / _tqh
|
||||
add_test(NAME hip_prefill_fused_iq_tq COMMAND hip_prefill_fused_iq "--only=+ T" --edge --no-timing)
|
||||
set_tests_properties(hip_prefill_fused_iq_tq PROPERTIES SKIP_RETURN_CODE 77 TIMEOUT 900 ENVIRONMENT "STRATA_PF_FUSED_TQ=1")
|
||||
|
||||
@@ -25753,14 +25753,21 @@
|
||||
{
|
||||
"name": "STRATA_PF_FUSED_Q6K",
|
||||
"backends": [
|
||||
"cuda"
|
||||
"cuda",
|
||||
"hip"
|
||||
],
|
||||
"reads": [
|
||||
{
|
||||
"file": "src/prefill/moe_fused_iq.cu",
|
||||
"line": 1969,
|
||||
"line": 2056,
|
||||
"backend": "cuda",
|
||||
"fn": "getenv"
|
||||
},
|
||||
{
|
||||
"file": "src/prefill/moe_fused_iq.cu",
|
||||
"line": 2399,
|
||||
"backend": "hip",
|
||||
"fn": "getenv"
|
||||
}
|
||||
],
|
||||
"parse": "flag",
|
||||
@@ -25779,7 +25786,7 @@
|
||||
"last_date": "",
|
||||
"status": "research",
|
||||
"owner": "prefill",
|
||||
"note": "CUDA (phase 4, opt-in, default off): a Q6_K gate/up with a Q8_0 down (UD-Q6_K_XL's 47 layers, UD-Q5_K_XL's one Q6_K layer) on the fused native kernels on any sm_80+ card instead of MMQ.",
|
||||
"note": "[DRAFT] CUDA and HIP gfx12 (phase 4, opt-in, default off): a Q6_K gate/up with a Q8_0 down (UD-Q6_K_XL's 47 layers, UD-Q5_K_XL's one Q6_K layer) on the fused native kernels instead of MMQ, on any sm_80+ card and on gfx1200 / gfx1201.",
|
||||
"retire_after": "",
|
||||
"retired_in": ""
|
||||
},
|
||||
@@ -25838,7 +25845,7 @@
|
||||
},
|
||||
{
|
||||
"file": "src/prefill/moe_fused_iq.cu",
|
||||
"line": 2390,
|
||||
"line": 2392,
|
||||
"backend": "hip",
|
||||
"fn": "getenv"
|
||||
}
|
||||
|
||||
@@ -2299,6 +2299,7 @@ bool f16_d(int t) { return t == T_Q2_0 || t == T_IQ4_NL || t == T_Q8_0 || t == T
|
||||
#if defined(__HIPCC__)
|
||||
bool tq_hip_requested(); // (STRATA_PF_FUSED_TQ on HIP: below)
|
||||
bool q8gu_hip_requested(); // (STRATA_PF_FUSED_Q8GU on HIP: below)
|
||||
bool q6k_hip_requested(); // (STRATA_PF_FUSED_Q6K on HIP: below)
|
||||
#endif
|
||||
bool gu_covered(int t) {
|
||||
return t == T_IQ2_XXS || t == T_IQ2_XS || t == T_IQ2_S || t == T_IQ3_XXS || t == T_IQ3_S || t == T_IQ4_XS
|
||||
@@ -2314,6 +2315,7 @@ bool gu_covered(int t) {
|
||||
|| ((t == T_Q4_K || t == T_Q5_K) && kq_on()) // the gfx11 kernels only
|
||||
|| ((t == T_TQK6 || t == T_TQ2_T) && dev_info().w12 && tq_hip_requested()) // STRATA_PF_FUSED_TQ=1 on gfx12
|
||||
|| (t == T_Q8_0 && dev_info().w12 && q8gu_hip_requested()) // STRATA_PF_FUSED_Q8GU=1 on gfx12
|
||||
|| (t == T_Q6_K && dev_info().w12 && q6k_hip_requested()) // STRATA_PF_FUSED_Q6K=1 on gfx12
|
||||
#endif
|
||||
;
|
||||
}
|
||||
@@ -2390,12 +2392,19 @@ bool q8gu_hip_requested() {
|
||||
static const bool on = [] { const char* v = std::getenv("STRATA_PF_FUSED_Q8GU"); return v != nullptr && v[0] == '1'; }();
|
||||
return on;
|
||||
}
|
||||
// STRATA_PF_FUSED_Q6K on HIP (phase 4, opt-in, gfx12 only): "1" lets a Q6_K gate/up with a Q8_0 down (UD-Q6_K_XL's 47 layers, UD-Q5_K_XL's one) take
|
||||
// native_w11_kernel's Q6_K gate/up instance instead of MMQ (the K-quant library, STRATA_MMQ_KQ=1, on gfx12). 256-value superblocks, an int8 scale per
|
||||
// 16 values (native_w11's per-16 path), the same decode as CUDA's. The same switch as CUDA's. gfx11: not measured, keeps its route.
|
||||
bool q6k_hip_requested() {
|
||||
static const bool on = [] { const char* v = std::getenv("STRATA_PF_FUSED_Q6K"); return v != nullptr && v[0] == '1'; }();
|
||||
return on;
|
||||
}
|
||||
#endif
|
||||
bool d_covered_on(int t, const DevInfo& d) {
|
||||
#if defined(__HIPCC__)
|
||||
if (t == T_Q5_0) return d.w12 ? q50_on(d) : q50_on(d) && f16::requested(); // gfx1151 has no int8 kernel for Q5_0 down (the F16 prompt set must be on); gfx12 has only the int8 one
|
||||
if (t == T_Q8_0 && !d.w12 && (f16::requested() || q8d_f16_default(d))) return true;
|
||||
if (t == T_Q8_0 && d.w12 && (q8d_hip_requested() || q8gu_hip_requested())) return true; // (behind an i-quant gate/up with Q8D, behind a Q8_0 one with Q8GU: native_supported)
|
||||
if (t == T_Q8_0 && d.w12 && (q8d_hip_requested() || q8gu_hip_requested() || q6k_hip_requested())) return true; // (behind an i-quant gate/up with Q8D, a Q8_0 one with Q8GU, a Q6_K one with Q6K: native_supported)
|
||||
if (t == T_TQK7 || t == T_TQ2_T) return d.w12 && tq_hip_requested(); // STRATA_PF_FUSED_TQ=1 (behind a trellis gate/up only: native_supported)
|
||||
#else
|
||||
if (t == T_Q5_0) return d.q50; // STRATA_PF_FUSED_Q50=1 and its kernels set up (dev_info)
|
||||
@@ -2587,6 +2596,11 @@ bool native_supported(int gu_type, int d_type) {
|
||||
const DevInfo& d = dev_info();
|
||||
return d_type == T_Q8_0 && d.ok && d.w12 && q8gu_hip_requested();
|
||||
}
|
||||
// A Q6_K gate/up on gfx12 (opt-in STRATA_PF_FUSED_Q6K=1; gu_covered checked it above): with a Q8_0 down only.
|
||||
if (gu_type == T_Q6_K) {
|
||||
const DevInfo& d = dev_info();
|
||||
return d_type == T_Q8_0 && d.ok && d.w12 && q6k_hip_requested();
|
||||
}
|
||||
#endif
|
||||
// default: only these three; the Q2_0 one (148-amd) is on Linux only: on Windows it is opt-in (STRATA_PF_FUSED=1) until tested there.
|
||||
// AMD-Q (owner decision 10-31): the IQ2_S and IQ4_XS gate/up layers too (the IQ3_S pack's 21 layers that kept MMQ), Linux only like the Q2_0 entry.
|
||||
@@ -2719,6 +2733,8 @@ void experts_native(const Batch& b, const NativeGeom& g, int n_expert, int64_t n
|
||||
// (STRATA_PF_FUSED_TQ=1, gfx12) the trellis gate/up: the plain launch; a folded down (set_down_rotation) takes H as FP32 rows in dm
|
||||
// (STRATA_PF_FUSED_Q8GU=1, gfx12) the Q8_0 gate/up (a Q8_0 down behind it): the plain launch
|
||||
case T_Q8_0: native_w11_kernel<T_Q8_0, true><<<g_gu, NW_THREADS, 0, s>>>(b, g, tb, xa8, src, ha8, nullptr); break;
|
||||
// (STRATA_PF_FUSED_Q6K=1, gfx12) the Q6_K gate/up (a Q8_0 down behind it): the plain launch
|
||||
case T_Q6_K: native_w11_kernel<T_Q6_K, true><<<g_gu, NW_THREADS, 0, s>>>(b, g, tb, xa8, src, ha8, nullptr); break;
|
||||
case T_TQK6: native_w11_kernel<T_TQK6, true><<<g_gu, NW_THREADS, 0, s>>>(b, g, tb, xa8, src, ha8, g_rot_on ? dm : nullptr); break;
|
||||
case T_TQ2_T: native_w11_kernel<T_TQ2_T, true><<<g_gu, NW_THREADS, 0, s>>>(b, g, tb, xa8, src, ha8, g_rot_on ? dm : nullptr); break;
|
||||
default: STRATA_NW_GU(T_IQ4_XS); break;
|
||||
|
||||
@@ -840,10 +840,10 @@ int main(int argc, char** argv) {
|
||||
const char* only_tq = nullptr;
|
||||
for (int i = 1; i < argc; ++i)
|
||||
if (std::strncmp(argv[i], "--only=", 7) == 0) only_tq = argv[i] + 7;
|
||||
if (only_tq != nullptr && std::strstr("TQK6 + TQK7 TQ2_T + TQ2_T", only_tq) != nullptr) {
|
||||
if (only_tq != nullptr && std::strstr("TQK6 + TQK7 TQ2_T + TQ2_T Q6_K + Q8_0", only_tq) != nullptr) { // (and the Q6_K pair: STRATA_PF_FUSED_Q6K=1 is gfx12's too)
|
||||
cudaDeviceProp prop{};
|
||||
if (cudaGetDeviceProperties(&prop, 0) == cudaSuccess && std::strncmp(prop.gcnArchName, "gfx12", 5) != 0) {
|
||||
std::printf("the trellis pairs: gfx12 only on HIP (%s: skipped)\n", prop.gcnArchName);
|
||||
std::printf("the trellis / Q6_K pairs: gfx12 only on HIP (%s: skipped)\n", prop.gcnArchName);
|
||||
return 77;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user