Archived
New models and formats: - IQR for Qwen3.8-27B: weights on the int8 grid under GPTQ, a trellis down each GPTQ column (IQR-V2), and IQR-V3, a computed trellis code under one scale a row, kept at its codes' width in VRAM and decoded in the GEMM; 15 IQR-V3 recipes from ~2 to ~7 bits a weight (data/recipes/q38-27b-*-v3.recipe, docs/IQR.md) - libhalo: a kernel library for Strix Halo (gfx1151), preferred there over libr3d - Nemotron 3.5 Embed 1B and 8B (nemotron35_embed): text and image embeddings through a Pixtral tower, on the card and on the CPU - Nemotron 3.5 Rerank 8B - /v1/systemone: Cloudflare's clef and clef-flash, Convai Innovations' Laya and Mica beside LiquidAI d1; scored steps read the candidates' logits from the head table with no lm_head pass - LFM2's 8-bit trunk: block-fp8 or int8 linears with the fused producers, and the d1-3B recipe - DeepSeek-V4.1's reply format with DSML tool calls and typed argument tags Weights on the drive: - The file tier reads only the experts the pass routes rows to; the draft head's weights stay in the host pool - A hot VRAM cache for routed experts read off the drive, reads deposited straight into free host pool slots, and copyless evictions; the file tier's counters are now ssd_* - GLM-5 Next shards its routed experts by expert, not by width, so they can live on the drive - The stall watch counts drive reads as progress, and the DMA lane's room check reads the lane's own completion fence Quantisation tooling: - --calib-corpus, --calib-dir and --calib-layers record each linear's input Hessian; beside --kld-record the reference's own run records them - --kld-top N records a sparse KL reference (the N most likely tokens and the tail's mass) - GPTQ in a third of the time with the same codes, trellis GPTQ on the card, vector codebooks with coordinate descent, and rad-convert --reuse repeated, each container supplying what the earlier ones lack Speculation: - Prompt lookup alone (--spec-ngram K, --spec-ngram-min/-max): each sequence keeps an index of its n-grams, and a proposal is verified only when its measured step cost says it pays; --draft-window adaptive follows it Speed: - IQR decode: the narrow tile splits K for four times the int8 tile's waves and folds each 128-K block once; at 8 tokens down and the output projections run in 0.61-0.82x and 0.70-0.92x FP8's time (2-6 bits); IQ6R-S-V3 with its DFlash2 drafter steps in 26.3 ms at TP2, against 29.4 ms before and FP8's 27.3 - Qwen MXFP4 feed-forward: the gated fold up to 16 rows, not 8 - libr4d: the gated prefill fold, the short-prompt split row, and the rows forms of rmsnorm and rope; KLATE again for the head-256 gqa6 paged prefill; gram_accum on the matrix cores Features: - /health, /v1/health and /ping answer 503 with "status": "stuck" once the device has advanced nothing for a minute or a queue has faulted, so a supervisor can restart a wedged server (#356) - --image-gen-max-pixels and --image-gen-max-refs size an image generator's buffers (#344) - The startup report lists only the options not at their default, with a count; -v lists all (#250) - --preempt-wait-ms bounds how long a preempted prefill waits for its whole-recompute room - --placement layer_offload spills dense layers so one --max-model-len sequence fits - Startup refuses amdgpu with CWSR off and says how to fix it; --proceed-with-incompatible-configuration starts anyway under an UNSUPPORTED banner Fixes: - The n-gram read-ahead hands each row to the reader once and reads only as far ahead as the row cache holds, and pauses while decode reads: about one drive read a row instead of two (#355) - A file-tier window reads each of its runs once, not once a run per run - The decode split law's verify floor is bounded by the batch's workgroups: max_seqs 256 no longer declares 64x the scratch (#342) - A prefetch DMA list's mark stays out of the signal pool until the engine has read it, and a prefill stage copies only the blocks its own tables name (#343) - The split-KV row sum is read with fetch-inactive (#328) - LFM2 on the host backend: libref and libavx serve the row-form ops it declares (#348) - The preempted-prefill gate skips a KV group that holds no blocks (#352) - Every request entry point bounded, gated and sanitised (JSON depth, invalid UTF-8, control bytes in the log, the dashboard's CSP, cross-origin browsers on the loopback-only routes); a prompt id outside the vocabulary refused at admission; --api-key "" refused at startup - The telemetry the HTTP thread reads is atomic - An RMS norm row no longer depends on how many rows its launch carries; prefill attention's rescale is decided by live rows only - A --kld-record prefill chunk that finishes no sequence gets its logits on a tied-head model - A kernel's lazily made counter block is zeroed outside the lock other ranks take (a TP2 first-step hang) Changes: Plugin ABI 32. Every plugin exports a layout fingerprint of the ABI structs and the loader refuses a plugin without it or with another (#302), so out-of-tree plugins must be rebuilt. Appended: RadBuildCtx calib_* and gen_max_*, RadArchProbe gen_max_*, RadBatch score_only and plugin_words, RadDeviceProps::unified, RadChatFormat arg_json_value_prefix.
338 lines
16 KiB
Plaintext
338 lines
16 KiB
Plaintext
/* Derived from libr4d/r4d_gemm_w8a8_tiled.hip by the libhalo rename transform (2026-10-26),
|
|
* then ported to gfx1151; see libhalo/README.md. */
|
|
// halo_gemm_w8a8_tiled.hip - halo_gemm_w8a8_tiled: the W8A8 GEMM for prefill batches.
|
|
//
|
|
// halo_gemm_w4a8_tiled with the weight radix doubled: the inner loop, double buffering, XOR swizzle
|
|
// and magic-bias epilogue are that kernel's, and staging copies the weight's bytes to LDS in
|
|
// `[tile][lane*8 + u*2]` order instead of unpacking nibbles.
|
|
//
|
|
// At prefill the promotion to eight bits is nearly free: the kernel is matrix-bound and the WMMA
|
|
// count does not depend on the radix, while twice the weight and LDS bytes are amortised over BM
|
|
// rows. (A skinny kernel would re-read the weight M/(16*MB) times.)
|
|
//
|
|
// The packed layout is halo_gemm_w8a8_nt_m64's: a lane owns 16 bytes of a 32-column block, staged
|
|
// with coalesced global_load_b128 to `lane*8 + kh*4` dwords of the tile's LDS run. One weight feeds
|
|
// both kernels. The scale plane is f16 only: a symmetric 8-bit grid has no zero point.
|
|
//
|
|
#include "halo.h"
|
|
#include "halo_gemm_args.h"
|
|
#include "halo_common.h"
|
|
#include "halo_gdn_wmma.h" // accRow: the gfx11 accumulator row mapping
|
|
#include <hip/hip_bf16.h>
|
|
#include <hip/hip_fp16.h>
|
|
#include <cstdint>
|
|
#include <stdexcept>
|
|
|
|
#define HALO_TILED8_KPB 32 // packed block: 32 columns, 16 bytes a lane
|
|
// BK = 32, not the 4-bit kernel's 64: at BK = 64 the 64x256 tile needs 40960 B of LDS (one
|
|
// workgroup per CU); BK = 32 needs 20480 B (three), worth several percent on down_proj at every
|
|
// prefill M despite twice the barriers per scale group.
|
|
#define HALO_TILED8_BK 32
|
|
|
|
typedef int v2i8_t __attribute__((ext_vector_type(2)));
|
|
typedef int v4i8_t __attribute__((ext_vector_type(4)));
|
|
typedef int v8i8_t __attribute__((ext_vector_type(8)));
|
|
typedef float v8f8_t __attribute__((ext_vector_type(8)));
|
|
typedef unsigned u4v8_t __attribute__((ext_vector_type(4)));
|
|
|
|
// WM x WN waves, each owning TM x TN WMMA tiles. BM = WM*TM*16, BN = WN*TN*16. UNR k blocks are
|
|
// unrolled per scale group. The accumulator carries the magic bias of halo_gemm_w4a8_tiled.hip:
|
|
// for |x| < 2^22, float(x) == __uint_as_float(0x4B400000 + x) - 12582912.0f.
|
|
//
|
|
// `Asum` is always null (an 8-bit grid here is symmetric). The slot keeps the 4-bit kernel's
|
|
// argument layout: dropping it changes the generated code of the tuned tiles.
|
|
// No minimum-occupancy bound: libr4d's 8 waves a SIMD caps a lane at 192 VGPRs on gfx1151 and
|
|
// spilled most arms (the 4x2 tile 158-165 slots); unbounded, the arms run 1.1-2.4x faster.
|
|
// PART: the grid's last row of blocks is cut by M, and its waves skip the WMMAs and folds of their
|
|
// padding fragments past M (wave-uniform; those rows are never stored). Only the launch for a
|
|
// ragged M instantiates it, so whole-band grids run the unguarded kernel.
|
|
template <int WM, int WN, int TM, int TN, int UNR, bool PART = false>
|
|
__global__ __launch_bounds__(WM * WN * 32) void halo_gemm_w8a8_tiled_kernel(
|
|
const signed char* __restrict__ A, const float* __restrict__ Ascale,
|
|
const unsigned* __restrict__ Wq, const unsigned* __restrict__ Ws,
|
|
const float* __restrict__ Asum, __hip_bfloat16* __restrict__ C, int M, int K, int N) {
|
|
constexpr int BK = HALO_TILED8_BK;
|
|
constexpr int GRP = HALO_GEMM_W8A8_GROUP;
|
|
constexpr int BM = WM * TM * 16, BN = WN * TN * 16;
|
|
constexpr int NTILE = BN / 16;
|
|
constexpr int AW = BM * BK / 4; // A dwords per buffer
|
|
constexpr int WW = NTILE * BK * 4; // W dwords per buffer: NTILE*16 rows x BK bytes
|
|
|
|
__shared__ unsigned lds_a[2][AW];
|
|
__shared__ unsigned lds_w[2][WW];
|
|
|
|
const int tid = threadIdx.x, lane = tid & 31, wave = tid >> 5;
|
|
const int wm = wave / WN, wn = wave % WN;
|
|
// halo_gemm_bf16_nt_tiled's block order: groups of 8 activation bands, M fastest, so the bands
|
|
// of one column block run together and share its weight through the cache -- a ragged last band
|
|
// then re-reads the weight from L2, not from DRAM after every other band is done.
|
|
constexpr unsigned kGroupM = 8;
|
|
const unsigned per = kGroupM * gridDim.x, lin = blockIdx.y * gridDim.x + blockIdx.x;
|
|
const unsigned first = lin / per * kGroupM, rr = lin % per;
|
|
const unsigned gm = min(gridDim.y - first, kGroupM);
|
|
const int m0 = (int)(first + rr % gm) * BM, bx = (int)(rr / gm), n0 = bx * BN;
|
|
const int live = PART ? __builtin_amdgcn_readfirstlane(
|
|
min(TM, max(0, (M + 15) / 16 - (m0 / 16 + wm * TM))))
|
|
: TM;
|
|
const int kpb = K / HALO_TILED8_KPB, nsz = K / GRP;
|
|
constexpr int NT_ = WM * WN * 32;
|
|
|
|
v8f8_t acc[TN][TM];
|
|
#pragma unroll
|
|
for (int j = 0; j < TN; j++)
|
|
#pragma unroll
|
|
for (int i = 0; i < TM; i++) acc[j][i] = (v8f8_t)(0.f);
|
|
v8i8_t g[TN][TM];
|
|
float csum[TN];
|
|
#pragma unroll
|
|
for (int j = 0; j < TN; j++) csum[j] = 0.f;
|
|
unsigned scv[TN];
|
|
|
|
// XOR swizzle of the A rows instead of padding, separating rows r >> 1 (see
|
|
// halo_gemm_w4a8_tiled.hip). The XOR must stay inside a row of BK/4 = 8 dwords, so the mask is
|
|
// derived from BK and steps by 2 for ds_load_b64 alignment.
|
|
#define ASW_M2 ((BK / 8) - 1)
|
|
#define ASW(r, c) ((r) * (BK / 4) + ((c) ^ ((((r) >> 1) & ASW_M2) << 1)))
|
|
|
|
// Prefetch into registers, compute off the other buffer, then commit to LDS, so the load wait
|
|
// lands after the WMMA work (a prefetch that writes LDS directly would stall the compute; >2x).
|
|
// Both stagings may be ragged (a predicate on the last pass), so the tile need not divide the
|
|
// workgroup width (e.g. BM = 80, 112; at BK = 32 the NTILE*32 weight chunks).
|
|
constexpr int APT = (AW + NT_ - 1) / NT_;
|
|
constexpr bool APAD = (AW % NT_) != 0;
|
|
unsigned ra[APT];
|
|
constexpr int WWP = NTILE * BK; // 16-byte weight chunks per buffer
|
|
constexpr int WPTU = (WWP + NT_ - 1) / NT_;
|
|
constexpr bool WPAD = (WWP % NT_) != 0;
|
|
u4v8_t rwu[WPTU];
|
|
// Global indices into A are 32-bit: a 64-bit address costs four extra instructions per load.
|
|
auto issue = [&](int kk) {
|
|
// Sixteen bytes per thread, copied unchanged. A lane owns 16 bytes of a 32-column packed
|
|
// block; at BK = 64 `kh` would pick one of two blocks 512 bytes apart. Coalesced across the
|
|
// wave.
|
|
#pragma unroll
|
|
for (int x = 0; x < WPTU; x++) {
|
|
const int t = tid + x * NT_;
|
|
if (WPAD && t >= WWP) continue;
|
|
const int tl = t / BK, rem = t % BK, kh = rem / 32, ln = rem % 32;
|
|
rwu[x] = *((const u4v8_t*)Wq +
|
|
(size_t)(((n0 / 16 + tl) * kpb + kk / HALO_TILED8_KPB + kh) * 32 + ln));
|
|
}
|
|
#pragma unroll
|
|
for (int x = 0; x < APT; x++) {
|
|
const int t = tid + x * NT_, r = t / (BK / 4), c = t % (BK / 4);
|
|
if (APAD && t >= AW) continue;
|
|
const int mm = m0 + r < M ? m0 + r : M - 1;
|
|
ra[x] = *(const unsigned*)(A + (unsigned)(mm * K + kk + c * 4));
|
|
}
|
|
};
|
|
auto commit = [&](int buf) {
|
|
#pragma unroll
|
|
for (int x = 0; x < WPTU; x++) {
|
|
const int t = tid + x * NT_;
|
|
if (WPAD && t >= WWP) continue;
|
|
const int tl = t / BK, rem = t % BK, kh = rem / 32, ln = rem % 32;
|
|
// [tile][lane][u][2] dwords: a lane's 16 bytes are k steps 2*kh and 2*kh+1, four
|
|
// consecutive dwords at `ln*8 + kh*4`, one ds_store_b128.
|
|
*(u4v8_t*)(lds_w[buf] + (size_t)tl * (BK * 4) + ln * (BK / 8) + kh * 4) = rwu[x];
|
|
}
|
|
#pragma unroll
|
|
for (int x = 0; x < APT; x++) {
|
|
const int t = tid + x * NT_, r = t / (BK / 4), c = t % (BK / 4);
|
|
if (APAD && t >= AW) continue;
|
|
lds_a[buf][ASW(r, c)] = ra[x];
|
|
}
|
|
};
|
|
|
|
issue(0);
|
|
commit(0);
|
|
__syncthreads();
|
|
|
|
// Unroll the K loop over the group (UNR = GRP/BK) so the group-boundary tests are compile-time per
|
|
// copy; a dynamic branch around the epilogue stops the scheduler interleaving it with the WMMA.
|
|
// Worth several percent.
|
|
for (int kg = 0, it = 0; kg < K; kg += BK * UNR) {
|
|
#pragma unroll
|
|
for (int h = 0; h < UNR; h++, it++) {
|
|
const int k0 = kg + h * BK;
|
|
const int buf = it & 1;
|
|
if (k0 + BK < K) issue(k0 + BK); // loads in flight across the WMMA work below
|
|
|
|
const bool first_half = (k0 % GRP) == 0;
|
|
// Fetch the group scale at the start of the group, so the waves do not all stall on it at the
|
|
// fold; keep the raw bits and convert at the group close. 32-bit index: the table has at most
|
|
// (N/16)*(K/GRP)*16 elements.
|
|
if ((k0 % GRP) == 0) {
|
|
#pragma unroll
|
|
for (int j = 0; j < TN; j++)
|
|
scv[j] = (unsigned)((const unsigned short*)Ws)[(unsigned)(((n0 / 16 + wn * TN + j) * nsz +
|
|
k0 / GRP) * 16 + (lane & 15))];
|
|
}
|
|
#pragma unroll
|
|
for (int u = 0; u < BK / 16; u++) {
|
|
v4i8_t af[TM];
|
|
#pragma unroll
|
|
for (int i = 0; i < TM; i++) {
|
|
/* The A tile is staged row-major, so the gfx11 fragment is the row's sixteen
|
|
* consecutive bytes: four dwords, each through the row XOR swizzle. */
|
|
const int row = (wm * TM + i) * 16 + (lane & 15);
|
|
#pragma unroll
|
|
for (int d = 0; d < 4; d++)
|
|
af[i][d] = (int)lds_a[buf][ASW(row, u * 4 + d)];
|
|
}
|
|
#pragma unroll
|
|
for (int j = 0; j < TN; j++) {
|
|
/* The W tile keeps libr4d's fragment order in LDS ([tile][lane][u][2] dwords): a
|
|
* lane's two dwords hold K quarters (0,2) in the low half-wave and (1,3) in the high,
|
|
* so the gfx11 fragment takes the cross-half partner's staged dwords too. */
|
|
const unsigned* lw = lds_w[buf] + (size_t)(wn * TN + j) * (BK * 4) + lane * (BK / 8) + u * 2;
|
|
const unsigned* pw = lds_w[buf] + (size_t)(wn * TN + j) * (BK * 4) + (lane ^ 16) * (BK / 8) + u * 2;
|
|
const bool hi = lane >> 4;
|
|
v4i8_t bf;
|
|
bf[0] = (int)(hi ? pw[0] : lw[0]);
|
|
bf[1] = (int)(hi ? lw[0] : pw[0]);
|
|
bf[2] = (int)(hi ? pw[1] : lw[1]);
|
|
bf[3] = (int)(hi ? lw[1] : pw[1]);
|
|
#pragma unroll
|
|
for (int i = 0; i < TM; i++) {
|
|
if (PART && i >= live) continue; // wave-uniform: padding fragments past M
|
|
g[j][i] = (first_half && u == 0)
|
|
? __builtin_amdgcn_wmma_i32_16x16x16_iu8_w32(
|
|
true, af[i], true, bf, (v8i8_t)(0x4B400000), false)
|
|
: __builtin_amdgcn_wmma_i32_16x16x16_iu8_w32(
|
|
true, af[i], true, bf, g[j][i], false);
|
|
}
|
|
}
|
|
}
|
|
|
|
if ((k0 + BK) % GRP == 0) { // the group closed: fold it into the float acc
|
|
float sc[TN];
|
|
#pragma unroll
|
|
for (int j = 0; j < TN; j++)
|
|
sc[j] = __half2float(__ushort_as_half((unsigned short)(scv[j] & 0xFFFFu)));
|
|
#pragma unroll
|
|
for (int j = 0; j < TN; j++) csum[j] += sc[j];
|
|
#pragma unroll
|
|
for (int i = 0; i < TM; i++) {
|
|
if (PART && i >= live) continue;
|
|
#pragma unroll
|
|
for (int j = 0; j < TN; j++)
|
|
#pragma unroll
|
|
for (int e = 0; e < 8; e++)
|
|
acc[j][i][e] = fmaf(__uint_as_float((unsigned)g[j][i][e]), sc[j], acc[j][i][e]);
|
|
}
|
|
}
|
|
if (k0 + BK < K) commit(buf ^ 1); // the wait for those loads lands here
|
|
__syncthreads();
|
|
}
|
|
}
|
|
#undef ASW
|
|
#undef ASW_M2
|
|
|
|
#pragma unroll
|
|
for (int j = 0; j < TN; j++) {
|
|
const float d = -12582912.0f * csum[j];
|
|
#pragma unroll
|
|
for (int i = 0; i < TM; i++)
|
|
#pragma unroll
|
|
for (int e = 0; e < 8; e++) acc[j][i][e] += d;
|
|
}
|
|
|
|
// The flat predicated store, as in the 4-bit kernel.
|
|
#pragma unroll
|
|
for (int j = 0; j < TN; j++)
|
|
#pragma unroll
|
|
for (int i = 0; i < TM; i++)
|
|
#pragma unroll
|
|
for (int e = 0; e < 8; e++) {
|
|
const int n = n0 + (wn * TN + j) * 16 + (lane & 15);
|
|
const int m = m0 + (wm * TM + i) * 16 + accRow(lane, e);
|
|
if (n < N && m < M)
|
|
// No 1/16 here, unlike the 4-bit kernel: an 8-bit code is the byte itself, with no
|
|
// high-nibble factor to undo.
|
|
C[(size_t)m * N + n] = (__hip_bfloat16)(acc[j][i][e] * Ascale[m]);
|
|
}
|
|
}
|
|
|
|
// CANPART: this arm instantiates the PART kernel for a ragged M (the default arm; the tuned arms
|
|
// keep one kernel each).
|
|
template <int WM, int WN, int TM, int TN, int UNR, bool CANPART = false>
|
|
static void halo_tiled8_launch(long a, long ascale, long wq, long ws, long c, int M, int K, int N,
|
|
long stream) {
|
|
constexpr int BM = WM * TM * 16, BN = WN * TN * 16;
|
|
// An 8-bit weight doubles the staged bytes.
|
|
static_assert(2 * (BM * HALO_TILED8_BK / 4 + (BN / 16) * HALO_TILED8_BK * 4) * sizeof(unsigned) <=
|
|
64 * 1024, "this tile needs more than 64 KB of LDS");
|
|
if (N % BN)
|
|
throw std::runtime_error("r4d gemm_w8a8_tiled: N is not a multiple of this variant's block");
|
|
dim3 grid(N / BN, (M + BM - 1) / BM), block(WM * WN * 32);
|
|
if (CANPART && M % BM)
|
|
hipLaunchKernelGGL((halo_gemm_w8a8_tiled_kernel<WM, WN, TM, TN, UNR, CANPART>), grid, block, 0,
|
|
(hipStream_t)stream, (const signed char*)a, (const float*)ascale,
|
|
(const unsigned*)wq, (const unsigned*)ws, nullptr, (__hip_bfloat16*)c, M, K,
|
|
N);
|
|
else
|
|
hipLaunchKernelGGL((halo_gemm_w8a8_tiled_kernel<WM, WN, TM, TN, UNR>), grid, block, 0,
|
|
(hipStream_t)stream, (const signed char*)a, (const float*)ascale,
|
|
(const unsigned*)wq, (const unsigned*)ws, nullptr, (__hip_bfloat16*)c, M, K,
|
|
N);
|
|
}
|
|
|
|
void halo_gemm_w8a8_tiled(long a, long ascale, long wq, long ws, long c, int M, int K, int N,
|
|
long stream, int variant) {
|
|
if (N % 256) throw std::runtime_error("r4d gemm_w8a8_tiled: N must be a multiple of 256");
|
|
if (K % HALO_GEMM_W8A8_GROUP)
|
|
throw std::runtime_error("r4d gemm_w8a8_tiled: K must be a multiple of the scale group");
|
|
if (M < 1) throw std::runtime_error("r4d gemm_w8a8_tiled: M must be positive");
|
|
// The unroll covers exactly one scale group (GRP/BK steps); see halo_gemm_w4a8_tiled.hip. The K
|
|
// check above makes every K a whole number of them.
|
|
static_assert(HALO_GEMM_W8A8_GROUP % HALO_TILED8_BK == 0, "the scale group must be whole k steps");
|
|
constexpr int UNRG = HALO_GEMM_W8A8_GROUP / HALO_TILED8_BK;
|
|
#define HALO_TILED8_LAUNCH(...) \
|
|
halo_tiled8_launch<__VA_ARGS__>(a, ascale, wq, ws, c, M, K, N, stream)
|
|
// The arms tile_bmbn in halo_rows.cpp lists, with the (BM, BN) it records for each.
|
|
switch (variant) {
|
|
case 6: HALO_TILED8_LAUNCH(2, 8, 2, 2, UNRG); break; // BM 64, BN 256
|
|
case 10: HALO_TILED8_LAUNCH(2, 8, 3, 2, UNRG); break; // BM 96, BN 256
|
|
case 12: HALO_TILED8_LAUNCH(2, 8, 3, 1, UNRG); break; // BM 96, BN 128
|
|
case 57: HALO_TILED8_LAUNCH(2, 8, 5, 1, UNRG); break; // BM 160, BN 128
|
|
case 59: HALO_TILED8_LAUNCH(2, 8, 4, 1, UNRG, true); break; // BM 128, BN 128
|
|
case 114: HALO_TILED8_LAUNCH(1, 8, 5, 1, UNRG); break; // BM 80, BN 128
|
|
case 124: HALO_TILED8_LAUNCH(1, 8, 4, 1, UNRG); break; // BM 64, BN 128
|
|
case 125: HALO_TILED8_LAUNCH(1, 8, 7, 1, UNRG); break; // BM 112, BN 128
|
|
case 126: HALO_TILED8_LAUNCH(1, 8, 10, 1, UNRG); break; // BM 160, BN 128
|
|
case 128: HALO_TILED8_LAUNCH(1, 8, 2, 1, UNRG); break; // BM 32, BN 128
|
|
case 129: HALO_TILED8_LAUNCH(1, 8, 3, 1, UNRG); break; // BM 48, BN 128
|
|
case 138: HALO_TILED8_LAUNCH(1, 16, 3, 1, UNRG); break; // BM 48, BN 256
|
|
case 139: HALO_TILED8_LAUNCH(1, 16, 7, 1, UNRG); break; // BM 112, BN 256
|
|
case 146: HALO_TILED8_LAUNCH(1, 8, 9, 1, UNRG); break; // BM 144, BN 128
|
|
// The untuned default is arm 59's tile (BM 128 x BN 128): 32-34 TFLOP/s on gfx1151 against
|
|
// 15-19 for libr4d's 4x2 default (see halo_gemm_w4a8_tiled.hip); the bytes are the same.
|
|
default: HALO_TILED8_LAUNCH(2, 8, 4, 1, UNRG, true); break;
|
|
}
|
|
#undef HALO_TILED8_LAUNCH
|
|
}
|
|
|
|
// ============================================================== the plugin ABI entry points
|
|
//
|
|
// The operand reader and the split law are in halo_gemm_args.h; see libhalo/halo_args.h.
|
|
extern "C" int halo_rad_gemm_w8a8_tiled(const RadArgs* a, RadStream s) {
|
|
GemmOps g;
|
|
int rc = gemm_ops(a, &g, 1);
|
|
if (rc != RAD_OK) return rc;
|
|
if (!g.ascale) return HALO_NO(RAD_E_INVAL);
|
|
if (is_asym(a)) return HALO_NO(RAD_E_UNSUPPORTED);
|
|
if (g.N % 256) return HALO_NO(RAD_E_SHAPE);
|
|
if (g.K % HALO_GEMM_W8A8_GROUP) return HALO_NO(RAD_E_SHAPE);
|
|
HaloTileCfg tv;
|
|
halo_cfg_tiled(a, &tv);
|
|
const HaloTileCfg* t = &tv;
|
|
rc = tile_ok(t, g.N);
|
|
if (rc != RAD_OK) return rc;
|
|
HALO_TRY("gemm_w8a8_tiled",
|
|
halo_gemm_w8a8_tiled(halo_addr(g.a), halo_addr(g.ascale), halo_addr(g.b), halo_addr(g.bscale),
|
|
halo_addr(g.y), (int)g.M, (int)g.K, (int)g.N, (long)(uintptr_t)s,
|
|
t->variant));
|
|
return RAD_OK;
|
|
}
|