dsv41: the matrix-core prompt attention (DS4_FAST_ATTN) on by default for gfx1151 on Windows
The switch was on for gfx12 only, and ds4_kernels.cu said why: "gfx11 and gfx1151 (Strix Halo) are untested and keep the scalar kernels". Measured on Strix Halo 2026-10-28 (2.00 bpw, 32K prompt, the synchronised chunk profile): the sparse-attention stage is 43.3% of the prompt's GPU time and runs at 2.3 TFLOPS effective; with DS4_FAST_ATTN=1 the stage falls from 38,340 ms to 6,976 ms and the prompt from 101.6 s to 70.8 s - +43.6%, 322.5 -> 463.0 tok/s - with the same greedy first token (27408,). The plan's D-P3a had closed this on +1.6 / -0.2 / +1.2 / -2.8% end to end, which is what 4K-8K shows; at 32K the term is five times its 4K size and the switch is the whole difference. fast_attn_default() takes the gfx1151-on-Windows flag as its own argument (the existing three-argument calls in the test are updated), ds4_kernels.cu decides it from the device name once, and experts_rule_test covers the new cell: gfx1151 Windows on, 0.2.6 arithmetic off, DS4_FAST_ATTN=0 off, =1 on anywhere.
This commit is contained in:
1 parent
2ea46ded73
commit
c697e859e9
3 files changed
+38
-12
No files matched your search
@@ -176,10 +176,12 @@ inline bool copy_hugetlb_default(int env, double pool_free_bytes, double copy_by
|
||||
return pool_free_bytes > 0.0 && pool_free_bytes >= copy_bytes;
|
||||
}
|
||||
|
||||
// DS4_FAST_ATTN (the chunked prompt's attention on the matrix cores): env -1 unset, else 0 / 1; 0.2.6: opt-in; 0.2.7: on for gfx1200 / gfx1201.
|
||||
inline bool fast_attn_default(int env, bool gfx12, bool v026 = false) {
|
||||
// DS4_FAST_ATTN (the chunked prompt's attention on the matrix cores): env -1 unset, else 0 / 1; 0.2.6: opt-in; 0.2.7: on for
|
||||
// gfx1200 / gfx1201, and (this change) on for gfx1151 on Windows, where it measured +43.6% on a 32K prompt (101.6 -> 70.8 s,
|
||||
// sparse attention 38.3 -> 7.0 s), the same greedy first token and a first-token KL far under the 0.0228 bar.
|
||||
inline bool fast_attn_default(int env, bool gfx12, bool gfx1151win = false, bool v026 = false) {
|
||||
if (env >= 0) return env != 0;
|
||||
return !v026 && gfx12;
|
||||
return !v026 && (gfx12 || gfx1151win);
|
||||
}
|
||||
|
||||
// The drafter's cumulative confidence cut (STRATA_DS4_DSPARK_CUM, a request's dspark_cum): the variable when set; 0.2.6: 0; 0.2.7: 0.5 on gfx1200 / gfx1201.
|
||||
|
||||
@@ -2038,7 +2038,9 @@ bool split_enabled() {
|
||||
// 0.006 gate, ids identical); gfx11 and gfx1151 (Strix Halo) are untested and keep the scalar kernels. DS4_FAST_ATTN=0 is the
|
||||
// off switch (exactly the 0.2.6 arithmetic), DS4_FAST_ATTN=1 turns it on elsewhere. Decided per device (the first call there).
|
||||
// The Marlin stream measured it ON on 4x R9700 (gfx1201), 2.25 bpw, 8K code prompts: 1180 -> 1354 ppts (+14.7%), the same ids,
|
||||
// KL 0.10833 against 0.10925 for the scalar path. It stays gfx12-only until Strix Halo (gfx1151) is tested.
|
||||
// KL 0.10833 against 0.10925 for the scalar path. gfx1151 on Windows was the untested part; measured on Strix Halo 2026-10-28
|
||||
// (32K prompt, 2.00 bpw): 101.6 -> 70.8 s (+43.6%), the sparse-attention stage 38.3 -> 7.0 s, the same greedy first token
|
||||
// (27408,), so it joins the default there and stays opt-in on every other gfx11 part.
|
||||
#if defined(STRATA_USE_HIP)
|
||||
bool device_is_gfx12() {
|
||||
static std::atomic<int> cache[64]; // 0 unknown, 1 no, 2 yes
|
||||
@@ -2055,6 +2057,22 @@ bool device_is_gfx12() {
|
||||
}
|
||||
return c == 2;
|
||||
}
|
||||
#if defined(_WIN32)
|
||||
bool device_is_gfx1151win() {
|
||||
static std::atomic<int> cache[64]; // 0 unknown, 1 no, 2 yes
|
||||
int dev = 0;
|
||||
cudaGetDevice(&dev);
|
||||
if (dev < 0 || dev >= 64) return false;
|
||||
int c = cache[dev].load();
|
||||
if (c == 0) {
|
||||
cudaDeviceProp prop{};
|
||||
const bool yes = cudaGetDeviceProperties(&prop, dev) == cudaSuccess && std::strncmp(prop.gcnArchName, "gfx1151", 7) == 0;
|
||||
c = yes ? 2 : 1;
|
||||
cache[dev].store(c);
|
||||
}
|
||||
return c == 2;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
bool fast_attn_enabled() {
|
||||
static const int env = [] {
|
||||
@@ -2062,9 +2080,13 @@ bool fast_attn_enabled() {
|
||||
return e == nullptr ? -1 : (std::atoi(e) != 0 ? 1 : 0);
|
||||
}();
|
||||
#if defined(STRATA_USE_HIP)
|
||||
return strata::ds4::fast_attn_default(env, device_is_gfx12(), strata::ds4::defaults_026());
|
||||
#if defined(_WIN32)
|
||||
return strata::ds4::fast_attn_default(env, device_is_gfx12(), device_is_gfx1151win(), strata::ds4::defaults_026());
|
||||
#else
|
||||
return strata::ds4::fast_attn_default(env, false, strata::ds4::defaults_026());
|
||||
return strata::ds4::fast_attn_default(env, device_is_gfx12(), false, strata::ds4::defaults_026());
|
||||
#endif
|
||||
#else
|
||||
return strata::ds4::fast_attn_default(env, false, false, strata::ds4::defaults_026());
|
||||
#endif
|
||||
}
|
||||
attnsplit::AttnSplitScratch split_scratch(cudaStream_t s, int heads) {
|
||||
|
||||
@@ -270,12 +270,14 @@ int main() {
|
||||
CHECK_EQ(copy_hugetlb_default(-1, 90 * GB, 100 * GB, false), 0);
|
||||
CHECK_EQ(copy_hugetlb_default(1, 0.0, 100 * GB, true), 1);
|
||||
CHECK_EQ(copy_hugetlb_default(0, 120 * GB, 100 * GB, false), 0); // the old DS4_COPY_HUGETLB=0
|
||||
// the matrix-core attention: opt-in again
|
||||
CHECK_EQ(fast_attn_default(-1, true, true), 0);
|
||||
CHECK_EQ(fast_attn_default(-1, true, false), 1);
|
||||
CHECK_EQ(fast_attn_default(-1, false, false), 0);
|
||||
CHECK_EQ(fast_attn_default(1, false, true), 1);
|
||||
CHECK_EQ(fast_attn_default(0, true, false), 0); // the old DS4_FAST_ATTN=0
|
||||
// the matrix-core attention: opt-in again, except on gfx12 and (since 2026-10-28) on gfx1151 on Windows
|
||||
CHECK_EQ(fast_attn_default(-1, true, false, true), 0);
|
||||
CHECK_EQ(fast_attn_default(-1, true, false, false), 1);
|
||||
CHECK_EQ(fast_attn_default(-1, false, false, false), 0);
|
||||
CHECK_EQ(fast_attn_default(-1, false, true, false), 1); // gfx1151 on Windows
|
||||
CHECK_EQ(fast_attn_default(-1, false, true, true), 0); // ... but never for 0.2.6's arithmetic
|
||||
CHECK_EQ(fast_attn_default(1, false, false, true), 1);
|
||||
CHECK_EQ(fast_attn_default(0, true, true, false), 0); // the old DS4_FAST_ATTN=0
|
||||
// the drafter's cumulative cut: 0 again; STRATA_DS4_DSPARK_CUM wins
|
||||
CHECK_EQ((int) (dspark_cum_value(false, 0.0f, true, true) * 100), 0);
|
||||
CHECK_EQ((int) (dspark_cum_value(false, 0.0f, true, false) * 100), 50);
|
||||
|
||||
Reference in new issue
Block a user