Archived
Merge remote-tracking branch 'origin/main' into pr1-device
This commit is contained in:
commit
be47bf19af
8 files changed
+255
-12
No files matched your search
@@ -35,6 +35,7 @@ To support the development of radiance: [Patreon](https://patreon.com/StillDeadC
|
||||
| Gemma 4 31B Q8: int8 trunk and lm_head (Q8_0's grid at group 128), int8 DFlash drafter, vision | `gemma4-31b-dense-q8-df.rad` (33 GiB) | [convert](#convert-a-checkpoint) | `gemma4-31b-q8-df.yaml` |
|
||||
| Gemma 4 31B on four cards: int4 trunk, int8 activations and lm_head, RedHatAI's DFlash2 drafter, vision | `gemma4-31b-dense-w4a8-df2-qkv.rad` (23 GiB) | [download](https://huggingface.co/Ashlyn4202025/gemma4-31b-w4a8-dflash2) | `gemma4-31b-w4a8-df2-tp4.yaml` |
|
||||
| NVIDIA-Nemotron-3.5-Bolt-E4B bf16 (Gemma 4 E4B), NVIDIA's DFlash drafter, vision, one card | `nemotron-3.5-bolt-e4b-bf16.rad` (16 GiB) | [download](https://huggingface.co/keptn/nemotron-3.5-bolt-e4b-bf16) | `nemotron-3.5-bolt-e4b-bf16.yaml` |
|
||||
| NVIDIA-Nemotron-3.5-Bolt-E4B int8 (i8a8, Gemma 4 E4B), NVIDIA's DFlash drafter, vision, one card | `nemotron-3.5-bolt-e4b-i8g.rad` (12 GiB) | [download](https://huggingface.co/keptn/nemotron-3.5-bolt-e4b-i8g) | `nemotron-3.5-bolt-e4b-i8g.yaml` |
|
||||
| Qwen-Image 2.1 FP8: text to image and image edits | `qwen-image-2.1-fp8.rad` (16 GiB) | [download](https://huggingface.co/StillDeadcode/radiance-qwen-image-2.1-fp8) | `qwen-image-2.1.yaml` |
|
||||
| Qwen-Image 2.1 Turbo FP8: the same in 8 steps | `qwen-image-2.1-turbo-fp8.rad` (16 GiB) | [download](https://huggingface.co/StillDeadcode/radiance-qwen-image-2.1-turbo-fp8) | `qwen-image-2.1-turbo.yaml` |
|
||||
| Krea 2 Turbo FP8: text to image, one card | `krea-2-turbo-fp8.rad` (16 GiB) | [download](https://huggingface.co/StillDeadcode/krea-2-turbo-radiance-fp8) | `krea-2-turbo.yaml` |
|
||||
|
||||
+11
-1
@@ -608,8 +608,18 @@ constexpr int64_t kPrefetchRows = 16;
|
||||
* would read in series on lane 0, so elsewhere the read goes on lane 1, behind a join from lane
|
||||
* 0. */
|
||||
inline bool prefetch_lane0() { return rad_chain_on() != 0; }
|
||||
/* RADIANCE_PREFETCH_BESIDE=0 issues none of these reads. Beside another server on the same card
|
||||
* the lane-1 form costs more than it gains: the card has fewer hardware queue slots than the two
|
||||
* servers have queues, and the join puts a queue switch into every decode step. */
|
||||
inline bool prefetch_beside_on() {
|
||||
static const bool on = [] {
|
||||
const char* e = std::getenv("RADIANCE_PREFETCH_BESIDE");
|
||||
return !(e && e[0] == '0' && e[1] == 0);
|
||||
}();
|
||||
return on;
|
||||
}
|
||||
inline void prefetch_beside(RadCtx* c, rad_op op, rad_weight w, int64_t T) {
|
||||
if (!op || T > kPrefetchRows) return;
|
||||
if (!op || T > kPrefetchRows || !prefetch_beside_on()) return;
|
||||
if (prefetch_lane0()) {
|
||||
RAD_ISSUE(c, op, RAD_W(w));
|
||||
return;
|
||||
|
||||
+36
-3
@@ -22,6 +22,7 @@
|
||||
#include <arch/rad_fp8.h>
|
||||
#include <arch/rad_block_dflash2.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
@@ -94,6 +95,13 @@ struct G3Linear {
|
||||
bool i8g = false;
|
||||
bool mx = false;
|
||||
bool a4 = false; /* asymmetric int4 over the per-(row, 128) int8 activation */
|
||||
/* a4 at decode heights, as LinearFP8's w4 (rad_fp8.h): up to kA4Split rows the bf16 input is
|
||||
* cast to f16 (`a16`) for w4a16_asym's skinny kernel; w4a8i8_asym has only a prefill kernel,
|
||||
* which at one row does 16 times the matrix work. */
|
||||
static constexpr int64_t kA4Split = 64;
|
||||
int64_t a4_split = 0;
|
||||
rad_buf a16 = 0;
|
||||
rad_op op_a16 = 0, op_dec = 0;
|
||||
bool shared_in = false;
|
||||
/* Set before declare: an E4M3 (MXFP4) linear's input pair given by the caller (the pipelined
|
||||
* prefill's one pair for every block) instead of one of its own. It keeps its own quantiser
|
||||
@@ -205,7 +213,8 @@ inline int G3Linear::declare(RadBuilder* b, Names& nm, const Geom& g, const char
|
||||
ws = decl_view(b, nm.f("%s.scale", base), wn, "scale,zero", RAD_F16, { N, K },
|
||||
RAD_ACCESS_PER_TOKEN, shard, grp, parts, np);
|
||||
if (!w || !ws) return RAD_E_INVAL;
|
||||
if (in_from && (in_from->i8g || in_from->a4) && in_from->q8 && in_from->K == K) {
|
||||
/* not an a4 linear's pair: below its decode band it writes none */
|
||||
if (in_from && in_from->i8g && in_from->q8 && in_from->K == K) {
|
||||
q8 = in_from->q8;
|
||||
s8 = in_from->s8;
|
||||
shared_in = true;
|
||||
@@ -225,7 +234,21 @@ inline int G3Linear::declare(RadBuilder* b, Names& nm, const Geom& g, const char
|
||||
RAD_INT("group", RAD_FP8_BLOCK), RAD_STR("dtype", "w4a8i8_asym")),
|
||||
RAD_WEIGHTS(w, ws)),
|
||||
{ q8, s8 }, { y });
|
||||
return op ? RAD_OK : RAD_E_INVAL;
|
||||
if (!op) return RAD_E_INVAL;
|
||||
a4_split = std::min<int64_t>(kA4Split, g.max_tok);
|
||||
a16 = decl_b(b, nm.f("%s.a16", base), RAD_F16, { a4_split, K });
|
||||
if (!a16) return RAD_E_INVAL;
|
||||
op_a16 = rw(b, RAD_OP(b, "cast",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, a4_split), RAD_INT("n", K),
|
||||
RAD_STR("from", g.dtype), RAD_STR("to", "f16")),
|
||||
RAD_NOWEIGHTS),
|
||||
{ a }, { a16 });
|
||||
op_dec = rw(b, RAD_OP(b, "gemm_nt_q",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, a4_split), RAD_INT("N", N), RAD_INT("K", K),
|
||||
RAD_INT("group", RAD_FP8_BLOCK), RAD_STR("dtype", "w4a16_asym")),
|
||||
RAD_WEIGHTS(w, ws)),
|
||||
{ a16 }, { y });
|
||||
return (op_a16 && op_dec) ? RAD_OK : RAD_E_INVAL;
|
||||
}
|
||||
if (i8g || mx) {
|
||||
if (N % 16 || K % RAD_FP8_BLOCK) {
|
||||
@@ -246,7 +269,7 @@ inline int G3Linear::declare(RadBuilder* b, Names& nm, const Geom& g, const char
|
||||
ws = decl_view(b, sn, wn, "scale", RAD_BF16, { N, K / RAD_FP8_BLOCK }, RAD_ACCESS_PER_TOKEN, shard, grp, parts, np);
|
||||
if (!w || !ws) return RAD_E_INVAL;
|
||||
}
|
||||
if (in_from && in_from->mx == mx && (in_from->i8g || in_from->a4) == i8g && in_from->q8 && in_from->K == K) {
|
||||
if (in_from && in_from->mx == mx && in_from->i8g == i8g && !in_from->a4 && in_from->q8 && in_from->K == K) {
|
||||
q8 = in_from->q8;
|
||||
s8 = in_from->s8;
|
||||
shared_in = true;
|
||||
@@ -288,6 +311,10 @@ inline void G3Linear::step(RadCtx* c, rad_buf a, rad_buf y, int64_t T) const {
|
||||
if (!shared_in)
|
||||
RAD_ISSUE_N(c, op_q, T, brows(a, T), brows(q8, T), brows(s8, T), RAD_NONE);
|
||||
gemm(c, y, T);
|
||||
} else if (a4 && T <= a4_split) {
|
||||
RAD_ISSUE_N(c, op_a16, T, brows(a, T), brows(a16, T));
|
||||
RAD_ISSUE_N(c, op_dec, T, brows(a16, T), RAD_NONE, RAD_W(w), RAD_W(ws), brows(y, T),
|
||||
RAD_NONE, RAD_NONE);
|
||||
} else if (i8g || mx || a4) {
|
||||
/* quant_act_i8g / quant_act_fp8 take x, q, scale: no optional `asum`. */
|
||||
if (!shared_in)
|
||||
@@ -308,6 +335,12 @@ inline void G3Linear::gemm_rows(RadCtx* c, rad_buf y, int64_t r0, int64_t n) con
|
||||
}
|
||||
|
||||
inline void G3Linear::step_rows(RadCtx* c, rad_buf a, rad_buf y, int64_t r0, int64_t n) const {
|
||||
if (a4 && n <= a4_split) {
|
||||
RAD_ISSUE_N(c, op_a16, n, brow_slice(a, r0, n, K), brows(a16, n));
|
||||
RAD_ISSUE_N(c, op_dec, n, brows(a16, n), RAD_NONE, RAD_W(w), RAD_W(ws),
|
||||
brow_slice(y, r0, n, N), RAD_NONE, RAD_NONE);
|
||||
return;
|
||||
}
|
||||
if (!shared_in)
|
||||
RAD_ISSUE_N(c, op_q, n, brow_slice(a, r0, n, K), brow_slice(q8, r0, n, K),
|
||||
brow_slice(s8, r0, n, K / RAD_FP8_BLOCK));
|
||||
|
||||
@@ -104,7 +104,25 @@ struct G4Linear {
|
||||
rad_op op = 0, op_q = 0; /* the quantised GEMM and, for w4a8, its activation quantiser */
|
||||
rad_buf q8 = 0, s8 = 0; /* the int8 pair (i8 codes + f32 row scale) the quantiser writes */
|
||||
int64_t N = 0, K = 0;
|
||||
bool quant = false; /* true: w4a8 */
|
||||
bool quant = false; /* true: w4a8 / w8a8 over a per-row int8 activation */
|
||||
/* true: i8a8 as arch/gemma3's G3Linear: int8 codes with a bf16 scale per [1 x 128] (libquant
|
||||
* `codes=i8 group=128 scale=bf16`) over quant_act_i8g, an activation scale per (row, 128).
|
||||
* Gemma 4 E4B's activations carry a few channels 40-200 times the row's median (the down
|
||||
* projection's input most), and one int8 scale a row spends its codes on them. There is no
|
||||
* fused norm/quantiser at this grid, so the junctions stay off for a model that uses it. */
|
||||
bool i8g = false;
|
||||
/* true: asymmetric int4 as arch/gemma3's G3Linear: u4 codes, a u8 zero point and an f16 scale
|
||||
* per [1 x 128] (libquant `codes=u4 zero=u8 group=128 scale=f16`), gemm_nt_q at w4a8i8_asym
|
||||
* over the same per-(row, 128) int8 activation as i8g. */
|
||||
bool a4 = false;
|
||||
bool grouped() const { return i8g || a4; }
|
||||
/* a4 at decode heights, as LinearFP8's w4 (rad_fp8.h): up to kA4Split rows the bf16 input is
|
||||
* cast to f16 (`a16`) for w4a16_asym's skinny kernel; w4a8i8_asym has only a prefill kernel,
|
||||
* which at one row does 16 times the matrix work and reads its weight a quarter as fast. */
|
||||
static constexpr int64_t kA4Split = 64;
|
||||
int64_t a4_split = 0; /* rows up to which op_dec serves; 0: no decode band */
|
||||
rad_buf a16 = 0;
|
||||
rad_op op_a16 = 0, op_dec = 0;
|
||||
/* Reads another linear's int8 pair. q, k and v quantise the same norm output on the same
|
||||
* per-row grid, so with `in_from` set at declare this linear reads that linear's pair and
|
||||
* declares no quantiser of its own: one dispatch instead of three. */
|
||||
@@ -175,6 +193,73 @@ inline int G4Linear::declare(RadBuilder* b, Names& nm, const Geom& g, const char
|
||||
* at w8a8 reads the same int8 activation and per-row scale as w4a8, so the quantiser is
|
||||
* shared. A recipe uses it for linears int4 hurts (attention, down_proj). */
|
||||
const uint32_t cdt = known && enc.n_planes > 0 ? enc.plane[0].dtype : 0;
|
||||
i8g = known && linear_is_w8(enc);
|
||||
{
|
||||
const RadEncPlane* sp = rad_enc_plane(&enc, "scale");
|
||||
const RadEncPlane* zp = rad_enc_plane(&enc, "zero");
|
||||
a4 = known && rad_enc_is(&enc, "affine") && enc.n_planes == 3 && !enc.transform[0] &&
|
||||
cdt == RAD_U4 && enc.plane[0].block[1] == 1 && sp && sp->dtype == RAD_F16 &&
|
||||
sp->block[0] == 1 && sp->block[1] == RAD_FP8_BLOCK && zp && zp->dtype == RAD_U8 &&
|
||||
zp->block[0] == 1 && zp->block[1] == RAD_FP8_BLOCK;
|
||||
}
|
||||
if (i8g || a4) {
|
||||
if (N % 16 || K % RAD_FP8_BLOCK) {
|
||||
fprintf(stderr, "radiance: '%s' is %lldx%lld per rank; it takes rows in 16s and K in "
|
||||
"whole %d-column activation scale groups\n", base, (long long)N,
|
||||
(long long)K, RAD_FP8_BLOCK);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
if (a4) {
|
||||
w = decl_view(b, wn, nullptr, "codes", RAD_U4, { N, K }, RAD_ACCESS_PER_TOKEN, shard, grp, parts, np);
|
||||
ws = decl_view(b, nm.f("%s.scale", base), wn, "scale,zero", RAD_F16, { N, K },
|
||||
RAD_ACCESS_PER_TOKEN, shard, grp, parts, np);
|
||||
} else {
|
||||
w = decl_view(b, wn, nullptr, "codes", RAD_I8, { N, K }, RAD_ACCESS_PER_TOKEN, shard, grp, parts, np);
|
||||
ws = decl_view(b, nm.f("%s.scale", base), wn, "scale", RAD_BF16, { N, K / RAD_FP8_BLOCK },
|
||||
RAD_ACCESS_PER_TOKEN, shard, grp, parts, np);
|
||||
}
|
||||
if (!w || !ws) return RAD_E_INVAL;
|
||||
/* not an a4 linear's pair: below its decode band it writes none */
|
||||
if (in_from && in_from->grouped() && !in_from->a4 && in_from->q8 && in_from->K == K) {
|
||||
q8 = in_from->q8;
|
||||
s8 = in_from->s8;
|
||||
shared_in = true;
|
||||
} else {
|
||||
q8 = decl_b(b, nm.f("%s.q8", base), RAD_I8, { g.max_tok, K });
|
||||
s8 = decl_b(b, nm.f("%s.s8", base), RAD_F32, { g.max_tok, K / RAD_FP8_BLOCK });
|
||||
if (!q8 || !s8) return RAD_E_INVAL;
|
||||
op_q = rw(b, RAD_OP(b, "quant_act_i8g",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", K),
|
||||
RAD_INT("group", RAD_FP8_BLOCK), RAD_STR("dtype", "bf16")),
|
||||
RAD_NOWEIGHTS),
|
||||
{ a }, { q8, s8 });
|
||||
if (!op_q) return RAD_E_INVAL;
|
||||
}
|
||||
op = rw(b, RAD_OP(b, "gemm_nt_q",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("N", N), RAD_INT("K", K),
|
||||
RAD_INT("group", RAD_FP8_BLOCK),
|
||||
RAD_STR("dtype", a4 ? "w4a8i8_asym" : "i8a8")),
|
||||
RAD_WEIGHTS(w, ws)),
|
||||
{ q8, s8 }, { y });
|
||||
if (!op) return RAD_E_INVAL;
|
||||
if (a4) {
|
||||
a4_split = std::min<int64_t>(kA4Split, g.max_tok);
|
||||
a16 = decl_b(b, nm.f("%s.a16", base), RAD_F16, { a4_split, K });
|
||||
if (!a16) return RAD_E_INVAL;
|
||||
op_a16 = rw(b, RAD_OP(b, "cast",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, a4_split), RAD_INT("n", K),
|
||||
RAD_STR("from", g.dtype), RAD_STR("to", "f16")),
|
||||
RAD_NOWEIGHTS),
|
||||
{ a }, { a16 });
|
||||
op_dec = rw(b, RAD_OP(b, "gemm_nt_q",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, a4_split), RAD_INT("N", N), RAD_INT("K", K),
|
||||
RAD_INT("group", RAD_FP8_BLOCK), RAD_STR("dtype", "w4a16_asym")),
|
||||
RAD_WEIGHTS(w, ws)),
|
||||
{ a16 }, { y });
|
||||
if (!op_a16 || !op_dec) return RAD_E_INVAL;
|
||||
}
|
||||
return RAD_OK;
|
||||
}
|
||||
if (known && g4_grid_w4(enc)) {
|
||||
if (N % 16 || K % 128) {
|
||||
fprintf(stderr, "radiance: '%s' is %lldx%lld per rank; a w4 weight takes rows in "
|
||||
@@ -216,8 +301,8 @@ inline int G4Linear::declare(RadBuilder* b, Names& nm, const Geom& g, const char
|
||||
|
||||
char en[256];
|
||||
rad_enc_format(&enc, en, sizeof en);
|
||||
fprintf(stderr, "radiance: '%s' is %s, and this model's linears are plain bf16, w4a8 or w8a8 -- "
|
||||
"neither matches\n", wn, en);
|
||||
fprintf(stderr, "radiance: '%s' is %s, and this model's linears are plain bf16, w4a8, w8a8, "
|
||||
"int8 a 128 (i8a8) or asymmetric int4 a 128 -- none matches\n", wn, en);
|
||||
return RAD_E_DTYPE;
|
||||
}
|
||||
|
||||
@@ -229,6 +314,16 @@ inline void G4Linear::step(RadCtx* c, rad_buf a, rad_buf y, int64_t T) const {
|
||||
if (!shared_in)
|
||||
RAD_ISSUE_N(c, op_q, T, brows(a, T), brows(q8, T), brows(s8, T), RAD_NONE);
|
||||
gemm(c, y, T);
|
||||
} else if (a4 && T <= a4_split) {
|
||||
/* the decode band: f16 copy of the input, the skinny kernel; operands as LinearFP8's w4 */
|
||||
RAD_ISSUE_N(c, op_a16, T, brows(a, T), brows(a16, T));
|
||||
RAD_ISSUE_N(c, op_dec, T, brows(a16, T), RAD_NONE, RAD_W(w), RAD_W(ws), brows(y, T),
|
||||
RAD_NONE, RAD_NONE);
|
||||
} else if (grouped()) {
|
||||
/* quant_act_i8g takes x, q, scale: no optional `asum`. */
|
||||
if (!shared_in)
|
||||
RAD_ISSUE_N(c, op_q, T, brows(a, T), brows(q8, T), brows(s8, T));
|
||||
gemm(c, y, T);
|
||||
} else
|
||||
RAD_ISSUE(c, op, brows(a, T), RAD_W(w), brows(y, T));
|
||||
}
|
||||
@@ -239,18 +334,29 @@ inline void G4Linear::gemm(RadCtx* c, rad_buf y, int64_t T) const {
|
||||
}
|
||||
|
||||
inline void G4Linear::step_rows(RadCtx* c, rad_buf a, rad_buf y, int64_t r0, int64_t n) const {
|
||||
if (!quant) {
|
||||
if (a4 && n <= a4_split) {
|
||||
RAD_ISSUE_N(c, op_a16, n, brow_slice(a, r0, n, K), brows(a16, n));
|
||||
RAD_ISSUE_N(c, op_dec, n, brows(a16, n), RAD_NONE, RAD_W(w), RAD_W(ws),
|
||||
brow_slice(y, r0, n, N), RAD_NONE, RAD_NONE);
|
||||
return;
|
||||
}
|
||||
if (!quant && !grouped()) {
|
||||
RAD_ISSUE_N(c, op, n, brow_slice(a, r0, n, K), RAD_W(w), brow_slice(y, r0, n, N));
|
||||
return;
|
||||
}
|
||||
if (!shared_in)
|
||||
const int64_t sw = grouped() ? K / RAD_FP8_BLOCK : 1; /* the scale plane's row width */
|
||||
if (!shared_in && grouped())
|
||||
RAD_ISSUE_N(c, op_q, n, brow_slice(a, r0, n, K), brow_slice(q8, r0, n, K),
|
||||
brow_slice(s8, r0, n, sw));
|
||||
else if (!shared_in)
|
||||
RAD_ISSUE_N(c, op_q, n, brow_slice(a, r0, n, K), brow_slice(q8, r0, n, K),
|
||||
brow_slice(s8, r0, n, 1), RAD_NONE);
|
||||
gemm_rows(c, y, r0, n);
|
||||
}
|
||||
|
||||
inline void G4Linear::gemm_rows(RadCtx* c, rad_buf y, int64_t r0, int64_t n) const {
|
||||
RAD_ISSUE_N(c, op, n, brow_slice(q8, r0, n, K), brow_slice(s8, r0, n, 1), RAD_W(w), RAD_W(ws),
|
||||
const int64_t sw = grouped() ? K / RAD_FP8_BLOCK : 1;
|
||||
RAD_ISSUE_N(c, op, n, brow_slice(q8, r0, n, K), brow_slice(s8, r0, n, sw), RAD_W(w), RAD_W(ws),
|
||||
brow_slice(y, r0, n, N), RAD_NONE, RAD_NONE);
|
||||
}
|
||||
|
||||
@@ -376,8 +482,11 @@ int Gemma4Attn::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, const
|
||||
if (cls.has_v) RAD_ARCH_TRY(map_concat(b, qkv_wn, { q_src, k_src, v_src }));
|
||||
else RAD_ARCH_TRY(map_concat(b, qkv_wn, { q_src, k_src }));
|
||||
{
|
||||
/* one q|k|v GEMM wherever the weight is on a quantised grid: w4a8 / w8a8, i8a8 or a4 */
|
||||
RadEncoding e{};
|
||||
fused = weight_enc(b, qkv_wn, &e) && g4_grid_w4(e);
|
||||
fused = weight_enc(b, qkv_wn, &e) && (g4_grid_w4(e) || linear_is_w8(e) ||
|
||||
(rad_enc_is(&e, "affine") && e.n_planes == 3 &&
|
||||
e.plane[0].dtype == RAD_U4));
|
||||
}
|
||||
if (fused) {
|
||||
if (!qkv_slot) return RAD_E_INVAL;
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
# gemma4-e4b-bf16-a4-df.recipe -- Gemma 4 E4B (text, vision, NVIDIA's DFlash drafter) from a bf16 checkpoint,
|
||||
# 4-bit: the feed-forward as asymmetric int4 (u4 codes, a u8 zero point and an f16 scale per [1 x 128]),
|
||||
# attention and layers 19-23 as int8 with a bf16 scale per [1 x 128] (i8a8). An int8 lm_head, the drafter on
|
||||
# block FP8, the vision tower bf16.
|
||||
#
|
||||
# rad-convert <checkpoint> --recipe data/recipes/gemma4-e4b-bf16-a4-df.recipe --draft-model <dflash-bf16> \
|
||||
# --set quantization_config.quant_method=compressed-tensors -o gemma4-e4b-a4-df.rad
|
||||
#
|
||||
# The int4 linears read the activation quantised to int8 with a scale per (row, 128) above 64 rows
|
||||
# (w4a8i8_asym) and an f16 copy of it at decode heights (w4a16_asym). Attention and layers 19-23, which
|
||||
# amplify rounding at single tokens, stay at 8 bits.
|
||||
|
||||
blk.19.attn_qkv.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.19.attn_o.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.19.ffn_gate_up.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.19.ffn_down.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.20.attn_qkv.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.20.attn_o.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.20.ffn_gate_up.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.20.ffn_down.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.21.attn_qkv.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.21.attn_o.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.21.ffn_gate_up.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.21.ffn_down.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.22.attn_qkv.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.22.attn_o.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.22.ffn_gate_up.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.22.ffn_down.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.23.attn_qkv.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.23.attn_o.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.23.ffn_gate_up.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.23.ffn_down.weight rtn codes=i8 group=128 scale=bf16
|
||||
|
||||
blk.*.attn_qkv.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.*.attn_q.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.*.attn_o.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.*.ffn_down.weight rtn codes=u4 zero=u8 group=128 scale=f16 rule=search
|
||||
blk.*.ffn_gate_up.weight rtn codes=u4 zero=u8 group=128 scale=f16 rule=search
|
||||
|
||||
output.weight rtn codes=i8 group=128 scale=bf16 clamp=sym
|
||||
|
||||
dflash.fc.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dflash.blk.*.attn_q.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dflash.blk.*.attn_k.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dflash.blk.*.attn_v.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dflash.blk.*.attn_output.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dflash.blk.*.ffn_gate_up.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dflash.blk.*.ffn_down.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dflash.draft_head.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
@@ -0,0 +1,24 @@
|
||||
# gemma4-e4b-bf16-i8g-df.recipe -- Gemma 4 E4B (text, vision, NVIDIA's DFlash drafter) from a bf16 checkpoint:
|
||||
# every trunk linear int8 with a bf16 scale per 128 columns, served at i8a8 (the activation quantised with a
|
||||
# scale per row and 128 columns), an int8 lm_head, the drafter on block FP8, the vision tower bf16.
|
||||
# Wikitext-2 KL against the bf16 original 0.010 (w8a8 recipe, one activation scale a row: 0.076).
|
||||
#
|
||||
# rad-convert <checkpoint> --recipe data/recipes/gemma4-e4b-bf16-i8g-df.recipe --draft-model <dflash-bf16> \
|
||||
# --set quantization_config.quant_method=compressed-tensors -o gemma4-e4b-i8g-df.rad
|
||||
|
||||
blk.*.attn_qkv.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.*.attn_q.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.*.attn_o.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.*.ffn_down.weight rtn codes=i8 group=128 scale=bf16
|
||||
blk.*.ffn_gate_up.weight rtn codes=i8 group=128 scale=bf16
|
||||
|
||||
output.weight rtn codes=i8 group=128 scale=bf16 clamp=sym
|
||||
|
||||
dflash.fc.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dflash.blk.*.attn_q.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dflash.blk.*.attn_k.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dflash.blk.*.attn_v.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dflash.blk.*.attn_output.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dflash.blk.*.ffn_gate_up.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dflash.blk.*.ffn_down.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dflash.draft_head.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
@@ -0,0 +1,16 @@
|
||||
# NVIDIA-Nemotron-3.5-Bolt-E4B (Gemma 4 E4B, post-trained by NVIDIA) at int8 on one card: every trunk
|
||||
# linear int8 at i8a8 (activation scale per row and 128 columns), NVIDIA's DFlash drafter (7 tokens a
|
||||
# pass, the block it was trained at) and the bf16 vision tower in pinned host memory. bf16 KV. Thinking
|
||||
# is off, as in NVIDIA's template; switch it per request (chat_template_kwargs). Sampling as NVIDIA
|
||||
# states it (temperature 1.0, top_p 0.95) and the checkpoint's top_k 64.
|
||||
name: radiance-nemotron-3.5-bolt-e4b-i8g
|
||||
services:
|
||||
radiance:
|
||||
extends: { file: common.yaml, service: radiance }
|
||||
container_name: radiance-nemotron-3.5-bolt-e4b-i8g
|
||||
command: >
|
||||
--model /models/nemotron-3.5-bolt-e4b-i8g.rad
|
||||
--host :: --port ${PORT:-8000} --api-key ${RADIANCE_API_KEY:?set RADIANCE_API_KEY in .env}
|
||||
--tp 1 --max-num-seqs 8 --max-model-len 65536 --kv-cache-dtype bf16
|
||||
--num-speculative-tokens 7 --mm-max-patches 2520 --vision-tower-placement ram
|
||||
--temp 1.0 --top-p 0.95 --top-k 64 --chat-template-kwargs '{"enable_thinking":false}'
|
||||
+2
-1
@@ -3460,6 +3460,7 @@ rad-kbench --home $RADIANCE_HOME --max-cases 1 # are the kernels correct?
|
||||
| `HF_TOKEN` | for `scripts/hfget.sh` and `--model <owner/name>` on a gated or private repo |
|
||||
| `XDG_CACHE_HOME` | where `--model <owner/name>` fetches to without `--download-dir` (`$XDG_CACHE_HOME/radiance/hf`, else `~/.cache/radiance/hf`) |
|
||||
| `R4D_AR_MAX_BLOCKS` | a ceiling on libr4d's collective block counts, for two tensor-parallel engines on one set of cards; set it in both (below). The MoE models' hyper-connection gathers keep the minimum their LDS table needs. Unset, nothing changes |
|
||||
| `RADIANCE_PREFETCH_BESIDE` | `0` issues no weight prefetch beside the decode collectives. For an engine that shares its cards with another server (below); alone it costs a few percent of decode. Unset, nothing changes |
|
||||
|
||||
**Two engines on one set of cards.** Every block of a libr4d collective spins until its twin on the
|
||||
peer card has pushed, and a prefill-sized fused all-reduce launches more blocks than a card holds at
|
||||
@@ -3472,7 +3473,7 @@ low enough that their spinners together leave part of a card free, the cycle can
|
||||
Qwen3.8-27B (its decode at 16 sequences x 4 rows stays uncapped) and 16 for the Gemma ran 15
|
||||
minutes of concurrent long prompts on both without a stall. The ceiling costs prefill time, the
|
||||
reductions running on fewer blocks: Qwen3.8-27B's 41k-token prefill 9.5 s uncapped, 9.8 s at 64,
|
||||
10.3 s at 32. Give the engine started first its `--gpu-headroom-mib` for the second.
|
||||
10.3 s at 32. Give the engine started first its `--gpu-headroom-mib` for the second. A model whose decode reads weights ahead on a second queue (Gemma 4 without chained launches) slows sharply beside a second server: an R9700 has four compute queue slots and the two servers hold eight, so every decode step waits for a queue switch. Gemma 4 31B at TP4 beside an idle Qwen3.8-Flash-Next went from 13 ms to 41 ms a step; with `RADIANCE_PREFETCH_BESIDE=0` in the Gemma engine it took 13.8 ms.
|
||||
|
||||
**Tooling**
|
||||
|
||||
|
||||
Reference in new issue
Block a user