Archived
radiance 1.7.0
- every model serves without a GPU: libavx covers every op, so `--kernels libavx` alone serves every shipped container - Qwen3-ASR (zivius): speech to text on /v1/audio/transcriptions and live over /v1/realtime - /v1/messages works with Claude Code as it ships (gearwave00001) - a long agent conversation keeps its cached history when the client rewrites its last turn (manueloverride) - a stream's first event goes out with the first token, so llama-benchy measures prefill right - opt-in --prefill-interleave (Smellyyyy, baKon) and --prefill-span (keptn42) - four-rank TP releases the link early; four-rank selftests and docs/TP4.md (goodman-b) - NVFP4 and FP8 compressed-tensors imports (devmilan); tools/rad-export for finetunes and LoRA adapters (baKon) - many fixes, among them lost tokens on stop strings under concurrency, keep-alive, MiniCPM5 tool arguments and the CPU's vision and audio encoders - plugin ABI 17 and changed op schemas: out-of-tree plugins must be rebuilt
This commit is contained in:
1 parent
b068190326
commit
1e968f6e1d
739 files changed
+128447
-84632
No files matched your search
@@ -1,12 +1,10 @@
|
||||
// r4d_gelu_mul_quant_i8.hip - r4d_gelu_mul_quant_i8: gelu(gate) * up and the per-row int8 quantiser
|
||||
// r4d_gemm_w4a8_nt_m64 reads, in one pass over the row.
|
||||
//
|
||||
// The down projection's input of a GELU-gated feed-forward (Gemma) on a w4a8 grid: unfused it is
|
||||
// gelu_mul and quant_act_i8, two single-row dispatches at a decode batch. This is the pair as one,
|
||||
// BYTE-IDENTICAL to it: the product is formed exactly as gelu_mul_kernel forms it (the tanh form,
|
||||
// the same constants, rounded to bf16), and the absmax, scale and codes are quant_act_i8's over
|
||||
// those bf16 values -- the absmax is a max and so takes no partition, and every code is a function
|
||||
// of its own value and the row scale.
|
||||
// The down projection's input of a GELU-gated feed-forward (Gemma) on a w4a8 grid, replacing the
|
||||
// gelu_mul + quant_act_i8 pair and byte-identical to it: the product is formed as gelu_mul_kernel
|
||||
// forms it (tanh form, same constants, rounded to bf16), and the absmax, scale and codes are
|
||||
// quant_act_i8's over those bf16 values. The absmax is a max, so partitioning does not change it.
|
||||
#include "r4d.h"
|
||||
#include "r4d_args.h"
|
||||
#include "r4d_emit.h"
|
||||
@@ -15,8 +13,6 @@
|
||||
|
||||
namespace {
|
||||
|
||||
__device__ __forceinline__ float bf2f(uint16_t h) { return __uint_as_float((uint32_t)h << 16); }
|
||||
|
||||
template <uint32_t THR>
|
||||
__global__ __launch_bounds__(THR) void gelu_mul_quant_i8_kernel(
|
||||
const uint16_t* __restrict__ gu, signed char* __restrict__ q, float* __restrict__ S,
|
||||
@@ -29,13 +25,13 @@ __global__ __launch_bounds__(THR) void gelu_mul_quant_i8_kernel(
|
||||
|
||||
float m = 0.0f;
|
||||
for (uint32_t i = threadIdx.x; i < n; i += THR) {
|
||||
const float g = bf2f(gr[i]);
|
||||
const float g = bf16_to_f32(gr[i]);
|
||||
const float k0 = 0.7978845608028654f, k1 = 0.044715f;
|
||||
const float gelu = 0.5f * g * (1.0f + tanhf(k0 * (g + k1 * g * g * g)));
|
||||
const uint16_t y = f32_to_bf16(gelu * bf2f(gr[n + i]));
|
||||
const uint16_t y = f32_to_bf16(gelu * bf16_to_f32(gr[n + i]));
|
||||
ybuf[i] = y;
|
||||
if (yo) yo[(size_t)row * y_ld + i] = y;
|
||||
m = fmaxf(m, fabsf(bf2f(y)));
|
||||
m = fmaxf(m, fabsf(bf16_to_f32(y)));
|
||||
}
|
||||
m = r4d_wave_max(m);
|
||||
if ((threadIdx.x & 31) == 0) lm[threadIdx.x >> 5] = m;
|
||||
@@ -50,7 +46,7 @@ __global__ __launch_bounds__(THR) void gelu_mul_quant_i8_kernel(
|
||||
for (uint32_t i = threadIdx.x; i < n; i += THR) {
|
||||
const uint32_t s = i >> 4, j = i & 15;
|
||||
const uint32_t src = (s << 4) + 8 * ((j & 7) >> 2) + 4 * (j >> 3) + (j & 3);
|
||||
const int t = __float2int_rn(bf2f(ybuf[src]) * inv);
|
||||
const int t = __float2int_rn(bf16_to_f32(ybuf[src]) * inv);
|
||||
qr[i] = (signed char)(t < -128 ? -128 : (t > 127 ? 127 : t));
|
||||
}
|
||||
}
|
||||
@@ -61,7 +57,7 @@ __global__ __launch_bounds__(THR) void gelu_mul_quant_i8_kernel(
|
||||
// fragment order, scale [M][1] f32, out_bf16 [M][n] bf16 optional.
|
||||
enum { GM_GU = 0, GM_Q, GM_S, GM_Y };
|
||||
|
||||
static int rad_gelu_mul_quant_i8_body(const RadArgs* a, const R4dSink& sk) {
|
||||
extern "C" int r4d_rad_gelu_mul_quant_i8(const RadArgs* a, RadStream stream) {
|
||||
int emit_rc = RAD_OK;
|
||||
const RadTensor* gu = r4d_opt(a, GM_GU);
|
||||
const RadTensor* q = r4d_opt(a, GM_Q);
|
||||
@@ -83,7 +79,7 @@ static int rad_gelu_mul_quant_i8_body(const RadArgs* a, const R4dSink& sk) {
|
||||
const size_t lds = (size_t)n * sizeof(uint16_t);
|
||||
if (lds > 60 * 1024) return R4D_NO(RAD_E_SHAPE);
|
||||
const int thr = r4d_act_threads((int)M, (int)n);
|
||||
#define R4D_GMQ_T(T) emit_rc = R4D_EMIT(sk, (gelu_mul_quant_i8_kernel<T>), dim3((uint32_t)M), dim3(T), lds, \
|
||||
#define R4D_GMQ_T(T) emit_rc = R4D_EMIT(stream, (gelu_mul_quant_i8_kernel<T>), dim3((uint32_t)M), dim3(T), lds, \
|
||||
(const uint16_t*)r4d_p(gu), (signed char*)r4d_wp(q), (float*)r4d_wp(s), (uint16_t*)r4d_wp(y), \
|
||||
(uint32_t)n, (uint32_t)gp, (uint32_t)yp)
|
||||
if (thr == 1024) R4D_GMQ_T(1024);
|
||||
@@ -93,4 +89,3 @@ static int rad_gelu_mul_quant_i8_body(const RadArgs* a, const R4dSink& sk) {
|
||||
#undef R4D_GMQ_T
|
||||
return emit_rc;
|
||||
}
|
||||
R4D_ENTRY(r4d_rad_gelu_mul_quant_i8, rad_gelu_mul_quant_i8_body)
|
||||
Reference in new issue
Block a user