37 tok/s from Qwen3-Next-80B (48 GB) on a 32 GB laptop, 24 without drafts vs 2.8 for llama.cpp; reading 62 vs 16 tok/s. Faster than llama.cpp on all 13 models compared in Q4_K_M. LLMs bigger than your RAM, pure C, CPU or GPU.
C avx2ccpu-inferenceggufinference-enginelinuxllmlocal-llmmixture-of-expertsmoenvmequantizationqwen3simdspeculative-decodingvulkan
/* SPDX-License-Identifier: GPL-3.0-or-later
Copyright (C) 2026 Maurizio Cammalleri
The table IQ3XXS_GRID below is the IQ3_XXS grid of ggml
(ggml/src/ggml-common.h, iq3xxs_grid), copied as data from
src/llm/iq3xxs_grid.h: it defines the format. Copyright (c) 2023-2026
The ggml authors, under the MIT licence (see the ggml repository).
Generated - not formatted by hand. */
#version 450
// IQ3_XXS weights times up to NV Q8_K vectors, one row per invocation, as
// janas_iq3xxs_dot_ref computes them: 98 bytes a block (d, 64 grid indices
// of four levels each, then for each group of 32 a word of four 7-bit sign
// indices - the eighth bit their parity, ggml's ksigns_iq2xs - and the
// scale in its top four bits), each group's integer dot times 1 + 2 s, the
// block's exact integer sum in one fma with (d / 4) d8: the CPU's float
// operations, so the results agree bit for bit. Blocks start on 2-byte
// boundaries: their words are realigned. Activations shared across the
// subgroup as in q4k_matvec.comp.
#extension GL_EXT_integer_dot_product : require
#extension GL_KHR_shader_subgroup_basic : require
#extension GL_KHR_shader_subgroup_ballot : require
#extension GL_EXT_buffer_reference : require
#extension GL_EXT_buffer_reference_uvec2 : require
layout(local_size_x = 64) in;
layout(constant_id = 0) const uint NV = 8;
layout(constant_id = 1) const uint SG = 8;
const uint NX = (19u + SG - 1u) / SG;
const uint BS = 98u, NW = (BS + 3u) / 4u + 1u;
layout(buffer_reference, std430, buffer_reference_align = 4) readonly buffer U1 { uint v[]; };
layout(buffer_reference, std430, buffer_reference_align = 16) readonly buffer U4 { uvec4 v[]; };
layout(buffer_reference, std430, buffer_reference_align = 4) writeonly buffer F { float v[]; };
layout(push_constant) uniform P { uvec2 w, x, y; uint rows, nb, nv, xs, ys; } p;
const uint IQ3XXS_GRID[256] = uint[256](
0x04040404u, 0x04040414u, 0x04040424u, 0x04040c0cu, 0x04040c1cu, 0x04040c3eu,
0x04041404u, 0x04041414u, 0x04041c0cu, 0x04042414u, 0x04043e1cu, 0x04043e2cu,
0x040c040cu, 0x040c041cu, 0x040c0c04u, 0x040c0c14u, 0x040c140cu, 0x040c142cu,
0x040c1c04u, 0x040c1c14u, 0x040c240cu, 0x040c2c24u, 0x040c3e04u, 0x04140404u,
0x04140414u, 0x04140424u, 0x04140c0cu, 0x04141404u, 0x04141414u, 0x04141c0cu,
0x04141c1cu, 0x04141c3eu, 0x04142c0cu, 0x04142c3eu, 0x04143e2cu, 0x041c040cu,
0x041c043eu, 0x041c0c04u, 0x041c0c14u, 0x041c142cu, 0x041c3e04u, 0x04240c1cu,
0x04241c3eu, 0x04242424u, 0x04242c3eu, 0x04243e1cu, 0x04243e2cu, 0x042c040cu,
0x042c043eu, 0x042c1c14u, 0x042c2c14u, 0x04341c2cu, 0x04343424u, 0x043e0c04u,
0x043e0c24u, 0x043e0c34u, 0x043e241cu, 0x043e340cu, 0x0c04040cu, 0x0c04041cu,
0x0c040c04u, 0x0c040c14u, 0x0c04140cu, 0x0c04141cu, 0x0c041c04u, 0x0c041c14u,
0x0c041c24u, 0x0c04243eu, 0x0c042c04u, 0x0c0c0404u, 0x0c0c0414u, 0x0c0c0c0cu,
0x0c0c1404u, 0x0c0c1414u, 0x0c14040cu, 0x0c14041cu, 0x0c140c04u, 0x0c140c14u,
0x0c14140cu, 0x0c141c04u, 0x0c143e14u, 0x0c1c0404u, 0x0c1c0414u, 0x0c1c1404u,
0x0c1c1c0cu, 0x0c1c2434u, 0x0c1c3434u, 0x0c24040cu, 0x0c24042cu, 0x0c242c04u,
0x0c2c1404u, 0x0c2c1424u, 0x0c2c2434u, 0x0c2c3e0cu, 0x0c34042cu, 0x0c3e1414u,
0x0c3e2404u, 0x14040404u, 0x14040414u, 0x14040c0cu, 0x14040c1cu, 0x14041404u,
0x14041414u, 0x14041434u, 0x14041c0cu, 0x14042414u, 0x140c040cu, 0x140c041cu,
0x140c042cu, 0x140c0c04u, 0x140c0c14u, 0x140c140cu, 0x140c1c04u, 0x140c341cu,
0x140c343eu, 0x140c3e04u, 0x14140404u, 0x14140414u, 0x14140c0cu, 0x14140c3eu,
0x14141404u, 0x14141414u, 0x14141c3eu, 0x14142404u, 0x14142c2cu, 0x141c040cu,
0x141c0c04u, 0x141c0c24u, 0x141c3e04u, 0x141c3e24u, 0x14241c2cu, 0x14242c1cu,
0x142c041cu, 0x142c143eu, 0x142c240cu, 0x142c3e24u, 0x143e040cu, 0x143e041cu,
0x143e0c34u, 0x143e242cu, 0x1c04040cu, 0x1c040c04u, 0x1c040c14u, 0x1c04140cu,
0x1c04141cu, 0x1c042c04u, 0x1c04342cu, 0x1c043e14u, 0x1c0c0404u, 0x1c0c0414u,
0x1c0c1404u, 0x1c0c1c0cu, 0x1c0c2424u, 0x1c0c2434u, 0x1c14040cu, 0x1c14041cu,
0x1c140c04u, 0x1c14142cu, 0x1c142c14u, 0x1c143e14u, 0x1c1c0c0cu, 0x1c1c1c1cu,
0x1c241c04u, 0x1c24243eu, 0x1c243e14u, 0x1c2c0404u, 0x1c2c0434u, 0x1c2c1414u,
0x1c2c2c2cu, 0x1c340c24u, 0x1c341c34u, 0x1c34341cu, 0x1c3e1c1cu, 0x1c3e3404u,
0x24040424u, 0x24040c3eu, 0x24041c2cu, 0x24041c3eu, 0x24042c1cu, 0x24042c3eu,
0x240c3e24u, 0x24141404u, 0x24141c3eu, 0x24142404u, 0x24143404u, 0x24143434u,
0x241c043eu, 0x241c242cu, 0x24240424u, 0x24242c0cu, 0x24243424u, 0x242c142cu,
0x242c241cu, 0x242c3e04u, 0x243e042cu, 0x243e0c04u, 0x243e0c14u, 0x243e1c04u,
0x2c040c14u, 0x2c04240cu, 0x2c043e04u, 0x2c0c0404u, 0x2c0c0434u, 0x2c0c1434u,
0x2c0c2c2cu, 0x2c140c24u, 0x2c141c14u, 0x2c143e14u, 0x2c1c0414u, 0x2c1c2c1cu,
0x2c240c04u, 0x2c24141cu, 0x2c24143eu, 0x2c243e14u, 0x2c2c0414u, 0x2c2c1c0cu,
0x2c342c04u, 0x2c3e1424u, 0x2c3e2414u, 0x34041424u, 0x34042424u, 0x34042434u,
0x34043424u, 0x340c140cu, 0x340c340cu, 0x34140c3eu, 0x34143424u, 0x341c1c04u,
0x341c1c34u, 0x34242424u, 0x342c042cu, 0x342c2c14u, 0x34341c1cu, 0x343e041cu,
0x343e140cu, 0x3e04041cu, 0x3e04042cu, 0x3e04043eu, 0x3e040c04u, 0x3e041c14u,
0x3e042c14u, 0x3e0c1434u, 0x3e0c2404u, 0x3e140c14u, 0x3e14242cu, 0x3e142c14u,
0x3e1c0404u, 0x3e1c0c2cu, 0x3e1c1c1cu, 0x3e1c3404u, 0x3e24140cu, 0x3e24240cu,
0x3e2c0404u, 0x3e2c0414u, 0x3e2c1424u, 0x3e341c04u);
int dp(uint a, uint b) { return dotPacked4x8EXT(int(a), int(b)); }
uvec4 bc(uvec4 xr[NX], uint k) { return subgroupBroadcast(xr[k / SG], k % SG); }
uint byte_at(uint wd[NW], uint i) { return (wd[i >> 2] >> (8u * (i & 3u))) & 0xffu; }
uint half_at(uint wd[NW], uint i) { return byte_at(wd, i) | (byte_at(wd, i + 1u) << 8); }
uint signs7(uint i) { return i | ((uint(bitCount(i)) & 1u) << 7); }
uint signed4(uint g, uint s)
{
uint r = 0u;
for (uint i = 0; i < 4u; i++) {
int v = int((g >> (8u * i)) & 0xffu);
if (((s >> i) & 1u) != 0u)
v = -v;
r |= (uint(v) & 0xffu) << (8u * i);
}
return r;
}
/* the grid in the workgroup's shared memory (iq4xs_matvec.comp) */
shared uint GS[256];
void main()
{
for (uint i = gl_LocalInvocationID.x; i < 256u; i += 64u)
GS[i] = IQ3XXS_GRID[i];
barrier();
U1 W = U1(p.w);
U4 X = U4(p.x);
F Y = F(p.y);
uint lane = gl_SubgroupInvocationID;
uint grow = gl_WorkGroupID.y * 64u + gl_LocalInvocationID.x;
uint row = min(grow, p.rows - 1u);
uint v0 = gl_WorkGroupID.x * NV;
uint xo[NV];
for (uint v = 0; v < NV; v++)
xo[v] = min(v0 + v, p.nv - 1u) * p.xs * 20u;
float acc[NV];
for (uint v = 0; v < NV; v++)
acc[v] = 0.0;
uint off = row * p.nb * BS;
for (uint b = 0; b < p.nb; b++, off += BS) {
uint base = off >> 2;
uint wd[NW];
for (uint k = 0; k < NW; k++)
wd[k] = W.v[base + k];
if ((off & 3u) != 0u) {
for (uint k = 0; k + 1u < NW; k++)
wd[k] = (wd[k] >> 16) | (wd[k + 1u] << 16);
wd[NW - 1u] = wd[NW - 1u] >> 16;
}
float d = unpackHalf2x16(wd[0] & 0xffffu).x;
/* group g: eight signed words (weights 4i..4i+3), its scale */
uint q[64];
int sc[8];
for (uint g = 0; g < 8u; g++) {
uint aux = half_at(wd, 66u + 4u * g) | (half_at(wd, 68u + 4u * g) << 16);
sc[g] = 1 + 2 * int(aux >> 28);
for (uint k = 0; k < 4u; k++) {
uint sg = signs7((aux >> (7u * k)) & 127u);
q[8u * g + 2u * k] = signed4(GS[byte_at(wd, 2u + 8u * g + 2u * k)], sg & 15u);
q[8u * g + 2u * k + 1u] = signed4(GS[byte_at(wd, 3u + 8u * g + 2u * k)], sg >> 4);
}
}
for (uint v = 0; v < NV; v++) {
uvec4 xr[NX];
for (uint j = 0; j < NX; j++)
xr[j] = X.v[xo[v] + min(j * SG + lane, 19u)];
int isum = 0;
for (uint g = 0; g < 8u; g++) {
uvec4 a0 = bc(xr, 2u * g), a1 = bc(xr, 2u * g + 1u);
uint q0 = 8u * g;
int s = dp(q[q0], a0.x) + dp(q[q0 + 1u], a0.y) + dp(q[q0 + 2u], a0.z) +
dp(q[q0 + 3u], a0.w) + dp(q[q0 + 4u], a1.x) + dp(q[q0 + 5u], a1.y) +
dp(q[q0 + 6u], a1.z) + dp(q[q0 + 7u], a1.w);
isum += sc[g] * s;
}
float d8 = uintBitsToFloat(bc(xr, 18u).x);
acc[v] = fma(d * 0.25 * d8, float(isum), acc[v]);
xo[v] += 20u;
}
}
if (grow < p.rows)
for (uint v = 0; v < NV; v++)
if (v0 + v < p.nv)
Y.v[(v0 + v) * p.ys + row] = acc[v];
}