Archived
New models:
- Hunyuan3D-2 (hunyuan3d2): an untextured 3-D mesh from one picture of an object. DINOv2-giant
over the picture, a FLUX-shaped flow-matching DiT (16 double-stream and 32 single-stream blocks
of 1024) over 3072 latents with both guidance branches in one step, and the shape VAE's
geometry decoder. Converted from tencent/Hunyuan3D-2's hunyuan3d-dit-v2-0 folder with
data/recipes/hunyuan3d-2-bf16.recipe (fp16 cast to bf16, 4.4 GiB, one card). The licence
(Tencent Hunyuan 3D 2.0 Community License) does not cover the EU, the UK or South Korea
- Served on Hunyuan3D-2's own API server routes, so its Blender add-on and scripts work
unchanged: POST /generate answers with the mesh, POST /send runs it in the background and
GET /status/{uid} reports steps_done and then the file. GLB, OBJ, PLY or STL; the field is
sampled coarse to fine as FlashVDM's hierarchical decoding does, or densely with
"volume_decoding": "dense"; seed, steps, guidance and octree_resolution as the reference.
Texturing (Hunyuan3D-Paint) is refused for now (docs/GUIDE.md §5.17)
Merged:
- libr3d rewritten for RDNA3's wave matrix (@RikshaDriver): bf16, f16, int8-activation and vocab
GEMMs retiled to 16x128 blocks with a double-buffered k-walk; fp8, mxfp4a8, w2a8, w4a16, w5a16
and w8a8 quantised GEMMs and the gated form; grouped MoE GEMMs (bf16, fp8a8f32, mxfp4a8); the
norms and quantisers, the QSA state ops and the MoE router, scatter and gather. Brought onto the
op contract before release (13 schemas, the MoE GEMMs on weight tables with a_order and bf16
output, moe_gather's gate pitch, moe_scatter above 1024 slots, the mxfp4 m16 dispatch) and its
gated-delta-net kernels replaced by libhalo's; every op it serves now passes rad-kbench against
libref on a gfx1151, and r3d_selftest checks its MoE GEMMs by value
- Gemma 4 31B: asymmetric int5 linears (w5a8i8 above 64 rows, w5a16 up to 64, a scale per 128),
the norm, GELU and two-rank all-reduce junctions at quant_act_i8g's grid (rmsnorm_quant_i8g,
gelu_mul_quant_i8g, ar_rmsnorm_quant_i8g) so the prefill overlap runs on the i8a8, a4 and w5
trunks, and compose files for the 31B i8g, heretic-ara-i8g and w5 on two cards (@keptn42)
- The norms' lane sum reads eight at a time: TranslateGemma 27B decode is back from 225 to 239
tok/s a stream at four streams, bit for bit the same output (@mici81)
- The head-256 prefill softmax rescales each row by its own maximum, not by a vote of the wave, so
a row's rounding no longer depends on which rows share its launch (@gostar)
Anthropic Messages API:
- /v1/messages takes min_p, presence_penalty, frequency_penalty, repetition_penalty and
repeat_last_n as top-level fields with the chat path's names, ranges and meaning, so clients that
speak only the Anthropic format (Claude Code) can set a model card's sampling, such as Qwen's
presence_penalty 1.5. The penalties count the last repeat_last_n tokens of prompt and reply (64
by default, --repeat-last-n), as llama.cpp does
Plugin ABI 33:
- Shape generators: rad_declare_shape_generator, RadShapeGenBatch (RadBatch::sgen_b) and
RadArchProbe::gen_shape, with the SCOND, SSTEP, SLATENT and SQUERY passes. The layout
fingerprint table is regenerated; out-of-tree plugins rebuild against 33
- New op point_fourier ([x | sin(x 2^j) | cos(x 2^j)], times pi on request) in libref, libavx,
libr4d and libhalo
- A checkpoint for a model that reads no text gets a one-token vocabulary
More cards from the one image:
- stilldeadcode/radiance now carries libr3d (RDNA3: gfx11-generic, every gfx11 chip) and libhalo
(Strix Halo: gfx1151, preferred there over libr3d) beside libr4d (gfx1201). docker/build.sh and
the Dockerfile default to gfx1201;gfx11-generic;gfx1151
- libr3d loads only where the KFD topology lists a gfx11 card and libhalo only where it lists a
gfx1151; a process without /dev/kfd sees neither. On an RDNA4 card, or with no card at all,
the image therefore behaves exactly as before, and rad-convert lays weights out as before
- libhalo and libr3d now declare gemm_nt_q's w_rb, and libhalo gram_accum's upper, as libr4d
does. Before, any build carrying them refused both at load ("9 parameters vs 8"), so a build
for Strix Halo or RDNA3 had no device kernel library
- libhalo does not yet have every op libr4d added after it was ported (the IQR rows, Pixtral and
Ministral rope, the tree-attention and DFlash-tree rows, among others); halo_parity lists them
and is left out of the image's test stage until they are ported
Fixed -- container and checkpoint parsing:
- A .rad expert-1 entry inside or before expert 0 is refused; a vocab section whose count names
an array at offset 0 is refused rather than read from the file header; offset checks no longer
wrap; header tables must sit on their element alignment
- An imatrix array of arrays (unbounded recursion) and a safetensors header naming a tensor twice
are refused; a failed RadWriter undo says the container is damaged; a tune cache measured on
another machine is refused, as its format contract says
Fixed -- plugins:
- Two plugins declaring one op with different parameter roles are refused; before, the core
applied the first one's chunk/capacity roles to the other's rows
- Null tables behind nonzero counts, unknown roles, keyless parameters or constraints and more
operands than an issue carries are refused by name at load; on the host backend device rows are
dropped even when no fat binary was registered; rad-schemas checks the ABI layout fingerprint as
the engine does
Fixed -- device:
- Stream slots are recycled under a new generation: before, 1024 stream create/destroy cycles
(LoRA loads, lanes, uplinks) made every later rad_stream_create fail
- A stream whose drain fails keeps its queue and kernarg ring instead of freeing them under the
card; the kernarg ring no longer leaks when its access grant fails; a block over 1024 work-items
is refused
- rad_dev_free takes the allocation off the ledger the pin-cap check reads; the host backend
charges pages to the card the range was reserved for
Fixed -- engine and server:
- Two NDEBUG-only asserts (runtime-window totals, ring blocks per group) are refusals; a
plugin-declared lcm past int64 saturates so the quantum check refuses it; every share view rect
and part span is bounded by its entry
- Video: the timestep regions hold the refine rungs a schedule appends, a zero-frame encode is
refused, /v1/videos bounds each side before the area product, and a realtime session needs a
clip length to cut a turn at
Fixed -- kernels and quantisation:
- A trellis run shorter than a state's codes (tcq_rows=1, or N % tcq_rows == 1) read its seam
out of bounds; the encoder now refuses it as the decoder does, and tcq_rows below one state is
refused at parse
- qsa_tail_store bounds its slot index by the state plane (libr4d and libhalo); paged attention
refuses kv_heads <= 0; libavx row_amax skips a NaN as libref does
Fixed -- tools:
- pad_tp.py no longer runs cp through a shell with shard names from the checkpoint's index
(quote injection, path traversal): names must be bare file names
- ops_doc_check.sh runs under mawk (Ubuntu's awk); rad-kbench --max-cases/--max-bytes are checked
integers; oot_plugins fails unless the installed replay passed a case and failed none
Thanks to @RikshaDriver, @keptn42, @mici81 and @gostar.
1032 lines
66 KiB
C
1032 lines
66 KiB
C
/* r4d_plugin.h -- what libr4d's translation units share.
|
|
*
|
|
* The row table (r4d_rows.cpp) and the weight layouts (r4d_layout.cpp) are pure host C++ and
|
|
* include only this file and the ABI; the launch shims include r4d.h and so <hip/hip_runtime.h>.
|
|
* The split lets the constraint table compile and be checked without ROCm, and is why every shim
|
|
* is declared here rather than beside its definition.
|
|
*
|
|
* Nothing in this header may include r4d.h.
|
|
*/
|
|
#ifndef RAD_R4D_PLUGIN_H
|
|
#define RAD_R4D_PLUGIN_H
|
|
|
|
#include "r4d_args.h"
|
|
|
|
|
|
extern "C" {
|
|
int r4d_rad_pixtral_patch(const RadArgs*, RadStream);
|
|
int r4d_rad_position_scale(const RadArgs*, RadStream);
|
|
int r4d_rad_ministral_rope(const RadArgs*, RadStream);
|
|
int r4d_rad_pixtral_rope(const RadArgs*, RadStream);
|
|
int r4d_rad_pixtral_merge(const RadArgs*, RadStream);
|
|
int r4d_rad_embed_attn(const RadArgs*, RadStream);
|
|
int64_t r4d_nemotron_scratch(const RadArgs*);
|
|
int r4d_ministral_init(const RadParam*, int, int, int, void**);
|
|
int r4d_pixtral_init(const RadParam*, int, int, int, void**);
|
|
void r4d_rotary_fini(void*);
|
|
}
|
|
|
|
/* ================================================================== the priority ladder
|
|
*
|
|
* The selector ranks candidate rows by an integer priority (spec §2.1); where two rows of one op
|
|
* can match a geometry, it decides which serves. Each group states the reason for its order.
|
|
* Values are spaced by ten so a row can be slipped between two without renumbering.
|
|
*/
|
|
enum {
|
|
/* A two-shot row's constraints are a superset of the one-shot's at the same world_size, so it
|
|
* must rank higher to be reachable. Its lower bound on `numel` keeps small messages on the
|
|
* one-shot. */
|
|
R4D_PRIO_AR_TWOSHOT = 70,
|
|
R4D_PRIO_AR_ONESHOT = 60,
|
|
|
|
/* `attn_paged` is banded on q_len, and the decode row's bound (q_len<=10 at h256, q_len<=16 at
|
|
* h128) is a bucket boundary, not a partition: both rows match in the low band, so decode must
|
|
* outrank prefill. */
|
|
R4D_PRIO_ATTN_DECODE = 70,
|
|
R4D_PRIO_ATTN_PREFILL = 60,
|
|
/* A lossy prefill row (e4m3 products) matches only a caller that states `prefill_fp8`, where
|
|
* the exact row matches too, so it ranks above it and below decode. */
|
|
R4D_PRIO_ATTN_PREFILL_FP8 = 61,
|
|
/* The windowed kernels (r4d_attn_paged_window.hip) serve every q_len, so where their geometry
|
|
* meets another leg's (h256 at gqa 2) they match in both of that leg's bands and rank below
|
|
* both: on R9700 at the 31B's shapes (window 1024, fp8 cache) the h256/gqa2 decode kernel takes
|
|
* 0.26-0.71 of the windowed kernel's time at q_len 1..32 and its prefill kernel 0.43-0.67 at
|
|
* 33..512, bf16 cache similar. The windowed rows keep that geometry's non-causal band past
|
|
* q_len 32, and attn_paged_qrow, which no other kernel serves. */
|
|
R4D_PRIO_ATTN_WINDOW = 50,
|
|
|
|
/* At M<=16 with K%256==0 both bf16 skinny rows match and the m16 (dot2) kernel is taken. The
|
|
* m64 WMMA kernel is faster on every shape measured, so a caller wanting it at low M asks with
|
|
* M=64 to exclude m16. */
|
|
R4D_PRIO_GEMM_M16 = 60,
|
|
R4D_PRIO_GEMM_SKINNY = 50,
|
|
/* The MXFP4 decode row outranks the MXFP4 skinny row, whose band it shares up to N = 36864. */
|
|
R4D_PRIO_GEMM_MXDEC = 55,
|
|
/* The MXFP4 gemv row (one to eight rows) outranks the decode row, whose band it shares there. */
|
|
R4D_PRIO_GEMM_MXGEMV = 58,
|
|
/* The decode kernel's short-K row outranks gemv_wide in the one corner of its band where the
|
|
* decode kernel is faster (33..64 rows, N >= 8192, K <= 2560). */
|
|
R4D_PRIO_GEMM_MXDEC_SHORTK = 59,
|
|
/* The skinny m64 row has no upper bound on M, so the tiled bf16 row (M > 64 only) must outrank
|
|
* it, and stays below m16, whose band it never enters. */
|
|
R4D_PRIO_GEMM_BF16_TILED = 55,
|
|
|
|
/* Bands already separate these from the skinny kernels (skinny is M<=64, these unbounded), so
|
|
* this pair only decides M>64. `pf` is the newer kernel and its tuned picks fall back to the
|
|
* tiled one, so it outranks. Not expressible here: the optimum crosses between the two kernels
|
|
* at a shape-dependent M, and tuning varies only within a kernel. */
|
|
R4D_PRIO_GEMM_PREFILL = 40,
|
|
R4D_PRIO_GEMM_TILED = 30,
|
|
|
|
/* The block-scaled fp8 family. fp8a16 is a separate dtype and needs no ordering against these;
|
|
* the narrow fp8a8 row's M <= 16 is a subset of the tiled row's unbounded M, so it must
|
|
* outrank. No dtype string reaches both these and the skinny int8 GEMMs. */
|
|
R4D_PRIO_GEMM_FP8_M16 = 60,
|
|
R4D_PRIO_GEMM_FP8_TILED = 40,
|
|
/* The lm_head at fp8 (and int8), above the bf16 projection, which reads twice the bytes.
|
|
* The head's encoding, fixed at conversion, decides which rows are candidates (spec §4.3):
|
|
* these rows' layout hooks refuse a bf16 head, and the bf16 row has no hook for a scaled
|
|
* one. */
|
|
R4D_PRIO_LOGITS_FP8 = 60,
|
|
/* The bf16 head's column form, above the block-per-column row whose bytes it gives, at the
|
|
* n_embd it is built for. */
|
|
R4D_PRIO_LOGITS_COLS = 55,
|
|
|
|
/* Runtime LoRA: the tiled rows serve a subset of the scalar rows' dtypes at every M, so they
|
|
* must outrank them to be reached; the scalar rows keep f16 / f32 activations (no exact WMMA)
|
|
* and a coded activation whose scale group is not whole 32-wide steps, and stay reachable by
|
|
* name. The choice never depends on M -- a row's bytes would then depend on its batch. */
|
|
R4D_PRIO_LORA_TILED = 60,
|
|
R4D_PRIO_LORA_SCALAR = 50,
|
|
|
|
/* Exactly one candidate row per (op, geometry). The value carries no ordering; it leaves a
|
|
* user's override plugin room above and below. */
|
|
R4D_PRIO_ONLY = 50,
|
|
};
|
|
|
|
/* ================================================================== the shims
|
|
*
|
|
* Declared here, defined in the HIP translation units. r4d_rows.cpp takes their addresses and so
|
|
* stays free of r4d.h.
|
|
*/
|
|
extern "C" {
|
|
|
|
/* -- attention (r4d_attn_*.hip) -- */
|
|
int r4d_rad_attn_prefill_h256_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_prefill_h256_fp8_qk8(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_prefill_h256_fp8_pv8(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_prefill_h256_fp8_qk8pv8(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_prefill_h256_bf16(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_decode_h256_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_decode_h256_fp8v4(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_prefill_h256_fp8v4(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_prefill_h256_fp8v4_qk8(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_prefill_h256_fp8v4_pv8(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_prefill_h256_fp8v4_qk8pv8(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_decode_h256_v4_scratch(const RadArgs*);
|
|
int r4d_rad_attn_decode_h256_k6v4(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_prefill_h256_k6v4(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_prefill_h256_k6v4_qk8(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_prefill_h256_k6v4_pv8(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_prefill_h256_k6v4_qk8pv8(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_decode_h256_k6_scratch(const RadArgs*);
|
|
int r4d_rad_attn_decode_h256_bf16 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_decode_h128_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_decode_h128_bf16 (const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_decode_h256_scratch(const RadArgs*);
|
|
/* The prefill rows' KV-split partials (r4d_attn_paged_h256_gqa6.hip, prefill_scratch), by cache
|
|
* row: fp8 and bf16, fp8_v4, k6_v4. */
|
|
int64_t r4d_rad_attn_prefill_h256_scratch(const RadArgs*);
|
|
int64_t r4d_rad_attn_prefill_h256_v4_scratch(const RadArgs*);
|
|
int64_t r4d_rad_attn_prefill_h256_k6_scratch(const RadArgs*);
|
|
int64_t r4d_rad_attn_decode_h128_scratch(const RadArgs*);
|
|
/* Gemma 4 dense sliding window (r4d_attn_paged_h256_gqa2.hip): head_dim 256, 2 queries per KV
|
|
* head. Both bands: decode (q_len*gqa <= 64, verify width 32 against the gqa6 leg's 10) and
|
|
* windowed prefill (the gqa6 leg's r4d_attn_prefill_kernel with WIN on). */
|
|
int r4d_rad_attn_prefill_h256_gqa2_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_prefill_h256_gqa2_bf16 (const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_prefill_h256_gqa2_scratch(const RadArgs*);
|
|
int r4d_rad_attn_decode_h256_gqa2_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_decode_h256_gqa2_bf16 (const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_decode_h256_gqa2_scratch(const RadArgs*);
|
|
/* Gemma 3 sliding window (r4d_attn_paged_h128_gqa2w.hip): head_dim 128, 2 queries per KV head,
|
|
* window >= 1. Decode (q_len*gqa <= 64) and windowed prefill, as the h256/gqa2 pair above. */
|
|
int r4d_rad_attn_prefill_h128_gqa2w_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_prefill_h128_gqa2w_bf16 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_decode_h128_gqa2w_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_decode_h128_gqa2w_bf16 (const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_decode_h128_gqa2w_scratch(const RadArgs*);
|
|
/* attn_paged_qrow on the split-KV decode kernel: the h256/gqa2 decode with q at its own pitch, and
|
|
* head_dim 128 at gqa 8 as the gqa-4 kernel with two query groups a kv head (R4DArgs::kv_rep). */
|
|
int r4d_rad_attn_qrow_decode_h256_gqa2_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_qrow_decode_h256_gqa2_bf16 (const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_qrow_decode_h256_gqa2_scratch(const RadArgs*);
|
|
int r4d_rad_attn_qrow_h128_gqa8_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_qrow_h128_gqa8_bf16 (const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_qrow_h128_gqa8_scratch(const RadArgs*);
|
|
/* Paged attention at head_dim 256 and 512, 1/2/4/8 queries per KV head, any window, causal or not
|
|
* (r4d_attn_paged_window.hip): one entry point per geometry and cache dtype, every q_len and any q
|
|
* row pitch, so they serve both attn_paged and attn_paged_qrow. */
|
|
int r4d_rad_attn_window_h128_gqa1_bf16(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_window_h128_gqa1_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_window_h256_gqa1_bf16(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_window_h256_gqa1_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_window_h256_gqa2_bf16(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_window_h256_gqa2_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_window_h256_gqa4_bf16(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_window_h256_gqa4_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_window_h256_gqa8_bf16(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_window_h256_gqa8_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_window_h512_gqa1_bf16(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_window_h512_gqa1_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_window_h512_gqa2_bf16(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_window_h512_gqa2_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_window_h512_gqa4_bf16(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_window_h512_gqa4_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_window_h512_gqa8_bf16(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_window_h512_gqa8_fp8 (const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_window_h128_scratch(const RadArgs*);
|
|
int64_t r4d_rad_attn_window_h256_scratch(const RadArgs*);
|
|
int64_t r4d_rad_attn_window_h512_scratch(const RadArgs*);
|
|
/* attn_paged_qrow_tree (docs/OPS.md): the h256/gqa2 split-KV decode and the windowed kernels with a
|
|
* tree verify's mask from operand 8, `spec_parent`. */
|
|
int r4d_rad_attn_qrow_tree_decode_h256_gqa2_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_qrow_tree_decode_h256_gqa2_bf16(const RadArgs*, RadStream);
|
|
#define R4D_WIN_TREE_DECL(HD, G) \
|
|
int r4d_rad_attn_window_tree_h##HD##_gqa##G##_bf16(const RadArgs*, RadStream); \
|
|
int r4d_rad_attn_window_tree_h##HD##_gqa##G##_fp8 (const RadArgs*, RadStream);
|
|
R4D_WIN_TREE_DECL(256, 1) R4D_WIN_TREE_DECL(256, 2) R4D_WIN_TREE_DECL(256, 4) R4D_WIN_TREE_DECL(256, 8)
|
|
R4D_WIN_TREE_DECL(512, 1) R4D_WIN_TREE_DECL(512, 2) R4D_WIN_TREE_DECL(512, 4) R4D_WIN_TREE_DECL(512, 8)
|
|
#undef R4D_WIN_TREE_DECL
|
|
/* dflash_tree (r4d_dflash_tree_bf16.hip): dflash_select's lattice grown best-first into a tree. */
|
|
int r4d_rad_dflash_tree(const RadArgs*, RadStream);
|
|
/* The top-1 of a row of all-gathered (id, value) pairs, written one id a row: the vocab-sharded
|
|
* draft head's merge (r4d_pair_argmax_f32.hip). */
|
|
int r4d_rad_pair_argmax_f32(const RadArgs*, RadStream);
|
|
/* Gemma 4's two sandwich-norm joins, each one kernel for a chain of rmsnorm / add / mul_weight
|
|
* launches (r4d_norm_join_bf16.hip), and expert_scale, the embed_lookup + mul pair that scales
|
|
* each routing weight by its expert's scale (r4d_expert_scale_bf16.hip). */
|
|
int r4d_rad_norm_add_norm_bf16 (const RadArgs*, RadStream);
|
|
int r4d_rad_norm_add_norm_route_bf16(const RadArgs*, RadStream);
|
|
int r4d_rad_join_add_scale_bf16 (const RadArgs*, RadStream);
|
|
int r4d_rad_expert_scale_bf16 (const RadArgs*, RadStream);
|
|
/* Runtime LoRA's two halves, each row's adapter named by its slot (r4d_lora_bf16.hip): the scalar
|
|
* rows, and the tiled rows (a WMMA shrink over row tiles with a K split fixed by K and R, its
|
|
* partials in the op's scratch, and an expand that stages B[s] in LDS for a tile of rows). */
|
|
int r4d_rad_lora_shrink (const RadArgs*, RadStream);
|
|
int r4d_rad_lora_expand (const RadArgs*, RadStream);
|
|
int r4d_rad_lora_shrink_wmma (const RadArgs*, RadStream);
|
|
int64_t r4d_rad_lora_shrink_wmma_scratch(const RadArgs*);
|
|
int r4d_rad_lora_expand_tiled (const RadArgs*, RadStream);
|
|
int r4d_rad_lora_expand_mm (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_vit (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_dense (const RadArgs*, RadStream);
|
|
/* Unlimited-OCR's SAM tower: windowed tiles with decomposed relative position
|
|
* (r4d_sam_attn_bf16.hip). */
|
|
int r4d_rad_sam_attn (const RadArgs*, RadStream);
|
|
int r4d_rad_seg_sinusoid (const RadArgs*, RadStream);
|
|
/* The image generator's attention (r4d_attn_gen.hip): a paged prefix and the pass's own rows, the
|
|
* causal-capable dense form at head_dim 128 (a text encoder's prompt), and one 1152-wide head
|
|
* (an image decoder's mid block). */
|
|
int r4d_rad_attn_prefix_self (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_dense_h128 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_cross (const RadArgs*, RadStream);
|
|
int r4d_rad_table_add (const RadArgs*, RadStream);
|
|
int r4d_rad_mix_rows (const RadArgs*, RadStream);
|
|
int r4d_rad_chan_stats (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_dense_wide (const RadArgs*, RadStream);
|
|
/* The image generator's other ops (r4d_gen.hip). */
|
|
int r4d_rad_ln_mod (const RadArgs*, RadStream);
|
|
int r4d_rad_ln_mod_quant_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_gate_add (const RadArgs*, RadStream);
|
|
int r4d_rad_timestep_embed (const RadArgs*, RadStream);
|
|
int r4d_rad_gather_rows2 (const RadArgs*, RadStream);
|
|
int r4d_rad_lane_gather (const RadArgs*, RadStream);
|
|
int r4d_rad_lane_store (const RadArgs*, RadStream);
|
|
int r4d_rad_randn_lanes (const RadArgs*, RadStream);
|
|
int r4d_rad_flow_euler (const RadArgs*, RadStream);
|
|
int r4d_rad_kd_input (const RadArgs*, RadStream);
|
|
int r4d_rad_kd_step (const RadArgs*, RadStream);
|
|
int r4d_rad_chan_affine (const RadArgs*, RadStream);
|
|
int r4d_rad_conv2d_nhwc (const RadArgs*, RadStream);
|
|
int r4d_rad_im2col_nhwc (const RadArgs*, RadStream);
|
|
int r4d_rad_l2norm_chan (const RadArgs*, RadStream);
|
|
int r4d_rad_d2s_add (const RadArgs*, RadStream);
|
|
int r4d_rad_s2d_avg_add (const RadArgs*, RadStream);
|
|
int r4d_rad_to_rgba8 (const RadArgs*, RadStream);
|
|
int r4d_rad_gelu_tanh (const RadArgs*, RadStream);
|
|
int r4d_rad_gelu_quick (const RadArgs*, RadStream);
|
|
int r4d_rad_scatter_add_rows (const RadArgs*, RadStream);
|
|
/* r4d_audio.hip */
|
|
int r4d_rad_conv1d (const RadArgs*, RadStream);
|
|
int r4d_rad_conv_t1d (const RadArgs*, RadStream);
|
|
int r4d_rad_conv1d_f32 (const RadArgs*, RadStream);
|
|
int r4d_rad_conv_t1d_f32 (const RadArgs*, RadStream);
|
|
int r4d_rad_snake (const RadArgs*, RadStream);
|
|
int r4d_rad_cfg_topk_sample (const RadArgs*, RadStream);
|
|
int r4d_rad_rvq_embed (const RadArgs*, RadStream);
|
|
int r4d_rad_vq_encode (const RadArgs*, RadStream);
|
|
int r4d_rad_frame_mix_store (const RadArgs*, RadStream);
|
|
int r4d_rad_end_status (const RadArgs*, RadStream);
|
|
int r4d_rad_ras_pick (const RadArgs*, RadStream);
|
|
int r4d_rad_frame_store (const RadArgs*, RadStream);
|
|
int r4d_rad_resample_nearest (const RadArgs*, RadStream);
|
|
int r4d_rad_fourier_embed (const RadArgs*, RadStream);
|
|
int r4d_rad_win_input (const RadArgs*, RadStream);
|
|
int r4d_rad_win_prep (const RadArgs*, RadStream);
|
|
int r4d_rad_win_finish (const RadArgs*, RadStream);
|
|
int r4d_rad_chan_split (const RadArgs*, RadStream);
|
|
int r4d_rad_interleave2 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_dense_small_h256 (const RadArgs*, RadStream);
|
|
int r4d_rad_iota (const RadArgs*, RadStream);
|
|
int r4d_rad_cu_repeat (const RadArgs*, RadStream);
|
|
int r4d_rad_int_affine (const RadArgs*, RadStream);
|
|
int r4d_rad_sub_i32 (const RadArgs*, RadStream);
|
|
/* r4d_video.hip */
|
|
int r4d_rad_rms_mod (const RadArgs*, RadStream);
|
|
int r4d_rad_rms_mod_quant_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_rms_mod_quant_i8 (const RadArgs*, RadStream);
|
|
int r4d_rad_flow_x0_step (const RadArgs*, RadStream);
|
|
int r4d_rad_flow_res_multistep (const RadArgs*, RadStream);
|
|
int r4d_rad_patch_unfold (const RadArgs*, RadStream);
|
|
int r4d_rad_vtile_gather (const RadArgs*, RadStream);
|
|
int r4d_rad_vtile_stitch (const RadArgs*, RadStream);
|
|
int r4d_rad_vtile_plan (const RadArgs*, RadStream);
|
|
int r4d_rad_vtile_crop (const RadArgs*, RadStream);
|
|
int r4d_rad_vtile_join (const RadArgs*, RadStream);
|
|
int r4d_rad_grid_pos3 (const RadArgs*, RadStream);
|
|
int r4d_rad_snake_aa (const RadArgs*, RadStream);
|
|
/* r4d_upscaler.hip: a video latent upscaler's 3D convolution, group norm, temporal depthwise
|
|
* convolution and resize, the patch fold and the re-noise. */
|
|
int r4d_rad_conv3d_ndhwc (const RadArgs*, RadStream);
|
|
int r4d_rad_group_norm (const RadArgs*, RadStream);
|
|
int r4d_rad_tconv_dw (const RadArgs*, RadStream);
|
|
int r4d_rad_resize_bilinear (const RadArgs*, RadStream);
|
|
int r4d_rad_patch_fold (const RadArgs*, RadStream);
|
|
int r4d_rad_flow_renoise (const RadArgs*, RadStream);
|
|
int r4d_rad_cond_aug (const RadArgs*, RadStream);
|
|
int r4d_rad_rope_split (const RadArgs*, RadStream);
|
|
int r4d_rad_head_gate (const RadArgs*, RadStream);
|
|
int r4d_rad_ltx_guide (const RadArgs*, RadStream);
|
|
int r4d_rad_pixel_norm (const RadArgs*, RadStream);
|
|
int r4d_rad_d2s3d (const RadArgs*, RadStream);
|
|
int r4d_rad_s2d3d (const RadArgs*, RadStream);
|
|
int r4d_rad_pix_patch (const RadArgs*, RadStream);
|
|
int r4d_rad_vol_index (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_na3d (const RadArgs*, RadStream);
|
|
int r4d_rad_tile_grid (const RadArgs*, RadStream);
|
|
int r4d_rad_tile_crop (const RadArgs*, RadStream);
|
|
int r4d_rad_tile_stitch (const RadArgs*, RadStream);
|
|
int r4d_rad_stft_logmel (const RadArgs*, RadStream);
|
|
int r4d_rad_bwe_up (const RadArgs*, RadStream);
|
|
/* r4d_vsa.hip: video sparse attention's selection (scratch for the tile means) and attention. */
|
|
int r4d_rad_vsa_select (const RadArgs*, RadStream);
|
|
int64_t r4d_rad_vsa_select_scratch (const RadArgs*);
|
|
int r4d_rad_attn_vsa (const RadArgs*, RadStream);
|
|
/* r4d_quant_act_fp8.hip: E4M3 codes with a scale per column over every row (an attention's V). */
|
|
int r4d_rad_quant_cols_fp8 (const RadArgs*, RadStream);
|
|
int64_t r4d_rad_quant_cols_fp8_scratch(const RadArgs*);
|
|
/* Eight queries per KV head (r4d_attn_paged_gqa8.hip): the routed 35B-A3B at head_dim 256 and
|
|
* MiniCPM5-2B at 128. A decode workgroup holds 64 rows of q_len*gqa, so the verify width (the
|
|
* row's constraint value) is 8, against the gqa6 leg's 10. */
|
|
int r4d_rad_attn_prefill_h256_gqa8_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_prefill_h256_gqa8_bf16(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_prefill_h256_gqa8_scratch(const RadArgs*);
|
|
int r4d_rad_attn_decode_h256_gqa8_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_decode_h256_gqa8_bf16 (const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_decode_h256_gqa8_scratch(const RadArgs*);
|
|
int r4d_rad_attn_prefill_h128_gqa8_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_prefill_h128_gqa8_bf16(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_decode_h128_gqa8_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_decode_h128_gqa8_bf16 (const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_decode_h128_gqa8_scratch(const RadArgs*);
|
|
/* ONE query a KV head, head_dim 128 -- plain MHA, the Unlimited-OCR decoder (10 over 10). Both
|
|
* legs from the generic body instantiated at ratio 1 (r4d_attn_paged_h128_gqa1.hip). */
|
|
int r4d_rad_attn_prefill_h128_gqa1_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_prefill_h128_gqa1_bf16(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_decode_h128_gqa1_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_decode_h128_gqa1_bf16 (const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_decode_h128_gqa1_scratch(const RadArgs*);
|
|
/* Four queries per KV head, head_dim 256 only (Qwen3.5-0.8B); same body, another instantiation
|
|
* (r4d_attn_paged_h256_gqa4.hip). */
|
|
int r4d_rad_attn_prefill_h256_gqa4_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_prefill_h256_gqa4_bf16(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_prefill_h256_gqa4_scratch(const RadArgs*);
|
|
int r4d_rad_attn_decode_h256_gqa4_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_decode_h256_gqa4_bf16 (const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_decode_h256_gqa4_scratch(const RadArgs*);
|
|
/* ...and its head_dim 64 prefill leg, LFM2's geometry, serving every query length. */
|
|
int r4d_rad_attn_prefill_h64_gqa4_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_prefill_h64_gqa4_bf16(const RadArgs*, RadStream);
|
|
/* Two queries per KV head at head_dim 128 (Qwen3-1.7B, Qwen3-ASR's decoder): the gqa8 body at
|
|
* gqa 2 (r4d_attn_paged_h128_gqa2.hip). */
|
|
int r4d_rad_attn_prefill_h128_gqa2_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_prefill_h128_gqa2_bf16(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_decode_h128_gqa2_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_decode_h128_gqa2_bf16 (const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_decode_h128_gqa2_scratch(const RadArgs*);
|
|
/* Twelve queries per KV head, head_dim 256 only: Qwen3.8-Flash-Next's QSA layers. Same body,
|
|
* another instantiation (r4d_attn_paged_h256_gqa12.hip). */
|
|
int r4d_rad_attn_prefill_h256_gqa12_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_prefill_h256_gqa12_bf16(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_prefill_h256_gqa12_scratch(const RadArgs*);
|
|
int r4d_rad_attn_decode_h256_gqa12_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_decode_h256_gqa12_bf16 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_decode_gq_h256_gqa12_fp8(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_decode_gq_h256_gqa12_bf16(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_decode_h256_gqa12_scratch(const RadArgs*);
|
|
/* Six queries per KV head, head_dim 256, paged block 4: the same QSA layers at four ranks, with
|
|
* the KV head replicated across a rank pair. The verify width is 64/6 = 10 against gqa12's 5,
|
|
* the decode rows' constraint value. */
|
|
int r4d_rad_attn_prefill_h256_gqa6_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_prefill_h256_gqa6_bf16(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_prefill_h256_gqa6_scratch(const RadArgs*);
|
|
int r4d_rad_attn_decode_h256_gqa6_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_decode_h256_gqa6_bf16 (const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_decode_h256_gqa6_scratch(const RadArgs*);
|
|
/* The same two merges with the output gate and the quantiser, at the four-rank ratio. The body
|
|
* instantiates these at every ratio (`R4D_ATTN_GQA` pastes them), so this needed a row, not a
|
|
* kernel; see attn_decode_gq_h256_gqa6_fp8kv. */
|
|
int r4d_rad_attn_decode_gq_h256_gqa6_fp8(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_decode_gq_h256_gqa6_bf16(const RadArgs*, RadStream);
|
|
/* The fp8_v4 and k6_v4 caches on both: prefill, decode, and decode with the gate and quantiser in
|
|
* the merge (R4D_ATTN_V4 in r4d_attn_paged_gqa8.hip). */
|
|
int r4d_rad_attn_prefill_h256_gqa12_fp8v4(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_prefill_h256_gqa12_fp8v4_scratch(const RadArgs*);
|
|
int r4d_rad_attn_decode_h256_gqa12_fp8v4(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_decode_gq_h256_gqa12_fp8v4(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_decode_h256_gqa12_fp8v4_scratch(const RadArgs*);
|
|
int r4d_rad_attn_prefill_h256_gqa12_k6v4(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_prefill_h256_gqa12_k6v4_scratch(const RadArgs*);
|
|
int r4d_rad_attn_decode_h256_gqa12_k6v4(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_decode_gq_h256_gqa12_k6v4(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_decode_h256_gqa12_k6v4_scratch(const RadArgs*);
|
|
int r4d_rad_attn_prefill_h256_gqa6_fp8v4(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_prefill_h256_gqa6_fp8v4_scratch(const RadArgs*);
|
|
int r4d_rad_attn_decode_h256_gqa6_fp8v4(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_decode_gq_h256_gqa6_fp8v4(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_decode_h256_gqa6_fp8v4_scratch(const RadArgs*);
|
|
int r4d_rad_attn_prefill_h256_gqa6_k6v4(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_prefill_h256_gqa6_k6v4_scratch(const RadArgs*);
|
|
int r4d_rad_attn_decode_h256_gqa6_k6v4(const RadArgs*, RadStream);
|
|
int r4d_rad_attn_decode_gq_h256_gqa6_k6v4(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_attn_decode_h256_gqa6_k6v4_scratch(const RadArgs*);
|
|
|
|
/* -- gated delta net (r4d_gdn_*.hip) -- */
|
|
int r4d_rad_gdn_chunk_scan (const RadArgs*, RadStream);
|
|
int r4d_rad_gdn_conv_prep (const RadArgs*, RadStream);
|
|
int r4d_rad_gdn_conv_update (const RadArgs*, RadStream);
|
|
int r4d_rad_gdn_kkt_solve (const RadArgs*, RadStream);
|
|
int r4d_rad_gdn_recurrent_update(const RadArgs*, RadStream);
|
|
/* gdn_conv_update folded into the recurrent update's prologue for the decode shape; q/k/v are
|
|
* never written (r4d_gdn_recurrent_update_k128_v128_bf16_fp32state.hip). */
|
|
int r4d_rad_gdn_conv_recurrent_update(const RadArgs*, RadStream);
|
|
int r4d_rad_gdn_gated_rmsnorm (const RadArgs*, RadStream);
|
|
int r4d_rad_dflash_conv (const RadArgs*, RadStream);
|
|
int r4d_rad_dflash_select (const RadArgs*, RadStream);
|
|
|
|
/* -- the gated residual (r4d_hc_bf16.hip) -- */
|
|
int r4d_rad_hc_enter (const RadArgs*, RadStream);
|
|
int r4d_rad_hc_project (const RadArgs*, RadStream);
|
|
int r4d_rad_mhc_pre(const RadArgs*, RadStream);
|
|
int r4d_rad_mhc_pre_partial(const RadArgs*, RadStream);
|
|
int r4d_rad_mhc_pre_finish(const RadArgs*, RadStream);
|
|
int r4d_rad_kda_update(const RadArgs*, RadStream);
|
|
int r4d_rad_moe_mxfp4(const RadArgs*, RadStream);
|
|
int r4d_rad_layout_moe_mxfp4(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, RadLayout*);
|
|
int r4d_rad_mhc_post(const RadArgs*, RadStream);
|
|
int r4d_rad_mhc_contract(const RadArgs*, RadStream);
|
|
int r4d_rad_mtp_enter (const RadArgs*, RadStream);
|
|
int64_t r4d_rad_mtp_enter_scratch(const RadArgs*);
|
|
int r4d_rad_hc_read (const RadArgs*, RadStream);
|
|
int64_t r4d_rad_hc_read_scratch(const RadArgs*);
|
|
int r4d_rad_hc_write (const RadArgs*, RadStream);
|
|
|
|
/* -- all-reduce (r4d_ar_entry.hip) -- */
|
|
int r4d_rad_ar_init(const RadParam*, int, int rank, int world, void** out);
|
|
void r4d_rad_ar_fini(void*);
|
|
/* The same three inits with every rank's exchange buffers in pinned host memory, for the host
|
|
* twins of the collective rows (r4d_rows.cpp); launches and fini are shared. */
|
|
int r4d_rad_ar_host_init(const RadParam*, int, int rank, int world, void** out);
|
|
int r4d_rad_ar_ln_host_init(const RadParam*, int, int rank, int world, void** out);
|
|
int r4d_rad_ar_hc_wide_host_init(const RadParam*, int, int rank, int world, void** out);
|
|
int r4d_rad_ar_oneshot_2rank_exact(const RadArgs*, RadStream);
|
|
int r4d_rad_ar_gather_2rank (const RadArgs*, RadStream);
|
|
/* The gather at a wide group's handshake (r4d_ar_gather_Nrank.hip launches it). */
|
|
int r4d_rad_ar_gather_4rank (const RadArgs*, RadStream);
|
|
int r4d_rad_ar_gather_8rank (const RadArgs*, RadStream);
|
|
int r4d_rad_ar_oneshot_2rank_wht6 (const RadArgs*, RadStream);
|
|
int r4d_rad_ar_oneshot_3rank_exact(const RadArgs*, RadStream);
|
|
int r4d_rad_ar_gather_3rank (const RadArgs*, RadStream);
|
|
int r4d_rad_ar_oneshot_4rank_exact(const RadArgs*, RadStream);
|
|
int r4d_rad_ar_oneshot_8rank_exact(const RadArgs*, RadStream);
|
|
int r4d_rad_ar_twoshot_3rank_exact(const RadArgs*, RadStream);
|
|
int r4d_rad_ar_twoshot_4rank_exact(const RadArgs*, RadStream);
|
|
int r4d_rad_ar_twoshot_8rank_exact(const RadArgs*, RadStream);
|
|
int r4d_rad_ar_twoshot_3rank_ti8 (const RadArgs*, RadStream);
|
|
int r4d_rad_ar_twoshot_4rank_ti8 (const RadArgs*, RadStream);
|
|
/* The fused all-reduce + norm shares the IPC set, so it shares init/fini. */
|
|
int r4d_rad_ar_ln_init(const RadParam*, int, int rank, int world, void** out);
|
|
int r4d_rad_ar_ln_had_quant_i8(const RadArgs*, RadStream);
|
|
int r4d_rad_ar_rmsnorm_quant_fp8(const RadArgs*, RadStream);
|
|
int r4d_rad_ar_rmsnorm_had_quant_i8g(const RadArgs*, RadStream);
|
|
int r4d_rad_ar_hc_write(const RadArgs*, RadStream);
|
|
/* ar_hc_write at four ranks, exact wire only, on an instance of the wide family keyed by its own
|
|
* M bound. */
|
|
int r4d_rad_ar_hc_wide_init(const RadParam*, int, int rank, int world, void** out);
|
|
int r4d_rad_ar_hc_write_4rank(const RadArgs*, RadStream);
|
|
int r4d_rad_ar_gather_hc_write(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_ar_gather_hc_write_scratch(const RadArgs*);
|
|
/* ar_gather_hc_write at four ranks, exact wire only, on an instance from the same init. */
|
|
int r4d_rad_ar_gather_hc_write_4rank(const RadArgs*, RadStream);
|
|
|
|
/* -- GEMM (r4d_gemm_*.hip) -- */
|
|
int r4d_rad_gemm_bf16_m16 (const RadArgs*, RadStream);
|
|
int r4d_rad_gemm_bf16_m64 (const RadArgs*, RadStream);
|
|
int r4d_rad_gemm_bf16_tiled (const RadArgs*, RadStream);
|
|
int r4d_rad_gemm_w4a16_m64 (const RadArgs*, RadStream);
|
|
int r4d_rad_gemm_w5a16_m64 (const RadArgs*, RadStream);
|
|
int r4d_rad_gemm_w4a16asym_m64(const RadArgs*, RadStream);
|
|
int r4d_rad_gemm_w4a8i8_tiled(const RadArgs*, RadStream);
|
|
int r4d_rad_gemm_w5a8i8_tiled(const RadArgs*, RadStream);
|
|
int r4d_rad_givens_dense_quant(const RadArgs*, RadStream);
|
|
int r4d_rad_gemm_w8a16_m64 (const RadArgs*, RadStream);
|
|
int r4d_rad_gemm_w4a8_m64 (const RadArgs*, RadStream);
|
|
int r4d_rad_gemm_w4a8_tiled (const RadArgs*, RadStream);
|
|
int r4d_rad_gemm_w4a8_prefill(const RadArgs*, RadStream);
|
|
int r4d_rad_gemm_w8a8_m64 (const RadArgs*, RadStream);
|
|
int r4d_rad_gemm_w8a8_tiled (const RadArgs*, RadStream);
|
|
int r4d_rad_gemm_w2a8 (const RadArgs*, RadStream);
|
|
int r4d_rad_gemm_mxfp4a8_m64(const RadArgs*, RadStream);
|
|
int r4d_rad_gemm_mxfp4a8_tiled(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_gemm_mxfp4a8_tiled_scratch(const RadArgs*);
|
|
int r4d_rad_gemm_mxfp4a8_decode(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_gemm_mxfp4a8_decode_scratch(const RadArgs*);
|
|
int r4d_rad_gemm_mxfp4a8_gemv(const RadArgs*, RadStream);
|
|
int r4d_rad_gemm_mxfp4a8_gated(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_gemm_mxfp4a8_gated_scratch(const RadArgs*);
|
|
/* M2XFP4 (the paper's weight-side Sg-EM): the same GEMM bands at the m2xfp4 encoding, one meta
|
|
* plane more (r4d_layout.cpp, m2xfp4). */
|
|
int r4d_rad_gemm_m2xfp4a8_tiled(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_gemm_m2xfp4a8_tiled_scratch(const RadArgs*);
|
|
int r4d_rad_gemm_m2xfp4a8_decode(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_gemm_m2xfp4a8_decode_scratch(const RadArgs*);
|
|
int r4d_rad_gemm_mxfp4a8_gated_wide(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_gemm_mxfp4a8_gated_wide_scratch(const RadArgs*);
|
|
int r4d_rad_dequant_w4 (const RadArgs*, RadStream);
|
|
int r4d_rad_rowtopk (const RadArgs*, RadStream);
|
|
int64_t r4d_rad_rowtopk_scratch(const RadArgs*);
|
|
int r4d_rad_rowtopk_merge (const RadArgs*, RadStream);
|
|
int r4d_rad_logit_rerank (const RadArgs*, RadStream);
|
|
int r4d_rad_logit_rerank_i8 (const RadArgs*, RadStream);
|
|
|
|
/* -- the routed mixture of experts (r4d_moe.hip) --
|
|
*
|
|
* `moe_gemm_q`'s weight operands are tables (RAD_OPD_WTAB): the core resolves a run of declared
|
|
* weights to a device array of per-expert pointers, since after placement a layer's experts are
|
|
* not contiguous. See abi/rad_runtime.h. */
|
|
int r4d_rad_router_topk (const RadArgs*, RadStream);
|
|
int r4d_rad_moe_scatter (const RadArgs*, RadStream);
|
|
int r4d_rad_router_topk_scatter(const RadArgs*, RadStream);
|
|
/* The router GEMM, selection and sort in one launch, optionally with the shared gate. init takes
|
|
* the instance's arrival counter (r4d_moe.hip, "the arrival counter") and fini returns it; a
|
|
* launch with no instance is refused. */
|
|
int r4d_rad_router_gemm_topk_scatter_init(const RadParam*, int, int rank, int world, void** out);
|
|
void r4d_rad_router_gemm_topk_scatter_fini(void*);
|
|
int r4d_rad_router_gemm_topk_scatter(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_moe_scatter_scratch(const RadArgs*);
|
|
int r4d_rad_moe_gemm_q (const RadArgs*, RadStream);
|
|
/* Scratch for the run map that aligns the prefill form. Zero in the decode band and for a shape
|
|
* whose parameters do not describe one, so a caller that never asks still gets a correct uniform
|
|
* grid. */
|
|
int64_t r4d_rad_moe_gemm_q_scratch (const RadArgs*);
|
|
int64_t r4d_rad_moe_gemm_w4a8_scratch(const RadArgs*);
|
|
/* The same grouped GEMM with a 4-bit expert weight: same operands, schema and inner loop; only the
|
|
* LDS staging and scale grid differ. See r4d_layout.cpp's moe w4 section for the stored plane. */
|
|
int r4d_rad_moe_gemm_w4a8 (const RadArgs*, RadStream);
|
|
/* `moe_gemm_q_mod4`: the same two kernels over four classes of experts, by the expert's number
|
|
* mod 4. The scratch hooks are the two-class ones. */
|
|
int r4d_rad_moe_gemm_q_mod4 (const RadArgs*, RadStream);
|
|
int r4d_rad_moe_gemm_w4a8_mod4 (const RadArgs*, RadStream);
|
|
/* `moe_gemm` at bf16: one weight table of the checkpoint's row-major planes, no scales. Same
|
|
* grouping and three forms; its scratch hook sizes the same run map. */
|
|
int r4d_rad_moe_gemm_bf16 (const RadArgs*, RadStream);
|
|
int64_t r4d_rad_moe_gemm_bf16_scratch(const RadArgs*);
|
|
int r4d_rad_moe_gather (const RadArgs*, RadStream);
|
|
int r4d_rad_scale_rows (const RadArgs*, RadStream);
|
|
int64_t r4d_rad_moe_gather_scratch (const RadArgs*);
|
|
|
|
/* -- quantisation, norms and the fusions (r4d_*quant*.hip, r4d_qk_norm_rope_gate.hip) -- */
|
|
int r4d_rad_quant_act_i8 (const RadArgs*, RadStream);
|
|
int r4d_rad_qkv_norm_rope (const RadArgs*, RadStream);
|
|
int r4d_rad_kv_len_trim (const RadArgs*, RadStream);
|
|
int r4d_rad_add_rmsnorm (const RadArgs*, RadStream);
|
|
int r4d_rad_prefetch (const RadArgs*, RadStream);
|
|
int r4d_rad_layout_any(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, RadLayout*);
|
|
int r4d_rad_qkv_norm_rope_kv_store(const RadArgs*, RadStream);
|
|
int r4d_rad_gelu_mul_quant_i8 (const RadArgs*, RadStream);
|
|
int r4d_rad_gelu_mul_quant_i8g (const RadArgs*, RadStream);
|
|
int r4d_rad_ar_rmsnorm_quant_i8 (const RadArgs*, RadStream);
|
|
int r4d_rad_ar_rmsnorm_quant_i8g (const RadArgs*, RadStream);
|
|
int r4d_rad_ar_rmsnorm_quant_i8_4rank(const RadArgs*, RadStream);
|
|
int r4d_rad_rmsnorm_quant_i8 (const RadArgs*, RadStream);
|
|
int r4d_rad_rmsnorm_quant_i8g (const RadArgs*, RadStream);
|
|
int r4d_rad_had_quant_act_i8 (const RadArgs*, RadStream);
|
|
int r4d_rad_rmsnorm_had_quant_i8 (const RadArgs*, RadStream);
|
|
int r4d_rad_gated_had_quant_i8 (const RadArgs*, RadStream);
|
|
int r4d_rad_gdn_gated_norm_hq_i8 (const RadArgs*, RadStream);
|
|
int r4d_rad_qk_norm_rope_gate (const RadArgs*, RadStream);
|
|
int r4d_rad_qk_norm_rope_gate_kv_store(const RadArgs*, RadStream);
|
|
int r4d_rad_qk_norm_rope_gate_kv_store_streamed(const RadArgs*, RadStream);
|
|
int r4d_rad_qk_norm_rope_gate_kv_store_fp8v4(const RadArgs*, RadStream);
|
|
int r4d_rad_qk_norm_rope_gate_kv_store_k6v4(const RadArgs*, RadStream);
|
|
int r4d_rad_rope_table (const RadArgs*, RadStream);
|
|
|
|
/* -- block-scaled fp8, and the device sampler (r4d_gemm_fp8*.hip / r4d_fp8_layout.cpp) --
|
|
*
|
|
* These return a negative code instead of throwing, unlike the rest of libr4d's GEMMs, so their
|
|
* shims carry no R4D_TRY. */
|
|
int r4d_rad_gemm_fp8a16_m1 (const RadArgs*, RadStream);
|
|
int r4d_rad_gemm_fp8a8_m16 (const RadArgs*, RadStream);
|
|
int r4d_rad_gemm_fp8a8_gated_m16(const RadArgs*, RadStream);
|
|
int r4d_rad_gemm_fp8a8_gated_wide(const RadArgs*, RadStream);
|
|
/* `gemm_nt_q_short`: the narrow row with the short-prompt split rule (narrow_ksplit). */
|
|
int r4d_rad_gemm_fp8a8_m16_short(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_gemm_fp8a8_m16_short_scratch(const RadArgs*);
|
|
int r4d_rad_gemm_fp8a8_bias_m16(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_gemm_fp8a8_m16_scratch(const RadArgs*);
|
|
int r4d_rad_gemm_fp8a8_tiled(const RadArgs*, RadStream);
|
|
int r4d_rad_gemm_i8a8_m16 (const RadArgs*, RadStream);
|
|
int64_t r4d_rad_gemm_i8a8_m16_scratch(const RadArgs*);
|
|
int r4d_rad_logits_gemm_i8(const RadArgs*, RadStream);
|
|
int r4d_rad_logits_gemm_iqr(const RadArgs*, RadStream);
|
|
int r4d_rad_logit_rerank_iqr(const RadArgs*, RadStream);
|
|
int r4d_rad_gemm_i8a8_tiled(const RadArgs*, RadStream);
|
|
int r4d_rad_gemm_i8a8_rb8_tiled(const RadArgs*, RadStream);
|
|
int r4d_rad_gemm_i8a8_rb32_tiled(const RadArgs*, RadStream);
|
|
/* The IQR weights, decoded from their codes where they are read (r4d_gemm_iqr.hip). */
|
|
int r4d_rad_gemm_iqr_m64(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_gemm_iqr_m64_scratch(const RadArgs*);
|
|
int r4d_rad_gemm_iqr_tiled(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_gemm_iqr_tiled_scratch(const RadArgs*);
|
|
int r4d_rad_quant_act_i8g(const RadArgs*, RadStream);
|
|
int r4d_rad_had_quant_act_i8g(const RadArgs*, RadStream);
|
|
int r4d_rad_quant_act_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_had_quant_act_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_givens_rotate (const RadArgs*, RadStream);
|
|
int r4d_rad_rmsnorm_quant_fp8(const RadArgs*, RadStream);
|
|
int r4d_rad_rmsnorm_had_quant_i8g(const RadArgs*, RadStream);
|
|
int r4d_rad_gated_quant_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_gated_had_quant_fp8(const RadArgs*, RadStream);
|
|
int r4d_rad_gated_had_quant_i8g(const RadArgs*, RadStream);
|
|
int r4d_rad_gate_quant_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_gram_accum (const RadArgs*, RadStream);
|
|
/* The same accumulator over a plain bf16 activation, no scale operand. */
|
|
int r4d_rad_gram_accum_bf16 (const RadArgs*, RadStream);
|
|
int r4d_rad_qsa_block_key (const RadArgs*, RadStream);
|
|
int r4d_rad_qsa_score (const RadArgs*, RadStream);
|
|
int r4d_rad_qsa_select (const RadArgs*, RadStream);
|
|
int64_t r4d_rad_qsa_select_scratch(const RadArgs*);
|
|
int r4d_rad_kv_resolve (const RadArgs*, RadStream);
|
|
int64_t r4d_rad_kv_resolve_scratch(const RadArgs*);
|
|
int r4d_rad_kv_store_streamed(const RadArgs*, RadStream);
|
|
int r4d_rad_qsa_tail_store (const RadArgs*, RadStream);
|
|
int r4d_rad_qsa_work (const RadArgs*, RadStream);
|
|
int r4d_rad_sample_chain (const RadArgs*, RadStream);
|
|
int r4d_rad_logits_gemm_fp8 (const RadArgs*, RadStream);
|
|
|
|
/* -- what each weight-reading kernel stores, from a weight's canonical planes --
|
|
*
|
|
* RadLayoutFn / RadRelayoutFn / RadUnrelayoutFn (rad_abi.h, spec §4.3). r4d_fp8_layout.cpp holds
|
|
* the fp8 families (block-fp8 codes in fragment order; the lm_head, hyper-connection and MTP rows
|
|
* with scales in each row's tail), r4d_layout.cpp the packed integer ones. Each refuses an
|
|
* encoding its kernel does not read. A family whose kernel reads the canonical plane unchanged
|
|
* (the row-major fp8 matvec, the fp8 experts) has only the layout hook, to check its input. */
|
|
#define R4D_HOOKS(name) \
|
|
int r4d_rad_layout_##name(const RadParam*, int, int, const RadEncoding*, const int*, \
|
|
const RadTensor*, int, RadLayout*); \
|
|
int r4d_rad_relayout_##name(const RadParam*, int, int, const RadEncoding*, const int*, \
|
|
const RadTensor*, int, void*, int64_t); \
|
|
int r4d_rad_unrelayout_##name(const RadParam*, int, int, const RadEncoding*, const int*, \
|
|
const void*, int64_t, const RadTensor*, int);
|
|
R4D_HOOKS(fp8_block)
|
|
R4D_HOOKS(i8_block)
|
|
R4D_HOOKS(iqr)
|
|
R4D_HOOKS(iqr_logits)
|
|
R4D_HOOKS(fp8_logits)
|
|
R4D_HOOKS(i8_logits)
|
|
R4D_HOOKS(hc_e4m3)
|
|
R4D_HOOKS(mtp_e4m3)
|
|
R4D_HOOKS(w4)
|
|
R4D_HOOKS(w2a8)
|
|
R4D_HOOKS(moe_w4)
|
|
R4D_HOOKS(moe_w4_mod4)
|
|
#undef R4D_HOOKS
|
|
int r4d_rad_layout_fp8_rowmajor(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, RadLayout*);
|
|
/* embed_lookup_bf16's check that its table is plain bf16 (r4d_fp8_layout.cpp), and the IQR
|
|
* table's hooks and gather (r4d_iqr_layout.cpp, r4d_iqr_embed.hip). */
|
|
int r4d_rad_layout_embed_bf16(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, RadLayout*);
|
|
int r4d_rad_layout_iqr_embed(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, RadLayout*);
|
|
int r4d_rad_relayout_iqr_embed(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, void*, int64_t);
|
|
int r4d_rad_embed_lookup_iqr(const RadArgs*, RadStream);
|
|
int r4d_rad_layout_embed_q(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, RadLayout*);
|
|
int r4d_rad_layout_moe_fp8(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, RadLayout*);
|
|
int r4d_rad_layout_moe_fp8_mod4(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, RadLayout*);
|
|
int r4d_rad_layout_w8a16(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, RadLayout*);
|
|
int r4d_rad_layout_w8a8(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, RadLayout*);
|
|
int r4d_rad_relayout_w8a16(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, void*, int64_t);
|
|
int r4d_rad_relayout_w8a8(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, void*, int64_t);
|
|
int r4d_rad_layout_w5(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, RadLayout*);
|
|
int r4d_rad_relayout_w5(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, void*, int64_t);
|
|
int r4d_rad_unrelayout_w5(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const void*, int64_t, const RadTensor*, int);
|
|
int r4d_rad_layout_gdense(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, RadLayout*);
|
|
int r4d_rad_relayout_gdense(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, void*, int64_t);
|
|
/* conv2d_nhwc's weight, PyTorch's [cout][cin][k][k] stored tap-major [cout][k][k][cin]
|
|
* (r4d_layout.cpp). */
|
|
int r4d_rad_layout_conv_tap(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, RadLayout*);
|
|
int r4d_rad_relayout_conv_tap(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, void*, int64_t);
|
|
int r4d_rad_unrelayout_conv_tap(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const void*, int64_t, const RadTensor*, int);
|
|
/* conv3d_ndhwc's weight, PyTorch's [cout][cin][kt][k][k] stored tap-major [cout][kt][k][k][cin]
|
|
* (r4d_layout.cpp). */
|
|
int r4d_rad_layout_conv3d_tap(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, RadLayout*);
|
|
int r4d_rad_relayout_conv3d_tap(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, void*, int64_t);
|
|
int r4d_rad_unrelayout_conv3d_tap(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const void*, int64_t, const RadTensor*, int);
|
|
/* conv1d's weight, PyTorch's [cout][cin][k] stored [cout][k][cin], and conv_t1d's, PyTorch's
|
|
* [cin][cout][2s] stored [s][cout][2][cin] (r4d_layout.cpp). */
|
|
int r4d_rad_layout_conv1d_tap(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, RadLayout*);
|
|
int r4d_rad_relayout_conv1d_tap(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, void*, int64_t);
|
|
int r4d_rad_unrelayout_conv1d_tap(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const void*, int64_t, const RadTensor*, int);
|
|
int r4d_rad_layout_convt_phase(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, RadLayout*);
|
|
int r4d_rad_relayout_convt_phase(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, void*, int64_t);
|
|
int r4d_rad_unrelayout_convt_phase(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const void*, int64_t, const RadTensor*, int);
|
|
/* The f32 rows' weights: conv1d's stored as bf16's, conv_t1d's [s][cout][ceil(k/s)][cin] with the
|
|
* taps past k zero (r4d_layout.cpp). */
|
|
int r4d_rad_layout_conv1d_tap_f32(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, RadLayout*);
|
|
int r4d_rad_relayout_conv1d_tap_f32(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, void*, int64_t);
|
|
int r4d_rad_unrelayout_conv1d_tap_f32(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const void*, int64_t, const RadTensor*, int);
|
|
int r4d_rad_layout_convt_phase_f32(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, RadLayout*);
|
|
int r4d_rad_relayout_convt_phase_f32(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, void*, int64_t);
|
|
int r4d_rad_unrelayout_convt_phase_f32(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const void*, int64_t, const RadTensor*, int);
|
|
int r4d_rad_layout_mxfp4(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, RadLayout*);
|
|
int r4d_rad_relayout_mxfp4(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, void*, int64_t);
|
|
int r4d_rad_layout_mxfp4_gated(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, RadLayout*);
|
|
int r4d_rad_relayout_mxfp4_gated(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, void*, int64_t);
|
|
int r4d_rad_layout_m2xfp4(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, RadLayout*);
|
|
int r4d_rad_relayout_m2xfp4(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, void*, int64_t);
|
|
int r4d_rad_layout_givens_pairs(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, RadLayout*);
|
|
int r4d_rad_relayout_givens_pairs(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, void*, int64_t);
|
|
int r4d_rad_unrelayout_givens_pairs(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const void*, int64_t, const RadTensor*, int);
|
|
|
|
/* -- the small bf16 model ops (r4d_model_bf16.hip) --
|
|
*
|
|
* The embedding gather, norm, adds, rotary and KV scatter. Required because the buffers are in
|
|
* VRAM and an op with no device launch is a fatal issue. `logits_gemm` is declared with them. */
|
|
int r4d_rad_embed_lookup (const RadArgs*, RadStream);
|
|
/* The quantised gather (embed_lookup_q) for the n-gram table, read from VRAM or from pinned host
|
|
* memory over the link. */
|
|
int r4d_rad_embed_lookup_q (const RadArgs*, RadStream);
|
|
int r4d_rad_ngram_ids (const RadArgs*, RadStream);
|
|
int r4d_rad_ple_gate (const RadArgs*, RadStream);
|
|
int r4d_rad_ple_conv (const RadArgs*, RadStream);
|
|
int r4d_rad_causal_conv1d (const RadArgs*, RadStream);
|
|
int r4d_rad_cast (const RadArgs*, RadStream);
|
|
int r4d_rad_gather_rows (const RadArgs*, RadStream);
|
|
int r4d_rad_gather_rows_u8 (const RadArgs*, RadStream);
|
|
int r4d_rad_scatter_rows_u8 (const RadArgs*, RadStream);
|
|
int r4d_rad_scatter_rows_bf16(const RadArgs*, RadStream);
|
|
int r4d_rad_rmsnorm (const RadArgs*, RadStream);
|
|
/* The same row choosing the short-row form when it serves (`rmsnorm_rows`, rmsnorm_short_kernel). */
|
|
int r4d_rad_rmsnorm_rows (const RadArgs*, RadStream);
|
|
int r4d_rad_rmsnorm_p (const RadArgs*, RadStream);
|
|
int r4d_rad_add (const RadArgs*, RadStream);
|
|
int r4d_rad_mul (const RadArgs*, RadStream);
|
|
int r4d_rad_mul_weight (const RadArgs*, RadStream);
|
|
int r4d_rad_act_mul (const RadArgs*, RadStream);
|
|
int r4d_rad_seg_mean (const RadArgs*, RadStream);
|
|
int r4d_rad_seg_softmax_pool(const RadArgs*, RadStream);
|
|
int r4d_rad_seg_mean_bf16_sum(const RadArgs*, RadStream);
|
|
int r4d_rad_qk_norm_rope (const RadArgs*, RadStream);
|
|
int r4d_rad_cast_widen (const RadArgs*, RadStream);
|
|
int r4d_rad_cast_f16 (const RadArgs*, RadStream);
|
|
int r4d_rad_cast_bf16 (const RadArgs*, RadStream);
|
|
int r4d_rad_pool_rows (const RadArgs*, RadStream);
|
|
int r4d_rad_pool_cols (const RadArgs*, RadStream);
|
|
int r4d_rad_point_fourier (const RadArgs*, RadStream);
|
|
int r4d_rad_relu (const RadArgs*, RadStream);
|
|
int r4d_rad_silu (const RadArgs*, RadStream);
|
|
int r4d_rad_gelu (const RadArgs*, RadStream);
|
|
int r4d_rad_clamp (const RadArgs*, RadStream);
|
|
int r4d_rad_conv2d (const RadArgs*, RadStream);
|
|
int r4d_rad_conv1d_dw (const RadArgs*, RadStream);
|
|
int r4d_rad_rel_sinusoid (const RadArgs*, RadStream);
|
|
int r4d_rad_conv2d_unfold (const RadArgs*, RadStream);
|
|
int r4d_rad_attn_local_rel (const RadArgs*, RadStream);
|
|
int r4d_rad_sigmoid (const RadArgs*, RadStream);
|
|
int r4d_rad_fill (const RadArgs*, RadStream);
|
|
int r4d_rad_logit_softcap (const RadArgs*, RadStream);
|
|
int r4d_rad_scale (const RadArgs*, RadStream);
|
|
int r4d_rad_silu_mul (const RadArgs*, RadStream);
|
|
int r4d_rad_swiglu_clamped(const RadArgs*, RadStream);
|
|
int r4d_rad_swiglu_clamped_quant_fp8(const RadArgs*, RadStream);
|
|
int r4d_rad_dsa_pool(const RadArgs*, RadStream);
|
|
int r4d_shape_dsa_pool(const RadParam*, int, int, RadOpdDesc*);
|
|
int r4d_rad_dsa_query(const RadArgs*, RadStream);
|
|
int r4d_rad_fp8_f32scale(const RadArgs*, RadStream);
|
|
int r4d_rad_moe_fp8_f32scale(const RadArgs*, RadStream);
|
|
int r4d_layout_fp8_f32scale(const RadParam*, int, int, const RadEncoding*, const int*,
|
|
const RadTensor*, int, RadLayout*);
|
|
int r4d_shape_dsa_query(const RadParam*, int, int, RadOpdDesc*);
|
|
int r4d_rad_gemm_nt_f32(const RadArgs*, RadStream);
|
|
int r4d_shape_gemm_nt_f32(const RadParam*, int, int, RadOpdDesc*);
|
|
int r4d_rad_mla_project(const RadArgs*, RadStream);
|
|
int r4d_shape_mla_project(const RadParam*, int, int, RadOpdDesc*);
|
|
int r4d_rad_dsa_score(const RadArgs*, RadStream);
|
|
int r4d_shape_dsa_score(const RadParam*, int, int, RadOpdDesc*);
|
|
int r4d_rad_mla_attn(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_mla_attn_scratch(const RadArgs*);
|
|
int r4d_rad_mla_attn_matrix(const RadArgs*, RadStream);
|
|
int64_t r4d_rad_mla_attn_matrix_scratch(const RadArgs*);
|
|
int r4d_rad_mla_attn_rows(const RadArgs*, RadStream);
|
|
int r4d_shape_mla_attn(const RadParam*, int, int, RadOpdDesc*);
|
|
int r4d_rad_router_sigmoid_topk(const RadArgs*, RadStream);
|
|
int r4d_shape_router_sigmoid_topk(const RadParam*, int, int, RadOpdDesc*);
|
|
int r4d_rad_router_sigmoid_topk_scatter(const RadArgs*, RadStream);
|
|
int r4d_rad_moe_scatter_inv(const RadArgs*, RadStream);
|
|
int r4d_shape_moe_scatter_inv(const RadParam*, int, int, RadOpdDesc*);
|
|
int r4d_rad_moe_gather_inv(const RadArgs*, RadStream);
|
|
int r4d_shape_moe_gather_inv(const RadParam*, int, int, RadOpdDesc*);
|
|
int r4d_shape_router_sigmoid_topk_scatter(const RadParam*, int, int, RadOpdDesc*);
|
|
int r4d_rad_gelu_mul (const RadArgs*, RadStream);
|
|
int r4d_rad_rope (const RadArgs*, RadStream);
|
|
/* The same row choosing the per-(token, pair) angles form when it serves (`rope_rows`). */
|
|
int r4d_rad_rope_rows (const RadArgs*, RadStream);
|
|
/* -- the vision tower's ops (r4d_vit_bf16.hip) -- */
|
|
int r4d_rad_layernorm (const RadArgs*, RadStream);
|
|
int r4d_rad_grid_embed (const RadArgs*, RadStream);
|
|
int r4d_rad_grid_embed_aa (const RadArgs*, RadStream);
|
|
int r4d_rad_gemm_nt_bias (const RadArgs*, RadStream);
|
|
/* gemm_nt_bias at f32 (r4d_gemm_f32_nt_bias.hip). */
|
|
int r4d_rad_gemm_f32_nt_bias(const RadArgs*, RadStream);
|
|
int r4d_rad_kv_store (const RadArgs*, RadStream);
|
|
int r4d_rad_kv_store_fp8 (const RadArgs*, RadStream);
|
|
int r4d_rad_kv_store_fp8v4 (const RadArgs*, RadStream);
|
|
int r4d_rad_kv_store_k6v4 (const RadArgs*, RadStream);
|
|
int r4d_rad_logits_gemm (const RadArgs*, RadStream);
|
|
int r4d_rad_logits_gemm_cols(const RadArgs*, RadStream);
|
|
|
|
/* -- the decomposed sampler chain (r4d_sample_stages_f32.hip) --
|
|
*
|
|
* docs/OPS.md's eleven ops, beside r4d_rad_sample_chain's fused form. The fused one suits a
|
|
* speculative verify; these let an engine compose the chain per request and carry the stages the
|
|
* fused one lacks. */
|
|
int r4d_rad_sample_penalties (const RadArgs*, RadStream);
|
|
int r4d_rad_sample_dry (const RadArgs*, RadStream);
|
|
/* The windowed no-repeat-ngram ban (r4d_sample_ngram_f32.hip): the row's history, one -infinity
|
|
* a banned column. */
|
|
int r4d_rad_sample_ngram_ban(const RadArgs*, RadStream);
|
|
int r4d_rad_sample_temp (const RadArgs*, RadStream);
|
|
int r4d_rad_sample_mask (const RadArgs*, RadStream);
|
|
int r4d_rad_sample_topk (const RadArgs*, RadStream);
|
|
int r4d_rad_sample_argmax (const RadArgs*, RadStream);
|
|
int r4d_rad_sample_logprobs (const RadArgs*, RadStream);
|
|
int r4d_rad_sample_topp (const RadArgs*, RadStream);
|
|
int r4d_rad_sample_minp (const RadArgs*, RadStream);
|
|
int r4d_rad_sample_typical (const RadArgs*, RadStream);
|
|
int r4d_rad_sample_xtc (const RadArgs*, RadStream);
|
|
int r4d_rad_sample_pick (const RadArgs*, RadStream);
|
|
int r4d_rad_sample_merge_topk(const RadArgs*, RadStream);
|
|
|
|
/* -- operand descriptions (r4d_shapes.cpp, pure host) --
|
|
*
|
|
* `RadKernelInfo::opd_shape`: the size and allowed contents of operand i of this op at this
|
|
* geometry. One function per op, not per row, because the description belongs to the operand list,
|
|
* not the tiling: all six `attn_paged` rows share one and read the cache width off `kv_dtype`.
|
|
* Where rows genuinely differ they take different functions, or carry NULL and are skipped by name
|
|
* (`logits_gemm`'s fp8 row). r4d_shapes.cpp's header lists every decline and its reason.
|
|
*
|
|
* Pure host code called before allocation, so like r4d_rows.cpp and r4d_layout.cpp it includes
|
|
* neither r4d.h nor <hip/hip_runtime.h>. */
|
|
int r4d_shape_embed_lookup (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_embed_lookup_q (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_gather_rows (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_gather_rows_u8 (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_scatter_rows_u8(const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_cast (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_rmsnorm (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_hc_enter (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_mhc_pre(const RadParam*, int, int, RadOpdDesc*);
|
|
int r4d_shape_mhc_pre_partial(const RadParam*, int, int, RadOpdDesc*);
|
|
int r4d_shape_mhc_pre_finish(const RadParam*, int, int, RadOpdDesc*);
|
|
int r4d_shape_kda_update(const RadParam*, int, int, RadOpdDesc*);
|
|
int r4d_shape_moe_mxfp4(const RadParam*, int, int, RadOpdDesc*);
|
|
int r4d_shape_mhc_post(const RadParam*, int, int, RadOpdDesc*);
|
|
int r4d_shape_mhc_contract(const RadParam*, int, int, RadOpdDesc*);
|
|
int r4d_shape_mtp_enter (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_hc_read (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_hc_write (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_hc_project (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_binary (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_mul_weight (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_scatter_rows_bf16(const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_layernorm (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_grid_embed (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_gemm_nt_bias (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_unary (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_fill (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_silu_mul (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_rope (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_kv_store (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_kv_store_streamed (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_logits_gemm (const RadParam*, int, int operand, RadOpdDesc*);
|
|
|
|
int r4d_shape_sample_penalties (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_sample_dry (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_sample_temp (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_sample_mask (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_sample_topk (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_sample_argmax (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_sample_logprobs (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_sample_narrow (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_sample_pick (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_sample_chain (const RadParam*, int, int operand, RadOpdDesc*);
|
|
|
|
int r4d_shape_attn_paged (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_attn_paged_gate_quant(const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_qk_norm_rope_gate (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_qk_norm_rope_gate_kv_store(const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_qkv_norm_rope (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_qkv_norm_rope_kv_store(const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_add_rmsnorm(const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_qk_norm_rope_gate_kv_store_streamed(const RadParam*, int, int operand,
|
|
RadOpdDesc*);
|
|
int r4d_shape_rope_table (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_gdn_gated_rmsnorm (const RadParam*, int, int operand, RadOpdDesc*);
|
|
|
|
int r4d_shape_all_reduce (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_all_gather (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_ar_ln_had_quant_i8 (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_ar_rmsnorm_quant_fp8 (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_ar_rmsnorm_had_quant_i8g (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_ar_hc_write (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_ar_gather_hc_write (const RadParam*, int, int operand, RadOpdDesc*);
|
|
|
|
int r4d_shape_gemm_nt (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_gemm_nt_q (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_gemm_nt_q_bias (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_gemm_nt_q_gated(const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_dequant_w4 (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_row_topk (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_router_topk (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_router_topk_scatter(const RadParam*, int, int, RadOpdDesc*);
|
|
int r4d_shape_router_gemm_topk_scatter(const RadParam*, int, int, RadOpdDesc*);
|
|
int r4d_shape_moe_scatter (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_moe_gemm_q (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_moe_gemm_q_mod4(const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_moe_gather (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_scale_rows (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_scale (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_row_topk_merge (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_pair_argmax (const RadParam*, int, int operand, RadOpdDesc*);
|
|
|
|
int r4d_shape_quant_act_i8 (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_had_quant_act_i8 (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_rmsnorm_had_quant_i8(const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_gated_had_quant_i8 (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_gdn_gated_norm_had_quant_i8(const RadParam*, int, int operand,
|
|
RadOpdDesc*);
|
|
int r4d_shape_quant_act_fp8 (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_rmsnorm_quant_fp8 (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_gated_quant_fp8 (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_rmsnorm_had_quant_i8g (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_gated_had_quant_i8g (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_gate_quant_fp8 (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_gram_accum (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_qsa_block_key (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_qsa_score (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_qsa_select (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_kv_resolve (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_qsa_tail_store (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_qsa_work (const RadParam*, int, int operand, RadOpdDesc*);
|
|
|
|
int r4d_shape_dflash_conv (const RadParam*, int, int operand, RadOpdDesc*);
|
|
int r4d_shape_dflash_select (const RadParam*, int, int operand, RadOpdDesc*);
|
|
|
|
/* -- declared fusions (r4d_fuse.cpp, pure host) --
|
|
*
|
|
* `RadKernelInfo::replaces`: the chain of conventional ops this kernel computes in one launch, so a
|
|
* tool can run the chain on this plugin's own unfused rows and compare bytes. One function per
|
|
* fused row, not per op: two rows of one op could fold different things.
|
|
*
|
|
* Only some rows declare one. r4d_fuse.cpp's header lists each decline with the libr4d line that
|
|
* decides it: the int8 rotated family runs its Hadamard before the norm closes and keeps the
|
|
* product in f32, so `silu_mul` + `had_quant_act_i8` is a different function, and
|
|
* `ar_ln_had_quant_i8` reduces without the bf16 round its unfused pair stores. A chain that is only
|
|
* close publishes no hook, because a false failure is worse than a skip.
|
|
*
|
|
* Pure host code, like r4d_rows.cpp, r4d_layout.cpp and r4d_shapes.cpp. */
|
|
int r4d_fuse_rmsnorm_quant_fp8 (const RadParam*, int, uint64_t, int, RadFuseStep*);
|
|
int r4d_fuse_gated_quant_fp8 (const RadParam*, int, uint64_t, int, RadFuseStep*);
|
|
int r4d_fuse_swiglu_clamped_quant_fp8(const RadParam*, int, uint64_t, int, RadFuseStep*);
|
|
int r4d_fuse_router_sigmoid_topk_scatter(const RadParam*, int, uint64_t, int, RadFuseStep*);
|
|
int r4d_fuse_gate_quant_fp8 (const RadParam*, int, uint64_t, int, RadFuseStep*);
|
|
int r4d_fuse_gemm_nt_q_gated (const RadParam*, int, uint64_t, int, RadFuseStep*);
|
|
int r4d_fuse_gemm_nt_q_gated_mx (const RadParam*, int, uint64_t, int, RadFuseStep*);
|
|
int r4d_fuse_gdn_conv_recurrent_update(const RadParam*, int, uint64_t, int, RadFuseStep*);
|
|
int r4d_fuse_qk_norm_rope_gate_kv_store(const RadParam*, int, uint64_t, int, RadFuseStep*);
|
|
int r4d_fuse_qkv_norm_rope_kv_store(const RadParam*, int, uint64_t, int, RadFuseStep*);
|
|
int r4d_fuse_add_rmsnorm(const RadParam*, int, uint64_t, int, RadFuseStep*);
|
|
int r4d_fuse_qk_norm_rope_gate_kv_store_streamed(const RadParam*, int, uint64_t, int,
|
|
RadFuseStep*);
|
|
int r4d_fuse_ar_rmsnorm_quant_fp8(const RadParam*, int, uint64_t, int, RadFuseStep*);
|
|
int r4d_fuse_ar_gather_hc_write (const RadParam*, int, uint64_t, int, RadFuseStep*);
|
|
int r4d_fuse_attn_paged_gate_quant(const RadParam*, int, uint64_t, int, RadFuseStep*);
|
|
|
|
} /* extern "C" */
|
|
|
|
#endif /* RAD_R4D_PLUGIN_H */
|