Archived
radiance 1.2.2
- Static YaRN for the Qwen rotary paths (#37): a container whose config names YaRN gets it in attention, the QSA index keys and a DFlash2 drafter; one reader for every rotary type, and a LLaMA container whose type is not served (llama3, longrope, dynamic) is refused by name. - --rope-scaling yarn:FACTOR[:ORIG] (#38) writes YaRN over a container's own rotary keys at load, no reconvert; the persisted prefix cache's fingerprint carries the resolved rotary. - An uneven world's cheaper rank (#36) pages the common token count and gives the rest of its VRAM to its experts; a plan and pool that disagree refuse to start. - MoE prefill (#35): wide gather, parallel scan and run-map prefix, 256-column down tile, early weight loads -- by rule, bit-identical. - MoE decode (#34): the sorted operand's own down kernel, its column tiles by routed rows. - --draft-window fixed|adaptive (#24): a per-sequence draft window priced by measured step time, one head depth per step over the batch; fixed stays the default. New metric radiance:draft_position_accepted_total and Grafana panels. - Out-of-tree plugin builds compile to the tree's device code from any build directory.
This commit is contained in:
1 parent
6fa7707dff
commit
ac79f4dc8a
63 files changed
+2744
-8759
No files matched your search
+22
-20
@@ -774,11 +774,12 @@ extern "C" int r4d_rope_bf16(long qkv, long pos, int M, int head_dim, int n_rope
|
||||
row_pitch, 0, nullptr, 0, 0, stream);
|
||||
}
|
||||
|
||||
// The multi-component form: `mode` 2 mrope, 3 imrope, 4 axial, `sec[0..n_sec)` the sections and
|
||||
// `plane` the component pitch of `pos`; plane 0 is the one-component rotary above.
|
||||
extern "C" int r4d_rope_mc_bf16(long qkv, long pos, int M, int head_dim, int n_rope_heads,
|
||||
int rot, int gptj, float theta, float rscale, int row_pitch,
|
||||
int mode, const int* sec, int n_sec, int plane, long stream) {
|
||||
// THE ONE LAUNCH OF rope_kernel. `yarn` with factor 0 is the plain rotary: the kernel's YaRN
|
||||
// blend returns the frequency it was given and the magnitude is not applied, so the C entry points
|
||||
// below and the op without YaRN run the same arithmetic with the same arguments.
|
||||
static int rope_launch(long qkv, long pos, int M, int head_dim, int n_rope_heads, int rot,
|
||||
int gptj, float theta, float rscale, int row_pitch, int mode,
|
||||
const int* sec, int n_sec, int plane, RadYarn yarn, long stream) {
|
||||
if (!qkv || !pos) return -1;
|
||||
if (M <= 0 || head_dim <= 0 || n_rope_heads <= 0) return -2;
|
||||
if (rot <= 0 || rot > head_dim || (rot & 1)) return -3;
|
||||
@@ -790,10 +791,19 @@ extern "C" int r4d_rope_mc_bf16(long qkv, long pos, int M, int head_dim, int n_r
|
||||
hipLaunchKernelGGL(rope_kernel, dim3((uint32_t)M, gy), dim3(kThreads), 0, (hipStream_t)stream,
|
||||
(uint16_t*)qkv, (const int32_t*)pos, (uint32_t)head_dim,
|
||||
(uint32_t)n_rope_heads, (uint32_t)rot, gptj, theta, rscale,
|
||||
(uint32_t)row_pitch, mode, s0, s1, s2, n_sec, (uint32_t)plane, RadYarn{});
|
||||
(uint32_t)row_pitch, mode, s0, s1, s2, n_sec, (uint32_t)plane, yarn);
|
||||
return hipGetLastError() == hipSuccess ? 0 : -4;
|
||||
}
|
||||
|
||||
// The multi-component form: `mode` 2 mrope, 3 imrope, 4 axial, `sec[0..n_sec)` the sections and
|
||||
// `plane` the component pitch of `pos`; plane 0 is the one-component rotary above.
|
||||
extern "C" int r4d_rope_mc_bf16(long qkv, long pos, int M, int head_dim, int n_rope_heads,
|
||||
int rot, int gptj, float theta, float rscale, int row_pitch,
|
||||
int mode, const int* sec, int n_sec, int plane, long stream) {
|
||||
return rope_launch(qkv, pos, M, head_dim, n_rope_heads, rot, gptj, theta, rscale, row_pitch,
|
||||
mode, sec, n_sec, plane, RadYarn{}, stream);
|
||||
}
|
||||
|
||||
extern "C" int r4d_kv_store_bf16(long k, long v, long slot, long kv, int M, int head_dim,
|
||||
int kv_heads, int block_size, int n_blocks,
|
||||
int k_ld, int v_ld, long stream) {
|
||||
@@ -1389,22 +1399,14 @@ extern "C" int r4d_rad_rope(const RadArgs* a, RadStream s) {
|
||||
const float rscale = (float)r4d_getf(a, "scale", 1.0);
|
||||
const RadYarn yarn = rad_yarn_args(a);
|
||||
if (!rad_yarn_valid(yarn)) return R4D_NO(RAD_E_INVAL);
|
||||
if (yarn.factor != 0.0f) {
|
||||
if (mc == 4 || rscale != 1.0f) return R4D_NO(RAD_E_UNSUPPORTED);
|
||||
const uint32_t heads = (uint32_t)(n_head + n_head_kv);
|
||||
const uint32_t gy = (heads * (uint32_t)(rot / 2) + kThreads - 1) / kThreads;
|
||||
hipLaunchKernelGGL(rope_kernel, dim3((uint32_t)Mp, gy), dim3(kThreads), 0, (hipStream_t)s,
|
||||
(uint16_t*)r4d_addr(qkv), (const int32_t*)r4d_addr(pos),
|
||||
(uint32_t)head_dim, heads, (uint32_t)rot, gptj, theta, rscale,
|
||||
(uint32_t)pitch, mc, sec[0], sec[1], sec[2], n_sec, (uint32_t)plane, yarn);
|
||||
return hipGetLastError() == hipSuccess ? RAD_OK : RAD_E_DEVICE;
|
||||
}
|
||||
/* YaRN over the axial vision rotary, or over a linear position divide, is no model's. */
|
||||
if (yarn.factor != 0.0f && (mc == 4 || rscale != 1.0f)) return R4D_NO(RAD_E_UNSUPPORTED);
|
||||
/* The Q heads and the K heads rotate; the V heads that follow them do not, which is the whole
|
||||
* reason this op takes the fused projection rather than two tensors. */
|
||||
return r4d_rope_mc_bf16(r4d_addr(qkv), r4d_addr(pos), (int)Mp, (int)head_dim,
|
||||
(int)(n_head + n_head_kv), (int)rot, gptj, theta, rscale, (int)pitch,
|
||||
mc, sec, n_sec, plane, (long)(uintptr_t)s) == 0 ? RAD_OK
|
||||
: RAD_E_DEVICE;
|
||||
return rope_launch(r4d_addr(qkv), r4d_addr(pos), (int)Mp, (int)head_dim,
|
||||
(int)(n_head + n_head_kv), (int)rot, gptj, theta, rscale, (int)pitch,
|
||||
mc, sec, n_sec, plane, yarn, (long)(uintptr_t)s) == 0 ? RAD_OK
|
||||
: RAD_E_DEVICE;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ kv_store */
|
||||
|
||||
Reference in new issue
Block a user