Archived
libr4d: tiled runtime-LoRA rows over row tiles, preferred over the scalar rows
The v1 rows grid by row: shrink is one block a row walking K serially, and expand one block a (row, 256 columns) that re-reads all of B[s] for every row, so a prefill chunk reads it M times and a chunk of base rows still launches M * ceil(N/256) blocks that read a slot and leave. lora_shrink_wmma (bf16 a) and lora_shrink_wmma_q (fp8 / i8 codes whose scale group is whole 32-wide steps) run WMMA bf16 over 16-row x 16-j tiles: K in 32-wide steps over 4 waves, the waves summed in fixed order in LDS, and a K split fixed by K and R alone (sh_plan) whose partials live in the op's scratch and are summed in split order by the last block to arrive; the arrival counters are a small block keyed on (device, t). Codes are exact in bf16 and each step's partial is scaled by its group's f32 scale; f16 / f32 activations and other groups stay on the scalar kernel. lora_expand_tiled stages B[s]'s [128 columns, 32 j] slab in LDS as f32 for a 32-row tile and keeps v1's per-output sequence (j ascending, no FMA), so its bytes are libref's. Both grid by row tiles; a tile of base rows leaves on one ballot before any barrier or operand load, a mixed tile runs one pass per distinct slot, and a small grid spreads a tile's passes over blockIdx.z. No choice depends on M but which block runs a pass. The scalar rows stay, by name and as the f16 / f32 shrink, below R4D_PRIO_LORA_TILED.
This commit is contained in:
1 parent
b427e2774c
commit
ec1e830c43
6 files changed
+690
-36
No files matched your search
+13
-1
@@ -68,6 +68,13 @@ enum {
|
||||
* one. */
|
||||
R4D_PRIO_LOGITS_FP8 = 60,
|
||||
|
||||
/* 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,
|
||||
@@ -128,9 +135,14 @@ 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). */
|
||||
/* Runtime LoRA's two halves, each row's adapter named by its slot (r4d_lora_bf16.hip): the v1
|
||||
* scalar rows, and the tiled rows -- 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_attn_vit (const RadArgs*, RadStream);
|
||||
int r4d_rad_attn_dense (const RadArgs*, RadStream);
|
||||
int r4d_rad_seg_sinusoid (const RadArgs*, RadStream);
|
||||
|
||||
Reference in new issue
Block a user