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
+1
-1
@@ -59,7 +59,7 @@ The table lists a selection; `r4d_rows.cpp` and `r4d.h` hold the full set.
|
||||
| `dflash_conv_t2_g16_bf16` | the drafter's causal conv, two taps, 16 groups |
|
||||
| `dflash_select_bf16` | the drafter's candidate selector: edge scores and the greedy path walk |
|
||||
| `dequant_w4_bf16` | unpacks a 4-bit fragment-ordered weight back to bf16 |
|
||||
| `lora_shrink` / `lora_expand` | runtime LoRA's two halves beside a trunk GEMM, each row's adapter read from a per-row slot on the device (base rows untouched): `t = x A[slot]^T` one block a row, `y += scale ⊙ (t B[slot]^T)` one thread an output; scalar f32, a row's bytes independent of M |
|
||||
| `lora_shrink` / `lora_expand` | runtime LoRA's two halves beside a trunk GEMM, each row's adapter read from a per-row slot on the device (base rows untouched). Tiled rows (preferred): `t = x A[slot]^T` WMMA bf16 over 16-row x 16-j tiles with a K split fixed by K and R (`lora_shrink_wmma`, `lora_shrink_wmma_q` for fp8/i8 codes), `y += scale ⊙ (t B[slot]^T)` over 32-row x 128-column tiles with B[slot] staged in LDS, libref's bytes (`lora_expand_tiled`); a tile of base rows leaves on one ballot, a mixed tile runs one pass a slot. Scalar v1 rows (`_scalar`): one block a row / one thread an output, and the f16/f32-activation shrink. A row's bytes are independent of M in every row |
|
||||
| `quant_act_i8` / `quant_act_i8_asum` | per-row int8 activation quantiser, in the r4d GEMMs' fragment byte order; the `_asum` form also emits the per-group row sums the asymmetric GEMMs need |
|
||||
| `had_quant_act_i8` | the same with a block Walsh-Hadamard rotation first, which is what makes one scale per row viable |
|
||||
| `rmsnorm_had_quant_i8` | residual add, RMS norm, rotate and quantise in one kernel |
|
||||
|
||||
Reference in new issue
Block a user