Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@ Each release's page on GitHub has its notes and measurements. See [the 1.0.0 rel

## Unreleased

- CUDA ERNIE 5.5: the mHC pre step (a row's mixes, Sinkhorn and the collapse's RMSNorm) runs under the kernel contract with planted controls; serving is unchanged (#5301, thanks @Bizuayeu).

- Server: `--confidential` refuses existing Linux tracers and, where whole-process locking is supported, locks current and future process memory against swap or refuses startup; Darwin currently refuses because this locking is unavailable.

- HIP, Qwen 3.5 and Nemotron on one GPU: long prompt chunks keep the next layer queued while they poll for a cancel, rather than draining the GPU at every layer; tokens unchanged, and a cancel still drains before the pass ends (#4887).



- Qwen3.5 on CUDA: MTP admission charges the target tap ring once per stream, and native inference reserves only its 64-row recurrent log unless slide learning needs rollback snapshots, so the admission bound matches what the engine allocates (fixes #5134). Thanks to @tacosta for the report.

- Metal: Inkling 2 with a DFlash 2 drafter now saves and restores the drafter's lane state in the prompt cache, so warm cache hits restore the drafter alongside the target (#5032, thanks @gilby).



- `tensorfold info --hexagon FILE.gguf` checks a Gemma 4 E4B IT Q4_0 GGUF export against the Hexagon layout (architecture, text geometry and all 666 tensors) without the Qualcomm SDK; a match reports device execution as unverified, and a mismatch names the reason and exits with status 2 (#5475, thanks @tgerighty).

- Qwen3.8-27B on Metal: Q and K head norm and RoPE run as one `q27_qk_norm_rope` dispatch instead of two head-norm launches, the barrier between them and two RoPE launches, on every chip and pass, keys-only prompt tails included; on an M5 Ultra every cache row and `qa` byte and the served replies match the previous path (#2955, part of #2940).
Expand Down Expand Up @@ -185,6 +183,8 @@ Each release's page on GitHub has its notes and measurements. See [the 1.0.0 rel

- CUDA kernels: ERNIE 5.5's MultiMax on the head's fp32 logits (`tf_ernie55_multimax`, in a new `ernie5_5_head` image), each step rounded once in the vendor's order with nothing fused, under the kernel contract against the host's replay of those steps; nothing launches it yet, so served output is unchanged (#5202, part of #4926). Thanks to @Bizuayeu.

- CUDA kernels: ERNIE 5.5's DSA key lists (`tf_ernie55_window_merge`, in a new `ernie5_5_index` image): each row's indexer top-k picks, then its 128-position sliding window, with the row's count, as the sparse MLA reads them; under the kernel contract against the host's lists; nothing launches it yet, so served output is unchanged (#5211, part of #4926).

- Inkling 2 Mini on Metal, M5: a register-tiled dense BF16 kernel computes the same rows in the same order, with tokens unchanged; on an M5 Ultra a 2K-token prompt fills 5.7-7.3% faster (#5201, refs #5191). Thanks to @gilby.

- Inkling 2 Mini on Metal: 3:1 GQA decode and verify read each key/value head once for its three query heads, and multi-stream attention batches across shared descriptors, with tokens unchanged; on an M3 Ultra four-stream decode is 12-14% faster and a 2K-token prompt 6% faster (#5206, refs #5191). Thanks to @gilby.
Expand Down
19 changes: 19 additions & 0 deletions docs/kernel-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,25 @@ once in the vendor's order with nothing fused. Each output must be the host's re
TP=2 rank's half; gate 4 runs whole logits with whole ranges and power-of-two weights, where every step is exact
(`ernie5_5-head`; two controls: each term's multiply and add fused into an fma, and the last term's square dropped).

CUDA also checks ERNIE 5.5's DSA key lists (`ernie5_5/index.cu`, `tf_ernie55_window_merge`): each row's indexer
picks (`topk_rows`' out, `picked` of them held to [0, k] and ending at the first -1), then its sliding window's
min(seq, 128) positions up to seq - 1, then -1, as vLLM-ERNIE's `merge_swa_topk` lays them out for the sparse MLA,
with the count of entries a row. The lists must be the host's (`ernie5_5/window.zig`) to the byte, and every row's
entries, rows told a negative count or one past k included, are rows below seq that ascend to seq - 1 with its picks
below the window, from a decode row at the first position and deep in context, across seq = 128 and seq = k + 128,
to prompt chunks and the 1M context's last rows (`ernie5_5-index`; two controls: every row taking all k picks, and
the window's oldest position dropped).

CUDA also checks ERNIE 5.5's mHC pre side (`ernie5_5/mhc.cu`, `tf_ernie55_mhc_pre`): a row's 24 mixes of its 4 bf16
streams with fn's float32 rows (a thread's 64 terms in one fma chain, then the warps' butterflies), times ERNIE's mix
RMS 1 / (sqrt(mean) + eps); pre, post (2 sigmoid) and comb (each row's softmax plus hc_eps, then 20 rounds of
Sinkhorn's column and row sums); then the collapse sum_s pre_s x_s, its RMSNorm from the unrounded sums' squares, and
the norm's weight times the bf16 collapse, rounded to bf16 once. Each output is held to its float64 bound alone, as
GLM's float32-weight finish is: the normed rows, post and comb (`ernie5_5/mhc.zig`), from rows near unit RMS, offset
by 8 and below 1e-6, where the mix RMS's eps outweighs sqrt(mean); gate 4 runs pre at 1/2 on one stream, where every
fp32 sum is exact (`ernie5_5-mhc`; two controls: the plain mix RMS 1 / sqrt(mean + eps), and comb's softmax over a
column).

CPU: Qwen3.5-2B's affine projection (4 bits, groups of 64, `cpu_kernels.zig`) at the widths the 2B calls it, one row
to a 128-row prompt chunk, registered once for each chain count of its projection classes (16; 32 for the delta rule's
a and b; 8 for the head), and its RMS norm over 2048-wide rows; each registration's runs take 1 to 8 threads in turn,
Expand Down
2 changes: 2 additions & 0 deletions zig/build/cuda.zig
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ pub fn targets(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bu
runner.addImport("ernie5_5_cuda", b.createModule(.{ .root_source_file = b.path("zig/src/families/ernie5_5/cuda_head.zig"), .target = target, .optimize = optimize, .imports = &.{.{ .name = "cuda", .module = cuda }} }));
runner.addImport("hy4_route_rows_cuda", b.createModule(.{ .root_source_file = b.path("zig/src/families/hy4_flash/rows_cuda.zig"), .target = target, .optimize = optimize, .imports = &.{.{ .name = "cuda", .module = cuda }} }));
runner.addImport("hy4_engram_fp8", b.createModule(.{ .root_source_file = b.path("zig/src/families/hy4_flash/engram_fp8_cuda.zig"), .target = target, .optimize = optimize, .imports = &.{.{ .name = "cuda", .module = cuda }} }));
runner.addImport("ernie5_5_index_cuda", b.createModule(.{ .root_source_file = b.path("zig/src/families/ernie5_5/cuda_index.zig"), .target = target, .optimize = optimize, .imports = &.{.{ .name = "cuda", .module = cuda }} }));
runner.addImport("ernie5_5_mhc_cuda", b.createModule(.{ .root_source_file = b.path("zig/src/families/ernie5_5/cuda_mhc.zig"), .target = target, .optimize = optimize, .imports = &.{.{ .name = "cuda", .module = cuda }} }));
runner.addImport("gemma4_cuda", @import("gemma4_cuda.zig").module(b, target, optimize, cuda, mods.core, mods.lanes));
runner.addImport("spark25", @import("spark25.zig").module(b, target, optimize, cuda, mods.core, mods.lanes));
// the served family and its engine, for the dots runner
Expand Down
2 changes: 2 additions & 0 deletions zig/build/cuda_kernels.zig
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ pub const kernels = [_]Kernel{
.{ .name = "hy4_route", .src = "hy4_flash/route", .flags = glue },
.{ .name = "hy4_rows", .src = "hy4_flash/rows", .flags = &.{"-O3"} },
.{ .name = "hy4_dfly2_glue", .src = "hy4_flash/dfly2_glue", .flags = glue },
.{ .name = "ernie5_5_index", .src = "ernie5_5/index", .flags = &.{"-O3"} }, // ours: ERNIE 5.5's DSA key lists
.{ .name = "ernie5_5_mhc", .src = "ernie5_5/mhc", .flags = &.{"-O3"} }, // ours: ERNIE 5.5's mHC pre side
.{ .name = "minimax_m3", .flags = glue }, // ours: MiniMax-M3.1-Flash's glue (norms, RoPE prep, routing, DSpark, tower RoPE)
.{ .name = "minimax_m3_attn", .flags = glue }, // ours: MiniMax-M3.1-Flash's indexer and block-sparse attention
.{ .name = "idol", .flags = glue }, // ours: Idol's denoiser glue and its fp16 head-64 attention
Expand Down
55 changes: 55 additions & 0 deletions zig/kernels/cuda/ernie5_5/index.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// ERNIE 5.5's sparse-attention key lists: each row's indexer picks, then its sliding window, for the sparse MLA.

namespace ernie55i {

enum Fault { none, all_picks, short_window };

// Row blockIdx.x at pos[0] + row: picks to picked[row] in [0, k] and the first -1, the window to seq - 1, -1, a count.
template <Fault F>
__device__ __forceinline__ void merge(const int* __restrict__ picks, const int* __restrict__ picked,
const int* __restrict__ pos, int* __restrict__ tok, int* __restrict__ cnt, int k,
int window, long long w) {
__shared__ int valid;
const long long row = blockIdx.x, seq = static_cast<long long>(pos[0]) + row + 1;
const int p = picked[row];
const long long held = F == all_picks ? k : p < 0 ? 0 : p > k ? k : p;
const long long sw = (seq < window ? seq : window) - (F == short_window ? 1 : 0), first = seq - sw;
const int* in = picks + row * k;
if (threadIdx.x == 0) valid = static_cast<int>(held);
__syncthreads();
// a negative pick inside the held count ends the picks (the control keeps every pick it is told)
if (F != all_picks)
for (long long c = threadIdx.x; c < held; c += blockDim.x)
if (in[c] < 0) atomicMin(&valid, static_cast<int>(c));
__syncthreads();
const long long n = valid;
int* out = tok + row * w;
for (long long c = threadIdx.x; c < w; c += blockDim.x)
out[c] = c < n ? in[c] : c < n + sw ? static_cast<int>(first + (c - n)) : -1;
if (threadIdx.x == 0) cnt[row] = static_cast<int>(n + sw);
}

} // namespace ernie55i

// One row a block of 256 threads; lists w wide (at least k + window).
extern "C" __global__ void __launch_bounds__(256)
tf_ernie55_window_merge(const int* __restrict__ picks, const int* __restrict__ picked, const int* __restrict__ pos,
int* __restrict__ tok, int* __restrict__ cnt, int k, int window, long long w) {
ernie55i::merge<ernie55i::none>(picks, picked, pos, tok, cnt, k, window, w);
}

// The contract's planted control: every row takes all k picks, its -1s past picked among them.
extern "C" __global__ void __launch_bounds__(256)
tf_ctl_ernie55_window_merge_all_picks(const int* __restrict__ picks, const int* __restrict__ picked,
const int* __restrict__ pos, int* __restrict__ tok, int* __restrict__ cnt,
int k, int window, long long w) {
ernie55i::merge<ernie55i::all_picks>(picks, picked, pos, tok, cnt, k, window, w);
}

// The contract's planted control: the window's oldest position dropped.
extern "C" __global__ void __launch_bounds__(256)
tf_ctl_ernie55_window_merge_short_window(const int* __restrict__ picks, const int* __restrict__ picked,
const int* __restrict__ pos, int* __restrict__ tok,
int* __restrict__ cnt, int k, int window, long long w) {
ernie55i::merge<ernie55i::short_window>(picks, picked, pos, tok, cnt, k, window, w);
}
Loading
Loading