Merge main into laya-arch-plugin

This commit is contained in:
Brandon Bertelsen committed 2026-10-29 13:45:18 -04:00
commit ec243c2a7d
189 files changed
+11212 -7060

No files matched your search

+328 -12
View File
@@ -1051,6 +1051,63 @@ static void attn_oracle_one(const uint16_t* qh, const uint8_t* kv, int kv_is_fp8
* band's upper bound (RadArgs.p), so `trim` here is 4096 while the issued count, and `tail`'s
* extent, is 1024. 90ede42 read the parameter, trimmed a 2048-key context to 0, and the attention
* over slice A's rows wrote nothing. */
/* The full-attention decode split law (r4d_decode_splits), read through the scratch hook's declare
* path, where the depth is the declared max_ctx. Qwen3.8-27B's TP2 rank: 12 query heads over 2 KV
* heads, head_dim 256. An 8-row verify (three waves at gqa 6) splits by depth: up to 16384 tokens
* 128 / units (x4: 16), then at least 64, and past 65536 512 / units capped at 256 (x1: 256, x2:
* 128, x4 and more: 64). A plain decode and the short block's 4-row verify keep the 256-workgroup
* target, and the two-tiles-a-segment cap still binds a short context (1024 tokens: 64 tiles of
* 16, at most 32 segments).
*
* The declared region is the worst over every sequence count up to max_seqs and every query length
* up to q_len (a shorter step can split more: attn_decode_scratch), so the region over the region
* at one forced segment is that worst, in the batch's own rows: `splits` is the law at the batch,
* `region` what the declare path must hold, at least `splits`. Where a 5-row step at shallow depth
* splits more per row than the 8-row verify (x1 at 65536, x2 and x4 at 16384, x4 at 1024), the
* region is the shorter step's. */
static void decode_split_law_case(const Plugin& pl) {
const char* name = "attn_decode_h256_gqa6_bf16kv";
if (!sel(name)) return;
const RadKernelInfo* r = find(pl, name);
if (!r || !r->scratch) { ok("decode split law", false, "row or its scratch hook absent"); return; }
auto bytes = [&](int64_t seqs, int64_t q_len, int64_t ctx, int64_t splits) {
std::vector<RadParam> ps = {
PI("n_head", 12), PI("gqa", 6), PI("head_dim", 256), PI("block_size", 16),
PI("max_seqs", seqs), PI("q_len", q_len), PI("max_ctx", ctx),
};
if (splits > 0) ps.push_back(PI("splits", splits));
RadArgs a;
std::memset(&a, 0, sizeof(a));
a.p = ps.data(); a.n_p = (int)ps.size();
a.world_size = 1;
return r->scratch(&a);
};
struct Want { int64_t seqs, q_len, ctx, splits, region; };
const Want want[] = {
{ 1, 8, 100000, 256, 256 }, { 2, 8, 100000, 128, 128 }, { 4, 8, 100000, 64, 64 },
{ 6, 8, 100000, 64, 64 }, { 8, 8, 100000, 64, 64 }, { 2, 8, 65536, 64, 64 },
{ 2, 8, 65552, 128, 128 }, { 1, 8, 65536, 64, 80 }, { 2, 8, 32768, 64, 64 },
{ 4, 8, 32768, 64, 64 }, { 7, 8, 32768, 64, 64 }, { 4, 8, 16400, 64, 64 },
{ 4, 8, 16384, 16, 20 }, { 2, 8, 16384, 32, 40 }, { 4, 8, 1024, 16, 20 },
{ 1, 8, 1024, 32, 32 }, { 4, 8, 640, 16, 16 }, { 8, 4, 100000, 16, 16 },
{ 16, 4, 100000, 8, 8 }, { 4, 1, 100000, 32, 32 }, { 1, 1, 100000, 128, 128 },
};
int bad = 0;
for (const Want& w : want) {
const int64_t law = bytes(w.seqs, w.q_len, w.ctx, 0), one = bytes(w.seqs, w.q_len, w.ctx, 1);
const int64_t got = one > 0 && law > 0 && law % one == 0 ? law / one : -1;
if (got != w.region || w.region < w.splits) {
std::printf(" FAIL decode split law: %lld x %lld rows over %lld: a region of %lld "
"segments, want %lld (the batch's own %lld)\n",
(long long)w.seqs, (long long)w.q_len, (long long)w.ctx, (long long)got,
(long long)w.region, (long long)w.splits);
++bad;
}
}
g_fail += bad;
if (!bad) std::printf(" ok decode split law: %zu batches\n", sizeof(want) / sizeof(want[0]));
}
static void kv_len_trim_case(const Plugin& pl) {
const char* name = "kv_len_trim";
if (!sel(name)) return;
@@ -1706,6 +1763,80 @@ static void attn_split_scratch_case(const Plugin& pl, const SplitGeo& g, const c
}
}
/* Every split-KV decode row's scratch at declare (the band's bound, parameters only, as the core
* sizes it) against what its launch checks at issue (the same hook over the issue's tensors): for
* each band bound up to 64 / gqa rows, every query length up to it and every sequence count up to
* max_seqs must fit. Host only; the tensors carry shapes and aligned placeholder addresses. The
* h256 split law targets 256 workgroups at q_len * gqa <= 32 and 128 above, so a step shorter than
* its band's bound can need more partials than the bound: 1.13.0 sized the bound only, and an MTP
* step of 4 rows at gqa 8 (band 5) refused with RAD_E_SCRATCH at issue (#293). */
static void attn_decode_scratch_band_case(const Plugin& pl) {
for (int k = 0; k < pl.kernel_count(); ++k) {
const RadKernelInfo* r = pl.kernel_at(k);
int hd = 0, gqa = 0;
if (std::strncmp(r->name, "attn_decode_h", 13) || !r->scratch ||
std::sscanf(r->name, "attn_decode_h%d_gqa%d", &hd, &gqa) != 2 || hd <= 0 || gqa <= 0)
continue;
if (!sel(r->name) && !sel("attn_decode_scratch")) continue;
const char* kvs = std::strrchr(r->name, '_') + 1;
const bool bf = !std::strcmp(kvs, "bf16kv");
const int64_t rowe = !std::strcmp(kvs, "fp8v4") ? 25 * hd / 16
: !std::strcmp(kvs, "k6v4") ? 22 * hd / 16 : 2 * hd;
const int64_t bs = std::strstr(r->name, "_bs4_") ? 4 : 16;
const int64_t max_seqs = 32, max_ctx = 200000, mb = (max_ctx + bs - 1) / bs;
const int top = std::max(1, 64 / gqa);
void* const fake = (void*)(uintptr_t)4096; /* aligned, never dereferenced */
std::string why;
int checked = 0;
for (const int64_t kv : { 1, 2 }) {
const int64_t n_head = kv * gqa;
for (int band = 1; band <= top; ++band) {
std::vector<RadParam> ps = {
PI("q_len", band), PI("head_dim", hd), PI("gqa", gqa), PI("n_head", n_head),
PI("max_seqs", max_seqs), PI("max_ctx", max_ctx), PI("block_size", bs),
PI("causal", 1), PI("window", 0), PS("q_dtype", "bf16"),
PS("kv_dtype", bf ? "bf16" : "fp8_e4m3") };
RadArgs d;
std::memset(&d, 0, sizeof(d));
d.p = ps.data(); d.n_p = (int)ps.size(); d.world_size = 1;
const int64_t declared = r->scratch(&d);
if (declared < 0) { why += fmt("; kv%lld band %d: declare refused %lld", (long long)kv,
band, (long long)declared); continue; }
/* the issue: no n_head / max_seqs, so the hook reads the tensors */
std::vector<RadParam> pi = {
PI("q_len", band), PI("head_dim", hd), PI("gqa", gqa), PI("max_ctx", max_ctx),
PI("block_size", bs), PI("causal", 1), PI("window", 0) };
for (int q = 1; q <= band; ++q)
for (int64_t n = 1; n <= max_seqs; ++n) {
std::vector<RadTensor> ts = {
T(fake, RAD_BF16, { n * q, n_head, hd }),
T(fake, bf ? RAD_BF16 : RAD_F8E4M3, { n * mb, kv, bs, rowe }),
T(fake, RAD_I32, { n, mb }), T(fake, RAD_I32, { n }),
T(fake, RAD_F32, { n, kv }), T(fake, RAD_F32, { n, kv }),
T(nullptr, RAD_I32, { n + 1 }),
T(fake, RAD_BF16, { n * q, n_head, hd }) };
RadArgs a;
std::memset(&a, 0, sizeof(a));
a.t = ts.data(); a.n_t = (int)ts.size();
a.p = pi.data(); a.n_p = (int)pi.size(); a.world_size = 1;
const int64_t need = r->scratch(&a);
++checked;
if (need < 0 || need > declared) {
why += fmt("; kv%lld band %d: q_len %d x %lld sequences needs %lld, "
"declared %lld", (long long)kv, band, q, (long long)n,
(long long)need, (long long)declared);
q = band;
break;
}
}
}
}
ok(fmt("%s: decode scratch at declare covers every shorter step", r->name).c_str(),
why.empty() && checked > 0,
why.empty() ? fmt("%d issue geometries", checked) : why.substr(2));
}
}
/* The h256/gqa6 prefill over an 8-bit cache with e4m3 products (`prefill_fp8` 1 Q.K^T, 2 P.V, 3
* both), against the inline oracle and against `exact`, the cache's exact row, on the same data.
@@ -13185,6 +13316,103 @@ static void fused_quant_fp8_numeric(const Plugin& pl) {
"rc=" + std::to_string(rc));
else same("gate_quant_fp8 is byte-identical to sigmoid + mul + quant_act_fp8");
/* --- mul + quant_act_fp8, against gate_quant_fp8 at act none -------------------------------
*
* LFM2's convolution gate: C * conv(B * x), then the codes its out projection reads. The
* kernel must round the product to bf16 (the `mul` step stores bf16) and take the codes over
* that value. Strided sources: gate and x are column slices of [M, 2K] planes, so a kernel
* ignoring a pitch reads the wrong half. Rows 1, 8 and 65 cover the narrow width's boundary
* and one past it; the scale plane stays K/128 wide at every M. */
{
const int64_t NROW = 65;
std::vector<uint16_t> hg((size_t)NROW * 2 * K), hx2((size_t)NROW * 2 * K);
for (int64_t r = 0; r < NROW; ++r)
for (int64_t c = 0; c < K; ++c) {
const float m = std::ldexp(1.0f, (int)(c / 128) - 2);
const float v = m * (0.041f * (float)((r * 31 + c * 17) % 73) - 1.4f);
hg[(size_t)r * 2 * K + c] = h_to_bf16(c == (r * 13) % K ? v * 23.0f : v);
hx2[(size_t)r * 2 * K + c] = h_to_bf16(m * (0.013f * (float)((r * 7 + c * 11) % 47) - 0.3f));
}
void* d_g = dalloc(hg.size() * 2);
void* d_x2 = dalloc(hx2.size() * 2);
void* d_py[2] = { dalloc((size_t)NROW * K * 2), dalloc((size_t)NROW * K * 2) };
void* d_pq[2] = { dalloc((size_t)NROW * K), dalloc((size_t)NROW * K) };
void* d_ps[2] = { dalloc((size_t)NROW * nkb * 4), dalloc((size_t)NROW * nkb * 4) };
if (!d_g || !d_x2 || !d_py[1] || !d_pq[1] || !d_ps[1]) {
ok("mul + quant_act_fp8 vs gate_quant_fp8 act none", false, "hipMalloc failed");
} else {
st_memcpy(d_g, hg.data(), hg.size() * 2, hipMemcpyHostToDevice);
st_memcpy(d_x2, hx2.data(), hx2.size() * 2, hipMemcpyHostToDevice);
for (const int64_t m : { (int64_t)1, (int64_t)8, (int64_t)65 }) {
RadTensor g = T(d_g, RAD_BF16, { m, K }); g.stride[0] = 2 * K;
RadTensor x = T(d_x2, RAD_BF16, { m, K }); x.stride[0] = 2 * K;
int r2 = launch_row(ml, { g, x, T(d_py[0], RAD_BF16, { m, K }) },
{ PI("M", m), PI("n", K), PS("dtype", "bf16") });
if (r2 == RAD_OK)
r2 = launch_row(qz, { T(d_py[0], RAD_BF16, { m, K }),
T(d_pq[0], RAD_F8E4M3, { m, K }),
T(d_ps[0], RAD_F32, { m, nkb }) },
{ PI("M", m), PI("n", K), PI("group", 128),
PS("dtype", "bf16") });
if (r2 == RAD_OK)
r2 = launch_row(tq, { g, x, T(d_pq[1], RAD_F8E4M3, { m, K }),
T(d_ps[1], RAD_F32, { m, nkb }),
T(d_py[1], RAD_BF16, { m, K }) },
{ PI("M", m), PI("n", K), PI("group", 128),
PS("dtype", "bf16"), PS("act", "none") });
if (r2 != RAD_OK) {
ok(("mul + quant_act_fp8 vs gate_quant_fp8 act none, M=" +
std::to_string(m)).c_str(), false, "rc=" + std::to_string(r2));
continue;
}
std::vector<uint16_t> y0((size_t)m * K), y1((size_t)m * K);
std::vector<uint8_t> qq0((size_t)m * K), qq1((size_t)m * K);
std::vector<float> ss0((size_t)m * nkb), ss1((size_t)m * nkb);
st_memcpy(y0.data(), d_py[0], y0.size() * 2, hipMemcpyDeviceToHost);
st_memcpy(y1.data(), d_py[1], y1.size() * 2, hipMemcpyDeviceToHost);
st_memcpy(qq0.data(), d_pq[0], qq0.size(), hipMemcpyDeviceToHost);
st_memcpy(qq1.data(), d_pq[1], qq1.size(), hipMemcpyDeviceToHost);
st_memcpy(ss0.data(), d_ps[0], ss0.size() * 4, hipMemcpyDeviceToHost);
st_memcpy(ss1.data(), d_ps[1], ss1.size() * 4, hipMemcpyDeviceToHost);
size_t ny = 0, nq = 0, ns = 0, nz = 0;
for (size_t i = 0; i < y0.size(); ++i) ny += y0[i] != y1[i];
for (size_t i = 0; i < qq0.size(); ++i) {
nq += qq0[i] != qq1[i];
nz += qq1[i] != 0;
}
for (size_t i = 0; i < ss0.size(); ++i)
ns += std::memcmp(&ss0[i], &ss1[i], 4) != 0;
ok(("gate_quant_fp8 act none is byte-identical to mul + quant_act_fp8, M=" +
std::to_string(m)).c_str(),
ny == 0 && nq == 0 && ns == 0 && nz > qq1.size() / 2,
"bf16 differs " + std::to_string(ny) + ", codes " + std::to_string(nq) +
", scales " + std::to_string(ns) + ", nonzero codes " +
std::to_string(nz));
/* Without out_bf16 the codes are taken over the same rounded product. */
r2 = launch_row(tq, { g, x, T(d_pq[1], RAD_F8E4M3, { m, K }),
T(d_ps[1], RAD_F32, { m, nkb }),
T(nullptr, RAD_BF16, {}) },
{ PI("M", m), PI("n", K), PI("group", 128),
PS("dtype", "bf16"), PS("act", "none") });
if (r2 != RAD_OK) {
ok(("gate_quant_fp8 act none without out_bf16, M=" +
std::to_string(m)).c_str(), false, "rc=" + std::to_string(r2));
continue;
}
st_memcpy(qq1.data(), d_pq[1], qq1.size(), hipMemcpyDeviceToHost);
st_memcpy(ss1.data(), d_ps[1], ss1.size() * 4, hipMemcpyDeviceToHost);
size_t dq2 = 0, ds2 = 0;
for (size_t i = 0; i < qq0.size(); ++i) dq2 += qq0[i] != qq1[i];
for (size_t i = 0; i < ss0.size(); ++i)
ds2 += std::memcmp(&ss0[i], &ss1[i], 4) != 0;
ok(("gate_quant_fp8 act none without out_bf16 keeps the codes, M=" +
std::to_string(m)).c_str(), dq2 == 0 && ds2 == 0,
"codes differ " + std::to_string(dq2) + ", scales " + std::to_string(ds2));
}
}
}
/* --- the same two at int8 codes, against the same products and quant_act_i8g ---
*
* With an I8 codes operand the producer writes int8 codes for an int8 trunk linear: the bf16
@@ -14416,6 +14644,90 @@ static void fp8_numeric(const Plugin& pl, int64_t N, int64_t K) {
std::to_string(live));
}
}
/* ---- past the narrow tile: `gemm_nt_q_gated_wide` runs the gated prefill tile,
* whose accumulators are the unfused prefill GEMM's, so its codes, scales and bf16
* product are the pair's over the whole prompt. 65 and 129 rows straddle one and
* two 64-row blocks. */
const RadKernelInfo* gt = find(pl, "gemm_fp8a8_tiled");
const RadKernelInfo* gw = find(pl, "gemm_fp8a8_gated_nt_wide");
for (const int64_t M : { (int64_t)65, (int64_t)129 }) {
if (!gt || !gw) {
ok("gemm_fp8a8_gated_nt_wide numeric", false, "row absent");
break;
}
void* dx = dalloc((size_t)M * K * 2);
void* dq = dalloc((size_t)M * K);
void* dqs = dalloc((size_t)M * sk * 4);
void* dy = dalloc((size_t)M * N * 2);
void* c0 = dalloc((size_t)M * nout);
void* c1 = dalloc((size_t)M * nout);
void* z0 = dalloc((size_t)M * gkb * 4);
void* z1 = dalloc((size_t)M * gkb * 4);
void* b0 = dalloc((size_t)M * nout * 2);
void* b1 = dalloc((size_t)M * nout * 2);
if (!dx || !dq || !dqs || !dy || !c1 || !z1 || !b1) {
ok("gemm_fp8a8_gated_nt_wide alloc", false, "hipMalloc failed");
continue;
}
std::vector<uint16_t> xm((size_t)M * K);
for (int64_t m = 0; m < M; ++m)
for (int64_t c = 0; c < K; ++c)
xm[(size_t)m * K + c] = xb[(size_t)((c + m * 37) % K)];
st_memcpy(dx, xm.data(), xm.size() * 2, hipMemcpyHostToDevice);
int rc = launch_row(qz, { T(dx, RAD_BF16, { M, K }), T(dq, RAD_F8E4M3, { M, K }),
T(dqs, RAD_F32, { M, sk }) },
{ PI("M", M), PI("n", K), PI("group", 128),
PS("dtype", "bf16") });
if (rc == RAD_OK)
rc = launch_row(gt, { T(dq, RAD_F8E4M3, { M, K }),
T(dqs, RAD_F32, { M, sk }),
T(d_wf, RAD_F8E4M3, { N, K }),
T(d_s, RAD_BF16, { sn, sk }),
T(dy, RAD_BF16, { M, N }) },
{ PI("M", M), PI("N", N), PI("K", K), PI("group", 128),
PS("dtype", "fp8a8") });
if (rc == RAD_OK)
rc = launch_row(gq, { T(dy, RAD_BF16, { M, N }),
T(c0, RAD_F8E4M3, { M, nout }),
T(z0, RAD_F32, { M, gkb }),
T(b0, RAD_BF16, { M, nout }) },
{ PI("M", M), PI("n", nout), PI("group", 128),
PS("dtype", "bf16"), PS("act", "silu") });
if (rc == RAD_OK)
rc = launch_row(gw, { T(dq, RAD_F8E4M3, { M, K }),
T(dqs, RAD_F32, { M, sk }),
T(d_wf, RAD_F8E4M3, { N, K }),
T(d_s, RAD_BF16, { sn, sk }),
T(c1, RAD_F8E4M3, { M, nout }),
T(z1, RAD_F32, { M, gkb }),
T(b1, RAD_BF16, { M, nout }) },
{ PI("M", M), PI("N", N), PI("K", K), PI("group", 128),
PS("dtype", "fp8a8"), PS("act", "silu") });
const std::string wn =
std::string("gemm_fp8a8_gated_nt_wide is byte-identical to the GEMM + "
"gated_quant_fp8, N ") + std::to_string((long long)N) +
" M " + std::to_string((long long)M);
if (rc != RAD_OK) { ok(wn.c_str(), false, "rc=" + std::to_string(rc)); continue; }
std::vector<uint8_t> q0((size_t)M * nout), q1((size_t)M * nout);
std::vector<float> s0((size_t)M * gkb), s1((size_t)M * gkb);
std::vector<uint16_t> y0((size_t)M * nout), y1((size_t)M * nout);
st_memcpy(q0.data(), c0, q0.size(), hipMemcpyDeviceToHost);
st_memcpy(q1.data(), c1, q1.size(), hipMemcpyDeviceToHost);
st_memcpy(s0.data(), z0, s0.size() * 4, hipMemcpyDeviceToHost);
st_memcpy(s1.data(), z1, s1.size() * 4, hipMemcpyDeviceToHost);
st_memcpy(y0.data(), b0, y0.size() * 2, hipMemcpyDeviceToHost);
st_memcpy(y1.data(), b1, y1.size() * 2, hipMemcpyDeviceToHost);
int nc = 0, nz = 0, ny = 0, live = 0;
for (size_t i = 0; i < q0.size(); ++i) nc += q0[i] != q1[i];
for (size_t i = 0; i < s0.size(); ++i)
nz += std::memcmp(&s0[i], &s1[i], 4) != 0;
for (size_t i = 0; i < y0.size(); ++i) ny += y0[i] != y1[i];
for (size_t i = 0; i < q1.size(); ++i) live += q1[i] != 0;
ok(wn.c_str(), nc == 0 && nz == 0 && ny == 0 && live > (int)q1.size() / 2,
"codes differ " + std::to_string(nc) + ", scales " + std::to_string(nz) +
", bf16 " + std::to_string(ny) + ", nonzero " + std::to_string(live));
}
}
}
}
@@ -18091,13 +18403,13 @@ static void hc_read_i8(const Plugin& pl, int64_t M, bool real_stream, int form)
}
/* The gated residual's read at its decode kernels, byte for byte: the launcher's rule (kernels A and
* B as one grid at one to seven rows, the tiled up-mix pipelined from eight) against the kernels it
* replaced, pinned through r4d_hc_read_pin_decode(1). E4M3 or int8 codes, on a real stream (the
* B as one grid at one to seven rows, the tiled up-mix pipelined from eight) against the two-grid
* form, pinned through r4d_hc_read_pin_decode(1). E4M3 or int8 codes, on a real stream (the
* one-grid form keys its counters on it). The two forms must dispatch different kernels, so a pin
* that is ignored cannot pass by comparing a form with itself. */
static void hc_decode_forms(const Plugin& pl, int64_t M, bool i8) {
const std::string nm = fmt("hc_read_e4m3 decode kernels at M=%lld, %s codes: the rule "
"byte-identical to the previous kernels", (long long)M,
"byte-identical to the two-grid form", (long long)M,
i8 ? "int8" : "E4M3");
const RadKernelInfo* r = find(pl, "hc_read_e4m3");
if (!r) { skip(nm.c_str(), "row absent"); return; }
@@ -18182,7 +18494,7 @@ static void hc_decode_forms(const Plugin& pl, int64_t M, bool i8) {
const int rc = r->launch(&a, (RadStream)hs);
const int nd = pl.record(nullptr, 0);
if (rc != RAD_OK || st_stream_sync(hs) != hipSuccess) {
ok(nm.c_str(), false, fmt("%s rc=%d", form ? "the previous kernels" : "the rule", rc));
ok(nm.c_str(), false, fmt("%s rc=%d", form ? "the two-grid form" : "the rule", rc));
pl.pin_hc_dec(0);
(void)hipStreamDestroy(hs);
return;
@@ -18396,12 +18708,12 @@ static void hc_prefill(const Plugin& pl, int64_t M, int iters, bool timed, bool
if (pl.pin_hc) pl.pin_hc(form);
time_now(kForm[form]);
}
/* The decode kernels against the ones they replaced (r4d_hc_read_pin_decode), under the
/* The two-grid decode form (r4d_hc_read_pin_decode(1)) against the served one, under the
* launcher's prefill rule. */
if (pl.pin_hc_dec && f8) {
if (pl.pin_hc) pl.pin_hc(0);
pl.pin_hc_dec(1);
time_now("the previous decode kernels");
time_now("the two-grid decode form");
pl.pin_hc_dec(0);
time_now("the launcher's rule");
}
@@ -25488,7 +25800,8 @@ struct ArThread {
* The engine carries this fact (device.p2p, RAD_FACT_P2P) and selects around its absence; a card
* count is not enough. hipDeviceCanAccessPeer answers it without a kernel: on a box with the IOMMU
* off the peer path is absent, the enable call throws `enable_peer: invalid device ordinal`, and
* init returns RAD_E_DEVICE — a skip line, like the card-count gates, not a failure. */
* init returns RAD_E_DEVICE. A missing path is a skip line, like the card-count gates, not a
* failure. */
static bool ar_peer_path_ok(const std::vector<int>& devs, int world) {
if (world < 2 || (int)devs.size() < world) return false;
for (int a = 0; a < world; ++a)
@@ -28563,9 +28876,10 @@ static void device_phase(const Plugin& pl) {
hipDeviceProp_t p;
if (hipGetDeviceProperties(&p, d) != hipSuccess) continue;
if (!g_case) std::printf(" device %d: %s\n", d, p.gcnArchName);
if (std::strncmp(p.gcnArchName, "gfx1201", 7) == 0) devs.push_back(d);
if (std::strncmp(p.gcnArchName, "gfx1201", 7) == 0 ||
std::strncmp(p.gcnArchName, "gfx1200", 7) == 0) devs.push_back(d);
}
if (devs.empty()) { skip("device phase", "no gfx1201 device"); return; }
if (devs.empty()) { skip("device phase", "no gfx1200/gfx1201 device"); return; }
st_set_device(devs[0]);
if (!g_case) std::printf("\ndevice smoke tests (device %d)\n", devs[0]);
@@ -28660,6 +28974,7 @@ static void device_phase(const Plugin& pl) {
attn_case(pl, "attn_window_h512_gqa8_fp8kv", 512, 8, 32, "fp8_e4m3", 1);
/* The 31B's prefill overlap at tp 4: sliding h256 gqa 2 (4 kv heads a rank, window 1024) and
* global h512 gqa 8 (1 kv head), a 2048-row chunk cut at 1024, first chunk and a later one. */
decode_split_law_case(pl);
kv_len_trim_case(pl);
for (const int64_t ctx : { (int64_t)2048, (int64_t)4096 }) {
attn_slice_case(pl, "attn_prefill_h256_gqa2_fp8kv", 256, 2, 4, 2048, 1024, ctx, 1024);
@@ -28771,6 +29086,7 @@ static void device_phase(const Plugin& pl) {
std::make_pair(8, 53), std::make_pair(1, 300),
std::make_pair(15, 640) })
attn_mixed_step_case(pl, *mr.g, mr.dec, mr.pre, mr.kv, c.first, c.second, 2048);
attn_decode_scratch_band_case(pl);
/* Flash-Next's QSA layers: twelve queries per KV head over 4-token pages, and six at
* four ranks, each layout's prefill (a long history and a ragged last tile), decode, and the
* widest verify (q_len 5 at gqa 12, 10 at gqa 6). */
@@ -31105,8 +31421,8 @@ static void device_phase(const Plugin& pl) {
for (int form : { 1, 2 }) hc_read_i8(pl, m, true, form);
for (int64_t m : { 700, 2048 }) hc_read_i8(pl, m, true, 3);
}
/* The decode kernels against the ones they replaced: each one-grid instantiation (1 to 7
* rows) and the tiled up-mix at both of its row tiles. */
/* The served decode kernels against the two-grid form: each one-grid instantiation (1 to
* 7 rows) and the tiled up-mix at both of its row tiles. */
for (int64_t m : { 1, 2, 3, 4, 5, 6, 7, 8, 16, 32, 33, 64 })
for (bool i8 : { false, true }) hc_decode_forms(pl, m, i8);
}
@@ -31574,7 +31890,7 @@ static void usage(void) {
" --perfhc M [iters]: hc_read_e4m3 at Qwen3.8-Flash-Next's shape and M rows, every\n"
" prefill-tile form that serves M (the wide kernels at the wide tile,\n"
" PF2 from M=512) compared byte for byte and timed as one op each,\n"
" then the previous decode kernels against the launcher's rule;\n"
" then the two-grid decode form against the launcher's rule;\n"
" run it under libr4d/isa/trace.sh for its launches.\n"
" --cold MIB: with a --perf mode, time cold: read MIB through the caches before\n"
" every timed launch (256 empties this card's L2 and last level) and\n"