diff --git a/.gitignore b/.gitignore index 7e1a6424..2bb59988 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ compile_commands.json /sync-jarvis.sh __pycache__/ .cache/ +/baseline-models/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 95a378c6..af6c76cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.21) # VERSION is the server release that /version reports. The plugin ABI version is separate and is # read from abi/rad_abi.h below. -project(radiance VERSION 1.15.1 LANGUAGES C CXX) +project(radiance VERSION 1.17.0 LANGUAGES C CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -20,6 +20,7 @@ set(RAD_WITH_FFMPEG "AUTO" CACHE STRING "ON | OFF | AUTO -- decode image, video and audio parts with libavformat/libavcodec/libswscale/libswresample") set_property(CACHE RAD_WITH_FFMPEG PROPERTY STRINGS ON OFF AUTO) option(RAD_BUILD_TESTS "Build the test suite" ON) +option(RAD_ENABLE_KV_ROLLBACK_TEST_HOOK "Compile the test-only device KV rollback observer" OFF) option(RAD_ASAN "Build host code with AddressSanitizer and UBSan" OFF) option(RAD_TSAN "Build host code with ThreadSanitizer" OFF) # LLVM 24's VOPD pairing is not repeatable unless patched (docker/llvm-vopd-pairing.patch); when @@ -391,8 +392,9 @@ if(RAD_HIP_FOUND AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/libr4d/CMakeLists.txt) endif() # libr3d: the RDNA3 kernel library, same shape as libr4d and same guard -- device code needs a HIP # toolchain. It declares itself for `^gfx11` and returns without a target when the build's -# RAD_GPU_TARGETS holds no RDNA3, so a gfx12-only build of this tree does not produce it. A card -# with no kernel library of its own refuses device-only ops (docs/PLUGIN.md §10). +# RAD_GPU_TARGETS holds no RDNA3, so a gfx12-only build of this tree does not produce it, and +# declines every machine without a gfx11 card (rad_plugin_open). A card with no kernel library of +# its own refuses device-only ops (docs/PLUGIN.md §10). if(RAD_HIP_FOUND AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/libr3d/CMakeLists.txt) add_subdirectory(libr3d) endif() diff --git a/Dockerfile b/Dockerfile index 8963f833..8f27542c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,10 +28,12 @@ # and refuses a compressed bundle. # # GPU_TARGETS must be named: a build container has no card to detect, unlike a bare-metal -# ./build.sh. They are the targets of the shipped kernel libraries; libr4d serves RDNA4 only and -# drops every architecture outside gfx12. The engine's own kernels carry the generic family -# targets and run on every AMD GPU family, so a kernel library for another card is added by -# mounting it on the search path: +# ./build.sh. They are the targets of the shipped kernel libraries, each of which keeps only its own +# family: libr4d takes gfx1201 (RDNA4), libr3d gfx11-generic (every RDNA3 chip) and gfx1151, and +# libhalo gfx1151 (Strix Halo), where the loader prefers it over libr3d. On any one card the other +# libraries decline or are left out, so the default image serves all three. The engine's own +# kernels carry the generic family targets and run on every AMD GPU family, so a kernel library for +# another card is added by mounting it on the search path: # docker run ... -v /my/plugins:/plugins -e RADIANCE_HOME=/plugins:/opt/radiance/share/radiance # # The image's ROCm userspace must be supported by the host's amdgpu kernel driver; it is pinned to @@ -131,7 +133,7 @@ RUN echo 1000 > /proc/self/oom_score_adj 2>/dev/null || true; \ # ------------------------------------------------------------------------------------------ build FROM rocm/dev-ubuntu-${UBUNTU_VERSION}:${ROCM_VERSION} AS build -ARG GPU_TARGETS=gfx1201 +ARG GPU_TARGETS="gfx1201;gfx11-generic;gfx1151" # Parallel compile jobs; empty means one per core. A device-kernel translation unit takes 2-3 GB # of RAM under hipcc, so lower it on a host that is also serving. ARG JOBS= @@ -227,11 +229,12 @@ ARG TEST_EXCLUDE= # perf_event_open, so the tests that bound work count CPU time rather than instructions # (tests/work_counter.h). The `oot` suite (every shipped plugin rebuilt against the installed # package) repeats this stage's whole compile, so it runs from the development tree instead -# (tests/oot_plugins.sh). +# (tests/oot_plugins.sh). The `parity` entry (halo_parity: libhalo's tables against libr4d's) is +# left out until libhalo has ported the ops libr4d added after it (the test names each one). RUN echo 1000 > /proc/self/oom_score_adj 2>/dev/null || true; \ bash /src/docker/llvm-check.sh /build \ && RAD_TEST_CPU_BUDGET_SCALE="${TEST_CPU_BUDGET_SCALE}" \ - ctest --test-dir /build -LE 'gpu|oot' ${TEST_EXCLUDE:+-E "${TEST_EXCLUDE}"} \ + ctest --test-dir /build -LE 'gpu|oot|parity' ${TEST_EXCLUDE:+-E "${TEST_EXCLUDE}"} \ -j"${TEST_JOBS:-${JOBS:-$(( ($(nproc) + 1) / 2 ))}}" --output-on-failure \ && touch /build/host-tests-passed @@ -283,7 +286,7 @@ RUN set -e; R=/rootfs; L=$R/usr/lib/x86_64-linux-gnu; \ # ---------------------------------------------------------------------------------------- runtime FROM scratch AS runtime -ARG GPU_TARGETS=gfx1201 +ARG GPU_TARGETS="gfx1201;gfx11-generic;gfx1151" ARG VERSION=dev ARG REVISION=unknown diff --git a/NOTICE b/NOTICE index 4fbf1c61..a24ca03e 100644 --- a/NOTICE +++ b/NOTICE @@ -19,13 +19,24 @@ Written by Deadcode, with contributions from: Gemma 4 31B heretic-ara and Ornith-1.5-35B-A3B compose files, Gemma 4's E2B/E4B form (KV-shared layers, per-layer embeddings, clipped vision linears) with NVIDIA-Nemotron-3.5-Bolt-E4B, its audio encoder, its i8a8 linears and its KV heads replicated over ranks, 4-bit weights at decode heights - through w4a16_asym, and the Ornith-1.5-122B compose files + through w4a16_asym, the Ornith-1.5-122B compose files, the Gemma 4 31B's asymmetric int5 + linears (w5a8i8 and w5a16), the junctions at quant_act_i8g's grid (rmsnorm_quant_i8g, + gelu_mul_quant_i8g and ar_rmsnorm_quant_i8g) with the prefill overlap on the i8a8, a4 and w5 + grids, the 31B's i8g, heretic-ara-i8g and w5 compose files, and Ling-3.0-flash (bailing_hybrid: + KDA, dense latent attention, group-limited sigmoid routing, the clipped SwiGLU and its MTP layer as + a serial drafter) with mla_attn_paged, its w4a8 recipes and compose files, possessive quantifiers + in the tokenizer's patterns, the Grafana dashboard's first screen, and Gemma 4 12B (its picture + and audio embedders, a picture's placeholders read both ways on the sliding layers, the windowed + attention at head_dim 512, suppress_tokens) with its compose files - mechkbfan: the token embedding in the pinned host pool - Code000: the n-gram gather on the card and the MTP head's history-pass skip, and the MTP draft coupling with its cooperative verify (--draft-coupling), the W4A8 prefill's tail scale read, the ISA instruments' VGPR granule, back-edge count and fail-closed parse, scored steps (rad_declare_scores, RadBatch::score_only), the gated prefill fold, the short-prompt split row and - the rows forms of rmsnorm and rope, and LFM2's 8-bit trunk with the d1-3B recipe + the rows forms of rmsnorm and rope, LFM2's 8-bit trunk with the d1-3B recipe, the file tier's + routed reads with their own router's counts and its deposit wait, the stop-string hold-back, and + the sampler's planes by the step's token bound, its n-gram ban beside a drafter and no candidate + cut over a top-1 row - baKon: three-rank tensor parallelism, serving any world size from the shipped container, the request log, an uneven world's per-rank KV and weights split, --rope-scaling, the model entry's context length, root and capabilities, /props, the three-rank two-shot all-reduce and tiered-int8 @@ -85,7 +96,8 @@ Written by Deadcode, with contributions from: split by depth, the delta net's out-projection read beside its decode recurrent update, the MXFP4 feed-forward's gated fold up to 16 rows, the three-wave verify floor bounded by the batch's workgroups, the split-KV row sum read with fetch-inactive, KLATE again for the head-256 gqa6 - paged prefill, and the preempted-prefill gate past a KV group that holds no blocks + paged prefill, the preempted-prefill gate past a KV group that holds no blocks, and the norms' + lane sum issuing its reads eight at a time - eddie168168: the rotated int8 trunk (i8a8h) and the qwen35_w8a8 plugin serving it, and the out-of-tree test at the tree's VOPD setting, and its norm and SiLU producers writing the int8 linears' operands directly @@ -106,7 +118,8 @@ Written by Deadcode, with contributions from: one-sequence KV floor over the live plan, and prefill staging paid by expert residency - Memoria: the dashboard's decode floor and recent window, the sparklines' percentile range, and the bringup time in /stats, the acceptance tiles' live figures and statsdump's size-capped - rotation + rotation, the dashboard's history line, session extremes, card-count changes and Requests-header + JSON export, with the page's JavaScript driven by tests/js - C_Tamas: control vectors, loaded when the deployment asks and applied as a per-layer residual projection, KV streaming for a context bigger than VRAM (--kv-resident), and the dashboard's request history, KV streaming traffic and one-unit KV meter @@ -118,7 +131,11 @@ Written by Deadcode, with contributions from: - farcryjohn: periodic window snapshots that let an edited prompt reuse its prefix - gostar: snapshot-backed prefix KV kept across recomputes, and Tencent's Hy-Memory (HYV3) -- its BF16, FP8 and GGUF adapters, its KV scales, its native sectioned tool calls, and its W4 decode - (the per-128 I4 expert packing, the one-row W4/W5 epilogue and the fused prologue and folds) + (the per-128 I4 expert packing, the one-row W4/W5 epilogue and the fused prologue and folds), + and the head-256 prefill softmax rescaled by row rather than by wave, Spark 2.5 (spark25: bf16 and + rotated-int8 IQ8R checkpoints, tensor parallelism with exact collectives, reasoning and tagged + tool calls) with its DSpark drafter (exact attention and Markov walk ops), the prefill split keyed + by live KV bounds, and --gpu-memory-mib - launch80_assets: tuning collectives as the exchange they serve at the served configuration, the per-layer embeddings' read-ahead queue and gather regimes, and the step loop's stall watch - hugypufy: M2XFP4 -- its quantiser, its GEMMs and its linears in the Qwen3.8 trunk and the DFlash2 @@ -134,7 +151,9 @@ Written by Deadcode, with contributions from: - Dad_Vibes: hc_read's decode kernels as one grid, its tiled up-mix pipelined and its one-grid wait trapping past its deadline, and gemm_fp8a8's narrow form with its scales staged through LDS and its gated three-tile form at 8 waves -- RikshaDriver: libr3d, the RDNA3 (gfx11) kernel library +- RikshaDriver: libr3d, the RDNA3 (gfx11) kernel library, and its wave-matrix rewrite: the GEMMs + retiled to 16x128 blocks, the grouped MoE GEMMs, the norms and quantisers, and the QSA and MoE + router rows - fl0l0u: every request entry point bounded, gated and sanitised (JSON parses bounded in depth, errors safe on invalid UTF-8, control bytes kept off the log, the dashboard's CSP, cross-origin browsers refused on the loopback-only routes, method-scoped API-key exemptions), prompt ids that @@ -150,6 +169,8 @@ Written by Deadcode, with contributions from: hot VRAM cache with its deposits and copyless relabels, and GLM-5.3-Flash's experts read file-direct under expert parallelism -- the stall watch counting drive reads as progress, and the DMA lane's lists fenced so a stalled read pointer no longer fills its ring +- pokesjw: the n-gram reader refilling its reads as they land, and a decode gather waiting on the + other rank's read of a row instead of reading it again This product includes software from the following projects, each under the MIT License. The license text is in the file named beside each. diff --git a/README.md b/README.md index aae54db5..494d243a 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,8 @@ APIs, Anthropic's Messages API and llama-server's native one, so their clients a unchanged. Model architectures, kernel libraries and quantisers are `.so` plugins; the ones in this tree are built and loaded the same way a third party's are ([`docs/PLUGIN.md`](docs/PLUGIN.md)). -The bundled device kernels (`libr4d`) target AMD RDNA4 (`gfx1200`, `gfx1201`). The serve flags +The bundled device kernels target AMD RDNA4 (`libr4d`: `gfx1200`, `gfx1201`), RDNA3 (`libr3d`: +`gfx11xx`) and Strix Halo (`libhalo`: `gfx1151`). The serve flags below are for two 32 GB cards (Radeon AI PRO R9700). The engine starts on any AMD GPU family; another card needs a kernel library for it. A machine with no GPU builds the host backend, whose AVX-512/AVX2 kernels (`libavx`) serve every model here: the small ones (EmbeddingGemma 2, @@ -91,6 +92,7 @@ it (`-DRAD_XE2_MKL=OFF`, or `XE2_NO_MKL=1` at run time, keeps the hand-written p | Qwen3.8-Flash-Next: 4-bit experts, int8 trunk, MTP, vision | `qwen3.8-next-flash-fp8-iq4r-moe.rad` (114 GiB) | [download](https://huggingface.co/StillDeadcode/qwen3.8-next-flash-fp8-iq4r-moe) | `flashnext.yaml` | | Qwen3.8-27B FP8, DFlash2 drafter, vision | `qwen3.8-27b-fp8.rad` (29 GiB) | [download](https://huggingface.co/StillDeadcode/qwen3.8-27b-fp8) | `qwen3.8-27b-fp8.yaml` | | Qwen3.8-27B MXFP4 (AMD Quark AWQ), DFlash2 drafter, vision | `qwen3.8-27b-mxfp4.rad` (19 GiB) | [download](https://huggingface.co/StillDeadcode/qwen3.8-27b-mxfp4) | `qwen3.8-27b-mxfp4.yaml` | +| Qwen3.8-27B IQR-V4, 2.5 to 8 bits a weight ([docs/IQR.md](docs/IQR.md)), DFlash2 drafter, vision | `qwen3.8-27b-iq2r-v4.rad` .. `qwen3.8-27b-iq8r-v4.rad` (10 to 28 GiB) | [download](https://huggingface.co/StillDeadcode/qwen3.8-27b-iqr-v4) | `qwen3.8-27b-iqr-v4.yaml` | | Qwen3.6-35B-A3B FP8, MTP | `qwen3.6-35b-a3b-fp8.rad` (35 GiB) | [download](https://huggingface.co/StillDeadcode/qwen3.6-35b-a3b-fp8) | `qwen3.6-35b-a3b.yaml` | | Ornith-1.5-35B-A3B FP8, MTP, vision | `ornith-1.5-35b-a3b-fp8.rad` (35 GiB) | [download](https://huggingface.co/keptn/ornith-1.5-35b-a3b-fp8) | `ornith-1.5-35b-a3b.yaml` | | Ornith-1.5-35B-A3B w4a8: 4-bit experts (GPTQ), MTP, vision, fits one card | `ornith-1.5-35b-a3b-w4a8.rad` (20 GiB) | [download](https://huggingface.co/keptn/ornith-1.5-35b-a3b-w4a8) | `ornith-1.5-35b-a3b-w4a8.yaml` | @@ -102,6 +104,7 @@ it (`-DRAD_XE2_MKL=OFF`, or `XE2_NO_MKL=1` at run time, keeps the hand-written p | Sage-A1.5 FP8, DFlash2 drafter, vision | `sage-a1.5-fp8-df2.rad` (34 GiB) | [download](https://huggingface.co/Aijuus/sage-a1.5-fp8-df2) | `sage-a1.5-df2.yaml` | | MiniCPM5-2B FP8, DSpark drafter | `minicpm5-2b-fp8.rad` (3 GiB) | [download](https://huggingface.co/StillDeadcode/minicpm5-2b-fp8) | `minicpm5-2b.yaml` | | MiniCPM5-2B bf16, DSpark drafter | `minicpm5-2b-bf16.rad` (5 GiB) | [download](https://huggingface.co/StillDeadcode/minicpm5-2b-bf16) | `minicpm5-2b-bf16.yaml` | +| Spark X2.6 4B bf16: thinking and tool calls, one to four cards | `spark-x2.6-4b-bf16.rad` (8.3 GiB) | [convert](#convert-a-checkpoint) | — | | Gemma 4 31B: GPTQ int4 trunk, int8 activations, MTP, vision | `gemma4-31b-w4a8.rad` (20 GiB) | [download](https://huggingface.co/keptn/gemma4-31b-w4a8) | `gemma4-31b-w4a8.yaml` | | Gemma 4 31B w5: GPTQ int5 trunk (a scale and a zero point per 128 weights), MTP, vision | `gemma4-31b-w5.rad` (23 GiB) | [download](https://huggingface.co/keptn/gemma4-31b-w5) | `gemma4-31b-w5.yaml` | | Gemma 4 31B heretic-ara (refusals removed): GPTQ int4 trunk, int8 activations, MTP, vision | `gemma4-31b-heretic-ara-w4a8.rad` (20 GiB) | [download](https://huggingface.co/keptn/gemma4-31b-heretic-ara-w4a8) | `gemma4-31b-heretic-ara-w4a8.yaml` | @@ -111,9 +114,14 @@ it (`-DRAD_XE2_MKL=OFF`, or `XE2_NO_MKL=1` at run time, keeps the hand-written p | 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` | | Gemma 4 31B on four or two cards: int4 trunk, int8 activations and lm_head, a block-16 DFlash2 drafter (15 drafts a step, verified as a tree), vision | `gemma4-31b-dense-w4a8-df2b16-qkv.rad` (23 GiB) | [download](https://huggingface.co/Ashlyn4202025/gemma4-31b-w4a8-dflash2-b16) | `gemma4-31b-w4a8-df2b16-tp4.yaml`, `gemma4-31b-w4a8-df2b16-tp2.yaml` | +| Gemma 4 12B bf16: MTP, vision, audio | `gemma4-12b-bf16.rad` (25 GiB) | [download](https://huggingface.co/keptn/gemma4-12b-bf16) | `gemma4-12b-bf16.yaml` | +| Gemma 4 12B int8 (i8a8): MTP, vision, audio | `gemma4-12b-i8g.rad` (14 GiB) | [download](https://huggingface.co/keptn/gemma4-12b-i8g) | `gemma4-12b-i8g.yaml` | | NVIDIA-Nemotron-3.5-Bolt-E4B bf16 (Gemma 4 E4B), NVIDIA's DFlash drafter, vision, audio | `nemotron-3.5-bolt-e4b-bf16.rad` (17 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, audio | `nemotron-3.5-bolt-e4b-i8g.rad` (13 GiB) | [download](https://huggingface.co/keptn/nemotron-3.5-bolt-e4b-i8g) | `nemotron-3.5-bolt-e4b-i8g.yaml` | | NVIDIA-Nemotron-3.5-Bolt-E4B 4-bit (int4 feed-forward, GPTQ, Gemma 4 E4B), NVIDIA's DFlash drafter, vision, audio | `nemotron-3.5-bolt-e4b-a4.rad` (12 GiB) | [download](https://huggingface.co/keptn/nemotron-3.5-bolt-e4b-a4) | `nemotron-3.5-bolt-e4b-a4.yaml` | +| Ling-3.0-flash-Sante w4a8: 4-bit experts (GPTQ), MTP, four or two cards | `ling-3.0-flash-sante-w4a8.rad` (66 GiB) | [download](https://huggingface.co/keptn/ling-3.0-flash-sante-w4a8) | `ling-3.0-flash-sante-w4a8.yaml`, `ling-3.0-flash-sante-w4a8-tp2.yaml` | +| NVIDIA-Nemotron-3.5-Bolt-74B-A9B w4a8: 4-bit experts, FP8 trunk, NVIDIA's LiLiCorr drafter, vision, two cards | `nemotron-3.5-bolt-74b-w4a8.rad` (43 GiB) | [download](https://huggingface.co/keptn/nemotron-3.5-bolt-74b-w4a8) | `nemotron-3.5-bolt-74b-w4a8.yaml` | +| NVIDIA-Nemotron-3.5-Bolt-74B-A9B FP8, NVIDIA's LiLiCorr drafter, vision, four cards | `nemotron-3.5-bolt-74b-fp8.rad` (73 GiB) | [download](https://huggingface.co/keptn/nemotron-3.5-bolt-74b-fp8) | `nemotron-3.5-bolt-74b-fp8.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` | @@ -219,8 +227,8 @@ card works best with Resizable BAR on (Above 4G Decoding and Resizable BAR in th without it the engine keeps kernel arguments in pinned host memory, and every dispatch reads them over the link. The image is [`stilldeadcode/radiance`](https://hub.docker.com/r/stilldeadcode/radiance), with its kernels -built for `gfx1201`. Pull it, clone this repository for its compose files, then start a model from -one of them: +built for `gfx1201` (RDNA4), `gfx11-generic` (RDNA3) and `gfx1151` (Strix Halo). Pull it, clone +this repository for its compose files, then start a model from one of them: ```sh docker pull stilldeadcode/radiance @@ -349,6 +357,8 @@ budgets, long context, speculative decoding and operating a server. `data/recipes/` names. Download checkpoints with `scripts/hfget.sh `. ```sh +# Spark X2.6 uses the checkpoint's BF16 weights, tokenizer and chat template; no recipe required. +build/bin/rad-convert /srv/models/hf/XHToken-Spark-X2.6-4B -o spark-x2.6-4b-bf16.rad --max-ctx 4096 build/bin/rad-convert /srv/models/hf/Qwen/Qwen3.8-27B -o qwen3.8-27b-bf16.rad \ --recipe data/recipes/q38-27b-bf16.recipe build/bin/rad-convert /srv/models/hf/Qwen/Qwen3.8-Flash-Next -o qwen3.8-flash-next-bf16.rad --max-ctx 4096 @@ -387,6 +397,12 @@ reads it: NVFP4 (compressed-tensors' and NVIDIA ModelOpt's) to the MXFP4 kernels Flash-Next's int4 block projections to int8. [docs/GUIDE.md](docs/GUIDE.md) names the recipes of record with their `rad-convert` commands. +Spark X2.6 runs BF16 at `--tp 1`, `2`, `3` or `4` -- and `8`, the worlds libr4d has an exact +all-reduce for -- without a drafter or quantisation recipe. Its checkpoint's chat template enables +thinking by default; replies return reasoning in `reasoning_content`. Set +`chat_template_kwargs.enable_thinking` to `false` for a non-thinking request. Tool calls use the +checkpoint's tagged format and are returned as OpenAI `tool_calls`. + ## Test ```sh diff --git a/abi/rad_abi.h b/abi/rad_abi.h index 4b0e648e..a32ab9f8 100644 --- a/abi/rad_abi.h +++ b/abi/rad_abi.h @@ -21,7 +21,7 @@ extern "C" { * (e.g. rad_plugin_reference) is not a change of shape: a plugin without it gets the default. * rad_sycl.h is versioned on its own (RAD_SYCL_STREAM_VERSION), since only SYCL kernel libraries * read it. */ -#define RAD_ABI_VERSION 32u +#define RAD_ABI_VERSION 37u /* ================================================================== plugin identity */ /* One value per plugin, not flags (QUANT is 3). RAD_PLUGIN_QUANT is a quantiser plugin: @@ -62,6 +62,16 @@ typedef struct RadArgs { void* instance; /* whatever init() returned for this resolved instance */ int rank; /* tensor-parallel rank and world size, for collectives */ int world_size; + /* ABI 35: host-side maximum KV length represented by this exact launch operand (a seqused + * span or a supported one-sequence prefill boundary), or -1 when it cannot be proven. In a + * decode, verify or draft pass of an architecture with no rad_arch_pass_key it is instead the + * step's context bound plus its longest query, which the recorded pass's key holds. Plugins + * must not infer it from a device pointer or synchronously read device memory to get it. */ + int32_t kv_used_max_h; + /* The current rank's WGP count (HIP multiProcessorCount on RDNA); lets split launchers use + * exactly the same per-device occupancy as architecture pass-key callbacks without querying + * the process-global current device on the hot path. */ + int32_t wgp_count; } RadArgs; /* Read a parameter by key. Inline definitions, because a plugin links only the ABI headers and @@ -467,15 +477,20 @@ typedef struct RadKernelInfo { * against: a named skip, not a failure. */ RadUnrelayoutFn unrelayout; /* The chain of conventional ops this kernel computes in one launch, or null if it is not a - * fusion. Non-null also counts in rad-kbench's fusion-claim column. + * fusion. Non-null also counts in rad-kbench's fusion-claim column. */ + RadFuseFn replaces; + /* Flags describing runtime behavior relevant to core safety decisions. Zero means none. * * Keep this field last. Kernel tables are positional aggregate initialisers * (`{..., nullptr, nullptr, r4d_rad_embed_lookup, nullptr, ...}`), so a field inserted * anywhere else shifts every later initialiser, and since `nullptr` converts to any function * pointer type, part of that shift would still compile. Append new fields after this one. */ - RadFuseFn replaces; + uint64_t capabilities; } RadKernelInfo; +/* This row's launch grid can depend on live seqused during prefill. */ +#define RAD_KERNEL_CAP_DYNAMIC_PREFILL_SPLIT (1ull << 0) + /* ================================================================== kernel plugin exports */ /* Every kernel plugin exports the whole set. The first plugin in hierarchy order to declare an op * fixes its schema; a later plugin declaring the same op name with a different schema is refused diff --git a/abi/rad_abi_layout_rows.h b/abi/rad_abi_layout_rows.h index ea2aa138..a641e90b 100644 --- a/abi/rad_abi_layout_rows.h +++ b/abi/rad_abi_layout_rows.h @@ -26,6 +26,7 @@ ABI_FIELD(RadArchProbe, state_f16_ok) ABI_FIELD(RadArchProbe, tree_pays) ABI_FIELD(RadArchProbe, gen_max_pixels) ABI_FIELD(RadArchProbe, gen_max_refs) +ABI_FIELD(RadArchProbe, gen_shape) ABI_STRUCT(RadArgs) ABI_FIELD(RadArgs, t) ABI_FIELD(RadArgs, n_t) @@ -36,6 +37,8 @@ ABI_FIELD(RadArgs, scratch_bytes) ABI_FIELD(RadArgs, instance) ABI_FIELD(RadArgs, rank) ABI_FIELD(RadArgs, world_size) +ABI_FIELD(RadArgs, kv_used_max_h) +ABI_FIELD(RadArgs, wgp_count) ABI_STRUCT(RadBatch) ABI_FIELD(RadBatch, phase) ABI_FIELD(RadBatch, step) @@ -93,6 +96,15 @@ ABI_FIELD(RadBatch, plugin_words) ABI_FIELD(RadBatch, plugin_cu) ABI_FIELD(RadBatch, plugin_words_h) ABI_FIELD(RadBatch, plugin_cu_h) +ABI_FIELD(RadBatch, sgen_b) +ABI_FIELD(RadBatch, kv_used_max_h) +ABI_FIELD(RadBatch, positions_h) +ABI_FIELD(RadBatch, n_bidi) +ABI_FIELD(RadBatch, bidi_row) +ABI_FIELD(RadBatch, bidi_n) +ABI_FIELD(RadBatch, bidi_seq) +ABI_FIELD(RadBatch, bidi_used) +ABI_FIELD(RadBatch, anchor_rows) ABI_STRUCT(RadBufDecl) ABI_FIELD(RadBufDecl, dtype) ABI_FIELD(RadBufDecl, rank) @@ -134,6 +146,7 @@ ABI_FIELD(RadBuildCtx, calib_layer_hi) ABI_FIELD(RadBuildCtx, calib_tokens) ABI_FIELD(RadBuildCtx, gen_max_pixels) ABI_FIELD(RadBuildCtx, gen_max_refs) +ABI_FIELD(RadBuildCtx, expert_file_tier) ABI_FIELD(RadBuildCtx, plain_norm) ABI_STRUCT(RadAudioGenBatch) ABI_FIELD(RadAudioGenBatch, n_lane) @@ -312,6 +325,7 @@ ABI_FIELD(RadEncoderDecl, max_patches) ABI_FIELD(RadEncoderDecl, n_embd) ABI_FIELD(RadEncoderDecl, out) ABI_FIELD(RadEncoderDecl, one_grid) +ABI_FIELD(RadEncoderDecl, bidirectional) ABI_STRUCT(RadEncoding) ABI_FIELD(RadEncoding, scheme) ABI_FIELD(RadEncoding, transform) @@ -501,6 +515,7 @@ ABI_FIELD(RadKVGroupBatch, state_index_pitch) ABI_FIELD(RadKVGroupBatch, block_size) ABI_FIELD(RadKVGroupBatch, max_blocks) ABI_FIELD(RadKVGroupBatch, stream) +ABI_FIELD(RadKVGroupBatch, seqused_h) ABI_STRUCT(RadKVGroupDecl) ABI_FIELD(RadKVGroupDecl, kind) ABI_FIELD(RadKVGroupDecl, dtype) @@ -542,6 +557,7 @@ ABI_FIELD(RadKernelInfo, relayout) ABI_FIELD(RadKernelInfo, opd_shape) ABI_FIELD(RadKernelInfo, unrelayout) ABI_FIELD(RadKernelInfo, replaces) +ABI_FIELD(RadKernelInfo, capabilities) ABI_STRUCT(RadLayout) ABI_FIELD(RadLayout, tag) ABI_FIELD(RadLayout, dtype) @@ -700,6 +716,44 @@ ABI_FIELD(RadSampleParams, hist_len) ABI_FIELD(RadSampleParams, mask_row) ABI_FIELD(RadSampleParams, flags) ABI_FIELD(RadSampleParams, dry_rep_limit) +ABI_STRUCT(RadShapeGenBatch) +ABI_FIELD(RadShapeGenBatch, lane) +ABI_FIELD(RadShapeGenBatch, patches) +ABI_FIELD(RadShapeGenBatch, step) +ABI_FIELD(RadShapeGenBatch, n_steps) +ABI_FIELD(RadShapeGenBatch, sigma) +ABI_FIELD(RadShapeGenBatch, sigma_next) +ABI_FIELD(RadShapeGenBatch, cfg) +ABI_FIELD(RadShapeGenBatch, pair) +ABI_FIELD(RadShapeGenBatch, lanes) +ABI_FIELD(RadShapeGenBatch, flags) +ABI_FIELD(RadShapeGenBatch, seed) +ABI_FIELD(RadShapeGenBatch, lat_cu) +ABI_FIELD(RadShapeGenBatch, n_query) +ABI_FIELD(RadShapeGenBatch, query) +ABI_FIELD(RadShapeGenBatch, query_cu) +ABI_STRUCT(RadShapeGenDecl) +ABI_FIELD(RadShapeGenDecl, name) +ABI_FIELD(RadShapeGenDecl, canvas) +ABI_FIELD(RadShapeGenDecl, border_ratio) +ABI_FIELD(RadShapeGenDecl, enc_size) +ABI_FIELD(RadShapeGenDecl, enc_patch) +ABI_FIELD(RadShapeGenDecl, pix_mean) +ABI_FIELD(RadShapeGenDecl, pix_std) +ABI_FIELD(RadShapeGenDecl, latent_rows) +ABI_FIELD(RadShapeGenDecl, latent_channels) +ABI_FIELD(RadShapeGenDecl, step_rows) +ABI_FIELD(RadShapeGenDecl, default_steps) +ABI_FIELD(RadShapeGenDecl, max_steps) +ABI_FIELD(RadShapeGenDecl, default_guidance) +ABI_FIELD(RadShapeGenDecl, bounds) +ABI_FIELD(RadShapeGenDecl, level) +ABI_FIELD(RadShapeGenDecl, default_resolution) +ABI_FIELD(RadShapeGenDecl, min_resolution) +ABI_FIELD(RadShapeGenDecl, max_resolution) +ABI_FIELD(RadShapeGenDecl, max_lanes) +ABI_FIELD(RadShapeGenDecl, max_query) +ABI_FIELD(RadShapeGenDecl, field_out) ABI_STRUCT(RadSyclStream) ABI_FIELD(RadSyclStream, magic) ABI_FIELD(RadSyclStream, version) diff --git a/abi/rad_builder.h b/abi/rad_builder.h index 8df163db..5151cfac 100644 --- a/abi/rad_builder.h +++ b/abi/rad_builder.h @@ -295,6 +295,13 @@ typedef struct RadBuildCtx { * fixed buffers ignores them, and the core says so at startup. */ int64_t gen_max_pixels; int64_t gen_max_refs; + + /* ---- appended in ABI 37 (where a routed expert may live) */ + /* --weights-disk-tier: nonzero when weights may stay in the container. An expert read from the + * drive has to be stored whole, so a plugin that can lay its routed experts out either way + * keeps them whole for this; 0 leaves it free to split them across the ranks by width. */ + int expert_file_tier; + /* ---- appended in the SYCL fork (the plain block norm) */ /* Nonzero: where no reader of a block norm's output takes its E4M3 code pair (every reader a * 4-bit or plain bf16 projection, which reads the bf16 plane), the plugin may run the norm as @@ -303,8 +310,9 @@ typedef struct RadBuildCtx { * quantising norm is bound by libref's ordered sum of squares while its `rmsnorm` is a fast * row (docs/SYCL_PROGRESS.md); 0 elsewhere, so other backends declare what they did. * - * Trailing and zero-defaulted, so a plugin built against the older struct is unchanged. */ - int plain_norm; + * Trailing and zero-defaulted, so a plugin built against the older struct is unchanged. 64-bit + * so it starts past the end of ABI 37's struct, not in the padding after expert_file_tier. */ + int64_t plain_norm; } RadBuildCtx; /* ================================================================== control vectors */ @@ -896,6 +904,13 @@ typedef struct RadEncoderDecl { * position tables or kernels are per geometry; the core ends a pass where the grid changes. * 0 packs segments of any grid into a pass. */ int32_t one_grid; + + /* ---- appended in ABI 32 (runs the language model reads both ways) */ + /* 1: the language model attends the placeholders of one picture or video frame to each other + * both ways (Gemma 4's use_bidirectional_attention "vision"), text before and after them + * causally. The core then ends no prefill chunk inside such a run and states each trunk pass's + * runs (RadBatch::n_bidi). 0 for an audio encoder. */ + int32_t bidirectional; } RadEncoderDecl; int rad_declare_encoder(RadBuilder* b, const RadEncoderDecl* d); @@ -1481,6 +1496,87 @@ typedef struct RadVideoGenDecl { int rad_declare_video_generator(RadBuilder* b, const RadVideoGenDecl* d); +/* ================================================================== the shape generator */ +/* A program that makes a 3-D shape from one picture: an image encoder reads the picture, a + * denoiser steps a set of latent rows by flow matching, guided against an unconditioned branch, + * and a decoder turns the latent into an occupancy field that the core samples at points of its + * choosing and meshes. The core drives the passes (RadBatch::gen, RadShapeGenBatch), one request + * a pass: + * + * RAD_GEN_PASS_SCOND the request's picture through the image encoder into the request's + * lane: what the denoiser reads of it at every step, for both branches + * (the picture's and the unconditioned one). + * RAD_GEN_PASS_SSTEP one denoising step of one lane over both branches, `step_rows` rows: + * each branch's conditioning and latent, laid out as the plugin likes, the + * latents two entries of `latent_rows` (the conditioned first) for the + * image generator's sampler ops. The first step draws the lane's noise. + * RAD_GEN_PASS_SLATENT the lane's final latent through the decoder's network, into the lane: + * what every query pass of the request reads. Runs once, after the last + * step. + * RAD_GEN_PASS_SQUERY the field at `n_query` points (RadShapeGenBatch::query, at most + * `max_query`), one f32 a point in `field_out`, which the core reads + * back. + * + * The picture. The core decodes it with its alpha (opaque without one) and prepares it as + * Hunyuan3D-2's ImageProcessorV2 and image encoder do: the alpha's bounding box (its last row and + * column left out, as the reference's slice leaves them) scaled with OpenCV's INTER_AREA to + * (1 - border_ratio) of the longer side of the square that holds the picture, centred on it and + * flattened onto white; that square resized to `canvas` x `canvas` with INTER_CUBIC; then as 0..1 + * values bilinearly resized to `enc_size` x `enc_size` (half-pixel centres, torchvision's), each + * channel normalised by `pix_mean` and `pix_std`, and cut into (enc_size / enc_patch)^2 patches of + * enc_patch x enc_patch pixels, row-major, each patch's values channel-major then row-major (a + * convolution's weight order). An SCOND pass carries those patches. + * + * The sampler: a request's `steps` are sigma grid points, sigma_i = i / (steps - 1) for i in + * [0, steps), numpy's linspace(0, 1) taken to f32; the latent starts as noise at sigma 0 and an + * evaluation at each sigma but the last steps it to the next (the reference evaluates at the + * last too, against itself, a step of zero). The model's timestep is sigma, the guided velocity + * neg + cfg (pos - neg), and the step x + (sigma_next - sigma) v. + * + * The field: the decoder's logit at a point, inside the shape above `level`. The core samples the + * cube [-bounds, bounds]^3 on a grid of `resolution` cells a side ((resolution + 1)^3 points, + * numpy's linspace in f32 along each axis), coarse to fine as FlashVDM's hierarchical decoding + * does: the whole grid at the coarsest level (resolution halved while it stays at least 63), then + * at each finer level only the points near where the coarser one crosses `level` or is within + * 0.95 of it. The surface is marching cubes over the finest grid, a vertex at grid index g placed + * at g 2 bounds / (resolution + 1) - bounds, as the reference places it. + * + * A program declares exactly one of this, the other generators, logits or pooled vectors. */ +enum { RAD_GEN_PASS_SCOND = 15, RAD_GEN_PASS_SSTEP = 16, RAD_GEN_PASS_SLATENT = 17, + RAD_GEN_PASS_SQUERY = 18 }; + +typedef struct RadShapeGenDecl { + const char* name; /* "hunyuan3d-2" -- the served model id and messages */ + + /* The picture (above). */ + int64_t canvas; + double border_ratio; + int64_t enc_size, enc_patch; + double pix_mean[3], pix_std[3]; + + /* The latent: `latent_rows` rows of `latent_channels` a branch; a step's rows, both branches + * with their conditioning. */ + int64_t latent_rows, latent_channels, step_rows; + + /* The sampler (above) and the guidance a request that names none runs at. */ + int64_t default_steps, max_steps; + double default_guidance; + + /* The field (above): the cube's half side, the iso value, and the grid's resolution a request + * that names none is sampled at, with the range a request may name. */ + double bounds; + double level; + int64_t default_resolution, min_resolution, max_resolution; + + /* `max_lanes` requests may hold state at once. `field_out` is a device f32 buffer of at least + * `max_query` elements. */ + int64_t max_lanes; + int64_t max_query; + rad_buf field_out; +} RadShapeGenDecl; + +int rad_declare_shape_generator(RadBuilder* b, const RadShapeGenDecl* d); + /* ================================================================== diagnostics */ /* A plugin may annotate the graph dump. Free-form, printed under --debug-graph. */ void rad_note(RadBuilder* b, const char* fmt, ...); @@ -1615,6 +1711,12 @@ typedef struct RadArchProbe { * gen_patches answer for them. */ int64_t gen_max_pixels; int64_t gen_max_refs; + + /* ---- appended in ABI 33 (the shape generator) */ + /* Nonzero for a shape generator, which the engine sizes as it does a video generator from + * `gen_rows` (its largest pass: a step's two branches, or a query pass's points). It keeps no + * KV. */ + int32_t gen_shape; } RadArchProbe; int rad_arch_probe(const RadModelMeta* meta, RadArchProbe* out); @@ -1856,6 +1958,12 @@ int rad_arch_declare(RadBuilder* b, const RadModelMeta* meta, const RadB struct RadCtx; struct RadBatch; void rad_arch_step(struct RadCtx* c, const struct RadBatch* batch); +/* Optional. Return a stable fingerprint of actual dispatch geometry whose grid depends on live + * per-group seqused values. `kv_used_max_h[g]` is the host maximum for batch->kv[g], and + * rad_ctx_wgp_count(c) supplies the device's WGP count. Return 0 when exact geometry is unknown; + * that pass runs live and is not recorded. */ +uint64_t rad_arch_pass_key(struct RadCtx* c, const struct RadBatch* batch, + const int32_t* kv_used_max_h); #ifdef __cplusplus } /* extern "C" */ diff --git a/abi/rad_prefill_split.h b/abi/rad_prefill_split.h new file mode 100644 index 00000000..9d06442d --- /dev/null +++ b/abi/rad_prefill_split.h @@ -0,0 +1,55 @@ +/* rad_prefill_split.h -- host-pure live-KV prefill split law shared by libr4d launchers and + * architecture pass-key callbacks. Keep this independent of HIP so callbacks can run before tape + * lookup without a device copy or launch. + */ +#pragma once + +#include +#include + +/* `bq` query positions per workgroup, `tile` keys per KV tile. `units` counts the workgroups that + * do work: a ragged batch's grid is sized from its longest sequence, but a shorter sequence's + * tiles past its end exit at once. Each split keeps at least eight tiles of the supplied context. + */ +static inline int rad_prefill_splits_law(int bq, int tile, int q_len, int total_q, int num_seqs, + int kv_heads, int max_ctx, int wgps) { + const long n = std::max(1, num_seqs); + const long qt = std::min(n * ((std::max(1, q_len) + bq - 1) / bq), + (std::max(1, total_q) + (long)(bq - 1) * n) / bq); + const long units = (long)std::max(1, kv_heads) * std::max(1L, qt); + if (units >= wgps) return 1; + const int s1 = (int)(wgps / units), s2 = (int)(2L * wgps / units); + int sp = s2 > 2 * s1 ? s2 : s1; + const int cap = ((max_ctx > 0 ? max_ctx : (1 << 30) - 1) + tile - 1) / tile / 8; + sp = std::min(sp, std::max(1, cap)); + return std::max(1, std::min(sp, 64)); +} + +/* The launcher's live-context refinement of the initial model-bound law. */ +static inline int rad_prefill_splits_for_live(int bq, int tile, int q_len, int total_q, + int num_seqs, int kv_heads, int max_ctx, + int used_ctx, int wgps) { + int splits = rad_prefill_splits_law(bq, tile, q_len, total_q, num_seqs, kv_heads, max_ctx, + wgps); + if (splits > 1 && used_ctx > 0 && (max_ctx <= 0 || used_ctx < max_ctx)) + splits = rad_prefill_splits_law(bq, tile, q_len, total_q, num_seqs, kv_heads, used_ctx, + wgps); + return splits; +} + +/* Fingerprint one actual launch tuple in packet-global sizes. Use this instead of the raw context + * so equal split grids share a recording key as live context advances. */ +static inline uint64_t rad_prefill_grid_key(int q_len, int bq, int splits, int kv_heads, + int num_seqs, int threads) { + const uint64_t gx = (uint64_t)((std::max(1, q_len) + bq - 1) / bq) * + (uint64_t)std::max(1, splits) * (uint64_t)threads; + const uint64_t gy = (uint64_t)std::max(1, kv_heads); + const uint64_t gz = (uint64_t)std::max(1, num_seqs); + uint64_t h = 0x9e3779b97f4a7c15ull; + const uint64_t grid[3] = {gx, gy, gz}; + for (uint64_t v : grid) { + h ^= v + 0x9e3779b97f4a7c15ull + (h << 6) + (h >> 2); + h *= 0xbf58476d1ce4e5b9ull; + } + return h | 1; +} diff --git a/abi/rad_runtime.h b/abi/rad_runtime.h index 034c3642..c6f5d7b1 100644 --- a/abi/rad_runtime.h +++ b/abi/rad_runtime.h @@ -68,8 +68,10 @@ typedef struct RadKVGroupBatch { int64_t state_index_pitch; int64_t block_size; int64_t max_blocks; - /* Null unless this group streams (RadKVStream). Trailing and zero-defaulted. */ + /* Null unless this group streams (RadKVStream). */ const RadKVStream* stream; + /* ABI 35: host mirror of seqused, retained through this batch for exact sliced-launch bounds. */ + const int32_t* seqused_h; } RadKVGroupBatch; typedef struct RadBatch { @@ -325,6 +327,42 @@ typedef struct RadBatch { const int32_t* plugin_cu; /* [n_seq + 1] device */ const int32_t* plugin_words_h; const int32_t* plugin_cu_h; + + /* ---- appended in ABI 33 (the shape generator) */ + /* A shape generator's pass (rad_declare_shape_generator; `gen` is one of its + * RAD_GEN_PASS_S*): its payload. Null on every other step. */ + const struct RadShapeGenBatch* sgen_b; + + /* ---- appended in ABI 34: host-side max seqused per entry of kv[], for an architecture's + * optional recorded-pass geometry key. Null when the batch has no host summary. */ + const int32_t* kv_used_max_h; + /* ABI 35: host mirror of positions, for a one-sequence prefill op whose exact KV bound is the + * position immediately after its first query piece. Valid through the batch's issue pass. */ + const int32_t* positions_h; + /* ---- appended in ABI 35 (runs read both ways) */ + /* The runs of a trunk pass whose rows attend to each other both ways + * (RadEncoderDecl::bidirectional): a picture's or a video frame's placeholders inside one + * sequence's chunk. The pass attends them causally like every other row; the plugin attends a + * run's rows again without the causal bound, over the keys before `bidi_used` (the position + * after the run's last token), in place of that result. The scheduler ends no chunk inside such + * a run, so its keys are this pass's or, after a prefix hit, the cache's; a run longer than any + * step is cut where its chunk ends, and that chunk's rows see the run up to the cut. + * + * host: n_bidi and, per run, its first row in this pass, its rows and the index of its sequence + * in the per-sequence arrays; device: [n_bidi] the keys a run's rows see. 0 runs on every other + * pass. */ + int64_t n_bidi; + const int32_t* bidi_row; /* host */ + const int32_t* bidi_n; /* host */ + const int32_t* bidi_seq; /* host */ + const int32_t* bidi_used; /* device */ + /* ---- appended in ABI 36 (a block drafter's anchor row) */ + /* A block drafter's query pass (draft_pass 1): [n_seq] device, for each drafting sequence the + * row of its last committed position in the context pass just run, whose rows are the verify + * step's in order. -1 for a row the card did not position. A drafter that conditions on the + * context state at the anchor (LiLiCorr) gathers it there; the query rows themselves sit past + * that position. Null on every other pass. */ + const int32_t* anchor_rows; } RadBatch; /* What a generator pass carries beside the step batch's own fields, which keep their meanings: @@ -712,6 +750,44 @@ typedef struct RadVideoGenBatch { enum { RAD_SAMPLER_EULER = 0, RAD_SAMPLER_RES_MULTISTEP = 1 }; +/* What a shape generator's pass carries beside the step batch's own fields (rad_builder.h, + * RadShapeGenDecl, describes the passes). Every pass is one request's, in lane `lane`: + * + * SCOND `n_tok` is the picture's patches, `patches` [n_tok, 3 enc_patch^2] f32. + * SSTEP `n_tok` is step_rows. The two branches' latents are entries 0 (the picture's) and 1 + * (the unconditioned one) of the image generator's sampler ops (`randn_lanes`, + * `lane_gather`, `flow_euler`): `lat_cu` bounds them and the per-entry arrays are + * theirs, entry 0 guided against entry 1 (`pair` {1, -2}) at the request's scale. + * SLATENT `n_tok` is latent_rows; nothing of the pass's own. + * SQUERY `n_tok` is n_query, `query` [n_query, 3] f32: x, y, z a point, and `query_cu` + * {0, n_query}. + * + * `lanes` and `lat_cu` are staged on every pass; the latent's rows are lat_cu[0..1]. Every + * pointer is device memory. */ +typedef struct RadShapeGenBatch { + int32_t lane; + + /* ---- SCOND */ + const float* patches; + + /* ---- SSTEP: the step (from 0) of the request's `n_steps` evaluations, then the two + * entries' sampler operands, [2] each but `seed` [2, 2] (low word first) and `lat_cu` [3]. */ + int32_t step, n_steps; + const float* sigma; + const float* sigma_next; + const float* cfg; + const int32_t* pair; + const int32_t* lanes; + const int32_t* flags; /* RAD_GEN_F_FIRST on entry 0 of the first step */ + const uint32_t* seed; + const int32_t* lat_cu; + + /* ---- SQUERY */ + int64_t n_query; + const float* query; + const int32_t* query_cu; +} RadShapeGenBatch; + /* RadVideoGenBatch::enc_kind: the media an encode pass carries, numbered from 1 within a kind. A * keyframe is 1 for the first frame and 2 for the last. */ enum { @@ -861,6 +937,9 @@ int rad_kv_stage_layer(RadCtx* c, rad_kvgroup group, const RadKVGrou int rad_kv_stage_next(RadCtx* c, rad_kvgroup group, int layer); int rad_rank(RadCtx* c); int rad_world_size(RadCtx* c); +/* Workgroups the current rank's card can run concurrently (HIP multiProcessorCount on RDNA; + * 32 on the host backend or when the backend has no positive count). */ +int rad_ctx_wgp_count(RadCtx* c); RadStream rad_stream(RadCtx* c); /* The routing result for a MoE layer, resolved on device against the current residency table. diff --git a/arch/bailing_hybrid/CMakeLists.txt b/arch/bailing_hybrid/CMakeLists.txt new file mode 100644 index 00000000..fbb15677 --- /dev/null +++ b/arch/bailing_hybrid/CMakeLists.txt @@ -0,0 +1,10 @@ +# Built in radiance's tree, or standalone against an installed radiance +# (`cmake -S arch/bailing_hybrid -B build -DCMAKE_PREFIX_PATH=`); see cmake/RadAddPlugin.cmake. +if(NOT COMMAND rad_add_plugin) + cmake_minimum_required(VERSION 3.21) + project(bailing_hybrid LANGUAGES CXX) + find_package(radiance REQUIRED) + rad_plugin_defaults() +endif() + +rad_add_plugin(bailing_hybrid architectures SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/bailing_hybrid.cpp) diff --git a/arch/bailing_hybrid/bailing_hybrid.cpp b/arch/bailing_hybrid/bailing_hybrid.cpp new file mode 100644 index 00000000..4c26523c --- /dev/null +++ b/arch/bailing_hybrid/bailing_hybrid.cpp @@ -0,0 +1,885 @@ +/* bailing_hybrid -- Ling-3.0-flash and its fine-tunes (`model_type: bailing_hybrid`, + * BailingMoeV3ForCausalLM), from the bf16 checkpoint, the routed experts as a recipe stores them + * (data/recipes/ling3-w4a8-rtn.recipe, ling3-w4a8-gptq.recipe). + * + * ============================== WHAT IT SERVES ============================== + * + * layers 42 in groups of six: five Kimi delta attention (KDA) layers, then one dense + * latent attention (MLA) layer, so layers 5, 11, ..., 41 are MLA + * KDA 32 heads of 128, separate q/k/v projections each with its own causal + * convolution, a full-rank per-channel forget gate (`f_proj`) and output gate + * (`g_proj`), lower bound -5 + * MLA no query LoRA, a 512-wide latent and a 64-wide rotary part (interleaved pairs), + * heads of 128 + 64, values of 128, a sigmoid gate per head + * feed-forward layers 0-1 dense (6144); from layer 2, 512 experts of 768 at top-8 under + * group-limited sigmoid routing (8 groups, 4 kept, a correction bias, x2.5), an + * ungated shared expert, and a SwiGLU clipped after the SiLU in the last layers + * (`expert_swiglu_limit_list`, `share_expert_swiglu_limit_list`, as vLLM and + * SGLang serve it; HF's reference ignores it) + * + * The KDA core is GLM-5.3's (KdaState), the router GLM-5.3's with groups (GlmRouter), the + * feed-forward MoeFP8. The KDA and MLA blocks around them are in this file. + * + * ============================== THE LATENT ATTENTION ============================== + * + * The MLA attends in the latent. The query projection is served as two, its heads' rotary rows and + * their nope rows (row maps over q_proj), so each is a plain [T, heads * width] plane: `rope` turns + * the first, and the second is absorbed into the latent through kv_b's key rows (mla_project). + * `mla_attn_paged` scores against a cache row of [normed latent 512 | rotated key 64] and returns + * the latent, gated per head; kv_b's value rows expand it. The cache row is stored as one KV head + * of 288, the latent's first 288 values in the K slot and the rest in the V slot. + * + * ============================== THE DRAFTER ============================== + * + * The MTP layer (checkpoint layer 42: an MLA layer with the full routed feed-forward) is a serial + * drafter around GlmMtp, declared when the deployment speculates. + * + * docs/ARCHITECTURES.md describes the model and its traps. */ +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace bailing_hybrid { + +using namespace rad::arch; + +/* The released geometry this graph is written for; a checkpoint that differs is refused by name. */ +struct Shape { + int64_t n_embd = 0, n_layer = 0, heads = 0, head_dim = 0, nope = 0, rope = 0, v_dim = 0, + latent = 0, experts = 0, top_k = 0, groups = 0, topk_groups = 0, ff_exp = 0, + ff_shared = 0, ff_dense = 0, dense_layers = 0, group_size = 0, conv = 0; + double lower = -5, route_scale = 1; + std::vector lim_exp, lim_shared; +}; + +/* A KDA layer: the q/k/v, beta, forget and output-gate projections into KdaState, then o_proj and + * its all-reduce. */ +struct LingKda { + struct Wire { + ActFP8 input{}; + rad_buf out = 0; + ActFP8 core_out{}; + KdaState::Wire core{}; + }; + Geom g{}; + Wire w{}; + KdaState core{}; + LinearFP8 qkv{}, beta{}, forget{}, gate{}, output{}; + QuantFP8 out_quant{}; + rad_op op_ar = 0; + + int declare(RadBuilder* b, Names& nm, const Geom& geom, const Shape& sh, int l, + const Wire& wire, const char* pre, rad_kvgroup state, rad_kvgroup history) { + g = geom; + w = wire; + const int64_t heads = sh.heads / g.world, width = heads * sh.head_dim; + const auto grp = grp_layer(l); + RAD_ARCH_TRY(qkv.declare(b, nm, g, nm.f("blk.%d.attn_qkv", l), 3 * width, g.n_embd, + RAD_SHARD_ROW, grp, + { nm.ckpt("%s.q_proj.weight", pre), nm.ckpt("%s.k_proj.weight", pre), + nm.ckpt("%s.v_proj.weight", pre) }, + w.input, w.core.qkv, 0, { width, width, width })); + RAD_ARCH_TRY(beta.declare(b, nm, g, nm.f("blk.%d.attn_beta", l), heads, g.n_embd, + RAD_SHARD_ROW, grp, { nm.ckpt("%s.b_proj.weight", pre) }, + w.input, w.core.beta)); + RAD_ARCH_TRY(forget.declare(b, nm, g, nm.f("blk.%d.attn_forget", l), width, g.n_embd, + RAD_SHARD_ROW, grp, { nm.ckpt("%s.f_proj.weight", pre) }, + w.input, w.core.a)); + RAD_ARCH_TRY(gate.declare(b, nm, g, nm.f("blk.%d.attn_gate", l), width, g.n_embd, + RAD_SHARD_ROW, grp, { nm.ckpt("%s.g_proj.weight", pre) }, + w.input, w.core.gate)); + KdaState::Config kc; + kc.heads = heads; + kc.dim = sh.head_dim; + kc.width = sh.conv; + kc.lower = sh.lower; + KdaState::Src ks{ nm.ckpt("%s.q_conv1d.weight", pre), nm.ckpt("%s.k_conv1d.weight", pre), + nm.ckpt("%s.v_conv1d.weight", pre), nm.ckpt("%s.A_log", pre), + nm.ckpt("%s.dt_bias", pre), nm.ckpt("%s.o_norm.weight", pre) }; + RAD_ARCH_TRY(core.declare(b, nm, g, l, state, history, kc, w.core, ks)); + const char* on = nm.f("blk.%d.attn_output", l); + RAD_ARCH_TRY(output.probe(b, nm, g, on, { nm.ckpt("%s.o_proj.weight", pre) })); + if (!output.reads_x) RAD_ARCH_TRY(out_quant.declare(b, g, w.core_out, width)); + RAD_ARCH_TRY(output.declare(b, nm, g, on, g.n_embd, width, RAD_SHARD_COL, grp, + { nm.ckpt("%s.o_proj.weight", pre) }, w.core_out, w.out)); + op_ar = GlmTp::reduce(b, g, w.out); + return g.world > 1 && !op_ar ? RAD_E_INVAL : RAD_OK; + } + void step(RadCtx* c, const RadBatch* batch) const { + const int64_t T = batch->n_tok; + qkv.step(c, w.input, w.core.qkv, T); + beta.step(c, w.input, w.core.beta, T); + forget.step(c, w.input, w.core.a, T); + gate.step(c, w.input, w.core.gate, T); + core.step(c, batch); + out_quant.step(c, T); + output.step(c, w.core_out, w.out, T); + if (op_ar) RAD_ISSUE_N(c, op_ar, T * g.n_embd, brows(w.out, T), RAD_NONE); + } +}; + +/* A dense MLA layer, attending in the latent (the file's head comment). The latent cache is + * replicated: every rank projects and stores the whole row, and splits the heads. */ +struct LingMla { + struct Wire { + ActFP8 input{}; + rad_buf q_rope = 0; /* [T, heads * rope] */ + rad_buf q_nope = 0; /* [T, heads * nope] */ + rad_buf row = 0; /* [T, latent + rope], the cache row */ + rad_buf q_lat = 0; /* [T, heads, latent] */ + rad_buf gate = 0; /* [T, heads] */ + rad_buf attn = 0; /* [T, heads, latent] */ + ActFP8 value{}; /* [T, heads * v] */ + rad_buf out = 0; + }; + Geom g{}; + Shape s{}; + Wire w{}; + int layer = 0; + int64_t heads = 0, qw = 0, cw = 0; + rad_kvgroup kv = 0; + LinearFP8 q_rope_proj{}, q_nope_proj{}, kv_a{}, g_proj{}, output{}; + QuantFP8 value_quant{}; + rad_weight kv_gain = 0, kv_b = 0; + rad_op op_kv_norm = 0, op_q_rope = 0, op_k_rope = 0, op_store = 0, op_absorb = 0, op_attn = 0, + op_expand = 0, op_ar = 0; + int64_t block = 0; + + static constexpr int64_t kBlock = 16; + + int declare(RadBuilder* b, Names& nm, const Geom& geom, const Shape& shape, int l, + const Wire& wire, const char* pre, rad_kvgroup group) { + g = geom; + s = shape; + w = wire; + layer = l; + kv = group; + heads = s.heads / g.world; + qw = s.rope + s.nope; + cw = s.latent + s.rope; + const auto grp = grp_layer(l); + RAD_ARCH_TRY(rad_bind_layer_kv(b, l, kv)); + /* One row map a part, a piece a head: [h * (nope + rope) + off, + width). Successive ROWS + * maps for one name extend it in call order (rad_builder.h), eight pieces a map. */ + const char* qsrc = nm.ckpt("%s.q_proj.weight", pre); + auto part = [&](const char* name, int64_t off, int64_t width) -> int { + for (int64_t h0 = 0; h0 < s.heads; h0 += 8) { + RadNameMap m = map_base(name, RAD_MAP_ROWS); + for (int64_t h = h0; h < std::min(h0 + 8, s.heads); ++h) { + m.src[m.n_src] = qsrc; + m.src_index[m.n_src] = (int)(h * qw + off); + m.src_rows[m.n_src] = width; + ++m.n_src; + } + RAD_ARCH_TRY(rad_decl_name_map(b, &m)); + } + return RAD_OK; + }; + RAD_ARCH_TRY(part(nm.f("blk.%d.attn_q_rope.weight", l), s.nope, s.rope)); + RAD_ARCH_TRY(part(nm.f("blk.%d.attn_q_nope.weight", l), 0, s.nope)); + q_rope_proj.mapped = q_nope_proj.mapped = true; + RAD_ARCH_TRY(q_rope_proj.declare(b, nm, g, nm.f("blk.%d.attn_q_rope", l), heads * s.rope, + g.n_embd, RAD_SHARD_ROW, grp, { qsrc }, w.input, w.q_rope)); + RAD_ARCH_TRY(q_nope_proj.declare(b, nm, g, nm.f("blk.%d.attn_q_nope", l), heads * s.nope, + g.n_embd, RAD_SHARD_ROW, grp, { qsrc }, w.input, w.q_nope)); + RAD_ARCH_TRY(kv_a.declare(b, nm, g, nm.f("blk.%d.attn_kv_a", l), cw, g.n_embd, + RAD_SHARD_NONE, grp, { nm.ckpt("%s.kv_a_proj_with_mqa.weight", pre) }, + w.input, w.row)); + const char* kn = nm.f("blk.%d.attn_kv_a_norm.weight", l); + RAD_ARCH_TRY(map_copy(b, kn, nm.ckpt("%s.kv_a_layernorm.weight", pre))); + kv_gain = decl_w(b, kn, RAD_F32, { s.latent }, RAD_ACCESS_PER_TOKEN, RAD_SHARD_NONE, grp); + if (!kv_gain) return RAD_E_INVAL; + op_kv_norm = rw(b, + RAD_OP(b, "rmsnorm", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", s.latent), + RAD_F64("eps", g.eps), RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(kv_gain)), + { w.row }, { w.row }); + op_q_rope = rw(b, decl_rope(b, g, g.max_tok, s.rope, heads, 0, s.rope, "gptj"), { w.q_rope }, + { w.q_rope }); + op_k_rope = rw(b, decl_rope(b, g, g.max_tok, s.rope, 1, 0, s.rope, "gptj"), { w.row }, + { w.row }); + /* The first op after the group to carry a block size claims it (rad_builder.cpp, + * find_kv_consumer). */ + op_store = rw(b, + RAD_OP(b, "kv_store", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("head_dim", cw / 2), + RAD_INT("n_head_kv", 1), RAD_INT("block_size", kBlock), + RAD_STR("kv_dtype", "bf16")), + RAD_NOWEIGHTS), + { w.row }, {}); + const char* bn = nm.f("blk.%d.attn_kv_b.weight", l); + RAD_ARCH_TRY(map_copy(b, bn, nm.ckpt("%s.kv_b_proj.weight", pre))); + kv_b = decl_w(b, bn, RAD_BF16, { heads * (s.nope + s.v_dim), s.latent }, RAD_ACCESS_PER_TOKEN, + RAD_SHARD_ROW, grp); + if (!op_kv_norm || !op_q_rope || !op_k_rope || !op_store || !kv_b) return RAD_E_INVAL; + op_absorb = rw(b, + RAD_OP(b, "mla_project", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("heads", heads), + RAD_INT("head_dim", s.nope), RAD_INT("latent_dim", s.latent), + RAD_STR("mode", "absorb"), RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(kv_b)), + { w.q_nope }, { w.q_lat }); + RAD_ARCH_TRY(g_proj.declare(b, nm, g, nm.f("blk.%d.attn_head_gate", l), heads, g.n_embd, + RAD_SHARD_ROW, grp, { nm.ckpt("%s.g_proj.weight", pre) }, + w.input, w.gate)); + op_attn = rw(b, + RAD_OP(b, "mla_attn_paged", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("heads", heads), + RAD_INT("latent_dim", s.latent), RAD_INT("rope_dim", s.rope), + RAD_INT("block_size", kBlock), + RAD_F64("scale", 1.0 / std::sqrt((double)qw)), + RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + { w.q_lat, w.q_rope, w.gate }, { w.attn }); + op_expand = rw(b, + RAD_OP(b, "mla_project", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("heads", heads), + RAD_INT("head_dim", s.v_dim), RAD_INT("latent_dim", s.latent), + RAD_STR("mode", "expand"), RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(kv_b)), + { w.attn }, { w.value.x }); + if (!op_absorb || !op_attn || !op_expand) return RAD_E_INVAL; + block = rad_kv_block_size(b, kv); + if (block != kBlock) { + fprintf(stderr, "radiance: bailing_hybrid: the latent cache's block is %lld tokens and " + "its ops are declared at %lld\n", (long long)block, (long long)kBlock); + return RAD_E_INVAL; + } + const char* on = nm.f("blk.%d.attn_output", l); + RAD_ARCH_TRY(output.probe(b, nm, g, on, { nm.ckpt("%s.dense.weight", pre) })); + if (!output.reads_x) RAD_ARCH_TRY(value_quant.declare(b, g, w.value, heads * s.v_dim)); + RAD_ARCH_TRY(output.declare(b, nm, g, on, g.n_embd, heads * s.v_dim, RAD_SHARD_COL, grp, + { nm.ckpt("%s.dense.weight", pre) }, w.value, w.out)); + op_ar = GlmTp::reduce(b, g, w.out); + return g.world > 1 && !op_ar ? RAD_E_INVAL : RAD_OK; + } + void step(RadCtx* c, const RadBatch* batch) const { + const auto* kb = kv_batch(batch, kv); + if (!kb || !kb->slot_mapping || !kb->block_table || !kb->seqused) { + rad_step_fail(c, "bailing_hybrid MLA requires the latent cache's slot mapping, block " + "table and sequence lengths"); + return; + } + const int64_t T = batch->n_tok, S = batch->n_seq; + const RadOperand pos = praw(batch->positions, RAD_I32, T); + q_rope_proj.step(c, w.input, w.q_rope, T); + q_nope_proj.step(c, w.input, w.q_nope, T); + kv_a.step(c, w.input, w.row, T); + g_proj.step(c, w.input, w.gate, T); + RAD_ISSUE_N(c, op_kv_norm, T, bcol(w.row, 0, s.latent, T), RAD_W(kv_gain), + bcol(w.row, 0, s.latent, T)); + RAD_ISSUE_N(c, op_q_rope, T, brows(w.q_rope, T), pos); + RAD_ISSUE_N(c, op_k_rope, T, bcol(w.row, s.latent, s.rope, T), pos); + RAD_ISSUE_N(c, op_store, T, bcol(w.row, 0, cw / 2, T), bcol(w.row, cw / 2, cw / 2, T), + praw(kb->slot_mapping, RAD_I32, T), kv_cache(kv, layer)); + RAD_ISSUE_N(c, op_absorb, T, brows(w.q_nope, T), RAD_W(kv_b), brows(w.q_lat, T)); + RAD_ISSUE_N(c, op_attn, T, brows(w.q_lat, T), brows(w.q_rope, T), kv_cache(kv, layer), + praw2(kb->block_table, RAD_I32, S, kb->block_table_pitch), + praw(kb->seqused, RAD_I32, S), praw(batch->cu_seqlens, RAD_I32, S + 1), + brows(w.gate, T), brows(w.attn, T)); + RAD_ISSUE_N(c, op_expand, T, brows(w.attn, T), RAD_W(kv_b), brows(w.value.x, T)); + value_quant.step(c, T); + output.step(c, w.value, w.out, T); + if (op_ar) RAD_ISSUE_N(c, op_ar, T * g.n_embd, brows(w.out, T), RAD_NONE); + } +}; + +struct Layer { + bool mla = false, dense = false; + rad_weight gain = 0; + NormQuantFP8 norm{}; + LingKda kda{}; + LingMla attn{}; + rad_op op_add = 0; + MlpFP8 mlp{}; + MoeFP8 moe{}; +}; + +struct Model { + Names nm{}; + Geom g{}; + Shape s{}; + std::vector layers; + rad_kvgroup latent = 0, state = 0, conv = 0; + rad_buf x = 0, y = 0, final_hidden = 0, logit_input = 0, logits = 0; + ActFP8 act{}; + LingKda::Wire kw{}; + LingMla::Wire aw{}; + MlpFP8::Wire dw{}; + MoeFP8::Wire mw{}; + rad_weight token = 0, head = 0, final_gain = 0; + rad_op embed = 0, embed_ar = 0, norm = 0, gather = 0, head_op = 0; + /* The draft head and its layer, declared only when the deployment speculates. */ + bool have_mtp = false; + GlmMtp mtp{}; + Layer draft{}; +}; + +static Model g_model[MAX_RANKS]; + +static int64_t cfg(const RadModelMeta* m, const char* key, int64_t fallback) { + return rad_meta_geti(m, key, fallback); +} + +static std::vector cfg_list(const RadModelMeta* m, const char* key) { + std::vector v; + for_each_token(rad_meta_gets(m, key, ""), [&](const char* t, size_t) { + v.push_back(std::strtod(t, nullptr)); + return true; + }); + return v; +} + +/* Layer l's SwiGLU clamp from a per-layer list; 0 (none) past its end or where it says 0. */ +static double limit_at(const std::vector& v, int64_t l) { + return l < (int64_t)v.size() && v[(size_t)l] > 0 ? v[(size_t)l] : 0; +} + +/* The last layer of each group of `layer_group_size` is MLA, and so is every layer of an + * incomplete last group. */ +static bool is_mla(const Shape& s, int64_t l) { + return (l + 1) % s.group_size == 0 || l >= s.n_layer / s.group_size * s.group_size; +} + +static int read_shape(const RadModelMeta* meta, Shape& s) { + s.n_embd = meta->n_embd; + s.n_layer = meta->n_layers; + s.heads = cfg(meta, "num_attention_heads", 0); + s.head_dim = cfg(meta, "head_dim", 0); + s.nope = cfg(meta, "qk_nope_head_dim", 0); + s.rope = cfg(meta, "qk_rope_head_dim", 0); + s.v_dim = cfg(meta, "v_head_dim", 0); + s.latent = cfg(meta, "kv_lora_rank", 0); + s.experts = cfg(meta, "num_experts", 0); + s.top_k = cfg(meta, "num_experts_per_tok", 0); + s.groups = cfg(meta, "n_group", 1); + s.topk_groups = cfg(meta, "topk_group", s.groups); + s.ff_exp = cfg(meta, "moe_intermediate_size", 0); + s.ff_shared = cfg(meta, "moe_shared_expert_intermediate_size", 0) * + cfg(meta, "num_shared_experts", 0); + s.ff_dense = cfg(meta, "intermediate_size", 0); + s.dense_layers = cfg(meta, "first_k_dense_replace", 0); + s.group_size = cfg(meta, "layer_group_size", 0); + s.conv = cfg(meta, "short_conv_kernel_size", 0); + s.lower = rad_meta_getf(meta, "kda_lower_bound", 0.0); + s.route_scale = rad_meta_getf(meta, "routed_scaling_factor", 0.0); + s.lim_exp = cfg_list(meta, "expert_swiglu_limit_list"); + s.lim_shared = cfg_list(meta, "share_expert_swiglu_limit_list"); + const struct { + const char* what; + bool ok; + } need[] = { + { "head_dim 128 (KDA)", s.head_dim == 128 }, + { "qk_nope_head_dim == v_head_dim (mla_project's head)", s.nope > 0 && s.nope == s.v_dim }, + { "an even qk_rope_head_dim", s.rope > 0 && !(s.rope & 1) }, + { "an even kv_lora_rank + qk_rope_head_dim", s.latent > 0 && !((s.latent + s.rope) & 1) }, + { "q_lora_rank null", cfg(meta, "q_lora_rank", 0) == 0 }, + { "no_kda_lora", cfg(meta, "no_kda_lora", 0) != 0 }, + { "kda_safe_gate", cfg(meta, "kda_safe_gate", 1) != 0 }, + { "a negative kda_lower_bound", s.lower < 0 && std::isfinite(s.lower) }, + { "rope_interleave", cfg(meta, "rope_interleave", 0) != 0 }, + { "head-wise gated attention", + !std::strcmp(rad_meta_gets(meta, "gated_attention_proj_granularity_type", ""), + "head_wise") }, + { "sigmoid scoring", !std::strcmp(rad_meta_gets(meta, "score_function", + rad_meta_gets(meta, "scoring_func", "")), + "sigmoid") }, + { "one shared expert", cfg(meta, "num_shared_experts", 0) == 1 }, + { "a layer group", s.group_size > 1 }, + { "a 4-tap short convolution", s.conv == 4 }, + { "experts, top-k and groups", s.experts > 0 && s.top_k > 0 && s.groups >= 1 && + s.experts % s.groups == 0 && s.topk_groups >= 1 && + s.topk_groups <= s.groups }, + { "a positive routed_scaling_factor", s.route_scale > 0 }, + { "no rope scaling", !rad_meta_gets(meta, "rope_scaling.type", nullptr) && + !rad_meta_gets(meta, "rope_scaling.rope_type", nullptr) }, + }; + for (const auto& n : need) + if (!n.ok) { + fprintf(stderr, "radiance: bailing_hybrid: this plugin serves %s, and the checkpoint " + "differs\n", n.what); + return RAD_E_UNSUPPORTED; + } + return RAD_OK; +} + +/* A rank's slice of a width of `blocks` 128-column blocks: blocks [lo, hi) in the order of the + * ranks starting at `first`, the first `blocks % world` ranks of that order one block wider. */ +static void slice_of(int64_t blocks, int world, int rank, int first, int64_t* lo, int64_t* hi) { + const int p = ((rank - first) % world + world) % world; + const int64_t base = blocks / world, extra = blocks % world; + *lo = p * base + std::min(p, extra); + *hi = *lo + base + (p < extra ? 1 : 0); +} + +/* ============================== The trunk's buffers ============================== */ + +static int buffers(RadBuilder* b, Model& m) { + auto& g = m.g; + auto& s = m.s; + auto& nm = m.nm; + const int64_t T = g.max_tok, E = g.n_embd, H = s.heads / g.world, W = H * s.head_dim; + auto bf = [&](const char* n, std::initializer_list shape) { + return decl_b(b, nm.f("%s", n), RAD_BF16, shape); + }; + m.x = bf("residual", { T, E }); + m.y = bf("attn_delta", { T, E }); + m.act.x = bf("normed", { T, E }); + RAD_ARCH_TRY(m.act.declare_qs(b, nm, g, "normed", E)); + m.final_hidden = decl_b(b, nm.f("final_hidden"), RAD_BF16, { T, E }, RAD_BUF_PERSIST); + m.logit_input = bf("logit_input", { g.max_logit_rows, E }); + m.logits = decl_b(b, nm.f("logits"), RAD_F32, { g.max_logit_rows, g.n_vocab }); + RAD_ARCH_TRY(rad_declare_logits(b, m.logits)); + + auto& kw = m.kw; + kw.input = m.act; + kw.out = m.y; + kw.core.qkv = bf("kda_qkv", { T, 3 * W }); + kw.core.conv = bf("kda_convolved", { T, 3 * W }); + kw.core.a = bf("kda_forget", { T, W }); + kw.core.beta = bf("kda_beta", { T, H }); + kw.core.gate = bf("kda_gate", { T, W }); + kw.core.out = bf("kda_out", { T, W }); + kw.core_out.x = kw.core.out; + RAD_ARCH_TRY(kw.core_out.declare_qs(b, nm, g, "kda_out", W)); + + auto& aw = m.aw; + aw.input = m.act; + aw.out = m.y; + aw.q_rope = bf("mla_q_rope", { T, H * s.rope }); + aw.q_nope = bf("mla_q_nope", { T, H * s.nope }); + aw.row = bf("mla_row", { T, s.latent + s.rope }); + aw.q_lat = bf("mla_q_latent", { T, H * s.latent }); + aw.gate = bf("mla_gate", { T, H }); + aw.attn = bf("mla_attn_latent", { T, H * s.latent }); + aw.value.x = bf("mla_value", { T, H * s.v_dim }); + RAD_ARCH_TRY(aw.value.declare_qs(b, nm, g, "mla_value", H * s.v_dim)); + + auto& dw = m.dw; + dw.x = m.x; + dw.h = m.act; + dw.gate_up = bf("dense_gate_up", { T, 2 * g.n_ff }); + dw.ffn.x = bf("dense_ff", { T, g.n_ff }); + RAD_ARCH_TRY(dw.ffn.declare_qs(b, nm, g, "dense_ff", g.n_ff)); + return RAD_OK; +} + +static int moe_buffers(RadBuilder* b, Model& m, const MoeFP8::Config& mc) { + auto& g = m.g; + auto& nm = m.nm; + const int64_t T = g.max_tok, E = g.n_embd, F = mc.n_ff_exp, k = mc.top_k; + auto bf = [&](const char* n, std::initializer_list shape) { + return decl_b(b, nm.f("%s", n), RAD_BF16, shape); + }; + auto& mw = m.mw; + mw.x = m.x; + mw.h = m.act; + mw.logits = decl_b(b, nm.f("router_logits"), RAD_F32, { T, mc.n_expert_all }); + mw.ids = decl_b(b, nm.f("expert_ids"), RAD_I32, { T, k }); + mw.ew = decl_b(b, nm.f("expert_weights"), RAD_F32, { T, k }); + mw.eoff = decl_b(b, nm.f("expert_offsets"), RAD_I32, { mc.n_expert + 1 }); + mw.ecnt = decl_b(b, nm.f("expert_counts"), RAD_I32, { mc.n_expert }); + mw.sorted = decl_b(b, nm.f("expert_sorted"), RAD_I32, { T * k }); + mw.egu = bf("expert_gate_up", { T * k, 2 * F }); + mw.eff.x = bf("expert_ff", { T * k, F }); + RAD_ARCH_TRY(mw.eff.declare_qs(b, nm, g, "expert_ff", F, T * k)); + mw.edn = bf("expert_down", { T * k, E }); + if (mc.expert_rot) { + mw.hr.q = decl_b(b, nm.f("normed_rot.q"), RAD_F8E4M3, { T, E }); + mw.hr.s = decl_b(b, nm.f("normed_rot.s"), RAD_F32, { T, E / RAD_FP8_BLOCK }); + if (!mw.hr.q || !mw.hr.s) return RAD_E_INVAL; + } + if (mc.n_ff_shared > 0) { + mw.sgu = bf("shared_gate_up", { T, 2 * mc.n_ff_shared }); + mw.sff.x = bf("shared_ff", { T, mc.n_ff_shared }); + RAD_ARCH_TRY(mw.sff.declare_qs(b, nm, g, "shared_ff", mc.n_ff_shared)); + mw.sout = bf("shared_out", { T, E }); + mw.sgate = bf("shared_one", { T, 1 }); + } + return RAD_OK; +} + +/* ============================== declare ============================== */ + +static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* ctx) { + if (!b || !meta || !ctx || ctx->is_draft || ctx->rank < 0 || ctx->rank >= MAX_RANKS) + return RAD_E_INVAL; + const int world = ctx->world_size ? ctx->world_size : 1; + /* A sizing declare writes scratch: the step reads g_model, filled by the real declare at the + * real max_tok (RadBuildCtx::shape_probe). */ + static thread_local Model probe_model; + Model& m = ctx->shape_probe ? probe_model : g_model[ctx->rank]; + m = Model{}; + m.nm = Names(ctx->scope); + auto& g = m.g; + auto& s = m.s; + auto& nm = m.nm; + RAD_ARCH_TRY(read_shape(meta, s)); + if (world != 1 && world != 2 && world != 4) { + fprintf(stderr, "radiance: bailing_hybrid: --tp %d; the head and expert splits are built " + "for 1, 2 or 4 ranks\n", world); + return RAD_E_UNSUPPORTED; + } + if (s.heads % world || s.ff_exp % RAD_FP8_BLOCK || s.ff_shared % RAD_FP8_BLOCK || + s.ff_exp / RAD_FP8_BLOCK < world) { + fprintf(stderr, "radiance: bailing_hybrid: %lld heads and experts of %lld do not split " + "over %d ranks in whole heads and 128-column blocks\n", + (long long)s.heads, (long long)s.ff_exp, world); + return RAD_E_UNSUPPORTED; + } + if (ctx->max_spec > 31) { + fprintf(stderr, "radiance: bailing_hybrid: the KDA verify pass takes at most 32 rows a " + "sequence, so --num-speculative-tokens is at most 31\n"); + return RAD_E_UNSUPPORTED; + } + if (ctx->kv_dtype && ctx->kv_dtype != RAD_BF16) { + fprintf(stderr, "radiance: bailing_hybrid: the latent and KDA caches are bf16; run with " + "--kv-cache-dtype bf16\n"); + return RAD_E_UNSUPPORTED; + } + RAD_ARCH_TRY(geom_from(g, meta, ctx, "bf16", RAD_BF16)); + g.head_dim = s.head_dim; + + /* ---- the routed experts' slice of this rank: whole at one rank, halves at two, and at four + * the six 128-column blocks of an expert split 2, 2, 1, 1 over the ranks, rotated by the + * expert's number mod 4, so every rank carries six blocks per four experts (moe_gemm_q_mod4). + * The shared expert splits the same way, unrotated. */ + MoeFP8::Config mc; + mc.n_expert = mc.n_expert_all = s.experts; + mc.top_k = s.top_k; + mc.sigmoid_router = 1; + mc.route_scale = s.route_scale; + mc.norm_topk = cfg(meta, "norm_topk_prob", 1) != 0; + mc.n_group = s.groups; + mc.topk_group = s.topk_groups; + mc.shared_ungated = 1; + mc.swiglu_step = 1; + mc.rows = g.max_tok; + /* GPTQ calibration (RADIANCE_CALIB_DIR): the tap writes each expert's down Hessian over its + * whole width, so a calibration run gives every rank whole experts (below). */ + mc.calib = calib_dir() != nullptr ? 1 : 0; + mc.probed_expert = (int64_t)g.rank * (s.experts / world); + const int64_t eb = s.ff_exp / RAD_FP8_BLOCK, sb = s.ff_shared / RAD_FP8_BLOCK; + if (world == 4) { + int64_t widest = 0; + for (int q = 0; q < 4; ++q) { + int64_t lo, hi; + slice_of(eb, world, g.rank, q, &lo, &hi); + mc.ff_lo4[q] = lo * RAD_FP8_BLOCK; + mc.ff_hi4[q] = hi * RAD_FP8_BLOCK; + widest = std::max(widest, mc.ff_hi4[q] - mc.ff_lo4[q]); + } + mc.n_ff_exp = widest; + } else if (eb % world == 0) { + mc.n_ff_exp = s.ff_exp / world; + } else { + fprintf(stderr, "radiance: bailing_hybrid: experts of %lld do not halve into 128-column " + "blocks\n", (long long)s.ff_exp); + return RAD_E_UNSUPPORTED; + } + if (sb % world == 0) { + mc.n_ff_shared = s.ff_shared / world; + } else { + int64_t lo, hi; + slice_of(sb, world, g.rank, 0, &lo, &hi); + mc.shared_lo = lo * RAD_FP8_BLOCK; + mc.shared_hi = hi * RAD_FP8_BLOCK; + mc.n_ff_shared = mc.shared_hi - mc.shared_lo; + } + if (s.ff_dense % (world * RAD_FP8_BLOCK)) { + fprintf(stderr, "radiance: bailing_hybrid: the dense feed-forward's %lld columns do not " + "split over %d ranks in 128-column blocks\n", (long long)s.ff_dense, world); + return RAD_E_UNSUPPORTED; + } + g.n_ff_all = s.ff_dense; + g.n_ff = s.ff_dense / world; + + /* ---- each routed layer's expert format, read before any buffer is declared: rotated experts + * need the rotated activation pair, sized here. The MTP layer follows the trunk's. */ + const bool mtp = ctx->max_spec > 0 && cfg(meta, "num_nextn_predict_layers", 0) == 1; + std::vector msrc((size_t)s.n_layer + 1); + for (int l = (int)s.dense_layers; l < (int)s.n_layer + (mtp ? 1 : 0); ++l) { + const char* pre = nm.ckpt("model.layers.%d", l); + MoeFP8::Src& ms = msrc[(size_t)l]; + ms.cfg = mc; + ms.cfg.swiglu_limit = limit_at(s.lim_exp, l); + ms.cfg.shared_swiglu_limit = limit_at(s.lim_shared, l); + ms.norm = nm.ckpt("%s.post_attention_layernorm.weight", pre); + ms.router = nm.ckpt("%s.mlp.gate.weight", pre); + ms.router_bias = nm.ckpt("%s.mlp.gate.expert_bias", pre); + ms.experts = nm.ckpt("%s.mlp.experts", pre); + ms.shared = nm.ckpt("%s.mlp.shared_experts", pre); + RAD_ARCH_TRY(MoeFP8::probe(b, nm, l, ms, &ms.cfg)); + if (ms.cfg.expert_rot) mc.expert_rot = 1; + if (ms.cfg.expert_bf16) mc.expert_bf16 = 1; + } + /* ---- whole experts per rank for a calibration run and for bf16 experts (a slice of a bf16 + * expert is not one container run), as qwen4exp does: rank r owns experts [r E/W, (r+1) E/W). + * Served to calibrate and compare, not for decode speed. */ + if (world > 1 && (mc.calib || mc.expert_bf16)) { + int64_t per = 0; + RAD_ARCH_TRY(divide_or_fail(s.experts, world, "num_experts", &per)); + for (int l = (int)s.dense_layers; l < (int)s.n_layer + (mtp ? 1 : 0); ++l) { + auto& c = msrc[(size_t)l].cfg; + c.n_expert = per; + c.expert_base = (int64_t)g.rank * per; + c.n_ff_exp = s.ff_exp; + for (int q = 0; q < 4; ++q) c.ff_lo4[q] = c.ff_hi4[q] = 0; + } + mc.n_expert = per; + mc.expert_base = (int64_t)g.rank * per; + mc.n_ff_exp = s.ff_exp; + rad_note(b, "%s: rank %d owns experts [%lld, %lld) of %lld whole", + mc.calib ? "calibration (each expert's Hessian is over its whole width)" + : "bf16 experts", + g.rank, (long long)mc.expert_base, (long long)(mc.expert_base + per), + (long long)s.experts); + } + RAD_ARCH_TRY(buffers(b, m)); + RAD_ARCH_TRY(moe_buffers(b, m, mc)); + + /* ---- the caches: the MLA layers' latent rows, the KDA layers' state and convolution + * history. */ + { + RadKVGroupDecl d{}; + d.kind = RAD_KV_FULL; + d.dtype = RAD_BF16; + d.n_head_kv = 1; + d.head_dim = (s.latent + s.rope) / 2; + m.latent = rad_decl_kv_group(b, nm.f("kv_latent"), &d); + d = {}; + d.kind = RAD_KV_LINEAR; + d.dtype = RAD_F32; + d.n_head_kv = s.heads / world; + d.state_dim[0] = d.state_dim[1] = s.head_dim; + m.state = rad_decl_kv_group(b, nm.f("kv_kda"), &d); + d = {}; + d.kind = RAD_KV_CONV; + d.dtype = RAD_BF16; + d.n_head_kv = 1; + d.head_dim = 3 * (s.heads / world) * s.head_dim; + d.conv_width = s.conv; + m.conv = rad_decl_kv_group(b, nm.f("kv_kda_conv"), &d); + if (!m.latent || !m.state || !m.conv) return RAD_E_INVAL; + } + + /* ---- the embedding, the layers, the final norm and the head. */ + RAD_ARCH_TRY(map_copy(b, nm.f("token_embd.weight"), nm.ckpt("model.word_embeddings.weight"))); + RAD_ARCH_TRY(map_copy(b, nm.f("output.weight"), nm.ckpt("lm_head.weight"))); + RAD_ARCH_TRY(map_copy(b, nm.f("output_norm.weight"), nm.ckpt("model.norm.weight"))); + m.token = decl_w(b, nm.f("token_embd.weight"), RAD_BF16, { g.n_vocab, g.n_embd }, + RAD_ACCESS_VOCAB, RAD_SHARD_ROW, grp_model()); + m.head = decl_w(b, nm.f("output.weight"), RAD_BF16, { g.n_vocab, g.n_embd }, RAD_ACCESS_VOCAB, + RAD_SHARD_ROW, grp_model()); + m.final_gain = decl_w(b, nm.f("output_norm.weight"), RAD_F32, { g.n_embd }, + RAD_ACCESS_PER_TOKEN, RAD_SHARD_NONE, grp_model()); + m.embed = rw(b, + RAD_OP(b, "embed_lookup", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n_embd", g.n_embd), + RAD_INT("n_vocab", g.n_vocab), RAD_STR("dtype", "bf16"), + RAD_INT("vocab_offset", g.vocab_off)), + RAD_WEIGHTS(m.token)), + {}, { m.x }); + m.embed_ar = GlmTp::reduce(b, g, m.x, true); + + m.layers.resize((size_t)s.n_layer); + for (int l = 0; l < (int)s.n_layer; ++l) { + Layer& lay = m.layers[(size_t)l]; + lay.mla = is_mla(s, l); + lay.dense = l < s.dense_layers; + const char* pre = nm.ckpt("model.layers.%d", l); + const char* nn = nm.f("blk.%d.attn_norm.weight", l); + RAD_ARCH_TRY(map_copy(b, nn, nm.ckpt("%s.input_layernorm.weight", pre))); + lay.gain = decl_w(b, nn, RAD_F32, { g.n_embd }, RAD_ACCESS_PER_TOKEN, RAD_SHARD_NONE, + grp_layer(l)); + RAD_ARCH_TRY(lay.norm.declare(b, g, lay.gain, m.x, m.act, g.n_embd)); + const char* ap = nm.ckpt("%s.attention", pre); + if (lay.mla) { + RAD_ARCH_TRY(lay.attn.declare(b, nm, g, s, l, m.aw, ap, m.latent)); + } else { + RAD_ARCH_TRY(rad_bind_layer_kv(b, l, m.state)); + RAD_ARCH_TRY(rad_bind_layer_kv(b, l, m.conv)); + RAD_ARCH_TRY(lay.kda.declare(b, nm, g, s, l, m.kw, ap, m.state, m.conv)); + } + lay.op_add = rw(b, + RAD_OP(b, "add", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", g.n_embd), + RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + { m.x, m.y }, { m.x }); + if (!lay.op_add) return RAD_E_INVAL; + if (lay.dense) { + MlpFP8::Src ds{ nm.ckpt("%s.post_attention_layernorm.weight", pre), + nm.ckpt("%s.mlp.gate_proj.weight", pre), + nm.ckpt("%s.mlp.up_proj.weight", pre), + nm.ckpt("%s.mlp.down_proj.weight", pre) }; + RAD_ARCH_TRY(lay.mlp.declare(b, nm, g, l, m.dw, ds)); + } else { + RAD_ARCH_TRY(lay.moe.declare(b, nm, g, l, m.mw, msrc[(size_t)l])); + } + } + RAD_ARCH_TRY(rad_kv_group_replicated(b, m.latent)); + m.norm = rw(b, + RAD_OP(b, "rmsnorm", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", g.n_embd), + RAD_F64("eps", g.eps), RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(m.final_gain)), + { m.x }, { m.final_hidden }); + m.gather = rw(b, + RAD_OP(b, "gather_rows", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows), RAD_INT("n", g.n_embd), + RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + { m.final_hidden }, { m.logit_input }); + m.head_op = + rw(b, + RAD_OP(b, "logits_gemm", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows), RAD_INT("n_vocab", g.n_vocab), + RAD_INT("n_embd", g.n_embd), RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(m.head)), + { m.logit_input }, { m.logits }); + if (!m.embed || !m.norm || !m.gather || !m.head_op) return RAD_E_INVAL; + + /* ---- the drafter: GlmMtp at Ling's width and checkpoint names around one more MLA layer + * with the routed feed-forward. It shares the trunk's buffers, latent cache, embedding and + * head. */ + if (mtp) { + const int l = (int)s.n_layer; + auto& mt = m.mtp; + mt.width = g.n_embd; + mt.prefix = nm.ckpt("model.layers.%d", l); + mt.layer = l; + mt.norm_src = "final_layernorm.weight"; + const GlmMtp::Wire tw{ m.final_hidden, m.logits, m.token, m.head }; + RAD_ARCH_TRY(mt.declare_inputs(b, g, tw, false)); + Layer& d = m.draft; + d.mla = true; + const char* pre = mt.prefix; + const char* nn = nm.f("blk.%d.attn_norm.weight", l); + RAD_ARCH_TRY(map_copy(b, nn, nm.ckpt("%s.input_layernorm.weight", pre))); + d.gain = decl_w(b, nn, RAD_F32, { g.n_embd }, RAD_ACCESS_PER_TOKEN, RAD_SHARD_NONE, + grp_layer(l)); + RAD_ARCH_TRY(d.norm.declare(b, g, d.gain, mt.x, m.act, g.n_embd)); + RAD_ARCH_TRY(d.attn.declare(b, nm, g, s, l, m.aw, nm.ckpt("%s.attention", pre), m.latent)); + RAD_ARCH_TRY(mt.declare_join(b, m.y)); + auto mw = m.mw; + mw.x = mt.x; + RAD_ARCH_TRY(d.moe.declare(b, nm, g, l, mw, msrc[(size_t)l])); + RAD_ARCH_TRY(mt.declare_head(b)); + m.have_mtp = true; + } + rad_note(b, + "Ling-3.0 (bailing_hybrid): TP%d, %lld layers, %lld KDA + %lld dense MLA, %lld experts " + "top-%lld in %lld groups (%lld kept), MTP %s", + world, (long long)s.n_layer, (long long)(s.n_layer - s.n_layer / s.group_size), + (long long)(s.n_layer / s.group_size), (long long)s.experts, (long long)s.top_k, + (long long)s.groups, (long long)s.topk_groups, m.have_mtp ? "enabled" : "not declared"); + return RAD_OK; +} + +/* ============================== step ============================== */ + +/* RADIANCE_LING_DUMP=DIR: the residual stream after each layer's attention and feed-forward, every + * row of every step, as `/s.t.l..r.bf16` ([rows, n_embd] + * bf16). A diagnostic for comparing against a reference model layer by layer; it synchronises the + * stream. */ +static void dump(RadCtx* c, const RadBatch* batch, rad_buf x, int64_t E, int layer, + const char* site) { + static const char* dir = std::getenv("RADIANCE_LING_DUMP"); + if (!dir || !*dir) return; + const int64_t T = batch->n_tok; + void* p = rad_buf_ptr(c, x); + if (!p) return; + std::vector h((size_t)(T * E)); + if (rad_memcpy_async(h.data(), p, T * E * 2, rad_stream(c)) < 0) return; + rad_stream_sync(rad_stream(c)); + char path[512]; + std::snprintf(path, sizeof path, "%s/s%d.t%lld.l%d.%s.r%d.bf16", dir, batch->step, + (long long)T, layer, site, rad_rank(c)); + if (FILE* f = std::fopen(path, "wb")) { + std::fwrite(h.data(), 2, h.size(), f); + std::fclose(f); + } +} + +/* A draft pass as GLM-5.3's (glm5next.cpp): the head's inputs, its MLA layer over every row (a + * history pass fills the draft layer's latent cache for all of them), then on the proposal rows the + * residual join, the routed feed-forward and the head. */ +static void draft_pass(RadCtx* c, Model& m, const RadBatch* batch) { + if (!m.have_mtp || batch->draft_pass == 1) { + rad_step_fail(c, "bailing_hybrid MTP pass is not declared or has invalid round 1"); + return; + } + const int64_t T = batch->n_tok; + m.mtp.step_inputs(c, batch); + auto& l = m.draft; + l.norm.step(c, T); + l.attn.step(c, batch); + if (batch->draft_pass < 0 && batch->n_draft_out <= 0) return; + m.mtp.step_join(c, batch, m.y); + l.moe.step_rows(c, GlmMtp::head_rows(batch)); + m.mtp.step_head(c, batch); +} + +static void step(RadCtx* c, const RadBatch* batch) { + Model& m = g_model[rad_rank(c)]; + const int64_t T = batch->n_tok, E = m.g.n_embd; + if (batch->enc) { + rad_step_fail(c, "bailing_hybrid serves text"); + return; + } + if (batch->draft_pass) { + draft_pass(c, m, batch); + return; + } + RAD_ISSUE_N(c, m.embed, T, praw(batch->token_ids, RAD_I32, T), RAD_W(m.token), brows(m.x, T)); + if (m.embed_ar) RAD_ISSUE_N(c, m.embed_ar, T * E, brows(m.x, T), RAD_NONE); + for (size_t i = 0; i < m.layers.size(); ++i) { + const Layer& l = m.layers[i]; + l.norm.step(c, T); + if (l.mla) + l.attn.step(c, batch); + else + l.kda.step(c, batch); + RAD_ISSUE_N(c, l.op_add, T, brows(m.x, T), brows(m.y, T), brows(m.x, T)); + dump(c, batch, m.x, E, (int)i, "attn"); + if (l.dense) + l.mlp.step(c, batch); + else + l.moe.step(c, batch); + dump(c, batch, m.x, E, (int)i, "ffn"); + } + RAD_ISSUE_N(c, m.norm, T, brows(m.x, T), RAD_W(m.final_gain), brows(m.final_hidden, T)); + if (batch->n_out > 0) { + RAD_ISSUE_N(c, m.gather, batch->n_out, brows(m.final_hidden, T), + praw(batch->out_ids, RAD_I32, batch->n_out), brows(m.logit_input, batch->n_out)); + RAD_ISSUE_N(c, m.head_op, batch->n_out, brows(m.logit_input, batch->n_out), RAD_W(m.head), + brows(m.logits, batch->n_out)); + } +} + +/* The default draft depth for `--num-speculative-tokens auto`: GlmMtp's operating point, when the + * checkpoint carries its one MTP layer. */ +static int probe(const RadModelMeta* meta, RadArchProbe* out) { + if (!meta || !out) return RAD_E_INVAL; + if (cfg(meta, "num_nextn_predict_layers", 0) == 1) out->draft_depth = GlmMtp::kDepth; + out->shape_probe_ok = 1; /* declare() writes scratch under shape_probe */ + return RAD_OK; +} + +} /* namespace bailing_hybrid */ + +#ifndef RAD_ARCH_NO_EXPORTS +RAD_ARCH_PROBE(bailing_hybrid) +RAD_ARCH_PLUGIN(bailing_hybrid, "bailinghybrid", "", "0.1.0", + "Ling-3.0 (bailing_hybrid): KDA and dense latent attention, group-routed experts") +#endif diff --git a/arch/common/rad_arch.h b/arch/common/rad_arch.h index 78fc0d46..7cfca781 100644 --- a/arch/common/rad_arch.h +++ b/arch/common/rad_arch.h @@ -17,6 +17,7 @@ #include "rad_yarn.h" #include "rad_abi_layout.h" +#include #include #include #include @@ -123,6 +124,36 @@ inline const char* calib_dir() { return d && *d ? d : nullptr; } +/* Whether layer `layer` taps (RADIANCE_CALIB_LAYERS: comma-separated layers and "lo-hi" ranges; + * unset, every layer). A model whose per-expert Hessians do not fit the host at once (Nemotron-3.5 + * Bolt's are 169 GiB) calibrates in several runs over disjoint ranges; each run writes only its + * layers' files, so the runs share one directory. */ +inline bool calib_layer_on(int layer) { + static const std::vector> ranges = [] { + std::vector> r; + const char* s = std::getenv("RADIANCE_CALIB_LAYERS"); + while (s && *s) { + char* e = nullptr; + const long lo = std::strtol(s, &e, 10); + if (e == s) break; + long hi = lo; + if (*e == '-') { + const char* h = e + 1; + hi = std::strtol(h, &e, 10); + if (e == h) break; + } + r.emplace_back((int)lo, (int)hi); + s = *e == ',' ? e + 1 : e; + if (*s && *s != ',' && !std::isdigit((unsigned char)*s)) break; + } + return r; + }(); + if (!std::getenv("RADIANCE_CALIB_LAYERS")) return true; + for (const auto& r : ranges) + if (layer >= r.first && layer <= r.second) return true; + return false; +} + /* Token count at which the tap dumps and switches itself off (RADIANCE_CALIB_TOKENS, default * 65536). Whether the tap runs at all is calib_dir()'s decision. */ inline long long calib_target() { @@ -980,7 +1011,7 @@ inline int geom_from(Geom& g, const RadModelMeta* m, const RadBuildCtx* c, g.wire_exact= c->tp_wire_lossy ? 0 : 1; g.wire_min_bytes = c->tp_wire_min_bytes; g.attn_prefill_fp8 = c->attn_prefill_fp8; - g.plain_norm = c->plain_norm; + g.plain_norm = c->plain_norm != 0; g.eps = m->rms_eps; g.theta = m->rope_theta; g.rope_scale= 1.0f; /* yarn_from reads the model's rotary scaling */ @@ -1504,7 +1535,12 @@ inline const char* drafter_layer_prefix(const RadModelMeta* meta) { return "draft.transformer_layer_config."; return "draft."; } -inline int drafter_geom(Geom& dg, const Geom& target, const RadModelMeta* meta, const char* what) { +/* `kv_repl_ok`: the drafter block reads its k and v at Geom::kv_off (rad_block_dflash2.h does), so + * fewer KV heads than ranks are replicated as geom_from replicates the target's: world a multiple + * of the head count, one KV head a rank, `kv_off` its first row in the unsharded k/v projection. + * Otherwise such a world is refused, as before. */ +inline int drafter_geom(Geom& dg, const Geom& target, const RadModelMeta* meta, const char* what, + bool kv_repl_ok = false) { dg = target; const char* pre = drafter_layer_prefix(meta); char key[160]; @@ -1529,7 +1565,15 @@ inline int drafter_geom(Geom& dg, const Geom& target, const RadModelMeta* meta, } RAD_ARCH_TRY(yarn_from(dg, meta, pre, dg.head_dim)); RAD_ARCH_TRY(divide_or_fail(dg.n_head_all, dg.world, "draft num_attention_heads", &dg.n_head)); - RAD_ARCH_TRY(divide_or_fail(dg.n_head_kv_all, dg.world, "draft num_key_value_heads", &dg.n_head_kv)); + /* The target's kv_off is the target's; the drafter's is set here or zero. */ + dg.kv_off = 0; + if (kv_repl_ok && dg.world > dg.n_head_kv_all && dg.world % dg.n_head_kv_all == 0) { + dg.n_head_kv = 1; /* world / n_head_kv_all ranks share each KV head */ + dg.kv_off = (dg.rank / (dg.world / dg.n_head_kv_all)) * dg.head_dim; + } else { + RAD_ARCH_TRY(divide_or_fail(dg.n_head_kv_all, dg.world, "draft num_key_value_heads", + &dg.n_head_kv)); + } RAD_ARCH_TRY(divide_or_fail(dg.n_ff_all, dg.world, "draft intermediate_size", &dg.n_ff)); const long long dvocab = rad_meta_geti(meta, k("vocab_size"), dg.n_vocab_all); if (dvocab != dg.n_vocab_all) { diff --git a/arch/common/rad_block_attn_fp8.h b/arch/common/rad_block_attn_fp8.h index 765a5a53..1182c896 100644 --- a/arch/common/rad_block_attn_fp8.h +++ b/arch/common/rad_block_attn_fp8.h @@ -9,6 +9,9 @@ * the GEMM output directly. * - No output gate. The attention output goes straight into the out-projection. * + * `rotary_dim` 0 is attention without positions (NoPE, Nemotron-H's attention layers): no `rope` + * is declared, and position reaches the model through its recurrent layers alone. + * * That allows a fused q|k|v, which the gated block cannot have (its query projection is [q|gate] * interleaved per head). The three weights concatenate along dim 0 into one * [q_dim + 2*kv_dim, n_embd], and `rope` takes that row as is: q heads, then k heads, v untouched @@ -81,19 +84,21 @@ inline int AttnFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, r const int64_t q_dim = g.q_dim(); const int64_t kv_dim = g.kv_dim(); - if (n_rot <= 0 || n_rot > g.head_dim || (n_rot & 1)) { + if (n_rot < 0 || n_rot > g.head_dim || (n_rot & 1)) { fprintf(stderr, "radiance: rotary_dim %lld is not an even width inside head_dim %lld\n", (long long)n_rot, (long long)g.head_dim); return RAD_E_INVAL; } - /* No KV-head replication: the fused [q|k|v] uses the plain even row shard, so above the KV head - * count a rank would read the wrong rows. rad_block_attn_gated_fp8.h is the block that uses - * geom_from's `kv_off`. */ - if (g.world > g.n_head_kv_all) { - fprintf(stderr, "radiance: %s declares no KV row span and cannot serve world_size = %d " - "with n_head_kv = %lld.\n", __func__, g.world, - (long long)g.n_head_kv_all); + /* Above the KV head count geom_from replicates KV heads (rad_arch.h): each of the fused row's + * three parts takes its own span (as gemma4's q|k|v does), q this rank's heads and k and v the + * shared head at `kv_off`, where the even shard would hand a rank part of a head. A smaller + * attention world (Geom::attn_world) is not served here. */ + const bool kv_repl = g.world > g.n_head_kv_all; + if (kv_repl && g.attn_world != g.world) { + fprintf(stderr, "radiance: %s replicates KV heads but declares no attention-zero ranks; " + "world_size = %d must be a multiple of n_head_kv = %lld.\n", __func__, + g.world, (long long)g.n_head_kv_all); return RAD_E_UNSUPPORTED; } @@ -107,9 +112,17 @@ inline int AttnFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, r RAD_ARCH_TRY(qkv.declare(b, nm, g, nm.f("blk.%d.attn_qkv", l), q_dim + 2 * kv_dim, g.n_embd, RAD_SHARD_ROW, grp_layer(l), { src.q, src.k, src.v }, w.h, w.qkv, 0, { q_dim, kv_dim, kv_dim })); + if (kv_repl) { + const int64_t lo[3] = { g.rank * q_dim, g.kv_off, g.kv_off }; + const int64_t hi[3] = { lo[0] + q_dim, lo[1] + kv_dim, lo[2] + kv_dim }; + const int64_t tot[3] = { g.n_head_all * g.head_dim, g.n_head_kv_all * g.head_dim, + g.n_head_kv_all * g.head_dim }; + RAD_ARCH_TRY(qkv.span_parts(b, lo, hi, tot, 3)); + } - op_rope = rw(b, decl_rope(b, g, g.max_tok, g.head_dim, g.n_head, g.n_head_kv, n_rot, mode), - {w.qkv}, {w.qkv}); + if (n_rot > 0) + op_rope = rw(b, decl_rope(b, g, g.max_tok, g.head_dim, g.n_head, g.n_head_kv, n_rot, mode), + {w.qkv}, {w.qkv}); /* Copies the query out of the fused row: libr4d's paged attention reads `q` as a dense * [total_q, n_head, head_dim] block with no pitch argument (r4d_attn_args.h, fill_paged), so a @@ -179,7 +192,7 @@ inline void AttnFP8::step(RadCtx* c, const RadBatch* batch) const { qkv.step(c, w.h, w.qkv, T); /* In place over the fused row: rotates n_head query heads, then n_head_kv key heads, and * leaves the value heads alone. */ - RAD_ISSUE(c, op_rope, brows(w.qkv, T), rope_posmc(g, batch, T)); + if (op_rope) RAD_ISSUE(c, op_rope, brows(w.qkv, T), rope_posmc(g, batch, T)); /* k and v are column slices of the fused row, at q_dim and q_dim + kv_dim. */ RAD_ISSUE(c, op_kv_store, diff --git a/arch/common/rad_block_attn_gated_fp8.h b/arch/common/rad_block_attn_gated_fp8.h index 345098d4..fbb3da0c 100644 --- a/arch/common/rad_block_attn_gated_fp8.h +++ b/arch/common/rad_block_attn_gated_fp8.h @@ -458,8 +458,10 @@ inline int AttnGatedFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int if (g.w_bf16) { RAD_ARCH_TRY(gate_pair(w.gate)); } else { - if (rad_op_declared(b, "gate_quant_fp8")) - op_gq = rw(b, RAD_OP(b, "gate_quant_fp8", + /* Rotated int8 codes (ActFP8::q8_rot): gate_had_quant_i8g, had_quant_act_i8g's codes. */ + const char* gq = w.attn.q8_rot ? "gate_had_quant_i8g" : "gate_quant_fp8"; + if (rad_op_declared(b, gq)) + op_gq = rw(b, RAD_OP(b, gq, RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok * g.n_head), RAD_INT("n", g.head_dim), RAD_INT("group", RAD_FP8_BLOCK), RAD_STR("dtype", g.dtype), RAD_STR("act", "sigmoid")), @@ -487,7 +489,7 @@ inline int AttnGatedFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int * and quantiser read, so one op merges, gates, rounds and quantises (byte-identical to the * pair). Declared only with a selection: the dense path also uses the prefill kernel, which * has no merge. */ - if (op_attn && qsa_sel && qsa_sequ && !g.w_bf16 && + if (op_attn && qsa_sel && qsa_sequ && !g.w_bf16 && !w.attn.q8_rot && rad_op_declared(b, "attn_paged_gate_quant")) { op_attn_gq = RAD_OP(b, "attn_paged_gate_quant", RAD_PARAMS(RAD_INT("q_len", 1), RAD_INT("head_dim", g.head_dim), diff --git a/arch/common/rad_block_dflash2.h b/arch/common/rad_block_dflash2.h index b9b9cf9c..ee63d53d 100644 --- a/arch/common/rad_block_dflash2.h +++ b/arch/common/rad_block_dflash2.h @@ -47,6 +47,13 @@ * hp = hidden_projection(x) the selector's query, rank 256 * tokens = dflash_select(cand, unary, hp, anchor, predecessor, successor) * + * ============================== LILICORR ============================== + * + * Config::lili is NVIDIA's LiLiCorr backbone (Nemotron-3.5-Bolt's drafter): the same layers with a + * learned sink logit a query head in the attention (attn_paged_sink, `attention_sink_bias`), and no + * selector or draft head here. The query pass ends with the gather into `sel_h`; the plugin then + * runs rad_block_lilicorr.h's correlator over those rows, which reads the target's own head. + * * ============================== WHAT IS SHARED WITH THE TARGET ============================== * * The embedding table and lm_head. The checkpoint (81 tensors) ships neither, and @@ -68,6 +75,8 @@ * * q/kv and gate_up shard by row, o and down by column with an all-reduce: ten collectives per * draft pass, each 5120 * block * 2 bytes (80 KiB at block 8), below the lossy wire's floor. + * Fewer KV heads than ranks are replicated (drafter_geom's `kv_repl_ok`): each rank reads its + * head's k/v rows at `kv_off` and keeps that head in its cache. * * fc [n_embd, n_taps*n_embd], 262 MiB in fp8 at Qwen3.8's width, read whole by the * context pass every step. Split by rows over the ranks and all-gathered, and @@ -152,6 +161,9 @@ struct Dflash2 { * acceptance, sum min(P, Q). */ double q_temp = 1.0; int64_t short_rows = 0; + /* LiLiCorr's backbone (the LILICORR section above): sinks, and the head left to the + * plugin. sel_rank and sel_topk are then unused. */ + int lili = 0; int64_t steps() const { return block - 1; } int64_t nodes() const { return tree && tree_nodes > 0 ? tree_nodes : steps(); } int64_t ng(int64_t n_embd) const { return group ? n_embd / group : 0; } @@ -294,6 +306,9 @@ struct Dflash2 { int64_t block_lo = 0; int64_t sel_lo_nodes = 0; /* a tree's nodes at the short block (op_sel_lo) */ rad_op op_qrope = 0, op_krope = 0, op_store = 0, op_attn = 0; + /* LiLiCorr: the attention with each layer's sinks, a weight, so one op a layer. */ + rad_weight w_sink[MAX_LAYERS] = {}; + rad_op op_attn_sink[MAX_LAYERS] = {}; rad_op op_act = 0, op_ar = 0, op_add = 0, op_final = 0; /* The residual add folded into the norm after it (add_rmsnorm), issued in place of op_add and * that norm where it resolves: op_afn[i] after layer i's attention (its feed-forward norm), @@ -353,7 +368,7 @@ inline int Dflash2::declare(RadBuilder* b, Names& nm, const Geom& geom, const Co (long long)g.n_layer, MAX_LAYERS); return RAD_E_UNSUPPORTED; } - if (cfg.block < 2 || cfg.n_taps <= 0 || cfg.sel_rank <= 0 || cfg.sel_topk <= 0) + if (cfg.block < 2 || cfg.n_taps <= 0 || (!cfg.lili && (cfg.sel_rank <= 0 || cfg.sel_topk <= 0))) return RAD_E_INVAL; const int64_t NG = cfg.ng(g.n_embd); @@ -401,23 +416,10 @@ inline int Dflash2::declare(RadBuilder* b, Names& nm, const Geom& geom, const Co } RAD_ARCH_TRY(map_copy(b, nm.f("dflash.hidden_norm.weight"), nm.ckpt("%s.hidden_norm.weight", ck))); RAD_ARCH_TRY(map_copy(b, nm.f("dflash.norm.weight"), nm.ckpt("%s.norm.weight", ck))); - RAD_ARCH_TRY(map_copy(b, nm.f("dflash.sel_proj.weight"), - nm.ckpt("%s.candidate_selector.hidden_projection.weight", ck))); - RAD_ARCH_TRY(map_copy(b, nm.f("dflash.sel_pred"), - nm.ckpt("%s.candidate_selector.predecessor_codebook", ck))); - RAD_ARCH_TRY(map_copy(b, nm.f("dflash.sel_succ"), - nm.ckpt("%s.candidate_selector.successor_codebook", ck))); - w_hnorm = decl_w(b, nm.f("dflash.hidden_norm.weight"), RAD_F32, {g.n_embd}, RAD_ACCESS_PER_TOKEN, RAD_SHARD_NONE, grp_model()); w_norm = decl_w(b, nm.f("dflash.norm.weight"), RAD_F32, {g.n_embd}, RAD_ACCESS_PER_TOKEN, RAD_SHARD_NONE, grp_model()); - w_selp = decl_w(b, nm.f("dflash.sel_proj.weight"), RAD_BF16, {cfg.sel_rank, g.n_embd}, - RAD_ACCESS_PER_TOKEN, RAD_SHARD_NONE, grp_model()); - w_pred = decl_w(b, nm.f("dflash.sel_pred"), RAD_BF16, {g.n_vocab_all, cfg.sel_rank}, - RAD_ACCESS_VOCAB, RAD_SHARD_NONE, grp_model()); - w_succ = decl_w(b, nm.f("dflash.sel_succ"), RAD_BF16, {g.n_vocab_all, cfg.sel_rank}, - RAD_ACCESS_VOCAB, RAD_SHARD_NONE, grp_model()); /* The 2-bit draft head, declared as the MTP head's is (rad_block_mtp_fp8.h): * `dflash.draft_head.weight` is the target's lm_head under its own name, quantised by the @@ -427,35 +429,53 @@ inline int Dflash2::declare(RadBuilder* b, Names& nm, const Geom& geom, const Co * When sharded, each rank's `row_topk` reports global ids, an all_gather moves R pairs a row, * and `row_topk_merge` reduces them to exactly the unsharded global top-R, ties included * (docs/OPS.md). This runs before the selector, so every rank holds the same candidates for - * the replicated codebooks. The all_gather is `world * R` pairs a row (2 KiB at R = 16). */ + * the replicated codebooks. The all_gather is `world * R` pairs a row (2 KiB at R = 16). + * + * LiLiCorr has neither the selector nor this head (its correlator reads the target's). */ enum { DF_W2_GROUP = 128 }; const bool dh_shard = head_sharded(g); const int dh_split = dh_shard ? RAD_SHARD_ROW : RAD_SHARD_NONE; - const char* dhn = nm.f("dflash.draft_head.weight"); - RAD_ARCH_TRY(map_copy(b, dhn, ck_lm)); - /* The 8-bit form: int8 codes, one f16 scale per (row, 128 of K), symmetric, which gemm_nt_q - * reads at w8a8 against the same quant_act_i8 activation (without its asum). */ - { - RadEncoding e{}; - const RadEncPlane* sc = nullptr; - head_i8 = weight_enc(b, dhn, &e) && rad_enc_is(&e, "affine") && e.n_planes == 2 && - !e.transform[0] && e.plane[0].dtype == RAD_I8 && e.plane[0].block[1] == 1 && - (sc = rad_enc_plane(&e, "scale")) && sc->dtype == RAD_F16 && - sc->block[0] == 1 && sc->block[1] == DF_W2_GROUP; + if (!cfg.lili) { + RAD_ARCH_TRY(map_copy(b, nm.f("dflash.sel_proj.weight"), + nm.ckpt("%s.candidate_selector.hidden_projection.weight", ck))); + RAD_ARCH_TRY(map_copy(b, nm.f("dflash.sel_pred"), + nm.ckpt("%s.candidate_selector.predecessor_codebook", ck))); + RAD_ARCH_TRY(map_copy(b, nm.f("dflash.sel_succ"), + nm.ckpt("%s.candidate_selector.successor_codebook", ck))); + w_selp = decl_w(b, nm.f("dflash.sel_proj.weight"), RAD_BF16, {cfg.sel_rank, g.n_embd}, + RAD_ACCESS_PER_TOKEN, RAD_SHARD_NONE, grp_model()); + w_pred = decl_w(b, nm.f("dflash.sel_pred"), RAD_BF16, {g.n_vocab_all, cfg.sel_rank}, + RAD_ACCESS_VOCAB, RAD_SHARD_NONE, grp_model()); + w_succ = decl_w(b, nm.f("dflash.sel_succ"), RAD_BF16, {g.n_vocab_all, cfg.sel_rank}, + RAD_ACCESS_VOCAB, RAD_SHARD_NONE, grp_model()); + + const char* dhn = nm.f("dflash.draft_head.weight"); + RAD_ARCH_TRY(map_copy(b, dhn, ck_lm)); + /* The 8-bit form: int8 codes, one f16 scale per (row, 128 of K), symmetric, which + * gemm_nt_q reads at w8a8 against the same quant_act_i8 activation (without its asum). */ + { + RadEncoding e{}; + const RadEncPlane* sc = nullptr; + head_i8 = weight_enc(b, dhn, &e) && rad_enc_is(&e, "affine") && e.n_planes == 2 && + !e.transform[0] && e.plane[0].dtype == RAD_I8 && e.plane[0].block[1] == 1 && + (sc = rad_enc_plane(&e, "scale")) && sc->dtype == RAD_F16 && + sc->block[0] == 1 && sc->block[1] == DF_W2_GROUP; + } + if (head_i8) { + w_dh = decl_view(b, dhn, nullptr, "codes", RAD_I8, {head_rows(g), g.n_embd}, + RAD_ACCESS_PER_TOKEN, dh_split, grp_model()); + w_dhs = decl_view(b, nm.f("dflash.draft_head.scale"), dhn, "scale", RAD_F16, + {head_rows(g), g.n_embd / DF_W2_GROUP}, RAD_ACCESS_PER_TOKEN, + dh_split, grp_model()); + } else { + w_dh = decl_view(b, dhn, nullptr, "codes", RAD_U2, {head_rows(g), g.n_embd}, + RAD_ACCESS_PER_TOKEN, dh_split, grp_model()); + w_dhs = decl_view(b, nm.f("dflash.draft_head.scale"), dhn, "scale,zero", RAD_F16, + {head_rows(g), g.n_embd}, RAD_ACCESS_PER_TOKEN, dh_split, + grp_model()); + } + if (!w_dh || !w_dhs) return RAD_E_INVAL; } - if (head_i8) { - w_dh = decl_view(b, dhn, nullptr, "codes", RAD_I8, {head_rows(g), g.n_embd}, - RAD_ACCESS_PER_TOKEN, dh_split, grp_model()); - w_dhs = decl_view(b, nm.f("dflash.draft_head.scale"), dhn, "scale", RAD_F16, - {head_rows(g), g.n_embd / DF_W2_GROUP}, RAD_ACCESS_PER_TOKEN, dh_split, - grp_model()); - } else { - w_dh = decl_view(b, dhn, nullptr, "codes", RAD_U2, {head_rows(g), g.n_embd}, - RAD_ACCESS_PER_TOKEN, dh_split, grp_model()); - w_dhs = decl_view(b, nm.f("dflash.draft_head.scale"), dhn, "scale,zero", RAD_F16, - {head_rows(g), g.n_embd}, RAD_ACCESS_PER_TOKEN, dh_split, grp_model()); - } - if (!w_dh || !w_dhs) return RAD_E_INVAL; /* ---------------------------------------------------------------- per-layer weights */ for (int64_t l = 0; l < g.n_layer; ++l) { @@ -492,6 +512,13 @@ inline int Dflash2::declare(RadBuilder* b, Names& nm, const Geom& geom, const Co RAD_ARCH_TRY(w_v[i].declare(b, nm, nm.f("dflash.blk.%d.attn_v", i), kvd, g.n_embd, RAD_ACCESS_PER_TOKEN, RAD_SHARD_ROW, grp_layer(first_layer + i), { nm.ckpt("%s.layers.%d.self_attn.v_proj.weight", ck, i) })); + /* Fewer KV heads than ranks (drafter_geom's `kv_repl_ok`): k and v are this rank's + * replicated head, rows [kv_off, kv_off + kv_dim) of the unsharded projection, where the + * even shard would hand a rank part of a head. q stays an even share of the heads. */ + if (g.world > g.n_head_kv_all) { + RAD_ARCH_TRY(w_k[i].span(b, g.kv_off, g.kv_off + kvd)); + RAD_ARCH_TRY(w_v[i].span(b, g.kv_off, g.kv_off + kvd)); + } w_qn[i] = decl_w(b, nm.f("dflash.blk.%d.attn_q_norm.weight", i), RAD_F32, {g.head_dim}, RAD_ACCESS_PER_TOKEN, RAD_SHARD_NONE, grp_layer(first_layer + i)); w_kn[i] = decl_w(b, nm.f("dflash.blk.%d.attn_k_norm.weight", i), RAD_F32, {g.head_dim}, @@ -520,6 +547,14 @@ inline int Dflash2::declare(RadBuilder* b, Names& nm, const Geom& geom, const Co w_fcb[i] = decl_w(b, nm.f("dflash.blk.%d.ffn_conv_base", i), RAD_BF16, {2, cfg.taps, g.n_embd}, RAD_ACCESS_PER_TOKEN, RAD_SHARD_NONE, grp_layer(first_layer + i)); + /* LiLiCorr's sink logit a query head, split with the heads. */ + if (cfg.lili) { + RAD_ARCH_TRY(map_copy(b, nm.f("dflash.blk.%d.attn_sinks", i), + nm.ckpt("%s.layers.%d.self_attn.attention_sink_bias", ck, i))); + w_sink[i] = decl_w(b, nm.f("dflash.blk.%d.attn_sinks", i), RAD_F32, {g.n_head}, + RAD_ACCESS_PER_TOKEN, RAD_SHARD_ROW, grp_layer(first_layer + i)); + if (!w_sink[i]) return RAD_E_INVAL; + } } @@ -529,15 +564,35 @@ inline int Dflash2::declare(RadBuilder* b, Names& nm, const Geom& geom, const Co * * Declared before both kv_stores, which read the resolved `block_size` back with * rad_kv_block_size(); before this declaration it returns zero. */ - op_attn = rw(b, RAD_OP(b, "attn_paged", - RAD_PARAMS(RAD_RANGE("q_len", 1, cfg.block), RAD_INT("head_dim", g.head_dim), - RAD_INT("gqa", g.gqa()), RAD_INT("causal", cfg.causal), - RAD_INT("window", cfg.window), RAD_INT("n_head", g.n_head), - RAD_INT("block_size", RAD_KV_BLOCK), - RAD_INT("max_seqs", g.max_seqs), RAD_INT("max_ctx", g.max_ctx), - RAD_STR("q_dtype", g.dtype), RAD_STR("kv_dtype", g.kv_dtype)), - RAD_NOWEIGHTS), - {w.q}, {w.attn}); + if (!cfg.lili) { + op_attn = rw(b, RAD_OP(b, "attn_paged", + RAD_PARAMS(RAD_RANGE("q_len", 1, cfg.block), RAD_INT("head_dim", g.head_dim), + RAD_INT("gqa", g.gqa()), RAD_INT("causal", cfg.causal), + RAD_INT("window", cfg.window), RAD_INT("n_head", g.n_head), + RAD_INT("block_size", RAD_KV_BLOCK), + RAD_INT("max_seqs", g.max_seqs), RAD_INT("max_ctx", g.max_ctx), + RAD_STR("q_dtype", g.dtype), RAD_STR("kv_dtype", g.kv_dtype)), + RAD_NOWEIGHTS), + {w.q}, {w.attn}); + } else { + for (int64_t l = 0; l < g.n_layer; ++l) { + const int i = (int)l; + op_attn_sink[i] = rw(b, RAD_OP(b, "attn_paged_sink", + RAD_PARAMS(RAD_RANGE("q_len", 1, cfg.block), + RAD_INT("head_dim", g.head_dim), + RAD_INT("gqa", g.gqa()), RAD_INT("causal", cfg.causal), + RAD_INT("window", cfg.window), + RAD_INT("n_head", g.n_head), + RAD_INT("block_size", RAD_KV_BLOCK), + RAD_INT("max_seqs", g.max_seqs), + RAD_INT("max_ctx", g.max_ctx), + RAD_STR("q_dtype", g.dtype), + RAD_STR("kv_dtype", g.kv_dtype)), + RAD_WEIGHTS(w_sink[i])), + {w.q}, {w.attn}); + if (!op_attn_sink[i]) return RAD_E_INVAL; + } + } /* ---------------------------------------------------------------- the context pass */ /* Every linear is `fp8a8` (or `mxfp4a8` for a 4-bit recipe; DenseFP8 reads which from the @@ -555,12 +610,15 @@ inline int Dflash2::declare(RadBuilder* b, Names& nm, const Geom& geom, const Co if (fc_rows) { /* The split (SHARDING above): this rank's block-aligned rows into `cpart`, its window of * them gathered into `c`. The GEMM takes its K split from the whole width. The gather - * rides the trunk's all-reduce instance (the same numel bound, so the same instance). */ + * rides the trunk's all-reduce instance (the same numel bound, so the same instance). + * The message is a range, as the all-reduce's: a fixed numel follows max_tok, and the + * arena's sizing declare (RadBuildCtx::shape_probe) refuses a fixed parameter that + * changes with the step size. */ op_cfc = w_fc.gemm(b, crows, fc_rows, cfg.n_taps * g.n_embd, {w.srcq, w.srcs}, {w.cpart}, g.n_embd); op_cgath = rw(b, RAD_OP(b, "all_gather", RAD_PARAMS(RAD_INT("world_size", g.world), - RAD_INT("numel", crows * g.n_embd), + RAD_RANGE("numel", g.n_embd, crows * g.n_embd), RAD_STR("dtype", g.dtype), RAD_INT("row", fc_share)), RAD_NOWEIGHTS), {w.cpart}, {w.c}); @@ -884,6 +942,8 @@ inline int Dflash2::declare(RadBuilder* b, Names& nm, const Geom& geom, const Co RAD_STR("dtype", g.dtype)), RAD_NOWEIGHTS), {w.h}, {w.sel_h}); + /* LiLiCorr's head is the plugin's (rad_block_lilicorr.h), over sel_h. */ + if (cfg.lili) return RAD_OK; op_dquant = rw(b, RAD_OP(b, "quant_act_i8", RAD_PARAMS(RAD_RANGE("M", 1, srows), RAD_INT("n", g.n_embd), RAD_INT("group", DF_W2_GROUP), RAD_STR("dtype", g.dtype)), @@ -1090,7 +1150,8 @@ inline void Dflash2::context(RadCtx* c, const RadBatch* batch) const { if (fc_rows) { RAD_ISSUE_N(c, op_cfc, T, brows(w.srcq, T), brows(w.srcs, T), RAD_W(w_fc.w), RAD_W(w_fc.s), brows(w.cpart, T), RAD_NONE, w_fc.bref()); - RAD_ISSUE_N(c, op_cgath, T, bcol(w.cpart, fc_off, fc_share, T), brows(w.c, T)); + RAD_ISSUE_N(c, op_cgath, T * g.n_embd, bcol(w.cpart, fc_off, fc_share, T), + brows(w.c, T)); } else { RAD_ISSUE_N(c, op_cfc, T, brows(w.srcq, T), brows(w.srcs, T), RAD_W(w_fc.w), RAD_W(w_fc.s), brows(w.c, T), RAD_NONE, w_fc.bref()); @@ -1188,13 +1249,22 @@ inline void Dflash2::step(RadCtx* c, const RadBatch* batch) const { RAD_ISSUE_N(c, op_store, T, brows(w.k, T), brows(w.v, T), praw(slot, RAD_I32, T), kv_cache(kv, first_layer + i)); } - RAD_ISSUE_N(c, op_attn, batch->max_q_len, - brows(w.q, T), kv_cache(kv, first_layer + i), - praw2(table, RAD_I32, batch->n_seq, kvb ? kvb->block_table_pitch : 0), - praw(used, RAD_I32, batch->n_seq), - RAD_NONE, RAD_NONE, - praw(batch->cu_seqlens, RAD_I32, batch->n_seq + 1), - brows(w.attn, T)); + if (cfg.lili) + RAD_ISSUE_N(c, op_attn_sink[i], batch->max_q_len, + brows(w.q, T), kv_cache(kv, first_layer + i), + praw2(table, RAD_I32, batch->n_seq, kvb ? kvb->block_table_pitch : 0), + praw(used, RAD_I32, batch->n_seq), + RAD_NONE, RAD_NONE, + praw(batch->cu_seqlens, RAD_I32, batch->n_seq + 1), + RAD_W(w_sink[i]), brows(w.attn, T)); + else + RAD_ISSUE_N(c, op_attn, batch->max_q_len, + brows(w.q, T), kv_cache(kv, first_layer + i), + praw2(table, RAD_I32, batch->n_seq, kvb ? kvb->block_table_pitch : 0), + praw(used, RAD_I32, batch->n_seq), + RAD_NONE, RAD_NONE, + praw(batch->cu_seqlens, RAD_I32, batch->n_seq + 1), + brows(w.attn, T)); RAD_ISSUE_N(c, op_qat, T, brows(w.attn, T), brows(w.atq, T), brows(w.ats, T)); RAD_ISSUE_N(c, op_op[i], T, brows(w.atq, T), brows(w.ats, T), RAD_W(w_o[i].w), RAD_W(w_o[i].s), brows(w.h, T), RAD_NONE, w_o[i].bref()); @@ -1238,6 +1308,7 @@ inline void Dflash2::step(RadCtx* c, const RadBatch* batch) const { const int64_t S = batch->n_out; if (S <= 0) return; RAD_ISSUE_N(c, op_gather, S, RAD_B(w.h), praw(batch->out_ids, RAD_I32, S), brows(w.sel_h, S)); + if (cfg.lili) return; /* the plugin's correlator takes sel_h from here */ /* `dsum` is group-major, [n_embd/group][ceil(M/16)*16], so it has no row slice; pass it * whole. */ diff --git a/arch/common/rad_block_dspark_bf16.h b/arch/common/rad_block_dspark_bf16.h new file mode 100644 index 00000000..bab0e601 --- /dev/null +++ b/arch/common/rad_block_dspark_bf16.h @@ -0,0 +1,958 @@ +/* rad_block_dspark_bf16.h -- the DSpark drafter over bf16 weights, at the widths a Spark layer + * uses: a few plain attention layers that denoise a whole block of masked positions in one pass, + * conditioned on the trunk's residual stream at a handful of layers, with a rank-N Markov head + * over the target's own output table. + * + * ============================== WHY A SECOND DSPARK BLOCK ============================== + * + * rad_block_dspark.h is the same drafter shape for a block-fp8 release: its linears are DenseFP8 + * behind `quant_act_fp8`, its feed-forward is `silu_mul`, its norms carry q/k gains, and its draft + * head is a 2-bit copy of the target's. The published Spark drafts (`dflash` GGUFs, and the HF + * Spark drafter releases behind them) ship the other way: bf16 linears, no q/k norms, one sigmoid + * gate a head on the attention output, exact-erf GELU, one RMS gain per tap, and a sliding window. + * Those are different ops, not different parameters, so this block declares its own graph and + * uses an explicit anchor-window attention op and a full-vocabulary Markov selector so neither + * semantic distinction is silently folded into the generic per-row window or candidate-lattice ops. + * + * Nothing here is quantised. The drafter is 624M parameters read whole a draft pass, so bf16 costs + * 1.2 GiB of residency and one extra weight pass a step; quantising it is a separate measurement + * (it can only move acceptance, since every draft is verified by the target). + * + * ============================== THE FORWARD PASS ============================== + * + * The reference is llama.cpp's `llama_model_dflash::graph` (XHToken/llama.cpp + * 22c0ae1871b, the branch the Spark draft cards name), which mirrors the HF export: + * + * tap(l) = rmsnorm(residual after trunk layer l) * fc_norm[l] one gain row per tap + * ctx = rmsnorm(fc(concat_l tap(l))) hidden_norm + * per draft layer (x5): + * h_n = input_layernorm(h) + * q,k,v = q_proj/k_proj/v_proj(h_n); k_ctx, v_ctx = k_proj/v_proj(ctx) + * rope(q, k); attention over [the layer's context K/V, this block] non-causally, + * inside a `window` positions + * h += o_proj(sigmoid(g_proj(h)) * attn) one gate a head, no q/k norms + * h += mlp(post_attention_layernorm(h)) gelu(gate) * up, then down + * logits = target.lm_head(output_norm(h)) + markov_w2 @ markov_w1[prev] + * + * The two projections of `ctx` are the drafter's own k_proj and v_proj, one pair per layer, and + * they run over every committed token; the drafter's layers never see the context rows. That is + * the context pass below, and the block above is the query pass -- the same split + * rad_block_dspark.h makes, and the same `RAD_DRAFT_BLOCK` drive. + * + * ============================== THE TAPS ARE NORMED, NOT JUST READ ================== + * + * `fc_norm` is [n_taps, n_embd]: the residual entering each tap layer is normed with its own gain + * before the concatenation, so `fc` sees n_taps unit-scaled streams instead of one sum whose + * magnitudes the trunk happens to have. One `rmsnorm` per tap over that tap's column slice of the + * tap buffer, into the same slice layout of a normed copy; `fc` then reads one contiguous + * [n_taps * n_embd] row. + * + * ============================== THE SHARED ANCHOR WINDOW ========================== + * + * The pinned llama.cpp oracle increments the configured history from 512 to 513 and repeats the + * anchor row's mask for every row in the denoising block. `attn_paged_anchor_window` implements + * that exact predicate: every row sees keys through the end of the staged context whose absolute + * position is less than 513 behind the anchor. The query row does not move the lower cutoff. The + * same 513-token width is passed to the KV group and scheduler, so rollback, cache recycling and + * block staging all retain the exact history the drafter reads. + * + * ============================== ROW ALIGNMENT ============================== + * + * Every row predicts, the anchor included (`dflash.sample_from_anchor`, which the GGUF import + * refuses when false): row j of [anchor, MASK x (block-1)] proposes the token at the anchor's + * position plus j + 1, so `steps()` is `block` and the head runs over all the block's rows. The + * core stages the block against `RadDrafterDecl::block` and runs the head over the last `depth` + * rows, which covers this and Dflash2's shift-by-one convention (abi/rad_builder.h). + * + * ============================== THE MARKOV HEAD ============================== + * + * The draft logits get a learned bigram bias + * + * score[l, token] = logits[l, token] + markov_w2[token] . markov_w1[prev(l)] + * prev(0) = the anchor; prev(l) = the greedy token chosen at l - 1 + * + * `dflash_markov_greedy` scans the full vocabulary at every position and greedily chooses the + * largest biased score, following the structure of the pinned reference's serial Markov walk. + * Base logits are F32; reduction order and tie behavior can still differ from the reference. It + * does not prune to the base head's top K, use a joint-path heap, or apply confidence to logits. + * + * The confidence head (`conf_proj`, one sigmoid a position predicting acceptance) is imported and + * ignored: it exists to let a serving loop cut the block short, this engine's depth is fixed at + * declare, and it changes nothing the drafter proposes. + * + * ============================== PRECISION ============================== + * + * bf16 for every weight and activation except the residual stream, which is f32 exactly as the + * Spark trunk keeps it (rad_block_dspark.h's fp8 graphs fold the residual into the norm; here the + * norms read the f32 stream and write bf16, and `add` keeps the sum in f32). The reference runs + * bf16 weights against an f32 residual, so rounding the drafter's stream to bf16 would be a third + * opinion on every layer's output for no saved bytes worth having at `block` rows. + * + * ============================== NOT DONE ============================== + * + * The head and full-vocabulary Markov scan are read replicated, so a vocab-sharded deployment + * cannot draft with them. The plugin refuses `world > 1` rather than scoring only one rank's + * slice of the vocabulary. + * + * The drafter's linears are four GEMMs and one attention a layer with no folding: the norms are + * plain `rmsnorm`, not a fused norm-add-quantise, because nothing here quantises. At seven rows + * a pass the launches, not the bytes, are the cost. + */ +#ifndef RAD_BLOCK_DSPARK_BF16_H +#define RAD_BLOCK_DSPARK_BF16_H + +#include "rad_arch.h" + +namespace rad { +namespace arch { + +/* The builder refuses a declaration it cannot serve and says why in its own words; this names which + * handle did not come back, so that message reads against a line of this file. An op that resolves + * to no kernel is recorded and handed back null -- it is only an error if the block issues it -- so + * without this a missing kernel surfaces as a bare "invalid argument" at startup. */ +#define DS_REFUSED(...) ::rad::arch::drafter_refused({ __VA_ARGS__ }) +inline int drafter_refused(std::initializer_list what) { + std::string list; + for (const char* w : what) { if (!list.empty()) list += ", "; list += w; } + std::fprintf(stderr, "DSpark drafter: the builder gave no handle for %s\n", list.c_str()); + return RAD_E_INVAL; +} + +struct DsparkBF16 { + enum { MAX_LAYERS = 8 }; + + /* The drafter's config beyond its geometry. Everything here comes from the container's + * `draft.` keys; nothing is defaulted quietly, because a silently ignored gate or window only + * moves acceptance, which is the one number the user cannot see. */ + struct Config { + int64_t n_taps = 0; /* how many trunk layers `fc` concatenates */ + int64_t block = 0; /* noise rows a sequence, and drafts (one per row) */ + int64_t rank = 0; /* markov_rank: the codebooks' width */ + int64_t window = 0; /* reference's anchor-aligned n_swa (configured history + 1) */ + int64_t rot = 0; /* rotary dimensions a head; 0 for all of head_dim */ + int causal = 0; + int tap_norm = 0; /* `fc_norm`: one RMS gain a tap before the concatenation */ + int qk_norm = 0; /* per-head q/k gains, and no output gate */ + int gate = 0; /* one sigmoid gate a head on the attention output */ + const char* act = "gelu"; /* the feed-forward's activation */ + int64_t steps() const { return block; } /* every row predicts */ + }; + + struct Wire { + /* ---- the context pass, one row per committed token */ + rad_buf src = 0; /* [max_tok, n_taps * n_embd] the trunk's taps, read only */ + rad_buf srcn = 0; /* [max_tok, n_taps * n_embd] each tap normed, same layout */ + rad_buf c = 0, cn = 0; /* [max_tok, n_embd] fc output and separately normed context */ + rad_buf ck = 0, ckn = 0; /* [max_tok, kv_dim] projected and optionally normed K */ + rad_buf cv = 0; /* [max_tok, kv_dim] and its V */ + + /* ---- the query pass, `block` rows per sequence */ + rad_buf x = 0; /* [qrows, n_embd] f32 the drafter's residual stream */ + rad_buf delta = 0; /* [qrows, n_embd] f32 the block a projection just wrote */ + rad_buf h = 0; /* [qrows, n_embd] bf16 the normed stream, and every linear's output */ + rad_buf q = 0, k = 0, v = 0, qn = 0, kn = 0; + rad_buf gate = 0, gaten = 0; /* [qrows, n_head] projection and sigmoid */ + rad_buf attn = 0, attng = 0; /* [qrows, q_dim] attention and gated attention */ + rad_buf gate_up = 0; rad_buf ff = 0; + + /* ---- the head and the walk, one row per draft position */ + rad_buf dlog = 0; /* [srows, n_vocab] f32 full-vocabulary draft logits */ + rad_buf best_score = 0; /* [max_seqs, ceil(n_vocab/64)] f32 partial argmax scores */ + rad_buf best_token = 0; /* [max_seqs, ceil(n_vocab/64)] i32 partial argmax ids */ + rad_buf tokens = 0; /* [max_seqs, steps] i32 the draft; the engine reads it by name */ + }; + + Geom g{}; /* the drafter's geometry, not the trunk's */ + Config cfg{}; + Wire w{}; + int first_layer = 0; /* absolute, for the KV group's layer_slot lookup */ + int64_t qrows = 0, crows = 0, srows = 0; + rad_kvgroup kv = 0; + + /* ---- model-scope weights */ + rad_weight w_fc = 0, w_hnorm = 0, w_norm = 0; + rad_weight w_fcnorm[MAX_LAYERS] = {}; /* one row of `fc_norm` a tap */ + rad_weight w_mk1 = 0, w_mk2 = 0; /* markov_w1 (pred), markov_w2 (succ) */ + rad_weight w_tok = 0; /* the target's embedding table */ + rad_weight w_head = 0; /* the target's output table */ + + /* ---- per-layer weights */ + rad_weight w_anorm[MAX_LAYERS] = {}, w_fnorm[MAX_LAYERS] = {}; + rad_weight w_q[MAX_LAYERS] = {}, w_k[MAX_LAYERS] = {}, w_v[MAX_LAYERS] = {}, w_o[MAX_LAYERS] = {}; + rad_weight w_qn[MAX_LAYERS] = {}, w_kn[MAX_LAYERS] = {}, w_gate[MAX_LAYERS] = {}; + rad_weight w_gu[MAX_LAYERS] = {}, w_dn[MAX_LAYERS] = {}; + + /* ---- the context pass */ + rad_op op_tapn[MAX_LAYERS] = {}; /* one per tap, not per layer */ + rad_op op_cfc = 0, op_cnorm = 0; + rad_op op_ck[MAX_LAYERS] = {}, op_cv[MAX_LAYERS] = {}, op_cknorm[MAX_LAYERS] = {}; + rad_op op_crope = 0, op_cstore = 0; + + /* ---- the query pass. The weightless ops are declared once and issued per layer; the ones + * with weights are per layer, since a weight's prefetch interval and residency class come + * from the op that declares it. */ + rad_op op_embed = 0, op_widen = 0, op_add = 0; + rad_op op_anorm[MAX_LAYERS] = {}, op_fnorm[MAX_LAYERS] = {}, op_outnorm = 0; + rad_op op_qp[MAX_LAYERS] = {}, op_kp[MAX_LAYERS] = {}, op_vp[MAX_LAYERS] = {}; + rad_op op_qn[MAX_LAYERS] = {}, op_kn[MAX_LAYERS] = {}, op_gp[MAX_LAYERS] = {}; + rad_op op_op[MAX_LAYERS] = {}, op_gu[MAX_LAYERS] = {}, op_dn[MAX_LAYERS] = {}; + rad_op op_widen2 = 0, op_widen3 = 0; + rad_op op_qrope = 0, op_krope = 0, op_store = 0, op_attn = 0; + rad_op op_sig = 0, op_gate_heads = 0, op_act = 0; + + /* ---- the head and the walk */ + rad_op op_dlogits = 0, op_markov = 0; + + int declare(RadBuilder* b, Names& nm, const Geom& geom, const Config& c, int base_layer, + rad_kvgroup group, rad_weight tok_embd, const char* ck, const char* ck_head, + const Wire& wire); + /* The context pass, one row per committed token. */ + void context(RadCtx* c, const RadBatch* batch) const; + /* The query pass, the head and the Markov walk, `block` rows per sequence. */ + void step(RadCtx* c, const RadBatch* batch) const; + +private: + int64_t q_dim() const { return g.n_head * g.head_dim; } + int64_t kv_dim() const { return g.n_head_kv * g.head_dim; } +}; + +/* ------------------------------------------------------------------------------ declare */ + +inline int DsparkBF16::declare(RadBuilder* b, Names& nm, const Geom& geom, const Config& c, + int base_layer, rad_kvgroup group, rad_weight tok_embd, + const char* ck, const char* ck_head, const Wire& wire) { + g = geom; cfg = c; w = wire; first_layer = base_layer; kv = group; w_tok = tok_embd; + if (!ck || !ck_head || !w_tok) return DS_REFUSED("ck", "ck_head", "w_tok"); + if (g.n_layer <= 0 || g.n_layer > MAX_LAYERS) { + fprintf(stderr, "radiance: the bf16 DSpark drafter has %lld layers; this block carries at " + "most %d\n", (long long)g.n_layer, MAX_LAYERS); + return RAD_E_UNSUPPORTED; + } + if (cfg.n_taps <= 0 || cfg.n_taps > MAX_LAYERS || cfg.block < 2 || cfg.rank <= 0) + return RAD_E_INVAL; + if (cfg.qk_norm && cfg.gate) { + fprintf(stderr, "radiance: the drafter declares both per-head q/k norms and a per-head " + "output gate; no published drafter ships both, and this block would have " + "to guess which one the checkpoint trained with\n"); + return RAD_E_UNSUPPORTED; + } + /* The full-vocabulary head and Markov scan are read replicated; partial-vocabulary drafting + * would need an exact distributed argmax and replicated codebook access. */ + if (g.world > 1) { + fprintf(stderr, "radiance: the bf16 DSpark drafter reads the target's whole output table " + "and cannot draft at tp %d; run it at tp 1\n", g.world); + return RAD_E_UNSUPPORTED; + } + + const int64_t qd = q_dim(), kvd = kv_dim(), E = g.n_embd; + crows = g.max_tok; + qrows = g.max_seqs * cfg.block; + if (qrows > g.max_tok) qrows = g.max_tok; + srows = g.max_seqs * cfg.steps(); /* every row predicts */ + if (qrows <= 0 || srows <= 0 || cfg.rot < 0 || cfg.rot > g.head_dim || cfg.rot % 2) + return RAD_E_INVAL; + const int64_t rot = cfg.rot ? cfg.rot : g.head_dim; + + /* One op declaration per kernel shape, shared by the layers: `rmsnorm`'s and `gemm_nt`'s + * parameters are geometry, and only the weights differ per layer. */ + auto gemm = [&](int64_t rows, int64_t n, int64_t k, rad_weight wt, rad_buf x, rad_buf y) { + return rw(b, RAD_OP(b, "gemm_nt", + RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("N", n), + RAD_INT("K", k), RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(wt)), + {x}, {y}); + }; + + /* ---------------------------------------------------------------- model-scope weights */ + RAD_ARCH_TRY(map_copy(b, nm.f("dspark.fc.weight"), nm.ckpt("%s.fc.weight", ck))); + w_fc = decl_w(b, nm.f("dspark.fc.weight"), RAD_BF16, {E, cfg.n_taps * E}, + RAD_ACCESS_PER_TOKEN, RAD_SHARD_NONE, grp_model()); + RAD_ARCH_TRY(map_copy(b, nm.f("dspark.hidden_norm.weight"), + nm.ckpt("%s.hidden_norm.weight", ck))); + w_hnorm = decl_w(b, nm.f("dspark.hidden_norm.weight"), RAD_BF16, {E}, + RAD_ACCESS_PER_TOKEN, RAD_SHARD_NONE, grp_model()); + RAD_ARCH_TRY(map_copy(b, nm.f("dspark.norm.weight"), nm.ckpt("%s.norm.weight", ck))); + w_norm = decl_w(b, nm.f("dspark.norm.weight"), RAD_BF16, {E}, + RAD_ACCESS_PER_TOKEN, RAD_SHARD_NONE, grp_model()); + if (!w_fc || !w_hnorm || !w_norm) return DS_REFUSED("w_fc", "w_hnorm", "w_norm"); + + /* `fc_norm` is [n_taps, n_embd]: one gain row a tap, read as that tap's slice. */ + if (cfg.tap_norm) { + const char* src = nm.ckpt("%s.fc_norm.weight", ck); + for (int64_t t = 0; t < cfg.n_taps; ++t) { + const int i = (int)t; + RAD_ARCH_TRY(map_rows(b, nm.f("dspark.fc_norm.%d.weight", i), + { { src, (int)t, 1 } })); + w_fcnorm[i] = decl_w(b, nm.f("dspark.fc_norm.%d.weight", i), RAD_BF16, {E}, + RAD_ACCESS_PER_TOKEN, RAD_SHARD_NONE, grp_model()); + if (!w_fcnorm[i]) return DS_REFUSED("w_fcnorm[i]"); + } + } + + /* The Markov codebooks, bf16, replicated over the whole vocabulary: both are [vocab, rank], so + * `w2 @ w1[prev]` is ``. RAD_ACCESS_VOCAB: each walk position reads one + * predecessor row and scans every successor row. */ + RAD_ARCH_TRY(map_copy(b, nm.f("dspark.markov_w1"), + nm.ckpt("%s.markov_head.markov_w1.weight", ck))); + RAD_ARCH_TRY(map_copy(b, nm.f("dspark.markov_w2"), + nm.ckpt("%s.markov_head.markov_w2.weight", ck))); + w_mk1 = decl_w(b, nm.f("dspark.markov_w1"), RAD_BF16, {g.n_vocab_all, cfg.rank}, + RAD_ACCESS_VOCAB, RAD_SHARD_NONE, grp_model()); + w_mk2 = decl_w(b, nm.f("dspark.markov_w2"), RAD_BF16, {g.n_vocab_all, cfg.rank}, + RAD_ACCESS_VOCAB, RAD_SHARD_NONE, grp_model()); + if (!w_mk1 || !w_mk2) return DS_REFUSED("w_mk1", "w_mk2"); + + /* The target's output table under the drafter's own name: one stored tensor, two arch weights, + * as rad_block_dspark.h does for its 2-bit copy. bf16 and replicated here, since the drafter + * reads it as the head its full-vocabulary walk scores (see NOT DONE for sharding). */ + RAD_ARCH_TRY(map_copy(b, nm.f("dspark.head.weight"), ck_head)); + w_head = decl_w(b, nm.f("dspark.head.weight"), RAD_BF16, {g.n_vocab_all, E}, + RAD_ACCESS_VOCAB, RAD_SHARD_NONE, grp_model()); + if (!w_head) return DS_REFUSED("w_head"); + + /* ---------------------------------------------------------------- per-layer weights + * + * One name map and one declaration a weight, spelled out: the list is the readable form of + * which checkpoint tensor feeds which matmul, and a drafter has few enough of them that a + * table would only hide it. */ + for (int64_t l = 0; l < g.n_layer; ++l) { + const int i = (int)l; + const RadWeightGroup grp = grp_layer(first_layer + i); + + /* A norm gain: f32, read whole, never sharded. */ + auto norm_w = [&](rad_weight* out, const char* suffix, const char* from, + std::initializer_list shape) -> int { + const char* name = nm.f("dspark.blk.%d.%s", i, suffix); + RAD_ARCH_TRY(map_copy(b, name, nm.ckpt("%s.layers.%d.%s", ck, i, from))); + *out = decl_w(b, name, RAD_BF16, shape, RAD_ACCESS_PER_TOKEN, RAD_SHARD_NONE, grp); + return *out ? RAD_OK : RAD_E_INVAL; + }; + /* A linear: bf16. More than one source is a concatenation, whose row parts say where each + * piece begins (RadWeightDecl::row_parts), so `act_mul` can read [gate | up] as one + * weight. */ + auto lin_w = [&](rad_weight* out, const char* suffix, + std::initializer_list srcs, + std::initializer_list shape, + std::initializer_list parts = {}) -> int { + const char* name = nm.f("dspark.blk.%d.%s", i, suffix); + if (srcs.size() > 1) RAD_ARCH_TRY(map_concat(b, name, srcs)); + else RAD_ARCH_TRY(map_copy(b, name, *srcs.begin())); + *out = decl_w(b, name, RAD_BF16, shape, RAD_ACCESS_PER_TOKEN, RAD_SHARD_NONE, grp, 0, + parts); + return *out ? RAD_OK : RAD_E_INVAL; + }; + +#define SRC(path) nm.ckpt("%s.layers.%d." path, ck, i) + RAD_ARCH_TRY(norm_w(&w_anorm[i], "attn_norm.weight", "input_layernorm.weight", {E})); + RAD_ARCH_TRY(norm_w(&w_fnorm[i], "ffn_norm.weight", "post_attention_layernorm.weight", {E})); + RAD_ARCH_TRY(lin_w(&w_q[i], "attn_q", { SRC("self_attn.q_proj.weight") }, {qd, E})); + RAD_ARCH_TRY(lin_w(&w_k[i], "attn_k", { SRC("self_attn.k_proj.weight") }, {kvd, E})); + RAD_ARCH_TRY(lin_w(&w_v[i], "attn_v", { SRC("self_attn.v_proj.weight") }, {kvd, E})); + RAD_ARCH_TRY(lin_w(&w_o[i], "attn_output", { SRC("self_attn.o_proj.weight") }, {E, qd})); + RAD_ARCH_TRY(lin_w(&w_gu[i], "ffn_gate_up", + { SRC("mlp.gate_proj.weight"), SRC("mlp.up_proj.weight") }, + {2 * g.n_ff, E}, { g.n_ff, g.n_ff })); + RAD_ARCH_TRY(lin_w(&w_dn[i], "ffn_down", { SRC("mlp.down_proj.weight") }, + {E, g.n_ff})); + if (cfg.gate) + RAD_ARCH_TRY(lin_w(&w_gate[i], "attn_gate", { SRC("self_attn.g_proj.weight") }, + {g.n_head, E})); + if (cfg.qk_norm) { + RAD_ARCH_TRY(norm_w(&w_qn[i], "attn_q_norm.weight", "self_attn.q_norm.weight", + {g.head_dim})); + RAD_ARCH_TRY(norm_w(&w_kn[i], "attn_k_norm.weight", "self_attn.k_norm.weight", + {g.head_dim})); + } +#undef SRC + } + + /* Non-causal: every query row sees its whole block and the context the trunk committed + * (`causal` comes from `draft.is_causal`). Declared before both kv_stores, which read the + * resolved `block_size` back with rad_kv_block_size(); before it, that returns zero. */ + op_attn = rw(b, RAD_OP(b, cfg.window > 0 ? "attn_paged_anchor_window" : "attn_paged", + RAD_PARAMS(RAD_RANGE("q_len", 1, cfg.block), RAD_INT("head_dim", g.head_dim), + RAD_INT("gqa", g.gqa()), RAD_INT("causal", cfg.causal), + RAD_INT("window", cfg.window), RAD_INT("n_head", g.n_head), + RAD_INT("block_size", RAD_KV_BLOCK), + RAD_INT("max_seqs", g.max_seqs), RAD_INT("max_ctx", g.max_ctx), + RAD_STR("q_dtype", "bf16"), RAD_STR("kv_dtype", g.kv_dtype)), + RAD_NOWEIGHTS), + {cfg.qk_norm ? w.qn : w.q}, {w.attn}); + if (!op_attn) return DS_REFUSED("op_attn"); + + /* ---------------------------------------------------------------- the context pass + * + * One row per committed token, run once per trunk step: the taps become the drafter's own K + * and V. Nothing here is per query row, so its cost follows the trunk's token count, not the + * block's. */ + for (int64_t t = 0; t < cfg.n_taps; ++t) { + const int i = (int)t; + op_tapn[i] = rw(b, RAD_OP(b, "rmsnorm", + RAD_PARAMS(RAD_RANGE("M", 1, crows), RAD_INT("n", E), + RAD_F64("eps", g.eps), RAD_F64("wadd", 0.0), + RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(w_fcnorm[i])), + {w.src}, {w.srcn}); + if (!op_tapn[i]) return DS_REFUSED("op_tapn[i]"); + } + op_cfc = gemm(crows, E, cfg.n_taps * E, w_fc, w.srcn, w.c); + op_cnorm = rw(b, RAD_OP(b, "rmsnorm", + RAD_PARAMS(RAD_RANGE("M", 1, crows), RAD_INT("n", E), + RAD_F64("eps", g.eps), RAD_F64("wadd", 0.0), + RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(w_hnorm)), + {w.c}, {w.cn}); + if (!op_cfc || !op_cnorm) return DS_REFUSED("op_cfc", "op_cnorm"); + + for (int64_t l = 0; l < g.n_layer; ++l) { + const int i = (int)l; + /* One op per weight: an op's declared weight list gives each weight its prefetch interval + * and residency class. */ + op_ck[i] = gemm(crows, kvd, E, w_k[i], w.cn, w.ck); + op_cv[i] = gemm(crows, kvd, E, w_v[i], w.cn, w.cv); + if (!op_ck[i] || !op_cv[i]) return DS_REFUSED("op_ck[i]", "op_cv[i]"); + if (cfg.qk_norm) { + op_cknorm[i] = rw(b, RAD_OP(b, "rmsnorm", + RAD_PARAMS(RAD_RANGE("M", 1, crows * g.n_head_kv), + RAD_INT("n", g.head_dim), + RAD_F64("eps", g.eps), RAD_F64("wadd", 0.0), + RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(w_kn[i])), + {w.ck}, {w.ckn}); + if (!op_cknorm[i]) return DS_REFUSED("op_cknorm[i]"); + } + } + + /* K-only rope: `rope` rotates the first n_head + n_head_kv heads, so a K-only tensor is + * n_head = n_head_kv, n_head_kv = 0. Weightless, so one op serves every layer. Each context + * row is rotated by its own absolute position, as the reference's single concatenated rope + * does. */ + op_crope = rw(b, decl_rope(b, g, crows, g.head_dim, g.n_head_kv, 0, rot, "neox"), + {cfg.qk_norm ? w.ckn : w.ck}, {cfg.qk_norm ? w.ckn : w.ck}); + op_cstore = rw(b, RAD_OP(b, "kv_store", + RAD_PARAMS(RAD_RANGE("M", 1, crows), RAD_INT("head_dim", g.head_dim), + RAD_INT("n_head_kv", g.n_head_kv), + RAD_INT("block_size", rad_kv_block_size(b, kv)), + RAD_STR("kv_dtype", g.kv_dtype)), + RAD_NOWEIGHTS), + {cfg.qk_norm ? w.ckn : w.ck, w.cv}, {}); + if (!op_crope || !op_cstore) return DS_REFUSED("op_crope", "op_cstore"); + + /* ---------------------------------------------------------------- the query pass + * + * `block` rows per sequence, through the drafter's layers. The residual stream is f32 and the + * linears read bf16, exactly as the trunk keeps them: `rmsnorm` reads the stream and writes the + * activations, `cast` widens a projection's output, and `add` keeps the sum in f32. */ + op_embed = rw(b, RAD_OP(b, "embed_lookup", + RAD_PARAMS(RAD_RANGE("M", 1, qrows), RAD_INT("n_embd", E), + RAD_INT("n_vocab", g.n_vocab), RAD_STR("dtype", "bf16"), + RAD_INT("vocab_offset", g.vocab_off)), + RAD_WEIGHTS(w_tok)), + {}, {w.h}); + op_widen = rw(b, RAD_OP(b, "cast", + RAD_PARAMS(RAD_RANGE("M", 1, qrows), RAD_INT("n", E), + RAD_STR("from", "bf16"), RAD_STR("to", "f32")), + RAD_NOWEIGHTS), + {w.h}, {w.x}); + /* One widen and one add serve both residual sites a layer: same shapes, same buffers. */ + op_widen2 = rw(b, RAD_OP(b, "cast", + RAD_PARAMS(RAD_RANGE("M", 1, qrows), RAD_INT("n", E), + RAD_STR("from", "bf16"), RAD_STR("to", "f32")), + RAD_NOWEIGHTS), + {w.h}, {w.delta}); + op_add = rw(b, RAD_OP(b, "add", + RAD_PARAMS(RAD_RANGE("M", 1, qrows), RAD_INT("n", E), + RAD_STR("dtype", "f32")), + RAD_NOWEIGHTS), + {w.x, w.delta}, {w.x}); + if (!op_embed || !op_widen || !op_widen2 || !op_add) + return DS_REFUSED("op_embed", "op_widen", "op_widen2", "op_add"); + + /* Invariant: the norms are declared where step() issues them. Declaration order is the buffer + * planner's liveness (core/build/rad_bufplan.cpp), and the stream `x` lives over the ops that + * touch it: each layer's two norms in the loop, the final one after everything the layers + * issue. Declared up front, the stream's lifetime would end before the layers and the planner + * could overlay a feed-forward temporary on it. */ + for (int64_t l = 0; l < g.n_layer; ++l) { + const int i = (int)l; + op_anorm[i] = rw(b, RAD_OP(b, "rmsnorm", + RAD_PARAMS(RAD_RANGE("M", 1, qrows), RAD_INT("n", E), + RAD_F64("eps", g.eps), RAD_F64("wadd", 0.0), + RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(w_anorm[i])), + {w.x}, {w.h}); + op_qp[i] = gemm(qrows, qd, E, w_q[i], w.h, w.q); + op_kp[i] = gemm(qrows, kvd, E, w_k[i], w.h, w.k); + op_vp[i] = gemm(qrows, kvd, E, w_v[i], w.h, w.v); + op_op[i] = gemm(qrows, E, qd, w_o[i], cfg.gate ? w.attng : w.attn, w.h); + op_fnorm[i] = rw(b, RAD_OP(b, "rmsnorm", + RAD_PARAMS(RAD_RANGE("M", 1, qrows), RAD_INT("n", E), + RAD_F64("eps", g.eps), RAD_F64("wadd", 0.0), + RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(w_fnorm[i])), + {w.x}, {w.h}); + op_gu[i] = gemm(qrows, 2 * g.n_ff, E, w_gu[i], w.h, w.gate_up); + op_dn[i] = gemm(qrows, E, g.n_ff, w_dn[i], w.ff, w.h); + if (!op_anorm[i] || !op_qp[i] || !op_kp[i] || !op_vp[i] || !op_op[i] || !op_fnorm[i] || + !op_gu[i] || !op_dn[i]) + return RAD_E_INVAL; + if (cfg.qk_norm) { + op_qn[i] = rw(b, RAD_OP(b, "rmsnorm", + RAD_PARAMS(RAD_RANGE("M", 1, qrows * g.n_head), + RAD_INT("n", g.head_dim), RAD_F64("eps", g.eps), + RAD_F64("wadd", 0.0), RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(w_qn[i])), + {w.q}, {w.qn}); + op_kn[i] = rw(b, RAD_OP(b, "rmsnorm", + RAD_PARAMS(RAD_RANGE("M", 1, qrows * g.n_head_kv), + RAD_INT("n", g.head_dim), RAD_F64("eps", g.eps), + RAD_F64("wadd", 0.0), RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(w_kn[i])), + {w.k}, {w.kn}); + if (!op_qn[i] || !op_kn[i]) return DS_REFUSED("op_qn[i]", "op_kn[i]"); + } + if (cfg.gate) { + op_gp[i] = gemm(qrows, g.n_head, E, w_gate[i], w.h, w.gate); + if (!op_gp[i]) return DS_REFUSED("op_gp[i]"); + } + } + + op_qrope = rw(b, decl_rope(b, g, qrows, g.head_dim, g.n_head, 0, rot, "neox"), + {cfg.qk_norm ? w.qn : w.q}, {cfg.qk_norm ? w.qn : w.q}); + op_krope = rw(b, decl_rope(b, g, qrows, g.head_dim, g.n_head_kv, 0, rot, "neox"), + {cfg.qk_norm ? w.kn : w.k}, {cfg.qk_norm ? w.kn : w.k}); + op_store = rw(b, RAD_OP(b, "kv_store", + RAD_PARAMS(RAD_RANGE("M", 1, qrows), RAD_INT("head_dim", g.head_dim), + RAD_INT("n_head_kv", g.n_head_kv), + RAD_INT("block_size", rad_kv_block_size(b, kv)), + RAD_STR("kv_dtype", g.kv_dtype)), + RAD_NOWEIGHTS), + {cfg.qk_norm ? w.kn : w.k, w.v}, {}); + /* The gate the trunk uses too: one sigmoid a head, then one scale a head's whole row. */ + if (cfg.gate) { + op_sig = rw(b, RAD_OP(b, "sigmoid", + RAD_PARAMS(RAD_RANGE("M", 1, qrows), RAD_INT("n", g.n_head), + RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + {w.gate}, {w.gaten}); + op_gate_heads = rw(b, RAD_OP(b, "scale_rows", + RAD_PARAMS(RAD_RANGE("M", 1, qrows * g.n_head), + RAD_INT("n", g.head_dim), RAD_STR("act", "none"), + RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + {w.attn, w.gaten}, {w.attng}); + if (!op_sig || !op_gate_heads) return DS_REFUSED("op_sig", "op_gate_heads"); + } + /* `act_mul` with the activation the drafter was trained with: exact-erf gelu for the Spark + * drafts (`hidden_activation: gelu`), silu for a Qwen3-shaped one. `gelu_mul` is the tanh + * approximation and is not what the reference runs. */ + op_act = rw(b, RAD_OP(b, "act_mul", + RAD_PARAMS(RAD_RANGE("M", 1, qrows), RAD_INT("n", g.n_ff), + RAD_STR("act", cfg.act), RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + {w.gate_up}, {w.ff}); + op_outnorm = rw(b, RAD_OP(b, "rmsnorm", + RAD_PARAMS(RAD_RANGE("M", 1, qrows), RAD_INT("n", E), + RAD_F64("eps", g.eps), RAD_F64("wadd", 0.0), + RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(w_norm)), + {w.x}, {w.h}); + if (!op_qrope || !op_krope || !op_store || !op_act || !op_outnorm) + return DS_REFUSED("op_qrope", "op_krope", "op_store", "op_act", "op_outnorm"); + + /* ---------------------------------------------------------------- the head and full-vocabulary walk + * + * Every row predicts, so the head scores all `steps` rows, anchor included. The row order is + * sequence-major, which is the selector's [sequence, position, vocabulary] contract. The + * greedy Markov op scans all vocabulary entries at every position and feeds each winning id + * into the next position's bigram bias. + */ + op_dlogits = rw(b, RAD_OP(b, "logits_gemm", + RAD_PARAMS(RAD_RANGE("M", 1, srows), RAD_INT("n_vocab", g.n_vocab), + RAD_INT("n_embd", E), RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(w_head)), + {w.h}, {w.dlog}); + op_markov = rw(b, RAD_OP(b, "dflash_markov_greedy_f32", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_seqs), + RAD_INT("steps", cfg.steps()), RAD_INT("rank", cfg.rank), + RAD_INT("n_vocab", g.n_vocab_all), + RAD_INT("anchor_stride", cfg.block), + RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(w_mk1, w_mk2)), + {w.dlog}, {w.best_score, w.best_token, w.tokens}); + if (!op_dlogits || !op_markov) return DS_REFUSED("op_dlogits", "op_markov"); + + return RAD_OK; +} + +/* ------------------------------------------------------------------------------ the context pass */ + +inline void DsparkBF16::context(RadCtx* c, const RadBatch* batch) const { + const int64_t T = batch->n_tok; + if (T <= 0) return; + const RadKVGroupBatch* kvb = kv_batch(batch, kv); + const int32_t* slot = kvb ? kvb->slot_mapping : nullptr; + const int64_t E = g.n_embd; + + /* Each tap's slice of the residual the trunk just tapped, normed with its own gain into the + * same slice layout of one row-per-token buffer. */ + for (int64_t t = 0; t < cfg.n_taps; ++t) { + const int i = (int)t; + if (!cfg.tap_norm) continue; + RAD_ISSUE_N(c, op_tapn[i], T, bcol(w.src, t * E, E, T), RAD_W(w_fcnorm[i]), + bcol(w.srcn, t * E, E, T)); + } + RAD_ISSUE_N(c, op_cfc, T, cfg.tap_norm ? brows(w.srcn, T) : brows(w.src, T), RAD_W(w_fc), + brows(w.c, T)); + RAD_ISSUE_N(c, op_cnorm, T, brows(w.c, T), RAD_W(w_hnorm), brows(w.cn, T)); + + for (int64_t l = 0; l < g.n_layer; ++l) { + const int i = (int)l; + RAD_ISSUE_N(c, op_ck[i], T, brows(w.cn, T), RAD_W(w_k[i]), brows(w.ck, T)); + RAD_ISSUE_N(c, op_cv[i], T, brows(w.cn, T), RAD_W(w_v[i]), brows(w.cv, T)); + if (cfg.qk_norm) + RAD_ISSUE_N(c, op_cknorm[i], T * g.n_head_kv, brows(w.ck, T), RAD_W(w_kn[i]), + brows(w.ckn, T)); + RAD_ISSUE_N(c, op_crope, T, brows(cfg.qk_norm ? w.ckn : w.ck, T), praw(batch->positions, RAD_I32, T)); + RAD_ISSUE_N(c, op_cstore, T, brows(cfg.qk_norm ? w.ckn : w.ck, T), brows(w.cv, T), + praw(slot, RAD_I32, T), kv_cache(kv, first_layer + i)); + } +} + +/* ------------------------------------------------------------------------------ the query pass */ + +inline void DsparkBF16::step(RadCtx* c, const RadBatch* batch) const { + const int64_t T = batch->n_tok; + if (T <= 0) return; + const RadKVGroupBatch* kvb = kv_batch(batch, kv); + const int32_t* slot = kvb ? kvb->slot_mapping : nullptr; + const int32_t* table = kvb ? kvb->block_table : nullptr; + const int32_t* used = kvb ? kvb->seqused : nullptr; + const RadOperand pos = praw(batch->positions, RAD_I32, T); + + /* The block the core staged: the token the sampler just chose, then the mask token in every + * unfilled slot. */ + RAD_ISSUE_N(c, op_embed, T, praw(batch->token_ids, RAD_I32, T), RAD_W(w_tok), brows(w.h, T)); + RAD_ISSUE_N(c, op_widen, T, brows(w.h, T), brows(w.x, T)); + + for (int64_t l = 0; l < g.n_layer; ++l) { + const int i = (int)l; + + RAD_ISSUE_N(c, op_anorm[i], T, brows(w.x, T), RAD_W(w_anorm[i]), brows(w.h, T)); + RAD_ISSUE_N(c, op_qp[i], T, brows(w.h, T), RAD_W(w_q[i]), brows(w.q, T)); + RAD_ISSUE_N(c, op_kp[i], T, brows(w.h, T), RAD_W(w_k[i]), brows(w.k, T)); + RAD_ISSUE_N(c, op_vp[i], T, brows(w.h, T), RAD_W(w_v[i]), brows(w.v, T)); + if (cfg.qk_norm) { + RAD_ISSUE_N(c, op_qn[i], T * g.n_head, brows(w.q, T), RAD_W(w_qn[i]), brows(w.qn, T)); + RAD_ISSUE_N(c, op_kn[i], T * g.n_head_kv, brows(w.k, T), RAD_W(w_kn[i]), + brows(w.kn, T)); + } + RAD_ISSUE_N(c, op_qrope, T, brows(cfg.qk_norm ? w.qn : w.q, T), pos); + RAD_ISSUE_N(c, op_krope, T, brows(cfg.qk_norm ? w.kn : w.k, T), pos); + /* The block's own K and V go into the cache past `seqused`, which is how every row of the + * block attends to every other; the next context pass overwrites them, which is the + * reference's `crop(start)`. */ + RAD_ISSUE_N(c, op_store, T, brows(cfg.qk_norm ? w.kn : w.k, T), brows(w.v, T), praw(slot, RAD_I32, T), + kv_cache(kv, first_layer + i)); + RAD_ISSUE_N(c, op_attn, batch->max_q_len, brows(cfg.qk_norm ? w.qn : w.q, T), kv_cache(kv, first_layer + i), + praw2(table, RAD_I32, batch->n_seq, kvb ? kvb->block_table_pitch : 0), + praw(used, RAD_I32, batch->n_seq), RAD_NONE, RAD_NONE, + praw(batch->cu_seqlens, RAD_I32, batch->n_seq + 1), brows(w.attn, T)); + if (cfg.gate) { + /* One gate a head, applied to that head's whole row of the attention output, before + * o_proj. View [rows, heads * dim] and [rows, heads] as one row a head. */ + RAD_ISSUE_N(c, op_gp[i], T, brows(w.h, T), RAD_W(w_gate[i]), brows(w.gate, T)); + RAD_ISSUE_N(c, op_sig, T, brows(w.gate, T), brows(w.gaten, T)); + const RadOperand heads = RAD_P_T2(rad_buf_ptr(c, w.attn), RAD_BF16, T * g.n_head, + g.head_dim); + const RadOperand gates = RAD_P_T2(rad_buf_ptr(c, w.gaten), RAD_BF16, T * g.n_head, 1); + const RadOperand gated = RAD_P_T2(rad_buf_ptr(c, w.attng), RAD_BF16, T * g.n_head, + g.head_dim); + RAD_ISSUE_N(c, op_gate_heads, T * g.n_head, heads, gates, RAD_NONE, gated); + } + RAD_ISSUE_N(c, op_op[i], T, brows(cfg.gate ? w.attng : w.attn, T), RAD_W(w_o[i]), brows(w.h, T)); + RAD_ISSUE_N(c, op_widen2, T, brows(w.h, T), brows(w.delta, T)); + RAD_ISSUE_N(c, op_add, T, brows(w.x, T), brows(w.delta, T), brows(w.x, T)); + + RAD_ISSUE_N(c, op_fnorm[i], T, brows(w.x, T), RAD_W(w_fnorm[i]), brows(w.h, T)); + RAD_ISSUE_N(c, op_gu[i], T, brows(w.h, T), RAD_W(w_gu[i]), brows(w.gate_up, T)); + RAD_ISSUE_N(c, op_act, T, bcol(w.gate_up, 0, g.n_ff, T), + bcol(w.gate_up, g.n_ff, g.n_ff, T), brows(w.ff, T)); + RAD_ISSUE_N(c, op_dn[i], T, brows(w.ff, T), RAD_W(w_dn[i]), brows(w.h, T)); + RAD_ISSUE_N(c, op_widen2, T, brows(w.h, T), brows(w.delta, T)); + RAD_ISSUE_N(c, op_add, T, brows(w.x, T), brows(w.delta, T), brows(w.x, T)); + } + + RAD_ISSUE_N(c, op_outnorm, T, brows(w.x, T), RAD_W(w_norm), brows(w.h, T)); + + /* The predicting rows, named by the scheduler through `out_ids`. */ + const int64_t S = batch->n_out; + if (S <= 0) return; + RAD_ISSUE_N(c, op_dlogits, S, brows(w.h, S), RAD_W(w_head), brows(w.dlog, S)); + RAD_ISSUE_N(c, op_markov, batch->n_seq, brows(w.dlog, S), + praw(batch->token_ids, RAD_I32, T), RAD_W(w_mk1), RAD_W(w_mk2), + brows(w.best_score, batch->n_seq), brows(w.best_token, batch->n_seq), + brows(w.tokens, batch->n_seq)); +} + +/* ================================================================== the trunk's side of it + * + * The taps, and one call a target plugin makes to put a drafter on. Both live here because both + * are the drafter's contract with the trunk: which residual streams it reads, where its blocks + * live, and how deep a proposal it makes. */ + +/* The residual streams a drafter reads, captured as the trunk passes them. */ +struct DsparkTaps { + enum { MAX_TAPS = DsparkBF16::MAX_LAYERS }; + + int n = 0; + int layer[MAX_TAPS] = {}; /* the trunk layer whose OUTPUT is tapped */ + rad_buf src = 0; /* [rows, n * n_embd] f32, one column slice a tap */ + rad_op op = 0; /* the residual stream, copied into that slice */ + + /* Read `draft.target_layer_ids`, which names the layers whose output is tapped. Zero taps when + * the container carries no drafter, or one that reads no trunk stream. Out-of-range ids are + * dropped, not clamped: a drafter naming a layer this model lacks belongs to another target. */ + int read(const RadModelMeta* meta, int64_t n_layer) { + n = 0; + const char* ids = rad_meta_gets(meta, "draft.target_layer_ids", nullptr); + if (!ids) ids = rad_meta_gets(meta, "draft.dflash_config.target_layer_ids", nullptr); + if (!ids) ids = rad_meta_gets(meta, "draft.gguf_target_layers", nullptr); + n = parse_layer_ids(ids, n_layer, layer, MAX_TAPS); + return n; + } + + /* The copy that saves a tap. A drafter reads the trunk's own residual stream, which is f32 + * here and stays f32: the widening the fp8 graphs do is theirs, not this one's. */ + int declare(RadBuilder* b, Names& nm, const Geom& g, int64_t rows, rad_buf residual) { + if (n <= 0) return RAD_OK; + src = decl_b(b, nm.f("draft_src"), RAD_F32, {rows, (int64_t)n * g.n_embd}); + if (!src) return DS_REFUSED("src"); + /* Declared over the trunk's own residual buffer: the op's operand pair is the stream and a + * tap's slice, and every issue site passes the slice it is writing. */ + op = rw(b, RAD_OP(b, "cast", + RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("n", g.n_embd), + RAD_STR("from", "f32"), RAD_STR("to", "f32")), + RAD_NOWEIGHTS), + {residual}, {src}); + return op ? RAD_OK : RAD_E_INVAL; + } + + /* The tap that follows trunk layer `l`, if any. Issued on prefill and decode alike: the + * drafter conditions on every committed token's residual stream. */ + void step(RadCtx* c, rad_buf residual, int64_t rows, int64_t l, int64_t n_embd) const { + if (!op) return; + for (int t = 0; t < n; ++t) + if (layer[t] == l) + RAD_ISSUE(c, op, brows(residual, rows), + bcol(src, (int64_t)t * n_embd, n_embd, rows)); + } +}; + +/* Put a DSpark drafter on a trunk: its config from the container's `draft.` keys, its own KV + * group, its graph, and the drafter declaration the core drives. `base_layer` is the absolute + * layer its first block takes, one past the trunk's last. + * + * Nothing is defaulted quietly. A `draft.` key that describes a drafter this file does not + * implement is refused by name, because a silently ignored gate, window or block length only moves + * acceptance -- the one number a user cannot see in the output. + * + * The plugin calls it last, after its own head and logits: a drafter's passes run after the whole + * trunk, and the buffer planner lays an op's lifetimes out in declaration order, so declaring it + * earlier would let a trunk temporary land on the stream the drafter is still reading. */ +inline int declare_dspark(DsparkBF16* ds, DsparkBF16::Wire* w, rad_kvgroup* kv, RadBuilder* b, + Names& nm, const RadModelMeta* meta, const RadBuildCtx* ctx, + const Geom& target, const DsparkTaps& taps, int base_layer, + rad_weight tok_embd, const char* ck_head) { + Geom dg{}; + RAD_ARCH_TRY(drafter_geom(dg, target, meta, "DSpark")); + /* The width the drafter concatenates and projects is the trunk's, and `drafter_geom` keeps the + * target's -- so a draft that disagrees is a draft for another model, and its `fc` would be + * read at a shape it was not trained at. */ + const int64_t want_embd = rad_meta_geti(meta, "draft.hidden_size", + rad_meta_geti(meta, "draft.dflash_config.hidden_size", + dg.n_embd)); + if (want_embd != dg.n_embd) { + fprintf(stderr, "radiance: the drafter reads a %lld-wide trunk and this target is %lld " + "wide; they are not the same model\n", (long long)want_embd, + (long long)dg.n_embd); + return RAD_E_UNSUPPORTED; + } + + DsparkBF16::Config c{}; + c.n_taps = taps.n; + c.rank = rad_meta_geti(meta, "draft.markov_rank", 0); + c.causal = rad_meta_geti(meta, "draft.is_causal", 0) ? 1 : 0; + c.tap_norm = rad_meta_geti(meta, "draft.fc_norm", 0) ? 1 : 0; + c.qk_norm = rad_meta_geti(meta, "draft.qk_norm", 0) ? 1 : 0; + c.gate = rad_meta_geti(meta, "draft.headwise_attn_output_gate", 0) ? 1 : 0; + const char* act = rad_meta_gets(meta, "draft.hidden_act", "silu"); + c.act = (!std::strcmp(act, "gelu") || !std::strcmp(act, "none")) ? "gelu" + : (!std::strcmp(act, "silu")) ? "silu" : nullptr; + if (!c.act) { + fprintf(stderr, "radiance: the drafter's feed-forward is '%s'; this block runs exact-erf " + "gelu (what the Spark drafts train with) or silu, and the two are not the " + "same function\n", act); + return RAD_E_UNSUPPORTED; + } + const char* gate_mode = rad_meta_gets(meta, "draft.gate_attn_act_mode", "sigmoid"); + if (c.gate && std::strcmp(gate_mode, "sigmoid")) { + fprintf(stderr, "radiance: the drafter gates its attention output with '%s'; this block " + "applies a sigmoid\n", gate_mode); + return RAD_E_UNSUPPORTED; + } + /* Every row predicts, the anchor included. Without it a block row's worth of proposals is + * missing and the head reads rows the drafter never filled. */ + if (!rad_meta_geti(meta, "draft.sample_from_anchor", 1)) { + fprintf(stderr, "radiance: the drafter declares sample_from_anchor false, whose bonus " + "anchor slot this block has no rows for\n"); + return RAD_E_UNSUPPORTED; + } + /* The reference applies the bigram bias to the full vocabulary before each greedy choice. */ + if (c.rank <= 0 || c.rank % 32 || c.rank > 512) { + fprintf(stderr, "radiance: the drafter's Markov head has rank %lld; the walk that applies " + "the bigram bias takes a multiple of 32 up to 512\n", (long long)c.rank); + return RAD_E_UNSUPPORTED; + } + + /* The block is both the number of noise rows and the number of drafts: every row, the anchor + * included, predicts the token after it, so the depth is `block_size` rather than the + * `block_size - 1` a DFlash2 container's is. A block-diffusion drafter is trained for one + * block length and has no partial block, so any other depth is refused. */ + const int64_t trained = rad_meta_geti(meta, "draft.block_size", 0); + if (trained < 2) { + fprintf(stderr, "radiance: this drafter declares no draft.block_size; the number of masked " + "positions it denoises is not a number this engine may choose.\n"); + return RAD_E_FORMAT; + } + if ((long long)ctx->max_spec != trained) { + fprintf(stderr, "radiance: the drafter was trained at block_size %lld, which is %lld draft " + "tokens, and this serve asks for %d. A block-diffusion drafter denoises a " + "fixed number of mask positions; run it at %lld.\n", + (long long)trained, (long long)trained, ctx->max_spec, (long long)trained); + return RAD_E_UNSUPPORTED; + } + c.block = trained; + + /* The reference gives every row of the block the anchor's history. `window` is the configured + * number of preceding positions; llama.cpp sets n_swa to window + 1 and masks when + * anchor - key >= n_swa. Keep that exact width in attention, the KV group and scheduler. */ + int64_t window = 0; + if (rad_meta_geti(meta, "draft.use_sliding_window", 0)) + window = rad_meta_geti(meta, "draft.sliding_window", 0); + if (window < 0 || (window && window < c.block)) { + fprintf(stderr, "radiance: the drafter's %lld-token window does not cover the %lld-token " + "block it denoises\n", (long long)window, (long long)c.block); + return RAD_E_UNSUPPORTED; + } + if (window > 0 && window == INT64_MAX) return RAD_E_INVAL; + c.window = window > 0 ? window + 1 : 0; /* llama.cpp dflash: n_swa += 1 */ + const double prf = rad_meta_getf(meta, "draft.partial_rotary_factor", + rad_meta_getf(meta, + "draft.rope_parameters.partial_rotary_factor", 1.0)); + const double rot = (double)dg.head_dim * prf; + if (!(prf > 0.0) && prf != 0.0) { + fprintf(stderr, "radiance: the drafter's partial_rotary_factor is %g\n", prf); + return RAD_E_INVAL; + } + if (std::floor(rot) != rot || (int64_t)rot % 2 || rot > (double)dg.head_dim) { + fprintf(stderr, "radiance: the drafter rotates %g of %lld head dimensions\n", rot, + (long long)dg.head_dim); + return RAD_E_INVAL; + } + c.rot = (int64_t)rot ? (int64_t)rot : dg.head_dim; + + RAD_ARCH_TRY(drafter_kv_group(b, nm, ctx, dg, c.window, base_layer, kv)); + + /* Activations: one row per committed token for the context pass, one row per block position + * for the query pass. Both are small; the drafter's cost is its weights. */ + const int64_t qd = dg.n_head * dg.head_dim, kvd = dg.n_head_kv * dg.head_dim; + int64_t qr = dg.max_seqs * c.block; + if (qr > dg.max_tok) qr = dg.max_tok; + const int64_t sr = dg.max_seqs * c.steps(); + DsparkBF16::Wire& dw = *w; + dw.src = taps.src; + dw.srcn = decl_b(b, nm.f("ds_srcn"), RAD_BF16, {dg.max_tok, c.n_taps * dg.n_embd}); + dw.c = decl_b(b, nm.f("ds_c"), RAD_BF16, {dg.max_tok, dg.n_embd}); + dw.cn = decl_b(b, nm.f("ds_cn"), RAD_BF16, {dg.max_tok, dg.n_embd}); + dw.ck = decl_b(b, nm.f("ds_ck"), RAD_BF16, {dg.max_tok, kvd}); + dw.cv = decl_b(b, nm.f("ds_cv"), RAD_BF16, {dg.max_tok, kvd}); + if (c.qk_norm) dw.ckn = decl_b(b, nm.f("ds_ckn"), RAD_BF16, {dg.max_tok, kvd}); + dw.x = decl_b(b, nm.f("ds_x"), RAD_F32, {qr, dg.n_embd}); + dw.delta = decl_b(b, nm.f("ds_delta"), RAD_F32, {qr, dg.n_embd}); + dw.h = decl_b(b, nm.f("ds_h"), RAD_BF16, {qr, dg.n_embd}); + dw.q = decl_b(b, nm.f("ds_q"), RAD_BF16, {qr, qd}); + dw.k = decl_b(b, nm.f("ds_k"), RAD_BF16, {qr, kvd}); + dw.v = decl_b(b, nm.f("ds_v"), RAD_BF16, {qr, kvd}); + if (c.qk_norm) { + dw.qn = decl_b(b, nm.f("ds_qn"), RAD_BF16, {qr, qd}); + dw.kn = decl_b(b, nm.f("ds_kn"), RAD_BF16, {qr, kvd}); + } + dw.gate = decl_b(b, nm.f("ds_gate"), RAD_BF16, {qr, dg.n_head}); + dw.attn = decl_b(b, nm.f("ds_attn"), RAD_BF16, {qr, qd}); + if (c.gate) { + dw.gaten = decl_b(b, nm.f("ds_gaten"), RAD_BF16, {qr, dg.n_head}); + dw.attng = decl_b(b, nm.f("ds_attng"), RAD_BF16, {qr, qd}); + } + dw.gate_up = decl_b(b, nm.f("ds_gate_up"), RAD_BF16, {qr, 2 * dg.n_ff}); + dw.ff = decl_b(b, nm.f("ds_ff"), RAD_BF16, {qr, dg.n_ff}); + dw.dlog = decl_b(b, nm.f("ds_dlog"), RAD_F32, {sr, dg.n_vocab}); + const int64_t n_markov_tiles = (dg.n_vocab_all + 63) / 64; + dw.best_score = decl_b(b, nm.f("ds_markov_score"), RAD_F32, + {dg.max_seqs, n_markov_tiles}); + dw.best_token = decl_b(b, nm.f("ds_markov_token"), RAD_I32, + {dg.max_seqs, n_markov_tiles}); + /* The proposal buffer (RadDrafterDecl::proposal): a block pass proposes through the drafter's + * own walk, never through the sampler's token buffer. */ + dw.tokens = decl_b(b, nm.f("ds_tokens"), RAD_I32, {dg.max_seqs, c.steps()}); + if (!dw.srcn || !dw.c || !dw.cn || !dw.ck || !dw.cv || + (c.qk_norm && (!dw.ckn || !dw.qn || !dw.kn)) || + (c.gate && (!dw.gaten || !dw.attng)) || !dw.x || !dw.delta || !dw.h || !dw.q || !dw.k || + !dw.v || !dw.gate || !dw.attn || !dw.gate_up || !dw.ff || !dw.dlog || + !dw.best_score || !dw.best_token || !dw.tokens) + return RAD_E_INVAL; + + RAD_ARCH_TRY(ds->declare(b, nm, dg, c, base_layer, *kv, tok_embd, "draft", ck_head, dw)); + + RadDrafterDecl drf{}; + drf.name = "dspark"; + drf.kind = RAD_DRAFT_BLOCK; + drf.depth = ctx->max_spec; + drf.block = c.block; + drf.proposal = dw.tokens; + drf.proposal_pitch = c.steps(); + drf.window = c.window; + drf.mask_token = (int32_t)rad_meta_geti(meta, "draft.mask_token_id", -1); + if (drf.mask_token < 0) + drf.mask_token = (int32_t)rad_meta_geti(meta, "draft.dflash_config.mask_token_id", -1); + if (drf.mask_token < 0) { + fprintf(stderr, "radiance: this drafter declares no mask_token_id, which every unfilled " + "block position embeds\n"); + return RAD_E_FORMAT; + } + RAD_ARCH_TRY(rad_declare_drafter(b, &drf)); + + rad_note(b, "DSpark drafter: %lld layers at absolute %d..%d, %lld heads / %lld kv x %lld, " + "ffn %lld, %s attention with a %lld-token anchor-aligned window (%lld configured " + "history + 1), %lld of %lld rotary dimensions, %s, %s a head, %d trunk tap(s); one " + "forward over %lld noise row(s), the anchor included, proposes %lld tokens", + (long long)dg.n_layer, base_layer, base_layer + (int)dg.n_layer - 1, + (long long)dg.n_head, (long long)dg.n_head_kv, (long long)dg.head_dim, + (long long)dg.n_ff, c.causal ? "causal" : "non-causal", (long long)c.window, + (long long)window, (long long)c.rot, (long long)dg.head_dim, c.act, + c.gate ? "sigmoid gate" : "no gate", (int)c.n_taps, (long long)c.block, + (long long)c.steps()); + rad_note(b, "the rank-%lld Markov bigram head greedily scans all %lld vocabulary tokens at " + "each draft position; confidence is not applied to logits%s", + (long long)c.rank, (long long)dg.n_vocab_all, + rad_meta_geti(meta, "draft.has_confidence_head", 0) + ? " (its reference role is adaptive depth, which this fixed-depth graph does not use)" + : ""); + return RAD_OK; +} + + +} /* namespace arch */ +} /* namespace rad */ + +#endif /* RAD_BLOCK_DSPARK_BF16_H */ \ No newline at end of file diff --git a/arch/common/rad_block_gdn_fp8.h b/arch/common/rad_block_gdn_fp8.h index 7cbe7685..ab3d8e2c 100644 --- a/arch/common/rad_block_gdn_fp8.h +++ b/arch/common/rad_block_gdn_fp8.h @@ -336,12 +336,14 @@ inline int GdnFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, const Con RAD_WEIGHTS(w_a_log, w_dt_bias, w_out_norm)), {w.q, w.k, w.v, w.ab, w.in.x}, {w.o.x}); /* The epilogue's codes for an fp8 or int8 out-projection (int8 when ActFP8::q8_fed; the codes - * dtype picks the quantiser). A bf16 out-projection reads only `o.x` and these stay absent. */ + * dtype picks the quantiser). A bf16 out-projection reads only `o.x` and these stay absent. + * Rotated int8 codes (ActFP8::q8_rot) only the conv fold writes (gdn_conv_recurrent_update_had); + * rows this update serves are quantised by q_o. */ if (g.plain_norm) { RAD_ARCH_TRY(out.probe(b, nm, g, nm.f("blk.%d.ssm_out", l), { s.out })); o_plain = out.codes_free && out.reads_x; } - if (op_recur && w.o.cq() && !o_plain) { + if (op_recur && w.o.cq() && !o_plain && !w.o.q8_rot) { const rad_buf oq[2] = { w.o.cq(), w.o.cs() }; RAD_ARCH_TRY(rad_op_writes(b, op_recur, oq, 2)); } @@ -349,7 +351,7 @@ inline int GdnFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, const Con * tokens per sequence. Optional (no RAD_ARCH_TRY): without it the pair runs. */ { const int64_t hi = g.max_tok < 8 ? g.max_tok : 8; - op_cr = rw(b, RAD_OP(b, "gdn_conv_recurrent_update", + op_cr = rw(b, RAD_OP(b, w.o.q8_rot ? "gdn_conv_recurrent_update_had" : "gdn_conv_recurrent_update", RAD_PARAMS(RAD_RANGE("q_len", 1, hi), RAD_INT("head_k", cfg.head_k), RAD_INT("head_v", cfg.head_v), RAD_INT("conv_width", cfg.conv_width), @@ -530,8 +532,10 @@ inline void GdnFP8::step(RadCtx* c, const RadBatch* batch, bool own_ar, praw2(st_idx, RAD_I32, D, st_w), praw(batch->num_accepted, RAD_I32, D), praw(batch->cu_seqlens, RAD_I32, D + 1), bcol(w.in.x, conv_dim, v_dim, DT), RAD_W(w_out_norm), brows(w.o.x, DT), - w.o.cq() && !o_plain ? brows(w.o.cq(), DT) : RAD_NONE, - w.o.cq() && !o_plain ? brows(w.o.cs(), DT) : RAD_NONE); + w.o.cq() && !o_plain && !w.o.q8_rot ? brows(w.o.cq(), DT) : RAD_NONE, + w.o.cq() && !o_plain && !w.o.q8_rot ? brows(w.o.cs(), DT) : RAD_NONE); + /* Rotated codes come only from the fold; here the decode rows take the quantiser. */ + if (w.o.q8_rot && !o_plain) q_o.step(c, T, 0, DT); } /* The output a piece at a time where the caller takes the all-reduce that way (ArPieces): the diff --git a/arch/common/rad_block_gemma4_unified.h b/arch/common/rad_block_gemma4_unified.h new file mode 100644 index 00000000..95fa25bb --- /dev/null +++ b/arch/common/rad_block_gemma4_unified.h @@ -0,0 +1,263 @@ +/* rad_block_gemma4_unified.h -- the media embedders of Gemma 4 12B ("unified", transformers' + * Gemma4UnifiedVisionEmbedder and the audio Gemma4UnifiedMultimodalEmbedder), served by gemma4_bf16. + * Neither has an encoder: the language model sees each patch or audio frame after a few norms and + * linears. + * + * image: a patch is 48 x 48 x 3 (3 x 3 of the processor's 16-pixel patches), staged by the core's + * Gemma 4 processor as u / 255 in bf16, (y, x, channel); a LayerNorm over the patch, a linear with + * a bias, a LayerNorm, plus a learned row for the patch's column and one for its row (the + * checkpoint's [npos, 2, width] table, read as its two taps of dimension 1), a LayerNorm, then the + * multimodal embedder: an RMS norm with no gain and a width -> n_embd linear. The LayerNorms are + * nn.LayerNorm's default eps 1e-5, which no config states. One patch is one row. + * audio: a frame is 640 samples at 16 kHz as they are, the last zero-padded, in bf16; an RMS norm + * with no gain and a 640 -> n_embd linear. One frame is one row. + * + * Their rows replace the placeholders' embeddings unscaled, as the vision tower's do. Every rank + * runs them whole (RAD_SHARD_NONE). */ +#ifndef RAD_BLOCK_GEMMA4_UNIFIED_H +#define RAD_BLOCK_GEMMA4_UNIFIED_H + +#include "rad_arch.h" + +#include +#include + +namespace rad { +namespace arch { + +struct Gemma4UnifiedVision { + bool on = false; + /* The language model reads a picture's rows both ways (RadEncoderDecl::bidirectional); the + * plugin sets it before declare. */ + bool bidirectional = false; + int64_t P = 0, width = 0, patch_dim = 0, npos = 0, n_embd = 0; + rad_weight w_ln1 = 0, w_ln1b = 0, w_in = 0, w_inb = 0, w_ln2 = 0, w_ln2b = 0, w_px = 0, w_py = 0; + rad_weight w_pn = 0, w_pnb = 0, w_proj = 0; + rad_op op_ln1 = 0, op_in = 0, op_ln2 = 0, op_px = 0, op_py = 0, op_padd = 0, op_add = 0; + rad_op op_pn = 0, op_norm = 0, op_out = 0; + rad_buf b_n = 0, b_x = 0, b_h = 0, b_px = 0, b_py = 0, b_out = 0; + + static bool present(const RadModelMeta* m) { + const char* t = rad_meta_gets(m, "vision_config.model_type", ""); + return t && !std::strcmp(t, "gemma4_unified_vision"); + } + + int declare(RadBuilder* b, const RadModelMeta* m, const RadBuildCtx* ctx, Names& nm, + int64_t model_embd, const char* who) { + on = false; + if (!present(m) || ctx->max_enc_patches <= 0) return RAD_OK; + width = rad_meta_geti(m, "vision_config.mm_embed_dim", 0); + npos = rad_meta_geti(m, "vision_config.mm_posemb_size", 0); + const int64_t side = rad_meta_geti(m, "vision_config.model_patch_size", 0); + const int64_t outd = rad_meta_geti(m, "vision_config.output_proj_dims", width); + const double eps = rad_meta_getf(m, "vision_config.rms_norm_eps", 1e-6); + if (width <= 0 || npos <= 0 || side <= 0 || outd != width) { + fprintf(stderr, "radiance: %s: the container's vision_config is incomplete or not the " + "embedder this plugin serves (mm_embed_dim %lld, mm_posemb_size %lld, " + "model_patch_size %lld, output_proj_dims %lld)\n", who, + (long long)width, (long long)npos, (long long)side, (long long)outd); + return RAD_E_UNSUPPORTED; + } + n_embd = model_embd; + patch_dim = 3 * side * side; + P = ctx->max_enc_patches; + const int A = RAD_ACCESS_PER_REQUEST, N = RAD_SHARD_NONE; + const char* V = "model.vision_embedder"; + struct { const char* to; const char* from; } cp[] = { + { "v.ln1.weight", "patch_ln1.weight" }, { "v.ln1.bias", "patch_ln1.bias" }, + { "v.in.weight", "patch_dense.weight" }, { "v.in.bias", "patch_dense.bias" }, + { "v.ln2.weight", "patch_ln2.weight" }, { "v.ln2.bias", "patch_ln2.bias" }, + { "v.pn.weight", "pos_norm.weight" }, { "v.pn.bias", "pos_norm.bias" } }; + for (const auto& e : cp) + RAD_ARCH_TRY(map_copy(b, nm.f("%s", e.to), nm.ckpt("%s.%s", V, e.from))); + RAD_ARCH_TRY(map_tap(b, nm.f("v.pos_x.weight"), nm.ckpt("%s.pos_embedding", V), 1, 0)); + RAD_ARCH_TRY(map_tap(b, nm.f("v.pos_y.weight"), nm.ckpt("%s.pos_embedding", V), 1, 1)); + RAD_ARCH_TRY(map_copy(b, nm.f("v.embed.weight"), nm.ckpt("model.embed_vision.embedding_projection.weight"))); + w_ln1 = decl_w(b, nm.f("v.ln1.weight"), RAD_BF16, {patch_dim}, A, N, grp_model()); + w_ln1b = decl_w(b, nm.f("v.ln1.bias"), RAD_BF16, {patch_dim}, A, N, grp_model()); + w_in = decl_w(b, nm.f("v.in.weight"), RAD_BF16, {width, patch_dim}, A, N, grp_model()); + w_inb = decl_w(b, nm.f("v.in.bias"), RAD_BF16, {width}, A, N, grp_model()); + w_ln2 = decl_w(b, nm.f("v.ln2.weight"), RAD_BF16, {width}, A, N, grp_model()); + w_ln2b = decl_w(b, nm.f("v.ln2.bias"), RAD_BF16, {width}, A, N, grp_model()); + w_px = decl_w(b, nm.f("v.pos_x.weight"), RAD_BF16, {npos, width}, A, N, grp_model()); + w_py = decl_w(b, nm.f("v.pos_y.weight"), RAD_BF16, {npos, width}, A, N, grp_model()); + w_pn = decl_w(b, nm.f("v.pn.weight"), RAD_BF16, {width}, A, N, grp_model()); + w_pnb = decl_w(b, nm.f("v.pn.bias"), RAD_BF16, {width}, A, N, grp_model()); + w_proj = decl_w(b, nm.f("v.embed.weight"), RAD_BF16, {n_embd, width}, A, N, grp_model()); + + b_n = decl_b(b, nm.f("v.n"), RAD_BF16, {P, patch_dim}); + b_x = decl_b(b, nm.f("v.x"), RAD_BF16, {P, width}); + b_h = decl_b(b, nm.f("v.h"), RAD_BF16, {P, width}); + b_px = decl_b(b, nm.f("v.px"), RAD_BF16, {P, width}); + b_py = decl_b(b, nm.f("v.py"), RAD_BF16, {P, width}); + b_out = decl_b(b, nm.f("v.out"), RAD_BF16, {P, n_embd}); + + auto ln = [&](int64_t n, rad_weight w, rad_weight bias) { + return RAD_OP(b, "layernorm", RAD_PARAMS(RAD_RANGE("M", 1, P), RAD_INT("n", n), + RAD_F64("eps", 1e-5), RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(w, bias)); + }; + auto lookup = [&](rad_weight w) { + return RAD_OP(b, "embed_lookup", + RAD_PARAMS(RAD_RANGE("M", 1, P), RAD_INT("n_embd", width), + RAD_INT("n_vocab", npos), RAD_STR("dtype", "bf16"), + RAD_INT("vocab_offset", 0), RAD_F64("mult", 1.0)), + RAD_WEIGHTS(w)); + }; + auto add = [&]() { + return RAD_OP(b, "add", RAD_PARAMS(RAD_RANGE("M", 1, P), RAD_INT("n", width), + RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS); + }; + op_ln1 = rw(b, ln(patch_dim, w_ln1, w_ln1b), {}, {b_n}); + op_in = rw(b, RAD_OP(b, "gemm_nt_bias", + RAD_PARAMS(RAD_RANGE("M", 1, P), RAD_INT("N", width), + RAD_INT("K", patch_dim), RAD_STR("dtype", "bf16"), + RAD_STR("act", "none")), + RAD_WEIGHTS(w_in, w_inb)), + {b_n}, {b_x}); + op_ln2 = rw(b, ln(width, w_ln2, w_ln2b), {b_x}, {b_h}); + op_px = rw(b, lookup(w_px), {}, {b_px}); + op_py = rw(b, lookup(w_py), {}, {b_py}); + op_padd = rw(b, add(), {b_px, b_py}, {b_px}); + op_add = rw(b, add(), {b_h, b_px}, {b_h}); + op_pn = rw(b, ln(width, w_pn, w_pnb), {b_h}, {b_x}); + op_norm = rw(b, RAD_OP(b, "rmsnorm", + RAD_PARAMS(RAD_RANGE("M", 1, P), RAD_INT("n", width), + RAD_F64("eps", eps), RAD_F64("wadd", 0.0), + RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + {b_x}, {b_h}); + op_out = rw(b, RAD_OP(b, "gemm_nt", + RAD_PARAMS(RAD_RANGE("M", 1, P), RAD_INT("N", n_embd), + RAD_INT("K", width), RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(w_proj)), + {b_h}, {b_out}); + + RadEncoderDecl e{}; + e.name = "vision"; + e.modalities = RAD_MM_IMAGE | RAD_MM_VIDEO; + e.patch_dim = patch_dim; + e.merge = 1; + e.max_patches = P; + e.n_embd = n_embd; + e.out = b_out; + e.bidirectional = bidirectional ? 1 : 0; + RAD_ARCH_TRY(rad_declare_encoder(b, &e)); + rad_note(b, "vision embedder (no tower): %lldx%lld patches of %lld values -> %lld, " + "positions %lld a side; %lld patches a pass -> %lld rows of %lld", + (long long)side, (long long)side, (long long)patch_dim, (long long)width, + (long long)npos, (long long)P, (long long)P, (long long)n_embd); + on = true; + return RAD_OK; + } + + void step(RadCtx* c, const RadBatch* batch) const { + const int64_t Pn = batch->enc_n_patch; + if (!on || Pn <= 0 || Pn > P || batch->enc_n_seg <= 0) { + rad_step_fail(c, "an encoder pass this program's vision embedder cannot serve: none " + "declared, or more patches than it was declared for"); + return; + } + const int32_t* crd = batch->enc_coord; + RAD_ISSUE_N(c, op_ln1, Pn, praw2(batch->enc_pixels, RAD_BF16, Pn, patch_dim), RAD_W(w_ln1), + RAD_W(w_ln1b), brows(b_n, Pn)); + RAD_ISSUE_N(c, op_in, Pn, brows(b_n, Pn), RAD_W(w_in), RAD_W(w_inb), RAD_NONE, brows(b_x, Pn)); + RAD_ISSUE_N(c, op_ln2, Pn, brows(b_x, Pn), RAD_W(w_ln2), RAD_W(w_ln2b), brows(b_h, Pn)); + RAD_ISSUE_N(c, op_px, Pn, praw(crd + Pn, RAD_I32, Pn), RAD_W(w_px), brows(b_px, Pn)); + RAD_ISSUE_N(c, op_py, Pn, praw(crd, RAD_I32, Pn), RAD_W(w_py), brows(b_py, Pn)); + RAD_ISSUE_N(c, op_padd, Pn, brows(b_px, Pn), brows(b_py, Pn), brows(b_px, Pn)); + RAD_ISSUE_N(c, op_add, Pn, brows(b_h, Pn), brows(b_px, Pn), brows(b_h, Pn)); + RAD_ISSUE_N(c, op_pn, Pn, brows(b_h, Pn), RAD_W(w_pn), RAD_W(w_pnb), brows(b_x, Pn)); + RAD_ISSUE_N(c, op_norm, Pn, brows(b_x, Pn), RAD_NONE, brows(b_h, Pn)); + RAD_ISSUE_N(c, op_out, Pn, brows(b_h, Pn), RAD_W(w_proj), brows(b_out, Pn)); + } +}; + +struct Gemma4UnifiedAudio { + bool on = false; + int64_t P = 0, frame = 0, n_embd = 0; + rad_weight w_proj = 0; + rad_op op_norm = 0, op_out = 0; + rad_buf b_n = 0, b_out = 0; + + static bool present(const RadModelMeta* m) { + const char* t = rad_meta_gets(m, "audio_config.model_type", ""); + return t && !std::strcmp(t, "gemma4_unified_audio"); + } + /* Samples a frame: the extractor's audio_samples_per_token, else the embedder's input width. */ + static int64_t frame_for(const RadModelMeta* m) { + return rad_meta_geti(m, "processor.feature_extractor.audio_samples_per_token", + rad_meta_geti(m, "audio_config.audio_embed_dim", 0)); + } + /* The longest clip in frames: processor_config.json's audio_seq_length, else 30 s. */ + static int64_t frames_for(const RadModelMeta* m) { + const int64_t f = frame_for(m); + const int64_t rate = rad_meta_geti(m, "processor.feature_extractor.sampling_rate", 16000); + if (f <= 0 || rate <= 0) return 0; + return rad_meta_geti(m, "processor.audio_seq_length", (30 * rate + f - 1) / f); + } + + int declare(RadBuilder* b, const RadModelMeta* m, const RadBuildCtx* ctx, Names& nm, + int64_t model_embd, const char* who) { + on = false; + if (!present(m) || ctx->max_audio_frames <= 0) return RAD_OK; + frame = frame_for(m); + const int64_t width = rad_meta_geti(m, "audio_config.audio_embed_dim", 0); + const double eps = rad_meta_getf(m, "audio_config.rms_norm_eps", 1e-6); + if (frame <= 0 || width != frame) { + fprintf(stderr, "radiance: %s: the container's audio frame (%lld samples) is not the " + "embedder's input (audio_embed_dim %lld)\n", who, (long long)frame, + (long long)width); + return RAD_E_UNSUPPORTED; + } + n_embd = model_embd; + P = ctx->max_audio_frames; + RAD_ARCH_TRY(map_copy(b, nm.f("a.embed.weight"), nm.ckpt("model.embed_audio.embedding_projection.weight"))); + w_proj = decl_w(b, nm.f("a.embed.weight"), RAD_BF16, {n_embd, frame}, RAD_ACCESS_PER_REQUEST, + RAD_SHARD_NONE, grp_model()); + b_n = decl_b(b, nm.f("a.n"), RAD_BF16, {P, frame}); + b_out = decl_b(b, nm.f("a.out"), RAD_BF16, {P, n_embd}); + op_norm = rw(b, RAD_OP(b, "rmsnorm", + RAD_PARAMS(RAD_RANGE("M", 1, P), RAD_INT("n", frame), + RAD_F64("eps", eps), RAD_F64("wadd", 0.0), + RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + {}, {b_n}); + op_out = rw(b, RAD_OP(b, "gemm_nt", + RAD_PARAMS(RAD_RANGE("M", 1, P), RAD_INT("N", n_embd), + RAD_INT("K", frame), RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(w_proj)), + {b_n}, {b_out}); + RadEncoderDecl e{}; + e.name = "audio"; + e.modalities = RAD_MM_AUDIO; + e.patch_dim = frame; + e.merge = 1; + e.max_patches = P; + e.n_embd = n_embd; + e.out = b_out; + RAD_ARCH_TRY(rad_declare_encoder(b, &e)); + rad_note(b, "audio embedder (no encoder): frames of %lld samples -> %lld; %lld frames a pass", + (long long)frame, (long long)n_embd, (long long)P); + on = true; + return RAD_OK; + } + + void step(RadCtx* c, const RadBatch* batch) const { + const int64_t Pn = batch->enc_n_patch; + if (!on || Pn <= 0 || Pn > P || batch->enc_n_seg <= 0) { + rad_step_fail(c, "an audio pass this program's audio embedder cannot serve: none " + "declared, or more frames than it was declared for"); + return; + } + RAD_ISSUE_N(c, op_norm, Pn, praw2(batch->enc_pixels, RAD_BF16, Pn, frame), RAD_NONE, + brows(b_n, Pn)); + RAD_ISSUE_N(c, op_out, Pn, brows(b_n, Pn), RAD_W(w_proj), brows(b_out, Pn)); + } +}; + +} /* namespace arch */ +} /* namespace rad */ + +#endif /* RAD_BLOCK_GEMMA4_UNIFIED_H */ diff --git a/arch/common/rad_block_gemma4_vision.h b/arch/common/rad_block_gemma4_vision.h index d64875c5..e037abb9 100644 --- a/arch/common/rad_block_gemma4_vision.h +++ b/arch/common/rad_block_gemma4_vision.h @@ -56,6 +56,9 @@ struct Gemma4Vision { rad_op op_c[C_N] = {}; }; bool on = false, standardize = false, clip = false; + /* The language model reads a picture's rows both ways (RadEncoderDecl::bidirectional); the + * plugin sets it before declare. */ + bool bidirectional = false; int64_t P = 0, R = 0, width = 0, heads = 0, hd = 0, ff = 0, patch_dim = 0, pool = 0; int64_t npos = 0, n_embd = 0; rad_weight w_in = 0, w_px = 0, w_py = 0, w_proj = 0, w_sbias = 0, w_sscale = 0; @@ -321,6 +324,7 @@ struct Gemma4Vision { e.max_patches = P; e.n_embd = n_embd; e.out = b_out; + e.bidirectional = bidirectional ? 1 : 0; RAD_ARCH_TRY(rad_declare_encoder(b, &e)); rad_note(b, "vision tower: %lld layers of %lld (%lld heads x %lld), ff %lld, patch %lld, " "pooled %lldx%lld%s%s; %lld patches a pass -> %lld rows of %lld", diff --git a/arch/common/rad_block_glm_indexer.h b/arch/common/rad_block_glm_indexer.h index c69b93ea..72d91141 100644 --- a/arch/common/rad_block_glm_indexer.h +++ b/arch/common/rad_block_glm_indexer.h @@ -27,6 +27,9 @@ struct DsaCache { rad_buf query = 0, codes = 0, scales = 0, gate = 0, kg = 0; rad_buf stage = 0, page = 0, bpos = 0, nc = 0, pooled = 0, pool_scale = 0; rad_buf score = 0, selected = 0, nsel = 0, length = 0; + /* A taking-all step's zero scores, [max_tok, topk + 1]: such a step does not split, and + * the score plane holds only a run of rows when the step may. */ + rad_buf unscored = 0; /* TP only: a rank's rebased bounds, page tables and lengths before the gathers. */ rad_buf cu_part = 0, sel_part = 0, len_part = 0; }; @@ -44,6 +47,7 @@ struct DsaCache { rad_kvgroup index = 0, tail = 0, attention = 0; rad_weight ape = 0; rad_op op_query = 0, op_work = 0, op_pool = 0, op_tail = 0, op_score = 0, op_select = 0; + rad_op op_unscored = 0, op_select_all = 0; rad_op op_score_part = 0, op_select_part = 0, op_gather_sel = 0, op_gather_len = 0; int declare(RadBuilder* b, Names& nm, const Geom& geom, int l, const Config& cfg, @@ -112,6 +116,15 @@ struct DsaCache { RAD_INT("seqs", g.max_seqs), RAD_STR("dtype", "bf16")), RAD_NOWEIGHTS), { w.kg }, {}); + /* A step whose every row reaches topk or fewer blocks selects them all (takes_all), and + * qsa_select takes any finite scores in block order then: zeros serve as well as the + * scorer's. The fill spans topk + 1 columns, at least the live reach of such a step. */ + op_unscored = rw(b, + RAD_OP(b, "fill", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), + RAD_INT("n", unscored_cols()), RAD_STR("dtype", "f32")), + RAD_NOWEIGHTS), + {}, { w.unscored }); op_score = rw(b, RAD_OP(b, "dsa_score", RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", 128), @@ -139,6 +152,14 @@ struct DsaCache { RAD_INT("seqs", g.max_seqs), RAD_INT("signed", 1)), RAD_NOWEIGHTS), { w.score, w.nc }, { w.selected, w.nsel, w.length }); + op_select_all = rw(b, + RAD_OP(b, "qsa_select", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), + RAD_INT("blocks", unscored_cols()), + RAD_INT("topk", 512), RAD_INT("ratio", 4), + RAD_INT("seqs", g.max_seqs), RAD_INT("signed", 1)), + RAD_NOWEIGHTS), + { w.unscored, w.nc }, { w.selected, w.nsel, w.length }); if (split) { op_select_part = rw( b, @@ -165,8 +186,12 @@ struct DsaCache { if (!op_score_part || !op_select_part || !op_gather_sel || !op_gather_len) return RAD_E_INVAL; } - return op_query && op_work && op_tail && op_score && op_select ? RAD_OK : RAD_E_INVAL; + return op_query && op_work && op_tail && op_unscored && op_score && op_select && + op_select_all + ? RAD_OK + : RAD_E_INVAL; } + int64_t unscored_cols() const { return c.topk + 1 < c.blocks ? c.topk + 1 : c.blocks; } /* The columns a step scores: the live reach the batch bounds on the host. */ int64_t live_blocks(const RadBatch* batch) const { const auto* ib = kv_batch(batch, index); @@ -179,13 +204,19 @@ struct DsaCache { } /* The decision reads the same host bound as the score plane's width (max_ctx_len, rounded by * the core), so every rank takes the same path and a recorded decode pass changes it only when - * that bound moves. */ + * that bound moves. A step that takes all its blocks never splits: with nothing to score, every + * rank selects the whole step itself, and the gathers have nothing to save. */ bool splits(const RadBatch* batch) const { const int64_t T = batch->n_tok; - return op_score_part && (GlmTp::splits(T, g.world) || - (T >= GlmTp::kSplitWorkRows && - T * live_blocks(batch) >= GlmTp::kSplitWork)); + return op_score_part && live_blocks(batch) > c.topk && + (GlmTp::splits(T, g.world) || + (T >= GlmTp::kSplitWorkRows && T * live_blocks(batch) >= GlmTp::kSplitWork)); } + /* Every row's history fits the selection, so the query side (projection, head gates, + * quantiser, scorer) has nothing to decide: the selected table is every live block in order, + * bit for bit what scoring would select. Read from the same host bound as splits(), so every + * rank agrees. */ + bool takes_all(const RadBatch* batch) const { return live_blocks(batch) <= c.topk; } /* The query rows this rank runs: the whole step, or its run of a split step (GlmTp::run_of). * A rank whose run lies wholly past a small step runs the step's first R rows instead: no * sequence holds its run, so its scores are -inf, and its answers land past T. The caller's @@ -210,11 +241,13 @@ struct DsaCache { const int64_t T = batch->n_tok, S = batch->n_seq; const int64_t work = (T + 3) / 4 + S, pitch = tb->state_index_pitch > 0 ? tb->state_index_pitch : 1; + const bool all = takes_all(batch); int64_t q0 = 0, qn = T; query_rows(batch, &q0, &qn); - RAD_ISSUE_N(ctx, op_query, qn * 32, brow_slice(w.query, q0 * 32, qn * 32, 128), - brow_slice(w.codes, q0 * 32, qn * 32, 128), - brow_slice(w.scales, q0 * 32, qn * 32, 1)); + if (!all) + RAD_ISSUE_N(ctx, op_query, qn * 32, brow_slice(w.query, q0 * 32, qn * 32, 128), + brow_slice(w.codes, q0 * 32, qn * 32, 128), + brow_slice(w.scales, q0 * 32, qn * 32, 1)); RAD_ISSUE_N(ctx, op_work, T, brows(w.kg, T), praw(batch->positions, RAD_I32, T), praw(batch->cu_seqlens, RAD_I32, S + 1), kv_cache(tail, layer), praw2(tb->state_index, RAD_I32, S, pitch), @@ -232,6 +265,16 @@ struct DsaCache { step_split(ctx, batch, live); return; } + if (all) { + const int64_t U = unscored_cols(); + RAD_ISSUE_N(ctx, op_unscored, T, brows(w.unscored, T)); + RAD_ISSUE_N(ctx, op_select_all, T, bcol_at(w.unscored, 0, U, 0, live, T), + praw2(ab->block_table, RAD_I32, S, ab->block_table_pitch), + brows(w.nc, S), praw(batch->positions, RAD_I32, T), + praw(batch->cu_seqlens, RAD_I32, S + 1), brows(w.selected, T), + brows(w.nsel, T), brows(w.length, T)); + return; + } // dsa_score declares ten operands, cu_part the optional tenth; the engine counts them. RAD_ISSUE_N(ctx, op_score, T, brows(w.codes, T * 32), brows(w.scales, T * 32), brows(w.gate, T), kv_cache(index, layer), RAD_NONE, @@ -348,23 +391,29 @@ struct GlmIndexer { }; int64_t r0 = 0, rows = T; cache.query_rows(batch, &r0, &rows); + /* The key side runs on every step, since the index cache must stay current; the query + * side only where the selection is a choice (DsaCache::takes_all). */ + const bool all = cache.takes_all(batch); /* Every output row of these ops is independent of the others and of how many there are, * except the bf16 projection's at 64 rows and under, a band whose split count a tuned * configuration may set: it stays on the step's rows unless every run is wider. */ const bool runs = cache.splits(batch); - if (runs && T - (g.world - 1) * DsaCache::part_rows(T, g.world) > 64) - query.step(ctx, act(w.q_low), w.q_wide, T, r0, rows); - else - query.step(ctx, act(w.q_low), w.q_wide, T); - RAD_ISSUE_N(ctx, op_query_copy, rows * 32, brow_slice(w.q_wide, r0, rows, 4096), - brow_slice(w.cache.query, r0 * 32, rows * 32, 128)); + if (!all) { + if (runs && T - (g.world - 1) * DsaCache::part_rows(T, g.world) > 64) + query.step(ctx, act(w.q_low), w.q_wide, T, r0, rows); + else + query.step(ctx, act(w.q_low), w.q_wide, T); + RAD_ISSUE_N(ctx, op_query_copy, rows * 32, brow_slice(w.q_wide, r0, rows, 4096), + brow_slice(w.cache.query, r0 * 32, rows * 32, 128)); + } key_gate.step(ctx, act(w.input), w.kg_raw, T); RAD_ISSUE_N(ctx, op_norm, T, bcol(w.kg_raw, 0, 128, T), RAD_W(gain), RAD_W(bias), bcol(w.cache.kg, 0, 128, T)); RAD_ISSUE_N(ctx, op_gate_copy, T, bcol(w.kg_raw, 128, 128, T), bcol(w.cache.kg, 128, 128, T)); - RAD_ISSUE_N(ctx, op_head, rows, brow_slice(w.input, r0, rows, 4096), RAD_W(head_weight), - brow_slice(w.cache.gate, r0, rows, 32)); + if (!all) + RAD_ISSUE_N(ctx, op_head, rows, brow_slice(w.input, r0, rows, 4096), + RAD_W(head_weight), brow_slice(w.cache.gate, r0, rows, 32)); cache.step(ctx, batch); } }; diff --git a/arch/common/rad_block_glm_mla.h b/arch/common/rad_block_glm_mla.h index e033c687..6ad3b89c 100644 --- a/arch/common/rad_block_glm_mla.h +++ b/arch/common/rad_block_glm_mla.h @@ -19,6 +19,7 @@ #include "rad_glm_tp.h" #include #include +#include #include namespace rad { @@ -27,6 +28,25 @@ struct MlaLatent { struct Config { int64_t heads = 16, head_dim = 256, latent_dim = 512, blocks = 513; }; + /* The attention over the latent cache, `rows` rows of `heads` heads. The cache is Geom::kv_dtype + * (bf16, or fp8_e4m3 under --kv-cache-dtype fp8); `kv_dtype` is stated only for a cache that is + * not bf16, so a bf16 build declares the op it always did. */ + static rad_op attn_op(RadBuilder* b, const Geom& g, int64_t rows, int64_t heads, + int64_t blocks, double scale) { + if (g.kv_dtype && std::strcmp(g.kv_dtype, "bf16")) + return RAD_OP(b, "mla_attn", + RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("latent_dim", 512), + RAD_INT("heads", heads), RAD_INT("blocks", blocks), + RAD_INT("block_size", 4), RAD_F64("scale", scale), + RAD_STR("dtype", "bf16"), RAD_STR("kv_dtype", g.kv_dtype)), + RAD_NOWEIGHTS); + return RAD_OP(b, "mla_attn", + RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("latent_dim", 512), + RAD_INT("heads", heads), RAD_INT("blocks", blocks), + RAD_INT("block_size", 4), RAD_F64("scale", scale), + RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS); + } struct Wire { rad_buf q = 0, q_latent = 0, attn_latent = 0, out = 0, selected = 0, length = 0; /* qsa_select's entry count (selected_count), one int a row: the streamed resolve's `nsel`. @@ -68,16 +88,10 @@ struct MlaLatent { RAD_STR("mode", "absorb"), RAD_STR("dtype", "bf16")), RAD_WEIGHTS(projection)), { w.q }, { w.q_latent }); - op_attn = - rw(b, - RAD_OP(b, "mla_attn", - RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("latent_dim", c.latent_dim), - RAD_INT("heads", c.heads), RAD_INT("blocks", c.blocks), - RAD_INT("block_size", 4), - RAD_F64("scale", 1.0 / std::sqrt((double)c.head_dim)), - RAD_STR("dtype", "bf16")), - RAD_NOWEIGHTS), - { w.q_latent, w.selected, w.length }, { w.attn_latent }); + op_attn = rw(b, + attn_op(b, g, g.max_tok, c.heads, c.blocks, + 1.0 / std::sqrt((double)c.head_dim)), + { w.q_latent, w.selected, w.length }, { w.attn_latent }); if (!op_attn || rad_kv_block_size(b, group) != 4) return RAD_E_INVAL; op_expand = rw( b, @@ -172,12 +186,13 @@ struct GlmMla { RAD_ARCH_TRY(q_b.declare(b, nm, g, nm.f("blk.%d.attn_q_b", l), GlmTp::mla_width(g.world), 1536, RAD_SHARD_ROW, wg, { nm.ckpt("%s.q_b_proj.weight", prefix) }, w.q_low, w.core.q)); - // Cache stores contiguous halves of the normalized latent, with no duplicated K/V. + /* Cache stores contiguous halves of the normalized latent, with no duplicated K/V. An E4M3 + * cache (Geom::kv_dtype) stores at kv_store's default descale of 1, which mla_attn reads. */ op_store = rw(b, RAD_OP(b, "kv_store", RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("head_dim", 256), RAD_INT("n_head_kv", 1), RAD_INT("block_size", 4), - RAD_STR("kv_dtype", "bf16")), + RAD_STR("kv_dtype", g.kv_dtype)), RAD_NOWEIGHTS), { w.latent }, {}); if (!op_store) return RAD_E_INVAL; @@ -200,7 +215,7 @@ struct GlmMla { RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("head_dim", 256), RAD_INT("n_head_kv", 1), RAD_INT("block_size", 4), - RAD_STR("kv_dtype", "bf16")), + RAD_STR("kv_dtype", g.kv_dtype)), RAD_NOWEIGHTS), { w.latent }, {}); /* Issued in finish, after this layer's indexer selects and before the attention reads @@ -239,15 +254,8 @@ struct GlmMla { { in }, { out }); }; op_rows_absorb = project("absorb", r.q, r.q_latent); - op_rows_attn = - rw(b, - RAD_OP(b, "mla_attn", - RAD_PARAMS(RAD_RANGE("M", 1, R), RAD_INT("latent_dim", 512), - RAD_INT("heads", 64), RAD_INT("blocks", core.c.blocks), - RAD_INT("block_size", 4), RAD_F64("scale", 1.0 / std::sqrt(256.0)), - RAD_STR("dtype", "bf16")), - RAD_NOWEIGHTS), - { r.q_latent, w.core.selected, w.core.length }, { r.attn_latent }); + op_rows_attn = rw(b, MlaLatent::attn_op(b, g, R, 64, core.c.blocks, 1.0 / std::sqrt(256.0)), + { r.q_latent, w.core.selected, w.core.length }, { r.attn_latent }); op_rows_expand = project("expand", r.attn_latent, r.attn.x); RAD_ARCH_TRY(rows_quant.declare(b, g, r.attn, 16384)); rows_output.stored = nm.f("blk.%d.attn_output.weight", layer); diff --git a/arch/common/rad_block_glm_mtp.h b/arch/common/rad_block_glm_mtp.h index 4e188626..86c168b4 100644 --- a/arch/common/rad_block_glm_mtp.h +++ b/arch/common/rad_block_glm_mtp.h @@ -16,7 +16,11 @@ * before the layer's attention, `join` (the residual add and the proposal rows' selection) between * its attention and its feed-forward, `head` after it. The embedding and lm_head are the trunk's. * Its names live under the `mtp.` scope (Names), its weights in layer 45's group. eh_proj - * (4096 x 8192 bf16, 64 MiB) is replicated and read whole in every draft pass. */ + * (4096 x 8192 bf16, 64 MiB) is replicated and read whole in every draft pass. + * + * The same head serves another DeepSeek-style drafter by its checkpoint layout, set before + * declare_inputs: the residual width, the layer's checkpoint prefix and index, and the name of the + * head's final norm (Ling-3.0: 2560, `model.layers.42`, 42, `final_layernorm.weight`). */ #ifndef RAD_BLOCK_GLM_MTP_H #define RAD_BLOCK_GLM_MTP_H #include "rad_glm_tp.h" @@ -31,6 +35,10 @@ struct GlmMtp { rad_weight token = 0, head = 0; }; static constexpr int kDepth = 3; /* --num-speculative-tokens auto */ + int64_t width = 4096; + const char* prefix = "model.language_model.layers.45"; + int layer = 45; + const char* norm_src = "shared_head.norm.weight"; Names nm{ "mtp" }; Geom g{}; Wire w{}; @@ -50,47 +58,48 @@ struct GlmMtp { w = wire; if (!b || !w.final_hidden || !w.logits || !w.token || !w.head || g.max_spec < 1) return RAD_E_INVAL; - x = decl_b(b, nm.f("x"), RAD_BF16, { g.max_tok, 4096 }); - hidden = decl_b(b, nm.f("hidden"), RAD_BF16, { g.max_tok, 4096 }, RAD_BUF_PERSIST); - embedding = decl_b(b, nm.f("embedding"), RAD_BF16, { g.max_tok, 4096 }); - concat = decl_b(b, nm.f("concat"), RAD_BF16, { g.max_tok, 8192 }); - out = decl_b(b, nm.f("final"), RAD_BF16, { g.max_tok, 4096 }); - const char* pre = "model.language_model.layers.45"; + const int64_t E = width; + x = decl_b(b, nm.f("x"), RAD_BF16, { g.max_tok, E }); + hidden = decl_b(b, nm.f("hidden"), RAD_BF16, { g.max_tok, E }, RAD_BUF_PERSIST); + embedding = decl_b(b, nm.f("embedding"), RAD_BF16, { g.max_tok, E }); + concat = decl_b(b, nm.f("concat"), RAD_BF16, { g.max_tok, 2 * E }); + out = decl_b(b, nm.f("final"), RAD_BF16, { g.max_tok, E }); + const char* pre = prefix; auto gain = [&](const char* n, const char* src) { const char* name = nm.f("%s", n); if (map_copy(b, name, nm.ckpt("%s.%s", pre, src)) < 0) return (rad_weight)0; - return decl_w(b, name, RAD_F32, { 4096 }, RAD_ACCESS_PER_TOKEN, RAD_SHARD_NONE, - grp_layer(45)); + return decl_w(b, name, RAD_F32, { E }, RAD_ACCESS_PER_TOKEN, RAD_SHARD_NONE, + grp_layer(layer)); }; en = gain("enorm.weight", "enorm.weight"); hn = gain("hnorm.weight", "hnorm.weight"); - norm = gain("output_norm.weight", "shared_head.norm.weight"); + norm = gain("output_norm.weight", norm_src); RAD_ARCH_TRY(map_copy(b, nm.f("eh_proj.weight"), nm.ckpt("%s.eh_proj.weight", pre))); - eh = decl_w(b, nm.f("eh_proj.weight"), RAD_BF16, { 4096, 8192 }, RAD_ACCESS_PER_TOKEN, - RAD_SHARD_NONE, grp_layer(45)); + eh = decl_w(b, nm.f("eh_proj.weight"), RAD_BF16, { E, 2 * E }, RAD_ACCESS_PER_TOKEN, + RAD_SHARD_NONE, grp_layer(layer)); if (!x || !hidden || !embedding || !concat || !out || !en || !hn || !norm || !eh) return RAD_E_INVAL; op_prev = rw(b, RAD_OP(b, "gather_rows", - RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", 4096), + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", E), RAD_STR("dtype", "bf16")), RAD_NOWEIGHTS), { w.final_hidden }, { hidden }); op_embed = rw(b, RAD_OP(b, "embed_lookup", - RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n_embd", 4096), + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n_embd", E), RAD_INT("n_vocab", g.n_vocab), RAD_STR("dtype", "bf16"), RAD_INT("vocab_offset", g.vocab_off)), RAD_WEIGHTS(w.token)), {}, { embedding }); - if (media) RAD_ARCH_TRY(mrows.declare(b, g.max_tok, 4096, embedding)); + if (media) RAD_ARCH_TRY(mrows.declare(b, g.max_tok, E, embedding)); op_embed_ar = GlmTp::reduce(b, g, embedding, true); op_en = rmsnorm(b, en, embedding, concat); op_hn = rmsnorm(b, hn, hidden, concat); op_eh = rw(b, RAD_OP(b, "gemm_nt", - RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("N", 4096), - RAD_INT("K", 8192), RAD_STR("dtype", "bf16")), + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("N", E), + RAD_INT("K", 2 * E), RAD_STR("dtype", "bf16")), RAD_WEIGHTS(eh)), { concat }, { x }); return op_prev && op_embed && op_en && op_hn && op_eh && (g.world == 1 || op_embed_ar) @@ -102,14 +111,14 @@ struct GlmMtp { int declare_join(RadBuilder* b, rad_buf y) { op_residual = rw(b, RAD_OP(b, "add", - RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", 4096), + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", width), RAD_STR("dtype", "bf16")), RAD_NOWEIGHTS), { x, y }, { x }); // All history rows fill the draft cache; only proposal rows need its FFN. op_select = rw(b, RAD_OP(b, "gather_rows", - RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows), RAD_INT("n", 4096), + RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows), RAD_INT("n", width), RAD_STR("dtype", "bf16")), RAD_NOWEIGHTS), { x }, { hidden }); @@ -124,7 +133,7 @@ struct GlmMtp { op_head = rw(b, RAD_OP(b, "logits_gemm", RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows), - RAD_INT("n_vocab", g.n_vocab), RAD_INT("n_embd", 4096), + RAD_INT("n_vocab", g.n_vocab), RAD_INT("n_embd", width), RAD_STR("dtype", "bf16")), RAD_WEIGHTS(w.head)), { hidden }, { w.logits }); @@ -150,9 +159,9 @@ struct GlmMtp { RAD_ISSUE_N(c, op_embed, T, praw(batch->token_ids, RAD_I32, T), RAD_W(w.token), brows(embedding, T)); mrows.step(c, batch, embedding, T); - if (op_embed_ar) RAD_ISSUE_N(c, op_embed_ar, T * 4096, brows(embedding, T), RAD_NONE); - RAD_ISSUE_N(c, op_en, T, brows(embedding, T), RAD_W(en), bcol(concat, 0, 4096, T)); - RAD_ISSUE_N(c, op_hn, T, brows(hidden, T), RAD_W(hn), bcol(concat, 4096, 4096, T)); + if (op_embed_ar) RAD_ISSUE_N(c, op_embed_ar, T * width, brows(embedding, T), RAD_NONE); + RAD_ISSUE_N(c, op_en, T, brows(embedding, T), RAD_W(en), bcol(concat, 0, width, T)); + RAD_ISSUE_N(c, op_hn, T, brows(hidden, T), RAD_W(hn), bcol(concat, width, width, T)); RAD_ISSUE_N(c, op_eh, T, brows(concat, T), RAD_W(eh), brows(x, T)); } void step_join(RadCtx* c, const RadBatch* batch, rad_buf y) const { @@ -175,7 +184,7 @@ private: rad_op rmsnorm(RadBuilder* b, rad_weight gain, rad_buf in, rad_buf out) const { return rw(b, RAD_OP(b, "rmsnorm", - RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", 4096), + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", width), RAD_F64("eps", g.eps), RAD_STR("dtype", "bf16")), RAD_WEIGHTS(gain)), { in }, { out }); @@ -183,7 +192,7 @@ private: rad_op cast(RadBuilder* b, rad_buf in, rad_buf out) const { return rw(b, RAD_OP(b, "cast", - RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", 4096), + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", width), RAD_STR("from", "bf16"), RAD_STR("to", "bf16")), RAD_NOWEIGHTS), { in }, { out }); diff --git a/arch/common/rad_block_glm_router.h b/arch/common/rad_block_glm_router.h index a23f901b..d2697a85 100644 --- a/arch/common/rad_block_glm_router.h +++ b/arch/common/rad_block_glm_router.h @@ -1,5 +1,6 @@ /* GLM noaux_tc router. Correction bias changes selection only; mixture weights - * come from the uncorrected sigmoid probabilities. All routing arithmetic is F32. */ + * come from the uncorrected sigmoid probabilities. All routing arithmetic is F32. With `groups` + * above 1 the selection is group-limited (router_sigmoid_group_topk, Ling-3.0's 8 groups, 4 kept). */ #ifndef RAD_BLOCK_GLM_ROUTER_H #define RAD_BLOCK_GLM_ROUTER_H #include "rad_glm_tp.h" @@ -9,7 +10,7 @@ namespace rad { namespace arch { struct GlmRouter { struct Config { - int64_t experts = 288, top_k = 8, rows = 32; + int64_t experts = 288, top_k = 8, rows = 32, groups = 1, topk_groups = 1; int norm = 1; double route_scale = 2.5; }; @@ -33,8 +34,9 @@ struct GlmRouter { w = wire; if (!b || !name || !src.weight || !src.correction || g.n_embd < 1 || c.experts < 1 || c.experts > 512 || c.top_k < 1 || c.top_k > c.experts || c.rows < 1 || - c.rows > g.max_tok || !std::isfinite(c.route_scale) || c.route_scale <= 0 || !w.input || - !w.logits || !w.ids || !w.weights || w.logits == w.weights) + c.rows > g.max_tok || !std::isfinite(c.route_scale) || c.route_scale <= 0 || + c.groups < 1 || c.experts % c.groups || c.topk_groups < 1 || c.topk_groups > c.groups || + !w.input || !w.logits || !w.ids || !w.weights || w.logits == w.weights) return RAD_E_INVAL; const char *pn = nm.f("%s.weight", name), *cn = nm.f("%s.correction", name); RAD_ARCH_TRY(map_copy(b, pn, src.weight)); @@ -52,14 +54,25 @@ struct GlmRouter { { w.input }, { w.logits }); RAD_ARCH_TRY(split.declare(b, nm, g, name, c.rows, c.experts, g.n_embd, projection, w.input, w.logits)); - op_select = - rw(b, - RAD_OP(b, "router_sigmoid_topk", - RAD_PARAMS(RAD_RANGE("M", 1, c.rows), RAD_INT("n_expert", c.experts), - RAD_INT("top_k", c.top_k), RAD_INT("norm", c.norm), - RAD_F64("route_scale", c.route_scale), RAD_STR("dtype", "f32")), - RAD_WEIGHTS(correction)), - { w.logits }, { w.ids, w.weights }); + if (c.groups > 1) + op_select = + rw(b, + RAD_OP(b, "router_sigmoid_group_topk", + RAD_PARAMS(RAD_RANGE("M", 1, c.rows), RAD_INT("n_expert", c.experts), + RAD_INT("top_k", c.top_k), RAD_INT("n_group", c.groups), + RAD_INT("topk_group", c.topk_groups), RAD_INT("norm", c.norm), + RAD_F64("route_scale", c.route_scale), RAD_STR("dtype", "f32")), + RAD_WEIGHTS(correction)), + { w.logits }, { w.ids, w.weights }); + else + op_select = + rw(b, + RAD_OP(b, "router_sigmoid_topk", + RAD_PARAMS(RAD_RANGE("M", 1, c.rows), RAD_INT("n_expert", c.experts), + RAD_INT("top_k", c.top_k), RAD_INT("norm", c.norm), + RAD_F64("route_scale", c.route_scale), RAD_STR("dtype", "f32")), + RAD_WEIGHTS(correction)), + { w.logits }, { w.ids, w.weights }); return op_project && op_select ? RAD_OK : RAD_E_INVAL; } void project(RadCtx* ctx, int64_t first, int64_t rows, int64_t output_first = 0) const { diff --git a/arch/common/rad_block_lilicorr.h b/arch/common/rad_block_lilicorr.h new file mode 100644 index 00000000..1219673a --- /dev/null +++ b/arch/common/rad_block_lilicorr.h @@ -0,0 +1,395 @@ +/* rad_block_lilicorr.h -- LiLiCorr's head: the candidate correlator after a DFlash2 backbone. + * + * NVIDIA's drafter for Nemotron-3.5-Bolt (vLLM's model_executor/models/lilicorr.py). The backbone is + * rad_block_dflash2.h's, with attention sinks (Dflash2::Config::lili). Its final hidden states at + * the block's draft rows go here instead of to DFlash2's selector: + * + * candidates each draft position's top-k from the target's own lm_head (log-softmax values, + * vocab-parallel: each rank's shard, all-gathered, merged) + * lattice steps x k rows a sequence, row s * k + j: + * token_proj(embed(cand)) + pass_hidden_proj(h_s) + * + feature_mlp(layernorm(five rank features)) + slot[s] + rank[j] + * 2 layers rmsnorm, attention over the lattice with a learned slot bias (lili_attn), the + * in/out projections; rmsnorm, silu MLP with biases; residuals + * factor x = output_norm(lattice), a = anchor_norm(context_proj(the anchor's context row)) + * f = silu(W [x | a | x * a] + b), [out | in] = edge heads of f + * walk normalised dot products, start from the anchor's own outgoing head, greedy + * (lili_walk) + * + * The anchor's context row is hidden_norm(fc(taps)) at the last committed position, which the + * context pass left in Dflash2's `c` (RadBatch::anchor_rows names the row). The head reads the + * target's embedding and lm_head, and its own 25 linears are bf16: ModelOpt ships them NVFP4, + * which no kernel serves, and the recipe decodes them (`cast dtype=bf16`). + * + * Every rank computes the whole lattice (vLLM: "candidate IDs and embeddings are replicated across + * TP ranks"); only the head's logits and the embedding lookup are per rank, with the merge in + * lili_cand and an exact all-reduce after the lookup. + */ +#ifndef RAD_BLOCK_LILICORR_H +#define RAD_BLOCK_LILICORR_H + +#include "rad_arch.h" + +namespace rad { +namespace arch { + +struct LiliCorr { + enum { MAX_LAYERS = 4 }; + + struct Config { + int64_t steps = 0; /* draft positions a sequence: the block less the anchor */ + int64_t k = 8; /* candidates a position (lilicorr_candidate_topk) */ + int64_t hs = 1024; /* the lattice's width (lilicorr_hidden_size) */ + int64_t n_head = 8; + int64_t mlp = 2048; /* hs * lilicorr_mlp_ratio */ + int64_t fdim = 1024; /* lilicorr_factor_dim */ + int64_t n_layer = 2; + double eps = 1e-6; /* rms_norm_eps, the lattice's RMS norms */ + double vec_eps = 1e-4; /* lilicorr_vector_eps, F.normalize's floor */ + double scale = 8.0; /* lilicorr_logit_scale */ + }; + + /* row_k: the pairs a rank's logprob row carries, k rounded up so 2 + 2 row_k floats are whole + * 16-byte words (the all-gather's unit): 9 for k = 8. */ + static int64_t row_k(int64_t k) { return (k % 2) ? k : k + 1; } + + struct Wire { + /* Dflash2's */ + rad_buf sel_h = 0; /* [srows, n_embd] the drafter's final hidden states, draft rows */ + rad_buf c = 0; /* [max_tok, n_embd] hidden_norm(fc(taps)), the context pass's rows */ + rad_buf tokens = 0; /* [max_seqs, steps] i32, the proposal */ + /* the head's own */ + rad_buf logits = 0; /* [srows, n_vocab] f32, this rank's shard */ + rad_buf stats = 0; /* [srows, 2 + 2 row_k] f32 */ + rad_buf sgath = 0; /* [srows, world * (2 + 2 row_k)] f32, world > 1 */ + rad_buf pas = 0; /* [srows, hs] */ + rad_buf cand = 0; /* [srows * k] i32 */ + rad_buf feat = 0; /* [lrows, hs] */ + rad_buf hh = 0; /* [lrows, hs] the lattice's residual stream; starts as lili_cand's base */ + rad_buf emb = 0; /* [lrows, n_embd] the candidates' embeddings */ + rad_buf y = 0; /* [lrows, hs] */ + rad_buf qkv = 0; /* [lrows, 3 hs] */ + rad_buf att = 0; /* [lrows, hs] */ + rad_buf up = 0; /* [lrows, mlp] */ + rad_buf ups = 0; /* [lrows, mlp] */ + rad_buf cat = 0; /* [lrows, 3 hs] */ + rad_buf fh = 0; /* [lrows, hs] */ + rad_buf fhs = 0; /* [lrows, hs] */ + rad_buf edges = 0; /* [lrows, 2 fdim] */ + rad_buf anc = 0; /* [max_seqs, n_embd] */ + rad_buf ast = 0; /* [max_seqs, hs] */ + rad_buf an = 0; /* [max_seqs, hs] */ + rad_buf aout = 0; /* [max_seqs, fdim] */ + }; + + Geom g{}; + Config cfg{}; + Wire w{}; + int64_t srows = 0, lrows = 0, rk = 0; + + rad_weight w_lm = 0, w_tok = 0; /* the target's */ + rad_weight w_tokp = 0, b_tokp = 0, w_pass = 0, b_pass = 0, w_ctx = 0, b_ctx = 0; + rad_weight w_fdn = 0, b_fdn = 0, ln_w = 0, ln_b = 0, up_w = 0, up_b = 0, w_slot = 0, w_rank = 0; + rad_weight w_anorm[MAX_LAYERS] = {}, w_in[MAX_LAYERS] = {}, b_in[MAX_LAYERS] = {}; + rad_weight w_out[MAX_LAYERS] = {}, b_out[MAX_LAYERS] = {}, w_mnorm[MAX_LAYERS] = {}; + rad_weight w_up[MAX_LAYERS] = {}, b_up[MAX_LAYERS] = {}, w_dn[MAX_LAYERS] = {}; + rad_weight b_dn[MAX_LAYERS] = {}; + rad_weight w_rel = 0, w_same = 0, w_onorm = 0, w_annorm = 0; + rad_weight w_fac = 0, b_fac = 0, w_edge = 0, b_edge = 0, w_aout = 0, b_aout = 0; + + rad_op op_logits = 0, op_stats = 0, op_sgath = 0, op_pas = 0, op_cand = 0; + rad_op op_emb = 0, op_emb_ar = 0, op_tokp = 0, op_fdn = 0; + rad_op op_anorm[MAX_LAYERS] = {}, op_in[MAX_LAYERS] = {}, op_attn = 0; + rad_op op_out[MAX_LAYERS] = {}, op_mnorm[MAX_LAYERS] = {}, op_up[MAX_LAYERS] = {}; + rad_op op_dn[MAX_LAYERS] = {}, op_silu_up = 0; + rad_op op_onorm = 0, op_anc = 0, op_ctx = 0, op_annorm = 0, op_factor = 0, op_fac = 0; + rad_op op_silu_f = 0, op_edge = 0, op_aout = 0, op_walk = 0; + + int declare(RadBuilder* b, Names& nm, const Geom& geom, const Config& c, rad_weight lm_head, + rad_weight tok_embd, const char* ck, const Wire& wire); + /* After Dflash2::step, on the same query batch: `sel_h` holds the draft rows. */ + void step(RadCtx* c, const RadBatch* batch) const; +}; + +inline int LiliCorr::declare(RadBuilder* b, Names& nm, const Geom& geom, const Config& c, + rad_weight lm_head, rad_weight tok_embd, const char* ck, + const Wire& wire) { + g = geom; cfg = c; w = wire; w_lm = lm_head; w_tok = tok_embd; + if (!w_lm || !w_tok || !ck || cfg.steps < 1 || cfg.k < 2 || cfg.n_layer < 1 || + cfg.n_layer > MAX_LAYERS || cfg.hs % cfg.n_head) + return RAD_E_INVAL; + const int64_t K = cfg.k, S = cfg.steps, hs = cfg.hs, fd = cfg.fdim, E = g.n_embd; + srows = g.max_seqs * S; + lrows = srows * K; + rk = row_k(K); + const int ACC = RAD_ACCESS_PER_TOKEN; + const RadWeightGroup grp = grp_model(); + + /* The head's weights, all replicated. Linears and tables bf16, biases, norms and the + * feature layer f32. */ + auto wt = [&](const char* dn, const char* src, uint32_t dt, + std::initializer_list shp) -> rad_weight { + if (map_copy(b, dn, src) < 0) return 0; + return decl_w(b, dn, dt, shp, ACC, RAD_SHARD_NONE, grp); + }; + const char* L = nm.ckpt("%s.lilicorr", ck); + auto src = [&](const char* tail) { return nm.ckpt("%s.%s", L, tail); }; + w_tokp = wt(nm.f("dflash.lili.token_proj.weight"), src("token_proj.weight"), RAD_BF16, { hs, E }); + b_tokp = wt(nm.f("dflash.lili.token_proj.bias"), src("token_proj.bias"), RAD_F32, { hs }); + w_pass = wt(nm.f("dflash.lili.pass_proj.weight"), src("pass_hidden_proj.weight"), RAD_BF16, + { hs, E }); + b_pass = wt(nm.f("dflash.lili.pass_proj.bias"), src("pass_hidden_proj.bias"), RAD_F32, { hs }); + w_ctx = wt(nm.f("dflash.lili.context_proj.weight"), src("context_proj.weight"), RAD_BF16, + { hs, E }); + b_ctx = wt(nm.f("dflash.lili.context_proj.bias"), src("context_proj.bias"), RAD_F32, { hs }); + ln_w = wt(nm.f("dflash.lili.feature_norm.weight"), src("feature_norm.weight"), RAD_F32, { 5 }); + ln_b = wt(nm.f("dflash.lili.feature_norm.bias"), src("feature_norm.bias"), RAD_F32, { 5 }); + up_w = wt(nm.f("dflash.lili.feature_up.weight"), src("feature_mlp.up_proj.weight"), RAD_F32, + { hs, 5 }); + up_b = wt(nm.f("dflash.lili.feature_up.bias"), src("feature_mlp.up_proj.bias"), RAD_F32, + { hs }); + w_fdn = wt(nm.f("dflash.lili.feature_down.weight"), src("feature_mlp.down_proj.weight"), + RAD_BF16, { hs, hs }); + b_fdn = wt(nm.f("dflash.lili.feature_down.bias"), src("feature_mlp.down_proj.bias"), RAD_F32, + { hs }); + /* [1, 1, steps, 1, hs] and [1, 1, 1, k, hs], read as tables (a reshape of one whole plane). */ + w_slot = wt(nm.f("dflash.lili.slot_embedding"), src("slot_embedding"), RAD_BF16, { S, hs }); + w_rank = wt(nm.f("dflash.lili.rank_embedding"), src("rank_embedding"), RAD_BF16, { K, hs }); + w_rel = wt(nm.f("dflash.lili.relative_slot_bias"), src("relative_slot_bias"), RAD_F32, + { cfg.n_head, 2 * (S + 1) - 1 }); + w_same = wt(nm.f("dflash.lili.same_slot_bias"), src("same_slot_bias"), RAD_F32, { cfg.n_head }); + for (int64_t l = 0; l < cfg.n_layer; ++l) { + const int i = (int)l; + auto ls = [&](const char* tail) { return nm.ckpt("%s.layers.%d.%s", L, i, tail); }; + w_anorm[i] = wt(nm.f("dflash.lili.blk.%d.attn_norm.weight", i), ls("attn_norm.weight"), + RAD_F32, { hs }); + w_in[i] = wt(nm.f("dflash.lili.blk.%d.attn_in.weight", i), ls("attn.in_proj_weight"), + RAD_BF16, { 3 * hs, hs }); + b_in[i] = wt(nm.f("dflash.lili.blk.%d.attn_in.bias", i), ls("attn.in_proj_bias"), RAD_F32, + { 3 * hs }); + w_out[i] = wt(nm.f("dflash.lili.blk.%d.attn_out.weight", i), ls("attn.out_proj.weight"), + RAD_BF16, { hs, hs }); + b_out[i] = wt(nm.f("dflash.lili.blk.%d.attn_out.bias", i), ls("attn.out_proj.bias"), + RAD_F32, { hs }); + w_mnorm[i] = wt(nm.f("dflash.lili.blk.%d.mlp_norm.weight", i), ls("mlp_norm.weight"), + RAD_F32, { hs }); + w_up[i] = wt(nm.f("dflash.lili.blk.%d.mlp_up.weight", i), ls("mlp.up_proj.weight"), + RAD_BF16, { cfg.mlp, hs }); + b_up[i] = wt(nm.f("dflash.lili.blk.%d.mlp_up.bias", i), ls("mlp.up_proj.bias"), RAD_F32, + { cfg.mlp }); + w_dn[i] = wt(nm.f("dflash.lili.blk.%d.mlp_down.weight", i), ls("mlp.down_proj.weight"), + RAD_BF16, { hs, cfg.mlp }); + b_dn[i] = wt(nm.f("dflash.lili.blk.%d.mlp_down.bias", i), ls("mlp.down_proj.bias"), + RAD_F32, { hs }); + if (!w_anorm[i] || !w_in[i] || !b_in[i] || !w_out[i] || !b_out[i] || !w_mnorm[i] || + !w_up[i] || !b_up[i] || !w_dn[i] || !b_dn[i]) + return RAD_E_INVAL; + } + w_onorm = wt(nm.f("dflash.lili.output_norm.weight"), src("output_norm.weight"), RAD_F32, { hs }); + w_annorm = wt(nm.f("dflash.lili.anchor_norm.weight"), src("anchor_norm.weight"), RAD_F32, { hs }); + w_fac = wt(nm.f("dflash.lili.factor_proj.weight"), src("factor_input_proj.weight"), RAD_BF16, + { hs, 3 * hs }); + b_fac = wt(nm.f("dflash.lili.factor_proj.bias"), src("factor_input_proj.bias"), RAD_F32, + { hs }); + /* [out_head | in_head] as one linear, as vLLM fuses them (`_fused_edge_weight`). */ + RAD_ARCH_TRY(map_concat(b, nm.f("dflash.lili.edge.weight"), + { src("out_head.weight"), src("in_head.weight") }, 0)); + RAD_ARCH_TRY(map_concat(b, nm.f("dflash.lili.edge.bias"), + { src("out_head.bias"), src("in_head.bias") }, 0)); + w_edge = decl_w(b, nm.f("dflash.lili.edge.weight"), RAD_BF16, { 2 * fd, hs }, ACC, + RAD_SHARD_NONE, grp); + b_edge = decl_w(b, nm.f("dflash.lili.edge.bias"), RAD_F32, { 2 * fd }, ACC, RAD_SHARD_NONE, + grp); + w_aout = wt(nm.f("dflash.lili.anchor_out.weight"), src("anchor_out_head.weight"), RAD_BF16, + { fd, hs }); + b_aout = wt(nm.f("dflash.lili.anchor_out.bias"), src("anchor_out_head.bias"), RAD_F32, { fd }); + if (!w_tokp || !b_tokp || !w_pass || !b_pass || !w_ctx || !b_ctx || !ln_w || !ln_b || !up_w || + !up_b || !w_fdn || !b_fdn || !w_slot || !w_rank || !w_rel || !w_same || !w_onorm || + !w_annorm || !w_fac || !b_fac || !w_edge || !b_edge || !w_aout || !b_aout) + return RAD_E_INVAL; + + /* ---------------------------------------------------------------- ops */ + auto gemm_b = [&](int64_t rows, int64_t N, int64_t Kd, rad_weight wgt, rad_weight bias) + -> rad_op { + return RAD_OP(b, "gemm_nt_bias", + RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("N", N), RAD_INT("K", Kd), + RAD_STR("dtype", "bf16"), RAD_STR("act", "none")), + RAD_WEIGHTS(wgt, bias)); + }; + auto rms = [&](int64_t rows, int64_t n, rad_weight gain) -> rad_op { + return RAD_OP(b, "rmsnorm", + RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("n", n), RAD_F64("eps", cfg.eps), + RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(gain)); + }; + auto silu = [&](int64_t rows, int64_t n) -> rad_op { + return RAD_OP(b, "silu", + RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("n", n), RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS); + }; + const int64_t sw = 2 + 2 * rk; + + /* The candidates: this rank's shard of the target's logits, its logprob row, the exchange. */ + op_logits = rw(b, RAD_OP(b, "logits_gemm", + RAD_PARAMS(RAD_RANGE("M", 1, srows), RAD_INT("n_vocab", g.n_vocab), + RAD_INT("n_embd", E), RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(w_lm)), + { w.sel_h }, { w.logits }); + /* Replicated, `vocab_off` is omitted: an optional parameter present at 0 is a different + * declaration from an absent one. */ + op_stats = g.world > 1 + ? rw(b, RAD_OP(b, "sample_logprobs", + RAD_PARAMS(RAD_RANGE("M", 1, srows), RAD_INT("n_vocab", g.n_vocab), + RAD_INT("k", rk), RAD_INT("vocab_off", g.vocab_off)), + RAD_NOWEIGHTS), + { w.logits }, { w.stats }) + : rw(b, RAD_OP(b, "sample_logprobs", + RAD_PARAMS(RAD_RANGE("M", 1, srows), RAD_INT("n_vocab", g.n_vocab), + RAD_INT("k", rk)), + RAD_NOWEIGHTS), + { w.logits }, { w.stats }); + if (g.world > 1) + op_sgath = rw(b, RAD_OP(b, "all_gather", + RAD_PARAMS(RAD_INT("world_size", g.world), + RAD_INT("numel", srows * sw), RAD_STR("dtype", "f32"), + RAD_INT("row", sw)), + RAD_NOWEIGHTS), + { w.stats }, { w.sgath }); + op_pas = rw(b, gemm_b(srows, hs, E, w_pass, b_pass), { w.sel_h }, { w.pas }); + op_cand = rw(b, RAD_OP(b, "lili_cand", + RAD_PARAMS(RAD_RANGE("M", 1, srows), RAD_INT("k", K), + RAD_INT("world", g.world), RAD_INT("steps", S), + RAD_INT("n", hs), RAD_STR("dtype", "bf16"), + RAD_F64("eps", 1e-5), RAD_INT("row_k", rk)), + RAD_WEIGHTS(ln_w, ln_b, up_w, up_b, w_slot, w_rank)), + { g.world > 1 ? w.sgath : w.stats, w.pas }, { w.cand, w.feat, w.hh }); + /* The lattice: candidates' embeddings (the trunk's vocab-sharded table, exact reduce), the + * token and feature projections added onto lili_cand's base in their GEMMs' residual. */ + op_emb = rw(b, RAD_OP(b, "embed_lookup", + RAD_PARAMS(RAD_RANGE("M", 1, lrows), RAD_INT("n_embd", E), + RAD_INT("n_vocab", g.n_vocab), RAD_STR("dtype", "bf16"), + RAD_INT("vocab_offset", g.vocab_off)), + RAD_WEIGHTS(w_tok)), + { w.cand }, { w.emb }); + if (g.world > 1) + op_emb_ar = rw(b, RAD_OP(b, "all_reduce", + RAD_PARAMS(RAD_INT("world_size", g.world), + RAD_RANGE("numel", E, lrows * E), + RAD_STR("dtype", "bf16"), RAD_INT("exact", 1)), + RAD_NOWEIGHTS), + { w.emb }, { w.emb }); + op_tokp = rw(b, gemm_b(lrows, hs, E, w_tokp, b_tokp), { w.emb, w.hh }, { w.hh }); + op_fdn = rw(b, gemm_b(lrows, hs, hs, w_fdn, b_fdn), { w.feat, w.hh }, { w.hh }); + for (int64_t l = 0; l < cfg.n_layer; ++l) { + const int i = (int)l; + op_anorm[i] = rw(b, rms(lrows, hs, w_anorm[i]), { w.hh }, { w.y }); + op_in[i] = rw(b, gemm_b(lrows, 3 * hs, hs, w_in[i], b_in[i]), { w.y }, { w.qkv }); + op_out[i] = rw(b, gemm_b(lrows, hs, hs, w_out[i], b_out[i]), { w.att, w.hh }, { w.hh }); + op_mnorm[i] = rw(b, rms(lrows, hs, w_mnorm[i]), { w.hh }, { w.y }); + op_up[i] = rw(b, gemm_b(lrows, cfg.mlp, hs, w_up[i], b_up[i]), { w.y }, { w.up }); + op_dn[i] = rw(b, gemm_b(lrows, hs, cfg.mlp, w_dn[i], b_dn[i]), { w.ups, w.hh }, { w.hh }); + } + op_attn = rw(b, RAD_OP(b, "lili_attn", + RAD_PARAMS(RAD_RANGE("M", 1, lrows), RAD_INT("steps", S), RAD_INT("k", K), + RAD_INT("n_head", cfg.n_head), + RAD_INT("head_dim", hs / cfg.n_head), + RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(w_rel, w_same)), + { w.qkv }, { w.att }); + op_silu_up = rw(b, silu(lrows, cfg.mlp), { w.up }, { w.ups }); + op_onorm = rw(b, rms(lrows, hs, w_onorm), { w.hh }, { w.y }); + /* The anchor: the context pass's row at each drafting sequence's last committed position. */ + op_anc = rw(b, RAD_OP(b, "gather_rows", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_seqs), RAD_INT("n", E), + RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + { w.c }, { w.anc }); + op_ctx = rw(b, gemm_b(g.max_seqs, hs, E, w_ctx, b_ctx), { w.anc }, { w.ast }); + op_annorm = rw(b, rms(g.max_seqs, hs, w_annorm), { w.ast }, { w.an }); + op_factor = rw(b, RAD_OP(b, "lili_factor", + RAD_PARAMS(RAD_RANGE("M", 1, lrows), RAD_INT("L", S * K), + RAD_INT("n", hs), RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + { w.y, w.an }, { w.cat }); + op_fac = rw(b, gemm_b(lrows, hs, 3 * hs, w_fac, b_fac), { w.cat }, { w.fh }); + op_silu_f = rw(b, silu(lrows, hs), { w.fh }, { w.fhs }); + op_edge = rw(b, gemm_b(lrows, 2 * fd, hs, w_edge, b_edge), { w.fhs }, { w.edges }); + op_aout = rw(b, gemm_b(g.max_seqs, fd, hs, w_aout, b_aout), { w.an }, { w.aout }); + op_walk = rw(b, RAD_OP(b, "lili_walk", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_seqs), RAD_INT("steps", S), + RAD_INT("k", K), RAD_INT("n", fd), RAD_STR("dtype", "bf16"), + RAD_F64("eps", cfg.vec_eps), RAD_F64("scale", cfg.scale)), + RAD_NOWEIGHTS), + { w.edges, w.aout, w.cand }, { w.tokens }); + if (!op_logits || !op_stats || (g.world > 1 && (!op_sgath || !op_emb_ar)) || !op_pas || + !op_cand || !op_emb || !op_tokp || !op_fdn || !op_attn || !op_silu_up || !op_onorm || + !op_anc || !op_ctx || !op_annorm || !op_factor || !op_fac || !op_silu_f || !op_edge || + !op_aout || !op_walk) + return RAD_E_INVAL; + return RAD_OK; +} + +inline void LiliCorr::step(RadCtx* c, const RadBatch* batch) const { + const int64_t n = batch->n_seq, S = n * cfg.steps, Lr = S * cfg.k; + if (n <= 0) return; + if (!batch->anchor_rows) { + rad_step_fail(c, "lilicorr: the query pass carries no anchor rows (RadBatch::anchor_rows): " + "this engine does not position a block drafter's anchor"); + return; + } + const int64_t E = g.n_embd, hs = cfg.hs, fd = cfg.fdim; + const int64_t sw = 2 + 2 * rk; + + RAD_ISSUE_N(c, op_logits, S, brows(w.sel_h, S), RAD_W(w_lm), brows(w.logits, S)); + RAD_ISSUE_N(c, op_stats, S, brows(w.logits, S), RAD_NONE, brows(w.stats, S)); + if (op_sgath) RAD_ISSUE(c, op_sgath, brows(w.stats, S), brows(w.sgath, S)); + RAD_ISSUE_N(c, op_pas, S, brows(w.sel_h, S), RAD_W(w_pass), RAD_W(b_pass), RAD_NONE, + brows(w.pas, S)); + RAD_ISSUE_N(c, op_cand, S, op_sgath ? brows(w.sgath, S) : brows(w.stats, S), brows(w.pas, S), + RAD_W(ln_w), RAD_W(ln_b), RAD_W(up_w), RAD_W(up_b), RAD_W(w_slot), RAD_W(w_rank), + brow_slice(w.cand, 0, Lr, 1), brows(w.feat, Lr), brows(w.hh, Lr)); + (void)sw; + + RAD_ISSUE_N(c, op_emb, Lr, brow_slice(w.cand, 0, Lr, 1), RAD_W(w_tok), brows(w.emb, Lr)); + if (op_emb_ar) RAD_ISSUE_N(c, op_emb_ar, Lr * E, brows(w.emb, Lr), RAD_NONE); + RAD_ISSUE_N(c, op_tokp, Lr, brows(w.emb, Lr), RAD_W(w_tokp), RAD_W(b_tokp), brows(w.hh, Lr), + brows(w.hh, Lr)); + RAD_ISSUE_N(c, op_fdn, Lr, brows(w.feat, Lr), RAD_W(w_fdn), RAD_W(b_fdn), brows(w.hh, Lr), + brows(w.hh, Lr)); + for (int64_t l = 0; l < cfg.n_layer; ++l) { + const int i = (int)l; + RAD_ISSUE_N(c, op_anorm[i], Lr, brows(w.hh, Lr), RAD_W(w_anorm[i]), brows(w.y, Lr)); + RAD_ISSUE_N(c, op_in[i], Lr, brows(w.y, Lr), RAD_W(w_in[i]), RAD_W(b_in[i]), RAD_NONE, + brows(w.qkv, Lr)); + RAD_ISSUE_N(c, op_attn, Lr, brows(w.qkv, Lr), RAD_W(w_rel), RAD_W(w_same), brows(w.att, Lr)); + RAD_ISSUE_N(c, op_out[i], Lr, brows(w.att, Lr), RAD_W(w_out[i]), RAD_W(b_out[i]), + brows(w.hh, Lr), brows(w.hh, Lr)); + RAD_ISSUE_N(c, op_mnorm[i], Lr, brows(w.hh, Lr), RAD_W(w_mnorm[i]), brows(w.y, Lr)); + RAD_ISSUE_N(c, op_up[i], Lr, brows(w.y, Lr), RAD_W(w_up[i]), RAD_W(b_up[i]), RAD_NONE, + brows(w.up, Lr)); + RAD_ISSUE_N(c, op_silu_up, Lr, brows(w.up, Lr), brows(w.ups, Lr)); + RAD_ISSUE_N(c, op_dn[i], Lr, brows(w.ups, Lr), RAD_W(w_dn[i]), RAD_W(b_dn[i]), + brows(w.hh, Lr), brows(w.hh, Lr)); + } + RAD_ISSUE_N(c, op_onorm, Lr, brows(w.hh, Lr), RAD_W(w_onorm), brows(w.y, Lr)); + + RAD_ISSUE_N(c, op_anc, n, RAD_B(w.c), praw(batch->anchor_rows, RAD_I32, n), brows(w.anc, n)); + RAD_ISSUE_N(c, op_ctx, n, brows(w.anc, n), RAD_W(w_ctx), RAD_W(b_ctx), RAD_NONE, brows(w.ast, n)); + RAD_ISSUE_N(c, op_annorm, n, brows(w.ast, n), RAD_W(w_annorm), brows(w.an, n)); + RAD_ISSUE_N(c, op_factor, Lr, brows(w.y, Lr), brows(w.an, n), brows(w.cat, Lr)); + RAD_ISSUE_N(c, op_fac, Lr, brows(w.cat, Lr), RAD_W(w_fac), RAD_W(b_fac), RAD_NONE, + brows(w.fh, Lr)); + RAD_ISSUE_N(c, op_silu_f, Lr, brows(w.fh, Lr), brows(w.fhs, Lr)); + RAD_ISSUE_N(c, op_edge, Lr, brows(w.fhs, Lr), RAD_W(w_edge), RAD_W(b_edge), RAD_NONE, + brows(w.edges, Lr)); + RAD_ISSUE_N(c, op_aout, n, brows(w.an, n), RAD_W(w_aout), RAD_W(b_aout), RAD_NONE, + brows(w.aout, n)); + RAD_ISSUE_N(c, op_walk, n, brows(w.edges, Lr), brows(w.aout, n), + brow_slice(w.cand, 0, Lr, 1), brows(w.tokens, n), RAD_NONE); + (void)E; (void)hs; (void)fd; +} + +} /* namespace arch */ +} /* namespace rad */ + +#endif /* RAD_BLOCK_LILICORR_H */ diff --git a/arch/common/rad_block_mlp_fp8.h b/arch/common/rad_block_mlp_fp8.h index d0dce54d..ce46da51 100644 --- a/arch/common/rad_block_mlp_fp8.h +++ b/arch/common/rad_block_mlp_fp8.h @@ -132,9 +132,9 @@ inline int MlpFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, co swiglu_limit)); /* The fold: decl_gated_fold (an fp8a8 tile) for block-fp8 weights, decl_gated_fold_mx for plain - * MXFP4 at one to 16 rows (eight where K is short). Other gate_up encodings (M2XFP4 included), - * and a clamped (swiglu_limit) product, take the pair. Over int8 codes only a host kernel would - * take it, which would pin the layer's weights to the host. */ + * MXFP4 at one to 16 rows (eight where K is short), decl_gated_fold_iqr for an IQR weight + * whose input and output are the rotated int8 trunk's fed pairs, to 16 rows. Other gate_up + * encodings (M2XFP4 included), and a clamped (swiglu_limit) product, take the pair. */ const bool fold_ok = swiglu_limit <= 0 && !gate_up.f32_scale; if (fold_ok && !gate_up.bf16 && !gate_up.mx && !gate_up.m2x && !gate_up.paro5 && !gate_up.w4 && !gate_up.i8) @@ -144,6 +144,14 @@ inline int MlpFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, co ? std::initializer_list{ w.ffn.q, w.ffn.s, w.ffn.x } : std::initializer_list{ w.ffn.q, w.ffn.s }, &gated_rows, wide_fold); + else if (fold_ok && gate_up.iqr && w.h.q8_fed && w.h.q8_rot && w.ffn.q8_fed && w.ffn.q8_rot) + op_gated = decl_gated_fold_iqr(b, g.max_tok, gate_up.N, gate_up.K, gate_up.w, gate_up.ws, + { w.h.q8, w.h.s8 }, + gq_ffn.want_x + ? std::initializer_list{ w.ffn.q8, w.ffn.s8, + w.ffn.x } + : std::initializer_list{ w.ffn.q8, w.ffn.s8 }, + &gated_rows); else if (fold_ok && gate_up.mx && !gate_up.paro) op_gated = decl_gated_fold_mx(b, g.max_tok, gate_up.N, gate_up.K, gate_up.w, gate_up.ws, gate_up.wref, { w.h.q, w.h.s }, @@ -207,10 +215,11 @@ inline void MlpFP8::body(RadCtx* c, int64_t T, int64_t r0, int64_t rows) const { brow_slice(w.ffn.s, r0, rows, g.n_ff / RAD_FP8_BLOCK), gq_ffn.want_x ? brow_slice(w.ffn.x, r0, rows, g.n_ff) : RAD_NONE); } else if (op_gated && rows <= gated_rows) { - RAD_ISSUE_N(c, op_gated, rows, brow_slice(w.h.q, r0, rows, g.n_embd), - brow_slice(w.h.s, r0, rows, g.n_embd / RAD_FP8_BLOCK), RAD_W(gate_up.w), - RAD_W(gate_up.ws), brow_slice(w.ffn.q, r0, rows, g.n_ff), - brow_slice(w.ffn.s, r0, rows, g.n_ff / RAD_FP8_BLOCK), + /* The fp8a8 fold's E4M3 pairs, or the IQR fold's int8 ones (cq / cs: the fed pair). */ + RAD_ISSUE_N(c, op_gated, rows, brow_slice(w.h.cq(), r0, rows, g.n_embd), + brow_slice(w.h.cs(), r0, rows, g.n_embd / RAD_FP8_BLOCK), RAD_W(gate_up.w), + RAD_W(gate_up.ws), brow_slice(w.ffn.cq(), r0, rows, g.n_ff), + brow_slice(w.ffn.cs(), r0, rows, g.n_ff / RAD_FP8_BLOCK), gq_ffn.want_x ? brow_slice(w.ffn.x, r0, rows, g.n_ff) : RAD_NONE); } else { gate_up.step(c, w.h, w.gate_up, T, r0, rows); diff --git a/arch/common/rad_block_moe_fp8.h b/arch/common/rad_block_moe_fp8.h index b862c1b8..b2d5cefa 100644 --- a/arch/common/rad_block_moe_fp8.h +++ b/arch/common/rad_block_moe_fp8.h @@ -182,8 +182,19 @@ struct MoeFP8 { /* Block-fp8 experts whose scale plane is f32 (format 9, dtype fp8a8f32). */ int expert_f32_scale = 0; double route_scale = 1.0; + /* With `sigmoid_router`: group-limited selection over `n_group` groups, `topk_group` kept + * (router_sigmoid_group_topk; Ling-3.0). 1 is GLM's single group. The fused selection and + * sort is single-group, so a grouped router runs the separate pair. */ + int64_t n_group = 1, topk_group = 1; /* Clamp of the SwiGLU product (swiglu_clamped); 0 is none. */ double swiglu_limit = 0.0; + /* The shared arm's clamp where it differs from the routed one (Ling-3.0 clamps its shared + * expert at 5 or 7 and its routed ones at 4, in different layers); negative: the routed + * arm's. */ + double shared_swiglu_limit = -1.0; + /* Clip after the SiLU (`swiglu_step`) rather than before it (`swiglu_clamped`), for both + * arms. */ + int swiglu_step = 0; /* With `swiglu_limit`: the clamped product and its quantiser as one launch * (GateQuantFP8::fuse_clamped), for the routed and the shared arm. */ int swiglu_quant = 0; @@ -196,6 +207,19 @@ struct MoeFP8 { * At TP1 the ungated gather preserves both roundings; TP>1 reduces each arm separately * before combining, so its gather cannot fold the shared output. */ int shared_fp32_combine = 0; + /* Experts without a gate (Nemotron-H): one projection up (`up_proj`), relu(x)^2, and down, + * so the first GEMM is n_ff_exp wide rather than 2 * n_ff_exp and the quantiser between + * the GEMMs squares rather than gates (GateQuantFP8's "relu2"). The routed arm only: such a + * family's shared expert is the caller's. */ + int ungated = 0; + /* The router's input width when it is not the experts' (Nemotron-H's latent experts: the + * router scores the full hidden state, the experts read a narrower projection of it, and + * this block's Geom is the experts'). 0 means n_embd. With it the router reads + * Wire::route. The sigmoid router only. */ + int64_t router_k = 0; + /* The caller reduces the block's delta across ranks, because it applies more linear work + * to it first (Nemotron-H's latent up-projection); no all-reduce is declared. */ + int no_reduce = 0; /* 4-bit experts (`i4*bf16[1x128]`) rather than E4M3 (`fp8_e4m3*bf16[128x128]`); for * Qwen3.8-Flash-Next this decides whether the model fits two cards (see the `moe_gemm_w4a8` * registry row). It is the stored encoding: probe() reads it from the first expert's @@ -267,6 +291,8 @@ struct MoeFP8 { struct Wire { rad_buf x = 0; /* [max_tok, n_embd] the residual stream */ ActFP8 h{}; /* [max_tok, n_embd] normed input, then the block's delta */ + /* The router's input when Config::router_k is set; `h` otherwise. */ + rad_buf route = 0; /* [max_tok, router_k] bf16 */ /* Rotated codes of the same input (only `q` and `s`; `x` is `h`'s). Declared only with * `expert_rot`: the routed gate_up reads them, the shared expert reads `h`'s. */ ActFP8 hr{}; /* [max_tok, n_embd] q + scale only */ @@ -547,17 +573,19 @@ inline int moe_expert_sources(RadBuilder* b, Names& nm, const char* tag, const c /* The gate_up and down name maps of one expert: a dim-0 slice of the stacked tensors, or the * checkpoint's per-expert gate and up joined along rows. `gate_up` false maps down alone. */ inline int moe_map_gate_up(RadBuilder* b, Names& nm, const MoeFP8::Src& src, const char* guw, - long long ge) { + long long ge, bool ungated = false) { if (src.experts_gate_up) return map_slice(b, guw, src.experts_gate_up, (int)ge); if (src.experts_gate && src.experts_up) return map_slice_concat(b, guw, {src.experts_gate, src.experts_up}, (int)ge); + /* Ungated experts (Nemotron-H) have no gate_proj: the first GEMM is up_proj alone. */ + if (ungated) return map_copy(b, guw, nm.ckpt("%s.%lld.up_proj.weight", src.experts, ge)); return map_concat(b, guw, {nm.ckpt("%s.%lld.gate_proj.weight", src.experts, ge), nm.ckpt("%s.%lld.up_proj.weight", src.experts, ge)}); } inline int moe_map_expert(RadBuilder* b, Names& nm, const MoeFP8::Src& src, const char* guw, const char* dnw, long long ge, bool gate_up) { - if (gate_up) RAD_ARCH_TRY(moe_map_gate_up(b, nm, src, guw, ge)); + if (gate_up) RAD_ARCH_TRY(moe_map_gate_up(b, nm, src, guw, ge, src.cfg.ungated)); if (src.experts_gate_up || src.experts_gate) return map_slice(b, dnw, src.experts_down, (int)ge); return map_copy(b, dnw, nm.ckpt("%s.%lld.down_proj.weight", src.experts, ge)); @@ -584,7 +612,7 @@ inline int MoeFP8::probe(RadBuilder* b, Names& nm, int l, const Src& src, Config int f = 0; for (long long ge = g0; ge < gn && ge <= g0 + kMaxProtected; ++ge) { const char* guw = nm.f("blk.%d.ffn_gate_up_exps.%lld.weight", l, ge); - RAD_ARCH_TRY(moe_map_gate_up(b, nm, src, guw, ge)); + RAD_ARCH_TRY(moe_map_gate_up(b, nm, src, guw, ge, cfg->ungated)); cfg->probed_count = ge - g0 + 1; RadEncoding e{}; f = 0; @@ -618,6 +646,8 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, int ar_in, bool ar_out_) { g = geom; c = src.cfg; w = wire; layer = l; ar_out = ar_out_; + if (c.n_group > 1) c.router_fuse = 0; + const double sh_limit = c.shared_swiglu_limit < 0 ? c.swiglu_limit : c.shared_swiglu_limit; /* 0 means not expert-parallel: this rank owns every expert. */ if (c.n_expert_all <= 0) c.n_expert_all = c.n_expert; if (c.n_expert <= 0 || c.top_k <= 0 || c.top_k > c.n_expert_all || c.n_ff_exp <= 0) @@ -639,6 +669,21 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, "BF16 shared arm and routed output\n", l); return RAD_E_INVAL; } + /* The first GEMM's rows per intermediate column (gate and up, or up alone) and the activation + * between the GEMMs. */ + const int64_t gu = c.ungated ? 1 : 2; + const char* const gact = c.ungated ? "relu2" : "silu"; + if (c.ungated && (shared || src.experts_gate_up || src.experts_gate || + c.swiglu_limit > 0)) { + fprintf(stderr, "radiance: ungated experts are served one by one (`up_proj`), unclamped and " + "without a shared arm in this block\n"); + return RAD_E_INVAL; + } + if (c.router_k && (!c.sigmoid_router || !w.route)) { + fprintf(stderr, "radiance: a router over another input than the experts' is the sigmoid " + "router reading Wire::route\n"); + return RAD_E_INVAL; + } /* Whether `w.sgate` is excluded from buffer sharing; set with the shared arm and required by * the fused router's gate write (see there). */ bool sgate_concurrent = false; @@ -764,9 +809,13 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, rc.rows = c.rows; rc.norm = c.norm_topk; rc.route_scale = c.route_scale; - const GlmRouter::Wire wire{ w.h.x, w.logits, w.ids, w.ew }; + rc.groups = c.n_group; + rc.topk_groups = c.topk_group; + const GlmRouter::Wire wire{ c.router_k ? w.route : w.h.x, w.logits, w.ids, w.ew }; const GlmRouter::Src rs{ src.router, src.router_bias }; - RAD_ARCH_TRY(glm_router.declare(b, nm, g, l, nm.f("blk.%d.glm_router", l), rc, wire, rs)); + Geom rg = g; + if (c.router_k) rg.n_embd = c.router_k; + RAD_ARCH_TRY(glm_router.declare(b, nm, rg, l, nm.f("blk.%d.glm_router", l), rc, wire, rs)); w_router = glm_router.projection; op_router = glm_router.op_project; op_topk = glm_router.op_select; @@ -931,7 +980,7 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, } const int sh_row = ep ? RAD_SHARD_NONE : RAD_SHARD_ROW; const int sh_col = ep ? RAD_SHARD_NONE : RAD_SHARD_COL; - const int n_parts = ep ? 0 : 2; + const int n_parts = ep ? 0 : (int)gu; /* The scale grid: one per 128x128 tile for E4M3, one per row per 128 of K for 4-bit (per 32 * for MXFP4). `sdiv` is how many weight rows or columns one scale covers along the split * dimension. */ @@ -969,10 +1018,10 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, return RAD_E_INVAL; } for (int64_t e = 0; e < ne; ++e) { - const int64_t parts[2] = { c.n_ff_exp, c.n_ff_exp }; + const int64_t parts[2] = { c.n_ff_exp, c.n_ff_exp }; /* gate, up (up alone: one) */ w_gu[(size_t)e] = decl_w_n(b, nm.f("blk.%d.ffn_gate_up_exps.%lld.weight", l, (long long)(c.expert_base + e)), - RAD_BF16, {2 * c.n_ff_exp, g.n_embd}, RAD_ACCESS_CONDITIONAL, + RAD_BF16, {gu * c.n_ff_exp, g.n_embd}, RAD_ACCESS_CONDITIONAL, sh_row, grp_expert_slot(l, (int)e, 0), 0, parts, n_parts); if (!w_gu[(size_t)e]) return RAD_E_INVAL; } @@ -986,7 +1035,7 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, /* Row orders as for the quantised GEMMs (see `a_order` below): gate_up gathers token rows, * down reads sorted rows. */ op_gu = rw(b, rad_decl_op(b, "moe_gemm", - RAD_PARAMS(RAD_RANGE("M", 1, c.rows), RAD_INT("N", 2 * c.n_ff_exp), + RAD_PARAMS(RAD_RANGE("M", 1, c.rows), RAD_INT("N", gu * c.n_ff_exp), RAD_INT("K", g.n_embd), RAD_INT("n_expert", ne), RAD_INT("top_k", c.top_k), RAD_STR("a_order", "token"), RAD_STR("dtype", "bf16")), @@ -996,8 +1045,8 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, * (rad_fp8.h: GateQuantFP8). */ Geom gx = g; gx.w_bf16 = true; - RAD_ARCH_TRY(gq_exp.declare(b, gx, w.egu, w.eff, c.n_ff_exp, "silu", c.rows * c.top_k, - true, false, c.swiglu_limit)); + RAD_ARCH_TRY(gq_exp.declare(b, gx, w.egu, w.eff, c.n_ff_exp, gact, c.rows * c.top_k, + true, false, c.swiglu_limit, c.swiglu_step != 0)); op_dn = rw(b, rad_decl_op(b, "moe_gemm", RAD_PARAMS(RAD_RANGE("M", 1, c.rows), RAD_INT("N", g.n_embd), RAD_INT("K", c.n_ff_exp), RAD_INT("n_expert", ne), @@ -1015,7 +1064,7 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, rad_weight& h = w_gu[(size_t)s]; h = decl_view(b, nm.f("blk.%d.ffn_gate_up_exps.%lld.weight", l, (long long)(c.expert_base + e)), - nullptr, ecodes, edt[0], {2 * wq[q], g.n_embd}, + nullptr, ecodes, edt[0], {gu * wq[q], g.n_embd}, RAD_ACCESS_CONDITIONAL, sh_row, grp_expert_slot(l, (int)s, 0), parts, n_parts); if (!h) return RAD_E_INVAL; @@ -1031,7 +1080,7 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, nm.f("blk.%d.ffn_gate_up_exps.%lld.weight", l, (long long)(c.expert_base + e)), escale, sdt, - {(c.expert_w4 || c.expert_mx) ? 2 * wq[q] : fp8_blocks(2 * wq[q]), + {(c.expert_w4 || c.expert_mx) ? gu * wq[q] : fp8_blocks(gu * wq[q]), (c.expert_w4 || c.expert_mx) ? g.n_embd / sgk : fp8_blocks(g.n_embd)}, RAD_ACCESS_CONDITIONAL, sh_row, grp_expert_slot(l, (int)s, 0), parts, n_parts); @@ -1107,22 +1156,22 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, const std::vector tab = tables(w_gu, w_gus); rad_op h = ncls == 4 ? rad_decl_op(b, "moe_gemm_q_mod4", - RAD_PARAMS(RAD_RANGE("M", 1, c.rows), RAD_INT("N", 2 * wq[0]), + RAD_PARAMS(RAD_RANGE("M", 1, c.rows), RAD_INT("N", gu * wq[0]), RAD_INT("K", g.n_embd), RAD_INT("n_expert", n_reg), RAD_INT("top_k", c.top_k), RAD_INT("group", RAD_FP8_BLOCK), RAD_STR("a_order", "token"), RAD_STR("dtype", edtype[0]), - RAD_INT("N_1", 2 * wq[1]), RAD_INT("K_1", g.n_embd), - RAD_INT("N_2", 2 * wq[2]), RAD_INT("K_2", g.n_embd), - RAD_INT("N_3", 2 * wq[3]), RAD_INT("K_3", g.n_embd), - RAD_INT("parts", 2)), + RAD_INT("N_1", gu * wq[1]), RAD_INT("K_1", g.n_embd), + RAD_INT("N_2", gu * wq[2]), RAD_INT("K_2", g.n_embd), + RAD_INT("N_3", gu * wq[3]), RAD_INT("K_3", g.n_embd), + RAD_INT("parts", gu)), tab.data(), (int)tab.size()) : rad_decl_op(b, "moe_gemm_q", - RAD_PARAMS(RAD_RANGE("M", 1, c.rows), RAD_INT("N", 2 * wq[0]), + RAD_PARAMS(RAD_RANGE("M", 1, c.rows), RAD_INT("N", gu * wq[0]), RAD_INT("K", g.n_embd), RAD_INT("n_expert", n_reg), RAD_INT("top_k", c.top_k), RAD_INT("group", RAD_FP8_BLOCK), RAD_STR("a_order", "token"), RAD_STR("dtype", edtype[0]), - RAD_INT("N_odd", 2 * wq[1]), RAD_INT("K_odd", g.n_embd), - RAD_INT("parts", 2)), + RAD_INT("N_odd", gu * wq[1]), RAD_INT("K_odd", g.n_embd), + RAD_INT("parts", gu)), tab.data(), (int)tab.size()); op_gu = rw(b, h, {rot ? w.hr.q : w.h.q, rot ? w.hr.s : w.h.s, w.sorted, w.eoff}, {w.egu}); } @@ -1130,8 +1179,8 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, * which takes the codes alone (no bf16 product is written), so the gated quantiser resolves to * the rotated op at no extra launch. */ gq_exp.fuse_clamped = c.swiglu_quant != 0; - RAD_ARCH_TRY(gq_exp.declare(b, g, w.egu, w.eff, c.n_ff_exp, "silu", c.rows * c.top_k, - false, rot, c.swiglu_limit)); + RAD_ARCH_TRY(gq_exp.declare(b, g, w.egu, w.eff, c.n_ff_exp, gact, c.rows * c.top_k, + false, rot, c.swiglu_limit, c.swiglu_step != 0)); { const std::vector tab = tables(w_dn, w_dns); rad_op h = ncls == 4 @@ -1184,7 +1233,7 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, * the plain even split with no span. */ psh_row = RAD_SHARD_ROW; psh_col = RAD_SHARD_COL; - pparts = 2; + pparts = (int)gu; if (full % g.world == 0 && (full / g.world) % 64 == 0) { wp = full / g.world; } else if (full % 64 || full / 64 < g.world) { @@ -1206,7 +1255,7 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, const int64_t parts[2] = { wp, wp }; w_pgu[(size_t)j] = decl_w_n(b, nm.f("blk.%d.ffn_gate_up_exps.%lld.weight", l, (long long)(c.expert_base + prot[(size_t)j])), - RAD_BF16, {2 * wp, g.n_embd}, RAD_ACCESS_PER_TOKEN, + RAD_BF16, {gu * wp, g.n_embd}, RAD_ACCESS_PER_TOKEN, psh_row, grp_layer(l), 0, parts, pparts); if (!w_pgu[(size_t)j]) return RAD_E_INVAL; if (phi > 0) RAD_ARCH_TRY(rad_weight_shard_span(b, w_pgu[(size_t)j], plo, phi)); @@ -1221,11 +1270,11 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, } /* The gate_up and gate outputs, bf16, one sorted row each; regular experts' rows are * unused. */ - b_pgu = decl_b(b, nm.f("blk.%d.moe_prot_gu", l), RAD_BF16, {c.rows * c.top_k, 2 * wp}); + b_pgu = decl_b(b, nm.f("blk.%d.moe_prot_gu", l), RAD_BF16, {c.rows * c.top_k, gu * wp}); pff.x = decl_b(b, nm.f("blk.%d.moe_prot_ff", l), RAD_BF16, {c.rows * c.top_k, wp}); if (!b_pgu || !pff.x) return RAD_E_INVAL; op_pgu = rw(b, rad_decl_op(b, "moe_gemm", - RAD_PARAMS(RAD_RANGE("M", 1, c.rows), RAD_INT("N", 2 * wp), + RAD_PARAMS(RAD_RANGE("M", 1, c.rows), RAD_INT("N", gu * wp), RAD_INT("K", g.n_embd), RAD_INT("n_expert", np), RAD_INT("top_k", c.top_k), RAD_STR("a_order", "token"), RAD_STR("dtype", "bf16")), @@ -1233,8 +1282,8 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, {w.h.x, w.sorted, w.eoff}, {b_pgu}); Geom gx = g; gx.w_bf16 = true; - RAD_ARCH_TRY(gq_prot.declare(b, gx, b_pgu, pff, wp, "silu", c.rows * c.top_k, true, - false, c.swiglu_limit)); + RAD_ARCH_TRY(gq_prot.declare(b, gx, b_pgu, pff, wp, gact, c.rows * c.top_k, true, + false, c.swiglu_limit, c.swiglu_step != 0)); op_pdn = rw(b, rad_decl_op(b, "moe_gemm", RAD_PARAMS(RAD_RANGE("M", 1, c.rows), RAD_INT("N", g.n_embd), RAD_INT("K", wp), RAD_INT("n_expert", np), @@ -1374,7 +1423,7 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, RAD_ARCH_TRY(rad_buf_concurrent(b, w.sff.q8)); RAD_ARCH_TRY(rad_buf_concurrent(b, w.sff.s8)); } - if (!w.sff.q || c.swiglu_limit>0 || (sh_down.reads_x && !(w.sff.q8_fed && sh_down.probed_i8))) + if (!w.sff.q || sh_limit>0 || (sh_down.reads_x && !(w.sff.q8_fed && sh_down.probed_i8))) RAD_ARCH_TRY(rad_buf_concurrent(b, w.sff.x)); RAD_ARCH_TRY(rad_buf_concurrent(b, w.sout)); RAD_ARCH_TRY(rad_buf_concurrent(b, w.sgate)); @@ -1391,7 +1440,7 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, gq_sh.fuse_clamped = c.swiglu_quant != 0; RAD_ARCH_TRY(gq_sh.declare(b, g, w.sgu, w.sff, c.n_ff_shared, "silu", c.rows, sh_down.reads_x && !(w.sff.q8_fed && sh_down.probed_i8), false, - c.swiglu_limit)); + sh_limit, c.swiglu_step != 0)); RAD_ARCH_TRY(sh_down.declare(b, nm, g, down_base, g.n_embd, c.n_ff_shared, RAD_SHARD_COL, grp_layer(l), { shared_down }, @@ -1515,7 +1564,7 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, } } - if (g.world > 1) { + if (g.world > 1 && !c.no_reduce) { const auto all_reduce = [&](const char* dtype, rad_buf buffer) { return rw(b, RAD_OP(b, "all_reduce", RAD_PARAMS(RAD_INT("world_size", g.world), @@ -1536,7 +1585,7 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, } /* The same collective for a caller that runs it beside other work (issue_ar, a pipelined * prefill): at `overlap` 1 it gets the rows that hold fewer CUs while waiting on the link. */ - if (g.world > 1 && ar_overlap > 0) + if (g.world > 1 && !c.no_reduce && ar_overlap > 0) op_ar_ov = rw(b, RAD_OP(b, "all_reduce", RAD_PARAMS(RAD_INT("world_size", g.world), RAD_RANGE("numel", g.n_embd, g.max_tok * g.n_embd), @@ -1784,6 +1833,9 @@ inline void MoeFP8::pass(RadCtx* c_, int64_t T, int64_t r0, int64_t rows, bool o (!calib_dne_failed && calib_dne.write(gram_dn_stem, c.expert_base, gram_domain, rad_rank(c_))); + /* Written: the host sums are done with (a layer's can be gigabytes). */ + calib_dne.acc = {}; + calib_dne.rows = {}; calib_done = true; if (layer == 0) std::fprintf(stderr, "radiance: calibration wrote layer Hessians after %lld " diff --git a/arch/common/rad_calib_full.h b/arch/common/rad_calib_full.h index 31e5dc85..8feb939a 100644 --- a/arch/common/rad_calib_full.h +++ b/arch/common/rad_calib_full.h @@ -25,7 +25,13 @@ * safetensors file per input, /.safetensors, holding `hessian_upper`, f32 * [k * (k + 1) / 2], row i's entries k2 = i .. k-1 after row i-1's, and metadata naming `k`, the * rows summed and the checkpoint linears that read the input. H is the raw sum; divide by `rows` - * for the mean second moment. */ + * for the mean second moment. + * + * An int8 trunk (site_i8, one rank only) is recorded from the codes and scales its GEMMs actually + * read, so H includes what the model's own quantisation did to the input -- the input a quantised + * model feeds each layer, for GPTQ against the error it inherits. Codes a rotating producer wrote + * are in the rotated domain; the file's metadata then names it (`domain`: the Hadamard width), as + * RADGRAM2's header does, and the reader converts. */ #pragma once #include @@ -52,6 +58,8 @@ struct CalibFull { rad_op op_gather = 0; /* the columns of every rank into `gathered`; 0 when replicated */ rad_op op_gram = 0; /* declared on the owner only */ bool owner = false; + rad_buf q8 = 0, s8 = 0; /* site_i8: the int8 codes and their f32 (row, 128) scales */ + uint32_t domain = 0; /* site_i8: the codes' rotation width, 0 for none */ std::vector tri; /* the owner's accumulator, upper triangle packed */ }; @@ -156,6 +164,32 @@ struct CalibFull { return RAD_OK; } + /* One input of layer `layer` from an int8 trunk's codes `q8` and scales `s8` (see the file + * comment): the whole input on one rank, `domain` the Hadamard width the codes were rotated by + * (0 for none). */ + int site_i8(RadBuilder* b, const Geom& g, int64_t layer, std::string stem, std::string linears, + rad_buf q8, rad_buf s8, int64_t K, uint32_t domain) { + if (world > 1 || !q8 || !s8 || K > kmax) return RAD_E_INVAL; + Site s; + s.stem = std::move(stem); + s.linears = std::move(linears); + s.K = s.k_local = K; + s.owner = true; + s.q8 = q8; + s.s8 = s8; + s.domain = domain; + (void)layer; + s.op_gram = rw(b, RAD_OP(b, "gram_accum", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", K), + RAD_INT("group", 128), RAD_STR("dtype", "i8a8"), + RAD_INT("upper", 1)), + RAD_NOWEIGHTS), + { q8, s8, scratch }, { scratch }); + if (!s.op_gram) return RAD_E_INVAL; + sites.push_back(std::move(s)); + return RAD_OK; + } + /* Site `i` over a step's T rows: gather (every rank), then on the owner the Gram into the * scratch, copied to a free square, the scratch zeroed, and the square handed to the worker. */ void tap(RadCtx* c, size_t i, int64_t T) { @@ -186,7 +220,10 @@ struct CalibFull { } } const int64_t K = s.K; - RAD_ISSUE_N(c, s.op_gram, T, a, RAD_NONE, praw2(dev, RAD_F32, K, K)); + if (s.q8) + RAD_ISSUE_N(c, s.op_gram, T, brows(s.q8, T), brows(s.s8, T), praw2(dev, RAD_F32, K, K)); + else + RAD_ISSUE_N(c, s.op_gram, T, a, RAD_NONE, praw2(dev, RAD_F32, K, K)); /* `upper` 1 writes no entry below the diagonal, so only the upper triangle comes back: * band by band of kBand rows, each from its first row's diagonal on, about half the * square's bytes. The link is what a step's taps wait on, 25 GB a step on each rank of @@ -317,7 +354,9 @@ private: const uint64_t bytes = (uint64_t)s.tri.size() * 4; std::string hdr = "{\"__metadata__\":{\"k\":\"" + std::to_string(s.K) + "\",\"rows\":\"" + std::to_string(seen) + "\",\"layout\":\"upper triangle, row-major, packed\"," - "\"linears\":\"" + s.linears + "\"},\"hessian_upper\":{\"dtype\":\"F32\"," + "\"linears\":\"" + s.linears + "\"" + + (s.domain ? ",\"domain\":\"" + std::to_string(s.domain) + "\"" : std::string()) + + "},\"hessian_upper\":{\"dtype\":\"F32\"," "\"shape\":[" + std::to_string(s.tri.size()) + "],\"data_offsets\":[0," + std::to_string(bytes) + "]}}"; while (hdr.size() % 8) hdr += ' '; diff --git a/arch/common/rad_fp8.h b/arch/common/rad_fp8.h index 7de7f18c..028fa09a 100644 --- a/arch/common/rad_fp8.h +++ b/arch/common/rad_fp8.h @@ -141,8 +141,9 @@ inline int QuantFP8::declare(RadBuilder* b, const Geom& g, const ActFP8& act, in if (g.w_bf16) { op = 0; return a.x ? RAD_OK : RAD_E_INVAL; } if (!a.x || !a.cq() || !a.cs() || n <= 0) return RAD_E_INVAL; /* `dtype` is the input's (bf16); the op name gives the output format. An input fed at int8 - * codes is quantised by quant_act_i8g into its int8 pair. */ - op = rw(b, RAD_OP(b, a.q8_fed ? "quant_act_i8g" : "quant_act_fp8", + * codes is quantised by quant_act_i8g into its int8 pair, or by had_quant_act_i8g where they + * are rotated (ActFP8::q8_rot). */ + op = rw(b, RAD_OP(b, a.q8_fed ? (a.q8_rot ? "had_quant_act_i8g" : "quant_act_i8g") : "quant_act_fp8", RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", n), RAD_INT("group", RAD_FP8_BLOCK), RAD_STR("dtype", g.dtype)), RAD_NOWEIGHTS), @@ -580,14 +581,20 @@ struct GateQuantFP8 { * not resolve: `silu_mul` into the bf16 plane (`op`), then `had_quant_act_fp8` over it into the * codes (`op_q`). */ rad_op op_q = 0; + /* act "relu2" (Nemotron-H's ungated experts): `gate_up` is one part, n wide, and `op` is + * act_mul's relu over it twice, relu(x)^2 into the bf16 plane, which `op_q` quantises (rotated + * for a rotated weight). No fused form yet: the plane is written either way. */ + bool ungated = false; /* Set before declare: the product in bf16 alone, as for bf16 linears, for a consumer that * quantises its input itself (an int8 linear's op_q). */ bool silu_only = false; + /* `step`: with `limit`, clip after the SiLU (`swiglu_step`, Ling-3.0) rather than before it + * (`swiglu_clamped`, GLM-5.3). It has no fused quantiser, so the pair runs. */ int declare(RadBuilder* b, const Geom& g, rad_buf gate_up, const ActFP8& act, int64_t n, const char* act_name = "silu", int64_t max_rows = 0, bool bf16_out = true, - bool rot = false, double limit = 0); + bool rot = false, double limit = 0, bool step = false); void step(RadCtx* c, rad_buf gate_up, int64_t T, int64_t r0 = 0, int64_t rows = 0) const; }; @@ -596,7 +603,7 @@ struct GateQuantFP8 { * bf16 output is unrotated either way. */ inline int GateQuantFP8::declare(RadBuilder* b, const Geom& g, rad_buf gate_up, const ActFP8& act, int64_t n, const char* act_name, int64_t max_rows, - bool bf16_out, bool rot, double limit) { + bool bf16_out, bool rot, double limit, bool step) { a = act; want_x = bf16_out; op_quant = 0; @@ -607,6 +614,28 @@ inline int GateQuantFP8::declare(RadBuilder* b, const Geom& g, rad_buf gate_up, clipped = limit > 0; clamped_fused = false; if (!std::isfinite(limit) || limit < 0) return RAD_E_INVAL; + ungated = std::strcmp(act_name, "relu2") == 0; + if (ungated) { + if (!gate_up || !a.x || n <= 0 || clipped || (!bf16 && (!a.cq() || !a.cs())) || + (rot && a.q8_fed)) + return RAD_E_INVAL; + const int64_t rows = max_rows > 0 ? max_rows : g.max_tok; + want_x = true; + op = rw(b, RAD_OP(b, "act_mul", + RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("n", n), RAD_STR("act", "relu"), + RAD_STR("dtype", g.dtype)), + RAD_NOWEIGHTS), + { gate_up }, { a.x }); + if (!op) return RAD_E_INVAL; + if (bf16) return RAD_OK; + const char* qn = rot ? "had_quant_act_fp8" : a.q8_fed ? "quant_act_i8g" : "quant_act_fp8"; + op_q = rw(b, RAD_OP(b, qn, + RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("n", n), + RAD_INT("group", RAD_FP8_BLOCK), RAD_STR("dtype", g.dtype)), + RAD_NOWEIGHTS), + { a.x }, { a.cq(), a.cs() }); + return op_q ? RAD_OK : RAD_E_INVAL; + } if (clipped) { /* No rotated int8 form: its quantiser would be quant_act_i8g, unrotated; and no clamp * with `silu_only`. */ @@ -614,7 +643,7 @@ inline int GateQuantFP8::declare(RadBuilder* b, const Geom& g, rad_buf gate_up, std::strcmp(act_name, "silu")) return RAD_E_INVAL; const int64_t rows = max_rows > 0 ? max_rows : g.max_tok; - if (fuse_clamped && !bf16 && !a.q8_fed && a.cq() && a.cs() && + if (fuse_clamped && !step && !bf16 && !a.q8_fed && a.cq() && a.cs() && rad_op_declared(b, "swiglu_clamped_quant_fp8")) { op = RAD_OP(b, "swiglu_clamped_quant_fp8", @@ -631,7 +660,7 @@ inline int GateQuantFP8::declare(RadBuilder* b, const Geom& g, rad_buf gate_up, } want_x = true; op = rw(b, - RAD_OP(b, "swiglu_clamped", + RAD_OP(b, step ? "swiglu_step" : "swiglu_clamped", RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("n", n), RAD_F64("limit", limit), RAD_STR("dtype", g.dtype)), RAD_NOWEIGHTS), @@ -701,6 +730,15 @@ inline int GateQuantFP8::declare(RadBuilder* b, const Geom& g, rad_buf gate_up, inline void GateQuantFP8::step(RadCtx* c, rad_buf gate_up, int64_t T, int64_t r0, int64_t rows) const { if (rows <= 0) rows = T - r0; + if (ungated) { + RAD_ISSUE_N(c, op, rows, brow_slice(gate_up, r0, rows, n), brow_slice(gate_up, r0, rows, n), + brow_slice(a.x, r0, rows, n)); + if (op_q) + RAD_ISSUE_N(c, op_q, rows, brow_slice(a.x, r0, rows, n), + brow_slice(a.cq(), r0, rows, n), + brow_slice(a.cs(), r0, rows, n / RAD_FP8_BLOCK)); + return; + } if (clamped_fused) { RAD_ISSUE_N(c, op, rows, brow_slice(gate_up, r0, rows, 2 * n), brow_slice(a.cq(), r0, rows, n), @@ -779,6 +817,13 @@ struct LinearFP8 { * writes E4M3. Read from the weight's encoding. */ bool i8 = false; rad_op op_q = 0; + /* An int8 weight stored rotated (i8a8h, or a rotated four- or five-bit one): its activation + * codes are in the 128-wide Hadamard domain, whoever wrote them (had_quant_act_i8g or a + * rotating producer). */ + bool i8_rot = false; + /* With i8_rot: an IQR weight (libr4d's r4d_iqr.h), whose codes decode where they are read: a + * u6 code under a zero, a table, a grid or a trellis. Read from the weight's encoding. */ + bool iqr = false; /* OCP-MXFP4 weight read by `gemm_nt_q` at dtype mxfp4a8 against the usual E4M3 activation pair: * e2m1 codes with one E8M0 exponent per 32 of K (libquant `codes=fp4_e2m1 group=32 * scale=e8m0`). libr4d folds each block's exponent into the e4m3 operand against a per-row @@ -1310,6 +1355,7 @@ inline int LinearFP8::declare(RadBuilder* b, Names& nm, const Geom& g, const cha const bool asym = known && linear_is_wnh(enc); const bool rot8 = known && (linear_is_w8h(enc) || asym); i8 = known && (linear_is_w8(enc) || rot8); + i8_rot = i8 && rot8; if (i8) { if (stored) { fprintf(stderr, "radiance: '%s' views '%s', which only a block-fp8 linear " @@ -1340,6 +1386,8 @@ inline int LinearFP8::declare(RadBuilder* b, Names& nm, const Geom& g, const cha const char* sn = nm.f("%s.scale", base); /* A narrower i8a8h weight's codes view takes the plane that decodes it too. */ const W8hForm form = linear_w8h_form(enc); + iqr = rot8 && !asym && (form == W8hForm::Zero || form == W8hForm::Table || + form == W8hForm::Grid || form == W8hForm::Trellis); const RadEncPlane* tpl = rad_enc_plane(&enc, "trellis"); const bool trb = form == W8hForm::Trellis && tpl && tpl->block[1] > 1; const char* cv = form == W8hForm::Zero ? "codes,zero" @@ -1829,6 +1877,23 @@ struct DenseFP8 { RAD_ARCH_TRY(rad_weight_shard_span(b, w, lo, hi)); return rad_weight_shard_span(b, s, lo / RAD_FP8_BLOCK, hi / RAD_FP8_BLOCK); } + /* This rank's rows [lo, hi) of a RAD_SHARD_ROW weight where the even shard is the wrong cut: a + * KV head replicated over ranks (Geom::kv_off), the same rows on every rank that shares it. + * Call after declare(), whose N is already hi - lo. The fp8 scale plane takes the span in its + * 128-row blocks; the MXFP4 and M2XFP4 planes are one row a weight row, as in LinearFP8. */ + int span(RadBuilder* b, int64_t lo, int64_t hi) const { + RAD_ARCH_TRY(rad_weight_shard_span(b, w, lo, hi)); + if (mx || m2x) { + RAD_ARCH_TRY(rad_weight_shard_span(b, s, lo, hi)); + return rad_weight_shard_span(b, ref, lo, hi); + } + if (lo % RAD_FP8_BLOCK || hi % RAD_FP8_BLOCK) { + fprintf(stderr, "radiance: a row span [%lld, %lld) is not whole %d-row scale blocks\n", + (long long)lo, (long long)hi, RAD_FP8_BLOCK); + return RAD_E_INVAL; + } + return rad_weight_shard_span(b, s, lo / RAD_FP8_BLOCK, hi / RAD_FP8_BLOCK); + } /* `gemm_nt_q` over this weight, `fp8a8`, `mxfp4a8` or `m2xfp4` as it was declared, ranged * M 1..hi. `split_n`, when set, is the stored width a row slice takes its K split from * (docs/OPS.md). */ @@ -1968,6 +2033,27 @@ inline rad_op decl_gated_fold_mx(RadBuilder* b, int64_t rows, int64_t N, int64_t return 0; } +/* The same fold over an IQR [2n, K] gate_up weight under the rotated int8 trunk (`gemm_nt_q_gated` + * at i8a8h: the codes and scale views gemm_nt_q reads, the input's and the output's int8 pairs, both + * in the Hadamard domain), declared for M up to min(rows, 16): libr4d's gemm_iqr_gated serves its + * GEMV and 16-token tile, each byte-identical to the GEMM row of its band followed by + * gated_had_quant_i8g. Optional like decl_gated_fold, and asked for only when a loaded library + * declares the op at that dtype: a CPU-only engine takes the pair. */ +inline rad_op decl_gated_fold_iqr(RadBuilder* b, int64_t rows, int64_t N, int64_t K, rad_weight w, + rad_weight ws, std::initializer_list reads, + std::initializer_list writes, int64_t* gated_rows) { + if (rows <= 0 || N % 256 || K % 256) return 0; + const int64_t hi = rows < 16 ? rows : 16; + const rad_op op = rw(b, RAD_OP(b, "gemm_nt_q_gated", + RAD_PARAMS(RAD_RANGE("M", 1, hi), RAD_INT("N", N), RAD_INT("K", K), + RAD_INT("group", RAD_FP8_BLOCK), RAD_STR("dtype", "i8a8h"), + RAD_STR("act", "silu")), + RAD_WEIGHTS(w, ws)), + reads, writes); + if (op) *gated_rows = hi; + return op; +} + /* ================================================== a calibration tap */ /* One tap of the GPTQ calibration (calib_dir): the Gram of a linear's bf16 input, summed over the * corpus in a PERSIST [K, K] f32 buffer that calib_write() saves. */ diff --git a/arch/gemma4_bf16/gemma4_bf16.cpp b/arch/gemma4_bf16/gemma4_bf16.cpp index 9a84cc0f..d65b1d99 100644 --- a/arch/gemma4_bf16/gemma4_bf16.cpp +++ b/arch/gemma4_bf16/gemma4_bf16.cpp @@ -1,5 +1,6 @@ /* gemma4_bf16.cpp -- Gemma 4 dense, bf16, with its vision tower (rad_block_gemma4_vision.h) and, - * for E2B/E4B, its audio encoder (rad_block_gemma4_audio.h). + * for E2B/E4B, its audio encoder (rad_block_gemma4_audio.h); for the 12B ("unified"), its image and + * audio embedders in their place (rad_block_gemma4_unified.h). * * Two attention classes over one residual stream, alternating by layer. A "sliding" layer is * sliding-window attention over head_dim 256 with a v projection and standard RoPE; a "global" @@ -17,6 +18,7 @@ */ #include #include +#include #include #include #include @@ -454,6 +456,16 @@ struct Gemma4Attn { * no library serves it, which the model reads as "no trees". */ bool tree = false; rad_op op_attn_tree = 0, op_tree_lift = 0; + /* Pictures read both ways (Model::bidi, set before declare; sliding layers only): attention + * again over a run's keys without the causal bound (RadBatch::n_bidi), reading q in the row + * (op_bidi_row) where the step's attention does, else in its own rows (op_bidi); 0 where no + * kernel serves it. */ + bool want_bidi = false; + rad_op op_bidi = 0, op_bidi_row = 0; + /* The same where the window bounds the keys behind a row only: a run longer than the window + * (op_ahead_row where q is read in the row); 0 where no kernel serves it. */ + rad_op op_ahead = 0, op_ahead_row = 0; + bool bidi_ok() const { return op_bidi || op_bidi_row; } /* the feed-forward's gate_up read into the cache beside this block's all-reduce, or 0 (see * "Prefetch beside the reductions") */ rad_op op_pf = 0; @@ -492,6 +504,9 @@ struct Gemma4Attn { bool slicable() const { return op_qnr_kv && (op_attn_row || op_attn); } void attend_rows(RadCtx* c, const RadBatch* batch, int64_t r0, int64_t n, RadOperand used) const; + /* The rows of each run read both ways, attended again (see op_bidi); `q_dense`: the step's + * attention left q in its own rows. */ + void attend_bidi(RadCtx* c, const RadBatch* batch, bool q_dense) const; }; int Gemma4Attn::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, const ClassGeom& cgeo, @@ -644,11 +659,12 @@ int Gemma4Attn::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, const /* Gemma 4 scores Q.K without the 1/sqrt(head_dim) factor (HF Gemma4TextAttention and vLLM * use scaling = 1.0; the q/k norm gains absorb it). attn_paged defaults to 1/sqrt(head_dim), * so 1.0 is passed explicitly. */ - auto attn = [&](const char* op, std::initializer_list rd, int64_t q_hi = 0) { + auto attn = [&](const char* op, std::initializer_list rd, int64_t q_hi = 0, + int causal = 1) { return rw(b, RAD_OP(b, op, RAD_PARAMS(RAD_RANGE("q_len", 1, q_hi > 0 ? q_hi : g.max_tok), RAD_INT("head_dim", cls.head_dim), - RAD_INT("gqa", cls.gqa()), RAD_INT("causal", 1), + RAD_INT("gqa", cls.gqa()), RAD_INT("causal", causal), RAD_INT("window", cls.window), RAD_INT("n_head", cls.n_head), RAD_INT("block_size", RAD_KV_BLOCK), RAD_INT("max_seqs", g.max_seqs), RAD_INT("max_ctx", g.max_ctx), @@ -729,6 +745,15 @@ int Gemma4Attn::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, const op_attn = attn("attn_paged", {w.q, w.qkv}); } } + if (want_bidi) { + if (op_attn_row) { + op_bidi_row = attn("attn_paged_qrow", {w.qkv}, 0, 0); + op_ahead_row = attn("attn_paged_qrow_ahead", {w.qkv}, 0, 0); + } else { + op_bidi = attn("attn_paged", {w.q}, 0, 0); + op_ahead = attn("attn_paged_ahead", {w.q}, 0, 0); + } + } /* The tree form over the decode rows: a verify block of 1 + n_spec rows a sequence, so the * split-KV band (q_len * gqa <= 64) covers it at every class here. In the row where the @@ -855,6 +880,23 @@ int Gemma4Attn::declare_shared(RadBuilder* b, Names& nm, const char* pre) { RAD_STR("q_dtype", g.dtype), RAD_STR("kv_dtype", g.kv_dtype)), RAD_NOWEIGHTS), {w.q}, {w.attn}); + if (want_bidi) { + auto bidi = [&](const char* op) { + return rw(b, RAD_OP(b, op, + RAD_PARAMS(RAD_RANGE("q_len", 1, g.max_tok), + RAD_INT("head_dim", cls.head_dim), + RAD_INT("gqa", cls.gqa()), RAD_INT("causal", 0), + RAD_INT("window", cls.window), RAD_INT("n_head", cls.n_head), + RAD_INT("block_size", RAD_KV_BLOCK), + RAD_INT("max_seqs", g.max_seqs), RAD_INT("max_ctx", g.max_ctx), + RAD_F64("scale", 1.0), + RAD_STR("q_dtype", g.dtype), RAD_STR("kv_dtype", g.kv_dtype)), + RAD_NOWEIGHTS), + {w.q}, {w.attn}); + }; + op_bidi = bidi("attn_paged"); + op_ahead = bidi("attn_paged_ahead"); + } if (g.world > 1) op_ar = rw(b, RAD_OP(b, "all_reduce", RAD_PARAMS(RAD_INT("world_size", g.world), RAD_RANGE("numel", g.n_embd, g.max_tok * g.n_embd), @@ -963,6 +1005,7 @@ void Gemma4Attn::attend(RadCtx* c, const RadBatch* batch) const { RAD_NONE, RAD_NONE, praw(batch->cu_seqlens, RAD_I32, batch->n_seq + 1), brows(w.attn, T)); + attend_bidi(c, batch, true); return; } /* q, k and v where the prologue works on them: their own buffers, or on a fused layer with the @@ -1001,6 +1044,7 @@ void Gemma4Attn::attend(RadCtx* c, const RadBatch* batch) const { * which come first (spec §8). */ const bool tree_step = op_attn_tree && batch->spec_parent && batch->draft_pass == 0 && batch->n_seq_decode > 0; + bool q_dense = true; if (!tree_step || batch->n_seq_decode < batch->n_seq) { /* attn_paged reads q dense: one row of the row's slice is, a taller step copies q out. */ rad_op a_op = op_attn; @@ -1011,8 +1055,9 @@ void Gemma4Attn::attend(RadCtx* c, const RadBatch* batch) const { } else if (op_attn_dec && batch->max_q_len <= dec_hi) { a_op = op_attn_dec; a_q = Q; + q_dense = false; } else if (row) { - if (T == 1) a_q = Q; + if (T == 1) { a_q = Q; q_dense = false; } else RAD_ISSUE_N(c, op_lift_q, T, Q, brows(w.q, T)); } RAD_ISSUE_N(c, a_op, batch->max_q_len, @@ -1039,6 +1084,44 @@ void Gemma4Attn::attend(RadCtx* c, const RadBatch* batch) const { brows(w.attn, Td), praw(batch->spec_parent, RAD_I32, Td)); } + attend_bidi(c, batch, q_dense); +} + +/* A run's rows (RadBatch::n_bidi) see every key of their run, later ones included: attention over + * their sequence's cache up to the run's end without the causal bound, written over what the + * causal pass left in their rows, on a sliding layer. Its window stays: (causal or the run) and + * the window, as transformers' mask has it. The window bounds the keys behind a row; within it a + * run's far end is in reach of every row up to the window's length, and a longer run is read with + * attn_paged_ahead, whose window bounds the keys behind only. The keys are all in the cache: the + * step stored its own, and a run's earlier rows are this step's or a prefix hit's. */ +void Gemma4Attn::attend_bidi(RadCtx* c, const RadBatch* batch, bool q_dense) const { + if (batch->n_bidi <= 0 || !bidi_ok()) return; + const RadKVGroupBatch* kvb = kv_batch(batch, kv); + const int32_t* table = kvb ? kvb->block_table : nullptr; + const int64_t pitch = kvb ? kvb->block_table_pitch : 0; + const int64_t qd = cls.q_dim(), kvd = cls.kv_dim(); + const int64_t qkvd = qd + kvd + (cls.has_v ? kvd : 0); + for (int64_t i = 0; i < batch->n_bidi; ++i) { + const int64_t r0 = batch->bidi_row[i], n = batch->bidi_n[i], s = batch->bidi_seq[i]; + const RadOperand tb = praw2(table ? table + s * pitch : nullptr, RAD_I32, 1, pitch); + const RadOperand used = praw(batch->bidi_used + i, RAD_I32, 1); + const RadOperand out = brow_slice(w.attn, r0, n, qd); + /* A run longer than the window has rows that miss its far end under a two-sided window; + * transformers' mask bounds only the keys behind. */ + const bool ahead = n > cls.window; + const rad_op bidi_row = ahead && op_ahead_row ? op_ahead_row : op_bidi_row; + const rad_op bidi = ahead && op_ahead ? op_ahead : op_bidi; + if (op_bidi_row) { + RAD_ISSUE_N(c, bidi_row, n, bcol_at(w.qkv, r0, qkvd, 0, qd, n), + kv_cache(kv, kv_layer), tb, used, RAD_NONE, RAD_NONE, RAD_NONE, out); + continue; + } + if (!q_dense) + RAD_ISSUE_N(c, op_lift_q, n, bcol_at(w.qkv, r0, qkvd, 0, qd, n), + brow_slice(w.q, r0, n, qd)); + RAD_ISSUE_N(c, bidi, n, brow_slice(w.q, r0, n, qd), kv_cache(kv, kv_layer), tb, used, + RAD_NONE, RAD_NONE, RAD_NONE, out); + } } /* A slice's rows see exactly the keys they see in the whole step: the cache holds the step's @@ -1414,10 +1497,11 @@ struct Gemma4Head { void step(RadCtx* c, const RadBatch* batch) const; }; -/* Does the container carry an assistant head at all? */ +/* Does the container carry an assistant head at all? The 12B's is the same head under another + * name (Gemma4UnifiedAssistantForCausalLM). */ static bool has_assistant(const RadModelMeta* m) { const char* a = rad_meta_gets(m, "draft.architectures", ""); - return a && std::strstr(a, "Gemma4Assistant") != nullptr; + return a && (std::strstr(a, "Gemma4Assistant") || std::strstr(a, "Gemma4UnifiedAssistant")); } int Gemma4Head::declare(RadBuilder* b, Names& nm, const RadModelMeta* meta, const Geom& trunk, @@ -1459,16 +1543,17 @@ int Gemma4Head::declare(RadBuilder* b, Names& nm, const RadModelMeta* meta, cons } /* The head reads the trunk's cache, so everything the cache's shape depends on must agree: * the two head widths, the two kv head counts and the window. A head that disagrees was trained - * with another trunk. */ + * with another trunk. The counts are the model's, not a rank's: a replicated kv head (fewer + * than ranks) is one head on every rank. */ if (n_trunk != trunk.n_embd || vocab != trunk.n_vocab_all || head_s != cs.head_dim || - head_g != cg.head_dim || n_kv != cs.n_head_kv * trunk.world || - n_kv_g != cg.n_head_kv * trunk.world || win != cs.window) { + head_g != cg.head_dim || n_kv != cs.n_head_kv_all || n_kv_g != cg.n_head_kv_all || + win != cs.window) { fprintf(stderr, "radiance: gemma4 assistant: this head was not made for this trunk -- it " "states width %lld, vocabulary %lld, heads %lld/%lld x %lld/%lld kv over a " "window of %lld; the trunk's cache is %lld/%lld kv heads of %lld/%lld over " "%lld, at width %lld and vocabulary %lld\n", (long long)n_trunk, vocab, n_kv, n_kv_g, head_s, head_g, win, - (long long)(cs.n_head_kv * trunk.world), (long long)(cg.n_head_kv * trunk.world), + (long long)cs.n_head_kv_all, (long long)cg.n_head_kv_all, (long long)cs.head_dim, (long long)cg.head_dim, (long long)cs.window, (long long)trunk.n_embd, (long long)trunk.n_vocab_all); return RAD_E_INVAL; @@ -1888,7 +1973,13 @@ struct Model { * embeddings. */ Gemma4Vision vis{}; Gemma4Audio aud{}; + Gemma4UnifiedVision uvis{}; /* the 12B's embedders, in place of the tower and encoder */ + Gemma4UnifiedAudio uaud{}; rad_op op_mm = 0; + /* A picture's or video frame's placeholders attend to each other both ways + * (use_bidirectional_attention "vision"): every sliding layer attends a run's rows again + * (Gemma4Attn::op_bidi), and the encoder says so (RadEncoderDecl::bidirectional). */ + bool bidi = false; G4Junction j0{}; /* the first block's entry: norm + quantiser of the embedding stream */ bool fuse = false; @@ -2404,8 +2495,10 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c * the lookup and before its all-reduce (RadBatch::mm_embd: rank 0 holds the rows, every other * rank zeros). The reference scales token embeddings by sqrt(n_embd) and scatters the media * features in unscaled. */ - if ((Gemma4Vision::present(meta) && ctx->max_enc_patches > 0) || - (Gemma4Audio::present(meta) && ctx->max_audio_frames > 0)) + if (((Gemma4Vision::present(meta) || Gemma4UnifiedVision::present(meta)) && + ctx->max_enc_patches > 0) || + ((Gemma4Audio::present(meta) || Gemma4UnifiedAudio::present(meta)) && + ctx->max_audio_frames > 0)) m.op_mm = rw(b, RAD_OP(b, "scatter_rows", RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", g.n_embd), RAD_STR("dtype", "bf16")), @@ -2508,10 +2601,18 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c kv_shared == 0 && ctx->draft_tree != 0; bool tree_all = tree_want; + /* Pictures read both ways where the model was trained so, on the sliding layers alone: the + * global layers stay causal (transformers' create_masks_for_vision_model, "Gemma 4 explicitly + * disables bidirectional attention on global attention layers"; KerasHub's Gemma 4 decoder + * block and vLLM agree). */ + const char* bidi_cfg = meta_text_gets(meta, "use_bidirectional_attention", ""); + const bool want_bidi = bidi_cfg && !std::strcmp(bidi_cfg, "vision") && ctx->max_enc_patches > 0 && + (Gemma4Vision::present(meta) || Gemma4UnifiedVision::present(meta)); m.layers.resize((size_t)m.n_main); for (int64_t l = 0; l < m.n_main; ++l) { Layer& lay = m.layers[(size_t)l]; lay.global = (is_global[(size_t)l] == 1); + lay.attn.want_bidi = want_bidi && !lay.global; const ClassGeom& cgeo = lay.global ? m.cg : m.cs; const rad_kvgroup kg = lay.global ? m.kv_g : m.kv_s; const Gemma4Attn::Wire& aw = lay.global ? gw : sw; @@ -2818,11 +2919,19 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c std::snprintf(k, sizeof k, "%snum_hidden_layers", drafter_layer_prefix(meta)); head_groups = rad_meta_geti(meta, k, 0); } + m.bidi = want_bidi; + for (const Layer& lay : m.layers) m.bidi = m.bidi && (lay.global || lay.attn.bidi_ok()); + if (want_bidi && !m.bidi) + rad_note(b, "pictures are read causally: no kernel attends a run's rows without the " + "causal bound"); + m.vis.bidirectional = m.uvis.bidirectional = m.bidi; RAD_ARCH_TRY(m.vis.declare(b, meta, ctx, nm, g.n_embd, (int)(m.n_main + head_groups), "model.", "gemma4_bf16")); RAD_ARCH_TRY(m.aud.declare(b, meta, ctx, nm, g.n_embd, (int)(m.n_main + head_groups) + (int)m.vis.L.size(), "model.", "gemma4_bf16")); + RAD_ARCH_TRY(m.uvis.declare(b, meta, ctx, nm, g.n_embd, "gemma4_bf16")); + RAD_ARCH_TRY(m.uaud.declare(b, meta, ctx, nm, g.n_embd, "gemma4_bf16")); } rad_note(b, "rank %d/%d: %lld layers (%lld global, %lld sliding), sliding window %lld, " @@ -2954,7 +3063,7 @@ static void trunk_overlap(RadCtx* c, const Model& m, const RadBatch* batch, int6 m.j0.step(c, T); const size_t L = m.layers.size(); - if (m.slice_attn && batch->n_seq == 1) { + if (m.slice_attn && batch->n_seq == 1 && batch->n_bidi == 0) { /* Attention per slice (see Model::slice_attn): slice A's context end first, then each * layer as A's attention block, B's beside A's attention-side reduction, A's feed-forward * beside B's, B's feed-forward beside A's, and the next layer's A block beside B's. Each @@ -3050,8 +3159,14 @@ static void step(RadCtx* c, const RadBatch* batch) { /* An encoder pass runs only its encoder. */ if (batch->enc) { - if (batch->enc == RAD_MM_AUDIO) m.aud.step(c, batch); - else m.vis.step(c, batch); + if (batch->enc == RAD_MM_AUDIO) { + if (m.uaud.on) m.uaud.step(c, batch); + else m.aud.step(c, batch); + } else if (m.uvis.on) { + m.uvis.step(c, batch); + } else { + m.vis.step(c, batch); + } return; } /* A draft pass runs only the draft model. The trunk already left its final-normed hidden state @@ -3192,12 +3307,15 @@ static int probe(const RadModelMeta* meta, RadArchProbe* out) { if (k > 0) out->enc_merge = k * k; } if (Gemma4Audio::present(meta)) out->audio_frames = Gemma4Audio::frames_for(meta); + /* The 12B's embedders: a patch and an audio frame are a row each. */ + if (Gemma4UnifiedVision::present(meta)) out->enc_merge = 1; + if (Gemma4UnifiedAudio::present(meta)) out->audio_frames = Gemma4UnifiedAudio::frames_for(meta); return RAD_OK; } #ifndef RAD_ARCH_NO_EXPORTS RAD_ARCH_PLUGIN(gemma4_bf16, "gemma4", "compressed-tensors", "0.1.0", - "Gemma 4 dense (text, images and E2B/E4B audio), w4a8 or w8a8 from its bf16 or its CT-INT4 (QAT) " + "Gemma 4 dense (text, images, E2B/E4B/12B audio), w4a8 or w8a8 from its bf16 or its CT-INT4 (QAT) " "release: sliding-window and proportional-RoPE global attention over a plain " "RMSNorm stream with GELU feed-forward, per-layer scalar scaling and soft-capped " "logits; Google's assistant head, z-lab's DFlash drafter or a DFlash2 drafter") diff --git a/arch/glm5next/glm5next.cpp b/arch/glm5next/glm5next.cpp index 39d514ed..4599aff9 100644 --- a/arch/glm5next/glm5next.cpp +++ b/arch/glm5next/glm5next.cpp @@ -50,6 +50,12 @@ struct Model { * form declares none of the row form's full-width weights (1.29 GiB a card at eight ranks); * the row form is opt-in because it is not bit-identical to it (docs/ARCHITECTURES.md). */ GlmMla::Form form = GlmMla::Form::heads; + /* Routed experts whole on their rank (288/world of them) instead of split by width across + * every rank. Whole experts can be read from the drive, which two cards need; at four and + * eight the width split is the shape the MXFP4 kernels are tuned for (prefill runs about three + * times faster), so all-MXFP4 experts take it unless --weights-disk-tier asks for the drive. + * Anything else stays whole: a plain bf16 expert cannot be sliced at all. */ + bool whole_experts = false; std::vector layers; rad_kvgroup latent = 0, index = 0, tail = 0, state = 0, conv = 0; /* The streams and the step's stream-wide buffers. */ @@ -76,6 +82,23 @@ struct Model { static std::unique_ptr models[MAX_RANKS]; static thread_local std::unique_ptr probe_model; +/* Whether every routed expert is MXFP4, asked before any buffer is sized and of the same experts on + * every rank, so all ranks reach the same layout. It reads the container's entries and declares no + * name map, so it leaves the graph as it was. One expert in another format settles it: a protected + * bf16 expert is served only whole. No answer means no container entry, and what is not known to + * be MXFP4 stays whole. */ +static bool experts_are_mxfp4(RadBuilder* b, Names& nm) { + for (int l = 3; l < 45; ++l) + for (int ge = 0; ge < 288; ++ge) + for (const char* fmt : { "blk.%d.ffn_gate_up_exps.%d.weight", + "blk.%d.ffn_down_exps.%d.weight" }) { + RadEncoding e{}; + if (!weight_enc(b, nm.f(fmt, l, ge), &e) || MoeFP8::format_of(e) != 8) + return false; + } + return true; +} + static int64_t cfg(const RadModelMeta* m, const char* key, int64_t fallback) { char nested[160]; std::snprintf(nested, sizeof nested, "text_config.%s", key); @@ -211,6 +234,7 @@ static int indexer_buffers(RadBuilder* b, Model& m) { * at 64k of context the whole step's plane would be 256 MiB. */ const int64_t scored = g.world > 1 ? std::min(T, std::max(part, GlmTp::kSplitRows)) : T; c.score = decl_b(b, nm.f("index_scores"), RAD_F32, { scored, blocks }); + c.unscored = decl_b(b, nm.f("index_unscored"), RAD_F32, { T, std::min(513, blocks) }); c.selected = m.aw.core.selected; c.length = m.aw.core.length; c.nsel = decl_b(b, nm.f("selected_count"), RAD_I32, { T }); @@ -243,13 +267,18 @@ static int ffn_buffers(RadBuilder* b, Model& m) { mw.ids = decl_b(b, nm.f("expert_ids"), RAD_I32, { T, 8 }); mw.ew = decl_b(b, nm.f("expert_weights"), RAD_F32, { T, 8 }); mw.eoff = decl_b(b, nm.f("expert_offsets"), RAD_I32, { 289 }); - mw.ecnt = decl_b(b, nm.f("expert_counts"), RAD_I32, { 288 }); + /* PERSIST, as every other MoE here declares it: the router writes the counts and no declared + * op reads them (rad_route_report is a handoff), so as a transient a later buffer could share + * their bytes and an arena level would move them, while the core copies them at the block's + * end and the file stager reads them, through the address the last pass reported, at the + * layer's first expert op. */ + mw.ecnt = decl_b(b, nm.f("expert_counts"), RAD_I32, { 288 }, RAD_BUF_PERSIST); mw.sorted = decl_b(b, nm.f("expert_sorted"), RAD_I32, { T * 8 }); mw.inv = decl_b(b, nm.f("expert_inverse"), RAD_I32, { T * 8 }); - // FE: the routed experts' WHOLE intermediate (2048). Under expert parallelism a rank owns - // whole experts, so the routed arm's buffers are full-width at every world size; the SHARED - // expert stays width-sharded (F). The two coincide at world 1. - const int64_t FE = 2048; + // FE: the routed experts' intermediate. Under expert parallelism a rank owns whole experts, + // so the routed arm's buffers are full-width (2048); split by width they are F. The SHARED + // expert stays width-sharded (F) either way. The two coincide at world 1. + const int64_t FE = m.whole_experts ? 2048 : F; mw.egu = decl_b(b, nm.f("expert_gate_up"), RAD_BF16, { T * 8, 2 * FE }); mw.eff.x = decl_b(b, nm.f("expert_ff"), RAD_BF16, { T * 8, FE }); RAD_ARCH_TRY(mw.eff.declare_qs(b, nm, g, "expert_ff", FE, T * 8)); @@ -266,7 +295,8 @@ static int kv_groups(RadBuilder* b, Model& m) { auto& nm = m.nm; RadKVGroupDecl d{}; d.kind = RAD_KV_FULL; - d.dtype = RAD_BF16; + // bf16, or E4M3 under --kv-cache-dtype fp8 (geometry); the other groups keep their own. + d.dtype = rad_dtype_parse(g.kv_dtype); d.n_head_kv = 1; d.head_dim = 256; m.latent = rad_decl_kv_group(b, nm.f("kv_latent"), &d); @@ -373,14 +403,19 @@ static int layer(RadBuilder* b, Model& m, Layer& lay, Names& nm, int l, bool dra // degenerates to the old whole-model declaration (n_expert == n_expert_all, no spans). s.cfg.n_expert_all = 288; s.cfg.top_k = 8; - s.cfg.n_expert = 288 / g.world; - // A shape probe may pass rank >= world (arch_test's parallel declares reuse i % 4); - // old code tolerated that because expert_base stayed 0, so clamp to rank 0's window. - const int ep_rank = g.rank < g.world ? g.rank : 0; - s.cfg.expert_base = ep_rank * (288 / g.world); - s.cfg.probed_expert = s.cfg.expert_base; // probe this rank's first owned expert - s.cfg.n_ff_exp = 2048; // whole: whole experts' intermediate - s.cfg.n_ff_shared = 2048 / g.world; + s.cfg.n_ff_shared = GlmTp::expert_width(g.world); + if (m.whole_experts) { + s.cfg.n_expert = 288 / g.world; + // A shape probe may pass rank >= world (arch_test's parallel declares reuse i % 4); + // old code tolerated that because expert_base stayed 0, so clamp to rank 0's window. + const int ep_rank = g.rank < g.world ? g.rank : 0; + s.cfg.expert_base = ep_rank * (288 / g.world); + s.cfg.probed_expert = s.cfg.expert_base; // probe this rank's first owned expert + s.cfg.n_ff_exp = 2048; // whole: whole experts' intermediate + } else { + s.cfg.n_expert = 288; + s.cfg.n_ff_exp = GlmTp::expert_width(g.world); + } s.cfg.rows = g.max_tok; s.cfg.sigmoid_router = 1; s.cfg.route_scale = 2.5; @@ -389,12 +424,12 @@ static int layer(RadBuilder* b, Model& m, Layer& lay, Names& nm, int l, bool dra s.cfg.router_fuse = 1; s.cfg.swiglu_quant = 1; // At world 1 the width-slice declaration IS the whole model: keep the spans so the - // graph stays the pinned one. At world > 1 expert parallelism is in force and whole - // experts need no width spans (split && ep is refused by the helper). - if (g.world == 1) { + // graph stays the pinned one. Whole experts need no width spans (split && ep is refused + // by the helper). + if (!m.whole_experts) { for (int q = 0; q < 2; ++q) { - s.cfg.ff_lo[q] = g.rank * (2048 / g.world); - s.cfg.ff_hi[q] = (g.rank + 1) * (2048 / g.world); + s.cfg.ff_lo[q] = g.rank * GlmTp::expert_width(g.world); + s.cfg.ff_hi[q] = (g.rank + 1) * GlmTp::expert_width(g.world); } } RAD_ARCH_TRY(MoeFP8::probe(b, nm, l, s, &s.cfg)); @@ -430,6 +465,9 @@ static int geometry(Geom& g, const RadModelMeta* meta, const RadBuildCtx* ctx, i g.max_logit_rows = std::min(g.max_tok, g.max_seqs * (g.max_spec + 1)); if (ctx->max_out_rows > g.max_logit_rows) g.max_logit_rows = ctx->max_out_rows; g.eps = meta->rms_eps; + /* --kv-cache-dtype names the latent cache's dtype only (kv_groups); declare refuses all but + * bf16 and fp8. */ + g.kv_dtype = rad_dtype_name(rad_kv_cache_dtype(ctx, RAD_BF16)); g.wire_exact = !ctx->tp_wire_lossy; g.wire_min_bytes = ctx->tp_wire_min_bytes; return g.max_tok < 1 || g.max_ctx < 1 || g.max_seqs < 1 || g.eps <= 0 ? RAD_E_INVAL : RAD_OK; @@ -468,11 +506,12 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c ctx->max_spec); return RAD_E_UNSUPPORTED; } - if (ctx->kv_dtype && ctx->kv_dtype != RAD_BF16) { - fprintf(stderr, "radiance: glm5next: --kv-cache-dtype %s; this plugin keeps its latent " - "attention, index tail and KDA caches in bf16 and has no fp8 cache, so " - "run it with --kv-cache-dtype bf16\n", - ctx->kv_dtype == RAD_F8E4M3 ? "fp8" : rad_dtype_name(ctx->kv_dtype)); + /* fp8 narrows the latent attention cache to E4M3 at a descale of 1 (kv_groups); the index + * tail, the DSA index and the KDA caches keep their dtypes. */ + if (ctx->kv_dtype && ctx->kv_dtype != RAD_BF16 && ctx->kv_dtype != RAD_F8E4M3) { + fprintf(stderr, "radiance: glm5next: --kv-cache-dtype %s; this plugin serves its latent " + "attention cache in bf16 or fp8 only\n", + rad_dtype_name(ctx->kv_dtype)); return RAD_E_UNSUPPORTED; } auto& slot = ctx->shape_probe ? probe_model : models[ctx->rank]; @@ -483,6 +522,8 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c auto& nm = m.nm; m.form = ctx->tp_attn_rows ? GlmMla::Form::rows : GlmMla::Form::heads; RAD_ARCH_TRY(geometry(g, meta, ctx, world)); + m.whole_experts = world == 2 || (world > 2 && (ctx->expert_file_tier || + !experts_are_mxfp4(b, nm))); RAD_ARCH_TRY(stream_buffers(b, m)); RAD_ARCH_TRY(kda_buffers(b, m)); RAD_ARCH_TRY(mla_buffers(b, m)); diff --git a/arch/hunyuan3d2/CMakeLists.txt b/arch/hunyuan3d2/CMakeLists.txt new file mode 100644 index 00000000..bc41bf6a --- /dev/null +++ b/arch/hunyuan3d2/CMakeLists.txt @@ -0,0 +1,10 @@ +# Built in radiance's tree, or standalone against an installed radiance +# (`cmake -S arch/hunyuan3d2 -B build -DCMAKE_PREFIX_PATH=`); see cmake/RadAddPlugin.cmake. +if(NOT COMMAND rad_add_plugin) + cmake_minimum_required(VERSION 3.21) + project(hunyuan3d2 LANGUAGES CXX) + find_package(radiance REQUIRED) + rad_plugin_defaults() +endif() + +rad_add_plugin(hunyuan3d2 architectures SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/hunyuan3d2.cpp) diff --git a/arch/hunyuan3d2/hunyuan3d2.cpp b/arch/hunyuan3d2/hunyuan3d2.cpp new file mode 100644 index 00000000..645cf203 --- /dev/null +++ b/arch/hunyuan3d2/hunyuan3d2.cpp @@ -0,0 +1,1231 @@ +/* hunyuan3d2 -- Hunyuan3D-2's shape model (tencent/Hunyuan3D-2, hunyuan3d-dit-v2-0): one picture + * to an untextured 3-D shape. + * + * ============================== THE MODEL ============================== + * + * Three networks in one checkpoint (hy3dgen's Hunyuan3DDiTFlowMatchingPipeline): + * + * Image encoder: DINOv2-giant (40 layers of 1536, 24 heads, SwiGLU feed-forward and layer + * scales) over the prepared picture, 518 x 518 in 14 x 14 patches and the class token, 1370 rows. + * Its last hidden state, after the final LayerNorm, is the conditioning; the unconditioned + * branch's is zeros. + * + * Denoiser: a FLUX-shaped transformer of width 1024 (16 heads of 64) over a set of 3072 latent + * rows of 64 values. The conditioning goes in through `cond_in`, the latent through + * `latent_in`; 16 double-stream blocks keep the two streams' weights apart and attend over both + * together, then 32 single-stream blocks run [conditioning | latent] as one. Each block's + * LayerNorms (no affine) are modulated by shift, scale and gate projected from the timestep + * embedding, and q and k are RMS-normed per head. Nothing is positional: the latent is a set. The + * output layer maps the latent rows to a velocity. + * + * Decoder: the shape VAE's latent network (64 -> 1024, then 16 self-attention blocks with + * per-head LayerNorms on q and k) turns the latent into 3072 rows the geometry decoder reads. + * The geometry decoder embeds a query point (x, sin and cos at 8 octaves, 51 values), projects + * it to 1024, attends once over those rows (one cross-attention block with its MLP), and maps + * the result to the occupancy logit there. + * + * Sampling is flow matching from sigma 0 (noise) to 1 (the shape), Euler steps, guided at 5 + * against the unconditioned branch (abi/rad_builder.h, RadShapeGenDecl). Both branches run in one + * step: rows [txt | latent] for the picture's branch, then [latent | txt] for the unconditioned + * one, so each branch is one run for the attention and the two latents are one run for every + * latent-stream op: + * + * rows [0, C) the picture's conditioning (C = 1370) + * rows [C, C + L) the picture's latent (L = 3072) + * rows [C + L, C + 2L) the unconditioned latent + * rows [C + 2L, 2C + 2L) the unconditioned conditioning + * + * ============================== PRECISION ============================== + * + * The reference runs in fp16; here every weight and activation is bf16, rounded where the + * reference stores a tensor, except the picture's patches and the query points' embedding, which + * stay f32 into their projections, and the timestep, which the embedding reads in f32. + * + * One card: the model is 2.2B parameters (4.4 GB in bf16), and every pass is one request's. + */ +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace hunyuan3d2 { + +using namespace rad::arch; + +/* ================================================================== the model's constants */ +/* DINOv2's picture: 518 x 518 in 14 x 14 patches, and its normalisation. */ +enum { kEncSize = 518, kPatch = 14, kGrid = kEncSize / kPatch, kNPatch = kGrid * kGrid, + kCond = kNPatch + 1, kPatchDim = 3 * kPatch * kPatch }; +static const double kMean[3] = { 0.485, 0.456, 0.406 }; +static const double kStd[3] = { 0.229, 0.224, 0.225 }; +/* ImageProcessorV2's canvas and border. */ +enum { kCanvas = 512 }; +/* Requests in flight; a pass is one request's. */ +enum { kLanes = 2 }; +/* The query points a pass carries. */ +enum { kMaxQuery = 32768 }; +/* The query embedding: x, then sin and cos at kFreqs octaves (1, 2, 4, ..., without pi). */ +enum { kFreqs = 8 }; +/* The grid: the reference's default bounds, and the resolutions served (Hunyuan3D-2's own app + * offers 16..512, 256 by default). */ +static const double kBounds = 1.01; +enum { kResDef = 256, kResMin = 16, kResMax = 512 }; + +enum : int { + kGrpDino = 1000, /* the encoder's layers kGrpDino + 1.. */ + kGrpDit = 2000, /* the double blocks kGrpDit + 1.., the single blocks kGrpSingle + 1.. */ + kGrpSingle = 2100, + kGrpVae = 3000, +}; + +/* ================================================================== the model */ +/* A bf16 linear: weight, bias, and its op. */ +struct Lin { + rad_weight w = 0, b = 0; + rad_op op = 0; +}; + +struct DinoLayer { + rad_weight n1w = 0, n1b = 0, n2w = 0, n2b = 0, ls1 = 0, ls2 = 0; + Lin qkv, o, up, down; + rad_op op_n1 = 0, op_attn = 0, op_ls1 = 0, op_add1 = 0, op_n2 = 0, op_gu = 0, op_ls2 = 0, + op_add2 = 0; +}; + +/* One stream of a double block. */ +struct Stream { + rad_weight qn = 0, kn = 0; + Lin mod, qkv, proj, mlp1, mlp2; + rad_op op_n1 = 0, op_qk = 0, op_n2 = 0; +}; + +struct Double { + Stream s[2]; /* kImg, kTxt */ + rad_op op_attn = 0; +}; +enum { kImg = 0, kTxt = 1 }; + +struct Single { + rad_weight qn = 0, kn = 0; + Lin mod, l1, l2; + rad_op op_n = 0, op_qk = 0, op_attn = 0, op_act = 0; +}; + +struct VaeLayer { + rad_weight n1w = 0, n1b = 0, n2w = 0, n2b = 0, qnw = 0, qnb = 0, knw = 0, knb = 0; + Lin q, k, v, proj, fc, out; + rad_op op_n1 = 0, op_qn = 0, op_kn = 0, op_attn = 0, op_n2 = 0; +}; + +struct Model { + Names nm{""}; + /* Parameter strings longer than Names keeps (its names are at most 255 characters). */ + std::deque strs; + /* Dimensions, from config.yaml (the importer's metadata). */ + int64_t D = 1024, H = 16, hd = 64, ff = 4096, C = 64, L = 3072; + int64_t E = 1536, EH = 24, Eff = 4096; + int64_t n_double = 16, n_single = 32, n_vae = 16, n_dino = 40; + double scale_factor = 1.0; + int64_t rows = 0; /* a step's: 2 (kCond + L) */ + int64_t lanes = kLanes; + + /* ---- the image encoder */ + rad_weight w_patch = 0, b_patchw = 0, w_cls = 0, w_pos = 0, w_lnw = 0, w_lnb = 0; + rad_op op_ids = 0, op_pos = 0, op_cls = 0, op_cls_add = 0, op_patch = 0, op_dcu = 0, + op_dln = 0; + std::vector dino; + rad_buf b_ids = 0, b_pos = 0, b_cls = 0, b_dx = 0, b_dh = 0, b_dqkv = 0, b_datt = 0, + b_do = 0, b_dgu = 0, b_dact = 0, b_dcu = 0, b_dout = 0; + /* ---- cond_in, both branches, into the lane's store */ + Lin cond_in; + rad_op op_zero = 0; + rad_buf b_zero = 0, b_cstore = 0; + + /* ---- the denoiser */ + Lin latent_in, t_in1, t_out, fin_mod, fin; + rad_op op_randn = 0, op_lgather = 0, op_ccopy = 0, op_temb = 0, op_tsilu = 0, op_vsilu = 0, + op_cu_txt = 0, op_cu_img = 0, op_cu_all = 0, op_cu_ent = 0, op_gate_img = 0, + op_gate_txt = 0, op_fin_n = 0, op_euler = 0; + std::vector dbl; + std::vector sgl; + rad_buf b_lat = 0, b_lx = 0, b_temb = 0, b_t1 = 0, b_t1s = 0, b_vec = 0, b_svec = 0, + b_mods = 0, b_x = 0, b_h = 0, b_qkv = 0, b_att = 0, b_o = 0, b_ff = 0, b_f = 0, + b_l1 = 0, b_cat = 0, b_v = 0, b_cu_txt = 0, b_cu_img = 0, b_cu_all = 0, b_cu_ent = 0; + int64_t mods_w = 0; + std::vector mod_dbl[2], mod_sgl; /* each block's columns in b_mods */ + int64_t mod_fin = 0; + + /* ---- the decoder's latent network, then the geometry decoder's keys and values */ + Lin post_kl; + rad_op op_unscale = 0, op_vcu = 0; + std::vector vae; + rad_weight g_n2w = 0, g_n2b = 0, g_knw = 0, g_knb = 0; + Lin g_k, g_v; + rad_op op_gn2 = 0, op_gkn = 0; + rad_buf b_vl = 0, b_vx = 0, b_vh = 0, b_vq = 0, b_vk = 0, b_vv = 0, b_vqn = 0, b_vkn = 0, + b_vatt = 0, b_vff = 0, b_vcu = 0, b_gk = 0, b_gv = 0; + + /* ---- the geometry decoder at the query points */ + rad_weight q_n1w = 0, q_n1b = 0, q_n3w = 0, q_n3b = 0, q_qnw = 0, q_qnb = 0, q_pw = 0, + q_pb = 0; + Lin q_proj, q_q, q_o, q_fc, q_out, q_head; + rad_op op_four = 0, op_qn1 = 0, op_qqn = 0, op_qattn = 0, op_qn3 = 0, op_qpost = 0, + op_qcast = 0; + rad_buf b_feat = 0, b_qx = 0, b_qh = 0, b_qq = 0, b_qqn = 0, b_qatt = 0, b_qff = 0, + b_qlogit = 0, b_field = 0; +}; + +static Model g_model; + +/* ================================================================== declare helpers */ +static rad_weight wcopy(RadBuilder* b, const char* dn, const char* src, uint32_t dtype, + std::initializer_list shape, int access, int group) { + if (map_copy(b, dn, src) < 0) return 0; + return decl_w(b, dn, dtype, shape, access, RAD_SHARD_NONE, grp_layer(group)); +} + +/* A biased linear [N, K] (bias absent with `bias` false), read whole, over at most `rows` rows, + * its activation and residual in the epilogue. The weight is mapped by the caller (`mapped`) or + * copied from `src`.weight. `adt` is the activation's dtype ("bf16", or "f32" with an f32 + * weight). */ +static int linear(RadBuilder* b, Names& nm, Lin& l, const char* dn, const char* src, int64_t N, + int64_t K, int64_t rows, rad_buf in, rad_buf out, int access, int group, + bool bias = true, const char* act = "none", rad_buf res = 0, bool mapped = false, + const char* adt = "bf16") { + const uint32_t wdt = std::strcmp(adt, "f32") == 0 ? RAD_F32 : RAD_BF16; + const char* wn = nm.f("%s.weight", dn); + if (!mapped && map_copy(b, wn, nm.ckpt("%s.weight", src)) < 0) return RAD_E_INVAL; + l.w = decl_w(b, wn, wdt, { N, K }, access, RAD_SHARD_NONE, grp_layer(group)); + if (!l.w) return RAD_E_INVAL; + if (bias) { + l.b = wcopy(b, nm.f("%s.bias", dn), nm.ckpt("%s.bias", src), wdt, { N }, access, group); + if (!l.b) return RAD_E_INVAL; + l.op = RAD_OP(b, "gemm_nt_bias", + RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("N", N), RAD_INT("K", K), + RAD_STR("dtype", adt), RAD_STR("act", act)), + RAD_WEIGHTS(l.w, l.b)); + } else { + l.op = RAD_OP(b, "gemm_nt", + RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("N", N), RAD_INT("K", K), + RAD_STR("dtype", adt)), + RAD_WEIGHTS(l.w)); + } + if (!l.op) return RAD_E_INVAL; + /* An input read from the batch (`in` 0) has no buffer to name. */ + const rad_buf reads[2] = { in, res }; + for (rad_buf r : reads) + if (r) rad_op_reads(b, l.op, &r, 1); + rad_op_writes(b, l.op, &out, 1); + return RAD_OK; +} + +/* Issue a linear over `n` rows: `in` -> `out`, the residual `res` added (RAD_NONE for none). */ +static void lin_issue(RadCtx* c, const Lin& l, int64_t n, RadOperand in, RadOperand out, + RadOperand res = RAD_NONE) { + if (l.b) RAD_ISSUE_N(c, l.op, n, in, RAD_W(l.w), RAD_W(l.b), res, out); + else RAD_ISSUE_N(c, l.op, n, in, RAD_W(l.w), out); +} + +/* A cu_seqlens of `n` + 1 entries, every run `step` rows: iota's constant runs. */ +static rad_op cu_op(RadBuilder* b, int64_t n, int64_t step, rad_buf y) { + return rw(b, RAD_OP(b, "iota", + RAD_PARAMS(RAD_RANGE("M", 1, n + 1), RAD_INT("start", 0), + RAD_INT("step", step)), + RAD_NOWEIGHTS), + {}, { y }); +} + +static rad_op attn_op(RadBuilder* b, const char* kind, int64_t rows, int64_t hd, rad_buf q, + rad_buf cu, rad_buf out) { + return rw(b, RAD_OP(b, kind, + RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("head_dim", hd), + RAD_INT("gqa", 1), RAD_INT("causal", 0), + RAD_STR("dtype", "bf16"), + RAD_F64("scale", 1.0 / std::sqrt((double)hd))), + RAD_NOWEIGHTS), + { q, cu }, { out }); +} + +/* norm(x) (1 + scale) + shift, a LayerNorm with no affine, after the gated branch before it. */ +static rad_op mod_norm(RadBuilder* b, int64_t rows, int64_t n, bool gated, rad_buf x, rad_buf y, + rad_buf mods, rad_buf cu, rad_buf z) { + rad_op op = RAD_OP(b, "rms_mod", + RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("n", n), RAD_F64("eps", 1e-6), + RAD_INT("gated", gated ? 1 : 0), RAD_STR("dtype", "bf16"), + RAD_STR("norm", "layer")), + RAD_NOWEIGHTS); + if (!op) return op; + if (gated) rw(b, op, { x, y, mods, cu }, { x, z }); + else rw(b, op, { x, mods, cu }, { z }); + return op; +} + +/* `n` copies of `v` as chan_affine's list, f32 digits (the op keeps the list in f32 at round 0). */ +static const char* list_of(Model& m, int64_t n, double v) { + std::string s; + char one[40]; + std::snprintf(one, sizeof one, "%.9g", v); + for (int64_t i = 0; i < n; ++i) { if (i) s += ' '; s += one; } + m.strs.push_back(std::move(s)); + return m.strs.back().c_str(); +} + +/* ================================================================== check_format */ +static int check_format(const RadModelMeta* meta) { + const char* dit = rad_meta_gets(meta, "model.target", ""); + const char* vae = rad_meta_gets(meta, "vae.target", ""); + const char* enc = rad_meta_gets(meta, "conditioner.params.main_image_encoder.type", ""); + if (std::strcmp(dit, "hy3dgen.shapegen.models.Hunyuan3DDiT") != 0 || + std::strcmp(vae, "hy3dgen.shapegen.models.ShapeVAE") != 0 || + std::strcmp(enc, "DinoImageEncoder") != 0) { + fprintf(stderr, "radiance: hunyuan3d2: the checkpoint is '%s' with '%s' and '%s'; this " + "plugin serves Hunyuan3DDiT with ShapeVAE and DINOv2 " + "(hunyuan3d-dit-v2-0)\n", + dit, vae, enc); + return RAD_E_UNSUPPORTED; + } + if (rad_meta_geti(meta, "model.params.guidance_embed", 0) != 0) { + fprintf(stderr, "radiance: hunyuan3d2: a guidance-distilled DiT (guidance_embed) is not " + "served yet\n"); + return RAD_E_UNSUPPORTED; + } + if (rad_meta_geti(meta, "model.params.depth", 16) <= 0 || + rad_meta_geti(meta, "vae.params.num_freqs", kFreqs) != kFreqs || + rad_meta_geti(meta, "vae.params.include_pi", 0) != 0 || + rad_meta_geti(meta, "conditioner.params.main_image_encoder.kwargs.image_size", kEncSize) != + kEncSize || + rad_meta_geti(meta, "conditioner.params.main_image_encoder.kwargs.config.patch_size", + kPatch) != kPatch || + rad_meta_geti(meta, "conditioner.params.main_image_encoder.kwargs.config.use_swiglu_ffn", + 1) != 1) { + fprintf(stderr, "radiance: hunyuan3d2: the checkpoint's geometry (query embedding, " + "encoder picture or feed-forward) is not hunyuan3d-dit-v2-0's\n"); + return RAD_E_UNSUPPORTED; + } + return RAD_OK; +} + +/* ================================================================== declare */ +static int declare_dino(RadBuilder* b, Model& m) { + Names& nm = m.nm; + const int64_t R = kCond, E = m.E; + const char* P = "conditioner.main_image_encoder.model"; + const int g0 = kGrpDino; + const int acc = RAD_ACCESS_PER_REQUEST; + m.b_ids = decl_b(b, nm.f("dino.ids"), RAD_I32, { R }); + m.b_pos = decl_b(b, nm.f("dino.pos"), RAD_BF16, { R, E }); + m.b_cls = decl_b(b, nm.f("dino.cls"), RAD_BF16, { 1, E }); + m.b_dx = decl_b(b, nm.f("dino.x"), RAD_BF16, { R, E }); + m.b_dh = decl_b(b, nm.f("dino.h"), RAD_BF16, { R, E }); + m.b_dqkv = decl_b(b, nm.f("dino.qkv"), RAD_BF16, { R, 3 * E }); + m.b_datt = decl_b(b, nm.f("dino.att"), RAD_BF16, { R, E }); + m.b_do = decl_b(b, nm.f("dino.o"), RAD_BF16, { R, E }); + m.b_dgu = decl_b(b, nm.f("dino.gate_up"), RAD_BF16, { R, 2 * m.Eff }); + m.b_dact = decl_b(b, nm.f("dino.act"), RAD_BF16, { R, m.Eff }); + m.b_dcu = decl_b(b, nm.f("dino.cu"), RAD_I32, { 2 }); + m.b_dout = decl_b(b, nm.f("dino.out"), RAD_BF16, { R, E }); + + m.op_ids = rw(b, RAD_OP(b, "iota", + RAD_PARAMS(RAD_RANGE("M", 1, R), RAD_INT("start", 0), + RAD_INT("step", 1)), + RAD_NOWEIGHTS), + {}, { m.b_ids }); + m.op_dcu = cu_op(b, 1, R, m.b_dcu); + /* The position table and the class token as rows of the stream: embedding lookups of + * the table's own rows. */ + m.w_pos = wcopy(b, nm.f("dino.pos_embed"), nm.ckpt("%s.embeddings.position_embeddings", P), + RAD_BF16, { R, E }, RAD_ACCESS_VOCAB, g0); + m.w_cls = wcopy(b, nm.f("dino.cls_token"), nm.ckpt("%s.embeddings.cls_token", P), RAD_BF16, + { 1, E }, RAD_ACCESS_VOCAB, g0); + if (!m.w_pos || !m.w_cls) return RAD_E_INVAL; + auto lookup = [&](int64_t rows, int64_t vocab, rad_weight w, rad_buf out) { + return rw(b, RAD_OP(b, "embed_lookup", + RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("n_embd", E), + RAD_INT("n_vocab", vocab), RAD_STR("dtype", "bf16"), + RAD_INT("vocab_offset", 0)), + RAD_WEIGHTS(w)), + { m.b_ids }, { out }); + }; + m.op_pos = lookup(R, R, m.w_pos, m.b_pos); + m.op_cls = lookup(1, 1, m.w_cls, m.b_cls); + m.op_cls_add = rw(b, RAD_OP(b, "add", + RAD_PARAMS(RAD_RANGE("M", 1, 1), RAD_INT("n", E), + RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + { m.b_cls, m.b_pos }, { m.b_dx }); + /* The 14 x 14 patch convolution as a linear over the f32 patches (its kernel read as + * [1536, 3 x 14 x 14]), the position rows added. */ + Lin patch; + RAD_ARCH_TRY(linear(b, nm, patch, "dino.patch", + nm.ckpt("%s.embeddings.patch_embeddings.projection", P), E, kPatchDim, + kNPatch, 0, m.b_dx, acc, g0, true, "none", m.b_pos, false, "f32")); + m.w_patch = patch.w; + m.b_patchw = patch.b; + m.op_patch = patch.op; + m.dino.resize((size_t)m.n_dino); + for (int64_t l = 0; l < m.n_dino; ++l) { + DinoLayer& Y = m.dino[(size_t)l]; + const int g = g0 + 1 + (int)l; + const char* lp = nm.ckpt("%s.encoder.layer.%lld", P, (long long)l); + auto W = [&](const char* dn, const char* src, std::initializer_list sh) { + return wcopy(b, nm.f("dino.blk.%lld.%s", (long long)l, dn), nm.ckpt("%s.%s", lp, src), + RAD_BF16, sh, acc, g); + }; + Y.n1w = W("norm1.weight", "norm1.weight", { E }); + Y.n1b = W("norm1.bias", "norm1.bias", { E }); + Y.n2w = W("norm2.weight", "norm2.weight", { E }); + Y.n2b = W("norm2.bias", "norm2.bias", { E }); + Y.ls1 = W("ls1", "layer_scale1.lambda1", { E }); + Y.ls2 = W("ls2", "layer_scale2.lambda1", { E }); + if (!Y.n1w || !Y.n1b || !Y.n2w || !Y.n2b || !Y.ls1 || !Y.ls2) return RAD_E_INVAL; + Y.op_n1 = rw(b, RAD_OP(b, "layernorm", + RAD_PARAMS(RAD_RANGE("M", 1, R), RAD_INT("n", E), + RAD_F64("eps", 1e-6), RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(Y.n1w, Y.n1b)), + { m.b_dx }, { m.b_dh }); + const char* qn = nm.f("dino.blk.%lld.qkv", (long long)l); + if (map_concat(b, nm.f("%s.weight", qn), + { nm.ckpt("%s.attention.attention.query.weight", lp), + nm.ckpt("%s.attention.attention.key.weight", lp), + nm.ckpt("%s.attention.attention.value.weight", lp) }) < 0 || + map_concat(b, nm.f("%s.bias", qn), + { nm.ckpt("%s.attention.attention.query.bias", lp), + nm.ckpt("%s.attention.attention.key.bias", lp), + nm.ckpt("%s.attention.attention.value.bias", lp) }) < 0) + return RAD_E_INVAL; + /* map_concat named both; the linear declares them without copying again. */ + Y.qkv.w = decl_w(b, nm.f("%s.weight", qn), RAD_BF16, { 3 * E, E }, acc, RAD_SHARD_NONE, + grp_layer(g)); + Y.qkv.b = decl_w(b, nm.f("%s.bias", qn), RAD_BF16, { 3 * E }, acc, RAD_SHARD_NONE, + grp_layer(g)); + if (!Y.qkv.w || !Y.qkv.b) return RAD_E_INVAL; + Y.qkv.op = rw(b, RAD_OP(b, "gemm_nt_bias", + RAD_PARAMS(RAD_RANGE("M", 1, R), RAD_INT("N", 3 * E), + RAD_INT("K", E), RAD_STR("dtype", "bf16"), + RAD_STR("act", "none")), + RAD_WEIGHTS(Y.qkv.w, Y.qkv.b)), + { m.b_dh }, { m.b_dqkv }); + Y.op_attn = attn_op(b, "attn_dense", R, 64, m.b_dqkv, m.b_dcu, m.b_datt); + RAD_ARCH_TRY(linear(b, nm, Y.o, nm.f("dino.blk.%lld.attn_out", (long long)l), + nm.ckpt("%s.attention.output.dense", lp), E, E, R, m.b_datt, m.b_do, + acc, g)); + auto ls = [&](rad_weight w) { + return rw(b, RAD_OP(b, "mul_weight", + RAD_PARAMS(RAD_RANGE("M", 1, R), RAD_INT("n", E), + RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(w)), + { m.b_do }, { m.b_do }); + }; + auto add = [&]() { + return rw(b, RAD_OP(b, "add", + RAD_PARAMS(RAD_RANGE("M", 1, R), RAD_INT("n", E), + RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + { m.b_do, m.b_dx }, { m.b_dx }); + }; + Y.op_ls1 = ls(Y.ls1); + Y.op_add1 = add(); + Y.op_n2 = rw(b, RAD_OP(b, "layernorm", + RAD_PARAMS(RAD_RANGE("M", 1, R), RAD_INT("n", E), + RAD_F64("eps", 1e-6), RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(Y.n2w, Y.n2b)), + { m.b_dx }, { m.b_dh }); + RAD_ARCH_TRY(linear(b, nm, Y.up, nm.f("dino.blk.%lld.ffn_in", (long long)l), + nm.ckpt("%s.mlp.weights_in", lp), 2 * m.Eff, E, R, m.b_dh, m.b_dgu, + acc, g)); + Y.op_gu = rw(b, RAD_OP(b, "silu_mul", + RAD_PARAMS(RAD_RANGE("M", 1, R), RAD_INT("n", m.Eff), + RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + { m.b_dgu }, { m.b_dact }); + RAD_ARCH_TRY(linear(b, nm, Y.down, nm.f("dino.blk.%lld.ffn_out", (long long)l), + nm.ckpt("%s.mlp.weights_out", lp), E, m.Eff, R, m.b_dact, m.b_do, + acc, g)); + Y.op_ls2 = ls(Y.ls2); + Y.op_add2 = add(); + if (!Y.op_n1 || !Y.qkv.op || !Y.op_attn || !Y.op_ls1 || !Y.op_add1 || !Y.op_n2 || + !Y.op_gu || !Y.op_ls2 || !Y.op_add2) + return RAD_E_INVAL; + } + m.w_lnw = wcopy(b, nm.f("dino.norm.weight"), nm.ckpt("%s.layernorm.weight", P), RAD_BF16, + { E }, acc, g0); + m.w_lnb = wcopy(b, nm.f("dino.norm.bias"), nm.ckpt("%s.layernorm.bias", P), RAD_BF16, { E }, + acc, g0); + if (!m.w_lnw || !m.w_lnb) return RAD_E_INVAL; + m.op_dln = rw(b, RAD_OP(b, "layernorm", + RAD_PARAMS(RAD_RANGE("M", 1, R), RAD_INT("n", E), + RAD_F64("eps", 1e-6), RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(m.w_lnw, m.w_lnb)), + { m.b_dx }, { m.b_dout }); + + /* ---- cond_in for both branches: the picture's rows, and the unconditioned branch's zeros + * (whose rows are cond_in's bias), into the lane's store */ + m.b_zero = decl_b(b, nm.f("cond.zero"), RAD_BF16, { R, E }); + m.op_zero = rw(b, RAD_OP(b, "fill", + RAD_PARAMS(RAD_RANGE("M", 1, R), RAD_INT("n", E), + RAD_STR("dtype", "bf16"), RAD_F64("value", 0.0)), + RAD_NOWEIGHTS), + {}, { m.b_zero }); + RAD_ARCH_TRY(linear(b, nm, m.cond_in, "dit.cond_in", "model.cond_in", m.D, E, R, m.b_dout, + m.b_cstore, acc, kGrpDit)); + rw(b, m.cond_in.op, { m.b_dout, m.b_zero }, { m.b_cstore }); + return m.op_ids && m.op_dcu && m.op_pos && m.op_cls && m.op_cls_add && m.op_patch && + m.op_dln && m.op_zero + ? RAD_OK : RAD_E_INVAL; +} + +/* One stream of a double block over `rows` rows. */ +static int declare_stream(RadBuilder* b, Model& m, Stream& S, int64_t l, int which, int64_t rows, + int g) { + Names& nm = m.nm; + const char* nmS = which == kImg ? "img" : "txt"; + const char* src = nm.ckpt("model.double_blocks.%lld", (long long)l); + const int acc = RAD_ACCESS_PER_TOKEN; + const char* dn = nm.f("dit.dbl.%lld.%s", (long long)l, nmS); + S.qn = wcopy(b, nm.f("%s.q_norm", dn), nm.ckpt("%s.%s_attn.norm.query_norm.scale", src, nmS), + RAD_F32, { m.hd }, acc, g); + S.kn = wcopy(b, nm.f("%s.k_norm", dn), nm.ckpt("%s.%s_attn.norm.key_norm.scale", src, nmS), + RAD_F32, { m.hd }, acc, g); + if (!S.qn || !S.kn) return RAD_E_INVAL; + RAD_ARCH_TRY(linear(b, nm, S.mod, nm.f("%s.mod", dn), nm.ckpt("%s.%s_mod.lin", src, nmS), + 6 * m.D, m.D, 1, m.b_svec, m.b_mods, acc, g)); + const rad_buf cu = which == kImg ? m.b_cu_img : m.b_cu_txt; + S.op_n1 = mod_norm(b, rows, m.D, l > 0, m.b_x, m.b_f, m.b_mods, cu, m.b_h); + RAD_ARCH_TRY(linear(b, nm, S.qkv, nm.f("%s.qkv", dn), nm.ckpt("%s.%s_attn.qkv", src, nmS), + 3 * m.D, m.D, rows, m.b_h, m.b_qkv, acc, g)); + S.op_qk = rw(b, RAD_OP(b, "qk_norm_rope", + RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("head_dim", m.hd), + RAD_INT("n_head", m.H), RAD_INT("n_head_kv", m.H), + RAD_F64("theta", 10000.0), RAD_F64("eps", 1e-6), + RAD_INT("rotary_dim", 0)), + RAD_WEIGHTS(S.qn, S.kn)), + { m.b_qkv }, { m.b_qkv }); + return S.op_n1 && S.op_qk ? RAD_OK : RAD_E_INVAL; +} + +static int declare_stream_out(RadBuilder* b, Model& m, Stream& S, int64_t l, int which, + int64_t rows, int g) { + Names& nm = m.nm; + const char* nmS = which == kImg ? "img" : "txt"; + const char* src = nm.ckpt("model.double_blocks.%lld", (long long)l); + const int acc = RAD_ACCESS_PER_TOKEN; + const char* dn = nm.f("dit.dbl.%lld.%s", (long long)l, nmS); + RAD_ARCH_TRY(linear(b, nm, S.proj, nm.f("%s.proj", dn), nm.ckpt("%s.%s_attn.proj", src, nmS), + m.D, m.D, rows, m.b_att, m.b_o, acc, g)); + S.op_n2 = mod_norm(b, rows, m.D, true, m.b_x, m.b_o, m.b_mods, + which == kImg ? m.b_cu_img : m.b_cu_txt, m.b_h); + RAD_ARCH_TRY(linear(b, nm, S.mlp1, nm.f("%s.mlp_in", dn), nm.ckpt("%s.%s_mlp.0", src, nmS), + m.ff, m.D, rows, m.b_h, m.b_ff, acc, g, true, "gelu_tanh")); + RAD_ARCH_TRY(linear(b, nm, S.mlp2, nm.f("%s.mlp_out", dn), nm.ckpt("%s.%s_mlp.2", src, nmS), + m.D, m.ff, rows, m.b_ff, m.b_f, acc, g)); + return S.op_n2 ? RAD_OK : RAD_E_INVAL; +} + +static int declare_dit(RadBuilder* b, Model& m) { + Names& nm = m.nm; + const int64_t N = m.rows, D = m.D, L2 = 2 * m.L; + const int acc = RAD_ACCESS_PER_TOKEN; + const int gx = kGrpDit; + m.b_lx = decl_b(b, nm.f("dit.lat"), RAD_BF16, { L2, m.C }); + m.b_temb = decl_b(b, nm.f("dit.temb"), RAD_BF16, { 1, 256 }); + m.b_t1 = decl_b(b, nm.f("dit.t1"), RAD_BF16, { 1, D }); + m.b_t1s = decl_b(b, nm.f("dit.t1s"), RAD_BF16, { 1, D }); + m.b_vec = decl_b(b, nm.f("dit.vec"), RAD_BF16, { 1, D }); + m.b_svec = decl_b(b, nm.f("dit.svec"), RAD_BF16, { 1, D }); + /* Every block's modulation, one row: each double block's two streams (6 D each), each single + * block's (3 D) and the output layer's (2 D). */ + for (int s = 0; s < 2; ++s) m.mod_dbl[s].clear(); + m.mod_sgl.clear(); + int64_t col = 0; + for (int64_t l = 0; l < m.n_double; ++l) + for (int s = 0; s < 2; ++s) { m.mod_dbl[s].push_back(col); col += 6 * D; } + for (int64_t l = 0; l < m.n_single; ++l) { m.mod_sgl.push_back(col); col += 3 * D; } + m.mod_fin = col; + col += 2 * D; + m.mods_w = col; + m.b_mods = decl_b(b, nm.f("dit.mods"), RAD_BF16, { 1, m.mods_w }); + m.b_x = decl_b(b, nm.f("dit.x"), RAD_BF16, { N, D }); + m.b_h = decl_b(b, nm.f("dit.h"), RAD_BF16, { N, D }); + m.b_qkv = decl_b(b, nm.f("dit.qkv"), RAD_BF16, { N, 3 * D }); + m.b_att = decl_b(b, nm.f("dit.att"), RAD_BF16, { N, D }); + m.b_o = decl_b(b, nm.f("dit.o"), RAD_BF16, { N, D }); + m.b_ff = decl_b(b, nm.f("dit.ff"), RAD_BF16, { N, m.ff }); + m.b_f = decl_b(b, nm.f("dit.f"), RAD_BF16, { N, D }); + m.b_l1 = decl_b(b, nm.f("dit.l1"), RAD_BF16, { N, 3 * D + m.ff }); + m.b_cat = decl_b(b, nm.f("dit.cat"), RAD_BF16, { N, D + m.ff }); + m.b_v = decl_b(b, nm.f("dit.v"), RAD_BF16, { L2, m.C }); + m.b_cu_txt = decl_b(b, nm.f("dit.cu_txt"), RAD_I32, { 2 }); + m.b_cu_img = decl_b(b, nm.f("dit.cu_img"), RAD_I32, { 2 }); + m.b_cu_all = decl_b(b, nm.f("dit.cu_all"), RAD_I32, { 2 }); + m.b_cu_ent = decl_b(b, nm.f("dit.cu_ent"), RAD_I32, { 3 }); + + /* ---- the latents: the first step's noise, both entries' rows of the lane, latent_in */ + m.op_randn = rw(b, RAD_OP(b, "randn_lanes", + RAD_PARAMS(RAD_RANGE("M", 1, L2), RAD_INT("n", m.C), + RAD_INT("stride", m.L), RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + { m.b_lat }, { m.b_lat }); + m.op_lgather = rw(b, RAD_OP(b, "lane_gather", + RAD_PARAMS(RAD_RANGE("M", 1, L2), RAD_INT("n", m.C), + RAD_INT("stride", m.L), RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + { m.b_lat }, { m.b_lx }); + RAD_ARCH_TRY(linear(b, nm, m.latent_in, "dit.latent_in", "model.latent_in", D, m.C, L2, + m.b_lx, m.b_x, acc, gx)); + /* The conditioning rows from the lane's store. */ + m.op_ccopy = rw(b, RAD_OP(b, "cast", + RAD_PARAMS(RAD_RANGE("M", 1, kCond), RAD_INT("n", D), + RAD_STR("from", "bf16"), RAD_STR("to", "bf16")), + RAD_NOWEIGHTS), + { m.b_cstore }, { m.b_x }); + /* ---- the timestep: the sinusoid of 1000 sigma, time_in, silu. The reference passes its + * time_factor (1000) where timestep_embedding takes max_period, so the model was trained on + * a period of 1000, and the time is scaled by the default factor, also 1000. */ + m.op_temb = rw(b, RAD_OP(b, "timestep_embed", + RAD_PARAMS(RAD_RANGE("M", 1, 1), RAD_INT("n", 256), + RAD_F64("scale", 1000.0), RAD_F64("max_period", 1000.0), + RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + {}, { m.b_temb }); + RAD_ARCH_TRY(linear(b, nm, m.t_in1, "dit.time_in.in", "model.time_in.in_layer", D, 256, 1, + m.b_temb, m.b_t1, acc, gx)); + m.op_tsilu = rw(b, RAD_OP(b, "silu", RAD_PARAMS(RAD_RANGE("M", 1, 1), RAD_INT("n", D), + RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + { m.b_t1 }, { m.b_t1s }); + RAD_ARCH_TRY(linear(b, nm, m.t_out, "dit.time_in.out", "model.time_in.out_layer", D, D, 1, + m.b_t1s, m.b_vec, acc, gx)); + m.op_vsilu = rw(b, RAD_OP(b, "silu", RAD_PARAMS(RAD_RANGE("M", 1, 1), RAD_INT("n", D), + RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + { m.b_vec }, { m.b_svec }); + m.op_cu_txt = cu_op(b, 1, kCond, m.b_cu_txt); + m.op_cu_img = cu_op(b, 1, L2, m.b_cu_img); + m.op_cu_all = cu_op(b, 1, N, m.b_cu_all); + m.op_cu_ent = cu_op(b, 2, N / 2, m.b_cu_ent); + + /* ---- the double blocks: each stream's norm, qkv and q/k norm, the joint attention, then + * each stream's projection, second norm and MLP, in the order the step issues them */ + m.dbl.resize((size_t)m.n_double); + for (int64_t l = 0; l < m.n_double; ++l) { + Double& B = m.dbl[(size_t)l]; + const int g = gx + 1 + (int)l; + RAD_ARCH_TRY(declare_stream(b, m, B.s[kImg], l, kImg, L2, g)); + RAD_ARCH_TRY(declare_stream(b, m, B.s[kTxt], l, kTxt, kCond, g)); + B.op_attn = attn_op(b, "attn_dense", N, m.hd, m.b_qkv, m.b_cu_ent, m.b_att); + RAD_ARCH_TRY(declare_stream_out(b, m, B.s[kImg], l, kImg, L2, g)); + RAD_ARCH_TRY(declare_stream_out(b, m, B.s[kTxt], l, kTxt, kCond, g)); + if (!B.op_attn) return RAD_E_INVAL; + } + auto gate_op = [&](int64_t rows, rad_buf cu) { + return rw(b, RAD_OP(b, "gate_add", + RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("n", D), + RAD_STR("dtype", "bf16"), RAD_STR("act", "none")), + RAD_NOWEIGHTS), + { m.b_f, m.b_mods, cu, m.b_x }, { m.b_x }); + }; + m.op_gate_img = gate_op(L2, m.b_cu_img); + m.op_gate_txt = gate_op(kCond, m.b_cu_txt); + + /* ---- the single blocks over every row */ + m.sgl.resize((size_t)m.n_single); + for (int64_t l = 0; l < m.n_single; ++l) { + Single& S = m.sgl[(size_t)l]; + const int g = kGrpSingle + 1 + (int)l; + const char* src = nm.ckpt("model.single_blocks.%lld", (long long)l); + const char* dn = nm.f("dit.sgl.%lld", (long long)l); + S.qn = wcopy(b, nm.f("%s.q_norm", dn), nm.ckpt("%s.norm.query_norm.scale", src), RAD_F32, + { m.hd }, acc, g); + S.kn = wcopy(b, nm.f("%s.k_norm", dn), nm.ckpt("%s.norm.key_norm.scale", src), RAD_F32, + { m.hd }, acc, g); + if (!S.qn || !S.kn) return RAD_E_INVAL; + RAD_ARCH_TRY(linear(b, nm, S.mod, nm.f("%s.mod", dn), nm.ckpt("%s.modulation.lin", src), + 3 * D, D, 1, m.b_svec, m.b_mods, acc, g)); + S.op_n = mod_norm(b, N, D, l > 0, m.b_x, m.b_f, m.b_mods, m.b_cu_all, m.b_h); + RAD_ARCH_TRY(linear(b, nm, S.l1, nm.f("%s.linear1", dn), nm.ckpt("%s.linear1", src), + 3 * D + m.ff, D, N, m.b_h, m.b_l1, acc, g)); + S.op_qk = rw(b, RAD_OP(b, "qk_norm_rope", + RAD_PARAMS(RAD_RANGE("M", 1, N), RAD_INT("head_dim", m.hd), + RAD_INT("n_head", m.H), RAD_INT("n_head_kv", m.H), + RAD_F64("theta", 10000.0), RAD_F64("eps", 1e-6), + RAD_INT("rotary_dim", 0)), + RAD_WEIGHTS(S.qn, S.kn)), + { m.b_l1 }, { m.b_l1 }); + S.op_attn = attn_op(b, "attn_dense", N, m.hd, m.b_l1, m.b_cu_ent, m.b_cat); + S.op_act = rw(b, RAD_OP(b, "gelu_tanh", + RAD_PARAMS(RAD_RANGE("M", 1, N), RAD_INT("n", m.ff), + RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + { m.b_l1 }, { m.b_cat }); + RAD_ARCH_TRY(linear(b, nm, S.l2, nm.f("%s.linear2", dn), nm.ckpt("%s.linear2", src), D, + D + m.ff, N, m.b_cat, m.b_f, acc, g)); + if (!S.op_n || !S.op_qk || !S.op_attn || !S.op_act) return RAD_E_INVAL; + } + + /* ---- the output layer over the latent rows, and the guided step */ + RAD_ARCH_TRY(linear(b, nm, m.fin_mod, "dit.final.mod", "model.final_layer.adaLN_modulation.1", + 2 * D, D, 1, m.b_svec, m.b_mods, acc, gx)); + m.op_fin_n = mod_norm(b, L2, D, true, m.b_x, m.b_f, m.b_mods, m.b_cu_img, m.b_h); + RAD_ARCH_TRY(linear(b, nm, m.fin, "dit.final.linear", "model.final_layer.linear", m.C, D, L2, + m.b_h, m.b_v, acc, gx)); + m.op_euler = rw(b, RAD_OP(b, "flow_euler", + RAD_PARAMS(RAD_RANGE("M", 1, L2), RAD_INT("n", m.C), + RAD_INT("stride", m.L), RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + { m.b_v, m.b_lat }, { m.b_lat }); + return m.op_randn && m.op_lgather && m.op_ccopy && m.op_temb && m.op_tsilu && m.op_vsilu && + m.op_cu_txt && m.op_cu_img && m.op_cu_all && m.op_cu_ent && m.op_gate_img && + m.op_gate_txt && m.op_fin_n && m.op_euler + ? RAD_OK : RAD_E_INVAL; +} + +/* Rows of a head-interleaved projection: for every head h of `heads`, rows + * [h * per + first, h * per + first + width) of `src`, joined (RAD_MAP_ROWS, eight a map). */ +static int map_heads(RadBuilder* b, const char* declared, const char* src, int64_t heads, + int64_t per, int64_t first, int64_t width) { + for (int64_t h0 = 0; h0 < heads; h0 += 8) { + RadNameMap mp = map_base(declared, RAD_MAP_ROWS); + for (int64_t h = h0; h < std::min(heads, h0 + 8); ++h) { + mp.src[mp.n_src] = src; + mp.src_index[mp.n_src] = (int)(h * per + first); + mp.src_rows[mp.n_src] = width; + ++mp.n_src; + } + RAD_ARCH_TRY(rad_decl_name_map(b, &mp)); + } + return RAD_OK; +} + +/* A per-head LayerNorm (gain and bias of head_dim) over [rows x heads] heads in place of rows. */ +static rad_op head_norm(RadBuilder* b, const Model& m, int64_t rows, rad_weight w, rad_weight bb, + rad_buf in, rad_buf out) { + return rw(b, RAD_OP(b, "layernorm", + RAD_PARAMS(RAD_RANGE("M", 1, rows * m.H), RAD_INT("n", m.hd), + RAD_F64("eps", 1e-6), RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(w, bb)), + { in }, { out }); +} + +static rad_op affine_norm(RadBuilder* b, int64_t rows, int64_t n, double eps, rad_weight w, + rad_weight bb, rad_buf in, rad_buf out) { + return rw(b, RAD_OP(b, "layernorm", + RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("n", n), RAD_F64("eps", eps), + RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(w, bb)), + { in }, { out }); +} + +static int declare_vae(RadBuilder* b, Model& m) { + Names& nm = m.nm; + const int64_t L = m.L, D = m.D; + const int acc = RAD_ACCESS_PER_REQUEST; + m.b_vl = decl_b(b, nm.f("vae.lat"), RAD_BF16, { L, m.C }); + m.b_vx = decl_b(b, nm.f("vae.x"), RAD_BF16, { L, D }); + m.b_vh = decl_b(b, nm.f("vae.h"), RAD_BF16, { L, D }); + m.b_vq = decl_b(b, nm.f("vae.q"), RAD_BF16, { L, D }); + m.b_vk = decl_b(b, nm.f("vae.k"), RAD_BF16, { L, D }); + m.b_vv = decl_b(b, nm.f("vae.v"), RAD_BF16, { L, D }); + m.b_vqn = decl_b(b, nm.f("vae.qn"), RAD_BF16, { L, D }); + m.b_vkn = decl_b(b, nm.f("vae.kn"), RAD_BF16, { L, D }); + m.b_vatt = decl_b(b, nm.f("vae.att"), RAD_BF16, { L, D }); + m.b_vff = decl_b(b, nm.f("vae.ff"), RAD_BF16, { L, 4 * D }); + m.b_vcu = decl_b(b, nm.f("vae.cu"), RAD_I32, { 2 }); + m.op_vcu = cu_op(b, 1, L, m.b_vcu); + /* 1 / scale_factor times the latent, in f32 and rounded once. */ + m.op_unscale = rw(b, RAD_OP(b, "chan_affine", + RAD_PARAMS(RAD_RANGE("M", 1, L), RAD_INT("n", m.C), + RAD_STR("mul", list_of(m, m.C, 1.0 / m.scale_factor)), + RAD_STR("add", list_of(m, m.C, 0.0)), + RAD_STR("mode", "fma"), RAD_STR("dtype", "bf16"), + RAD_INT("round", 0)), + RAD_NOWEIGHTS), + { m.b_lat }, { m.b_vl }); + RAD_ARCH_TRY(linear(b, nm, m.post_kl, "vae.post_kl", "vae.post_kl", D, m.C, L, m.b_vl, m.b_vx, + acc, kGrpVae)); + m.vae.resize((size_t)m.n_vae); + for (int64_t l = 0; l < m.n_vae; ++l) { + VaeLayer& V = m.vae[(size_t)l]; + const int g = kGrpVae + 1 + (int)l; + const char* src = nm.ckpt("vae.transformer.resblocks.%lld", (long long)l); + const char* dn = nm.f("vae.blk.%lld", (long long)l); + auto W = [&](const char* d, const char* s, int64_t n) { + return wcopy(b, nm.f("%s.%s", dn, d), nm.ckpt("%s.%s", src, s), RAD_BF16, { n }, acc, + g); + }; + V.n1w = W("ln_1.weight", "ln_1.weight", D); + V.n1b = W("ln_1.bias", "ln_1.bias", D); + V.n2w = W("ln_2.weight", "ln_2.weight", D); + V.n2b = W("ln_2.bias", "ln_2.bias", D); + V.qnw = W("q_norm.weight", "attn.attention.q_norm.weight", m.hd); + V.qnb = W("q_norm.bias", "attn.attention.q_norm.bias", m.hd); + V.knw = W("k_norm.weight", "attn.attention.k_norm.weight", m.hd); + V.knb = W("k_norm.bias", "attn.attention.k_norm.bias", m.hd); + if (!V.n1w || !V.n1b || !V.n2w || !V.n2b || !V.qnw || !V.qnb || !V.knw || !V.knb) + return RAD_E_INVAL; + V.op_n1 = affine_norm(b, L, D, 1e-6, V.n1w, V.n1b, m.b_vx, m.b_vh); + /* c_qkv holds each head's q, k and v side by side (192 rows a head). */ + const char* qkv = nm.ckpt("%s.attn.c_qkv.weight", src); + const char* part[3] = { "q", "k", "v" }; + Lin* lin3[3] = { &V.q, &V.k, &V.v }; + const rad_buf out3[3] = { m.b_vq, m.b_vk, m.b_vv }; + for (int p = 0; p < 3; ++p) { + const char* pn = nm.f("%s.attn_%s", dn, part[p]); + RAD_ARCH_TRY(map_heads(b, nm.f("%s.weight", pn), qkv, m.H, 3 * m.hd, p * m.hd, m.hd)); + RAD_ARCH_TRY(linear(b, nm, *lin3[p], pn, nullptr, D, D, L, m.b_vh, out3[p], acc, g, + false, "none", 0, true)); + } + V.op_qn = head_norm(b, m, L, V.qnw, V.qnb, m.b_vq, m.b_vqn); + V.op_kn = head_norm(b, m, L, V.knw, V.knb, m.b_vk, m.b_vkn); + V.op_attn = attn_op(b, "attn_dense", L, m.hd, m.b_vqn, m.b_vcu, m.b_vatt); + rw(b, V.op_attn, { m.b_vqn, m.b_vkn, m.b_vv }, { m.b_vatt }); + RAD_ARCH_TRY(linear(b, nm, V.proj, nm.f("%s.attn_out", dn), nm.ckpt("%s.attn.c_proj", src), + D, D, L, m.b_vatt, m.b_vx, acc, g, true, "none", m.b_vx)); + V.op_n2 = affine_norm(b, L, D, 1e-6, V.n2w, V.n2b, m.b_vx, m.b_vh); + RAD_ARCH_TRY(linear(b, nm, V.fc, nm.f("%s.mlp_in", dn), nm.ckpt("%s.mlp.c_fc", src), + 4 * D, D, L, m.b_vh, m.b_vff, acc, g, true, "gelu")); + RAD_ARCH_TRY(linear(b, nm, V.out, nm.f("%s.mlp_out", dn), nm.ckpt("%s.mlp.c_proj", src), + D, 4 * D, L, m.b_vff, m.b_vx, acc, g, true, "none", m.b_vx)); + if (!V.op_n1 || !V.op_qn || !V.op_kn || !V.op_attn || !V.op_n2) return RAD_E_INVAL; + } + /* ---- the geometry decoder's keys and values over the latent network's rows, normed and + * kept in the lane (c_kv holds each head's k and v side by side, 128 rows a head) */ + const char* gd = "vae.geo_decoder.cross_attn_decoder"; + const int g = kGrpVae + 100; + auto GW = [&](const char* dn, const char* pre, const char* src, int64_t n) { + return wcopy(b, nm.f("%s", dn), nm.ckpt("%s.%s", pre, src), RAD_BF16, { n }, acc, g); + }; + m.g_n2w = GW("geo.ln_2.weight", gd, "ln_2.weight", D); + m.g_n2b = GW("geo.ln_2.bias", gd, "ln_2.bias", D); + m.g_knw = wcopy(b, nm.f("geo.k_norm.weight"), nm.ckpt("%s.attn.attention.k_norm.weight", gd), + RAD_BF16, { m.hd }, acc, g); + m.g_knb = wcopy(b, nm.f("geo.k_norm.bias"), nm.ckpt("%s.attn.attention.k_norm.bias", gd), + RAD_BF16, { m.hd }, acc, g); + if (!m.g_n2w || !m.g_n2b || !m.g_knw || !m.g_knb) return RAD_E_INVAL; + m.op_gn2 = affine_norm(b, L, D, 1e-6, m.g_n2w, m.g_n2b, m.b_vx, m.b_vh); + const char* kv = nm.ckpt("%s.attn.c_kv.weight", gd); + RAD_ARCH_TRY(map_heads(b, nm.f("geo.attn_k.weight"), kv, m.H, 2 * m.hd, 0, m.hd)); + RAD_ARCH_TRY(map_heads(b, nm.f("geo.attn_v.weight"), kv, m.H, 2 * m.hd, m.hd, m.hd)); + RAD_ARCH_TRY(linear(b, nm, m.g_k, "geo.attn_k", nullptr, D, D, L, m.b_vh, m.b_vk, acc, g, + false, "none", 0, true)); + RAD_ARCH_TRY(linear(b, nm, m.g_v, "geo.attn_v", nullptr, D, D, L, m.b_vh, m.b_gv, acc, g, + false, "none", 0, true)); + m.op_gkn = head_norm(b, m, L, m.g_knw, m.g_knb, m.b_vk, m.b_gk); + return m.op_vcu && m.op_unscale && m.op_gn2 && m.op_gkn ? RAD_OK : RAD_E_INVAL; +} + +static int declare_query(RadBuilder* b, Model& m) { + Names& nm = m.nm; + const int64_t Q = kMaxQuery, D = m.D, F = 3 * (2 * kFreqs + 1); + const int acc = RAD_ACCESS_PER_REQUEST; + const int g = kGrpVae + 101; + const char* gd = "vae.geo_decoder"; + m.b_feat = decl_b(b, nm.f("geo.feat"), RAD_F32, { Q, F }); + m.b_qx = decl_b(b, nm.f("geo.x"), RAD_BF16, { Q, D }); + m.b_qh = decl_b(b, nm.f("geo.h"), RAD_BF16, { Q, D }); + m.b_qq = decl_b(b, nm.f("geo.q"), RAD_BF16, { Q, D }); + m.b_qqn = decl_b(b, nm.f("geo.qn"), RAD_BF16, { Q, D }); + m.b_qatt = decl_b(b, nm.f("geo.att"), RAD_BF16, { Q, D }); + m.b_qff = decl_b(b, nm.f("geo.ff"), RAD_BF16, { Q, 4 * D }); + m.b_qlogit = decl_b(b, nm.f("geo.logit"), RAD_BF16, { Q, 1 }); + m.b_field = decl_b(b, nm.f("geo.field"), RAD_F32, { Q }); + m.op_four = rw(b, RAD_OP(b, "point_fourier", + RAD_PARAMS(RAD_RANGE("M", 1, Q), RAD_INT("n", 3), + RAD_INT("freqs", kFreqs), RAD_INT("pi", 0), + RAD_STR("dtype", "f32")), + RAD_NOWEIGHTS), + {}, { m.b_feat }); + RAD_ARCH_TRY(linear(b, nm, m.q_proj, "geo.query_proj", "vae.geo_decoder.query_proj", D, F, Q, + m.b_feat, m.b_qx, acc, g, true, "none", 0, false, "f32")); + const char* cb = "vae.geo_decoder.cross_attn_decoder"; + auto GW = [&](const char* dn, const char* pre, const char* src, int64_t n) { + return wcopy(b, nm.f("%s", dn), nm.ckpt("%s.%s", pre, src), RAD_BF16, { n }, acc, g); + }; + m.q_n1w = GW("geo.ln_1.weight", cb, "ln_1.weight", D); + m.q_n1b = GW("geo.ln_1.bias", cb, "ln_1.bias", D); + m.q_n3w = GW("geo.ln_3.weight", cb, "ln_3.weight", D); + m.q_n3b = GW("geo.ln_3.bias", cb, "ln_3.bias", D); + m.q_qnw = wcopy(b, nm.f("geo.q_norm.weight"), nm.ckpt("%s.attn.attention.q_norm.weight", cb), + RAD_BF16, { m.hd }, acc, g); + m.q_qnb = wcopy(b, nm.f("geo.q_norm.bias"), nm.ckpt("%s.attn.attention.q_norm.bias", cb), + RAD_BF16, { m.hd }, acc, g); + m.q_pw = GW("geo.ln_post.weight", gd, "ln_post.weight", D); + m.q_pb = GW("geo.ln_post.bias", gd, "ln_post.bias", D); + if (!m.q_n1w || !m.q_n1b || !m.q_n3w || !m.q_n3b || !m.q_qnw || !m.q_qnb || !m.q_pw || !m.q_pb) + return RAD_E_INVAL; + m.op_qn1 = affine_norm(b, Q, D, 1e-6, m.q_n1w, m.q_n1b, m.b_qx, m.b_qh); + RAD_ARCH_TRY(linear(b, nm, m.q_q, "geo.attn_q", nm.ckpt("%s.attn.c_q", cb), D, D, Q, m.b_qh, + m.b_qq, acc, g, false)); + m.op_qqn = head_norm(b, m, Q, m.q_qnw, m.q_qnb, m.b_qq, m.b_qqn); + m.op_qattn = rw(b, RAD_OP(b, "attn_cross", + RAD_PARAMS(RAD_RANGE("M", 1, Q), RAD_INT("head_dim", m.hd), + RAD_INT("gqa", 1), RAD_INT("causal", 0), + RAD_STR("dtype", "bf16"), + RAD_F64("scale", 1.0 / std::sqrt((double)m.hd))), + RAD_NOWEIGHTS), + { m.b_qqn, m.b_gk, m.b_gv }, { m.b_qatt }); + RAD_ARCH_TRY(linear(b, nm, m.q_o, "geo.attn_out", nm.ckpt("%s.attn.c_proj", cb), D, D, Q, + m.b_qatt, m.b_qx, acc, g, true, "none", m.b_qx)); + m.op_qn3 = affine_norm(b, Q, D, 1e-6, m.q_n3w, m.q_n3b, m.b_qx, m.b_qh); + RAD_ARCH_TRY(linear(b, nm, m.q_fc, "geo.mlp_in", nm.ckpt("%s.mlp.c_fc", cb), 4 * D, D, Q, + m.b_qh, m.b_qff, acc, g, true, "gelu")); + RAD_ARCH_TRY(linear(b, nm, m.q_out, "geo.mlp_out", nm.ckpt("%s.mlp.c_proj", cb), D, 4 * D, Q, + m.b_qff, m.b_qx, acc, g, true, "none", m.b_qx)); + /* torch's LayerNorm default eps, 1e-5, unlike the blocks' 1e-6. */ + m.op_qpost = affine_norm(b, Q, D, 1e-5, m.q_pw, m.q_pb, m.b_qx, m.b_qh); + RAD_ARCH_TRY(linear(b, nm, m.q_head, "geo.output_proj", "vae.geo_decoder.output_proj", 1, D, Q, + m.b_qh, m.b_qlogit, acc, g)); + m.op_qcast = rw(b, RAD_OP(b, "cast", + RAD_PARAMS(RAD_RANGE("M", 1, Q), RAD_INT("n", 1), + RAD_STR("from", "bf16"), RAD_STR("to", "f32")), + RAD_NOWEIGHTS), + { m.b_qlogit }, { m.b_field }); + return m.op_four && m.op_qn1 && m.op_qqn && m.op_qattn && m.op_qn3 && m.op_qpost && + m.op_qcast + ? RAD_OK : RAD_E_INVAL; +} + +static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* ctx) { + Model& m = g_model; + m = Model{}; + m.nm = Names(ctx->scope); + RAD_ARCH_TRY(check_format(meta)); + if (ctx->world_size > 1) { + fprintf(stderr, "radiance: hunyuan3d2 runs on one card (--tp 1): the model is 2.2B and a " + "pass is one request's\n"); + return RAD_E_UNSUPPORTED; + } + const char* dc = "conditioner.params.main_image_encoder.kwargs.config"; + char key[160]; + auto ci = [&](const char* k, long long d) { + std::snprintf(key, sizeof key, "%s.%s", dc, k); + return (int64_t)rad_meta_geti(meta, key, d); + }; + m.D = rad_meta_geti(meta, "model.params.hidden_size", 1024); + m.H = rad_meta_geti(meta, "model.params.num_heads", 16); + m.hd = m.D / std::max(m.H, 1); + m.ff = (int64_t)(m.D * rad_meta_getf(meta, "model.params.mlp_ratio", 4.0)); + m.C = rad_meta_geti(meta, "model.params.in_channels", 64); + m.n_double = rad_meta_geti(meta, "model.params.depth", 16); + m.n_single = rad_meta_geti(meta, "model.params.depth_single_blocks", 32); + m.L = rad_meta_geti(meta, "vae.params.num_latents", 3072); + m.n_vae = rad_meta_geti(meta, "vae.params.num_decoder_layers", 16); + m.scale_factor = rad_meta_getf(meta, "vae.params.scale_factor", 1.0); + m.E = ci("hidden_size", 1536); + m.EH = ci("num_attention_heads", 24); + m.n_dino = ci("num_hidden_layers", 40); + /* DINOv2's SwiGLU width: 2/3 of mlp_ratio times the width, rounded up to 8. */ + m.Eff = ((int64_t)(m.E * ci("mlp_ratio", 4) * 2 / 3) + 7) / 8 * 8; + if (m.hd != 64 || m.E / std::max(m.EH, 1) != 64 || + rad_meta_geti(meta, "vae.params.width", m.D) != m.D || + rad_meta_geti(meta, "vae.params.heads", m.H) != m.H || + rad_meta_geti(meta, "vae.params.embed_dim", m.C) != m.C || + rad_meta_geti(meta, "model.params.context_in_dim", m.E) != m.E || + !(m.scale_factor > 0.0)) { + fprintf(stderr, "radiance: hunyuan3d2: the networks' widths disagree (DiT %lld x %lld, " + "encoder %lld x %lld, VAE scale %g); every attention here is 64 wide\n", + (long long)m.H, (long long)m.hd, (long long)m.EH, (long long)m.E, m.scale_factor); + return RAD_E_UNSUPPORTED; + } + /* Lanes are requests holding state, not a pass's sequences (a pass is one request's, and + * --max-num-seqs is 1): one denoising or decoding while the next is conditioned. */ + m.rows = 2 * (kCond + m.L); + m.lanes = kLanes; + Names& nm = m.nm; + m.b_lat = decl_b(b, nm.f("lat_state"), RAD_BF16, { m.lanes * m.L, m.C }, RAD_BUF_PERSIST); + m.b_cstore = decl_b(b, nm.f("cond_store"), RAD_BF16, { m.lanes * 2 * kCond, m.D }, + RAD_BUF_PERSIST); + m.b_gk = decl_b(b, nm.f("geo_k"), RAD_BF16, { m.lanes * m.L, m.D }, RAD_BUF_PERSIST); + m.b_gv = decl_b(b, nm.f("geo_v"), RAD_BF16, { m.lanes * m.L, m.D }, RAD_BUF_PERSIST); + RAD_ARCH_TRY(declare_dino(b, m)); + RAD_ARCH_TRY(declare_dit(b, m)); + RAD_ARCH_TRY(declare_vae(b, m)); + RAD_ARCH_TRY(declare_query(b, m)); + + RadShapeGenDecl d{}; + d.name = "hunyuan3d-2"; + d.canvas = rad_meta_geti(meta, "image_processor.params.size", kCanvas); + d.border_ratio = rad_meta_getf(meta, "image_processor.params.border_ratio", 0.15); + d.enc_size = kEncSize; + d.enc_patch = kPatch; + for (int c = 0; c < 3; ++c) { d.pix_mean[c] = kMean[c]; d.pix_std[c] = kStd[c]; } + d.latent_rows = m.L; + d.latent_channels = m.C; + d.step_rows = m.rows; + d.default_steps = 50; + d.max_steps = 200; + d.default_guidance = 5.0; + d.bounds = kBounds; + d.level = 0.0; + d.default_resolution = kResDef; + d.min_resolution = kResMin; + d.max_resolution = kResMax; + d.max_lanes = m.lanes; + d.max_query = kMaxQuery; + d.field_out = m.b_field; + RAD_ARCH_TRY(rad_declare_shape_generator(b, &d)); + rad_note(b, "Hunyuan3D-2 shape: DINOv2 %lld x %lld, DiT %lld double + %lld single blocks of " + "%lld, VAE %lld blocks over %lld latents; %lld lanes, %d query points a pass", + (long long)m.n_dino, (long long)m.E, (long long)m.n_double, (long long)m.n_single, + (long long)m.D, (long long)m.n_vae, (long long)m.L, (long long)m.lanes, kMaxQuery); + return RAD_OK; +} + +/* ================================================================== step */ +static void step_cond(RadCtx* c, const RadShapeGenBatch* S, const Model& m) { + const int64_t R = kCond, E = m.E, D = m.D; + RAD_ISSUE_N(c, m.op_ids, R, brows(m.b_ids, R)); + RAD_ISSUE_N(c, m.op_dcu, 2, brows(m.b_dcu, 2)); + RAD_ISSUE_N(c, m.op_pos, R, brows(m.b_ids, R), RAD_W(m.w_pos), brows(m.b_pos, R)); + RAD_ISSUE_N(c, m.op_cls, 1, brows(m.b_ids, 1), RAD_W(m.w_cls), brows(m.b_cls, 1)); + RAD_ISSUE_N(c, m.op_cls_add, 1, brows(m.b_cls, 1), brows(m.b_pos, 1), brows(m.b_dx, 1)); + RAD_ISSUE_N(c, m.op_patch, kNPatch, praw2(S->patches, RAD_F32, kNPatch, kPatchDim), + RAD_W(m.w_patch), RAD_W(m.b_patchw), brow_slice(m.b_pos, 1, kNPatch, E), + brow_slice(m.b_dx, 1, kNPatch, E)); + const RadOperand cu = brows(m.b_dcu, 2); + for (const DinoLayer& Y : m.dino) { + RAD_ISSUE_N(c, Y.op_n1, R, brows(m.b_dx, R), RAD_W(Y.n1w), RAD_W(Y.n1b), brows(m.b_dh, R)); + lin_issue(c, Y.qkv, R, brows(m.b_dh, R), brows(m.b_dqkv, R)); + RAD_ISSUE_N(c, Y.op_attn, R, bcol(m.b_dqkv, 0, E, R), bcol(m.b_dqkv, E, E, R), + bcol(m.b_dqkv, 2 * E, E, R), cu, brows(m.b_datt, R)); + lin_issue(c, Y.o, R, brows(m.b_datt, R), brows(m.b_do, R)); + RAD_ISSUE_N(c, Y.op_ls1, R, brows(m.b_do, R), RAD_W(Y.ls1), brows(m.b_do, R)); + RAD_ISSUE_N(c, Y.op_add1, R, brows(m.b_do, R), brows(m.b_dx, R), brows(m.b_dx, R)); + RAD_ISSUE_N(c, Y.op_n2, R, brows(m.b_dx, R), RAD_W(Y.n2w), RAD_W(Y.n2b), brows(m.b_dh, R)); + lin_issue(c, Y.up, R, brows(m.b_dh, R), brows(m.b_dgu, R)); + RAD_ISSUE_N(c, Y.op_gu, R, brows(m.b_dgu, R), brows(m.b_dact, R)); + lin_issue(c, Y.down, R, brows(m.b_dact, R), brows(m.b_do, R)); + RAD_ISSUE_N(c, Y.op_ls2, R, brows(m.b_do, R), RAD_W(Y.ls2), brows(m.b_do, R)); + RAD_ISSUE_N(c, Y.op_add2, R, brows(m.b_do, R), brows(m.b_dx, R), brows(m.b_dx, R)); + } + RAD_ISSUE_N(c, m.op_dln, R, brows(m.b_dx, R), RAD_W(m.w_lnw), RAD_W(m.w_lnb), + brows(m.b_dout, R)); + /* The lane's store: the picture's branch, then the unconditioned one. */ + const int64_t base = (int64_t)S->lane * 2 * R; + RAD_ISSUE_N(c, m.op_zero, R, brows(m.b_zero, R)); + lin_issue(c, m.cond_in, R, brows(m.b_dout, R), brow_slice(m.b_cstore, base, R, D)); + lin_issue(c, m.cond_in, R, brows(m.b_zero, R), brow_slice(m.b_cstore, base + R, R, D)); +} + +/* One stream's rows of a step: the latents' one run, or the conditioning's two. */ +template static void each_run(int which, const Model& m, F&& f) { + if (which == kImg) { f((int64_t)kCond, 2 * m.L); return; } + f(0, (int64_t)kCond); + f((int64_t)kCond + 2 * m.L, (int64_t)kCond); +} + +static void step_dit(RadCtx* c, const RadShapeGenBatch* S, const Model& m) { + const int64_t N = m.rows, D = m.D, L2 = 2 * m.L, Cn = kCond; + const RadOperand lat_cu = praw(S->lat_cu, RAD_I32, 3); + const RadOperand lanes = praw(S->lanes, RAD_I32, 2); + const int64_t LR = m.lanes * m.L; + /* ---- the latent rows: noise on the first step, both entries from the lane, latent_in */ + RAD_ISSUE_N(c, m.op_randn, L2, praw(S->flags, RAD_I32, 2), praw(S->seed, RAD_U32, 4), lanes, + lat_cu, brows(m.b_lat, LR)); + RAD_ISSUE_N(c, m.op_lgather, L2, brows(m.b_lat, LR), lanes, lat_cu, brows(m.b_lx, L2)); + lin_issue(c, m.latent_in, L2, brows(m.b_lx, L2), brow_slice(m.b_x, Cn, L2, D)); + /* ---- the conditioning rows from the lane's store */ + const int64_t base = (int64_t)S->lane * 2 * Cn; + RAD_ISSUE_N(c, m.op_ccopy, Cn, brow_slice(m.b_cstore, base, Cn, D), + brow_slice(m.b_x, 0, Cn, D)); + RAD_ISSUE_N(c, m.op_ccopy, Cn, brow_slice(m.b_cstore, base + Cn, Cn, D), + brow_slice(m.b_x, Cn + L2, Cn, D)); + /* ---- the timestep and every modulation */ + RAD_ISSUE_N(c, m.op_temb, 1, praw(S->sigma, RAD_F32, 1), brows(m.b_temb, 1)); + lin_issue(c, m.t_in1, 1, brows(m.b_temb, 1), brows(m.b_t1, 1)); + RAD_ISSUE_N(c, m.op_tsilu, 1, brows(m.b_t1, 1), brows(m.b_t1s, 1)); + lin_issue(c, m.t_out, 1, brows(m.b_t1s, 1), brows(m.b_vec, 1)); + RAD_ISSUE_N(c, m.op_vsilu, 1, brows(m.b_vec, 1), brows(m.b_svec, 1)); + for (int64_t l = 0; l < m.n_double; ++l) + for (int s = 0; s < 2; ++s) + lin_issue(c, m.dbl[(size_t)l].s[s].mod, 1, brows(m.b_svec, 1), + bcol(m.b_mods, m.mod_dbl[s][(size_t)l], 6 * D, 1)); + for (int64_t l = 0; l < m.n_single; ++l) + lin_issue(c, m.sgl[(size_t)l].mod, 1, brows(m.b_svec, 1), + bcol(m.b_mods, m.mod_sgl[(size_t)l], 3 * D, 1)); + lin_issue(c, m.fin_mod, 1, brows(m.b_svec, 1), bcol(m.b_mods, m.mod_fin, 2 * D, 1)); + RAD_ISSUE_N(c, m.op_cu_txt, 2, brows(m.b_cu_txt, 2)); + RAD_ISSUE_N(c, m.op_cu_img, 2, brows(m.b_cu_img, 2)); + RAD_ISSUE_N(c, m.op_cu_all, 2, brows(m.b_cu_all, 2)); + RAD_ISSUE_N(c, m.op_cu_ent, 3, brows(m.b_cu_ent, 3)); + auto mod = [&](int64_t col, int64_t off, int64_t w) { + return bcol(m.b_mods, col + off * D, w, 1); + }; + auto rcu = [&](int64_t n) { return n == L2 ? brows(m.b_cu_img, 2) : brows(m.b_cu_txt, 2); }; + + /* ---- the double blocks */ + for (int64_t l = 0; l < m.n_double; ++l) { + const Double& B = m.dbl[(size_t)l]; + for (int s = 0; s < 2; ++s) { + const Stream& T = B.s[s]; + const int64_t col = m.mod_dbl[s][(size_t)l]; + const int64_t pcol = l > 0 ? m.mod_dbl[s][(size_t)(l - 1)] : 0; + each_run(s, m, [&](int64_t r0, int64_t n) { + const RadOperand x = brow_slice(m.b_x, r0, n, D); + if (l > 0) + RAD_ISSUE_N(c, T.op_n1, n, brow_slice(m.b_f, r0, n, D), mod(pcol, 5, D), + mod(col, 0, 2 * D), RAD_NONE, rcu(n), x, + brow_slice(m.b_h, r0, n, D)); + else + RAD_ISSUE_N(c, T.op_n1, n, RAD_NONE, RAD_NONE, mod(col, 0, 2 * D), RAD_NONE, + rcu(n), x, brow_slice(m.b_h, r0, n, D)); + lin_issue(c, T.qkv, n, brow_slice(m.b_h, r0, n, D), + brow_slice(m.b_qkv, r0, n, 3 * D)); + RAD_ISSUE_N(c, T.op_qk, n, brow_slice(m.b_qkv, r0, n, 3 * D), RAD_NONE, + RAD_W(T.qn), RAD_W(T.kn)); + }); + } + RAD_ISSUE_N(c, B.op_attn, N, bcol(m.b_qkv, 0, D, N), bcol(m.b_qkv, D, D, N), + bcol(m.b_qkv, 2 * D, D, N), brows(m.b_cu_ent, 3), brows(m.b_att, N)); + for (int s = 0; s < 2; ++s) { + const Stream& T = B.s[s]; + const int64_t col = m.mod_dbl[s][(size_t)l]; + each_run(s, m, [&](int64_t r0, int64_t n) { + lin_issue(c, T.proj, n, brow_slice(m.b_att, r0, n, D), brow_slice(m.b_o, r0, n, D)); + RAD_ISSUE_N(c, T.op_n2, n, brow_slice(m.b_o, r0, n, D), mod(col, 2, D), + mod(col, 3, 2 * D), RAD_NONE, rcu(n), brow_slice(m.b_x, r0, n, D), + brow_slice(m.b_h, r0, n, D)); + lin_issue(c, T.mlp1, n, brow_slice(m.b_h, r0, n, D), + brow_slice(m.b_ff, r0, n, m.ff)); + lin_issue(c, T.mlp2, n, brow_slice(m.b_ff, r0, n, m.ff), + brow_slice(m.b_f, r0, n, D)); + }); + } + } + /* The last double block's MLP, gated in, each stream by its own gate. */ + { + const int64_t l = m.n_double - 1; + for (int s = 0; s < 2; ++s) { + const int64_t col = m.mod_dbl[s][(size_t)l]; + each_run(s, m, [&](int64_t r0, int64_t n) { + RAD_ISSUE_N(c, s == kImg ? m.op_gate_img : m.op_gate_txt, n, + brow_slice(m.b_f, r0, n, D), mod(col, 5, D), rcu(n), + brow_slice(m.b_x, r0, n, D)); + }); + } + } + /* ---- the single blocks */ + for (int64_t l = 0; l < m.n_single; ++l) { + const Single& T = m.sgl[(size_t)l]; + const int64_t col = m.mod_sgl[(size_t)l]; + if (l > 0) + RAD_ISSUE_N(c, T.op_n, N, brows(m.b_f, N), mod(m.mod_sgl[(size_t)(l - 1)], 2, D), + mod(col, 0, 2 * D), RAD_NONE, brows(m.b_cu_all, 2), brows(m.b_x, N), + brows(m.b_h, N)); + else + RAD_ISSUE_N(c, T.op_n, N, RAD_NONE, RAD_NONE, mod(col, 0, 2 * D), RAD_NONE, + brows(m.b_cu_all, 2), brows(m.b_x, N), brows(m.b_h, N)); + lin_issue(c, T.l1, N, brows(m.b_h, N), brows(m.b_l1, N)); + RAD_ISSUE_N(c, T.op_qk, N, bcol(m.b_l1, 0, 3 * D, N), RAD_NONE, RAD_W(T.qn), RAD_W(T.kn)); + RAD_ISSUE_N(c, T.op_attn, N, bcol(m.b_l1, 0, D, N), bcol(m.b_l1, D, D, N), + bcol(m.b_l1, 2 * D, D, N), brows(m.b_cu_ent, 3), bcol(m.b_cat, 0, D, N)); + RAD_ISSUE_N(c, T.op_act, N, bcol(m.b_l1, 3 * D, m.ff, N), bcol(m.b_cat, D, m.ff, N)); + lin_issue(c, T.l2, N, brows(m.b_cat, N), brows(m.b_f, N)); + } + /* ---- the output layer over the latent rows (the last single block gated in), the step */ + const int64_t lcol = m.mod_sgl.back(); + RAD_ISSUE_N(c, m.op_fin_n, L2, brow_slice(m.b_f, Cn, L2, D), mod(lcol, 2, D), + mod(m.mod_fin, 0, 2 * D), RAD_NONE, brows(m.b_cu_img, 2), + brow_slice(m.b_x, Cn, L2, D), brow_slice(m.b_h, Cn, L2, D)); + lin_issue(c, m.fin, L2, brow_slice(m.b_h, Cn, L2, D), brows(m.b_v, L2)); + RAD_ISSUE_N(c, m.op_euler, L2, brows(m.b_v, L2), praw(S->sigma, RAD_F32, 2), + praw(S->sigma_next, RAD_F32, 2), praw(S->cfg, RAD_F32, 2), + praw(S->pair, RAD_I32, 2), lanes, praw(S->flags, RAD_I32, 2), + praw(S->seed, RAD_U32, 4), lat_cu, RAD_NONE, RAD_NONE, brows(m.b_lat, LR), + RAD_NONE); +} + +/* A per-head view of rows [first_row, first_row + rows) of a [*, H hd] bf16 buffer: the same + * bytes as [rows H, hd], one head a row (the buffer's liveness is declared on the op). */ +static RadOperand heads(RadCtx* c, rad_buf h, int64_t first_row, int64_t rows, const Model& m) { + const char* p = (const char*)rad_buf_ptr(c, h) + first_row * m.D * 2; + return RAD_P_T2(p, RAD_BF16, rows * m.H, m.hd); +} + +static void step_latent(RadCtx* c, const RadShapeGenBatch* S, const Model& m) { + const int64_t L = m.L, D = m.D; + const int64_t base = (int64_t)S->lane * L; + RAD_ISSUE_N(c, m.op_vcu, 2, brows(m.b_vcu, 2)); + RAD_ISSUE_N(c, m.op_unscale, L, brow_slice(m.b_lat, base, L, m.C), brows(m.b_vl, L)); + lin_issue(c, m.post_kl, L, brows(m.b_vl, L), brows(m.b_vx, L)); + for (const VaeLayer& V : m.vae) { + RAD_ISSUE_N(c, V.op_n1, L, brows(m.b_vx, L), RAD_W(V.n1w), RAD_W(V.n1b), brows(m.b_vh, L)); + lin_issue(c, V.q, L, brows(m.b_vh, L), brows(m.b_vq, L)); + lin_issue(c, V.k, L, brows(m.b_vh, L), brows(m.b_vk, L)); + lin_issue(c, V.v, L, brows(m.b_vh, L), brows(m.b_vv, L)); + RAD_ISSUE_N(c, V.op_qn, L * m.H, heads(c, m.b_vq, 0, L, m), RAD_W(V.qnw), RAD_W(V.qnb), + heads(c, m.b_vqn, 0, L, m)); + RAD_ISSUE_N(c, V.op_kn, L * m.H, heads(c, m.b_vk, 0, L, m), RAD_W(V.knw), RAD_W(V.knb), + heads(c, m.b_vkn, 0, L, m)); + RAD_ISSUE_N(c, V.op_attn, L, brows(m.b_vqn, L), brows(m.b_vkn, L), brows(m.b_vv, L), + brows(m.b_vcu, 2), brows(m.b_vatt, L)); + lin_issue(c, V.proj, L, brows(m.b_vatt, L), brows(m.b_vx, L), brows(m.b_vx, L)); + RAD_ISSUE_N(c, V.op_n2, L, brows(m.b_vx, L), RAD_W(V.n2w), RAD_W(V.n2b), brows(m.b_vh, L)); + lin_issue(c, V.fc, L, brows(m.b_vh, L), brows(m.b_vff, L)); + lin_issue(c, V.out, L, brows(m.b_vff, L), brows(m.b_vx, L), brows(m.b_vx, L)); + } + RAD_ISSUE_N(c, m.op_gn2, L, brows(m.b_vx, L), RAD_W(m.g_n2w), RAD_W(m.g_n2b), brows(m.b_vh, L)); + lin_issue(c, m.g_k, L, brows(m.b_vh, L), brows(m.b_vk, L)); + lin_issue(c, m.g_v, L, brows(m.b_vh, L), brow_slice(m.b_gv, base, L, D)); + RAD_ISSUE_N(c, m.op_gkn, L * m.H, heads(c, m.b_vk, 0, L, m), RAD_W(m.g_knw), RAD_W(m.g_knb), + heads(c, m.b_gk, base, L, m)); +} + +static void step_query(RadCtx* c, const RadShapeGenBatch* S, const Model& m) { + const int64_t n = S->n_query, D = m.D, L = m.L; + const int64_t base = (int64_t)S->lane * L; + RAD_ISSUE_N(c, m.op_four, n, praw2(S->query, RAD_F32, n, 3), brows(m.b_feat, n)); + lin_issue(c, m.q_proj, n, brows(m.b_feat, n), brows(m.b_qx, n)); + RAD_ISSUE_N(c, m.op_qn1, n, brows(m.b_qx, n), RAD_W(m.q_n1w), RAD_W(m.q_n1b), brows(m.b_qh, n)); + lin_issue(c, m.q_q, n, brows(m.b_qh, n), brows(m.b_qq, n)); + RAD_ISSUE_N(c, m.op_qqn, n * m.H, heads(c, m.b_qq, 0, n, m), RAD_W(m.q_qnw), RAD_W(m.q_qnb), + heads(c, m.b_qqn, 0, n, m)); + RAD_ISSUE_N(c, m.op_qattn, n, brows(m.b_qqn, n), brow_slice(m.b_gk, base, L, D), + brow_slice(m.b_gv, base, L, D), praw(S->query_cu, RAD_I32, 2), + praw(S->lat_cu, RAD_I32, 2), brows(m.b_qatt, n)); + lin_issue(c, m.q_o, n, brows(m.b_qatt, n), brows(m.b_qx, n), brows(m.b_qx, n)); + RAD_ISSUE_N(c, m.op_qn3, n, brows(m.b_qx, n), RAD_W(m.q_n3w), RAD_W(m.q_n3b), brows(m.b_qh, n)); + lin_issue(c, m.q_fc, n, brows(m.b_qh, n), brows(m.b_qff, n)); + lin_issue(c, m.q_out, n, brows(m.b_qff, n), brows(m.b_qx, n), brows(m.b_qx, n)); + RAD_ISSUE_N(c, m.op_qpost, n, brows(m.b_qx, n), RAD_W(m.q_pw), RAD_W(m.q_pb), brows(m.b_qh, n)); + lin_issue(c, m.q_head, n, brows(m.b_qh, n), brows(m.b_qlogit, n)); + RAD_ISSUE_N(c, m.op_qcast, n, brows(m.b_qlogit, n), brows(m.b_field, n)); +} + +static void step(RadCtx* c, const RadBatch* batch) { + const Model& m = g_model; + const RadShapeGenBatch* S = batch->sgen_b; + if (!batch->gen || !S) { + rad_step_fail(c, "hunyuan3d2 is a shape generator and runs generator passes only"); + return; + } + switch (batch->gen) { + case RAD_GEN_PASS_SCOND: step_cond(c, S, m); return; + case RAD_GEN_PASS_SSTEP: step_dit(c, S, m); return; + case RAD_GEN_PASS_SLATENT: step_latent(c, S, m); return; + case RAD_GEN_PASS_SQUERY: step_query(c, S, m); return; + default: rad_step_fail(c, "hunyuan3d2: a generator pass of a kind this plugin does not know"); + } +} + +/* ================================================================== the probe */ +/* The rows of the largest pass: a query pass's points, against a step's two branches. */ +static int probe(const RadModelMeta* meta, RadArchProbe* out) { + if (!meta || !out) return RAD_E_INVAL; + const int64_t L = rad_meta_geti(meta, "vae.params.num_latents", 3072); + out->gen_rows = std::max(kMaxQuery, 2 * (kCond + L)); + out->gen_shape = 1; + return RAD_OK; +} + +} /* namespace hunyuan3d2 */ + +RAD_ARCH_PROBE(hunyuan3d2) +RAD_ARCH_PLUGIN(hunyuan3d2, "hunyuan3d2", "", "0.1.0", + "Hunyuan3D-2's shape model: DINOv2-giant over the picture, a flow-matching DiT of " + "16 double and 32 single blocks over 3072 latents, and the shape VAE's geometry " + "decoder sampled at the core's grid points; bf16") diff --git a/arch/nemotronh/CMakeLists.txt b/arch/nemotronh/CMakeLists.txt new file mode 100644 index 00000000..d362b6f5 --- /dev/null +++ b/arch/nemotronh/CMakeLists.txt @@ -0,0 +1,7 @@ +if(NOT COMMAND rad_add_plugin) + cmake_minimum_required(VERSION 3.21) + project(nemotronh LANGUAGES CXX) + find_package(radiance REQUIRED) + rad_plugin_defaults() +endif() +rad_add_plugin(nemotronh architectures SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nemotronh.cpp) diff --git a/arch/nemotronh/nemotronh.cpp b/arch/nemotronh/nemotronh.cpp new file mode 100644 index 00000000..d1b2c946 --- /dev/null +++ b/arch/nemotronh/nemotronh.cpp @@ -0,0 +1,1142 @@ +/* nemotronh -- NVIDIA's Nemotron-H hybrids from the bf16 checkpoint: Nemotron-3.5-Bolt-74B-A9B + * (`model_type: nemotron_h_omni` around a `nemotron_h_puzzle` language model, + * NemotronH_Omni_Reasoning_V3), its language model; the routed experts as the recipe stores them. + * + * 88 blocks, each one mixer behind its own RMS norm and a residual add: 40 Mamba-2, 40 routed + * feed-forward and 8 attention, in the order `layers_block_type` gives + * Mamba-2: 128 heads of 64 in 8 groups, a 128-wide state, a 4-tap causal convolution with bias + * and SiLU over x|B|C, dt = softplus(dt + dt_bias), a D skip, and RMSNormGated over groups of + * 1024 of y * silu(z) + * attention: 32 query heads and 2 KV heads of 128, no position encoding (NoPE) + * feed-forward: a latent MoE. The router scores the normed hidden state (sigmoid, a correction + * bias for the selection only, top-9, normalised, x5); the routed experts run in a 1024-wide + * latent (fc1_latent_proj in front, fc2_latent_proj behind) and are ungated, + * down(relu(up(x))^2). Count and width differ by layer (Puzzle's `block_configs`: 240 to 496 + * experts of 1536 to 2560). A shared expert of 5376, relu^2 as well, reads the hidden state. + * + * ============================== THE LATENT FEED-FORWARD ============================== + * + * MoeFP8 serves the routed arm with its Geom at the latent width: its input is fc1's output + * (quantised here), the router reads the hidden state over Config::router_k, and its gather writes + * the routed sum back into the latent plane. fc2 has no bias and is linear, so under tensor + * parallelism each rank applies it (replicated) to its partial latent sum and adds its slice of the + * shared expert; one all-reduce over the hidden width then sums both arms (Config::no_reduce). fc1 + * is replicated too: the latent is every rank's input. + * + * ============================== THE MAMBA-2 MIXER ============================== + * + * in_proj's rows are z | x | B | C | dt (8192, 8192, 1024, 1024, 128). It is served as three linears + * over row maps of the one tensor: z, x|B|C (the convolution's input) and dt. Under tensor + * parallelism each rank takes whole heads and their groups' B and C, and dt's 128 rows split 32 a + * rank at four, which is no whole 128-row scale block; dt is its own linear so a recipe can keep + * it bf16 while the others are block fp8. + * + * The scan is `ssd_update`, Mamba-2's recurrence a token at a time (libref/ref_ssd.cpp), for + * prefill and decode. dt is not clamped: the checkpoint's `time_step_limit` is (0, inf), as vLLM + * serves it; HF's torch path clamps to time_step_min, which moves 13 % of the steps of the first + * layers. + * + * RMSNormGated is three ops: act_mul (silu of z times y), a gainless rmsnorm over rows of 1024 (the + * group), and mul_weight with the 8192 gains. A rank's heads are whole groups. + * + * ============================== RANKS, SPECULATION, VISION ============================== + * + * One, two or four ranks. At four each of the 2 KV heads is replicated over a rank pair (AttnFP8's + * spans), the LiLiCorr drafter's 2 the same way (Dflash2's spans). Speculating, the scan keeps its + * state in ssd_update's anchor form (one committed state and a scratch of per-token records), at + * most 31 drafts a step; the convolution's window is ple_conv's rolling one. Pictures and video go + * through the C-RADIO tower (radio.h) when the container holds it. A finite `time_step_limit` is + * refused by name, and so is every other geometry the release does not have. + * docs/ARCHITECTURES.md describes the model. */ +#include +#include +#include +#include +#include +#include "radio.h" +#include +#include +#include +#include +#include + +namespace nemotronh { +using namespace rad::arch; + +enum Kind { kMamba, kMoe, kAttn }; + +/* The released geometry this graph is written for; a checkpoint that differs is refused by name. */ +struct Shape { + int64_t n_embd = 0, n_layer = 0, heads = 0, head_dim = 0, state = 0, groups = 0, conv = 0, + latent = 0, ff_shared = 0; + double route_scale = 1; + std::vector kind; + std::vector experts, ff, top_k; /* per layer; 0 off the routed layers */ +}; + +static int64_t cfg(const RadModelMeta* m, const char* key, int64_t fallback) { + return rad_meta_geti(m, key, fallback); +} + +/* One all-reduce of [rows, n_embd] in place, or 0 at one rank. */ +static rad_op reduce(RadBuilder* b, const Geom& g, rad_buf x, bool exact = false) { + if (g.world <= 1) return 0; + return rw(b, RAD_OP(b, "all_reduce", + RAD_PARAMS(RAD_INT("world_size", g.world), + RAD_RANGE("numel", g.n_embd, g.max_tok * g.n_embd), + RAD_STR("dtype", g.dtype), + RAD_INT("exact", exact ? 1 : g.wire_exact), + RAD_INT("min_bytes", g.wire_min_bytes)), + RAD_NOWEIGHTS), + { x }, { x }); +} + +struct Mamba { + struct Wire { + ActFP8 input{}; /* [T, n_embd] the normed hidden state */ + rad_buf z = 0; /* [T, W] */ + rad_buf xbc = 0; /* [T, W + 2 GN] the convolution's input */ + rad_buf conv = 0; /* [T, W + 2 GN] its output */ + rad_buf dt = 0; /* [T, H] */ + rad_buf y = 0; /* [T, W] the scan's output */ + ActFP8 core_out{}; /* [T, W] the gated norm's, the out-projection's input */ + rad_buf out = 0; /* [T, n_embd] */ + }; + Geom g{}; + Wire w{}; + int layer = 0; + /* This rank's heads, groups and widths. */ + int64_t H = 0, P = 0, N = 0, G = 0, W = 0, GN = 0; + rad_kvgroup state = 0, history = 0; + LinearFP8 in_z{}, in_xbc{}, in_dt{}, output{}; + QuantFP8 out_quant{}; + rad_weight taps = 0, bias = 0, alog = 0, dtb = 0, dskip = 0, gain = 0; + rad_op op_conv = 0, op_prefill = 0, op_verify = 0, op_gate = 0, op_norm = 0, op_gain = 0, + op_ar = 0; + + static constexpr int64_t kNormGroup = 1024; + + int declare(RadBuilder* b, Names& nm, const Geom& geom, const Shape& s, int l, + const Wire& wire, const char* pre, rad_kvgroup st, rad_kvgroup cv) { + g = geom; + w = wire; + layer = l; + state = st; + history = cv; + H = s.heads / g.world; + P = s.head_dim; + N = s.state; + G = s.groups / g.world; + W = H * P; + GN = G * N; + const int64_t Wa = s.heads * s.head_dim, GNa = s.groups * s.state; + const auto grp = grp_layer(l); + RAD_ARCH_TRY(rad_bind_layer_kv(b, l, st)); + RAD_ARCH_TRY(rad_bind_layer_kv(b, l, cv)); + /* in_proj as three row maps: z, x|B|C, dt. */ + const char* src = nm.ckpt("%s.in_proj.weight", pre); + RAD_ARCH_TRY(map_rows(b, nm.f("blk.%d.ssm_in_z.weight", l), { { src, 0, Wa } })); + RAD_ARCH_TRY(map_rows(b, nm.f("blk.%d.ssm_in_xbc.weight", l), + { { src, (int)Wa, Wa + 2 * GNa } })); + RAD_ARCH_TRY(map_rows(b, nm.f("blk.%d.ssm_dt.weight", l), + { { src, (int)(2 * Wa + 2 * GNa), s.heads } })); + in_z.mapped = in_xbc.mapped = in_dt.mapped = true; + RAD_ARCH_TRY(in_z.declare(b, nm, g, nm.f("blk.%d.ssm_in_z", l), W, g.n_embd, RAD_SHARD_ROW, + grp, { src }, w.input, w.z)); + RAD_ARCH_TRY(in_xbc.declare(b, nm, g, nm.f("blk.%d.ssm_in_xbc", l), W + 2 * GN, g.n_embd, + RAD_SHARD_ROW, grp, { src }, w.input, w.xbc, 0, + { W, GN, GN })); + RAD_ARCH_TRY(in_dt.declare(b, nm, g, nm.f("blk.%d.ssm_dt", l), H, g.n_embd, RAD_SHARD_ROW, + grp, { src }, w.input, w.dt)); + + const char *tn = nm.f("blk.%d.ssm_conv1d.weight", l), *bn = nm.f("blk.%d.ssm_conv1d.bias", l), + *an = nm.f("blk.%d.ssm_a_log", l), *dn = nm.f("blk.%d.ssm_dt.bias", l), + *sn = nm.f("blk.%d.ssm_d", l), *gn = nm.f("blk.%d.ssm_norm.weight", l); + RAD_ARCH_TRY(map_copy(b, tn, nm.ckpt("%s.conv1d.weight", pre))); + RAD_ARCH_TRY(map_copy(b, bn, nm.ckpt("%s.conv1d.bias", pre))); + RAD_ARCH_TRY(map_copy(b, an, nm.ckpt("%s.A_log", pre))); + RAD_ARCH_TRY(map_copy(b, dn, nm.ckpt("%s.dt_bias", pre))); + RAD_ARCH_TRY(map_copy(b, sn, nm.ckpt("%s.D", pre))); + RAD_ARCH_TRY(map_copy(b, gn, nm.ckpt("%s.norm.weight", pre))); + taps = decl_w(b, tn, RAD_BF16, { W + 2 * GN, s.conv }, RAD_ACCESS_PER_TOKEN, RAD_SHARD_ROW, + grp, 0, { W, GN, GN }); + bias = decl_w(b, bn, RAD_BF16, { W + 2 * GN }, RAD_ACCESS_PER_TOKEN, RAD_SHARD_ROW, grp, 0, + { W, GN, GN }); + alog = decl_w(b, an, RAD_F32, { H }, RAD_ACCESS_PER_TOKEN, RAD_SHARD_ROW, grp); + dtb = decl_w(b, dn, RAD_F32, { H }, RAD_ACCESS_PER_TOKEN, RAD_SHARD_ROW, grp); + dskip = decl_w(b, sn, RAD_F32, { H }, RAD_ACCESS_PER_TOKEN, RAD_SHARD_ROW, grp); + gain = decl_w(b, gn, RAD_F32, { W }, RAD_ACCESS_PER_TOKEN, RAD_SHARD_ROW, grp); + if (!taps || !bias || !alog || !dtb || !dskip || !gain) return RAD_E_INVAL; + + op_conv = rw(b, + RAD_OP(b, "ple_conv_bias", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", W + 2 * GN), + RAD_INT("width", s.conv), RAD_INT("dilation", 1), + RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(taps, bias)), + { w.xbc }, { w.conv }); + for (int verify = 0; verify < 2; ++verify) { + const rad_op op = + rw(b, + RAD_OP(b, "ssd_update", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("heads", H), + RAD_INT("head_dim", P), RAD_INT("d_state", N), + RAD_INT("groups", G), + RAD_STR("mode", verify ? "verify" : "prefill"), + RAD_STR("dtype", "bf16"), + RAD_STR("state_form", + g.max_spec > 0 ? "anchor" : "per_candidate")), + RAD_WEIGHTS(alog, dtb, dskip)), + { w.conv, w.dt }, { w.y }); + if (verify) + op_verify = op; + else + op_prefill = op; + } + /* RMSNormGated: norm(y * silu(z)) * gain, normed over groups of 1024 (whole groups on a + * rank; read as rows of 1024 of the contiguous plane). */ + op_gate = rw(b, + RAD_OP(b, "act_mul", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", W), + RAD_STR("act", "silu"), RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + { w.z, w.y }, { w.core_out.x }); + op_norm = rw(b, + RAD_OP(b, "rmsnorm", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok * (W / kNormGroup)), + RAD_INT("n", kNormGroup), RAD_F64("eps", g.eps), + RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + { w.core_out.x }, { w.core_out.x }); + op_gain = rw(b, + RAD_OP(b, "mul_weight", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", W), + RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(gain)), + { w.core_out.x }, { w.core_out.x }); + if (!op_conv || !op_prefill || !op_verify || !op_gate || !op_norm || !op_gain) + return RAD_E_INVAL; + const char* on = nm.f("blk.%d.ssm_out", l); + RAD_ARCH_TRY(output.probe(b, nm, g, on, { nm.ckpt("%s.out_proj.weight", pre) })); + if (!output.reads_x) RAD_ARCH_TRY(out_quant.declare(b, g, w.core_out, W)); + RAD_ARCH_TRY(output.declare(b, nm, g, on, g.n_embd, W, RAD_SHARD_COL, grp, + { nm.ckpt("%s.out_proj.weight", pre) }, w.core_out, w.out)); + op_ar = reduce(b, g, w.out); + return g.world > 1 && !op_ar ? RAD_E_INVAL : RAD_OK; + } + + /* The recurrent core over the decode rows (verify) and then the prefill rows, as KdaState. */ + void step(RadCtx* c, const RadBatch* batch) const { + const auto *st = kv_batch(batch, state), *cv = kv_batch(batch, history); + if (!st || !cv || !st->state_index || !cv->state_index) { + rad_step_fail(c, "nemotronh Mamba-2 requires recurrent and convolution state indices"); + return; + } + const int64_t T = batch->n_tok, S = batch->n_seq; + const int64_t pitch = st->state_index_pitch > 0 ? st->state_index_pitch : 1; + in_z.step(c, w.input, w.z, T); + in_xbc.step(c, w.input, w.xbc, T); + in_dt.step(c, w.input, w.dt, T); + int64_t D = 0, DT = 0; + batch_split(batch, &D, &DT); + for (int verify = 1; verify >= 0; --verify) { + const int64_t seq0 = verify ? 0 : D, seqs = verify ? D : S - D, rows = verify ? DT : T; + if (!seqs) continue; + const RadOperand cu = praw(batch->cu_seqlens + seq0, RAD_I32, seqs + 1); + const RadOperand init = praw(batch->ctx_lens + seq0, RAD_I32, seqs); + const RadOperand accepted = + verify ? praw(batch->num_accepted, RAD_I32, seqs) : RAD_NONE; + RAD_ISSUE_N(c, op_conv, rows, brows(w.xbc, rows), RAD_W(taps), + kv_cache(history, layer), cu, RAD_NONE, + praw(cv->state_index + seq0, RAD_I32, seqs), init, accepted, + RAD_W(bias), brows(w.conv, rows)); + RAD_ISSUE_N(c, verify ? op_verify : op_prefill, rows, bcol(w.conv, 0, W, rows), + bcol(w.conv, W, GN, rows), bcol(w.conv, W + GN, GN, rows), + brows(w.dt, rows), RAD_W(alog), RAD_W(dtb), RAD_W(dskip), + kv_cache(state, layer), + praw2(st->state_index + seq0 * pitch, RAD_I32, seqs, pitch), cu, accepted, + init, brows(w.y, rows)); + } + RAD_ISSUE_N(c, op_gate, T, brows(w.z, T), brows(w.y, T), brows(w.core_out.x, T)); + RAD_ISSUE_N(c, op_norm, T * (W / kNormGroup), brows(w.core_out.x, T), RAD_NONE, + brows(w.core_out.x, T)); + RAD_ISSUE_N(c, op_gain, T, brows(w.core_out.x, T), RAD_W(gain), brows(w.core_out.x, T)); + out_quant.step(c, T); + output.step(c, w.core_out, w.out, T); + if (op_ar) RAD_ISSUE_N(c, op_ar, T * g.n_embd, brows(w.out, T), RAD_NONE); + } +}; + +/* The latent feed-forward around MoeFP8 (see the header). */ +struct LatentMoe { + struct Wire { + ActFP8 h{}; /* [T, n_embd] the normed hidden state */ + ActFP8 lat{}; /* [T, latent] fc1's output, then the routed sum */ + rad_buf routed = 0; /* [T, n_embd] fc2's output, then the block's delta */ + rad_buf sup = 0; /* [T, ff_shared / world] */ + ActFP8 sff{}; /* [T, ff_shared / world] */ + rad_buf sout = 0; /* [T, n_embd] */ + MoeFP8::Wire moe{}; /* the routed arm's own planes; its h and route are set here */ + }; + Geom g{}; + Wire w{}; + LinearFP8 fc1{}, fc2{}, sh_up{}, sh_down{}; + QuantFP8 lat_in{}, lat_out{}; + GateQuantFP8 sh_act{}; + MoeFP8 moe{}; + rad_op op_join = 0, op_ar = 0; + + int declare(RadBuilder* b, Names& nm, const Geom& geom, const Shape& s, int l, + const Wire& wire, const char* pre, MoeFP8::Src& ms, int64_t sh_lo, int64_t sh_hi, + int64_t sh_w) { + g = geom; + w = wire; + const auto grp = grp_layer(l); + RAD_ARCH_TRY(fc1.declare(b, nm, g, nm.f("blk.%d.ffn_latent_in", l), s.latent, g.n_embd, + RAD_SHARD_NONE, grp, + { nm.ckpt("%s.fc1_latent_proj.weight", pre) }, w.h, w.lat.x)); + /* The routed arm reads the latent's codes unless its experts are bf16. */ + if (!ms.cfg.expert_bf16) RAD_ARCH_TRY(lat_in.declare(b, g, w.lat, s.latent)); + Geom ge = g; + ge.n_embd = s.latent; + ge.n_ff_all = s.ff[(size_t)l]; + MoeFP8::Wire mw = w.moe; + mw.h = w.lat; + mw.route = w.h.x; + RAD_ARCH_TRY(moe.declare(b, nm, ge, l, mw, ms, false, false)); + const char* f2 = nm.f("blk.%d.ffn_latent_out", l); + RAD_ARCH_TRY(fc2.probe(b, nm, g, f2, { nm.ckpt("%s.fc2_latent_proj.weight", pre) })); + if (!fc2.reads_x) RAD_ARCH_TRY(lat_out.declare(b, g, w.lat, s.latent)); + RAD_ARCH_TRY(fc2.declare(b, nm, g, f2, g.n_embd, s.latent, RAD_SHARD_NONE, grp, + { nm.ckpt("%s.fc2_latent_proj.weight", pre) }, w.lat, w.routed)); + /* The shared expert over the hidden state, this rank's slice of its 5376 columns. */ + if (sh_w > 0) { + const char* dn = nm.f("blk.%d.ffn_down_shexp", l); + RAD_ARCH_TRY(sh_down.probe(b, nm, g, dn, + { nm.ckpt("%s.shared_experts.down_proj.weight", pre) })); + RAD_ARCH_TRY(sh_up.declare(b, nm, g, nm.f("blk.%d.ffn_up_shexp", l), sh_w, g.n_embd, + RAD_SHARD_ROW, grp, + { nm.ckpt("%s.shared_experts.up_proj.weight", pre) }, w.h, + w.sup, 0, {}, sh_lo, sh_hi)); + RAD_ARCH_TRY(sh_act.declare(b, g, w.sup, w.sff, sh_w, "relu2", 0, true, false)); + RAD_ARCH_TRY(sh_down.declare(b, nm, g, dn, g.n_embd, sh_w, RAD_SHARD_COL, grp, + { nm.ckpt("%s.shared_experts.down_proj.weight", pre) }, + w.sff, w.sout, 0, {}, sh_lo, sh_hi)); + op_join = rw(b, + RAD_OP(b, "add", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", g.n_embd), + RAD_STR("dtype", g.dtype)), + RAD_NOWEIGHTS), + { w.routed, w.sout }, { w.routed }); + if (!op_join) return RAD_E_INVAL; + } + op_ar = reduce(b, g, w.routed); + return g.world > 1 && !op_ar ? RAD_E_INVAL : RAD_OK; + } + void step(RadCtx* c, const RadBatch* batch) const { + const int64_t T = batch->n_tok; + fc1.step(c, w.h, w.lat.x, T); + lat_in.step(c, T); + moe.step(c, batch); + lat_out.step(c, T); + fc2.step(c, w.lat, w.routed, T); + if (op_join) { + sh_up.step(c, w.h, w.sup, T); + sh_act.step(c, w.sup, T); + sh_down.step(c, w.sff, w.sout, T); + RAD_ISSUE_N(c, op_join, T, brows(w.routed, T), brows(w.sout, T), brows(w.routed, T)); + } + if (op_ar) RAD_ISSUE_N(c, op_ar, T * g.n_embd, brows(w.routed, T), RAD_NONE); + } +}; + +struct Layer { + Kind kind = kMamba; + rad_weight gain = 0; + NormQuantFP8 norm{}; + Mamba mamba{}; + LatentMoe moe{}; + AttnFP8 attn{}; + rad_op op_add = 0; +}; +struct Model { + Names nm{}; + Geom g{}; + Shape s{}; + std::vector layers; + rad_kvgroup kv_attn = 0, kv_state = 0, kv_conv = 0; + rad_buf x = 0, y = 0, final_hidden = 0, logit_input = 0, logits = 0; + ActFP8 act{}; + Mamba::Wire mw{}; + AttnFP8::Wire aw{}; + LatentMoe::Wire ew{}; + /* The routed arm's planes by (experts, width): layers of one class share them. */ + std::map, MoeFP8::Wire> classes; + rad_weight token = 0, head = 0, final_gain = 0; + rad_op embed = 0, embed_ar = 0, norm = 0, gather = 0, head_op = 0; + /* The vision encoder (C-RADIO and its projector) and the scatter of its rows over the token + * embeddings they replace. */ + Radio radio{}; + MediaRows media{}; + /* LiLiCorr, the drafter (`--draft-model`): the trunk's residual stream after each tapped block + * into one column slice of `dfsrc` a tap; the DFlash2 backbone in LiLiCorr's mode at absolute + * layers n_layer.. of its own KV group, and the correlator after it. */ + enum { MAX_TAPS = 8 }; + int n_taps = 0; + int tap_layer[MAX_TAPS] = {}; + rad_buf dfsrc = 0; + rad_op op_tap = 0; + bool have_df = false; + rad_kvgroup kv_draft = 0; + Dflash2 df{}; + Dflash2::Wire dfw{}; + LiliCorr lili{}; + LiliCorr::Wire lw{}; +}; +static std::unique_ptr models[MAX_RANKS]; +static thread_local std::unique_ptr probe_model; + +static int read_shape(const RadModelMeta* meta, Shape& s) { + s.n_embd = meta->n_embd; + s.n_layer = meta->n_layers; + s.heads = cfg(meta, "mamba_num_heads", 0); + s.head_dim = cfg(meta, "mamba_head_dim", 0); + s.state = cfg(meta, "ssm_state_size", 0); + s.groups = cfg(meta, "n_groups", 0); + s.conv = cfg(meta, "conv_kernel", 0); + s.latent = cfg(meta, "moe_latent_size", 0); + s.ff_shared = cfg(meta, "moe_shared_expert_intermediate_size", 0) * + cfg(meta, "n_shared_experts", 0); + s.route_scale = rad_meta_getf(meta, "routed_scaling_factor", 0.0); + /* `layers_block_type` names each block; `block_configs..*` (Puzzle) gives a routed layer's + * expert count, width and top-k, the top-level keys where it is absent. */ + bool kinds_ok = true; + for_each_token(rad_meta_gets(meta, "layers_block_type", ""), [&](const char* t, size_t n) { + const std::string k(t, n); + if (k == "mamba") s.kind.push_back(kMamba); + else if (k == "moe") s.kind.push_back(kMoe); + else if (k == "attention") s.kind.push_back(kAttn); + else kinds_ok = false; + return true; + }); + s.experts.assign((size_t)s.n_layer, 0); + s.ff.assign((size_t)s.n_layer, 0); + s.top_k.assign((size_t)s.n_layer, 0); + bool moe_ok = true; + for (int64_t l = 0; l < (int64_t)s.kind.size() && l < s.n_layer; ++l) { + if (s.kind[(size_t)l] != kMoe) continue; + char key[96]; + auto per = [&](const char* field, const char* global) { + std::snprintf(key, sizeof key, "block_configs.%lld.%s", (long long)l, field); + return cfg(meta, key, cfg(meta, global, 0)); + }; + s.experts[(size_t)l] = per("n_routed_experts", "n_routed_experts"); + s.ff[(size_t)l] = per("moe_intermediate_size", "moe_intermediate_size"); + s.top_k[(size_t)l] = per("num_experts_per_tok", "num_experts_per_tok"); + moe_ok = moe_ok && s.experts[(size_t)l] > 0 && s.ff[(size_t)l] > 0 && + s.top_k[(size_t)l] > 0 && s.top_k[(size_t)l] <= s.experts[(size_t)l] && + s.experts[(size_t)l] <= 512 && s.ff[(size_t)l] % RAD_FP8_BLOCK == 0; + } + /* A clamp the scan does not apply: present only when the limit is a list of numbers. */ + bool unclamped = true; + { + std::vector lim; + for_each_token(rad_meta_gets(meta, "time_step_limit", ""), [&](const char* t, size_t) { + lim.push_back(std::strtod(t, nullptr)); + return true; + }); + unclamped = lim.empty() || (lim.size() == 2 && lim[0] <= 0 && std::isinf(lim[1])); + } + const char* act = rad_meta_gets(meta, "mlp_hidden_act", rad_meta_gets(meta, "hidden_act", "")); + const struct { + const char* what; + bool ok; + } need[] = { + { "a block type per layer (mamba, moe, attention)", + kinds_ok && (int64_t)s.kind.size() == s.n_layer }, + { "Mamba-2 heads of 64 in groups that divide them", + s.head_dim == 64 && s.heads > 0 && s.groups > 0 && s.heads % s.groups == 0 }, + { "a Mamba-2 inner width of whole 1024-wide norm groups", + (s.heads * s.head_dim) % (s.groups * Mamba::kNormGroup) == 0 || + (s.heads * s.head_dim) == s.groups * Mamba::kNormGroup }, + { "a state of 128", s.state == 128 }, + { "a 4-tap convolution with bias", s.conv == 4 && cfg(meta, "use_conv_bias", 0) != 0 }, + { "no in_proj or out_proj bias", cfg(meta, "mamba_proj_bias", 0) == 0 && + cfg(meta, "use_bias", 0) == 0 }, + { "an unclamped dt (time_step_limit (0, inf))", unclamped }, + { "a SiLU Mamba activation", + !std::strcmp(rad_meta_gets(meta, "mamba_hidden_act", "silu"), "silu") }, + { "relu2 experts", !std::strcmp(act, "relu2") }, + { "routed layers with experts, width and top-k", moe_ok }, + { "a latent of whole 128-column blocks", + s.latent > 0 && s.latent % RAD_FP8_BLOCK == 0 }, + { "one shared expert of whole 128-column blocks", + cfg(meta, "n_shared_experts", 0) == 1 && s.ff_shared % RAD_FP8_BLOCK == 0 }, + { "sigmoid scoring", + !std::strcmp(rad_meta_gets(meta, "scoring_func", ""), "sigmoid") }, + { "ungrouped routing", cfg(meta, "n_group", 1) == 1 && cfg(meta, "topk_group", 1) == 1 }, + { "a positive routed_scaling_factor", s.route_scale > 0 }, + { "no attention or MLP bias", cfg(meta, "attention_bias", 0) == 0 && + cfg(meta, "mlp_bias", 0) == 0 }, + { "no MTP layers", cfg(meta, "num_nextn_predict_layers", 0) == 0 }, + { "a residual stream in the activation dtype", cfg(meta, "residual_in_fp32", 0) == 0 }, + { "untied embeddings", cfg(meta, "tie_word_embeddings", 0) == 0 }, + }; + for (const auto& n : need) + if (!n.ok) { + fprintf(stderr, "radiance: nemotronh: this plugin serves %s, and the checkpoint " + "differs\n", n.what); + return RAD_E_UNSUPPORTED; + } + return RAD_OK; +} + +/* A rank's slice of a width of `blocks` 128-column blocks: blocks [lo, hi) in the order of the + * ranks starting at `first`, the first `blocks % world` ranks of that order one block wider. */ +static void slice_of(int64_t blocks, int world, int rank, int first, int64_t* lo, int64_t* hi) { + const int p = ((rank - first) % world + world) % world; + const int64_t base = blocks / world, extra = blocks % world; + *lo = p * base + std::min(p, extra); + *hi = *lo + base + (p < extra ? 1 : 0); +} + +/* ------------------------------------------------------------------ declare */ +static int buffers(RadBuilder* b, Model& m) { + auto& g = m.g; + auto& s = m.s; + auto& nm = m.nm; + const int64_t T = g.max_tok, E = g.n_embd; + const int64_t H = s.heads / g.world, W = H * s.head_dim, GN = s.groups / g.world * s.state; + auto bf = [&](const char* n, std::initializer_list shape) { + return decl_b(b, nm.f("%s", n), RAD_BF16, shape); + }; + m.x = bf("residual", { T, E }); + m.y = bf("mixer_delta", { T, E }); + m.act.x = bf("normed", { T, E }); + RAD_ARCH_TRY(m.act.declare_qs(b, nm, g, "normed", E)); + m.final_hidden = decl_b(b, nm.f("final_hidden"), RAD_BF16, { T, E }, RAD_BUF_PERSIST); + m.logit_input = bf("logit_input", { g.max_logit_rows, E }); + m.logits = decl_b(b, nm.f("logits"), RAD_F32, { g.max_logit_rows, g.n_vocab }); + RAD_ARCH_TRY(rad_declare_logits(b, m.logits)); + + auto& mw = m.mw; + mw.input = m.act; + mw.out = m.y; + mw.z = bf("ssm_z", { T, W }); + mw.xbc = bf("ssm_xbc", { T, W + 2 * GN }); + mw.conv = bf("ssm_conv", { T, W + 2 * GN }); + mw.dt = bf("ssm_dt", { T, H }); + mw.y = bf("ssm_y", { T, W }); + mw.core_out.x = bf("ssm_out", { T, W }); + RAD_ARCH_TRY(mw.core_out.declare_qs(b, nm, g, "ssm_out", W)); + + auto& aw = m.aw; + aw.x = m.x; + aw.h = m.act; + aw.qkv = bf("attn_qkv", { T, g.qkv_dim() }); + aw.q = bf("attn_q", { T, g.q_dim() }); + aw.attn.x = bf("attn_out", { T, g.q_dim() }); + RAD_ARCH_TRY(aw.attn.declare_qs(b, nm, g, "attn_out", g.q_dim())); + return RAD_OK; +} + +/* The latent feed-forward's planes, and the routed arm's per (experts, width) class. */ +static int moe_buffers(RadBuilder* b, Model& m, const std::vector& msrc, + int64_t sh_w) { + auto& g = m.g; + auto& s = m.s; + auto& nm = m.nm; + const int64_t T = g.max_tok, E = g.n_embd, L = s.latent; + auto bf = [&](const char* n, std::initializer_list shape) { + return decl_b(b, nm.f("%s", n), RAD_BF16, shape); + }; + auto& ew = m.ew; + ew.h = m.act; + ew.lat.x = bf("latent", { T, L }); + RAD_ARCH_TRY(ew.lat.declare_qs(b, nm, g, "latent", L)); + ew.routed = m.y; + if (sh_w > 0) { + ew.sup = bf("shared_up", { T, sh_w }); + ew.sff.x = bf("shared_ff", { T, sh_w }); + RAD_ARCH_TRY(ew.sff.declare_qs(b, nm, g, "shared_ff", sh_w)); + ew.sout = bf("shared_out", { T, E }); + } + Geom gl = g; + gl.n_embd = L; + for (int64_t l = 0; l < s.n_layer; ++l) { + if (s.kind[(size_t)l] != kMoe) continue; + const MoeFP8::Config& c = msrc[(size_t)l].cfg; + const auto key = std::make_pair(c.n_expert_all, c.n_ff_exp); + if (m.classes.count(key)) continue; + const int64_t F = c.n_ff_exp, k = c.top_k, rows = c.rows > 0 ? c.rows : T; + char tag[64]; + std::snprintf(tag, sizeof tag, "e%lldf%lld", (long long)c.n_expert_all, (long long)F); + MoeFP8::Wire w{}; + w.logits = decl_b(b, nm.f("%s.router_logits", tag), RAD_F32, { T, c.n_expert_all }); + w.ids = decl_b(b, nm.f("%s.expert_ids", tag), RAD_I32, { T, k }); + w.ew = decl_b(b, nm.f("%s.expert_weights", tag), RAD_F32, { T, k }); + w.eoff = decl_b(b, nm.f("%s.expert_offsets", tag), RAD_I32, { c.n_expert + 1 }); + w.ecnt = decl_b(b, nm.f("%s.expert_counts", tag), RAD_I32, { c.n_expert }); + w.sorted = decl_b(b, nm.f("%s.expert_sorted", tag), RAD_I32, { rows * k }); + w.egu = bf(nm.f("%s.expert_up", tag), { rows * k, F }); + w.eff.x = bf(nm.f("%s.expert_ff", tag), { rows * k, F }); + RAD_ARCH_TRY(w.eff.declare_qs(b, nm, gl, nm.f("%s.expert_ff", tag), F, rows * k)); + w.edn = bf(nm.f("%s.expert_down", tag), { rows * k, L }); + if (c.expert_rot) { + w.hr.q = decl_b(b, nm.f("%s.latent_rot.q", tag), RAD_F8E4M3, { T, L }); + w.hr.s = decl_b(b, nm.f("%s.latent_rot.s", tag), RAD_F32, { T, L / RAD_FP8_BLOCK }); + if (!w.hr.q || !w.hr.s) return RAD_E_INVAL; + } + if (!w.logits || !w.ids || !w.ew || !w.eoff || !w.ecnt || !w.sorted || !w.egu || + !w.eff.x || !w.edn) + return RAD_E_INVAL; + m.classes[key] = w; + } + return RAD_OK; +} + +/* LiLiCorr: the DFlash2 backbone with sinks (rad_block_dflash2.h, Config::lili), its KV group and + * buffers, then the correlator (rad_block_lilicorr.h) over the backbone's draft rows, proposing a + * block of `max_spec` tokens through the walk. The drafter's own config is the container's + * `draft.` keys (rad-convert --draft-model); what this implementation does not apply is refused. */ +static int declare_lilicorr(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* ctx, + Model& m, int base_layer) { + Names& nm = m.nm; + Geom dg{}; + /* Two KV heads: at four ranks each is replicated over two (Dflash2 reads k and v at kv_off). */ + RAD_ARCH_TRY(drafter_geom(dg, m.g, meta, "LiLiCorr", true)); + auto dc_i = [&](const char* k, long long d) { + char key[160]; + std::snprintf(key, sizeof key, "draft.dflash_config.%s", k); + return rad_meta_geti(meta, key, d); + }; + auto dc_f = [&](const char* k, double d) { + char key[160]; + std::snprintf(key, sizeof key, "draft.dflash_config.%s", k); + return rad_meta_getf(meta, key, d); + }; + const long long trained = rad_meta_geti(meta, "draft.block_size", dc_i("block_size", 0)); + Dflash2::Config dc{}; + dc.lili = 1; + dc.n_taps = m.n_taps; + dc.block = ctx->max_spec + 1; + dc.taps = dc_i("conv_kernel_size", 2); + dc.group = dc_i("conv_group_size", 16); + dc.causal = dc_i("causal", 0) ? 1 : 0; + if (dc_i("use_swa", 0)) + dc.window = dc_i("swa_window_size", rad_meta_geti(meta, "draft.sliding_window", 0)); + /* The correlator has a slot embedding a draft position, trained at one block: run at it. */ + if (trained <= 1 || dc.block != trained) { + fprintf(stderr, "radiance: nemotronh: LiLiCorr was trained at block_size %lld (%lld draft " + "tokens) and its correlator has a learned embedding for each of them; this " + "serve asks for %d draft tokens\n", + trained, trained - 1, ctx->max_spec); + return RAD_E_UNSUPPORTED; + } + if (!dc_i("lilicorr_enabled", 0) || !rad_meta_geti(meta, "draft.attention_sink_bias", + dc_i("attention_sink_bias", 0))) { + fprintf(stderr, "radiance: nemotronh: the drafter's dflash_config is not LiLiCorr's " + "(lilicorr_enabled and attention_sink_bias)\n"); + return RAD_E_UNSUPPORTED; + } + const double escale = dc_f("input_embedding_scale", 1.0); + if (escale != 1.0) { + fprintf(stderr, "radiance: nemotronh: LiLiCorr scaling its input embedding by %g is not " + "implemented\n", escale); + return RAD_E_UNSUPPORTED; + } + LiliCorr::Config lc{}; + lc.steps = dc.steps(); + lc.k = dc_i("lilicorr_candidate_topk", 8); + lc.hs = dc_i("lilicorr_hidden_size", 1024); + lc.n_head = dc_i("lilicorr_num_heads", 8); + lc.n_layer = dc_i("lilicorr_num_layers", 2); + lc.mlp = (int64_t)std::llround((double)lc.hs * dc_f("lilicorr_mlp_ratio", 2.0)); + lc.fdim = dc_i("lilicorr_factor_dim", 1024); + lc.eps = dg.eps; + lc.vec_eps = dc_f("lilicorr_vector_eps", 1e-4); + lc.scale = dc_f("lilicorr_logit_scale", 8.0); + if (lc.k < 2 || lc.k > 64 || (lc.k & (lc.k - 1)) || lc.steps * lc.k > 64 || + lc.hs % lc.n_head || lc.hs / lc.n_head > 128) { + fprintf(stderr, "radiance: nemotronh: LiLiCorr's lattice (%lld positions of %lld, %lld " + "heads over %lld) is outside what lili_attn serves\n", + (long long)lc.steps, (long long)lc.k, (long long)lc.n_head, (long long)lc.hs); + return RAD_E_UNSUPPORTED; + } + + RAD_ARCH_TRY(drafter_kv_group(b, nm, ctx, dg, dc.window, base_layer, &m.kv_draft)); + + const int64_t qd = dg.n_head * dg.head_dim; + const int64_t kvd = dg.n_head_kv * dg.head_dim; + int64_t qr = dg.max_seqs * dc.block; + if (qr > dg.max_tok) qr = dg.max_tok; + const int64_t sr = dg.max_seqs * dc.steps(); + const int64_t lr = sr * lc.k; + const int64_t E = dg.n_embd; + const uint32_t A = dg.act_dtype; + + Dflash2::Wire& dw = m.dfw; + dw.src = m.dfsrc; + /* PERSIST: the context pass writes it, the next query pass reads the anchor's row from it, + * so no transient may share it in between. */ + dw.c = decl_b(b, nm.f("df_c"), A, {dg.max_tok, E}, RAD_BUF_PERSIST); + dw.ck = decl_b(b, nm.f("df_ck"), A, {dg.max_tok, kvd}); + dw.cv = decl_b(b, nm.f("df_cv"), A, {dg.max_tok, kvd}); + dw.x = decl_b(b, nm.f("df_x"), A, {qr, E}); + dw.h = decl_b(b, nm.f("df_h"), A, {qr, E}); + dw.h2 = decl_b(b, nm.f("df_h2"), A, {qr, E}); + dw.coef = decl_b(b, nm.f("df_coef"), A, {qr, dc.coef_dim(E)}); + dw.q = decl_b(b, nm.f("df_q"), A, {qr, qd}); + dw.k = decl_b(b, nm.f("df_k"), A, {qr, kvd}); + dw.v = decl_b(b, nm.f("df_v"), A, {qr, kvd}); + dw.attn = decl_b(b, nm.f("df_attn"), A, {qr, qd}); + dw.gate_up = decl_b(b, nm.f("df_gate_up"), A, {qr, 2 * dg.n_ff}); + dw.ffn = decl_b(b, nm.f("df_ffn"), A, {qr, dg.n_ff}); + dw.srcq = decl_b(b, nm.f("df_srcq"), RAD_F8E4M3, {dg.max_tok, dc.n_taps * E}); + dw.srcs = decl_b(b, nm.f("df_srcs"), RAD_F32, {dg.max_tok, fp8_blocks(dc.n_taps * E)}); + dw.cq = decl_b(b, nm.f("df_cq"), RAD_F8E4M3, {dg.max_tok, E}); + dw.cs = decl_b(b, nm.f("df_cs"), RAD_F32, {dg.max_tok, fp8_blocks(E)}); + dw.h2q = decl_b(b, nm.f("df_h2q"), RAD_F8E4M3, {qr, E}); + dw.h2s = decl_b(b, nm.f("df_h2s"), RAD_F32, {qr, fp8_blocks(E)}); + dw.atq = decl_b(b, nm.f("df_atq"), RAD_F8E4M3, {qr, qd}); + dw.ats = decl_b(b, nm.f("df_ats"), RAD_F32, {qr, fp8_blocks(qd)}); + dw.ffq = decl_b(b, nm.f("df_ffq"), RAD_F8E4M3, {qr, dg.n_ff}); + dw.ffs = decl_b(b, nm.f("df_ffs"), RAD_F32, {qr, fp8_blocks(dg.n_ff)}); + dw.sel_h = decl_b(b, nm.f("df_selh"), A, {sr, E}); + /* The proposal buffer (RadDrafterDecl::proposal), written by the walk. */ + dw.tokens = decl_b(b, nm.f("dflash_tokens"), RAD_I32, {dg.max_seqs, dc.steps()}); + RAD_ARCH_TRY(m.df.declare(b, nm, dg, dc, base_layer, m.kv_draft, m.token, "draft", + nm.ckpt("language_model.lm_head.weight"), dw)); + + LiliCorr::Wire& lw = m.lw; + const int64_t sw = 2 + 2 * LiliCorr::row_k(lc.k); + lw.sel_h = dw.sel_h; + lw.c = dw.c; + lw.tokens = dw.tokens; + lw.logits = decl_b(b, nm.f("lili_logits"), RAD_F32, {sr, dg.n_vocab}); + lw.stats = decl_b(b, nm.f("lili_stats"), RAD_F32, {sr, sw}); + if (dg.world > 1) + lw.sgath = decl_b(b, nm.f("lili_sgath"), RAD_F32, {sr, (int64_t)dg.world * sw}); + lw.pas = decl_b(b, nm.f("lili_pas"), A, {sr, lc.hs}); + lw.cand = decl_b(b, nm.f("lili_cand"), RAD_I32, {lr}); + lw.feat = decl_b(b, nm.f("lili_feat"), A, {lr, lc.hs}); + lw.hh = decl_b(b, nm.f("lili_hh"), A, {lr, lc.hs}); + lw.emb = decl_b(b, nm.f("lili_emb"), A, {lr, E}); + lw.y = decl_b(b, nm.f("lili_y"), A, {lr, lc.hs}); + lw.qkv = decl_b(b, nm.f("lili_qkv"), A, {lr, 3 * lc.hs}); + lw.att = decl_b(b, nm.f("lili_att"), A, {lr, lc.hs}); + lw.up = decl_b(b, nm.f("lili_up"), A, {lr, lc.mlp}); + lw.ups = decl_b(b, nm.f("lili_ups"), A, {lr, lc.mlp}); + lw.cat = decl_b(b, nm.f("lili_cat"), A, {lr, 3 * lc.hs}); + lw.fh = decl_b(b, nm.f("lili_fh"), A, {lr, lc.hs}); + lw.fhs = decl_b(b, nm.f("lili_fhs"), A, {lr, lc.hs}); + lw.edges = decl_b(b, nm.f("lili_edges"), A, {lr, 2 * lc.fdim}); + lw.anc = decl_b(b, nm.f("lili_anc"), A, {dg.max_seqs, E}); + lw.ast = decl_b(b, nm.f("lili_ast"), A, {dg.max_seqs, lc.hs}); + lw.an = decl_b(b, nm.f("lili_an"), A, {dg.max_seqs, lc.hs}); + lw.aout = decl_b(b, nm.f("lili_aout"), A, {dg.max_seqs, lc.fdim}); + RAD_ARCH_TRY(m.lili.declare(b, nm, dg, lc, m.head, m.token, "draft", lw)); + m.have_df = true; + + RadDrafterDecl drf{}; + drf.name = "lilicorr"; + drf.kind = RAD_DRAFT_BLOCK; + drf.depth = ctx->max_spec; + drf.block = dc.block; + drf.proposal = dw.tokens; + drf.proposal_pitch = dc.steps(); + drf.window = dc.window; + drf.mask_token = (int32_t)dc_i("mask_token_id", -1); + if (drf.mask_token < 0) { + fprintf(stderr, "radiance: nemotronh: the LiLiCorr checkpoint declares no " + "dflash_config.mask_token_id\n"); + return RAD_E_FORMAT; + } + RAD_ARCH_TRY(rad_declare_drafter(b, &drf)); + rad_note(b, "LiLiCorr drafter: %lld layers at absolute %d..%d, %lld heads / %lld kv%s x %lld " + "with sinks, ffn %lld, %s attention with a %lld-token window, %d trunk taps; a " + "%lld x %lld candidate lattice proposes %lld tokens", + (long long)dg.n_layer, base_layer, base_layer + (int)dg.n_layer - 1, + (long long)dg.n_head, (long long)dg.n_head_kv, + dg.world > dg.n_head_kv_all ? " (replicated)" : "", (long long)dg.head_dim, + (long long)dg.n_ff, dc.causal ? "causal" : "non-causal", (long long)dc.window, + m.n_taps, (long long)lc.steps, (long long)lc.k, (long long)dc.steps()); + return RAD_OK; +} + +static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* ctx) { + if (!b || !meta || !ctx || ctx->is_draft || ctx->rank < 0 || ctx->rank >= MAX_RANKS) + return RAD_E_INVAL; + const int world = ctx->world_size ? ctx->world_size : 1; + auto& slot = ctx->shape_probe ? probe_model : models[ctx->rank]; + slot = std::make_unique(); + auto& m = *slot; + auto& g = m.g; + auto& s = m.s; + m.nm = Names(ctx->scope); + auto& nm = m.nm; + RAD_ARCH_TRY(read_shape(meta, s)); + if (world != 1 && world != 2 && world != 4) { + fprintf(stderr, "radiance: nemotronh: --tp %d; the head and expert splits are built for 1, " + "2 or 4 ranks\n", world); + return RAD_E_UNSUPPORTED; + } + if (s.heads % world || s.groups % world || (s.heads / world * s.head_dim) % Mamba::kNormGroup) { + fprintf(stderr, "radiance: nemotronh: %lld Mamba heads in %lld groups do not split over %d " + "ranks in whole groups of the gated norm\n", + (long long)s.heads, (long long)s.groups, world); + return RAD_E_UNSUPPORTED; + } + if (ctx->max_spec > 31) { + fprintf(stderr, "radiance: nemotronh: the Mamba-2 verify pass keeps at most 32 records a " + "sequence, so --num-speculative-tokens is at most 31\n"); + return RAD_E_UNSUPPORTED; + } + RAD_ARCH_TRY(geom_from(g, meta, ctx, "bf16", RAD_BF16)); + + /* Each routed layer's experts: its own count and width; the slice of each expert this rank + * holds, even, or by slice_of at four ranks (2, 2, 1, 1 of six blocks, by number mod 4). */ + std::vector msrc((size_t)s.n_layer); + bool calib = calib_dir() != nullptr, any_bf16 = false; + for (int l = 0; l < (int)s.n_layer; ++l) { + if (s.kind[(size_t)l] != kMoe) continue; + const char* pre = nm.ckpt("language_model.backbone.layers.%d.mixer", l); + MoeFP8::Src& ms = msrc[(size_t)l]; + MoeFP8::Config& c = ms.cfg; + const int64_t ne = s.experts[(size_t)l], ff = s.ff[(size_t)l]; + c.n_expert = c.n_expert_all = ne; + c.top_k = s.top_k[(size_t)l]; + c.sigmoid_router = 1; + c.route_scale = s.route_scale; + c.norm_topk = cfg(meta, "norm_topk_prob", 1) != 0; + c.ungated = 1; + c.router_k = g.n_embd; + c.no_reduce = 1; + c.rows = g.max_tok; + /* RADIANCE_CALIB_LAYERS splits the calibration over runs (calib_layer_on). */ + c.calib = calib && calib_layer_on(l) ? 1 : 0; + c.probed_expert = (int64_t)g.rank * (ne / world); + const int64_t eb = ff / RAD_FP8_BLOCK; + if (eb % world == 0) { + c.n_ff_exp = ff / world; + } else if (world == 4) { + int64_t widest = 0; + for (int q = 0; q < 4; ++q) { + int64_t lo, hi; + slice_of(eb, world, g.rank, q, &lo, &hi); + c.ff_lo4[q] = lo * RAD_FP8_BLOCK; + c.ff_hi4[q] = hi * RAD_FP8_BLOCK; + widest = std::max(widest, c.ff_hi4[q] - c.ff_lo4[q]); + } + c.n_ff_exp = widest; + } else { + fprintf(stderr, "radiance: nemotronh: layer %d's experts of %lld do not split over %d " + "ranks in 128-column blocks\n", l, (long long)ff, world); + return RAD_E_UNSUPPORTED; + } + ms.router = nm.ckpt("%s.gate.weight", pre); + ms.router_bias = nm.ckpt("%s.gate.e_score_correction_bias", pre); + ms.experts = nm.ckpt("%s.experts", pre); + RAD_ARCH_TRY(MoeFP8::probe(b, nm, l, ms, &c)); + any_bf16 = any_bf16 || c.expert_bf16; + } + /* Whole experts per rank for a calibration run and for bf16 experts: rank r owns experts + * [r E/W, (r+1) E/W) of each layer. */ + if (world > 1 && (calib || any_bf16)) + for (int l = 0; l < (int)s.n_layer; ++l) { + if (s.kind[(size_t)l] != kMoe) continue; + auto& c = msrc[(size_t)l].cfg; + int64_t per = 0; + RAD_ARCH_TRY(divide_or_fail(c.n_expert_all, world, "n_routed_experts", &per)); + c.n_expert = per; + c.expert_base = (int64_t)g.rank * per; + c.n_ff_exp = s.ff[(size_t)l]; + for (int q = 0; q < 4; ++q) c.ff_lo4[q] = c.ff_hi4[q] = 0; + } + /* The shared expert's slice: even, or slice_of's whole blocks. */ + int64_t sh_lo = 0, sh_hi = 0, sh_w = s.ff_shared / world; + { + const int64_t sb = s.ff_shared / RAD_FP8_BLOCK; + if (sb % world) { + slice_of(sb, world, g.rank, 0, &sh_lo, &sh_hi); + sh_lo *= RAD_FP8_BLOCK; + sh_hi *= RAD_FP8_BLOCK; + sh_w = sh_hi - sh_lo; + } + } + RAD_ARCH_TRY(buffers(b, m)); + RAD_ARCH_TRY(moe_buffers(b, m, msrc, sh_w)); + { + RadKVGroupDecl d{}; + d.kind = RAD_KV_FULL; + d.dtype = rad_kv_cache_dtype(ctx, RAD_BF16); + d.n_head_kv = g.n_head_kv; + d.head_dim = g.head_dim; + m.kv_attn = rad_decl_kv_group(b, nm.f("kv_attn"), &d); + g.kv_dtype = rad_dtype_name(d.dtype); + d = {}; + d.kind = RAD_KV_LINEAR; + d.dtype = RAD_F32; + d.n_head_kv = s.heads / world; + d.state_dim[0] = s.head_dim; + d.state_dim[1] = s.state; + m.kv_state = rad_decl_kv_group(b, nm.f("kv_ssm"), &d); + d = {}; + d.kind = RAD_KV_CONV; + d.dtype = RAD_BF16; + d.n_head_kv = 1; + d.head_dim = (s.heads * s.head_dim + 2 * s.groups * s.state) / world; + d.conv_width = s.conv; + m.kv_conv = rad_decl_kv_group(b, nm.f("kv_ssm_conv"), &d); + if (!m.kv_attn || !m.kv_state || !m.kv_conv) return RAD_E_INVAL; + } + + RAD_ARCH_TRY(map_copy(b, nm.f("token_embd.weight"), + nm.ckpt("language_model.backbone.embeddings.weight"))); + RAD_ARCH_TRY(map_copy(b, nm.f("output.weight"), nm.ckpt("language_model.lm_head.weight"))); + RAD_ARCH_TRY(map_copy(b, nm.f("output_norm.weight"), + nm.ckpt("language_model.backbone.norm_f.weight"))); + m.token = decl_w(b, nm.f("token_embd.weight"), RAD_BF16, { g.n_vocab, g.n_embd }, + RAD_ACCESS_VOCAB, RAD_SHARD_ROW, grp_model()); + m.head = decl_w(b, nm.f("output.weight"), RAD_BF16, { g.n_vocab, g.n_embd }, RAD_ACCESS_VOCAB, + RAD_SHARD_ROW, grp_model()); + m.final_gain = decl_w(b, nm.f("output_norm.weight"), RAD_F32, { g.n_embd }, + RAD_ACCESS_PER_TOKEN, RAD_SHARD_NONE, grp_model()); + m.embed = rw(b, + RAD_OP(b, "embed_lookup", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n_embd", g.n_embd), + RAD_INT("n_vocab", g.n_vocab), RAD_STR("dtype", "bf16"), + RAD_INT("vocab_offset", g.vocab_off)), + RAD_WEIGHTS(m.token)), + {}, { m.x }); + /* Exact: each token's embedding comes from one rank and the others add zero. */ + m.embed_ar = reduce(b, g, m.x, true); + /* Images and video: the tower's rows replace their placeholders' embeddings before that + * reduction (rank 0 carries them, the others zeros). Its weight groups follow the layers'. */ + RAD_ARCH_TRY(m.radio.declare(b, meta, ctx, nm, g.n_embd, (int)s.n_layer)); + if (m.radio.on) RAD_ARCH_TRY(m.media.declare(b, g.max_tok, g.n_embd, m.x)); + + /* LiLiCorr's taps, only when the container carries the drafter and the deployment speculates: + * the residual stream after each block `target_layer_ids` names (vLLM's aux layer id + 1, the + * output of that block), copied into its column slice of `dfsrc` by `cast`. */ + if (ctx->max_spec > 0) { + const char* da = rad_meta_gets(meta, "draft.architectures", ""); + if (da && std::strstr(da, "LiLiCorr")) { + m.n_taps = parse_layer_ids( + rad_meta_gets(meta, "draft.dflash_config.target_layer_ids", nullptr), s.n_layer, + m.tap_layer, Model::MAX_TAPS); + if (m.n_taps <= 0) { + fprintf(stderr, "radiance: nemotronh: the LiLiCorr drafter names no trunk layer " + "this model has (dflash_config.target_layer_ids)\n"); + return RAD_E_UNSUPPORTED; + } + m.dfsrc = decl_b(b, nm.f("dflash_src"), RAD_BF16, + { g.max_tok, (int64_t)m.n_taps * g.n_embd }); + m.op_tap = rw(b, RAD_OP(b, "cast", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", g.n_embd), + RAD_STR("from", "bf16"), RAD_STR("to", "bf16")), + RAD_NOWEIGHTS), + { m.x }, { m.dfsrc }); + if (!m.dfsrc || !m.op_tap) return RAD_E_INVAL; + } + } + + m.layers.resize((size_t)s.n_layer); + for (int l = 0; l < (int)s.n_layer; ++l) { + Layer& lay = m.layers[(size_t)l]; + lay.kind = s.kind[(size_t)l]; + const char* pre = nm.ckpt("language_model.backbone.layers.%d", l); + const char* mx = nm.ckpt("%s.mixer", pre); + if (lay.kind == kAttn) { + AttnFP8::Src as{}; + as.norm = nm.ckpt("%s.norm.weight", pre); + as.q = nm.ckpt("%s.q_proj.weight", mx); + as.k = nm.ckpt("%s.k_proj.weight", mx); + as.v = nm.ckpt("%s.v_proj.weight", mx); + as.o = nm.ckpt("%s.o_proj.weight", mx); + RAD_ARCH_TRY(rad_bind_layer_kv(b, l, m.kv_attn)); + RAD_ARCH_TRY(lay.attn.declare(b, nm, g, l, m.kv_attn, 0, m.aw, as)); + continue; + } + const char* nn = nm.f(lay.kind == kMoe ? "blk.%d.ffn_norm.weight" : "blk.%d.attn_norm.weight", + l); + RAD_ARCH_TRY(map_copy(b, nn, nm.ckpt("%s.norm.weight", pre))); + lay.gain = decl_w(b, nn, RAD_F32, { g.n_embd }, RAD_ACCESS_PER_TOKEN, RAD_SHARD_NONE, + grp_layer(l)); + RAD_ARCH_TRY(lay.norm.declare(b, g, lay.gain, m.x, m.act, g.n_embd)); + if (lay.kind == kMamba) { + RAD_ARCH_TRY(lay.mamba.declare(b, nm, g, s, l, m.mw, mx, m.kv_state, m.kv_conv)); + } else { + LatentMoe::Wire ew = m.ew; + const MoeFP8::Config& c = msrc[(size_t)l].cfg; + ew.moe = m.classes[std::make_pair(c.n_expert_all, c.n_ff_exp)]; + RAD_ARCH_TRY(lay.moe.declare(b, nm, g, s, l, ew, mx, msrc[(size_t)l], sh_lo, sh_hi, + sh_w)); + } + lay.op_add = rw(b, + RAD_OP(b, "add", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", g.n_embd), + RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + { m.x, m.y }, { m.x }); + if (!lay.op_add) return RAD_E_INVAL; + } + m.norm = rw(b, + RAD_OP(b, "rmsnorm", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", g.n_embd), + RAD_F64("eps", g.eps), RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(m.final_gain)), + { m.x }, { m.final_hidden }); + m.gather = rw(b, + RAD_OP(b, "gather_rows", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows), RAD_INT("n", g.n_embd), + RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + { m.final_hidden }, { m.logit_input }); + m.head_op = + rw(b, + RAD_OP(b, "logits_gemm", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows), RAD_INT("n_vocab", g.n_vocab), + RAD_INT("n_embd", g.n_embd), RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(m.head)), + { m.logit_input }, { m.logits }); + if (!m.embed || !m.norm || !m.gather || !m.head_op) return RAD_E_INVAL; + if (m.n_taps > 0) RAD_ARCH_TRY(declare_lilicorr(b, meta, ctx, m, (int)s.n_layer)); + int64_t n_m = 0, n_e = 0, n_a = 0; + for (Kind k : s.kind) (k == kMamba ? n_m : k == kMoe ? n_e : n_a) += 1; + rad_note(b, + "Nemotron-H (nemotronh): TP%d, %lld blocks: %lld Mamba-2, %lld latent MoE, %lld NoPE " + "attention; experts %s", + world, (long long)s.n_layer, (long long)n_m, (long long)n_e, (long long)n_a, + world > 1 && (calib || any_bf16) ? "whole per rank" : "sliced per rank"); + return RAD_OK; +} + +/* ------------------------------------------------------------------ step */ +/* RADIANCE_DEBUG_NEMOTRONH_DUMP=DIR: the residual stream after each block, every row of every + * step, as `/s.t.l.r.bf16` ([rows, n_embd] bf16). A diagnostic for + * comparing against a reference model block by block; it synchronises the stream. */ +static void dump(RadCtx* c, const RadBatch* batch, rad_buf x, int64_t E, int layer) { + static const char* dir = std::getenv("RADIANCE_DEBUG_NEMOTRONH_DUMP"); + if (!dir || !*dir) return; + const int64_t T = batch->n_tok; + void* p = rad_buf_ptr(c, x); + if (!p) return; + std::vector h((size_t)(T * E)); + if (rad_memcpy_async(h.data(), p, T * E * 2, rad_stream(c)) < 0) return; + rad_stream_sync(rad_stream(c)); + char path[512]; + std::snprintf(path, sizeof path, "%s/s%d.t%lld.l%d.r%d.bf16", dir, batch->step, (long long)T, + layer, rad_rank(c)); + if (FILE* f = std::fopen(path, "wb")) { + std::fwrite(h.data(), 2, h.size(), f); + std::fclose(f); + } +} + +/* The drafter's side of the same diagnostic, `/d..r.`: on its query + * pass the batch's tokens (the anchor, then the masks) and anchor rows, the context pass's normed + * fc rows `c` (still the last context pass's), the draft rows `selh`, the candidates and the + * proposal. With the trunk step's per-block dumps (the taps) a reference recomputes the pass. */ +static void dump_draft(RadCtx* c, const RadBatch* batch, const char* what, const void* p, + int64_t bytes, const char* dt) { + static const char* dir = std::getenv("RADIANCE_DEBUG_NEMOTRONH_DUMP"); + if (!dir || !*dir || !p || bytes <= 0) return; + std::vector h((size_t)bytes); + if (rad_memcpy_async(h.data(), p, bytes, rad_stream(c)) < 0) return; + rad_stream_sync(rad_stream(c)); + char path[512]; + std::snprintf(path, sizeof path, "%s/d%d.%s.r%d.%s", dir, batch->step, what, rad_rank(c), dt); + if (FILE* f = std::fopen(path, "wb")) { + std::fwrite(h.data(), 1, h.size(), f); + std::fclose(f); + } +} + +static void step(RadCtx* c, const RadBatch* batch) { + auto& m = *models[rad_rank(c)]; + const int64_t T = batch->n_tok, E = m.g.n_embd; + if (batch->enc) { + m.radio.step(c, batch); + return; + } + /* A drafter pass runs only the drafter: positive is LiLiCorr's query pass (the backbone, then + * the correlator over its draft rows), negative its context pass over the rows the trunk step + * just ran, whose taps are in `dfsrc`. */ + if (batch->draft_pass) { + if (!m.have_df) { + rad_step_fail(c, "nemotronh: a drafter pass, and no drafter is declared (the container " + "carries none, or the deployment does not speculate)"); + return; + } + if (batch->draft_pass > 0) { + const int64_t n = batch->n_seq, S = n * m.lili.cfg.steps, E = m.g.n_embd; + m.df.step(c, batch); + /* Before the correlator: `selh` is dead after its last read there, and the arena may + * hand its bytes to a later op (at four ranks it does). */ + dump_draft(c, batch, "selh", rad_buf_ptr(c, m.dfw.sel_h), S * E * 2, "bf16"); + m.lili.step(c, batch); + dump_draft(c, batch, "tok", batch->token_ids, batch->n_tok * 4, "i32"); + dump_draft(c, batch, "arow", batch->anchor_rows, n * 4, "i32"); + dump_draft(c, batch, "c", rad_buf_ptr(c, m.dfw.c), m.g.max_tok * E * 2, "bf16"); + dump_draft(c, batch, "cand", rad_buf_ptr(c, m.lw.cand), S * m.lili.cfg.k * 4, "i32"); + dump_draft(c, batch, "tokens", rad_buf_ptr(c, m.dfw.tokens), S * 4, "i32"); + } else { + m.df.context(c, batch); + } + return; + } + RAD_ISSUE_N(c, m.embed, T, praw(batch->token_ids, RAD_I32, T), RAD_W(m.token), brows(m.x, T)); + m.media.step(c, batch, m.x, T); + if (m.embed_ar) RAD_ISSUE_N(c, m.embed_ar, T * E, brows(m.x, T), RAD_NONE); + for (const auto& l : m.layers) { + if (l.kind == kAttn) { + l.attn.step(c, batch); + } else { + l.norm.step(c, T); + if (l.kind == kMamba) + l.mamba.step(c, batch); + else + l.moe.step(c, batch); + RAD_ISSUE_N(c, l.op_add, T, brows(m.x, T), brows(m.y, T), brows(m.x, T)); + } + const int li = (int)(&l - m.layers.data()); + dump(c, batch, m.x, E, li); + /* The drafter's taps: this block's output, which the next block overwrites. */ + for (int t = 0; t < m.n_taps; ++t) + if (m.tap_layer[t] == li) + RAD_ISSUE(c, m.op_tap, brows(m.x, T), bcol(m.dfsrc, (int64_t)t * E, E, T)); + } + RAD_ISSUE_N(c, m.norm, T, brows(m.x, T), RAD_W(m.final_gain), brows(m.final_hidden, T)); + if (batch->n_out > 0) { + RAD_ISSUE_N(c, m.gather, batch->n_out, brows(m.final_hidden, T), + praw(batch->out_ids, RAD_I32, batch->n_out), brows(m.logit_input, batch->n_out)); + RAD_ISSUE_N(c, m.head_op, batch->n_out, brows(m.logit_input, batch->n_out), RAD_W(m.head), + brows(m.logits, batch->n_out)); + } +} +static int probe(const RadModelMeta* meta, RadArchProbe* out) { + if (!meta || !out) return RAD_E_INVAL; + out->shape_probe_ok = 1; + /* LiLiCorr proposes exactly its trained block less the anchor. */ + const char* da = rad_meta_gets(meta, "draft.architectures", ""); + if (da && std::strstr(da, "LiLiCorr")) { + const long long bs = rad_meta_geti(meta, "draft.block_size", + rad_meta_geti(meta, "draft.dflash_config.block_size", 8)); + out->draft_depth = bs > 1 ? (int)(bs - 1) : 7; + out->draft_depth_fixed = 1; + } + /* The vision encoder's rows per output row, so a pass bound is whole merged rows. */ + if (Radio::present(meta)) { + const double r = rad_meta_getf(meta, "downsample_ratio", 0.0); + const int64_t mg = r > 0.0 ? (int64_t)std::llround(1.0 / r) : 0; + out->enc_merge = mg * mg; + } + return RAD_OK; +} +} // namespace nemotronh +#ifndef RAD_ARCH_NO_EXPORTS +RAD_ARCH_PROBE(nemotronh) +RAD_ARCH_PLUGIN(nemotronh, "nemotronh", "", "0.1.0", + "Nemotron-H (nemotron_h_omni/puzzle): Mamba-2, latent relu^2 MoE and NoPE attention") +#endif diff --git a/arch/nemotronh/radio.h b/arch/nemotronh/radio.h new file mode 100644 index 00000000..edea3261 --- /dev/null +++ b/arch/nemotronh/radio.h @@ -0,0 +1,348 @@ +/* radio.h -- Nemotron-H Omni's vision encoder: C-RADIO (v4-H) and the projector after it (mlp1). + * + * Per encoder pass (RadBatch::enc). The processor (core/mm, Family::Radio) gives every segment + * `n_prefix` zero rows ahead of its patches, with coordinate (-1, k): + * + * x = rows @ W^T one GEMM for both projections: a row is a + * tubelet's frames then a picture's patch, the part + * not in use zero, and W = [video_embedder | + * embedder] concatenated at convert; no bias + * x += CPE(table, row, col), or prefix[k] grid_embed_cpe: the 128 x 128 table resampled + * half-pixel bilinear onto a square of the grid's + * longer side and cropped to it; a prefix row takes + * the k-th class or register token + * depth times (pre-norm, LayerScale 1): + * x += proj(attn(qkv(LN1(x)))) full attention within a segment, no rotary + * x += fc2(gelu(fc1(LN2(x)))) exact GELU + * y = each segment's patch rows gather_rows: the prefix rows dropped + * out = l2(relu(l1(rms(y viewed [P/4, 4 * width])))^2) + * + * which is transformers' RadioModel (make_preprocessor_external) then NemotronH_Omni's vision + * projector with vision_final_layernorm off. The pixel shuffle (ps v2) is the view: the processor + * keeps a 2 x 2 block's patches consecutive, (dy, dx), the order the shuffle concatenates them; + * the tower is order-independent within a segment (attention is permutation-equivariant, every + * other layer is per row, the position term is sampled at each row's own coordinate). + * + * A pass is one grid (RadEncoderDecl::one_grid), so its segments are equally long and each + * segment's patch rows sit at a fixed offset, which `step` gathers with slices of one identity + * index. Replicated, per-request weights and pass-sized activations, as in + * arch/common/rad_block_vit.h's tower. + */ +#ifndef NEMOTRONH_RADIO_H +#define NEMOTRONH_RADIO_H + +#include + +#include +#include +#include +#include + +namespace nemotronh { + +using namespace rad::arch; + +struct Radio { + int64_t depth = 0, width = 0, heads = 0, ff = 0, patch = 0, merge = 0, side = 0, npre = 0; + int64_t tubelet = 0, head_dim = 0, patch_dim = 0, proj_hidden = 0, n_embd = 0, P = 0, R = 0; + float eps = 1e-6f; + bool on = false; + + struct Layer { + rad_weight n1w = 0, n1b = 0, n2w = 0, n2b = 0; + rad_weight qkv_w = 0, qkv_b = 0, out_w = 0, out_b = 0; + rad_weight up_w = 0, up_b = 0, down_w = 0, down_b = 0; + rad_op ln1 = 0, qkv = 0, attn = 0, proj = 0, ln2 = 0, up = 0, down = 0; + }; + std::vector L; + rad_weight w_patch = 0, w_pos = 0, w_pre = 0, mn_w = 0, m1_w = 0, m2_w = 0; + rad_op op_patch = 0, op_pos = 0, op_seq = 0, op_gather = 0, op_mln = 0, op_m1 = 0; + rad_op op_act = 0, op_m2 = 0; + rad_buf b_x = 0, b_h = 0, b_qkv = 0, b_att = 0, b_ff = 0, b_seq = 0, b_g = 0, b_mn = 0; + rad_buf b_mf = 0, b_ma = 0, b_out = 0; + + /* A tower to declare: the container is a Nemotron-H Omni one, whose vision_config is RADIO's. */ + static bool present(const RadModelMeta* m) { + return !std::strcmp(rad_meta_gets(m, "vision_config.model_type", ""), "radio") && + rad_meta_geti(m, "vision_config.num_hidden_layers", 0) > 0; + } + + int declare(RadBuilder* b, const RadModelMeta* m, const RadBuildCtx* ctx, Names& nm, + int64_t model_embd, int first_group); + void step(RadCtx* c, const RadBatch* batch) const; +}; + +inline int Radio::declare(RadBuilder* b, const RadModelMeta* m, const RadBuildCtx* ctx, Names& nm, + int64_t model_embd, int first_group) { + on = false; + if (!present(m) || ctx->max_enc_patches <= 0) return RAD_OK; + + depth = rad_meta_geti(m, "vision_config.num_hidden_layers", 0); + width = rad_meta_geti(m, "vision_config.hidden_size", 0); + heads = rad_meta_geti(m, "vision_config.num_attention_heads", 0); + ff = (int64_t)std::llround(rad_meta_getf(m, "vision_config.mlp_ratio", 0.0) * (double)width); + patch = rad_meta_geti(m, "vision_config.patch_size", 0); + eps = (float)rad_meta_getf(m, "vision_config.layer_norm_eps", 1e-6); + side = rad_meta_geti(m, "vision_config.max_img_size", 0) / (patch > 0 ? patch : 1); + npre = rad_meta_geti(m, "vision_config.num_cls_tokens", 0) + + rad_meta_geti(m, "vision_config.num_registers", 0); + tubelet = rad_meta_geti(m, "vision_config.video_temporal_patch_size", + rad_meta_geti(m, "video_temporal_patch_size", 0)); + const double ratio = rad_meta_getf(m, "downsample_ratio", 0.0); + merge = ratio > 0.0 ? (int64_t)std::llround(1.0 / ratio) : 0; + proj_hidden = rad_meta_geti(m, "projector_hidden_size", 0); + n_embd = model_embd; + const int64_t chans = rad_meta_geti(m, "vision_config.num_channels", 3); + if (depth <= 0 || width <= 0 || heads <= 0 || ff <= 0 || patch <= 0 || side <= 0 || + npre <= 0 || tubelet <= 0 || merge <= 0 || proj_hidden <= 0 || width % heads || + chans != 3) { + fprintf(stderr, "radiance: nemotronh: the container's RADIO vision_config is incomplete or " + "inconsistent (layers %lld, hidden %lld, heads %lld, ff %lld, patch %lld, " + "table %lld, prefix %lld, tubelet %lld, merge %lld, projector %lld)\n", + (long long)depth, (long long)width, (long long)heads, (long long)ff, + (long long)patch, (long long)side, (long long)npre, (long long)tubelet, + (long long)merge, (long long)proj_hidden); + return RAD_E_INVAL; + } + /* What this tower serves of RADIO's options: the plain GELU MLP, LayerScale 1 (no stored + * scales), q/k/v with biases, and no final layer norm before the projector. */ + const char* act = rad_meta_gets(m, "vision_config.hidden_act", "gelu"); + const bool swiglu = rad_meta_geti(m, "vision_config.use_swiglu_ffn", 0) != 0 || + !std::strcmp(rad_meta_gets(m, "vision_config.use_swiglu_ffn", ""), "true"); + const bool final_ln = rad_meta_geti(m, "vision_final_layernorm", 0) != 0 || + !std::strcmp(rad_meta_gets(m, "vision_final_layernorm", ""), "true"); + if (std::strcmp(act, "gelu") || swiglu || final_ln || + rad_meta_getf(m, "vision_config.layerscale_value", 1.0) != 1.0) { + fprintf(stderr, "radiance: nemotronh: this RADIO tower (activation '%s'%s%s, layer scale " + "%g) is not the one served: GELU MLP, layer scale 1, no final layer norm\n", + act, swiglu ? ", SwiGLU" : "", final_ln ? ", final layer norm" : "", + rad_meta_getf(m, "vision_config.layerscale_value", 1.0)); + return RAD_E_UNSUPPORTED; + } + head_dim = width / heads; + const int64_t pp = chans * patch * patch; + patch_dim = pp * (1 + tubelet); + const int64_t mm = merge * merge, mw = mm * width; + + /* A pass's rows, prefix rows included; the output rows are at most a quarter of them. */ + P = ctx->max_enc_patches; + const int64_t max_seg = P; + if (ctx->shape_probe) { + const int64_t r = std::min(P, ctx->max_tok); + P = std::max(mm, r / mm * mm); + } + R = P / mm; + if (R <= 0) return RAD_E_SHAPE; + const int ACC = RAD_ACCESS_PER_REQUEST; + + auto bw = [&](const char* dn, const char* src, std::initializer_list shp, + RadWeightGroup g) -> rad_weight { + if (map_copy(b, dn, src) < 0) return 0; + return decl_w(b, dn, RAD_BF16, shp, ACC, RAD_SHARD_NONE, g); + }; + const char* pg = "vision_model.radio_model.model.patch_generator."; + /* [video_embedder | embedder] along K: one GEMM for a row of either kind. */ + if (map_concat(b, nm.f("v.patch.weight"), + { nm.ckpt("%svideo_embedder.weight", pg), nm.ckpt("%sembedder.weight", pg) }, + 1) < 0) + return RAD_E_INVAL; + /* Whether the tower is here at all: its stem's encoding, which convert answers from the + * checkpoint and load from the container alike. A text-only cut (a few blocks for a host + * reference) or a container converted without it serves text; the map left behind is inert. */ + { + RadEncoding enc; + if (rad_weight_encoding(b, nm.f("v.patch.weight"), &enc, nullptr, nullptr) != RAD_OK) { + rad_note(b, "nemotronh: vision_config names a RADIO tower its weights are not here " + "for; serving text"); + return RAD_OK; + } + } + w_patch = decl_w(b, nm.f("v.patch.weight"), RAD_BF16, { width, patch_dim }, ACC, + RAD_SHARD_NONE, grp_model()); + /* The checkpoint's [1, side * side, width] read as the [side * side, width] table. */ + w_pos = bw(nm.f("v.pos.weight"), nm.ckpt("%spos_embed", pg), { side * side, width }, grp_model()); + w_pre = bw(nm.f("v.prefix.weight"), nm.ckpt("%scls_token.token", pg), { npre, width }, + grp_model()); + L.assign((size_t)depth, Layer{}); + for (int64_t i = 0; i < depth; ++i) { + Layer& l = L[(size_t)i]; + const RadWeightGroup g = grp_layer(first_group + (int)i); + const int li = (int)i; + const char* e = "vision_model.radio_model.model.blocks.%d.%s"; + l.n1w = bw(nm.f("v.blk.%d.norm1.weight", li), nm.ckpt(e, li, "norm1.weight"), { width }, g); + l.n1b = bw(nm.f("v.blk.%d.norm1.bias", li), nm.ckpt(e, li, "norm1.bias"), { width }, g); + l.qkv_w = bw(nm.f("v.blk.%d.qkv.weight", li), nm.ckpt(e, li, "attn.qkv.weight"), { 3 * width, width }, g); + l.qkv_b = bw(nm.f("v.blk.%d.qkv.bias", li), nm.ckpt(e, li, "attn.qkv.bias"), { 3 * width }, g); + l.out_w = bw(nm.f("v.blk.%d.proj.weight", li), nm.ckpt(e, li, "attn.proj.weight"), { width, width }, g); + l.out_b = bw(nm.f("v.blk.%d.proj.bias", li), nm.ckpt(e, li, "attn.proj.bias"), { width }, g); + l.n2w = bw(nm.f("v.blk.%d.norm2.weight", li), nm.ckpt(e, li, "norm2.weight"), { width }, g); + l.n2b = bw(nm.f("v.blk.%d.norm2.bias", li), nm.ckpt(e, li, "norm2.bias"), { width }, g); + l.up_w = bw(nm.f("v.blk.%d.fc1.weight", li), nm.ckpt(e, li, "mlp.fc1.weight"), { ff, width }, g); + l.up_b = bw(nm.f("v.blk.%d.fc1.bias", li), nm.ckpt(e, li, "mlp.fc1.bias"), { ff }, g); + l.down_w = bw(nm.f("v.blk.%d.fc2.weight", li), nm.ckpt(e, li, "mlp.fc2.weight"), { width, ff }, g); + l.down_b = bw(nm.f("v.blk.%d.fc2.bias", li), nm.ckpt(e, li, "mlp.fc2.bias"), { width }, g); + if (!l.n1w || !l.n1b || !l.n2w || !l.n2b || !l.qkv_w || !l.qkv_b || !l.out_w || + !l.out_b || !l.up_w || !l.up_b || !l.down_w || !l.down_b) + return RAD_E_INVAL; + } + mn_w = bw(nm.f("v.proj.norm.weight"), nm.ckpt("mlp1.0.weight"), { mw }, grp_model()); + m1_w = bw(nm.f("v.proj.fc1.weight"), nm.ckpt("mlp1.1.weight"), { proj_hidden, mw }, grp_model()); + m2_w = bw(nm.f("v.proj.fc2.weight"), nm.ckpt("mlp1.3.weight"), { n_embd, proj_hidden }, grp_model()); + if (!w_patch || !w_pos || !w_pre || !mn_w || !m1_w || !m2_w) return RAD_E_INVAL; + + /* ---- activations. `g` holds the gathered patch rows at `width` and is read by the norm as + * R rows of mm * width (the pixel shuffle's view, no copy). */ + b_x = decl_b(b, nm.f("v.x"), RAD_BF16, { P, width }); + b_h = decl_b(b, nm.f("v.h"), RAD_BF16, { P, width }); + b_qkv = decl_b(b, nm.f("v.qkv"), RAD_BF16, { P, 3 * width }); + b_att = decl_b(b, nm.f("v.att"), RAD_BF16, { P, width }); + b_ff = decl_b(b, nm.f("v.ff"), RAD_BF16, { P, ff }); + b_seq = decl_b(b, nm.f("v.seq"), RAD_I32, { P }); + b_g = decl_b(b, nm.f("v.g"), RAD_BF16, { R, mw }); + b_mn = decl_b(b, nm.f("v.mn"), RAD_BF16, { R, mw }); + b_mf = decl_b(b, nm.f("v.mf"), RAD_BF16, { R, proj_hidden }); + b_ma = decl_b(b, nm.f("v.ma"), RAD_BF16, { R, proj_hidden }); + b_out = decl_b(b, nm.f("v.out"), RAD_BF16, { R, n_embd }); + if (!b_x || !b_h || !b_qkv || !b_att || !b_ff || !b_seq || !b_g || !b_mn || !b_mf || !b_ma || + !b_out) + return RAD_E_INVAL; + + auto gemm_b = [&](int64_t rows, int64_t N, int64_t K, const char* a, rad_weight w, + rad_weight bias) -> rad_op { + return RAD_OP(b, "gemm_nt_bias", + RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("N", N), RAD_INT("K", K), + RAD_STR("dtype", "bf16"), RAD_STR("act", a)), + RAD_WEIGHTS(w, bias)); + }; + auto gemm = [&](int64_t rows, int64_t N, int64_t K, rad_weight w) -> rad_op { + return RAD_OP(b, "gemm_nt", + RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("N", N), RAD_INT("K", K), + RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(w)); + }; + auto lnorm = [&](int64_t rows, rad_weight w, rad_weight bias) -> rad_op { + return RAD_OP(b, "layernorm", + RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("n", width), + RAD_F64("eps", eps), RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(w, bias)); + }; + + op_patch = rw(b, gemm(P, width, patch_dim, w_patch), {}, { b_x }); + op_pos = rw(b, RAD_OP(b, "grid_embed_cpe", + RAD_PARAMS(RAD_RANGE("M", 1, P), RAD_INT("n", width), + RAD_INT("side", side), RAD_INT("n_prefix", npre), + RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(w_pos, w_pre)), + { b_x }, { b_x }); + op_seq = rw(b, RAD_OP(b, "iota", + RAD_PARAMS(RAD_RANGE("M", 1, P), RAD_INT("start", 0), RAD_INT("step", 1)), + RAD_NOWEIGHTS), + {}, { b_seq }); + for (Layer& l : L) { + l.ln1 = rw(b, lnorm(P, l.n1w, l.n1b), { b_x }, { b_h }); + l.qkv = rw(b, gemm_b(P, 3 * width, width, "none", l.qkv_w, l.qkv_b), { b_h }, { b_qkv }); + l.attn = rw(b, RAD_OP(b, "attn_dense", + RAD_PARAMS(RAD_RANGE("M", 1, P), RAD_INT("head_dim", head_dim), + RAD_INT("gqa", 1), RAD_INT("causal", 0), + RAD_STR("dtype", "bf16"), + RAD_F64("scale", 1.0 / std::sqrt((double)head_dim)), + RAD_INT("max_seqlen", max_seg)), + RAD_NOWEIGHTS), + { b_qkv }, { b_att }); + l.proj = rw(b, gemm_b(P, width, width, "none", l.out_w, l.out_b), { b_att, b_x }, { b_x }); + l.ln2 = rw(b, lnorm(P, l.n2w, l.n2b), { b_x }, { b_h }); + l.up = rw(b, gemm_b(P, ff, width, "gelu", l.up_w, l.up_b), { b_h }, { b_ff }); + l.down = rw(b, gemm_b(P, width, ff, "none", l.down_w, l.down_b), { b_ff, b_x }, { b_x }); + } + op_gather = rw(b, RAD_OP(b, "gather_rows", + RAD_PARAMS(RAD_RANGE("M", 1, P), RAD_INT("n", width), + RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + { b_x, b_seq }, { b_g }); + op_mln = rw(b, RAD_OP(b, "rmsnorm", + RAD_PARAMS(RAD_RANGE("M", 1, R), RAD_INT("n", mw), RAD_F64("eps", 1e-5), + RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(mn_w)), + { b_g }, { b_mn }); + op_m1 = rw(b, gemm(R, proj_hidden, mw, m1_w), { b_mn }, { b_mf }); + /* relu(x)^2: act_mul's "relu" with the one tensor in both operands. */ + op_act = rw(b, RAD_OP(b, "act_mul", + RAD_PARAMS(RAD_RANGE("M", 1, R), RAD_INT("n", proj_hidden), + RAD_STR("act", "relu"), RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), + { b_mf }, { b_ma }); + op_m2 = rw(b, gemm(R, n_embd, proj_hidden, m2_w), { b_ma }, { b_out }); + + if (!ctx->shape_probe) { + RadEncoderDecl e{}; + e.name = "vision"; + e.modalities = RAD_MM_IMAGE | RAD_MM_VIDEO; + e.patch_dim = patch_dim; + e.merge = mm; + e.max_patches = P; + e.n_embd = n_embd; + e.out = b_out; + e.one_grid = 1; + RAD_ARCH_TRY(rad_declare_encoder(b, &e)); + rad_note(b, "RADIO tower: %lld blocks of %lld (%lld heads x %lld), ff %lld, patch %lld " + "(tubelet %lld), %lld x %lld position table, %lld prefix rows; projector %lld " + "-> %lld -> %lld; %lld rows a pass", + (long long)depth, (long long)width, (long long)heads, (long long)head_dim, + (long long)ff, (long long)patch, (long long)tubelet, (long long)side, + (long long)side, (long long)npre, (long long)mw, (long long)proj_hidden, + (long long)n_embd, (long long)P); + } + on = true; + return RAD_OK; +} + +inline void Radio::step(RadCtx* c, const RadBatch* batch) const { + const int64_t Pn = batch->enc_n_patch, S = batch->enc_n_seg; + const int64_t mm = merge * merge; + const int64_t gh = S > 0 && batch->enc_seg_h ? batch->enc_seg_h[0] : 0; + const int64_t gw = S > 0 && batch->enc_seg_w ? batch->enc_seg_w[0] : 0; + const int64_t seg = npre + gh * gw, Rn = S * gh * gw / (mm > 0 ? mm : 1); + if (!on || Pn <= 0 || Pn > P || S <= 0 || gh <= 0 || gw <= 0 || (gh * gw) % mm || + S * seg != Pn || Rn > R) { + rad_step_fail(c, "nemotronh: an encoder pass this program's RADIO tower cannot serve: no " + "tower, more rows than it was declared for, or segments that are not one " + "grid of whole merged rows behind their prefix rows"); + return; + } + const RadOperand pix = praw2(batch->enc_pixels, RAD_BF16, Pn, patch_dim); + const RadOperand crd = praw2(batch->enc_coord, RAD_I32, 4, Pn); + const RadOperand cu = praw(batch->enc_cu, RAD_I32, S + 1); + + RAD_ISSUE_N(c, op_patch, Pn, pix, RAD_W(w_patch), brows(b_x, Pn)); + RAD_ISSUE_N(c, op_pos, Pn, brows(b_x, Pn), RAD_W(w_pos), crd, RAD_W(w_pre)); + RAD_ISSUE_N(c, op_seq, Pn, brows(b_seq, Pn)); + for (const Layer& l : L) { + RAD_ISSUE_N(c, l.ln1, Pn, brows(b_x, Pn), RAD_W(l.n1w), RAD_W(l.n1b), brows(b_h, Pn)); + RAD_ISSUE_N(c, l.qkv, Pn, brows(b_h, Pn), RAD_W(l.qkv_w), RAD_W(l.qkv_b), RAD_NONE, + brows(b_qkv, Pn)); + RAD_ISSUE_N(c, l.attn, Pn, + bcol(b_qkv, 0, width, Pn), bcol(b_qkv, width, width, Pn), + bcol(b_qkv, 2 * width, width, Pn), cu, brows(b_att, Pn)); + RAD_ISSUE_N(c, l.proj, Pn, brows(b_att, Pn), RAD_W(l.out_w), RAD_W(l.out_b), + brows(b_x, Pn), brows(b_x, Pn)); + RAD_ISSUE_N(c, l.ln2, Pn, brows(b_x, Pn), RAD_W(l.n2w), RAD_W(l.n2b), brows(b_h, Pn)); + RAD_ISSUE_N(c, l.up, Pn, brows(b_h, Pn), RAD_W(l.up_w), RAD_W(l.up_b), RAD_NONE, + brows(b_ff, Pn)); + RAD_ISSUE_N(c, l.down, Pn, brows(b_ff, Pn), RAD_W(l.down_w), RAD_W(l.down_b), + brows(b_x, Pn), brows(b_x, Pn)); + } + /* Each segment's patch rows, behind its prefix rows, into `g` at width: segment s's are rows + * [s * seg + npre, (s + 1) * seg) of x, which the identity index names by a slice. */ + const int64_t hw = gh * gw; + for (int64_t s = 0; s < S; ++s) + RAD_ISSUE_N(c, op_gather, hw, brows(b_x, Pn), brow_slice(b_seq, s * seg + npre, hw, 1), + brow_slice(b_g, s * hw / mm, hw / mm, mm * width)); + RAD_ISSUE_N(c, op_mln, Rn, brows(b_g, Rn), RAD_W(mn_w), brows(b_mn, Rn)); + RAD_ISSUE_N(c, op_m1, Rn, brows(b_mn, Rn), RAD_W(m1_w), brows(b_mf, Rn)); + RAD_ISSUE_N(c, op_act, Rn, brows(b_mf, Rn), brows(b_mf, Rn), brows(b_ma, Rn)); + RAD_ISSUE_N(c, op_m2, Rn, brows(b_ma, Rn), RAD_W(m2_w), brows(b_out, Rn)); +} + +} /* namespace nemotronh */ + +#endif /* NEMOTRONH_RADIO_H */ diff --git a/arch/qwen35_fp8/qwen35_fp8.cpp b/arch/qwen35_fp8/qwen35_fp8.cpp index e6f5f4f3..adb10cbc 100644 --- a/arch/qwen35_fp8/qwen35_fp8.cpp +++ b/arch/qwen35_fp8/qwen35_fp8.cpp @@ -80,6 +80,7 @@ #include #include #include +#include #include #if QWEN35_MOE #include @@ -134,6 +135,9 @@ struct Layer { * beside the feed-forward's; 0 where none is declared. */ rad_op op_pf_gu = 0, op_pf_next = 0; rad_weight pf_gu_w = 0, pf_next_w = 0; + /* The layer's calibration inputs (rad_calib_full.h, site_i8), -1 where this run does not record + * it: the mixer's input and its output projection's, the feed-forward's and its down's. */ + int cs_in = -1, cs_o = -1, cs_mlp = -1, cs_down = -1; }; struct Model { @@ -208,6 +212,12 @@ struct Model { rad_op op_tap = 0; rad_weight w_tok = 0, w_out_norm = 0, w_lm_head = 0; + /* A vocabulary-weighted head (logits_gemm_vocab): its width classes' codes, scales and rows' + * vocabulary ids, and this rank's rows of each. */ + enum { MAX_VCLS = 4 }; + int n_vcls = 0; + rad_weight w_vw[MAX_VCLS] = {}, w_vs[MAX_VCLS] = {}, w_vi[MAX_VCLS] = {}, w_vrow = 0; + int64_t vcls_rows[MAX_VCLS] = {}; rad_op op_embed = 0, op_embed_ar = 0, op_final_norm = 0, op_gather = 0, op_logits = 0; /* Set by a plugin built over this one whose head answers a request from its words * (RadBatch::plugin_words): a `fill` of the logits rows that plugin declared. A step every @@ -224,6 +234,7 @@ struct Model { MediaRows mrows{}; std::vector layers; + CalibFull calib; /* --calib-dir over an int8 trunk (rad_calib_full.h) */ /* The pipelined prefill (step_pipelined): on where declare allowed it; the bounds buffer it * cuts a step by, rewritten by every pipelined step from the pinned table `pipe_tbl` of @@ -871,6 +882,13 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c (g.world != 2 || rad_op_declared(b, "ar_rmsnorm_had_quant_i8g"))) m.a_h.q8_fed = m.a_h.q8_rot = true; if (rad_op_declared(b, "gated_had_quant_i8g")) m.a_ffn.q8_fed = m.a_ffn.q8_rot = true; + /* The delta net's output likewise, from the decode conv fold's epilogue + * (gdn_conv_recurrent_update_had) and had_quant_act_i8g on the other rows (GdnFP8::q_o). */ + if (rad_op_declared(b, "gdn_conv_recurrent_update_had") && rad_op_declared(b, "had_quant_act_i8g")) + m.a_go.q8_fed = m.a_go.q8_rot = true; + /* And the gated attention's output, from its gate (gate_had_quant_i8g). */ + if (rad_op_declared(b, "gate_had_quant_i8g") && rad_op_declared(b, "had_quant_act_i8g")) + m.a_attn.q8_fed = m.a_attn.q8_rot = true; #endif m.b_hout = decl_b(b, nm.f("h_out"), g.act_dtype, {g.max_logit_rows, g.n_embd}); @@ -929,10 +947,45 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c } m.w_out_norm = decl_w(b, nm.f("output_norm.weight"), RAD_F32, {g.n_embd}, RAD_ACCESS_PER_TOKEN, RAD_SHARD_NONE, grp_model()); - /* Row-sharded with the vocabulary: g.n_vocab is this rank's share (rad_arch.h). */ - m.w_lm_head = decl_w(b, nm.f("output.weight"), - weight_codes_dtype(b, nm.f("output.weight"), RAD_BF16), - {g.n_vocab, g.n_embd}, RAD_ACCESS_VOCAB, RAD_SHARD_ROW, grp_model()); + /* A vocabulary-weighted head, where the model holds one in place of output.weight: the rows + * sorted by their token's probability into classes of one computed-trellis width each, + * `output.k.weight`, with `output.k.ids` [rows, 1] each row's vocabulary id, and + * `output.vrow` [n_vocab, 1] the inverse (each id's class width and row). Each class is + * row-sharded like any lm_head, the converter keeping an id's row among its rank's rows + * (libr4d's logits_gemm_vocab). */ + for (int B = 7; B >= 2; --B) { + const char* wn = nm.f("output.k%d.weight", B); + RAD_ARCH_TRY(map_copy(b, wn, nm.ckpt("lm_head.k%d.weight", B))); + RadEncoding e{}; + int64_t shp[RAD_MAX_RANK] = {}; + if (rad_weight_encoding(b, wn, &e, shp, nullptr) != RAD_OK) continue; + if (m.n_vcls == Model::MAX_VCLS || shp[0] % (256 * g.world) || shp[1] != g.n_embd) { + fprintf(stderr, "radiance: '%s' is not a head class this build reads (at most %d " + "classes, rows a multiple of 256 a rank)\n", wn, (int)Model::MAX_VCLS); + return RAD_E_SHAPE; + } + const int64_t n = shp[0] / g.world; + const int k = m.n_vcls++; + m.w_vw[k] = decl_view(b, wn, nullptr, "codes,trellis,trellis.mad", e.plane[0].dtype, + {n, g.n_embd}, RAD_ACCESS_VOCAB, RAD_SHARD_ROW, grp_model()); + m.w_vs[k] = decl_view(b, nm.f("output.k%d.scale", B), wn, + rad_enc_plane(&e, "scale.col") ? "scale,scale.col" : "scale", + RAD_F32, {n, g.n_embd}, RAD_ACCESS_VOCAB, RAD_SHARD_ROW, grp_model()); + const char* in = nm.f("output.k%d.ids", B); + RAD_ARCH_TRY(map_copy(b, in, nm.ckpt("lm_head.k%d.ids", B))); + m.w_vi[k] = decl_w(b, in, RAD_I32, {n, 1}, RAD_ACCESS_VOCAB, RAD_SHARD_ROW, grp_model()); + m.vcls_rows[k] = n; + } + if (m.n_vcls) { + RAD_ARCH_TRY(map_copy(b, nm.f("output.vrow"), nm.ckpt("lm_head.vrow"))); + m.w_vrow = decl_w(b, nm.f("output.vrow"), RAD_I32, {g.n_vocab, 1}, RAD_ACCESS_VOCAB, + RAD_SHARD_ROW, grp_model()); + } else { + /* Row-sharded with the vocabulary: g.n_vocab is this rank's share (rad_arch.h). */ + m.w_lm_head = decl_w(b, nm.f("output.weight"), + weight_codes_dtype(b, nm.f("output.weight"), RAD_BF16), + {g.n_vocab, g.n_embd}, RAD_ACCESS_VOCAB, RAD_SHARD_ROW, grp_model()); + } m.op_embed = rw(b, RAD_OP(b, "embed_lookup", RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n_embd", g.n_embd), @@ -1028,6 +1081,15 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c * unfolded: it is a separate chain over its own residual buffer and saves only two launches a * step. */ m.layers.resize((size_t)m.n_main); +#if !QWEN35_MOE + /* GPTQ calibration over the trunk's own int8 codes (rad_calib_full.h, site_i8): one rank, the + * serial step. The scratch is the widest input's square, the feed-forward's. */ + if (ctx->calib_dir && *ctx->calib_dir && g.world > 1) { + fprintf(stderr, "radiance: qwen35: --calib-dir records an int8 trunk at --tp 1 only\n"); + return RAD_E_INVAL; + } + RAD_ARCH_TRY(m.calib.begin(b, nm, g, ctx, m.n_main, 0, std::max(g.n_ff, g.n_embd))); +#endif for (int64_t l = 0; l < m.n_main; ++l) { Layer& lay = m.layers[(size_t)l]; lay.full = is_full_attention(l, interval) ? 1 : 0; @@ -1093,6 +1155,36 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c #endif RAD_ARCH_TRY(lay.mlp.declare(b, nm, g, (int)l, mw, ms, true, f.mlp_add, f.mlp_ar_in, f.mlp_ar_out)); +#if !QWEN35_MOE + if (m.calib.records(l)) { + /* The codes each int8 GEMM reads, in the domain its weight is stored in (i8_rot). */ + const ActFP8& ao = lay.full ? m.a_attn : m.a_go; + const LinearFP8& li = lay.full ? lay.attn.qg : lay.gdn.in; + const LinearFP8& lo = lay.full ? lay.attn.o : lay.gdn.out; + if (!m.a_h.q8 || !ao.q8 || !m.a_ffn.q8 || !lay.mlp.gate_up.i8 || !lo.i8) { + fprintf(stderr, "radiance: qwen35: --calib-dir records an int8 trunk; layer %lld " + "is not one\n", (long long)l); + return RAD_E_INVAL; + } + auto dom = [](const LinearFP8& w) { return w.i8_rot ? (uint32_t)RAD_FP8_BLOCK : 0u; }; + const std::string L = "model.language_model.layers." + std::to_string(l); + const std::string mix = L + (lay.full ? ".self_attn" : ".linear_attn"); + const std::string op = lay.full ? ".o_proj" : ".out_proj"; + lay.cs_in = (int)m.calib.sites.size(); + RAD_ARCH_TRY(m.calib.site_i8(b, g, l, L + ".input", mix, m.a_h.q8, m.a_h.s8, g.n_embd, + dom(li))); + lay.cs_o = (int)m.calib.sites.size(); + RAD_ARCH_TRY(m.calib.site_i8(b, g, l, mix + op + ".input", mix + op, ao.q8, ao.s8, lo.K, + dom(lo))); + lay.cs_mlp = (int)m.calib.sites.size(); + RAD_ARCH_TRY(m.calib.site_i8(b, g, l, L + ".post_attention.input", + L + ".mlp.gate_proj," + L + ".mlp.up_proj", m.a_h.q8, + m.a_h.s8, g.n_embd, dom(lay.mlp.gate_up))); + lay.cs_down = (int)m.calib.sites.size(); + RAD_ARCH_TRY(m.calib.site_i8(b, g, l, L + ".mlp.down_proj.input", L + ".mlp.down_proj", + m.a_ffn.q8, m.a_ffn.s8, g.n_ff, dom(lay.mlp.down))); + } +#endif } #if QWEN35_MOE /* Each routed layer predicts the next one's experts at its router input (MoeFP8::xp_next). */ @@ -1136,12 +1228,22 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c RAD_NOWEIGHTS), {m.a_h.x}, {m.b_hout}); - m.op_logits = rw(b, RAD_OP(b, "logits_gemm", - RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows), - RAD_INT("n_vocab", g.n_vocab), - RAD_INT("n_embd", g.n_embd), RAD_STR("dtype", g.dtype)), - RAD_WEIGHTS(m.w_lm_head)), - {m.b_hout}, {m.b_logits}); + m.op_logits = m.n_vcls + ? rw(b, RAD_OP(b, "logits_gemm_vocab", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows), RAD_INT("n_vocab", g.n_vocab), + RAD_INT("n_embd", g.n_embd), RAD_STR("dtype", g.dtype), + RAD_INT("vocab_offset", g.vocab_off), + RAD_INT("rows0", m.vcls_rows[0]), RAD_INT("rows1", m.vcls_rows[1]), + RAD_INT("rows2", m.vcls_rows[2]), RAD_INT("rows3", m.vcls_rows[3])), + RAD_WEIGHTS(m.w_vw[0], m.w_vs[0], m.w_vi[0], m.w_vw[1], m.w_vs[1], m.w_vi[1], + m.w_vw[2], m.w_vs[2], m.w_vi[2], m.w_vw[3], m.w_vs[3], m.w_vi[3], + m.w_vrow)), + {m.b_hout}, {m.b_logits}) + : rw(b, RAD_OP(b, "logits_gemm", + RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows), RAD_INT("n_vocab", g.n_vocab), + RAD_INT("n_embd", g.n_embd), RAD_STR("dtype", g.dtype)), + RAD_WEIGHTS(m.w_lm_head)), + {m.b_hout}, {m.b_logits}); /* ---- the multi-token-prediction head (rad_block_mtp_fp8.h). * @@ -1151,7 +1253,8 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c * * Also only when there is no DFlash2 drafter (`n_taps` == 0): a deployment drafts with one, * and DFlash2 (one forward per block rather than one per token) is the better one here. */ - if (nextn > 0 && g.max_spec > 0 && m.n_taps == 0) { + /* (A vocabulary-weighted head has no output.weight for the draft head to read.) */ + if (nextn > 0 && g.max_spec > 0 && m.n_taps == 0 && !m.n_vcls) { /* Sized at max_tok, not max_logit_rows: a draft round is one row per sequence, but the * history pass that fills the head's own K and V is one row per token over a whole prefill * chunk (26 MiB at a 512-token chunk, beside 477 MiB of head weights). */ @@ -1321,6 +1424,19 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c return RAD_OK; } +/* The lm_head over the gathered rows: the one weight, or a vocabulary-weighted head's classes. */ +static void issue_logits(RadCtx* c, const Model& m, int n) { + if (!m.n_vcls) { + RAD_ISSUE_N(c, m.op_logits, n, brows(m.b_hout, n), RAD_W(m.w_lm_head), + brows(m.b_logits, n)); + return; + } + auto w = [](rad_weight h) { return h ? RAD_W(h) : RAD_NONE; }; + RAD_ISSUE_N(c, m.op_logits, n, brows(m.b_hout, n), w(m.w_vw[0]), w(m.w_vs[0]), w(m.w_vi[0]), + w(m.w_vw[1]), w(m.w_vs[1]), w(m.w_vi[1]), w(m.w_vw[2]), w(m.w_vs[2]), w(m.w_vi[2]), + w(m.w_vw[3]), w(m.w_vs[3]), w(m.w_vi[3]), RAD_W(m.w_vrow), brows(m.b_logits, n)); +} + #if !QWEN35_MOE /* ============================== A prefill step in two pieces ============================== * @@ -1547,9 +1663,7 @@ static void step_pipelined(RadCtx* c, const RadBatch* batch, Model& m, const int RAD_ISSUE_N(c, m.op_gather, batch->n_out, brows(m.a_h.x, T), praw(batch->out_ids, RAD_I32, batch->n_out), brows(m.b_hout, batch->n_out)); - RAD_ISSUE_N(c, m.op_logits, batch->n_out, - brows(m.b_hout, batch->n_out), RAD_W(m.w_lm_head), - brows(m.b_logits, batch->n_out)); + issue_logits(c, m, batch->n_out); } } #endif @@ -1628,9 +1742,15 @@ static void step(RadCtx* c, const RadBatch* batch) { const Layer& l = m.layers[(size_t)li]; if (l.full) l.attn.step(c, batch); else l.gdn.step(c, batch); + /* The calibration taps read the codes the block's GEMMs just read, before the next block's + * norm rewrites the shared input planes. */ + if (l.cs_in >= 0) m.calib.tap(c, (size_t)l.cs_in, batch->n_tok); + if (l.cs_o >= 0) m.calib.tap(c, (size_t)l.cs_o, batch->n_tok); prefetch_beside(c, l.op_pf_gu, l.pf_gu_w, pf_h); dbg_resid(c, (int)li, "mix", m.g.n_embd, m.b_x, m.a_h.x); l.mlp.step(c, batch); + if (l.cs_mlp >= 0) m.calib.tap(c, (size_t)l.cs_mlp, batch->n_tok); + if (l.cs_down >= 0) m.calib.tap(c, (size_t)l.cs_down, batch->n_tok); prefetch_beside(c, l.op_pf_next, l.pf_next_w, pf_h); dbg_resid(c, (int)li, "ffn", m.g.n_embd, m.b_x, m.a_h.x); @@ -1643,6 +1763,8 @@ static void step(RadCtx* c, const RadBatch* batch) { } } + m.calib.after_step(c, batch->n_tok); + RAD_ISSUE(c, m.op_final_norm, brows(m.b_x, batch->n_tok), RAD_W(m.w_out_norm), brows(m.a_h.x, batch->n_tok)); @@ -1655,9 +1777,7 @@ static void step(RadCtx* c, const RadBatch* batch) { brows(m.a_h.x, batch->n_tok), praw(batch->out_ids, RAD_I32, batch->n_out), brows(m.b_hout, batch->n_out)); - RAD_ISSUE_N(c, m.op_logits, batch->n_out, - brows(m.b_hout, batch->n_out), RAD_W(m.w_lm_head), - brows(m.b_logits, batch->n_out)); + issue_logits(c, m, batch->n_out); } } diff --git a/arch/qwen4exp_fp8/qwen4exp_fp8.cpp b/arch/qwen4exp_fp8/qwen4exp_fp8.cpp index d5cca086..da49a3c0 100644 --- a/arch/qwen4exp_fp8/qwen4exp_fp8.cpp +++ b/arch/qwen4exp_fp8/qwen4exp_fp8.cpp @@ -88,6 +88,7 @@ #include #include +#include #include #include #include @@ -1696,6 +1697,72 @@ static void step(RadCtx* c, const RadBatch* batch) { * acceptance stays high at every depth, but each extra verify row costs real time because the * weights do not fit device memory (more experts streamed, more n-gram rows faulted from the * mapped table). */ +uint64_t pass_key(RadCtx* c, const RadBatch* batch, const int32_t* used_max_h) { + if (!c || !batch) return 0; + if (batch->enc) return 1; + /* Mixed batches split the query rows into decode and prefill subsets before attention; the + * whole-batch host summary cannot key those subset geometries exactly. */ + if (batch->phase == RAD_PHASE_MIXED) return 0; + + Model& m = g_model[rad_rank(c)]; + /* Decode, verify and draft passes (the MTP head attends over the same KV group): every + * attention launch covers all the pass's sequences, and the shape fields the core keys (n_tok, + * n_seq, max_q_len, n_spec, draft_pass) fix each launch's q_len band and units. The live KV + * length enters a split launcher's count only through the cap of eight 48-key tiles a split + * (rad_prefill_splits_law; every head_dim 256 launcher has P_TILE 48), and from 64 splits up + * the cap no longer binds. Keying that cap level lets these passes be recorded while each launch + * still splits by its exact live length: answering 0 left them unrecorded (issue #402), and the + * core's keyed bound for a plugin without the callback rounds the length up a bucket, which split + * a short single-stream verify into several partials with a merge (x1 203 against 219 tok/s). */ + if (batch->phase != RAD_PHASE_PREFILL || batch->draft_pass != 0 || batch->n_spec > 0) { + if (!m.kv_full || !used_max_h || !batch->kv) return 0; + int group = -1; + for (int i = 0; i < batch->n_kv_groups; ++i) + if (batch->kv[i].group == m.kv_full) { group = i; break; } + if (group < 0) return 2; // no full-attention KV in this pass: nothing splits by length + const int used = used_max_h[group]; + if (used <= 0) return 0; // Missing host summary is not the same as an empty KV cache. + constexpr int tile = 48; + const int ctx = (m.g.max_ctx > 0 && used >= m.g.max_ctx) ? (int)m.g.max_ctx : used; + const int cap = std::min(((ctx + tile - 1) / tile) / 8, 64); + return 3 + (uint64_t)cap; + } + + bool has_full_attention = false; + for (const Layer& layer : m.layers) { + if (!layer.full) continue; + if (layer.attn.kv_block != 4) return 0; + has_full_attention = true; + } + if (!has_full_attention) return 1; + if (m.g.head_dim != 256 || (m.g.gqa() != 6 && m.g.gqa() != 12) || !m.kv_full || + !used_max_h || !batch->kv || batch->n_kv_groups <= 0) + return 0; + + int group = -1; + for (int i = 0; i < batch->n_kv_groups; ++i) + if (batch->kv[i].group == m.kv_full) { group = i; break; } + if (group < 0) return 0; + + /* Qwen always passes cu_seqlens, so fill_paged takes q_len = min(band, total_q). That equals + * n_tok only for one sequence; a ragged or multi-sequence launch's band is not the host group + * max, and mixed decode-prefix / prefill-suffix launches use the suffix's own KV lengths. */ + if (batch->n_seq != 1 || batch->n_tok <= 0 || m.g.max_ctx <= 0) return 0; + const int q_len = (int)batch->n_tok; + const int total_q = (int)batch->n_tok; + const int num_seqs = 1; + const int kv_heads = (int)m.g.n_head_kv; + const int used = used_max_h[group]; + if (used <= 0) return 0; // Missing host summary is not the same as an empty KV cache. + const int wgps = rad_ctx_wgp_count(c); + if (wgps <= 0) return 0; + constexpr int tile = 48, nwarps = 24; + const int bq = nwarps * 16 / m.g.gqa(); + const int splits = rad_prefill_splits_for_live(bq, tile, q_len, total_q, num_seqs, + kv_heads, m.g.max_ctx, used, wgps); + return rad_prefill_grid_key(q_len, bq, splits, kv_heads, num_seqs, nwarps * 32); +} + static int probe(const RadModelMeta* meta, RadArchProbe* out) { if (!meta || !out) return RAD_E_INVAL; /* The gated attention block declares the streamed store and the resolve @@ -1717,6 +1784,11 @@ static int probe(const RadModelMeta* meta, RadArchProbe* out) { } /* The gated residual applies a control vector after every block's write (HcProject). */ out->control_vector_ok = 1; + /* Chained launches pay with the MTP drafter: the speculative step's small kernels wait on the + * previous one on the card instead of behind a queue barrier (libr4d/r4d_chain.h). On 2x R9700, + * sampled at temperature 1 with a 25k prompt, MTP depth 3, with the chained hc_read forms: + * 1/2/4/8/16 streams 174/291/458/657/851 -> 207/339/493/647/843 tok/s. */ + out->chain_pays = 1; return RAD_OK; } @@ -1728,4 +1800,8 @@ RAD_ARCH_PLUGIN(qwen4exp_fp8, "qwen4exp", "", "0.1.0", "Qwen4-Exp (Qwen3.8-Flash-Next): hybrid Gated DeltaNet / gated attention, a gated " "residual four streams wide and 512 routed experts, from a dense bf16 checkpoint " "quantised ahead of time by a recipe") +extern "C" uint64_t rad_arch_pass_key(RadCtx* c, const RadBatch* batch, + const int32_t* used_max_h) { + return qwen4exp_fp8::pass_key(c, batch, used_max_h); +} #endif diff --git a/arch/spark25_bf16/CMakeLists.txt b/arch/spark25_bf16/CMakeLists.txt new file mode 100644 index 00000000..f6e7bd31 --- /dev/null +++ b/arch/spark25_bf16/CMakeLists.txt @@ -0,0 +1,9 @@ +# Built in tree or against an installed radiance. +if(NOT COMMAND rad_add_plugin) + cmake_minimum_required(VERSION 3.21) + project(spark25_bf16 LANGUAGES CXX) + find_package(radiance REQUIRED) + rad_plugin_defaults() +endif() + +rad_add_plugin(spark25_bf16 architectures SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/spark25_bf16.cpp) diff --git a/arch/spark25_bf16/chat.h b/arch/spark25_bf16/chat.h new file mode 100644 index 00000000..fbb1385b --- /dev/null +++ b/arch/spark25_bf16/chat.h @@ -0,0 +1,35 @@ +/* Spark's reply format: the checkpoint's template writes these tags around each call. */ +#pragma once +#include "rad_builder.h" + +namespace spark25_bf16 { + +inline const RadChatFormat* spark_chat_format() { + static const char* const breaks[] = {""}; + static const char* const triggers[] = {""}; + static const RadChatFormat f = [] { + RadChatFormat x{}; + x.struct_size = sizeof(x); + x.name = "plugin:spark25"; + x.reasoning_open = ""; + x.reasoning_close = ""; + x.reasoning_breaks = breaks; + x.n_reasoning_breaks = 1; + x.reasoning_in_prompt = RAD_CHAT_THINK_FROM_PROMPT; + /* There is no delimiter between the call opener and the function name. */ + x.name_prefix = ""; + x.call_end = ""; + x.arg_prefix = ""; + x.arg_name_suffix = ""; + x.arg_value_prefix = ""; + x.arg_value_suffix = ""; + x.string_value = RAD_CHAT_VALUE_RAW; + x.other_value = RAD_CHAT_VALUE_JSON; + x.triggers = triggers; + x.n_triggers = 1; + return x; + }(); + return &f; +} + +} /* namespace spark25_bf16 */ diff --git a/arch/spark25_bf16/spark25_bf16.cpp b/arch/spark25_bf16/spark25_bf16.cpp new file mode 100644 index 00000000..52ed2d93 --- /dev/null +++ b/arch/spark25_bf16/spark25_bf16.cpp @@ -0,0 +1,626 @@ +/* Spark X2.6 (Spark2_5ForCausalLM), BF16 weights and activations. + * + * The checkpoint has one [q | k | v] projection per layer. Conversion splits its rows into + * contiguous matrices because paged attention needs a contiguous query. The MLP's two matrices + * are concatenated as [gate | up]; act_mul with exact erf GELU matches the reference, unlike + * gelu_mul (which is the tanh approximation). The attention gate is one sigmoid per head, not + * per channel. Local and full layers have different NeoX rotary dimensions and theta values. + * + * Tensor parallelism splits attention by whole KV groups, replicating KV heads when ranks + * outnumber them. As in the HF reference, residuals accumulate in f32; rmsnorm reads that stream + * and writes bf16 for the linear projections. + * + * A container built with `--draft-model` also carries a DSpark drafter, which reads the residual + * stream after the trunk layers its config names and denoises a block of masked positions in one + * pass. The trunk's part of that is the taps and the drafter pass dispatch (see + * arch/rad_block_dspark_bf16.h for the drafter itself). + */ +#include +#include +#include +#include "chat.h" +#include "spark25_prefill_pass_key.h" + +#include +#include +#include +#include +#include + +namespace spark25_bf16 { +using namespace rad::arch; + +struct Layer { + rad_kvgroup kv = 0; + rad_weight an = 0, q = 0, k = 0, v = 0, gate = 0, o = 0, fn = 0, gu = 0, down = 0; + rad_op anorm = 0, qp = 0, kp = 0, vp = 0, gp = 0, rq = 0, rk = 0, store = 0, attn = 0; + rad_op sigmoid = 0, gate_heads = 0, op = 0, widen_attn = 0, reduce_attn = 0, add_attn = 0; + rad_op fnorm = 0, gup = 0, act = 0, dp = 0, widen_ffn = 0, reduce_ffn = 0, add_ffn = 0; + CalibTap tap_in{}, tap_o{}, tap_gu{}, tap_down{}; +}; + +struct Model { + Names nm{""}; + Geom g{}; + rad_kvgroup kv = 0; + rad_buf x = 0, delta = 0, h = 0, q = 0, k = 0, v = 0, gate = 0, attn = 0, gu = 0, ff = 0; + rad_buf hout = 0, logits = 0; + rad_weight tok = 0, norm = 0, head = 0; + rad_op embed = 0, widen = 0, reduce_embed = 0, final_norm = 0, gather = 0, logits_op = 0; + std::vector layers; + bool tap_live = false; + long long calib_rows = 0; + int64_t calib_lo = 0, calib_hi = 0; + /* The drafter, declared only when the container carries one and this serve speculates. Its own + * KV group holds the context it derived from the trunk's taps. */ + DsparkBF16 ds{}; + DsparkBF16::Wire dsw{}; + DsparkTaps taps{}; + rad_kvgroup kv_draft = 0; + bool have_ds = false; +}; +static Model models[MAX_RANKS]; + +/* Whether the container carries a drafter at all (`--draft-model` merged one under `draft.`), and + * whether this file implements it. A drafter this plugin cannot run is refused at declare rather + * than left unused: the container would serve at the speed of a model with no drafter, and the + * user would have no way to find out that the flag they passed did nothing. */ +static int drafter_kind(const RadModelMeta* meta, bool* present) { + *present = false; + const char* da = rad_meta_gets(meta, "draft.architectures", ""); + if (!da || !*da) { + /* A drafter's config.json flattened, or a GGUF import, either of which names it. */ + if (rad_meta_geti(meta, "draft.num_hidden_layers", 0) <= 0) return RAD_OK; + da = rad_meta_gets(meta, "draft.model_type", ""); + } + if (std::strstr(da, "DSpark") || std::strcmp(da, "dspark") == 0) { + *present = true; + return RAD_OK; + } + *present = true; + fprintf(stderr, "radiance: spark25: this container carries a '%s' drafter. Spark's drafts are " + "DSpark, with a rank-N Markov head over the target's own table; this " + "architecture implements that and nothing else\n", da); + return RAD_E_UNSUPPORTED; +} + +/* The HF config names every layer. Do not infer a periodic schedule: it changes the mask and + * rotary of a layer and would silently produce a different model. */ +static int schedule(const RadModelMeta* meta, int64_t n, std::vector& local) { + const char* s = rad_meta_gets(meta, "layer_types", nullptr); + if (!s) { + fprintf(stderr, "radiance: spark25: layer_types is required\n"); + return RAD_E_INVAL; + } + std::istringstream in(s); + std::string word; + while (in >> word) { + if (word != "sliding_attention" && word != "full_attention") { + fprintf(stderr, "radiance: spark25: unknown layer type '%s'\n", word.c_str()); + return RAD_E_UNSUPPORTED; + } + local.push_back(word == "sliding_attention"); + } + if ((int64_t)local.size() != n) { + fprintf(stderr, "radiance: spark25: layer_types has %zu entries for %lld layers\n", + local.size(), (long long)n); + return RAD_E_INVAL; + } + return RAD_OK; +} + +struct Span { + int64_t first = 0, count = 0; +}; + +/* Remainder-first contiguous slices, in whole units. */ +static Span split(int64_t n, int parts, int rank) { + const int64_t base = n / parts, rem = n % parts; + return {base * rank + std::min(rank, rem), base + (rank < rem ? 1 : 0)}; +} + +struct Shards { + Span q, kv, ff; /* q and kv in heads; ff in channels */ +}; + +/* A rank's attention heads must describe whole GQA groups, or a slice of a single group with + * that group's KV head replicated. This also covers non-divisible worlds such as 3 ranks over + * the checkpoint's 4 KV heads. Projection and FFN spans below give the loader those exact cuts. */ +static int shard_geometry(Geom& g, const RadBuildCtx* ctx, Shards& s) { + g.world = ctx->world_size > 0 ? ctx->world_size : 1; + g.rank = ctx->rank; + if (g.rank >= g.world || g.world > g.n_head_all || g.n_head_kv_all <= 0 || + g.n_head_all % g.n_head_kv_all || g.world > g.n_ff_all) { + fprintf(stderr, "radiance: spark25: cannot shard %lld query heads, %lld KV heads and " + "%lld FFN channels over %d ranks\n", (long long)g.n_head_all, + (long long)g.n_head_kv_all, (long long)g.n_ff_all, g.world); + return RAD_E_INVAL; + } + const int64_t group = g.n_head_all / g.n_head_kv_all; + if (g.world <= g.n_head_kv_all) { + s.kv = split(g.n_head_kv_all, g.world, g.rank); + s.q = {s.kv.first * group, s.kv.count * group}; + } else { + int first_rank = 0; + for (int64_t k = 0; k < g.n_head_kv_all; ++k) { + const int n = (int)split(g.world, (int)g.n_head_kv_all, (int)k).count; + if (g.rank < first_rank + n) { + const Span q = split(group, n, g.rank - first_rank); + s.kv = {k, 1}; + s.q = {k * group + q.first, q.count}; + break; + } + first_rank += n; + } + } + /* Prefer whole 128-channel blocks for a ragged split, keeping device GEMMs aligned. */ + const int64_t unit = g.n_ff_all % 128 == 0 && g.n_ff_all / 128 >= g.world ? 128 : 1; + s.ff = split(g.n_ff_all / unit, g.world, g.rank); + s.ff.first *= unit; + s.ff.count *= unit; + g.n_head = s.q.count; + g.n_head_kv = s.kv.count; + g.n_ff = s.ff.count; + g.n_vocab = shard_extent(g.n_vocab_all, g.world, g.rank); + g.vocab_off = shard_begin(g.n_vocab_all, g.world, g.rank); + return g.n_head > 0 && g.n_head_kv > 0 && g.n_ff > 0 && g.n_vocab > 0 ? RAD_OK : RAD_E_INVAL; +} + +static bool needs_span(const Span& s, int64_t total, const Geom& g) { + return total % g.world != 0 || s.first != g.rank * (total / g.world) || + s.count != total / g.world; +} + +static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* ctx) { + if (!b || !meta || !ctx || ctx->rank < 0 || ctx->rank >= MAX_RANKS) return RAD_E_INVAL; + Model& m = models[ctx->rank]; + m = Model{}; + m.nm = Names(ctx->scope); + /* geom_from's even-only split cannot express a ragged GQA/FFN world. Read the whole geometry, + * then give each rank a group-preserving shard and state its spans on the weights. */ + RadBuildCtx whole = *ctx; + whole.rank = 0; + whole.world_size = 1; + RAD_ARCH_TRY(geom_from(m.g, meta, &whole, "bf16", RAD_BF16)); + Geom& g = m.g; + Shards shards; + RAD_ARCH_TRY(shard_geometry(g, ctx, shards)); + Names& nm = m.nm; + if (g.n_head_kv <= 0 || g.n_head % g.n_head_kv || g.head_dim % 2 || meta->n_expert || + rad_meta_geti(meta, "attention_bias", 0) || rad_meta_geti(meta, "mlp_bias", 0) || + !rad_meta_geti(meta, "tie_word_embeddings", 0) || + !rad_meta_geti(meta, "headwise_attn_output_gate", 0) || + std::strcmp(rad_meta_gets(meta, "gate_attn_act_mode", "sigmoid"), "sigmoid") || + std::strcmp(rad_meta_gets(meta, "hidden_act", "gelu"), "gelu")) { + fprintf(stderr, "radiance: spark25: requires a dense, bias-free, tied model with headwise " + "sigmoid gates, exact GELU and divisible attention heads\n"); + return RAD_E_UNSUPPORTED; + } + /* A single global override cannot describe this model's two rotary ladders. */ + RAD_ARCH_TRY(yarn_from(g, meta, "", g.head_dim)); + if (g.yarn.factor != 0.0f || g.rope_scale != 1.0f || g.rope_mc) { + fprintf(stderr, "radiance: spark25: rotary scaling overrides are not supported\n"); + return RAD_E_UNSUPPORTED; + } + std::vector local; + RAD_ARCH_TRY(schedule(meta, g.n_layer, local)); + if (calib_dir()) { + if (g.world != 1) { + fprintf(stderr, "radiance: spark25 calibration requires one rank so column-split " + "Grams retain their cross terms\n"); + return RAD_E_UNSUPPORTED; + } + RAD_ARCH_TRY(calib_layers("spark25", "RADIANCE_SPARK_CALIB_LAYERS", g.n_layer, + &m.calib_lo, &m.calib_hi)); + m.tap_live = true; + } + const int64_t window = rad_meta_geti(meta, "sliding_window", 0); + if (window <= 0) { + fprintf(stderr, "radiance: spark25: a positive sliding_window is required\n"); + return RAD_E_INVAL; + } + double theta[2]{}; + int64_t rot[2]{}; + const char* kinds[] = {"full_attention", "sliding_attention"}; + for (int j = 0; j < 2; ++j) { + theta[j] = rad_meta_getf(meta, nm.f("rope_parameters.%s.rope_theta", kinds[j]), 10000.0); + const double factor = rad_meta_getf(meta, + nm.f("rope_parameters.%s.partial_rotary_factor", kinds[j]), 1.0); + const char* type = rad_meta_gets(meta, nm.f("rope_parameters.%s.rope_type", kinds[j]), "default"); + if (std::strcmp(type, "default")) { + fprintf(stderr, "radiance: spark25: %s rotary type '%s' is not supported\n", kinds[j], type); + return RAD_E_UNSUPPORTED; + } + const double r = g.head_dim * factor; + if (!std::isfinite(theta[j]) || !(theta[j] > 0) || !(factor > 0 && factor <= 1) || !std::isfinite(r) || + std::floor(r) != r || (int64_t)r % 2) { + fprintf(stderr, "radiance: spark25: invalid %s rotary theta %g or factor %g\n", + kinds[j], theta[j], factor); + return RAD_E_INVAL; + } + rot[j] = (int64_t)r; + } + + /* A full cache for both kinds keeps prefix caching valid. The local attention op enforces + * its own window (q - k < window); the full layers read all past positions. */ + RadKVGroupDecl kd{}; + kd.kind = RAD_KV_FULL; + kd.dtype = rad_kv_cache_dtype(ctx, RAD_BF16); + kd.n_head_kv = g.n_head_kv; + kd.head_dim = g.head_dim; + m.kv = rad_decl_kv_group(b, nm.f("kv_attn"), &kd); + if (!m.kv) return RAD_E_INVAL; + g.kv_dtype = rad_dtype_name(kd.dtype); + + const int64_t T = g.max_tok, E = g.n_embd, Q = g.q_dim(), K = g.kv_dim(), F = g.n_ff; + m.x = decl_b(b, nm.f("x"), RAD_F32, {T, E}); + m.delta = decl_b(b, nm.f("delta"), RAD_F32, {T, E}); + m.h = decl_b(b, nm.f("h"), RAD_BF16, {T, E}); + m.q = decl_b(b, nm.f("q"), RAD_BF16, {T, Q}); + m.k = decl_b(b, nm.f("k"), RAD_BF16, {T, K}); + m.v = decl_b(b, nm.f("v"), RAD_BF16, {T, K}); + m.gate = decl_b(b, nm.f("gate"), RAD_BF16, {T, g.n_head}); + m.attn = decl_b(b, nm.f("attn"), RAD_BF16, {T, Q}); + m.gu = decl_b(b, nm.f("gate_up"), RAD_BF16, {T, 2 * F}); + m.ff = decl_b(b, nm.f("ff"), RAD_BF16, {T, F}); + m.hout = decl_b(b, nm.f("h_out"), RAD_BF16, {g.max_logit_rows, E}); + m.logits = decl_b(b, nm.f("logits"), RAD_F32, {g.max_logit_rows, g.n_vocab}); + if (!m.x || !m.delta || !m.h || !m.q || !m.k || !m.v || !m.gate || !m.attn || !m.gu || !m.ff || + !m.hout || !m.logits) return RAD_E_INVAL; + RAD_ARCH_TRY(rad_declare_logits(b, m.logits)); + + /* ---- the drafter's taps, when the container carries a drafter and this serve speculates. + * Declared before the layer loop because the stream outlives it: the drafter's context pass + * runs after the trunk's, on the residual streams the trunk saved here. */ + bool drafter = false; + RAD_ARCH_TRY(drafter_kind(meta, &drafter)); + if (drafter && ctx->max_spec > 0) { + m.taps.read(meta, g.n_layer); + if (m.taps.n <= 0) { + fprintf(stderr, "radiance: spark25: the drafter names no trunk layer to read, or names " + "only layers past this target's last (`draft.target_layer_ids`)\n"); + return RAD_E_FORMAT; + } + RAD_ARCH_TRY(m.taps.declare(b, nm, g, g.max_tok, m.x)); + } + + auto weight = [&](const char* name, const char* src, uint32_t dt, + std::initializer_list shape, RadWeightGroup group, + int access = RAD_ACCESS_PER_TOKEN, int shard = RAD_SHARD_NONE) { + if (map_copy(b, name, src) != RAD_OK) return (rad_weight)0; + return decl_w(b, name, dt, shape, access, shard, group); + }; + m.tok = weight(nm.f("token_embd.weight"), nm.ckpt("model.embedding.weight"), RAD_BF16, + {g.n_vocab, E}, grp_model(), RAD_ACCESS_VOCAB, RAD_SHARD_ROW); + m.head = weight(nm.f("output.weight"), nm.ckpt("model.embedding.weight"), RAD_BF16, + {g.n_vocab, E}, grp_model(), RAD_ACCESS_VOCAB, RAD_SHARD_ROW); + m.norm = weight(nm.f("output_norm.weight"), nm.ckpt("model.norm.weight"), RAD_F32, + {E}, grp_model()); + if (!m.tok || !m.head || !m.norm) return RAD_E_INVAL; + if (g.world > 1 && g.n_vocab_all % g.world) { + RAD_ARCH_TRY(rad_weight_shard_span(b, m.tok, g.vocab_off, g.vocab_off + g.n_vocab)); + RAD_ARCH_TRY(rad_weight_shard_span(b, m.head, g.vocab_off, g.vocab_off + g.n_vocab)); + } + + auto norm = [&](rad_weight w, rad_buf x, rad_buf y) { + return rw(b, RAD_OP(b, "rmsnorm", RAD_PARAMS(RAD_RANGE("M", 1, T), RAD_INT("n", E), + RAD_F64("eps", g.eps), RAD_F64("wadd", 0.0), RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(w)), {x}, {y}); + }; + auto gemm = [&](int64_t n, int64_t k, rad_weight w, rad_buf x, rad_buf y) { + return rw(b, RAD_OP(b, "gemm_nt", RAD_PARAMS(RAD_RANGE("M", 1, T), RAD_INT("N", n), + RAD_INT("K", k), RAD_STR("dtype", "bf16")), RAD_WEIGHTS(w)), {x}, {y}); + }; + auto add = [&]() { + return rw(b, RAD_OP(b, "add", RAD_PARAMS(RAD_RANGE("M", 1, T), RAD_INT("n", E), + RAD_STR("dtype", "f32")), RAD_NOWEIGHTS), {m.x, m.delta}, {m.x}); + }; + m.embed = rw(b, RAD_OP(b, "embed_lookup", RAD_PARAMS(RAD_RANGE("M", 1, T), + RAD_INT("n_embd", E), RAD_INT("n_vocab", g.n_vocab), RAD_STR("dtype", "bf16"), + RAD_INT("vocab_offset", g.vocab_off)), RAD_WEIGHTS(m.tok)), {}, {m.h}); + auto widen = [&](rad_buf output) { + return rw(b, RAD_OP(b, "cast", RAD_PARAMS(RAD_RANGE("M", 1, T), RAD_INT("n", E), + RAD_STR("from", "bf16"), RAD_STR("to", "f32")), RAD_NOWEIGHTS), {m.h}, {output}); + }; + m.widen = widen(m.x); + /* Embedding shards contribute disjoint rows, so their widened sum is exact. Projection + * shards must instead reduce in bf16, rounding the merged output before it is widened and + * added to the f32 residual, as in the reference's BF16 linear layers. */ + auto reduce = [&](rad_buf x, const char* dtype) { + if (g.world <= 1) return (rad_op)0; + return rw(b, RAD_OP(b, "all_reduce", RAD_PARAMS(RAD_INT("world_size", g.world), + RAD_RANGE("numel", E, T * E), RAD_STR("dtype", dtype), RAD_INT("exact", 1)), + RAD_NOWEIGHTS), {x}, {x}); + }; + m.reduce_embed = reduce(m.x, "fp32"); + if (g.world > 1 && !m.reduce_embed) { + fprintf(stderr, "radiance: spark25 requires an exact fp32 all-reduce for TP=%d\n", g.world); + return RAD_E_UNSUPPORTED; + } + + m.layers.resize((size_t)g.n_layer); + for (int l = 0; l < g.n_layer; ++l) { + Layer& a = m.layers[(size_t)l]; + auto src = [&](const char* suffix) { return nm.ckpt("model.layers.%d.%s", l, suffix); }; + auto w = [&](const char* suffix, const char* s, uint32_t dt, + std::initializer_list shape, int shard = RAD_SHARD_NONE) { + return weight(nm.f("blk.%d.%s", l, suffix), src(s), dt, shape, grp_layer(l), + RAD_ACCESS_PER_TOKEN, shard); + }; + a.an = w("attn_norm.weight", "input_layernorm.weight", RAD_F32, {E}); + a.gate = w("attn_gate.weight", "self_attn.g_proj.weight", RAD_BF16, {g.n_head, E}, RAD_SHARD_ROW); + a.o = w("attn_output.weight", "self_attn.out_proj.weight", RAD_BF16, {E, Q}, RAD_SHARD_COL); + a.fn = w("ffn_norm.weight", "post_attention_layernorm.weight", RAD_F32, {E}); + a.down = w("ffn_down.weight", "mlp.down_proj.weight", RAD_BF16, {E, F}, RAD_SHARD_COL); + const char* qkv = src("self_attn.q_k_v_proj.weight"); + auto part = [&](const char* name, int first, int64_t all_rows, int64_t rows) { + const char* target = nm.f("blk.%d.attn_%s.weight", l, name); + if (map_rows(b, target, {{qkv, first, all_rows}}) != RAD_OK) return (rad_weight)0; + return decl_w(b, target, RAD_BF16, {rows, E}, RAD_ACCESS_PER_TOKEN, RAD_SHARD_ROW, + grp_layer(l)); + }; + const int64_t qall = g.n_head_all * g.head_dim, kall = g.n_head_kv_all * g.head_dim; + a.q = part("q", 0, qall, Q); + a.k = part("k", (int)qall, kall, K); + a.v = part("v", (int)(qall + kall), kall, K); + const char* gu = nm.f("blk.%d.ffn_gate_up.weight", l); + RAD_ARCH_TRY(map_concat(b, gu, {src("mlp.gate_proj.weight"), src("mlp.up_proj.weight")})); + a.gu = decl_w(b, gu, RAD_BF16, {2 * F, E}, RAD_ACCESS_PER_TOKEN, RAD_SHARD_ROW, + grp_layer(l), 0, {F, F}); + if (!a.an || !a.q || !a.k || !a.v || !a.gate || !a.o || !a.fn || !a.gu || !a.down) + return RAD_E_INVAL; + if (g.world > 1 && needs_span(shards.q, g.n_head_all, g)) { + RAD_ARCH_TRY(rad_weight_shard_span(b, a.q, shards.q.first * g.head_dim, + (shards.q.first + shards.q.count) * g.head_dim)); + RAD_ARCH_TRY(rad_weight_shard_span(b, a.gate, shards.q.first, + shards.q.first + shards.q.count)); + RAD_ARCH_TRY(rad_weight_shard_span(b, a.o, shards.q.first * g.head_dim, + (shards.q.first + shards.q.count) * g.head_dim)); + } + if (g.world > 1 && needs_span(shards.kv, g.n_head_kv_all, g)) { + for (rad_weight h : {a.k, a.v}) + RAD_ARCH_TRY(rad_weight_shard_span(b, h, shards.kv.first * g.head_dim, + (shards.kv.first + shards.kv.count) * g.head_dim)); + } + if (g.world > 1 && needs_span(shards.ff, g.n_ff_all, g)) { + for (rad_weight h : {a.gu, a.down}) + RAD_ARCH_TRY(rad_weight_shard_span(b, h, shards.ff.first, + shards.ff.first + shards.ff.count)); + } + a.kv = m.kv; + RAD_ARCH_TRY(rad_bind_layer_kv(b, l, a.kv)); + a.anorm = norm(a.an, m.x, m.h); + a.qp = gemm(Q, E, a.q, m.h, m.q); + a.kp = gemm(K, E, a.k, m.h, m.k); + a.vp = gemm(K, E, a.v, m.h, m.v); + a.gp = gemm(g.n_head, E, a.gate, m.h, m.gate); + Geom rope = g; + const int kind = local[(size_t)l] ? 1 : 0; + rope.theta = (float)theta[kind]; + a.rq = rw(b, decl_rope(b, rope, T, g.head_dim, g.n_head, 0, rot[kind], "neox"), {m.q}, {m.q}); + a.rk = rw(b, decl_rope(b, rope, T, g.head_dim, g.n_head_kv, 0, rot[kind], "neox"), {m.k}, {m.k}); + a.attn = rw(b, decl_attn(b, g, "attn_paged", + RAD_PARAMS(RAD_RANGE("q_len", 1, T), RAD_INT("head_dim", g.head_dim), + RAD_INT("gqa", g.gqa()), RAD_INT("causal", 1), RAD_INT("window", kind ? window : 0), + RAD_INT("n_head", g.n_head), RAD_INT("block_size", RAD_KV_BLOCK), + RAD_INT("max_seqs", g.max_seqs), RAD_INT("max_ctx", g.max_ctx), + RAD_STR("q_dtype", "bf16"), RAD_STR("kv_dtype", g.kv_dtype)), RAD_NOWEIGHTS), + {m.q}, {m.attn}); + a.store = rw(b, RAD_OP(b, "kv_store", RAD_PARAMS(RAD_RANGE("M", 1, T), + RAD_INT("head_dim", g.head_dim), RAD_INT("n_head_kv", g.n_head_kv), + RAD_INT("block_size", rad_kv_block_size(b, a.kv)), RAD_STR("kv_dtype", g.kv_dtype)), + RAD_NOWEIGHTS), {m.k, m.v}, {}); + a.sigmoid = rw(b, RAD_OP(b, "sigmoid", RAD_PARAMS(RAD_RANGE("M", 1, T), + RAD_INT("n", g.n_head), RAD_STR("dtype", "bf16")), RAD_NOWEIGHTS), {m.gate}, {m.gate}); + /* View dense [tokens, heads * dim] and [tokens, heads] as one row per head. */ + a.gate_heads = rw(b, RAD_OP(b, "scale_rows", RAD_PARAMS(RAD_RANGE("M", 1, T * g.n_head), + RAD_INT("n", g.head_dim), RAD_STR("act", "none"), RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), {m.attn, m.gate}, {m.attn}); + a.op = gemm(E, Q, a.o, m.attn, m.h); + a.reduce_attn = reduce(m.h, "bf16"); + a.widen_attn = widen(m.delta); + a.add_attn = add(); + a.fnorm = norm(a.fn, m.x, m.h); + a.gup = gemm(2 * F, E, a.gu, m.h, m.gu); + a.act = rw(b, RAD_OP(b, "act_mul", RAD_PARAMS(RAD_RANGE("M", 1, T), RAD_INT("n", F), + RAD_STR("act", "gelu"), RAD_STR("dtype", "bf16")), RAD_NOWEIGHTS), {m.gu}, {m.ff}); + a.dp = gemm(E, F, a.down, m.ff, m.h); + a.reduce_ffn = reduce(m.h, "bf16"); + if (g.world > 1 && (!a.reduce_attn || !a.reduce_ffn)) { + fprintf(stderr, "radiance: spark25 requires exact bf16 all-reduces for TP=%d\n", g.world); + return RAD_E_UNSUPPORTED; + } + a.widen_ffn = widen(m.delta); + a.add_ffn = add(); + if (m.tap_live && l >= m.calib_lo && l < m.calib_hi) { + RAD_ARCH_TRY(a.tap_in.declare(b, nm, T, nm.f("blk.%d.attn_in", l), m.h, E)); + RAD_ARCH_TRY(a.tap_o.declare(b, nm, T, nm.f("blk.%d.attn_o", l), m.attn, Q)); + RAD_ARCH_TRY(a.tap_gu.declare(b, nm, T, nm.f("blk.%d.ffn_in", l), m.h, E)); + RAD_ARCH_TRY(a.tap_down.declare(b, nm, T, nm.f("blk.%d.ffn_down_in", l), m.ff, F)); + } + } + m.final_norm = norm(m.norm, m.x, m.h); + m.gather = rw(b, RAD_OP(b, "gather_rows", RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows), + RAD_INT("n", E), RAD_STR("dtype", "bf16")), RAD_NOWEIGHTS), {m.h}, {m.hout}); + m.logits_op = rw(b, RAD_OP(b, "logits_gemm", RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows), + RAD_INT("n_vocab", g.n_vocab), RAD_INT("n_embd", E), RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(m.head)), {m.hout}, {m.logits}); + char ids[128] = ""; + /* The drafter is declared last, after the head. The buffer planner takes lifetimes in + * declaration order, and a drafter's passes run after the whole trunk's, so declaring it in the + * middle would let a trunk temporary be planned onto bytes the drafter is still reading. */ + if (m.taps.n > 0) { + RAD_ARCH_TRY(declare_dspark(&m.ds, &m.dsw, &m.kv_draft, b, nm, meta, ctx, g, m.taps, + (int)g.n_layer, m.tok, nm.ckpt("model.embedding.weight"))); + m.have_ds = true; + for (int t = 0, off = 0; t < m.taps.n && off < (int)sizeof(ids) - 8; ++t) + off += std::snprintf(ids + off, sizeof ids - off, "%s%d", t ? ", " : "", + m.taps.layer[t]); + rad_note(b, "the drafter reads the residual stream after layer(s) %s", ids); + } + + rad_note(b, "spark25 rank %d/%d: %lld layers, %lld query / %lld KV heads x %lld, " + "FFN %lld, vocab [%lld, %lld), local window %lld", g.rank, g.world, + (long long)g.n_layer, (long long)g.n_head, (long long)g.n_head_kv, + (long long)g.head_dim, (long long)g.n_ff, (long long)g.vocab_off, + (long long)(g.vocab_off + g.n_vocab), (long long)window); + return RAD_OK; +} + +static void step(RadCtx* c, const RadBatch* batch) { + Model& m = models[rad_rank(c)]; + const Geom& g = m.g; + /* A drafter pass; the sign gives the kind. Positive is the query pass, which denoises the whole + * block and proposes from it; negative is the context pass, which turns the tokens the trunk + * just committed into the drafter's own K and V. Zero is a trunk step. */ + if (batch->draft_pass != 0) { + if (!m.have_ds) { + rad_step_fail(c, "the batch asks for a drafter pass and no drafter is declared: the " + "container carries no `draft.` block, or declare ran at max_spec 0"); + return; + } + if (batch->draft_pass > 0) m.ds.step(c, batch); + else m.ds.context(c, batch); + return; + } + const int64_t T = batch->n_tok; + const RadOperand pos = praw(batch->positions, RAD_I32, T); + RAD_ISSUE(c, m.embed, praw(batch->token_ids, RAD_I32, T), RAD_W(m.tok), brows(m.h, T)); + RAD_ISSUE(c, m.widen, brows(m.h, T), brows(m.x, T)); + if (m.reduce_embed) RAD_ISSUE_N(c, m.reduce_embed, T * g.n_embd, brows(m.x, T), RAD_NONE); + for (size_t i = 0; i < m.layers.size(); ++i) { + const Layer& a = m.layers[i]; + const RadKVGroupBatch* kvb = kv_batch(batch, a.kv); + const int32_t* slot = kvb ? kvb->slot_mapping : nullptr; + const int32_t* table = kvb ? kvb->block_table : nullptr; + const int32_t* used = kvb ? kvb->seqused : nullptr; + RAD_ISSUE(c, a.anorm, brows(m.x, T), RAD_W(a.an), brows(m.h, T)); + RAD_ISSUE(c, a.qp, brows(m.h, T), RAD_W(a.q), brows(m.q, T)); + RAD_ISSUE(c, a.kp, brows(m.h, T), RAD_W(a.k), brows(m.k, T)); + RAD_ISSUE(c, a.vp, brows(m.h, T), RAD_W(a.v), brows(m.v, T)); + RAD_ISSUE(c, a.gp, brows(m.h, T), RAD_W(a.gate), brows(m.gate, T)); + a.tap_in.step(c, m.h, T, m.tap_live); + RAD_ISSUE(c, a.rq, brows(m.q, T), pos); + RAD_ISSUE(c, a.rk, brows(m.k, T), pos); + RAD_ISSUE(c, a.store, brows(m.k, T), brows(m.v, T), praw(slot, RAD_I32, T), + kv_cache(a.kv, (int)i)); + RAD_ISSUE_N(c, a.attn, batch->max_q_len, brows(m.q, T), kv_cache(a.kv, (int)i), + praw2(table, RAD_I32, batch->n_seq, kvb ? kvb->block_table_pitch : 0), + praw(used, RAD_I32, batch->n_seq), RAD_NONE, RAD_NONE, + praw(batch->cu_seqlens, RAD_I32, batch->n_seq + 1), brows(m.attn, T)); + RAD_ISSUE(c, a.sigmoid, brows(m.gate, T), brows(m.gate, T)); + const RadOperand heads = RAD_P_T2(rad_buf_ptr(c, m.attn), RAD_BF16, T * g.n_head, g.head_dim); + const RadOperand gates = RAD_P_T2(rad_buf_ptr(c, m.gate), RAD_BF16, T * g.n_head, 1); + RAD_ISSUE_N(c, a.gate_heads, T * g.n_head, heads, gates, RAD_NONE, heads); + a.tap_o.step(c, m.attn, T, m.tap_live); + RAD_ISSUE(c, a.op, brows(m.attn, T), RAD_W(a.o), brows(m.h, T)); + if (a.reduce_attn) RAD_ISSUE_N(c, a.reduce_attn, T * g.n_embd, brows(m.h, T), RAD_NONE); + RAD_ISSUE(c, a.widen_attn, brows(m.h, T), brows(m.delta, T)); + RAD_ISSUE(c, a.add_attn, brows(m.x, T), brows(m.delta, T), brows(m.x, T)); + RAD_ISSUE(c, a.fnorm, brows(m.x, T), RAD_W(a.fn), brows(m.h, T)); + RAD_ISSUE(c, a.gup, brows(m.h, T), RAD_W(a.gu), brows(m.gu, T)); + a.tap_gu.step(c, m.h, T, m.tap_live); + RAD_ISSUE(c, a.act, bcol(m.gu, 0, g.n_ff, T), bcol(m.gu, g.n_ff, g.n_ff, T), brows(m.ff, T)); + a.tap_down.step(c, m.ff, T, m.tap_live); + RAD_ISSUE(c, a.dp, brows(m.ff, T), RAD_W(a.down), brows(m.h, T)); + if (a.reduce_ffn) RAD_ISSUE_N(c, a.reduce_ffn, T * g.n_embd, brows(m.h, T), RAD_NONE); + RAD_ISSUE(c, a.widen_ffn, brows(m.h, T), brows(m.delta, T)); + RAD_ISSUE(c, a.add_ffn, brows(m.x, T), brows(m.delta, T), brows(m.x, T)); + /* The tap after this layer, on prefill and decode alike: the drafter conditions on every + * committed token's residual stream, not only on prefill's. */ + m.taps.step(c, m.x, T, (int64_t)i, g.n_embd); + } + RAD_ISSUE(c, m.final_norm, brows(m.x, T), RAD_W(m.norm), brows(m.h, T)); + if (batch->n_out > 0) { + RAD_ISSUE_N(c, m.gather, batch->n_out, brows(m.h, T), + praw(batch->out_ids, RAD_I32, batch->n_out), brows(m.hout, batch->n_out)); + RAD_ISSUE_N(c, m.logits_op, batch->n_out, brows(m.hout, batch->n_out), RAD_W(m.head), + brows(m.logits, batch->n_out)); + } + if (m.tap_live) { + m.calib_rows += T; + if (m.calib_rows >= calib_target()) { + bool ok = true; + for (int64_t l = m.calib_lo; l < m.calib_hi; ++l) { + const Layer& a = m.layers[(size_t)l]; + char stem[96]; + for (const char* proj : {"attn_q", "attn_k", "attn_v"}) { + std::snprintf(stem, sizeof stem, "blk.%lld.%s", (long long)l, proj); + ok = calib_write(c, a.tap_in.h, a.tap_in.K, m.calib_rows, stem, 0) && ok; + } + std::snprintf(stem, sizeof stem, "blk.%lld.attn_output", (long long)l); + ok = calib_write(c, a.tap_o.h, a.tap_o.K, m.calib_rows, stem, 0) && ok; + std::snprintf(stem, sizeof stem, "blk.%lld.ffn_gate_up", (long long)l); + ok = calib_write(c, a.tap_gu.h, a.tap_gu.K, m.calib_rows, stem, 0) && ok; + std::snprintf(stem, sizeof stem, "blk.%lld.ffn_down", (long long)l); + ok = calib_write(c, a.tap_down.h, a.tap_down.K, m.calib_rows, stem, 0) && ok; + } + m.tap_live = false; + std::fprintf(stderr, "radiance: spark25 rank %d wrote calibration Grams for layers " + "%lld:%lld after %lld tokens to %s%s\n", rad_rank(c), + (long long)m.calib_lo, (long long)m.calib_hi, m.calib_rows, calib_dir(), + ok ? "" : ", with errors"); + } + } +} + +#ifdef SPARK25_HAVE_PREFILL_SPLIT +static uint64_t pass_key(RadCtx* c, const RadBatch* batch, const int32_t* used_max_h) { + if (!c || !batch) return 0; + Model& m = models[rad_rank(c)]; + int group = -1; + if (batch->kv) for (int i = 0; i < batch->n_kv_groups; ++i) + if (batch->kv[i].group == m.kv) { group = i; break; } + spark25_prefill_key::Request r; + r.phase = batch->phase; + r.n_tok = batch->n_tok; + r.n_seq = batch->n_seq; + r.max_q_len = batch->max_q_len; + r.max_ctx = m.g.max_ctx; + r.n_spec = batch->n_spec; + r.draft_pass = batch->draft_pass; + r.enc = batch->enc != 0; + r.head_dim = m.g.head_dim; + r.gqa = m.g.gqa(); + r.kv_heads = m.g.n_head_kv; + r.kv_group_found = group >= 0; + r.used = used_max_h && group >= 0 ? used_max_h[group] : 0; + r.wgps = rad_ctx_wgp_count(c); + return spark25_prefill_key::pass_key(r); +} +#endif + +/* The speculation depth this container supports: zero without a drafter, or the block length a + * DSpark drafter was trained at. `draft_depth_fixed` because a block-diffusion drafter denoises + * exactly that many mask positions, and `declare` refuses to run it at any other depth. */ +static int probe(const RadModelMeta* meta, RadArchProbe* out) { + if (!meta || !out) return RAD_E_INVAL; + out->draft_depth = 0; + out->draft_depth_fixed = 0; + bool present = false; + if (drafter_kind(meta, &present) != RAD_OK) return RAD_E_UNSUPPORTED; + if (!present) return RAD_OK; + const long long bs = rad_meta_geti(meta, "draft.block_size", 0); + if (bs < 2) { + fprintf(stderr, "radiance: spark25: the container carries a drafter with no " + "draft.block_size\n"); + return RAD_E_FORMAT; + } + out->draft_depth = (int)bs; + out->draft_depth_fixed = 1; + return RAD_OK; +} + +static const RadChatFormat* chat_format(const RadModelMeta*) { return spark_chat_format(); } +} +#ifndef RAD_ARCH_NO_EXPORTS +RAD_ARCH_PROBE(spark25_bf16) +RAD_ARCH_PLUGIN(spark25_bf16, "spark25", "", "0.1.0", "Spark X2.6 BF16") +RAD_ARCH_CHAT_FORMAT(spark25_bf16) +#ifdef SPARK25_HAVE_PREFILL_SPLIT +extern "C" uint64_t rad_arch_pass_key(RadCtx* c, const RadBatch* batch, + const int32_t* used_max_h) { + return spark25_bf16::pass_key(c, batch, used_max_h); +} +#endif +#endif diff --git a/arch/spark25_bf16/spark25_prefill_pass_key.h b/arch/spark25_bf16/spark25_prefill_pass_key.h new file mode 100644 index 00000000..a733f4ca --- /dev/null +++ b/arch/spark25_bf16/spark25_prefill_pass_key.h @@ -0,0 +1,67 @@ +/* Spark's prefill pass-key geometry. Keep this host-pure and mirror the h256/GQA4 + * R4D launcher exactly; unsupported batches fail closed. */ +#pragma once + +#include + +#if defined(__has_include) +# if __has_include() +# include +# define SPARK25_HAVE_PREFILL_SPLIT 1 +# endif +#endif + +namespace spark25_prefill_key { + +constexpr int kNwarps = 24; +constexpr int kTile = 48; +constexpr int kGqa = 4; +constexpr int kHeadDim = 256; +constexpr int kBq = kNwarps * 16 / kGqa; +constexpr int kThreads = kNwarps * 32; +constexpr int kDecodeRowCap = 64; +constexpr int kPhasePrefill = 0; +constexpr int kPhaseDecode = 1; +constexpr int kPhaseMixed = 2; + +static_assert(kBq == 96, "Spark GQA4 prefill BQ must match the R4D launcher"); +static_assert(kThreads == 768, "Spark prefill launcher uses 768 threads"); + +struct Request { + int phase = kPhasePrefill; + int64_t n_tok = 0, n_seq = 0, max_q_len = 0, max_ctx = 0; + int64_t n_spec = 0, draft_pass = 0; + int enc = 0; + int64_t head_dim = 0, gqa = 0, kv_heads = 0; + int kv_group_found = 0, used = 0, wgps = 0; +}; + +#ifdef SPARK25_HAVE_PREFILL_SPLIT +inline uint64_t pass_key(const Request& r) { + if (r.enc) return 1; + if (r.draft_pass != 0) return 0; + /* Mixed and speculative passes can launch attention on sub-batches whose exact geometry + * is not represented by the whole-batch summary. */ + if (r.phase == kPhaseMixed || r.n_spec > 0) return 0; + if (r.phase != kPhasePrefill) return 1; + if (r.head_dim != kHeadDim || r.gqa != kGqa || r.kv_heads <= 0 || !r.kv_group_found) + return 0; + /* For a singleton, these equalities prove the R4D q_len band and total_q used by its launch. + * Do not infer geometry for multi-sequence/ragged batches. */ + if (r.n_seq != 1 || r.n_tok <= 0 || r.max_q_len != r.n_tok || r.max_ctx <= 0 || + r.used <= 0 || r.wgps <= 0) + return 0; + /* The short-query path resolves to the decode launcher, with a different split law. */ + if (r.max_q_len * r.gqa <= kDecodeRowCap) return 0; + + const int q_len = (int)r.max_q_len; + const int splits = rad_prefill_splits_for_live(kBq, kTile, q_len, (int)r.n_tok, 1, + (int)r.kv_heads, (int)r.max_ctx, r.used, + r.wgps); + return rad_prefill_grid_key(q_len, kBq, splits, (int)r.kv_heads, 1, kThreads); +} +#else +inline uint64_t pass_key(const Request&) { return 0; } +#endif + +} // namespace spark25_prefill_key diff --git a/arch/spark25_w8a8/CMakeLists.txt b/arch/spark25_w8a8/CMakeLists.txt new file mode 100644 index 00000000..d1f35447 --- /dev/null +++ b/arch/spark25_w8a8/CMakeLists.txt @@ -0,0 +1,9 @@ +# Built in tree or against an installed radiance. +if(NOT COMMAND rad_add_plugin) + cmake_minimum_required(VERSION 3.21) + project(spark25_w8a8 LANGUAGES CXX) + find_package(radiance REQUIRED) + rad_plugin_defaults() +endif() + +rad_add_plugin(spark25_w8a8 architectures SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/spark25_w8a8.cpp) diff --git a/arch/spark25_w8a8/spark25_w8a8.cpp b/arch/spark25_w8a8/spark25_w8a8.cpp new file mode 100644 index 00000000..27c43645 --- /dev/null +++ b/arch/spark25_w8a8/spark25_w8a8.cpp @@ -0,0 +1,682 @@ +/* Spark X2.6 (Spark2_5ForCausalLM), rotated int8 weights and activations. + * + * The checkpoint has one [q | k | v] projection per layer. Conversion splits its rows into + * contiguous matrices because paged attention needs a contiguous query. The MLP's two matrices + * are concatenated as [gate | up]; act_mul with exact erf GELU matches the reference, unlike + * gelu_mul (which is the tanh approximation). The attention gate is one sigmoid per head, not + * per channel. Local and full layers have different NeoX rotary dimensions and theta values. + * + * Tensor parallelism splits attention by whole KV groups, replicating KV heads when ranks + * outnumber them. As in the HF reference, residuals accumulate in f32; rmsnorm reads that stream + * and writes bf16 for the linear projections. + * + * A container built with `--draft-model` also carries a DSpark drafter, which reads the residual + * stream after the trunk layers its config names and denoises a block of masked positions in one + * pass. The drafter itself is bf16 whatever the trunk's quantisation (arch/rad_block_dspark_bf16.h + * says why); the trunk's part is the taps and the drafter pass dispatch below. + */ +#include +#include +#include +#include "../spark25_bf16/chat.h" +#include "../spark25_bf16/spark25_prefill_pass_key.h" + +#include +#include +#include +#include +#include + +namespace spark25_w8a8 { +using namespace rad::arch; + +struct Layer { + rad_kvgroup kv = 0; + rad_weight an = 0, gate = 0, fn = 0; + LinearFP8 q{}, k{}, v{}, o{}, gu{}, down{}; + rad_op anorm = 0, gp = 0, rq = 0, rk = 0, store = 0, attn = 0; + rad_op sigmoid = 0, gate_heads = 0, widen_attn = 0, reduce_attn = 0, add_attn = 0; + rad_op fnorm = 0, act = 0, widen_ffn = 0, reduce_ffn = 0, add_ffn = 0; + CalibTap tap_in{}, tap_o{}, tap_gu{}, tap_down{}; +}; + +struct Model { + Names nm{""}; + Geom g{}; + rad_kvgroup kv = 0; + rad_buf x = 0, delta = 0, h = 0, q = 0, k = 0, v = 0, gate = 0, attn = 0, gu = 0, ff = 0; + rad_buf hout = 0, logits = 0; + ActFP8 a_h{}, a_attn{}, a_ff{}; + rad_weight tok = 0, norm = 0, head = 0; + rad_op embed = 0, widen = 0, reduce_embed = 0, had = 0, final_norm = 0, gather = 0, logits_op = 0; + std::vector layers; + bool tap_live = false; + long long calib_rows = 0; + int64_t calib_lo = 0, calib_hi = 0; + /* The drafter, declared only when the container carries one and this serve speculates. Its own + * KV group holds the context it derived from the trunk's taps. */ + DsparkBF16 ds{}; + DsparkBF16::Wire dsw{}; + DsparkTaps taps{}; + rad_kvgroup kv_draft = 0; + bool have_ds = false; +}; +static Model models[MAX_RANKS]; + +/* Whether the container carries a drafter at all (`--draft-model` merged one under `draft.`), and + * whether this file implements it. A drafter this plugin cannot run is refused at declare rather + * than left unused: the container would serve at the speed of a model with no drafter, and the + * user would have no way to find out that the flag they passed did nothing. */ +static int drafter_kind(const RadModelMeta* meta, bool* present) { + *present = false; + const char* da = rad_meta_gets(meta, "draft.architectures", ""); + if (!da || !*da) { + /* A drafter's config.json flattened, or a GGUF import, either of which names it. */ + if (rad_meta_geti(meta, "draft.num_hidden_layers", 0) <= 0) return RAD_OK; + da = rad_meta_gets(meta, "draft.model_type", ""); + } + if (std::strstr(da, "DSpark") || std::strcmp(da, "dspark") == 0) { + *present = true; + return RAD_OK; + } + *present = true; + fprintf(stderr, "radiance: spark25: this container carries a '%s' drafter. Spark's drafts are " + "DSpark, with a rank-N Markov head over the target's own table; this " + "architecture implements that and nothing else\n", da); + return RAD_E_UNSUPPORTED; +} + +/* The HF config names every layer. Do not infer a periodic schedule: it changes the mask and + * rotary of a layer and would silently produce a different model. */ +static int schedule(const RadModelMeta* meta, int64_t n, std::vector& local) { + const char* s = rad_meta_gets(meta, "layer_types", nullptr); + if (!s) { + fprintf(stderr, "radiance: spark25: layer_types is required\n"); + return RAD_E_INVAL; + } + std::istringstream in(s); + std::string word; + while (in >> word) { + if (word != "sliding_attention" && word != "full_attention") { + fprintf(stderr, "radiance: spark25: unknown layer type '%s'\n", word.c_str()); + return RAD_E_UNSUPPORTED; + } + local.push_back(word == "sliding_attention"); + } + if ((int64_t)local.size() != n) { + fprintf(stderr, "radiance: spark25: layer_types has %zu entries for %lld layers\n", + local.size(), (long long)n); + return RAD_E_INVAL; + } + return RAD_OK; +} + +struct Span { + int64_t first = 0, count = 0; +}; + +/* Remainder-first contiguous slices, in whole units. */ +static Span split(int64_t n, int parts, int rank) { + const int64_t base = n / parts, rem = n % parts; + return {base * rank + std::min(rank, rem), base + (rank < rem ? 1 : 0)}; +} + +struct Shards { + Span q, kv, ff; /* q and kv in heads; ff in channels */ +}; + +/* A rank's attention heads must describe whole GQA groups, or a slice of a single group with + * that group's KV head replicated. This also covers non-divisible worlds such as 3 ranks over + * the checkpoint's 4 KV heads. Projection and FFN spans below give the loader those exact cuts. */ +static int shard_geometry(Geom& g, const RadBuildCtx* ctx, Shards& s) { + g.world = ctx->world_size > 0 ? ctx->world_size : 1; + g.rank = ctx->rank; + if (g.rank >= g.world || g.world > g.n_head_all || g.n_head_kv_all <= 0 || + g.n_head_all % g.n_head_kv_all || g.world > g.n_ff_all) { + fprintf(stderr, "radiance: spark25: cannot shard %lld query heads, %lld KV heads and " + "%lld FFN channels over %d ranks\n", (long long)g.n_head_all, + (long long)g.n_head_kv_all, (long long)g.n_ff_all, g.world); + return RAD_E_INVAL; + } + const int64_t group = g.n_head_all / g.n_head_kv_all; + if (g.world <= g.n_head_kv_all) { + s.kv = split(g.n_head_kv_all, g.world, g.rank); + s.q = {s.kv.first * group, s.kv.count * group}; + } else { + int first_rank = 0; + for (int64_t k = 0; k < g.n_head_kv_all; ++k) { + const int n = (int)split(g.world, (int)g.n_head_kv_all, (int)k).count; + if (g.rank < first_rank + n) { + const Span q = split(group, n, g.rank - first_rank); + s.kv = {k, 1}; + s.q = {k * group + q.first, q.count}; + break; + } + first_rank += n; + } + } + /* Prefer whole 128-channel blocks for a ragged split, keeping device GEMMs aligned. */ + const int64_t unit = g.n_ff_all % 128 == 0 && g.n_ff_all / 128 >= g.world ? 128 : 1; + s.ff = split(g.n_ff_all / unit, g.world, g.rank); + s.ff.first *= unit; + s.ff.count *= unit; + g.n_head = s.q.count; + g.n_head_kv = s.kv.count; + g.n_ff = s.ff.count; + g.n_vocab = shard_extent(g.n_vocab_all, g.world, g.rank); + g.vocab_off = shard_begin(g.n_vocab_all, g.world, g.rank); + return g.n_head > 0 && g.n_head_kv > 0 && g.n_ff > 0 && g.n_vocab > 0 ? RAD_OK : RAD_E_INVAL; +} + +static bool needs_span(const Span& s, int64_t total, const Geom& g) { + return total % g.world != 0 || s.first != g.rank * (total / g.world) || + s.count != total / g.world; +} + +static int check_format(const RadModelMeta* meta) { + const char* method = rad_meta_gets(meta, "quantization_config.quant_method", nullptr); + const char* fmt = rad_meta_gets(meta, "quantization_config.fmt", nullptr); + if (!method || std::strcmp(method, "w8a8") != 0 || !fmt || std::strcmp(fmt, "fwht128") != 0) { + fprintf(stderr, "radiance: spark25_w8a8 serves a rotated int8 trunk (quant_method " + "'w8a8', fmt 'fwht128'); this container says '%s' / '%s'\n", + method ? method : "(none)", fmt ? fmt : "(none)"); + return RAD_E_UNSUPPORTED; + } + return RAD_OK; +} + +static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* ctx) { + if (!b || !meta || !ctx || ctx->rank < 0 || ctx->rank >= MAX_RANKS) return RAD_E_INVAL; + RAD_ARCH_TRY(check_format(meta)); + Model& m = models[ctx->rank]; + m = Model{}; + m.nm = Names(ctx->scope); + /* geom_from's even-only split cannot express a ragged GQA/FFN world. Read the whole geometry, + * then give each rank a group-preserving shard and state its spans on the weights. */ + RadBuildCtx whole = *ctx; + whole.rank = 0; + whole.world_size = 1; + RAD_ARCH_TRY(geom_from(m.g, meta, &whole, "bf16", RAD_BF16)); + Geom& g = m.g; + Shards shards; + RAD_ARCH_TRY(shard_geometry(g, ctx, shards)); + /* A column-sharded int8 linear slices its input's scale groups, so every rank's + * feed-forward span must be whole 128-column groups. shard_geometry prefers whole blocks + * even for ragged worlds such as TP=3; refuse a geometry that cannot be split that way. */ + if (g.world > 1 && shards.ff.count % RAD_FP8_BLOCK) { + fprintf(stderr, "radiance: spark25_w8a8 cannot shard %lld FFN channels over %d ranks: a " + "rank's %lld are not whole %d-column scale groups. An int8 down projection " + "sliced inside a group would read its scale plane at the wrong width\n", + (long long)g.n_ff_all, g.world, (long long)shards.ff.count, RAD_FP8_BLOCK); + return RAD_E_UNSUPPORTED; + } + Names& nm = m.nm; + if (g.n_head_kv <= 0 || g.n_head % g.n_head_kv || g.head_dim % 2 || meta->n_expert || + rad_meta_geti(meta, "attention_bias", 0) || rad_meta_geti(meta, "mlp_bias", 0) || + !rad_meta_geti(meta, "tie_word_embeddings", 0) || + !rad_meta_geti(meta, "headwise_attn_output_gate", 0) || + std::strcmp(rad_meta_gets(meta, "gate_attn_act_mode", "sigmoid"), "sigmoid") || + std::strcmp(rad_meta_gets(meta, "hidden_act", "gelu"), "gelu")) { + fprintf(stderr, "radiance: spark25: requires a dense, bias-free, tied model with headwise " + "sigmoid gates, exact GELU and divisible attention heads\n"); + return RAD_E_UNSUPPORTED; + } + /* A single global override cannot describe this model's two rotary ladders. */ + RAD_ARCH_TRY(yarn_from(g, meta, "", g.head_dim)); + if (g.yarn.factor != 0.0f || g.rope_scale != 1.0f || g.rope_mc) { + fprintf(stderr, "radiance: spark25: rotary scaling overrides are not supported\n"); + return RAD_E_UNSUPPORTED; + } + std::vector local; + RAD_ARCH_TRY(schedule(meta, g.n_layer, local)); + if (calib_dir()) { + if (g.world != 1) { + fprintf(stderr, "radiance: spark25 calibration requires one rank so column-split " + "Grams retain their cross terms\n"); + return RAD_E_UNSUPPORTED; + } + RAD_ARCH_TRY(calib_layers("spark25", "RADIANCE_SPARK_CALIB_LAYERS", g.n_layer, + &m.calib_lo, &m.calib_hi)); + m.tap_live = true; + } + const int64_t window = rad_meta_geti(meta, "sliding_window", 0); + if (window <= 0) { + fprintf(stderr, "radiance: spark25: a positive sliding_window is required\n"); + return RAD_E_INVAL; + } + double theta[2]{}; + int64_t rot[2]{}; + const char* kinds[] = {"full_attention", "sliding_attention"}; + for (int j = 0; j < 2; ++j) { + theta[j] = rad_meta_getf(meta, nm.f("rope_parameters.%s.rope_theta", kinds[j]), 10000.0); + const double factor = rad_meta_getf(meta, + nm.f("rope_parameters.%s.partial_rotary_factor", kinds[j]), 1.0); + const char* type = rad_meta_gets(meta, nm.f("rope_parameters.%s.rope_type", kinds[j]), "default"); + if (std::strcmp(type, "default")) { + fprintf(stderr, "radiance: spark25: %s rotary type '%s' is not supported\n", kinds[j], type); + return RAD_E_UNSUPPORTED; + } + const double r = g.head_dim * factor; + if (!std::isfinite(theta[j]) || !(theta[j] > 0) || !(factor > 0 && factor <= 1) || !std::isfinite(r) || + std::floor(r) != r || (int64_t)r % 2) { + fprintf(stderr, "radiance: spark25: invalid %s rotary theta %g or factor %g\n", + kinds[j], theta[j], factor); + return RAD_E_INVAL; + } + rot[j] = (int64_t)r; + } + + /* A full cache for both kinds keeps prefix caching valid. The local attention op enforces + * its own window (q - k < window); the full layers read all past positions. */ + RadKVGroupDecl kd{}; + kd.kind = RAD_KV_FULL; + kd.dtype = rad_kv_cache_dtype(ctx, RAD_BF16); + kd.n_head_kv = g.n_head_kv; + kd.head_dim = g.head_dim; + m.kv = rad_decl_kv_group(b, nm.f("kv_attn"), &kd); + if (!m.kv) return RAD_E_INVAL; + g.kv_dtype = rad_dtype_name(kd.dtype); + + const int64_t T = g.max_tok, E = g.n_embd, Q = g.q_dim(), K = g.kv_dim(), F = g.n_ff; + m.x = decl_b(b, nm.f("x"), RAD_F32, {T, E}); + m.delta = decl_b(b, nm.f("delta"), RAD_F32, {T, E}); + m.h = decl_b(b, nm.f("h"), RAD_BF16, {T, E}); + m.q = decl_b(b, nm.f("q"), RAD_BF16, {T, Q}); + m.k = decl_b(b, nm.f("k"), RAD_BF16, {T, K}); + m.v = decl_b(b, nm.f("v"), RAD_BF16, {T, K}); + m.gate = decl_b(b, nm.f("gate"), RAD_BF16, {T, g.n_head}); + m.attn = decl_b(b, nm.f("attn"), RAD_BF16, {T, Q}); + m.gu = decl_b(b, nm.f("gate_up"), RAD_BF16, {T, 2 * F}); + m.ff = decl_b(b, nm.f("ff"), RAD_BF16, {T, F}); + m.hout = decl_b(b, nm.f("h_out"), RAD_BF16, {g.max_logit_rows, E}); + m.logits = decl_b(b, nm.f("logits"), RAD_F32, {g.max_logit_rows, g.n_vocab}); + if (!m.x || !m.delta || !m.h || !m.q || !m.k || !m.v || !m.gate || !m.attn || !m.gu || !m.ff || + !m.hout || !m.logits) return RAD_E_INVAL; + m.a_h.x = m.h; + RAD_ARCH_TRY(m.a_h.declare_qs(b, nm, g, "h", E, 0, true, false)); + m.a_h.q8_fed = true; + m.a_h.q8_rot = true; + m.a_attn.x = m.attn; + RAD_ARCH_TRY(m.a_attn.declare_qs(b, nm, g, "attn_out", Q, 0, true, false)); + m.a_ff.x = m.ff; + RAD_ARCH_TRY(m.a_ff.declare_qs(b, nm, g, "ff", F, 0, true, false)); + m.had = rw(b, RAD_OP(b, "had_quant_act_i8g", + RAD_PARAMS(RAD_RANGE("M", 1, T), RAD_INT("n", E), RAD_INT("group", RAD_FP8_BLOCK), + RAD_STR("dtype", "bf16")), RAD_NOWEIGHTS), + {m.h}, {m.a_h.q8, m.a_h.s8}); + if (!m.had) return RAD_E_INVAL; + RAD_ARCH_TRY(rad_declare_logits(b, m.logits)); + + /* ---- the drafter's taps, when the container carries a drafter and this serve speculates. + * Declared before the layer loop because the stream outlives it: the drafter's context pass + * runs after the trunk's, on the residual streams the trunk saved here. */ + bool drafter = false; + RAD_ARCH_TRY(drafter_kind(meta, &drafter)); + if (drafter && ctx->max_spec > 0) { + m.taps.read(meta, g.n_layer); + if (m.taps.n <= 0) { + fprintf(stderr, "radiance: spark25: the drafter names no trunk layer to read, or names " + "only layers past this target's last (`draft.target_layer_ids`)\n"); + return RAD_E_FORMAT; + } + RAD_ARCH_TRY(m.taps.declare(b, nm, g, g.max_tok, m.x)); + } + + auto weight = [&](const char* name, const char* src, uint32_t dt, + std::initializer_list shape, RadWeightGroup group, + int access = RAD_ACCESS_PER_TOKEN, int shard = RAD_SHARD_NONE) { + if (map_copy(b, name, src) != RAD_OK) return (rad_weight)0; + return decl_w(b, name, dt, shape, access, shard, group); + }; + m.tok = weight(nm.f("token_embd.weight"), nm.ckpt("model.embedding.weight"), RAD_BF16, + {g.n_vocab, E}, grp_model(), RAD_ACCESS_VOCAB, RAD_SHARD_ROW); + /* The head is the tied table again, at whatever the container holds it: bf16 as shipped, or + * the int8 grid where the recipe quantised it, which is the widest GEMM a decode step runs. */ + if (map_copy(b, nm.f("output.weight"), nm.ckpt("model.embedding.weight")) != RAD_OK) + return RAD_E_INVAL; + m.head = decl_w(b, nm.f("output.weight"), + weight_codes_dtype(b, nm.f("output.weight"), RAD_BF16), + {g.n_vocab, E}, RAD_ACCESS_VOCAB, RAD_SHARD_ROW, grp_model()); + m.norm = weight(nm.f("output_norm.weight"), nm.ckpt("model.norm.weight"), RAD_F32, + {E}, grp_model()); + if (!m.tok || !m.head || !m.norm) return RAD_E_INVAL; + if (g.world > 1 && g.n_vocab_all % g.world) { + RAD_ARCH_TRY(rad_weight_shard_span(b, m.tok, g.vocab_off, g.vocab_off + g.n_vocab)); + RAD_ARCH_TRY(rad_weight_shard_span(b, m.head, g.vocab_off, g.vocab_off + g.n_vocab)); + } + + auto norm = [&](rad_weight w, rad_buf x, rad_buf y) { + return rw(b, RAD_OP(b, "rmsnorm", RAD_PARAMS(RAD_RANGE("M", 1, T), RAD_INT("n", E), + RAD_F64("eps", g.eps), RAD_F64("wadd", 0.0), RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(w)), {x}, {y}); + }; + auto gemm = [&](int64_t n, int64_t k, rad_weight w, rad_buf x, rad_buf y) { + return rw(b, RAD_OP(b, "gemm_nt", RAD_PARAMS(RAD_RANGE("M", 1, T), RAD_INT("N", n), + RAD_INT("K", k), RAD_STR("dtype", "bf16")), RAD_WEIGHTS(w)), {x}, {y}); + }; + auto add = [&]() { + return rw(b, RAD_OP(b, "add", RAD_PARAMS(RAD_RANGE("M", 1, T), RAD_INT("n", E), + RAD_STR("dtype", "f32")), RAD_NOWEIGHTS), {m.x, m.delta}, {m.x}); + }; + m.embed = rw(b, RAD_OP(b, "embed_lookup", RAD_PARAMS(RAD_RANGE("M", 1, T), + RAD_INT("n_embd", E), RAD_INT("n_vocab", g.n_vocab), RAD_STR("dtype", "bf16"), + RAD_INT("vocab_offset", g.vocab_off)), RAD_WEIGHTS(m.tok)), {}, {m.h}); + auto widen = [&](rad_buf output) { + return rw(b, RAD_OP(b, "cast", RAD_PARAMS(RAD_RANGE("M", 1, T), RAD_INT("n", E), + RAD_STR("from", "bf16"), RAD_STR("to", "f32")), RAD_NOWEIGHTS), {m.h}, {output}); + }; + m.widen = widen(m.x); + /* Embedding shards contribute disjoint rows, so their widened sum is exact. Projection + * shards must instead reduce in bf16, rounding the merged output before it is widened and + * added to the f32 residual, as in the reference's BF16 linear layers. */ + auto reduce = [&](rad_buf x, const char* dtype) { + if (g.world <= 1) return (rad_op)0; + return rw(b, RAD_OP(b, "all_reduce", RAD_PARAMS(RAD_INT("world_size", g.world), + RAD_RANGE("numel", E, T * E), RAD_STR("dtype", dtype), RAD_INT("exact", 1)), + RAD_NOWEIGHTS), {x}, {x}); + }; + m.reduce_embed = reduce(m.x, "fp32"); + if (g.world > 1 && !m.reduce_embed) { + fprintf(stderr, "radiance: spark25_w8a8 requires an exact fp32 all-reduce for TP=%d\n", g.world); + return RAD_E_UNSUPPORTED; + } + + m.layers.resize((size_t)g.n_layer); + for (int l = 0; l < g.n_layer; ++l) { + Layer& a = m.layers[(size_t)l]; + auto src = [&](const char* suffix) { return nm.ckpt("model.layers.%d.%s", l, suffix); }; + auto w = [&](const char* suffix, const char* s, uint32_t dt, + std::initializer_list shape, int shard = RAD_SHARD_NONE) { + return weight(nm.f("blk.%d.%s", l, suffix), src(s), dt, shape, grp_layer(l), + RAD_ACCESS_PER_TOKEN, shard); + }; + a.an = w("attn_norm.weight", "input_layernorm.weight", RAD_F32, {E}); + a.gate = w("attn_gate.weight", "self_attn.g_proj.weight", RAD_BF16, {g.n_head, E}, RAD_SHARD_ROW); + a.fn = w("ffn_norm.weight", "post_attention_layernorm.weight", RAD_F32, {E}); + const char* qkv = src("self_attn.q_k_v_proj.weight"); + const int64_t qall = g.n_head_all * g.head_dim, kall = g.n_head_kv_all * g.head_dim; + const int64_t qlo = needs_span(shards.q, g.n_head_all, g) ? shards.q.first * g.head_dim : 0; + const int64_t qhi = needs_span(shards.q, g.n_head_all, g) + ? (shards.q.first + shards.q.count) * g.head_dim : 0; + const int64_t kvlo = needs_span(shards.kv, g.n_head_kv_all, g) + ? shards.kv.first * g.head_dim : 0; + const int64_t kvhi = needs_span(shards.kv, g.n_head_kv_all, g) + ? (shards.kv.first + shards.kv.count) * g.head_dim : 0; + auto map_part = [&](const char* name, int64_t first, int64_t rows) { + const char* target = nm.f("blk.%d.attn_%s.weight", l, name); + return map_rows(b, target, {{qkv, (int)first, rows}}); + }; + const char* qb = nm.f("blk.%d.attn_q", l); + const char* kb = nm.f("blk.%d.attn_k", l); + const char* vb = nm.f("blk.%d.attn_v", l); + RAD_ARCH_TRY(map_part("q", 0, qall)); + RAD_ARCH_TRY(map_part("k", qall, kall)); + RAD_ARCH_TRY(map_part("v", qall + kall, kall)); + a.q.mapped = a.k.mapped = a.v.mapped = true; + RAD_ARCH_TRY(a.q.declare(b, nm, g, qb, Q, E, RAD_SHARD_ROW, grp_layer(l), {qkv}, + m.a_h, m.q, 0, {}, qlo, qhi)); + RAD_ARCH_TRY(a.k.declare(b, nm, g, kb, K, E, RAD_SHARD_ROW, grp_layer(l), {qkv}, + m.a_h, m.k, 0, {}, kvlo, kvhi)); + RAD_ARCH_TRY(a.v.declare(b, nm, g, vb, K, E, RAD_SHARD_ROW, grp_layer(l), {qkv}, + m.a_h, m.v, 0, {}, kvlo, kvhi)); + const int64_t olo = qlo, ohi = qhi; + RAD_ARCH_TRY(a.o.declare(b, nm, g, nm.f("blk.%d.attn_output", l), E, Q, + RAD_SHARD_COL, grp_layer(l), {src("self_attn.out_proj.weight")}, + m.a_attn, m.h, 0, {}, olo, ohi)); + RAD_ARCH_TRY(a.gu.declare(b, nm, g, nm.f("blk.%d.ffn_gate_up", l), 2 * F, E, + RAD_SHARD_ROW, grp_layer(l), + {src("mlp.gate_proj.weight"), src("mlp.up_proj.weight")}, + m.a_h, m.gu, 0, {F, F})); + const int64_t flo = needs_span(shards.ff, g.n_ff_all, g) ? shards.ff.first : 0; + const int64_t fhi = needs_span(shards.ff, g.n_ff_all, g) + ? shards.ff.first + shards.ff.count : 0; + if (needs_span(shards.ff, g.n_ff_all, g)) { + const int64_t lo[2] = {shards.ff.first, shards.ff.first}; + const int64_t hi[2] = {shards.ff.first + shards.ff.count, + shards.ff.first + shards.ff.count}; + const int64_t total[2] = {g.n_ff_all, g.n_ff_all}; + RAD_ARCH_TRY(a.gu.span_parts(b, lo, hi, total, 2)); + } + RAD_ARCH_TRY(a.down.declare(b, nm, g, nm.f("blk.%d.ffn_down", l), E, F, + RAD_SHARD_COL, grp_layer(l), {src("mlp.down_proj.weight")}, + m.a_ff, m.h, 0, {}, flo, fhi)); + if (!a.an || !a.gate || !a.fn || !a.q.w || !a.k.w || !a.v.w || !a.o.w || + !a.gu.w || !a.down.w) return RAD_E_INVAL; + if (g.world > 1 && needs_span(shards.q, g.n_head_all, g)) + RAD_ARCH_TRY(rad_weight_shard_span(b, a.gate, shards.q.first, + shards.q.first + shards.q.count)); + a.kv = m.kv; + RAD_ARCH_TRY(rad_bind_layer_kv(b, l, a.kv)); + a.anorm = norm(a.an, m.x, m.h); + a.gp = gemm(g.n_head, E, a.gate, m.h, m.gate); + Geom rope = g; + const int kind = local[(size_t)l] ? 1 : 0; + rope.theta = (float)theta[kind]; + a.rq = rw(b, decl_rope(b, rope, T, g.head_dim, g.n_head, 0, rot[kind], "neox"), {m.q}, {m.q}); + a.rk = rw(b, decl_rope(b, rope, T, g.head_dim, g.n_head_kv, 0, rot[kind], "neox"), {m.k}, {m.k}); + a.attn = rw(b, decl_attn(b, g, "attn_paged", + RAD_PARAMS(RAD_RANGE("q_len", 1, T), RAD_INT("head_dim", g.head_dim), + RAD_INT("gqa", g.gqa()), RAD_INT("causal", 1), RAD_INT("window", kind ? window : 0), + RAD_INT("n_head", g.n_head), RAD_INT("block_size", RAD_KV_BLOCK), + RAD_INT("max_seqs", g.max_seqs), RAD_INT("max_ctx", g.max_ctx), + RAD_STR("q_dtype", "bf16"), RAD_STR("kv_dtype", g.kv_dtype)), RAD_NOWEIGHTS), + {m.q}, {m.attn}); + a.store = rw(b, RAD_OP(b, "kv_store", RAD_PARAMS(RAD_RANGE("M", 1, T), + RAD_INT("head_dim", g.head_dim), RAD_INT("n_head_kv", g.n_head_kv), + RAD_INT("block_size", rad_kv_block_size(b, a.kv)), RAD_STR("kv_dtype", g.kv_dtype)), + RAD_NOWEIGHTS), {m.k, m.v}, {}); + a.sigmoid = rw(b, RAD_OP(b, "sigmoid", RAD_PARAMS(RAD_RANGE("M", 1, T), + RAD_INT("n", g.n_head), RAD_STR("dtype", "bf16")), RAD_NOWEIGHTS), {m.gate}, {m.gate}); + /* View dense [tokens, heads * dim] and [tokens, heads] as one row per head. */ + a.gate_heads = rw(b, RAD_OP(b, "scale_rows", RAD_PARAMS(RAD_RANGE("M", 1, T * g.n_head), + RAD_INT("n", g.head_dim), RAD_STR("act", "none"), RAD_STR("dtype", "bf16")), + RAD_NOWEIGHTS), {m.attn, m.gate}, {m.attn}); + a.reduce_attn = reduce(m.h, "bf16"); + a.widen_attn = widen(m.delta); + a.add_attn = add(); + a.fnorm = norm(a.fn, m.x, m.h); + a.act = rw(b, RAD_OP(b, "act_mul", RAD_PARAMS(RAD_RANGE("M", 1, T), RAD_INT("n", F), + RAD_STR("act", "gelu"), RAD_STR("dtype", "bf16")), RAD_NOWEIGHTS), {m.gu}, {m.ff}); + a.reduce_ffn = reduce(m.h, "bf16"); + if (g.world > 1 && (!a.reduce_attn || !a.reduce_ffn)) { + fprintf(stderr, "radiance: spark25_w8a8 requires exact bf16 all-reduces for TP=%d\n", g.world); + return RAD_E_UNSUPPORTED; + } + a.widen_ffn = widen(m.delta); + a.add_ffn = add(); + if (m.tap_live && l >= m.calib_lo && l < m.calib_hi) { + RAD_ARCH_TRY(a.tap_in.declare(b, nm, T, nm.f("blk.%d.attn_in", l), m.h, E)); + RAD_ARCH_TRY(a.tap_o.declare(b, nm, T, nm.f("blk.%d.attn_o", l), m.attn, Q)); + RAD_ARCH_TRY(a.tap_gu.declare(b, nm, T, nm.f("blk.%d.ffn_in", l), m.h, E)); + RAD_ARCH_TRY(a.tap_down.declare(b, nm, T, nm.f("blk.%d.ffn_down_in", l), m.ff, F)); + } + } + m.final_norm = norm(m.norm, m.x, m.h); + m.gather = rw(b, RAD_OP(b, "gather_rows", RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows), + RAD_INT("n", E), RAD_STR("dtype", "bf16")), RAD_NOWEIGHTS), {m.h}, {m.hout}); + m.logits_op = rw(b, RAD_OP(b, "logits_gemm", RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows), + RAD_INT("n_vocab", g.n_vocab), RAD_INT("n_embd", E), RAD_STR("dtype", "bf16")), + RAD_WEIGHTS(m.head)), {m.hout}, {m.logits}); + char ids[128] = ""; + /* The drafter is declared last, after the head. The buffer planner takes lifetimes in + * declaration order, and a drafter's passes run after the whole trunk's, so declaring it in the + * middle would let a trunk temporary be planned onto bytes the drafter is still reading. */ + if (m.taps.n > 0) { + RAD_ARCH_TRY(declare_dspark(&m.ds, &m.dsw, &m.kv_draft, b, nm, meta, ctx, g, m.taps, + (int)g.n_layer, m.tok, nm.ckpt("model.embedding.weight"))); + m.have_ds = true; + for (int t = 0, off = 0; t < m.taps.n && off < (int)sizeof(ids) - 8; ++t) + off += std::snprintf(ids + off, sizeof ids - off, "%s%d", t ? ", " : "", + m.taps.layer[t]); + rad_note(b, "the drafter reads the residual stream after layer(s) %s", ids); + } + + rad_note(b, "spark25 rank %d/%d: %lld layers, %lld query / %lld KV heads x %lld, " + "FFN %lld, vocab [%lld, %lld), local window %lld", g.rank, g.world, + (long long)g.n_layer, (long long)g.n_head, (long long)g.n_head_kv, + (long long)g.head_dim, (long long)g.n_ff, (long long)g.vocab_off, + (long long)(g.vocab_off + g.n_vocab), (long long)window); + return RAD_OK; +} + +static void step(RadCtx* c, const RadBatch* batch) { + Model& m = models[rad_rank(c)]; + const Geom& g = m.g; + /* A drafter pass; the sign gives the kind. Positive is the query pass, which denoises the whole + * block and proposes from it; negative is the context pass, which turns the tokens the trunk + * just committed into the drafter's own K and V. Zero is a trunk step. */ + if (batch->draft_pass != 0) { + if (!m.have_ds) { + rad_step_fail(c, "the batch asks for a drafter pass and no drafter is declared: the " + "container carries no `draft.` block, or declare ran at max_spec 0"); + return; + } + if (batch->draft_pass > 0) m.ds.step(c, batch); + else m.ds.context(c, batch); + return; + } + const int64_t T = batch->n_tok; + const RadOperand pos = praw(batch->positions, RAD_I32, T); + RAD_ISSUE(c, m.embed, praw(batch->token_ids, RAD_I32, T), RAD_W(m.tok), brows(m.h, T)); + RAD_ISSUE(c, m.widen, brows(m.h, T), brows(m.x, T)); + if (m.reduce_embed) RAD_ISSUE_N(c, m.reduce_embed, T * g.n_embd, brows(m.x, T), RAD_NONE); + for (size_t i = 0; i < m.layers.size(); ++i) { + const Layer& a = m.layers[i]; + const RadKVGroupBatch* kvb = kv_batch(batch, a.kv); + const int32_t* slot = kvb ? kvb->slot_mapping : nullptr; + const int32_t* table = kvb ? kvb->block_table : nullptr; + const int32_t* used = kvb ? kvb->seqused : nullptr; + RAD_ISSUE(c, a.anorm, brows(m.x, T), RAD_W(a.an), brows(m.h, T)); + a.tap_in.step(c, m.h, T, m.tap_live); + RAD_ISSUE(c, m.had, brows(m.h, T), brows(m.a_h.q8, T), brows(m.a_h.s8, T)); + a.q.step(c, m.a_h, m.q, T); + a.k.step(c, m.a_h, m.k, T); + a.v.step(c, m.a_h, m.v, T); + RAD_ISSUE(c, a.gp, brows(m.h, T), RAD_W(a.gate), brows(m.gate, T)); + RAD_ISSUE(c, a.rq, brows(m.q, T), pos); + RAD_ISSUE(c, a.rk, brows(m.k, T), pos); + RAD_ISSUE(c, a.store, brows(m.k, T), brows(m.v, T), praw(slot, RAD_I32, T), + kv_cache(a.kv, (int)i)); + RAD_ISSUE_N(c, a.attn, batch->max_q_len, brows(m.q, T), kv_cache(a.kv, (int)i), + praw2(table, RAD_I32, batch->n_seq, kvb ? kvb->block_table_pitch : 0), + praw(used, RAD_I32, batch->n_seq), RAD_NONE, RAD_NONE, + praw(batch->cu_seqlens, RAD_I32, batch->n_seq + 1), brows(m.attn, T)); + RAD_ISSUE(c, a.sigmoid, brows(m.gate, T), brows(m.gate, T)); + const RadOperand heads = RAD_P_T2(rad_buf_ptr(c, m.attn), RAD_BF16, T * g.n_head, g.head_dim); + const RadOperand gates = RAD_P_T2(rad_buf_ptr(c, m.gate), RAD_BF16, T * g.n_head, 1); + RAD_ISSUE_N(c, a.gate_heads, T * g.n_head, heads, gates, RAD_NONE, heads); + a.tap_o.step(c, m.attn, T, m.tap_live); + a.o.step(c, m.a_attn, m.h, T); + if (a.reduce_attn) RAD_ISSUE_N(c, a.reduce_attn, T * g.n_embd, brows(m.h, T), RAD_NONE); + RAD_ISSUE(c, a.widen_attn, brows(m.h, T), brows(m.delta, T)); + RAD_ISSUE(c, a.add_attn, brows(m.x, T), brows(m.delta, T), brows(m.x, T)); + RAD_ISSUE(c, a.fnorm, brows(m.x, T), RAD_W(a.fn), brows(m.h, T)); + a.tap_gu.step(c, m.h, T, m.tap_live); + RAD_ISSUE(c, m.had, brows(m.h, T), brows(m.a_h.q8, T), brows(m.a_h.s8, T)); + a.gu.step(c, m.a_h, m.gu, T); + RAD_ISSUE(c, a.act, bcol(m.gu, 0, g.n_ff, T), bcol(m.gu, g.n_ff, g.n_ff, T), brows(m.ff, T)); + a.tap_down.step(c, m.ff, T, m.tap_live); + a.down.step(c, m.a_ff, m.h, T); + if (a.reduce_ffn) RAD_ISSUE_N(c, a.reduce_ffn, T * g.n_embd, brows(m.h, T), RAD_NONE); + RAD_ISSUE(c, a.widen_ffn, brows(m.h, T), brows(m.delta, T)); + RAD_ISSUE(c, a.add_ffn, brows(m.x, T), brows(m.delta, T), brows(m.x, T)); + /* The tap after this layer, on prefill and decode alike: the drafter conditions on every + * committed token's residual stream, not only on prefill's. */ + m.taps.step(c, m.x, T, (int64_t)i, g.n_embd); + } + RAD_ISSUE(c, m.final_norm, brows(m.x, T), RAD_W(m.norm), brows(m.h, T)); + if (batch->n_out > 0) { + RAD_ISSUE_N(c, m.gather, batch->n_out, brows(m.h, T), + praw(batch->out_ids, RAD_I32, batch->n_out), brows(m.hout, batch->n_out)); + RAD_ISSUE_N(c, m.logits_op, batch->n_out, brows(m.hout, batch->n_out), RAD_W(m.head), + brows(m.logits, batch->n_out)); + } + if (m.tap_live) { + m.calib_rows += T; + if (m.calib_rows >= calib_target()) { + bool ok = true; + for (int64_t l = m.calib_lo; l < m.calib_hi; ++l) { + const Layer& a = m.layers[(size_t)l]; + char stem[96]; + for (const char* proj : {"attn_q", "attn_k", "attn_v"}) { + std::snprintf(stem, sizeof stem, "blk.%lld.%s", (long long)l, proj); + ok = calib_write(c, a.tap_in.h, a.tap_in.K, m.calib_rows, stem, 0) && ok; + } + std::snprintf(stem, sizeof stem, "blk.%lld.attn_output", (long long)l); + ok = calib_write(c, a.tap_o.h, a.tap_o.K, m.calib_rows, stem, 0) && ok; + std::snprintf(stem, sizeof stem, "blk.%lld.ffn_gate_up", (long long)l); + ok = calib_write(c, a.tap_gu.h, a.tap_gu.K, m.calib_rows, stem, 0) && ok; + std::snprintf(stem, sizeof stem, "blk.%lld.ffn_down", (long long)l); + ok = calib_write(c, a.tap_down.h, a.tap_down.K, m.calib_rows, stem, 0) && ok; + } + m.tap_live = false; + std::fprintf(stderr, "radiance: spark25 rank %d wrote calibration Grams for layers " + "%lld:%lld after %lld tokens to %s%s\n", rad_rank(c), + (long long)m.calib_lo, (long long)m.calib_hi, m.calib_rows, calib_dir(), + ok ? "" : ", with errors"); + } + } +} + +#ifdef SPARK25_HAVE_PREFILL_SPLIT +static uint64_t pass_key(RadCtx* c, const RadBatch* batch, const int32_t* used_max_h) { + if (!c || !batch) return 0; + Model& m = models[rad_rank(c)]; + int group = -1; + if (batch->kv) for (int i = 0; i < batch->n_kv_groups; ++i) + if (batch->kv[i].group == m.kv) { group = i; break; } + spark25_prefill_key::Request r; + r.phase = batch->phase; + r.n_tok = batch->n_tok; + r.n_seq = batch->n_seq; + r.max_q_len = batch->max_q_len; + r.max_ctx = m.g.max_ctx; + r.n_spec = batch->n_spec; + r.draft_pass = batch->draft_pass; + r.enc = batch->enc != 0; + r.head_dim = m.g.head_dim; + r.gqa = m.g.gqa(); + r.kv_heads = m.g.n_head_kv; + r.kv_group_found = group >= 0; + r.used = used_max_h && group >= 0 ? used_max_h[group] : 0; + r.wgps = rad_ctx_wgp_count(c); + return spark25_prefill_key::pass_key(r); +} +#endif + +/* The speculation depth this container supports: zero without a drafter, or the block length a + * DSpark drafter was trained at. `draft_depth_fixed` because a block-diffusion drafter denoises + * exactly that many mask positions, and `declare` refuses to run it at any other depth. */ +static int probe(const RadModelMeta* meta, RadArchProbe* out) { + if (!meta || !out) return RAD_E_INVAL; + out->draft_depth = 0; + out->draft_depth_fixed = 0; + bool present = false; + if (drafter_kind(meta, &present) != RAD_OK) return RAD_E_UNSUPPORTED; + if (!present) return RAD_OK; + const long long bs = rad_meta_geti(meta, "draft.block_size", 0); + if (bs < 2) { + fprintf(stderr, "radiance: spark25: the container carries a drafter with no " + "draft.block_size\n"); + return RAD_E_FORMAT; + } + out->draft_depth = (int)bs; + out->draft_depth_fixed = 1; + return RAD_OK; +} + +static const RadChatFormat* chat_format(const RadModelMeta*) { return spark25_bf16::spark_chat_format(); } +} +#ifndef RAD_ARCH_NO_EXPORTS +RAD_ARCH_PROBE(spark25_w8a8) +RAD_ARCH_PLUGIN(spark25_w8a8, "spark25", "w8a8_fwht128", "0.1.0", + "Spark X2.6 with an int8 trunk: i8 weights with a bf16 scale a 128 of K, rotated " + "by a 128-wide Hadamard, against int8 activations the same rotation quantises") +RAD_ARCH_CHAT_FORMAT(spark25_w8a8) +#ifdef SPARK25_HAVE_PREFILL_SPLIT +extern "C" uint64_t rad_arch_pass_key(RadCtx* c, const RadBatch* batch, + const int32_t* used_max_h) { + return spark25_w8a8::pass_key(c, batch, used_max_h); +} +#endif +#endif diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 9b69099f..7362ec9b 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -23,6 +23,11 @@ list(APPEND RAD_CORE_SRC ${_top}) add_library(rad_core STATIC ${RAD_CORE_SRC}) target_link_libraries(rad_core PUBLIC rad_abi ${CMAKE_DL_LIBS} Threads::Threads) target_compile_definitions(rad_core PUBLIC RAD_VERSION="${PROJECT_VERSION}") +if(RAD_ENABLE_KV_ROLLBACK_TEST_HOOK) + # Scheduler is embedded in Engine and its test-only callback changes its class layout. + # Propagate the definition to every consumer to keep all translation units ABI-consistent. + target_compile_definitions(rad_core PUBLIC RAD_ENABLE_KV_ROLLBACK_TEST_HOOK=1) +endif() target_include_directories(rad_core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/abi diff --git a/core/build/rad_build.h b/core/build/rad_build.h index 4c5ad87a..120d6c60 100644 --- a/core/build/rad_build.h +++ b/core/build/rad_build.h @@ -137,6 +137,7 @@ public: int declare_generator(const RadGeneratorDecl* d); int declare_audio_generator(const RadAudioGenDecl* d); int declare_video_generator(const RadVideoGenDecl* d); + int declare_shape_generator(const RadShapeGenDecl* d); void note_v (const char* f, va_list ap); /* An op's buffer operands (rad_op_reads/rad_op_writes in rad_builder.h), which give the diff --git a/core/build/rad_builder.cpp b/core/build/rad_builder.cpp index 9aebb1ea..7b99f01d 100644 --- a/core/build/rad_builder.cpp +++ b/core/build/rad_builder.cpp @@ -1201,6 +1201,11 @@ int Builder::declare_logits(rad_buf b) { prog_.vgen_str.name.c_str()); return RAD_E_STATE; } + if (prog_.is_shape_generator()) { + err(RAD_E_STATE, "declare_logits: this program already declared the shape generator '%s'", + prog_.sgen_name.c_str()); + return RAD_E_STATE; + } prog_.logits_buf = b; return RAD_OK; } @@ -1241,6 +1246,11 @@ int Builder::declare_pooled(rad_buf b) { prog_.vgen_str.name.c_str()); return RAD_E_STATE; } + if (prog_.is_shape_generator()) { + err(RAD_E_STATE, "declare_pooled: this program already declared the shape generator '%s'", + prog_.sgen_name.c_str()); + return RAD_E_STATE; + } const RadBufDecl& d = prog_.buffers[b].decl; if (d.dtype != RAD_F32 || d.domain != RAD_DOMAIN_DEVICE || d.rank != 2 || d.shape[0] < prog_.ctx.max_seqs || d.shape[1] <= 0) { @@ -1329,6 +1339,11 @@ int Builder::declare_encoder(const RadEncoderDecl* d) { (int)d->one_grid); return RAD_E_INVAL; } + if (d->bidirectional != 0 && (d->bidirectional != 1 || audio)) { + err(RAD_E_INVAL, "declare_encoder '%s': bidirectional %d -- 0, or 1 for a picture and video " + "encoder", nm, (int)d->bidirectional); + return RAD_E_INVAL; + } slot = *d; slot_name = nm; slot.name = nullptr; /* the plugin's storage; the name is the copy */ @@ -1348,12 +1363,13 @@ int Builder::declare_generator(const RadGeneratorDecl* d) { return RAD_E_STATE; } if (prog_.logits_buf != RAD_NULL_HANDLE || prog_.pooled_buf != RAD_NULL_HANDLE || - prog_.is_audio_generator() || prog_.is_video_generator()) { + prog_.is_audio_generator() || prog_.is_video_generator() || prog_.is_shape_generator()) { err(RAD_E_STATE, "declare_generator '%s': this program already declared %s; a program " - "generates text, embeds, makes images, audio or video -- one of the five", - nm, prog_.logits_buf != RAD_NULL_HANDLE ? "logits" + "generates text, embeds, makes images, audio, video or shapes -- one of " + "the six", nm, prog_.logits_buf != RAD_NULL_HANDLE ? "logits" : prog_.pooled_buf != RAD_NULL_HANDLE ? "a pooled output" - : prog_.is_audio_generator() ? "an audio generator" : "a video generator"); + : prog_.is_audio_generator() ? "an audio generator" + : prog_.is_video_generator() ? "a video generator" : "a shape generator"); return RAD_E_STATE; } if (d->layout != RAD_GEN_LAYOUT_JOINT_GRID && d->layout != RAD_GEN_LAYOUT_JOINT_STEP) { @@ -1505,13 +1521,14 @@ int Builder::declare_audio_generator(const RadAudioGenDecl* d) { return RAD_E_STATE; } if (prog_.logits_buf != RAD_NULL_HANDLE || prog_.pooled_buf != RAD_NULL_HANDLE || - prog_.generator.layout != 0 || prog_.is_video_generator()) { + prog_.generator.layout != 0 || prog_.is_video_generator() || prog_.is_shape_generator()) { err(RAD_E_STATE, "declare_audio_generator '%s': this program already declared %s; a " - "program generates text, embeds, makes images, audio or video -- one of " - "the five", nm, + "program generates text, embeds, makes images, audio, video or shapes -- " + "one of the six", nm, prog_.logits_buf != RAD_NULL_HANDLE ? "logits" : prog_.pooled_buf != RAD_NULL_HANDLE ? "a pooled output" - : prog_.generator.layout != 0 ? "an image generator" : "a video generator"); + : prog_.generator.layout != 0 ? "an image generator" + : prog_.is_video_generator() ? "a video generator" : "a shape generator"); return RAD_E_STATE; } if (!d->tmpl && !d->tmpl_plain) { @@ -1682,13 +1699,14 @@ int Builder::declare_video_generator(const RadVideoGenDecl* d) { return RAD_E_STATE; } if (prog_.logits_buf != RAD_NULL_HANDLE || prog_.pooled_buf != RAD_NULL_HANDLE || - prog_.generator.layout != 0 || prog_.is_audio_generator()) { + prog_.generator.layout != 0 || prog_.is_audio_generator() || prog_.is_shape_generator()) { err(RAD_E_STATE, "declare_video_generator '%s': this program already declared %s; a " - "program generates text, embeds, makes images, audio or video -- one of " - "the five", nm, + "program generates text, embeds, makes images, audio, video or shapes -- " + "one of the six", nm, prog_.logits_buf != RAD_NULL_HANDLE ? "logits" : prog_.pooled_buf != RAD_NULL_HANDLE ? "a pooled output" - : prog_.generator.layout != 0 ? "an image generator" : "an audio generator"); + : prog_.generator.layout != 0 ? "an image generator" + : prog_.is_audio_generator() ? "an audio generator" : "a shape generator"); return RAD_E_STATE; } if (!d->tmpl || !std::strstr(d->tmpl, "{prompt}") || d->max_text <= 0) { @@ -1903,6 +1921,108 @@ int Builder::declare_video_generator(const RadVideoGenDecl* d) { return RAD_OK; } +/* The shape generator (rad_declare_shape_generator). Checked here rather than at the first request: + * the picture's geometry, the sampler, the grid and the field's buffer, which the core reads back + * after every query pass. */ +int Builder::declare_shape_generator(const RadShapeGenDecl* d) { + if (finished_) { + err(RAD_E_STATE, "declare_shape_generator after declare finished"); + return RAD_E_STATE; + } + if (!d) { err(RAD_E_INVAL, "declare_shape_generator: null declaration"); return RAD_E_INVAL; } + const char* nm = d->name && *d->name ? d->name : "(unnamed)"; + if (prog_.is_shape_generator()) { + err(RAD_E_STATE, "declare_shape_generator: '%s' was already declared; '%s' is a second one", + prog_.sgen_name.c_str(), nm); + return RAD_E_STATE; + } + if (prog_.logits_buf != RAD_NULL_HANDLE || prog_.pooled_buf != RAD_NULL_HANDLE || + prog_.generator.layout != 0 || prog_.is_audio_generator() || prog_.is_video_generator()) { + err(RAD_E_STATE, "declare_shape_generator '%s': this program already declared %s; a " + "program generates text, embeds, makes images, audio, video or shapes -- " + "one of the six", nm, + prog_.logits_buf != RAD_NULL_HANDLE ? "logits" + : prog_.pooled_buf != RAD_NULL_HANDLE ? "a pooled output" + : prog_.generator.layout != 0 ? "an image generator" + : prog_.is_audio_generator() ? "an audio generator" : "a video generator"); + return RAD_E_STATE; + } + if (d->canvas < 1 || d->canvas > 4096 || !(d->border_ratio >= 0.0 && d->border_ratio < 1.0) || + d->enc_patch < 1 || d->enc_size < d->enc_patch || d->enc_size > 4096 || + d->enc_size % d->enc_patch != 0) { + err(RAD_E_INVAL, "declare_shape_generator '%s': the picture is out of range (canvas %lld, " + "border %g, encoder %lld in patches of %lld): the canvas 1..4096, the " + "border in [0, 1), the encoder's side 1..4096 and a whole number of " + "patches", nm, (long long)d->canvas, d->border_ratio, + (long long)d->enc_size, (long long)d->enc_patch); + return RAD_E_INVAL; + } + for (int c = 0; c < 3; ++c) + if (!std::isfinite(d->pix_mean[c]) || !(d->pix_std[c] > 0.0) || + !std::isfinite(d->pix_std[c])) { + err(RAD_E_INVAL, "declare_shape_generator '%s': channel %d's mean %g and deviation %g " + "must be finite and the deviation positive", nm, c, d->pix_mean[c], + d->pix_std[c]); + return RAD_E_INVAL; + } + if (d->latent_rows < 1 || d->latent_channels < 1 || d->step_rows < 2 * d->latent_rows) { + err(RAD_E_INVAL, "declare_shape_generator '%s': a latent of %lld rows of %lld channels " + "and a step of %lld rows; a step holds both branches' latents", nm, + (long long)d->latent_rows, (long long)d->latent_channels, (long long)d->step_rows); + return RAD_E_INVAL; + } + if (d->default_steps < 2 || d->max_steps < d->default_steps || d->max_steps > 1000 || + !(d->default_guidance >= 0.0) || !std::isfinite(d->default_guidance)) { + err(RAD_E_INVAL, "declare_shape_generator '%s': the sampler is out of range (%lld steps " + "by default, %lld at most, guidance %g): at least 2 grid points, at most " + "1000, the guidance finite and not negative", nm, + (long long)d->default_steps, (long long)d->max_steps, d->default_guidance); + return RAD_E_INVAL; + } + if (!(d->bounds > 0.0) || !std::isfinite(d->bounds) || !std::isfinite(d->level) || + d->min_resolution < 2 || d->default_resolution < d->min_resolution || + d->max_resolution < d->default_resolution || d->max_resolution > 2048) { + err(RAD_E_INVAL, "declare_shape_generator '%s': the field is out of range (bounds %g, " + "level %g, resolution %lld in %lld..%lld): the bounds positive, the level " + "finite, the resolutions in order from 2 to 2048", nm, d->bounds, + d->level, (long long)d->default_resolution, (long long)d->min_resolution, + (long long)d->max_resolution); + return RAD_E_INVAL; + } + if (d->max_lanes < 1 || d->max_query < 1) { + err(RAD_E_INVAL, "declare_shape_generator '%s': %lld lanes and %lld points a query pass; " + "both at least 1", nm, (long long)d->max_lanes, (long long)d->max_query); + return RAD_E_INVAL; + } + const int64_t n_patch = (d->enc_size / d->enc_patch) * (d->enc_size / d->enc_patch); + const int64_t rows = std::max({ d->step_rows, d->max_query, n_patch, d->latent_rows }); + if (prog_.ctx.max_tok < rows) { + err(RAD_E_INVAL, "declare_shape_generator '%s': a pass carries %lld rows and this one's " + "largest is %lld", nm, (long long)prog_.ctx.max_tok, (long long)rows); + return RAD_E_INVAL; + } + const rad_buf h = d->field_out; + if (h == RAD_NULL_HANDLE || (size_t)h >= prog_.buffers.size()) { + err(RAD_E_INVAL, "declare_shape_generator '%s': field_out %u is not a declared buffer", nm, + (unsigned)h); + return RAD_E_INVAL; + } + const RadBufDecl& ob = prog_.buffers[h].decl; + if (ob.dtype != RAD_F32 || ob.domain != RAD_DOMAIN_DEVICE || + decl_numel(ob.rank, ob.shape) < d->max_query) { + err(RAD_E_INVAL, "declare_shape_generator '%s': field_out '%s' must be a device f32 " + "buffer of at least %lld elements", nm, prog_.buffers[h].name.c_str(), + (long long)d->max_query); + return RAD_E_INVAL; + } + prog_.sgen_name = nm; + prog_.shape_gen = *d; + /* As for the other generators: the Program is moved after declare; the name lives in + * sgen_name. */ + prog_.shape_gen.name = nullptr; + return RAD_OK; +} + /* Validates the draft head at declare rather than at the first draft pass, where a bad decl would * only show as zero acceptance. `depth` must equal RadBuildCtx::max_spec, which the plugin sized * its buffers with. */ @@ -2745,6 +2865,11 @@ int rad_declare_video_generator(RadBuilder* b, const RadVideoGenDecl* d) { return B(b)->declare_video_generator(d); } +int rad_declare_shape_generator(RadBuilder* b, const RadShapeGenDecl* d) { + if (!b) return RAD_E_INVAL; + return B(b)->declare_shape_generator(d); +} + void rad_note(RadBuilder* b, const char* f, ...) { if (!b) return; va_list ap; diff --git a/core/config.cpp b/core/config.cpp index b0c63b42..5276fad6 100644 --- a/core/config.cpp +++ b/core/config.cpp @@ -76,8 +76,10 @@ static const Flag g_flags[] = { "(default) leaves decode rows and new requests their room,\n" "off takes the whole step, N holds the chunk to N tokens" }, { "--prefill-interleave", "N", "decode-only steps after each prefill chunk while other\n" - "sequences decode, at most 64; 0 (default) lets every step\n" - "carry a chunk" }, + "sequences decode, at most 64; auto fits them in a quarter\n" + "of the chunk step's time, auto:SHARE in SHARE of it (0-4];\n" + "0 lets every step carry a chunk; served default auto:1\n" + "(0 under --deterministic, KL mode, generators)" }, { "--preempt-wait-ms", "N", "how long a preempted prefill may wait for the whole-\n" "recompute gate before reclaiming cache blocks and\n" "preempting the lowest-priority running request; 0\n" @@ -87,7 +89,10 @@ static const Flag g_flags[] = { { "--rope-scaling", "SPEC", "yarn:FACTOR[:ORIG]: static YaRN over the container's own rotary\n" "keys, no reconvert (docs/YARN.md); none: off" }, - { "--gpu-headroom-mib", "N", "VRAM left unclaimed on every card (default 96)" }, + { "--gpu-memory-mib", "N", "VRAM claimed on every card; the rest is left unclaimed.\n" + "Not with --gpu-headroom-mib" }, + { "--gpu-headroom-mib", "N", "VRAM left unclaimed on every card (default 96).\n" + "Not with --gpu-memory-mib" }, { "--kv-cache-dtype", "T", "bf16 | fp8 | fp8_v4 | k6_v4 -- fp8 halves what a token of\n" "context costs; fp8_v4 keeps V in 4 bits (0.78 of fp8), k6_v4\n" "also K in 6 (0.69); both Qwen3.8-27B and -Flash-Next" }, @@ -568,7 +573,22 @@ int config_parse(int argc, char** argv, Config* c) { else if (!std::strcmp(v, "off")) c->busy_prefill_chunk = 0; else if (!parse_int(a.c_str(), v, 1, INT64_MAX, &c->busy_prefill_chunk)) return RAD_E_INVAL; } - else if (S("--prefill-interleave")) { if (!num(0, 64, &c->prefill_interleave)) return RAD_E_INVAL; } + else if (S("--prefill-interleave")) { + if (!(v = need(i))) return RAD_E_INVAL; + c->prefill_interleave_set = true; + if (!std::strcmp(v, "auto")) { c->prefill_interleave = -1; c->prefill_interleave_share = 0.25; } + else if (!std::strncmp(v, "auto:", 5)) { + /* auto:SHARE -- decode-only steps for up to SHARE x a chunk step's time, 0 < SHARE <= 4 */ + char* e = nullptr; + const double sh = std::strtod(v + 5, &e); + if (e == v + 5 || *e || !(sh > 0.0 && sh <= 4.0)) { + RAD_ERR("--prefill-interleave %s: auto:SHARE takes a share in (0, 4]", v); + return RAD_E_INVAL; + } + c->prefill_interleave = -1; c->prefill_interleave_share = sh; + } + else if (!parse_int(a.c_str(), v, 0, 64, &c->prefill_interleave)) return RAD_E_INVAL; + } else if (S("--preempt-wait-ms")) { if (!num(0, INT64_MAX, &c->preempt_wait_ms)) return RAD_E_INVAL; } else if (S("--max-num-seqs")) { if (!num(1, INT64_MAX, &c->max_seqs)) return RAD_E_INVAL; } else if (S("--max-model-len")) { if (!num(0, INT64_MAX, &c->max_ctx)) return RAD_E_INVAL; } @@ -587,14 +607,15 @@ int config_parse(int argc, char** argv, Config* c) { * old launch lines at the flags that move the split. */ else if (S("--vram-weights-mib") || S("--vram-kv-mib")) { RAD_ERR("%s was removed: the card is split between the weights and the cache from what " - "the model needs. --gpu-headroom-mib takes card space away, --max-model-len and " - "--max-num-seqs bound the cache, and --host-pool-mib decides which experts stay " - "on the card", a.c_str()); + "the model needs. --gpu-headroom-mib or --gpu-memory-mib take card space away, " + "--max-model-len and --max-num-seqs bound the cache, and --host-pool-mib " + "decides which experts stay on the card", a.c_str()); return RAD_E_INVAL; } /* --gpu-headroom is accepted as an alias of --gpu-headroom-mib. */ else if (S("--gpu-headroom-mib") || S("--gpu-headroom")) { if (!num(0, INT64_MAX, &c->gpu_headroom_mib)) return RAD_E_INVAL; } + else if (S("--gpu-memory-mib")) { if (!num(1, INT64_MAX, &c->gpu_memory_mib)) return RAD_E_INVAL; } else if (S("--host-headroom-mib")) { if (!num(0, INT64_MAX, &c->host_headroom_mib)) return RAD_E_INVAL; } else if (S("--kv-cache-dtype")) { if (!(v = need(i))) return RAD_E_INVAL; @@ -641,7 +662,7 @@ int config_parse(int argc, char** argv, Config* c) { RAD_ERR("--embedding-placement takes ram or vram, not '%s'", v); return RAD_E_INVAL; } - std::string share_dir; + std::string share_dir, disk_dir; if (!emb && !std::strncmp(v, "ram=", 4)) { share_dir = v + 4; if (share_dir.empty()) { @@ -650,11 +671,23 @@ int config_parse(int argc, char** argv, Config* c) { return RAD_E_INVAL; } p = TablePlacement::Ram; + } else if (!emb && !std::strncmp(v, "disk=", 5)) { + disk_dir = v + 5; + if (disk_dir.empty()) { + RAD_ERR("--ngram-placement disk= needs a directory: disk=DIR, where the table " + "is read from its own file"); + return RAD_E_INVAL; + } + p = TablePlacement::Disk; } else if (!emb && !parse_table_placement(v, &p)) { - RAD_ERR("%s takes auto, vram, ram, ram=DIR or disk, not '%s'", a.c_str(), v); + RAD_ERR("%s takes auto, vram, ram, ram=DIR, disk or disk=DIR, not '%s'", a.c_str(), + v); return RAD_E_INVAL; } - if (!emb) c->ngram_share_dir = share_dir; + if (!emb) { + c->ngram_share_dir = share_dir; + c->ngram_disk_dir = disk_dir; + } (emb ? c->embedding_placement : c->ngram_placement) = p; if (emb) c->embedding_placement_given = true; } @@ -1130,6 +1163,14 @@ int config_parse(int argc, char** argv, Config* c) { return RAD_E_INVAL; } + /* --gpu-memory-mib claims the card; --gpu-headroom-mib leaves it unclaimed. The alias + * --gpu-headroom is recorded as --gpu-headroom-mib, so it is covered. */ + if (c->given.count("--gpu-memory-mib") && c->given.count("--gpu-headroom-mib")) { + RAD_ERR("--gpu-memory-mib claims the card and --gpu-headroom-mib leaves it unclaimed; " + "give one"); + return RAD_E_INVAL; + } + /* Prompt lookup alone: the window is its K, stated once. */ if (c->spec_ngram_min > c->spec_ngram_max) { RAD_ERR("--spec-ngram-min %d is longer than --spec-ngram-max %d", c->spec_ngram_min, @@ -1322,12 +1363,16 @@ const ShowRow kShow[] = { return c.busy_prefill_chunk < 0 ? std::string("auto") : c.busy_prefill_chunk == 0 ? std::string("off") : num(c.busy_prefill_chunk); } }, { "--prefill-interleave", [](const Config& c) { - return c.prefill_interleave > 0 ? num(c.prefill_interleave) : std::string("off"); } }, + return c.prefill_interleave > 0 ? num(c.prefill_interleave) + : c.prefill_interleave < 0 ? "auto:" + std::to_string(c.prefill_interleave_share) + : std::string("off"); } }, { "--preempt-wait-ms", [](const Config& c) { return num(c.preempt_wait_ms); } }, { "--max-num-seqs", [](const Config& c) { return num(c.max_seqs); } }, { "--max-model-len", [](const Config& c) { return c.max_ctx ? num(c.max_ctx) : std::string("0 (the model's training context)"); } }, { "--rope-scaling", [](const Config& c) { return or_none(c.rope_scaling, "the checkpoint's own"); } }, + { "--gpu-memory-mib", [](const Config& c) { + return c.gpu_memory_mib ? num(c.gpu_memory_mib) : std::string("0 (use --gpu-headroom-mib)"); } }, { "--gpu-headroom-mib", [](const Config& c) { return num(c.gpu_headroom_mib); } }, { "--kv-cache-dtype", [](const Config& c) { return c.kv_cache_dtype; } }, { "--state-cache-dtype", [](const Config& c) { return c.state_cache_dtype; } }, @@ -1340,7 +1385,8 @@ const ShowRow kShow[] = { { "--embedding-placement", [](const Config& c) { return std::string(table_placement_name(c.embedding_placement)); } }, { "--ngram-placement", [](const Config& c) { std::string v = table_placement_name(c.ngram_placement); - return c.ngram_share_dir.empty() ? v : v + "=" + c.ngram_share_dir; } }, + const std::string& dir = c.ngram_share_dir.empty() ? c.ngram_disk_dir : c.ngram_share_dir; + return dir.empty() ? v : v + "=" + dir; } }, { "--vision-tower-placement", [](const Config& c) { return std::string(table_placement_name(c.tower_placement)); } }, { "--weights-disk-tier", [](const Config& c) { return onoff(c.weights_disk_tier); } }, { "--prefix-cache-mib", [](const Config& c) { diff --git a/core/device/aql.cpp b/core/device/aql.cpp index bf291647..33ffa868 100644 --- a/core/device/aql.cpp +++ b/core/device/aql.cpp @@ -589,7 +589,7 @@ KernelRec* kernel_for(const void* stub, int ord, std::string* why) { struct Stream { uint64_t magic = kStreamMagic; int ord = 0; - uint32_t id = 0; /* index into g_queue_by_id, never reused */ + uint32_t id = 0; /* queue_of's key, never reused (see there) */ hsa_agent_t agent{}; hsa_queue_t* q = nullptr; uint64_t mask = 0; @@ -623,12 +623,27 @@ struct Stream { void unlock() { busy.store(false, std::memory_order_release); } }; -/* Every queue this process has made, by an id that is never reused, so "packet i of queue n" - * stays meaningful after the queue is destroyed. A destroyed queue's entry is null; everything - * it held has been consumed. */ +/* Every live queue, by an id that is never reused, so "packet i of queue n" stays meaningful after + * the queue is destroyed: queue_of answers null for a destroyed queue's id, and everything it held + * has been consumed. At most kMaxQueues are live at once; a destroyed queue's slot is taken again + * under a new generation, id = generation * kMaxQueues + slot, so a stale id never names the + * slot's next queue. */ constexpr uint32_t kMaxQueues = 1024; std::atomic g_queue_by_id[kMaxQueues]; -std::atomic g_next_queue_id{0}; +std::atomic g_queue_id_at[kMaxQueues]; /* the id holding each slot now */ +std::mutex g_queue_slot_mu; +std::vector g_queue_free; /* destroyed queues' slots */ +uint32_t g_queue_next_slot = 0; +uint32_t g_queue_gen[kMaxQueues]; + +/* The queue an id names, or null once it is destroyed. The slot's id is stored before its queue + * (release), so a queue read here that belongs to a later generation is seen with that + * generation's id and refused. */ +inline hsa_queue_t* queue_of(uint32_t id) { + const uint32_t slot = id % kMaxQueues; + hsa_queue_t* q = g_queue_by_id[slot].load(std::memory_order_acquire); + return g_queue_id_at[slot].load(std::memory_order_acquire) == id ? q : nullptr; +} inline Stream* ours(const void* s) { if ((uintptr_t)s < 4096) return nullptr; @@ -1127,6 +1142,9 @@ int dispatch(Stream* s, const KernelRec* k, dim3 g, dim3 b, void** args, size_t if (!gx || !gy || !gz) return RAD_OK; if (gx > UINT32_MAX || gy > UINT32_MAX || gz > UINT32_MAX) return RAD_E_INVAL; if ((uint64_t)k->group_size + shm > 65536) return RAD_E_INVAL; + /* The packet's fields are 16 bits wide and the card runs at most 1024 work-items a group; + * HIP refuses a larger block, and so does this. */ + if ((uint64_t)b.x * b.y * b.z > 1024) return RAD_E_INVAL; alignas(64) unsigned char ka[kKargMax]; const uint32_t n = (k->kernarg_size + 15u) & ~15u; @@ -1562,6 +1580,7 @@ int a_stream_create(RadStream* out, int high_priority) { if (hsa_amd_memory_pool_allocate(kpool, (size_t)(s->mask + 2) * kKargSlot, 0, &ka) != HSA_STATUS_SUCCESS || hsa_amd_agents_allow_access(1, &kpeer, nullptr, ka) != HSA_STATUS_SUCCESS) { + if (ka) hsa_amd_memory_pool_free(ka); /* allocated, then refused access */ hsa_queue_destroy(s->q); device_set_error("rad_stream_create: the kernel argument ring could not be placed in %s", d.host_kargs ? "pinned host memory" : "VRAM the host can write"); @@ -1582,17 +1601,28 @@ int a_stream_create(RadStream* out, int high_priority) { s->bounce = static_cast(bb); note_alloc(ka, (int64_t)(s->mask + 2) * kKargSlot, -1); note_alloc(bb, kBounceBytes, -1); - s->id = g_next_queue_id.fetch_add(1, std::memory_order_relaxed); - if (s->id >= kMaxQueues) { + uint32_t slot = kMaxQueues; + { + std::lock_guard lk(g_queue_slot_mu); + if (!g_queue_free.empty()) { + slot = g_queue_free.back(); + g_queue_free.pop_back(); + } else if (g_queue_next_slot < kMaxQueues) { + slot = g_queue_next_slot++; + } + if (slot < kMaxQueues) s->id = g_queue_gen[slot]++ * kMaxQueues + slot; + } + if (slot >= kMaxQueues) { note_free(bb); note_free(ka); hsa_amd_memory_pool_free(bb); hsa_amd_memory_pool_free(ka); hsa_queue_destroy(s->q); - device_set_error("rad_stream_create: more than %u streams in one process", kMaxQueues); + device_set_error("rad_stream_create: more than %u streams live at once", kMaxQueues); return RAD_E_NOMEM; } - g_queue_by_id[s->id].store(s->q, std::memory_order_release); + g_queue_id_at[slot].store(s->id, std::memory_order_release); + g_queue_by_id[slot].store(s->q, std::memory_order_release); { std::lock_guard lk(G().streams_mu); G().streams.push_back(s.get()); @@ -1604,14 +1634,24 @@ int a_stream_create(RadStream* out, int high_priority) { void a_stream_destroy(RadStream rs) { Stream* s = ours(rs); if (!s) return; - (void)stream_drain(s); + /* Undrained (a closed gate, a fault), the queue may still be read by the card, and so may its + * kernel argument ring: both are left allocated rather than freed under it. */ + if (const int rc = stream_drain(s); rc < 0) { + RAD_WARN("device: a stream was destroyed with work it could not drain (%s); its queue and " + "argument ring stay allocated", rad_strerror(rc)); + return; + } { std::lock_guard lk(G().streams_mu); auto& v = G().streams; for (size_t i = 0; i < v.size(); ++i) if (v[i] == s) { v.erase(v.begin() + (long)i); break; } } - g_queue_by_id[s->id].store(nullptr, std::memory_order_release); + g_queue_by_id[s->id % kMaxQueues].store(nullptr, std::memory_order_release); hsa_queue_destroy(s->q); + { + std::lock_guard lk(g_queue_slot_mu); + g_queue_free.push_back(s->id % kMaxQueues); + } note_free(s->karg); note_free(s->bounce); hsa_amd_memory_pool_free(s->karg); @@ -1676,7 +1716,7 @@ bool xp_list_finished(int ord, uint32_t k); bool reusable(const Sig* g) { if (g->stamped || hsa_signal_load_relaxed(g->h) != 0) return false; for (const auto& w : g->waiters) { - hsa_queue_t* q = g_queue_by_id[w.first].load(std::memory_order_acquire); + hsa_queue_t* q = queue_of(w.first); if (q && hsa_queue_load_read_index_relaxed(q) <= w.second) return false; } const int32_t xd = g->xp_dev.load(std::memory_order_acquire); @@ -1902,7 +1942,7 @@ std::vector g_tape_retired; * kReserveMargin past it has launched, which proves it as in reserve(). */ bool tape_idle(const Tape* t) { for (const auto& l : t->last) { - hsa_queue_t* q = g_queue_by_id[l.first].load(std::memory_order_acquire); + hsa_queue_t* q = queue_of(l.first); if (q && hsa_queue_load_read_index_scacquire(q) < l.second + kReserveMargin) return false; } return true; @@ -2574,6 +2614,7 @@ struct DmaQueue { * a queue while the engine runs on, and a ring the host thinks full would wait forever. */ volatile uint32_t* fin = nullptr; uint32_t lists = 0; /* lists handed over; list k ends at ends[k % kDmaEnds] */ + uint64_t seen = 0; /* the most the room check has known read, under the lock */ std::unique_ptr ends; }; constexpr uint32_t kDmaEnds = 4096; @@ -2818,22 +2859,26 @@ inline uint64_t dma_read(const DmaQueue* q) { uint64_t r = *q->rptr; if (q->fin) { const uint32_t k = *q->fin; - if (k) r = std::max(r, q->ends[k % kDmaEnds]); + /* ends[k % kDmaEnds] is list k's only while fewer than kDmaEnds lists are behind it. */ + if (k && q->lists - k < kDmaEnds) r = std::max(r, q->ends[k % kDmaEnds]); } - return r; + return std::max(r, q->seen); } /* Writes `n` dwords to the ring; queue lock held. A packet never straddles the ring end: the tail * is padded with single-dword NOPs. The ring holds a few hundred layers' lists, so waiting for * room means the host is that far ahead of a stalled engine. */ int dma_put(DmaQueue* q, const uint32_t* dw, uint64_t n) { + /* What was once known read stays read: a list number whose ends slot a later list has taken + * cannot be used any more, and the read pointer alone may be behind it. */ + q->seen = dma_read(q); const uint64_t cap = kDmaRingBytes / 4; uint64_t at = (q->w / 4) & (cap - 1); const uint64_t pad = at + n > cap ? cap - at : 0; const uint64_t need = (pad + n) * 4; if (q->w + need - dma_read(q) > kDmaRingBytes) { Stall st("a full DMA ring"); - while (q->w + need - dma_read(q) > kDmaRingBytes) { + while (q->w + need - (q->seen = dma_read(q)) > kDmaRingBytes) { if (G().faulted.load(std::memory_order_relaxed)) { device_set_error("rad_memcpy_list_async: a queue faulted while the DMA ring was full"); return RAD_E_DEVICE; diff --git a/core/device/device.h b/core/device/device.h index c8c8393f..6dc52761 100644 --- a/core/device/device.h +++ b/core/device/device.h @@ -406,7 +406,8 @@ int64_t dev_stuck_ms(); constexpr int kTapeOverlapRun = 6; /* ------------------------------------------------------------------ the allocation ledger - * What rad_dev_alloc has handed out since process start, by RAD_MEM_* kind. It does not see a + * By RAD_MEM_* kind: the bytes rad_dev_alloc has handed out and rad_dev_free has not taken back, + * and the number of allocations since process start. It does not see a * kernel plugin that calls hipMalloc directly; see the ledger in dispatch.cpp. */ void rad_dev_alloc_totals(int kind, int64_t* bytes, int64_t* count); diff --git a/core/device/dispatch.cpp b/core/device/dispatch.cpp index de78f950..61c49933 100644 --- a/core/device/dispatch.cpp +++ b/core/device/dispatch.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -172,6 +173,26 @@ struct Ledger { std::atomic count{0}; }; Ledger g_ledger[4]; /* indexed by RAD_MEM_*; rad_dev_alloc bounds the kind */ +/* Each live allocation's size, so rad_dev_free (which has none) takes it back off the ledger's + * bytes: pinned ranges are freed and taken again during bring-up, and the pin-cap check reads the + * ledger as what the process holds. Allocations are rare, never per step. */ +struct LiveAlloc { int64_t bytes; int kind; }; +std::mutex g_ledger_mu; +std::unordered_map g_ledger_live; + +void ledger_add(void* p, int64_t bytes, int kind) { + g_ledger[kind].bytes.fetch_add(bytes, std::memory_order_relaxed); + std::lock_guard lk(g_ledger_mu); + g_ledger_live[p] = LiveAlloc{ bytes, kind }; +} +void ledger_drop(void* p) { + if (!p) return; + std::lock_guard lk(g_ledger_mu); + const auto it = g_ledger_live.find(p); + if (it == g_ledger_live.end()) return; + g_ledger[it->second.kind].bytes.fetch_sub(it->second.bytes, std::memory_order_relaxed); + g_ledger_live.erase(it); +} /* Live event handles, counted here so the number is backend-independent; the only place an * event leaked at teardown shows. */ @@ -450,7 +471,7 @@ void* rad_dev_alloc(int64_t bytes, int kind) { thread_local int64_t t_device_ordinal = 0; void* p = dev()->alloc(bytes, kind); if (p && kind >= 0 && kind < (int)std::size(rad::g_ledger)) { - rad::g_ledger[kind].bytes.fetch_add(bytes, std::memory_order_relaxed); + rad::ledger_add(p, bytes, kind); const int64_t total = rad::g_ledger[kind].count.fetch_add(1, std::memory_order_relaxed) + 1; const int64_t ordinal = kind == RAD_MEM_DEVICE ? ++t_device_ordinal : total; const int64_t floor_ = rad::trace_floor(); @@ -476,8 +497,7 @@ void* rad_dev_alloc(int64_t bytes, int kind) { return p; } void rad_dev_free(void* p, int kind) { - /* The ledger counts allocations, not live bytes: rad_dev_free has no size. The engine frees - * only at teardown, so the two agree while running. */ + rad::ledger_drop(p); dev()->free(p, kind); } void* rad_dev_host_ptr(void* p) { return dev()->host_ptr(p); } @@ -694,7 +714,7 @@ void* rad_dev_map_file(int fd, int64_t foff, int64_t bytes) { } void* p = f(fd, foff, bytes); if (p) { - rad::g_ledger[RAD_MEM_HOST_MAPPED].bytes.fetch_add(bytes, std::memory_order_relaxed); + rad::ledger_add(p, bytes, RAD_MEM_HOST_MAPPED); rad::g_ledger[RAD_MEM_HOST_MAPPED].count.fetch_add(1, std::memory_order_relaxed); } return p; diff --git a/core/device/host.cpp b/core/device/host.cpp index e739d0ac..60d28d68 100644 --- a/core/device/host.cpp +++ b/core/device/host.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -723,6 +724,21 @@ constexpr int64_t kVmemGranule = RAD_ALIGN_POOL; int64_t h_vmem_granularity(void) { return kVmemGranule; } +/* Each reservation's card, recorded at reserve: the thread that later commits into a pool, or + * releases it at teardown, may have selected another card, and the pages count against the card + * the range was reserved for (as the AQL backend's VRes does). Keyed by base. */ +struct VRange { char* end; int device; }; +std::mutex g_vres_mu; +std::map g_vres; + +int vmem_device_of(const void* addr) { + std::lock_guard lk(g_vres_mu); + auto it = g_vres.upper_bound((const char*)addr); + if (it == g_vres.begin()) return t_device; + --it; + return (const char*)addr < it->second.end ? it->second.device : t_device; +} + void* h_vmem_reserve(int64_t bytes, int64_t align) { if (bytes <= 0) return nullptr; if (align < kVmemGranule) align = kVmemGranule; @@ -740,11 +756,20 @@ void* h_vmem_reserve(int64_t bytes, int64_t align) { if (head) ::munmap(raw, head); const size_t tail = raw_len - head - (size_t)bytes; if (tail) ::munmap(base + bytes, tail); + { + std::lock_guard lk(g_vres_mu); + g_vres[base] = VRange{ base + bytes, t_device }; + } return base; } void h_vmem_release(void* base, int64_t bytes) { - if (base && bytes > 0) ::munmap(base, (size_t)bytes); + if (!base || bytes <= 0) return; + { + std::lock_guard lk(g_vres_mu); + g_vres.erase((const char*)base); + } + ::munmap(base, (size_t)bytes); } int h_vmem_commit(void* addr, int64_t bytes) { @@ -755,7 +780,7 @@ int h_vmem_commit(void* addr, int64_t bytes) { device_set_error("vmem_commit(%p, %lld): mmap failed", addr, (long long)bytes); return RAD_E_NOMEM; } - g_used[t_device].fetch_add(bytes, std::memory_order_relaxed); + g_used[vmem_device_of(addr)].fetch_add(bytes, std::memory_order_relaxed); return RAD_OK; } @@ -769,7 +794,7 @@ int h_vmem_decommit(void* addr, int64_t bytes) { device_set_error("vmem_decommit(%p, %lld): mmap failed", addr, (long long)bytes); return RAD_E_INVAL; } - g_used[t_device].fetch_sub(bytes, std::memory_order_relaxed); + g_used[vmem_device_of(addr)].fetch_sub(bytes, std::memory_order_relaxed); return RAD_OK; } diff --git a/core/engine.cpp b/core/engine.cpp index 83d8d62f..31708566 100644 --- a/core/engine.cpp +++ b/core/engine.cpp @@ -6,6 +6,7 @@ #include "gen/driver.h" #include "gen/audio_driver.h" #include "gen/video_driver.h" +#include "gen/shape_driver.h" #include "kld.h" #include "mm/processor.h" #include "mm/media.h" @@ -41,10 +42,220 @@ #include #include #include +#include #include +#ifdef RAD_ENABLE_KV_ROLLBACK_TEST_HOOK +#include +#endif + namespace rad { +#ifdef RAD_ENABLE_KV_ROLLBACK_TEST_HOOK +namespace { +struct KVRollbackTestEvidence { + bool waiting_for_greedy = false; + std::string report_path; + uint64_t seq = 0; + int step = -1; + int proposals = 0; + int accepted = -1; + int32_t group = -1; + int64_t prefix_before = 0; + int64_t rollback_tokens_before = 0; + int64_t rollback_to_tokens = 0; + int64_t prefix_after_rollback = -1; + int64_t first_block_pos = 0; + int64_t block_size = 0; + int64_t n_layers = 0; + int64_t bytes_per_layer = 0; + std::vector logical_blocks; + std::vector physical_slots; + std::vector before; + uint64_t after_hash = 0; + bool bytes_equal = false; + bool mapping_equal = false; + bool negative_control_detected = false; +}; + +uint64_t kv_test_hash(const std::vector& bytes) { + uint64_t h = 14695981039346656037ull; + for (uint8_t b : bytes) h = (h ^ b) * 1099511628211ull; + return h; +} + +bool kv_test_bytes_equal(const std::vector& a, const std::vector& b) { + return a.size() == b.size() && std::equal(a.begin(), a.end(), b.begin()); +} + +template +bool kv_test_snapshot(RankT& rank, uint64_t seq, int32_t group, int64_t prefix_tokens, + int64_t* first_block_pos, std::vector* logical, + std::vector* physical, std::vector* bytes) { + const KVGroupPlan* p = rank.kv.plan(group); + if (!p || p->zero || !p->paged() || p->kind != RAD_KV_FULL || p->streamed() || + p->n_layers <= 0 || p->block_size <= 0 || !p->base) return false; + const auto& table = rank.kv.block_table(seq, group); + const int64_t first_pos = rank.kv.first_block_pos(seq, group); + if (first_pos < 0 || prefix_tokens < first_pos) return false; + const int64_t complete = (prefix_tokens - first_pos) / p->block_size; + if (complete <= 0 || complete > (int64_t)table.size()) return false; + if (first_block_pos) *first_block_pos = first_pos; + /* Snapshot every complete block in the retained pre-verify prefix. The trailing partial + * block is omitted because accepted verify tokens may legitimately fill its unused slots. */ + const int64_t nblocks = complete; + const int64_t layer_bytes = p->layer_bytes_per_block(); + const int64_t block_bytes = p->n_layers * layer_bytes; + if (nblocks <= 0 || layer_bytes <= 0 || p->bytes_per_block != block_bytes) return false; + if (rad_dev_set(rank.device) < 0 || rad_stream_sync(rank.ctx.stream()) < 0) return false; + logical->clear(); + physical->clear(); + logical->reserve((size_t)nblocks); + physical->reserve((size_t)nblocks); + bytes->resize((size_t)nblocks * (size_t)block_bytes); + for (int64_t b = 0; b < nblocks; ++b) { + const int32_t id = table[(size_t)b]; + if (id < 0 || id >= p->pool_blocks()) return false; + logical->push_back((int32_t)(first_pos / p->block_size + b)); + physical->push_back(id); + for (int64_t layer = 0; layer < p->n_layers; ++layer) { + const auto* src = static_cast(p->base) + + layer * p->layer_stride() + (int64_t)id * layer_bytes; + auto* dst = bytes->data() + b * block_bytes + layer * layer_bytes; + if (rad_memcpy_async(dst, src, layer_bytes, rank.ctx.stream()) < 0) return false; + } + } + return rad_stream_sync(rank.ctx.stream()) >= 0; +} + +void kv_test_write_report(const KVRollbackTestEvidence& e, bool greedy, int greedy_token, + int64_t tokens_at_greedy) { + if (e.report_path.empty()) return; + std::ofstream f(e.report_path, std::ios::trunc); + if (!f) return; + f << "{\"partial_rejection_observed\":true,\"step\":" << e.step + << ",\"sequence\":" << e.seq << ",\"proposals\":" << e.proposals + << ",\"accepted\":" << e.accepted << ",\"group\":" << e.group + << ",\"prefix_tokens_before_verify\":" << e.prefix_before + << ",\"rollback_tokens_before\":" << e.rollback_tokens_before + << ",\"rollback_to_tokens\":" << e.rollback_to_tokens + << ",\"prefix_tokens_after\":" << e.prefix_after_rollback + << ",\"first_block_pos\":" << e.first_block_pos + << ",\"block_size\":" << e.block_size << ",\"layers\":" << e.n_layers + << ",\"bytes_per_layer\":" << e.bytes_per_layer << ",\"logical_blocks\":["; + for (size_t i = 0; i < e.logical_blocks.size(); ++i) f << (i ? "," : "") << e.logical_blocks[i]; + f << "],\"physical_slots\":["; + for (size_t i = 0; i < e.physical_slots.size(); ++i) f << (i ? "," : "") << e.physical_slots[i]; + f << "],\"committed_prefix_bytes\":" << e.before.size() + << ",\"before_hash\":" << kv_test_hash(e.before) + << ",\"after_hash\":" << e.after_hash + << ",\"bytes_equal\":" << (e.bytes_equal ? "true" : "false") + << ",\"mapping_equal\":" << (e.mapping_equal ? "true" : "false") + << ",\"negative_control_detected\":" << (e.negative_control_detected ? "true" : "false") + << ",\"next_greedy_decode_observed\":" << (greedy ? "true" : "false") + << ",\"tokens_at_next_greedy_decode\":" << (greedy ? tokens_at_greedy : -1) + << ",\"next_greedy_token\":" << (greedy ? greedy_token : -1) << "}\n"; +} + +KVRollbackTestEvidence& kv_test_evidence() { + static KVRollbackTestEvidence e; + return e; +} + +template +void kv_test_before_commit(const StepPlan& plan, const Output& so, int step, Ranks& ranks) { + auto& e = kv_test_evidence(); + if (!e.waiting_for_greedy && !e.report_path.empty() && e.accepted < 0) { + for (size_t i = 0; i < plan.e.size(); ++i) { + const StepEntry& entry = plan.e[i]; + if (entry.seq == e.seq && step == e.step && entry.n_spec == e.proposals && + (so.accepted[i] <= 0 || so.accepted[i] >= e.proposals)) { + e = KVRollbackTestEvidence{}; + return; + } + } + } + if (!e.waiting_for_greedy) return; + for (size_t i = 0; i < plan.e.size(); ++i) { + const StepEntry& entry = plan.e[i]; + if (entry.seq == e.seq && entry.req && entry.req->sp.greedy() && + so.first_row[i] >= 0) { + kv_test_write_report(e, true, so.token[i], ranks[0]->kv.seq_tokens(e.seq)); + e.waiting_for_greedy = false; + break; + } + } +} + +template +void kv_test_prepare(const StepPlan& plan, int step, Ranks& ranks) { + auto& e = kv_test_evidence(); + if (!e.report_path.empty() || e.waiting_for_greedy) return; + const char* path = std::getenv("RADIANCE_TEST_KV_ROLLBACK_REPORT"); + if (!path || !*path) return; + for (const StepEntry& entry : plan.e) { + if (!entry.req || entry.n_spec != 7) continue; + const int64_t prefix = entry.ctx_len; + for (int32_t g = 0; g < ranks[0]->kv.n_groups(); ++g) { + const KVGroupPlan* p = ranks[0]->kv.plan(g); + if (!p || p->kind != RAD_KV_FULL || p->zero || p->streamed() || + prefix < p->block_size) continue; + KVRollbackTestEvidence candidate; + candidate.report_path = path; + candidate.seq = entry.seq; + candidate.step = step; + candidate.proposals = entry.n_spec; + candidate.group = g; + candidate.prefix_before = prefix; + candidate.block_size = p->block_size; + candidate.n_layers = p->n_layers; + candidate.bytes_per_layer = p->layer_bytes_per_block(); + if (!kv_test_snapshot(*ranks[0], entry.seq, g, prefix, &candidate.first_block_pos, + &candidate.logical_blocks, &candidate.physical_slots, + &candidate.before)) continue; + e = std::move(candidate); + return; + } + } +} + +template +void kv_test_rollback(uint64_t seq, int proposals, int accepted, int64_t valid, + bool before, RankT& rank) { + auto& e = kv_test_evidence(); + if (e.report_path.empty() || e.waiting_for_greedy || seq != e.seq || + proposals != e.proposals || proposals != 7 || accepted <= 0 || accepted >= proposals) + return; + if (before) { + e.accepted = accepted; + e.rollback_tokens_before = rank.kv.seq_tokens(seq); + e.rollback_to_tokens = valid; + return; + } + std::vector logical, physical; + std::vector after; + int64_t first_block_pos = -1; + const bool copied = kv_test_snapshot(rank, seq, e.group, std::min(e.prefix_before, valid), + &first_block_pos, &logical, &physical, &after); + bool mapping_equal = copied && first_block_pos == e.first_block_pos && + logical == e.logical_blocks && physical == e.physical_slots; + const bool bytes_equal = copied && kv_test_bytes_equal(after, e.before); + e.after_hash = copied ? kv_test_hash(after) : 0; + e.bytes_equal = bytes_equal; + std::vector mutated = e.before; + if (!mutated.empty()) mutated[0] ^= 1; + e.negative_control_detected = !mutated.empty() && !kv_test_bytes_equal(e.before, mutated); + const int64_t after_tokens = rank.kv.seq_tokens(seq); + mapping_equal = mapping_equal && after_tokens == e.rollback_to_tokens; + e.mapping_equal = mapping_equal; + e.prefix_after_rollback = after_tokens; + kv_test_write_report(e, false, -1, -1); + e.waiting_for_greedy = true; + (void)valid; // rollback's requested length is emitted by the manager as after_tokens +} +} // namespace +#endif + /* The operator's RADIANCE_* names, captured at construction for the diagnostics report. */ Engine::Engine(Config cfg) : cfg_(std::move(cfg)), env_set_(diag::env_names(environ, "RADIANCE_")) {} @@ -108,6 +319,8 @@ Engine::~Engine() { ranks_.clear(); for (TableCopy& c : table_copies_) table_copy_free(&c); table_copies_.clear(); + for (TableCopy& c : table_files_) ::munmap(c.base, c.bytes); + table_files_.clear(); for (void* p : card_copies_) rad_dev_free(p, RAD_MEM_HOST_MAPPED); card_copies_.clear(); for (TableShare& t : table_shares_) table_share_close(&t); @@ -164,6 +377,10 @@ int Engine::declare_sampler(int rank, RadBuilder* b, int64_t logits_width, bool } sc.max_seqs = cfg_.max_seqs; sc.max_spec = cfg_.n_spec; + /* The real step bound, not the sizing declare's level: the sampler's planes must be the same + * buffers in every declare of the program (plan_level compares them), and a step can sample + * no more rows than the real bound lets it carry tokens. */ + sc.max_tok = cfg_.max_tok; sc.rank = rank; sc.world_size = cfg_.tp; sc.draft_coupling = cfg_.draft_coupling; @@ -171,11 +388,14 @@ int Engine::declare_sampler(int rank, RadBuilder* b, int64_t logits_width, bool /* Where the chain writes the sampled ids. The engine declares it because rad-kbench drives the * same chain against its own buffer. PERSIST, since the step loop copies it back after the - * step, when a transient's storage may belong to another buffer. */ + * step, when a transient's storage may belong to another buffer. One id per sampler row, + * capped as the rows are (SamplerConfig::max_tok). */ RadBufDecl d{}; d.dtype = RAD_I32; d.rank = 1; d.shape[0] = cfg_.max_seqs * (cfg_.n_spec > 0 ? cfg_.n_spec + 1 : 1); + if (cfg_.max_tok > 0) + d.shape[0] = std::min(d.shape[0], std::max(cfg_.max_tok, cfg_.max_seqs)); d.kind = RAD_BUF_PERSIST; tok = rad_decl_buffer(b, "sampler.tokens", &d); return tok ? RAD_OK : RAD_E_STATE; @@ -506,6 +726,9 @@ int Engine::issue_ahead(const RadBatch** out) { sched_.expect_draft(block_row_[(size_t)i].seq, block_steps_); const RadBatch* nb = sched_.step_next(); if (!nb) return RAD_OK; +#ifdef RAD_ENABLE_KV_ROLLBACK_TEST_HOOK + kv_test_prepare(sched_.plan(), nb->step, ranks_); +#endif /* Its rows' tokens, positions and slots, advanced on the card behind this step's acceptance * and drafts. */ RAD_TRY(advance_all(ADV_TRUNK, 0, false)); @@ -567,6 +790,15 @@ int Engine::step_loop() { return fail_loop(RAD_E_UNSUPPORTED); } const bool t_on = (int)log_level() >= (int)Log::Debug; +#ifdef RAD_ENABLE_KV_ROLLBACK_TEST_HOOK + if (std::getenv("RADIANCE_TEST_KV_ROLLBACK_REPORT")) { + sched_.set_kv_rollback_test_hook([this](uint64_t seq, int proposals, int accepted, + int64_t valid, bool before) { + if (!ranks_.empty()) kv_test_rollback(seq, proposals, accepted, valid, before, + *ranks_[0]); + }); + } +#endif /* The next step's forward pass when already issued behind the previous step, before its * readback (Scheduler::step_next). */ const RadBatch* ahead = nullptr; @@ -620,6 +852,9 @@ int Engine::step_loop() { * produces_token, 1 + n_spec rows each. Row and sequence indices differ (a mid-prompt * chunk produces no row). */ const StepPlan& plan = sched_.plan(); +#ifdef RAD_ENABLE_KV_ROLLBACK_TEST_HOOK + kv_test_prepare(plan, b->step, ranks_); +#endif /* One entry per request; Sampler::build_step expands each into 1 + n_draft rows itself * (giving each position its RNG coordinate), so one push per row would stage (1+n)^2 rows. * `first_row` indexes sampled tokens, so it counts rows. */ @@ -883,6 +1118,9 @@ int Engine::step_loop() { res.first_row = so.first_row.data(); } res.path = so.path.empty() ? nullptr : so.path.data(); +#ifdef RAD_ENABLE_KV_ROLLBACK_TEST_HOOK + kv_test_before_commit(plan, so, b->step, ranks_); +#endif st = sched_.commit(res); if (t_on) phase_mark(PH_COMMIT); if (st < 0) { RAD_ERR("commit: %s", rad_strerror(st)); return fail_loop(st); } @@ -1809,17 +2047,20 @@ int Engine::serve(std::unique_ptr watch) { embedding_ = ranks_[0]->program.pooled_buf != RAD_NULL_HANDLE; const bool audio_gen = ranks_[0]->program.is_audio_generator(); const bool video_gen = ranks_[0]->program.is_video_generator(); + const bool shape_gen = ranks_[0]->program.is_shape_generator(); const bool generator = ranks_[0]->program.is_pass_driven(); if (ranks_[0]->program.logits_buf == RAD_NULL_HANDLE && !embedding_ && !generator) { RAD_ERR("the '%s' plugin declared no logits buffer (rad_declare_logits), no pooled output " "(rad_declare_pooled) and no generator (rad_declare_generator, " - "rad_declare_audio_generator, rad_declare_video_generator), so a step produces " + "rad_declare_audio_generator, rad_declare_video_generator, " + "rad_declare_shape_generator), so a step produces " "nothing anyone can read. An encoder-only plugin cannot serve.", plugins_.arch_plugin.c_str()); return RAD_E_UNSUPPORTED; } if (generator) { - const char* const what = audio_gen ? "audio" : video_gen ? "video" : "images"; + const char* const what = audio_gen ? "audio" : video_gen ? "video" + : shape_gen ? "shapes" : "images"; if (cfg_.kld() || cfg_.n_spec > 0) { RAD_ERR("the '%s' plugin makes %s: --kld and speculative decoding have no tokens to " "work on", plugins_.arch_plugin.c_str(), what); @@ -1828,6 +2069,7 @@ int Engine::serve(std::unique_ptr watch) { for (size_t i = 1; i < ranks_.size(); ++i) if (ranks_[i]->program.is_audio_generator() != audio_gen || ranks_[i]->program.is_video_generator() != video_gen || + ranks_[i]->program.is_shape_generator() != shape_gen || !ranks_[i]->program.is_pass_driven()) { RAD_ERR("rank %zu declared a different generator from rank 0's", i); return RAD_E_STATE; @@ -1838,6 +2080,8 @@ int Engine::serve(std::unique_ptr watch) { "after them" : video_gen ? "a video generator: a prompt is read by its own request's steps and keeps no KV" + : shape_gen + ? "a shape generator: a picture is read by its own request's steps and keeps no KV" : "an image generator: a conditioning is read by its own request's images and by " "nothing after them"; decide("--no-prefix-cache", "prefix caching off", prefix_off_why_); @@ -1994,7 +2238,16 @@ int Engine::serve(std::unique_ptr watch) { rio.push_back({ rk->device, rk->ctx.stream(), &rk->program, rk->pools.kv().base(), rank_stream_views_[r].data() }); } - if (video_gen) { + if (shape_gen) { + /* As for the image generator below. */ + std::vector gio; + for (auto& rk : ranks_) gio.push_back({ rk->device, rk->ctx.stream() }); + auto d = std::make_unique(); + RAD_TRY(d->init(ranks_[0]->program, gio)); + shp_gen_ = d.get(); + gen_ = std::move(d); + RAD_TRY(rad_dev_set(ranks_[0]->device)); + } else if (video_gen) { /* As for the image generator below; the plugin lays out each request's rows. */ std::vector gio; for (auto& rk : ranks_) gio.push_back({ rk->device, rk->ctx.stream() }); @@ -2596,6 +2849,7 @@ int Engine::run_server() { o.image_model = img_gen_ != nullptr; o.audio_model = aud_gen_ != nullptr; o.video_model = vid_gen_ != nullptr; + o.shape_model = shp_gen_ != nullptr; o.decision_type = rad_meta_gets(&meta_, "decision.type", ""); /* clef's learned scalars, which the server applies to what the head returns (server/clef.h); * rad-convert writes them beside decision.type. */ @@ -2792,6 +3046,18 @@ int Engine::run_server() { return RAD_E_INVAL; } if (cfg_.image_tokens) vc.max_image_tokens = *cfg_.image_tokens; + } else if (vc.family == mm::Family::Radio) { + /* NVIDIA's processor sizes a picture and a video frame by patch budgets + * (min_num_patches..max_num_patches, video_target_num_patches), not pixel bands. */ + if (cfg_.image_min_pixels || cfg_.image_max_pixels || cfg_.image_tokens || + cfg_.video_min_pixels || cfg_.video_max_pixels || cfg_.video_max_frame_tokens) { + RAD_ERR("media: this model's processor sizes images and video frames by its patch " + "budgets (min_num_patches, max_num_patches, video_target_num_patches), so " + "--image-min/max-pixels, --image-tokens, --video-min/max-pixels and " + "--video-max-frame-tokens do nothing on it"); + return RAD_E_INVAL; + } + if (cfg_.video_min_frames) vc.min_frames = *cfg_.video_min_frames; } else { if (cfg_.image_tokens) { RAD_ERR("media: --image-tokens is a token budget, and this model's processor " @@ -2892,6 +3158,16 @@ int Engine::run_server() { ranks_[0]->program.encoder_name.c_str(), mm_proc->config().image_soft_tokens, mm_proc->config().video_soft_tokens, mm_proc->config().fps, mm_proc->config().max_frames, (long long)encd.max_patches); + else if (mm_proc->config().family == mm::Family::Radio) + RAD_INFO("media: %s%s through '%s'; an image becomes one tile of %d..%d patches " + "(a quarter as many tokens), a video frame about %d patches, %d frames a " + "tubelet at %.3g frames a second, at most %d frames, no pruning; %lld " + "patches a pass", o.allow_image ? "images" : "", + o.allow_video ? " and video" : "", ranks_[0]->program.encoder_name.c_str(), + mm_proc->config().radio_min_patches, mm_proc->config().radio_max_patches, + mm_proc->config().radio_video_patches, mm_proc->config().radio_tubelet, + mm_proc->config().fps, mm_proc->config().max_frames, + (long long)encd.max_patches); else RAD_INFO("media: %s%s through '%s'; an image resizes to at most %lld pixels (%lld " "patches a pass), a video to %lld pixels over all its frames", @@ -2961,7 +3237,13 @@ int Engine::run_server() { return rc; } o.allow_audio = true; - if (mm::decoder_available()) + if (mm::decoder_available() && ac.family == mm::AudioFamily::Gemma4Unified) + RAD_INFO("media: audio through '%s'; a clip is cut at %.3g s, a token is a frame of %d " + "samples (%d ms); %lld frames a pass", + ranks_[0]->program.audio_encoder_name.c_str(), + (double)mm_proc->audio_config().max_samples / (double)ac.rate, ac.frame_length, + ac.frame_length * 1000 / ac.rate, (long long)aend.max_patches); + else if (mm::decoder_available()) RAD_INFO("media: audio through '%s'; a clip is cut at %.3g s, %d mel bins a %d ms frame, " "%d frames a token; %lld frames a pass", ranks_[0]->program.audio_encoder_name.c_str(), @@ -3159,6 +3441,29 @@ int Engine::run_server() { /* A video generator's endpoints: the driver's queue and the declared prompt, sizes and * lengths. */ + struct ShapeBridge final : server::IShapeGen { + gen::ShapeDriver* drv = nullptr; + const gen::ShapeGenInfo& info() const override { return drv->info(); } + int submit(std::unique_ptr r, std::string* why) override { + return drv->submit(std::move(r), why); + } + int64_t queued() const override { return drv->queued(); } + int64_t running() const override { return drv->running(); } + } shape_bridge; + if (shp_gen_) { + shape_bridge.drv = shp_gen_; + d.shapes = &shape_bridge; + const gen::ShapeGenInfo& in = shp_gen_->info(); + if (cfg_.served_model_name.empty() && !in.name.empty()) { + o.model_id = in.name; + decide("--served-model-name", o.model_id, "a shape generator: its own name"); + } + RAD_INFO("shape: '%s', a %lldx%lld picture to a field sampled at %lld cells a side by " + "default (%lld..%lld), %lld steps by default at guidance %g", + in.name.c_str(), (long long)in.canvas, (long long)in.canvas, + (long long)in.default_resolution, (long long)in.min_resolution, + (long long)in.max_resolution, (long long)in.default_steps, in.default_guidance); + } struct VideoBridge final : server::IVideoGen { gen::VideoDriver* drv = nullptr; server::VideoGenInfo inf; @@ -3209,8 +3514,8 @@ int Engine::run_server() { in.decoder_max_area = pg.vgen_str.decoder_max_area; if (in.image_cond && in.image_crf > 0 && !mm::h264_roundtrip_available()) RAD_WARN("video: '%s' prepares a first frame with an H.264 round trip at crf %d, which " - "needs libx264; this build's libavcodec has none, so input_reference is " - "refused", in.name.c_str(), (int)in.image_crf); + "needs an H.264 encoder and decoder; this build's libavcodec lacks one, so " + "input_reference is refused", in.name.c_str(), (int)in.image_crf); in.max_lanes = vd.max_lanes; in.max_ref_images = vd.max_ref_images; in.max_ref_videos = vd.max_ref_videos; @@ -3308,6 +3613,9 @@ int Engine::run_server() { else if (vid_gen_) RAD_INFO("serving on http://%s:%d (/v1/videos; completions and chat are 501%s)", o.host.c_str(), o.port, keyed); + else if (shp_gen_) + RAD_INFO("serving on http://%s:%d (/generate, /send and /status/{uid}; completions and " + "chat are 501%s)", o.host.c_str(), o.port, keyed); else if (gen_) RAD_INFO("serving on http://%s:%d (/v1/images/generations%s; completions and chat are " "501%s)", o.host.c_str(), o.port, diff --git a/core/engine.h b/core/engine.h index 13bd3d43..c913d1c0 100644 --- a/core/engine.h +++ b/core/engine.h @@ -50,7 +50,7 @@ namespace rad { class Kld; class StallWatch; -namespace gen { class Driver; class AudioDriver; class VideoDriver; struct IPassDriver; } +namespace gen { class Driver; class AudioDriver; class VideoDriver; class ShapeDriver; struct IPassDriver; } namespace server { class Sink; } struct TierPump; struct TierJob; @@ -169,6 +169,7 @@ private: std::vector meta_kv_kp_, meta_kv_vp_; void (*arch_step_)(RadCtx*, const RadBatch*) = nullptr; + uint64_t (*arch_pass_key_)(RadCtx*, const RadBatch*, const int32_t*) = nullptr; int load_plugins(); int read_metadata(); @@ -254,6 +255,11 @@ private: * copies are freed, because the holder that leaves last deletes the file. */ std::vector table_shares_; std::vector> table_copy_of_; + /* --ngram-placement disk=DIR: the table's own file, mapped read-only in place of the + * container's range (table_file_map); unmapped in ~Engine. */ + std::vector table_files_; + std::vector table_file_src_; /* the container address each of table_files_ replaces */ + int table_file_map(const uint8_t* src, int64_t n, int64_t foff, void** out, std::string* why); /* --expert-profile: the decode ranking loaded once, before any rank plans, and handed to every * rank's planner in place of the container's activation profile. */ std::vector expert_profile_; @@ -431,14 +437,16 @@ private: int collect_pooled_issue(const RadBatch* b, StepOut& so); int collect_pooled(const RadBatch* b, StepOut& so); /* A generator (rad_declare_generator, rad_declare_audio_generator, - * rad_declare_video_generator): the driver that turns requests into passes and the loop that - * runs them, replacing the scheduler and step loop (engine_gen.cpp). Null for every other - * program. `img_gen_`, `aud_gen_` and `vid_gen_` are the same driver by its kind, for the - * endpoints; one of them is set when `gen_` is. */ + * rad_declare_video_generator, rad_declare_shape_generator): the driver that turns requests + * into passes and the loop that runs them, replacing the scheduler and step loop + * (engine_gen.cpp). Null for every other program. `img_gen_`, `aud_gen_`, `vid_gen_` and + * `shp_gen_` are the same driver by its kind, for the endpoints; one of them is set when + * `gen_` is. */ std::unique_ptr gen_; gen::Driver* img_gen_ = nullptr; gen::AudioDriver* aud_gen_ = nullptr; gen::VideoDriver* vid_gen_ = nullptr; + gen::ShapeDriver* shp_gen_ = nullptr; int gen_loop(); /* Zeroes the state slots the KV manager granted since the last step, on every rank's stream, * before the step or pass that first reads them. */ diff --git a/core/engine_bringup.cpp b/core/engine_bringup.cpp index 5b2db9b2..8eb83984 100644 --- a/core/engine_bringup.cpp +++ b/core/engine_bringup.cpp @@ -11,6 +11,7 @@ #include "gen/driver.h" #include "gen/audio_driver.h" #include "gen/video_driver.h" +#include "gen/shape_driver.h" #include "build/startup.h" #include "build/rad_build.h" @@ -481,6 +482,35 @@ int Engine::copy_table(const uint8_t* src, int64_t n, int64_t foff, bool card, v return RAD_OK; } +/* --ngram-placement disk=DIR: the container's [src, src + n) at file offset `foff` read from its own + * file, DIR/ngram-.bin (the table's bytes and nothing else, the id table_share_id's: the + * container's path, size and mtime and the table's place in it). The first start fills it from the + * container through a temporary name and renames it, so a file under the real name is complete; a + * later start checks samples of it against the container. Mapped read-only in place of the + * container's range, which is all the disk gather needs: it finds the file behind the mapping and + * reads it directly (libavx avx_ngram.cpp, table_file). */ +int Engine::table_file_map(const uint8_t* src, int64_t n, int64_t foff, void** out, + std::string* why) { + const auto t0 = std::chrono::steady_clock::now(); + const std::string id = table_share_id(file_->path(), foff, n); + if (id.empty()) { + *why = fmt("the container %s cannot be stat'ed, which names the table's file", file_->path()); + return RAD_E_IO; + } + const std::string& dir = cfg_.ngram_disk_dir; + const std::string path = dir + (dir.back() == '/' ? "" : "/") + "ngram-" + id + ".bin"; + TableCopy c; + bool filled = false; + const int rc = table_file_open(*file_, src, n, foff, path, &c, &filled, why); + if (rc != RAD_OK) return rc; + table_files_.push_back(c); + RAD_INFO("placement: n-gram table read from %s (%s%s, %.1f s)", path.c_str(), humanb(n).c_str(), + filled ? ", filled from the container" : "", + std::chrono::duration(std::chrono::steady_clock::now() - t0).count()); + *out = c.base; + return RAD_OK; +} + /* When --ngram-placement auto chose a pinned copy for a card and it could not be made, move the * gather to the host. Every rank's n-gram weights take the host site, in both the WeightInfo * Ctx::init reads and the plan, so the gather and its scale move together; a copy already @@ -967,6 +997,7 @@ int Engine::load_plugins() { const Plugin* ap = rad_tools_registry().plugin(plugins_.arch_plugin); arch_step_ = ap ? ap->arch_step : nullptr; + arch_pass_key_ = ap ? ap->arch_pass_key : nullptr; return RAD_OK; } @@ -1000,6 +1031,7 @@ RadBuildCtx Engine::build_ctx(int rank, int64_t max_tok) const { * fast row (RadBuildCtx::plain_norm). */ bc.plain_norm = std::strcmp(device_backend_name(), "sycl") == 0 ? 1 : 0; bc.tp_wire_min_bytes = cfg_.tp_wire_min_kb * 1024; + bc.expert_file_tier = cfg_.weights_disk_tier ? 1 : 0; bc.scope = ""; bc.max_enc_patches = cfg_.mm_max_patches > 0 ? cfg_.mm_max_patches : 0; bc.max_audio_frames = cfg_.mm_audio_frames > 0 ? cfg_.mm_audio_frames : 0; @@ -1113,6 +1145,25 @@ int Engine::declare() { if (cfg_.mm_max_patches < 0) cfg_.mm_max_patches = 0; if (cfg_.n_spec < 0) cfg_.n_spec = 0; cfg_.prefix_cache = false; + } else if (pb.gen_rows > 0 && pb.gen_shape) { + if (!cfg_.given.count("--max-num-batched-tokens")) { + cfg_.max_tok = pb.gen_rows; + decide("--max-num-batched-tokens", std::to_string(cfg_.max_tok), + "a shape generator: a denoising step's two branches or a query pass's " + "points, whichever is more"); + } + if (!cfg_.given.count("--max-num-seqs")) { + cfg_.max_seqs = 1; + decide("--max-num-seqs", "1", "a shape generator: a pass is one request's"); + } + if (!cfg_.given.count("--max-model-len") && cfg_.max_ctx == 0) { + cfg_.max_ctx = pb.gen_rows; + decide("--max-model-len", std::to_string(cfg_.max_ctx), + "a shape generator: a pass's rows"); + } + if (cfg_.mm_max_patches < 0) cfg_.mm_max_patches = 0; + if (cfg_.n_spec < 0) cfg_.n_spec = 0; + cfg_.prefix_cache = false; } else if (pb.gen_rows > 0 && pb.gen_video) { if (!cfg_.given.count("--max-num-batched-tokens")) { cfg_.max_tok = pb.gen_rows; @@ -1302,6 +1353,27 @@ int Engine::declare() { : "the model carries no vision tower"); } + /* --prefill-interleave not given: auto:1, decode-only steps for as long as a chunk step took, + * so decoders keep about half their rate while prompts prefill (measured on Flash-Next: 8 + * decoders beside a 64K prefill, 12 -> 41 tokens/s each). Not where the schedule must not + * follow timing (--deterministic) or nothing decodes beside a prefill (a generator's passes, + * KL mode's scoring); an explicit N or auto[:SHARE] is kept as given. */ + if (!cfg_.prefill_interleave_set) { + RadArchProbe pb{}; + (void)rad_tools_probe(plugins_, meta_, &pb, cfg_.image_gen_max_pixels, cfg_.image_gen_max_refs); + const char* none = pb.gen_rows > 0 ? "a generator: its passes carry no decode rows" + : cfg_.kld() ? "KL mode scores documents and decodes nothing" : nullptr; + if (none || cfg_.deterministic) { + decide("--prefill-interleave", "0", none ? none : "--deterministic keeps a " + "timing-independent schedule (--prefill-interleave N or auto overrides it)"); + } else { + cfg_.prefill_interleave = -1; + cfg_.prefill_interleave_share = 1.0; + decide("--prefill-interleave", "auto:1", "decode-only steps for as long as a chunk " + "step took while prompts prefill beside decoding sequences"); + } + } + /* Control vectors are resolved before any rank declares, because the plugin reads the * direction table from RadBuildCtx. Only `--control-vector off|on` loads one; without it * nothing is looked for and the graph declares no projection op. With it, a plugin that does @@ -1827,6 +1899,7 @@ int Engine::plan() { f.staging = r->program.is_generator() ? gen::Driver::device_bytes(r->program) : r->program.is_audio_generator() ? gen::AudioDriver::device_bytes(r->program) : r->program.is_video_generator() ? gen::VideoDriver::device_bytes(r->program) + : r->program.is_shape_generator() ? gen::ShapeDriver::device_bytes(r->program) : BatchBuilder::device_bytes(r->program, cfg_, kg); if (f.staging < 0) return RAD_E_INVAL; late_step_bytes_ = std::max(late_step_bytes_, f.staging); @@ -3052,6 +3125,26 @@ int Engine::load_weights() { "rows are read from the container%s", into, why.c_str(), card ? " by the host gather" : "")); } + /* --ngram-placement disk=DIR: the table's own file instead of the container. */ + if (cfg_.ngram_resolved == TablePlacement::Disk && !cfg_.ngram_disk_dir.empty() && + is_ngram_table(r->program, (rad_weight)i) && n >= kTableShareMin) { + void* m = nullptr; + for (size_t k = 0; k < table_files_.size() && !m; ++k) + if (table_file_src_[k] == w.host_ptr) m = table_files_[k].base; + std::string why; + if (!m) { + const int fs = table_file_map((const uint8_t*)w.ptr, n, (int64_t)p0.offset, + &m, &why); + if (fs != RAD_OK) { + RAD_ERR("--ngram-placement disk=%s: '%s': %s", + cfg_.ngram_disk_dir.c_str(), w.name.c_str(), why.c_str()); + return fs; + } + table_file_src_.push_back(w.host_ptr); + } + w.ptr = m; + w.host_ptr = m; + } /* No readahead on a mapped weight: a host kernel gathers a few rows from a table * too large to be resident, so the default 128 KiB readahead would read 32 pages * for a row of a few hundred bytes. MADV_RANDOM is per range, so the rest of the @@ -3871,6 +3964,7 @@ int Engine::start() { /* Null for all-in-VRAM: the mover never runs and lookup uses WeightInfo::ptr. */ d.residency = r->plan.strategy == Strategy::AllVram ? nullptr : r->mover.residency(); d.arch_step = arch_step_; + d.arch_pass_key = arch_pass_key_; d.profile_ops = cfg_.profile_ops; bind_kv_pools(r->program, [&](int32_t g) { return r->kv.plan(g); }, &d.kv); d.registry = &rad_tools_registry(); @@ -3916,10 +4010,15 @@ int Engine::start() { }, &r->ctx)); if (r->fstager.enabled() && r->index == 0) - RAD_INFO("file stager: %zu routed layers hold experts read from the container; each " - "pass reads a layer's (up to %s) into one of two VRAM buffers before its " - "first expert op, so every step is paced by the drive", - r->fstager.n_layers(), humanb(r->plan.file_layer_max).c_str()); + RAD_INFO("file stager: it covers %zu routed layers (a pool-cached unit of one may " + "be read from the container); each pass reads a layer's (up to %s) into one " + "of two VRAM buffers before its first expert op, so every step is paced by the drive%s", + r->fstager.n_layers(), humanb(r->plan.file_layer_max).c_str(), + r->fstager.whole_rows() > 0 + ? fmt("; a pass of %lld tokens or more reads its layers whole, each " + "while the card computes the one before", + (long long)r->fstager.whole_rows()).c_str() + : ""); if (r->stager.enabled() && r->fstager.enabled()) { r->stagers.set(&r->stager, &r->fstager); r->ctx.set_stager(&r->stagers); @@ -4138,10 +4237,16 @@ int Engine::start() { : fmt("%s --gpu-headroom-mib", humanb(want).c_str()); if (room < allowance) { const int64_t raise_mib = (allowance - room + MiB - 1) / MiB; + const int64_t need_head = std::max(cfg_.gpu_headroom_mib, 0) + raise_mib; + const std::string fix = cfg_.gpu_memory_mib > 0 + ? fmt("Set --gpu-memory-mib to at most %lld: what is left here falls with it one " + "for one.", + (long long)(props.vram_bytes / MiB - need_head)) + : fmt("Set --gpu-headroom-mib to at least %lld: what is left here rises with it " + "one for one.", (long long)need_head); RAD_WARN("card %d settled at %s free against %s, which leaves %s for a kernel's first " "launch to load its code object and size its scratch in -- under the %s this " - "engine allows for its own. %s Set --gpu-headroom-mib to at least %lld: what " - "is left here rises with it one for one.", + "engine allows for its own. %s %s", r->device, humanb(got).c_str(), asked.c_str(), humanb(std::max(room, 0)).c_str(), humanb(allowance).c_str(), got < want @@ -4149,7 +4254,7 @@ int Engine::start() { "another process on it or an allocation the budget does not " "count.", humanb(want - got).c_str()).c_str() : "", - (long long)(std::max(cfg_.gpu_headroom_mib, 0) + raise_mib)); + fix.c_str()); } else if (got < want) { RAD_INFO("card %d settled at %s free against %s: %s of the headroom was taken after " "the budget read the card, by another process on it or an allocation the " @@ -4211,6 +4316,8 @@ int Engine::load_vocab() { return RAD_E_FORMAT; } RAD_TRY(vocab_deserialize(file_->base(), (uint64_t)file_->size(), vs.h, vb)); + } else if (meta_textless(rad_meta_gets(&meta_, "radiance.text", nullptr))) { + vocab_textless(vb); } else if (ckpt_->is_gguf()) { /* GGUF names its pre-tokeniser; the chain is reconstructed from the name or refused (a * container converted with --tokenizer bakes in the declared one). */ diff --git a/core/engine_gen.cpp b/core/engine_gen.cpp index e4e02569..862f95a8 100644 --- a/core/engine_gen.cpp +++ b/core/engine_gen.cpp @@ -1,6 +1,6 @@ /* engine_gen.cpp -- a generator's loop: the driver's passes (core/gen/pass.h; driver.h for - * images, audio_driver.h for audio, video_driver.h for video) run on the ranks like token steps, one at a time, each drained - * before the next. + * images, audio_driver.h for audio, video_driver.h for video, shape_driver.h for shapes) run on the + * ranks like token steps, one at a time, each drained before the next. * * Draining is cheap: a pass is tens to thousands of milliseconds of device work, and the next * pass depends only on the driver's host bookkeeping, so the wait costs the microseconds of @@ -29,6 +29,12 @@ static const char* pass_name(int gen) { case RAD_GEN_PASS_ADECODE: return "adecode"; case RAD_GEN_PASS_VDECODE: return "vdecode"; case RAD_GEN_PASS_VUPSCALE: return "vupscale"; + case RAD_GEN_PASS_VENCODE: return "vencode"; + case RAD_GEN_PASS_AENCODE: return "aencode"; + case RAD_GEN_PASS_SCOND: return "scond"; + case RAD_GEN_PASS_SSTEP: return "sstep"; + case RAD_GEN_PASS_SLATENT: return "slatent"; + case RAD_GEN_PASS_SQUERY: return "squery"; default: return ""; } } diff --git a/core/format/checkpoint.cpp b/core/format/checkpoint.cpp index 66739bfc..0486c995 100644 --- a/core/format/checkpoint.cpp +++ b/core/format/checkpoint.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include namespace rad { @@ -54,8 +55,9 @@ void MetaOwn::finish() { * since the plugin only sees RadModelMeta, whose typed fields size everything at declare. * * A text-only model puts its dimensions at the top level; a multimodal one nests them under - * `text_config` beside `vision_config`. Every key is flattened into the free-form list by dotted - * path, and typed fields are read from `text_config.X`, falling back to `X`, so a plugin finds + * `text_config` beside `vision_config` (NVIDIA's omni wrappers: `llm_config`). Every key is + * flattened into the free-form list by dotted path, and typed fields are read from + * `text_config.X`, then `llm_config.X`, falling back to `X`, so a plugin finds * `vision_config.depth` under that name either way. */ /* An array's scalars appended to `s` space-separated, nested arrays flattened row-major (a @@ -95,10 +97,20 @@ static void flatten_json(const nlohmann::json& j, const std::string& prefix, Met else if (v.is_string()) out->kv(key, v.get()); else if (v.is_array()) { /* An array of scalars becomes a space-separated string (mrope_section "11 11 10", - * layer_types "linear_attention full_attention ..."), nested arrays row-major. - * Arrays of objects are skipped. */ + * layer_types "linear_attention full_attention ..."), nested arrays row-major. An + * array of objects is flattened element by element under its index (Nemotron-H + * Puzzle's per-layer `block_configs.1.n_routed_experts`); other mixed arrays are + * skipped. */ std::string s; - if (join_scalars(v, &s)) out->kv(key, s); + if (join_scalars(v, &s)) { + out->kv(key, s); + } else { + bool objects = !v.empty(); + for (const auto& e : v) objects = objects && e.is_object(); + if (objects) + for (size_t i = 0; i < v.size(); ++i) + flatten_json(v[i], key + "." + std::to_string(i), out); + } } } } @@ -196,31 +208,38 @@ int meta_from_config_json(const std::string& dir, MetaOwn* out) { flatten_json(j, "", out); - /* Alias text_config.X to a bare X where no bare X exists, so plugins read the same free-form - * keys (e.g. `partial_rotary_factor`) with or without a vision tower. A bare key wins where - * both exist. */ + /* Alias text_config.X (or llm_config.X) to a bare X where no bare X exists, so plugins read + * the same free-form keys (e.g. `partial_rotary_factor`) with or without a vision tower. A + * bare key wins where both exist. */ { const size_t n = out->keys.size(); - for (size_t i = 0; i < n; ++i) { - const std::string& k = out->keys[i]; - if (k.rfind("text_config.", 0) != 0) continue; - const std::string bare = k.substr(12); - bool have = false; - for (size_t j2 = 0; j2 < n; ++j2) if (out->keys[j2] == bare) { have = true; break; } - if (!have) out->kv(bare, out->vals[i]); + for (const char* pre : { "text_config.", "llm_config." }) { + const size_t len = std::strlen(pre); + for (size_t i = 0; i < n; ++i) { + const std::string& k = out->keys[i]; + if (k.rfind(pre, 0) != 0) continue; + const std::string bare = k.substr(len); + bool have = false; + for (size_t j2 = 0; j2 < out->keys.size(); ++j2) + if (out->keys[j2] == bare) { have = true; break; } + if (!have) out->kv(bare, out->vals[i]); + } } } auto gs = [&](const char* k) -> const char* { return out->get(k); }; - /* text_config first, then the top level. */ - auto gi = [&](const char* k, int64_t dflt) -> int64_t { + /* text_config first, then llm_config, then the top level. */ + auto nested = [&](const char* k) -> const char* { const char* v = gs((std::string("text_config.") + k).c_str()); - if (!v) v = gs(k); + if (!v) v = gs((std::string("llm_config.") + k).c_str()); + return v ? v : gs(k); + }; + auto gi = [&](const char* k, int64_t dflt) -> int64_t { + const char* v = nested(k); return v ? strtoll(v, nullptr, 10) : dflt; }; auto gf = [&](const char* k, double dflt) -> double { - const char* v = gs((std::string("text_config.") + k).c_str()); - if (!v) v = gs(k); + const char* v = nested(k); return v ? strtod(v, nullptr) : dflt; }; @@ -232,6 +251,11 @@ int meta_from_config_json(const std::string& dir, MetaOwn* out) { /* LFM2-VL names the wrapper, not the text model; one plugin serves LFM2 with or without * its tower. `model_type` stays in the free-form keys. */ if (out->arch == "lfm2vl") out->arch = "lfm2"; + /* Gemma 4 12B (`gemma4_unified`): its text model is Gemma 4's, served by the gemma4 + * plugins; `model_type` tells them apart. */ + if (out->arch == "gemma4unified") out->arch = "gemma4"; + /* Nemotron-H Omni wraps a Nemotron-H Puzzle text model (`llm_config`) the same way. */ + if (out->arch == "nemotronhomni") out->arch = "nemotronh"; } if (const char* nm = gs("_name_or_path")) out->name = nm; @@ -240,6 +264,15 @@ int meta_from_config_json(const std::string& dir, MetaOwn* out) { * moe_top_k. They are the last fallbacks in each chain, so a config carrying both spellings * reads the HuggingFace one. */ m.n_layers = gi("num_hidden_layers", gi("n_layer", 0)); + /* Nemotron-H Puzzle states no count: HF derives it from the per-layer list. */ + if (m.n_layers == 0) + if (const char* types = nested("layers_block_type")) + for (const char* p = types; *p;) { + while (*p == ' ') ++p; + if (!*p) break; + ++m.n_layers; + while (*p && *p != ' ') ++p; + } m.n_embd = gi("hidden_size", gi("n_embd", 0)); m.n_head = gi("num_attention_heads", gi("n_head", 0)); m.n_head_kv = gi("num_key_value_heads", m.n_head); @@ -688,6 +721,124 @@ int Checkpoint::open_diffusers() { return RAD_OK; } +/* config.yaml's maps of scalars as dotted keys, a list's items space-separated, booleans as 1 and + * 0 and a trailing comment dropped: the subset Hunyuan3D-2's configs are written in. Anything else + * (a multi-line value, a list of maps) is refused, not guessed at. */ +static int meta_from_yaml(const std::string& path, MetaOwn* out) { + std::ifstream f(path); + if (!f) { + RAD_ERR("%s: cannot read", path.c_str()); + return RAD_E_IO; + } + std::vector> stack; /* indentation, key */ + std::string line; + int ln = 0; + auto trim = [](std::string s) { + const size_t a = s.find_first_not_of(" \t\r"), b = s.find_last_not_of(" \t\r"); + return a == std::string::npos ? std::string() : s.substr(a, b - a + 1); + }; + while (std::getline(f, line)) { + ++ln; + if (const size_t h = line.find(" #"); h != std::string::npos) line.resize(h); + const std::string body = trim(line); + if (body.empty() || body[0] == '#') continue; + const size_t ind = line.find_first_not_of(' '); + const size_t colon = body.find(':'); + if (colon == std::string::npos || body[0] == '-') { + RAD_ERR("%s:%d: not a `key: value` line of the YAML this importer reads", path.c_str(), ln); + return RAD_E_FORMAT; + } + while (!stack.empty() && stack.back().first >= ind) stack.pop_back(); + const std::string key = trim(body.substr(0, colon)); + std::string val = trim(body.substr(colon + 1)); + std::string full; + for (const auto& s : stack) full += s.second + "."; + full += key; + if (val.empty()) { + stack.emplace_back(ind, key); + continue; + } + if (val.front() == '[') { + if (val.back() != ']') { + RAD_ERR("%s:%d: a list must close on its line", path.c_str(), ln); + return RAD_E_FORMAT; + } + std::string items; + for (char& ch : val) if (ch == '[' || ch == ']' || ch == ',') ch = ' '; + std::istringstream is(val); + for (std::string it; is >> it;) items += (items.empty() ? "" : " ") + it; + val = items; + } else if (val == "True" || val == "true") { + val = "1"; + } else if (val == "False" || val == "false") { + val = "0"; + } else if (val.size() >= 2 && (val.front() == '"' || val.front() == '\'') && + val.back() == val.front()) { + val = val.substr(1, val.size() - 2); + } + out->set(full, val); + } + return RAD_OK; +} + +/* A Hunyuan3D-2 shape model (tencent/Hunyuan3D-2's hunyuan3d-dit-v2-0 and its kin): a folder of + * config.yaml and one safetensors holding three networks under `model.` (the DiT), + * `conditioner.` (DINOv2's image encoder) and `vae.` (the shape VAE), the names kept. config.yaml's + * keys go into the metadata by dotted path (model.params.hidden_size, vae.params.scale_factor, + * conditioner.params.main_image_encoder.kwargs.config.num_hidden_layers, ...). The architecture + * is `hunyuan3d2`, and the model reads no text (`radiance.text` none). */ +int Checkpoint::open_hy3d(const std::string& weights) { + kind_ = SafeT; + RAD_TRY(add_shard(weights)); + RAD_TRY(meta_from_yaml(dir_ + "/config.yaml", &meta_)); + meta_.arch = "hunyuan3d2"; + meta_.set("radiance.text", "none"); + /* The typed dimensions are the denoiser's: its blocks, width and heads, read off its tensors; + * the vocabulary is the one token of a model that reads no text, and the context a step's + * rows (both branches of the 1370 conditioning rows and the latent). */ + { + RadModelMeta& m = meta_.m; + const SrcTensor* lat = find("model.latent_in.weight"); + const SrcTensor* mlp = find("model.double_blocks.0.img_mlp.0.weight"); + const SrcTensor* qn = find("model.double_blocks.0.img_attn.norm.query_norm.scale"); + const SrcTensor* vae = find("vae.post_kl.weight"); + int64_t layers = 0; + while (find("model.double_blocks." + std::to_string(layers) + ".img_mod.lin.weight")) + ++layers; + for (int64_t s = 0; find("model.single_blocks." + std::to_string(s) + ".linear1.weight"); ++s) + ++layers; + if (!lat || lat->shape.size() != 2 || !mlp || mlp->shape.size() != 2 || !qn || + qn->shape.size() != 1 || qn->shape[0] <= 0 || !vae || !layers) { + RAD_ERR("%s: Hunyuan3D-2's DiT or shape VAE is incomplete", weights.c_str()); + return RAD_E_FORMAT; + } + m.n_layers = layers; + m.n_embd = lat->shape[0]; + m.head_dim = qn->shape[0]; + m.n_head = m.n_head_kv = m.n_embd / m.head_dim; + m.n_ff = mlp->shape[0]; + m.n_vocab = 1; + m.n_ctx_train = 2 * (1370 + 3072); + m.rms_eps = 1e-6f; + m.rope_theta = 10000.0f; + m.rope_scale = 1.0f; + } + meta_.finish(); + return RAD_OK; +} + +/* Whether `file` is a Hunyuan3D-2 shape checkpoint: its DiT and image encoder by name. */ +static bool hy3d_weights(const std::string& file) { + SafeTensorsFile probe; + if (probe.open(file) != RAD_OK) return false; + bool dit = false, enc = false; + for (const auto& t : probe.tensors()) { + dit = dit || t.name == "model.latent_in.weight"; + enc = enc || t.name.rfind("conditioner.main_image_encoder.", 0) == 0; + } + return dit && enc; +} + /* A single-file Stable Diffusion XL checkpoint in Stability's (sgm) layout, the form SDXL and its * finetunes (Illustrious, NoobAI, Pony and the rest) are published in: one safetensors holding * @@ -887,6 +1038,16 @@ int Checkpoint::open_safetensors(const std::string& path) { ((path_exists(dir_ + "/model_index.json") && !path_exists(dir_ + "/config.json")) || path_exists(dir_ + "/modular_model_index.json"))) return open_diffusers(); + /* A Hunyuan3D-2 shape model: config.yaml beside its one safetensors (the fp16 one when the + * folder holds both). */ + if (!is_index && path_exists(dir_ + "/config.yaml")) { + std::string w = path; + if (!is_file) + for (const char* f : { "/model.fp16.safetensors", "/model.safetensors" }) + if (path_exists(dir_ + f)) { w = dir_ + f; break; } + if (w != path || is_file) + if (hy3d_weights(w)) return open_hy3d(w); + } if (is_file) { shards.push_back(path); /* A single-file Stable Diffusion XL checkpoint, as Stability and every SDXL finetune @@ -1274,16 +1435,17 @@ int Checkpoint::import_piece(const std::string& name, const SrcTensor** codes, if (why) *why = std::move(m); return rc; }; + const Import im = imports_at(name); /* a drafter's own form under its prefix */ /* CtFp8 has no imported form: its FP8 weights read stock (ckpt_resolve). */ - if (import_ == Import::None || import_ == Import::CtFp8) return RAD_E_NOTFOUND; + if (im == Import::None || im == Import::CtFp8) return RAD_E_NOTFOUND; if (auto hit = imported_.find(name); hit != imported_.end()) { *codes = hit->second.first; *scale = hit->second.second; return RAD_OK; } - if (import_ == Import::ParoI5 || import_ == Import::ParoI4) { - const bool i5 = import_ == Import::ParoI5; + if (im == Import::ParoI5 || im == Import::ParoI4) { + const bool i5 = im == Import::ParoI5; /* Paro int5: `X.weight` is X.qweight/.qweight_hi (codes), X.scales (f16 [G, N]) and * X.qzeros/.qzeros_hi (zero points). The view describes the logical [N, K] u5 matrix; * ckpt_plane_rows re-lays the planes row by row. */ @@ -1323,13 +1485,13 @@ int Checkpoint::import_piece(const std::string& name, const SrcTensor** codes, return RAD_OK; } - if (import_ == Import::QuarkMx || import_ == Import::ParoMx || import_ == Import::ParoM2) { + if (im == Import::QuarkMx || im == Import::ParoMx || im == Import::ParoM2) { /* Quark's MXFP4 is `fp4_e2m1*e8m0[1x32]` as stored: two codes per byte (element 2j in the * low nibble), one biased exponent per 32 of K. The view only renames dtypes and the * logical width. Excluded layers are plain tensors. ParoQuant's M2XFP4 grid carries one * more plane (`weight_meta`, [N, K/32] u8) that is handed to the weight through * import_meta: its bytes are the encoding's third plane as they ship. */ - const bool m2 = import_ == Import::ParoM2; + const bool m2 = im == Import::ParoM2; const SrcTensor* w = find(name); const SrcTensor* e = w ? find(name + "_scale") : nullptr; if (!w || !e || w->rad_dtype != RAD_U8) return RAD_E_NOTFOUND; @@ -1356,7 +1518,7 @@ int Checkpoint::import_piece(const std::string& name, const SrcTensor** codes, return RAD_OK; } - if (import_ == Import::CtInt4) { + if (im == Import::CtInt4) { /* CT-INT4: `X.weight` ships as X.weight_packed (i32 [N, K/8], eight codes per word from the * low bits, each the signed code plus 8) and X.weight_scale ([N, K/group]), and when * asymmetric X.weight_zero_point (see SrcTensor::ct_zero). compressed-tensors dequantises @@ -1427,7 +1589,7 @@ int Checkpoint::import_piece(const std::string& name, const SrcTensor** codes, return RAD_OK; } - if (import_ == Import::ModelOpt) { + if (im == Import::ModelOpt) { /* ModelOpt's NVFP4: `X.weight` U8 [N, K/2] (two e2m1 codes a byte, the even k in the low * nibble), `X.weight_scale` e4m3 [N, K/16] and `X.weight_scale_2` f32, one per tensor. * ModelOpt dequantises @@ -1483,7 +1645,7 @@ int Checkpoint::import_piece(const std::string& name, const SrcTensor** codes, return RAD_OK; } - if (import_ == Import::Nvfp4) { + if (im == Import::Nvfp4) { /* NVFP4 (compressed-tensors' nvfp4-pack-quantized): `X.weight_packed` U8 [N, K/2], two * e2m1 codes per byte with the even k in the low nibble; `X.weight_scale` e4m3 [N, K/16]; * `X.weight_global_scale` f32, one per tensor. The global scale is a divisor: the value is @@ -1661,6 +1823,36 @@ int Checkpoint::add_draft(const std::string& dir, const std::string& prefix) { std::unordered_map owner; RAD_TRY(shard_list(dir, dir + "/model.safetensors.index.json", false, &shards, &owner)); for (const auto& sh : shards) RAD_TRY(add_shard(sh, prefix, owner.empty() ? nullptr : &owner)); + /* The drafter's own quantisation. One is read: ModelOpt's NVFP4 in groups of 16 (LiLiCorr + * ships `modelopt_fp4` / `W4A16_NVFP4`: NVFP4 weights, bf16 activations, which a recipe rule + * decodes like the target's NVFP4). Its names take that form (imports_at); anything else + * quantised is refused by name rather than read as plain tensors. */ + const std::string dq = prefix + "quantization_config."; + auto qd = [&](const char* k) { + const char* v = meta_.get(dq + k); + return v ? std::string(v) : std::string(); + }; + const std::string qm = qd("quant_method"); + if (!qm.empty()) { + const std::string qa = qd("quant_algo"), gs = qd("group_size"); + const bool modelopt = qm == "modelopt" || qm == "modelopt_fp4"; + if (!modelopt || (qa != "NVFP4" && qa != "W4A16_NVFP4") || (!gs.empty() && gs != "16")) { + RAD_ERR("drafter %s: quantization_config %s / %s (group %s) is not one this reads; " + "ModelOpt's NVFP4 in groups of 16 is", dir.c_str(), qm.c_str(), qa.c_str(), + gs.empty() ? "unstated" : gs.c_str()); + return RAD_E_UNSUPPORTED; + } + if (import_ != Import::None && import_ != Import::ModelOpt) { + RAD_ERR("drafter %s: an NVFP4 drafter beside a target imported in another form is not " + "read", dir.c_str()); + return RAD_E_UNSUPPORTED; + } + draft_import_ = Import::ModelOpt; + draft_prefix_ = prefix; + /* As the target's: the tool's config is provenance, not a served format. */ + for (std::string& k : meta_.keys) + if (k.rfind(dq, 0) == 0) k = prefix + "imported_" + k.substr(prefix.size()); + } meta_.finish(); return RAD_OK; } @@ -2580,8 +2772,9 @@ int ckpt_resolve(Checkpoint& ck, const Program& prog, const std::string& name, b "rad-convert imports with its scales rounded to bf16 -- serve the " "container it writes"; } - } else if (dt == RAD_FP4E2M1 && scaled && (ck.imports() == Checkpoint::Import::Nvfp4 || - ck.imports() == Checkpoint::Import::ModelOpt)) { + } else if (dt == RAD_FP4E2M1 && scaled && + (ck.imports_at(p0.name) == Checkpoint::Import::Nvfp4 || + ck.imports_at(p0.name) == Checkpoint::Import::ModelOpt)) { /* NVFP4 as import_piece reads it: e2m1 codes beside the f32 scale the e4m3 one and the * second level make, one per 16 of K, each piece with its own second level. Not trivial * (the scale is derived), so the loader refuses it and rad-convert decodes it for a diff --git a/core/format/checkpoint.h b/core/format/checkpoint.h index 27821d4a..3ed6dd4c 100644 --- a/core/format/checkpoint.h +++ b/core/format/checkpoint.h @@ -187,6 +187,12 @@ public: enum class Import { None, Gptq, QuarkMx, CtInt4, ParoMx, ParoM2, ParoI5, ParoI4, Nvfp4, CtFp8, ModelOpt }; Import imports() const { return import_; } + /* The form `name` is read in: a drafter merged by add_draft ships its own quantisation (a + * ModelOpt NVFP4 drafter beside a bf16 target), so names under its prefix take that one. */ + Import imports_at(const std::string& name) const { + return draft_import_ != Import::None && name.rfind(draft_prefix_, 0) == 0 ? draft_import_ + : import_; + } const std::string& import_refusal() const { return import_why_; } /* The pieces an imported `name` (a `.weight`) is read from, as views owned here: GPTQ-packed @@ -209,6 +215,7 @@ private: int open_safetensors(const std::string& path); int open_diffusers(); int open_sgm(); + int open_hy3d(const std::string& weights); int add_companions(); int add_torch_files(); int open_gguf(const std::string& path); @@ -230,6 +237,9 @@ private: int64_t fp8_br_ = 128, fp8_bc_ = 128; Import import_ = Import::None; std::string import_why_; + /* add_draft's drafter, when it ships a quantisation of its own: the form and the prefix. */ + Import draft_import_ = Import::None; + std::string draft_prefix_; int64_t ct_group_ = 0; /* CtInt4: the group every weight's config states */ bool ct_asym_ = false; /* CtInt4: the config states asymmetric weights */ /* import_piece's answers by name, so a weight resolved twice reuses its views. */ diff --git a/core/format/imatrix.cpp b/core/format/imatrix.cpp index 4b9568a9..9e289d5d 100644 --- a/core/format/imatrix.cpp +++ b/core/format/imatrix.cpp @@ -56,6 +56,9 @@ struct Cursor { case GT_ARR: { uint32_t et = 0; uint64_t n = 0; if (!get(&et) || !get(&n)) return false; + /* An array of arrays is refused, as the GGUF reader refuses it: each level costs a + * file 12 bytes and this walker a stack frame. */ + if (et == GT_ARR) { ok = false; return false; } for (uint64_t i = 0; i < n && ok; ++i) if (!skip_value(et)) return false; return ok; } diff --git a/core/format/radfile.cpp b/core/format/radfile.cpp index c8167e96..9d7946d7 100644 --- a/core/format/radfile.cpp +++ b/core/format/radfile.cpp @@ -48,7 +48,7 @@ void RadFile::close() { int RadFile::read_at(void* dst, int64_t bytes, int64_t off) const { if (fd_ < 0) { RAD_ERR("read_at on a closed container"); return RAD_E_STATE; } - if (off < 0 || bytes < 0 || off + bytes > size_) { + if (off < 0 || bytes < 0 || off > size_ || bytes > size_ - off) { RAD_ERR("read_at [%lld, %lld) is outside the %lld-byte container", (long long)off, (long long)(off + bytes), (long long)size_); return RAD_E_FORMAT; @@ -210,6 +210,21 @@ int RadFile::validate() { return RAD_E_FORMAT; } + /* The tables are read in place through typed pointers, so each must sit on its element's + * alignment (the writer places every one 8-aligned), as the vocab section's arrays must. */ + auto aligned = [&](uint64_t off, uint64_t count, size_t align, const char* what) { + if (count == 0 || off % align == 0) return true; + RAD_ERR("%s: %s starts at %llu, which is not %zu-aligned", path_.c_str(), what, + (unsigned long long)off, align); + return false; + }; + if (!aligned(hdr_->meta_off, hdr_->meta_count, alignof(RadFileKV), "the metadata table") || + !aligned(hdr_->dir_off, hdr_->dir_count, alignof(RadFileEntry), "the weight directory") || + !aligned(hdr_->plane_off, hdr_->plane_count, alignof(RadFilePlane), "the plane table") || + !aligned(hdr_->enc_off, hdr_->enc_count, alignof(RadEncoding), "the encoding table") || + !aligned(hdr_->prof_off, hdr_->prof_count, alignof(RadFileProfile), "the expert profile")) + return RAD_E_FORMAT; + meta_ = (const RadFileKV*)(base_ + hdr_->meta_off); dir_ = (const RadFileEntry*)(base_ + hdr_->dir_off); planes_ = (const RadFilePlane*)(base_ + hdr_->plane_off); @@ -335,18 +350,21 @@ int RadFile::validate() { } const RadVocabHeader* v = (const RadVocabHeader*)(base_ + voff); /* Offset 0 means an optional array is absent (scores are unigram-only; types default to - * normal). Nothing real lives at file offset 0. */ - auto arr_ok = [&](uint64_t off, uint64_t bytes, size_t align) { - return bytes == 0 || off == 0 || - (off >= voff && off - voff <= vbytes && bytes <= vbytes - (off - voff) && - off % align == 0); + * normal). Nothing real lives at file offset 0. Token texts, merges and steps are not + * optional: the writer places each one its count says exists, and a reader handed a + * count with no array would read the file header in its place. */ + auto arr_ok = [&](uint64_t off, uint64_t bytes, size_t align, bool optional) { + if (bytes == 0) return true; + if (off == 0) return optional; + return off >= voff && off - voff <= vbytes && bytes <= vbytes - (off - voff) && + off % align == 0; }; const uint64_t nt = v->n_tokens, nm = v->n_merges, ns = v->n_steps; - if (!arr_ok(v->tok_text_off, nt * sizeof(rad_stroff), alignof(rad_stroff)) || - !arr_ok(v->tok_score_off, nt * sizeof(float), alignof(float)) || - !arr_ok(v->tok_type_off, nt, 1) || - !arr_ok(v->merge_off, nm * 2 * sizeof(uint32_t), alignof(uint32_t)) || - !arr_ok(v->step_off, ns * sizeof(RadVocabStep), alignof(RadVocabStep))) { + if (!arr_ok(v->tok_text_off, nt * sizeof(rad_stroff), alignof(rad_stroff), false) || + !arr_ok(v->tok_score_off, nt * sizeof(float), alignof(float), true) || + !arr_ok(v->tok_type_off, nt, 1, true) || + !arr_ok(v->merge_off, nm * 2 * sizeof(uint32_t), alignof(uint32_t), false) || + !arr_ok(v->step_off, ns * sizeof(RadVocabStep), alignof(RadVocabStep), false)) { RAD_ERR("%s: the %s section's arrays do not fit inside it, or one is not aligned to its " "element", path_.c_str(), what); @@ -458,7 +476,17 @@ int RadFile::index_experts() { return RAD_E_FORMAT; } const uint64_t ebase = dir_[j].offset; - if (e_id == 1) g.stride = ebase - g.base; + if (e_id == 1) { + /* Expert 1 defines the stride, so the arithmetic test below cannot check it: it + * must step forward by at least one whole unit, or experts overlap (or wrap). */ + if (ebase < g.base || ebase - g.base < g.unit_bytes) { + RAD_ERR("%s: layer %d expert 1 starts at %llu, inside or before expert 0's " + "%llu bytes at %llu", path_.c_str(), layer, (unsigned long long)ebase, + (unsigned long long)g.unit_bytes, (unsigned long long)g.base); + return RAD_E_FORMAT; + } + g.stride = ebase - g.base; + } if (ebase != g.base + (uint64_t)e_id * g.stride) { RAD_ERR("%s: layer %d expert %d starts at %llu, but base + %d*%llu is %llu -- the " "layer has no fixed stride and cannot be addressed by arithmetic", @@ -565,8 +593,16 @@ void RadWriter::abort() { /* The file is the caller's container: restore its header (a no-op unless finish_append() * failed in that write) and truncate the tail. */ if (fd_out_ >= 0) { - (void)!::pwrite(fd_out_, &old_hdr_, sizeof old_hdr_, 0); - (void)!::ftruncate(fd_out_, (off_t)old_size_); + /* A failed restore leaves a file that is neither the old container nor the new one, + * and the caller has only been told that the write failed. */ + const bool hdr_ok = ::pwrite(fd_out_, &old_hdr_, sizeof old_hdr_, 0) == + (ssize_t)sizeof old_hdr_; + const bool cut_ok = ::ftruncate(fd_out_, (off_t)old_size_) == 0; + if (!hdr_ok || !cut_ok) + RAD_ERR("%s: the append was undone only in part (%s) -- the container is damaged; " + "restore it from a copy", path_.c_str(), + !hdr_ok ? "its header could not be rewritten" + : "its tail could not be cut back"); ::close(fd_out_); } if (fd_spill_ >= 0) ::close(fd_spill_); @@ -1009,8 +1045,11 @@ int RadWriter::set_vocab_section(const void* blob, int64_t bytes) { !fits(h->tok_score_off, h->tok_score_off ? (uint64_t)h->n_tokens * sizeof(float) : 0) || !fits(h->tok_type_off, h->tok_type_off ? h->n_tokens : 0) || !fits(h->merge_off, (uint64_t)h->n_merges * 2 * sizeof(uint32_t)) || - !fits(h->step_off, (uint64_t)h->n_steps * sizeof(RadVocabStep))) { - RAD_ERR("the vocab section's arrays do not fit inside its %lld bytes. Its offsets must be " + !fits(h->step_off, (uint64_t)h->n_steps * sizeof(RadVocabStep)) || + (h->n_tokens && !h->tok_text_off) || (h->n_merges && !h->merge_off) || + (h->n_steps && !h->step_off)) { + RAD_ERR("the vocab section's arrays do not fit inside its %lld bytes, or one its count " + "names is absent. Its offsets must be " "SECTION-RELATIVE -- serialise with a section_file_off of 0 and let finish() " "rebase them.", (long long)bytes); return RAD_E_INVAL; diff --git a/core/format/safetensors.cpp b/core/format/safetensors.cpp index e83b8775..e5bcf5df 100644 --- a/core/format/safetensors.cpp +++ b/core/format/safetensors.cpp @@ -295,7 +295,13 @@ int SafeTensorsFile::open(const std::string& path) { return RAD_E_FORMAT; } - index_.emplace(t.name, tensors_.size()); + /* A JSON object's keys are unique; a header naming one tensor twice has two answers to + * find() and is refused rather than resolved to the first. */ + if (!index_.emplace(t.name, tensors_.size()).second) { + RAD_ERR("%s: the header names '%s' twice", path.c_str(), name.c_str()); + close(); + return RAD_E_FORMAT; + } tensors_.push_back(std::move(t)); if (!sc.eat(',')) break; diff --git a/core/format/share.cpp b/core/format/share.cpp index f038ba09..8b400d07 100644 --- a/core/format/share.cpp +++ b/core/format/share.cpp @@ -155,6 +155,20 @@ int weight_share(const WeightInfo& w, const RadEncoding& enc, uint32_t rank, con } } + /* The view's rectangles come from plugin-stated spans and parts, sum-checked only. A single + * selected plane takes them as its own rectangles below, with no enc_plane_rect to bound + * them, so every one is held to the entry here. */ + for (int g = 0; !whole && g < w.n_part_spans; ++g) + if (w.part_lo[g] < 0 || w.part_lo[g] > w.part_hi[g] || w.part_hi[g] > w.part_total[g]) + return refuse(fmt("part %d's span [%lld, %lld) is outside its %lld", g, + (long long)w.part_lo[g], (long long)w.part_hi[g], + (long long)w.part_total[g])); + for (const VRect& q : view) + if (q.r0 < 0 || q.r0 > q.r1 || q.r1 > VR || q.c0 < 0 || q.c0 > q.c1 || q.c1 > VC) + return refuse(fmt("the slice [%lld, %lld) x [%lld, %lld) is outside the entry's " + "%lld x %lld", (long long)q.r0, (long long)q.r1, (long long)q.c0, + (long long)q.c1, (long long)VR, (long long)VC)); + for (int k = 0; k < w.n_sel; ++k) { const RadEncPlane& p = enc.plane[w.sel[k]]; PlaneShare& s = out[k]; @@ -186,7 +200,10 @@ int weight_share(const WeightInfo& w, const RadEncoding& enc, uint32_t rank, con return refuse(fmt("columns [%lld, %lld) of the %s '%s' plane do not fall on whole " "bytes", (long long)pq.col0, (long long)(pq.col0 + pq.cols), rad_dtype_name(p.dtype), p.role)); - if (!s.rects.empty() && pq.cols != s.cols) + /* A vector's stacked parts lie end to end as one row, so they may differ in width (a + * Mamba convolution's bias is [x | B | C]); a matrix's parts stack as rows. */ + const bool vec = rank == 1 && pq.rows == 1; + if (!vec && !s.rects.empty() && pq.cols != s.cols) return refuse("the share's parts differ in width"); PlaneShare::Rect r; r.row0 = pq.row0; @@ -194,11 +211,16 @@ int weight_share(const WeightInfo& w, const RadEncoding& enc, uint32_t rank, con r.byte0 = pq.col0 * bits / 8; r.bytes = rad_enc_row_bytes(p.dtype, pq.cols); s.rects.push_back(r); - s.rows += pq.rows; - s.cols = pq.cols; + if (vec) { + s.rows = 1; + s.cols += pq.cols; + } else { + s.rows += pq.rows; + s.cols = pq.cols; + } } - /* A vector's stacked parts come out as one piece a part, each a row of the share; laid - * end to end they are the declared vector, so only the element count has to agree. */ + /* Laid end to end, a vector's parts are the declared vector, so only the element count + * has to agree. */ const bool fits = rank == 1 ? s.rows * s.cols == w.sel_rows[k] * w.sel_cols[k] : s.rows == w.sel_rows[k] && s.cols == w.sel_cols[k]; if (!fits) diff --git a/core/format/table_copy.cpp b/core/format/table_copy.cpp index 727fbde1..b6e37033 100644 --- a/core/format/table_copy.cpp +++ b/core/format/table_copy.cpp @@ -3,7 +3,10 @@ #include "../rad_internal.h" +#include #include +#include +#include #include #include @@ -91,6 +94,69 @@ int table_copy_make(const RadFile& file, const uint8_t* src, int64_t n, int64_t return RAD_OK; } +int table_file_open(const RadFile& file, const uint8_t* src, int64_t n, int64_t foff, + const std::string& path, TableCopy* out, bool* filled, std::string* why) { + if (!out || !filled || !why || !src || n <= 0 || path.empty()) return RAD_E_INVAL; + *out = TableCopy{}; + *filled = false; + struct stat st; + if (::stat(path.c_str(), &st) != 0 || st.st_size != n) { + const std::string tmp = path + ".part"; + const int fd = ::open(tmp.c_str(), O_RDWR | O_CREAT | O_TRUNC | O_CLOEXEC, 0644); + if (fd < 0) { + *why = fmt("creating %s: %s", tmp.c_str(), std::strerror(errno)); + return RAD_E_IO; + } + void* m = MAP_FAILED; + if (::ftruncate(fd, (off_t)n) == 0) + m = ::mmap(nullptr, (size_t)n, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + if (m == MAP_FAILED) { + *why = fmt("sizing %s to %s: %s", tmp.c_str(), humanb(n).c_str(), std::strerror(errno)); + ::close(fd); + ::unlink(tmp.c_str()); + return RAD_E_IO; + } + int rc = table_copy_fill(file, src, n, foff, static_cast(m), why); + if (rc == RAD_OK && (::msync(m, (size_t)n, MS_SYNC) != 0 || ::fsync(fd) != 0)) { + *why = fmt("writing %s: %s", tmp.c_str(), std::strerror(errno)); + rc = RAD_E_IO; + } + ::munmap(m, (size_t)n); + ::close(fd); + if (rc == RAD_OK && ::rename(tmp.c_str(), path.c_str()) != 0) { + *why = fmt("renaming %s: %s", tmp.c_str(), std::strerror(errno)); + rc = RAD_E_IO; + } + if (rc != RAD_OK) { + ::unlink(tmp.c_str()); + return rc; + } + *filled = true; + } + const int fd = ::open(path.c_str(), O_RDONLY | O_CLOEXEC); + if (fd < 0) { + *why = fmt("opening %s: %s", path.c_str(), std::strerror(errno)); + return RAD_E_IO; + } + void* m = ::mmap(nullptr, (size_t)n, PROT_READ, MAP_SHARED, fd, 0); + ::close(fd); + if (m == MAP_FAILED) { + *why = fmt("mapping %s: %s", path.c_str(), std::strerror(errno)); + return RAD_E_IO; + } + if (!*filled) { + const int rc = table_copy_check(src, n, static_cast(m), why); + if (rc != RAD_OK) { + ::munmap(m, (size_t)n); + *why = fmt("%s does not match the container (%s); remove it and it is filled again", + path.c_str(), why->c_str()); + return rc; + } + } + *out = TableCopy{ m, (size_t)n }; + return RAD_OK; +} + void table_copy_free(TableCopy* c) { if (!c || !c->base) return; ::munlock(c->base, c->bytes); diff --git a/core/format/table_copy.h b/core/format/table_copy.h index ba490a04..6cff6222 100644 --- a/core/format/table_copy.h +++ b/core/format/table_copy.h @@ -37,6 +37,14 @@ int table_copy_fill(const RadFile& file, const uint8_t* src, int64_t n, int64_t * another process filled. */ int table_copy_check(const uint8_t* src, int64_t n, const uint8_t* buf, std::string* why); +/* --ngram-placement disk=DIR: [src, src + n) read from its own file `path` (the table's bytes and + * nothing else), mapped read-only in `out` (`bytes` = n). A missing file, or one of another size, is + * filled from the container under `path`.part and renamed, so a file under `path` is complete + * (`*filled` true); an existing one is checked as table_copy_check checks. The disk gather finds the + * file behind the mapping and reads it directly. Release with munmap(out->base, out->bytes). */ +int table_file_open(const RadFile& file, const uint8_t* src, int64_t n, int64_t foff, + const std::string& path, TableCopy* out, bool* filled, std::string* why); + /* Unlock and unmap; a no-op for a copy never made. */ void table_copy_free(TableCopy* c); diff --git a/core/format/tunecache.cpp b/core/format/tunecache.cpp index 06069234..8e4ecdd4 100644 --- a/core/format/tunecache.cpp +++ b/core/format/tunecache.cpp @@ -175,10 +175,15 @@ int TuneCache::load(const std::string& home, const std::string& machine) { continue; } if (tok[0] == "machine") { - if (tok.size() >= 2 && std::string(tok[1]) != machine) - RAD_WARN("%s: measured on '%.*s' but this machine is '%s' -- the rows may not " - "describe this card", path.c_str(), (int)tok[1].size(), tok[1].data(), - machine.c_str()); + /* A cache from another card is wrong, not just slow (tunecache.h): a file renamed or + * copied to this machine's name is refused, as another format version is. */ + if (tok.size() >= 2 && std::string(tok[1]) != machine) { + RAD_WARN("%s: measured on '%.*s' but this machine is '%s' -- ignoring the cache", + path.c_str(), (int)tok[1].size(), tok[1].data(), machine.c_str()); + std::free(line); + ::fclose(f); + return RAD_E_FORMAT; + } continue; } if (tok.size() < 5) { ++bad; continue; } diff --git a/core/gen/shape.cpp b/core/gen/shape.cpp new file mode 100644 index 00000000..726129c9 --- /dev/null +++ b/core/gen/shape.cpp @@ -0,0 +1,771 @@ +/* shape.cpp -- the shape generator's host geometry (shape.h): the picture, the sampler's grid, the + * field's levels, marching cubes and the mesh's files; and the ticket a caller waits on. */ +#include "shape.h" +#include "rad_internal.h" + +#include + +#include +#include +#include +#include +#include + +namespace rad { +namespace gen { + +ShapeGenInfo shape_info(const RadShapeGenDecl& d, const std::string& name) { + ShapeGenInfo g; + g.name = name; + g.canvas = d.canvas; + g.enc_size = d.enc_size; + g.enc_patch = d.enc_patch; + g.border_ratio = d.border_ratio; + for (int c = 0; c < 3; ++c) { g.pix_mean[c] = d.pix_mean[c]; g.pix_std[c] = d.pix_std[c]; } + g.default_steps = d.default_steps; + g.max_steps = d.max_steps; + g.default_guidance = d.default_guidance; + g.bounds = d.bounds; + g.level = d.level; + g.default_resolution = d.default_resolution; + g.min_resolution = d.min_resolution; + g.max_resolution = d.max_resolution; + g.max_lanes = d.max_lanes; + return g; +} + +/* ================================================================== the picture */ +namespace { + +/* An 8-bit image, `ch` channels interleaved. */ +struct Img { + int32_t w = 0, h = 0, ch = 0; + std::vector px; + uint8_t* at(int32_t y, int32_t x) { return px.data() + ((size_t)y * w + x) * ch; } + const uint8_t* at(int32_t y, int32_t x) const { return px.data() + ((size_t)y * w + x) * ch; } +}; + +/* OpenCV's saturate_cast of a float: round half to even, clipped. */ +inline uint8_t sat_u8(float v) { + const float r = std::nearbyint(v); + return (uint8_t)(r < 0.0f ? 0.0f : r > 255.0f ? 255.0f : r); +} + +/* cv::resize's INTER_AREA when it shrinks both sides: computeResizeAreaTab's weights, a row's + * horizontal sums, then the weighted rows, in float. */ +struct AreaTap { int32_t di, si; float alpha; }; +std::vector area_tab(int32_t ssize, int32_t dsize, double scale) { + std::vector tab; + for (int32_t dx = 0; dx < dsize; ++dx) { + const double fsx1 = dx * scale, fsx2 = fsx1 + scale; + const double cell = std::min(scale, ssize - fsx1); + int32_t sx1 = (int32_t)std::ceil(fsx1), sx2 = (int32_t)std::floor(fsx2); + sx2 = std::min(sx2, ssize - 1); + sx1 = std::min(sx1, sx2); + if (sx1 - fsx1 > 1e-3) tab.push_back({ dx, sx1 - 1, (float)((sx1 - fsx1) / cell) }); + for (int32_t sx = sx1; sx < sx2; ++sx) tab.push_back({ dx, sx, (float)(1.0 / cell) }); + if (fsx2 - sx2 > 1e-3) + tab.push_back({ dx, sx2, (float)(std::min(std::min(fsx2 - sx2, 1.0), cell) / cell) }); + } + return tab; +} + +void resize_area_down(const Img& s, int32_t dw, int32_t dh, Img* d) { + const double sx = (double)s.w / dw, sy = (double)s.h / dh; + const std::vector xt = area_tab(s.w, dw, sx), yt = area_tab(s.h, dh, sy); + const int32_t ch = s.ch; + std::vector row((size_t)dw * ch), acc((size_t)dw * ch); + d->w = dw; d->h = dh; d->ch = ch; + d->px.assign((size_t)dw * dh * ch, 0); + size_t k = 0; + for (int32_t dy = 0; dy < dh; ++dy) { + std::fill(acc.begin(), acc.end(), 0.0f); + for (; k < yt.size() && yt[k].di == dy; ++k) { + std::fill(row.begin(), row.end(), 0.0f); + const uint8_t* src = s.at(yt[k].si, 0); + for (const AreaTap& t : xt) + for (int32_t c = 0; c < ch; ++c) + row[(size_t)t.di * ch + c] += src[(size_t)t.si * ch + c] * t.alpha; + for (size_t i = 0; i < acc.size(); ++i) acc[i] += row[i] * yt[k].alpha; + } + uint8_t* dst = d->at(dy, 0); + for (size_t i = 0; i < acc.size(); ++i) dst[i] = sat_u8(acc[i]); + } +} + +/* cv::resize's fixed-point separable filter for 8-bit images: each tap's float coefficient + * rounded to 11 bits, the horizontal sums in int, the vertical sum shifted back by 22 with + * rounding. `taps` coefficients a destination pixel, first at source index ofs[d] (indices + * clamped to the image, OpenCV's BORDER_REPLICATE). */ +struct Taps { + int32_t ksize = 0; + std::vector ofs; + std::vector c; +}; + +Taps taps_linear_area(int32_t ssize, int32_t dsize) { + /* INTER_AREA when it does not shrink both sides: linear taps in OpenCV's area mode. */ + const double scale = (double)ssize / dsize, inv = (double)dsize / ssize; + Taps t; + t.ksize = 2; + for (int32_t dx = 0; dx < dsize; ++dx) { + const int32_t sx = (int32_t)std::floor(dx * scale); + float fx = (float)((dx + 1) - (sx + 1) * inv); + fx = fx <= 0 ? 0.0f : fx - std::floor(fx); + t.ofs.push_back(sx); + t.c.push_back((int16_t)std::nearbyint((1.0f - fx) * 2048.0f)); + t.c.push_back((int16_t)std::nearbyint(fx * 2048.0f)); + } + return t; +} + +Taps taps_cubic(int32_t ssize, int32_t dsize) { + const double scale = (double)ssize / dsize; + const float A = -0.75f; + Taps t; + t.ksize = 4; + for (int32_t dx = 0; dx < dsize; ++dx) { + float fx = (float)((dx + 0.5) * scale - 0.5); + const int32_t sx = (int32_t)std::floor(fx); + fx -= sx; + float w[4]; + w[0] = ((A * (fx + 1) - 5 * A) * (fx + 1) + 8 * A) * (fx + 1) - 4 * A; + w[1] = ((A + 2) * fx - (A + 3)) * fx * fx + 1; + w[2] = ((A + 2) * (1 - fx) - (A + 3)) * (1 - fx) * (1 - fx) + 1; + w[3] = 1.0f - w[0] - w[1] - w[2]; + t.ofs.push_back(sx - 1); + for (float v : w) t.c.push_back((int16_t)std::nearbyint(v * 2048.0f)); + } + return t; +} + +void resize_fixed(const Img& s, const Taps& tx, const Taps& ty, int32_t dw, int32_t dh, Img* d) { + const int32_t ch = s.ch; + /* Every source row through the horizontal taps, then each destination row from its rows. */ + std::vector hrow((size_t)s.h * dw * ch); + for (int32_t y = 0; y < s.h; ++y) + for (int32_t dx = 0; dx < dw; ++dx) + for (int32_t c = 0; c < ch; ++c) { + int32_t sum = 0; + for (int32_t k = 0; k < tx.ksize; ++k) { + const int32_t sx = std::clamp(tx.ofs[(size_t)dx] + k, 0, s.w - 1); + sum += s.at(y, sx)[c] * tx.c[(size_t)dx * tx.ksize + k]; + } + hrow[((size_t)y * dw + dx) * ch + c] = sum; + } + d->w = dw; d->h = dh; d->ch = ch; + d->px.assign((size_t)dw * dh * ch, 0); + for (int32_t dy = 0; dy < dh; ++dy) + for (int32_t i = 0; i < dw * ch; ++i) { + int64_t v = 0; + for (int32_t k = 0; k < ty.ksize; ++k) { + const int32_t sy = std::clamp(ty.ofs[(size_t)dy] + k, 0, s.h - 1); + v += (int64_t)hrow[(size_t)sy * dw * ch + i] * ty.c[(size_t)dy * ty.ksize + k]; + } + const int64_t r = (v + (1 << 21)) >> 22; + d->px[(size_t)dy * dw * ch + i] = (uint8_t)std::clamp(r, 0, 255); + } +} + +/* cv2.resize(src, (dw, dh), INTER_AREA). */ +void resize_area(const Img& s, int32_t dw, int32_t dh, Img* d) { + if (dw == s.w && dh == s.h) { *d = s; return; } + if (s.w >= dw && s.h >= dh) { resize_area_down(s, dw, dh, d); return; } + resize_fixed(s, taps_linear_area(s.w, dw), taps_linear_area(s.h, dh), dw, dh, d); +} + +/* cv2.resize(src, (dw, dh), INTER_CUBIC). */ +void resize_cubic(const Img& s, int32_t dw, int32_t dh, Img* d) { + if (dw == s.w && dh == s.h) { *d = s; return; } + resize_fixed(s, taps_cubic(s.w, dw), taps_cubic(s.h, dh), dw, dh, d); +} + +/* torchvision's antialiased bilinear resize along one axis (align_corners false): the triangle + * filter around each output's centre, widened by the scale when shrinking, normalised over the + * taps inside the image. */ +struct AaTaps { std::vector lo; std::vector> w; }; +AaTaps aa_taps(int32_t in, int32_t out) { + const double scale = (double)in / out; + const double support = scale >= 1.0 ? scale : 1.0; + const double inv = scale >= 1.0 ? 1.0 / scale : 1.0; + AaTaps t; + for (int32_t i = 0; i < out; ++i) { + const double center = scale * (i + 0.5); + const int32_t lo = std::max((int32_t)(center - support + 0.5), 0); + const int32_t hi = std::min((int32_t)(center + support + 0.5), in); + std::vector w; + double total = 0.0; + for (int32_t j = lo; j < hi; ++j) { + const double x = std::fabs((j - center + 0.5) * inv); + const double v = x < 1.0 ? 1.0 - x : 0.0; + w.push_back((float)v); + total += v; + } + if (total > 0.0) for (float& v : w) v = (float)(v / total); + t.lo.push_back(lo); + t.w.push_back(std::move(w)); + } + return t; +} + +} /* namespace */ + +int shape_picture(const ShapeGenInfo& g, const mm::FrameRGBA& rgba, std::vector* patches, + std::string* why) { + auto no = [&](const std::string& w) { + if (why) *why = w; + return RAD_E_INVAL; + }; + const int32_t H = rgba.h, W = rgba.w; + if (H < 1 || W < 1 || rgba.rgba.size() != (size_t)H * W * 4) return no("the picture is empty"); + /* ---- ImageProcessorV2.recenter: the alpha's bounding box on a square of the longer side */ + int32_t y0 = H, y1 = -1, x0 = W, x1 = -1; + for (int32_t y = 0; y < H; ++y) + for (int32_t x = 0; x < W; ++x) + if (rgba.rgba[((size_t)y * W + x) * 4 + 3]) { + y0 = std::min(y0, y); y1 = std::max(y1, y); + x0 = std::min(x0, x); x1 = std::max(x1, x); + } + if (y1 < 0) return no("the picture is fully transparent: nothing to make a shape of"); + const int32_t h = y1 - y0, w = x1 - x0; + if (h == 0 || w == 0) + return no("the picture's opaque part is a single row or column: nothing to make a shape " + "of"); + const int32_t size = std::max(H, W); + const int32_t desired = (int32_t)(size * (1.0 - g.border_ratio)); + const double scale = (double)desired / std::max(h, w); + const int32_t h2 = (int32_t)(h * scale), w2 = (int32_t)(w * scale); + if (h2 < 1 || w2 < 1) + return no("the picture's opaque part is too thin to scale onto the canvas"); + Img crop; + crop.w = w; crop.h = h; crop.ch = 4; + crop.px.resize((size_t)w * h * 4); + for (int32_t y = 0; y < h; ++y) + std::memcpy(crop.at(y, 0), rgba.rgba.data() + ((size_t)(y0 + y) * W + x0) * 4, + (size_t)w * 4); + Img fit; + resize_area(crop, w2, h2, &fit); + const int32_t oy = (size - h2) / 2, ox = (size - w2) / 2; + /* Flattened onto white in float, then truncated to 8 bits, as numpy's astype does. */ + Img sq; + sq.w = size; sq.h = size; sq.ch = 3; + sq.px.assign((size_t)size * size * 3, 255); + for (int32_t y = 0; y < h2; ++y) + for (int32_t x = 0; x < w2; ++x) { + const uint8_t* p = fit.at(y, x); + const float a = (float)p[3] / 255.0f; + uint8_t* q = sq.at(oy + y, ox + x); + for (int c = 0; c < 3; ++c) { + const float v = (float)p[c] * a + 255.0f * (1.0f - a); + q[c] = (uint8_t)std::clamp(v, 0.0f, 255.0f); + } + } + /* ---- the canvas, INTER_CUBIC */ + const int32_t C = (int32_t)g.canvas; + Img can; + resize_cubic(sq, C, C, &can); + /* ---- the encoder's transform: 0..1, bilinear (antialiased) to enc_size, normalised */ + const int32_t E = (int32_t)g.enc_size, P = (int32_t)g.enc_patch, G = E / P; + const AaTaps ta = aa_taps(C, E); + std::vector hor((size_t)C * E * 3), img((size_t)E * E * 3); + for (int32_t y = 0; y < C; ++y) + for (int32_t x = 0; x < E; ++x) + for (int c = 0; c < 3; ++c) { + float s = 0.0f; + const std::vector& wt = ta.w[(size_t)x]; + for (size_t k = 0; k < wt.size(); ++k) + s += wt[k] * ((float)can.at(y, ta.lo[(size_t)x] + (int32_t)k)[c] / 255.0f); + hor[((size_t)y * E + x) * 3 + c] = s; + } + for (int32_t y = 0; y < E; ++y) + for (int32_t x = 0; x < E; ++x) + for (int c = 0; c < 3; ++c) { + float s = 0.0f; + const std::vector& wt = ta.w[(size_t)y]; + for (size_t k = 0; k < wt.size(); ++k) + s += wt[k] * hor[(((size_t)ta.lo[(size_t)y] + k) * E + x) * 3 + c]; + img[((size_t)y * E + x) * 3 + c] = + (float)((s - g.pix_mean[c]) / g.pix_std[c]); + } + /* ---- patches, row-major; a patch's values (channel, row, column) */ + const int64_t pd = 3 * (int64_t)P * P; + patches->assign((size_t)G * G * pd, 0.0f); + for (int32_t py = 0; py < G; ++py) + for (int32_t px = 0; px < G; ++px) { + float* o = patches->data() + ((size_t)py * G + px) * pd; + for (int c = 0; c < 3; ++c) + for (int32_t i = 0; i < P; ++i) + for (int32_t j = 0; j < P; ++j) + o[((size_t)c * P + i) * P + j] = + img[(((size_t)py * P + i) * E + px * P + j) * 3 + c]; + } + return RAD_OK; +} + +/* ================================================================== the sampler and the grid */ +std::vector shape_sigmas(int32_t steps) { + std::vector s; + if (steps < 2) return s; + const double step = 1.0 / (steps - 1); + for (int32_t i = 0; i < steps; ++i) s.push_back(i == steps - 1 ? 1.0f : (float)(i * step)); + return s; +} + +std::vector shape_levels(int32_t resolution) { + std::vector r; + if (resolution < 63) r.push_back(resolution); + for (int32_t v = resolution; v >= 63; v /= 2) r.push_back(v); + std::reverse(r.begin(), r.end()); + return r; +} + +std::vector shape_axis(double bounds, int32_t r) { + std::vector a((size_t)r + 1); + const double step = 2.0 * bounds / r; + for (int32_t i = 0; i <= r; ++i) a[(size_t)i] = (float)(i * step + -bounds); + a[(size_t)r] = (float)bounds; + return a; +} + +namespace { + +/* A 3 x 3 x 3 dilation of an n^3 mask (zero outside), as separable maxima along each axis. */ +void dilate(std::vector& m, int64_t n) { + std::vector t(m.size()); + auto pass = [&](const std::vector& src, std::vector& dst, int64_t stride) { + for (int64_t p = 0; p < (int64_t)src.size(); ++p) { + const int64_t c = (p / stride) % n; + uint8_t v = src[(size_t)p]; + if (c > 0) v |= src[(size_t)(p - stride)]; + if (c + 1 < n) v |= src[(size_t)(p + stride)]; + dst[(size_t)p] = v; + } + }; + pass(m, t, 1); + pass(t, m, n); + pass(m, t, n * n); + m.swap(t); +} + +} /* namespace */ + +std::vector shape_refine(const std::vector& prev, int32_t rp, int32_t r, + double level, bool last) { + const int64_t np = (int64_t)rp + 1, n = (int64_t)r + 1; + std::vector near((size_t)(np * np * np), 0); + auto sgn = [](float v) { return (v > 0.0f) - (v < 0.0f); }; + const float lv = (float)level; + for (int64_t i = 0; i < np; ++i) + for (int64_t j = 0; j < np; ++j) + for (int64_t k = 0; k < np; ++k) { + const int64_t p = (i * np + j) * np + k; + const float raw = prev[(size_t)p]; + if (std::isnan(raw)) continue; + const float v = raw - lv; + const int s = sgn(v); + bool cross = std::fabs(v) < 0.95f; + const int64_t nb[6][3] = { { i - 1, j, k }, { i + 1, j, k }, { i, j - 1, k }, + { i, j + 1, k }, { i, j, k - 1 }, { i, j, k + 1 } }; + for (int q = 0; q < 6 && !cross; ++q) { + const int64_t a = nb[q][0], b = nb[q][1], c = nb[q][2]; + /* Outside the grid the reference replicates the border, and a neighbour not + * sampled stands in as the point itself: neither crosses. */ + if (a < 0 || a >= np || b < 0 || b >= np || c < 0 || c >= np) continue; + const float u = prev[(size_t)((a * np + b) * np + c)]; + if (std::isnan(u)) continue; + cross = sgn(u - lv) != s; + } + near[(size_t)p] = cross; + } + if (!last) dilate(near, np); + std::vector mark((size_t)(n * n * n), 0); + auto up = [&](int64_t c) { return (c * r + rp / 2) / rp; }; + for (int64_t i = 0; i < np; ++i) + for (int64_t j = 0; j < np; ++j) + for (int64_t k = 0; k < np; ++k) + if (near[(size_t)((i * np + j) * np + k)]) + mark[(size_t)((up(i) * n + up(j)) * n + up(k))] = 1; + dilate(mark, n); + if (last) dilate(mark, n); + std::vector pts; + for (int64_t p = 0; p < (int64_t)mark.size(); ++p) + if (mark[(size_t)p]) pts.push_back((uint32_t)p); + return pts; +} + +/* ================================================================== marching cubes */ +namespace { + +/* Corner c of a cube is at (c & 1, c >> 1 & 1, c >> 2 & 1) along the grid's (i, j, k). Edge e is + * along axis e / 4 from corner kEdge[e][0] to kEdge[e][1]. */ +struct McTables { + int32_t edge[12][2]; + /* Each case's triangles as edge triples, -1 ended. */ + int8_t tri[256][31]; +}; + +McTables build_tables() { + McTables T{}; + int ne = 0; + for (int a = 0; a < 3; ++a) + for (int c = 0; c < 8; ++c) + if (!(c >> a & 1)) { T.edge[ne][0] = c; T.edge[ne][1] = c | (1 << a); ++ne; } + auto edge_of = [&](int c0, int c1) { + for (int e = 0; e < 12; ++e) + if ((T.edge[e][0] == c0 && T.edge[e][1] == c1) || + (T.edge[e][0] == c1 && T.edge[e][1] == c0)) + return e; + return -1; + }; + auto pos = [](int c, double* p) { p[0] = c & 1; p[1] = c >> 1 & 1; p[2] = c >> 2 & 1; }; + for (int m = 0; m < 256; ++m) { + for (int i = 0; i < 31; ++i) T.tri[m][i] = -1; + if (m == 0 || m == 255) continue; + auto in = [&](int c) { return (m >> c & 1) != 0; }; + /* Each face's segments between its crossing edges. A face with all four edges crossing + * (its inside corners diagonal) separates the inside corners, the rule both cubes that + * share the face apply, so the surface has no cracks. */ + std::vector> seg; + for (int a = 0; a < 3; ++a) + for (int s = 0; s < 2; ++s) { + const int u = (a + 1) % 3, v = (a + 2) % 3; + const int base = s << a; + const int cyc[4] = { base, base | (1 << u), base | (1 << u) | (1 << v), + base | (1 << v) }; + int fe[4]; + bool cr[4]; + int ncr = 0; + for (int q = 0; q < 4; ++q) { + fe[q] = edge_of(cyc[q], cyc[(q + 1) % 4]); + cr[q] = in(cyc[q]) != in(cyc[(q + 1) % 4]); + ncr += cr[q]; + } + if (ncr == 2) { + int a0 = -1, a1 = -1; + for (int q = 0; q < 4; ++q) { + if (!cr[q]) continue; + if (a0 < 0) a0 = fe[q]; else a1 = fe[q]; + } + seg.push_back({ a0, a1 }); + } else if (ncr == 4) { + for (int q = 0; q < 4; ++q) + if (in(cyc[q])) seg.push_back({ fe[(q + 3) % 4], fe[q] }); + } + } + /* The segments close into loops; each crossing edge is in exactly two. */ + std::vector used(seg.size(), false); + int nt = 0; + for (size_t s0 = 0; s0 < seg.size(); ++s0) { + if (used[s0]) continue; + std::vector loop = { seg[s0][0], seg[s0][1] }; + used[s0] = true; + for (bool grew = true; grew;) { + grew = false; + for (size_t q = 0; q < seg.size(); ++q) { + if (used[q]) continue; + const int tail = loop.back(); + int nx = -1; + if (seg[q][0] == tail) nx = seg[q][1]; + else if (seg[q][1] == tail) nx = seg[q][0]; + if (nx < 0) continue; + used[q] = true; + grew = true; + if (nx != loop.front()) loop.push_back(nx); + } + } + /* Orientation: the loop's normal (Newell's, over the edges' midpoints) points from the + * inside corners to the outside ones. */ + double nrm[3] = { 0, 0, 0 }, out[3] = { 0, 0, 0 }; + std::vector> mid; + for (int e : loop) { + double p0[3], p1[3]; + pos(T.edge[e][0], p0); + pos(T.edge[e][1], p1); + mid.push_back({ (p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2, (p0[2] + p1[2]) / 2 }); + const double sg = in(T.edge[e][0]) ? 1.0 : -1.0; + for (int d = 0; d < 3; ++d) out[d] += sg * (p1[d] - p0[d]); + } + for (size_t q = 0; q < mid.size(); ++q) { + const auto& c = mid[q]; + const auto& d = mid[(q + 1) % mid.size()]; + nrm[0] += (c[1] - d[1]) * (c[2] + d[2]); + nrm[1] += (c[2] - d[2]) * (c[0] + d[0]); + nrm[2] += (c[0] - d[0]) * (c[1] + d[1]); + } + if (nrm[0] * out[0] + nrm[1] * out[1] + nrm[2] * out[2] < 0) + std::reverse(loop.begin(), loop.end()); + for (size_t q = 1; q + 1 < loop.size() && nt < 10; ++q) { + T.tri[m][3 * nt] = (int8_t)loop[0]; + T.tri[m][3 * nt + 1] = (int8_t)loop[q]; + T.tri[m][3 * nt + 2] = (int8_t)loop[q + 1]; + ++nt; + } + } + } + return T; +} + +const McTables& tables() { + static const McTables t = build_tables(); + return t; +} + +} /* namespace */ + +void shape_mesh(const std::vector& field, int32_t r, double bounds, double level, + ShapeMesh* out) { + out->v.clear(); + out->f.clear(); + const McTables& T = tables(); + const int64_t n = (int64_t)r + 1, nn = n * n; + const float lv = (float)level; + const double sc = 2.0 * bounds / (double)n; + /* An edge's vertex by its first grid point: the x edges between planes i and i + 1, and the + * y and z edges of planes i and i + 1. */ + std::vector ex((size_t)nn), ey[2], ez[2]; + for (int p = 0; p < 2; ++p) { ey[p].assign((size_t)nn, -1); ez[p].assign((size_t)nn, -1); } + auto value = [&](int64_t i, int64_t j, int64_t k) { + return field[(size_t)((i * n + j) * n + k)]; + }; + for (int64_t i = 0; i + 1 < n; ++i) { + std::fill(ex.begin(), ex.end(), -1); + if (i > 0) { + std::swap(ey[0], ey[1]); + std::swap(ez[0], ez[1]); + std::fill(ey[1].begin(), ey[1].end(), -1); + std::fill(ez[1].begin(), ez[1].end(), -1); + } + for (int64_t j = 0; j + 1 < n; ++j) + for (int64_t k = 0; k + 1 < n; ++k) { + float v[8]; + bool skip = false; + int m = 0; + for (int c = 0; c < 8 && !skip; ++c) { + v[c] = value(i + (c & 1), j + (c >> 1 & 1), k + (c >> 2 & 1)); + if (std::isnan(v[c])) skip = true; + else if (v[c] > lv) m |= 1 << c; + } + if (skip || m == 0 || m == 255) continue; + for (int t = 0; t < 30 && T.tri[m][t] >= 0; ++t) { + const int e = T.tri[m][t]; + const int c0 = T.edge[e][0], c1 = T.edge[e][1], a = e / 4; + const int64_t bi = c0 & 1, bj = c0 >> 1 & 1, bk = c0 >> 2 & 1; + int32_t* slot = a == 0 ? &ex[(size_t)((j + bj) * n + k + bk)] + : a == 1 ? &ey[bi][(size_t)(j * n + k + bk)] + : &ez[bi][(size_t)((j + bj) * n + k)]; + if (*slot < 0) { + const float t0 = v[c0], t1 = v[c1]; + const float f = t1 != t0 ? (lv - t0) / (t1 - t0) : 0.5f; + float g[3] = { (float)(i + bi), (float)(j + bj), (float)(k + bk) }; + g[a] += f; + *slot = (int32_t)(out->v.size() / 3); + for (int d = 0; d < 3; ++d) out->v.push_back((float)(g[d] * sc - bounds)); + } + out->f.push_back((uint32_t)*slot); + } + } + } +} + +/* ================================================================== files */ +namespace { + +void put(std::string& s, const void* p, size_t n) { s.append((const char*)p, n); } +template void put_v(std::string& s, T v) { put(s, &v, sizeof v); } + +/* Area-weighted vertex normals, unit length (zero for a vertex of only degenerate faces). */ +std::vector vertex_normals(const ShapeMesh& m) { + std::vector nrm(m.v.size(), 0.0f); + for (size_t t = 0; t + 2 < m.f.size(); t += 3) { + const float* a = &m.v[(size_t)m.f[t] * 3]; + const float* b = &m.v[(size_t)m.f[t + 1] * 3]; + const float* c = &m.v[(size_t)m.f[t + 2] * 3]; + const float u[3] = { b[0] - a[0], b[1] - a[1], b[2] - a[2] }; + const float w[3] = { c[0] - a[0], c[1] - a[1], c[2] - a[2] }; + const float x[3] = { u[1] * w[2] - u[2] * w[1], u[2] * w[0] - u[0] * w[2], + u[0] * w[1] - u[1] * w[0] }; + for (int q = 0; q < 3; ++q) + for (int d = 0; d < 3; ++d) nrm[(size_t)m.f[t + q] * 3 + d] += x[d]; + } + for (size_t i = 0; i + 2 < nrm.size(); i += 3) { + const float l = + std::sqrt(nrm[i] * nrm[i] + nrm[i + 1] * nrm[i + 1] + nrm[i + 2] * nrm[i + 2]); + if (l > 0.0f) for (int d = 0; d < 3; ++d) nrm[i + d] /= l; + } + return nrm; +} + +std::string glb(const ShapeMesh& m) { + const size_t nv = m.v.size() / 3, ni = m.f.size(); + const std::vector nrm = vertex_normals(m); + float lo[3] = { INFINITY, INFINITY, INFINITY }, hi[3] = { -INFINITY, -INFINITY, -INFINITY }; + for (size_t i = 0; i < nv; ++i) + for (int d = 0; d < 3; ++d) { + lo[d] = std::min(lo[d], m.v[i * 3 + d]); + hi[d] = std::max(hi[d], m.v[i * 3 + d]); + } + const size_t vb = nv * 12, ib = ni * 4; + std::string bin; + put(bin, m.v.data(), vb); + put(bin, nrm.data(), vb); + put(bin, m.f.data(), ib); + while (bin.size() % 4) bin.push_back('\0'); + using nlohmann::json; + json j; + j["asset"] = { { "version", "2.0" }, { "generator", "radiance" } }; + j["scene"] = 0; + j["scenes"] = json::array({ { { "nodes", json::array({ 0 }) } } }); + j["nodes"] = json::array({ { { "mesh", 0 } } }); + const json prim = { { "attributes", { { "POSITION", 0 }, { "NORMAL", 1 } } }, + { "indices", 2 }, { "mode", 4 } }; + j["meshes"] = json::array({ { { "primitives", json::array({ prim }) } } }); + j["buffers"] = json::array({ { { "byteLength", bin.size() } } }); + j["bufferViews"] = json::array({ + { { "buffer", 0 }, { "byteOffset", 0 }, { "byteLength", vb }, { "target", 34962 } }, + { { "buffer", 0 }, { "byteOffset", vb }, { "byteLength", vb }, { "target", 34962 } }, + { { "buffer", 0 }, { "byteOffset", 2 * vb }, { "byteLength", ib }, { "target", 34963 } } }); + j["accessors"] = json::array({ + { { "bufferView", 0 }, { "componentType", 5126 }, { "count", nv }, { "type", "VEC3" }, + { "min", { lo[0], lo[1], lo[2] } }, { "max", { hi[0], hi[1], hi[2] } } }, + { { "bufferView", 1 }, { "componentType", 5126 }, { "count", nv }, { "type", "VEC3" } }, + { { "bufferView", 2 }, { "componentType", 5125 }, { "count", ni }, + { "type", "SCALAR" } } }); + std::string js = j.dump(); + while (js.size() % 4) js.push_back(' '); + std::string out; + put_v(out, 0x46546C67u); /* "glTF" */ + put_v(out, 2); + put_v(out, (uint32_t)(12 + 8 + js.size() + 8 + bin.size())); + put_v(out, (uint32_t)js.size()); + put_v(out, 0x4E4F534Au); /* "JSON" */ + out += js; + put_v(out, (uint32_t)bin.size()); + put_v(out, 0x004E4942u); /* "BIN\0" */ + out += bin; + return out; +} + +std::string obj(const ShapeMesh& m) { + std::string s; + char line[128]; + for (size_t i = 0; i + 2 < m.v.size(); i += 3) { + const int n = std::snprintf(line, sizeof line, "v %.9g %.9g %.9g\n", (double)m.v[i], + (double)m.v[i + 1], (double)m.v[i + 2]); + s.append(line, (size_t)n); + } + for (size_t t = 0; t + 2 < m.f.size(); t += 3) { + const int n = std::snprintf(line, sizeof line, "f %u %u %u\n", m.f[t] + 1, m.f[t + 1] + 1, + m.f[t + 2] + 1); + s.append(line, (size_t)n); + } + return s; +} + +std::string ply(const ShapeMesh& m) { + const size_t nv = m.v.size() / 3, nf = m.f.size() / 3; + std::string s = "ply\nformat binary_little_endian 1.0\nelement vertex " + std::to_string(nv) + + "\nproperty float x\nproperty float y\nproperty float z\nelement face " + + std::to_string(nf) + "\nproperty list uchar int vertex_indices\nend_header\n"; + put(s, m.v.data(), m.v.size() * 4); + for (size_t t = 0; t < nf; ++t) { + put_v(s, 3); + for (int q = 0; q < 3; ++q) put_v(s, (int32_t)m.f[t * 3 + q]); + } + return s; +} + +std::string stl(const ShapeMesh& m) { + std::string s(80, '\0'); + std::memcpy(&s[0], "radiance", 8); + const size_t nf = m.f.size() / 3; + put_v(s, (uint32_t)nf); + for (size_t t = 0; t < nf; ++t) { + const float* a = &m.v[(size_t)m.f[t * 3] * 3]; + const float* b = &m.v[(size_t)m.f[t * 3 + 1] * 3]; + const float* c = &m.v[(size_t)m.f[t * 3 + 2] * 3]; + const float u[3] = { b[0] - a[0], b[1] - a[1], b[2] - a[2] }; + const float w[3] = { c[0] - a[0], c[1] - a[1], c[2] - a[2] }; + float x[3] = { u[1] * w[2] - u[2] * w[1], u[2] * w[0] - u[0] * w[2], + u[0] * w[1] - u[1] * w[0] }; + const float l = std::sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]); + if (l > 0.0f) for (float& q : x) q /= l; + put(s, x, 12); + put(s, a, 12); + put(s, b, 12); + put(s, c, 12); + put_v(s, 0); + } + return s; +} + +} /* namespace */ + +int shape_export(const ShapeMesh& m, const std::string& format, std::string* bytes, + std::string* mime, std::string* why) { + if (format == "glb") { *bytes = glb(m); *mime = "model/gltf-binary"; return RAD_OK; } + if (format == "obj") { *bytes = obj(m); *mime = "model/obj"; return RAD_OK; } + if (format == "ply") { *bytes = ply(m); *mime = "application/x-ply"; return RAD_OK; } + if (format == "stl") { *bytes = stl(m); *mime = "model/stl"; return RAD_OK; } + if (why) *why = "type '" + format + "' is not one this server writes: glb, obj, ply or stl"; + return RAD_E_INVAL; +} + +/* ================================================================== the ticket */ +void ShapeTicket::progress(int32_t steps_done, int32_t points_done) { + std::lock_guard lk(mu_); + steps_done_ = steps_done; + points_done_ = points_done; +} + +void ShapeTicket::set_field(std::vector&& field, int32_t r) { + std::lock_guard lk(mu_); + field_ = std::move(field); + r_ = r; +} + +void ShapeTicket::finish(int status, const std::string& why) { + { + std::lock_guard lk(mu_); + if (done_) return; + done_ = true; + status_ = status; + why_ = why; + } + cv_.notify_all(); +} + +bool ShapeTicket::wait(int ms) { + std::unique_lock lk(mu_); + cv_.wait_for(lk, std::chrono::milliseconds(ms), [this] { return done_; }); + return done_; +} + +bool ShapeTicket::finished() const { + std::lock_guard lk(mu_); + return done_; +} + +int ShapeTicket::status() const { + std::lock_guard lk(mu_); + return status_; +} + +std::string ShapeTicket::why() const { + std::lock_guard lk(mu_); + return why_; +} + +std::vector ShapeTicket::take_field(int32_t* r) { + std::lock_guard lk(mu_); + if (r) *r = r_; + return std::move(field_); +} + +void ShapeTicket::progress_of(int32_t* steps_done, int32_t* points_done) const { + std::lock_guard lk(mu_); + if (steps_done) *steps_done = steps_done_; + if (points_done) *points_done = points_done_; +} + +} /* namespace gen */ +} /* namespace rad */ diff --git a/core/gen/shape.h b/core/gen/shape.h new file mode 100644 index 00000000..9947dc77 --- /dev/null +++ b/core/gen/shape.h @@ -0,0 +1,137 @@ +/* shape.h -- shape generation: the request, the channel its field comes back on, and the host + * geometry around the model's passes. + * + * A shape generator (abi/rad_builder.h, rad_declare_shape_generator) makes a 3-D shape from one + * picture: it denoises a latent, then decodes it into an occupancy field that is sampled on a + * grid. core/gen/shape_driver.h turns a request into those passes; this is what a caller hands it + * (the picture already prepared, shape_picture), what it hands back (progress as the steps and + * the grid's levels run, then the finest grid), and the geometry both sides share: the sampler's + * sigmas, the grid's levels and the points each level queries, and the mesh made of the grid + * (shape_mesh) with its file formats. + */ +#pragma once +#include "rad_core.h" +#include "mm/media.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace rad { +namespace gen { + +/* What the driver knows of the declaration, for the server and the geometry below. */ +struct ShapeGenInfo { + std::string name; + int64_t canvas = 0, enc_size = 0, enc_patch = 0; + double border_ratio = 0.0; + double pix_mean[3] = {}, pix_std[3] = {}; + int64_t default_steps = 0, max_steps = 0; + double default_guidance = 0.0; + double bounds = 1.0, level = 0.0; + int64_t default_resolution = 0, min_resolution = 0, max_resolution = 0; + int64_t max_lanes = 1; +}; +ShapeGenInfo shape_info(const RadShapeGenDecl& d, const std::string& name); + +/* The picture as an SCOND pass carries it (RadShapeGenDecl, "The picture"): `rgba` decoded with + * its alpha, out as f32 [(enc_size / enc_patch)^2, 3 enc_patch^2]. Refuses a picture whose alpha + * leaves nothing, or a bounding box of one row or column, as the reference does. */ +int shape_picture(const ShapeGenInfo& g, const mm::FrameRGBA& rgba, std::vector* patches, + std::string* why); + +/* The sampler's grid points: numpy's linspace(0, 1, steps) taken to f32. An evaluation at each + * but the last steps to the next. */ +std::vector shape_sigmas(int32_t steps); + +/* The grid's levels, coarsest first: `resolution` halved while it stays at least 63, then + * reversed (one level when it is below 63). */ +std::vector shape_levels(int32_t resolution); + +/* One axis of a level's grid: numpy's linspace(-bounds, bounds, r + 1) in f32. */ +std::vector shape_axis(double bounds, int32_t r); + +/* The grid points of level `r` (index (i, j, k) at (i (r+1) + j) (r+1) + k) to query, given the + * coarser level's field `prev` at resolution `rp` (NaN where it was not sampled): the coarse + * points whose sign against `level` differs from a neighbour's, or whose value is within 0.95 of + * zero, dilated once unless this is the last level, put at their places on this grid and dilated + * twice there (once when the coarse set was). As FlashVDM's hierarchical decoding. */ +std::vector shape_refine(const std::vector& prev, int32_t rp, int32_t r, + double level, bool last); + +/* A triangle mesh: positions xyz, and faces as three vertex indices, counter-clockwise seen from + * outside the shape. */ +struct ShapeMesh { + std::vector v; + std::vector f; +}; + +/* Marching cubes over `field` ((r+1)^3 values, the layout above) at `level`, inside above it. A + * cube with a corner not sampled (NaN) makes nothing. Vertices sit on the grid's edges where the + * linear interpolation of their ends crosses the level, one vertex an edge, and grid index g goes + * to g 2 bounds / (r + 1) - bounds (RadShapeGenDecl, "The field"). */ +void shape_mesh(const std::vector& field, int32_t r, double bounds, double level, + ShapeMesh* out); + +/* The mesh as a file: "glb" (positions, smooth normals and indices), "obj", "ply" (binary) or + * "stl" (binary). The content type goes to `mime`. Refuses another format by name. */ +int shape_export(const ShapeMesh& m, const std::string& format, std::string* bytes, + std::string* mime, std::string* why); + +/* ================================================================== the request */ +class ShapeTicket { +public: + /* driver side */ + void progress(int32_t steps_done, int32_t points_done); + /* The finest grid, at resolution `r`, and the end. */ + void finish(int status, const std::string& why = std::string()); + void set_field(std::vector&& field, int32_t r); + + /* caller side: waits at most `ms` milliseconds for the end; true once it came. */ + bool wait(int ms); + bool finished() const; + int status() const; + std::string why() const; + /* The field, once finished with RAD_OK; moved out. */ + std::vector take_field(int32_t* r); + void progress_of(int32_t* steps_done, int32_t* points_done) const; + + std::atomic cancel{false}; + + /* Written by the driver at submit: the evaluations, the resolution and the guidance. */ + int32_t steps = 0, resolution = 0; + double guidance = 0.0; + /* Usage, written by the driver before finish(): the points the decoder was queried at, and + * per-phase times. */ + int64_t points = 0; + int64_t t_submit_ns = 0, t_cond_ns = 0, t_denoised_ns = 0, t_done_ns = 0; + +private: + mutable std::mutex mu_; + std::condition_variable cv_; + bool done_ = false; + int status_ = RAD_OK; + std::string why_; + int32_t steps_done_ = 0, points_done_ = 0; + std::vector field_; + int32_t r_ = 0; +}; + +struct ShapeRequest { + /* The picture, prepared (shape_picture). */ + std::vector patches; + int32_t steps = 0; /* sigma grid points; 0: the model's default */ + double guidance = NAN; /* NaN: the model's default */ + int32_t resolution = 0; /* the finest grid's cells a side; 0: the model's default */ + bool dense = false; /* sample every point of the finest grid, no coarser levels */ + uint64_t seed = 0; + std::shared_ptr ticket; +}; + +} /* namespace gen */ +} /* namespace rad */ diff --git a/core/gen/shape_driver.cpp b/core/gen/shape_driver.cpp new file mode 100644 index 00000000..88d7547d --- /dev/null +++ b/core/gen/shape_driver.cpp @@ -0,0 +1,436 @@ +/* shape_driver.cpp -- the shape generator's pass driver (shape_driver.h). */ +#include "shape_driver.h" +#include "rad_internal.h" + +#include +#include +#include + +namespace rad { +namespace gen { + +namespace { + +constexpr int64_t kAlign = 256; + +/* Region offsets and sizes, in the enum's order (shape_driver.h), and the total; shared by the + * allocation and the VRAM budget. */ +int64_t carve(const RadShapeGenDecl& d, int64_t (*bytes)[2], int n) { + const int64_t side = d.enc_size / d.enc_patch; + const int64_t want[] = { + side * side * 3 * d.enc_patch * d.enc_patch * 4, /* R_PATCH: f32 */ + 2 * 4, /* R_SIGMA */ + 2 * 4, /* R_SNEXT */ + 2 * 4, /* R_CFG */ + 2 * 4, /* R_PAIR */ + 2 * 4, /* R_LANES */ + 2 * 4, /* R_FLAGS */ + 2 * 2 * 4, /* R_SEED */ + 3 * 4, /* R_LATCU */ + d.max_query * 3 * 4, /* R_QUERY: f32 */ + 2 * 4, /* R_QCU */ + }; + int64_t off = 0; + for (int r = 0; r < n; ++r) { + bytes[r][0] = off; + bytes[r][1] = want[r]; + off = align_up(off + want[r], kAlign); + } + return off; +} + +} /* namespace */ + +int64_t ShapeDriver::device_bytes(const Program& prog) { + if (!prog.is_shape_generator()) return 0; + int64_t b[R_N][2]; + return carve(prog.shape_gen, b, R_N); +} + +int ShapeDriver::init(const Program& prog, const std::vector& ranks) { + fini(); + if (!prog.is_shape_generator()) return RAD_E_STATE; + decl_ = prog.shape_gen; + info_ = shape_info(decl_, prog.sgen_name); + ranks_ = ranks; + n_patch_ = (decl_.enc_size / decl_.enc_patch) * (decl_.enc_size / decl_.enc_patch); + patch_dim_ = 3 * decl_.enc_patch * decl_.enc_patch; + int64_t b[R_N][2]; + bytes_ = carve(decl_, b, R_N); + for (int r = 0; r < R_N; ++r) { + reg_[r].off = b[r][0]; + reg_[r].bytes = b[r][1]; + reg_[r].used = 0; + } + host_ = static_cast(rad_dev_alloc(bytes_, RAD_MEM_HOST_PINNED)); + field_host_ = static_cast(rad_dev_alloc(decl_.max_query * 4, RAD_MEM_HOST_PINNED)); + if (!host_ || !field_host_) { + RAD_ERR("shape generator: no pinned host memory for the pass staging and the field " + "(%lld + %lld bytes)", (long long)bytes_, (long long)(decl_.max_query * 4)); + return RAD_E_NOMEM; + } + std::memset(host_, 0, (size_t)bytes_); + dev_.assign(ranks_.size(), nullptr); + for (size_t r = 0; r < ranks_.size(); ++r) { + RAD_TRY(rad_dev_set(ranks_[r].device)); + dev_[r] = rad_dev_alloc(bytes_, RAD_MEM_DEVICE); + if (!dev_[r]) { + RAD_ERR("shape generator: rank %zu has no room for the pass staging (%lld bytes)", r, + (long long)bytes_); + return RAD_E_NOMEM; + } + } + if (!ranks_.empty()) RAD_TRY(rad_dev_set(ranks_[0].device)); + out_.assign(ranks_.size(), RadBatch{}); + sout_.assign(ranks_.size(), RadShapeGenBatch{}); + free_lanes_.clear(); + for (int64_t i = decl_.max_lanes - 1; i >= 0; --i) free_lanes_.push_back((int32_t)i); + return RAD_OK; +} + +void ShapeDriver::fini() { + for (size_t r = 0; r < dev_.size(); ++r) + if (dev_[r]) { + if (r < ranks_.size()) rad_dev_set(ranks_[r].device); + rad_dev_free(dev_[r], RAD_MEM_DEVICE); + } + dev_.clear(); + if (!ranks_.empty()) rad_dev_set(ranks_[0].device); + if (host_) rad_dev_free(host_, RAD_MEM_HOST_PINNED); + if (field_host_) rad_dev_free(field_host_, RAD_MEM_HOST_PINNED); + host_ = nullptr; + field_host_ = nullptr; +} + +/* ================================================================== requests */ +int ShapeDriver::submit(std::unique_ptr r, std::string* why) { + if (!r || !r->ticket) return RAD_E_INVAL; + const RadShapeGenDecl& d = decl_; + auto no = [&](const std::string& w) { + if (why) *why = w; + return RAD_E_INVAL; + }; + if ((int64_t)r->patches.size() != n_patch_ * patch_dim_) + return no("the picture is not prepared for this model's image encoder"); + const int32_t steps = r->steps > 0 ? r->steps : (int32_t)d.default_steps; + if (steps < 2 || steps > d.max_steps) + return no("num_inference_steps must be 2.." + std::to_string(d.max_steps) + + " (sigma grid points, the last one the clean shape)"); + const double cfg = std::isnan(r->guidance) ? d.default_guidance : r->guidance; + if (!(cfg >= 0.0) || !std::isfinite(cfg)) + return no("guidance_scale must be finite and not negative"); + const int32_t res = r->resolution > 0 ? r->resolution : (int32_t)d.default_resolution; + if (res < d.min_resolution || res > d.max_resolution) + return no("octree_resolution must be " + std::to_string(d.min_resolution) + ".." + + std::to_string(d.max_resolution)); + + auto j = std::make_unique(); + j->sigmas = shape_sigmas(steps); + j->evals = steps - 1; + j->cfg = (float)cfg; + j->levels = r->dense ? std::vector{ res } : shape_levels(res); + ShapeTicket& t = *r->ticket; + t.steps = j->evals; + t.resolution = res; + t.guidance = cfg; + t.t_submit_ns = (int64_t)rad_mono_ns(); + std::lock_guard lk(mu_); + if (closed_) { + if (why) *why = closed_why_; + return closed_status_; + } + j->id = next_id_++; + j->req = std::move(r); + jobs_.push_back(std::move(j)); + return RAD_OK; +} + +void ShapeDriver::shutdown(const char* why, int status) { + std::lock_guard lk(mu_); + closed_ = true; + closed_why_ = why ? why : "the engine stopped"; + closed_status_ = status; + for (auto& j : jobs_) j->req->ticket->finish(status, closed_why_); +} + +int64_t ShapeDriver::queued() const { + std::lock_guard lk(mu_); + int64_t n = 0; + for (const auto& j : jobs_) if (!j->admitted) ++n; + return n; +} + +int64_t ShapeDriver::running() const { + std::lock_guard lk(mu_); + int64_t n = 0; + for (const auto& j : jobs_) if (j->admitted) ++n; + return n; +} + +ShapeDriver::Job* ShapeDriver::job_locked(uint64_t id) { + for (auto& j : jobs_) if (j->id == id) return j.get(); + return nullptr; +} + +void ShapeDriver::release_locked(Job& j) { + if (j.lane >= 0) { + free_lanes_.push_back(j.lane); + j.lane = -1; + } +} + +void ShapeDriver::fail_locked(Job& j, int status, const std::string& why) { + j.failed = true; + j.req->ticket->finish(status, why); +} + +/* In arrival order: a request needs only a lane. */ +void ShapeDriver::admit_locked() { + for (auto& jp : jobs_) { + Job& j = *jp; + if (j.admitted || j.failed) continue; + if (free_lanes_.empty()) break; + j.lane = free_lanes_.back(); + free_lanes_.pop_back(); + j.admitted = true; + } +} + +/* A level of the grid begins: its field unsampled, its points `pts` (every point when `all`). */ +void ShapeDriver::start_level(Job& j, size_t level, std::vector&& pts, bool all) { + const int32_t r = j.levels[level]; + const int64_t n = (int64_t)r + 1; + j.level = level; + j.field.assign((size_t)(n * n * n), NAN); + j.axis = shape_axis(decl_.bounds, r); + j.all = all; + j.pts = std::move(pts); + j.n_pts = all ? n * n * n : (int64_t)j.pts.size(); + j.next = 0; +} + +/* ================================================================== staging */ +int ShapeDriver::upload() { + for (size_t r = 0; r < ranks_.size(); ++r) + for (int g = 0; g < R_N; ++g) { + if (reg_[g].used <= 0) continue; + RAD_TRY(rad_memcpy_async((char*)dev_[r] + reg_[g].off, host_ + reg_[g].off, + reg_[g].used, ranks_[r].stream)); + } + return RAD_OK; +} + +void ShapeDriver::stage_common(const Job& j) { + const int32_t lanes[2] = { j.lane, j.lane }; + const int32_t cu[3] = { 0, (int32_t)decl_.latent_rows, (int32_t)(2 * decl_.latent_rows) }; + std::memcpy(hptr(R_LANES), lanes, sizeof lanes); + std::memcpy(hptr(R_LATCU), cu, sizeof cu); + reg_[R_LANES].used = sizeof lanes; + reg_[R_LATCU].used = sizeof cu; +} + +void ShapeDriver::base_batches(const Job& j, int64_t n_tok, int kind, int step) { + for (size_t r = 0; r < ranks_.size(); ++r) { + RadBatch& B = out_[r]; + RadShapeGenBatch& S = sout_[r]; + const int ri = (int)r; + B = RadBatch{}; + B.step = step; + B.phase = RAD_PHASE_PREFILL; + B.n_tok = n_tok; + B.n_seq = 1; + B.max_q_len = (int32_t)n_tok; + B.max_q_len_prefill = (int32_t)n_tok; + B.gen = kind; + S = RadShapeGenBatch{}; + S.lane = j.lane; + S.patches = dptr(ri, R_PATCH); + S.step = j.step; + S.n_steps = j.evals; + S.sigma = dptr(ri, R_SIGMA); + S.sigma_next = dptr(ri, R_SNEXT); + S.cfg = dptr(ri, R_CFG); + S.pair = dptr(ri, R_PAIR); + S.lanes = dptr(ri, R_LANES); + S.flags = dptr(ri, R_FLAGS); + S.seed = dptr(ri, R_SEED); + S.lat_cu = dptr(ri, R_LATCU); + S.query = dptr(ri, R_QUERY); + S.query_cu = dptr(ri, R_QCU); + B.sgen_b = &S; + } + pass_.kind = kind; + pass_.job = j.id; +} + +/* ================================================================== the passes */ +const RadBatch* ShapeDriver::next(int step) { + std::lock_guard lk(mu_); + pass_ = Pass{}; + rb_.clear(); + if (closed_) return nullptr; + /* Retire finished, failed and cancelled jobs, returning their lanes before admitting. Safe + * because next() runs between passes, with nothing in flight. */ + for (auto it = jobs_.begin(); it != jobs_.end();) { + Job& j = **it; + const bool cancelled = j.req->ticket->cancel.load(std::memory_order_acquire); + if (!(j.failed || cancelled || j.finished)) { ++it; continue; } + if (cancelled && !j.failed && !j.finished) + j.req->ticket->finish(RAD_E_CANCELLED, "the request was cancelled"); + release_locked(j); + it = jobs_.erase(it); + } + admit_locked(); + + /* 1. The decoding of a denoised lane: its latent, then its grid. */ + for (auto& jp : jobs_) { + Job& j = *jp; + if (!j.admitted || j.failed || !j.cond_done || j.step < j.evals) continue; + return j.latent_done ? build_query(j, step) : build_latent(j, step); + } + /* 2. A picture. */ + for (auto& jp : jobs_) { + Job& j = *jp; + if (j.admitted && !j.failed && !j.cond_done) return build_cond(j, step); + } + /* 3. The oldest lane's next step. */ + for (auto& jp : jobs_) { + Job& j = *jp; + if (j.admitted && !j.failed && j.cond_done && j.step < j.evals) return build_step(j, step); + } + return nullptr; +} + +const RadBatch* ShapeDriver::batch_for(int rank) const { + if (rank < 0 || (size_t)rank >= out_.size() || pass_.kind == 0) return nullptr; + return &out_[(size_t)rank]; +} + +const RadBatch* ShapeDriver::build_cond(Job& j, int step) { + for (int g = 0; g < R_N; ++g) reg_[g].used = 0; + std::memcpy(hptr(R_PATCH), j.req->patches.data(), j.req->patches.size() * 4); + reg_[R_PATCH].used = (int64_t)j.req->patches.size() * 4; + stage_common(j); + if (upload() < 0) return nullptr; + base_batches(j, n_patch_, RAD_GEN_PASS_SCOND, step); + return &out_[0]; +} + +/* The two entries of the step: the picture's latent guided against the unconditioned one, which + * reads the same lane and moves nothing. */ +const RadBatch* ShapeDriver::build_step(Job& j, int step) { + for (int g = 0; g < R_N; ++g) reg_[g].used = 0; + const float s = j.sigmas[(size_t)j.step], sn = j.sigmas[(size_t)j.step + 1]; + const float sig[2] = { s, s }, nxt[2] = { sn, sn }, cfg[2] = { j.cfg, 1.0f }; + const int32_t pair[2] = { 1, -2 }; + const int32_t flags[2] = { j.step == 0 ? (int32_t)RAD_GEN_F_FIRST : 0, 0 }; + const uint32_t lo = (uint32_t)j.req->seed, hi = (uint32_t)(j.req->seed >> 32); + const uint32_t seed[4] = { lo, hi, lo, hi }; + auto stage = [&](int r, const void* p, int64_t n) { + std::memcpy(host_ + reg_[r].off, p, (size_t)n); + reg_[r].used = n; + }; + stage(R_SIGMA, sig, sizeof sig); + stage(R_SNEXT, nxt, sizeof nxt); + stage(R_CFG, cfg, sizeof cfg); + stage(R_PAIR, pair, sizeof pair); + stage(R_FLAGS, flags, sizeof flags); + stage(R_SEED, seed, sizeof seed); + stage_common(j); + if (upload() < 0) return nullptr; + base_batches(j, decl_.step_rows, RAD_GEN_PASS_SSTEP, step); + return &out_[0]; +} + +const RadBatch* ShapeDriver::build_latent(Job& j, int step) { + for (int g = 0; g < R_N; ++g) reg_[g].used = 0; + stage_common(j); + if (upload() < 0) return nullptr; + base_batches(j, decl_.latent_rows, RAD_GEN_PASS_SLATENT, step); + return &out_[0]; +} + +/* The level's next run of points, at most max_query, as x, y, z. */ +const RadBatch* ShapeDriver::build_query(Job& j, int step) { + for (int g = 0; g < R_N; ++g) reg_[g].used = 0; + const int64_t n = std::min(decl_.max_query, j.n_pts - j.next); + const int64_t side = (int64_t)j.levels[j.level] + 1; + float* q = hptr(R_QUERY); + for (int64_t i = 0; i < n; ++i) { + const int64_t p = j.all ? j.next + i : (int64_t)j.pts[(size_t)(j.next + i)]; + q[3 * i] = j.axis[(size_t)(p / (side * side))]; + q[3 * i + 1] = j.axis[(size_t)(p / side % side)]; + q[3 * i + 2] = j.axis[(size_t)(p % side)]; + } + reg_[R_QUERY].used = n * 3 * 4; + const int32_t qcu[2] = { 0, (int32_t)n }; + std::memcpy(hptr(R_QCU), qcu, sizeof qcu); + reg_[R_QCU].used = sizeof qcu; + stage_common(j); + if (upload() < 0) return nullptr; + base_batches(j, n, RAD_GEN_PASS_SQUERY, step); + for (auto& S : sout_) S.n_query = n; + pass_.n_query = n; + rb_.assign(1, Readback{ decl_.field_out, n * 4, field_host_ }); + return &out_[0]; +} + +int ShapeDriver::done() { + std::lock_guard lk(mu_); + const int64_t now = (int64_t)rad_mono_ns(); + Job* j = job_locked(pass_.job); + switch (j ? pass_.kind : 0) { + case RAD_GEN_PASS_SCOND: + j->cond_done = true; + j->req->ticket->t_cond_ns = now; + /* The patches are on the card for good; the request keeps no copy. */ + std::vector().swap(j->req->patches); + break; + case RAD_GEN_PASS_SSTEP: + ++j->step; + j->req->ticket->progress(j->step, 0); + if (j->step >= j->evals) j->req->ticket->t_denoised_ns = now; + break; + case RAD_GEN_PASS_SLATENT: + j->latent_done = true; + start_level(*j, 0, {}, true); + break; + case RAD_GEN_PASS_SQUERY: { + const int64_t n = pass_.n_query; + for (int64_t i = 0; i < n; ++i) { + const int64_t p = j->all ? j->next + i : (int64_t)j->pts[(size_t)(j->next + i)]; + j->field[(size_t)p] = field_host_[i]; + } + j->next += n; + j->points += n; + j->req->ticket->progress(j->step, (int32_t)std::min(j->points, INT32_MAX)); + if (j->next < j->n_pts) break; + /* The level is complete: the next one's points, or the end (also when no point of this + * level is near the surface, which leaves the finer levels nothing to sample). */ + if (j->level + 1 < j->levels.size()) { + const int32_t rp = j->levels[j->level], r = j->levels[j->level + 1]; + const bool last = j->level + 2 == j->levels.size(); + std::vector pts = shape_refine(j->field, rp, r, decl_.level, last); + if (!pts.empty()) { + start_level(*j, j->level + 1, std::move(pts), false); + break; + } + } + ShapeTicket& t = *j->req->ticket; + t.points = j->points; + t.t_done_ns = now; + t.set_field(std::move(j->field), j->levels[j->level]); + j->finished = true; + t.finish(RAD_OK); + break; + } + default: + break; + } + pass_ = Pass{}; + rb_.clear(); + return RAD_OK; +} + +} /* namespace gen */ +} /* namespace rad */ diff --git a/core/gen/shape_driver.h b/core/gen/shape_driver.h new file mode 100644 index 00000000..0821e4d4 --- /dev/null +++ b/core/gen/shape_driver.h @@ -0,0 +1,141 @@ +/* shape_driver.h -- the shape generator's pass driver (shape.h; abi/rad_builder.h's + * RadShapeGenDecl describes the passes). + * + * Driven by the engine thread like the other drivers (pass.h): `next()` picks and stages a pass, + * `done()` folds its result back once every rank has run it. Requests arrive from HTTP threads + * through `submit()` and leave through their ShapeTicket. + * + * A request holds a lane from admission to its last query. Its picture is prepared and its + * schedule fixed at submit; between passes the driver only stages, except when a level of the + * grid is complete, when it works out the points of the next (shape_refine). + * + * Pass priority, one pass at a time: + * + * 1. SLATENT, then the SQUERY passes level by level, of a lane whose denoising is done: they + * finish a request and free its lane. + * 2. SCOND of an admitted request, so its steps can follow the current request's without a gap. + * 3. SSTEP of the oldest lane with steps left. Requests are denoised one after another, not in + * turns: a pass is one request's, so taking turns would only delay the first. + */ +#pragma once +#include "shape.h" +#include "pass.h" +#include "device/device.h" + +#include +#include + +namespace rad { +namespace gen { + +class ShapeDriver final : public IPassDriver { +public: + struct RankIO { + int device = 0; + RadStream stream = nullptr; + }; + + int init(const Program& prog, const std::vector& ranks); + void fini(); + ~ShapeDriver() override { fini(); } + + /* The bytes init() allocates on each rank's card, for the VRAM budget. */ + static int64_t device_bytes(const Program& prog); + + /* ---------------------------------------------------------- HTTP threads */ + /* Queue a request, refused at once with `why` when it can never run. */ + int submit(std::unique_ptr r, std::string* why); + const ShapeGenInfo& info() const { return info_; } + void shutdown(const char* why, int status) override; + + /* ---------------------------------------------------------- the engine thread */ + const RadBatch* next(int step) override; + const RadBatch* batch_for(int rank) const override; + const std::vector& readbacks() const override { return rb_; } + int done() override; + + int64_t queued() const override; + int64_t running() const override; + +private: + struct Job { + uint64_t id = 0; + std::unique_ptr req; + std::vector sigmas; /* the request's grid points */ + float cfg = 0.0f; + int32_t evals = 0; /* steps the request takes: grid points less one */ + int32_t lane = -1; + bool admitted = false; + bool cond_done = false; + int32_t step = 0; /* steps done */ + bool latent_done = false; + /* The grid: its levels, the one being sampled, its field (NaN where not sampled) and + * the points it samples, all of them when `all` (the coarsest level, and dense + * sampling); `next` is the first not yet queried. */ + std::vector levels; + size_t level = 0; + std::vector field; + std::vector axis; + std::vector pts; + bool all = false; + int64_t n_pts = 0, next = 0; + int64_t points = 0; /* every level's, for the usage */ + bool failed = false; + bool finished = false; + }; + struct Pass { + int kind = 0; + uint64_t job = 0; + int64_t n_query = 0; + }; + struct Region { int64_t off = 0, bytes = 0, used = 0; }; + enum { R_PATCH, R_SIGMA, R_SNEXT, R_CFG, R_PAIR, R_LANES, R_FLAGS, R_SEED, R_LATCU, R_QUERY, + R_QCU, R_N }; + + template T* hptr(int r) const { return reinterpret_cast(host_ + reg_[r].off); } + template T* dptr(int rank, int r) const { + return reinterpret_cast((char*)dev_[(size_t)rank] + reg_[r].off); + } + int upload(); + /* What every pass carries: the lane twice (the step's two entries) and the latents' bounds. */ + void stage_common(const Job& j); + void base_batches(const Job& j, int64_t n_tok, int kind, int step); + void start_level(Job& j, size_t level, std::vector&& pts, bool all); + + void admit_locked(); + void release_locked(Job& j); + void fail_locked(Job& j, int status, const std::string& why); + Job* job_locked(uint64_t id); + + const RadBatch* build_cond(Job& j, int step); + const RadBatch* build_step(Job& j, int step); + const RadBatch* build_latent(Job& j, int step); + const RadBatch* build_query(Job& j, int step); + + RadShapeGenDecl decl_{}; + ShapeGenInfo info_; + int64_t n_patch_ = 0, patch_dim_ = 0; + std::vector ranks_; + + char* host_ = nullptr; /* pinned, same layout as each slab */ + int64_t bytes_ = 0; + std::vector dev_; + Region reg_[R_N]; + float* field_host_ = nullptr; + std::vector rb_; + + std::vector out_; /* one per rank */ + std::vector sout_; + Pass pass_; + + mutable std::mutex mu_; + std::deque> jobs_; /* arrival order */ + std::vector free_lanes_; + uint64_t next_id_ = 1; + bool closed_ = false; + std::string closed_why_; + int closed_status_ = RAD_E_STATE; +}; + +} /* namespace gen */ +} /* namespace rad */ diff --git a/core/gen/video_driver.cpp b/core/gen/video_driver.cpp index caa318ad..b7f1a5c2 100644 --- a/core/gen/video_driver.cpp +++ b/core/gen/video_driver.cpp @@ -198,6 +198,9 @@ int64_t carve(const RadVideoGenDecl& d, int64_t max_tok, int64_t ep, int64_t pd, int64_t (*bytes)[2], int n) { /* A guided model's VCOND carries the negative prompt after the positive. */ const int64_t prompts = d.guidance ? 2 : 1; + /* A schedule's steps: a request's, at most max_steps, plus the refinement rungs an upscaling + * request appends after them (video_schedule). */ + const int64_t sched_cap = (int64_t)d.max_steps + std::max(d.n_refine_rungs, 0); const int64_t want[] = { prompts * d.max_text * 4, /* R_TOK */ prompts * d.max_text * 4, /* R_POS */ @@ -205,8 +208,8 @@ int64_t carve(const RadVideoGenDecl& d, int64_t max_tok, int64_t ep, int64_t pd, 3 * max_tok * 4, /* R_ROPE: a step's positions, or the prompt's M-RoPE */ RAD_VGEOM_N * 4, /* R_GEOM */ 16 * 4, /* R_SCHED */ - d.max_steps * 4, /* R_TV */ - d.max_steps * 4, /* R_TA */ + sched_cap * 4, /* R_TV */ + sched_cap * 4, /* R_TA */ 4 * 4, /* R_SEED */ 4, /* R_LANE */ 4, /* R_FIRST */ @@ -1008,6 +1011,11 @@ const RadBatch* VideoDriver::build_cond(Job& j, int step) { px[i] = rad_f32_to_bf16(2.0f * ((float)img[i] / 255.0f) - 1.0f); reg_[R_IMG].used = (int64_t)img.size() * 2; } + if ((int64_t)j.sched.steps * 4 > reg_[R_TV].bytes) { + fail_locked(j, RAD_E_STATE, "the schedule's " + std::to_string(j.sched.steps) + + " steps are more than the timestep regions hold"); + return nullptr; + } float* tv = hptr(R_TV); float* ta = hptr(R_TA); for (int32_t i = 0; i < j.sched.steps; ++i) { @@ -1238,7 +1246,7 @@ const RadBatch* VideoDriver::build_encode(Job& j, int step) { } else { const int64_t nf = m.enc_frames, area = (int64_t)eh * ew * 3; stage_frames = ng > 23 ? gd[23] : 0; - if (stage_frames < nf || stage_frames * area * 4 > reg_[R_ENCPX].bytes) { + if (nf < 1 || stage_frames < nf || stage_frames * area * 4 > reg_[R_ENCPX].bytes) { fail_locked(j, RAD_E_STATE, "'" + m.name + "' does not fit an encode pass"); return nullptr; } diff --git a/core/gen_config.cpp b/core/gen_config.cpp index ee5a9216..4eaee7d5 100644 --- a/core/gen_config.cpp +++ b/core/gen_config.cpp @@ -39,6 +39,7 @@ SamplingParams GenSampling::onto(SamplingParams base) const { if (ngram_ban_n >= 0) base.ngram_ban_n = ngram_ban_n; if (ngram_window >= 0) base.ngram_window = ngram_window; if (!ngram_whitelist.empty()) base.ngram_whitelist = ngram_whitelist; + if (!suppress.empty()) base.suppress_tokens = suppress; return base; } @@ -156,6 +157,23 @@ bool gen_sampling_parse(const std::string& json_text, const char* src, GenSampli out->ngram_whitelist.push_back((int)id); } } + + /* transformers' suppress_tokens, a JSON array of ids. Dropped entry by entry like the + * whitelist above. */ + it = j.find("suppress_tokens"); + if (it != j.end() && !it->is_array()) { + RAD_WARN("%s states suppress_tokens that is not an array; ignoring it", src); + } else if (it != j.end()) { + for (const auto& v : *it) { + const int64_t id = v.is_number_integer() ? v.get() : -1; + if (id < 0 || id > INT32_MAX) { + RAD_WARN("%s states a suppress_tokens entry outside [0, %d]; ignoring it", + src, INT32_MAX); + continue; + } + out->suppress.push_back((int)id); + } + } return out->any(); } @@ -175,7 +193,7 @@ bool gen_sampling_from_kv(const std::function& get, Ge nlohmann::json j = nlohmann::json::object(); static const char* const kFields[] = { "do_sample", "temperature", "top_p", "min_p", "top_k", "no_repeat_ngram_size", "no_repeat_ngram_window_size", - "no_repeat_ngram_whitelist" }; + "no_repeat_ngram_whitelist", "suppress_tokens" }; for (const char* k : kFields) { const char* v = get(k); if (!v || !*v) continue; @@ -195,6 +213,18 @@ bool gen_sampling_from_kv(const std::function& get, Ge } continue; } + if (std::strcmp(k, "suppress_tokens") == 0) { + /* An array of scalars is flattened to a space-separated string (flatten_json). */ + nlohmann::json ids = nlohmann::json::array(); + char* p = const_cast(v); + for (char* e = nullptr;; p = e) { + const long long id = std::strtoll(p, &e, 10); + if (e == p) break; + ids.push_back(id); + } + j[k] = std::move(ids); + continue; + } char* end = nullptr; const double d = std::strtod(v, &end); if (end == v) { diff --git a/core/gen_config.h b/core/gen_config.h index 28c4aaa7..74e5d6eb 100644 --- a/core/gen_config.h +++ b/core/gen_config.h @@ -33,10 +33,13 @@ struct GenSampling { * has no field for it; a container states it as `generation.no_repeat_ngram_whitelist`, a * JSON array of ids. Empty means not stated. */ std::vector ngram_whitelist; + /* transformers' suppress_tokens: ids never sampled. Empty means not stated. */ + std::vector suppress; bool any() const { return temp >= 0.0f || top_p >= 0.0f || min_p >= 0.0f || top_k >= 0 || - ngram_ban_n >= 0 || ngram_window >= 0 || !ngram_whitelist.empty(); + ngram_ban_n >= 0 || ngram_window >= 0 || !ngram_whitelist.empty() || + !suppress.empty(); } /* Overlay onto `base` field by field; unstated fields keep base's, so sources stack. */ diff --git a/core/mem/kv.cpp b/core/mem/kv.cpp index 12e4c656..82a539c7 100644 --- a/core/mem/kv.cpp +++ b/core/mem/kv.cpp @@ -381,12 +381,16 @@ int KVManager::declare_runtime_window(int32_t g, int64_t window_tokens) { fixed_ += align_up(max_seqs_ * q.ring_blocks_max() * q.bytes_per_block, RAD_ALIGN_UNIT); if (counted) { const int64_t was = q.window_blocks * q.bytes_per_block; - /* The plan counted this group's snapshot section, so both totals carry `was`. - * Saturating hides an accounting bug; surface it in debug builds. */ - assert(window_ck_bytes_ >= was && checkpoint_bytes_ >= was && - "runtime window: snapshot byte totals below the section being removed"); - window_ck_bytes_ = window_ck_bytes_ > was ? window_ck_bytes_ - was : 0; - checkpoint_bytes_ = checkpoint_bytes_ > was ? checkpoint_bytes_ - was : 0; + /* The plan counted this group's snapshot section, so both totals carry `was`; less + * is an accounting bug, and the pool would be sized from a wrong total. */ + if (window_ck_bytes_ < was || checkpoint_bytes_ < was) { + RAD_ERR("kv group %d: runtime window: the snapshot byte totals (%lld, %lld) are " + "below the %lld-byte section being removed", (int)g, + (long long)window_ck_bytes_, (long long)checkpoint_bytes_, (long long)was); + return RAD_E_STATE; + } + window_ck_bytes_ -= was; + checkpoint_bytes_ -= was; } } return RAD_OK; @@ -520,8 +524,8 @@ int KVManager::carve_into(Pool& kv_pool) { " vram_kv %10s\n" " short by %10s\n" "Lower --max-num-seqs, or give the cache more of the card: a smaller " - "--gpu-headroom-mib or a larger --host-pool-mib. The engine will not shrink one of " - "them for you (spec §6).", + "--gpu-headroom-mib, a larger --gpu-memory-mib, or a larger --host-pool-mib. The " + "engine will not shrink one of them for you (spec §6).", humanb(fixed).c_str(), (long long)max_seqs_, humanb(budget_bytes).c_str(), humanb(fixed - budget_bytes + 1).c_str()); return RAD_E_NOMEM; @@ -550,8 +554,8 @@ int KVManager::carve_into(Pool& kv_pool) { } if (p.n_blocks <= 0) { RAD_ERR("KV group '%s': a %s KV pool leaves 0 blocks (%s a page) after the fixed " - "linear/conv costs of %s. Raise --host-pool-mib or lower --gpu-headroom-mib, or " - "lower --max-num-seqs.", + "linear/conv costs of %s. Raise --host-pool-mib or --gpu-memory-mib, or lower " + "--gpu-headroom-mib or --max-num-seqs.", p.name.c_str(), humanb(budget_bytes).c_str(), humanb(p.bytes_per_block).c_str(), humanb(fixed).c_str()); return RAD_E_NOMEM; diff --git a/core/mem/kvtier.cpp b/core/mem/kvtier.cpp index 3d1face9..1d779948 100644 --- a/core/mem/kvtier.cpp +++ b/core/mem/kvtier.cpp @@ -536,7 +536,10 @@ void IdleTiers::report(const TierJob& job, bool ok, uint64_t now_ns) { static bool chain_extends(const std::vector& shorter, const std::vector& longer) { if (shorter.size() > longer.size()) return false; - for (size_t i = 0; i < shorter.size(); ++i) if (shorter[i] != longer[i]) return false; + /* Hashes are chained, so the last block decides; it is compared first, and a chain that + * diverges anywhere rejects in one compare. */ + if (!shorter.empty() && shorter.back() != longer[shorter.size() - 1]) return false; + for (size_t i = 0; i + 1 < shorter.size(); ++i) if (shorter[i] != longer[i]) return false; return true; } @@ -546,7 +549,7 @@ void IdleTiers::note_session(uint64_t id, const std::vector& chain, i std::lock_guard lk(mu_); /* A session is a leaf of the prefix trie. Each turn arrives under a new request id, so the - * candidates are the sessions sharing this root (a handful at most): + * candidates are the sessions sharing this root (at most kRootSessions): * * - a chain this one extends is no longer a leaf and is absorbed; * - a chain that extends this one means this is not a leaf either (a preempted request @@ -590,6 +593,22 @@ void IdleTiers::note_session(uint64_t id, const std::vector& chain, i s.chain = chain; s.label = std::move(kept_label); at_root.push_back(id); + /* Rows under one root are pruned only when the root block goes, and a prompt every request + * shares (a decision model's instructions) never goes: the list grew by a row a request and + * each insert walked it under the lock the engine threads take (#375: prefill from 9k to + * 2.5k tok/s after 500K requests). Past kRootSessions the least recently used row is + * dropped; a row is bookkeeping, so its blocks stay cached. */ + if (at_root.size() > kRootSessions) { + uint64_t oldest = 0, oldest_ns = ~uint64_t{0}; + for (uint64_t sid : at_root) { + auto it = sessions_.find(sid); + if (it != sessions_.end() && it->second.last_used_ns < oldest_ns) { + oldest_ns = it->second.last_used_ns; + oldest = sid; + } + } + if (oldest) drop_session(oldest); + } } void IdleTiers::drop_session(uint64_t id) { diff --git a/core/mem/kvtier.h b/core/mem/kvtier.h index a42b7530..5bd9b244 100644 --- a/core/mem/kvtier.h +++ b/core/mem/kvtier.h @@ -404,6 +404,9 @@ private: * freed, so ticks do not spin on the queue. */ bool wb_stuck_ = false; std::unordered_map sessions_; + /* Rows kept under one root (sessions sharing a first block); past it the least recently used + * goes (note_session). */ + static constexpr size_t kRootSessions = 1024; /* Sessions by first block. A chain is reachable only from position zero, so once its first * block goes (forget(), or a drop here via drop_rooted) its rows go too; this keeps the table * bounded. Sessions sharing a system prompt share a root, hence a list. */ diff --git a/core/mem/vram_budget.cpp b/core/mem/vram_budget.cpp index 08d365e2..b7e4e7b7 100644 --- a/core/mem/vram_budget.cpp +++ b/core/mem/vram_budget.cpp @@ -76,6 +76,21 @@ static int resolve(Config& cfg, const std::vector& per_rank, VramBudg if (f.unified) b.host_pinned = std::max(b.host_pinned, f.host_pinned); } if (!b.unified) b.host_pinned = 0; + /* --gpu-memory-mib is the inverse of --gpu-headroom-mib: N + headroom = the card, in MiB. + * Convert once the smallest rank capacity is known. A device that reports no capacity has + * nothing to claim, so the flag does not apply. */ + if (b.capacity > 0 && cfg.gpu_memory_mib > 0) { + const int64_t cap_mib = b.capacity / kMiB; + if (cfg.gpu_memory_mib > cap_mib) { + b.report = fmt("--gpu-memory-mib %lld is above this card's %lld MiB", + (long long)cfg.gpu_memory_mib, (long long)cap_mib); + if (log) RAD_ERR("%s", b.report.c_str()); + if (out) *out = b; + return RAD_E_INVAL; + } + cfg.gpu_headroom_mib = cap_mib - cfg.gpu_memory_mib; + cfg.given["--gpu-headroom-mib"] = "derived from --gpu-memory-mib"; + } b.headroom = std::max(cfg.gpu_headroom_mib, 0) * kMiB; int64_t host_reserve = 0; for (const VramFacts& f : per_rank) host_reserve = std::max(host_reserve, f.host_reserve); @@ -116,6 +131,11 @@ static int resolve(Config& cfg, const std::vector& per_rank, VramBudg b.queues + b.prefetch + b.host_pinned); if (b.claimable < 0) { + const char* how = cfg.gpu_memory_mib > 0 + ? "Raise --gpu-memory-mib, lower --max-num-batched-tokens (the arena scales with it), " + "or free the card.\n" + : "Lower --gpu-headroom-mib, lower --max-num-batched-tokens (the arena scales with it), " + "or free the card.\n"; b.report = fmt( "VRAM does not cover the fixed costs before a single pool is sized:\n" " card total %10s\n" @@ -128,12 +148,11 @@ static int resolve(Config& cfg, const std::vector& per_rank, VramBudg " expert prefetch %10s (its ring of expert units and buffers)\n" " ------------------------------\n" " short by %10s\n" - "Lower --gpu-headroom-mib, lower --max-num-batched-tokens (the arena scales with it), " - "or free the card.\n", + "%s", humanb(b.capacity).c_str(), humanb(b.already_held).c_str(), humanb(b.drift).c_str(), humanb(b.headroom).c_str(), humanb(b.arena).c_str(), humanb(b.staging).c_str(), humanb(b.queues).c_str(), b.n_queues, humanb(b.queue_bytes).c_str(), - humanb(b.prefetch).c_str(), humanb(-b.claimable).c_str()); + humanb(b.prefetch).c_str(), humanb(-b.claimable).c_str(), how); if (log) RAD_ERR("%s", b.report.c_str()); if (out) *out = b; return RAD_E_NOMEM; diff --git a/core/mem/vram_budget.h b/core/mem/vram_budget.h index 8e729565..899c7a95 100644 --- a/core/mem/vram_budget.h +++ b/core/mem/vram_budget.h @@ -10,6 +10,8 @@ * loaded code. The only observed term, printed on its own line so a * desktop on the card shows up there instead of shrinking a pool. * --gpu-headroom-mib what the operator leaves alone (default 96 MiB). + * --gpu-memory-mib the inverse: claim this much of the card; headroom is the rest. + * Not with --gpu-headroom-mib. * arena activation arena plus scratch, from arena_plan_bytes() on the buffer * plan, the same call that later allocates it. * @@ -32,9 +34,9 @@ * KVManager::ceiling; the experts at the whole plane) and one side's excess goes to the other. * * No flag states a pool size: unbudgeted VRAM is unusable, and on a model whose experts do not - * fit every unbudgeted GiB costs decode time. Operators move the inputs instead: --gpu-headroom-mib, - * --max-model-len and --max-num-seqs (cache bound), --host-pool-mib (which experts must stay on - * the card). + * fit every unbudgeted GiB costs decode time. Operators move the inputs instead: --gpu-headroom-mib + * or --gpu-memory-mib, --max-model-len and --max-num-seqs (cache bound), --host-pool-mib (which + * experts must stay on the card). * * The host backend uses half the machine's memory as its capacity (host_vram_bytes) and splits it * like a card; its weights pool holds what a host kernel cannot read where the container stores it diff --git a/core/mm/item.cpp b/core/mm/item.cpp index f6b2f111..d7b6d985 100644 --- a/core/mm/item.cpp +++ b/core/mm/item.cpp @@ -31,7 +31,16 @@ void Item::coords(int64_t first, int64_t count, int32_t* planes) const { while (s + 1 < n_seg && patch_at(s + 1) <= first) ++s; for (int64_t k = 0; k < count; ++k) { while (s + 1 < n_seg && patch_at(s + 1) <= first + k) ++s; - const int64_t within = first + k - patch_at(s); + int64_t within = first + k - patch_at(s); + if (within < seg_prefix) { + /* A row the tower fills itself: row -1, the column naming which. */ + planes[k] = -1; + planes[count + k] = (int32_t)within; + planes[2 * count + k] = seg_h(s); + planes[3 * count + k] = seg_w(s); + continue; + } + within -= seg_prefix; const int64_t bw = seg_w(s) / merge; int64_t row, col; if (patch_raster) { diff --git a/core/mm/media.cpp b/core/mm/media.cpp index 17559449..40c021a3 100644 --- a/core/mm/media.cpp +++ b/core/mm/media.cpp @@ -702,21 +702,41 @@ int decode_audio(const uint8_t* data, size_t n, int32_t rate, int64_t max_sample return RAD_OK; } +namespace { + +/* The H.264 encoder the round trip uses: libx264, the reference's, else libopenh264 (the published + * image carries libopenh264 and no libx264). Not any H.264 encoder: the hardware ones need a device + * context this path does not set up. */ +const AVCodec* h264_encoder() { + for (const char* name : { "libx264", "libopenh264" }) + if (const AVCodec* c = avcodec_find_encoder_by_name(name)) return c; + return nullptr; +} + +} /* namespace */ + bool h264_roundtrip_available() { - return avcodec_find_encoder_by_name("libx264") && avcodec_find_decoder(AV_CODEC_ID_H264); + return h264_encoder() && avcodec_find_decoder(AV_CODEC_ID_H264); } /* PyAV's single-frame round trip: VideoFrame.from_ndarray(rgb24).reformat("yuv420p") (plain * SWS_BILINEAR, BT.601 coefficients, limited-range output), libx264 with the given crf, then the - * decoded frame's to_ndarray("rgb24"), which to_rgb reproduces. */ + * decoded frame's to_ndarray("rgb24"), which to_rgb reproduces. Without libx264, libopenh264 takes + * the frame at a quantiser held at the crf, about the compression libx264's crf gives a single intra + * frame, so the first frame is close to the reference's but not exact. libopenh264 takes no side + * under 16, so a smaller picture is encoded with its last row and column repeated out to 16 and + * the decoded frame cut back. */ int h264_roundtrip(const Frame& in, int32_t crf, Frame* out, std::string* why) { std::string w; if (!why) why = &w; const int W = in.w & ~1, H = in.h & ~1; if (W <= 0 || H <= 0) { *why = "the picture is smaller than 2x2"; return RAD_E_INVAL; } - const AVCodec* enc = avcodec_find_encoder_by_name("libx264"); + const AVCodec* enc = h264_encoder(); const AVCodec* dcd = avcodec_find_decoder(AV_CODEC_ID_H264); - if (!enc || !dcd) { *why = "this libavcodec has no libx264 encoder or H.264 decoder"; return RAD_E_UNSUPPORTED; } + if (!enc) { *why = "this libavcodec has no H.264 encoder"; return RAD_E_UNSUPPORTED; } + if (!dcd) { *why = "this libavcodec has no H.264 decoder"; return RAD_E_UNSUPPORTED; } + const bool x264 = !std::strcmp(enc->name, "libx264"); + const int EW = x264 ? W : std::max(W, 16), EH = x264 ? H : std::max(H, 16); AVCodecContext* ec = avcodec_alloc_context3(enc); AVCodecContext* dc = avcodec_alloc_context3(dcd); AVFrame* yuv = av_frame_alloc(); @@ -733,8 +753,8 @@ int h264_roundtrip(const Frame& in, int32_t crf, Frame* out, std::string* why) { *why = "out of memory"; st = RAD_E_NOMEM; } else { - ec->width = W; - ec->height = H; + ec->width = EW; + ec->height = EH; ec->pix_fmt = AV_PIX_FMT_YUV420P; ec->time_base = AVRational{ 1, 1 }; ec->framerate = AVRational{ 1, 1 }; @@ -742,19 +762,26 @@ int h264_roundtrip(const Frame& in, int32_t crf, Frame* out, std::string* why) { * that many slices, which shapes the bitstream. */ ec->thread_count = 0; ec->thread_type = FF_THREAD_SLICE; - av_opt_set(ec->priv_data, "preset", "veryfast", 0); - av_opt_set(ec->priv_data, "crf", std::to_string(crf).c_str(), 0); + if (x264) { + av_opt_set(ec->priv_data, "preset", "veryfast", 0); + av_opt_set(ec->priv_data, "crf", std::to_string(crf).c_str(), 0); + } else { + /* libopenh264's rate control held between qmin and qmax: its "off" mode encodes at the + * layer quantiser FFmpeg leaves at the library's default and ignores both. */ + ec->qmin = ec->qmax = std::clamp(crf, 1, 51); + av_opt_set(ec->priv_data, "rc_mode", "quality", 0); + } int e = avcodec_open2(ec, enc, nullptr); - if (e < 0) fail("opening libx264", e); + if (e < 0) fail(x264 ? "opening libx264" : "opening the H.264 encoder", e); if (st == RAD_OK && (e = avcodec_open2(dc, dcd, nullptr)) < 0) fail("opening the H.264 decoder", e); if (st == RAD_OK) { yuv->format = AV_PIX_FMT_YUV420P; - yuv->width = W; - yuv->height = H; + yuv->width = EW; + yuv->height = EH; if ((e = av_frame_get_buffer(yuv, 0)) < 0) fail("allocating a frame", e); } if (st == RAD_OK) { - sws = sws_getContext(W, H, AV_PIX_FMT_RGB24, W, H, AV_PIX_FMT_YUV420P, SWS_BILINEAR, + sws = sws_getContext(EW, EH, AV_PIX_FMT_RGB24, EW, EH, AV_PIX_FMT_YUV420P, SWS_BILINEAR, nullptr, nullptr, nullptr); if (!sws) fail("no RGB to yuv420p conversion", 0); } @@ -765,14 +792,17 @@ int h264_roundtrip(const Frame& in, int32_t crf, Frame* out, std::string* why) { if (!rgb) fail("out of memory", AVERROR(ENOMEM)); else { rgb->format = AV_PIX_FMT_RGB24; - rgb->width = W; - rgb->height = H; + rgb->width = EW; + rgb->height = EH; if ((e = av_frame_get_buffer(rgb, 0)) < 0) fail("allocating a frame", e); else { - for (int y = 0; y < H; ++y) - std::memcpy(rgb->data[0] + (ptrdiff_t)y * rgb->linesize[0], - in.rgb.data() + (size_t)y * in.w * 3, (size_t)W * 3); - if (sws_scale(sws, rgb->data, rgb->linesize, 0, H, yuv->data, yuv->linesize) != H) + for (int y = 0; y < EH; ++y) { + uint8_t* row = rgb->data[0] + (ptrdiff_t)y * rgb->linesize[0]; + std::memcpy(row, in.rgb.data() + (size_t)std::min(y, H - 1) * in.w * 3, + (size_t)W * 3); + for (int x = W; x < EW; ++x) std::memcpy(row + x * 3, row + (W - 1) * 3, 3); + } + if (sws_scale(sws, rgb->data, rgb->linesize, 0, EH, yuv->data, yuv->linesize) != EH) fail("colour conversion failed", 0); } av_frame_free(&rgb); @@ -795,6 +825,19 @@ int h264_roundtrip(const Frame& in, int32_t crf, Frame* out, std::string* why) { st = to_rgb(dec, &back, out, why); sws_freeContext(back); got = st == RAD_OK; + if (got && (out->w != W || out->h != H)) { + if (out->w < W || out->h < H) { + fail("the round trip decoded to a smaller frame", 0); + got = false; + } else { + for (int y = 0; y < H; ++y) + std::memmove(out->rgb.data() + (size_t)y * W * 3, + out->rgb.data() + (size_t)y * out->w * 3, (size_t)W * 3); + out->rgb.resize((size_t)W * H * 3); + out->w = W; + out->h = H; + } + } } av_frame_unref(dec); } diff --git a/core/mm/media.h b/core/mm/media.h index 2a3adf06..61f83d35 100644 --- a/core/mm/media.h +++ b/core/mm/media.h @@ -90,9 +90,9 @@ int decode_audio(const uint8_t* data, size_t n, int32_t rate, int64_t max_sample /* `in` encoded as a one-frame H.264 stream at constant quality `crf` (libx264, preset veryfast, * yuv420p) and decoded back, as a video model's reference pipeline does to a conditioning * picture so it carries the compression of the footage the model was trained on. An odd width - * or height loses its last column or row first. Needs libx264. */ + * or height loses its last column or row first. Needs an H.264 encoder: libx264, else libopenh264. */ int h264_roundtrip(const Frame& in, int32_t crf, Frame* out, std::string* why); -/* Whether this build can run h264_roundtrip: its libavcodec has libx264. */ +/* Whether this build can run h264_roundtrip: its libavcodec has an H.264 encoder and decoder. */ bool h264_roundtrip_available(); } /* namespace mm */ diff --git a/core/mm/processor.cpp b/core/mm/processor.cpp index c845254e..a1e45956 100644 --- a/core/mm/processor.cpp +++ b/core/mm/processor.cpp @@ -244,10 +244,74 @@ int VisionConfig::from_meta(const RadModelMeta& m, std::string* why) { } return RAD_OK; } - if (mt && !std::strcmp(mt, "gemma4_vision")) { + /* NVIDIA's Nemotron-H Omni states its tile budget in the processor configs (preprocessor and + * processor_config's image_processor carry the same keys) and its token ids in config.json, + * except and , which the vocabulary names (Processor::init). */ + if (mt && !std::strcmp(mt, "radio")) { + family = Family::Radio; + auto geti = [&](const char* k, int64_t dflt) { + const std::string a = std::string("processor.image_processor.") + k; + const std::string b = std::string("preprocessor.") + k; + return rad_meta_geti(&m, a.c_str(), rad_meta_geti(&m, b.c_str(), dflt)); + }; + patch = (int32_t)geti("patch_size", rad_meta_geti(&m, "vision_config.patch_size", 0)); + const double ratio = rad_meta_getf(&m, "downsample_ratio", 0.0); + merge = ratio > 0.0 ? (int32_t)std::lround(1.0 / ratio) : 0; + temporal = 1; + radio_tubelet = (int32_t)rad_meta_geti( + &m, "processor.video_temporal_patch_dim", + rad_meta_geti(&m, "video_temporal_patch_size", + rad_meta_geti(&m, "vision_config.video_temporal_patch_size", 0))); + radio_prefix = (int32_t)(rad_meta_geti(&m, "vision_config.num_cls_tokens", 0) + + rad_meta_geti(&m, "vision_config.num_registers", 0)); + tok_image = (int32_t)rad_meta_geti(&m, "img_context_token_id", -1); + if (patch <= 0 || merge <= 0 || radio_tubelet <= 0 || radio_prefix <= 0 || tok_image < 0) { + if (why) *why = "the container states no Nemotron-H Omni processor geometry " + "(vision_config.patch_size, downsample_ratio, video_temporal_patch_size, " + "num_cls_tokens + num_registers, img_context_token_id)"; + return RAD_E_NOTFOUND; + } + radio_min_patches = (int32_t)geti("min_num_patches", 1024); + radio_max_patches = (int32_t)geti("max_num_patches", 13312); + radio_max_len = (int32_t)geti("max_model_len", 16384); + radio_video_patches = (int32_t)geti("video_target_num_patches", 1024); + if (!read_triple(m, "processor.image_processor.norm_mean", mean) && + !read_triple(m, "preprocessor.norm_mean", mean)) + read_triple(m, "norm_mean", mean); + if (!read_triple(m, "processor.image_processor.norm_std", stdv) && + !read_triple(m, "preprocessor.norm_std", stdv)) + read_triple(m, "norm_std", stdv); + /* The model card's serving default: 2 frames a second, at most 128 (64 tubelets). */ + fps = 2.0; + min_frames = radio_tubelet; + max_frames = 128; + max_frame_rows = 0; + /* The pixel bands only have to be consistent for check(); the tile rule sizes by patches. */ + const int64_t p2 = (int64_t)patch * patch; + image_min_pixels = (int64_t)radio_min_patches * p2; + image_max_pixels = std::max(image_min_pixels, (int64_t)radio_max_patches * p2); + video_min_pixels = video_max_pixels = (int64_t)radio_video_patches * p2; + std::string bad; + if (radio_min_patches <= 0 || radio_video_patches <= 0 || radio_max_len <= 0) + bad = "min_num_patches, video_target_num_patches and max_model_len must be positive"; + if (bad.empty() && check(&bad) < 0) bad = "the container's Nemotron-H Omni processor " + "configuration is inconsistent: " + bad; + if (!bad.empty()) { + if (why) *why = bad; + return RAD_E_INVAL; + } + return RAD_OK; + } + /* Gemma 4 12B ("unified") has no tower: its embedder takes a whole 48 x 48 pooling window as + * one patch, so a patch is a row (merge 1), and its values are u / 255. The sizes are the + * same: a window is 48 pixels a side either way. */ + const bool unified = mt && !std::strcmp(mt, "gemma4_unified_vision"); + if (mt && (!std::strcmp(mt, "gemma4_vision") || unified)) { family = Family::Gemma4; - patch = (int32_t)rad_meta_geti(&m, "vision_config.patch_size", 0); - merge = (int32_t)rad_meta_geti(&m, "vision_config.pooling_kernel_size", 0); + unit_pixels = unified; + patch = (int32_t)rad_meta_geti(&m, unified ? "vision_config.model_patch_size" + : "vision_config.patch_size", 0); + merge = unified ? 1 : (int32_t)rad_meta_geti(&m, "vision_config.pooling_kernel_size", 0); temporal = 1; if (patch <= 0 || merge <= 0) { if (why) *why = "the container states no vision tower geometry (vision_config." @@ -267,7 +331,8 @@ int VisionConfig::from_meta(const RadModelMeta& m, std::string* why) { image_soft_tokens = (int32_t)rad_meta_geti( &m, "processor.image_processor.max_soft_tokens", rad_meta_geti(&m, "vision_soft_tokens_per_image", - rad_meta_geti(&m, "vision_config.default_output_length", 280))); + rad_meta_geti(&m, "vision_config.default_output_length", + rad_meta_geti(&m, "vision_config.num_soft_tokens", 280)))); video_soft_tokens = (int32_t)rad_meta_geti(&m, "processor.video_processor.max_soft_tokens", 70); fps = rad_meta_getf(&m, "processor.video_processor.fps", 1.0); @@ -970,6 +1035,134 @@ void resize_bicubic_torch(const Frame& in, int32_t w, int32_t h, Frame* out) { resize_bicubic_impl(in, w, h, out, true); } +/* Python's round(): the nearest integer, a tie to the even one. The default floating-point + * environment rounds that way, which nearbyint follows. */ +static inline int64_t py_round(double x) { return (int64_t)std::nearbyint(x); } + +void radio_size(int64_t w, int64_t h, const VisionConfig& c, int32_t* wp, int32_t* hp) { + const int64_t div = c.merge, lo = c.radio_min_patches; + const int64_t hi = c.radio_max_patches > 0 ? c.radio_max_patches : INT64_MAX; + const int64_t budget = std::max((int64_t)(c.radio_max_len - 4) * div * div, lo); + const int64_t avail = std::max(std::min(budget, hi), lo); + /* round(x + 0.5): x + 1 rounded down for a fraction, and for a whole x, x or x + 1 by parity + * (Python's tie to even), which the reference's comment does not say but its code does. */ + const int64_t ch = py_round((double)h / (double)c.patch + 0.5); + const int64_t cw = py_round((double)w / (double)c.patch + 0.5); + const double factor = std::min(std::sqrt((double)avail / (double)(ch * cw)), 1.0); + int64_t th = (int64_t)std::floor(factor * (double)ch); + int64_t tw = (int64_t)std::floor(factor * (double)cw); + if (avail > lo && th * tw < lo) { + const double up = std::sqrt((double)lo / (double)(th * tw)); + th = (int64_t)std::ceil(up * (double)th); + tw = (int64_t)std::ceil(up * (double)tw); + } + if (const int64_t r = th % div) th = (th + div - r) * tw <= avail ? th + div - r + : std::max(div, th - r); + if (const int64_t r = tw % div) tw = th * (tw + div - r) <= avail ? tw + div - r + : std::max(div, tw - r); + *wp = (int32_t)tw; + *hp = (int32_t)th; +} + +void radio_video_size(int64_t w, int64_t h, const VisionConfig& c, int32_t* wp, int32_t* hp) { + const int64_t div = c.merge, target = c.radio_video_patches; + const double aspect = (double)w / (double)std::max(h, 1); + int64_t ph = std::max(py_round(std::sqrt((double)target / aspect)), 1); + int64_t pw = std::max(py_round(std::sqrt((double)target * aspect)), 1); + if (div > 1) { + const int64_t rh = ph % div, rw = pw % div; + const int64_t phu = ph + (rh ? div - rh : 0), pwu = pw + (rw ? div - rw : 0); + if (phu * pwu <= target) { + ph = phu; + pw = pwu; + } else { + ph = std::max(div, ph - rh); + pw = std::max(div, pw - rw); + } + } + *wp = (int32_t)pw; + *hp = (int32_t)ph; +} + +/* ATen's antialiased bicubic (Keys, a = -0.5) on float, one axis: output i reads inputs + * [lo, lo + n) at the filter's normalised weights, the support widened by the scale when + * shrinking. */ +namespace { +struct AaTaps { std::vector lo, n; std::vector w; int32_t width = 0; }; +inline float aa_cubic(float x) { + const float a = -0.5f; + x = std::fabs(x); + if (x < 1.0f) return ((a + 2.0f) * x - (a + 3.0f)) * x * x + 1.0f; + if (x < 2.0f) return ((a * x - 5.0f * a) * x + 8.0f * a) * x - 4.0f * a; + return 0.0f; +} +AaTaps aa_taps_f32(int32_t in, int32_t out) { + AaTaps t; + const float scale = (float)in / (float)out; + const float support = scale >= 1.0f ? 2.0f * scale : 2.0f; + const float inv = scale >= 1.0f ? 1.0f / scale : 1.0f; + t.width = (int32_t)std::ceil(support) * 2 + 1; + t.lo.resize((size_t)out); + t.n.resize((size_t)out); + t.w.assign((size_t)out * t.width, 0.0f); + for (int32_t i = 0; i < out; ++i) { + const float center = scale * ((float)i + 0.5f); + const int32_t lo = std::max((int32_t)(center - support + 0.5f), 0); + const int32_t n = std::min((int32_t)(center + support + 0.5f), in) - lo; + float* w = &t.w[(size_t)i * t.width]; + float total = 0.0f; + for (int32_t j = 0; j < n && j < t.width; ++j) { + w[j] = aa_cubic(((float)(j + lo) - center + 0.5f) * inv); + total += w[j]; + } + for (int32_t j = 0; j < n && j < t.width; ++j) w[j] = total != 0.0f ? w[j] / total : 0.0f; + t.lo[(size_t)i] = lo; + t.n[(size_t)i] = std::min(n, t.width); + } + return t; +} +} /* namespace */ + +void resize_bicubic_aa_f32(const Frame& in, int32_t w, int32_t h, std::vector* out) { + std::vector src((size_t)in.w * in.h * 3); + for (size_t i = 0; i < src.size(); ++i) src[i] = (float)in.rgb[i]; + /* Width first, then height; a side that keeps its size is skipped (its taps are the identity). */ + std::vector mid; + const std::vector* cur = &src; + int32_t cw = in.w; + if (w != in.w) { + const AaTaps t = aa_taps_f32(in.w, w); + mid.assign((size_t)w * in.h * 3, 0.0f); + for (int32_t y = 0; y < in.h; ++y) + for (int32_t x = 0; x < w; ++x) + for (int c = 0; c < 3; ++c) { + float acc = 0.0f; + const float* wt = &t.w[(size_t)x * t.width]; + for (int32_t j = 0; j < t.n[(size_t)x]; ++j) + acc += src[((size_t)y * in.w + t.lo[(size_t)x] + j) * 3 + c] * wt[j]; + mid[((size_t)y * w + x) * 3 + c] = acc; + } + cur = ∣ + cw = w; + } + if (h != in.h) { + const AaTaps t = aa_taps_f32(in.h, h); + out->assign((size_t)cw * h * 3, 0.0f); + for (int32_t y = 0; y < h; ++y) { + const float* wt = &t.w[(size_t)y * t.width]; + for (int32_t x = 0; x < cw; ++x) + for (int c = 0; c < 3; ++c) { + float acc = 0.0f; + for (int32_t j = 0; j < t.n[(size_t)y]; ++j) + acc += (*cur)[((size_t)(t.lo[(size_t)y] + j) * cw + x) * 3 + c] * wt[j]; + (*out)[((size_t)y * cw + x) * 3 + c] = acc; + } + } + return; + } + *out = *cur; +} + void cap_area(const Frame& in, int64_t max_pixels, Frame* out) { if (max_pixels <= 0 || (int64_t)in.w * in.h <= max_pixels) { *out = in; return; } const double scale = std::sqrt((double)max_pixels / ((double)in.w * in.h)); @@ -1071,7 +1264,8 @@ void patchify(const VisionConfig& c, const std::vector& frames, It * processor's rescale u * (1/255). The processors AutoProcessor loads take that product in f32 for * pictures (Gemma4ImageProcessor) and in double, rounded to f32, for video (Gemma 4's and * EmbeddingGemma 2's video processors); `video` picks which, and the two differ for u = 127. One - * frame per segment. */ + * frame per segment. With `unit_pixels` (the 12B, merge 1: a row is one 48 x 48 window) the value + * is p itself, rounded to bf16. */ void patchify_gemma4(const VisionConfig& c, const std::vector& frames, bool video, Item* it) { const int P = c.patch, M = c.merge; @@ -1080,7 +1274,7 @@ void patchify_gemma4(const VisionConfig& c, const std::vector& fra for (int v = 0; v < 256; ++v) { const float p = video ? (float)((double)v * (1.0 / 255.0)) : (float)v * (float)(1.0 / 255.0); - lut[v] = rad_f32_to_bf16(2.0f * (p - 0.5f)); + lut[v] = rad_f32_to_bf16(c.unit_pixels ? p : 2.0f * (p - 0.5f)); } const int64_t dim = it->patch_dim; it->pixels.assign((size_t)it->n_patch * (size_t)dim, 0); @@ -1100,6 +1294,55 @@ void patchify_gemma4(const VisionConfig& c, const std::vector& fra } } +/* Radio's patch rows (Family::Radio), segment by segment: `n_prefix` zero rows, then the patches + * in merge-block order. A row is [the tubelet's frames (frame, channel, y, x) | the picture's + * (channel, y, x)]: a picture fills the second part, a video tubelet the first, the rest zero. + * Each value is (u / 255 - mean) / std in f32 on the resized float pixels, rounded to bf16, as the + * reference processor's tensor ops and the model's cast to bf16 give it. `frames` holds + * grid_t * tubelet frames of [grid_h * patch, grid_w * patch, 3] floats for a video, one for a + * picture. */ +void patchify_radio(const VisionConfig& c, const std::vector*>& frames, + bool video, Item* it) { + const int P = c.patch, M = c.merge, T = c.radio_tubelet; + const int gh = it->grid_h, gw = it->grid_w, W = gw * P; + const int64_t dim = it->patch_dim, pp = 3LL * P * P; + it->pixels.assign((size_t)it->n_patch * (size_t)dim, 0); + uint16_t* dst = it->pixels.data(); + auto norm = [&](float u, int ch) { + return rad_f32_to_bf16((u / 255.0f - c.mean[ch]) / c.stdv[ch]); + }; + for (int g = 0; g < it->grid_t; ++g) { + dst += (size_t)it->seg_prefix * dim; + for (int bh = 0; bh < gh / M; ++bh) + for (int bw = 0; bw < gw / M; ++bw) + for (int mh = 0; mh < M; ++mh) + for (int mw = 0; mw < M; ++mw) { + const int py0 = (bh * M + mh) * P, px0 = (bw * M + mw) * P; + const int nf = video ? T : 1; + uint16_t* o = dst + (video ? 0 : (int64_t)T * pp); + for (int t = 0; t < nf; ++t) { + const std::vector& f = *frames[(size_t)(g * nf + t)]; + for (int ch = 0; ch < 3; ++ch) + for (int y = 0; y < P; ++y) + for (int x = 0; x < P; ++x) + *o++ = norm(f[((size_t)(py0 + y) * W + px0 + x) * 3 + ch], ch); + } + dst += dim; + } + } +} + +/* Radio's item geometry: finish_item's, with the prefix rows counted in the patches. */ +void finish_item_radio(const VisionConfig& c, Item* it) { + it->patch_dim = c.patch_dim(); + it->seg_prefix = c.radio_prefix; + it->rows_h = it->grid_h / c.merge; + it->rows_w = it->grid_w / c.merge; + it->seg_rows = it->rows_h * it->rows_w; + it->n_seg = it->grid_t; + it->n_patch = (int64_t)it->grid_t * (c.radio_prefix + (int64_t)it->grid_h * it->grid_w); +} + void finish_item(const VisionConfig& c, Item* it) { it->patch_dim = c.patch_dim(); it->n_patch = (int64_t)it->grid_t * it->grid_h * it->grid_w; @@ -1153,6 +1396,26 @@ int Processor::init(const VisionConfig& cfg, encode_text_ = std::move(encode_text); return RAD_OK; } + if (cfg.family == Family::Radio) { + /* The markers around a run are vocabulary words, not config ids. A tile is one segment of + * one pass with its prefix rows, so the picture budget is lowered to what a pass holds; + * a video frame's target must fit as it is. */ + if (!token_id) return RAD_E_INVAL; + cfg_.tok_start = token_id(""); + cfg_.tok_end = token_id(""); + if (cfg_.tok_start < 0 || cfg_.tok_end < 0) return RAD_E_NOTFOUND; + const int64_t cap = cfg.max_patches - cfg.radio_prefix; + if (cap < cfg.radio_min_patches || cap < cfg.radio_video_patches) return RAD_E_INVAL; + if (cfg_.radio_max_patches > cap) cfg_.radio_max_patches = (int32_t)cap; + /* A video's budget: max_frames frames in tubelets, each its prefix plus the frame target + * (the video tile never exceeds it). */ + if (cfg_.max_video_patches <= 0) + cfg_.max_video_patches = (int64_t)((cfg.max_frames + cfg.radio_tubelet - 1) / + cfg.radio_tubelet) * + (cfg.radio_prefix + cfg.radio_video_patches); + encode_text_ = std::move(encode_text); + return RAD_OK; + } if (cfg.family == Family::Glm5Next) { /* A token is merge^2 patches and an image is one segment of one pass, so the budget is * lowered to what a pass holds. */ @@ -1712,6 +1975,99 @@ int Processor::image_pixtral(const Frame& f, std::shared_ptr* out, std::st return RAD_OK; } +/* NVIDIA's Nemotron-H Omni image processor: one tile, sized by radio_size, resized with torch's + * antialiased bicubic on float pixels (none when the size already fits). */ +int Processor::image_radio(const Frame& f, std::shared_ptr* out, std::string* why) const { + const VisionConfig& c = cfg_; + int32_t wp = 0, hp = 0; + radio_size(f.w, f.h, c, &wp, &hp); + std::vector px; + resize_bicubic_aa_f32(f, wp * c.patch, hp * c.patch, &px); + auto it = std::make_shared(); + it->kind = Kind::Image; + it->grid_t = 1; + it->grid_h = hp; + it->grid_w = wp; + it->rope_1d = true; + finish_item_radio(c, it.get()); + if (it->n_patch > c.max_patches) { + if (why) *why = "the image resizes to more patches than one encoder pass holds"; + return RAD_E_INVAL; + } + patchify_radio(c, { &px }, false, it.get()); + one_run(it.get(), c.tok_start, it->seg_rows, c.tok_image, c.tok_end); + *out = std::move(it); + return RAD_OK; +} + +/* Its video path: every frame at the video tile (radio_video_size of the first), `tubelet` + * frames a segment (the last repeated to fill one), each run labelled as the reference processor + * labels a tubelet -- "Frame i sampled at T seconds and frame i+1 sampled at T' seconds: ", T the + * frame's source index times int(1000 / fps) ms -- the runs joined by a newline. No pruning (EVS): + * every tubelet keeps all its rows. */ +int Processor::video_radio(const Video& v, std::shared_ptr* out, std::string* why) const { + const VisionConfig& c = cfg_; + if (v.frames.empty()) { if (why) *why = "the video decoded to no frames"; return RAD_E_INVAL; } + int32_t wp = 0, hp = 0; + radio_video_size(v.frames[0].w, v.frames[0].h, c, &wp, &hp); + const int32_t T = c.radio_tubelet; + const int64_t nf = (int64_t)v.frames.size(); + auto it = std::make_shared(); + it->kind = Kind::Video; + it->grid_t = (int32_t)((nf + T - 1) / T); + it->grid_h = hp; + it->grid_w = wp; + it->rope_1d = true; + finish_item_radio(c, it.get()); + if (c.radio_prefix + (int64_t)hp * wp > c.max_patches) { + if (why) *why = "a video frame resizes to more patches than one encoder pass holds"; + return RAD_E_INVAL; + } + if (it->n_patch > c.max_video_patches) { + if (why) *why = "the video is over the server's patch budget for one video"; + return RAD_E_INVAL; + } + std::vector> resized((size_t)nf); + for (int64_t i = 0; i < nf; ++i) + resize_bicubic_aa_f32(v.frames[(size_t)i], wp * c.patch, hp * c.patch, &resized[(size_t)i]); + std::vector*> frames; + for (int64_t i = 0; i < (int64_t)it->grid_t * T; ++i) + frames.push_back(&resized[(size_t)std::min(i, nf - 1)]); + patchify_radio(c, frames, true, it.get()); + content_key(*it, &it->key_hi, &it->key_lo); + + const int64_t frame_ms = v.info.fps > 0.0 ? (int64_t)(1000.0 / v.info.fps) : 0; + for (int32_t g = 0; g < it->grid_t; ++g) { + std::string label = g > 0 ? "\n" : ""; + for (int32_t j = 0; j < T; ++j) { + const int64_t fi = (int64_t)g * T + j; + if (fi >= nf) break; + char part[96]; + if (frame_ms > 0) + std::snprintf(part, sizeof part, "%s%s %lld sampled at %.2f seconds", + j ? " and " : "", j ? "frame" : "Frame", (long long)(fi + 1), + (double)(v.index[(size_t)fi] * frame_ms) / 1000.0); + else + std::snprintf(part, sizeof part, "%s%s %lld", j ? " and " : "", + j ? "frame" : "Frame", (long long)(fi + 1)); + label += part; + } + label += ": "; + const std::vector tt = encode_text_ ? encode_text_(label) : std::vector{}; + if (tt.empty()) { + if (why) *why = "the tokenizer produced nothing for a video frame label"; + return RAD_E_STATE; + } + it->expand.insert(it->expand.end(), tt.begin(), tt.end()); + it->expand.push_back(c.tok_start); + it->seg_at.push_back((int32_t)it->expand.size()); + it->expand.insert(it->expand.end(), (size_t)it->seg_rows, c.tok_image); + it->expand.push_back(c.tok_end); + } + *out = std::move(it); + return RAD_OK; +} + int Processor::image_from(const Frame& f, std::shared_ptr* out, std::string* why, const ImageMode& mode) const { const VisionConfig& c = cfg_; @@ -1723,6 +2079,7 @@ int Processor::image_from(const Frame& f, std::shared_ptr* out, std::strin if (c.family == Family::Pixtral) return image_pixtral(f, out, why); if (c.family == Family::Lfm2) return image_lfm2(f, out, why); if (c.family == Family::Glm5Next) return image_glm5next(f, out, why); + if (c.family == Family::Radio) return image_radio(f, out, why); if (c.family == Family::UnlimitedOcr) return image_unlimitedocr(f, mode, out, why); int64_t h = 0, w = 0; RAD_TRY(smart_resize_image(f.h, f.w, c.factor(), c.image_min_pixels, c.image_max_pixels, @@ -1816,6 +2173,7 @@ int Processor::video_gemma4(const Video& v, std::shared_ptr* out, std::str int Processor::video_from(const Video& v, std::shared_ptr* out, std::string* why) const { const VisionConfig& c = cfg_; if (c.family == Family::Gemma4) return video_gemma4(v, out, why); + if (c.family == Family::Radio) return video_radio(v, out, why); if (c.family == Family::Glm5Next || c.family == Family::Pixtral) { if (why) *why = "this model's processor takes pictures, not video"; return RAD_E_UNSUPPORTED; @@ -2131,12 +2489,40 @@ static int qwen3asr_from_meta(const RadModelMeta& m, AudioConfig* c, std::string return RAD_OK; } +/* Gemma4UnifiedAudioFeatureExtractor's framing (Gemma 4 12B): processor_config.json's + * `feature_extractor` and the clip cap `audio_seq_length` (in frames). The frame's width is what the + * embedder takes, so it stands in `n_mels` as a mel spectrum's bins do. */ +static int unified_from_meta(const RadModelMeta& m, AudioConfig* c, std::string* why) { + c->family = AudioFamily::Gemma4Unified; + c->rate = (int32_t)rad_meta_geti(&m, "processor.feature_extractor.sampling_rate", 16000); + c->frame_length = (int32_t)rad_meta_geti( + &m, "processor.feature_extractor.audio_samples_per_token", + rad_meta_geti(&m, "audio_config.audio_samples_per_token", + rad_meta_geti(&m, "audio_config.audio_embed_dim", 0))); + c->hop = c->frame_length; + c->n_mels = c->frame_length; + c->max_samples = rad_meta_geti(&m, "processor.audio_seq_length", 750) * c->frame_length; + c->tok_audio = (int32_t)rad_meta_geti(&m, "audio_token_id", -1); + c->tok_start = (int32_t)rad_meta_geti(&m, "boa_token_id", -1); + c->tok_end = (int32_t)rad_meta_geti(&m, "eoa_token_id", + rad_meta_geti(&m, "eoa_token_index", -1)); + if (c->rate <= 0 || c->frame_length <= 0 || c->max_samples <= 0 || c->tok_audio < 0 || + c->tok_start < 0 || c->tok_end < 0) { + if (why) *why = "the container's audio framing is incomplete (sampling_rate, " + "audio_samples_per_token, audio_seq_length, audio_token_id, boa_token_id, " + "eoa_token_id)"; + return RAD_E_INVAL; + } + return RAD_OK; +} + int AudioConfig::from_meta(const RadModelMeta& m, std::string* why) { const char* mt = rad_meta_gets(&m, "audio_config.model_type", ""); if (mt && !std::strcmp(mt, "qwen3_asr_encoder")) return qwen3asr_from_meta(m, this, why); + if (mt && !std::strcmp(mt, "gemma4_unified_audio")) return unified_from_meta(m, this, why); if (!mt || std::strcmp(mt, "gemma4_audio")) { if (why) *why = "the container states no audio tower this processor knows (audio_config." - "model_type gemma4_audio or qwen3_asr_encoder)"; + "model_type gemma4_audio, gemma4_unified_audio or qwen3_asr_encoder)"; return RAD_E_NOTFOUND; } /* preprocessor_config.json's keys (`preprocessor.`), else processor_config.json's @@ -2273,6 +2659,12 @@ int Processor::init_audio(const AudioConfig& cfg, std::string* why) { return refuse(RAD_E_INVAL, "the audio encoder's pass (" + std::to_string(cfg.max_frames) + " frames) is not whole rows of " + std::to_string(cfg.merge) + " frames"); + /* The 12B's frames are samples: no window, no FFT, no mel bank. */ + if (cfg.family == AudioFamily::Gemma4Unified) { + acfg_ = cfg; + audio_on_ = true; + return RAD_OK; + } const bool qwen = cfg.family == AudioFamily::Qwen3ASR; /* Gemma 4's FFT is radix 2; Qwen3-ASR's runs mixed radix over any length. */ if (!qwen && (cfg.fft < 2 || (cfg.fft & (cfg.fft - 1)) != 0)) @@ -2481,11 +2873,44 @@ int Processor::audio_qwen3asr(const std::vector& samples, std::shared_ptr return RAD_OK; } +/* The 12B's clip (AudioFamily::Gemma4Unified): ceil(n / frame_length) frames of samples, the last + * zero-padded, each sample rounded to bf16 as the reference casts the frames for its embedder; one + * frame a placeholder. The reference cuts nothing; a clip past `max_samples` is cut there. */ +int Processor::audio_unified(const std::vector& samples, std::shared_ptr* out, + std::string* why) const { + const AudioConfig& c = acfg_; + const int64_t n = std::min((int64_t)samples.size(), c.max_samples); + const int64_t fl = c.frame_length, rows = (n + fl - 1) / fl; + if (rows * c.merge > c.max_frames) { + if (why) *why = "the clip is more frames than one audio encoder pass holds"; + return RAD_E_INVAL; + } + auto it = std::make_shared(); + it->kind = Kind::Audio; + it->grid_t = 1; + it->grid_h = (int32_t)rows; + it->grid_w = 1; + it->patch_dim = fl; + it->n_patch = rows; + it->valid = (int32_t)rows; + it->rows_h = (int32_t)rows; + it->rows_w = 1; + it->seg_rows = (int32_t)rows; + it->n_seg = rows > 0 ? 1 : 0; + it->pixels.assign((size_t)(rows * fl), 0); + for (int64_t i = 0; i < n; ++i) it->pixels[(size_t)i] = rad_f32_to_bf16(samples[(size_t)i]); + one_run(it.get(), c.tok_start, rows, c.tok_audio, c.tok_end); + if (rows == 0) it->encoded = true; + *out = std::move(it); + return RAD_OK; +} + int Processor::audio_from(const std::vector& samples, std::shared_ptr* out, std::string* why) const { if (!audio_on_) { if (why) *why = "this program declares no audio encoder"; return RAD_E_UNSUPPORTED; } const AudioConfig& c = acfg_; if (c.family == AudioFamily::Qwen3ASR) return audio_qwen3asr(samples, out, why); + if (c.family == AudioFamily::Gemma4Unified) return audio_unified(samples, out, why); const int64_t n = std::min((int64_t)samples.size(), c.max_samples); const int64_t real = c.real_frames(n); const int64_t rows = (real + c.merge - 1) / c.merge; diff --git a/core/mm/processor.h b/core/mm/processor.h index 14392cad..4f1e524b 100644 --- a/core/mm/processor.h +++ b/core/mm/processor.h @@ -50,6 +50,8 @@ enum class Kind { Image, Video, Audio }; * channel) as 2 * (u / 255) - 1, the reference model's own input scaling; a video is * frames sampled at `fps` (at most `max_frames`, thinned evenly), each its own segment * at the per-frame budget, each spelled placeholders with no timestamp. + * Gemma 4 12B ("unified", no tower) is the same with a whole pooling window as one + * patch (patch = 48, merge 1) and its values u / 255 (`unit_pixels`). * Lfm2 LFM2-VL's: a picture within its token budget (times a tolerance) is resized whole -- * sides multiples of patch * merge, pixels within the budget's band -- and one past it * is cut into tile x tile crops, min_tiles..max_tiles of them in the ratio nearest its @@ -79,8 +81,19 @@ enum class Kind { Image, Video, Audio }; * Pixtral Nemotron 3.5's noncausal Mistral3 wrapper: longest-edge resize, then ceil each side * to patch * merge; PIL bicubic and CLIP normalization. Raster (channel, y, x) patches; * image placeholders per merged grid row, each followed by IMG_BREAK (last: IMG_END). - * Every token has ordinary 1-D positions, and separators retain their token embedding. */ -enum class Family { QwenVL, Gemma4, Lfm2, UnlimitedOcr, Glm5Next, Pixtral }; + * Every token has ordinary 1-D positions, and separators retain their token embedding. + * Radio NVIDIA's Nemotron-H Omni with C-RADIO: a picture becomes one tile whose patch grid + * falls between min_num_patches and max_num_patches, aspect ratio kept and both sides + * even (the pixel shuffle's factor), resized with torch's antialiased bicubic on float + * pixels; a video frame the same at about video_target_num_patches. Values are + * (u / 255 - mean) / std in f32, rounded to bf16. A patch row is the tubelet's frames + * (frame, channel, y, x) and then the picture's (channel, y, x), the part not in use + * zero, so one embedding GEMM serves both projections. Each segment carries `n_prefix` + * zero rows ahead of its patches, which the tower fills with its class and register + * tokens. Pictures are spelled placeholders ; a video one such run a + * tubelet, each after its "Frame i sampled at T seconds and frame i+1 ...: " label, + * runs joined by a newline. Tokens at their positions (NoPE). */ +enum class Family { QwenVL, Gemma4, Lfm2, UnlimitedOcr, Glm5Next, Pixtral, Radio }; struct VisionConfig { Family family = Family::QwenVL; @@ -88,6 +101,8 @@ struct VisionConfig { /* Gemma4: soft tokens (output rows) an image and a video frame may take. One of 70, 140, * 280, 560, 1120, the budgets the model was trained at. */ int32_t image_soft_tokens = 0, video_soft_tokens = 0; + /* Gemma4: patch values u / 255 rather than 2 * (u / 255) - 1 (the 12B's embedder). */ + bool unit_pixels = false; int64_t image_min_pixels = 0, image_max_pixels = 0; int64_t video_min_pixels = 0, video_max_pixels = 0; /* Glm5Next: the band an image's canvas falls in, in output rows (tokens). */ @@ -104,6 +119,11 @@ struct VisionConfig { /* Lfm2: the tiling (see Family). `max_segment_patches` is the tower's longest segment. */ int32_t min_tiles = 0, max_tiles = 0, tile = 0; bool use_thumbnail = false; + /* Radio: a picture's patch budget [radio_min_patches, radio_max_patches] (with the global cap + * radio_max_len tokens), the per-frame target of a video, the frames a tubelet packs and the + * learned rows (class and register tokens) a segment carries ahead of its patches. */ + int32_t radio_min_patches = 0, radio_max_patches = 0, radio_max_len = 0; + int32_t radio_video_patches = 0, radio_tubelet = 0, radio_prefix = 0; double max_pixels_tolerance = 0.0; int64_t max_segment_patches = 0; @@ -135,7 +155,11 @@ struct VisionConfig { * engine again after command-line overrides. */ int check(std::string* why) const; - int64_t patch_dim() const { return 3LL * temporal * patch * patch; } + int64_t patch_dim() const { + /* Radio's row is a tubelet's frames and then the picture's patch (Family::Radio). */ + if (family == Family::Radio) return 3LL * (1 + radio_tubelet) * patch * patch; + return 3LL * temporal * patch * patch; + } int32_t factor() const { return patch * merge; } /* Read from the container; refuses one with no vision tower. Processor-only keys the @@ -165,6 +189,9 @@ struct ImageMode { * through an fft-point FFT, magnitudes through an HTK mel bank, log(x + mel_floor). * The clip's real frames, then zero frames to whole output rows. * + * Gemma4Unified Gemma4UnifiedAudioFeatureExtractor (the 12B's): no spectrum; a frame is + * `frame_length` samples as they are, the last zero-padded, one frame a row. + * * Qwen3ASR Qwen3ASRFeatureExtractor (Whisper's): a clip shorter than `min_samples` is * zero-padded to it; frames are torch.stft's, centred with a reflected n_fft / 2 at * each end, a periodic Hann window and power spectra, the last frame dropped, so n @@ -176,7 +203,7 @@ struct ImageMode { * padding, and, where that exceeds a whole chunk, frames past it that the encoder * reads as zero. Plane 1 of the coordinates marks those (RadBatch::enc_coord), which * keeps one chunk's convolution from seeing the next. */ -enum class AudioFamily { Gemma4, Qwen3ASR }; +enum class AudioFamily { Gemma4, Qwen3ASR, Gemma4Unified }; /* Audio features, configured from the container: Gemma 4's framing from `preprocessor.*` (the * checkpoint's preprocessor_config.json), Qwen3-ASR's from `processor.feature_extractor.*` @@ -257,6 +284,10 @@ struct Item { /* Patches are in raster order (row by row), not merge-block order: the coordinate planes * invert the one or the other (Unlimited-OCR's tower reads a picture patch by patch). */ bool patch_raster = false; + /* Rows ahead of each segment's patches that the encoder fills itself (Family::Radio: C-RADIO's + * class and register tokens): zero pixels, coordinate (-1, k), counted in patch_at and + * n_patch but never in a segment's output rows. */ + int32_t seg_prefix = 0; int32_t seg_h(int32_t s) const { return segments.empty() ? grid_h : segments[(size_t)s].h; } int32_t seg_w(int32_t s) const { return segments.empty() ? grid_w : segments[(size_t)s].w; } @@ -265,7 +296,7 @@ struct Item { bool seg_is_sep(int32_t s) const { return !segments.empty() && segments[(size_t)s].sep; } /* Segment s's first patch and first output row; s == n_seg is the end of the item. */ int64_t patch_at(int32_t s) const { - if (segments.empty()) return (int64_t)s * grid_h * grid_w; + if (segments.empty()) return (int64_t)s * (seg_prefix + (int64_t)grid_h * grid_w); return s >= n_seg ? n_patch : segments[(size_t)s].patch0; } int64_t row_at(int32_t s) const { @@ -424,6 +455,8 @@ private: std::string* why) const; int image_glm5next(const Frame& f, std::shared_ptr* out, std::string* why) const; int image_pixtral(const Frame& f, std::shared_ptr* out, std::string* why) const; + int image_radio(const Frame& f, std::shared_ptr* out, std::string* why) const; + int video_radio(const Video& v, std::shared_ptr* out, std::string* why) const; /* Lfm2's markers: <|img_thumbnail|>, and <|img_row_R_col_C|> at (R-1) * max_tiles + C-1. */ int32_t tok_thumbnail_ = -1; std::vector tok_tiles_; @@ -434,6 +467,8 @@ private: bool audio_on_ = false; int audio_qwen3asr(const std::vector& samples, std::shared_ptr* out, std::string* why) const; + int audio_unified(const std::vector& samples, std::shared_ptr* out, + std::string* why) const; std::vector hann_; /* the window, float32 as the reference stores it */ std::vector mel_; /* [n_mels, fft/2 + 1]: filter b's weight on bin k */ @@ -459,6 +494,15 @@ std::vector sample_frames_gemma4(const VideoInfo& info, double fps, int * within `max_patches`, aspect ratio kept (get_aspect_ratio_preserving_size). */ int gemma4_size(int64_t h, int64_t w, int32_t patch, int32_t pool, int64_t max_patches, int64_t* oh, int64_t* ow, std::string* why); +/* Radio's tile for a picture of w x h pixels (NVIDIA's _compute_target_patches, Python's + * round-half-even included) and for a video frame (_compute_target_patches_video), in patches. */ +void radio_size(int64_t w, int64_t h, const VisionConfig& c, int32_t* wp, int32_t* hp); +void radio_video_size(int64_t w, int64_t h, const VisionConfig& c, int32_t* wp, int32_t* hp); +/* torch's F.interpolate(mode="bicubic", align_corners=False, antialias=True) of packed RGB bytes + * taken as float, without rounding or clamping: [h, w, 3] f32 in 0..255 give or take the + * filter's overshoot. Separable, width first, as ATen's CPU kernel; a side that keeps its size is + * the identity. */ +void resize_bicubic_aa_f32(const Frame& in, int32_t w, int32_t h, std::vector* out); /* PIL's antialiased bicubic resample of packed RGB, bit for bit: fixed-point coefficients, a * horizontal pass into an 8-bit intermediate and then a vertical one. */ void resize_bicubic(const Frame& in, int32_t w, int32_t h, Frame* out); diff --git a/core/place/mover.cpp b/core/place/mover.cpp index 5b5e634d..23ff49f2 100644 --- a/core/place/mover.cpp +++ b/core/place/mover.cpp @@ -334,6 +334,22 @@ int Mover::init(const Program& prog, const Plan& plan, const MoverConfig& cfg, P std::memset(calm_, 0, 8 << 20); } + /* ---- the file tier's cache cycle (stage_file_units) ------------------------------------- + * + * The stager covers the plan's file-tier units from the start; it may cover more + * (cover_file_units). Each layer's file-tier bytes start as the plan's, which the plan sized + * the stager's buffers for. */ + file_ok_.assign(plan.units.size(), 0); + layer_file_.assign((size_t)std::max(n_layers_, 1), 0); + file_cap_ = file_buf_bytes_; + for (size_t u = 0; u < plan.units.size(); ++u) { + const MoveUnit& mu = plan.units[u]; + if (mu.tier != Tier::SSD || mu.access != RAD_ACCESS_CONDITIONAL) continue; + file_ok_[u] = 1; + if (mu.layer >= 0) layer_file_[(size_t)mu.layer] += align_up(mu.bytes, RAD_ALIGN_UNIT); + } + victims_.assign(plan.classes.size(), VictimRank{}); + /* ---- streams, events, move records ------------------------------------------------------ */ RAD_TRY(rad_stream_create(&mover_, /*high_priority=*/0)); /* Every event here is local: they order the mover's queue against this card's compute queue @@ -664,18 +680,6 @@ int64_t Mover::stage_need(const std::vector& units, int64_t* largest) c /* ---- a routed layer read from the container (see mover.h) ---------------------------------- */ namespace { -/* One weight's bytes: where they are in the container and where they go. */ -struct FileExt { - int64_t foff = 0, bytes = 0; - char* dst = nullptr; - /* Into a hot-cache slot rather than the layer buffer: counted as - * ssd_promoted_bytes, and the copy leaves the unit resident. */ - bool hot = false; - /* Into a host pool slot rather than the layer buffer: counted as - * ssd_deposit_bytes, and the copy leaves the unit resident in RAM. */ - bool deposit = false; -}; - /* The largest gap a run reads through instead of starting another pread. A routed layer's * weights sit together in the container, each on RAD_ALIGN_UNIT, so a gap between two file-tier * weights is either alignment padding (cheaper to read than a second pread) or units on another @@ -685,36 +689,125 @@ constexpr int64_t kReadThrough = (int64_t)256 << 10; } /* namespace */ +bool Mover::on_file_tier(const std::vector& units) const { + for (int32_t u : units) { + if (u < 0 || (size_t)u >= unit_.size()) continue; + const UnitState& us = unit_[(size_t)u]; + if (us.tier == Tier::SSD && us.slab_slot < 0 && us.klass >= 0) return true; + } + return false; +} + +bool Mover::routes_any(const std::vector& units, const int32_t* ecnt, + int32_t n_expert) const { + if (!plan_ || !ecnt) return !units.empty(); + for (int32_t u : units) { + if (u < 0 || (size_t)u >= plan_->units.size()) continue; + const int32_t e = plan_->units[(size_t)u].expert; + if (e < 0 || e >= n_expert || ecnt[e] != 0) return true; + } + return false; +} + +void Mover::cover_file_units(const std::vector& more) { + /* A unit whose container bytes are not its kernel's layout cannot be read back. */ + for (int32_t u : more) + if (u >= 0 && (size_t)u < file_ok_.size() && plan_->units[(size_t)u].file_direct) + file_ok_[(size_t)u] = 1; +} + +/* A full pool's relabel victim for a deposit of class `klass`: its coldest pooled unit that the + * file stager reads back (Mover::file_ok_), with nothing in flight, outside the `protect` layers, + * and whose layer's file-tier part still fits the stager's buffer with it. -1 when none, or when + * that unit is not colder than `below` (the unit being read): trading a pooled unit for a colder + * one would only make the next step read the warmer one from the drive. + * + * The protected layers are the one being read and any whose ops are about to be issued: a + * relabelled unit's weights are published at the zero region at once, so taking one of theirs + * would hand the next GEMM zeros for a routed expert. Every other layer is safe: one already + * issued this pass read the pool slot, which the quarantine keeps until those kernels are done, + * and a later one is read back by its own trigger, since the stager covers the unit. The + * routing counts protect nothing here: they are the counts of the layer being read, and indexing + * them by another layer's expert number protected a random set while a whole-layer read (no + * counts) protected nothing at all. + * + * The cap keeps every read of a layer within the stager's buffer: the plan sized it for the + * largest layer's file-tier part, and a relabel adds to its victim's. */ +int32_t Mover::pick_victim(int32_t klass, const int32_t* protect, int n_protect, float below) { + if (klass < 0 || (size_t)klass >= victims_.size() || !heat_) return -1; + VictimRank& vr = victims_[(size_t)klass]; + if (vr.at != dispatch_) { + vr.at = dispatch_; + vr.by_heat.clear(); + for (int32_t v = 0; v < (int32_t)unit_.size(); ++v) { + const UnitState& vs = unit_[(size_t)v]; + if (vs.klass != klass || vs.tier != Tier::HostPinned || vs.pool_slot < 0 || + vs.slab_slot >= 0 || !file_ok_[(size_t)v]) + continue; + vr.by_heat.push_back({ heat_->heat(v), v }); + } + /* Hottest first; on equal heat the higher unit first, so the back is the coldest and, + * among equally cold ones, the lowest: the unit a scan keeping its first strict minimum + * would pick. */ + std::sort(vr.by_heat.begin(), vr.by_heat.end(), + [](const std::pair& a, const std::pair& b) { + return a.first != b.first ? a.first > b.first : a.second > b.second; + }); + } + for (size_t k = vr.by_heat.size(); k-- > 0;) { + const int32_t v = vr.by_heat[k].second; + if (v < 0) continue; + const UnitState& vs = unit_[(size_t)v]; + /* Within a dispatch a unit leaves the pool only by a relabel, so one that is not there any + * more is gone for the rest of it. A copy in flight or a protected layer only waits. */ + if (vs.klass != klass || vs.tier != Tier::HostPinned || vs.pool_slot < 0 || + vs.slab_slot >= 0) { + vr.by_heat[k].second = -1; + continue; + } + if (copying_[(size_t)v]) continue; + const int32_t layer = plan_->units[(size_t)v].layer; + bool held = layer < 0 || (size_t)layer >= layer_file_.size(); + for (int p = 0; p < n_protect && !held; ++p) held = protect[p] >= 0 && protect[p] == layer; + if (held) continue; + if (layer_file_[(size_t)layer] + align_up(vs.bytes, RAD_ALIGN_UNIT) > file_cap_) continue; + /* Every candidate further in is at least as warm. */ + if (!(vr.by_heat[k].first < below)) return -1; + vr.by_heat[k].second = -1; + while (!vr.by_heat.empty() && vr.by_heat.back().second < 0) vr.by_heat.pop_back(); + return v; + } + return -1; +} + int Mover::stage_file_units(const std::vector& units, char* dst, int64_t cap, - RadEvent after, RadEvent done, std::vector* staged, - std::vector* skipped, const int32_t* ecnt, - int32_t n_expert, std::vector* promoted) { - if (!plan_ || !dst || !staged || !done) return RAD_E_INVAL; - staged->clear(); - if (skipped) skipped->clear(); - if (promoted) promoted->clear(); + RadEvent after, RadEvent done, FileRead* rd, const int32_t* ecnt, + int32_t n_expert, const int32_t* protect, int n_protect) { + if (!plan_ || !dst || !rd || !done) return RAD_E_INVAL; if (!file_.ok() || !windows_ || n_windows_ <= 0) return RAD_E_STATE; - /* The layout in `dst`, unit by unit in the order given, and every weight's extent. */ - std::vector ext; - std::vector at; - std::vector pbases; /* hot-cache units' slot bases, in promoted order */ - int64_t off = 0, hot_bytes = 0; + /* The layout in `dst`, unit by unit in the order given after what earlier calls for the + * layer packed, and every weight's extent. */ + fext_.clear(); + fat_.clear(); + fbase_.clear(); + frec_.clear(); + const size_t staged0 = rd->staged.size(), skipped0 = rd->skipped.size(), + promoted0 = rd->promoted.size(); + const int64_t used0 = rd->used; + int64_t off = rd->used, hot_bytes = 0; for (int32_t u : units) { if (u < 0 || (size_t)u >= unit_.size()) return RAD_E_INVAL; UnitState& us = unit_[(size_t)u]; if (us.tier != Tier::SSD || us.slab_slot >= 0 || us.klass < 0) continue; - /* Routing-aware reads: the layer's router has run by the time the stager triggers - * (the trigger is the layer's first expert op), so `ecnt` holds this pass's counts. - * An expert counted zero has no sorted rows, so no GEMM run names it and nothing - * reads its weights: leave its bytes on the drive. The dummy publication below - * keeps every table entry valid for the pass. */ - if (ecnt && skipped) { - const MoveUnit& mu = plan_->units[(size_t)u]; - if (mu.expert >= 0 && mu.expert < n_expert && ecnt[mu.expert] == 0) { - skipped->push_back(u); - continue; - } + const MoveUnit& mu = plan_->units[(size_t)u]; + /* Routing-aware reads: `ecnt` holds the counts of the rows about to run, taken at the + * layer's trigger behind its router. An expert counted zero has no sorted rows, so no + * GEMM run names it and nothing reads its weights: leave its bytes on the drive. The + * dummy publication below keeps every table entry valid for the pass. */ + if (ecnt && mu.expert >= 0 && mu.expert < n_expert && ecnt[mu.expert] == 0) { + rd->skipped.push_back(u); + continue; } /* The hot VRAM cache: heat past the admission bar and a free * budgeted slot, and this pass's read lands in the slot and stays there. The read is @@ -722,7 +815,7 @@ int Mover::stage_file_units(const std::vector& units, char* dst, int64_ * bookkeeping (the container is ground truth), so a mistake costs one future * re-read. No free slot, no heat, or no move record: the buffer path below, as * before. */ - if (promoted && plan_->dynamic && heat_ && heat_->admit_hot(u) && !unit_in_flight(u)) { + if (plan_->dynamic && heat_ && heat_->admit_hot(u) && !unit_in_flight(u)) { ClassPools& cp = pools_[(size_t)us.klass]; const int rec = free_move_record(); int64_t slot = -1; @@ -730,7 +823,6 @@ int Mover::stage_file_units(const std::vector& units, char* dst, int64_ else slot = cp.slab.take_where([&](int64_t s) { return s < cp.n_fixed; }); if (slot >= 0 && record_gate() < 0) { cp.slab.add_free(slot); slot = -1; } if (slot >= 0) { - const MoveUnit& mu = plan_->units[(size_t)u]; char* const base = cp.slot_ptr(slot); Move& m = moves_[(size_t)rec]; m.state = Move::State::Copying; @@ -746,74 +838,58 @@ int Mover::stage_file_units(const std::vector& units, char* dst, int64_ for (size_t k = 0; k < mu.weights.size(); ++k) { const WeightInfo& w = prog_->weights[mu.weights[k]]; if (w.stored_bytes <= 0) continue; /* nothing to read, nothing to place */ - ext.push_back(FileExt{ (int64_t)w.file_offset, w.stored_bytes, - base + mu.offset[k], true }); + fext_.push_back(FileExt{ (int64_t)w.file_offset, w.stored_bytes, + base + mu.offset[k], true, false }); } - promoted->push_back(u); - pbases.push_back(base); + rd->promoted.push_back(u); + fbase_.push_back(base); + frec_.push_back((int32_t)rec); hot_bytes += us.bytes; continue; } } - /* A free pool slot and this read deposits the unit into the pool -- the O_DIRECT - * read's destination IS the slot, and the unit becomes a pool unit: the GEMM reads it + /* A free pool slot and this read deposits the unit into the pool: its window's copy list + * carries it into the slot, and the unit becomes a pool unit -- the GEMM reads it * zero-copy this step, heat promotes it at PCIe speed, and its demotion is a copyless - * drop. The pool is ALL cache: no free slot and the coldest idle pool unit -- native - * or deposited, the container is ground truth for both -- relabels back to the file - * tier, copyless. Its slot feeds a future deposit after the - * coldest idle pool unit -- native or deposited, the container is ground truth for both -- - * relabels back to the file tier, copyless. Its slot feeds a future deposit after the - * quarantine; this read takes the buffer path. */ - if (promoted && plan_->dynamic && heat_ && !unit_in_flight(u)) { + * drop. The pool is all cache: with no free slot, its coldest unit the stager covers is + * relabelled back to the file tier, copyless (the container holds every unit's bytes), + * provided it is colder than this one (pick_victim). The slot it gives up feeds a later + * deposit after the quarantine; this read takes the buffer path. */ + if (plan_->dynamic && heat_ && !unit_in_flight(u)) { ClassPools& cp = pools_[(size_t)us.klass]; const int rec = free_move_record(); int64_t g = -1; if (rec < 0) ++stats_.no_record; else if (record_gate() >= 0) g = cp.pool.take(); - if (g < 0 && heat_) { - /* The pool is full. Eviction is a copyless relabel: the - * container holds every unit's bytes, so the victim loses nothing but its slot -- - * it becomes a file-tier unit whose next read deposits again. The victim is the - * coldest idle unit of the class, however it got there: the cache adapts to the - * workload, not to where a unit started. The freed slot feeds a future deposit - * after the quarantine; this read takes the buffer path. */ - int32_t victim = -1; - float best = 0; - for (int32_t v = 0; v < (int32_t)unit_.size(); ++v) { - UnitState& vs = unit_[(size_t)v]; - if (vs.klass != us.klass || - vs.tier != Tier::HostPinned || vs.pool_slot < 0 || - vs.slab_slot >= 0 || copying_[(size_t)v] || unit_in_flight(v)) - continue; - const MoveUnit& mv = plan_->units[(size_t)v]; - if (mv.expert >= 0 && mv.expert < n_expert && ecnt && ecnt[mv.expert] > 0) - continue; /* routed this pass: still wanted */ - const float h = heat_->heat(v); - if (victim < 0 || h < best) { victim = v; best = h; } - } + if (g < 0 && rec >= 0) { + /* The deposit's own record is still free (nothing uses it this read), so the + * relabel may take the same one. */ + const int r2 = free_move_record(); + const int32_t victim = + r2 >= 0 ? pick_victim(us.klass, protect, n_protect, heat_->heat(u)) : -1; if (victim >= 0) { - const int r2 = free_move_record(); - if (r2 >= 0) { - UnitState& vs = unit_[(size_t)victim]; - const MoveUnit& mv = plan_->units[(size_t)victim]; - Move& m2 = moves_[(size_t)r2]; - m2.state = Move::State::Published; /* nothing to copy: the drive has it */ - m2.kind = Move::Kind::Evict; - m2.unit = victim; - m2.slab_slot = -1; - m2.pool_slot = vs.pool_slot; - for (size_t k = 0; k < mv.weights.size(); ++k) - res_.publish(mv.weights[k], calm_); - vs.tier = Tier::SSD; - vs.site = Site::DeviceStaged; - vs.pool_slot = -1; - heat_->set_tier(victim, Tier::SSD); - ++stats_.pool_evictions; - } + UnitState& vs = unit_[(size_t)victim]; + const MoveUnit& mv = plan_->units[(size_t)victim]; + Move& m2 = moves_[(size_t)r2]; + m2.state = Move::State::Published; /* nothing to copy: the drive has it */ + m2.kind = Move::Kind::Evict; + m2.unit = victim; + m2.slab_slot = -1; + m2.pool_slot = vs.pool_slot; + for (size_t k = 0; k < mv.weights.size(); ++k) + res_.publish(mv.weights[k], calm_); + vs.tier = Tier::SSD; + vs.site = Site::DeviceStaged; + vs.pool_slot = -1; + layer_file_[(size_t)mv.layer] += align_up(vs.bytes, RAD_ALIGN_UNIT); + heat_->set_tier(victim, Tier::SSD); + /* No pool slot to promote from until a read deposits it again, which makes + * it movable once more; its layer's trigger reads it meanwhile. */ + heat_->set_movable(victim, false); + ++stats_.pool_evictions; } } if (g >= 0) { - const MoveUnit& mu = plan_->units[(size_t)u]; Move& m = moves_[(size_t)rec]; m.state = Move::State::Copying; m.kind = Move::Kind::Deposit; @@ -824,20 +900,23 @@ int Mover::stage_file_units(const std::vector& units, char* dst, int64_ us.pool_slot = g; us.tier = Tier::HostPinned; us.site = Site::DeviceZeroCopy; + if (mu.layer >= 0 && (size_t)mu.layer < layer_file_.size()) + layer_file_[(size_t)mu.layer] -= align_up(us.bytes, RAD_ALIGN_UNIT); heat_->set_tier(u, Tier::HostPinned); heat_->set_movable(u, true); /* the slot makes it a PCIe-speed promotion candidate */ heat_->set_busy(u, true); ++stats_.ssd_deposits; + char* const slot = (char*)cp.pool_base + g * cp.stride; for (size_t k = 0; k < mu.weights.size(); ++k) { const WeightInfo& w = prog_->weights[mu.weights[k]]; if (w.stored_bytes <= 0) continue; /* nothing to read, nothing to place */ - ext.push_back(FileExt{ (int64_t)w.file_offset, w.stored_bytes, - (char*)cp.pool_base + g * cp.stride + mu.offset[k], - false, true }); + fext_.push_back(FileExt{ (int64_t)w.file_offset, w.stored_bytes, + slot + mu.offset[k], false, true }); } for (size_t k = 0; k < mu.weights.size(); ++k) res_.publish(mu.weights[k], (char*)cp.pool_dev + g * cp.stride + mu.offset[k]); + frec_.push_back((int32_t)rec); continue; } } @@ -847,42 +926,58 @@ int Mover::stage_file_units(const std::vector& units, char* dst, int64_ "the plan sized for the largest one", humanb(cap).c_str()); return RAD_E_SCRATCH; } - const MoveUnit& mu = plan_->units[(size_t)u]; for (size_t k = 0; k < mu.weights.size(); ++k) { const WeightInfo& w = prog_->weights[mu.weights[k]]; if (w.stored_bytes <= 0) continue; /* nothing to read, and nothing to place */ - ext.push_back(FileExt{ (int64_t)w.file_offset, w.stored_bytes, dst + off + mu.offset[k] }); + fext_.push_back(FileExt{ (int64_t)w.file_offset, w.stored_bytes, + dst + off + mu.offset[k], false, false }); } - staged->push_back(u); - at.push_back(off); + rd->staged.push_back(u); + fat_.push_back(off); off += need; } - /* Skipped units' table entries must not name their stale addresses either: point them - * into the layer buffer, whose base is a valid allocation no zero-count expert reads - * through (a dead row would read row 0 of a real expert's region and discard it). The - * caller nulls them again with the staged units. Published even when EVERY unit of the - * layer was skipped -- a decode step can route nothing to a layer -- because the kernels - * still issue the layer's table and a null entry fails the step. */ - if (skipped) { - for (int32_t u : *skipped) { - const MoveUnit& mu = plan_->units[(size_t)u]; - for (size_t j = 0; j < mu.weights.size(); ++j) - res_.publish(mu.weights[j], calm_); - stats_.ssd_skipped_bytes += (uint64_t)unit_[(size_t)u].bytes; - } - stats_.ssd_skipped_units += (uint64_t)skipped->size(); + rd->used = off; + + /* Publish before the reads: nothing resolves these addresses until the caller's layer op, + * which waits on `done` first. Skipped units' entries must not name stale addresses either: + * they point at the zero region, which no zero-count expert reads through (a dead row reads + * zeros and discards them). Published even when EVERY unit of the layer was skipped -- a + * decode step can route nothing to a layer -- because the kernels still issue the layer's + * table and a null entry fails the step. The caller nulls them again with the staged units. + * Hot-cache units publish at their slots and stay published: nothing unstages them, and + * retire() finishes their admission when the copies land. */ + for (size_t k = skipped0; k < rd->skipped.size(); ++k) { + const int32_t u = rd->skipped[k]; + const MoveUnit& mu = plan_->units[(size_t)u]; + for (size_t j = 0; j < mu.weights.size(); ++j) res_.publish(mu.weights[j], calm_); + stats_.ssd_skipped_bytes += (uint64_t)unit_[(size_t)u].bytes; } - if (ext.empty()) return RAD_OK; + stats_.ssd_skipped_units += (uint64_t)(rd->skipped.size() - skipped0); + for (size_t k = staged0; k < rd->staged.size(); ++k) { + const int32_t u = rd->staged[k]; + const MoveUnit& mu = plan_->units[(size_t)u]; + for (size_t j = 0; j < mu.weights.size(); ++j) + res_.publish(mu.weights[j], dst + fat_[k - staged0] + mu.offset[j]); + stats_.ssd_read_bytes += (uint64_t)unit_[(size_t)u].bytes; + } + for (size_t k = promoted0; k < rd->promoted.size(); ++k) { + const int32_t u = rd->promoted[k]; + const MoveUnit& mu = plan_->units[(size_t)u]; + for (size_t j = 0; j < mu.weights.size(); ++j) + res_.publish(mu.weights[j], fbase_[k - promoted0] + mu.offset[j]); + stats_.ssd_read_bytes += (uint64_t)unit_[(size_t)u].bytes; + } + if (fext_.empty()) return RAD_OK; /* Container order, so a window is one long run of the drive rather than a seek per weight. */ - std::stable_sort(ext.begin(), ext.end(), + std::stable_sort(fext_.begin(), fext_.end(), [](const FileExt& a, const FileExt& b) { return a.foff < b.foff; }); /* The dashboard's SSD panel and /stats ssd_reads read these: the file tier's container * reads are the expert SSD traffic the metric names. The scheduled prefetch path counted * its own link reads here; the file stager's were invisible, so the panels showed zero * however much the drive streamed. */ - stats_.ssd_reads += (uint64_t)ext.size(); - for (const FileExt& e : ext) { + stats_.ssd_reads += (uint64_t)fext_.size(); + for (const FileExt& e : fext_) { stats_.ssd_bytes += (uint64_t)e.bytes; /* The copies below move the same bytes from the windows to their destination, which * crosses the link either way: into the layer buffer when the unit is discarded at the @@ -902,8 +997,8 @@ int Mover::stage_file_units(const std::vector& units, char* dst, int64_ std::vector segs; std::vector cps; size_t i = 0; - int64_t piece = 0; /* bytes of ext[i] already placed */ - while (i < ext.size()) { + int64_t piece = 0; /* bytes of fext_[i] already placed */ + while (i < fext_.size()) { const int w = win_next_; win_next_ = (win_next_ + 1) % n_windows_; char* win = windows_ + (int64_t)w * W; @@ -921,8 +1016,8 @@ int Mover::stage_file_units(const std::vector& units, char* dst, int64_ * cannot finish across this window and the next. */ segs.clear(); cps.clear(); - while (i < ext.size()) { - const FileExt& e = ext[i]; + while (i < fext_.size()) { + const FileExt& e = fext_[i]; const int64_t fo = e.foff + piece, left = e.bytes - piece; int64_t wo; if (!segs.empty() && fo >= segs.back().fs && fo <= segs.back().fe + kReadThrough) { @@ -958,26 +1053,14 @@ int Mover::stage_file_units(const std::vector& units, char* dst, int64_ win_rec_[(size_t)w] = 1; } RAD_TRY(rad_event_record(done, mover_)); + /* The hot-cache admissions and deposits are copies like the staged units': their records + * land behind them, so retire() finishes a move when its bytes are in its slot. */ + for (int32_t rec : frec_) RAD_TRY(rad_event_record(moves_[(size_t)rec].ev, mover_)); + rd->copied = true; - for (size_t k = 0; k < staged->size(); ++k) { - const int32_t u = (*staged)[k]; - const MoveUnit& mu = plan_->units[(size_t)u]; - for (size_t j = 0; j < mu.weights.size(); ++j) - res_.publish(mu.weights[j], dst + at[k] + mu.offset[j]); - stats_.ssd_read_bytes += (uint64_t)unit_[(size_t)u].bytes; - } - /* Hot-cache units publish at their slots and stay published: nothing unstages them, and - * retire() finishes their admission when the copies land. */ - for (size_t k = 0; k < pbases.size(); ++k) { - const int32_t u = (*promoted)[k]; - const MoveUnit& mu = plan_->units[(size_t)u]; - for (size_t j = 0; j < mu.weights.size(); ++j) - res_.publish(mu.weights[j], pbases[k] + mu.offset[j]); - stats_.ssd_read_bytes += (uint64_t)unit_[(size_t)u].bytes; - } ++stats_.ssd_layers; - stats_.ssd_units += (uint64_t)(staged->size() + pbases.size()); - stats_.h2d_bytes += (uint64_t)(off + hot_bytes); + stats_.ssd_units += (uint64_t)((rd->staged.size() - staged0) + (rd->promoted.size() - promoted0)); + stats_.h2d_bytes += (uint64_t)(off - used0 + hot_bytes); return RAD_OK; } @@ -1809,6 +1892,7 @@ int Mover::retire(HeatEngine* heat) { break; case Move::Kind::Release: case Move::Kind::Drop: + case Move::Kind::Evict: /* published at issue, never Copying */ break; } /* Safe without synchronisation: both copies of the bytes are valid now (see diff --git a/core/place/mover.h b/core/place/mover.h index 9b32c84b..ea2f7df7 100644 --- a/core/place/mover.h +++ b/core/place/mover.h @@ -366,8 +366,9 @@ struct MoverStats { uint64_t ssd_layers = 0, ssd_units = 0, ssd_read_bytes = 0, ssd_preads = 0; uint64_t ssd_read_ns = 0, ssd_wait_ns = 0; /* Routing-aware reads: units of experts whose routing count was zero at the layer's - * trigger, not read (their weights are re-published to the layer buffer as a dummy - * address for the pass, and nulled again with the staged units). */ + * trigger, not read (their weights are published at the zero region for the pass, and + * nulled again with the staged units). Counted per read: a later slice of the layer's rows + * that reads some of them counts the rest again. */ uint64_t ssd_skipped_units = 0, ssd_skipped_bytes = 0; }; @@ -604,28 +605,58 @@ public: * and published there; afterwards unstage_units publishes them as null again. The plan * charges the two buffers to the weights pool (Plan::file_stage_vram). * - * stage_file_units reads every file-tier unit of `units` into `dst`, packed at RAD_ALIGN_UNIT - * in the order given, through the pinned read windows: container-order - * runs, each window draining to `dst` on the mover's stream while the next - * fills, behind `after` (if set), with `done` recorded last. Published - * settled. RAD_E_SCRATCH if the units exceed `cap`. The reads block this - * thread. + * stage_file_units reads the file-tier units of `units` into `dst`, packed at RAD_ALIGN_UNIT + * in the order given from `rd->used` on, through the pinned read windows: + * container-order runs, each window drained to its destinations by one + * copy list on the mover's stream while the next fills, behind `after` (if + * set), with `done` recorded last. Published settled, so the compute + * stream must wait on `done` before an op reads any of them; `rd->copied` + * says whether there is anything to wait for (a hot-cache admission or a + * pool deposit is a copy like a staged unit's). RAD_E_SCRATCH if the units + * exceed `cap`. The reads block this thread. Appends to `rd`, so a second + * call for another slice of the layer's rows adds what the first left out. + * + * Routing-aware reads: with `ecnt` (host, `n_expert` entries, the layer's per-expert routing + * counts for the rows about to run), a unit whose expert is counted zero is not read: it goes + * to `rd->skipped`, its weights are published at the zero region (valid memory a no-run + * expert never reads through), and the caller nulls it again with the staged units. Null + * `ecnt` reads every file-tier unit given. + * + * A read that finds the pool full relabels its coldest unit back to the file tier (see the + * definition). Units of the `protect` layers (plan layer numbers; the one being read and any + * whose ops are about to be issued) are never taken, whatever their counts. * - * Routing-aware reads: with `ecnt` (host, `n_expert` entries, the layer's per-expert - * routing counts for the current pass), a unit whose expert is counted zero is not read: - * it goes to `skipped`, its weights are published at `dst` (a dummy address inside the - * layer buffer, valid memory a no-run expert never reads through), and the caller nulls - * it again with the staged units. Null `ecnt` reads the whole layer. * file_buffer buffer 0 or 1 of the plan's two, or null when the plan has none. */ + struct FileRead { + std::vector staged; /* read into the layer buffer; nulled at release */ + std::vector skipped; /* counted zero; published at the zero region */ + std::vector promoted; /* read into hot-cache slots; they keep that address */ + int64_t used = 0; /* bytes of the buffer the staged units take */ + bool copied = false; /* `done` is behind copies an op will read */ + void clear() { + staged.clear(); skipped.clear(); promoted.clear(); + used = 0; + copied = false; + } + }; int stage_file_units(const std::vector& units, char* dst, int64_t cap, - RadEvent after, RadEvent done, std::vector* staged, - std::vector* skipped = nullptr, + RadEvent after, RadEvent done, FileRead* rd, const int32_t* ecnt = nullptr, int32_t n_expert = 0, - std::vector* promoted = nullptr); + const int32_t* protect = nullptr, int n_protect = 0); char* file_buffer(int i) const { return (file_vram_ && (i == 0 || i == 1)) ? file_vram_ + i * file_buf_bytes_ : nullptr; } int64_t file_buffer_bytes() const { return file_vram_ ? file_buf_bytes_ : 0; } + /* Whether any of `units` is on the file tier now (no slab slot, no pool slot): a layer with + * none has nothing to read, and its trigger skips the read and the drain it would cost. */ + bool on_file_tier(const std::vector& units) const; + /* Whether `ecnt` (as stage_file_units takes it) routes any of `units`. */ + bool routes_any(const std::vector& units, const int32_t* ecnt, int32_t n_expert) const; + /* The units the file stager reads back when they are on the file tier: every routed unit the + * plan put there, plus `more` (pooled and resident ones it also covers). Only a covered unit + * may be relabelled back to the file tier to make room for a deposit, since nothing else + * would ever read it again. Called once, at the stager's bring-up. */ + void cover_file_units(const std::vector& more); /* A snapshot by value: the counters are atomics read while the rank thread writes them. */ MoverStats stats() const { return stats_.snapshot(); } @@ -779,6 +810,34 @@ private: int win_next_ = 0; std::vector win_ev_; std::vector win_rec_; + /* stage_file_units' working lists, kept so a read allocates nothing once warm. A FileExt is + * one weight's bytes: where they are in the container and where they go -- the layer + * buffer, a hot-cache slot (`hot`, counted as ssd_promoted_bytes) or a pool slot + * (`deposit`, counted as ssd_deposit_bytes). */ + struct FileExt { + int64_t foff = 0, bytes = 0; + char* dst = nullptr; + bool hot = false; + bool deposit = false; + }; + std::vector fext_; + std::vector fat_; /* the staged units' buffer offsets */ + std::vector fbase_; /* the hot-cache units' slot bases */ + std::vector frec_; /* move records whose copies this read issues */ + /* The file tier's cache cycle. `file_ok_`: by unit, the file stager reads it back when it is + * on the file tier (cover_file_units). `layer_file_`: by plan layer, the bytes of its units + * that are on the file tier or in the hot VRAM cache (which hands them back to the file tier + * when evicted), at the stager's packing; a relabel keeps it within `file_cap_`, the stager's + * buffer, so any read of a layer fits. */ + std::vector file_ok_; + std::vector layer_file_; + int64_t file_cap_ = 0; + /* A full pool's relabel candidates per class, ranked once per dispatch like donors_: every + * covered pooled unit, hottest first, so the coldest is at the back. Heat does not change + * within a dispatch, so this picks what a scan of every unit at each read would. */ + struct VictimRank { int at = -1; std::vector> by_heat; }; + std::vector victims_; + int32_t pick_victim(int32_t klass, const int32_t* protect, int n_protect, float below); /* The lead gate's ring: one event a dispatch, and a host wait on the one from * max_lead_dispatches ago. */ diff --git a/core/place/stager.cpp b/core/place/stager.cpp index 20bccff2..aa3e50e7 100644 --- a/core/place/stager.cpp +++ b/core/place/stager.cpp @@ -380,7 +380,7 @@ int FileStager::init(const Program& prog, const Plan& plan, Mover* mover, if (!mover) return RAD_OK; /* Routing-aware reads. The source may still decline per layer (a layer that has not - * reported this pass is read whole). */ + * reported yet is read whole). */ routes_ = routes; routes_ud_ = routes_ud; scratch_ = nullptr; @@ -391,12 +391,38 @@ int FileStager::init(const Program& prog, const Plan& plan, Mover* mover, RAD_MEM_HOST_PINNED); if (!scratch_) { scratch_n_ = 0; routes_ = nullptr; } } + /* A pass's rows each route n_expert_used of the model's n_expert experts, so a pass of + * kWholeRows * n_expert / n_expert_used rows routes kWholeRows to an expert on average, on + * every rank: an expert-parallel rank holds fewer experts and gets their share of the rows. */ + whole_rows_ = routes_ && prog.meta.n_expert_used > 0 + ? (kWholeRows * prog.meta.n_expert + prog.meta.n_expert_used - 1) / + prog.meta.n_expert_used + : 0; + whole_ = false; - /* A unit declared and never read has no op span and is left out. */ - size_t c = 0; - layers_ = routed_layers(plan, [](const MoveUnit& mu) { + /* The plan's file-tier units, and under a dynamic plan every movable routed unit of a class + * that has some: a deposit can relabel those to the file tier (see stager.h, "which units"). + * A unit declared and never read has no op span and is left out. */ + auto on_file = [](const MoveUnit& mu) { return mu.tier == Tier::SSD && mu.access == RAD_ACCESS_CONDITIONAL; - }, &c); + }; + std::vector file_class(plan.classes.size(), 0); + for (const MoveUnit& mu : plan.units) + if (on_file(mu) && mu.slab_class >= 0 && (size_t)mu.slab_class < file_class.size()) + file_class[(size_t)mu.slab_class] = 1; + auto may_be = [&](const MoveUnit& mu) { + return on_file(mu) || + (plan.dynamic && mu.access == RAD_ACCESS_CONDITIONAL && mu.movable && + mu.expert >= 0 && mu.slab_class >= 0 && (size_t)mu.slab_class < file_class.size() && + file_class[(size_t)mu.slab_class]); + }; + size_t c = 0; + layers_ = routed_layers(plan, may_be, &c); + bool wide = !layers_.empty(); + if (c > 0) { + wide = false; + layers_ = routed_layers(plan, on_file, &c); + } if (layers_.empty()) return RAD_OK; /* A layer's copies stay published until the next one starts, so interleaved layers would need * a third buffer for the read-ahead; with no fallback address, such a plan is refused. */ @@ -423,6 +449,13 @@ int FileStager::init(const Program& prog, const Plan& plan, Mover* mover, if ((size_t)layers_[i].first_op < first_of_.size()) first_of_[(size_t)layers_[i].first_op] = (int32_t)i; mover_ = mover; + if (wide) { + std::vector more; + for (const Layer& L : layers_) + for (int32_t u : L.units) + if (!on_file(plan.units[(size_t)u])) more.push_back(u); + mover_->cover_file_units(more); + } for (int b = 0; b < 2; ++b) if (rad_event_create_local(&done_[b]) < 0 || rad_event_create_local(&free_[b]) < 0) { layers_.clear(); @@ -441,6 +474,7 @@ bool FileStager::begin_pass(const RadBatch* b) { first_op_ = true; pass_kind_ = b->draft_pass; last_issued_ = -1; + whole_ = whole_rows_ > 0 && b->n_tok >= whole_rows_; return true; } @@ -449,46 +483,101 @@ bool FileStager::will_issue(int32_t li) const { return it == pass_last_.end() || layers_[(size_t)li].first_op <= it->second; } -int FileStager::start(int32_t li, RadStream s) { +bool FileStager::counted(int32_t li) const { + if (!routes_ || whole_) return false; + int64_t n = 0; + const int32_t* dev = routes_(routes_ud_, layers_[(size_t)li].layer, &n); + return dev && n > 0 && n <= scratch_n_; +} + +/* Called only at the layer's trigger or a repeat of it, so the router of the rows about to run + * has been issued on `s` ahead of the copy. The drain costs far less than the read it decides. */ +int FileStager::counts(int32_t li, RadStream s, const int32_t** ecnt, int32_t* n_expert) { + *ecnt = nullptr; + *n_expert = 0; + if (!routes_) return RAD_OK; + int64_t n = 0; + const int32_t* dev = routes_(routes_ud_, layers_[(size_t)li].layer, &n); + if (!dev || n <= 0 || n > scratch_n_) return RAD_OK; + RAD_TRY(rad_memcpy_async(scratch_, dev, (size_t)n * sizeof(int32_t), s)); + RAD_TRY(rad_stream_sync(s)); + *ecnt = scratch_; + *n_expert = (int32_t)n; + return RAD_OK; +} + +/* Read layer `li` into its buffer: with this pass's counts when the source has them (only at the + * layer's trigger), whole otherwise. A layer with nothing on the file tier now is not held. */ +int FileStager::start(int32_t li, RadStream s, bool* resync) { const int b = li & 1; if (holds_[b] >= 0) return RAD_E_STATE; /* released before the next read, by construction */ - /* Routing-aware reads: the trigger (this call) runs at the layer's first expert op, - * after the layer's router on the same stream, so this pass's counts are ordered - * before the copy. The stream sync costs far less than a gigabyte-scale layer read; - * a source that declines (no report yet this pass) reads the whole layer. */ + const Layer& L = layers_[(size_t)li]; + if (!mover_->on_file_tier(L.units)) return RAD_OK; const int32_t* ecnt = nullptr; int32_t n_expert = 0; - if (routes_) { - int64_t n = 0; - const int32_t* dev = routes_(routes_ud_, layers_[(size_t)li].layer, &n); - if (dev && n > 0 && n <= scratch_n_ && - rad_memcpy_async(scratch_, dev, (size_t)n * sizeof(int32_t), s) >= 0 && - rad_stream_sync(s) >= 0) { - ecnt = scratch_; - n_expert = (int32_t)n; - } - } - const int rc = mover_->stage_file_units(layers_[(size_t)li].units, buf_[b], cap_, - free_rec_[b] ? free_[b] : nullptr, done_[b], - &staged_[b], &skipped_[b], ecnt, n_expert, - &promoted_[b]); - if (rc < 0) return rc; - if (!staged_[b].empty() || !promoted_[b].empty()) holds_[b] = li; + if (counted(li)) RAD_TRY(counts(li, s, &ecnt, &n_expert)); + /* The layer read, the one held in the other buffer, and the one whose ops are being issued + * (cur_: it may hold nothing on the file tier, and so be held by neither): their pooled units + * must keep their addresses. */ + const int32_t protect[3] = { L.layer, holds_[b ^ 1] >= 0 ? layers_[(size_t)holds_[b ^ 1]].layer + : -1, + cur_ >= 0 ? layers_[(size_t)cur_].layer : -1 }; + rd_[b].clear(); + holds_[b] = li; + *resync = true; + RAD_TRY(mover_->stage_file_units(L.units, buf_[b], cap_, free_rec_[b] ? free_[b] : nullptr, + done_[b], &rd_[b], ecnt, n_expert, protect, 3)); + pending_[b] = rd_[b].copied; + return RAD_OK; +} + +/* Another slice of the current layer's rows: its router has rewritten the counts, and an expert + * the earlier slices did not route is read now. The buffer is the layer's, and the new units are + * packed after the ones already there, so nothing is waited on before the copies. */ +int FileStager::top_up(int32_t li, RadStream s, bool* resync) { + const int b = li & 1; + if (holds_[b] != li || rd_[b].skipped.empty()) return RAD_OK; + const int32_t* ecnt = nullptr; + int32_t n_expert = 0; + RAD_TRY(counts(li, s, &ecnt, &n_expert)); + /* The earlier slices were read with counts, so the source has them; were it to decline, + * everything left is read. A slice that routes nothing new changes nothing. */ + if (!mover_->routes_any(rd_[b].skipped, ecnt, n_expert)) return RAD_OK; + again_.swap(rd_[b].skipped); + rd_[b].skipped.clear(); + rd_[b].copied = false; + const int32_t protect[3] = { layers_[(size_t)li].layer, + holds_[b ^ 1] >= 0 ? layers_[(size_t)holds_[b ^ 1]].layer : -1, + cur_ >= 0 ? layers_[(size_t)cur_].layer : -1 }; + *resync = true; + const int rc = mover_->stage_file_units(again_, buf_[b], cap_, nullptr, done_[b], &rd_[b], + ecnt, n_expert, protect, 3); + again_.clear(); + RAD_TRY(rc); + if (rd_[b].copied) pending_[b] = true; + return wait(b, s); +} + +int FileStager::wait(int32_t b, RadStream s) { + if (!pending_[b]) return RAD_OK; + RAD_TRY(rad_event_wait(s, done_[b])); + pending_[b] = false; + ++waits_; return RAD_OK; } int FileStager::finish(int32_t b, RadStream s) { + /* A read the pass never reached (a read-ahead past where it ended) still deposited into the + * pool or admitted into the hot cache, whose publications outlive it: order the stream behind + * those copies before anything later can read them. */ + RAD_TRY(wait(b, s)); RAD_TRY(rad_event_record(free_[b], s)); free_rec_[b] = true; - mover_->unstage_units(staged_[b]); - staged_[b].clear(); - if (!skipped_[b].empty()) { - mover_->unstage_units(skipped_[b]); /* the dummy publications go to null too */ - skipped_[b].clear(); - } - /* Hot-cache units are NOT unstaged: their publications name their slots, which outlive - * the buffer. The layer's copies into them landed before its ops ran (the done_ wait). */ - promoted_[b].clear(); + mover_->unstage_units(rd_[b].staged); + /* The skipped units' dummy publications go to null too. Hot-cache units are not unstaged: + * their publications name their slots, which outlive the buffer. */ + mover_->unstage_units(rd_[b].skipped); + rd_[b].clear(); holds_[b] = -1; return RAD_OK; } @@ -497,41 +586,34 @@ int FileStager::before_op(rad_op h, RadStream s, bool* resync) { *resync = false; if ((int32_t)h > last_issued_) last_issued_ = (int32_t)h; - /* Read the pass's first routed layer at its first op of any kind. */ + /* Read the pass's first routed layer at its first op of any kind, when it is read whole. */ if (first_op_) { first_op_ = false; const auto it = std::lower_bound(layers_.begin(), layers_.end(), (int32_t)h, [](const Layer& L, int32_t op) { return L.first_op < op; }); if (it != layers_.end()) { const int32_t li = (int32_t)(it - layers_.begin()); - if (will_issue(li)) { - RAD_TRY(start(li, s)); - *resync = true; - } + if (will_issue(li) && !counted(li)) RAD_TRY(start(li, s, resync)); } } if ((size_t)h >= first_of_.size()) return RAD_OK; const int32_t li = first_of_[(size_t)h]; - if (li < 0 || li == cur_) return RAD_OK; + if (li < 0) return RAD_OK; + if (li == cur_) return top_up(li, s, resync); /* Entering layer `li`: the layer before is behind every op issued so far on this stream. */ for (int b = 0; b < 2; ++b) if (holds_[b] >= 0 && holds_[b] != li) { RAD_TRY(finish(b, s)); *resync = true; } - /* A layer the read-ahead skipped (the learned bound said the pass ends before it) is read - * here rather than issued without addresses. */ - if (holds_[li & 1] != li) { - RAD_TRY(start(li, s)); - *resync = true; - } - if (holds_[li & 1] == li) RAD_TRY(rad_event_wait(s, done_[li & 1])); + /* Read here unless read ahead: a counted layer always, a whole one the read-ahead skipped + * (the learned bound said the pass ends before it). */ + if (holds_[li & 1] != li) RAD_TRY(start(li, s, resync)); + RAD_TRY(wait(li & 1, s)); cur_ = li; const int32_t next = li + 1; - if ((size_t)next < layers_.size() && will_issue(next)) { - RAD_TRY(start(next, s)); - *resync = true; - } + if ((size_t)next < layers_.size() && will_issue(next) && !counted(next)) + RAD_TRY(start(next, s, resync)); return RAD_OK; } diff --git a/core/place/stager.h b/core/place/stager.h index e2779258..5d1c21ce 100644 --- a/core/place/stager.h +++ b/core/place/stager.h @@ -214,47 +214,92 @@ private: * GEMM is handed every expert's pointer at issue. So on every pass, decode included, each routed * layer's file-tier units are read into one of the mover's two file buffers before the layer's * first expert op and published there, then published as null when the next routed layer starts. - * The router's picks are not known on the host without a round trip, so the layer's whole - * file-tier part is read; decode is then paced by the drive, which is the trade the flag makes. * - * the pass's first op read the first routed layer the pass issues - * a layer's first op release the layer before (record its buffer free on the stream, publish - * null), wait on this layer's copies, and read the next layer into the - * buffer just released -- its copies queue behind that free event + * ---- which experts ------------------------------------------------------------------------------- + * + * Only the experts the layer's rows route to are read. Their counts are known only once the + * layer's router has run, so a layer is read at its own trigger, its first expert op: the counts + * are copied back behind the router on the same stream (one drain of the stream), and a unit + * counted zero is published at the mover's zero region instead of being read. The read cannot + * start earlier: counts taken before the router are another layer's, or the last pass's, and a + * truly routed expert they count zero would be computed from zeros. The card waits for every + * read either way, so reading at the trigger costs what reading the next layer ahead behind the + * same drain did. + * + * A layer the count source cannot give counts for (the first pass, before any report) is read + * whole, and since that read needs no counts it goes ahead of time as before: at the pass's + * first op for the first routed layer, at a layer's trigger for the next one, into the buffer + * just released. + * + * So is every layer of a pass large enough that its rows route nearly every expert, kWholeRows + * rows an expert on average by the model's expert count and top-k (whole_rows()). An exact read + * takes the same bytes there, and each layer costs the card's work plus the drive's, since the + * card idles behind the drain while the drive reads. A whole read needs no counts, so nothing + * drains the stream, and the drive reads the next layer while the card computes the one before. + * At 64 rows an expert, one routed an eighth as often as the average is left out of about one + * pass in 3000, and read for nothing then. Smaller passes skip enough to pay for the drain: at + * decode nearly every file-tier expert. + * + * the pass's first op read the first routed layer the pass issues, if it is read whole + * a layer's first op release the layer before (record its buffer free on the stream, + * publish null), read this layer unless read ahead, wait on its + * copies, and read the next layer ahead if it is read whole -- its + * copies queue behind the free event of the buffer it takes + * a repeat of that op another slice of rows: read what its counts route that the earlier + * slices' did not, and wait on those copies * the pass's end release whatever is still held * * A layer is released when the next one starts, not at its own last op: a routed block that slices * a large step into passes of `rows` tokens issues its expert ops once per slice, so a release at - * the last op would leave the next slice reading null. Repeats of the current layer's first op do - * nothing. + * the last op would leave the next slice reading null. Each slice routes its own rows, which is + * why a repeat reads again. * - * The read blocks the issuing thread while the card runs what was issued before it. A layer's - * file-tier part is gigabytes against milliseconds of compute, so the step is drive-bound either - * way; a reader thread would gain little and add a second writer of the residency table. + * Every read that issued a copy is waited on, a hot-cache admission's or a pool deposit's as much + * as a staged unit's: all are published settled, so the wait is the only thing between the GEMM + * and the slot's previous bytes. + * + * The read blocks the issuing thread while the card runs what was issued before it; a reader + * thread would gain little and add a second writer of the residency table. * * A layer is read ahead only when the pass will issue it (a bound learned per draft_pass from the - * last pass of that kind), so a trunk pass does not read the MTP head's layer. */ + * last pass of that kind), so a trunk pass does not read the MTP head's layer. + * + * ---- which units ------------------------------------------------------------------------------- + * + * Under a dynamic plan the pool is a cache of the file tier: a deposit may relabel a pooled unit + * back to the file tier (Mover::stage_file_units). A pooled unit the plan put in the pool is then + * on the file tier too, so the stager covers every movable routed unit of a class with file-tier + * units, not only the plan's file-tier ones, and tells the mover so (Mover::cover_file_units); a + * trigger whose layer has nothing on the file tier skips the read and its drain. Where covering + * them would interleave two layers' spans, only the plan's file-tier units are covered, and the + * mover relabels none of the others. */ class FileStager final : public OpStager { public: ~FileStager() override; - /* Routing-aware reads: the engine binds a source of the layer's per-expert routing - * counts for the current pass (the router reports them to the Ctx before the layer's - * first expert op, which is the stager's trigger). Returns the device pointer of - * `n_expert` i32 counts, or null when the layer has not reported this pass — the - * caller then reads the whole layer. Null `routes` reads whole layers. */ + /* Routing-aware reads: the engine binds a source of a layer's per-expert routing counts + * (Ctx::route_counts_device). It returns the device pointer of `n_expert` i32 counts that the + * layer's router rewrites every pass before the layer's first expert op, which is the + * stager's trigger, or null when it has none (the layer has not reported yet) -- the stager + * then reads the whole layer. Null `routes` reads whole layers. */ using RouteCounts = const int32_t* (*)(void* ud, int32_t layer, int64_t* n_expert); /* Binds the routed layers with file-tier units and the ops that read them, over the mover's * two file buffers. Leaves enabled() false when no routed unit is on the file tier. Refuses a - * plan whose routed layers are read by interleaved ops, since a file-tier unit has no other - * address to fall back on. */ + * plan whose routed file-tier layers are read by interleaved ops, since a file-tier unit has + * no other address to fall back on. */ int init(const Program& prog, const Plan& plan, Mover* mover, RouteCounts routes = nullptr, void* routes_ud = nullptr); bool enabled() const { return !layers_.empty(); } size_t n_layers() const { return layers_.size(); } int64_t buffer_bytes() const { return cap_; } + /* Stream waits on the stager's copies so far, one per read that issued any. Tests read it. */ + int64_t waits() const { return waits_; } + /* The smallest pass, in tokens, whose layers are read whole and ahead (see "which experts"), + * or 0 when every pass is read exactly (no routing source, or the model's top-k unknown). */ + int64_t whole_rows() const { return whole_rows_; } + static constexpr int64_t kWholeRows = 64; bool begin_pass(const RadBatch* b) override; int before_op(rad_op h, RadStream s, bool* resync) override; @@ -262,7 +307,8 @@ public: private: using Layer = StagedLayer; - std::vector layers_; /* the routed layers with file-tier units, in first-op order */ + int64_t waits_ = 0; + std::vector layers_; /* the routed layers the stager covers, in first-op order */ std::vector first_of_; /* by op: the layer whose first op it is, or -1 */ Mover* mover_ = nullptr; @@ -272,16 +318,15 @@ private: void* routes_ud_ = nullptr; int32_t* scratch_ = nullptr; /* pinned, for the trigger's blocking counts copy */ int64_t scratch_n_ = 0; - std::vector skipped_[2]; /* per buffer: units not read, nulled at release */ - /* Per buffer: units the stager read into hot-cache slots. Unlike the - * staged ones they keep their publications when the buffer is released — the slot is - * their address from here on, until heat evicts one. */ - std::vector promoted_[2]; + /* Per buffer: what its layer's reads staged (nulled at release), skipped (likewise) and read + * into hot-cache slots (whose publications outlive the buffer -- the slot is their address + * until heat evicts one). */ + Mover::FileRead rd_[2]; + std::vector again_; /* a repeat's candidates: the layer's skipped units */ RadEvent done_[2] = { nullptr, nullptr }; /* behind a buffer's copies, on the mover stream */ RadEvent free_[2] = { nullptr, nullptr }; /* behind the ops that read a buffer's layer */ bool free_rec_[2] = { false, false }; - std::vector staged_[2]; - int start(int32_t li, RadStream s); + bool pending_[2] = { false, false }; /* copies no stream has waited on yet */ int32_t holds_[2] = { -1, -1 }; /* the layer a buffer holds, or -1 */ int32_t cur_ = -1; /* the layer whose ops are being issued */ @@ -290,9 +335,18 @@ private: int32_t pass_kind_ = 0; int32_t last_issued_ = -1; std::map pass_last_; /* by draft_pass: the last op such a pass issued */ + int64_t whole_rows_ = 0; + bool whole_ = false; /* this pass reads every layer whole (whole_rows) */ bool will_issue(int32_t li) const; - int start(int32_t li); + /* Whether layer `li` is read with counts, at its own trigger; otherwise it is read whole, + * and may be read ahead. */ + bool counted(int32_t li) const; + /* The counts of the rows about to run, copied back behind the router on `s`, or null. */ + int counts(int32_t li, RadStream s, const int32_t** ecnt, int32_t* n_expert); + int start(int32_t li, RadStream s, bool* resync); + int top_up(int32_t li, RadStream s, bool* resync); + int wait(int32_t b, RadStream s); int finish(int32_t b, RadStream s); }; diff --git a/core/plugin/loader.cpp b/core/plugin/loader.cpp index 640157e6..0a1d059f 100644 --- a/core/plugin/loader.cpp +++ b/core/plugin/loader.cpp @@ -52,9 +52,10 @@ bool target_covers(const std::string& declared, const char* arch) { } /* Two schemas for one op are the same when every positional slot means the same thing: parameter - * keys, types and requiredness (what the selector matches on) and operand count, roles and - * optionality (arguments are positional). Operand names are for diagnostics only (ABI), so "b" - * and "w_gate" in slot 1 agree. */ + * keys, types, requiredness (what the selector matches on) and roles (the core reads the first + * registrant's: a chunk or a capacity named by one plugin applies to every plugin's rows), and + * operand count, roles and optionality (arguments are positional). Operand names are for + * diagnostics only (ABI), so "b" and "w_gate" in slot 1 agree. */ bool schema_same(const RadOpSchema& a, const RadOpSchema& b, std::string* diff) { if (a.n_params != b.n_params) { *diff = fmt("%d parameters vs %d", a.n_params, b.n_params); @@ -77,6 +78,10 @@ bool schema_same(const RadOpSchema& a, const RadOpSchema& b, std::string* diff) x.required ? "required" : "optional", y.required ? "required" : "optional"); return false; } + if (x.role != y.role) { + *diff = fmt("parameter '%s' has role %d vs %d", or_empty(x.key), x.role, y.role); + return false; + } } if (a.n_operands != b.n_operands) { *diff = fmt("%d operands vs %d", a.n_operands, b.n_operands); @@ -212,6 +217,8 @@ int Registry::commit_(Staged& s, int order) { p.arch_declare = dl_fn( s.handle, "rad_arch_declare"); p.arch_step = dl_fn(s.handle, "rad_arch_step"); + p.arch_pass_key = dl_fn( + s.handle, "rad_arch_pass_key"); if (!id_fn || !p.arch_declare || !p.arch_step) { err_("architecture plugin '%s' is missing rad_arch_id, rad_arch_declare or " "rad_arch_step", p.name.c_str()); @@ -291,6 +298,27 @@ int Registry::commit_(Staged& s, int order) { unstage_(s); return RAD_E_INVAL; } + /* The counts are the plugin's word; the tables they index are walked at every + * selection and every issue, so a null table or an operand count past what an issue + * can carry (MAX_OPERANDS) is refused here, by name, rather than read there. */ + if (sch->n_params < 0 || (sch->n_params && !sch->params) || sch->n_operands < 0 || + sch->n_operands > MAX_OPERANDS || (sch->n_operands && !sch->operands)) { + err_("kernel plugin '%s': op '%s' declares %d parameters and %d operands, a table " + "missing, or more operands than an issue carries (%d)", p.name.c_str(), + sch->op, sch->n_params, sch->n_operands, MAX_OPERANDS); + unstage_(s); + return RAD_E_INVAL; + } + for (int q = 0; q < sch->n_params; ++q) { + const RadParamSpec& ps = sch->params[q]; + if (!ps.key || !ps.key[0] || ps.role < RAD_PROLE_NONE || + ps.role > RAD_PROLE_CAPACITY) { + err_("kernel plugin '%s': op '%s' parameter %d has no key or an unknown role " + "(%d)", p.name.c_str(), sch->op, q, ps.role); + unstage_(s); + return RAD_E_INVAL; + } + } std::string diff; auto it = schemas_.find(sch->op); if (it != schemas_.end()) { @@ -338,6 +366,23 @@ int Registry::commit_(Staged& s, int order) { unstage_(s); return RAD_E_INVAL; } + /* The selector reads every constraint of every row at every query, and the tuner every + * tunable, so their tables must exist wherever a count says they do. */ + if (k->n_tunables < 0 || (k->n_tunables && !k->tunables) || k->n_constraints < 0 || + (k->n_constraints && !k->constraints)) { + err_("kernel '%s' in plugin '%s' declares %d tunables and %d constraints with a " + "missing table", k->name, p.name.c_str(), k->n_tunables, k->n_constraints); + unstage_(s); + return RAD_E_INVAL; + } + for (int c = 0; c < k->n_constraints; ++c) + if (!k->constraints[c].key || !k->constraints[c].key[0] || + (k->constraints[c].op == RAD_C_IN && !k->constraints[c].sval)) { + err_("kernel '%s' in plugin '%s' declares constraint %d with no key, or an IN " + "with no set", k->name, p.name.c_str(), c); + unstage_(s); + return RAD_E_INVAL; + } /* Every tunable axis must carry a default that is one of its own values. Untuned * shapes (no cache, an unmeasured shape, another card's cache) run the defaults, with * no other fallback (spec §15). Checked at load rather than first use so a bad axis @@ -382,8 +427,15 @@ int Registry::commit_(Staged& s, int order) { if (no_device_code_) why = "no card is visible, so this process runs on the host backend and no GPU code " "object runs here"; - if (n_device > 0 && s.code_to > s.code_from && - (no_device_code_ || rad::dev_code_runs(s.code_from, s.code_to, code_device_, &why) == 0)) { + /* The code range decides only the per-card test: on the host backend the rows go even when + * this dlopen registered no fat binary (no HIP in the build, or the library already + * mapped by another registry). */ + const bool no_code_here = + n_device > 0 && + (no_device_code_ || + (s.code_to > s.code_from && + rad::dev_code_runs(s.code_from, s.code_to, code_device_, &why) == 0)); + if (no_code_here) { std::vector> keep; for (const auto& r : staged_rows) if (r.first->domain != RAD_DOMAIN_DEVICE) keep.push_back(r); diff --git a/core/plugin/registry.h b/core/plugin/registry.h index fdced875..3c564e70 100644 --- a/core/plugin/registry.h +++ b/core/plugin/registry.h @@ -82,6 +82,7 @@ struct Plugin { std::string arch_quant; int (*arch_declare)(RadBuilder*, const RadModelMeta*, const RadBuildCtx*) = nullptr; void (*arch_step)(RadCtx*, const RadBatch*) = nullptr; + uint64_t (*arch_pass_key)(RadCtx*, const RadBatch*, const int32_t*) = nullptr; /* Optional (rad_builder.h); null means every question answers zero. Asked before declare, so * model facts that are inputs to declaration are still read by the plugin, not the core. */ int (*arch_probe)(const RadModelMeta*, RadArchProbe*) = nullptr; diff --git a/core/rad_core.h b/core/rad_core.h index b92a1d5b..dbdc8dcb 100644 --- a/core/rad_core.h +++ b/core/rad_core.h @@ -17,6 +17,11 @@ namespace rad { +/* The widest conventional op is gdn_conv_prep at sixteen operands (docs/OPS.md). Thirty-two leaves + * room for an architecture plugin's private ops without a variable-length array on the hot path. + * The plugin loader refuses a schema with more, so no issue carries more. */ +constexpr int MAX_OPERANDS = 32; + namespace mm { struct Item; struct PromptMedia; } class Registry; @@ -451,9 +456,15 @@ public: std::vector decoder_max_area; } vgen_str; bool is_video_generator() const { return video_gen.max_lanes != 0; } + /* The declared shape generator (rad_declare_shape_generator); `max_lanes` 0 when none. Its + * name points at `sgen_name`. */ + RadShapeGenDecl shape_gen{}; + std::string sgen_name; + bool is_shape_generator() const { return shape_gen.max_lanes != 0; } /* Driven by passes, not token steps: any generator. */ bool is_pass_driven() const { - return is_generator() || is_audio_generator() || is_video_generator(); + return is_generator() || is_audio_generator() || is_video_generator() || + is_shape_generator(); } /* Two arenas, because a host-site activation cannot index device memory. The buffer plan @@ -671,6 +682,10 @@ struct SamplingParams { * duplicates ignored. Empty (the default) is off: the ban is then bit-identical to the * no-whitelist form. */ std::vector ngram_whitelist; + /* Token ids this request never samples (generation_config.json's suppress_tokens: Gemma 4's + * end-of-image and end-of-audio markers). Global ids, duplicates ignored; empty is off. The + * sampler takes them out of the row as it does a grammar's mask. */ + std::vector suppress_tokens; }; /* Raw logits at chosen vocabulary ids at the prompt's last position, for a caller that answers @@ -824,7 +839,13 @@ struct Config { * prefill stager arms for. 0 = off: the chunk takes every token the step has left. N > 0: cap * the chunk at N tokens on such a step. See Scheduler::step, docs/GUIDE.md. */ int64_t busy_prefill_chunk = -1; - int64_t prefill_interleave = 0; /* --prefill-interleave: decode-only steps between chunks */ + double prefill_interleave_share = 0.25; /* --prefill-interleave auto[:SHARE] */ + /* Whether --prefill-interleave was given. Not given, engine bring-up serves auto:1 (decode-only + * steps for as long as a chunk step took) except under --deterministic, in KL mode and for a + * generator; the Config default 0 is what a Scheduler built directly (tests) gets. */ + bool prefill_interleave_set = false; + int64_t prefill_interleave = 0; /* --prefill-interleave: decode-only steps between chunks; + * -1 auto (Scheduler::interleave_steps) */ /* --preempt-wait-ms: how long a preempted prefill may wait for the whole-recompute gate * before the scheduler evicts cache blocks and preempts a lower-priority running request to * make room for it. 0 = fall back on the next step; default 5000 ms. */ @@ -848,6 +869,9 @@ struct Config { int64_t vram_weights_mib = 0; int64_t vram_kv_mib = 0; int64_t gpu_headroom_mib = 96; /* --gpu-headroom-mib, left unclaimed on every card */ + /* --gpu-memory-mib: claim this much of every card; 0 uses gpu_headroom_mib. Inverse of + * headroom: N + headroom = the card, in MiB. Not with --gpu-headroom-mib. */ + int64_t gpu_memory_mib = 0; /* --kv-cache-dtype bf16|fp8|fp8_v4|k6_v4. fp8 is an E4M3 cache with per-(sequence, head) * descales; it halves the per-token cost, most of the KV pool at production context. fp8_v4 * keeps K as E4M3 and V as int4 in groups of 32, k6_v4 also K as int6 (RadBuildCtx::kv_quant), @@ -887,6 +911,10 @@ struct Config { /* --ngram-placement ram=DIR: the pinned n-gram copy is the file DIR/ngram-.tab (a tmpfs), * mapped shared, so engines on separate cards hold one table. Empty: a private copy. */ std::string ngram_share_dir; + /* --ngram-placement disk=DIR: the table is read from its own file, DIR/ngram-.bin, filled + * from the container at the first start, instead of from the container (a faster drive than + * the model's). Empty: from the container. */ + std::string ngram_disk_dir; TablePlacement embedding_resolved = TablePlacement::Vram; TablePlacement ngram_resolved = TablePlacement::Disk; /* Set by the resolver: pinned host MiB per rank for the token embedding when it resolves to diff --git a/core/runtime/ctx.cpp b/core/runtime/ctx.cpp index 7fce02f1..e56b9882 100644 --- a/core/runtime/ctx.cpp +++ b/core/runtime/ctx.cpp @@ -31,11 +31,15 @@ int Ctx::init(const CtxDesc& d) { registry_ = d.registry; kv_ = d.kv; arch_step_ = d.arch_step; + arch_pass_key_ = d.arch_pass_key; profiling_ = d.profile_ops; /* The rank owns one device. Set it here so allocation lands on the right card, and again from * the rank thread in bind_thread() because the backend's current device is thread-local. */ RAD_TRY(rad_dev_set(device_)); + RadDeviceProps props{}; + if (rad_dev_props(device_, &props) >= 0 && !props.is_host_backend && props.n_cu > 0) + wgp_count_ = props.n_cu; if (d.stream) { stream_ = d.stream; @@ -367,6 +371,7 @@ int Ctx::bind_ops() { ip.args.instance = r.instance; ip.args.rank = rank_; ip.args.world_size = world_size_; + ip.args.wgp_count = wgp_count_; /* A launch that ends its own link hold gets the hold word as an extra * `link_gate` parameter after the geometry's. */ if (r.row->releases_link) @@ -777,13 +782,30 @@ const int32_t* Ctx::route_counts_device(int layer, int64_t* n_expert) const { if (n_expert) *n_expert = 0; if (layer < 0 || (size_t)layer >= route_.size()) return nullptr; const RouteSlot& s = route_[(size_t)layer]; - /* No step gate: route_report lands at the END of the block's passes (heat consumes it a - * step later), but the reported buffer is the block's own ecnt, whose CONTENT the router - * kernel rewrote this pass -- and the file stager's trigger runs after that router on the - * same stream, so a stream-ordered copy reads this pass's counts. The counts are indexed - * by the rank's local expert slot (the kernel subtracts expert_base), which is also what - * the mover's units carry. */ + /* No step gate: route_report lands at the END of the block's passes, so at the file stager's + * trigger (the layer's first expert op) the pointer is the one the last pass reported. That + * is right only for a buffer whose address is the same in this pass: the block's own counts + * buffer, which its router rewrites every pass -- and the trigger runs after that router on + * the same stream, so a stream-ordered copy reads the counts of the rows about to run. The + * counts are indexed by the rank's local expert slot (the kernel subtracts expert_base), + * which is also what the mover's units carry. */ if (!s.routing.expert_count || s.reported < 0) return nullptr; + /* A transient buffer is at another offset at another arena level, and liveness lets a + * later buffer share its bytes, since no declared op reads the counts (the report is a + * handoff, not an op): the bytes under the last pass's pointer may be anything. A whole read + * is slow but right; counts read there could name a routed expert zero and leave it + * unread. Every architecture here declares the counts RAD_BUF_PERSIST. */ + const char* p = (const char*)s.routing.expert_count; + const char* base = (const char*)arena_.base(); + if (base && program_ && p >= base + program_->arena_fixed_bytes && p < base + arena_.bytes()) { + if (!route_transient_noted_) { + route_transient_noted_ = true; + RAD_WARN("rank %d: layer %d reports its routing counts in a transient buffer, so the " + "file stager reads its routed experts whole; declare the counts " + "RAD_BUF_PERSIST", rank_, layer); + } + return nullptr; + } if (n_expert) *n_expert = s.routing.n_expert ? s.routing.n_expert : route_n_expert_; return s.routing.expert_count; } @@ -942,23 +964,36 @@ int Ctx::lane_join(int from, int to) { /* The key below reads every RadBatch field a pass's shape or arguments can depend on, by hand. A * field added to RadBatch changes its size: decide whether the key must read it, then update the - * size here. `agen_b` and `vgen_b` are set only on generator passes, which are never recorded - * (below). */ -static_assert(sizeof(void*) != 8 || sizeof(RadBatch) == 408, + * size here. The ABI-35 host mirrors are used by issue-time split selection; unsupported dynamic + * geometries fail closed via the pass-key contract, while Qwen keys its full-group maximum in the + * architecture callback. `agen_b`, `vgen_b` and `sgen_b` are set only on generator passes, which are + * never recorded (below). */ +static_assert(sizeof(void*) != 8 || sizeof(RadBatch) == 480, "RadBatch changed: check that Ctx::pass_key reads every new field a pass depends on"); -static_assert(sizeof(void*) != 8 || sizeof(RadKVGroupBatch) == 80, +static_assert(sizeof(void*) != 8 || sizeof(RadKVGroupBatch) == 88, "RadKVGroupBatch changed: check that Ctx::pass_key reads every new field"); uint64_t Ctx::pass_key(const RadBatch* b) const { /* Not recordable: encoder passes are shaped by their media, and passes carrying encoder rows - * issue the scatter only when they have some. */ - if (b->enc || b->n_mm_rows > 0) return 0; + * issue the scatter only when they have some (and the second attention over a run read both + * ways, n_bidi, only on such a pass). */ + if (b->enc || b->n_mm_rows > 0 || b->n_bidi > 0) return 0; + /* A plugin with no pass-key callback cannot key a launch that splits its KV by the live + * context, so a prefill or mixed pass of a program holding such a launcher is not recorded. + * Its decode, verify and draft passes are: their launches get the keyed context bound in + * place of the live maximum (Ctx::issue_body). */ + if (!arch_pass_key_ && (b->phase == RAD_PHASE_PREFILL || b->phase == RAD_PHASE_MIXED)) { + for (const IssuePlan& ip : issue_table_) + if (ip.row && ip.row->info && + (ip.row->info->capabilities & RAD_KERNEL_CAP_DYNAMIC_PREFILL_SPLIT)) + return 0; + } /* A pass carrying a request's words for the plugin is shaped by them (a head issues per * sequence from their counts), and such a step samples a prompt's first token, which is not * the repeating decode pass. */ if (b->n_plugin_words > 0) return 0; - /* A generator pass is shaped by what RadBatch::gen_b, agen_b or vgen_b carries, which no key - * below reads. */ + /* A generator pass is shaped by what RadBatch::gen_b, agen_b, vgen_b or sgen_b carries, which + * no key below reads. */ if (b->gen) return 0; uint64_t h = 0x9e3779b97f4a7c15ull; auto mix = [&](uint64_t v) { @@ -976,6 +1011,8 @@ uint64_t Ctx::pass_key(const RadBatch* b) const { ptr(b->token_ids); ptr(b->positions); ptr(b->cu_seqlens); ptr(b->seq_ids); ptr(b->out_ids); ptr(b->q_lens); ptr(b->ctx_lens); ptr(b->num_accepted); ptr(b->spec_parent); ptr(b->checkpoint_tok); ptr(b->checkpoint_slot); ptr(b->draft_out_ids); + /* A block drafter's query pass reads it (null on every other pass). */ + ptr(b->anchor_rows); /* Null on a step with no adapter row, which then issues no adapter op (Ctx::issue_lora): the * two are different passes. The slots themselves are read on the card. */ ptr(b->lora_slot); @@ -989,6 +1026,11 @@ uint64_t Ctx::pass_key(const RadBatch* b) const { /* A streamed group's view by the memory it names, never its address (kvstream_view_key). */ mix(kvstream_view_key(k.stream)); } + if (arch_pass_key_) { + const uint64_t geometry = arch_pass_key_(const_cast(this), b, b->kv_used_max_h); + if (!geometry) return 0; + mix(geometry); + } mix((uint64_t)level_); mix(dense_epoch_); mix(domain_epoch_.load(std::memory_order_relaxed)); diff --git a/core/runtime/ctx.h b/core/runtime/ctx.h index 1ee74d2b..2ec9f8e1 100644 --- a/core/runtime/ctx.h +++ b/core/runtime/ctx.h @@ -40,10 +40,6 @@ class Registry; struct XpState; struct XpLayer; -/* The widest conventional op is gdn_conv_prep at sixteen operands (docs/OPS.md). Thirty-two leaves - * room for an architecture plugin's private ops without a variable-length array on the hot path. */ -constexpr int MAX_OPERANDS = 32; - typedef void (*ArchStepFn)(RadCtx*, const RadBatch*); /* "[shape]/[stride]" of a tensor's live dimensions, for diagnostics. */ @@ -196,6 +192,7 @@ struct CtxDesc { RadStream stream = nullptr; /* null: the Ctx creates its own compute stream */ ResidencyTable* residency = nullptr; /* null in the all-in-VRAM case */ ArchStepFn arch_step = nullptr; /* the architecture plugin's rad_arch_step */ + uint64_t (*arch_pass_key)(RadCtx*, const RadBatch*, const int32_t*) = nullptr; bool profile_ops = false; /* spec §16, and it changes what you measure */ /* Whether a repeated pass may be recorded and played back. False for a caller whose pass * issues work the batch does not describe (e.g. a test driving another component through @@ -260,6 +257,7 @@ public: } /* This rank's device ordinal, for the calls that name a card rather than a stream. */ int device() const { return device_; } + int wgp_count() const { return wgp_count_; } int world_size() const { return world_size_; } RadStream stream() const { return stream_; } Program* program() const { return program_; } @@ -334,10 +332,11 @@ public: /* Called by the drain, so the ring knows which banks are still unread. */ void mark_credited(int layer, int bank); const RadRouting* last_routing(int layer) const; - /* The device pointer of `layer`'s expert counts for the current step, with `n_expert` set, - * or null when the layer has not reported this step (a routing-aware file stager then - * reads the layer whole). The pointer is stream-ordered behind the router: a copy on the - * compute stream at the stager's trigger sees this pass's counts. */ + /* The device pointer of the buffer `layer`'s router writes its expert counts to, as the + * layer last reported it, with `n_expert` set; null when the layer has not reported yet, or + * when the buffer is a transient one (a routing-aware file stager then reads the layer + * whole). The router rewrites it every pass before the layer's first expert op, so a copy on + * the compute stream at the stager's trigger sees the counts of the rows about to run. */ const int32_t* route_counts_device(int layer, int64_t* n_expert) const; /* ---------------------------------------------------------- the placement seam */ @@ -657,6 +656,8 @@ private: bool staging_ = false; /* the stager armed for the pass being issued */ int issue_body(rad_op h, const RadOperand* opd, int n_opd, int64_t n); ArchStepFn arch_step_ = nullptr; + uint64_t (*arch_pass_key_)(RadCtx*, const RadBatch*, const int32_t*) = nullptr; + int wgp_count_ = 32; /* The expert prefetch's state (xp_state.h), null while it is off. */ std::unique_ptr xp_; @@ -778,6 +779,8 @@ private: std::vector route_; int64_t route_n_expert_ = 0; + /* route_counts_device has said once that a layer's counts are a transient buffer. */ + mutable bool route_transient_noted_ = false; /* A bank is one step's histograms for every layer: [kRouteBanks][n_layer][n_expert] in pinned * host memory. A report copies a layer's counts into its row of the card-side * [n_layer][n_expert] (an on-card copy that orders nothing else); the end of the pass copies diff --git a/core/runtime/issue.cpp b/core/runtime/issue.cpp index 3ffbfef0..8d188036 100644 --- a/core/runtime/issue.cpp +++ b/core/runtime/issue.cpp @@ -10,6 +10,7 @@ * the host. See ctx.h for the cost budget (spec §3.2). */ #include +#include #include #include #include @@ -62,6 +63,66 @@ std::string tensor_shape_str(const RadTensor& t) { return s + "]"; } +/* A device launch may use a host-side KV bound only when its exact operand maps to the host mirror + * of seqused (including a sequence slice), or to the position just after a one-sequence prefill + * piece. Never copy seqused back from a device queue here: the AQL upload may still be pending on + * another queue. */ +static bool issue_vector_operand(const RadTensor& t) { + return (t.rank == 1 && t.stride[0] == 1) || + (t.rank == 2 && t.shape[1] == 1 && t.stride[0] == 1 && t.stride[1] == 1); +} + +static bool issue_host_span_max(const RadTensor& t, const int32_t* device, const int32_t* host, + int64_t total, int32_t* out) { + if (!t.data || !issue_vector_operand(t) || t.shape[0] <= 0 || !device || !host || total <= 0 || !out) + return false; + const std::uintptr_t p = reinterpret_cast(t.data); + const std::uintptr_t base = reinterpret_cast(device); + if (p < base) return false; + const std::uintptr_t delta = p - base; + if (delta % sizeof(int32_t)) return false; + const std::uint64_t first = delta / sizeof(int32_t); + const std::uint64_t count = (std::uint64_t)t.shape[0]; + if (first > (std::uint64_t)total || count > (std::uint64_t)total - first) return false; + int32_t maximum = host[first]; + for (std::uint64_t i = 1; i < count; ++i) maximum = std::max(maximum, host[first + i]); + *out = maximum; + return true; +} + +static int32_t issue_kv_used_max_h(const RadBatch* b, const RadTensor* t, int n) { + if (!b || !t || b->n_seq <= 0) return -1; + bool have = false; + int32_t found = -1; + auto add = [&](int32_t value) { + if (!have) { found = value; have = true; } + else if (found != value) return false; + return true; + }; + for (int i = 0; i < n; ++i) { + if (!t[i].data || !issue_vector_operand(t[i]) || t[i].shape[0] <= 0) continue; + if (b->kv) for (int g = 0; g < b->n_kv_groups; ++g) { + if (b->kv_used_max_h && t[i].data == b->kv[g].seqused && + t[i].shape[0] == b->n_seq) { + if (!add(b->kv_used_max_h[g])) return -1; + continue; + } + int32_t used = -1; + if (issue_host_span_max(t[i], b->kv[g].seqused, b->kv[g].seqused_h, + b->n_seq, &used) && !add(used)) return -1; + } + /* ArPieces' first attention uses positions[R] as its exact KV end: it is the position after + * the first query piece. This special operand is one length for one ordinary prefill seq. */ + if (b->phase == RAD_PHASE_PREFILL && b->n_seq == 1 && b->n_spec == 0 && + b->draft_pass == 0 && t[i].shape[0] == 1) { + int32_t used = -1; + if (issue_host_span_max(t[i], b->positions, b->positions_h, b->n_tok, &used) && + !add(used)) return -1; + } + } + return have ? found : -1; +} + /* Element offset to byte offset. False when it cannot be expressed: a mid-byte offset into a * packed sub-byte weight (e.g. an odd W4 element), or a plugin-private dtype with no core-known * size. */ @@ -854,6 +915,17 @@ int Ctx::issue_body(rad_op h, const RadOperand* opd, int n_opd, int64_t n) { /* The rest of RadArgs was filled in at prepare; args.t already points at tbuf_. There is one * entry per schema operand, the trailing optional ones the issue left out null. */ ip.args.n_t = std::max(n_opd, (int)p.n_opd_schema); + ip.args.kv_used_max_h = issue_kv_used_max_h(batch_, t, ip.args.n_t); + /* A plugin with no pass-key callback has its decode, verify and draft passes recorded + * (pass_key), and a played pass keeps the arguments it was recorded with, so a launch there + * must not read a bound the key does not: it gets the step's context bound plus its longest + * query, both keyed, which crosses a bucket every 1024 tokens or more (batch.cpp) instead of + * moving with every token. Its prefill and mixed passes are never recorded and keep the + * exact maximum. */ + if (ip.args.kv_used_max_h > 0 && !arch_pass_key_ && batch_ && + batch_->phase != RAD_PHASE_PREFILL && batch_->phase != RAD_PHASE_MIXED) + ip.args.kv_used_max_h = (int32_t)std::min( + INT32_MAX, (int64_t)batch_->max_ctx_len + batch_->max_q_len); p.issued = true; ++n_issues_; @@ -1280,6 +1352,9 @@ int rad_kv_layer_index(RadCtx* c, rad_kvgroup group, int layer) { } int rad_rank(RadCtx* c) { return c ? static_cast(c)->rank() : 0; } int rad_world_size(RadCtx* c) { return c ? static_cast(c)->world_size() : 1; } +int rad_ctx_wgp_count(RadCtx* c) { + return c ? static_cast(c)->wgp_count() : 32; +} RadStream rad_stream(RadCtx* c) { return c ? static_cast(c)->stream() : nullptr; } /* The second lane. `rad_lane` selects the lane subsequent issues launch on; `rad_lane_join` diff --git a/core/sample/sampler.cpp b/core/sample/sampler.cpp index 013a586e..aad092ae 100644 --- a/core/sample/sampler.cpp +++ b/core/sample/sampler.cpp @@ -119,8 +119,13 @@ static RadOperand opd_none() { static int64_t rows_for(const SamplerConfig& c) { /* One row per sampled position: a verify samples n_spec+1 positions per sequence, each with - * its own RNG coordinate. Sized for the worst step, as the arena is (spec §3.1). */ - return c.max_seqs * (int64_t)(c.max_spec + 1); + * its own RNG coordinate. Sized for the worst step, as the arena is (spec §3.1). A step + * carries at most max_tok tokens and samples at most one row per token, so a deep drafter + * at the default 256 sequences no longer sizes every plane for 256 * (depth + 1) rows; a + * drafter's greedy pass stages one row per drafting sequence, so never below max_seqs. */ + const int64_t want = c.max_seqs * (int64_t)(c.max_spec + 1); + if (c.max_tok <= 0) return want; + return std::min(want, std::max(c.max_tok, c.max_seqs)); } /* ================================================================== declare */ @@ -331,8 +336,9 @@ int Sampler::declare(RadBuilder* b, const SamplerConfig& cfg) { RAD_TRY(stage_alloc()); declared_ = true; - RAD_INFO("sampler: %lld-token vocabulary (%lld this rank), %lld rows, %lld mask words " + RAD_INFO("sampler: %lld-token vocabulary (%lld this rank), %lld rows%s, %lld mask words " "(%s per row)", (long long)cfg_.n_vocab, (long long)nv, (long long)rows, + rows < cfg_.max_seqs * (int64_t)(cfg_.max_spec + 1) ? " (the step's token bound)" : "", (long long)mask_words_, humanb(mask_words_ * 4).c_str()); return RAD_OK; } @@ -980,6 +986,7 @@ int Sampler::build_step(const std::vector& reqs, int64_t step) { if (budget && think.inside() && think.body >= sp.thinking_budget) force_close(p, row, sp.reasoning.close); + if (!sp.suppress_tokens.empty()) suppress(p, row, sp.suppress_tokens); if (want_lp) { /* Temperature the candidate value carries: early and late, each counted only @@ -1038,6 +1045,19 @@ void Sampler::force_close(DeviceSampleParams& p, int64_t row, int32_t close) { p.flags |= RAD_SP_MASK; } +void Sampler::suppress(DeviceSampleParams& p, int64_t row, const std::vector& ids) { + uint32_t* dst = mask_stage_ + row * mask_words_; + if (!(p.flags & RAD_SP_MASK)) { + std::memset(dst, 0xff, (size_t)mask_words_ * 4); + p.mask_row = (int32_t)row; + p.flags |= RAD_SP_MASK; + } + for (int32_t id : ids) { + const int64_t at = (int64_t)id - cfg_.vocab_off; + if (at >= 0 && at < cfg_.n_vocab_local) dst[at >> 5] &= ~(1u << (uint32_t)(at & 31)); + } +} + int Sampler::build_greedy(int64_t n) { if (!declared_) return RAD_E_STATE; if (n < 0) return RAD_E_INVAL; @@ -1054,13 +1074,11 @@ int Sampler::build_greedy(int64_t n) { any_ngram_wl_ = false; any_couple_ = false; cur_stage_ = greedy_stage_; - /* A drafter's rows run the argmax only, so the n-gram plane is cleared: `run` reads it from - * the staging, and a stale pair from an earlier request's build must not issue the ban over - * history that was not staged this step. The exemption plane needs no clear: `run` uploads - * it only beside an issued ban, every row that runs the ban has its words rewritten in full - * by the build that staged the pair (build_step), and rows below a zeroed pair are skipped - * by the op before they read a word. */ - std::memset(ngram_stage_, 0, (size_t)cap * 2 * sizeof(int32_t)); + /* Nothing a step's build staged is written here: a drafter's pass is built right after the + * step's chain was issued, whose uploads read the pinned staging only when the stream reaches + * them, behind the step's forward. So the n-gram pairs stay as the step staged them and the + * ban is gated on any_ngram_, which this clears; before, the pairs were zeroed here and a + * banning step with drafter passes uploaded the zeros, so the ban never ran on the card. */ if (greedy_ready_) return RAD_OK; for (int64_t i = 0; i < cap; ++i) { DeviceSampleParams& p = greedy_stage_[i]; @@ -1083,27 +1101,32 @@ int Sampler::run(RadCtx* c, rad_buf logits, rad_buf out_tokens) { const RadStream s = rad_stream(c); bool any_mask = false, any_greedy = false, any_chain = false; - bool any_penalty = false, any_dry = false, any_xtc = false, any_ngram = false; + bool any_penalty = false, any_dry = false, any_xtc = false; bool any_topp = false, any_minp = false, any_typ = false, any_temp = false; for (int64_t i = 0; i < n_seq_; ++i) { const DeviceSampleParams& p = cur_stage_[i]; any_mask |= (p.flags & RAD_SP_MASK) != 0; any_penalty |= (p.flags & RAD_SP_PENALTY) != 0; any_dry |= (p.flags & RAD_SP_DRY) != 0; - any_xtc |= (p.flags & RAD_SP_XTC) != 0; - /* The pair plane is read directly, not through cur_stage_: it is per-step staging the - * LAST builder filled (build_step writes a row's pair, build_greedy zeroes every pair), - * so it agrees with cur_stage_ by builder contract. A new builder must keep that - * contract: stage the pair with the params, zero it with the greedy ones. */ - any_ngram |= ngram_stage_[2 * i] > 0; if (p.flags & RAD_SP_GREEDY) any_greedy = true; else { any_chain = true; /* sample_temp leaves a row at temperature <= 0 or exactly 1 as it is */ any_temp |= p.temp > 0.0f && p.temp != 1.0f; - any_topp |= p.top_p < 1.0f; - any_minp |= p.min_p > 0.0f; - any_typ |= p.typical_p < 1.0f; + /* The cuts only remove candidates, and a top-1 row has one: a greedy row over a split + * vocabulary or asking for logprobs, and every row of a drafter's greedy pass. Every + * implementation keeps it (top-p and min-p keep the best, typical keeps a lone + * candidate, XTC needs two above its threshold), so such a row issues none of them; + * nor does a top_p or typical_p outside (0, 1), which every kernel skips. A drafter's + * greedy pass under a split vocabulary, whose rows are zeroed, issued top-p and + * typical every round: two launches with a max and a sum over the candidate width a + * row, for nothing. */ + if (p.top_k != 1) { + any_topp |= p.top_p > 0.0f && p.top_p < 1.0f; + any_minp |= p.min_p > 0.0f; + any_typ |= p.typical_p > 0.0f && p.typical_p < 1.0f; + any_xtc |= (p.flags & RAD_SP_XTC) != 0; + } } } @@ -1115,6 +1138,13 @@ int Sampler::run(RadCtx* c, rad_buf logits, rad_buf out_tokens) { return RAD_E_STATE; } + /* The ban runs only for a build_step build in which some row's staged history holds a whole + * n-gram (any_ngram_; build_greedy clears it). A shorter one bans nothing, however the op is + * implemented, so neither the op nor its planes are issued for it. The pair plane is not + * scanned for a row with a positive n: a drafter's greedy build leaves it as the step staged + * it (see build_greedy). */ + const bool any_ngram = any_ngram_; + /* Async copies on the compute stream, only of what some row reads. The mask is 19 KiB per * constrained sequence at a 151K vocab, which keeps a host-side grammar affordable * (spec §13). */ diff --git a/core/sample/sampler.h b/core/sample/sampler.h index 73615bcf..682cabb3 100644 --- a/core/sample/sampler.h +++ b/core/sample/sampler.h @@ -106,6 +106,12 @@ struct SamplerConfig { int64_t max_seqs = 0; /* the largest number of sequences one step may carry */ int64_t max_hist = 2048; /* the penalty window bound; a longer request is truncated */ int max_spec = 0; + /* The step's token bound (--max-num-batched-tokens), 0 for none. A step samples one row per + * token it verifies or completes, and the model's logits rows are capped here too + * (rad_arch.h, max_logit_rows), so rows past it could never be staged; the planes are sized + * for min(max_seqs * (max_spec + 1), max(max_tok, max_seqs)). Never below max_seqs: a drafter + * pass stages one greedy row per sequence it drafts for (build_greedy). */ + int64_t max_tok = 0; int rank = 0; int world_size = 1; /* This rank's first vocabulary row. sample_topk adds it to the candidate ids it packs into @@ -218,6 +224,9 @@ public: * meaningful only where the row carries RAD_SP_MASK. */ const uint32_t* staged_mask(int64_t row) const { return mask_stage_ + row * mask_words_; } int64_t mask_words() const { return mask_words_; } + /* Staged row `row`'s n-gram ban pair {n, window}, as the last build_step staged it: a greedy + * build leaves it, since that step's upload may not have read it yet. */ + const int32_t* staged_ngram(int64_t row) const { return ngram_stage_ + 2 * row; } /* Staged row `row`'s bound coupled state, as `run` uploads it: all-zero where the row carries * none (bonus row, greedy row, uncoupled step). Lets a build be checked without a device. */ const RadMtpCoupleState& staged_couple(int64_t row) const { return couple_stage_[row]; } @@ -267,6 +276,9 @@ private: * inside the block. A grammar mask on the row wins: the close is forced only where the * grammar admits it, otherwise at a later position. */ void force_close(DeviceSampleParams& p, int64_t row, int32_t close); + /* Take `ids` out of the row: from the grammar's mask where it has one, from a full row where + * not. */ + void suppress(DeviceSampleParams& p, int64_t row, const std::vector& ids); SamplerConfig cfg_{}; const VocabView* vocab_ = nullptr; @@ -341,8 +353,9 @@ private: /* Whether any DRY row this step has breakers; only then is the breaker plane uploaded and * passed to sample_dry. */ bool any_brk_ = false; - /* Whether any row this step runs the n-gram ban. Its history is the plane the penalties use, - * so this only decides whether that plane is uploaded and the op issued. */ + /* Whether any row this step runs the n-gram ban over a history at least its n-gram long; a + * shorter one bans nothing. Its history is the plane the penalties use, so this only decides + * whether that plane is uploaded and the op issued. Cleared by build_greedy. */ bool any_ngram_ = false; /* Whether any banned row this step whitelists a column of this rank's shard; only then is * the exemption plane uploaded and passed to sample_ngram_ban. */ diff --git a/core/sched/advance.h b/core/sched/advance.h index dd221b9d..fdd09264 100644 --- a/core/sched/advance.h +++ b/core/sched/advance.h @@ -48,7 +48,11 @@ struct StepSlot { * drafter's context rows by it. 0 after a chain verify, which needs neither. */ int32_t npath; int32_t path[RAD_SCHED_MAX_SPEC]; - int32_t pad[2]; + /* The last verify step's row of its last committed position, in that step's own row order, + * which a block drafter's context pass mirrors. ADV_BLOCK hands it to the query pass + * (RadBatch::anchor_rows): LiLiCorr's correlator reads the context state there. */ + int32_t hrow; + int32_t pad[1]; }; enum AdvMode : int32_t { @@ -115,6 +119,7 @@ struct AdvanceArgs { int32_t n_groups = 0; char* slab = nullptr; /* this rank's device slab */ int64_t tok_off = 0, pos_off = 0, ctx_off = 0, acc_off = 0, out_off = 0; + int64_t arow_off = -1; /* [n_seq] ADV_BLOCK: each row's StepSlot::hrow; -1 when not carved */ int64_t sid_off = 0, cu_off = 0, q_off = 0; /* [4][row_pitch] int32: device-row flag; the verify step's token row of the row's first * verified position; its first sampled row, or -1 for a row that sampled nothing; and one diff --git a/core/sched/advance_impl.h b/core/sched/advance_impl.h index 55f84eb8..6b1699fe 100644 --- a/core/sched/advance_impl.h +++ b/core/sched/advance_impl.h @@ -153,6 +153,7 @@ RAD_ADV_FN void adv_row(const AdvanceArgs& a, int i) { S.ctx = head + 1; S.n_acc = acc + 1; S.tok[0] = y[acc == 0 ? 0 : S.path[acc - 1]]; + S.hrow = rtok + (acc == 0 ? 0 : S.path[acc - 1]); /* rows are nodes, in order */ S.npath = acc; return; } @@ -167,6 +168,7 @@ RAD_ADV_FN void adv_row(const AdvanceArgs& a, int i) { const int32_t head = ctx[i] + (rtok - k) + acc; S.acc = acc; S.head = head; + S.hrow = rtok + acc; S.ctx = head + 1; S.n_acc = acc + 1; S.tok[0] = y[acc]; @@ -296,6 +298,7 @@ RAD_ADV_FN void adv_row(const AdvanceArgs& a, int i) { for (int32_t j = 1; j < n; ++j) tok[k + j] = aux; for (int32_t j = 0; j < n; ++j) adv_pos(a, pos, k + j, base + j); ctx[i] = base; + if (a.arow_off >= 0) adv_i32(a, a.arow_off)[i] = S.hrow; adv_groups(a, i, k, base, n); return; } diff --git a/core/sched/batch.cpp b/core/sched/batch.cpp index 84a607eb..c4fde6a3 100644 --- a/core/sched/batch.cpp +++ b/core/sched/batch.cpp @@ -123,6 +123,7 @@ void BatchBuilder::carve(Set& s, char* h) { /* The advance's per-sequence runtime-window data (advance.h); 0 when there is none. */ pair(&s.h_rpos, &s.d_rpos, S); pair(&s.h_tlen, &s.d_tlen, S); + pair(&s.h_arow, &s.d_arow, S); s.h_grp = ::rad::carve(h, oh, (int64_t)s.groups.size()); s.d_grp = ::rad::carve(d, od, (int64_t)s.groups.size()); for (size_t gi = 0; gi < s.groups.size(); ++gi) { @@ -135,6 +136,7 @@ void BatchBuilder::carve(Set& s, char* h) { * moves a rotary position off the token index. */ pair(&s.h_rope, &s.d_rope, mm_on_ ? 3 * T : 0); pair(&s.h_mmrow, &s.d_mmrow, mm_on_ ? T : 0); + pair(&s.h_bidi, &s.d_bidi, bidi_on_ ? 4 * T : 0); /* Each row's adapter slot, carved only when the engine serves adapters, so an engine without * them lays the slab out as if the array did not exist. */ pair(&s.h_lora, &s.d_lora, lora_on_ ? T : 0); @@ -245,6 +247,7 @@ int BatchBuilder::alloc_set(Set& s, const std::vector& groups) { o.kv.assign(ranks_.size(), std::vector(s.groups.size())); o.stream.assign(ranks_.size(), std::vector(s.groups.size())); o.batch.assign(ranks_.size(), RadBatch{}); + o.kv_used_max_h.assign(s.groups.size(), 0); o.seqs.clear(); o.seqs.reserve((size_t)max_seqs_); /* a build fills it without allocating */ o.has_seqs = false; @@ -480,6 +483,7 @@ int BatchBuilder::layout(Program& prog, const Config& cfg) { }); mm_on_ = prog.encoder.modalities != 0 || prog.audio_encoder.modalities != 0; + bidi_on_ = prog.encoder.modalities != 0 && prog.encoder.bidirectional != 0; lora_on_ = cfg.lora.enabled(); pw_cap_ = prog.plugin_words; return RAD_OK; @@ -725,7 +729,13 @@ int BatchBuilder::build_groups(const StepPlan& plan, const IKVManager& kv, Set& first = kv.first_block_pos(e.seq, (int32_t)gi); has_win = kv.runtime_window(e.seq, (int32_t)gi, &win); if (has_win) { - assert(!ring_blocks || ring_blocks == (int32_t)win.ring_blocks); + /* The ring size sets the group header's geometry, so every sequence in the + * group must report the same one. */ + if (ring_blocks && ring_blocks != (int32_t)win.ring_blocks) { + RAD_ERR("kv group %d: sequences report ring sizes of %d and %d blocks", + (int)gi, (int)ring_blocks, (int)win.ring_blocks); + return RAD_E_STATE; + } ring_blocks = (int32_t)win.ring_blocks; } bt_len = (int64_t)bt.size(); @@ -808,6 +818,10 @@ int BatchBuilder::build_groups(const StepPlan& plan, const IKVManager& kv, Set& (int)g.sidx_pitch); } } + int32_t group_used = 0; + for (int64_t i = 0; i < n_seq; ++i) + group_used = std::max(group_used, g.h_used[i]); + o.kv_used_max_h[gi] = group_used; /* A state group's rows are one slot per sequence: n_seq words, restaged whole. */ if (!L.paged) { stage(g.bt_fix, np, n_seq); @@ -846,6 +860,7 @@ int BatchBuilder::build_groups(const StepPlan& plan, const IKVManager& kv, Set& b.block_table = on_rank(base, s.dev[0], g.d_bt); b.block_table_pitch = pitch; b.seqused = on_rank(base, s.dev[0], g.d_used); + b.seqused_h = g.h_used; b.state_index = on_rank(base, s.dev[0], g.d_sidx); b.state_index_pitch = g.sidx_pitch; b.block_size = L.block_size; @@ -933,6 +948,7 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv, int64_t n_out = 0, n_dout = 0; int32_t rope_mixed = 0; int64_t n_mm = 0; + int64_t n_bidi = 0; bool lora_rows = false; int32_t cvec_rows = 0; int64_t n_pw = 0; @@ -1022,6 +1038,23 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv, n_mm += got; } } + /* The part of each picture's or video frame's run inside this chunk, read both ways + * (RadBatch::n_bidi), on a trunk pass: its rows see the keys up to the run's end, or the + * chunk's where a run longer than any step was cut (Scheduler::bidi_fit). */ + if (bidi_on_ && plan.draft_pass == 0 && shift == 0 && e.req && e.req->media) { + const mm::PromptMedia& pm = *e.req->media; + const int64_t c0 = e.ctx_len, c1 = c0 + e.n_tokens, T = max_tok_; + for (const mm::RopeLayout::Run& run : pm.rope.runs) { + const int64_t a = std::max(run.tok, c0); + const int64_t b = std::min((int64_t)run.tok + run.n, c1); + if (a >= b || pm.items[(size_t)run.item].item->kind == mm::Kind::Audio) continue; + s.h_bidi[n_bidi] = (int32_t)b; + s.h_bidi[T + n_bidi] = (int32_t)(k + a - c0); + s.h_bidi[2 * T + n_bidi] = (int32_t)(b - a); + s.h_bidi[3 * T + n_bidi] = (int32_t)i; + ++n_bidi; + } + } if (e.ckpt_tok >= 0 && e.ckpt_slot >= 0) { /* checkpoint_tok indexes this step's tokens: the sequence's base plus the offset the * scheduler chose, the last token of a checkpoint interval (§7.3). */ @@ -1075,6 +1108,7 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv, s.h_q[i] = e.n_tokens; s.h_ctx[i] = e.ctx_len; s.h_acc[i] = e.n_accepted; + s.h_arow[i] = -1; if (e.is_prefill) { if (e.n_tokens > max_q_pf) max_q_pf = e.n_tokens; } else { if (e.n_tokens > max_q_dec) max_q_dec = e.n_tokens; } } @@ -1205,6 +1239,7 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv, B.n_seq = n_seq; B.token_ids = on_rank(base, b0, s.d_tok); B.positions = on_rank(base, b0, s.d_pos); + B.positions_h = s.h_pos; B.cu_seqlens = on_rank(base, b0, s.d_cu); B.seq_ids = on_rank(base, b0, s.d_sid); B.n_out = n_out; @@ -1220,6 +1255,7 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv, B.max_q_len_decode = max_q_dec; B.max_q_len_prefill = max_q_pf; B.max_ctx_len = (int32_t)ctx_bound; + B.kv_used_max_h = o.kv_used_max_h.data(); B.n_kv_groups = (int)o.kv[r].size(); B.kv = o.kv[r].data(); B.draft_pass = plan.draft_pass; @@ -1230,10 +1266,17 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv, B.num_accepted = cfg_.n_spec > 0 ? on_rank(base, b0, s.d_acc) : nullptr; /* Staged above on a tree step: each row's parent row, -2 for an ordinary causal one. */ B.spec_parent = plan.spec_is_tree ? on_rank(base, b0, s.d_parent) : nullptr; + /* Pass 1 is a block drafter's query pass (a serial head has no pass 1). */ + B.anchor_rows = plan.draft_pass == 1 ? on_rank(base, b0, s.d_arow) : nullptr; B.rope_pos = mm_on_ ? on_rank(base, b0, s.d_rope) : nullptr; B.rope_mixed = rope_mixed; B.n_mm_rows = n_mm; B.mm_rows = n_mm ? on_rank(base, b0, s.d_mmrow) : nullptr; + B.n_bidi = n_bidi; + B.bidi_used = n_bidi ? on_rank(base, b0, s.d_bidi) : nullptr; + B.bidi_row = n_bidi ? s.h_bidi + max_tok_ : nullptr; + B.bidi_n = n_bidi ? s.h_bidi + 2 * max_tok_ : nullptr; + B.bidi_seq = n_bidi ? s.h_bidi + 3 * max_tok_ : nullptr; B.mm_embd = n_mm ? mm_dev_[r] : nullptr; /* Null on a step with no adapter row: the core then issues no adapter op, and the step * runs the same pass as an engine serving no adapters. */ @@ -1309,6 +1352,7 @@ AdvanceArgs BatchBuilder::advance_args(int rank) const { a.ctx_off = off(s.d_ctx); a.acc_off = off(s.d_acc); a.out_off = off(s.d_out); + a.arow_off = off(s.d_arow); a.sid_off = off(s.d_sid); a.cu_off = off(s.d_cu); a.q_off = off(s.d_q); diff --git a/core/sched/batch.h b/core/sched/batch.h index 27c93c62..afb9b641 100644 --- a/core/sched/batch.h +++ b/core/sched/batch.h @@ -220,12 +220,19 @@ private: * runtime window (advance.h). Per sequence because each prompt has its own floor. */ int32_t *h_rpos = nullptr, *d_rpos = nullptr; int32_t *h_tlen = nullptr, *d_tlen = nullptr; + /* [max_seqs] a block drafter's query pass: each row's last committed row in the context + * pass just run (RadBatch::anchor_rows), written on the card by ADV_BLOCK. */ + int32_t *h_arow = nullptr, *d_arow = nullptr; char* h_derived = nullptr; /* derivation staging, byte-addressed */ /* [3][n_tok] rotary positions and [n_tok] encoder-row targets (RadBatch::rope_pos, * mm_rows): carved only when the program declared an encoder, empty otherwise. */ int32_t *h_rope = nullptr, *d_rope = nullptr; int32_t *h_mmrow = nullptr, *d_mmrow = nullptr; + /* [4][max_tok] the runs read both ways (RadBatch::n_bidi): their key counts (the one plane + * the device reads), first rows, rows and sequences; carved only when the program's + * encoder asks for them (RadEncoderDecl::bidirectional). */ + int32_t *h_bidi = nullptr, *d_bidi = nullptr; /* [n_tok] each row's runtime LoRA adapter slot (RadBatch::lora_slot): carved only when the * engine serves adapters, empty otherwise. */ int32_t *h_lora = nullptr, *d_lora = nullptr; @@ -265,6 +272,7 @@ private: /* Per rank and group, the RadKVStream a batch names: each rank's own copy, outside the slab. */ std::vector> stream; std::vector batch; + std::vector kv_used_max_h; /* The build's sequences in row order (step_seqs); none for an encoder pass. */ std::vector seqs; bool has_seqs = false; @@ -344,6 +352,7 @@ private: * (see RadBatch::mm_embd). The staging is refilled only after its last upload has run * (`mm_ev_`). */ bool mm_on_ = false; + bool bidi_on_ = false; /* RadEncoderDecl::bidirectional */ /* The engine serves runtime LoRA adapters (Config::lora): the batch carries each row's slot. */ bool lora_on_ = false; /* Program::plugin_words: the words a sequence may carry, 0 for none. */ diff --git a/core/sched/geometry.cpp b/core/sched/geometry.cpp index f185cd74..d052ae62 100644 --- a/core/sched/geometry.cpp +++ b/core/sched/geometry.cpp @@ -9,11 +9,13 @@ namespace rad { -/* lcm, with a non-positive side meaning "no constraint yet". */ +/* lcm, with a non-positive side meaning "no constraint yet". The sides are plugin-declared; an lcm + * past int64 saturates, so the quantum check refuses it rather than wrapping to a small one. */ static int64_t lcm64(int64_t a, int64_t b) { if (a <= 0) return b; if (b <= 0) return a; - return std::lcm(a, b); + const int64_t q = a / std::gcd(a, b); + return q > INT64_MAX / b ? INT64_MAX : q * b; } /* The op's sequence-chunk parameter, found by role (RAD_PROLE_SEQ_CHUNK) in its schema. Steps diff --git a/core/sched/scheduler.cpp b/core/sched/scheduler.cpp index 7968acc5..f14a3f3e 100644 --- a/core/sched/scheduler.cpp +++ b/core/sched/scheduler.cpp @@ -138,7 +138,14 @@ int Scheduler::init(Program& prog, const Config& cfg, IKVManager* kv, IPrefixCac "prompt unfinished while other sequences decode, the next %lld steps carry " "decode rows only and admit nothing", (long long)cfg.prefill_interleave, (long long)cfg.prefill_interleave); + else if (cfg.prefill_interleave < 0) + RAD_INFO("scheduler: --prefill-interleave auto: after a prefill chunk that leaves its " + "prompt unfinished while other sequences decode, decode-only steps follow for up " + "to %.2f of the chunk step's measured time (at most %lld steps)", + cfg.prefill_interleave_share, (long long)kInterleaveAutoMax); interleave_left_ = 0; + ema_chunk_s_ = 0.0; + ema_decode_s_ = 0.0; held_prefill_ = 0; draft_refill_ = 0; if (cfg.n_spec > 0 && prog.drafter.kind == RAD_DRAFT_BLOCK && prog.drafter.window > 0 && @@ -375,6 +382,11 @@ int Scheduler::add_locked(std::unique_ptr r) { s.arrived_us = mono_us(); s.first_tok_us = 0; s.preempted_us = 0; + /* A recycled slot keeps its struct, and the prefill figure is computed from admitted_us + * whenever it is non-zero: left standing, it would date this request's first token to the + * admission of whichever request held the slot before. The re-admission guard below needs + * it zero for the same reason -- a stale stamp would read as an earlier admission. */ + s.admitted_us = 0; s.slot = slot; s.card = -1; s.running = false; @@ -584,14 +596,11 @@ void Scheduler::trim_prefix_cache() { if (short_by > 0) (void)pc_->trim(short_by); } -void Scheduler::close_request(SchedReq& s, ReqState st, const char* reason, bool defer_free, - bool publish, int status, const char* why) { - ++step_finished_; - /* Publish before freeing: this is the only moment the whole prefix is both computed and still - * owned. insert() takes its own KV references, so the blocks survive the free below. Cancelled - * and failed requests are published too; their prompts were computed, and a client that hangs - * up mid-answer is likely to ask for that prefix again. */ - if (publish && cfg_.prefix_cache && pc_ && kv_->has_sequence(s.req->id) && +/* What a request computed, into the prefix cache, while it still owns the blocks: at its close, + * and at a preemption, whose recompute then adopts its prompt instead of computing it again. + * True when published. */ +bool Scheduler::publish_prefix(SchedReq& s) { + if (cfg_.prefix_cache && pc_ && kv_->has_sequence(s.req->id) && s.req->n_computed > 0 && !kv_->has_runtime_window(s.req->id)) { /* R-SWA: a sequence with a runtime window is not published (KVManager::set_window). Its * table is a reference plus a ring rather than a prefix from position 0, and the window @@ -613,8 +622,20 @@ void Scheduler::close_request(SchedReq& s, ReqState st, const char* reason, bool RAD_DEBUG("prefix cache: request %llu not published: %s", (unsigned long long)s.req->id, rad_strerror(rc)); trim_prefix_cache(); + return rc >= 0; } } + return false; +} + +void Scheduler::close_request(SchedReq& s, ReqState st, const char* reason, bool defer_free, + bool publish, int status, const char* why) { + ++step_finished_; + /* Publish before freeing: this is the only moment the whole prefix is both computed and still + * owned. insert() takes its own KV references, so the blocks survive the free below. Cancelled + * and failed requests are published too; their prompts were computed, and a client that hangs + * up mid-answer is likely to ask for that prefix again. */ + if (publish) (void)publish_prefix(s); if (cfg_.prefix_cache && pc_) pc_->release(*s.req); /* Prompt lookup's index is this text's alone. */ @@ -901,6 +922,8 @@ int Scheduler::requests_locked(ReqStat* out, int max) const { o.slot = s.slot; o.age_s = (double)(now - s.arrived_us) / 1e6; o.ttft_s = s.first_tok_us ? (double)(s.first_tok_us - s.arrived_us) / 1e6 : -1.0; + o.prefill_s = (s.first_tok_us && s.admitted_us) + ? (double)(s.first_tok_us - s.admitted_us) / 1e6 : -1.0; /* Since the first token, not admission, so time spent queued does not read as slow * decode. */ const double dec = s.first_tok_us ? (double)(now - s.first_tok_us) / 1e6 : 0.0; @@ -968,7 +991,7 @@ int64_t Scheduler::chunk_end(const Request& r, int64_t n_target) const { * so a chunk clamped to it is already aligned; in the other order a chunk past the checkpoint * would be rounded down and miss the boundary. */ int64_t Scheduler::plan_chunk(int64_t n_computed, int64_t n_target, int64_t budget, - int64_t* checkpoint_pos, int64_t keep_at) const { + int64_t* checkpoint_pos, int64_t keep_at, const Request* r) const { if (checkpoint_pos) *checkpoint_pos = -1; int64_t remaining = n_target - n_computed; if (remaining <= 0 || budget <= 0) return 0; @@ -1093,9 +1116,48 @@ int64_t Scheduler::plan_chunk(int64_t n_computed, int64_t n_target, int64_t budg if (checkpoint_pos && *checkpoint_pos > aligned) *checkpoint_pos = -1; } } + if (r) { + const int64_t fit = bidi_fit(*r, n_computed, n_target, want, budget); + /* A trimmed chunk keeps a window snapshot it still carries (as above); a grown one drops it. */ + if (fit != want && checkpoint_pos && (fit > want || *checkpoint_pos > n_computed + fit)) + *checkpoint_pos = -1; + want = fit; + } return want; } +/* A chunk that ended inside a run read both ways would give the run's rows of this chunk keys the + * next chunk writes. So it ends before the run, on a quantum (and before every run that lands in, + * as a video's frames do); a chunk that starts at or inside the run (nothing fits before it) runs + * to the run's end, rounded up to a quantum unless the sequence ends first, past every run that + * lands in, or waits for a step that holds that. A run no step holds is cut where the chunk falls, + * and its rows see the run up to the cut (RadBatch::bidi_used). */ +int64_t Scheduler::bidi_fit(const Request& r, int64_t n_computed, int64_t n_target, int64_t want, + int64_t budget) const { + if (!prog_ || !prog_->encoder.bidirectional || !r.media || want <= 0) return want; + const mm::PromptMedia& pm = *r.media; + const int64_t Q = std::max(geo_.quantum, 1); + /* The run read both ways that a chunk ending at `end` would cut, or null. */ + auto cut = [&](int64_t end) -> const mm::RopeLayout::Run* { + if (end >= n_target) return nullptr; + const mm::RopeLayout::Run* run = pm.rope.run_at(end); + if (!run || run->tok == end || pm.items[(size_t)run->item].item->kind == mm::Kind::Audio) + return nullptr; + return run; + }; + int64_t end = n_computed + want; + for (const mm::RopeLayout::Run* run = cut(end); run; run = cut(end)) { + const int64_t before = (int64_t)run->tok / Q * Q; + if (before <= n_computed) break; + end = before; + } + if (!cut(end)) return end - n_computed; + for (const mm::RopeLayout::Run* run = cut(end); run; run = cut(end)) + end = std::min(n_target, ((int64_t)run->tok + run->n + Q - 1) / Q * Q); + if (end - n_computed <= budget) return end - n_computed; + return end - n_computed > cfg_.max_tok ? want : 0; +} + /* The tail checkpoint of a `target`-token prompt, or -1. Under --prefix-resume exact, where its * last chunk starts (below). Under nearest, its last quantum boundary, only past the first * interval (a shorter prompt is cheap to redo) and only where it gains at least a quarter @@ -1215,14 +1277,44 @@ int64_t Scheduler::busy_cap(int64_t n_computed, int64_t n_target, int64_t budget return std::min(std::max(cap, Q), budget); } +/* ------------------------------------------------------------------ decode-only steps */ +/* How many decode-only steps follow a chunk that ran beside decoding sequences + * (--prefill-interleave). N as given; under auto, as many as fit in Config::prefill_interleave_share of a chunk + * step's measured time at a decode step's, so the prefill gives up at most a fifth of its rate + * (a quarter of a chunk step) however many sequences decode, and the decoders get the steps that + * share buys: several where decode steps are cheap beside the chunk, none where one costs more + * than a quarter of it (they still ride every chunk). One until both costs are measured, which + * takes the first decode-only step. Both are wall times read off step_finished, so under auto + * which steps carry a chunk follows the device's timing and differs from run to run; a number + * schedules the same steps every time. */ +void Scheduler::step_cost_locked(bool chunk, double seconds) { + double& ema = chunk ? ema_chunk_s_ : ema_decode_s_; + ema = ema > 0.0 ? ema + kInterleaveEma * (seconds - ema) : seconds; +} + +void Scheduler::note_step_cost(bool chunk, double seconds) { + std::lock_guard lk(mu_); + if (seconds > 0) step_cost_locked(chunk, seconds); +} + +int64_t Scheduler::interleave_steps() const { + if (cfg_.prefill_interleave >= 0) return cfg_.prefill_interleave; + if (ema_chunk_s_ <= 0.0 || ema_decode_s_ <= 0.0) return 1; + const double n = cfg_.prefill_interleave_share * ema_chunk_s_ / ema_decode_s_; + return n >= (double)kInterleaveAutoMax ? kInterleaveAutoMax : (int64_t)n; +} + /* ------------------------------------------------------------------ preemption */ -void Scheduler::preempt_back() { +bool Scheduler::preempt_back() { int32_t slot = running_.back(); SchedReq& s = *reqs_[(size_t)slot]; Request& r = *s.req; /* Preemption by recompute: the blocks go back and the request restarts from zero. Its output - * is the tail of its token sequence, so it simply re-prefills prompt ++ output. */ + * is the tail of its token sequence, so it simply re-prefills prompt ++ output. What it computed + * is published first: the recompute adopts it from the cache, and under pressure the cache gives + * the blocks back (the newest entries last). */ + const bool published = publish_prefix(s); kv_->preempt(r.id); drop_card(s); r.n_computed = 0; @@ -1242,6 +1334,7 @@ void Scheduler::preempt_back() { running_.pop_back(); queue_insert(waiting_, slot); /* original arrival -> the front of its priority class */ ++m_.preemptions; + return published; } /* ------------------------------------------------------------------ admission */ @@ -1319,6 +1412,7 @@ int Scheduler::admit_one(SchedReq& s, int64_t budget, int64_t reserve) { const RestoreResult rr = pc_->restore(r, whole_only); if (rr == RestoreResult::Declined) { s.restore_waited = true; + admit_next_step_ = true; RAD_DEBUG("admit %llu: the restore waits a step for %d deferred release(s)", (unsigned long long)r.id, n_deferred_); return RAD_E_FULL; @@ -1471,9 +1565,12 @@ int Scheduler::admit_one(SchedReq& s, int64_t budget, int64_t reserve) { * to what really has to run. */ const int64_t cap = busy_cap(r.n_computed, target, budget, reserve, !plan_.e.empty()); const int64_t end = chunk_end(r, target); - want = plan_chunk(r.n_computed, end, cap, &ckpt, r.checkpoint_at); - if (cap < budget && want > 0) - admit_full_ = plan_chunk(r.n_computed, end, budget, nullptr, r.checkpoint_at); + want = plan_chunk(r.n_computed, end, cap, &ckpt, r.checkpoint_at, &r); + /* A run read both ways (bidi_fit) the share cannot hold takes the step instead. */ + if (want <= 0 && cap < budget && prog_->encoder.bidirectional) + want = plan_chunk(r.n_computed, end, budget, &ckpt, r.checkpoint_at, &r); + else if (cap < budget && want > 0) + admit_full_ = plan_chunk(r.n_computed, end, budget, nullptr, r.checkpoint_at, &r); } int rc = RAD_OK; if (want <= 0) rc = RAD_E_FULL; @@ -1522,6 +1619,8 @@ int Scheduler::admit_one(SchedReq& s, int64_t budget, int64_t reserve) { if (s.card < 0) { s.card = free_cards_.back(); free_cards_.pop_back(); } r.state = ReqState::Running; + if (!s.admitted_us) s.admitted_us = mono_us(); /* first admission; a re-admit after + * preemption keeps the original stamp */ s.preempted_us = 0; s.running = true; server::sink_admitted(r.sink); @@ -1552,6 +1651,9 @@ void Scheduler::undo_hit(SchedReq& s) { bool Scheduler::preempted_can_prefill(const SchedReq& s) const { const Request& r = *s.req; const int64_t target = s.seq_len(); + /* What the recompute adopts from the cache (its own prefix, published at the preemption) needs + * no new block. */ + const int64_t hit = (cfg_.prefix_cache && pc_) ? pc_->lookup(r, nullptr, nullptr).n_attn_tokens : 0; for (size_t g = 0; g < kvgeom_.g.size(); ++g) { const KVGeom::G& gg = kvgeom_.g[g]; @@ -1559,7 +1661,7 @@ bool Scheduler::preempted_can_prefill(const SchedReq& s) const { * wanted the whole prompt from a pool of none and kept a preempted request out for good. */ if (!gg.paged || kv_->total_blocks((int32_t)g) <= 0) continue; int64_t need = (target + gg.block_size - 1) / gg.block_size - - (int64_t)kv_->block_table(r.id, (int32_t)g).size(); + (int64_t)kv_->block_table(r.id, (int32_t)g).size() - hit / gg.block_size; if (need < 0) need = 0; for (int32_t slot : running_) { const SchedReq& rs = *reqs_[(size_t)slot]; @@ -1692,7 +1794,7 @@ const RadBatch* Scheduler::step() { running_.erase(std::find(running_.begin(), running_.end(), victim)); running_.push_back(victim); } - preempt_back(); + if (preempt_back()) evict_rounds = 0; /* its blocks stay in the cache: evict them first */ } } @@ -1704,7 +1806,7 @@ const RadBatch* Scheduler::step() { bool any_decoding = false; bool hold_prefill = false; held_prefill_ = 0; - if (cfg_.prefill_interleave > 0) { + if (cfg_.prefill_interleave != 0) { for (int32_t slot : running_) { const SchedReq& s = *reqs_[(size_t)slot]; if (!s.req || !s.running) continue; @@ -1820,10 +1922,13 @@ const RadBatch* Scheduler::step() { const int64_t cap = busy_cap(r.n_computed, target, budget, reserve, !plan_.e.empty(), /*rows_only=*/shares == 0); const int64_t end = chunk_end(r, target); - want = plan_chunk(r.n_computed, end, cap, &ckpt, r.checkpoint_at); - if (cap < budget && want > 0 && capped_at < 0) { + want = plan_chunk(r.n_computed, end, cap, &ckpt, r.checkpoint_at, &r); + /* A run read both ways (bidi_fit) the share cannot hold takes the step instead. */ + if (want <= 0 && cap < budget && prog_->encoder.bidirectional) + want = plan_chunk(r.n_computed, end, budget, &ckpt, r.checkpoint_at, &r); + else if (cap < budget && want > 0 && capped_at < 0) { const int64_t full = plan_chunk(r.n_computed, end, budget, nullptr, - r.checkpoint_at); + r.checkpoint_at, &r); if (want < full) { capped_at = (int32_t)plan_.e.size(); capped_full = full; } } /* A prefill with no room left does not end the walk: it takes nothing this step, but @@ -1910,7 +2015,9 @@ const RadBatch* Scheduler::step() { /* The back of the running set gives its blocks up. When that is this request, the * requests ahead of it hold the pool: it is preempted by recompute and waits for * them, rather than failed. */ - preempt_back(); + /* A victim that published keeps its blocks in the cache: eviction gets its rounds + * back, so they are reclaimed before anyone else is preempted. */ + if (preempt_back()) evict_rounds = 0; preempted_here = true; if (last) { yielded = true; break; } } @@ -2001,13 +2108,28 @@ const RadBatch* Scheduler::step() { (int64_t)plan_.e.size() + 1 < cfg_.max_seqs && free_cards_.size() > 1 ? share_tok : 0; admit_full_ = 0; + admit_next_step_ = false; const int as = admit_one(s, budget, areserve); - if (as == kAdmitWait) { ++at; continue; } + /* A preempted request waiting for its whole-recompute gate lets the next one be asked; + * an overdue one does not. The room the overdue path made this step is for it, and a + * request queued behind it would take that room back: a victim just forced off for it, + * its prompt published, needs almost nothing to come back, and under KV pressure the + * same victim was forced off and re-admitted 26 times in 16 s while the overdue request + * waited. */ + if (as == kAdmitWait) { + if (s.req->state == ReqState::Preempted && preempt_wait_overdue(s)) break; + ++at; + continue; + } /* An overdue preempted prefill on an idle engine that still cannot be admitted will * not become admissible by waiting: nothing is running to finish and free the pool. - * Fail it (spec §17) and ask the next request, instead of parking the step loop. */ - if (as < 0 && running_.empty() && s.req && s.req->state == ReqState::Preempted && - preempt_wait_overdue(s)) { + * Fail it (spec §17) and ask the next request, instead of parking the step loop. Not + * when this step admitted someone ahead of it (the budget or a card went to them) or + * the refusal is a restore waiting a step for deferred releases: both clear by the + * next step, and failing them lost two of ten preempted requests under KV pressure + * once their prompts were published at the preemption (1. 11. 2026). */ + if (as < 0 && running_.empty() && plan_.e.empty() && !admit_next_step_ && s.req && + s.req->state == ReqState::Preempted && preempt_wait_overdue(s)) { RAD_WARN("request %llu failed: overdue preempted prefill could not be admitted " "with nothing running (%s)", (unsigned long long)s.req->id, rad_strerror(as)); @@ -2081,7 +2203,7 @@ const RadBatch* Scheduler::step() { if (cfg_.busy_prefill_chunk > 0) limit = std::min(limit, std::max(had, cfg_.busy_prefill_chunk)); int64_t ckpt = -1; const int64_t grown = e.ckpt_slot < 0 && limit > had - ? plan_chunk(r.n_computed, chunk_end(r, s.seq_len()), limit, &ckpt, r.checkpoint_at) + ? plan_chunk(r.n_computed, chunk_end(r, s.seq_len()), limit, &ckpt, r.checkpoint_at, &r) : had; if (grown > had && kv_->ensure_from(r.id, r.n_computed + grown, r.n_computed) >= 0) { e.n_tokens = (int32_t)grown; @@ -2135,13 +2257,13 @@ const RadBatch* Scheduler::step() { case RAD_PHASE_MIXED: ++m_.steps_mixed; break; default: ++m_.steps_decode; break; } - if (cfg_.prefill_interleave > 0) { + if (cfg_.prefill_interleave != 0) { /* Armed only while a prompt continues past this step: after a last chunk nothing is left * to interleave, and holding would only keep the next request out. */ bool continues = false; for (const StepEntry& e : plan_.e) if (e.is_prefill && !e.produces_token) continues = true; - if (any_pf) interleave_left_ = any_decoding && continues ? cfg_.prefill_interleave : 0; + if (any_pf) interleave_left_ = any_decoding && continues ? interleave_steps() : 0; else if (interleave_left_ > 0) --interleave_left_; if (held_prefill_ > 0) ++m_.steps_held; } @@ -2562,7 +2684,14 @@ int Scheduler::commit(StepResult& res) { /* Not while a step issued ahead writes past `valid`; that step's commit rolls back to * the end it reaches. */ if (a < e.n_spec && !(next_open_ && s.entry_next >= 0)) { +#ifdef RAD_ENABLE_KV_ROLLBACK_TEST_HOOK + if (kv_rollback_test_hook_) kv_rollback_test_hook_(r.id, e.n_spec, a, valid, true); +#endif int st = kv_->rollback(r.id, valid); +#ifdef RAD_ENABLE_KV_ROLLBACK_TEST_HOOK + if (st >= 0 && kv_rollback_test_hook_) + kv_rollback_test_hook_(r.id, e.n_spec, a, valid, false); +#endif if (st < 0) RAD_WARN("kv rollback for request %llu: %s", (unsigned long long)r.id, rad_strerror(st)); } @@ -2736,6 +2865,9 @@ void Scheduler::step_finished() { /* The window ages by all elapsed time, idle included; only the busy part is added as time the * tokens took. */ const double aged = std::chrono::duration(step_end - last_step_at_).count(); + /* --prefill-interleave auto's two step costs (interleave_steps). */ + if (wall > 0 && cfg_.prefill_interleave < 0) + step_cost_locked(plan_.phase != RAD_PHASE_DECODE, wall); if (wall > 0) { constexpr double kWindowS = 1.0; const double f = std::exp(-aged / kWindowS); diff --git a/core/sched/scheduler.h b/core/sched/scheduler.h index c8c5ef9d..9c105dce 100644 --- a/core/sched/scheduler.h +++ b/core/sched/scheduler.h @@ -19,6 +19,9 @@ #include "ngram.h" #include +#ifdef RAD_ENABLE_KV_ROLLBACK_TEST_HOOK +#include +#endif #include #include #include @@ -42,6 +45,9 @@ struct SchedReq { /* Wall clock, for the live request table; `arrival` is a counter and cannot measure time. */ int64_t arrived_us = 0; int64_t first_tok_us = 0; /* 0 until the first output token: this request's TTFT */ + int64_t admitted_us = 0; /* 0 until the first admission: where the queue ends, so a + * prefill rate can divide by the prefill alone. ttft covers + * the wait for admission (GUIDE); this excludes it. */ int64_t preempted_us = 0; /* when this state became Preempted; 0 otherwise. Bounds the * whole-recompute admission wait (--preempt-wait-ms). */ @@ -274,6 +280,7 @@ public: int32_t slot = -1; double age_s = 0; double ttft_s = -1; /* negative until the first token */ + double prefill_s = -1; /* first token minus admission; negative until both */ double decode_tps = 0; /* this request's own, since its first token */ }; /* Oldest first, since the oldest is the one most likely stuck. Returns how many were @@ -463,7 +470,15 @@ public: * token budget, and the checkpoint position it will land on (-1 for none). `keep_at` is the * request's own checkpoint (Request::checkpoint_at), 0 for none. */ int64_t plan_chunk(int64_t n_computed, int64_t n_target, int64_t budget, - int64_t* checkpoint_pos, int64_t keep_at = 0) const; + int64_t* checkpoint_pos, int64_t keep_at = 0, + const Request* r = nullptr) const; + /* Visible for tests: `want` tokens of `r` from `n_computed` cut so the chunk ends inside no run + * the language model reads both ways (RadEncoderDecl::bidirectional): before the run on a + * quantum, or at its end when the chunk starts in it and `budget` holds that, else 0. A run + * longer than any step keeps the cut where it falls. `want` unchanged for a program with no + * such runs. */ + int64_t bidi_fit(const Request& r, int64_t n_computed, int64_t n_target, int64_t want, + int64_t budget) const; /* The smallest step the prefill stager overlaps, in tokens (0 = no stager), set once by the * engine after init. --busy-prefill-chunk keeps a held-back chunk at or above it (busy_cap). @@ -489,8 +504,21 @@ public: * multi-token chunk past the floor would overwrite keys its own earlier rows still read, while * one token a step attends as its decode step did. Otherwise `n_target`. */ int64_t chunk_end(const Request& r, int64_t n_target) const; + /* --prefill-interleave: the decode-only steps that follow a chunk run beside decoding + * sequences. N as configured; under auto, from the measured step costs (see the definition). + * Visible for tests, as is note_step_cost, which feeds auto a step's wall time as + * step_finished does: `chunk` for a step that carried a prefill chunk, else a decode step. */ + int64_t interleave_steps() const; + void note_step_cost(bool chunk, double seconds); private: +#ifdef RAD_ENABLE_KV_ROLLBACK_TEST_HOOK + friend class Engine; + /* Test-build-only observer at the concrete rollback operation. */ + void set_kv_rollback_test_hook(std::function hook) { + kv_rollback_test_hook_ = std::move(hook); + } +#endif Program* prog_ = nullptr; Config cfg_{}; ChunkGeometry geo_{}; @@ -503,11 +531,15 @@ private: int64_t span_min_ = 0; /* Set by admit_one when it held the admitted chunk back: what it would have taken. */ int64_t admit_full_ = 0; + bool admit_next_step_ = false; /* admit_one's refusal is a wait for the next step */ /* Whether this step's prefill may span (ChunkGeometry::span): set by step() for the step it * plans, true only for a prefill alone in its step, and read by plan_chunk. True outside a * step, so plan_chunk called directly answers for a span. */ bool span_now_ = true; IKVManager* kv_ = nullptr; +#ifdef RAD_ENABLE_KV_ROLLBACK_TEST_HOOK + std::function kv_rollback_test_hook_; +#endif IPrefixCache* pc_ = nullptr; /* Does a prefix-cache hit leave a hole in a block drafter's own KV? Only if some paged group @@ -748,6 +780,13 @@ private: * the hold is spent, or the chunk would wait as long as the decoders keep stepping ahead. */ int64_t interleave_left_ = 0; int64_t held_prefill_ = 0; + /* --prefill-interleave auto: the decode-only steps after a chunk (interleave_steps), sized by + * the running means of a step that carried a chunk and of a decode step, in seconds, fed by + * step_finished. */ + static constexpr double kInterleaveEma = 0.25; + static constexpr int64_t kInterleaveAutoMax = 64; + double ema_chunk_s_ = 0.0, ema_decode_s_ = 0.0; + void step_cost_locked(bool chunk, double seconds); /* The throughput window (step_finished): each kind's tokens and the wall time the steps * covered, both decayed with the same time constant, so their ratio is tokens over time. */ double tps_win_prefill_ = 0.0, tps_win_decode_ = 0.0, tps_win_time_ = 0.0; @@ -796,7 +835,8 @@ private: const Request* serial_req(const SerialSeq& m) const; /* Both snapshots resolve the same way; the two wrappers exist because the row types differ. */ const Request* live_req(int32_t slot, uint64_t id) const; - void preempt_back(); + bool preempt_back(); /* true: the victim published its prefix */ + bool publish_prefix(SchedReq& s); /* A preempted request waits until the pool can hold its WHOLE remaining recompute, the rest * of every running prefill, and one block of headroom per runner. Admitting it against only * the next token steals the blocks a running prefill still needs and preempt_back() resets diff --git a/core/server/adapters.h b/core/server/adapters.h index f7ff20b5..ce654427 100644 --- a/core/server/adapters.h +++ b/core/server/adapters.h @@ -311,6 +311,7 @@ public: o.slot = r.slot; o.age_s = r.age_s; o.ttft_s = r.ttft_s; + o.prefill_s = r.prefill_s; o.decode_tps = r.decode_tps; out->push_back(std::move(o)); } diff --git a/core/server/admin.cpp b/core/server/admin.cpp index 8e6969b9..de2e8134 100644 --- a/core/server/admin.cpp +++ b/core/server/admin.cpp @@ -390,7 +390,7 @@ json Server::capabilities() const { caps["reasoning"] = !rerank && deps_.chat && deps_.chat->supports_reasoning(); /* An image model reads pictures only for edits and writes no text a grammar could constrain, * whatever its conditioning network's processor would take. */ - const bool img = opt_.image_model || opt_.video_model; + const bool img = opt_.image_model || opt_.video_model || opt_.shape_model; caps["grammar"] = !img && !rerank && deps_.grammar != nullptr; /* Laya runs on the embedding path, but answers /v1/systemone, not /v1/embeddings. */ caps["embedding"] = deps_.embed != nullptr && !rerank && opt_.decision_type != "laya"; @@ -403,11 +403,13 @@ json Server::capabilities() const { caps["image_edit"] = deps_.images != nullptr && deps_.images->info().max_refs > 0; caps["audio_generation"] = deps_.audio != nullptr; caps["video_generation"] = deps_.videos != nullptr; + caps["shape_generation"] = deps_.shapes != nullptr; /* The decision protocol /v1/systemone serves (ServerOptions::decision_type), so a proxy can * route to a decision model without trying a generation; null when it serves none. */ caps["decision"] = opt_.decision_type.empty() ? json(nullptr) : json(opt_.decision_type); /* What a video request may carry. */ if (deps_.videos) video_caps(caps, deps_.videos); + if (deps_.shapes) shape_caps(caps, deps_.shapes); /* The efforts a chat request may send, probed from the template at startup; null when it * takes any word. "none" and "minimal" are this server's and turn thinking off. */ if (lim_.reasoning_efforts.empty()) { diff --git a/core/server/dashboard.cpp b/core/server/dashboard.cpp index 3510e60a..c132cf0f 100644 --- a/core/server/dashboard.cpp +++ b/core/server/dashboard.cpp @@ -385,6 +385,7 @@ HttpResponse Server::handle_stats(const HttpRequest&) { j["slot"] = q.slot; j["age_s"] = q.age_s; if (q.ttft_s >= 0) j["ttft_s"] = q.ttft_s; + if (q.prefill_s >= 0) j["prefill_s"] = q.prefill_s; j["tps"] = q.decode_tps; reqs.push_back(std::move(j)); } @@ -586,6 +587,18 @@ h1 { margin:0; font-size:13.5px; font-weight:600; letter-spacing:-.005em; } .cap { font-size:10.5px; font-weight:600; letter-spacing:.1em; text-transform:uppercase; color:var(--dim); } .aside { font-family:var(--mono); font-size:11.5px; color:var(--dim); } +/* A panel header's left side can hold a title plus a control; the header itself is + * space-between, so without this group the control would land in the middle. */ +.pleft { display:flex; align-items:baseline; gap:9px; } +.pbtn { background:none; border:0; padding:0; margin:0; color:var(--faint); cursor:pointer; + display:inline-flex; align-items:center; } +.pbtn:hover { color:var(--fg); } +.pbtn:focus-visible { outline:1px solid var(--edge); outline-offset:3px; } +/* The glyph is nudged down 2px so the tray bar's bottom lines up with the bottom of the + * caption's letters. align-items:baseline puts the SVG's BOX on the text baseline, but the + * baseline sits above the box bottom, so the bar floated ~2px high -- measured in headless + * Chrome, not eyeballed. The viewBox-flush geometry alone does not fix this. */ +#reqjson svg { transform: translateY(2px); } .pbody { padding:14px 16px 16px; } /* The control vector's switch: a checkbox row with its explanation under it. The two need a gap @@ -595,6 +608,13 @@ h1 { margin:0; font-size:13.5px; font-weight:600; letter-spacing:-.005em; } .cvrow { display:flex; align-items:center; gap:8px; } #cvnote { margin-top:9px; padding-left:4px; } +.pollrow { display:flex; align-items:center; gap:10px; font-size:13px; color:var(--fg); } +.pollrow + .pollnote { margin-top:6px; } +.pollnote { max-width:74ch; } +.pollrow input[type=number] { width:11ch; font:400 15px/1.4 var(--mono); color:var(--fg); + background:var(--track); border:1px solid var(--edge); + border-radius:5px; padding:7px 10px; } + /* ------------------------------------------------ THE FIRST ROW IS FIXED, THE REST FIT THEIR CONTENT A card whose content changes LENGTH moves every card under it while it is being read, and one card here does that every poll: the list of requests gains and loses rows. So the first row -- @@ -734,6 +754,12 @@ th + th, td + td { padding-left:14px; } margin-top:14px; padding-top:12px; border-top:1px solid var(--rule); } #hist .hhead { display:flex; align-items:baseline; gap:10px; margin-bottom:8px; } #hist .hsum { flex:1; font-family:var(--mono); font-size:11px; color:var(--dim); line-height:1.5; } +/* Each category is one atomic unit: if it cannot fit on the line it moves whole, rather than + * breaking mid-figure and orphaning a unit -- "810" at the end of one line, "ms" on the next. + * The separator is its own element with padding because HTML collapses runs of spaces, so + * spacing in the string could never have widened the category break. */ +#hist .hgrp { white-space:nowrap; } +#hist .hsep { color:var(--faint); padding:0 9px; } #hist .hbtn { font-family:var(--mono); font-size:10px; color:var(--faint); cursor:pointer; user-select:none; padding:0 4px; } #hist .hbtn:hover { color:var(--bad); } @@ -1167,6 +1193,7 @@ nav button.on { color:var(--fg); background:var(--track); } + @@ -1212,7 +1239,17 @@ nav button.on { color:var(--fg); background:var(--track); }
-
Requests +
Requests +
@@ -1224,8 +1261,7 @@ nav button.on { color:var(--fg); background:var(--track); }
history - - json + clear
@@ -1359,6 +1395,25 @@ nav button.on { color:var(--fg); background:var(--track); } + + + @@ -1477,7 +1532,7 @@ $("key").addEventListener("change", (e) => { * tab is left and re-opened. */ loadControlVector(); }); -const HIST = 120; /* 60s of history at the 500ms poll */ +const HIST_S = 60; /* the sparkline's window in SECONDS: the span it draws and prunes to */ const el = (t, c, x) => { const e = document.createElement(t); if (c) e.className = c; if (x !== undefined) e.textContent = x; @@ -1594,6 +1649,10 @@ const stepTime = (ms) => !finite(ms) ? { n: DASH, u: "ms" } /* The caption and the unit live in the document beside the cell they label. Holding a second * copy of them here would be holding a copy that can differ. */ const METRICS = ["step", "decode", "prefill", "flight", "kv", "accept"]; +/* One monotonic stamp per poll: every ring is pruned and drawn against it, so a window means + * the same span of seconds whatever interval the browser polls at. performance.now() so a wall + * clock adjustment cannot stretch or shrink a window. */ +let nowS = 0; const M = {}, hist = {}; for (const k of METRICS) { hist[k] = []; @@ -1608,9 +1667,10 @@ for (const k of METRICS) { * rare spike owns the box and the typical variation is squeezed into a pixel. A spike past the * 95th draws pinned to the top; the number above carries the level and the detail line the * extremes. The stroke is 1.25 units wide, so a one-unit inset keeps it off the edge. */ -function spark(key, vals) { +function spark(key, pts) { const s = M[key], w = 200, h = 22; - if (vals.length < 3) { s.line.setAttribute("d", ""); return; } + if (pts.length < 3) { s.line.setAttribute("d", ""); return; } + const vals = pts.map(p => p.v); const q = (sorted, p) => sorted[Math.min(sorted.length - 1, Math.floor(p * (sorted.length - 1)))]; const sorted = [...vals].sort((a, b) => a - b); let lo = q(sorted, 0.05), hi = q(sorted, 0.95); @@ -1618,18 +1678,28 @@ function spark(key, vals) { * extremes then serve, so the spikes still show. */ if (!(hi > lo)) { lo = sorted[0]; hi = sorted[sorted.length - 1]; } const span = hi - lo; - const dx = w / (vals.length - 1); + /* X IS TIME, NOT SAMPLE INDEX. Index spacing is only honest while every sample is the same age + * apart; once the poll rate varies -- adaptive, or a browser throttling a busy tab -- a busy + * stretch of 100 ms samples would be drawn five times wider than the seconds it took. The newest + * sample sits on the right edge and the window spans HIST_S back from it, so a stretch gets the + * room its seconds deserve and a gap in the samples shows as a gap in the line. */ + const t1 = pts[pts.length - 1].t; let d = ""; - for (let i = 0; i < vals.length; i++) { + for (let i = 0; i < pts.length; i++) { let t = span > Math.abs(hi) * 1e-3 ? (vals[i] - lo) / span : 0.5; if (t < 0) t = 0; else if (t > 1) t = 1; - d += (i ? "L" : "M") + (i * dx).toFixed(1) + "," + (h - 1 - (h - 2) * t).toFixed(1); + const x = Math.min(w, Math.max(0, w * (1 - (t1 - pts[i].t) / HIST_S))); + d += (i ? "L" : "M") + x.toFixed(1) + "," + (h - 1 - (h - 2) * t).toFixed(1); } s.line.setAttribute("d", d); } function setMetric(key, value, text) { M[key].n.firstChild.nodeValue = text; - if (value != null) { hist[key].push(value); if (hist[key].length > HIST) hist[key].shift(); } + if (value != null) { + const r = hist[key]; + r.push({ t: nowS, v: value }); + while (r.length && r[0].t < nowS - HIST_S) r.shift(); + } spark(key, hist[key]); } @@ -1637,8 +1707,9 @@ function setMetric(key, value, text) { * publishes a floor and a recent window only for the decode step; for these it publishes one * figure per poll, so the three figures are the page's own: * best / highest - the extreme this page has seen at the current concurrency; it resets on - * reload, not on a server restart. "highest" where more is not better. - * recent - the mean of the last RECENT samples at that concurrency. + * reload AND on a server restart (a new started_at runs newEngineRun()). + * "highest" where more is not better. + * recent - the mean of the last RECENT_S seconds at that concurrency. * now - the current value as a percentage of that extreme. * Figures are kept per concurrency ("@cN" past one), because a batched rate read against the * single-stream best reports a batch arriving as a level change. Requests in flight keeps one @@ -1647,28 +1718,44 @@ function setMetric(key, value, text) { * without a now clause. There is no ~99 cap as on the decode step: the extreme comes from the * same series as `now`, so 100% is exact. * - * RECENT is shorter than the sparkline's 60 s: a 60 s mean still shows a burst long after the lane + * RECENT_S is shorter than the sparkline's HIST_S: a 60 s mean still shows a burst long after the lane * went quiet, and 15 s decays within a quarter-minute while still tracking the mean mid-burst. * Prefill's window is 5 s, so `recent` follows a prefill of several seconds while it runs instead * of diluting it; the engine's prefill rate is itself already windowed. */ -const RECENT = 30; /* 15 s at the 500 ms poll for a figure sampled every poll; acceptance is - sampled only on polls that drafted, so its 30 samples can span minutes */ -const RECENT_PREFILL = 10; /* 5 s */ -const extAt = {}, winAt = {}; -let lastActiveC = 0; +const RECENT_S = 15; /* the `recent` window in seconds, for a figure sampled every poll */ +const RECENT_PREFILL_S = 5; /* prefill's is shorter, so a several-second prefill shows up in it */ +const extAt = {}, winAt = {}, extAtS = {}; /* extAtS: the poll at which each extreme was set */ +let lastActiveC = 0, lastStart = null; +/* A new engine process is a different discontinuity from a quiet minute: the previous run's + * requests are gone and its configuration may differ, so nothing from it carries over. Every + * other figure already refuses to pool across a restart -- accWindow drops its rings, histIngest + * resets its base -- and the session extremes are no different, since a best from a run that no + * longer exists is not this lane's best. */ +function newEngineRun() { + resetWindows(); + for (const k in extAt) delete extAt[k]; + for (const k in extAtS) delete extAtS[k]; +} /* Whether the server streams its KV (--kv-resident). Settled at bringup, so it cannot change under * a running page: the cells that name a memory tier read it instead of guessing. */ let kvStreamOn = false; /* `win` false records the extreme only: acceptance pools its window in accPool and reads only * `highest` from extAt. */ -function noteSample(key, c, value, cap, win) { +function noteSample(key, c, value, capS, win) { if (value == null || !finite(value)) return; const e = extAt[key] || (extAt[key] = {}); - if (!(c in e) || value > e[c]) e[c] = value; + if (!(c in e) || value > e[c]) { + e[c] = value; + /* When the extreme was set, so a figure that outlives its window can say how old it is. */ + const t = extAtS[key] || (extAtS[key] = {}); + t[c] = nowS; + } if (win === false) return; const w = winAt[key] || (winAt[key] = {}); const s = w[c] || (w[c] = []); - s.push(value); if (s.length > (cap || RECENT)) s.shift(); + const lim = capS || RECENT_S; + s.push({ t: nowS, v: value }); + while (s.length && s[0].t < nowS - lim) s.shift(); } function triple(key, c, label, fmt, showNow) { /* `recent` is a window mean: a window maximum would equal `best` on any steady lane. */ @@ -1676,16 +1763,30 @@ function triple(key, c, label, fmt, showNow) { if (!e || !(c in e)) return ""; /* A bucket whose extreme is zero still renders (requests in flight before the first request); * only the `now` clause needs a nonzero extreme to divide by. */ - const s = winAt[key][c]; - let sum = 0; - for (const v of s) sum += v; - const recent = sum / s.length; - const now = s[s.length - 1]; + /* The extreme is a property of the session and outlives a cleared window (a gap, a restart); + * `recent` and `now` are properties of the window, so they are dropped until it fills again. + * Rendering the extreme alone keeps the line's one surviving figure rather than blanking it. */ + const s = (winAt[key] || {})[c]; const tag = typeof c === "number" && c > 1 ? "@c" + c : ""; - let out = label + " " + fmt(e[c]) + " · recent " + fmt(recent); + let out = label + " " + fmt(e[c]); + if (!s || !s.length) { + /* The extreme outlives the window by design, so the age is what makes it honest: without it a + * figure from before a gap -- or from before an engine restart, which the page treats as a + * discontinuity everywhere else -- reads as the lane's current best. */ + const t = (extAtS[key] || {})[c]; + /* Only once it is actually stale: an extreme set on this poll is current, and "0 ms ago" + * would be noise. A second is the resolution dur() itself reports below. */ + if (typeof t === "number" && nowS - t >= 1) out += " | " + dur(nowS - t) + " ago"; + return out; + } + let sum = 0; + for (const p of s) sum += p.v; + const recent = sum / s.length; + const now = s[s.length - 1].v; + out += " | recent " + fmt(recent); /* No `now` clause while nothing runs, as on the decode step: a zero rate is an idle lane, and * "now 0% of best" would read as a fault. */ - if (showNow !== false && e[c] > 0) out += " · now " + Math.round(100 * now / e[c]) + "% of " + label + tag; + if (showNow !== false && e[c] > 0) out += " | now " + Math.round(100 * now / e[c]) + "% of " + label + tag; return out; } /* The acceptance tile's detail line. `highest` is the session's extreme of per-poll ratios; @@ -1693,15 +1794,21 @@ function triple(key, c, label, fmt, showNow) { function acceptTriple(c, showNow) { const e = extAt["accept"]; const ring = accPool[c]; - if (!e || !(c in e) || !ring || !ring.length) return ""; + if (!e || !(c in e)) return ""; + const tag = typeof c === "number" && c > 1 ? "@c" + c : ""; + let out = "highest " + pct(e[c], 0); + if (!ring || !ring.length) { + const t = (extAtS["accept"] || {})[c]; + if (typeof t === "number" && nowS - t >= 1) out += " | " + dur(nowS - t) + " ago"; + return out; + } let R = 0, A = 0; for (const d of ring) { R += d.dr; A += d.da; } - if (R <= 0) return ""; + if (R <= 0) return out; const last = ring[ring.length - 1]; - const tag = typeof c === "number" && c > 1 ? "@c" + c : ""; - let out = "highest " + pct(e[c], 0) + " \u00b7 recent " + pct(A / R, 0); + out += " | recent " + pct(A / R, 0); if (showNow !== false && e[c] > 0 && last.dr > 0) - out += " \u00b7 now " + Math.round(100 * (last.da / last.dr) / e[c]) + "% of highest" + tag; + out += " | now " + Math.round(100 * (last.da / last.dr) / e[c]) + "% of highest" + tag; return out; } @@ -1925,15 +2032,20 @@ function lines(svgId, series) { } } let hi = 0; - for (const s of series) for (const v of s.vals) if (v > hi) hi = v; + for (const s of series) for (const p of s.pts) if (p.v > hi) hi = p.v; + /* X IS TIME, as on the sparklines: both series share one window, so a busy stretch is the width + * of its seconds in both and the two lines stay comparable to each other. */ + let t1 = 0; + for (const s of series) if (s.pts.length) t1 = Math.max(t1, s.pts[s.pts.length - 1].t); series.forEach((s, k) => { const p = svg.childNodes[k + 1]; - if (s.vals.length < 2) { p.setAttribute("d", ""); return; } - const dx = w / (s.vals.length - 1); + if (s.pts.length < 2) { p.setAttribute("d", ""); return; } let d = ""; - for (let i = 0; i < s.vals.length; i++) - d += (i ? "L" : "M") + (i * dx).toFixed(1) + "," + - (h - 1 - (h - 4) * (hi > 0 ? s.vals[i] / hi : 0)).toFixed(1); + for (const q of s.pts) { + const x = Math.min(w, Math.max(0, w * (1 - (t1 - q.t) / HIST_S))); + d += (d ? "L" : "M") + x.toFixed(1) + "," + + (h - 1 - (h - 4) * (hi > 0 ? q.v / hi : 0)).toFixed(1); + } p.setAttribute("d", d); }); return hi; @@ -2075,9 +2187,15 @@ function histSave() { /* Prefill rate: the prompt tokens computed (not from the prefix cache) over the time to first * token; none for a fully cached prompt. */ function histPrefill(r) { - if (!finite(r.prompt) || !finite(r.ttft_s) || r.ttft_s <= 0) return null; + if (!finite(r.prompt)) return null; const fresh = r.prompt - (r.cached || 0); - return fresh > 0 ? fresh / r.ttft_s : null; + if (fresh <= 0) return null; + /* GUIDE: prefill speed is the prefill's own duration, not the prompt over time to + * first token -- the latter charges the admission queue to the prefill. Fall back to + * ttft for a server that does not report prefill_s. */ + const t = finite(r.prefill_s) && r.prefill_s > 0 ? r.prefill_s + : (finite(r.ttft_s) && r.ttft_s > 0 ? r.ttft_s : null); + return t ? fresh / t : null; } function histFinish(r, run) { if (!r || !r.id) return; @@ -2130,7 +2248,17 @@ const HCOLS = [ { h: "tok/s", f: (h) => tps(h.tps) }, { h: "age", f: null }, /* rewritten in place every poll */ ]; -for (const c of HCOLS) $("hhead").appendChild(el("th", null, c.h)); +const HTITLE = { + "id": "this browser's history id; 0 again after a clear", + "prompt": "prompt tokens", + "out": "output tokens", + "ctx": "context tokens, prompt plus output", + "ttft": "time to first token, measured from arrival, so it includes queue wait", + "prefill tok/s": "fresh prompt tokens over the time from admission to first token, so queue wait is not charged to it; a mostly-cached prompt scores low", + "tok/s": "this request's own decode rate since its first token", + "age": "how long ago this request finished", +}; +for (const c of HCOLS) { const th = el("th", null, c.h); if (HTITLE[c.h]) th.title = HTITLE[c.h]; $("hhead").appendChild(th); } function histRender(missed) { const mean = (a) => a.length ? a.reduce((p, c) => p + c, 0) / a.length : null; @@ -2138,8 +2266,13 @@ function histRender(missed) { * the headline, and the recent window is what a change in the workload shows up in first. */ const group = (vals, fmt, label) => { const all = mean(vals), a20 = mean(vals.slice(-20)), a5 = mean(vals.slice(-5)); - return label + " avg " + fmt(all) + - (a20 != null ? " (20: " + fmt(a20) + ", 5: " + fmt(a5) + ")" : ""); + /* A window whose rows are a subset of a wider one shown is the same mean twice: show + * "last 20" only once 20 requests exist and "last 5" only once 5 do, so every figure on + * the line is a different question. */ + const w = []; + if (vals.length >= 20) w.push("last 20: " + fmt(a20)); + if (vals.length >= 5) w.push("last 5: " + fmt(a5)); + return label + " mean " + fmt(all) + (w.length ? " | " + w.join(" | ") : ""); }; const tpsV = hRows.map((h) => h.tps).filter((v) => v != null); const pfV = hRows.map((h) => h.pf).filter((v) => v != null); @@ -2147,8 +2280,24 @@ function histRender(missed) { const parts = [hRows.length + " done"]; if (tpsV.length) parts.push(group(tpsV, tps, "tok/s")); if (pfV.length) parts.push(group(pfV, cnt3, "prefill")); - if (tfs.length) parts.push("ttft " + dur(tfs[Math.floor(tfs.length / 2)])); - $("hsum").textContent = parts.join(" · "); + if (tfs.length) parts.push("ttft median " + dur(tfs[Math.floor(tfs.length / 2)])); + /* One element per category so it wraps whole, and the dot between them is its own element so + * its spacing survives. The dot marks a category change; the pipe inside each group marks a + * different question about the same category. */ + const hsum = $("hsum"); + hsum.textContent = ""; + parts.forEach((p, i) => { + /* The zero-width space is the line's ONLY break opportunity. The groups are nowrap so they + * cannot split, and with no break point here a long summary overflows the row and clips + * whatever follows it -- which is what the padded separators did to this line. */ + if (i) hsum.appendChild(document.createTextNode("\u200b")); + const g = el("span", "hgrp"); + /* The dot travels WITH the category it introduces: as a sibling it could be left stranded + * at the end of a line when the category wrapped, which is the orphan this avoids. */ + if (i) g.appendChild(el("span", "hsep", "\u00b7")); + g.appendChild(document.createTextNode(p)); + hsum.appendChild(g); + }); /* Newest first. The rows are rebuilt only when the set changes; a poll only rewrites the ages. */ const body = $("hbody"); @@ -2185,8 +2334,13 @@ $("hclr").addEventListener("click", () => { lsSet(HK, "[]"); lsSet(HKN, "0"); lsSet(HKC, String(Date.now())); hDrawn = null; histRender(0); }); -$("hjson").addEventListener("click", () => { - try { navigator.clipboard.writeText(JSON.stringify(hRows)); } catch (e) {} +$("reqjson").addEventListener("click", () => { + const url = URL.createObjectURL(new Blob([JSON.stringify(hRows, null, 2)], + { type: "application/json" })); + const a = el("a"); + a.href = url; a.download = "radiance-history.json"; + document.body.appendChild(a); a.click(); a.remove(); + setTimeout(() => URL.revokeObjectURL(url), 1000); }); histLoad(); histRender(0); @@ -2202,11 +2356,12 @@ let lastStepMs = null; * lane is doing, so a restart priced against it would not pay back. Until the engine's first * window completes, the fastest single-stream step this tab has seen stands in. */ let c1hist = []; -const C1CAP = 7200; /* an hour at 2 polls/s of single-stream samples */ +const C1CAP_S = 3600; /* the fallback floor's horizon in seconds */ const bestAt = {}; /* fastest step seen at each concurrency, this process */ function update(s, dt) { - $("ver").textContent = s.version + " · up " + dur(s.uptime_s); + nowS = performance.now() / 1000; + $("ver").textContent = s.version + " | up " + dur(s.uptime_s); /* THE DECODE STEP TIME, OUT OF THE ENGINE'S OWN CLOCK, and deliberately not out of the * browser's. Wall time over step count is wrong in two directions at once, both of them silent: @@ -2228,14 +2383,18 @@ function update(s, dt) { /* Single-stream steps only: the floor is a single-sequence window, and a batched step read * against it would report a batch arriving as a slowdown. */ - if (s.running === 1 && stepMs != null) { c1hist.push(stepMs); if (c1hist.length > C1CAP) c1hist.shift(); } + if (s.running === 1 && stepMs != null) { + c1hist.push({ t: nowS, v: stepMs }); + while (c1hist.length && c1hist[0].t < nowS - C1CAP_S) c1hist.shift(); + } const engBestMs = s.step_ns_decode_best > 0 ? s.step_ns_decode_best / 1e6 : 0; const engRecentMs = s.step_ns_decode_recent > 0 ? s.step_ns_decode_recent / 1e6 : 0; - const floorMs = engBestMs > 0 ? engBestMs : (c1hist.length ? Math.min(...c1hist) : 0); + const floorMs = engBestMs > 0 ? engBestMs + : (c1hist.length ? Math.min(...c1hist.map(x => x.v)) : 0); let det = ""; if (floorMs > 0) { det = "best " + floorMs.toFixed(2) + "ms"; - if (engRecentMs > 0) det += " · recent " + engRecentMs.toFixed(2) + "ms"; + if (engRecentMs > 0) det += " | recent " + engRecentMs.toFixed(2) + "ms"; } /* The step as a percentage of the fastest at this concurrency (`@cN` above one). `now` is a * ~500 ms poll mean and `best` a 32-step window mean, so a short fast stretch can beat the @@ -2248,7 +2407,7 @@ function update(s, dt) { if (!(k in bestAt) || lastStepMs < bestAt[k]) bestAt[k] = lastStepMs; const ref = k === 1 && floorMs > 0 ? floorMs : bestAt[k]; const shown = ref > 0 ? Math.min(99, Math.round(100 * ref / lastStepMs)) : 0; - if (ref > 0) det += " · now " + (shown === 99 ? "~99" : shown) + "% of best" + (k === 1 ? "" : "@c" + k); + if (ref > 0) det += " | now " + (shown === 99 ? "~99" : shown) + "% of best" + (k === 1 ? "" : "@c" + k); } $("m-stepdet").textContent = det; @@ -2256,10 +2415,15 @@ function update(s, dt) { setMetric("prefill", s.prefill_tps, tps(s.prefill_tps)); setMetric("flight", s.in_flight, String(s.in_flight)); const busy = s.running > 0; - if (busy) { - lastActiveC = s.running; - noteSample("decode", s.running, s.decode_tps); - noteSample("prefill", s.running, s.prefill_tps, RECENT_PREFILL); + if (busy) lastActiveC = s.running; + /* Sampled every poll, idle included. The engine decays its own rate toward zero on idle, so + * feeding that decayed value into the last active concurrency's window lets `recent` wind down + * with the engine. Gating this on busy froze the detail line at the last busy mean, so it read + * "recent 214" beside a headline of 0. Skipped before any activity (lastActiveC 0) so a fresh + * idle page shows no figures rather than a column of zeros. */ + if (lastActiveC > 0) { + noteSample("decode", lastActiveC, s.decode_tps); + noteSample("prefill", lastActiveC, s.prefill_tps, RECENT_PREFILL_S); } noteSample("flight", "*", s.in_flight); const cNow = busy ? s.running : lastActiveC; @@ -2308,9 +2472,9 @@ function update(s, dt) { $("m-kvcap").textContent = kvStream ? "kv cache in ram" : "kv cache in vram"; $("m-kvdet").textContent = s.kv_bytes_total > 0 ? (kvStream - ? "of " + hb(s.kv_bytes_total) + " in host mirror · " + cnt3(s.kv_tokens_used) + " tok" + ? "of " + hb(s.kv_bytes_total) + " in host mirror | " + cnt3(s.kv_tokens_used) + " tok" + " · " + hb(s.kv_bytes_carved || 0) + " VRAM ring" - : "of " + hb(s.kv_bytes_total) + " (max " + hb(s.kv_bytes_carved || 0) + ") · " + : "of " + hb(s.kv_bytes_total) + " (max " + hb(s.kv_bytes_carved || 0) + ") | " + cnt3(s.kv_tokens_used) + " tok" + (kvGave > 0 ? " · " + hb(kvGave) + " lent to experts" : "")) : ""; @@ -2321,7 +2485,8 @@ function update(s, dt) { if (aw != null && aw.dr > 0) { const c = s.running > 0 ? s.running : lastActiveC; const ring = accPool[c] || (accPool[c] = []); - ring.push(aw); if (ring.length > RECENT) ring.shift(); + ring.push({ t: nowS, dr: aw.dr, da: aw.da }); + while (ring.length && ring[0].t < nowS - RECENT_S) ring.shift(); } /* The headline is this poll's conditional acceptance, as every other tile's big number is the * current value; the lifetime ratio stays in the Speculation panel, on /stats and on /metrics. @@ -2339,7 +2504,7 @@ function update(s, dt) { const list = s.requests || []; renderRequests(list, s.kv_tokens_total || 0); renderBatch(list, s); - $("reqaside").textContent = list.length ? s.running + " running · " + s.waiting + " waiting" : ""; + $("reqaside").textContent = list.length ? s.running + " running | " + s.waiting + " waiting" : ""; histRender(histIngest(s)); totals["Requests"].textContent = cnt(s.total_requests); @@ -2363,7 +2528,7 @@ function update(s, dt) { self-explanatory. The split is by who references the blocks: the first part is context a request on the card is reading, the second context nothing reads and the next eviction frees. */ mKvSub.textContent = s.kv_tokens_used > 0 - ? cnt3(kvLive) + " tok read by running requests · " + cnt3(kvCached) + " kept for reuse" + ? cnt3(kvLive) + " tok read by running requests | " + cnt3(kvCached) + " kept for reuse" : ""; mKvMax.textContent = kvStream ? (s.kv_tokens_max > 0 @@ -2434,8 +2599,15 @@ function update(s, dt) { /* ---- devices, in the same panel as the cache meter: they are one question. */ const cards = s.cards || []; - if (devs.length !== cards.length) + if (devs.length !== cards.length) { + /* Rebuild means REPLACE. The old rows must leave the panel: a card-count change -- a + * TP flip, a card swap -- otherwise stacks a fresh set on the stale one, and the panel + * grows by the old count every time until the page is reloaded. Per-row removal rather + * than the sibling guards' container-clear: #mem is shared with the KV and prefix + * meters, which are built once and must survive. Same shape as the request rows above. */ + devs.forEach((d) => d.wrap.remove()); devs = cards.map((c) => meter($("mem"), "dev", c.name, c.index)); + } cards.forEach((c, i) => { setBar(devs[i].i, c.vram_total ? c.vram_used / c.vram_total : 0, false); devs[i].v.textContent = hbOf(c.vram_used, c.vram_total, " / "); @@ -2459,8 +2631,8 @@ function update(s, dt) { name: t.name, ink: TIER_INK[i] || TIER_INK[3], w: t.units, a: cnt(t.units), b: hb(t.bytes) }))); const res = ex.tiers && ex.tiers.length ? ex.tiers[0].units : 0; - $("expaside").textContent = cnt(ex.n_units) + " units · " + hb(ex.bytes) + - (ex.heat ? " · heat engine on" : " · static plan"); + $("expaside").textContent = cnt(ex.n_units) + " units | " + hb(ex.bytes) + + (ex.heat ? " | heat engine on" : " | static plan"); /* THE HIT RATE, WHICH IS NOT THE RESIDENCY. Residency is a property of the PLAN -- how many * units sit in VRAM -- and this is a property of the TRAFFIC: how often the router asked for @@ -2499,7 +2671,7 @@ function update(s, dt) { const b = layerBars[i]; b.style.height = Math.max(2, 100 * f).toFixed(1) + "%"; b.className = f >= 0.999 ? "full" : ""; - b.title = "layer " + i + ": " + lr[i] + " of " + n + " resident · " + pct(f); + b.title = "layer " + i + ": " + lr[i] + " of " + n + " resident | " + pct(f); }); /* Only when there IS a weakest layer. Every layer fully resident is the answer this panel * most wants to be able to give, and colouring an arbitrary one of them amber says the @@ -2507,7 +2679,7 @@ function update(s, dt) { if (worst >= 0 && wf < 0.999) layerBars[worst].className = "min"; $("layv").textContent = !lu.length ? DASH : wf >= 0.999 ? "all resident" - : pct(sum / lu.length) + " mean · worst L" + worst + " " + pct(wf); + : pct(sum / lu.length) + " mean | worst L" + worst + " " + pct(wf); /* Residency, not capability: every bucket says where units are, and the buckets add up to * the plan. The old "N movable" read as if cold disk experts could not move -- deposits and * the stager move them constantly; what they lack is an address heat can relocate without @@ -2517,7 +2689,7 @@ function update(s, dt) { cnt(t.units) + " " + (t.name === "pinned" ? "in host pool" : t.name === "ssd" ? "on the file tier" : t.name)); $("planev").textContent = cnt(res) + " of " + cnt(ex.n_units) + " in VRAM" + - (rest.length ? " · " + rest.join(" · ") : " · fully resident"); + (rest.length ? " · " + rest.join(" · ") : " | fully resident"); /* ---- the plane itself. * @@ -2647,7 +2819,7 @@ function update(s, dt) { /* THE CAVEAT SITS ON THE BAR IT QUALIFIES. Run along the panel's title it was a third line of heading, and it describes one element rather than the panel. */ $("linkaside").textContent = lk.world > 1 - ? lk.world + " cards · " + cnt3(lk.ar_calls) + " collectives" : "single rank"; + ? lk.world + " cards | " + cnt3(lk.ar_calls) + " collectives" : "single rank"; $("linkhint").textContent = live ? "shares below are the rate over the last poll" : "idle — shares below are lifetime totals, not rates"; @@ -2664,15 +2836,17 @@ function update(s, dt) { const rdn = prev && prev.experts && dt > 0 ? Math.max(0, (ex.demotions - prev.experts.demotions) / dt) : 0; if (prev && prev.experts && dt > 0) { - moveHist.up.push(rup); if (moveHist.up.length > HIST) moveHist.up.shift(); - moveHist.down.push(rdn); if (moveHist.down.length > HIST) moveHist.down.shift(); + for (const pair of [[moveHist.up, rup], [moveHist.down, rdn]]) { + pair[0].push({ t: nowS, v: pair[1] }); + while (pair[0].length && pair[0][0].t < nowS - HIST_S) pair[0].shift(); + } } - const peak = lines("movechart", [{ ink: INK_UP, vals: moveHist.up }, - { ink: INK_DOWN, vals: moveHist.down, dash: true }]); + const peak = lines("movechart", [{ ink: INK_UP, pts: moveHist.up }, + { ink: INK_DOWN, pts: moveHist.down, dash: true }]); $("mvr_n").firstChild.nodeValue = num3(rup + rdn); /* TWO FIGURES, because the column is a fixed width and their digit count is the data; the window's peak is the chart's scale and sits on its axis. */ - $("movev").textContent = peak > 0 ? num3(rup) + " up · " + num3(rdn) + " down" : "settled"; + $("movev").textContent = peak > 0 ? num3(rup) + " up | " + num3(rdn) + " down" : "settled"; $("movepk").textContent = num3(peak); moveKv["Promotions"].textContent = cnt(ex.promotions); @@ -2948,7 +3122,7 @@ function laneLabels(lanes) { if (l.length !== 1) return "spelled out"; const g = geoms[i]; const bits = differing.map((k) => k + " " + (g[k] === undefined ? "—" : g[k])); - return bits.length ? bits.join(" · ") : "fused"; + return bits.length ? bits.join(" | ") : "fused"; }); } @@ -3055,7 +3229,7 @@ function highlight(q) { } } $("gcount").textContent = needle ? hit + " of " + nodes.length + " nodes match" - : cnt(graph.order.length) + " declared ops · " + + : cnt(graph.order.length) + " declared ops | " + graph.ops.length + " distinct"; } @@ -3131,7 +3305,7 @@ function drawKernel(host, p) { if (p.shape) kvRow(dl, "compiled for", p.shape); if (p.dtypes) kvRow(dl, "dtypes", p.dtypes); if (p.variant) kvRow(dl, "variant", p.variant, - p.variant_source + " · " + p.n_variants + " offered"); + p.variant_source + " | " + p.n_variants + " offered"); if (p.scratch) kvRow(dl, "scratch", hb(p.scratch)); if (dl.children.length) host.appendChild(dl); @@ -3217,7 +3391,7 @@ function drawBand(host, b) { const s = el("div", "msub"); s.appendChild(el("div", "sh", "host domain — the placement planner may run it here")); const t = el("div", "mtags"); - t.appendChild(el("span", "mtag", b.host.kernel + " · " + b.host.plugin)); + t.appendChild(el("span", "mtag", b.host.kernel + " | " + b.host.plugin)); s.appendChild(t); bb.appendChild(s); } @@ -3244,7 +3418,7 @@ function drawWeights(host, o) { add("dtype", w.dtype); if (w.shape) add("shape", w.shape); add("layout", w.layout); - add("lives", w.tier + " · " + w.site); + add("lives", w.tier + " | " + w.site); if (w.layer >= 0) add("layer", String(w.layer)); if (w.expert != null) add("expert", String(w.expert)); it.appendChild(m); @@ -3336,7 +3510,7 @@ function drawSummary() { s.appendChild(cell(cnt(fusedLaunches), "", "fused launches")); s.appendChild(cell(cnt(fusedOps - fusedLaunches), "", "launches removed")); s.appendChild(cell(ab.n, ab.u, "activation arena")); - s.appendChild(cell(String(m.n_layers), "", "layers · rank " + m.rank + "/" + m.world)); + s.appendChild(cell(String(m.n_layers), "", "layers | rank " + m.rank + "/" + m.world)); const gl = $("glibs"); gl.textContent = ""; @@ -3352,7 +3526,7 @@ function drawSummary() { d.appendChild(el("span", "n", pl.name)); const used = libs[pl.name] || 0; d.appendChild(el("span", "c", pl.kernels + " kernels" + - (used ? " · " + cnt(used) + " launches" : " · unused"))); + (used ? " · " + cnt(used) + " launches" : " | unused"))); gl.appendChild(d); } $("gsum").textContent = missing ? cnt(missing) + " op(s) with no device kernel" @@ -3370,9 +3544,9 @@ function drawMeta() { host.className = "gmeta"; const dm = (graph.misses || []).filter((m) => m.domain !== "host").length; $("gmetasum").textContent = - (graph.notes ? graph.notes.length : 0) + " notes from the architecture plugin · " + - (graph.kv_groups ? graph.kv_groups.length : 0) + " kv groups · " + - (graph.drafter ? graph.drafter.name + " drafter · " : "") + + (graph.notes ? graph.notes.length : 0) + " notes from the architecture plugin | " + + (graph.kv_groups ? graph.kv_groups.length : 0) + " kv groups | " + + (graph.drafter ? graph.drafter.name + " drafter | " : "") + (dm ? dm + " unresolved device band(s)" : "no unresolved device band"); const block = (title, cls) => { const se = el("section", cls); @@ -3390,15 +3564,15 @@ function drawMeta() { const ul = block("kv groups — sized by the resolved attention kernels"); for (const g of graph.kv_groups) ul.appendChild(el("li", null, - g.name + " · " + g.kind + " · " + g.layers + " layer" + (g.layers === 1 ? "" : "s") + - (g.block_size ? " · block " + g.block_size + " tokens, " + hb(g.bytes_per_block) - : " · " + hb(g.bytes_per_state) + " a sequence"))); + g.name + " | " + g.kind + " | " + g.layers + " layer" + (g.layers === 1 ? "" : "s") + + (g.block_size ? " | block " + g.block_size + " tokens, " + hb(g.bytes_per_block) + : " | " + hb(g.bytes_per_state) + " a sequence"))); } if (graph.drafter) { const ul = block("draft head"); - ul.appendChild(el("li", null, graph.drafter.name + " · " + graph.drafter.kind + " · " + + ul.appendChild(el("li", null, graph.drafter.name + " | " + graph.drafter.kind + " | " + graph.drafter.depth + " token(s) a step" + - (graph.drafter.window ? " · window " + graph.drafter.window + (graph.drafter.window ? " | window " + graph.drafter.window : ""))); } /* ABSENCE IS ASYMMETRIC (spec 2.1), and so is this list. No DEVICE kernel for a band is a hole @@ -3453,22 +3627,28 @@ $("gq").addEventListener("input", (e) => highlight(e.target.value)); /* ---------------------------------------------------------------- tabs */ function show(which) { - const model = which === "model", sess = which === "sess"; - $("view-dash").hidden = model || sess; + const model = which === "model", sess = which === "sess", adv = which === "adv"; + /* The Advanced view holds no live figures, so the dashboard's poll pauses while it is open, as + * it does for the Model view. Returning to the dashboard after more than a window there clears + * the sampled windows, which is what poll() already does for a backgrounded tab. */ + $("view-dash").hidden = model || sess || adv; $("view-sess").hidden = !sess; $("view-model").hidden = !model; - $("tab-dash").className = (model || sess) ? "" : "on"; + $("view-adv").hidden = !adv; + $("tab-dash").className = (model || sess || adv) ? "" : "on"; $("tab-sess").className = sess ? "on" : ""; $("tab-model").className = model ? "on" : ""; + $("tab-adv").className = adv ? "on" : ""; if (model) { loadGraph(); loadControlVector(); } if (sess) loadSessions(); window.scrollTo(0, 0); - const h = model ? "#model" : sess ? "#sessions" : "#"; + const h = model ? "#model" : sess ? "#sessions" : adv ? "#advanced" : "#"; if (location.hash !== h) history.replaceState(null, "", h); } $("tab-dash").addEventListener("click", () => show("dash")); $("tab-sess").addEventListener("click", () => show("sess")); $("tab-model").addEventListener("click", () => show("model")); +$("tab-adv").addEventListener("click", () => show("adv")); /* WHAT THE ENGINE IS STILL HOLDING BETWEEN TURNS. Polled on its own schedule and only while the view is open: a stored session changes on the scale of its idle thresholds -- tens of seconds at @@ -3507,7 +3687,7 @@ function sessRow(r, hybrid, manyModels) { const reuse = reuseOf(r, hybrid), ret = tr.appendChild(el("td", "l ret")); if (reuse > 0) { ret.appendChild(el("b", null, "reuses " + cnt3(reuse))); - ret.appendChild(document.createTextNode(" · prefills " + cnt3(r.tokens - reuse))); + ret.appendChild(document.createTextNode(" | prefills " + cnt3(r.tokens - reuse))); } else { ret.textContent = "prefills all " + cnt3(r.tokens); } @@ -3633,8 +3813,8 @@ async function loadControlVector() { $("cvbox").disabled = false; $("cvbox").checked = !!p.default; /* The family the loader validated the file against, then its range and scale. */ - $("cvsum").textContent = (p.arch ? p.arch + " \u00b7 " : "") + "layers " + p.first + - "\u2013" + p.last + " \u00b7 " + p.mode + " \u00b7 scale " + p.scale; + $("cvsum").textContent = (p.arch ? p.arch + " | " : "") + "layers " + p.first + + "\u2013" + p.last + " | " + p.mode + " | scale " + p.scale; /* A running request keeps the choice it was admitted with, and a refusal already in a * session's context is in the prompt the next turn reads. */ $("cvnote").textContent = "New requests only. A session with a refusal already in its " + @@ -3676,31 +3856,107 @@ $("cvbox").addEventListener("change", async (e) => { } }); -/* The poll runs every 100 ms while a request is in flight, so the history sees most finished - * requests before they leave /stats, and every 500 ms otherwise. */ +/* THE POLL CADENCE, SET BY THIS BROWSER. Held in localStorage, not on the server: the cadence is + * a property of who is reading, not of what is serving, and browser storage outlives an image swap + * or an engine restart that a file beside the engine would not. Two intervals, both editable: the + * page fetches at the idle interval while nothing runs and the busy interval while a request is in + * flight. Set them equal for one fixed rate. One key holds both, so a change is one write. */ +const POLL_K = "radiance.poll"; +const POLL_MIN = 100, POLL_MAX = 5000; +const clampMs = (v, d) => Math.min(POLL_MAX, Math.max(POLL_MIN, Math.round(+v || d))); +let pollIdleMs = 500, pollBusyMs = 300; +try { + const raw = lsGet(POLL_K); + if (raw) { + const p = JSON.parse(raw) || {}; + if (typeof p.idle === "number") pollIdleMs = clampMs(p.idle, 500); + if (typeof p.busy === "number") pollBusyMs = clampMs(p.busy, pollIdleMs); + else if (typeof p.ms === "number") { pollIdleMs = clampMs(p.ms, 500); pollBusyMs = pollIdleMs; } + } +} catch (e) { /* the defaults */ } +const pollCadence = (inFlight) => inFlight > 0 ? pollBusyMs : pollIdleMs; +function pollSummary() { + $("advsum").textContent = pollIdleMs === pollBusyMs ? pollIdleMs + " ms" + : pollIdleMs + " ms idle | " + pollBusyMs + " ms busy"; +} +function pollSave() { + lsSet(POLL_K, JSON.stringify({ idle: pollIdleMs, busy: pollBusyMs })); + pollSummary(); +} +$("pollidle").value = pollIdleMs; +$("pollbusy").value = pollBusyMs; +pollSummary(); +$("pollidle").addEventListener("change", (e) => { + pollIdleMs = clampMs(e.target.value, 500); + e.target.value = pollIdleMs; /* show what was stored, not what was typed */ + pollSave(); + schedulePoll(pollIdleMs); +}); +$("pollbusy").addEventListener("change", (e) => { + pollBusyMs = clampMs(e.target.value, 300); + e.target.value = pollBusyMs; + pollSave(); + schedulePoll(pollIdleMs); +}); let pollTimer = null; function schedulePoll(ms) { clearTimeout(pollTimer); pollTimer = setTimeout(poll, ms); } +/* Past one window's length of not polling, the sampled windows hold only pre-gap samples and the + * first poll back would charge the whole span to a single sample. There is nothing to keep, so + * the windows and the poll's baseline clear and the page refills from the return, rather than + * presenting the pre-gap lane as current. The session's extremes (extAt) and the single-stream + * floor (c1hist) survive: a fastest-ever and a floor are properties of the session, not of the + * last minute. Checked in poll(), not on the visibility event, so a view switch, a backgrounded + * tab and a laptop sleep all take the same path. */ +const GAP_S = HIST_S; /* the same span the sparklines draw: past it there is nothing to keep */ +let lastPollAt = 0; +function resetWindows() { + for (const k in hist) hist[k].length = 0; + for (const k in winAt) delete winAt[k]; + for (const k in accPool) delete accPool[k]; + moveHist.up.length = 0; moveHist.down.length = 0; + prev = null; prevAt = 0; accPrev = null; +} async function poll() { /* A background tab watches nothing, and neither does the Model view -- which is static. */ - if (document.hidden || $("view-dash").hidden) { schedulePoll(500); return; } + if (document.hidden || $("view-dash").hidden) { schedulePoll(pollIdleMs); return; } + const wall = Date.now(); + if (lastPollAt && (wall - lastPollAt) / 1000 > GAP_S) resetWindows(); + lastPollAt = wall; try { const r = await api("stats"); if (!r.ok) throw new Error(r.status); const s = await r.json(); + /* A new engine process is a discontinuity, not a new measurement, and started_at names it. + * It is a whole-second clock, so two processes could share one and the clear would be + * missed. For that, the replacement would have to start within the same second as the one + * the page last read -- and the page can only read it once /stats answers, startup_s after + * the old process began (69 s here). A replacement that starts after its predecessor stopped + * answering is therefore stamped a later second. The guarantee needs startup_s >= 1 s; a + * model that came up inside a second could collide, and the cost would be one stale extreme + * carrying a true age. + * + * uptime_s is NOT a backstop for that case, because it is derived: unix_now() - started_at_, + * both whole seconds, so started_at + uptime_s is exactly the wall clock at every poll. A + * later poll always reports a larger uptime for the same started_at, so a comparison firing + * on a smaller one detects a backward NTP step and nothing else. Checked before update() so + * the new run's samples land in fresh windows. */ + if (lastStart !== null && s.started_at !== lastStart) newEngineRun(); + lastStart = s.started_at; const now = performance.now(); update(s, prevAt ? (now - prevAt) / 1000 : 0); prev = s; prevAt = now; $("view-dash").classList.remove("boot"); $("dot").className = "dot"; - schedulePoll((s.in_flight || 0) > 0 ? 100 : 500); + schedulePoll(pollCadence(s.in_flight || 0)); } catch (e) { $("dot").className = "dot stale"; - schedulePoll(500); + schedulePoll(pollIdleMs); } } identify(); if (location.hash === "#model") show("model"); else if (location.hash === "#sessions") show("sess"); +else if (location.hash === "#advanced") show("adv"); /* A server that never answers still gets its frame drawn, rather than an empty page that gives * the reader nothing to tell "starting up" apart from "broken". */ setTimeout(() => $("view-dash").classList.remove("boot"), 1500); diff --git a/core/server/iface.h b/core/server/iface.h index 12960e28..976b96f5 100644 --- a/core/server/iface.h +++ b/core/server/iface.h @@ -22,7 +22,8 @@ struct RadModelMeta; namespace rad { -namespace gen { struct Request; struct AudioRequest; class AudioTicket; struct VideoRequest; class VideoTicket; } +namespace gen { struct Request; struct AudioRequest; class AudioTicket; struct VideoRequest; class VideoTicket; + struct ShapeRequest; struct ShapeGenInfo; } namespace mm { struct Frame; struct Item; } namespace server { @@ -212,6 +213,7 @@ struct RequestStat { int32_t slot = -1; double age_s = 0; double ttft_s = -1; /* negative until the first token */ + double prefill_s = -1; /* first token minus admission; negative until both */ double decode_tps = 0; }; @@ -816,5 +818,19 @@ public: virtual int64_t running() const = 0; }; +/* The shape generator (core/gen/shape_driver.h), for a model that makes a 3-D shape from a + * picture: its declared picture, sampler and grid (gen::ShapeGenInfo) and its request queue. The + * server prepares the picture (gen::shape_picture), queues the request, and meshes the field the + * ticket hands back. */ +class IShapeGen { +public: + virtual ~IShapeGen() = default; + virtual const gen::ShapeGenInfo& info() const = 0; + /* Queue a request; refused at once, with `why`, when it can never run. */ + virtual int submit(std::unique_ptr r, std::string* why) = 0; + virtual int64_t queued() const = 0; + virtual int64_t running() const = 0; +}; + } /* namespace server */ } /* namespace rad */ diff --git a/core/server/oai.cpp b/core/server/oai.cpp index bcefbbd3..ff8d64b5 100644 --- a/core/server/oai.cpp +++ b/core/server/oai.cpp @@ -3379,11 +3379,16 @@ int anthropic_image(const json& block, const std::string& at, json* out, ApiErro * continuation sends only the tail of the conversation), so a field outside these lists is * refused by name rather than ignored. The refusal says "Extra inputs are not permitted", as * Anthropic's does; Claude Code matches those words to retry without a beta field it can - * drop. */ + * drop. + * + * The last row is not Anthropic's: the chat path's history penalties and min-p, under the chat + * path's names, ranges and meaning, for clients that speak only this format to a model whose + * card asks for them (Qwen's presence_penalty). */ const char* kAnthropicFields[] = { "model", "messages", "system", "max_tokens", "temperature", "top_p", "top_k", "stream", "stop_sequences", "tools", "tool_choice", "thinking", "metadata", "output_config", "output_format", "context_management", "thread", + "min_p", "presence_penalty", "frequency_penalty", "repetition_penalty", "repeat_last_n", }; /* Accepted and not acted on: none of them can change the answer here. Capacity and placement @@ -3917,8 +3922,11 @@ int anthropic_to_chat(const std::string& body, const OaiLimits& lim, std::string if (one) o["parallel_tool_calls"] = false; } - /* `model` included, since the reply names it back as Anthropic's does. */ - for (const char* k : { "model", "max_tokens", "temperature", "top_p", "top_k", "stream" }) + /* `model` included, since the reply names it back as Anthropic's does. The penalties and + * min-p are the chat path's own fields, checked there. */ + for (const char* k : { "model", "max_tokens", "temperature", "top_p", "top_k", "stream", + "min_p", "presence_penalty", "frequency_penalty", "repetition_penalty", + "repeat_last_n" }) if (b.contains(k)) o[k] = b.at(k); if (b.contains("stop_sequences")) o["stop"] = b.at("stop_sequences"); diff --git a/core/server/realtime.cpp b/core/server/realtime.cpp index c9788901..9417c822 100644 --- a/core/server/realtime.cpp +++ b/core/server/realtime.cpp @@ -220,6 +220,12 @@ void Server::handle_realtime(const HttpRequest& req, WsConn& ws) { "this model does not transcribe: its architecture plugin states no " "transcription format (rad_arch_audio_format), or it was started without " "its audio encoder", 1008); + /* An open turn is cut at the encoder's clip length; without one it would grow for as long as + * the client appends audio. */ + if (deps_.mm->audio_max_samples() <= 0) + return refuse("invalid_request_error", "model_not_supported", + "this model's audio encoder states no clip length, which a realtime turn " + "is cut at", 1008); /* A session holds a connection's thread and one of its own for its whole life, and runs one * pass at a time: more sessions than the engine has sequences would only queue. */ const int64_t cap = std::max(1, opt_.max_seqs); diff --git a/core/server/server.cpp b/core/server/server.cpp index 84432396..b83c7816 100644 --- a/core/server/server.cpp +++ b/core/server/server.cpp @@ -134,6 +134,10 @@ void Server::register_routes() { [this](const HttpRequest& q) { return handle_video_delete(q); }); router_.get ("/v1/videos/:id/content", [this](const HttpRequest& q) { return handle_video_content(q); }); + /* Hunyuan3D-2's API server: a shape from a picture. */ + router_.post("/generate", [this](const HttpRequest& q) { return handle_shape_generate(q); }); + router_.post("/send", [this](const HttpRequest& q) { return handle_shape_send(q); }); + router_.get ("/status/:uid", [this](const HttpRequest& q) { return handle_shape_status(q); }); router_.post("/v1/audio/transcriptions", [this](const HttpRequest& q) { return handle_transcription(q); }); /* The same, live over a WebSocket (OpenAI's realtime transcription session). A plain GET @@ -374,6 +378,7 @@ void Server::stop() { stopping_.store(true); transport_.stop(); stop_videos(); + stop_shapes(); drain_graveyard(2000); } @@ -661,6 +666,57 @@ static std::vector kept_logprobs(const std::vector& return std::vector(lp.begin(), lp.begin() + (long)lp_before_cut(lp, 0, cut)); } +/* How many trailing bytes of a running choice's text are held back for its stop strings: the + * longest tail that is a proper prefix of one of them (core/text's Detokenizer holds back the + * same in what it has not returned). Every byte before that tail is final. A stop string that + * began there would already be complete in `text`, and pump() would have cut it, or it can no + * longer be completed, since the text only grows at its end. So this holds back exactly what + * pump() may yet cut, for any decoder: one that leaves stop strings to the server (iface.h), and + * core/text's, which cannot see a stop the server's scan can find in the U+FFFD it returned for + * a byte that was not UTF-8. A blanket (longest stop - 1) bytes, which this replaced, delayed + * every delta, the first one included, by up to a 4 KiB stop's worth of text. + * + * Run on every drain of every running choice, so its cost is bounded three ways: + * + * - Only the bytes not yet on the wire (`emitted` on) can be held back, and the tail never + * starts before them: a tail that began earlier would have been a longer one at the drain + * that sent those bytes. So the tails looked at are the ones in what the drain adds to what + * it held back, however long the stop strings are. + * - A tail is compared only where it starts with a byte some stop string starts with. + * - The comparisons share a budget (kStopTailBudget: a stop string looked at costs one, and + * each byte compared one more). A client sets its stop strings (64 of up to 4 KiB) and + * steers the text, and text that keeps almost matching long stop strings would cost a drain + * up to 4095 tails times 64 strings times their length. Past the budget the whole unsent + * window, up to the longest stop less a byte, is held back: more than the tail, never less, + * so nothing of a stop string is sent, and as late as the blanket hold-back this replaced. + * The next drain tries again. */ +constexpr size_t kStopTailBudget = size_t(1) << 14; + +static size_t stop_prefix_tail(std::string_view text, size_t emitted, + const std::vector& stops, size_t maxstop) { + const size_t unsent = text.size() > emitted ? text.size() - emitted : 0; + const size_t limit = std::min(unsent, maxstop > 0 ? maxstop - 1 : 0); + bool starts[256] = {}; + for (const std::string& s : stops) + if (s.size() > 1) starts[(unsigned char)s[0]] = true; + size_t budget = kStopTailBudget; + for (size_t n = limit; n > 0; --n) { + const char* tail = text.data() + text.size() - n; + if (!starts[(unsigned char)*tail]) continue; + for (const std::string& s : stops) { + if (budget == 0) return limit; + --budget; + if (s.size() <= n || s[0] != *tail) continue; + size_t i = 1; /* s[0] is known to match */ + while (i < n && s[i] == tail[i]) ++i; + if (i == n) return n; + if (budget < i) return limit; + budget -= i; + } + } + return 0; +} + bool Server::pump(std::vector& gens, const OaiRequest& r) { bool progress = false; SinkToken buf[128]; @@ -1223,15 +1279,16 @@ HttpResponse Server::streaming_completion(const HttpRequest& req, OaiRequest& r) } } if (g.delta && g.sink->n_produced() > 0) out += g.delta->started(); - /* While the choice runs, hold back the longest stop string minus one byte, or the - * start of a stop sequence would already be on the wire when it is recognised. + /* While the choice runs, hold back a tail that may still become a stop string + * (stop_prefix_tail), or its start would already be on the wire when it is + * recognised. * * Only while running: a closed choice has no more bytes coming, so its whole text is * the answer, including a trailing `\` or partial `\uXXXX` the escape rule would * otherwise hold back. */ size_t safe = g.text.size(); if (!g.closed) { - if (maxstop > 1) safe = safe > maxstop - 1 ? safe - (maxstop - 1) : 0; + if (maxstop > 1) safe -= stop_prefix_tail(g.text, g.emitted, st->r.stop, maxstop); safe = json_stable_prefix(std::string_view(g.text.data(), safe)); if (safe <= g.emitted) continue; } @@ -1389,6 +1446,8 @@ std::optional Server::refuse_text(const std::string& peer, ApiShap "generates no text" : opt_.video_model ? "this is a video model: it serves /v1/videos and generates " "no text" + : opt_.shape_model ? "this is a 3-D shape model: it serves /generate and generates " + "no text" : nullptr; if (!why) return std::nullopt; return error_response(err_not_implemented(why), peer, shape); @@ -1675,6 +1734,7 @@ HttpResponse Server::serve_pooled(const HttpRequest& req, bool rerank) { opt_.image_model ? "/v1/embeddings requires an embedding model; this one makes images" : opt_.audio_model ? "/v1/embeddings requires an embedding model; this one makes audio" : opt_.video_model ? "/v1/embeddings requires an embedding model; this one makes video" + : opt_.shape_model ? "/v1/embeddings requires an embedding model; this one makes shapes" : "/v1/embeddings requires an embedding model; this one generates " "text"), req.peer); diff --git a/core/server/server.h b/core/server/server.h index 582a763c..b38feaee 100644 --- a/core/server/server.h +++ b/core/server/server.h @@ -43,6 +43,7 @@ struct Deps { IImageGen* images = nullptr; /* absent -> the images endpoints are 501 */ IAudioGen* audio = nullptr; /* absent -> /v1/audio/speech is 501 */ IVideoGen* videos = nullptr; /* absent -> /v1/videos is 501 */ + IShapeGen* shapes = nullptr; /* absent -> /generate is 501 */ const SpeechFormat* speech = nullptr; /* absent -> /v1/audio/transcriptions is 501 */ /* Engine-side state the server cannot see (per-card VRAM, the expert plane), as a snapshot @@ -88,6 +89,10 @@ struct ServerOptions { * many finished videos are kept at most (the oldest go first). */ int64_t video_ttl_s = 3600; int64_t max_videos = 32; + /* A shape generator (rad_declare_shape_generator) generates no text either: the text + * endpoints answer 501 naming /generate. A shape made through /send is kept for /status for + * as long as a video, as many at most. */ + bool shape_model = false; /* The decision protocol from the container's `decision.type`: "d1" serves /v1/systemone * (systemone.h), "clef" serves it through the head on the card (clef.h), "laya" through the * Laya plugin's option logits (laya.h), "mica" through Mica's label logits (mica.h); empty @@ -264,6 +269,7 @@ private: struct RealtimeSession; /* realtime.cpp */ struct SpeechSession; /* speech_stream.cpp */ struct VideoJob; /* videos.cpp */ + struct ShapeJob; /* shapes.cpp */ struct StreamState; static UsageOut usage_of(const OaiRequest& r, const std::vector& gens); @@ -366,6 +372,17 @@ private: /* What this deployment can do (chat, tools, reasoning, grammar, media, logprobs, reasoning * efforts), shared by /server_info's `capabilities` and the model entry so they agree. */ json capabilities() const; + /* ------------------------------------------------------------------ shapes.cpp + * Hunyuan3D-2's own API: a shape from a picture, made at once (/generate) or in the + * background (/send) and collected (/status/{uid}). */ + HttpResponse handle_shape_generate(const HttpRequest& req); + HttpResponse handle_shape_send(const HttpRequest& req); + HttpResponse handle_shape_status(const HttpRequest& req); + void shape_work(std::shared_ptr j); + void sweep_shapes_locked(int64_t now); + void stop_shapes(); + static void shape_caps(json& caps, const IShapeGen* gen); + /* A video model's capabilities (videos.cpp). */ static void video_caps(json& caps, const IVideoGen* gen); HttpResponse handle_reset_prefix_cache(const HttpRequest& req); @@ -453,6 +470,9 @@ private: std::mutex videos_m_; std::vector> videos_; std::vector> videos_gone_; + /* The background shapes (/send), oldest first, and their threads (shapes.cpp). */ + std::mutex shapes_m_; + std::vector> shapes_; }; } /* namespace server */ diff --git a/core/server/shapes.cpp b/core/server/shapes.cpp new file mode 100644 index 00000000..f02010b1 --- /dev/null +++ b/core/server/shapes.cpp @@ -0,0 +1,334 @@ +/* shapes.cpp -- Hunyuan3D-2's API over a shape generator (core/gen/shape_driver.h): a 3-D shape + * from one picture. + * + * The routes and fields are the reference's own API server's (hy3dgen's api_server.py), so its + * clients (its Blender add-on, scripts written against it) work unchanged: + * + * POST /generate the shape, made while the request waits, as the file itself; + * POST /send the same in the background, answered at once with {"uid"}; + * GET /status/{uid} {"status": "processing"}, or "completed" with the file as + * `model_base64`, or "error" with its `message`. + * + * The body is JSON: `image`, the picture as base64 (or a data URL), with an alpha channel for a + * cut-out object -- the reference removes the background of an opaque picture with rembg, which + * this server does not, so an opaque picture is taken whole; `seed` (1234 when absent, as the + * reference), `octree_resolution`, `num_inference_steps` and `guidance_scale` (the model's own + * when absent), and `type`, the file: glb (the default), obj, ply or stl. `volume_decoding` + * "dense" samples every point of the grid instead of refining it coarse to fine. Texturing + * (`texture` true) and the reference's text-to-image and re-texturing inputs (`text`, `mesh`) + * are refused. The reference's knobs that change nothing here are taken and ignored: `face_count` + * (texturing's face budget), `num_chunks` (its decoder's batch) and `mc_algo` "mc"; any other + * field is refused by name. A finished background shape is kept for as long as a video, as many + * as videos. + */ +#include "server.h" +#include "oai.h" + +#include "gen/shape.h" +#include "mm/media.h" +#include "rad_internal.h" + +#include + +#include +#include +#include + +namespace rad { +namespace server { + +namespace { + +/* The largest picture decoded, as the image endpoints bound theirs. */ +constexpr int64_t kMaxSourcePixels = (int64_t)1 << 26; + +/* A request as the routes read it, and its file's format. */ +struct ShapeAsk { + std::unique_ptr req; + std::string type = "glb"; +}; + +int read_ask(const HttpRequest& q, const OaiLimits& lim, const gen::ShapeGenInfo& info, + ShapeAsk* out, ApiError* err) { + json b; + if (parse_request_object(q.body, lim, &b, err) < 0) return RAD_E_INVAL; + auto bad = [&](const std::string& p, const std::string& why) { + *err = err_bad(p, why); + return RAD_E_INVAL; + }; + static const char* const kFields[] = { "image", "seed", "octree_resolution", + "num_inference_steps", "guidance_scale", "type", + "volume_decoding", "texture", "text", "mesh", + "face_count", "num_chunks", "mc_algo" }; + for (auto it = b.begin(); it != b.end(); ++it) { + bool known = false; + for (const char* k : kFields) known = known || it.key() == k; + if (!known) + return bad(it.key(), "'" + it.key() + "' is not a field of /generate"); + } + if (b.contains("mc_algo") && !b["mc_algo"].is_null() && + !(b["mc_algo"].is_string() && b["mc_algo"].get() == "mc")) { + *err = err_unsupported("mc_algo", "the surface is marching cubes ('mc'); differentiable " + "marching cubes ('dmc') is not served"); + return RAD_E_INVAL; + } + for (const char* k : { "text", "mesh" }) + if (b.contains(k) && !b[k].is_null()) { + *err = err_unsupported(k, std::string("this server makes a shape from a picture; '") + + k + "' (the reference's text-to-image and re-texturing " + "inputs) is not served"); + return RAD_E_INVAL; + } + if (b.contains("texture") && b["texture"].is_boolean() && b["texture"].get()) { + *err = err_unsupported("texture", "texturing (Hunyuan3D-Paint) is not served: this " + "server makes the untextured shape"); + return RAD_E_INVAL; + } + if (!b.contains("image") || !b["image"].is_string() || b["image"].get().empty()) + return bad("image", "'image' must be the picture as base64"); + std::string img = b["image"].get(); + if (img.rfind("data:", 0) == 0) { + const size_t comma = img.find(','); + if (comma == std::string::npos || img.compare(comma - 7, 7, ";base64") != 0) + return bad("image", "a data URL must be base64 ('data:;base64,...')"); + img = img.substr(comma + 1); + } + std::vector bytes; + if (!base64_decode(img, &bytes) || bytes.empty()) + return bad("image", "'image' is not valid base64"); + mm::FrameRGBA f; + std::string why; + if (mm::decode_image_rgba(bytes.data(), bytes.size(), kMaxSourcePixels, &f, &why) < 0) + return bad("image", "the picture could not be decoded: " + why); + + auto r = std::make_unique(); + if (gen::shape_picture(info, f, &r->patches, &why) < 0) return bad("image", why); + auto int_field = [&](const char* k, int64_t lo, int64_t hi, int32_t* v) { + if (!b.contains(k) || b[k].is_null()) return true; + if (!b[k].is_number_integer() || b[k].get() < lo || b[k].get() > hi) { + bad(k, std::string("'") + k + "' must be an integer " + std::to_string(lo) + ".." + + std::to_string(hi)); + return false; + } + *v = (int32_t)b[k].get(); + return true; + }; + if (!int_field("num_inference_steps", 2, info.max_steps, &r->steps) || + !int_field("octree_resolution", info.min_resolution, info.max_resolution, + &r->resolution)) + return RAD_E_INVAL; + if (b.contains("guidance_scale") && !b["guidance_scale"].is_null()) { + if (!b["guidance_scale"].is_number() || !(b["guidance_scale"].get() >= 0.0) || + !std::isfinite(b["guidance_scale"].get())) + return bad("guidance_scale", "'guidance_scale' must be a finite number, not negative"); + r->guidance = b["guidance_scale"].get(); + } + r->seed = 1234; + if (b.contains("seed") && !b["seed"].is_null()) { + if (!b["seed"].is_number_integer()) + return bad("seed", "'seed' must be an integer"); + r->seed = b["seed"].is_number_unsigned() ? b["seed"].get() + : (uint64_t)b["seed"].get(); + } + if (b.contains("volume_decoding") && !b["volume_decoding"].is_null()) { + const std::string v = b["volume_decoding"].is_string() + ? b["volume_decoding"].get() : ""; + if (v != "hierarchical" && v != "dense") + return bad("volume_decoding", "'volume_decoding' is hierarchical or dense"); + r->dense = v == "dense"; + } + if (b.contains("type") && !b["type"].is_null()) { + if (!b["type"].is_string()) return bad("type", "'type' is glb, obj, ply or stl"); + out->type = b["type"].get(); + if (out->type != "glb" && out->type != "obj" && out->type != "ply" && out->type != "stl") + return bad("type", "type '" + out->type + "' is not one this server writes: glb, obj, " + "ply or stl"); + } + r->ticket = std::make_shared(); + out->req = std::move(r); + return RAD_OK; +} + +/* The ticket's field as a mesh file, once the driver is done with it. */ +int finish_file(gen::ShapeTicket& t, const gen::ShapeGenInfo& info, const std::string& type, + std::string* file, std::string* mime, std::string* why) { + if (t.status() < 0) { + *why = t.why(); + return t.status(); + } + int32_t r = 0; + std::vector field = t.take_field(&r); + gen::ShapeMesh mesh; + gen::shape_mesh(field, r, info.bounds, info.level, &mesh); + std::vector().swap(field); + if (mesh.f.empty()) { + *why = "the model's field crosses the surface level nowhere in the grid: the picture made " + "no shape"; + return RAD_E_INVAL; + } + return gen::shape_export(mesh, type, file, mime, why); +} + +} /* namespace */ + +struct Server::ShapeJob { + std::string uid, type; + int64_t created_at = 0, done_at = 0; + std::shared_ptr ticket; + std::thread worker; + /* Under Server::shapes_m_ from here on. */ + bool finished = false, failed = false; + std::string file, message; +}; + +void Server::shape_caps(json& caps, const IShapeGen* gen) { + const gen::ShapeGenInfo& info = gen->info(); + caps["shape_max_steps"] = info.max_steps; + caps["shape_resolutions"] = { info.min_resolution, info.max_resolution }; + caps["shape_formats"] = json::array({ "glb", "obj", "ply", "stl" }); +} + +HttpResponse Server::handle_shape_generate(const HttpRequest& req) { + if (!deps_.shapes) + return error_response(err_not_implemented( + "/generate requires a 3-D shape model; this one does not make shapes"), req.peer); + const gen::ShapeGenInfo& info = deps_.shapes->info(); + ShapeAsk a; + ApiError err; + if (read_ask(req, lim_, info, &a, &err) < 0) return error_response(err, req.peer); + std::shared_ptr t = a.req->ticket; + std::string why; + if (const int st = deps_.shapes->submit(std::move(a.req), &why); st < 0) + return error_response(st == RAD_E_INVAL ? err_bad("image", why) : err_overloaded(why), + req.peer); + while (!t->wait(500)) + if (stopping_.load()) { + t->cancel.store(true); + return error_response(err_overloaded("the server is stopping"), req.peer); + } + std::string file, mime; + if (const int st = finish_file(*t, info, a.type, &file, &mime, &why); st < 0) + return error_response(st == RAD_E_INVAL ? err_bad("image", why) : err_internal(why), + req.peer); + HttpResponse res; + res.content_type = mime; + res.body = std::move(file); + return res; +} + +void Server::shape_work(std::shared_ptr j) { + const gen::ShapeGenInfo& info = deps_.shapes->info(); + gen::ShapeTicket& t = *j->ticket; + while (!t.wait(500)) + if (stopping_.load()) { + t.cancel.store(true); + t.wait(60000); + break; + } + std::string file, mime, why; + const int st = t.finished() ? finish_file(t, info, j->type, &file, &mime, &why) + : RAD_E_CANCELLED; + std::lock_guard lk(shapes_m_); + j->finished = true; + j->done_at = unix_now(); + if (st < 0) { + j->failed = true; + j->message = why.empty() ? std::string(rad_strerror(st)) : why; + } else { + j->file = std::move(file); + } +} + +void Server::sweep_shapes_locked(int64_t now) { + for (size_t i = 0; i < shapes_.size();) { + ShapeJob& j = *shapes_[i]; + const bool expired = j.finished && now - j.done_at > opt_.video_ttl_s; + if (!expired) { ++i; continue; } + if (j.worker.joinable()) j.worker.join(); + shapes_.erase(shapes_.begin() + (std::ptrdiff_t)i); + } + /* Past the cap the oldest finished shapes go first. */ + size_t done = 0; + for (const auto& j : shapes_) done += j->finished; + const size_t cap = (size_t)std::max(opt_.max_videos, 1); + for (size_t i = 0; done > cap && i < shapes_.size();) { + if (!shapes_[i]->finished) { ++i; continue; } + if (shapes_[i]->worker.joinable()) shapes_[i]->worker.join(); + shapes_.erase(shapes_.begin() + (std::ptrdiff_t)i); + --done; + } +} + +void Server::stop_shapes() { + std::vector> all; + { + std::lock_guard lk(shapes_m_); + all = shapes_; + } + for (auto& j : all) j->ticket->cancel.store(true); + for (auto& j : all) + if (j->worker.joinable()) j->worker.join(); +} + +HttpResponse Server::handle_shape_send(const HttpRequest& req) { + if (!deps_.shapes) + return error_response(err_not_implemented( + "/send requires a 3-D shape model; this one does not make shapes"), req.peer); + const gen::ShapeGenInfo& info = deps_.shapes->info(); + ShapeAsk a; + ApiError err; + if (read_ask(req, lim_, info, &a, &err) < 0) return error_response(err, req.peer); + auto j = std::make_shared(); + j->uid = random_id("shape_"); + j->type = a.type; + j->created_at = unix_now(); + j->ticket = a.req->ticket; + std::string why; + if (const int st = deps_.shapes->submit(std::move(a.req), &why); st < 0) + return error_response(st == RAD_E_INVAL ? err_bad("image", why) : err_overloaded(why), + req.peer); + { + std::lock_guard lk(shapes_m_); + sweep_shapes_locked(unix_now()); + shapes_.push_back(j); + } + j->worker = std::thread([this, j] { shape_work(j); }); + json o; + o["uid"] = j->uid; + return HttpResponse::json_body(200, json_dump(o)); +} + +HttpResponse Server::handle_shape_status(const HttpRequest& req) { + if (!deps_.shapes) + return error_response(err_not_implemented( + "/status requires a 3-D shape model; this one does not make shapes"), req.peer); + const std::string uid = req.param("uid"); + std::lock_guard lk(shapes_m_); + sweep_shapes_locked(unix_now()); + for (const auto& j : shapes_) { + if (j->uid != uid) continue; + json o; + if (!j->finished) { + o["status"] = "processing"; + int32_t steps = 0, points = 0; + j->ticket->progress_of(&steps, &points); + o["steps_done"] = steps; + o["steps"] = j->ticket->steps; + } else if (j->failed) { + o["status"] = "error"; + o["message"] = j->message; + } else { + o["status"] = "completed"; + o["type"] = j->type; + o["model_base64"] = base64_encode(j->file.data(), j->file.size()); + } + return HttpResponse::json_body(200, json_dump(o)); + } + ApiError e = err_bad("uid", "no shape '" + uid + "'; it may have expired"); + e.status = 404; + e.type = "not_found_error"; + return error_response(e, req.peer); +} + +} /* namespace server */ +} /* namespace rad */ diff --git a/core/server/videos.cpp b/core/server/videos.cpp index eceee3bd..c0e5785d 100644 --- a/core/server/videos.cpp +++ b/core/server/videos.cpp @@ -535,7 +535,7 @@ HttpResponse Server::handle_video_create(const HttpRequest& req) { canvas_for(rw, rh, se, info.max_area, info.size_multiple, &W, &H); } if (W % info.size_multiple || H % info.size_multiple || W < info.min_side || - H < info.min_side || W * H > info.max_area || + H < info.min_side || W > info.max_area || H > info.max_area || W * H > info.max_area || std::max(W, H) > info.max_aspect * std::min(W, H)) { int64_t sw = 0, sh = 0; canvas_for((double)W, (double)H, short_def, info.max_area, info.size_multiple, &sw, &sh); @@ -887,7 +887,8 @@ HttpResponse Server::handle_video_create(const HttpRequest& req) { const int e = mm::h264_roundtrip(f, info.image_crf, &rt, &why); if (e < 0) { ApiError err = err_bad("input_reference", "the picture could not be prepared: " + why); - if (e != RAD_E_INVAL) { err.status = 503; err.type = "server_error"; } + /* A build without an H.264 codec cannot prepare one at all: 501, not a transient 503. */ + if (e != RAD_E_INVAL) { err.status = e == RAD_E_UNSUPPORTED ? 501 : 503; err.type = "server_error"; } return error_response(err, req.peer); } f = std::move(rt); diff --git a/core/text/tokenizer.h b/core/text/tokenizer.h index fe0740fc..edf8c55f 100644 --- a/core/text/tokenizer.h +++ b/core/text/tokenizer.h @@ -320,6 +320,12 @@ int parse_tokenizer_json(const char* path, VocabBuild& out); /* Same, from an in-memory buffer, for a tokenizer.json that arrived some other way. */ int parse_tokenizer_json_buf(std::string_view json, const char* origin, VocabBuild& out); +/* The vocabulary of a model that reads no text (container metadata `radiance.text` = none: a + * picture-to-shape generator): one control token, which no request reaches, since such a program + * serves no text endpoint. rad-convert bakes it and the engine builds it for a checkpoint. */ +void vocab_textless(VocabBuild& out); +inline bool meta_textless(const char* v) { return v && std::string_view(v) == "none"; } + /* Read a standalone chat template file into out.chat_template, trailing newlines stripped. * A release that ships no template (DeepSeek's does not) needs one from elsewhere; the caller * passes the file. An unreadable or empty file is an error, never a silent skip. Returns diff --git a/core/text/tokenizer_json.cpp b/core/text/tokenizer_json.cpp index 79e389e4..85ec896b 100644 --- a/core/text/tokenizer_json.cpp +++ b/core/text/tokenizer_json.cpp @@ -892,6 +892,14 @@ const PreEntry k_pre[] = { } /* namespace */ +void vocab_textless(VocabBuild& out) { + out = VocabBuild{}; + out.kind = RAD_TOK_BPE; + out.tokens = { "<|no-text|>" }; + out.types = { RAD_TT_CONTROL }; + out.source = "none: the model reads no text"; +} + int vocab_from_gguf(const GgufFile& g, VocabBuild& out) { out = VocabBuild{}; out.source = g.path(); @@ -1107,7 +1115,8 @@ int vocab_deserialize(const void* file_base, uint64_t file_bytes, const RadVocab * in, so the caller cannot pass a mismatched one. */ if (file_bytes < sizeof(RadFileHeader)) return RAD_E_FORMAT; const RadFileHeader* fh = reinterpret_cast(base); - if (fh->str_off + fh->str_bytes > file_bytes) return RAD_E_FORMAT; + if (fh->str_off > file_bytes || fh->str_bytes > file_bytes - fh->str_off) + return RAD_E_FORMAT; strs = reinterpret_cast(base + fh->str_off); str_bytes = fh->str_bytes; } @@ -1128,7 +1137,8 @@ int vocab_deserialize(const void* file_base, uint64_t file_bytes, const RadVocab out.ignore_merges = (h->flags & RAD_VOCAB_IGNORE_MERGES) != 0; out.chat_template = S(h->chat_template); - if (!in_file(h->tok_text_off, (uint64_t)h->n_tokens * sizeof(rad_stroff))) + if ((h->n_tokens && !h->tok_text_off) || + !in_file(h->tok_text_off, (uint64_t)h->n_tokens * sizeof(rad_stroff))) return RAD_E_FORMAT; const rad_stroff* toff = reinterpret_cast(base + h->tok_text_off); out.tokens.resize(h->n_tokens); diff --git a/core/text/tokenizer_regex.cpp b/core/text/tokenizer_regex.cpp index a56a7632..6c4035c8 100644 --- a/core/text/tokenizer_regex.cpp +++ b/core/text/tokenizer_regex.cpp @@ -266,6 +266,12 @@ private: std::vector off_; /* byte offset of each codepoint */ size_t i_ = 0; size_t start_ = 0; /* where the construct being parsed began */ + /* Groups open around the construct being parsed: a possessive quantifier is taken only at + * depth 0, where what follows its concatenation is the end of the match. */ + int depth_ = 0; + /* Possessive repetitions parse_quant accepted, read as greedy; parse_concat checks that the + * rest of their concatenation cannot take back what they consumed. */ + std::vector possessive_; bool decode_pattern() { const uint8_t* p = (const uint8_t*)pat_.data(); @@ -382,6 +388,7 @@ private: if (a < 0) return -1; items.push_back(a); } + if (!possessive_tails_ok(items)) return -1; if (items.empty()) return add(Node{}); if (items.size() == 1) return items[0]; Node n; n.kind = Node::CAT; n.kids = std::move(items); @@ -448,11 +455,17 @@ private: else if (!interval_at(i_, &mn, &mx, &len)) return atom; const bool brace = c == '{'; i_ += len; - bool greedy = true; + bool greedy = true, possessive = false; if (!at_end() && peek() == '?') { greedy = false; ++i_; } else if (!at_end() && peek() == '+') { - return failn(brace ? "a quantifier applied to a quantifier (Ruby reads '{n,m}+' as nested repetition)" - : "a possessive quantifier"); + if (brace) + return failn("a quantifier applied to a quantifier (Ruby reads '{n,m}+' as nested repetition)"); + /* A possessive repetition of one class at the top level is read as greedy, which + * parse_concat proves gives the same matches; anything else has no DFA form. */ + if (depth_ > 0 || nodes[atom].kind != Node::SET) + return failn("a possessive quantifier"); + possessive = true; + ++i_; } if (is_quantifier_at(i_)) return failn("a quantifier applied to a quantifier"); if (nodes[atom].kind == Node::ASSERT) return failn("a quantifier on an assertion"); @@ -461,7 +474,35 @@ private: if (mx < 0 && nullable(nodes, atom)) return failn("unbounded repetition of an expression that can match empty"); Node n; n.kind = Node::REP; n.min = mn; n.max = mx; n.greedy = greedy; n.kids = { atom }; - return add(n); + const int r = add(n); + if (possessive) possessive_.push_back(r); + return r; + } + + /* A possessive repetition of the class S never gives back, a greedy one gives back only when + * the rest of the match fails after its longest run. At the top level that rest is the tail of + * its concatenation and then the end of the match. When the tail is classes and repetitions of + * classes, none of which can take a codepoint of S, a shorter run leaves the tail facing a + * codepoint of S it cannot take, so no shorter run matches where the longest did not, and the + * greedy reading reports exactly the possessive matches (Ling-3.0's `[^\r\n\p{L}\p{N}]?+\p{L}+` + * and ` ?[^\s\p{L}\p{N}]++[\r\n]*`). Any other tail is refused. */ + bool possessive_tails_ok(const std::vector& items) { + for (size_t k = 0; k < items.size(); ++k) { + if (std::find(possessive_.begin(), possessive_.end(), items[k]) == possessive_.end()) + continue; + const CpSet& own = sets[nodes[nodes[items[k]].kids[0]].set]; + CpSet tail; + for (size_t j = k + 1; j < items.size(); ++j) { + const Node& n = nodes[items[j]]; + const Node& m = n.kind == Node::REP ? nodes[n.kids[0]] : n; + if (m.kind != Node::SET) + return fail("a possessive quantifier followed by something other than classes"); + tail = set_union(tail, sets[m.set]); + } + if (!set_intersect(own, tail).empty()) + return fail("a possessive quantifier whose class the rest of the match can take"); + } + return true; } int literal(uint32_t c, const Flags& f) { @@ -494,6 +535,7 @@ private: int parse_group(const Flags& outer) { /* `(` already consumed. */ + struct Depth { int& d; explicit Depth(int& x) : d(x) { ++d; } ~Depth() { --d; } } depth(depth_); Flags f = outer; if (peek() != '?') { const int r = parse_alt(f); diff --git a/core/text/tokenizer_regex.h b/core/text/tokenizer_regex.h index a9c1f90a..72275e60 100644 --- a/core/text/tokenizer_regex.h +++ b/core/text/tokenizer_regex.h @@ -18,7 +18,9 @@ * the `onig` crate does. * * Anything else is refused at compile time with the construct named: backreferences, atomic - * groups and possessive quantifiers, lookaround wider than one codepoint, unbounded repetition of + * groups, possessive quantifiers except where the greedy reading provably matches the same (one + * class at the top level, followed only by classes it shares no codepoint with, as in Ling-3.0's + * pattern), lookaround wider than one codepoint, unbounded repetition of * something that can match empty, `(?i)` over a character that folds to several (U+00DF vs "ss"), * and properties the tables do not carry. There is no fallback matcher; a pattern that does not * compile fails the vocabulary load. diff --git a/data/kernels_nemotronh.rkb b/data/kernels_nemotronh.rkb new file mode 100644 index 00000000..f8cd2f3f Binary files /dev/null and b/data/kernels_nemotronh.rkb differ diff --git a/data/recipes/gemma4-12b-bf16.recipe b/data/recipes/gemma4-12b-bf16.recipe new file mode 100644 index 00000000..517f4cce --- /dev/null +++ b/data/recipes/gemma4-12b-bf16.recipe @@ -0,0 +1,9 @@ +# gemma4-12b-bf16.recipe -- Gemma 4 12B ("unified": text, images, audio, Google's assistant head) at bf16. +# Every weight stays as the release holds it. The image embedder's position table, [npos, 2, width], is read +# as its two taps of dimension 1 (the column's rows and the row's), computed at convert and stored bf16 here. +# +# rad-convert --draft-model \ +# --recipe data/recipes/gemma4-12b-bf16.recipe \ +# --set quantization_config.quant_method=compressed-tensors -o gemma4-12b-bf16.rad + +v.pos_*.weight cast dtype=bf16 diff --git a/data/recipes/gemma4-12b-i8g.recipe b/data/recipes/gemma4-12b-i8g.recipe new file mode 100644 index 00000000..493ea640 --- /dev/null +++ b/data/recipes/gemma4-12b-i8g.recipe @@ -0,0 +1,18 @@ +# gemma4-12b-i8g.recipe -- Gemma 4 12B ("unified": text, images, audio, Google's assistant head) from its bf16 +# release: every trunk linear int8 with a bf16 scale per 128 columns, served at i8a8, the trunk's and the +# assistant's lm_heads int8; the assistant's layers and the image and audio embedders bf16, the position +# table's two taps stored bf16 (gemma4-12b-bf16.recipe). +# +# rad-convert --draft-model \ +# --recipe data/recipes/gemma4-12b-i8g.recipe \ +# --set quantization_config.quant_method=compressed-tensors -o gemma4-12b-i8g.rad + +blk.*.attn_qkv.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 +mtp.output.weight rtn codes=i8 group=128 scale=bf16 clamp=sym + +v.pos_*.weight cast dtype=bf16 diff --git a/data/recipes/hunyuan3d-2-bf16.recipe b/data/recipes/hunyuan3d-2-bf16.recipe new file mode 100644 index 00000000..13fc9ec5 --- /dev/null +++ b/data/recipes/hunyuan3d-2-bf16.recipe @@ -0,0 +1,15 @@ +# hunyuan3d-2-bf16.recipe -- Hunyuan3D-2's shape model (hunyuan3d-dit-v2-0) served at bf16. +# +# rad-convert /hunyuan3d-dit-v2-0 \ +# --recipe data/recipes/hunyuan3d-2-bf16.recipe -o hunyuan3d-2-bf16.rad +# +# The folder holds config.yaml and model.fp16.safetensors (the DiT, the DINOv2 image encoder and +# the shape VAE in one file), read as one checkpoint. The release ships fp16; every weight is cast +# to bf16 but the two projections that read f32 inputs (the picture's patches and the query points' +# embedding) and the DiT's q and k norm gains, which are widened to f32 exactly. + +dino.patch.* cast dtype=f32 +geo.query_proj.* cast dtype=f32 +dit.*.q_norm cast dtype=f32 +dit.*.k_norm cast dtype=f32 +* cast dtype=bf16 diff --git a/data/recipes/ling3-w4a8-gptq.recipe b/data/recipes/ling3-w4a8-gptq.recipe new file mode 100644 index 00000000..cef55bea --- /dev/null +++ b/data/recipes/ling3-w4a8-gptq.recipe @@ -0,0 +1,18 @@ +# ling3-w4a8-gptq.recipe -- Ling-3.0-flash or a fine-tune of it (Ling-3.0-flash-Sante) from the bf16 +# checkpoint: the routed experts at four bits, an int4 code and a bf16 scale per 128 of K, chosen by +# GPTQ against the Hessians of a calibration run (docs/MOE-W4.md "Calibration"); everything else as +# the checkpoint holds it. The format is ling3-w4a8-rtn.recipe's, so the same kernels serve both. +# +# 1. rad-convert --recipe data/recipes/ling3-w4a8-rtn.recipe -o ling3-w4a8-rtn.rad +# 2. RADIANCE_CALIB_DIR= radiance --model ling3-w4a8-rtn.rad ... (a calibration run: +# whole experts per rank; push a corpus that looks like the traffic through prefill) +# 3. CALIB= rad-convert --recipe data/recipes/ling3-w4a8-gptq.recipe \ +# --reuse ling3-w4a8-rtn.rad -o ling3-w4a8-gptq.rad +# +# A routed expert's down projection takes its own Hessian where the calibration routed it enough rows, +# the layer's pooled one otherwise (libquant says which on stderr). +# +# Measured on Ling-3.0-flash-Sante as ling3-w4a8-rtn.recipe is: mean KL 0.036, top-1 agreement +# 92.96%, from 1.26M calibration tokens of medical text, documents, code, tool calls and chat. + +blk.*.ffn_*_exps.*.weight gptq codes=i4 group=128 scale=bf16 calib=$CALIB diff --git a/data/recipes/ling3-w4a8-rtn.recipe b/data/recipes/ling3-w4a8-rtn.recipe new file mode 100644 index 00000000..ea0b4f1b --- /dev/null +++ b/data/recipes/ling3-w4a8-rtn.recipe @@ -0,0 +1,14 @@ +# ling3-w4a8-rtn.recipe -- Ling-3.0-flash or a fine-tune of it (Ling-3.0-flash-Sante) from the bf16 +# checkpoint: the routed experts at four bits, an int4 code and a bf16 scale per 128 of K, rounded to +# nearest; everything else as the checkpoint holds it (the KDA and MLA projections, the dense layers, +# the shared expert, the router, the embedding and lm_head in bf16). +# +# rad-convert --recipe data/recipes/ling3-w4a8-rtn.recipe -o ling3-w4a8-rtn.rad +# +# It is the container to calibrate in: served with RADIANCE_CALIB_DIR set, its experts' Grams feed +# the GPTQ recipe. +# +# Measured on Ling-3.0-flash-Sante with the engine's KL mode against the bf16 model (wikitext-2, +# 100 chunks of 512 tokens, the second half of each scored): mean KL 0.038, top-1 agreement 92.54%. + +blk.*.ffn_*_exps.*.weight rtn codes=i4 group=128 scale=bf16 diff --git a/data/recipes/nemotron74-fp8.recipe b/data/recipes/nemotron74-fp8.recipe new file mode 100644 index 00000000..b187220b --- /dev/null +++ b/data/recipes/nemotron74-fp8.recipe @@ -0,0 +1,21 @@ +# nemotron74-fp8.recipe -- Nemotron-3.5-Bolt-74B-A9B (nemotron_h_omni) from its bf16 checkpoint: every +# block linear and every routed expert as block fp8 (E4M3 codes, a bf16 scale a 128x128 tile); the +# rest as the checkpoint holds it: dt's 128 rows of in_proj (32 a rank at four ranks, no whole scale +# block), the convolution, A_log, dt_bias, D, the norms, the router (f32), the embedding and lm_head. +# +# rad-convert --recipe data/recipes/nemotron74-fp8.recipe -o nemotron74-fp8.rad +# +# It is the container the GPTQ calibration runs on (RADIANCE_CALIB_DIR; whole experts per rank, +# RADIANCE_CALIB_LAYERS to split the per-expert Hessians over runs) and the fp8 reference for the +# four-bit containers. + +blk.*.ssm_in_z.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 +blk.*.ssm_in_xbc.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 +blk.*.ssm_out.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 +blk.*.attn_qkv.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 +blk.*.attn_output.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 +blk.*.ffn_latent_in.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 +blk.*.ffn_latent_out.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 +blk.*.ffn_up_shexp.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 +blk.*.ffn_down_shexp.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 +blk.*.ffn_*_exps.*.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 diff --git a/data/recipes/nemotron74-w4nl64-gptq.recipe b/data/recipes/nemotron74-w4nl64-gptq.recipe new file mode 100644 index 00000000..c5e5f184 --- /dev/null +++ b/data/recipes/nemotron74-w4nl64-gptq.recipe @@ -0,0 +1,44 @@ +# nemotron74-w4nl64-gptq.recipe -- Nemotron-3.5-Bolt-74B-A9B (nemotron_h_omni) from its bf16 +# checkpoint: the routed experts as rotated u4 codes into the w4nl codebook with one E4M3 scale a +# (row, 64 of K) under a fixed f32 of 2^-13 (libr4d's w4nl64a8h), the codes chosen by GPTQ against +# $CALIB and three sweeps of coordinate descent, as qwen4exp-w4nl64-i8-hc8m.recipe does; the block +# linears block fp8, as nemotron74-fp8.recipe; the rest as the checkpoint holds it. +# +# CALIB=DIR rad-convert --recipe data/recipes/nemotron74-w4nl64-gptq.recipe \ +# -o nemotron74-w4nl64.rad +# +# DIR holds each routed layer's pooled up Gram (K = the 1024-wide latent) and each expert's own down +# Gram, recorded on nemotron74-fp8.rad (RADIANCE_CALIB_LAYERS splits the per-expert Hessians, 169 +# GiB for all 40 layers, over several runs). Without $CALIB the experts are rounded to nearest. + +blk.*.ffn_*_exps.*.weight gptq table=w4nl group=64 scale=fp8_e4m3 scale2=f32 block2=*x* scale2_value=0.0001220703125 transform=fwht128 rule=search cd=3 calib=$CALIB + +blk.*.ssm_in_z.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 +blk.*.ssm_in_xbc.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 +blk.*.ssm_out.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 +blk.*.attn_qkv.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 +blk.*.attn_output.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 +blk.*.ffn_latent_in.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 +blk.*.ffn_latent_out.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 +blk.*.ffn_up_shexp.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 +blk.*.ffn_down_shexp.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 + +# The LiLiCorr drafter, when merged (`--draft-model `): ModelOpt NVFP4 +# for fc, the backbone's MLPs and six of the correlator's linears, bf16 elsewhere (rad-convert +# reads the NVFP4 under the drafter's prefix). The backbone's seven linears block fp8, as +# rad_block_dflash2.h's DenseFP8 reads them (Gemma's DFlash2 recipe); NVFP4 to E4M3 with a scale a +# 128 x 128 block loses less than the NVFP4 grid already did. The correlator's NVFP4 linears are +# decoded to bf16 for its plain GEMMs; its other weights stay as shipped. +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.lili.token_proj.weight cast dtype=bf16 +dflash.lili.pass_proj.weight cast dtype=bf16 +dflash.lili.context_proj.weight cast dtype=bf16 +dflash.lili.blk.*.attn_out.weight cast dtype=bf16 +dflash.lili.blk.*.mlp_up.weight cast dtype=bf16 +dflash.lili.blk.*.mlp_down.weight cast dtype=bf16 diff --git a/data/recipes/q38-27b-iq2r-l-v4.recipe b/data/recipes/q38-27b-iq2r-l-v4.recipe new file mode 100644 index 00000000..fb1b93d0 --- /dev/null +++ b/data/recipes/q38-27b-iq2r-l-v4.recipe @@ -0,0 +1,308 @@ +# q38-27b-iq2r-l-v4.recipe -- IQ2R-L-V4: Qwen3.8-27B at ~2.797 bits a weight. +# IQR-V4: every trunk linear rotated by fwht128 and fitted by GPTQ in act order (tcq_order=1) against the +# calib Hessians, its codes a tail-biting trellis down each column whose 2^16 states' values are computed +# from the state (tcq=16 tcq_code=mad; 2^15 at two bits) under one f32 scale a row, the head-fed projections +# under a bf16 scale a (row, 128) block; widths by layer band and projection from measured prices +# (2-bit, 3-bit, 4-bit; docs/IQR.md, "IQR-V4"). Served by qwen35_w8a8 at i8a8h with rotated int8 activations. +# The lm_head is vocabulary-weighted (4.0 b mean, data/vhead/): its width classes output.k are +# rows of the checkpoint tools/vhead.py builds from the bf16 one; GPTQ reads the head's input Hessian. +# +# python3 tools/vhead.py VHEAD data/vhead/q38-27b-vhead-4.0.cls +# CALIB= rad-convert VHEAD --recipe data/recipes/q38-27b-iq2r-l-v4.recipe \ +# --set quantization_config.quant_method=w8a8 --set quantization_config.fmt=fwht128 -o OUT.rad +# +# The competition's private tiers 1+2: 2.797 bpw, mean KL 0.03602, top-1 93.29% (IQ2R-L-V3: 2.786 bpw, 0.04241). + +blk.0.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_qg.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_k.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_v.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_qg.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_k.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_v.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +token_embd.weight gptq codes=u2 tcq=12 tcq_rows=256 tcq_lut=data/codebooks/iqr-tcq-L12-k2.txt group=128 scale=fp8_e4m3 scale2=f32 block2=*x* transform=fwht128 +output.k3.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +output.k4.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +output.k5.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +output.k6.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 diff --git a/data/recipes/q38-27b-iq2r-v4.recipe b/data/recipes/q38-27b-iq2r-v4.recipe new file mode 100644 index 00000000..e40d3d22 --- /dev/null +++ b/data/recipes/q38-27b-iq2r-v4.recipe @@ -0,0 +1,308 @@ +# q38-27b-iq2r-v4.recipe -- IQ2R-V4: Qwen3.8-27B at ~2.470 bits a weight. +# IQR-V4: every trunk linear rotated by fwht128 and fitted by GPTQ in act order (tcq_order=1) against the +# calib Hessians, its codes a tail-biting trellis down each column whose 2^16 states' values are computed +# from the state (tcq=16 tcq_code=mad; 2^15 at two bits) under one f32 scale a row, the head-fed projections +# under a bf16 scale a (row, 128) block; widths by layer band and projection from measured prices +# (2-bit, 3-bit, 4-bit; docs/IQR.md, "IQR-V4"). Served by qwen35_w8a8 at i8a8h with rotated int8 activations. +# The lm_head is vocabulary-weighted (4.0 b mean, data/vhead/): its width classes output.k are +# rows of the checkpoint tools/vhead.py builds from the bf16 one; GPTQ reads the head's input Hessian. +# +# python3 tools/vhead.py VHEAD data/vhead/q38-27b-vhead-4.0.cls +# CALIB= rad-convert VHEAD --recipe data/recipes/q38-27b-iq2r-v4.recipe \ +# --set quantization_config.quant_method=w8a8 --set quantization_config.fmt=fwht128 -o OUT.rad +# +# The competition's private tiers 1+2: 2.470 bpw, mean KL 0.06113, top-1 91.23% (IQ2R-V3: 2.465 bpw, 0.06807). + +blk.0.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_qg.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_k.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_v.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_qg.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_k.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_v.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_out.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_out.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_out.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_qg.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_k.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_v.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_output.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_out.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_out.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_out.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_qg.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_k.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_v.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_output.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_out.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_out.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_out.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_qg.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_k.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_v.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_output.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_out.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_out.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_out.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_qg.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_k.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_v.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_output.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.ffn_down.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_qg.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_k.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_v.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_qg.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_k.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_v.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_qg.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_k.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_v.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_qg.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_k.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_v.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_qg.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_k.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_v.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_inz.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_qg.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_k.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_v.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +token_embd.weight gptq codes=u2 tcq=12 tcq_rows=256 tcq_lut=data/codebooks/iqr-tcq-L12-k2.txt group=128 scale=fp8_e4m3 scale2=f32 block2=*x* transform=fwht128 +output.k3.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +output.k4.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +output.k5.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +output.k6.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 diff --git a/data/recipes/q38-27b-iq3r-l-v4.recipe b/data/recipes/q38-27b-iq3r-l-v4.recipe new file mode 100644 index 00000000..309626bd --- /dev/null +++ b/data/recipes/q38-27b-iq3r-l-v4.recipe @@ -0,0 +1,308 @@ +# q38-27b-iq3r-l-v4.recipe -- IQ3R-L-V4: Qwen3.8-27B at ~3.804 bits a weight. +# IQR-V4: every trunk linear rotated by fwht128 and fitted by GPTQ in act order (tcq_order=1) against the +# calib Hessians, its codes a tail-biting trellis down each column whose 2^16 states' values are computed +# from the state (tcq=16 tcq_code=mad; 2^15 at two bits) under one f32 scale a row, the head-fed projections +# under a bf16 scale a (row, 128) block; widths by layer band and projection from measured prices +# (3-bit, 4-bit, 5-bit, 6-bit; docs/IQR.md, "IQR-V4"). Served by qwen35_w8a8 at i8a8h with rotated int8 activations. +# The lm_head is vocabulary-weighted (4.0 b mean, data/vhead/): its width classes output.k are +# rows of the checkpoint tools/vhead.py builds from the bf16 one; GPTQ reads the head's input Hessian. +# +# python3 tools/vhead.py VHEAD data/vhead/q38-27b-vhead-4.0.cls +# CALIB= rad-convert VHEAD --recipe data/recipes/q38-27b-iq3r-l-v4.recipe \ +# --set quantization_config.quant_method=w8a8 --set quantization_config.fmt=fwht128 -o OUT.rad +# +# The competition's private tiers 1+2: 3.804 bpw, mean KL 0.00917, top-1 96.61% (IQ3R-L-V3: 3.798 bpw, 0.01129). + +blk.0.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +token_embd.weight gptq codes=u3 tcq=12 tcq_rows=256 tcq_lut=data/codebooks/iqr-tcq-L12-k3.txt group=128 scale=fp8_e4m3 scale2=f32 block2=*x* transform=fwht128 +output.k3.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +output.k4.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +output.k5.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +output.k6.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 diff --git a/data/recipes/q38-27b-iq3r-s-v4.recipe b/data/recipes/q38-27b-iq3r-s-v4.recipe new file mode 100644 index 00000000..b7e08ec8 --- /dev/null +++ b/data/recipes/q38-27b-iq3r-s-v4.recipe @@ -0,0 +1,308 @@ +# q38-27b-iq3r-s-v4.recipe -- IQ3R-S-V4: Qwen3.8-27B at ~3.157 bits a weight. +# IQR-V4: every trunk linear rotated by fwht128 and fitted by GPTQ in act order (tcq_order=1) against the +# calib Hessians, its codes a tail-biting trellis down each column whose 2^16 states' values are computed +# from the state (tcq=16 tcq_code=mad; 2^15 at two bits) under one f32 scale a row, the head-fed projections +# under a bf16 scale a (row, 128) block; widths by layer band and projection from measured prices +# (2-bit, 3-bit, 4-bit, 5-bit; docs/IQR.md, "IQR-V4"). Served by qwen35_w8a8 at i8a8h with rotated int8 activations. +# The lm_head is vocabulary-weighted (4.0 b mean, data/vhead/): its width classes output.k are +# rows of the checkpoint tools/vhead.py builds from the bf16 one; GPTQ reads the head's input Hessian. +# +# python3 tools/vhead.py VHEAD data/vhead/q38-27b-vhead-4.0.cls +# CALIB= rad-convert VHEAD --recipe data/recipes/q38-27b-iq3r-s-v4.recipe \ +# --set quantization_config.quant_method=w8a8 --set quantization_config.fmt=fwht128 -o OUT.rad +# +# The competition's private tiers 1+2: 3.157 bpw, mean KL 0.02241, top-1 94.75% (IQ3R-S-V3: 3.145 bpw, 0.02584). + +blk.0.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.ffn_gate_up.weight gptq codes=u2 tcq=15 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.04 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +token_embd.weight gptq codes=u2 tcq=12 tcq_rows=256 tcq_lut=data/codebooks/iqr-tcq-L12-k2.txt group=128 scale=fp8_e4m3 scale2=f32 block2=*x* transform=fwht128 +output.k3.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +output.k4.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +output.k5.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +output.k6.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 diff --git a/data/recipes/q38-27b-iq3r-v4.recipe b/data/recipes/q38-27b-iq3r-v4.recipe new file mode 100644 index 00000000..6de8db27 --- /dev/null +++ b/data/recipes/q38-27b-iq3r-v4.recipe @@ -0,0 +1,308 @@ +# q38-27b-iq3r-v4.recipe -- IQ3R-V4: Qwen3.8-27B at ~3.472 bits a weight. +# IQR-V4: every trunk linear rotated by fwht128 and fitted by GPTQ in act order (tcq_order=1) against the +# calib Hessians, its codes a tail-biting trellis down each column whose 2^16 states' values are computed +# from the state (tcq=16 tcq_code=mad; 2^15 at two bits) under one f32 scale a row, the head-fed projections +# under a bf16 scale a (row, 128) block; widths by layer band and projection from measured prices +# (3-bit, 4-bit, 5-bit; docs/IQR.md, "IQR-V4"). Served by qwen35_w8a8 at i8a8h with rotated int8 activations. +# The lm_head is vocabulary-weighted (4.0 b mean, data/vhead/): its width classes output.k are +# rows of the checkpoint tools/vhead.py builds from the bf16 one; GPTQ reads the head's input Hessian. +# +# python3 tools/vhead.py VHEAD data/vhead/q38-27b-vhead-4.0.cls +# CALIB= rad-convert VHEAD --recipe data/recipes/q38-27b-iq3r-v4.recipe \ +# --set quantization_config.quant_method=w8a8 --set quantization_config.fmt=fwht128 -o OUT.rad +# +# The competition's private tiers 1+2: 3.472 bpw, mean KL 0.01495, top-1 95.74% (IQ3R-V3: 3.459 bpw, 0.01698). + +blk.0.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_out.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_output.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.ffn_down.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +token_embd.weight gptq codes=u3 tcq=12 tcq_rows=256 tcq_lut=data/codebooks/iqr-tcq-L12-k3.txt group=128 scale=fp8_e4m3 scale2=f32 block2=*x* transform=fwht128 +output.k3.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +output.k4.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +output.k5.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +output.k6.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 diff --git a/data/recipes/q38-27b-iq4r-l-v4.recipe b/data/recipes/q38-27b-iq4r-l-v4.recipe new file mode 100644 index 00000000..cdabe0c0 --- /dev/null +++ b/data/recipes/q38-27b-iq4r-l-v4.recipe @@ -0,0 +1,308 @@ +# q38-27b-iq4r-l-v4.recipe -- IQ4R-L-V4: Qwen3.8-27B at ~4.793 bits a weight. +# IQR-V4: every trunk linear rotated by fwht128 and fitted by GPTQ in act order (tcq_order=1) against the +# calib Hessians, its codes a tail-biting trellis down each column whose 2^16 states' values are computed +# from the state (tcq=16 tcq_code=mad; 2^15 at two bits) under one f32 scale a row, the head-fed projections +# under a bf16 scale a (row, 128) block; widths by layer band and projection from measured prices +# (4-bit, 5-bit, 6-bit; docs/IQR.md, "IQR-V4"). Served by qwen35_w8a8 at i8a8h with rotated int8 activations. +# The lm_head is vocabulary-weighted (4.5 b mean, data/vhead/): its width classes output.k are +# rows of the checkpoint tools/vhead.py builds from the bf16 one; GPTQ reads the head's input Hessian. +# +# python3 tools/vhead.py VHEAD data/vhead/q38-27b-vhead-4.5.cls +# CALIB= rad-convert VHEAD --recipe data/recipes/q38-27b-iq4r-l-v4.recipe \ +# --set quantization_config.quant_method=w8a8 --set quantization_config.fmt=fwht128 -o OUT.rad +# +# The competition's private tiers 1+2: 4.793 bpw, mean KL 0.00297, top-1 98.07% (IQ4R-L-V3: 4.783 bpw, 0.00342). + +blk.0.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.0.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.1.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.2.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.3.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.4.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.5.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.6.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.7.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.16.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.17.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.18.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.19.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.20.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.21.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.22.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.23.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.24.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.25.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.26.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.27.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.28.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.29.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.30.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.31.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.32.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.33.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.34.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.35.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.36.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.37.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.38.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.39.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.40.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.41.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.42.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.43.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.44.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.45.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.46.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.47.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.48.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.49.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.50.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.51.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.52.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.53.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.54.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.55.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.56.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.57.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.58.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.59.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.60.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.61.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.62.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.63.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +token_embd.weight gptq codes=u4 tcq=12 tcq_rows=256 tcq_lut=data/codebooks/iqr-tcq-L12-k4.txt group=128 scale=fp8_e4m3 scale2=f32 block2=*x* transform=fwht128 +output.k4.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +output.k5.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +output.k6.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +output.k7.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.3 damp=0.01 calib=$CALIB tcq_order=1 diff --git a/data/recipes/q38-27b-iq4r-s-v4.recipe b/data/recipes/q38-27b-iq4r-s-v4.recipe new file mode 100644 index 00000000..a3f4477c --- /dev/null +++ b/data/recipes/q38-27b-iq4r-s-v4.recipe @@ -0,0 +1,308 @@ +# q38-27b-iq4r-s-v4.recipe -- IQ4R-S-V4: Qwen3.8-27B at ~4.142 bits a weight. +# IQR-V4: every trunk linear rotated by fwht128 and fitted by GPTQ in act order (tcq_order=1) against the +# calib Hessians, its codes a tail-biting trellis down each column whose 2^16 states' values are computed +# from the state (tcq=16 tcq_code=mad; 2^15 at two bits) under one f32 scale a row, the head-fed projections +# under a bf16 scale a (row, 128) block; widths by layer band and projection from measured prices +# (3-bit, 4-bit, 5-bit; docs/IQR.md, "IQR-V4"). Served by qwen35_w8a8 at i8a8h with rotated int8 activations. +# The lm_head is vocabulary-weighted (4.0 b mean, data/vhead/): its width classes output.k are +# rows of the checkpoint tools/vhead.py builds from the bf16 one; GPTQ reads the head's input Hessian. +# +# python3 tools/vhead.py VHEAD data/vhead/q38-27b-vhead-4.0.cls +# CALIB= rad-convert VHEAD --recipe data/recipes/q38-27b-iq4r-s-v4.recipe \ +# --set quantization_config.quant_method=w8a8 --set quantization_config.fmt=fwht128 -o OUT.rad +# +# The competition's private tiers 1+2: 4.142 bpw, mean KL 0.00643, top-1 97.12% (IQ4R-S-V3: 4.131 bpw, 0.00762). + +blk.0.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.0.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.1.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.2.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.3.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.4.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.5.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.6.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.7.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_inz.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_qg.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_k.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_v.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.ffn_gate_up.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.24.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.25.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.26.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.27.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.28.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.29.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.30.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.31.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.32.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.33.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.34.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.35.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.36.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.37.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.38.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.39.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.40.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.41.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.42.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.43.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.44.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.45.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.46.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.47.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.48.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.49.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.50.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.51.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.52.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.53.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.54.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.55.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.56.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.57.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.58.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.59.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.60.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.61.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.62.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.63.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +token_embd.weight gptq codes=u4 tcq=12 tcq_rows=256 tcq_lut=data/codebooks/iqr-tcq-L12-k4.txt group=128 scale=fp8_e4m3 scale2=f32 block2=*x* transform=fwht128 +output.k3.weight gptq codes=u3 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.08 damp=0.01 calib=$CALIB tcq_order=1 +output.k4.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +output.k5.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +output.k6.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 diff --git a/data/recipes/q38-27b-iq4r-v4.recipe b/data/recipes/q38-27b-iq4r-v4.recipe new file mode 100644 index 00000000..6f64d761 --- /dev/null +++ b/data/recipes/q38-27b-iq4r-v4.recipe @@ -0,0 +1,308 @@ +# q38-27b-iq4r-v4.recipe -- IQ4R-V4: Qwen3.8-27B at ~4.473 bits a weight. +# IQR-V4: every trunk linear rotated by fwht128 and fitted by GPTQ in act order (tcq_order=1) against the +# calib Hessians, its codes a tail-biting trellis down each column whose 2^16 states' values are computed +# from the state (tcq=16 tcq_code=mad; 2^15 at two bits) under one f32 scale a row, the head-fed projections +# under a bf16 scale a (row, 128) block; widths by layer band and projection from measured prices +# (4-bit, 5-bit, 6-bit; docs/IQR.md, "IQR-V4"). Served by qwen35_w8a8 at i8a8h with rotated int8 activations. +# The lm_head is vocabulary-weighted (4.5 b mean, data/vhead/): its width classes output.k are +# rows of the checkpoint tools/vhead.py builds from the bf16 one; GPTQ reads the head's input Hessian. +# +# python3 tools/vhead.py VHEAD data/vhead/q38-27b-vhead-4.5.cls +# CALIB= rad-convert VHEAD --recipe data/recipes/q38-27b-iq4r-v4.recipe \ +# --set quantization_config.quant_method=w8a8 --set quantization_config.fmt=fwht128 -o OUT.rad +# +# The competition's private tiers 1+2: 4.473 bpw, mean KL 0.00444, top-1 97.69% (IQ4R-V3: 4.458 bpw, 0.00512). + +blk.0.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.0.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.1.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.2.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.3.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.4.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.5.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.6.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.7.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_out.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_output.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.16.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.17.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.18.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.19.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.20.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.21.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.22.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.23.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.24.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.25.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.26.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.27.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.28.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.29.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.30.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.31.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.32.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.33.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.34.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.35.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.36.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.37.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.38.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.39.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.40.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.41.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.42.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.43.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.44.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.45.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.46.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.47.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.48.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.49.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.50.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.51.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.52.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.53.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.54.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.55.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.56.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.57.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.58.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.59.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.60.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.61.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.62.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.63.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +token_embd.weight gptq codes=u3 tcq=12 tcq_rows=256 tcq_lut=data/codebooks/iqr-tcq-L12-k3.txt group=128 scale=fp8_e4m3 scale2=f32 block2=*x* transform=fwht128 +output.k4.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +output.k5.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +output.k6.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +output.k7.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.3 damp=0.01 calib=$CALIB tcq_order=1 diff --git a/data/recipes/q38-27b-iq5r-s-v4.recipe b/data/recipes/q38-27b-iq5r-s-v4.recipe new file mode 100644 index 00000000..e600eb76 --- /dev/null +++ b/data/recipes/q38-27b-iq5r-s-v4.recipe @@ -0,0 +1,308 @@ +# q38-27b-iq5r-s-v4.recipe -- IQ5R-S-V4: Qwen3.8-27B at ~5.071 bits a weight. +# IQR-V4: every trunk linear rotated by fwht128 and fitted by GPTQ in act order (tcq_order=1) against the +# calib Hessians, its codes a tail-biting trellis down each column whose 2^16 states' values are computed +# from the state (tcq=16 tcq_code=mad; 2^15 at two bits) under one f32 scale a row, the head-fed projections +# under a bf16 scale a (row, 128) block; widths by layer band and projection from measured prices +# (4-bit, 5-bit, 6-bit; docs/IQR.md, "IQR-V4"). Served by qwen35_w8a8 at i8a8h with rotated int8 activations. +# The lm_head is vocabulary-weighted (5.0 b mean, data/vhead/): its width classes output.k are +# rows of the checkpoint tools/vhead.py builds from the bf16 one; GPTQ reads the head's input Hessian. +# +# python3 tools/vhead.py VHEAD data/vhead/q38-27b-vhead-5.0.cls +# CALIB= rad-convert VHEAD --recipe data/recipes/q38-27b-iq5r-s-v4.recipe \ +# --set quantization_config.quant_method=w8a8 --set quantization_config.fmt=fwht128 -o OUT.rad +# +# The competition's private tiers 1+2: 5.071 bpw, mean KL 0.00223, top-1 98.33% (IQ5R-S-V3: 5.064 bpw, 0.00249). + +blk.0.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.0.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.1.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.2.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.3.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.4.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.5.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.6.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.7.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.8.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.9.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.10.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.11.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.12.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.13.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_inz.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.14.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_qg.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_k.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_v.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.15.ffn_gate_up.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.ffn_down.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=1024 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.16.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.17.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.18.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.19.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.20.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.21.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.22.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.23.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.24.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.25.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.26.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.27.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.28.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.29.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.30.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.31.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.32.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.33.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.34.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.35.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.36.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.37.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.38.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.39.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.40.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.41.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.42.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.43.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.44.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.45.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.46.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.47.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.48.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.49.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.50.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.51.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.52.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.53.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.54.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.55.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.56.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.57.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.58.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.59.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.60.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.61.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.62.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.63.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +token_embd.weight gptq codes=u5 tcq=12 tcq_rows=256 tcq_lut=data/codebooks/iqr-tcq-L12-k5.txt group=128 scale=fp8_e4m3 scale2=f32 block2=*x* transform=fwht128 +output.k4.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +output.k5.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +output.k6.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +output.k7.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.3 damp=0.01 calib=$CALIB tcq_order=1 diff --git a/data/recipes/q38-27b-iq5r-v4.recipe b/data/recipes/q38-27b-iq5r-v4.recipe new file mode 100644 index 00000000..f0549dd7 --- /dev/null +++ b/data/recipes/q38-27b-iq5r-v4.recipe @@ -0,0 +1,308 @@ +# q38-27b-iq5r-v4.recipe -- IQ5R-V4: Qwen3.8-27B at ~5.433 bits a weight. +# IQR-V4: every trunk linear rotated by fwht128 and fitted by GPTQ in act order (tcq_order=1) against the +# calib Hessians, its codes a tail-biting trellis down each column whose 2^16 states' values are computed +# from the state (tcq=16 tcq_code=mad; 2^15 at two bits) under one f32 scale a row, the head-fed projections +# under a bf16 scale a (row, 128) block; widths by layer band and projection from measured prices +# (5-bit, 6-bit; docs/IQR.md, "IQR-V4"). Served by qwen35_w8a8 at i8a8h with rotated int8 activations. +# The lm_head is vocabulary-weighted (5.0 b mean, data/vhead/): its width classes output.k are +# rows of the checkpoint tools/vhead.py builds from the bf16 one; GPTQ reads the head's input Hessian. +# +# python3 tools/vhead.py VHEAD data/vhead/q38-27b-vhead-5.0.cls +# CALIB= rad-convert VHEAD --recipe data/recipes/q38-27b-iq5r-v4.recipe \ +# --set quantization_config.quant_method=w8a8 --set quantization_config.fmt=fwht128 -o OUT.rad +# +# The competition's private tiers 1+2: 5.433 bpw, mean KL 0.00154, top-1 98.60% (IQ5R-V3: 5.422 bpw, 0.00182). + +blk.0.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.0.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.1.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.2.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.3.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.4.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.5.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.6.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.7.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.8.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.9.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.10.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.11.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.12.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.13.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.14.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.15.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.16.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.17.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.18.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.19.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.20.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.21.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.22.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.23.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.24.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.25.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.26.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.27.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.28.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.29.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.30.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.31.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.32.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.33.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.34.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.35.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.36.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.37.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.38.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.39.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.40.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.41.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.42.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.43.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.44.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.45.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.46.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.47.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.48.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.49.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.50.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.51.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.52.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.53.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.54.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.55.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.56.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.57.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.58.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.59.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.60.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.61.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.62.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.63.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +token_embd.weight gptq codes=u4 tcq=12 tcq_rows=256 tcq_lut=data/codebooks/iqr-tcq-L12-k4.txt group=128 scale=fp8_e4m3 scale2=f32 block2=*x* transform=fwht128 +output.k4.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +output.k5.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +output.k6.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +output.k7.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.3 damp=0.01 calib=$CALIB tcq_order=1 diff --git a/data/recipes/q38-27b-iq6r-l-v4.recipe b/data/recipes/q38-27b-iq6r-l-v4.recipe new file mode 100644 index 00000000..7a02eb4f --- /dev/null +++ b/data/recipes/q38-27b-iq6r-l-v4.recipe @@ -0,0 +1,303 @@ +# q38-27b-iq6r-l-v4.recipe -- IQ6R-L-V4: Qwen3.8-27B at ~6.939 bits a weight. +# IQR-V4: every trunk linear rotated by fwht128 and fitted by GPTQ in act order (tcq_order=1) against the +# calib Hessians, its codes a tail-biting trellis down each column whose 2^16 states' values are computed +# from the state (tcq=16 tcq_code=mad; 2^15 at two bits) under one f32 scale a row, the head-fed projections +# under a bf16 scale a (row, 128) block; widths by layer band and projection from measured prices +# (6-bit, 7-bit, int8; docs/IQR.md, "IQR-V4"). Served by qwen35_w8a8 at i8a8h with rotated int8 activations. +# The lm_head is int8, GPTQ'd against the head's input Hessian. +# +# CALIB= rad-convert --recipe data/recipes/q38-27b-iq6r-l-v4.recipe \ +# --set quantization_config.quant_method=w8a8 --set quantization_config.fmt=fwht128 -o OUT.rad +# +# The competition's private tiers 1+2: 6.939 bpw, mean KL 0.00068, top-1 99.08% (IQ6R-L-V3: 6.939 bpw, 0.00072). + +blk.0.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.56.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.56.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.56.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.57.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.57.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.57.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.57.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.58.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.58.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.58.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.58.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.59.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.59.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.59.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.59.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.59.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.59.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.60.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.60.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.60.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.60.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.61.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.61.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.61.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.61.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.62.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.62.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.62.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.62.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.63.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.63.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.63.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.63.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.63.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.63.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +token_embd.weight rtn codes=u6 zero=u6 group=128 scale=bf16 rule=search +output.weight gptq codes=i8 group=128 scale=bf16 clamp=sym rule=search damp=0.01 calib=$CALIB diff --git a/data/recipes/q38-27b-iq6r-s-v4.recipe b/data/recipes/q38-27b-iq6r-s-v4.recipe new file mode 100644 index 00000000..a1c4c509 --- /dev/null +++ b/data/recipes/q38-27b-iq6r-s-v4.recipe @@ -0,0 +1,308 @@ +# q38-27b-iq6r-s-v4.recipe -- IQ6R-S-V4: Qwen3.8-27B at ~6.063 bits a weight. +# IQR-V4: every trunk linear rotated by fwht128 and fitted by GPTQ in act order (tcq_order=1) against the +# calib Hessians, its codes a tail-biting trellis down each column whose 2^16 states' values are computed +# from the state (tcq=16 tcq_code=mad; 2^15 at two bits) under one f32 scale a row, the head-fed projections +# under a bf16 scale a (row, 128) block; widths by layer band and projection from measured prices +# (5-bit, 6-bit, int8; docs/IQR.md, "IQR-V4"). Served by qwen35_w8a8 at i8a8h with rotated int8 activations. +# The lm_head is vocabulary-weighted (5.0 b mean, data/vhead/): its width classes output.k are +# rows of the checkpoint tools/vhead.py builds from the bf16 one; GPTQ reads the head's input Hessian. +# +# python3 tools/vhead.py VHEAD data/vhead/q38-27b-vhead-5.0.cls +# CALIB= rad-convert VHEAD --recipe data/recipes/q38-27b-iq6r-s-v4.recipe \ +# --set quantization_config.quant_method=w8a8 --set quantization_config.fmt=fwht128 -o OUT.rad +# +# The competition's private tiers 1+2: 6.063 bpw, mean KL 0.00100, top-1 98.86% (IQ6R-S-V3: 6.049 bpw, 0.00106). + +blk.0.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.0.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.1.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.2.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.3.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.4.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.5.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.6.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.7.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.8.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.9.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.10.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.11.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.12.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.13.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_inz.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_out.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.14.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_qg.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_k.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_v.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_output.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.15.ffn_gate_up.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.ffn_down.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.16.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.17.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.18.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.19.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.20.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.21.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.22.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.23.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.24.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.25.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.26.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.27.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.28.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.29.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.30.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.31.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.32.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.33.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.34.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.35.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.36.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.37.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.38.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.39.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.40.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.41.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.42.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.43.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.44.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.45.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.46.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.47.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.48.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.49.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.50.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.51.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.52.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.53.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.54.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.55.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.56.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.56.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.56.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.57.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.57.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.57.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.57.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.58.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.58.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.58.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.58.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.59.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.59.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.59.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.59.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.59.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.59.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.60.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.60.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.60.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.60.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.61.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.61.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.61.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.61.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.62.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.62.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.62.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.62.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.63.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.63.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.63.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.63.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.63.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.63.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +token_embd.weight gptq codes=u5 tcq=12 tcq_rows=256 tcq_lut=data/codebooks/iqr-tcq-L12-k5.txt group=128 scale=fp8_e4m3 scale2=f32 block2=*x* transform=fwht128 +output.k4.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +output.k5.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +output.k6.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +output.k7.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.3 damp=0.01 calib=$CALIB tcq_order=1 diff --git a/data/recipes/q38-27b-iq6r-v4.recipe b/data/recipes/q38-27b-iq6r-v4.recipe new file mode 100644 index 00000000..a7bcfd0d --- /dev/null +++ b/data/recipes/q38-27b-iq6r-v4.recipe @@ -0,0 +1,308 @@ +# q38-27b-iq6r-v4.recipe -- IQ6R-V4: Qwen3.8-27B at ~6.439 bits a weight. +# IQR-V4: every trunk linear rotated by fwht128 and fitted by GPTQ in act order (tcq_order=1) against the +# calib Hessians, its codes a tail-biting trellis down each column whose 2^16 states' values are computed +# from the state (tcq=16 tcq_code=mad; 2^15 at two bits) under one f32 scale a row, the head-fed projections +# under a bf16 scale a (row, 128) block; widths by layer band and projection from measured prices +# (6-bit, 7-bit; docs/IQR.md, "IQR-V4"). Served by qwen35_w8a8 at i8a8h with rotated int8 activations. +# The lm_head is vocabulary-weighted (5.0 b mean, data/vhead/): its width classes output.k are +# rows of the checkpoint tools/vhead.py builds from the bf16 one; GPTQ reads the head's input Hessian. +# +# python3 tools/vhead.py VHEAD data/vhead/q38-27b-vhead-5.0.cls +# CALIB= rad-convert VHEAD --recipe data/recipes/q38-27b-iq6r-v4.recipe \ +# --set quantization_config.quant_method=w8a8 --set quantization_config.fmt=fwht128 -o OUT.rad +# +# The competition's private tiers 1+2: 6.439 bpw, mean KL 0.00081, top-1 98.96% (IQ6R-V3: 6.372 bpw, 0.00088). + +blk.0.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.0.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.1.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.2.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.3.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.4.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.5.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.6.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.7.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.8.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.9.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.10.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.11.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.12.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.13.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.14.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.15.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.16.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.17.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.18.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.19.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.20.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.21.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.22.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.23.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.24.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.25.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.26.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.27.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.28.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.29.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.30.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 group=128 scale=bf16 dyn=1 transform=fwht128 tcq_gain=1.2 damp=0.01 calib=$CALIB +blk.31.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.ffn_down.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.33.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.34.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.35.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.36.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.37.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.38.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.39.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.40.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.49.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.50.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.51.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.52.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.53.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.54.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.55.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.56.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.57.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.58.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.59.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.60.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.61.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.62.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.63.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +token_embd.weight rtn codes=u6 zero=u6 group=128 scale=bf16 rule=search +output.k4.weight gptq codes=u4 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.12 damp=0.01 calib=$CALIB tcq_order=1 +output.k5.weight gptq codes=u5 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.16 damp=0.01 calib=$CALIB tcq_order=1 +output.k6.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +output.k7.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.3 damp=0.01 calib=$CALIB tcq_order=1 diff --git a/data/recipes/q38-27b-iq7r-v4.recipe b/data/recipes/q38-27b-iq7r-v4.recipe new file mode 100644 index 00000000..ef64c59c --- /dev/null +++ b/data/recipes/q38-27b-iq7r-v4.recipe @@ -0,0 +1,303 @@ +# q38-27b-iq7r-v4.recipe -- IQ7R-V4: Qwen3.8-27B at ~7.420 bits a weight. +# IQR-V4: every trunk linear rotated by fwht128 and fitted by GPTQ in act order (tcq_order=1) against the +# calib Hessians, its codes a tail-biting trellis down each column whose 2^16 states' values are computed +# from the state (tcq=16 tcq_code=mad; 2^15 at two bits) under one f32 scale a row, the head-fed projections +# under a bf16 scale a (row, 128) block; widths by layer band and projection from measured prices +# (6-bit, 7-bit, int8; docs/IQR.md, "IQR-V4"). Served by qwen35_w8a8 at i8a8h with rotated int8 activations. +# The lm_head is int8, GPTQ'd against the head's input Hessian. +# +# CALIB= rad-convert --recipe data/recipes/q38-27b-iq7r-v4.recipe \ +# --set quantization_config.quant_method=w8a8 --set quantization_config.fmt=fwht128 -o OUT.rad +# +# The competition's private tiers 1+2: 7.420 bpw, mean KL 0.00059, top-1 99.15% (IQ7R-V3: 7.420 bpw, 0.00060). + +blk.0.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.0.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.1.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.2.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.3.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.4.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.5.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.6.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.7.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.8.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.9.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.10.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.11.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.12.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.13.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_inz.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ssm_out.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.14.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_qg.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_k.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_v.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.attn_output.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.ffn_gate_up.weight gptq codes=u6 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.24 damp=0.01 calib=$CALIB tcq_order=1 +blk.15.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.16.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.17.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.18.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.19.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.20.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.21.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.22.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.23.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.24.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.25.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.26.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.27.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.28.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.29.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_inz.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ssm_out.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.30.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_qg.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_k.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_v.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.attn_output.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.5 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.ffn_gate_up.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=512 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.31.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.32.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.32.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.32.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.32.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.33.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.33.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.33.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.33.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.34.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.34.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.34.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.34.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.35.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.35.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.35.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.35.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.35.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.35.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.36.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.36.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.36.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.36.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.37.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.37.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.37.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.37.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.38.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.38.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.38.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.38.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.39.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.39.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.39.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.39.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.39.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.39.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.40.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.40.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.40.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.40.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.41.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.41.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.41.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.41.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.42.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.42.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.42.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.42.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.43.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.43.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.43.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.43.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.43.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.43.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.44.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.44.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.44.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.44.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.45.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.45.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.45.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.45.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.46.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.46.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.46.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.46.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.47.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.47.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.47.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.47.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.47.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.47.ffn_down.weight gptq codes=u7 tcq=16 tcq_code=mad tcq_rows=256 block=1x* scale=f32 transform=fwht128 tcq_gain=1.30 damp=0.01 calib=$CALIB tcq_order=1 +blk.48.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.48.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.48.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.48.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.49.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.49.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.49.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.49.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.50.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.50.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.50.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.50.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.51.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.51.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.51.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.51.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.51.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.51.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.52.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.52.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.52.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.52.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.53.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.53.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.53.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.53.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.54.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.54.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.54.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.54.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.55.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.55.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.55.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.55.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.55.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.55.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.56.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.56.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.56.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.56.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.57.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.57.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.57.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.57.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.58.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.58.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.58.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.58.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.59.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.59.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.59.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.59.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.59.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.59.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.60.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.60.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.60.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.60.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.61.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.61.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.61.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.61.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.62.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.62.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.62.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.62.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.63.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.63.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.63.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.63.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.63.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.63.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +token_embd.weight rtn codes=u6 zero=u6 group=128 scale=bf16 rule=search +output.weight gptq codes=i8 group=128 scale=bf16 clamp=sym rule=search damp=0.01 calib=$CALIB diff --git a/data/recipes/q38-27b-iq8r-v4.recipe b/data/recipes/q38-27b-iq8r-v4.recipe new file mode 100644 index 00000000..97ed6b59 --- /dev/null +++ b/data/recipes/q38-27b-iq8r-v4.recipe @@ -0,0 +1,303 @@ +# q38-27b-iq8r-v4.recipe -- IQ8R-V4: Qwen3.8-27B at ~8.040 bits a weight. +# IQR-V4: every trunk linear rotated by fwht128 and fitted by GPTQ in act order (tcq_order=1) against the +# calib Hessians, its codes a tail-biting trellis down each column whose 2^16 states' values are computed +# from the state (tcq=16 tcq_code=mad; 2^15 at two bits) under one f32 scale a row, the head-fed projections +# under a bf16 scale a (row, 128) block; widths by layer band and projection from measured prices +# (int8; docs/IQR.md, "IQR-V4"). Served by qwen35_w8a8 at i8a8h with rotated int8 activations. +# The lm_head is int8, GPTQ'd against the head's input Hessian. +# +# CALIB= rad-convert --recipe data/recipes/q38-27b-iq8r-v4.recipe \ +# --set quantization_config.quant_method=w8a8 --set quantization_config.fmt=fwht128 -o OUT.rad +# +# The competition's private tiers 1+2: 8.040 bpw, mean KL 0.00046, top-1 99.22% (IQ8R-V3: 8.040 bpw, 0.00047). + +blk.0.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.0.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.0.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.0.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.1.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.1.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.1.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.1.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.2.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.2.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.2.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.2.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.3.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.3.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.3.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.3.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.3.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.3.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.4.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.4.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.4.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.4.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.5.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.5.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.5.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.5.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.6.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.6.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.6.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.6.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.7.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.7.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.7.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.7.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.7.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.7.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.8.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.8.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.8.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.8.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.9.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.9.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.9.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.9.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.10.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.10.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.10.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.10.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.11.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.11.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.11.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.11.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.11.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.11.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.12.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.12.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.12.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.12.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.13.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.13.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.13.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.13.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.14.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.14.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.14.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.14.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.15.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.15.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.15.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.15.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.15.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.15.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.16.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.16.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.16.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.16.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.17.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.17.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.17.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.17.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.18.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.18.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.18.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.18.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.19.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.19.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.19.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.19.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.19.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.19.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.20.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.20.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.20.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.20.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.21.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.21.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.21.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.21.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.22.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.22.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.22.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.22.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.23.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.23.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.23.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.23.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.23.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.23.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.24.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.24.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.24.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.24.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.25.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.25.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.25.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.25.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.26.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.26.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.26.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.26.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.27.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.27.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.27.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.27.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.27.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.27.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.28.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.28.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.28.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.28.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.29.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.29.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.29.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.29.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.30.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.30.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.30.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.30.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.31.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.31.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.31.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.31.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.31.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.31.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.32.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.32.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.32.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.32.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.33.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.33.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.33.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.33.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.34.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.34.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.34.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.34.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.35.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.35.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.35.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.35.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.35.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.35.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.36.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.36.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.36.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.36.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.37.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.37.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.37.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.37.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.38.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.38.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.38.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.38.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.39.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.39.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.39.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.39.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.39.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.39.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.40.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.40.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.40.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.40.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.41.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.41.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.41.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.41.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.42.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.42.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.42.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.42.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.43.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.43.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.43.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.43.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.43.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.43.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.44.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.44.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.44.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.44.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.45.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.45.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.45.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.45.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.46.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.46.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.46.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.46.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.47.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.47.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.47.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.47.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.47.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.47.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.48.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.48.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.48.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.48.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.49.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.49.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.49.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.49.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.50.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.50.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.50.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.50.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.51.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.51.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.51.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.51.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.51.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.51.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.52.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.52.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.52.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.52.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.53.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.53.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.53.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.53.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.54.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.54.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.54.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.54.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.55.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.55.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.55.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.55.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.55.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.55.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.56.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.56.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.56.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.56.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.57.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.57.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.57.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.57.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.58.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.58.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.58.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.58.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.59.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.59.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.59.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.59.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.59.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.59.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.60.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.60.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.60.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.60.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.61.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.61.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.61.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.61.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.62.ssm_inz.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.62.ssm_out.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.62.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.62.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.63.attn_qg.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.63.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.63.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.63.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.63.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.63.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +token_embd.weight rtn codes=u6 zero=u6 group=128 scale=bf16 rule=search +output.weight gptq codes=i8 group=128 scale=bf16 clamp=sym rule=search damp=0.01 calib=$CALIB diff --git a/data/recipes/spark-x26-4b-iq8r-keep12.recipe b/data/recipes/spark-x26-4b-iq8r-keep12.recipe new file mode 100644 index 00000000..8e180797 --- /dev/null +++ b/data/recipes/spark-x26-4b-iq8r-keep12.recipe @@ -0,0 +1,158 @@ +# Quality-preferred tested allocation for Spark X2.6 4B. +# Keep layers 0..11 in source BF16; fit the six projections in layers 12..35 to IQ8R. +# The ordered recipe glob syntax has no exclusions, so the 144 layer/projection rules below +# explicitly begin at layer 12. Unmatched weights keep their checkpoint encoding. +# The tied output head remains RTN-quantized; the small attention gate and other non-target +# tensors remain BF16/FP32 as described in docs/ARCHITECTURES.md. +# +# Reproduce from the BF16 checkpoint with the published RADGRAM2 calibration directory: +# CALIB=/path/to/grams rad-convert /path/to/XHToken-Spark-X2.6-4B \ +# --recipe data/recipes/spark-x26-4b-iq8r-keep12.recipe \ +# --set quantization_config.quant_method=w8a8 \ +# --set quantization_config.fmt=fwht128 -o spark-x2.6-4b-iq8r-keep12.rad +# This is a tested allocation, not a universal task-quality guarantee. +blk.12.attn_q.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.12.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.12.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.12.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.12.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.12.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.13.attn_q.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.13.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.13.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.13.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.13.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.13.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.14.attn_q.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.14.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.14.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.14.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.14.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.14.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.15.attn_q.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.15.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.15.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.15.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.15.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.15.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.16.attn_q.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.16.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.16.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.16.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.16.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.16.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.17.attn_q.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.17.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.17.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.17.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.17.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.17.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.18.attn_q.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.18.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.18.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.18.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.18.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.18.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.19.attn_q.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.19.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.19.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.19.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.19.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.19.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.20.attn_q.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.20.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.20.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.20.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.20.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.20.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.21.attn_q.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.21.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.21.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.21.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.21.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.21.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.22.attn_q.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.22.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.22.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.22.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.22.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.22.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.23.attn_q.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.23.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.23.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.23.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.23.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.23.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.24.attn_q.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.24.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.24.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.24.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.24.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.24.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.25.attn_q.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.25.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.25.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.25.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.25.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.25.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.26.attn_q.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.26.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.26.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.26.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.26.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.26.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.27.attn_q.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.27.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.27.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.27.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.27.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.27.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.28.attn_q.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.28.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.28.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.28.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.28.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.28.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.29.attn_q.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.29.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.29.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.29.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.29.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.29.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.30.attn_q.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.30.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.30.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.30.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.30.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.30.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.31.attn_q.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.31.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.31.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.31.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.31.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.31.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.32.attn_q.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.32.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.32.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.32.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.32.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.32.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.33.attn_q.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.33.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.33.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.33.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.33.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.33.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.34.attn_q.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.34.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.34.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.34.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.34.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.34.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.35.attn_q.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.35.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.35.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.35.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.35.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.35.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +output.weight rtn codes=i8 group=128 scale=bf16 clamp=sym rule=search diff --git a/data/recipes/spark-x26-4b-iq8r.recipe b/data/recipes/spark-x26-4b-iq8r.recipe new file mode 100644 index 00000000..1fd7c9c2 --- /dev/null +++ b/data/recipes/spark-x26-4b-iq8r.recipe @@ -0,0 +1,29 @@ +# Full, opt-in speed/size variant for Spark X2.6 4B (Spark2_5ForCausalLM) on IQ8R's rotated int8 grid. +# For the tested quality-preferred allocation retaining layers 0..11 in BF16, use +# spark-x26-4b-iq8r-keep12.recipe instead. Neither allocation guarantees task quality for every use. +# Every trunk linear rotated by fwht128 and fitted by GPTQ against calibration +# Hessians (RADGRAM2), an int8 code with a bf16 scale per [1 x 128] (docs/IQR.md). Served by +# arch/spark25_w8a8 at gemm_nt_q dtype i8a8h behind had_quant_act_i8g. +# +# The tap is arch/spark25_bf16's: serve the BF16 container with RADIANCE_CALIB_DIR set and push a +# corpus through prefill. The f32 [K,K] accumulators are 533 MB a layer, so calibrate a slice at a +# time -- RADIANCE_SPARK_CALIB_LAYERS=lo:hi, once per slice, same directory: +# +# RADIANCE_CALIB_DIR=$CALIB RADIANCE_CALIB_TOKENS=65536 RADIANCE_SPARK_CALIB_LAYERS=0:12 \ +# radiance --model spark-x2.6-4b-radiance-bf16.rad ... # and drive prompts at max_tokens=1 +# +# CALIB=$CALIB rad-convert --recipe data/recipes/spark-x26-4b-iq8r.recipe \ +# --set quantization_config.quant_method=w8a8 --set quantization_config.fmt=fwht128 \ +# -o spark-x2.6-4b-radiance-iq8r.rad +# +# Left unquantised, as arch/spark25_w8a8 declares them: the two norms a layer, the head's norm, the +# embedding (which `blk.*.attn_gate.weight`-sized bf16 aside, the tied table the gather reads) and +# the 16-row attention gate projection, which is 41k parameters and serves a sigmoid per head. + +blk.*.attn_q.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.*.attn_k.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.*.attn_v.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.*.attn_output.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.*.ffn_gate_up.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +blk.*.ffn_down.weight gptq codes=i8 group=128 scale=bf16 transform=fwht128 clamp=sym rule=search calib=$CALIB +output.weight rtn codes=i8 group=128 scale=bf16 clamp=sym rule=search diff --git a/data/vhead/README.md b/data/vhead/README.md new file mode 100644 index 00000000..5cc14662 --- /dev/null +++ b/data/vhead/README.md @@ -0,0 +1,15 @@ +# Vocabulary-weighted lm_head classes + +The width classes of Qwen3.8-27B's vocabulary-weighted lm_head, used by the IQR-V4 recipes +(`data/recipes/q38-27b-*-v4.recipe`) from IQ2R-V4 to IQ6R-V4. `tools/vhead.py` turns the bf16 +checkpoint and one of these files into the checkpoint those recipes convert: + +| file | mean width | widths (rows) | +|---|---|---| +| `q38-27b-vhead-4.0.cls` | 4.0 b | 3 (130560), 4 (31744), 5 (41472), 6 (44544) | +| `q38-27b-vhead-4.5.cls` | 4.5 b | 4 (171008), 5 (43008), 6 (22016), 7 (12288) | +| `q38-27b-vhead-5.0.cls` | 5.0 b | 4 (130560), 5 (33280), 6 (38400), 7 (46080) | + +Each 256-row run of the vocabulary was given the width that minimises its rows' output error +(dW H dW^T against the head's input Hessian) weighted by their tokens' mean probability on +calibration text, at the file's mean width. The format is in `tools/vhead.py`. diff --git a/data/vhead/q38-27b-vhead-4.0.cls b/data/vhead/q38-27b-vhead-4.0.cls new file mode 100644 index 00000000..622967bf Binary files /dev/null and b/data/vhead/q38-27b-vhead-4.0.cls differ diff --git a/data/vhead/q38-27b-vhead-4.5.cls b/data/vhead/q38-27b-vhead-4.5.cls new file mode 100644 index 00000000..e4a30cda Binary files /dev/null and b/data/vhead/q38-27b-vhead-4.5.cls differ diff --git a/data/vhead/q38-27b-vhead-5.0.cls b/data/vhead/q38-27b-vhead-5.0.cls new file mode 100644 index 00000000..04fa6bd5 Binary files /dev/null and b/data/vhead/q38-27b-vhead-5.0.cls differ diff --git a/deploy/compose/gemma4-12b-bf16.yaml b/deploy/compose/gemma4-12b-bf16.yaml new file mode 100644 index 00000000..567faffd --- /dev/null +++ b/deploy/compose/gemma4-12b-bf16.yaml @@ -0,0 +1,16 @@ +# Gemma 4 12B-it at bf16 on two cards: every weight as Google released it, Google's assistant head +# merged in as the MTP drafter (depth 3). Pictures and audio go in through the 12B's own embedders (no +# vision tower, no audio encoder). bf16 KV: fp8 KV costs the 12B more than it saves. Thinking is off, +# as in Google's template; switch it per request (chat_template_kwargs). Sampling as the checkpoint's +# generation_config states it (temperature 1.0, top_p 0.95, top_k 64). +name: radiance-gemma4-12b-bf16 +services: + radiance: + extends: { file: common.yaml, service: radiance } + container_name: radiance-gemma4-12b-bf16 + command: > + --model /models/gemma4-12b-bf16.rad + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY + --tp 2 --max-num-seqs 8 --max-model-len 65536 --kv-cache-dtype bf16 + --num-speculative-tokens 3 --max-num-batched-tokens 2048 --mm-max-patches 1120 + --temp 1.0 --top-p 0.95 --top-k 64 --chat-template-kwargs '{"enable_thinking":false}' diff --git a/deploy/compose/gemma4-12b-i8g.yaml b/deploy/compose/gemma4-12b-i8g.yaml new file mode 100644 index 00000000..4c51c607 --- /dev/null +++ b/deploy/compose/gemma4-12b-i8g.yaml @@ -0,0 +1,16 @@ +# Gemma 4 12B-it at int8 on one card: every trunk linear int8 at i8a8 (activation scale per row and +# 128 columns), Google's assistant head merged in as the MTP drafter (depth 3), the image and audio +# embedders at bf16. bf16 KV: fp8 KV costs the 12B more than it saves. Thinking is off, as in Google's +# template; switch it per request (chat_template_kwargs). Sampling as the checkpoint's generation_config +# states it (temperature 1.0, top_p 0.95, top_k 64). +name: radiance-gemma4-12b-i8g +services: + radiance: + extends: { file: common.yaml, service: radiance } + container_name: radiance-gemma4-12b-i8g + command: > + --model /models/gemma4-12b-i8g.rad + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY + --tp 1 --max-num-seqs 8 --max-model-len 65536 --kv-cache-dtype bf16 + --num-speculative-tokens 3 --max-num-batched-tokens 2048 --mm-max-patches 1120 + --temp 1.0 --top-p 0.95 --top-k 64 --chat-template-kwargs '{"enable_thinking":false}' diff --git a/deploy/compose/ling-3.0-flash-sante-w4a8-tp2.yaml b/deploy/compose/ling-3.0-flash-sante-w4a8-tp2.yaml new file mode 100644 index 00000000..b2c0b31f --- /dev/null +++ b/deploy/compose/ling-3.0-flash-sante-w4a8-tp2.yaml @@ -0,0 +1,20 @@ +# Ling-3.0-flash-Sante w4a8 on two cards: the same file as ling-3.0-flash-sante-w4a8.yaml. Two cards do +# not hold all 66 GiB, so part of the routed experts stay in pinned host memory (expert_tiered, 16 GiB +# a rank; the host needs about 40 GiB free RAM). With --max-model-len 262144 the cache holds +# 1,048,592 tokens: four full-length sessions. +# +# On 2x R9700 at 215 W, BetterBench with thinking off: 157 tok/s single-stream and 249 tok/s aggregate +# at 4 users. Prefill reads the whole cache for each query row, so it slows with depth: 4,800 tok/s at +# 2k, 1,230 at 24k, 650 at 47k. +name: radiance-ling-3.0-flash-sante-w4a8-tp2 +services: + radiance: + extends: { file: common.yaml, service: radiance } + container_name: radiance-ling-3.0-flash-sante-w4a8-tp2 + command: > + --model /models/ling-3.0-flash-sante-w4a8.rad + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY + --tp 2 --placement expert_tiered --host-pool-mib 16384 + --max-num-seqs 4 --max-model-len 262144 --kv-cache-dtype bf16 + --max-num-batched-tokens 2048 --num-speculative-tokens 3 + --temp 1.0 --top-p 0.95 diff --git a/deploy/compose/ling-3.0-flash-sante-w4a8.yaml b/deploy/compose/ling-3.0-flash-sante-w4a8.yaml new file mode 100644 index 00000000..8c3edd5d --- /dev/null +++ b/deploy/compose/ling-3.0-flash-sante-w4a8.yaml @@ -0,0 +1,20 @@ +# Ling-3.0-flash-Sante, inclusionAI's medical fine-tune of Ling-3.0-flash (124B, 5.1B active), with +# its routed experts at four bits (int4, a bf16 scale per 128 of K, GPTQ; +# data/recipes/ling3-w4a8-gptq.recipe), everything else bf16 as the checkpoint holds it, and its own +# MTP head: 66 GiB, every weight in VRAM on four cards. The latent and KDA caches are bf16 only. +# With --max-model-len 262144 the cache holds 1,048,576 tokens at 4 sequences, four full-length +# sessions, and 1,608,032 at 8. Sampling is inclusionAI's evaluation setting. +# +# On 4x R9700 at 215 W, BetterBench with thinking off: 236 tok/s single-stream (weighted over its +# categories; JSON 270, code 258, prose 172) and 460 / 572 tok/s aggregate at 4 / 8 users. +name: radiance-ling-3.0-flash-sante-w4a8 +services: + radiance: + extends: { file: common.yaml, service: radiance } + container_name: radiance-ling-3.0-flash-sante-w4a8 + command: > + --model /models/ling-3.0-flash-sante-w4a8.rad + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY + --tp 4 --max-num-seqs 8 --max-model-len 65536 --kv-cache-dtype bf16 + --num-speculative-tokens 3 + --temp 1.0 --top-p 0.95 diff --git a/deploy/compose/nemotron-3.5-bolt-74b-fp8.yaml b/deploy/compose/nemotron-3.5-bolt-74b-fp8.yaml new file mode 100644 index 00000000..a4ae04f3 --- /dev/null +++ b/deploy/compose/nemotron-3.5-bolt-74b-fp8.yaml @@ -0,0 +1,22 @@ +# NVIDIA-Nemotron-3.5-Bolt-74B-A9B on four cards: every linear and routed expert block FP8, NVIDIA's +# LiLiCorr drafter and the C-RADIO vision tower. Converted with data/recipes/nemotron74-fp8.recipe +# and the drafter, or downloaded from https://huggingface.co/keptn/nemotron-3.5-bolt-74b-fp8. +# Thinking is switched per request (chat_template_kwargs). +# +# --tp 4: each rank replicates one of the two KV heads, the trunk's and the drafter's. LiLiCorr +# proposes 7 tokens in one block pass, its trained block of 8 less the anchor. The KV cache stays +# bf16. 8 sequences of up to 65536 tokens; --max-model-len 262144 --max-num-seqs 2 serves the whole +# context. +# +# On 4x R9700 at 215 W, BetterBench 0.6.1 with thinking off: 248 tok/s single-stream, 407 tok/s +# aggregate at 4 users, and 6074 tok/s prefill at 24k tokens. +name: radiance-nemotron-3.5-bolt-74b-fp8 +services: + radiance: + extends: { file: common.yaml, service: radiance } + container_name: radiance-nemotron-3.5-bolt-74b-fp8 + command: > + --model /models/nemotron-3.5-bolt-74b-fp8.rad + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY + --tp 4 --max-num-seqs 8 --max-model-len 65536 --max-num-batched-tokens 8192 + --num-speculative-tokens 7 diff --git a/deploy/compose/nemotron-3.5-bolt-74b-w4a8.yaml b/deploy/compose/nemotron-3.5-bolt-74b-w4a8.yaml new file mode 100644 index 00000000..a0b32144 --- /dev/null +++ b/deploy/compose/nemotron-3.5-bolt-74b-w4a8.yaml @@ -0,0 +1,23 @@ +# NVIDIA-Nemotron-3.5-Bolt-74B-A9B on two cards: the routed experts as 4-bit codebook codes at E4M3 +# scales per 64 weights (w4nl64a8h, round to nearest), every other linear block FP8, NVIDIA's +# LiLiCorr drafter and the C-RADIO vision tower. Converted with +# data/recipes/nemotron74-w4nl64-gptq.recipe (CALIB an empty directory) and the drafter, or +# downloaded from https://huggingface.co/keptn/nemotron-3.5-bolt-74b-w4a8. Thinking is switched per +# request (chat_template_kwargs). +# +# LiLiCorr proposes 7 tokens in one block pass, its trained block of 8 less the anchor. The KV cache +# stays bf16. 8 sequences of up to 65536 tokens; --max-model-len 262144 --max-num-seqs 2 serves the +# whole context. +# +# On 2x R9700 at 215 W, BetterBench 0.6.1 with thinking off: 207 tok/s single-stream, 351 tok/s +# aggregate at 4 users, and 5272 tok/s prefill at 24k tokens. +name: radiance-nemotron-3.5-bolt-74b-w4a8 +services: + radiance: + extends: { file: common.yaml, service: radiance } + container_name: radiance-nemotron-3.5-bolt-74b-w4a8 + command: > + --model /models/nemotron-3.5-bolt-74b-w4a8.rad + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY + --tp 2 --max-num-seqs 8 --max-model-len 65536 --max-num-batched-tokens 8192 + --num-speculative-tokens 7 diff --git a/deploy/compose/qwen3.8-27b-iqr-v4.yaml b/deploy/compose/qwen3.8-27b-iqr-v4.yaml new file mode 100644 index 00000000..2f9ec657 --- /dev/null +++ b/deploy/compose/qwen3.8-27b-iqr-v4.yaml @@ -0,0 +1,13 @@ +# Qwen3.8-27B in IQR-V4 (docs/IQR.md), one size of the ladder from 2.5 to 8 bits a weight, with the +# DFlash2 block-diffusion drafter and the vision tower in the container. IQR_V4 names the size, the +# part of the file name between qwen3.8-27b- and .rad (default iq4r-s-v4, 15 GiB); the speculation +# depth is the drafter's own operating point. +name: radiance-qwen3.8-27b-iqr-v4 +services: + radiance: + extends: { file: common.yaml, service: radiance } + container_name: radiance-qwen3.8-27b-iqr-v4 + command: > + --model /models/qwen3.8-27b-${IQR_V4:-iq4r-s-v4}.rad + --host :: --port ${PORT:-8000} --api-key-env RADIANCE_API_KEY + --tp 2 --max-num-seqs 32 --max-model-len 200000 --kv-cache-dtype fp8 diff --git a/deploy/grafana/radiance.json b/deploy/grafana/radiance.json index 2b723299..d715246d 100644 --- a/deploy/grafana/radiance.json +++ b/deploy/grafana/radiance.json @@ -16,7 +16,7 @@ "from": "now-1h", "to": "now" }, - "description": "radiance: throughput, speculation by draft position, scheduler, latency, prefix cache, HTTP. Prometheus or VictoriaMetrics.", + "description": "radiance: totals over the time range, throughput, speculation by draft position, scheduler, latency, prefix cache, HTTP. Prometheus or VictoriaMetrics.", "annotations": { "list": [] }, @@ -94,6 +94,322 @@ "y": 0 } }, + { + "type": "stat", + "title": "Prompt tokens in", + "id": 44, + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "description": "Prompt tokens of the requests that finished in the time range, added up. Each prompt counts with its full length, the cached part included. It is the sum of usage.prompt_tokens in the responses.", + "gridPos": { + "h": 4, + "w": 4, + "x": 0, + "y": 1 + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum(increase(vllm:prompt_tokens_total{instance=~\"$instance\", model_name=~\"$model_name\"}[$__range]))", + "legendFormat": "", + "refId": "A", + "range": false, + "instant": true + } + ], + "fieldConfig": { + "defaults": { + "unit": "short", + "color": { + "mode": "thresholds" + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "text", + "value": null + } + ] + }, + "decimals": 2 + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "value", + "graphMode": "area", + "textMode": "auto", + "justifyMode": "auto" + } + }, + { + "type": "stat", + "title": "Prompt tokens read from cache", + "id": 45, + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "description": "Prompt tokens that were not computed again, over the time range. Two numbers: tokens whose attention KV came from the paged prefix cache, and tokens whose recurrent state came from a linear checkpoint. A hybrid model such as Qwen3.8-Flash-Next uses both. The two numbers count the same tokens from two sides, so do not add them. Compute is saved only up to the checkpoint: the linear number plus Prompt tokens computed equals the prompt tokens admitted. Counted when a request is admitted.", + "gridPos": { + "h": 4, + "w": 6, + "x": 4, + "y": 1 + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum(increase(radiance:attn_cached_tokens_total{instance=~\"$instance\", model_name=~\"$model_name\"}[$__range]))", + "legendFormat": "attention cache", + "refId": "A", + "range": false, + "instant": true + }, + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum(increase(radiance:linear_cached_tokens_total{instance=~\"$instance\", model_name=~\"$model_name\"}[$__range]))", + "legendFormat": "linear checkpoint", + "refId": "B", + "range": false, + "instant": true + } + ], + "fieldConfig": { + "defaults": { + "unit": "short", + "color": { + "mode": "thresholds" + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "text", + "value": null + } + ] + }, + "decimals": 2 + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "value", + "graphMode": "area", + "textMode": "value_and_name", + "justifyMode": "auto" + } + }, + { + "type": "stat", + "title": "Prompt tokens computed", + "id": 46, + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "description": "Prompt tokens the engine computed over the time range. Tokens read from the cache are not in it.", + "gridPos": { + "h": 4, + "w": 4, + "x": 10, + "y": 1 + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum(increase(radiance:prefill_tokens_total{instance=~\"$instance\", model_name=~\"$model_name\"}[$__range]))", + "legendFormat": "", + "refId": "A", + "range": false, + "instant": true + } + ], + "fieldConfig": { + "defaults": { + "unit": "short", + "color": { + "mode": "thresholds" + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "text", + "value": null + } + ] + }, + "decimals": 2 + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "value", + "graphMode": "area", + "textMode": "auto", + "justifyMode": "auto" + } + }, + { + "type": "stat", + "title": "Generated tokens out", + "id": 47, + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "description": "Tokens generated for the requests that finished in the time range, added up. Reasoning tokens are in it. It is the sum of usage.completion_tokens in the responses. A request that is still running is not counted yet: Decode shows the live rate.", + "gridPos": { + "h": 4, + "w": 4, + "x": 14, + "y": 1 + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum(increase(vllm:generation_tokens_total{instance=~\"$instance\", model_name=~\"$model_name\"}[$__range]))", + "legendFormat": "", + "refId": "A", + "range": false, + "instant": true + } + ], + "fieldConfig": { + "defaults": { + "unit": "short", + "color": { + "mode": "thresholds" + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "text", + "value": null + } + ] + }, + "decimals": 2 + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "value", + "graphMode": "area", + "textMode": "auto", + "justifyMode": "auto" + } + }, + { + "type": "stat", + "title": "Requests", + "id": 48, + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "description": "Requests that finished in the time range, for all finish reasons. The graph Requests finished, below, splits them by reason.", + "gridPos": { + "h": 4, + "w": 3, + "x": 18, + "y": 1 + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum(increase(vllm:request_success_total{instance=~\"$instance\", model_name=~\"$model_name\"}[$__range]))", + "legendFormat": "", + "refId": "A", + "range": false, + "instant": true + } + ], + "fieldConfig": { + "defaults": { + "unit": "short", + "color": { + "mode": "thresholds" + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "text", + "value": null + } + ] + }, + "decimals": 0 + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "value", + "graphMode": "area", + "textMode": "auto", + "justifyMode": "auto" + } + }, { "type": "stat", "title": "Running", @@ -107,7 +423,7 @@ "h": 4, "w": 4, "x": 0, - "y": 1 + "y": 5 }, "targets": [ { @@ -167,7 +483,7 @@ "h": 4, "w": 4, "x": 4, - "y": 1 + "y": 5 }, "targets": [ { @@ -231,7 +547,7 @@ "h": 4, "w": 4, "x": 8, - "y": 1 + "y": 5 }, "targets": [ { @@ -292,7 +608,7 @@ "h": 4, "w": 4, "x": 12, - "y": 1 + "y": 5 }, "targets": [ { @@ -353,7 +669,7 @@ "h": 4, "w": 4, "x": 16, - "y": 1 + "y": 5 }, "targets": [ { @@ -422,7 +738,7 @@ "h": 4, "w": 4, "x": 20, - "y": 1 + "y": 5 }, "targets": [ { @@ -470,6 +786,19 @@ "justifyMode": "auto" } }, + { + "type": "row", + "title": "Ratios over the time range", + "id": 49, + "collapsed": false, + "panels": [], + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 26 + } + }, { "type": "stat", "title": "Prompt from attention cache", @@ -481,9 +810,9 @@ "description": "Share of prompt tokens served from the paged attention prefix cache over the time range (vllm:gpu_prefix_cache_hit_rate is the same ratio since start).", "gridPos": { "h": 4, - "w": 4, + "w": 5, "x": 0, - "y": 5 + "y": 27 }, "targets": [ { @@ -542,9 +871,9 @@ "description": "Share of prompt tokens whose recurrent state came from a checkpoint over the time range (radiance:linear_prefix_cache_hit_rate since start). A prompt can be fully attention-cached and still re-run every recurrent layer.", "gridPos": { "h": 4, - "w": 4, - "x": 4, - "y": 5 + "w": 5, + "x": 5, + "y": 27 }, "targets": [ { @@ -603,9 +932,9 @@ "description": "engine_step_seconds_decode_total / engine_steps_decode_total over the time range: decode only. Wall clock over steps would charge idle and prefill to it.", "gridPos": { "h": 4, - "w": 4, - "x": 8, - "y": 5 + "w": 5, + "x": 10, + "y": 27 }, "targets": [ { @@ -664,9 +993,9 @@ "description": "Verified draft blocks per decode-only step over the time range. Falls when rows stop drafting, which the acceptance ratio does not show.", "gridPos": { "h": 4, - "w": 4, - "x": 12, - "y": 5 + "w": 5, + "x": 15, + "y": 27 }, "targets": [ { @@ -726,8 +1055,8 @@ "gridPos": { "h": 4, "w": 4, - "x": 16, - "y": 5 + "x": 20, + "y": 27 }, "targets": [ { @@ -801,9 +1130,9 @@ "description": "Over the time range.", "gridPos": { "h": 4, - "w": 4, - "x": 20, - "y": 5 + "w": 3, + "x": 21, + "y": 1 }, "targets": [ { @@ -1241,7 +1570,7 @@ "h": 1, "w": 24, "x": 0, - "y": 26 + "y": 31 } }, { @@ -1257,7 +1586,7 @@ "h": 8, "w": 12, "x": 0, - "y": 27 + "y": 32 }, "targets": [ { @@ -1479,7 +1808,7 @@ "h": 8, "w": 6, "x": 12, - "y": 27 + "y": 32 }, "targets": [ { @@ -1536,7 +1865,7 @@ "h": 8, "w": 6, "x": 18, - "y": 27 + "y": 32 }, "targets": [ { @@ -1591,7 +1920,7 @@ "h": 8, "w": 8, "x": 0, - "y": 35 + "y": 40 }, "targets": [ { @@ -1646,7 +1975,7 @@ "h": 8, "w": 8, "x": 8, - "y": 35 + "y": 40 }, "targets": [ { @@ -1701,7 +2030,7 @@ "h": 8, "w": 8, "x": 16, - "y": 35 + "y": 40 }, "targets": [ { @@ -1756,7 +2085,7 @@ "h": 8, "w": 12, "x": 0, - "y": 43 + "y": 48 }, "targets": [ { @@ -1811,7 +2140,7 @@ "h": 8, "w": 12, "x": 12, - "y": 43 + "y": 48 }, "targets": [ { @@ -1863,7 +2192,7 @@ "h": 1, "w": 24, "x": 0, - "y": 51 + "y": 56 } }, { @@ -1879,7 +2208,7 @@ "h": 8, "w": 8, "x": 0, - "y": 52 + "y": 57 }, "targets": [ { @@ -1956,7 +2285,7 @@ "h": 8, "w": 8, "x": 8, - "y": 52 + "y": 57 }, "targets": [ { @@ -2022,7 +2351,7 @@ "h": 8, "w": 8, "x": 16, - "y": 52 + "y": 57 }, "targets": [ { @@ -2087,7 +2416,7 @@ "h": 1, "w": 24, "x": 0, - "y": 60 + "y": 65 } }, { @@ -2103,7 +2432,7 @@ "h": 8, "w": 8, "x": 0, - "y": 61 + "y": 66 }, "targets": [ { @@ -2180,7 +2509,7 @@ "h": 8, "w": 8, "x": 8, - "y": 61 + "y": 66 }, "targets": [ { @@ -2257,7 +2586,7 @@ "h": 8, "w": 8, "x": 16, - "y": 61 + "y": 66 }, "targets": [ { @@ -2331,7 +2660,7 @@ "h": 1, "w": 24, "x": 0, - "y": 69 + "y": 74 } }, { @@ -2347,7 +2676,7 @@ "h": 8, "w": 8, "x": 0, - "y": 70 + "y": 75 }, "targets": [ { @@ -2404,7 +2733,7 @@ "h": 8, "w": 8, "x": 8, - "y": 70 + "y": 75 }, "targets": [ { @@ -2472,7 +2801,7 @@ "h": 8, "w": 8, "x": 16, - "y": 70 + "y": 75 }, "targets": [ { @@ -2557,7 +2886,7 @@ "h": 1, "w": 24, "x": 0, - "y": 78 + "y": 83 } }, { @@ -2573,7 +2902,7 @@ "h": 8, "w": 12, "x": 0, - "y": 79 + "y": 84 }, "targets": [ { @@ -2628,7 +2957,7 @@ "h": 8, "w": 12, "x": 12, - "y": 79 + "y": 84 }, "targets": [ { diff --git a/docker/build.sh b/docker/build.sh index db5c59fd..042618a8 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -9,7 +9,8 @@ # docker/build.sh HEAD, here # docker/build.sh -s HOST HEAD, built on and kept by HOST # docker/build.sh -r COMMIT another commit -# docker/build.sh -t 'gfx1200;gfx1201' other GPU architectures (default gfx1201) +# docker/build.sh -t 'gfx1200;gfx1201' other GPU architectures (default +# 'gfx1201;gfx11-generic;gfx1151') # docker/build.sh -j 8 fewer compile jobs, for a host that is also serving # docker/build.sh -J 4 fewer tests at a time (default: the compile jobs) # docker/build.sh -B 5 multiply every test's CPU budget, for a host slower per @@ -24,7 +25,7 @@ cd "$(dirname "$0")/.." REV=HEAD HOST= -TARGETS=gfx1201 +TARGETS='gfx1201;gfx11-generic;gfx1151' JOBS= TEST_JOBS= BUDGET_SCALE= diff --git a/docs/ARCHITECTURES.md b/docs/ARCHITECTURES.md index 9a26457c..cdac69f2 100644 --- a/docs/ARCHITECTURES.md +++ b/docs/ARCHITECTURES.md @@ -18,11 +18,14 @@ plugin claims. | `arch/qwen35moe_fp8` | `qwen35moe` | `fp8_e4m3` | `qwen35_fp8` with the feed-forward routed | | `arch/qwen4exp_fp8` | `qwen4exp` | *(empty)* | Qwen4-Exp (Qwen3.8-Flash-Next), a bf16 checkpoint quantised at convert, or Qwen's FP8 release as it ships | | `arch/glm5next` | `glm5next` | *(empty)* | GLM-5.3-Flash from AMD's Quark MXFP4 export: four mHC residual streams over 34 KDA and 11 sparse latent-attention (MLA) layers with a DSA indexer, 288 MXFP4 experts at top-8 under sigmoid routing, block-FP8 attention and dense layers at f32 scales, each weight served as stored; its MTP layer is a serial drafter. Pictures through its vision tower (`arch/common/rad_block_glm_vision.h`); bf16 KV | +| `arch/bailing_hybrid` | `bailinghybrid` | *(empty)* | Ling-3.0-flash and its fine-tunes (Ling-3.0-flash-Sante) from the bf16 checkpoint: 35 KDA and 7 dense latent-attention (MLA) layers with a rotary part and a head-wise gate, 512 experts at top-8 under group-limited sigmoid routing with an ungated shared expert, the routed experts as the recipe stores them (`data/recipes/ling3-w4a8-rtn.recipe`); its MTP layer is a serial drafter; bf16 KV | +| `arch/nemotronh` | `nemotronh` | *(empty)* | Nemotron-3.5-Bolt-74B-A9B (`nemotron_h_omni` around `nemotron_h_puzzle`), its language model from the bf16 checkpoint: 40 Mamba-2, 40 latent-MoE and 8 NoPE attention blocks in the order `layers_block_type` gives, 240 to 496 ungated relu^2 experts a layer in a 1024-wide latent with a relu^2 shared expert; linears and experts as the recipe stores them (`data/recipes/nemotron74-fp8.recipe`, `nemotron74-w4nl64-gptq.recipe`); pictures and video through its C-RADIO tower (`arch/nemotronh/radio.h`); bf16 KV | | `arch/lfm2_bf16` | `lfm2` | *(empty)* | LiquidAI's LFM2 and LFM2-VL, bf16, one rank | +| `arch/spark25_bf16` | `spark25` | *(empty)* | Spark X2.6, bf16 checkpoint, mixed sliding/full attention, TP1 or TP with exact collectives ([geometry](#spark25-spark-x26)). Optional DSpark drafter when the container already holds `draft.*` tensors, TP1 only. | | `arch/embgemma2` | `embeddinggemma2` | *(empty)* | EmbeddingGemma 2: a bidirectional encoder with Gemma 4's vision tower and audio conformer, pooled to one vector | | `arch/nomicbert` | `nomicbert` | *(empty)* | nomic-embed-text-v2-moe: a bidirectional post-norm encoder, 12 layers with 8 experts at top 2 on every second layer, mean-pooled to one vector an input | | `arch/nemotron35_embed` | `mistral3` | *(empty)* | Nemotron 3.5 Embed 1B/8B and Rerank 8B: native BF16 bidirectional text/image retrieval with a Pixtral tower, TP1 ([geometry and contracts](#nemotron35_embed-embedding-models)) | -| `arch/gemma4_bf16` | `gemma4` | `compressed-tensors` | Gemma 4 31B dense, and the E2B/E4B form at one rank, with its vision tower: sliding-window and proportional-RoPE global (`attention_k_eq_v`) attention, GELU ffn, softcapped logits; int4 codes with an f16 scale per 128 from Google's CT-INT4 (QAT) release or from bf16, served w4a8, or int8 codes on the same grid from bf16 (w8a8, the Q8 container). Optional draft model (`rad-convert --draft-model`): Google's assistant, with no cache of its own (`rad_drafter_shared_kv`), or z-lab's DFlash drafter, the block `arch/gemma4` serves (`arch/common/rad_gemma4_dflash.h`), or RedHatAI's DFlash2 speculator (`arch/common/rad_block_dflash2.h`) | +| `arch/gemma4_bf16` | `gemma4` | `compressed-tensors` | Gemma 4 31B dense, the E2B/E4B form at one rank, and the 12B (`gemma4_unified`, its image and audio embedders in place of a tower), with its vision tower: sliding-window and proportional-RoPE global (`attention_k_eq_v`) attention, GELU ffn, softcapped logits; int4 codes with an f16 scale per 128 from Google's CT-INT4 (QAT) release or from bf16, served w4a8, or int8 codes on the same grid from bf16 (w8a8, the Q8 container). Optional draft model (`rad-convert --draft-model`): Google's assistant, with no cache of its own (`rad_drafter_shared_kv`), or z-lab's DFlash drafter, the block `arch/gemma4` serves (`arch/common/rad_gemma4_dflash.h`), or RedHatAI's DFlash2 speculator (`arch/common/rad_block_dflash2.h`) | | `arch/gemma3` | `gemma3` | *(empty)* | Gemma 3 dense text (TranslateGemma 27B) from the bf16 checkpoint: sliding-window and global attention at one head geometry, GemmaRMSNorm, GELU ffn; linears bf16, or int8, MXFP4 or asymmetric int4 over an activation scaled per (row, 128), as the recipe stores them. Optional DFlash2 drafter (`rad-convert --draft-model`) | | `arch/gemma4` | `gemma4` | *(empty)* | Gemma 4 text from Google's bf16 checkpoint (the 26B-A4B MoE and the dense sizes without per-layer embeddings) with z-lab's DFlash drafter; routed experts bf16 or block fp8 | | `arch/qwenimage21` | `qwenimage21` | *(empty)* | Qwen-Image 2.1 and 2.1-Turbo, an image generator, from the diffusers pipeline directory; DiT and text encoder bf16 or block fp8 | @@ -35,6 +38,7 @@ plugin claims. | `arch/minimaxmusic3` | `minimaxmusic3` | *(empty)* | MiniMax-Music3, songs from a description and lyrics: a Qwen3-8B frame model, a depth decoder, a flow-matching DiT and a DAC vocoder, from the diffusers pipeline directory, bf16 | | `arch/breeze` | `breeze` | *(empty)* | Breeze-TTS-2, speech from text and a description of the voice: a T5Gemma 2 text encoder, a Qwen3 backbone with a 16-codebook depth decoder and the Qwen3-TTS 12 Hz codec, from the release directory, bf16, one card | | `arch/fishomni` | `fishomni` | `bsgemm-moe` | Fish Audio drama-3, speech from text with speaker tags and inline direction, its voices cloned from reference clips: the Qwen3.5-35B-A3B backbone with its routed experts block fp8 at f32 scales and everything else bf16, a 13-layer codebook tower over the backbone's full-attention cache, and Fish S2's modified DAC, encoder and decoder (`codec.pth`, read as data); from the release directory, two cards | +| `arch/hunyuan3d2` | `hunyuan3d2` | *(empty)* | Hunyuan3D-2's shape model (hunyuan3d-dit-v2-0), an untextured 3-D shape from one picture: DINOv2-giant over the picture, a FLUX-shaped flow-matching DiT (16 double-stream and 32 single-stream blocks of 1024) over a set of 3072 latents, and the shape VAE's geometry decoder, whose occupancy field the core samples on a grid and meshes; from the release folder (config.yaml and one safetensors), its fp16 weights cast to bf16 (`data/recipes/hunyuan3d-2-bf16.recipe`) | | `arch/minimaxh3` | `minimaxh3` | *(empty)* | MiniMax-H3, a video with its stereo soundtrack from text, between keyframes or from reference media: Qwen3-VL-32B's language model as the text encoder, a 33B single-stream diffusion transformer, a tiled ViT video decoder and a BigVGAN audio decoder, from the diffusers pipeline directory; linears block fp8 (`data/recipes/minimax-h3-fp8.recipe`), or the DiT's per-token linears int8, served w8a8 (`minimax-h3-w8a8.recipe`); a curve-form checkpoint, whose timestep embeddings ship as a table, by the `minimax-h3-curve-*` recipes | | `arch/ltx2` | `ltx2` | *(empty)* | LTX-2.5 (base and distilled), a video with its stereo soundtrack from text or from text and a first frame: Gemma 4's language model and two text connectors, the duration head, a dual-stream audio-video DiT with four-way guidance, the causal video VAE (tiled past the default canvas) or the diffusion decoder, the audio VAE with a BigVGAN vocoder and bandwidth extension, the x2 latent upsampler; bf16 or block fp8, one card | @@ -68,6 +72,164 @@ comes first in one and second in the other. The tables, by plugin: --- +# `spark25`: Spark X2.6 + +`model_type: spark2_5` / `Spark2_5ForCausalLM`. The 4B checkpoint has 36 layers, hidden size +2560, 16 query heads and 4 KV heads at head dimension 256, a 10240-wide gated MLP and a tied +131072-token embedding. It has no q/k norms or projection biases. The residual is accumulated in +f32; norms write bf16 before the projections. + +The checkpoint's fused Q/K/V matrix is split by rows in that order at conversion; gate and up are +joined in that order. The MLP uses **exact erf GELU**, not `gelu_mul`'s tanh approximation. Each +attention head's output is multiplied by its own sigmoid gate before the output projection. +`layer_types` is authoritative: sliding layers use window 512 and full-head NeoX rotary at theta +10000; full layers use 64 rotary dimensions at theta 5000000. Both use the full KV group, with the +window applied by the local attention op, so prefix caching remains valid. + +## Tensor parallelism + +A rank's attention slice is whole GQA groups, so a world that does not divide 4 KV heads still +shards cleanly: the three ranks of a 3-rank world take 2, 1 and 1 KV heads with the query heads +that belong to them. Above the KV-head count the KV heads are replicated and one group's query +heads are split between the ranks sharing its KV head, so every query head still attends the KV +head the checkpoint gave it -- a rank's own `gqa` can then be smaller than the checkpoint's, while +the KV cache it stores is a replica of its peer's. The gate and output projections take the +matching row and column spans, and the tied embedding and lm_head take the contiguous vocabulary +shard `rad_arch.h`'s `shard_begin` describes, because that is the split the sampler's candidate +merge assumes. + +The FFN splits by channels, whole 128-column blocks where the width has them, and a rank's +`[gate | up]` keeps both parts the same width. Every split dimension is covered exactly once at +every world from 1 to 8, asserted in `spark25_arch_test`. + +Column-sharded projection outputs are partial sums. Each layer issues two exact bf16 +`all_reduce`s on the projection buffer, rounding the merged output to bf16 **before** widening it +and adding it to the f32 residual. This preserves the reference's BF16 projection-output boundary +without rounding away the residual's low bits. Sharding still changes the dot-product reduction +order, so it does not promise bitwise parity with one card. The embedding uses one exact f32 +`all_reduce` over its widened, disjoint token rows. TP1 declares no collectives. At TP>1, declaration +requires the exact fp32 embedding reduction and every exact bf16 projection reduction to resolve; +otherwise it fails with `RAD_E_UNSUPPORTED` rather than running rank-local partial outputs. libr4d +serves these collectives at 2, 3, 4 and 8 ranks; other widths resolve only on a library with a +general `all_reduce` (libref), so a card deployment is limited to those worlds. + +Both plugins reject multi-rank declarations if a required exact collective cannot be resolved; +otherwise a missing reduction would silently leave rank-local projections in the residual. + +The tokenizer and its template come from the checkpoint; the architecture declares the +``/`` reasoning markers and the `name...` tool-call format. +Other gate activations and rotary-scaling overrides are not implemented. + +## Rotated int8 (IQ8R) + +`arch/spark25_w8a8` serves a trunk whose linears use the fwht128-rotated int8 grid: per-128 int8 +activation codes feed `i8a8h` GEMMs, while the embedding and small per-head gate remain BF16 and +normalisation gains remain FP32. Exact GELU runs before the down projection's separate Hadamard +quantiser. The output head may be BF16 or a separately quantised int8 table. The descriptor is +`w8a8_fwht128`; the container must set `quantization_config.quant_method=w8a8` and +`quantization_config.fmt=fwht128`. + +The full recipe, `data/recipes/spark-x26-4b-iq8r.recipe`, is an explicit speed/size tradeoff, not a +quality-preferred default. `data/recipes/spark-x26-4b-iq8r-keep12.recipe` leaves layers 0–11 in +BF16 and is the tested quality-preferred allocation (6.09 GB / 5.67 GiB). The full IQ8R container +is 4.52 GiB; BF16 is 8.29 GiB. The measured comparison used top-128-plus-tail KL, with the full +variant's maximum 11.883 and keep12's maximum 0.247 over 31,391 held-out positions. These are +coarsened distribution-parity measurements, not full-vocabulary KL or task-benchmark scores. The +source revision and replay commands, tail details, hashes, calibration/evaluation provenance, and +limits are in [`SPARK25-IQ8R.md`](SPARK25-IQ8R.md). The cited numbers require the shared prefill +softmax fix #362 (`7480da3d46b0475d9d77966e31284cc19072759`); they are not evidence for standalone +#363 without that prerequisite. + +The BF16 plugin records the calibration Grams with `RADIANCE_CALIB_DIR`, `RADIANCE_CALIB_TOKENS`, +and `RADIANCE_SPARK_CALIB_LAYERS=lo:hi`; use TP=1 to retain off-diagonal cross-rank terms. Drive +a representative corpus through prefill with prefix caching and speculation disabled. Each layer +slice writes six RADGRAM2 files. The published calibration manifest and dataset revision are +recorded in [`SPARK25-IQ8R.md`](SPARK25-IQ8R.md); calibration completeness is not a measure of +quality. + +A column-sharded input must have a 128-column-aligned offset and width. When possible, FFN sharding +partitions whole 128-channel groups with a ragged remainder-first split. Spark's 10,240-channel FFN +has 80 groups, so TP=3 gets 27/27/26 groups and is aligned; TP=3 is not inherently refused. The +architecture rejects a particular computed span only if it is not group-aligned. Actual serving +also requires the selected kernels and collectives to support the world size. `tests/spark25_iq8r.py` +compares a deterministic quantised fixture with the Transformers reference, including top-10 +probabilities across cached decoding; `--wide-tp --tp N` checks aligned attention/FFN shards for +N=1..8. Use a GPU-denying device cgroup for this CPU fixture on shared machines. + +## DSpark drafting + +Both Spark plugins declare a DSpark graph when the container already carries `draft.*` tensors +(the presence of `draft.markov_w1.weight` is the switch). Building that container from XHToken's +standalone GGUF is not in this change. + +The container's `draft.target_layer_ids` are the ids of the layers that *consume* each tap, so they +are one above the taps `arch/spark25_bf16` and `arch/spark25_w8a8` copy out of the residual stream: +3, 11, 19, 26 and 34 become the taps after layers 2, 10, 18, 25 and 33. The drafter's five +`fc_norm` rows -- one gain per tap -- are the `fc_norm_t0` ... `fc_norm_t4` vectors the graph +declares. + +`arch/common/rad_block_dspark_bf16.h` is the drafter's graph, declared by both Spark plugins after +the trunk when the container carries `draft.markov_w1.weight`. It is its own block: the MiniCPM5 +DSpark block (`rad_block_dspark.h`) has Q/K norms, SiLU and an fp8 activation grid, and Spark's has +none of those. Per pass it encodes the taps the trunk copied into `dflash_src` (each tap RMS-normed +by its own `fc_norm_t`, concatenated, projected by `fc`, normed by `output_norm_enc`), embeds the +anchor token, runs the five bf16 sliding-window layers over the drafter's own KV group, then scores +the vocabulary through the trunk's tied table. At each position, the rank-256 Markov head adds +`sum_r w1[previous,r] * w2[token,r]` to the draft-head logit for **every** vocabulary token and +greedily selects the greatest biased score (ties to the lower token id); that selected token is the +next position's predecessor. This follows the pinned reference's serial greedy walk, not a top-K +walk or joint-path heap. The head writes F32 logits before the walk, but numerical identity is not +established: the reference CPU chooses the last equal maximum, its GPU reduction has backend-specific +tie ordering, and this graph chooses the lower token id. Reduction order can also change near-tie +results; real reference proposal parity remains unvalidated. A +retained confidence projection is not used: it neither rescales logits nor changes proposals; +adaptive depth is not implemented by this fixed-depth graph. + +Sliding attention uses a separate `attn_paged_anchor_window` operation because ordinary +`attn_paged` measures its window from each query row. For a configured 512-token history, the +reference uses `n_swa = 513`: every draft query shares the anchor's exact inclusive key range, +`[anchor - 512, anchor]` for causal attention, or the anchor's lower cutoff and the staged context's +upper end for non-causal attention. The same 513-token width is declared for attention, the drafter +KV group and scheduler staging; cache recycling and rollback boundaries still require independent +runtime validation. Both new operations have distinct names, so an older device library that +does not implement these semantics refuses the graph rather than resolving a similar-looking op. + +The drafter is declared only at one rank: its `fc` is unsharded and its head scores the full +vocabulary, so a `--tp` above 1 is refused at declaration rather than served half-sharded. + +DSpark's acceptance, latency and throughput on this exact graph are not measured yet (figures taken +with an approximate window and a candidate-pruned walk do not carry over); run the QoS harness below +before quoting any. The W8A8 caller shares the bf16 drafter graph. Verification against the target +does not by itself show that drafting keeps acceptance, latency or the generated text under every +serving schedule. + +`scripts/dspark_qos_regression.py` is an unvalidated two-server QoS harness, not evidence that +runtime gates pass. In particular, it treats missing metrics as zero, aggregate proposed versus +accepted counts cannot prove a partial rejection, and a stop finish reason does not prove an +explicit stop sequence was encountered. `--prefix-cache-mib 0` does not disable the VRAM prefix +cache; use `--no-prefix-cache` for that. See `docs/DSPARK-370-DEVICE-FOLLOWUP.md` for the +limitations and serial diagnostic receipts. Controlled KV rollback/eviction, acceptance quality, +and QoS measurements remain open; CPU tests and matching sample text cannot establish them. + +For a CPU differential against the reference implementation's `configuration_spark.py` and +`modeling_spark.py`, with Python's torch, transformers and safetensors installed: + +```sh +python3 tests/spark25_reference.py --reference /path/to/XHToken-Spark-X2.6-4B --build build +python3 tests/spark25_reference.py --reference /path/to/XHToken-Spark-X2.6-4B --build build --tp 3 +SPARK25_REFERENCE_TEMPLATE=/path/to/XHToken-Spark-X2.6-4B/chat_template.jinja \ + build/tests/spark25_chat_test +``` + +The first builds a small deterministic checkpoint and compares prefill, chunked prefill and cached +decode against the reference with GPUs hidden; `--tp` runs the same fixture over that many fake host +ranks, which is how the sharding and the collectives are checked without cards. ROCm may still open +GPU device nodes while probing even with visibility masks; on a shared machine run the CPU +comparison in a device cgroup that denies access to `/dev/kfd` and the GPU render nodes. The last +also exercises the checkpoint's actual chat template, which is not redistributed in this tree. + +--- + # `llama`: the plain decoder `model_type: llama` with `LlamaForCausalLM`. Every layer is full attention; unlike `qwen35_fp8` @@ -593,12 +755,14 @@ Traps: - **MTP concatenates the normalized embedding first,** the normalized previous hidden second. - **No RoPE anywhere** (`qk_rope_head_dim` 0); the indexer's only rotation is the Hadamard. -**KV groups.** Five, all bf16 or wider; a `--kv-cache-dtype` other than bf16 is refused at -declare. +**KV groups.** Five. `--kv-cache-dtype fp8` narrows `kv_latent` alone to E4M3, stored at +`kv_store`'s default descale of 1 and read by the `mla_attn` fp8kv rows (docs/OPS.md); the other +four keep the dtypes below whatever the flag, and a cache dtype other than bf16 or fp8 is refused +at declare. | group | kind | per layer | layers | |---|---|---|---| -| `kv_latent` | `RAD_KV_FULL`, bf16, 1 head of 256, block 4 | the 512-wide normed latent, its two halves in the K and V slots | 11 MLA + MTP | +| `kv_latent` | `RAD_KV_FULL`, bf16 (E4M3 under fp8), 1 head of 256, block 4 | the 512-wide normed latent, its two halves in the K and V slots | 11 MLA + MTP | | `kv_dsa_index` | `RAD_KV_FULL`, u8, block 4 | one page a pooled key: 128 E4M3 codes and their f32 scale (`dsa_pool`'s cache form) | 11 MLA + MTP | | `kv_index_tail` | `RAD_KV_LINEAR`, bf16, `[4 + spec, 256]` | the key and gate rows not yet pooled; the ring is wider by the draft depth so a rejected draft rolls back | 11 MLA + MTP | | `kv_kda` | `RAD_KV_LINEAR`, f32, 128 x 128 a head | the recurrent state, 64 / tp heads a rank | 34 KDA | @@ -608,7 +772,7 @@ The latent and the index are replicated: every rank keeps the whole latent cache declares both so (`rad_kv_group_replicated`), which lets the host tier (`--prefix-cache-mib`) hold each once a slot: 49.59 KiB a 4-token block at any rank count (`kv_latent` 48.00 KiB over its 12 layers, `kv_dsa_index` 1.59 KiB), 12.4 KiB a token, where a copy per rank would make a slot -396.75 KiB at eight. The model is a hybrid, so a prefix-cache hit is usable only from a state +396.75 KiB at eight. Under fp8 `kv_latent` is 24.00 KiB a block, 6.4 KiB a token in all. The model is a hybrid, so a prefix-cache hit is usable only from a state checkpoint at or below it, and `--checkpoint-interval` decides how much of a shared system prompt is reused. @@ -812,6 +976,82 @@ the four depths above. --- +# `bailing_hybrid`: Ling-3.0-flash + +`arch/bailing_hybrid` serves Ling-3.0-flash (`model_type: bailing_hybrid`, BailingMoeV3ForCausalLM) +and its fine-tunes from the bf16 checkpoint. The reference is vLLM's `bailing_moe_v3.py` and +SGLang's; the HF `modeling_bailing_moe_v3.py` agrees except for the SwiGLU clamp (below). The plugin +reuses GLM-5.3's KDA core (`KdaState`), sigmoid router (`GlmRouter`, with groups) and draft head +(`GlmMtp`), and `MoeFP8`; its KDA and MLA blocks are in the plugin file. + +``` +42 layers, hidden 2560, vocab 157184 (embedding and lm_head separate), rope_theta 6e6 +layers 5, 11, ..., 41 ((l + 1) % 6 == 0): dense MLA + q 2560 -> 32 x (128 nope + 64 rope), no q LoRA; kv_a 2560 -> 512 + 64: the latent (RMS-normed) + and the rotary key, both cached; kv_b 512 -> 32 x (128 + 128) + rotary over 64 dims, interleaved pairs (HF de-interleaves, then rotates by halves): `gptj` + scores scaled by 1/sqrt(192); a sigmoid gate per head (2560 -> 32); o 4096 -> 2560 (`dense`) +the other 35 layers: KDA, 32 heads of 128 + q, k, v 2560 -> 3 x 4096, each with a causal depthwise conv of width 4 + SiLU + forget gate per channel, full rank (`f_proj` 2560 -> 4096, no_kda_lora), lower bound -5 + (safe gate); beta per head (2560 -> 32); output gate full rank (`g_proj`), sigmoid-gated + RMS norm per head +feed-forward: layers 0-1 dense SwiGLU 2 x 6144; layers 2-41 MoE + 512 routed experts of 768 at top-8, sigmoid scores, correction bias (`expert_bias`), 8 groups of + 64 ranked by the sum of their two best biased scores, 4 kept (noaux_tc); weights normalized + and scaled by 2.5; one shared expert of 768 without a gate + SwiGLU clamped where `expert_swiglu_limit_list` / `share_expert_swiglu_limit_list` say: the + routed experts at 4 in layers 35-41, the shared one at 5 (34-39) and 7 (40-41) +MTP: checkpoint layer 42 -- enorm, hnorm, eh_proj 5120 -> 2560, one MLA layer with the full MoE, + final_layernorm; the trunk's embedding and lm_head +``` + +Traps: + +- **The clamp is taken after the SiLU.** vLLM (`SwigluStepAndMul`) and SGLang compute + `min(silu(gate), L) * clamp(up, -L, L)`; GLM-5.3's `swiglu_clamped` clips the gate before the + SiLU, which at L = 4 caps a large gate at `silu(4) = 3.93` instead of 4. The plugin issues + `swiglu_step`. HF's reference model ignores the lists entirely; the served form is the one the + checkpoint is evaluated with. The routed and the shared arm clamp at different values, often in + different layers (`MoeFP8::Config::shared_swiglu_limit`). +- **Routing is group-limited.** `router_sigmoid_group_topk`: a group's rank is the sum of its two + highest `p + bias`, only the experts of the four best groups are candidates. A single-group + top-8 picks other experts with every shape valid. +- **The query is two projections.** The checkpoint's q rows are per head [nope 128 | rope 64]; the + plugin maps them as two weights (row maps over `q_proj`) into two plain planes, `[T, 32 * 64]` + for `rope` and `[T, 32 * 128]` for the absorption. A single `[T, 32, 192]` plane with column + views turns the wrong rows on libavx, whose `rope` reads a rank-3 operand's head stride as its + row stride. +- **The cache row is [latent | rotary key].** One KV head of 288, the row's first half in the K + slot and the second in the V slot, so `kv_store` writes the 576-wide row contiguously and + `mla_attn_paged` reads it as `[pages, 1, block, 576]`. Scores are taken in the latent; the head + gate multiplies the attention's latent output before the expansion, a reordering of HF's gate on + the expanded values that only rounding tells apart. +- **The pre-tokeniser's pattern has possessive quantifiers** (`[^\r\n\p{L}\p{N}]?+\p{L}+`, + ` ?[^\s\p{L}\p{N}]++[\r\n]*`). Both are one class followed by classes that share no codepoint + with it, which the tokenizer compiles as greedy (core/text/tokenizer_regex.cpp); the ids match + HuggingFace's. + +**KV groups.** + +| group | kind | per layer | layers | +|---|---|---|---| +| `kv_latent` | `RAD_KV_FULL`, bf16, 1 head of 288, block 16 | the 512-wide normed latent and the 64-wide rotated key | 7 MLA + MTP | +| `kv_kda` | `RAD_KV_LINEAR`, f32, 128 x 128 a head | the recurrent state, 32 / tp heads a rank | 35 KDA | +| `kv_kda_conv` | `RAD_KV_CONV`, bf16, width 4 | the convolution history, 3 x 4096 / tp channels a rank | 35 KDA | + +The latent is replicated: every rank computes and stores the whole row. + +**Tensor parallelism.** At 1, 2 or 4 ranks. KDA and MLA split their 32 heads (with them the q/k/v +rows, the convolution taps and the state; the MLA's q, kv_b and gate rows and o's columns); kv_a +and the latent are replicated. The dense feed-forward splits its 6144 columns. A routed expert's +768 columns are six 128-column blocks: halves at two ranks, and at four 2, 2, 1, 1 blocks rotated +by the expert's number mod 4 (`moe_gemm_q_mod4`), so every rank carries six blocks per four +experts. The shared expert splits the same way, unrotated. A calibration run +(`RADIANCE_CALIB_DIR`) and bf16 experts give every rank whole experts instead. + +--- + # Sample size Top-1 agreement between two numeric formats is one Bernoulli trial per prompt, so at p ≈ 0.93 its @@ -1305,6 +1545,31 @@ gemma-4-E2B-it) at one rank: - The vision tower's clipped linears (`use_clipped_linears`) clamp each projection's input and output to the bounds the checkpoint stores (`rad_block_gemma4_vision.h`). +**The 12B form.** Gemma 4 12B (`gemma4_unified`, served through the arch id's alias) has no vision +tower and no audio encoder; `rad_block_gemma4_unified.h` holds what replaces them: +- A picture's patch is a whole 48 x 48 pooling window, its values u / 255 (the processor's Gemma 4 + family with merge 1). The embedder is a LayerNorm over the patch, a linear with its bias, a + LayerNorm, the column's and the row's learned rows, a LayerNorm, the weightless RMS norm and a + projection. The LayerNorms take nn.LayerNorm's eps of 1e-5, which no config states. The position + table `[1120, 2, width]` is read as its two taps of dimension 1, computed at convert, so a + container needs a recipe rule to store them (`gemma4-12b-bf16`, `gemma4-12b-i8g`). One patch is + one row: `--mm-max-patches` counts rows here, and 1120 holds the largest picture. +- An audio clip is frames of 640 samples (40 ms at 16 kHz) as they are, the last zero-padded, one + token each: a weightless RMS norm and a 640 -> width projection. A clip is cut at + `audio_seq_length` (750 frames, 30 s). +- **A picture's rows read both ways.** With `use_bidirectional_attention: "vision"` (the 12B and the + 31B) a picture's or video frame's placeholders attend to each other both ways on the sliding + layers; the global layers stay causal. That is transformers' Gemma 4 mask + (`create_masks_for_vision_model`), KerasHub's and vLLM's; transformers' `gemma4_unified` forward + overlays every layer, which differs little on most pictures. The scheduler ends no prefill chunk + inside such a run (`Scheduler::bidi_fit`), the trunk pass names its runs (`RadBatch::n_bidi`), and + each sliding layer attends a run's rows a second time with `attn_paged` at `causal` 0 over the + cache up to the run's end, written over their causal result. The window stays, as in + transformers' mask (the window AND (causal OR the same picture)): it bounds the keys behind a row. + A run longer than the window (1120 soft tokens against 1024) is read with `attn_paged_ahead`, whose + window bounds the keys behind only, so its first rows see the run's far end. Read causally, the 12B answers pictures differently and often wrongly (on DocVQA, "The image does not + provide information" for an answer it reads off the page). + NVIDIA's DFlash drafter states `dflash_config.causal: false`, with every layer sliding; that flag sets the sliding layers' causality. The recipes are `gemma4-e4b-bf16-df`, `-w8a8-df`, `-w4a8` and `-w4a8-df`. The bf16 container's KL to HF bf16 is 0.0015 with bf16 KV and 0.014 with fp8 KV, so @@ -1805,6 +2070,79 @@ same model and this engine 0.8%. The transcripts match word for word. --- +# `nemotronh`: Nemotron-3.5-Bolt-74B-A9B + +`arch/nemotronh` serves the language model of Nemotron-3.5-Bolt-74B-A9B (`model_type: +nemotron_h_omni`, NemotronH_Omni_Reasoning_V3; the text model is `llm_config`, `nemotron_h_puzzle`) +from the bf16 checkpoint. The reference is vLLM's `nemotron_h.py` and `mamba_mixer2.py`; NVIDIA's HF +`modeling_nemotron_h.py` agrees except for the CPU scan (below). The plugin reuses `MoeFP8` for the +routed arm and `AttnFP8` for attention; its Mamba-2 block and the latent feed-forward around +`MoeFP8` are in the plugin file. + +``` +88 blocks, hidden 4096, vocab 131072 (embedding and lm_head separate), RMS eps 1e-5; each block one + mixer behind its own norm and a residual add, the type from `layers_block_type` +40 Mamba-2: 128 heads of 64 in 8 groups, state 128 + in_proj 4096 -> z 8192 | x 8192 | B 1024 | C 1024 | dt 128, no bias + x|B|C through a causal depthwise conv of width 4 with bias, then SiLU + dt' = softplus(dt + dt_bias), unclamped; A = -exp(A_log); a D skip per head + y = scan(x, B, C, dt'); RMSNormGated: norm over groups of 1024 of y * silu(z), times 8192 gains + out_proj 8192 -> 4096 +40 latent MoE: router on the normed hidden state (sigmoid, a correction bias for the selection + only, one group, top-9, normalized, x5) + fc1_latent_proj 4096 -> 1024; routed experts in the latent, ungated: down(relu(up(x))^2); + per layer (`block_configs`) 240 to 496 experts of 1536 to 2560; fc2_latent_proj 1024 -> 4096 + one shared expert on the hidden state, 4096 -> 5376 -> 4096, relu^2 +8 attention: 32 query heads, 2 KV heads of 128, no position encoding +``` + +Traps: + +- **The layer count is not stated.** `llm_config` has no `num_hidden_layers`; HF derives it from + `block_configs`. The checkpoint reader counts `layers_block_type` when the key is absent, and + flattens the array of objects `block_configs` into `block_configs..`, from which the + plugin reads each routed layer's experts, width and top-k. +- **dt is not clamped.** `time_step_limit` is (0, inf), and vLLM passes exactly that to its scan. + HF's CPU path `torch_forward` clamps dt' below at `time_step_min` (0.001), which in the first + layers moves 13 % of the (token, head) steps, and it is also wrong past its first 128-token chunk + (the state handoff between chunks): HF on the CPU is no reference beyond 128 tokens. +- **The gated norm normalises the product, per group.** `norm(y * silu(z)) * w` with the RMS over + 1024 channels (8 groups of the 8192), not `norm(y) * w * silu(z)` (the delta net's + `gdn_gated_rmsnorm`). Served as `act_mul` (silu), a gainless `rmsnorm` over rows of 1024 and + `mul_weight`; a rank's heads are whole groups. +- **The router reads the hidden state, the experts the latent.** `MoeFP8` runs at the latent width + (`Config::router_k` sizes the router, `Wire::route` feeds it); fc2 is linear and has no bias, so + each rank applies it to its partial latent sum and one all-reduce over the hidden width sums the + routed and shared arms (`Config::no_reduce`). +- **relu^2 is `act_mul`'s relu over one operand twice:** relu(x) * x, rounded once, which is + torch's `relu(x) ** 2` in bf16 bit for bit. +- **The bf16 checkpoint has no BOS in its template.** Its chat template sets none, as llama.cpp + does for the MoE form. + +**KV groups.** + +| group | kind | per layer | layers | +|---|---|---|---| +| `kv_attn` | `RAD_KV_FULL`, bf16, 2 / tp heads of 128 (1 at four ranks, replicated over a pair), block 16 | keys and values | 8 attention | +| `kv_ssm` | `RAD_KV_LINEAR`, f32, 64 x 128 a head | the recurrent state, 128 / tp heads a rank | 40 Mamba-2 | +| `kv_ssm_conv` | `RAD_KV_CONV`, bf16, width 4 | the convolution history, (8192 + 2048) / tp channels a rank | 40 Mamba-2 | +| `kv_draft` | `RAD_KV_WINDOW` (1024), bf16, 2 / tp heads of 128 (1 at four ranks, replicated over a pair), block 16 | the LiLiCorr drafter's keys and values | its 5 layers, past the trunk | + +**Speculation.** With drafts the scan keeps `ssd_update`'s anchor form (the committed state and a +scratch of per-token records: decay, `dt' x`, B), at most 31 drafts a step. NVIDIA's LiLiCorr block +drafter proposes 7: 32 query heads over 2 KV heads of 128, which four ranks replicate as the trunk's +attention does (`drafter_geom`'s `kv_repl_ok`: each rank reads its head's k and v rows at `kv_off`, +and `attn_paged_sink` runs at gqa 8 instead of 16). A verify's 8 query rows run the trunk's +attention in the split-KV decode kernel a plain decode runs, at gqa 16 (one and two ranks) in eight +waves as at gqa 8 (four) in four, so each row is the single-row decode at its position bit for bit +while each of the split law's segments holds one 16-key tile (a context up to 2048 tokens: 256 +segments at a decode, 128 at a verify). Past that the partition differs and a near-tie can flip +greedy text, as `ident.sh` allows ([TOOLS](TOOLS.md)). + +**Vision.** `arch/nemotronh/radio.h` serves the C-RADIO (v4-H) tower and its `mlp1` projector when +the container holds them (`vision_config.model_type` `radio`): pictures, and video in tubelets of +two frames, through `core/mm`'s `Radio` family. + # `minimaxmusic3`: MiniMax-Music3, songs `arch/minimaxmusic3` declares an audio generator (`rad_declare_audio_generator`), which makes the @@ -2337,3 +2675,43 @@ with and without a first frame; diffusers on CUDA and on the CPU differ from eac On an R9700 (libr4d) the same five renders land within 0.15% of diffusers' CUDA rows, every op agreeing with its host reference under the op oracle. Block fp8 moves the random model's rows by 0.2 to 0.4% (the card's fp8a8 GEMMs, the CPU's fp8 codes widened to bf16). + +# `hunyuan3d2`: Hunyuan3D-2, a 3-D shape from a picture + +`arch/hunyuan3d2` declares a shape generator (`rad_declare_shape_generator`), which makes the +program one the engine drives through `core/gen/shape_driver.h`: SCOND runs the image encoder over +the picture and `cond_in` over its rows and over the unconditioned branch's zeros, into the lane; +SSTEP is one denoising step of both branches together; SLATENT runs the shape VAE's latent network +and leaves the geometry decoder's keys and values in the lane; each SQUERY pass is the geometry +decoder at up to 32768 points the core chose. The core samples the grid coarse to fine (FlashVDM's +hierarchical decoding with full attention) and meshes the finest level with marching cubes. A +request is a lane; two hold state at once. It is served on Hunyuan3D-2's own routes, `/generate`, +`/send` and `/status/{uid}` ([GUIDE §5.17](GUIDE.md)), bf16 on one card. The checkpoint is the +release's hunyuan3d-dit-v2-0 folder: config.yaml (its keys under their dotted paths) and one +safetensors holding `model.`, `conditioner.` and `vae.`. + +``` +picture the alpha's box at 85% of the picture's square, centred on white (OpenCV's INTER_AREA), + 512 x 512 (INTER_CUBIC), then 518 x 518 (bilinear) normalised by ImageNet's statistics, + in 37 x 37 patches of 14 x 14, f32 into the patch projection +encoder DINOv2-giant: 40 layers of 1536 (24 heads of 64), LayerNorm eps 1e-6, SwiGLU 4096 with + biases, layer scales on both branches, the class token and a learned position table; + the last hidden state after the final LayerNorm, 1370 rows. The unconditioned branch is + zeros, so its rows after cond_in are cond_in's bias +DiT FLUX's layout without a rotary: 16 double-stream blocks (the conditioning and the latent + each with their own weights, one joint attention) and 32 single-stream blocks + (linear1 = [qkv | mlp], linear2 over [attn | gelu_tanh(mlp)]), width 1024, 16 heads of + 64, q and k RMS-normed per head (eps 1e-6), LayerNorms without affine modulated as + (1 + scale) LN(x) + shift with gates and no tanh. The timestep embedding is the sinusoid + of 1000 sigma at a period of 1000 (the reference passes its time factor where + timestep_embedding takes max_period), then time_in. Rows a step: [cond | latent] for + the picture's branch and [latent | cond] for the unconditioned one, so each branch is + one attention run and the two latents one run for the latent stream's ops +sampler flow matching from sigma 0 (noise) to 1: Euler on numpy's linspace(0, 1, steps), the + last grid point's evaluation (a zero step in the reference) skipped; guidance 5 +VAE latent / scale_factor, post_kl 64 -> 1024, 16 self-attention blocks (q, k, v and the + geometry decoder's k, v are head-interleaved in the checkpoint and gathered per head at + conversion; per-head LayerNorms on q and k, exact GELU MLP 4096) +geometry a point's [x | sin | cos] at 8 octaves (51 values, f32, point_fourier), query_proj, one + cross-attention block over the latent rows (its own MLP), ln_post (eps 1e-5), a logit +``` diff --git a/docs/DOCKER.md b/docs/DOCKER.md index 5861b95f..5191af01 100644 --- a/docs/DOCKER.md +++ b/docs/DOCKER.md @@ -7,7 +7,8 @@ Docker, an AMD GPU and an `amdgpu` kernel driver that supports ROCm 10.1. It doe compiler or FFmpeg. The image is published as [`stilldeadcode/radiance`](https://hub.docker.com/r/stilldeadcode/radiance), -with its kernels built for `gfx1201`: `docker pull stilldeadcode/radiance`. Build it yourself for +with its kernels built for RDNA4 (`gfx1201`, libr4d), RDNA3 (`gfx11-generic`, libr3d) and Strix Halo +(`gfx1151`, libhalo): `docker pull stilldeadcode/radiance`. Build it yourself for other cards or another commit. The examples below use `radiance`, the tag a local build gets; with the published image, write `stilldeadcode/radiance` instead. @@ -26,7 +27,7 @@ docker/build.sh -j 8 # cap compile jobs (a device kernel takes docker/build.sh -J 4 # tests at a time (default: the compile jobs) docker/build.sh -B 5 # every test's CPU budget times 5, for a host slower per thread docker/build.sh -E tokenizer_perf_test # leave tests matching a regex out of the test stage -docker/build.sh -t 'gfx1200;gfx1201' # GPU architectures to compile kernels for (default gfx1201) +docker/build.sh -t 'gfx1200;gfx1201' # GPU architectures (default 'gfx1201;gfx11-generic;gfx1151') docker/build.sh -r # any other commit docker/build.sh --target build # stop at a stage, tagged radiance- ``` @@ -143,13 +144,18 @@ the cards the engine runs on. | `sage-a1.5-mxfp4-df2.yaml` | `sage-a1.5-mxfp4-df2.rad` | The same with the trunk, the experts and the drafter at MXFP4; ten 262,144-token sessions | | `qwen3.8-27b-fp8.yaml` | `qwen3.8-27b-fp8.rad` | Qwen3.8-27B FP8 with its DFlash2 drafter and vision tower | | `qwen3.8-27b-mxfp4.yaml` | `qwen3.8-27b-mxfp4.rad` | Qwen3.8-27B with AMD's Quark AWQ-MXFP4 trunk, its DFlash2 drafter and vision tower | +| `qwen3.8-27b-iqr-v4.yaml` | `qwen3.8-27b-${IQR_V4}.rad` | Qwen3.8-27B in IQR-V4 at the size `IQR_V4` names (default `iq4r-s-v4`), its DFlash2 drafter and vision tower | | `qwen3.8-27b-paro.yaml` | `qwen3.8-27b-paro-int4.rad` | Qwen3.8-27B ParoQuant int4 (learned rotations) with its DFlash2 drafter and vision tower, on one card; the int5 and MXFP4 containers serve from it too | | `qwen3.8-27b-bf16.yaml` | `qwen3.8-27b-bf16.rad` | Qwen3.8-27B in bf16 | | `gemma4-31b-w4a8.yaml` | `gemma4-31b-w4a8.rad` | Gemma 4 31B, int4 trunk with int8 activations, its assistant head as the MTP drafter, vision tower | | `gemma4-31b-heretic-ara-w4a8.yaml` | `gemma4-31b-heretic-ara-w4a8.rad` | The same for Gemma 4 31B heretic-ara (refusals removed) | +| `gemma4-12b-bf16.yaml` | `gemma4-12b-bf16.rad` | Gemma 4 12B in bf16, its assistant head as the MTP drafter, pictures and audio through the 12B's embedders, on two cards | +| `gemma4-12b-i8g.yaml` | `gemma4-12b-i8g.rad` | The same with the trunk at int8 (i8a8), on one card | | `nemotron-3.5-bolt-e4b-bf16.yaml` | `nemotron-3.5-bolt-e4b-bf16.rad` | NVIDIA-Nemotron-3.5-Bolt-E4B (Gemma 4 E4B) in bf16 with NVIDIA's DFlash drafter, the vision tower in pinned host memory, on one card | | `nemotron-3.5-bolt-e4b-i8g.yaml` | `nemotron-3.5-bolt-e4b-i8g.rad` | The same with the trunk at int8 (i8a8) | | `nemotron-3.5-bolt-e4b-a4.yaml` | `nemotron-3.5-bolt-e4b-a4.rad` | The same with the feed-forward at four bits (GPTQ), attention and layers 19-23 at i8a8 | +| `nemotron-3.5-bolt-74b-w4a8.yaml` | `nemotron-3.5-bolt-74b-w4a8.rad` | NVIDIA-Nemotron-3.5-Bolt-74B-A9B with four-bit experts and a block-FP8 trunk, NVIDIA's LiLiCorr drafter, vision, on two cards | +| `nemotron-3.5-bolt-74b-fp8.yaml` | `nemotron-3.5-bolt-74b-fp8.rad` | NVIDIA-Nemotron-3.5-Bolt-74B-A9B in block FP8 with NVIDIA's LiLiCorr drafter, vision, on four cards | | `translategemma-27b.yaml` | `translategemma-27b-mxfp4-gptq.rad` | TranslateGemma 27B MXFP4 with its chat template (`gemma3.jinja`) | | `glm53-flash.yaml` | `glm53-flash-mxfp4.rad` | GLM-5.3-Flash, MXFP4 experts and block-FP8 attention, on eight cards | | `minicpm5-2b.yaml` | `minicpm5-2b-fp8.rad` | MiniCPM5-2B FP8 with its DSpark drafter | diff --git a/docs/GUIDE.md b/docs/GUIDE.md index eff75f60..7e24e0d0 100644 --- a/docs/GUIDE.md +++ b/docs/GUIDE.md @@ -316,6 +316,7 @@ and runs. | `fishomni` | Fish Audio drama-3, speech from text with speaker tags and inline direction (§5.15) | | `minimaxh3` | MiniMax-H3 and FastH3, video with its stereo soundtrack from text (§5.16) | | `ltx2` | LTX-2.5, video with its stereo soundtrack from text or a first frame (§5.16) | +| `hunyuan3d2` | Hunyuan3D-2's shape model, an untextured 3-D mesh from one picture (§5.17) | **4. Falling back to the reference library is fatal.** If any op resolves to `libref`, the engine refuses to start and names the ops, because serving from it is orders of magnitude slower with nothing @@ -708,7 +709,8 @@ radiance --model m.rad --debug-placement # the placement plan only The card is split into resident weights and the paged KV pool. The engine derives the split from the card and the model; no flag states either pool. Its inputs: `--gpu-headroom-mib` leaves card space -alone, `--max-model-len` and `--max-num-seqs` bound the cache, and `--host-pool-mib` decides which +alone, `--gpu-memory-mib` claims a size (headroom is the card less that; give one of the two), +`--max-model-len` and `--max-num-seqs` bound the cache, and `--host-pool-mib` decides which experts must stay on the card. The startup receipt prints every term. With no visible card (the host backend) half of RAM stands in for the card and is split the same way; the weights pool is then host memory, holding the weights a host kernel cannot read where the container stores them. @@ -784,6 +786,7 @@ Related flags: ```sh --gpu-headroom-mib 96 # VRAM left unclaimed on every card +# --gpu-memory-mib 28000 # the same knob as a claim; not with --gpu-headroom-mib --kv-cache-dtype fp8 # halve what a token of context costs (a real quantisation) --host-pool-mib 8192 # pinned host tier for weights --embedding-placement vram # keep the token embedding on the card (below) @@ -859,15 +862,35 @@ the pinned total is twice the table: set `amdgpu.no_system_mem_limit=1` (the cap and 1.5 GiB) or the second pin can be refused. The kernel charges the tmpfs pages to the memory cgroup of the engine that filled them. +`--ngram-placement disk=DIR` reads the table from its own file, `DIR/ngram-.bin`, instead of from +the container: a table on a faster or separate drive (an Optane beside a model on a large NVMe, or a +model on a hard disk with its table on an SSD) at no host memory. The first start fills the file from +the container (the table's size free in `DIR`, written under `.part` and renamed, so the real name is +always complete); later starts check samples of it against the container and reuse it. The `` is +`ram=DIR`'s, so a file never serves another model; remove the file to have it filled again. Reads go +to it as `disk` reads the container, through the row cache with direct I/O, so `DIR`'s filesystem must +support `O_DIRECT` (tmpfs since Linux 6.6 does, but a tmpfs is what `ram` is for). + **`--weights-disk-tier`** serves a model larger than the card and the host pool together, with every step paced by the drive. A routed expert that fits neither lives only in the container. Before each -routed layer's first expert op, on every pass, the engine reads all that layer's on-disk experts into -one of two VRAM buffers (a router's picks are not known on the host, and a prefill chunk routes to -nearly all of them). The buffers come out of the weight budget (the plan's `file buffers` line), and -the reads go through four 32 MiB pinned windows out of `--host-pool-mib`, as long runs that skip -resident experts. It is meant for running a checkpoint as shipped, to calibrate or compare against. -The bf16 Qwen3.8-Flash-Next (335 GiB) runs on two cards at about 28 s a step, the same at one token as -at 32K, so use large prefill steps: +routed layer's first expert op, on every pass, the engine reads the layer's on-disk experts that its +rows route to into one of two VRAM buffers: the layer's router has run by then, and its counts are +copied back first (one wait on the card per routed layer), so an expert no row routes stays on the +drive. A step whose rows route nearly every expert, 64 rows an expert on average (3277 tokens for +Qwen3.8-Flash-Next's 512 experts at top-10), reads its layers whole instead, each one while the card +computes the one before, with no wait on the card. The buffers come out of the weight budget (the +plan's `file buffers` line), and the reads go through four 32 MiB pinned windows out of +`--host-pool-mib`, as long runs that skip resident experts. Without `--deterministic` the host pool +is also a cache of the drive: an expert read from it is kept in a free pool slot, and a full pool +gives its coldest expert back to the drive for a warmer one. It is meant for running a checkpoint +as shipped, to calibrate or compare against. The bf16 Qwen3.8-Flash-Next (335 GiB) runs on two +cards at about 28 s a 32K-token step, so use large prefill steps: + +GLM-5.3-Flash lays its routed experts out by what the deployment needs. At four and eight cards each +MXFP4 expert is split by width across every card, the shape its kernels are tuned for, and every expert +must then fit in VRAM and the host pool. A container with any expert in another format stays whole. `--weights-disk-tier` keeps them whole on one card each, so they +can stay on the drive, at about a third of the prefill speed and two thirds of the decode speed on 4 x +R9700. Two cards always keep them whole. ```sh rad-convert /srv/models/Qwen/Qwen3.8-Flash-Next -o flashnext-bf16.rad --max-ctx 4096 # no recipe: bf16 @@ -884,9 +907,10 @@ plane grows into what it releases, so a model whose experts do not fit never str for unused cache. **Headroom.** `--gpu-headroom-mib` is kept for allocations the engine does not make, chiefly a -kernel's code object, which HIP loads at the kernel's first launch. With too little left, the first -kernel that has never run (a draft head's, a sampler chain's) fails its load and faults inside the -HIP runtime: a segfault in a correct kernel on a server that had been serving. +kernel's code object, which HIP loads at the kernel's first launch. `--gpu-memory-mib N` is the same +knob written as a claim: headroom is the card less N. The two flags cannot be combined. With too +little left, the first kernel that has never run (a draft head's, a sampler chain's) fails its load +and faults inside the HIP runtime: a segfault in a correct kernel on a server that had been serving. Once everything is allocated, startup logs `card N settled at ... free`. Memory taken after the budget read the card (another process such as a desktop, or a driver allocation) comes out of the headroom, @@ -911,8 +935,9 @@ takes the model's training context. `--kv-cache-dtype fp8` is an E4M3 cache with per-(sequence, head) descales. It halves what a token of context costs, which at a production context is most of the pool. It is a real quantisation that changes the output slightly, so it is only ever set explicitly. Every architecture serves both -widths except GLM-5.3-Flash (`glm5next`), whose latent-attention cache is bf16 only and which refuses -`fp8` at startup. The flag sets every attention cache of the deployment, a drafter's (DSpark, +widths. On GLM-5.3-Flash (`glm5next`) `fp8` narrows the latent-attention cache alone, to E4M3 at a +descale of 1 (half its bf16 size); the DSA index, its key tail and the KDA caches keep their own +widths. The flag sets every attention cache of the deployment, a drafter's (DSpark, DFlash2) included. The delta-net state and the QSA indexer's key tail are recurrent state and keep their own widths. @@ -1127,8 +1152,27 @@ chunk's time, and every sequence decoding beside it waits that long for its next `--prefill-interleave 2`, after a step that carried a chunk while other sequences were decoding, the next two steps carry decode rows only and admit nothing, then the next chunk is scheduled. The prompt's time to first token grows by those steps and the decoders keep their cadence. A lone prefill is not held, nor is the step after a prompt's last -chunk. `0` (the default) schedules as before. `/stats` counts the decode-only steps the hold -inserted as `steps_held`, `/metrics` as `radiance:engine_steps_held_total`. +chunk. `0` schedules as before. `/stats` counts the decode-only steps the hold inserted as +`steps_held`, `/metrics` as `radiance:engine_steps_held_total`. + +Served default: `--prefill-interleave auto:1` (below), so decoding sessions keep about half their +rate while prompts prefill; `--deterministic`, KL mode and generators keep 0, and an explicit `N` +or `auto[:SHARE]` is kept as given. Measured on Qwen3.8-Flash-Next (fp8, TP2, MTP 3, 8 sessions +decoding beside 64K prompts): 12.3 -> 40.9 decode tokens/s a session, aggregate prefill 3.7K -> +1.8K tokens/s, time to first token 17 -> 36 s. `--prefill-interleave 0` restores the old schedule. + +`--prefill-interleave auto` sizes the hold from measured step times instead: after each such chunk, +as many decode-only steps as fit in a quarter of a chunk step's time at a decode step's (running +means of both, at most 64 steps; one until a decode step has been timed). `auto:SHARE` uses SHARE +of the chunk step's time instead of a quarter (0 < SHARE <= 4; `auto:1` gives decode as much time +as prefill). With the quarter the prefill gives up at most a fifth of its rate however many +sequences decode, and the decoders get several steps where a decode step is cheap beside a chunk, +none where one costs more than that quarter (they still ride every chunk). In the scheduler's host simulation of 32 prompts of 128K tokens sent at once, each +then decoding 512 tokens (2048-token chunks, MTP 3, step costs fitted to a lone prefill and to +decode alone), auto raised the decode rate of the sequences decoding while prompts still waited +from 6.5 to 31 tokens/s each and delayed the last first token by 6 %. Because the hold follows the +device's timing, which steps carry a chunk differs from run to run; a number schedules the same +steps every time. **A prefill alone in its step can carry several intervals** (`--prefill-span N`, default 1). A chunk ends on every checkpoint interval, so a prompt is otherwise prefilled one interval a step. @@ -2045,8 +2089,8 @@ by 0.002-0.003 nats. | flag | default | | |---|---|---| | `--max-num-batched-tokens N` | 2048 | largest token count one step may carry | -| `--prefill-interleave N` | 0 (off) | decode-only steps after each prefill chunk while other sequences decode (§4.5), at most 64 | -| `--preempt-wait-ms N` | 5000 | how long a preempted prefill may wait for its whole-recompute gate before reclaiming cache blocks and preempting lowest-priority running requests until one overdue request can prefill; `0` falls back on the next step | +| `--prefill-interleave N` | auto:1 (0 under `--deterministic`, KL mode, generators) | decode-only steps after each prefill chunk while other sequences decode (§4.5), at most 64; `auto` fits them in a quarter of the chunk step's measured time, `auto:SHARE` in SHARE of it (0 < SHARE <= 4); `0` lets every step carry a chunk | +| `--preempt-wait-ms N` | 5000 | how long a preempted prefill may wait for its whole-recompute gate before reclaiming cache blocks and preempting lowest-priority running requests until one overdue request can prefill; `0` falls back on the next step. A preempted request publishes what it computed to the prefix cache, as a finished one does, so its recompute adopts its prompt instead of computing it again; under pressure the cache gives those blocks back, the newest last, before another request is preempted | | `--busy-prefill-chunk MODE` | auto | a prefill chunk's share of a step that has other work: `auto` leaves decode rows and waiting requests their room (§4.5), `off` takes the whole step, `N` holds it to N tokens | | `--max-num-seqs N` | 256 | largest number of sequences one step may carry | | `--max-model-len N` | 0 | context bound; 0 takes the model's training context | @@ -2057,6 +2101,7 @@ by 0.002-0.003 nats. | flag | default | | |---|---|---| | `--gpu-headroom-mib N` | 96 | VRAM left unclaimed on every card | +| `--gpu-memory-mib N` | 0 (use `--gpu-headroom-mib`) | VRAM claimed on every card; inverse of `--gpu-headroom-mib`. Give one (§4.3) | | `--kv-cache-dtype T` | bf16 | `bf16`, `fp8`, or on Qwen3.8-27B and Qwen3.8-Flash-Next `fp8_v4` or `k6_v4` (§4.4) | | `--state-cache-dtype T` | f32 | `f32` or `f16`: the recurrent (delta-net) state cache; f16 halves the state memory and is lossy, `qwen35` plugins only (§4.4) | | `--attn-prefill-fp8 MODE` | off | `off`, `qk`, `pv` or `both`: the prefill attention's Q·Kᵀ, P·V or both in E4M3 over an `fp8`, `fp8_v4` or `k6_v4` cache; lossy, Qwen3.8-27B (§4.4) | @@ -2064,7 +2109,7 @@ by 0.002-0.003 nats. | `--kv-resident N` | 0 (off) | stream the sparse attention group's KV from pinned host memory, keeping a ring of N tokens on the card. Raised to 32 768 and to one decode step's selection; a ring that covers the context streams nothing. Ignored with a warning on an architecture that cannot stream (§4.4.1, [KV-STREAMING.md](KV-STREAMING.md)) | | `--host-headroom-mib N` | 4096 | host RAM left free for the system when startup pins host memory — kept for the unpooled allocations, staging and page cache (§4.3). A snapshot store's floor takes back the shortfall from it, down to 1 GiB, rather than come up with none (`--checkpoint-slots`, §4.8) | | `--embedding-placement WHERE` | ram | `ram` or `vram`: the token embedding pinned in host memory beside `--host-pool-mib` and read in place, or on the card (§4.3) | -| `--ngram-placement WHERE` | auto | `auto`, `vram`, `ram` or `disk`: an n-gram table on the card, as a copy in RAM made at load and read by the card, or read from the container (§4.3) | +| `--ngram-placement WHERE` | auto | `auto`, `vram`, `ram` or `disk`: an n-gram table on the card, as a copy in RAM made at load and read by the card, or read from the container (§4.3); `ram=DIR` shares the RAM copy between engines, `disk=DIR` reads the table from its own file in `DIR` | | `--vision-tower-placement WHERE` | vram | `vram` or `ram`: the encoder towers (vision, and audio where a model has one) on the card, or pinned in host memory beside `--host-pool-mib` and read in place once an image (§4.3) | | `--weights-disk-tier` | off | read weights that fit neither VRAM nor the host pool from the container (O_DIRECT); routed experts a layer at a time | @@ -2132,7 +2177,7 @@ by 0.002-0.003 nats. | `--allow-host NAME` | — | a `Host` name the keyless loopback-only routes accept besides the loopback names; repeatable (§6.6) | | `--trusted-proxy CIDR` | — | a network whose sockets may name the client behind them, via `X-Forwarded-For`, for the log; vouching changes attribution, never access; repeatable (§6.6) | | `--served-model-name NAME` | container's name | the model id `/v1/models` lists, the metrics carry and a response names when its request named none. A request may name any model; the loaded one serves it | -| `--mm-max-patches N` | auto | patches one vision-encoder pass carries, and so the largest image (a patch is 16x16 pixels, 14x14 on GLM-5.3). `auto` is 16384 when the container carries a vision tower; 0 serves text only and keeps the tower off the card. A pass is not one tower invocation: inside it the tower batches at most 8 tiles per weight read, and the pass size may reduce that (4 tiles at the 64-pixel grid with the default 16384 patches); a picture contributes a separate pass per grid. See the concurrency notes for Unlimited-OCR (§5.17) | +| `--mm-max-patches N` | auto | patches one vision-encoder pass carries, and so the largest image (a patch is 16x16 pixels, 14x14 on GLM-5.3). `auto` is 16384 when the container carries a vision tower; 0 serves text only and keeps the tower off the card. A pass is not one tower invocation: inside it the tower batches at most 8 tiles per weight read, and the pass size may reduce that (4 tiles at the 64-pixel grid with the default 16384 patches); a picture contributes a separate pass per grid. See the concurrency notes for Unlimited-OCR (§5.18) | | `--override-chat-template PATH` | container's | a Jinja chat template file served in place of the container's. The reply format (reasoning markers, tool calls) is derived from it too, unless the architecture plugin declares one. An unreadable or empty file stops startup | | `--max-queued-requests N` | 8 × `--max-num-seqs` | requests admitted and unfinished at once; past it, 429 | | `--http-threads N` | one per hardware thread, at least 4 | HTTP workers kept while idle | @@ -2229,6 +2274,7 @@ flags are refused on it, and so are the pixel bands. | `POST /v1/audio/speech` | OpenAI's speech API, whole or streamed: speech from a speech model (Breeze-TTS-2, `instructions` describing the voice; drama-3, speakers and direction in the input); songs from a music model (MiniMax-Music3), `input` the lyrics and `instructions` the song; else 501 (§5.15) | | `GET /v1/audio/speech/stream` (WebSocket) | vLLM-Omni's realtime speech session: text streamed in, each sentence's audio streamed out as soon as the sentence is complete; needs an audio generation model (§5.15) | | `POST /v1/videos`, `GET /v1/videos[/:id[/content]]`, `DELETE /v1/videos/:id` | OpenAI's video jobs: a video with its soundtrack from a prompt, made in the background and downloaded as MP4; needs a video model (MiniMax-H3), else 501 (§5.16) | +| `POST /generate`, `POST /send`, `GET /status/:uid` | Hunyuan3D-2's API server's routes: a 3-D mesh (GLB, OBJ, PLY or STL) from a picture, at once or in the background; needs a shape model (Hunyuan3D-2), else 501 (§5.17) | | `POST /v1/messages`, `POST /v1/messages/count_tokens` | Anthropic's Messages API, for Claude Code and the Anthropic SDKs (§5.9, §5.11) | | `POST /v1/responses`, `POST /v1/responses/input_tokens` | OpenAI's Responses API, for Codex and the OpenAI SDKs' `responses` client (§5.9) | | `POST /completion`, `/completions`, `POST /infill` | llama-server's native completion and fill-in-the-middle, for llama.vim, llama.vscode and clients of llama-server's own API (§5.9) | @@ -2638,7 +2684,7 @@ passes but not launches (the UNet runs once per image and branch), so two take t |---|---| | `model` | accepted and not enforced: one server serves one model | | `messages` / `prompt` / `input` | chat / completion / embedding | -| `images_config` | image models only: the processor mode the request wants, by name (`gundam`, `base`) or as an object restating the served sizes; a geometry the model does not serve is refused (Unlimited-OCR, §5.17) | +| `images_config` | image models only: the processor mode the request wants, by name (`gundam`, `base`) or as an object restating the served sizes; a geometry the model does not serve is refused (Unlimited-OCR, §5.18) | | `max_tokens`, `max_completion_tokens`, `n_predict` | default: what the context leaves after the prompt (`--default-max-tokens`); -1 is llama-server's "no limit", the same without the default. Clamped to what the context leaves, and to `--max-tokens-cap`, rather than refused (§5.8) | | `temperature` | [0, 2] | | `top_p` | (0, 1] | @@ -2856,6 +2902,7 @@ each field is read, taken without effect, or refused by name. | `role: "system"` in `messages` | after the head of the conversation, its text joins a user message at its position, since templates read a system message only at the head: as a text block ahead of the user message right after it, else after the one right before it, else as a user message of its own, so no two user turns follow each other. `clear_at: "next_user_message"` stops rendering it once a later user message (a `tool_result`-only one included) exists. An effort-only message (no text, `output_config: {"effort": ...}`) sets the effort from the next user message on. Blocks other than text (`tool_addition`, ...) are refused | | `tools`, `tool_choice` | client tools; server tools (`web_search_…`, `code_execution_…`) are refused. `tool_choice` as an object (`auto`, `any`, `tool`, `none`, `disable_parallel_tool_use`) or a string (`"auto"`, `"none"`, `"any"`); `any` is the chat path's `required` (§5.4) | | `max_tokens`, `temperature`, `top_p`, `top_k`, `stop_sequences`, `stream` | as on the chat path; `max_tokens` is optional there too | +| `min_p`, `presence_penalty`, `frequency_penalty`, `repetition_penalty`, `repeat_last_n` | not Anthropic's: the chat path's fields with its ranges and meaning (§5.7), for clients that speak only this format. The penalties count a token's occurrences in the last `repeat_last_n` tokens of prompt and reply (64 by default, `--repeat-last-n`), as llama.cpp does | | `thinking` | `enabled` (its `budget_tokens` is the chat request's `thinking_token_budget`), `adaptive`, `disabled`, `between_tools` (off). `display` and `block_binding` are taken: the reasoning comes back whole, with an empty `signature` | | `output_config` | `effort` (`low`, `medium`, `high`, `xhigh`, `max`) is the chat request's `reasoning_effort`, which the template reads in its own level names: a level it does not take is refused with the ones it does, and `--reasoning-effort-map` renames them (§4.9). `format` (`{"type": "json_schema", "schema": ...}`, or the older top-level `output_format`) is a `response_format` (§5.5). `task_budget` is taken | | `context_management` | validated; the conversation is served as sent, and the answer says so: `"context_management": {"applied_edits": []}`, on `message_delta` in a stream | @@ -3526,7 +3573,53 @@ The MP4's soundtrack is 48 kHz stereo. LTX-2.5 runs on one card; `--tp` above 1 Gemma 4 text encoder (13 GiB in fp8) does not fit a 32 GB card beside the DiT: serve it with `--vision-tower-placement ram`, which keeps it in pinned host memory and reads it once a prompt. -### 5.17 Documents: Unlimited-OCR +### 5.17 3-D shapes: `/generate` + +A shape generation model (Hunyuan3D-2) makes an untextured 3-D mesh from one picture of an object. +It answers Hunyuan3D-2's own API server's routes, so that server's clients (its Blender add-on, +scripts written against it) work unchanged: `POST /generate` makes the shape while the request +waits and answers with the file; `POST /send` makes it in the background and answers at once with +`{"uid": ...}`; `GET /status/{uid}` reports `{"status": "processing"}` (with `steps_done` of +`steps`), then `"completed"` with the file as base64 in `model_base64`, or `"error"` with its +`message`. + +```sh +# The shape model is tencent/Hunyuan3D-2's hunyuan3d-dit-v2-0 folder: config.yaml and +# model.fp16.safetensors. Its weights ship in fp16 and are cast to bf16 at conversion. +rad-convert Hunyuan3D-2/hunyuan3d-dit-v2-0 --recipe data/recipes/hunyuan3d-2-bf16.recipe \ + -o hunyuan3d-2-bf16.rad +radiance --model hunyuan3d-2-bf16.rad + +curl -s http://localhost:8000/generate -H 'Content-Type: application/json' \ + -d "{\"image\": \"$(base64 -w0 penguin.png)\"}" -o penguin.glb +``` + +- **`image`** is the picture as base64 (a data URL is taken too). Give it an alpha channel that cuts + the object out: the reference removes an opaque picture's background with rembg first, which this + server does not, so an opaque picture is taken whole, background and all. The picture is prepared + as the reference prepares it: the alpha's bounding box scaled to 85% of the square that holds the + picture, centred on white, 512 x 512, then the image encoder's 518 x 518. +- **`num_inference_steps`** counts sigma grid points (50, so 49 evaluations, by default; 2 to + 200); **`guidance_scale`** is the classifier-free guidance against the unconditioned branch (5 + by default); **`seed`** makes a shape repeatable (1234 when absent, as the reference). +- **`octree_resolution`** is the grid's cells a side the field is sampled on (256 by default, 16 + to 512). The grid is sampled coarse to fine, as FlashVDM's hierarchical decoding does: the whole + grid at the coarsest level (the resolution halved while it stays at least 63), then only the + points near the surface at each finer level; with `"volume_decoding": "dense"` every point of + the finest grid is sampled instead, as the reference's default decoder does (slower, the same + field). The surface is marching cubes over the finest grid at level 0. +- **`type`** is the file: `glb` (the default; positions, smooth normals and faces), `obj`, `ply` + (binary) or `stl` (binary). The mesh is the raw surface, as the reference's `/generate` returns + it without texturing: no floater removal or face reduction. +- **`texture`** true (Hunyuan3D-Paint) is refused: this server makes the untextured shape. So are + the reference's `text` (its text-to-image front end) and `mesh` (re-texturing) inputs. + +A shape is about 3 TFLOP of conditioning, 18 TFLOP a denoising step (both branches) and 34 MFLOP +a sampled grid point. The model runs on one card (2.2B parameters, 4.4 GiB in bf16); `--tp` above 1 +is refused. The licence (Tencent Hunyuan 3D 2.0 Community License) does not cover the European +Union, the United Kingdom or South Korea. + +### 5.18 Documents: Unlimited-OCR `unlimited-ocr` (baidu/Unlimited-OCR, bf16; the converted container is [Aijuus/unlimited-ocr-bf16](https://huggingface.co/Aijuus/unlimited-ocr-bf16), with its recipe; @@ -3608,7 +3701,7 @@ completions entry point), so prompt parity with the reference is a chat-endpoint ### 6.1 The dashboard -Open `http://:/` in a browser. It has three tabs. +Open `http://:/` in a browser. It has four tabs. **Dashboard**: the live strip across the top (decode step time, decode and prefill throughput, requests in flight, KV cache in VRAM, draft acceptance), then cards for the batch, memory and @@ -3619,7 +3712,7 @@ The KV cache meter splits what it holds into two segments: ``` KV cache 3.3 / 4.5 GiB · 75.5% ▓▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -20.8k tok read by running requests · 369.3k kept for reuse +20.8k tok read by running requests | 369.3k kept for reuse ``` The full-strength segment is context running requests are reading; the dim segment is prefix cache, @@ -3630,7 +3723,7 @@ from the total fill, since a full pool causes preemption. The decode step tile carries two figures and a percentage under the big number: ``` -best 14.79ms · recent 15.21ms · now 97% of best +best 14.79ms | recent 15.21ms | now 97% of best ``` Both are window means of single-sequence decode steps, measured by the engine: @@ -3674,14 +3767,17 @@ The decode, prefill, requests-in-flight and draft-acceptance tiles carry a line which the page computes from its own polls: ``` -best 58 · recent 54 · now 93% of best@c4 +best 58.0 | recent 54.0 | now 93% of best@c4 ``` `best` (`highest` on requests in flight and acceptance) is the extreme this page has seen at the -current concurrency, `recent` the mean of its last 30 samples there (15 s at one poll every 500 ms; -5 s for prefill), and `now` the current value as a share of the extreme. Past one sequence the line +current concurrency, `recent` the mean of the last 15 s there (5 s for prefill), and `now` the +current value as a share of the extreme. The windows are kept by elapsed time rather than sample +count, so a span means the same span whatever rate is set on Advanced. Past one sequence the line names its concurrency (`@c4`); requests in flight keeps a single set. Reloading the page resets these -figures, a server restart does not. While nothing runs, the big figure reads 0 and the line keeps its +figures, and so does a server restart: the page notices the engine's new start time and +inherits nothing from the run before it. While nothing runs, the big figure reads 0 and the line +keeps its last figures without `now`. Draft acceptance is reported as two ratios with different denominators. A draft position is @@ -3689,8 +3785,8 @@ verified only when every earlier one passed, so: - **accepted / reached** (conditional): of the drafts verified at a position, the share that passed. The acceptance tile, the Speculation panel's large "conditionally accepted" figure and the - per-position bars show it. The headline is the last poll's; the tile's `recent` pools the last 30 - polls that drafted as a ratio of sums. + per-position bars show it. The headline is the last poll's; the tile's `recent` pools the polls + that drafted in the last 15 s as a ratio of sums. - **accepted / drafted**: of every drafted token, the share that became text, since the process started. The Speculation panel's "Accepted of drafted", `draft_accept` on `/stats` and `radiance:draft_acceptance_ratio` on `/metrics` show it. @@ -3700,6 +3796,30 @@ passing 56%, 75% and 77% of the time they are reached, a step reaches 1 + 0.56 + positions on average and accepts 0.56 + 0.42 + 0.32 = 1.30 tokens: 66% accepted / reached against 1.30 / 3 = 43% accepted / drafted. +Under the live request table, **history** keeps every finished request a poll saw. A request is in +`/stats` only while it exists -- a finished row leaves the payload within about 20 ms to half a +second -- so without this the numbers would be gone before they could be read. The last 200 are +kept in this browser's `localStorage`, not on the server, and rows are keyed by the engine's start +and the request id, so a second tab or a reload keys a request alike rather than counting it twice. +A request that began and finished between two polls cannot be sampled at all; those are counted in +a grey row so the total still adds up. **clear** empties it, and the marker it leaves is a +timestamp every tab honours, so a clear in one window is a clear in all of them. + +The line above the table summarises those rows: how many are done, then decode rate, prefill rate +and time to first token. The first two carry their mean over all the rows and, where enough +rows exist, the same mean over the last 20 and the last 5; time to first token is a median +over all the rows, with no windows. A window appears only once enough rows +exist for it to be a different question: with 12 rows stored, the mean over the last 20 would just +be the mean over all 12, so only *last 5* shows. At exactly 20 rows *last 20* repeats the overall +mean; from 21 up the three figures are three different questions. +These are means of per-request rates, not the pooled rate the tiles above show: one long request +does not get to decide the headline. On this line a dot separates one category from the next and a +pipe separates the windows within a category. + +The download icon beside the **Requests** heading saves those stored rows as +`radiance-history.json`, indented, from the browser -- it is the same data **clear** would discard, +so a run worth keeping can be written out before it is cleared. + **Sessions**: one row per stored conversation: how many tokens, which tier it is in, and whether its linear half is still reachable. Sizes overlap and cannot be added: two sessions sharing a system prompt share its blocks. @@ -3709,6 +3829,14 @@ scheduler clamps reuse to the last linear checkpoint. That verdict is the tab's **Model**: the resolved graph: every op, which library serves it, and what did not resolve. +**Advanced**: two editable poll intervals -- *Idle interval* while nothing runs and *Busy interval* +while a request is in flight, each clamped to 100-5000 ms. Set them equal for one fixed rate; the +summary beside the panel title names what is set. The values live in the browser, not on the +server, so they +survive a restart and apply to this browser only. Polling pauses on every view but Dashboard, so +the figures hold while you are reading another page -- for about a minute. Past 60 s the +next poll drops the windows, since there is nothing left to compare them against. + ### 6.2 The JSON behind it ```sh @@ -3778,7 +3906,9 @@ Two pitfalls: - Step time is not wall-clock over steps. Use `engine_step_seconds_decode_total / engine_steps_decode_total`, which charges only decode; wall-clock also charges idle and prefill. -`deploy/grafana/radiance.json` charts both families over time, on Prometheus or VictoriaMetrics. +`deploy/grafana/radiance.json` charts both families over time, on Prometheus or VictoriaMetrics. Its first screen shows +totals over the selected time range (prompt tokens in, prompt tokens read from cache, prompt tokens +computed, tokens out, requests) and the live status; the detail panels are below. ### 6.4 The live terminal view @@ -3895,7 +4025,7 @@ is the part of a log to paste into an issue. Its sections: warning is also printed as a `W` line of its own. ``` -I STARTUP REPORT -- radiance 1.15.1 +I STARTUP REPORT -- radiance 1.17.0 I CONFIGURATION -- every option, the value in force, and where it came from I --model /models/flashnext.rad [command line] I --tp 2 [command line] diff --git a/docs/IQR.md b/docs/IQR.md index e5a7327e..aff6ddc4 100644 --- a/docs/IQR.md +++ b/docs/IQR.md @@ -169,3 +169,54 @@ int8 grid both share. The design, the per-weight and GEMM measurements and the comparison with V1 and V2 are in the IQR-V3 technical report (radiance.stilldeadco.de/whitepapers/iqr-v3.pdf). + +## IQR-V4: measured widths, a vocabulary-weighted head and faster kernels + +IQR-V4 keeps V3's computed trellis and its one f32 scale a row, and changes how the bits are spent and +how the GEMMs read them. GPTQ runs in act order inside the column trellis (`tcq_order=1`: the columns +are fitted in descending Hessian diagonal and the codes stored in column order), and the FFN weights' +trellis runs grow to 512 or 1024 rows (`tcq_rows`). The projections the attention heads feed +(`attn_output`, `ssm_out`) take a bf16 scale a (row, 128) block from five bits up (`group=128 +scale=bf16 dyn=1`), where V3's code reached its resolution first. The widths come from measured +prices: each band of eight layers and projection is priced by the KL a width step costs it, measured +at the 2/3-, 3/4- and 4/5-bit boundaries and shrunk halfway to the model's prices, and layer 63's +`ffn_gate_up`, the one tensor whose price is several times its band's, sits one width up (the V4S +entries, to IQ3R-L); from IQ4R-S up the model's prices are as good and are kept (V4W). + +The vocabulary edges carry about a tenth of every entry's bytes. The lm_head's KL weighs each +vocabulary row by its token's probability, so below IQ6R-L the head is vocabulary-weighted: its rows +are four width classes of the computed trellis (`output.k`, a 256-row run a class, chosen by the +row's probability-weighted output error at a 4.0, 4.5 or 5.0 b mean; `data/vhead/`, `tools/vhead.py`), +decoded in one launch by `logits_gemm_vocab` with the head input held at 16 bits and the logits +gathered back into vocabulary order. At 1 to 16 tokens it is faster than the int8 head it replaces. +IQ6R-L-V4 to IQ8R-V4 keep the int8 head, now GPTQ'd against the head's input Hessian, which costs no +bytes and lowers the median KL about 10%. + +The kernels: the one-token GEMV gives each 16-row tile a block whose waves split K, so a GEMM's tiles +finish together instead of trailing off on a few long waves; a 16-token tile without block barriers serves 2 to 16 tokens; and +the activation quantisers after `gate_up`, the delta net's decode fold and the attention gate are folded +into the kernels that produce their input. On Qwen3.8-27B at TP1 IQ4R-S-V4 decodes one stream 4% faster +than the MXFP4 checkpoint at 5x lower KL, and IQ3R-S-V4 is faster at every concurrency. + +| recipe | bpw | KL mean | top-1 | V3 at that size | its bpw | its KL | KL | +|---|---:|---:|---:|---|---:|---:|---:| +| `q38-27b-iq8r-v4` | 8.040 | 0.00046 | 99.22% | IQ8R-V3 | 8.040 | 0.00047 | -2% | +| `q38-27b-iq7r-v4` | 7.420 | 0.00059 | 99.15% | IQ7R-V3 | 7.420 | 0.00060 | -2% | +| `q38-27b-iq6r-l-v4` | 6.939 | 0.00068 | 99.08% | IQ6R-L-V3 | 6.939 | 0.00072 | -6% | +| `q38-27b-iq6r-v4` | 6.439 | 0.00081 | 98.96% | IQ6R-V3 | 6.372 | 0.00088 | -8% | +| `q38-27b-iq6r-s-v4` | 6.063 | 0.00100 | 98.86% | IQ6R-S-V3 | 6.049 | 0.00106 | -6% | +| `q38-27b-iq5r-v4` | 5.433 | 0.00154 | 98.60% | IQ5R-V3 | 5.422 | 0.00182 | -15% | +| `q38-27b-iq5r-s-v4` | 5.071 | 0.00223 | 98.33% | IQ5R-S-V3 | 5.064 | 0.00249 | -10% | +| `q38-27b-iq4r-l-v4` | 4.793 | 0.00297 | 98.07% | IQ4R-L-V3 | 4.783 | 0.00342 | -13% | +| `q38-27b-iq4r-v4` | 4.473 | 0.00444 | 97.69% | IQ4R-V3 | 4.458 | 0.00512 | -13% | +| `q38-27b-iq4r-s-v4` | 4.142 | 0.00643 | 97.12% | IQ4R-S-V3 | 4.131 | 0.00762 | -16% | +| `q38-27b-iq3r-l-v4` | 3.804 | 0.00917 | 96.61% | IQ3R-L-V3 | 3.798 | 0.01129 | -19% | +| `q38-27b-iq3r-v4` | 3.472 | 0.01495 | 95.74% | IQ3R-V3 | 3.459 | 0.01698 | -12% | +| `q38-27b-iq3r-s-v4` | 3.157 | 0.02241 | 94.75% | IQ3R-S-V3 | 3.145 | 0.02584 | -13% | +| `q38-27b-iq2r-l-v4` | 2.797 | 0.03602 | 93.29% | IQ2R-L-V3 | 2.786 | 0.04241 | -15% | +| `q38-27b-iq2r-v4` | 2.470 | 0.06113 | 91.23% | IQ2R-V3 | 2.465 | 0.06807 | -10% | + +IQ4R-L-V4 is 24% below the official FP8 checkpoint's KL (8.766 bpw, 0.00389) at 55% of its size, and +IQ2R-L-V4, at 2.8 bpw, is below the AWQ-tuned MXFP4 checkpoint (4.994 bpw, 0.03824). The design, the +kernels and the measurements are in the IQR-V4 technical report +(radiance.stilldeadco.de/whitepapers/iqr-v4.pdf). diff --git a/docs/KERNELS.md b/docs/KERNELS.md index 4966d301..35f1bd6b 100644 --- a/docs/KERNELS.md +++ b/docs/KERNELS.md @@ -1,109 +1,238 @@ # radiance kernel libraries -Generated by `rad-kbench`. Every kernel of every loaded library ran on the same inputs and each +Generated by `rad-kbench`. 188 of 1031 declared kernel rows ran on the same inputs and each case that passed was timed in the same run, so correctness, completeness and speed come from one run (the Speed section says how the times were taken). -- fixture: `data/kernels.rkb`, 741 case(s) recorded 2026-10-15 from `qwen3.8-27b-fp8.rad` -- libraries: `libavx@0.1.0 libr4d@0.5.0 libref@0.1.0` +Rows no case in this pass reached are listed under *Rows nothing ran*; a row there is a gap in +coverage, not a failing kernel. + +- fixture: `data/kernels.rkb`, 741 case(s) recorded 2026-10-16 from `qwen3.8-27b-fp8.rad`; `data/kernels_nemotronh.rkb`, 1009 case(s) recorded 2026-10-31 from `c9.skel.rad` +- libraries: `libavx@0.1.0 libr4d@0.5.0 spechub@0.1.0 libref@0.1.0` - reference: `libref`; every correctness number is relative to it, so it has none of its own -- 2202 case(s) checked, 2202 passed, 0 failed, 7 skipped, 0 capped; worst rel_l2 4.270e-03 -- 734 reference result(s) taken from the cache; every comparison ran +- 5226 case(s) checked, 5226 passed, 0 failed, 7 skipped, 0 capped; worst rel_l2 4.270e-03 +- 3 case(s) vacuous: the reference and the output both identically zero, so nothing was + checked (listed under Not covered) +- 59 reference result(s) taken from the cache; every comparison ran ## Libraries -`ops` is how many of the 147-op vocabulary this library has a row for, and `graph` how many of -the 43 ops this container's declared graph asks for. +`ops` is how many of the 277-op vocabulary this library has a row for, and `graph` how many of +the 59 ops this container's declared graph asks for. `rows` is how many kernel rows the library declares and `run` how many of them a case in this pass reached; the Rows nothing ran section lists the rest. | library | version | domain | rows | run | ops | graph | cases | pass | fail | worst rel_l2 | median us | |---|---|---|---|---|---|---|---|---|---|---|---| -| `libavx` | 0.1.0 | host | 100 | 42 of 100 | 100 of 147 | 43 of 43 | 734 | 734 | 0 | 9.01e-04 | 78.91 | -| `libr4d` | 0.5.0 | device | 291 | 48 of 291 | 142 of 147 | 43 of 43 | 734 | 734 | 0 | 4.27e-03 | 12.78 | -| `libref` (oracle) | 0.1.0 | host | 123 | 42 of 123 | 123 of 147 | 43 of 43 | 734 | 734 | 0 | 0.00e+00 | - | +| `libavx` | 0.1.0 | host | 237 | 58 of 237 | 237 of 277 | 59 of 59 | 1743 | 1742 | 0 | 1.82e-03 | 20992.02 | +| `libr4d` | 0.5.0 | device | 551 | 72 of 551 | 270 of 277 | 59 of 59 | 1743 | 1742 | 0 | 4.27e-03 | 11.46 | +| `spechub` | 0.1.0 | device+host | 6 | 0 of 6 | 3 of 277 | 0 of 59 | 0 | 0 | 0 | - | - | +| `libref` (oracle) | 0.1.0 | host | 237 | 58 of 237 | 237 of 277 | 59 of 59 | 1743 | 1742 | 0 | 1.82e-03 | 20996.53 | Rows declaring an optional hook (tuning, fusion, weight layout): | library | tunable rows | fusion claims | weight layouts | |---|---|---|---| -| `libavx` | 0 | 0 | 1 | -| `libr4d` | 84 | 17 | 35 | -| `libref` | 0 | 0 | 0 | +| `libavx` | 0 | 0 | 9 | +| `libr4d` | 123 | 32 | 62 | +| `spechub` | 0 | 0 | 0 | +| `libref` | 0 | 0 | 8 | ## Rows nothing ran -132 of 514 declared row(s) were reached by a case in this pass. +188 of 1031 declared row(s) were reached by a case in this pass. -`libavx`: 58 row(s) not reached: +`libavx`: 179 row(s) not reached: | kernel | op | |---|---| -| `avx_act_mul` | `act_mul` | | `avx_all_gather` | `all_gather` | | `avx_all_reduce` | `all_reduce` | +| `avx_attn_cross` | `attn_cross` | | `avx_attn_local_rel` | `attn_local_rel` | +| `avx_attn_na3d` | `attn_na3d` | +| `avx_attn_paged_tree` | `attn_paged_tree` | +| `avx_attn_prefix_self` | `attn_prefix_self` | +| `avx_attn_vsa` | `attn_vsa` | +| `avx_bwe_up` | `bwe_up` | | `avx_causal_conv1d` | `causal_conv1d` | +| `avx_cfg_topk_sample` | `cfg_topk_sample` | +| `avx_chan_affine` | `chan_affine` | +| `avx_chan_split` | `chan_split` | +| `avx_chan_stats` | `chan_stats` | | `avx_clamp` | `clamp` | +| `avx_cond_aug` | `cond_aug` | +| `avx_conv1d` | `conv1d` | | `avx_conv1d_dw` | `conv1d_dw` | | `avx_conv2d` | `conv2d` | +| `avx_conv2d_nhwc` | `conv2d_nhwc` | +| `avx_conv2d_unfold` | `conv2d_unfold` | +| `avx_conv3d_ndhwc` | `conv3d_ndhwc` | +| `avx_conv_t1d` | `conv_t1d` | +| `avx_cu_repeat` | `cu_repeat` | +| `avx_d2s3d` | `d2s3d` | +| `avx_d2s_add` | `d2s_add` | | `avx_dequant` | `dequant` | +| `avx_dflash_conv` | `dflash_conv` | +| `avx_dflash_tree` | `dflash_tree` | +| `avx_dsa_pool` | `dsa_pool` | +| `avx_dsa_query` | `dsa_query` | +| `avx_dsa_score` | `dsa_score` | +| `avx_embed_attn` | `embed_attn` | | `avx_embed_lookup_q` | `embed_lookup_q` | +| `avx_end_status` | `end_status` | | `avx_fill` | `fill` | +| `avx_flow_euler` | `flow_euler` | +| `avx_flow_renoise` | `flow_renoise` | +| `avx_flow_res_multistep` | `flow_res_multistep` | +| `avx_flow_x0_step` | `flow_x0_step` | +| `avx_fourier_embed` | `fourier_embed` | +| `avx_frame_mix_store` | `frame_mix_store` | +| `avx_frame_store` | `frame_store` | +| `avx_gate_add` | `gate_add` | | `avx_gated_had_quant_i8` | `gated_had_quant_i8` | +| `avx_gather_rows2` | `gather_rows2` | | `avx_gdn_conv_prep` | `gdn_conv_prep` | | `avx_gdn_conv_recurrent_update` | `gdn_conv_recurrent_update` | | `avx_gelu` | `gelu` | | `avx_gelu_mul` | `gelu_mul` | +| `avx_gelu_quick` | `gelu_quick` | +| `avx_gelu_tanh` | `gelu_tanh` | | `avx_gemm_nt_q_bias` | `gemm_nt_q_bias` | +| `avx_gemm_nt_q_gated_wide` | `gemm_nt_q_gated_wide` | +| `avx_gemm_nt_q_short` | `gemm_nt_q_short` | | `avx_givens_dense_quant` | `givens_dense_quant` | | `avx_givens_rotate` | `givens_rotate` | | `avx_gram_accum` | `gram_accum` | | `avx_grid_embed_aa` | `grid_embed_aa` | -| `avx_had_quant_act_fp8` | `had_quant_act_fp8` | +| `avx_grid_pos3` | `grid_pos3` | +| `avx_group_norm` | `group_norm` | | `avx_had_quant_act_i8` | `had_quant_act_i8` | +| `avx_had_quant_act_i8g` | `had_quant_act_i8g` | | `avx_hc_enter` | `hc_enter` | +| `avx_hc_project` | `hc_project` | | `avx_hc_read` | `hc_read` | | `avx_hc_write` | `hc_write` | +| `avx_head_gate` | `head_gate` | +| `avx_im2col_nhwc` | `im2col_nhwc` | +| `avx_int_affine` | `int_affine` | +| `avx_interleave2` | `interleave2` | +| `avx_kd_input` | `kd_input` | +| `avx_kd_step` | `kd_step` | +| `avx_kda_update` | `kda_update` | +| `avx_kv_resolve` | `kv_resolve` | +| `avx_kv_store_streamed` | `kv_store_streamed` | +| `avx_l2norm_chan` | `l2norm_chan` | +| `avx_lane_gather` | `lane_gather` | +| `avx_lane_store` | `lane_store` | +| `avx_lili_cand` | `lili_cand` | +| `avx_ln_mod` | `ln_mod` | +| `avx_ln_mod_quant_fp8` | `ln_mod_quant_fp8` | | `avx_logit_rerank` | `logit_rerank` | | `avx_logit_softcap` | `logit_softcap` | -| `avx_moe_gather` | `moe_gather` | +| `avx_lora_expand` | `lora_expand` | +| `avx_lora_expand_mm` | `lora_expand_mm` | +| `avx_lora_shrink` | `lora_shrink` | +| `avx_ltx_guide` | `ltx_guide` | +| `avx_mhc_contract` | `mhc_contract` | +| `avx_mhc_post` | `mhc_post` | +| `avx_mhc_pre` | `mhc_pre` | +| `avx_mhc_pre_finish` | `mhc_pre_finish` | +| `avx_mhc_pre_partial` | `mhc_pre_partial` | +| `avx_ministral_rope` | `ministral_rope` | +| `avx_mix_rows` | `mix_rows` | +| `avx_mla_attn` | `mla_attn` | +| `avx_mla_project` | `mla_project` | | `avx_moe_gemm` | `moe_gemm` | | `avx_moe_gemm_q` | `moe_gemm_q` | | `avx_moe_gemm_q_mod4` | `moe_gemm_q_mod4` | -| `avx_moe_scatter` | `moe_scatter` | | `avx_mtp_enter` | `mtp_enter` | | `avx_mul` | `mul` | -| `avx_mul_weight` | `mul_weight` | | `avx_ngram_ids` | `ngram_ids` | | `avx_pair_argmax` | `pair_argmax` | +| `avx_patch_fold` | `patch_fold` | +| `avx_patch_unfold` | `patch_unfold` | +| `avx_pix_patch` | `pix_patch` | +| `avx_pixel_norm` | `pixel_norm` | +| `avx_pixtral_merge` | `pixtral_merge` | +| `avx_pixtral_rope` | `pixtral_rope` | | `avx_ple_conv` | `ple_conv` | | `avx_ple_gate` | `ple_gate` | +| `avx_pool_cols` | `pool_cols` | | `avx_pool_rows` | `pool_rows` | +| `avx_position_scale` | `position_scale` | | `avx_qk_norm_rope` | `qk_norm_rope` | | `avx_qsa_block_key` | `qsa_block_key` | +| `avx_qsa_score` | `qsa_score` | +| `avx_qsa_select` | `qsa_select` | +| `avx_qsa_tail_store` | `qsa_tail_store` | +| `avx_qsa_work` | `qsa_work` | | `avx_quant_act_i8g` | `quant_act_i8g` | +| `avx_quant_cols_fp8` | `quant_cols_fp8` | +| `avx_randn_lanes` | `randn_lanes` | +| `avx_ras_pick` | `ras_pick` | | `avx_rel_sinusoid` | `rel_sinusoid` | | `avx_relu` | `relu` | +| `avx_resample_nearest` | `resample_nearest` | +| `avx_resize_bilinear` | `resize_bilinear` | +| `avx_rms_mod` | `rms_mod` | +| `avx_rms_mod_quant_fp8` | `rms_mod_quant_fp8` | | `avx_rmsnorm_add` | `rmsnorm_add` | | `avx_rmsnorm_had_quant_i8` | `rmsnorm_had_quant_i8` | | `avx_rmsnorm_p` | `rmsnorm_p` | +| `avx_rmsnorm_rows` | `rmsnorm_rows` | +| `avx_rope_rows` | `rope_rows` | +| `avx_rope_split` | `rope_split` | +| `avx_router_gemm_topk_scatter` | `router_gemm_topk_scatter` | | `avx_router_topk` | `router_topk` | +| `avx_router_topk_scatter` | `router_topk_scatter` | | `avx_row_topk_merge` | `row_topk_merge` | +| `avx_rvq_embed` | `rvq_embed` | +| `avx_s2d3d` | `s2d3d` | +| `avx_s2d_avg_add` | `s2d_avg_add` | +| `avx_sam_attn` | `sam_attn` | | `avx_sample_merge_topk` | `sample_merge_topk` | | `avx_scale` | `scale` | | `avx_scale_rows` | `scale_rows` | +| `avx_scatter_add_rows` | `scatter_add_rows` | | `avx_seg_mean` | `seg_mean` | +| `avx_seg_mean_bf16_sum` | `seg_mean_bf16_sum` | +| `avx_seg_sinusoid` | `seg_sinusoid` | +| `avx_seg_softmax_pool` | `seg_softmax_pool` | | `avx_sigmoid` | `sigmoid` | -| `avx_silu` | `silu` | +| `avx_snake` | `snake` | +| `avx_snake_aa` | `snake_aa` | | `avx_softmax` | `softmax` | +| `avx_ssd_update` | `ssd_update` | +| `avx_stft_logmel` | `stft_logmel` | +| `avx_sub_i32` | `sub_i32` | +| `avx_swiglu_clamped` | `swiglu_clamped` | +| `avx_table_add` | `table_add` | +| `avx_tconv_dw` | `tconv_dw` | +| `avx_tile_crop` | `tile_crop` | +| `avx_tile_grid` | `tile_grid` | +| `avx_tile_stitch` | `tile_stitch` | +| `avx_timestep_embed` | `timestep_embed` | +| `avx_to_rgba8` | `to_rgba8` | +| `avx_vol_index` | `vol_index` | +| `avx_vq_encode` | `vq_encode` | +| `avx_vsa_select` | `vsa_select` | +| `avx_vtile_crop` | `vtile_crop` | +| `avx_vtile_gather` | `vtile_gather` | +| `avx_vtile_join` | `vtile_join` | +| `avx_vtile_plan` | `vtile_plan` | +| `avx_vtile_stitch` | `vtile_stitch` | +| `avx_win_finish` | `win_finish` | +| `avx_win_input` | `win_input` | +| `avx_win_prep` | `win_prep` | -`libr4d`: 243 row(s) not reached: +`libr4d`: 479 row(s) not reached: | kernel | op | |---|---| -| `act_mul_bf16` | `act_mul` | +| `add_f32` | `add` | +| `add_rmsnorm_bf16` | `add_rmsnorm` | | `ar_gather_2rank` | `all_gather` | | `ar_gather_2rank_host` | `all_gather` | | `ar_gather_3rank` | `all_gather` | @@ -136,9 +265,15 @@ Rows declaring an optional hook (tuning, fusion, weight layout): | `ar_oneshot_4rank_exact_host` | `all_reduce` | | `ar_oneshot_8rank_exact` | `all_reduce` | | `ar_oneshot_8rank_exact_host` | `all_reduce` | +| `ar_rmsnorm_had_quant_i8g` | `ar_rmsnorm_had_quant_i8g` | +| `ar_rmsnorm_had_quant_i8g_host` | `ar_rmsnorm_had_quant_i8g` | +| `ar_rmsnorm_post_quant_fp8` | `ar_rmsnorm_post_quant_fp8` | +| `ar_rmsnorm_post_quant_fp8_host` | `ar_rmsnorm_post_quant_fp8` | | `ar_rmsnorm_quant_fp8` | `ar_rmsnorm_quant_fp8` | | `ar_rmsnorm_quant_fp8_host` | `ar_rmsnorm_quant_fp8` | | `ar_rmsnorm_quant_i8` | `ar_rmsnorm_quant_i8` | +| `ar_rmsnorm_quant_i8_4rank` | `ar_rmsnorm_quant_i8` | +| `ar_rmsnorm_quant_i8_4rank_host` | `ar_rmsnorm_quant_i8` | | `ar_rmsnorm_quant_i8_host` | `ar_rmsnorm_quant_i8` | | `ar_twoshot_3rank_exact` | `all_reduce` | | `ar_twoshot_3rank_exact_host` | `all_reduce` | @@ -146,19 +281,38 @@ Rows declaring an optional hook (tuning, fusion, weight layout): | `ar_twoshot_3rank_ti8_host` | `all_reduce` | | `ar_twoshot_4rank_exact` | `all_reduce` | | `ar_twoshot_4rank_exact_host` | `all_reduce` | +| `ar_twoshot_4rank_exact_lane` | `all_reduce` | +| `ar_twoshot_4rank_exact_lane_host` | `all_reduce` | | `ar_twoshot_4rank_ti8` | `all_reduce` | | `ar_twoshot_4rank_ti8_host` | `all_reduce` | +| `ar_twoshot_4rank_ti8_lane` | `all_reduce` | +| `ar_twoshot_4rank_ti8_lane_host` | `all_reduce` | | `ar_twoshot_8rank_exact` | `all_reduce` | | `ar_twoshot_8rank_exact_host` | `all_reduce` | +| `attn_cross_h128_bf16` | `attn_cross` | +| `attn_cross_h64_bf16` | `attn_cross` | | `attn_decode_gq_h256_gqa12_bf16kv` | `attn_paged_gate_quant` | | `attn_decode_gq_h256_gqa12_fp8kv` | `attn_paged_gate_quant` | +| `attn_decode_gq_h256_gqa12_fp8v4` | `attn_paged_gate_quant` | +| `attn_decode_gq_h256_gqa12_k6v4` | `attn_paged_gate_quant` | | `attn_decode_gq_h256_gqa6_bs4_bf16kv` | `attn_paged_gate_quant` | | `attn_decode_gq_h256_gqa6_bs4_fp8kv` | `attn_paged_gate_quant` | +| `attn_decode_gq_h256_gqa6_bs4_fp8v4` | `attn_paged_gate_quant` | +| `attn_decode_gq_h256_gqa6_bs4_k6v4` | `attn_paged_gate_quant` | +| `attn_decode_h128_gqa16_fp8kv` | `attn_paged` | +| `attn_decode_h128_gqa1_bf16kv` | `attn_paged` | +| `attn_decode_h128_gqa1_fp8kv` | `attn_paged` | +| `attn_decode_h128_gqa2_bf16kv` | `attn_paged` | +| `attn_decode_h128_gqa2_fp8kv` | `attn_paged` | +| `attn_decode_h128_gqa2w_bf16kv` | `attn_paged` | +| `attn_decode_h128_gqa2w_fp8kv` | `attn_paged` | | `attn_decode_h128_gqa4_bf16kv` | `attn_paged` | | `attn_decode_h128_gqa8_bf16kv` | `attn_paged` | | `attn_decode_h128_gqa8_fp8kv` | `attn_paged` | | `attn_decode_h256_gqa12_bf16kv` | `attn_paged` | | `attn_decode_h256_gqa12_fp8kv` | `attn_paged` | +| `attn_decode_h256_gqa12_fp8v4` | `attn_paged` | +| `attn_decode_h256_gqa12_k6v4` | `attn_paged` | | `attn_decode_h256_gqa2_bf16kv` | `attn_paged` | | `attn_decode_h256_gqa2_fp8kv` | `attn_paged` | | `attn_decode_h256_gqa4_bf16kv` | `attn_paged` | @@ -166,19 +320,41 @@ Rows declaring an optional hook (tuning, fusion, weight layout): | `attn_decode_h256_gqa6_bf16kv` | `attn_paged` | | `attn_decode_h256_gqa6_bs4_bf16kv` | `attn_paged` | | `attn_decode_h256_gqa6_bs4_fp8kv` | `attn_paged` | +| `attn_decode_h256_gqa6_bs4_fp8v4` | `attn_paged` | +| `attn_decode_h256_gqa6_bs4_k6v4` | `attn_paged` | +| `attn_decode_h256_gqa6_fp8v4` | `attn_paged` | +| `attn_decode_h256_gqa6_k6v4` | `attn_paged` | | `attn_decode_h256_gqa8_bf16kv` | `attn_paged` | | `attn_decode_h256_gqa8_fp8kv` | `attn_paged` | | `attn_dense_h1152_bf16` | `attn_dense` | | `attn_dense_h128_bf16` | `attn_dense` | +| `attn_dense_h256_bf16` | `attn_dense` | | `attn_dense_h256_gqa2_bf16` | `attn_dense` | +| `attn_dense_h256_gqa4_bf16` | `attn_dense` | +| `attn_dense_h256_gqa8_bf16` | `attn_dense` | +| `attn_dense_h384_bf16` | `attn_dense` | +| `attn_dense_h512_bf16` | `attn_dense` | +| `attn_dense_h512_gqa2_bf16` | `attn_dense` | | `attn_dense_h512_gqa4_bf16` | `attn_dense` | +| `attn_dense_h512_gqa8_bf16` | `attn_dense` | | `attn_dense_h64_bf16` | `attn_dense` | | `attn_dense_h768_bf16` | `attn_dense` | +| `attn_dense_small_h256_bf16` | `attn_dense` | | `attn_local_rel_bf16` | `attn_local_rel` | +| `attn_na3d_h64` | `attn_na3d` | +| `attn_prefill_h128_gqa16_fp8kv` | `attn_paged` | +| `attn_prefill_h128_gqa1_bf16kv` | `attn_paged` | +| `attn_prefill_h128_gqa1_fp8kv` | `attn_paged` | +| `attn_prefill_h128_gqa2_bf16kv` | `attn_paged` | +| `attn_prefill_h128_gqa2_fp8kv` | `attn_paged` | +| `attn_prefill_h128_gqa2w_bf16kv` | `attn_paged` | +| `attn_prefill_h128_gqa2w_fp8kv` | `attn_paged` | | `attn_prefill_h128_gqa8_bf16kv` | `attn_paged` | | `attn_prefill_h128_gqa8_fp8kv` | `attn_paged` | | `attn_prefill_h256_gqa12_bf16kv` | `attn_paged` | | `attn_prefill_h256_gqa12_fp8kv` | `attn_paged` | +| `attn_prefill_h256_gqa12_fp8v4` | `attn_paged` | +| `attn_prefill_h256_gqa12_k6v4` | `attn_paged` | | `attn_prefill_h256_gqa2_bf16kv` | `attn_paged` | | `attn_prefill_h256_gqa2_fp8kv` | `attn_paged` | | `attn_prefill_h256_gqa4_bf16kv` | `attn_paged` | @@ -186,11 +362,30 @@ Rows declaring an optional hook (tuning, fusion, weight layout): | `attn_prefill_h256_gqa6_bf16kv` | `attn_paged` | | `attn_prefill_h256_gqa6_bs4_bf16kv` | `attn_paged` | | `attn_prefill_h256_gqa6_bs4_fp8kv` | `attn_paged` | +| `attn_prefill_h256_gqa6_bs4_fp8v4` | `attn_paged` | +| `attn_prefill_h256_gqa6_bs4_k6v4` | `attn_paged` | +| `attn_prefill_h256_gqa6_fp8kv_pv8` | `attn_paged` | +| `attn_prefill_h256_gqa6_fp8kv_qk8` | `attn_paged` | +| `attn_prefill_h256_gqa6_fp8kv_qk8pv8` | `attn_paged` | +| `attn_prefill_h256_gqa6_fp8v4` | `attn_paged` | +| `attn_prefill_h256_gqa6_fp8v4_pv8` | `attn_paged` | +| `attn_prefill_h256_gqa6_fp8v4_qk8` | `attn_paged` | +| `attn_prefill_h256_gqa6_fp8v4_qk8pv8` | `attn_paged` | +| `attn_prefill_h256_gqa6_k6v4` | `attn_paged` | +| `attn_prefill_h256_gqa6_k6v4_pv8` | `attn_paged` | +| `attn_prefill_h256_gqa6_k6v4_qk8` | `attn_paged` | +| `attn_prefill_h256_gqa6_k6v4_qk8pv8` | `attn_paged` | | `attn_prefill_h256_gqa8_bf16kv` | `attn_paged` | | `attn_prefill_h256_gqa8_fp8kv` | `attn_paged` | | `attn_prefill_h64_gqa4_bf16kv` | `attn_paged` | | `attn_prefill_h64_gqa4_fp8kv` | `attn_paged` | | `attn_prefix_self_h128_bf16` | `attn_prefix_self` | +| `attn_qrow_decode_h256_gqa2_bf16kv` | `attn_paged_qrow` | +| `attn_qrow_decode_h256_gqa2_fp8kv` | `attn_paged_qrow` | +| `attn_qrow_h128_gqa1_bf16kv` | `attn_paged_qrow` | +| `attn_qrow_h128_gqa1_fp8kv` | `attn_paged_qrow` | +| `attn_qrow_h128_gqa8_bf16kv` | `attn_paged_qrow` | +| `attn_qrow_h128_gqa8_fp8kv` | `attn_paged_qrow` | | `attn_qrow_h256_gqa1_bf16kv` | `attn_paged_qrow` | | `attn_qrow_h256_gqa1_fp8kv` | `attn_paged_qrow` | | `attn_qrow_h256_gqa2_bf16kv` | `attn_paged_qrow` | @@ -207,6 +402,27 @@ Rows declaring an optional hook (tuning, fusion, weight layout): | `attn_qrow_h512_gqa4_fp8kv` | `attn_paged_qrow` | | `attn_qrow_h512_gqa8_bf16kv` | `attn_paged_qrow` | | `attn_qrow_h512_gqa8_fp8kv` | `attn_paged_qrow` | +| `attn_qrow_tree_decode_h256_gqa2_bf16kv` | `attn_paged_qrow_tree` | +| `attn_qrow_tree_decode_h256_gqa2_fp8kv` | `attn_paged_qrow_tree` | +| `attn_qrow_tree_h256_gqa1_bf16kv` | `attn_paged_qrow_tree` | +| `attn_qrow_tree_h256_gqa1_fp8kv` | `attn_paged_qrow_tree` | +| `attn_qrow_tree_h256_gqa2_bf16kv` | `attn_paged_qrow_tree` | +| `attn_qrow_tree_h256_gqa2_fp8kv` | `attn_paged_qrow_tree` | +| `attn_qrow_tree_h256_gqa4_bf16kv` | `attn_paged_qrow_tree` | +| `attn_qrow_tree_h256_gqa4_fp8kv` | `attn_paged_qrow_tree` | +| `attn_qrow_tree_h256_gqa8_bf16kv` | `attn_paged_qrow_tree` | +| `attn_qrow_tree_h256_gqa8_fp8kv` | `attn_paged_qrow_tree` | +| `attn_qrow_tree_h512_gqa1_bf16kv` | `attn_paged_qrow_tree` | +| `attn_qrow_tree_h512_gqa1_fp8kv` | `attn_paged_qrow_tree` | +| `attn_qrow_tree_h512_gqa2_bf16kv` | `attn_paged_qrow_tree` | +| `attn_qrow_tree_h512_gqa2_fp8kv` | `attn_paged_qrow_tree` | +| `attn_qrow_tree_h512_gqa4_bf16kv` | `attn_paged_qrow_tree` | +| `attn_qrow_tree_h512_gqa4_fp8kv` | `attn_paged_qrow_tree` | +| `attn_qrow_tree_h512_gqa8_bf16kv` | `attn_paged_qrow_tree` | +| `attn_qrow_tree_h512_gqa8_fp8kv` | `attn_paged_qrow_tree` | +| `attn_vsa_h128_bf16` | `attn_vsa` | +| `attn_window_h128_gqa1_bf16kv` | `attn_paged` | +| `attn_window_h128_gqa1_fp8kv` | `attn_paged` | | `attn_window_h256_gqa1_bf16kv` | `attn_paged` | | `attn_window_h256_gqa1_fp8kv` | `attn_paged` | | `attn_window_h256_gqa2_bf16kv` | `attn_paged` | @@ -223,36 +439,89 @@ Rows declaring an optional hook (tuning, fusion, weight layout): | `attn_window_h512_gqa4_fp8kv` | `attn_paged` | | `attn_window_h512_gqa8_bf16kv` | `attn_paged` | | `attn_window_h512_gqa8_fp8kv` | `attn_paged` | +| `attn_window_sink_h128_gqa16_fp8kv` | `attn_paged_sink` | +| `attn_window_sink_h128_gqa8_bf16kv` | `attn_paged_sink` | +| `attn_window_sink_h128_gqa8_fp8kv` | `attn_paged_sink` | +| `bwe_up` | `bwe_up` | +| `cast_bf16_f16` | `cast` | | `cast_bf16_f32` | `cast` | +| `cast_f32_bf16` | `cast` | +| `cast_f32_f32` | `cast` | | `causal_conv1d_bf16` | `causal_conv1d` | +| `cfg_topk_sample` | `cfg_topk_sample` | | `chan_affine_bf16` | `chan_affine` | +| `chan_affine_f32` | `chan_affine` | +| `chan_split_bf16` | `chan_split` | +| `chan_stats_bf16` | `chan_stats` | +| `chan_stats_f32` | `chan_stats` | | `clamp_bf16` | `clamp` | +| `cond_aug_f32` | `cond_aug` | +| `conv1d_bf16` | `conv1d` | | `conv1d_dw_bf16` | `conv1d_dw` | +| `conv1d_f32` | `conv1d` | | `conv2d_bf16` | `conv2d` | | `conv2d_nhwc_bf16` | `conv2d_nhwc` | +| `conv2d_unfold_bf16` | `conv2d_unfold` | +| `conv3d_ndhwc_bf16` | `conv3d_ndhwc` | +| `conv_t1d_bf16` | `conv_t1d` | +| `conv_t1d_f32` | `conv_t1d` | +| `cu_repeat` | `cu_repeat` | +| `d2s3d` | `d2s3d` | | `d2s_add_bf16` | `d2s_add` | | `dequant_w4_bf16` | `dequant_w4` | | `dflash_conv_t2_g16_bf16` | `dflash_conv` | +| `dflash_tree_bf16` | `dflash_tree` | +| `dsa_pool_fp8` | `dsa_pool` | +| `dsa_query_fp8` | `dsa_query` | +| `dsa_score_fp8` | `dsa_score` | +| `embed_attn_h128_bf16` | `embed_attn` | +| `embed_attn_h64_bf16` | `embed_attn` | +| `embed_lookup_iqr` | `embed_lookup` | | `embed_lookup_q_bf16` | `embed_lookup_q` | +| `end_status` | `end_status` | | `expert_scale_bf16` | `expert_scale` | | `fill_bf16` | `fill` | +| `fill_f32` | `fill` | | `flow_euler_bf16` | `flow_euler` | +| `flow_renoise_f32` | `flow_renoise` | +| `flow_res_multistep_f32` | `flow_res_multistep` | +| `flow_x0_step_f32` | `flow_x0_step` | +| `fourier_embed_bf16` | `fourier_embed` | +| `frame_mix_store_bf16` | `frame_mix_store` | +| `frame_store` | `frame_store` | | `gate_add_bf16` | `gate_add` | | `gate_quant_fp8` | `gate_quant_fp8` | | `gated_had_quant_fp8` | `gated_had_quant_fp8` | | `gated_had_quant_i8` | `gated_had_quant_i8` | +| `gated_had_quant_i8g` | `gated_had_quant_i8g` | | `gather_rows2_bf16` | `gather_rows2` | | `gather_rows_u8` | `gather_rows` | | `gdn_conv_prep_w4_h128_bf16` | `gdn_conv_prep` | | `gdn_conv_recurrent_update_k128_v128_bf16` | `gdn_conv_recurrent_update` | | `gdn_gated_norm_had_quant_i8` | `gdn_gated_norm_had_quant_i8` | +| `gelu_bf16` | `gelu` | | `gelu_mul_bf16` | `gelu_mul` | | `gelu_mul_quant_i8` | `gelu_mul_quant_i8` | +| `gelu_quick_bf16` | `gelu_quick` | | `gelu_tanh_bf16` | `gelu_tanh` | -| `gemm_bf16_nt_tiled` | `gemm_nt` | +| `gemm_bf16_pixtral_patch` | `gemm_nt` | +| `gemm_f32_nt_bias` | `gemm_nt_bias` | | `gemm_fp8a16_nt_m1` | `gemm_nt_q` | +| `gemm_fp8a8_bias_nt_m16` | `gemm_nt_q_bias` | +| `gemm_fp8a8_f32scale` | `gemm_nt_q` | +| `gemm_fp8a8_gated_nt_wide` | `gemm_nt_q_gated_wide` | +| `gemm_fp8a8_nt_m16_short` | `gemm_nt_q_short` | | `gemm_i8a8_nt_m16` | `gemm_nt_q` | +| `gemm_i8a8_rb32_tiled` | `gemm_nt_q` | +| `gemm_i8a8_rb8_tiled` | `gemm_nt_q` | | `gemm_i8a8_tiled` | `gemm_nt_q` | +| `gemm_iqr_nt_m64` | `gemm_nt_q` | +| `gemm_iqr_tiled` | `gemm_nt_q` | +| `gemm_m2xfp4a8_decode` | `gemm_nt_q` | +| `gemm_m2xfp4a8_tiled` | `gemm_nt_q` | +| `gemm_mxfp4a8_decode_shortk` | `gemm_nt_q` | +| `gemm_mxfp4a8_gated_gemv` | `gemm_nt_q_gated_mx` | +| `gemm_mxfp4a8_gated_gemv_wide` | `gemm_nt_q_gated_mx` | | `gemm_mxfp4a8_nt_m64` | `gemm_nt_q` | | `gemm_w2a8_nt` | `gemm_nt_q` | | `gemm_w4a16_asym_nt_m64` | `gemm_nt_q` | @@ -271,70 +540,138 @@ Rows declaring an optional hook (tuning, fusion, weight layout): | `gram_accum` | `gram_accum` | | `gram_accum_bf16` | `gram_accum` | | `grid_embed_aa_bf16` | `grid_embed_aa` | -| `had_quant_act_fp8` | `had_quant_act_fp8` | +| `grid_pos3` | `grid_pos3` | +| `group_norm` | `group_norm` | | `had_quant_act_i8` | `had_quant_act_i8` | | `had_quant_act_i8g` | `had_quant_act_i8g` | | `hc_enter_bf16` | `hc_enter` | +| `hc_project_bf16` | `hc_project` | | `hc_read_bf16` | `hc_read` | | `hc_read_e4m3` | `hc_read` | | `hc_write_bf16` | `hc_write` | +| `head_gate` | `head_gate` | +| `im2col_nhwc_bf16` | `im2col_nhwc` | +| `int_affine` | `int_affine` | +| `interleave2_bf16` | `interleave2` | | `join_add_scale_bf16` | `join_add_scale` | -| `kv_store_bf16` | `kv_store` | +| `kd_input_bf16` | `kd_input` | +| `kd_step_bf16` | `kd_step` | +| `kda_update_k128_v128_bf16` | `kda_update` | +| `kv_len_trim` | `kv_len_trim` | +| `kv_resolve_i32` | `kv_resolve` | +| `kv_store_fp8v4` | `kv_store` | +| `kv_store_k6v4` | `kv_store` | | `kv_store_streamed_bf16` | `kv_store_streamed` | | `kv_store_streamed_fp8` | `kv_store_streamed` | | `l2norm_chan_bf16` | `l2norm_chan` | | `lane_gather_w32` | `lane_gather` | | `lane_store_w32` | `lane_store` | +| `lili_cand_bf16` | `lili_cand` | | `ln_mod_bf16` | `ln_mod` | | `ln_mod_quant_fp8_bf16` | `ln_mod_quant_fp8` | | `logit_rerank` | `logit_rerank` | | `logit_rerank_i8` | `logit_rerank` | +| `logit_rerank_iqr` | `logit_rerank` | | `logit_softcap_bf16` | `logit_softcap` | | `logit_softcap_f32` | `logit_softcap` | | `logits_gemm_bf16` | `logits_gemm` | | `logits_gemm_i8` | `logits_gemm` | -| `moe_gather_bf16` | `moe_gather` | +| `logits_gemm_iqr` | `logits_gemm` | +| `lora_expand_mm_wmma` | `lora_expand_mm` | +| `lora_expand_scalar` | `lora_expand` | +| `lora_expand_tiled` | `lora_expand` | +| `lora_shrink_scalar` | `lora_shrink` | +| `lora_shrink_wmma` | `lora_shrink` | +| `lora_shrink_wmma_q` | `lora_shrink` | +| `ltx_guide` | `ltx_guide` | +| `mhc_contract_bf16` | `mhc_contract` | +| `mhc_post_bf16` | `mhc_post` | +| `mhc_pre_bf16` | `mhc_pre` | +| `mhc_pre_finish_bf16` | `mhc_pre_finish` | +| `mhc_pre_partial_bf16` | `mhc_pre_partial` | +| `ministral_rope_h128_bf16` | `ministral_rope` | +| `ministral_rope_h64_bf16` | `ministral_rope` | +| `mix_rows_bf16` | `mix_rows` | +| `mla_attn_bf16` | `mla_attn` | +| `mla_attn_matrix_bf16` | `mla_attn` | +| `mla_attn_rows_bf16` | `mla_attn` | +| `mla_project_bf16` | `mla_project` | +| `moe_gather_inv_bf16` | `moe_gather_inv` | | `moe_gemm_bf16` | `moe_gemm` | | `moe_gemm_fp8a8` | `moe_gemm_q` | +| `moe_gemm_fp8a8_f32scale` | `moe_gemm_q` | | `moe_gemm_fp8a8_mod4` | `moe_gemm_q_mod4` | +| `moe_gemm_mxfp4a8` | `moe_gemm_q` | | `moe_gemm_w4a8` | `moe_gemm_q` | | `moe_gemm_w4a8_mod4` | `moe_gemm_q_mod4` | -| `moe_scatter_i32` | `moe_scatter` | +| `moe_scatter_inv_i32` | `moe_scatter_inv` | | `mtp_enter_bf16` | `mtp_enter` | | `mtp_enter_e4m3` | `mtp_enter` | | `mul_bf16` | `mul` | -| `mul_weight_bf16` | `mul_weight` | +| `mul_weight_f32` | `mul_weight` | | `ngram_ids_i32` | `ngram_ids` | | `norm_add_norm_bf16` | `norm_add_norm` | | `norm_add_norm_route_bf16` | `norm_add_norm_route` | | `pair_argmax_f32` | `pair_argmax` | +| `patch_fold_f32` | `patch_fold` | +| `patch_unfold_f32` | `patch_unfold` | +| `pix_patch` | `pix_patch` | +| `pixel_norm` | `pixel_norm` | +| `pixtral_merge_bf16` | `pixtral_merge` | +| `pixtral_rope_h128_bf16` | `pixtral_rope` | +| `pixtral_rope_h64_bf16` | `pixtral_rope` | | `ple_conv_bf16` | `ple_conv` | | `ple_gate_bf16` | `ple_gate` | +| `pool_cols_bf16` | `pool_cols` | | `pool_rows_bf16` | `pool_rows` | +| `position_scale_bf16` | `position_scale` | +| `prefetch` | `prefetch` | | `qk_norm_rope_bf16` | `qk_norm_rope` | | `qk_norm_rope_gate` | `qk_norm_rope_gate` | | `qk_norm_rope_gate_kv_store_bf16` | `qk_norm_rope_gate_kv_store` | | `qk_norm_rope_gate_kv_store_fp8` | `qk_norm_rope_gate_kv_store` | -| `qk_norm_rope_gate_kv_store_streamed_fp8` | `qk_norm_rope_gate_kv_store_streamed` | +| `qk_norm_rope_gate_kv_store_fp8v4` | `qk_norm_rope_gate_kv_store` | +| `qk_norm_rope_gate_kv_store_k6v4` | `qk_norm_rope_gate_kv_store` | | `qk_norm_rope_gate_kv_store_streamed_bf16` | `qk_norm_rope_gate_kv_store_streamed` | +| `qk_norm_rope_gate_kv_store_streamed_fp8` | `qk_norm_rope_gate_kv_store_streamed` | | `qkv_norm_rope_bf16` | `qkv_norm_rope` | +| `qkv_norm_rope_h128_bf16` | `qkv_norm_rope` | +| `qkv_norm_rope_kv_store_bf16` | `qkv_norm_rope_kv_store` | +| `qkv_norm_rope_kv_store_fp8` | `qkv_norm_rope_kv_store` | +| `qkv_norm_rope_kv_store_h128_bf16` | `qkv_norm_rope_kv_store` | | `qsa_block_key_bf16` | `qsa_block_key` | | `qsa_score_bf16` | `qsa_score` | | `qsa_select_i32` | `qsa_select` | | `qsa_tail_store_bf16` | `qsa_tail_store` | | `qsa_work_bf16` | `qsa_work` | | `quant_act_i8g` | `quant_act_i8g` | +| `quant_cols_fp8_bf16` | `quant_cols_fp8` | | `randn_lanes_bf16` | `randn_lanes` | +| `randn_lanes_f32` | `randn_lanes` | +| `ras_pick` | `ras_pick` | | `rel_sinusoid_bf16` | `rel_sinusoid` | | `relu_bf16` | `relu` | +| `resample_nearest_bf16` | `resample_nearest` | +| `resize_bilinear` | `resize_bilinear` | +| `rms_mod_bf16` | `rms_mod` | +| `rms_mod_quant_fp8_bf16` | `rms_mod_quant_fp8` | +| `rms_mod_quant_i8_bf16` | `rms_mod_quant_i8` | | `rmsnorm_had_quant_i8` | `rmsnorm_had_quant_i8` | +| `rmsnorm_had_quant_i8g` | `rmsnorm_had_quant_i8g` | | `rmsnorm_p_bf16` | `rmsnorm_p` | | `rmsnorm_quant_i8` | `rmsnorm_quant_i8` | +| `rmsnorm_rows_bf16` | `rmsnorm_rows` | +| `rope_rows_bf16` | `rope_rows` | +| `rope_split` | `rope_split` | | `router_gemm_topk_scatter_bf16` | `router_gemm_topk_scatter` | +| `router_sigmoid_topk_scatter_f32` | `router_sigmoid_topk_scatter` | | `router_topk_bf16` | `router_topk` | | `router_topk_scatter_bf16` | `router_topk_scatter` | | `rowtopk_merge` | `row_topk_merge` | +| `rvq_embed_bf16` | `rvq_embed` | +| `s2d3d` | `s2d3d` | | `s2d_avg_add_bf16` | `s2d_avg_add` | +| `sam_attn_bf16` | `sam_attn` | | `sample_chain_f32` | `sample_chain` | | `sample_merge_topk_f32` | `sample_merge_topk` | | `scale_bf16` | `scale` | @@ -342,32 +679,96 @@ Rows declaring an optional hook (tuning, fusion, weight layout): | `scatter_add_rows_bf16` | `scatter_add_rows` | | `scatter_rows_u8` | `scatter_rows` | | `seg_mean_bf16` | `seg_mean` | +| `seg_mean_bf16_sum` | `seg_mean_bf16_sum` | +| `seg_sinusoid_bf16` | `seg_sinusoid` | +| `seg_softmax_pool_bf16` | `seg_softmax_pool` | | `sigmoid_bf16` | `sigmoid` | -| `silu_bf16` | `silu` | +| `silu_f32` | `silu` | +| `snake_aa_f32` | `snake_aa` | +| `snake_bf16` | `snake` | +| `ssd_update_n128_bf16` | `ssd_update` | +| `stft_logmel` | `stft_logmel` | +| `sub_i32` | `sub_i32` | +| `swiglu_clamped_bf16` | `swiglu_clamped` | +| `swiglu_clamped_quant_fp8` | `swiglu_clamped_quant_fp8` | +| `table_add_bf16` | `table_add` | +| `tconv_dw_bf16` | `tconv_dw` | +| `tile_crop` | `tile_crop` | +| `tile_grid` | `tile_grid` | +| `tile_stitch` | `tile_stitch` | | `timestep_embed_bf16` | `timestep_embed` | +| `timestep_embed_f32` | `timestep_embed` | | `to_rgba8_bf16` | `to_rgba8` | +| `vol_index` | `vol_index` | +| `vq_encode` | `vq_encode` | +| `vsa_select_h128_bf16` | `vsa_select` | +| `vtile_crop` | `vtile_crop` | +| `vtile_gather` | `vtile_gather` | +| `vtile_join` | `vtile_join` | +| `vtile_plan` | `vtile_plan` | +| `vtile_stitch` | `vtile_stitch` | +| `win_finish_bf16` | `win_finish` | +| `win_input_bf16` | `win_input` | +| `win_prep_bf16` | `win_prep` | -`libref`: 81 row(s) not reached: +`spechub`: 6 row(s) not reached: + +| kernel | op | +|---|---| +| `ref_dflash_couple_propose` | `dflash_couple_propose` | +| `ref_mtp_couple_propose` | `mtp_couple_propose` | +| `ref_mtp_couple_verify` | `mtp_couple_verify` | +| `spechub_dflash_couple_propose` | `dflash_couple_propose` | +| `spechub_mtp_couple_propose` | `mtp_couple_propose` | +| `spechub_mtp_couple_verify` | `mtp_couple_verify` | + +`libref`: 179 row(s) not reached: | kernel | op | |---|---| -| `ref_act_mul` | `act_mul` | | `ref_all_gather` | `all_gather` | | `ref_all_reduce` | `all_reduce` | +| `ref_attn_cross` | `attn_cross` | | `ref_attn_local_rel` | `attn_local_rel` | +| `ref_attn_na3d` | `attn_na3d` | +| `ref_attn_paged_tree` | `attn_paged_tree` | | `ref_attn_prefix_self` | `attn_prefix_self` | +| `ref_attn_vsa` | `attn_vsa` | +| `ref_bwe_up` | `bwe_up` | | `ref_causal_conv1d` | `causal_conv1d` | +| `ref_cfg_topk_sample` | `cfg_topk_sample` | | `ref_chan_affine` | `chan_affine` | +| `ref_chan_split` | `chan_split` | +| `ref_chan_stats` | `chan_stats` | | `ref_clamp` | `clamp` | +| `ref_cond_aug` | `cond_aug` | +| `ref_conv1d` | `conv1d` | | `ref_conv1d_dw` | `conv1d_dw` | | `ref_conv2d` | `conv2d` | | `ref_conv2d_nhwc` | `conv2d_nhwc` | +| `ref_conv2d_unfold` | `conv2d_unfold` | +| `ref_conv3d_ndhwc` | `conv3d_ndhwc` | +| `ref_conv_t1d` | `conv_t1d` | +| `ref_cu_repeat` | `cu_repeat` | +| `ref_d2s3d` | `d2s3d` | | `ref_d2s_add` | `d2s_add` | | `ref_dequant` | `dequant` | | `ref_dflash_conv` | `dflash_conv` | +| `ref_dflash_tree` | `dflash_tree` | +| `ref_dsa_pool` | `dsa_pool` | +| `ref_dsa_query` | `dsa_query` | +| `ref_dsa_score` | `dsa_score` | +| `ref_embed_attn` | `embed_attn` | | `ref_embed_lookup_q` | `embed_lookup_q` | +| `ref_end_status` | `end_status` | | `ref_fill` | `fill` | | `ref_flow_euler` | `flow_euler` | +| `ref_flow_renoise` | `flow_renoise` | +| `ref_flow_res_multistep` | `flow_res_multistep` | +| `ref_flow_x0_step` | `flow_x0_step` | +| `ref_fourier_embed` | `fourier_embed` | +| `ref_frame_mix_store` | `frame_mix_store` | +| `ref_frame_store` | `frame_store` | | `ref_gate_add` | `gate_add` | | `ref_gated_had_quant_i8` | `gated_had_quant_i8` | | `ref_gather_rows2` | `gather_rows2` | @@ -375,37 +776,71 @@ Rows declaring an optional hook (tuning, fusion, weight layout): | `ref_gdn_conv_recurrent_update` | `gdn_conv_recurrent_update` | | `ref_gelu` | `gelu` | | `ref_gelu_mul` | `gelu_mul` | +| `ref_gelu_quick` | `gelu_quick` | | `ref_gelu_tanh` | `gelu_tanh` | | `ref_gemm_nt_q_bias` | `gemm_nt_q_bias` | +| `ref_gemm_nt_q_gated_wide` | `gemm_nt_q_gated_wide` | +| `ref_gemm_nt_q_short` | `gemm_nt_q_short` | | `ref_givens_dense_quant` | `givens_dense_quant` | | `ref_givens_rotate` | `givens_rotate` | | `ref_gram_accum` | `gram_accum` | | `ref_grid_embed_aa` | `grid_embed_aa` | -| `ref_had_quant_act_fp8` | `had_quant_act_fp8` | +| `ref_grid_pos3` | `grid_pos3` | +| `ref_group_norm` | `group_norm` | | `ref_had_quant_act_i8` | `had_quant_act_i8` | +| `ref_had_quant_act_i8g` | `had_quant_act_i8g` | | `ref_hc_enter` | `hc_enter` | +| `ref_hc_project` | `hc_project` | | `ref_hc_read` | `hc_read` | | `ref_hc_write` | `hc_write` | +| `ref_head_gate` | `head_gate` | +| `ref_im2col_nhwc` | `im2col_nhwc` | +| `ref_int_affine` | `int_affine` | +| `ref_interleave2` | `interleave2` | +| `ref_kd_input` | `kd_input` | +| `ref_kd_step` | `kd_step` | +| `ref_kda_update` | `kda_update` | +| `ref_kv_resolve` | `kv_resolve` | +| `ref_kv_store_streamed` | `kv_store_streamed` | | `ref_l2norm_chan` | `l2norm_chan` | | `ref_lane_gather` | `lane_gather` | | `ref_lane_store` | `lane_store` | +| `ref_lili_cand` | `lili_cand` | | `ref_ln_mod` | `ln_mod` | | `ref_ln_mod_quant_fp8` | `ln_mod_quant_fp8` | | `ref_logit_rerank` | `logit_rerank` | | `ref_logit_softcap` | `logit_softcap` | -| `ref_moe_gather` | `moe_gather` | +| `ref_lora_expand` | `lora_expand` | +| `ref_lora_expand_mm` | `lora_expand_mm` | +| `ref_lora_shrink` | `lora_shrink` | +| `ref_ltx_guide` | `ltx_guide` | +| `ref_mhc_contract` | `mhc_contract` | +| `ref_mhc_post` | `mhc_post` | +| `ref_mhc_pre` | `mhc_pre` | +| `ref_mhc_pre_finish` | `mhc_pre_finish` | +| `ref_mhc_pre_partial` | `mhc_pre_partial` | +| `ref_ministral_rope` | `ministral_rope` | +| `ref_mix_rows` | `mix_rows` | +| `ref_mla_attn` | `mla_attn` | +| `ref_mla_project` | `mla_project` | | `ref_moe_gemm` | `moe_gemm` | | `ref_moe_gemm_q` | `moe_gemm_q` | | `ref_moe_gemm_q_mod4` | `moe_gemm_q_mod4` | -| `ref_moe_scatter` | `moe_scatter` | | `ref_mtp_enter` | `mtp_enter` | | `ref_mul` | `mul` | -| `ref_mul_weight` | `mul_weight` | | `ref_ngram_ids` | `ngram_ids` | | `ref_pair_argmax` | `pair_argmax` | +| `ref_patch_fold` | `patch_fold` | +| `ref_patch_unfold` | `patch_unfold` | +| `ref_pix_patch` | `pix_patch` | +| `ref_pixel_norm` | `pixel_norm` | +| `ref_pixtral_merge` | `pixtral_merge` | +| `ref_pixtral_rope` | `pixtral_rope` | | `ref_ple_conv` | `ple_conv` | | `ref_ple_gate` | `ple_gate` | +| `ref_pool_cols` | `pool_cols` | | `ref_pool_rows` | `pool_rows` | +| `ref_position_scale` | `position_scale` | | `ref_qk_norm_rope` | `qk_norm_rope` | | `ref_qsa_block_key` | `qsa_block_key` | | `ref_qsa_score` | `qsa_score` | @@ -413,25 +848,63 @@ Rows declaring an optional hook (tuning, fusion, weight layout): | `ref_qsa_tail_store` | `qsa_tail_store` | | `ref_qsa_work` | `qsa_work` | | `ref_quant_act_i8g` | `quant_act_i8g` | +| `ref_quant_cols_fp8` | `quant_cols_fp8` | | `ref_randn_lanes` | `randn_lanes` | +| `ref_ras_pick` | `ras_pick` | | `ref_rel_sinusoid` | `rel_sinusoid` | | `ref_relu` | `relu` | +| `ref_resample_nearest` | `resample_nearest` | +| `ref_resize_bilinear` | `resize_bilinear` | +| `ref_rms_mod` | `rms_mod` | +| `ref_rms_mod_quant_fp8` | `rms_mod_quant_fp8` | | `ref_rmsnorm_add` | `rmsnorm_add` | | `ref_rmsnorm_had_quant_i8` | `rmsnorm_had_quant_i8` | | `ref_rmsnorm_p` | `rmsnorm_p` | +| `ref_rmsnorm_rows` | `rmsnorm_rows` | +| `ref_rope_rows` | `rope_rows` | +| `ref_rope_split` | `rope_split` | +| `ref_router_gemm_topk_scatter` | `router_gemm_topk_scatter` | | `ref_router_topk` | `router_topk` | +| `ref_router_topk_scatter` | `router_topk_scatter` | | `ref_row_topk_merge` | `row_topk_merge` | +| `ref_rvq_embed` | `rvq_embed` | +| `ref_s2d3d` | `s2d3d` | | `ref_s2d_avg_add` | `s2d_avg_add` | +| `ref_sam_attn` | `sam_attn` | | `ref_sample_merge_topk` | `sample_merge_topk` | | `ref_scale` | `scale` | | `ref_scale_rows` | `scale_rows` | | `ref_scatter_add_rows` | `scatter_add_rows` | | `ref_seg_mean` | `seg_mean` | +| `ref_seg_mean_bf16_sum` | `seg_mean_bf16_sum` | +| `ref_seg_sinusoid` | `seg_sinusoid` | +| `ref_seg_softmax_pool` | `seg_softmax_pool` | | `ref_sigmoid` | `sigmoid` | -| `ref_silu` | `silu` | +| `ref_snake` | `snake` | +| `ref_snake_aa` | `snake_aa` | | `ref_softmax` | `softmax` | +| `ref_ssd_update` | `ssd_update` | +| `ref_stft_logmel` | `stft_logmel` | +| `ref_sub_i32` | `sub_i32` | +| `ref_swiglu_clamped` | `swiglu_clamped` | +| `ref_table_add` | `table_add` | +| `ref_tconv_dw` | `tconv_dw` | +| `ref_tile_crop` | `tile_crop` | +| `ref_tile_grid` | `tile_grid` | +| `ref_tile_stitch` | `tile_stitch` | | `ref_timestep_embed` | `timestep_embed` | | `ref_to_rgba8` | `to_rgba8` | +| `ref_vol_index` | `vol_index` | +| `ref_vq_encode` | `vq_encode` | +| `ref_vsa_select` | `vsa_select` | +| `ref_vtile_crop` | `vtile_crop` | +| `ref_vtile_gather` | `vtile_gather` | +| `ref_vtile_join` | `vtile_join` | +| `ref_vtile_plan` | `vtile_plan` | +| `ref_vtile_stitch` | `vtile_stitch` | +| `ref_win_finish` | `win_finish` | +| `ref_win_input` | `win_input` | +| `ref_win_prep` | `win_prep` | ## Completeness @@ -440,161 +913,289 @@ One row per op in the vocabulary. A cell names the domain the library serves tha where it has no row. `graph` marks the ops this container's declared program asks for; a `-` on a marked row is a hole this model falls into. -| op | graph | libavx | libr4d | libref | -|---|---|---|---|---| -| `act_mul` | | host | device | host | -| `add` | yes | host | device | host | -| `all_gather` | | host | device | host | -| `all_reduce` | | host | device | host | -| `ar_gather_hc_write` | | - | device | - | -| `ar_hc_write` | | - | device | - | -| `ar_ln_had_quant_i8` | | - | device | - | -| `ar_rmsnorm_quant_fp8` | | - | device | - | -| `ar_rmsnorm_quant_i8` | | - | device | - | -| `attn_dense` | yes | host | device | host | -| `attn_local_rel` | | host | device | host | -| `attn_paged` | yes | host | device | host | -| `attn_paged_gate_quant` | | - | device | - | -| `attn_paged_qrow` | | - | device | - | -| `attn_prefix_self` | | - | device | host | -| `cast` | yes | host | device | host | -| `causal_conv1d` | | host | device | host | -| `chan_affine` | | - | device | host | -| `clamp` | | host | device | host | -| `conv1d_dw` | | host | device | host | -| `conv2d` | | host | device | host | -| `conv2d_nhwc` | | - | device | host | -| `d2s_add` | | - | device | host | -| `dequant` | | host | - | host | -| `dequant_w4` | | - | device | - | -| `dflash_conv` | | - | device | host | -| `dflash_select` | yes | host | device | host | -| `embed_lookup` | yes | host | device | host | -| `embed_lookup_q` | | host | device | host | -| `expert_scale` | | - | device | - | -| `fill` | | host | device | host | -| `flow_euler` | | - | device | host | -| `gate_add` | | - | device | host | -| `gate_quant_fp8` | | - | device | - | -| `gated_had_quant_fp8` | | - | device | - | -| `gated_had_quant_i8` | | host | device | host | -| `gated_quant_fp8` | yes | host | device | host | -| `gather_rows` | yes | host | device | host | -| `gather_rows2` | | - | device | host | -| `gdn_chunk_scan` | yes | host | device | host | -| `gdn_conv_prep` | | host | device | host | -| `gdn_conv_recurrent_update` | | host | device | host | -| `gdn_conv_update` | yes | host | device | host | -| `gdn_gated_norm_had_quant_i8` | | - | device | - | -| `gdn_gated_rmsnorm` | yes | host | device | host | -| `gdn_kkt_solve` | yes | host | device | host | -| `gdn_recurrent_update` | yes | host | device | host | -| `gelu` | | host | - | host | -| `gelu_mul` | | host | device | host | -| `gelu_mul_quant_i8` | | - | device | - | -| `gelu_tanh` | | - | device | host | -| `gemm_nt` | yes | host | device | host | -| `gemm_nt_bias` | yes | host | device | host | -| `gemm_nt_q` | yes | host | device | host | -| `gemm_nt_q_bias` | | host | - | host | -| `gemm_nt_q_gated` | yes | host | device | host | -| `givens_dense_quant` | | host | device | host | -| `givens_rotate` | | host | device | host | -| `gram_accum` | | host | device | host | -| `grid_embed` | yes | host | device | host | -| `grid_embed_aa` | | host | device | host | -| `had_quant_act_fp8` | | host | device | host | -| `had_quant_act_i8` | | host | device | host | -| `had_quant_act_i8g` | | - | device | - | -| `hc_enter` | | host | device | host | -| `hc_read` | | host | device | host | -| `hc_write` | | host | device | host | -| `join_add_scale` | | - | device | - | -| `kv_store` | yes | host | device | host | -| `kv_store_streamed` | | host | device | host | -| `l2norm_chan` | | - | device | host | -| `lane_gather` | | - | device | host | -| `lane_store` | | - | device | host | -| `layernorm` | yes | host | device | host | -| `ln_mod` | | - | device | host | -| `ln_mod_quant_fp8` | | - | device | host | -| `logit_rerank` | yes | host | device | host | -| `logit_softcap` | | host | device | host | -| `logits_gemm` | yes | host | device | host | -| `moe_gather` | | host | device | host | -| `moe_gemm` | | host | device | host | -| `moe_gemm_q` | | host | device | host | -| `moe_gemm_q_mod4` | | host | device | host | -| `moe_scatter` | | host | device | host | -| `mtp_enter` | | host | device | host | -| `mul` | | host | device | host | -| `mul_weight` | | host | device | host | -| `ngram_ids` | | host | device | host | -| `norm_add_norm` | | - | device | - | -| `norm_add_norm_route` | | - | device | - | -| `pair_argmax` | | host | device | host | -| `ple_conv` | | host | device | host | -| `ple_gate` | | host | device | host | -| `pool_rows` | | host | device | host | -| `qk_norm_rope` | | host | device | host | -| `qk_norm_rope_gate` | | - | device | - | -| `qk_norm_rope_gate_kv_store` | | - | device | - | -| `qk_norm_rope_gate_kv_store_streamed` | | - | device | - | -| `qkv_norm_rope` | | - | device | - | -| `qsa_block_key` | | host | device | host | -| `qsa_score` | | - | device | host | -| `qsa_select` | | - | device | host | -| `qsa_tail_store` | | - | device | host | -| `qsa_work` | | - | device | host | -| `quant_act_fp8` | yes | host | device | host | -| `quant_act_i8` | yes | host | device | host | -| `quant_act_i8g` | | host | device | host | -| `randn_lanes` | | - | device | host | -| `rel_sinusoid` | | host | device | host | -| `relu` | | host | device | host | -| `rmsnorm` | yes | host | device | host | -| `rmsnorm_add` | | host | - | host | -| `rmsnorm_had_quant_i8` | | host | device | host | -| `rmsnorm_p` | | host | device | host | -| `rmsnorm_quant_fp8` | yes | host | device | host | -| `rmsnorm_quant_i8` | | - | device | - | -| `rope` | yes | host | device | host | -| `rope_table` | yes | host | device | host | -| `router_gemm_topk_scatter` | | - | device | - | -| `router_topk` | | host | device | host | -| `router_topk_scatter` | | - | device | - | -| `row_topk` | yes | host | device | host | -| `row_topk_merge` | | host | device | host | -| `s2d_avg_add` | | - | device | host | -| `sample_argmax` | yes | host | device | host | -| `sample_chain` | | - | device | - | -| `sample_dry` | yes | host | device | host | -| `sample_logprobs` | yes | host | device | host | -| `sample_mask` | yes | host | device | host | -| `sample_merge_topk` | | host | device | host | -| `sample_minp` | yes | host | device | host | -| `sample_penalties` | yes | host | device | host | -| `sample_pick` | yes | host | device | host | -| `sample_temp` | yes | host | device | host | -| `sample_topk` | yes | host | device | host | -| `sample_topp` | yes | host | device | host | -| `sample_typical` | yes | host | device | host | -| `sample_xtc` | yes | host | device | host | -| `scale` | | host | device | host | -| `scale_rows` | | host | device | host | -| `scatter_add_rows` | | - | device | host | -| `scatter_rows` | yes | host | device | host | -| `seg_mean` | | host | device | host | -| `sigmoid` | | host | device | host | -| `silu` | | host | device | host | -| `silu_mul` | yes | host | device | host | -| `softmax` | | host | - | host | -| `timestep_embed` | | - | device | host | -| `to_rgba8` | | - | device | host | +| op | graph | libavx | libr4d | spechub | libref | +|---|---|---|---|---|---| +| `act_mul` | yes | host | device | - | host | +| `add` | yes | host | device | - | host | +| `add_rmsnorm` | | - | device | - | - | +| `all_gather` | | host | device | - | host | +| `all_reduce` | | host | device | - | host | +| `ar_gather_hc_write` | | - | device | - | - | +| `ar_hc_write` | | - | device | - | - | +| `ar_ln_had_quant_i8` | | - | device | - | - | +| `ar_rmsnorm_had_quant_i8g` | | - | device | - | - | +| `ar_rmsnorm_post_quant_fp8` | | - | device | - | - | +| `ar_rmsnorm_quant_fp8` | | - | device | - | - | +| `ar_rmsnorm_quant_i8` | | - | device | - | - | +| `attn_cross` | | host | device | - | host | +| `attn_dense` | yes | host | device | - | host | +| `attn_local_rel` | | host | device | - | host | +| `attn_na3d` | | host | device | - | host | +| `attn_paged` | yes | host | device | - | host | +| `attn_paged_gate_quant` | | - | device | - | - | +| `attn_paged_qrow` | | - | device | - | - | +| `attn_paged_qrow_tree` | | - | device | - | - | +| `attn_paged_sink` | yes | host | device | - | host | +| `attn_paged_tree` | | host | - | - | host | +| `attn_prefix_self` | | host | device | - | host | +| `attn_vsa` | | host | device | - | host | +| `bwe_up` | | host | device | - | host | +| `cast` | yes | host | device | - | host | +| `causal_conv1d` | | host | device | - | host | +| `cfg_topk_sample` | | host | device | - | host | +| `chan_affine` | | host | device | - | host | +| `chan_split` | | host | device | - | host | +| `chan_stats` | | host | device | - | host | +| `clamp` | | host | device | - | host | +| `cond_aug` | | host | device | - | host | +| `conv1d` | | host | device | - | host | +| `conv1d_dw` | | host | device | - | host | +| `conv2d` | | host | device | - | host | +| `conv2d_nhwc` | | host | device | - | host | +| `conv2d_unfold` | | host | device | - | host | +| `conv3d_ndhwc` | | host | device | - | host | +| `conv_t1d` | | host | device | - | host | +| `cu_repeat` | | host | device | - | host | +| `d2s3d` | | host | device | - | host | +| `d2s_add` | | host | device | - | host | +| `dequant` | | host | - | - | host | +| `dequant_w4` | | - | device | - | - | +| `dflash_conv` | | host | device | - | host | +| `dflash_couple_propose` | | - | - | device+host | - | +| `dflash_select` | yes | host | device | - | host | +| `dflash_tree` | | host | device | - | host | +| `dsa_pool` | | host | device | - | host | +| `dsa_query` | | host | device | - | host | +| `dsa_score` | | host | device | - | host | +| `embed_attn` | | host | device | - | host | +| `embed_lookup` | yes | host | device | - | host | +| `embed_lookup_q` | | host | device | - | host | +| `end_status` | | host | device | - | host | +| `expert_scale` | | - | device | - | - | +| `fill` | | host | device | - | host | +| `flow_euler` | | host | device | - | host | +| `flow_renoise` | | host | device | - | host | +| `flow_res_multistep` | | host | device | - | host | +| `flow_x0_step` | | host | device | - | host | +| `fourier_embed` | | host | device | - | host | +| `frame_mix_store` | | host | device | - | host | +| `frame_store` | | host | device | - | host | +| `gate_add` | | host | device | - | host | +| `gate_quant_fp8` | | - | device | - | - | +| `gated_had_quant_fp8` | | - | device | - | - | +| `gated_had_quant_i8` | | host | device | - | host | +| `gated_had_quant_i8g` | | - | device | - | - | +| `gated_quant_fp8` | yes | host | device | - | host | +| `gather_rows` | yes | host | device | - | host | +| `gather_rows2` | | host | device | - | host | +| `gdn_chunk_scan` | yes | host | device | - | host | +| `gdn_conv_prep` | | host | device | - | host | +| `gdn_conv_recurrent_update` | | host | device | - | host | +| `gdn_conv_update` | yes | host | device | - | host | +| `gdn_gated_norm_had_quant_i8` | | - | device | - | - | +| `gdn_gated_rmsnorm` | yes | host | device | - | host | +| `gdn_kkt_solve` | yes | host | device | - | host | +| `gdn_recurrent_update` | yes | host | device | - | host | +| `gelu` | | host | device | - | host | +| `gelu_mul` | | host | device | - | host | +| `gelu_mul_quant_i8` | | - | device | - | - | +| `gelu_quick` | | host | device | - | host | +| `gelu_tanh` | | host | device | - | host | +| `gemm_nt` | yes | host | device | - | host | +| `gemm_nt_bias` | yes | host | device | - | host | +| `gemm_nt_f32` | yes | host | device | - | host | +| `gemm_nt_q` | yes | host | device | - | host | +| `gemm_nt_q_bias` | | host | device | - | host | +| `gemm_nt_q_gated` | yes | host | device | - | host | +| `gemm_nt_q_gated_mx` | | - | device | - | - | +| `gemm_nt_q_gated_wide` | | host | device | - | host | +| `gemm_nt_q_short` | | host | device | - | host | +| `givens_dense_quant` | | host | device | - | host | +| `givens_rotate` | | host | device | - | host | +| `gram_accum` | | host | device | - | host | +| `grid_embed` | yes | host | device | - | host | +| `grid_embed_aa` | | host | device | - | host | +| `grid_embed_cpe` | yes | host | device | - | host | +| `grid_pos3` | | host | device | - | host | +| `group_norm` | | host | device | - | host | +| `had_quant_act_fp8` | yes | host | device | - | host | +| `had_quant_act_i8` | | host | device | - | host | +| `had_quant_act_i8g` | | host | device | - | host | +| `hc_enter` | | host | device | - | host | +| `hc_project` | | host | device | - | host | +| `hc_read` | | host | device | - | host | +| `hc_write` | | host | device | - | host | +| `head_gate` | | host | device | - | host | +| `im2col_nhwc` | | host | device | - | host | +| `int_affine` | | host | device | - | host | +| `interleave2` | | host | device | - | host | +| `iota` | yes | host | device | - | host | +| `join_add_scale` | | - | device | - | - | +| `kd_input` | | host | device | - | host | +| `kd_step` | | host | device | - | host | +| `kda_update` | | host | device | - | host | +| `kv_len_trim` | | - | device | - | - | +| `kv_resolve` | | host | device | - | host | +| `kv_store` | yes | host | device | - | host | +| `kv_store_streamed` | | host | device | - | host | +| `l2norm_chan` | | host | device | - | host | +| `lane_gather` | | host | device | - | host | +| `lane_store` | | host | device | - | host | +| `layernorm` | yes | host | device | - | host | +| `lili_attn` | yes | host | device | - | host | +| `lili_cand` | | host | device | - | host | +| `lili_factor` | yes | host | device | - | host | +| `lili_walk` | yes | host | device | - | host | +| `ln_mod` | | host | device | - | host | +| `ln_mod_quant_fp8` | | host | device | - | host | +| `logit_rerank` | yes | host | device | - | host | +| `logit_softcap` | | host | device | - | host | +| `logits_gemm` | yes | host | device | - | host | +| `lora_expand` | | host | device | - | host | +| `lora_expand_mm` | | host | device | - | host | +| `lora_shrink` | | host | device | - | host | +| `ltx_guide` | | host | device | - | host | +| `mhc_contract` | | host | device | - | host | +| `mhc_post` | | host | device | - | host | +| `mhc_pre` | | host | device | - | host | +| `mhc_pre_finish` | | host | device | - | host | +| `mhc_pre_partial` | | host | device | - | host | +| `ministral_rope` | | host | device | - | host | +| `mix_rows` | | host | device | - | host | +| `mla_attn` | | host | device | - | host | +| `mla_project` | | host | device | - | host | +| `moe_gather` | yes | host | device | - | host | +| `moe_gather_inv` | | - | device | - | - | +| `moe_gemm` | | host | device | - | host | +| `moe_gemm_q` | | host | device | - | host | +| `moe_gemm_q_mod4` | | host | device | - | host | +| `moe_scatter` | yes | host | device | - | host | +| `moe_scatter_inv` | | - | device | - | - | +| `mtp_couple_propose` | | - | - | device+host | - | +| `mtp_couple_verify` | | - | - | device+host | - | +| `mtp_enter` | | host | device | - | host | +| `mul` | | host | device | - | host | +| `mul_weight` | yes | host | device | - | host | +| `ngram_ids` | | host | device | - | host | +| `norm_add_norm` | | - | device | - | - | +| `norm_add_norm_route` | | - | device | - | - | +| `pair_argmax` | | host | device | - | host | +| `patch_fold` | | host | device | - | host | +| `patch_unfold` | | host | device | - | host | +| `pix_patch` | | host | device | - | host | +| `pixel_norm` | | host | device | - | host | +| `pixtral_merge` | | host | device | - | host | +| `pixtral_rope` | | host | device | - | host | +| `ple_conv` | | host | device | - | host | +| `ple_conv_bias` | yes | host | device | - | host | +| `ple_gate` | | host | device | - | host | +| `pool_cols` | | host | device | - | host | +| `pool_rows` | | host | device | - | host | +| `position_scale` | | host | device | - | host | +| `prefetch` | | - | device | - | - | +| `qk_norm_rope` | | host | device | - | host | +| `qk_norm_rope_gate` | | - | device | - | - | +| `qk_norm_rope_gate_kv_store` | | - | device | - | - | +| `qk_norm_rope_gate_kv_store_streamed` | | - | device | - | - | +| `qkv_norm_rope` | | - | device | - | - | +| `qkv_norm_rope_kv_store` | | - | device | - | - | +| `qsa_block_key` | | host | device | - | host | +| `qsa_score` | | host | device | - | host | +| `qsa_select` | | host | device | - | host | +| `qsa_tail_store` | | host | device | - | host | +| `qsa_work` | | host | device | - | host | +| `quant_act_fp8` | yes | host | device | - | host | +| `quant_act_i8` | yes | host | device | - | host | +| `quant_act_i8g` | | host | device | - | host | +| `quant_cols_fp8` | | host | device | - | host | +| `randn_lanes` | | host | device | - | host | +| `ras_pick` | | host | device | - | host | +| `rel_sinusoid` | | host | device | - | host | +| `relu` | | host | device | - | host | +| `resample_nearest` | | host | device | - | host | +| `resize_bilinear` | | host | device | - | host | +| `rms_mod` | | host | device | - | host | +| `rms_mod_quant_fp8` | | host | device | - | host | +| `rms_mod_quant_i8` | | - | device | - | - | +| `rmsnorm` | yes | host | device | - | host | +| `rmsnorm_add` | | host | - | - | host | +| `rmsnorm_had_quant_i8` | | host | device | - | host | +| `rmsnorm_had_quant_i8g` | | - | device | - | - | +| `rmsnorm_p` | | host | device | - | host | +| `rmsnorm_quant_fp8` | yes | host | device | - | host | +| `rmsnorm_quant_i8` | | - | device | - | - | +| `rmsnorm_rows` | | host | device | - | host | +| `rope` | yes | host | device | - | host | +| `rope_rows` | | host | device | - | host | +| `rope_split` | | host | device | - | host | +| `rope_table` | yes | host | device | - | host | +| `router_gemm_topk_scatter` | | host | device | - | host | +| `router_sigmoid_topk` | yes | host | device | - | host | +| `router_sigmoid_topk_scatter` | | - | device | - | - | +| `router_topk` | | host | device | - | host | +| `router_topk_scatter` | | host | device | - | host | +| `row_topk` | yes | host | device | - | host | +| `row_topk_merge` | | host | device | - | host | +| `rvq_embed` | | host | device | - | host | +| `s2d3d` | | host | device | - | host | +| `s2d_avg_add` | | host | device | - | host | +| `sam_attn` | | host | device | - | host | +| `sample_argmax` | yes | host | device | - | host | +| `sample_chain` | | - | device | - | - | +| `sample_dry` | yes | host | device | - | host | +| `sample_logprobs` | yes | host | device | - | host | +| `sample_mask` | yes | host | device | - | host | +| `sample_merge_topk` | | host | device | - | host | +| `sample_minp` | yes | host | device | - | host | +| `sample_ngram_ban` | yes | host | device | - | host | +| `sample_penalties` | yes | host | device | - | host | +| `sample_pick` | yes | host | device | - | host | +| `sample_temp` | yes | host | device | - | host | +| `sample_topk` | yes | host | device | - | host | +| `sample_topp` | yes | host | device | - | host | +| `sample_typical` | yes | host | device | - | host | +| `sample_xtc` | yes | host | device | - | host | +| `scale` | | host | device | - | host | +| `scale_rows` | | host | device | - | host | +| `scatter_add_rows` | | host | device | - | host | +| `scatter_rows` | yes | host | device | - | host | +| `seg_mean` | | host | device | - | host | +| `seg_mean_bf16_sum` | | host | device | - | host | +| `seg_sinusoid` | | host | device | - | host | +| `seg_softmax_pool` | | host | device | - | host | +| `sigmoid` | | host | device | - | host | +| `silu` | yes | host | device | - | host | +| `silu_mul` | yes | host | device | - | host | +| `snake` | | host | device | - | host | +| `snake_aa` | | host | device | - | host | +| `softmax` | | host | - | - | host | +| `ssd_update` | | host | device | - | host | +| `stft_logmel` | | host | device | - | host | +| `sub_i32` | | host | device | - | host | +| `swiglu_clamped` | | host | device | - | host | +| `swiglu_clamped_quant_fp8` | | - | device | - | - | +| `table_add` | | host | device | - | host | +| `tconv_dw` | | host | device | - | host | +| `tile_crop` | | host | device | - | host | +| `tile_grid` | | host | device | - | host | +| `tile_stitch` | | host | device | - | host | +| `timestep_embed` | | host | device | - | host | +| `to_rgba8` | | host | device | - | host | +| `vol_index` | | host | device | - | host | +| `vq_encode` | | host | device | - | host | +| `vsa_select` | | host | device | - | host | +| `vtile_crop` | | host | device | - | host | +| `vtile_gather` | | host | device | - | host | +| `vtile_join` | | host | device | - | host | +| `vtile_plan` | | host | device | - | host | +| `vtile_stitch` | | host | device | - | host | +| `win_finish` | | host | device | - | host | +| `win_input` | | host | device | - | host | +| `win_prep` | | host | device | - | host | ## Correctness -2202 distinct case(s) over 2202 check(s). `n` is how many times the case ran (typically one per +5052 distinct case(s) over 5229 check(s). `n` is how many times the case ran (typically one per layer) and `rel_l2` is the worst of them. `(synth w)` means this op's weights are not in the container and were drawn instead, so the case checks the arithmetic, not the artifact. @@ -694,19 +1295,19 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `rope_table` | `rope_table_f32` | libr4d | device | `rot=64 theta=1e+07 scale=1 dtype=f32 M=1` | - | 1 | ok | 0.00e+00 | 1e-05 | | `rope_table` | `ref_rope_table` | libref | host | `rot=64 theta=1e+07 scale=1 dtype=f32 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | | `rope_table` | `avx_rope_table` | libavx | host | `rot=64 theta=1e+07 scale=1 dtype=f32 M=2` | - | 1 | ok | 0.00e+00 | 1e-05 | -| `rope_table` | `rope_table_f32` | libr4d | device | `rot=64 theta=1e+07 scale=1 dtype=f32 M=2` | - | 1 | ok | 3.76e-09 | 1e-05 | +| `rope_table` | `rope_table_f32` | libr4d | device | `rot=64 theta=1e+07 scale=1 dtype=f32 M=2` | - | 1 | ok | 5.61e-09 | 1e-05 | | `rope_table` | `ref_rope_table` | libref | host | `rot=64 theta=1e+07 scale=1 dtype=f32 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | | `rope_table` | `avx_rope_table` | libavx | host | `rot=64 theta=1e+07 scale=1 dtype=f32 M=4` | - | 1 | ok | 0.00e+00 | 1e-05 | -| `rope_table` | `rope_table_f32` | libr4d | device | `rot=64 theta=1e+07 scale=1 dtype=f32 M=4` | - | 1 | ok | 1.48e-08 | 1e-05 | +| `rope_table` | `rope_table_f32` | libr4d | device | `rot=64 theta=1e+07 scale=1 dtype=f32 M=4` | - | 1 | ok | 1.56e-08 | 1e-05 | | `rope_table` | `ref_rope_table` | libref | host | `rot=64 theta=1e+07 scale=1 dtype=f32 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | | `rope_table` | `avx_rope_table` | libavx | host | `rot=64 theta=1e+07 scale=1 dtype=f32 M=8` | - | 1 | ok | 0.00e+00 | 1e-05 | -| `rope_table` | `rope_table_f32` | libr4d | device | `rot=64 theta=1e+07 scale=1 dtype=f32 M=8` | - | 1 | ok | 2.47e-08 | 1e-05 | +| `rope_table` | `rope_table_f32` | libr4d | device | `rot=64 theta=1e+07 scale=1 dtype=f32 M=8` | - | 1 | ok | 2.48e-08 | 1e-05 | | `rope_table` | `ref_rope_table` | libref | host | `rot=64 theta=1e+07 scale=1 dtype=f32 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | | `rope_table` | `avx_rope_table` | libavx | host | `rot=64 theta=1e+07 scale=1 dtype=f32 M=16` | - | 1 | ok | 0.00e+00 | 1e-05 | -| `rope_table` | `rope_table_f32` | libr4d | device | `rot=64 theta=1e+07 scale=1 dtype=f32 M=16` | - | 1 | ok | 5.15e-08 | 1e-05 | +| `rope_table` | `rope_table_f32` | libr4d | device | `rot=64 theta=1e+07 scale=1 dtype=f32 M=16` | - | 1 | ok | 5.11e-08 | 1e-05 | | `rope_table` | `ref_rope_table` | libref | host | `rot=64 theta=1e+07 scale=1 dtype=f32 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | | `rope_table` | `avx_rope_table` | libavx | host | `rot=64 theta=1e+07 scale=1 dtype=f32 M=32` | - | 1 | ok | 0.00e+00 | 1e-05 | -| `rope_table` | `rope_table_f32` | libr4d | device | `rot=64 theta=1e+07 scale=1 dtype=f32 M=32` | - | 1 | ok | 9.56e-08 | 1e-05 | +| `rope_table` | `rope_table_f32` | libr4d | device | `rot=64 theta=1e+07 scale=1 dtype=f32 M=32` | - | 1 | ok | 9.54e-08 | 1e-05 | | `rope_table` | `ref_rope_table` | libref | host | `rot=64 theta=1e+07 scale=1 dtype=f32 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | | `rope_table` | `avx_rope_table` | libavx | host | `rot=64 theta=1e+07 scale=1 dtype=f32 M=64` | - | 1 | ok | 0.00e+00 | 1e-05 | | `rope_table` | `rope_table_f32` | libr4d | device | `rot=64 theta=1e+07 scale=1 dtype=f32 M=64` | - | 1 | ok | 1.62e-07 | 1e-05 | @@ -715,12 +1316,12 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | device | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=1` | - | 1 | ok | 1.60e-04 | 4e-03 | | `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | host | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | | `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | host | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=2` | - | 1 | ok | 1.15e-04 | 4e-03 | -| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | device | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=2` | - | 1 | ok | 1.22e-04 | 4e-03 | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | device | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=2` | - | 1 | ok | 1.15e-04 | 4e-03 | | `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | host | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | | `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | host | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=4` | - | 1 | ok | 3.25e-04 | 4e-03 | | `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | device | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=4` | - | 1 | ok | 3.25e-04 | 4e-03 | | `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | host | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | host | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=8` | - | 1 | ok | 2.12e-04 | 4e-03 | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | host | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=8` | - | 1 | ok | 2.13e-04 | 4e-03 | | `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | device | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=8` | - | 1 | ok | 2.12e-04 | 4e-03 | | `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | host | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | | `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | host | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=16` | - | 1 | ok | 3.48e-04 | 4e-03 | @@ -729,56 +1330,56 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | host | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=32` | - | 1 | ok | 5.75e-04 | 4e-03 | | `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | device | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=32` | - | 1 | ok | 5.75e-04 | 4e-03 | | `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | host | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | host | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=64` | - | 1 | ok | 3.34e-04 | 4e-03 | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | host | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=64` | - | 1 | ok | 3.32e-04 | 4e-03 | | `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | device | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=64` | - | 1 | ok | 3.35e-04 | 4e-03 | | `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | host | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | host | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=128` | - | 1 | ok | 7.83e-04 | 4e-03 | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | host | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=128` | - | 1 | ok | 7.91e-04 | 4e-03 | | `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | device | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=128` | - | 1 | ok | 7.83e-04 | 4e-03 | | `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | host | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | host | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=256` | - | 1 | ok | 9.01e-04 | 4e-03 | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | host | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=256` | - | 1 | ok | 8.91e-04 | 4e-03 | | `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | device | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=256` | - | 1 | ok | 9.01e-04 | 4e-03 | | `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | host | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | host | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=512` | - | 1 | ok | 5.88e-04 | 4e-03 | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | host | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=512` | - | 1 | ok | 5.74e-04 | 4e-03 | | `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | device | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=512` | - | 1 | ok | 5.92e-04 | 4e-03 | | `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | host | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 1.08e-08 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=16384 K=5120 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 2.34e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=16384 K=5120 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 6.93e-07 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 3.61e-06 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 2.95e-05 | 5e-03 | | `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=16384 K=5120 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 1.44e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 3.11e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=16384 K=5120 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 2.14e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 5.55e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=16384 K=5120 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 2.16e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 3.30e-06 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=16384 K=5120 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 7.38e-06 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 1.72e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=16384 K=5120 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 1.91e-06 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 1.67e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=16384 K=5120 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 9.03e-06 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 1.09e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=16384 K=5120 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 1.71e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 1.88e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=16384 K=5120 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 1.81e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 7.01e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=16384 K=5120 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 1.68e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 9.17e-06 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=16384 K=5120 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 9.87e-06 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 7.79e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=16384 K=5120 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 1.50e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 2.32e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=16384 K=5120 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 2.64e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 7.13e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=16384 K=5120 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 2.31e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 2.13e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=16384 K=5120 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 1.62e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 7.35e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=16384 K=5120 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 1.37e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 2.09e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=16384 K=5120 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 1.42e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 6.66e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=16384 K=5120 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 2.16e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 2.18e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=16384 K=5120 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 2.27e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 8.45e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=16384 K=5120 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 1.99e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 2.39e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=16384 K=5120 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 1.75e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 7.79e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=16384 K=5120 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 1.74e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 1.84e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=16384 K=5120 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 1.71e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 6.51e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=16384 K=5120 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 2.03e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=16384 K=5120 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | | `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=96 K=5120 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 6.72e-08 | 8e-03 | | `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=96 K=5120 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 5.74e-06 | 8e-03 | @@ -792,28 +1393,28 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=96 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=96 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt` | `ref_gemm_nt` | libref | host | `N=96 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=96 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 2.16e-08 | 8e-03 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=96 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=96 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 2.16e-08 | 8e-03 | | `gemm_nt` | `ref_gemm_nt` | libref | host | `N=96 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=96 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 2.11e-08 | 8e-03 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=96 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=96 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 2.11e-08 | 8e-03 | | `gemm_nt` | `ref_gemm_nt` | libref | host | `N=96 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=96 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 2.46e-04 | 8e-03 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=96 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=96 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 2.47e-04 | 8e-03 | | `gemm_nt` | `ref_gemm_nt` | libref | host | `N=96 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=96 K=5120 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 9.76e-08 | 8e-03 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=96 K=5120 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=96 K=5120 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 2.79e-06 | 8e-03 | | `gemm_nt` | `ref_gemm_nt` | libref | host | `N=96 K=5120 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=96 K=5120 dtype=bf16 M=65 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 5.06e-05 | 8e-03 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=96 K=5120 dtype=bf16 M=65 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=96 K=5120 dtype=bf16 M=65 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 4.38e-05 | 8e-03 | | `gemm_nt` | `ref_gemm_nt` | libref | host | `N=96 K=5120 dtype=bf16 M=65 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=96 K=5120 dtype=bf16 M=130 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 9.08e-05 | 8e-03 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=96 K=5120 dtype=bf16 M=130 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=96 K=5120 dtype=bf16 M=130 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 9.03e-05 | 8e-03 | | `gemm_nt` | `ref_gemm_nt` | libref | host | `N=96 K=5120 dtype=bf16 M=130 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=96 K=5120 dtype=bf16 M=260 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 1.07e-04 | 8e-03 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=96 K=5120 dtype=bf16 M=260 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=96 K=5120 dtype=bf16 M=260 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 1.02e-04 | 8e-03 | | `gemm_nt` | `ref_gemm_nt` | libref | host | `N=96 K=5120 dtype=bf16 M=260 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=96 K=5120 dtype=bf16 M=512 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 6.05e-05 | 8e-03 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=96 K=5120 dtype=bf16 M=512 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=96 K=5120 dtype=bf16 M=512 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 1.06e-04 | 8e-03 | | `gemm_nt` | `ref_gemm_nt` | libref | host | `N=96 K=5120 dtype=bf16 M=512 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | | `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | host | `head_k=128 M=1 chunk=64` | - | 1 | ok | 0.00e+00 | 2e-03 | @@ -828,52 +1429,52 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | host | `head_k=128 M=8 chunk=64` | - | 1 | ok | 0.00e+00 | 2e-03 | | `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | device | `head_k=128 M=8 chunk=64` | - | 1 | ok | 3.78e-05 | 2e-03 | | `gdn_kkt_solve` | `ref_gdn_kkt_solve` | libref | host | `head_k=128 M=8 chunk=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | host | `head_k=128 M=16 chunk=64` | - | 1 | ok | 1.07e-09 | 2e-03 | +| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | host | `head_k=128 M=16 chunk=64` | - | 1 | ok | 1.69e-08 | 2e-03 | | `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | device | `head_k=128 M=16 chunk=64` | - | 1 | ok | 4.35e-05 | 2e-03 | | `gdn_kkt_solve` | `ref_gdn_kkt_solve` | libref | host | `head_k=128 M=16 chunk=64` | - | 1 | ok | 0.00e+00 | 0e+00 | | `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | host | `head_k=128 M=32 chunk=64` | - | 1 | ok | 3.04e-09 | 2e-03 | | `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | device | `head_k=128 M=32 chunk=64` | - | 1 | ok | 4.26e-05 | 2e-03 | | `gdn_kkt_solve` | `ref_gdn_kkt_solve` | libref | host | `head_k=128 M=32 chunk=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | host | `head_k=128 M=64 chunk=64` | - | 1 | ok | 6.45e-13 | 2e-03 | +| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | host | `head_k=128 M=64 chunk=64` | - | 1 | ok | 1.68e-11 | 2e-03 | | `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | device | `head_k=128 M=64 chunk=64` | - | 1 | ok | 7.76e-05 | 2e-03 | | `gdn_kkt_solve` | `ref_gdn_kkt_solve` | libref | host | `head_k=128 M=64 chunk=64` | - | 1 | ok | 0.00e+00 | 0e+00 | | `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | host | `head_k=128 M=128 chunk=64` | - | 1 | ok | 1.78e-06 | 2e-03 | | `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | device | `head_k=128 M=128 chunk=64` | - | 1 | ok | 8.13e-05 | 2e-03 | | `gdn_kkt_solve` | `ref_gdn_kkt_solve` | libref | host | `head_k=128 M=128 chunk=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | host | `head_k=128 M=256 chunk=64` | - | 1 | ok | 3.67e-08 | 2e-03 | +| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | host | `head_k=128 M=256 chunk=64` | - | 1 | ok | 8.41e-09 | 2e-03 | | `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | device | `head_k=128 M=256 chunk=64` | - | 1 | ok | 5.42e-05 | 2e-03 | | `gdn_kkt_solve` | `ref_gdn_kkt_solve` | libref | host | `head_k=128 M=256 chunk=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | host | `head_k=128 M=512 chunk=64` | - | 1 | ok | 3.89e-07 | 2e-03 | +| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | host | `head_k=128 M=512 chunk=64` | - | 1 | ok | 3.90e-07 | 2e-03 | | `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | device | `head_k=128 M=512 chunk=64` | - | 1 | ok | 4.61e-05 | 2e-03 | | `gdn_kkt_solve` | `ref_gdn_kkt_solve` | libref | host | `head_k=128 M=512 chunk=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | host | `head_k=128 head_v=128 scale=0.0883883 M=1 chunk=64` | - | 1 | ok | 4.79e-05 | 2e-02 | +| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | host | `head_k=128 head_v=128 scale=0.0883883 M=1 chunk=64` | - | 1 | ok | 7.49e-07 | 2e-02 | | `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | device | `head_k=128 head_v=128 scale=0.0883883 M=1 chunk=64` | - | 1 | ok | 3.04e-03 | 2e-02 | | `gdn_chunk_scan` | `ref_gdn_chunk_scan` | libref | host | `head_k=128 head_v=128 scale=0.0883883 M=1 chunk=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | host | `head_k=128 head_v=128 scale=0.0883883 M=2 chunk=64` | - | 1 | ok | 2.73e-07 | 2e-02 | +| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | host | `head_k=128 head_v=128 scale=0.0883883 M=2 chunk=64` | - | 1 | ok | 6.19e-06 | 2e-02 | | `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | device | `head_k=128 head_v=128 scale=0.0883883 M=2 chunk=64` | - | 1 | ok | 2.48e-03 | 2e-02 | | `gdn_chunk_scan` | `ref_gdn_chunk_scan` | libref | host | `head_k=128 head_v=128 scale=0.0883883 M=2 chunk=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | host | `head_k=128 head_v=128 scale=0.0883883 M=4 chunk=64` | - | 1 | ok | 6.84e-08 | 2e-02 | +| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | host | `head_k=128 head_v=128 scale=0.0883883 M=4 chunk=64` | - | 1 | ok | 5.85e-08 | 2e-02 | | `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | device | `head_k=128 head_v=128 scale=0.0883883 M=4 chunk=64` | - | 1 | ok | 3.08e-03 | 2e-02 | | `gdn_chunk_scan` | `ref_gdn_chunk_scan` | libref | host | `head_k=128 head_v=128 scale=0.0883883 M=4 chunk=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | host | `head_k=128 head_v=128 scale=0.0883883 M=8 chunk=64` | - | 1 | ok | 5.40e-05 | 2e-02 | +| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | host | `head_k=128 head_v=128 scale=0.0883883 M=8 chunk=64` | - | 1 | ok | 5.44e-05 | 2e-02 | | `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | device | `head_k=128 head_v=128 scale=0.0883883 M=8 chunk=64` | - | 1 | ok | 2.88e-03 | 2e-02 | | `gdn_chunk_scan` | `ref_gdn_chunk_scan` | libref | host | `head_k=128 head_v=128 scale=0.0883883 M=8 chunk=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | host | `head_k=128 head_v=128 scale=0.0883883 M=16 chunk=64` | - | 1 | ok | 5.06e-06 | 2e-02 | +| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | host | `head_k=128 head_v=128 scale=0.0883883 M=16 chunk=64` | - | 1 | ok | 4.33e-06 | 2e-02 | | `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | device | `head_k=128 head_v=128 scale=0.0883883 M=16 chunk=64` | - | 1 | ok | 2.76e-03 | 2e-02 | | `gdn_chunk_scan` | `ref_gdn_chunk_scan` | libref | host | `head_k=128 head_v=128 scale=0.0883883 M=16 chunk=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | host | `head_k=128 head_v=128 scale=0.0883883 M=32 chunk=64` | - | 1 | ok | 2.59e-06 | 2e-02 | +| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | host | `head_k=128 head_v=128 scale=0.0883883 M=32 chunk=64` | - | 1 | ok | 8.62e-06 | 2e-02 | | `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | device | `head_k=128 head_v=128 scale=0.0883883 M=32 chunk=64` | - | 1 | ok | 3.40e-03 | 2e-02 | | `gdn_chunk_scan` | `ref_gdn_chunk_scan` | libref | host | `head_k=128 head_v=128 scale=0.0883883 M=32 chunk=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | host | `head_k=128 head_v=128 scale=0.0883883 M=64 chunk=64` | - | 1 | ok | 4.07e-06 | 2e-02 | -| `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | device | `head_k=128 head_v=128 scale=0.0883883 M=64 chunk=64` | - | 1 | ok | 3.72e-03 | 2e-02 | +| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | host | `head_k=128 head_v=128 scale=0.0883883 M=64 chunk=64` | - | 1 | ok | 9.76e-06 | 2e-02 | +| `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | device | `head_k=128 head_v=128 scale=0.0883883 M=64 chunk=64` | - | 1 | ok | 3.71e-03 | 2e-02 | | `gdn_chunk_scan` | `ref_gdn_chunk_scan` | libref | host | `head_k=128 head_v=128 scale=0.0883883 M=64 chunk=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | host | `head_k=128 head_v=128 scale=0.0883883 M=128 chunk=64` | - | 1 | ok | 3.81e-05 | 2e-02 | +| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | host | `head_k=128 head_v=128 scale=0.0883883 M=128 chunk=64` | - | 1 | ok | 4.40e-05 | 2e-02 | | `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | device | `head_k=128 head_v=128 scale=0.0883883 M=128 chunk=64` | - | 1 | ok | 4.27e-03 | 2e-02 | | `gdn_chunk_scan` | `ref_gdn_chunk_scan` | libref | host | `head_k=128 head_v=128 scale=0.0883883 M=128 chunk=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | host | `head_k=128 head_v=128 scale=0.0883883 M=256 chunk=64` | - | 1 | ok | 1.92e-05 | 2e-02 | +| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | host | `head_k=128 head_v=128 scale=0.0883883 M=256 chunk=64` | - | 1 | ok | 1.78e-05 | 2e-02 | | `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | device | `head_k=128 head_v=128 scale=0.0883883 M=256 chunk=64` | - | 1 | ok | 3.53e-03 | 2e-02 | | `gdn_chunk_scan` | `ref_gdn_chunk_scan` | libref | host | `head_k=128 head_v=128 scale=0.0883883 M=256 chunk=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | host | `head_k=128 head_v=128 scale=0.0883883 M=512 chunk=64` | - | 1 | ok | 1.92e-05 | 2e-02 | +| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | host | `head_k=128 head_v=128 scale=0.0883883 M=512 chunk=64` | - | 1 | ok | 2.81e-05 | 2e-02 | | `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | device | `head_k=128 head_v=128 scale=0.0883883 M=512 chunk=64` | - | 1 | ok | 3.64e-03 | 2e-02 | | `gdn_chunk_scan` | `ref_gdn_chunk_scan` | libref | host | `head_k=128 head_v=128 scale=0.0883883 M=512 chunk=64` | - | 1 | ok | 0.00e+00 | 0e+00 | | `gdn_gated_rmsnorm` | `avx_gdn_gated_rmsnorm` | libavx | host | `channels=128 eps=1e-06 act=silu M=1` | - | 1 | ok | 0.00e+00 | 2e-03 | @@ -936,19 +1537,19 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `gdn_conv_update` | `avx_gdn_conv_update` | libavx | host | `head_k=128 head_v=128 conv_width=4 q_len=512` | - | 1 | ok | 7.80e-06 | 2e-03 | | `gdn_conv_update` | `gdn_conv_update_w4_h128_bf16` | libr4d | device | `head_k=128 head_v=128 conv_width=4 q_len=512` | - | 1 | ok | 1.50e-05 | 2e-03 | | `gdn_conv_update` | `ref_gdn_conv_update` | libref | host | `head_k=128 head_v=128 conv_width=4 q_len=512` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gdn_recurrent_update` | `avx_gdn_recurrent_update` | libavx | host | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=1` | - | 1 | ok | 1.04e-05 | 2e-02 | +| `gdn_recurrent_update` | `avx_gdn_recurrent_update` | libavx | host | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=1` | - | 1 | ok | 2.16e-07 | 2e-02 | | `gdn_recurrent_update` | `gdn_recurrent_update_k128_v128_bf16_fp32state` | libr4d | device | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=1` | - | 1 | ok | 6.54e-07 | 2e-02 | | `gdn_recurrent_update` | `ref_gdn_recurrent_update` | libref | host | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gdn_recurrent_update` | `avx_gdn_recurrent_update` | libavx | host | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=2` | - | 1 | ok | 6.01e-05 | 2e-02 | +| `gdn_recurrent_update` | `avx_gdn_recurrent_update` | libavx | host | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=2` | - | 1 | ok | 6.04e-05 | 2e-02 | | `gdn_recurrent_update` | `gdn_recurrent_update_k128_v128_bf16_fp32state` | libr4d | device | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=2` | - | 1 | ok | 6.04e-05 | 2e-02 | | `gdn_recurrent_update` | `ref_gdn_recurrent_update` | libref | host | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=2` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gdn_recurrent_update` | `avx_gdn_recurrent_update` | libavx | host | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=4` | - | 1 | ok | 2.39e-07 | 2e-02 | +| `gdn_recurrent_update` | `avx_gdn_recurrent_update` | libavx | host | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=4` | - | 1 | ok | 2.86e-07 | 2e-02 | | `gdn_recurrent_update` | `gdn_recurrent_update_k128_v128_bf16_fp32state` | libr4d | device | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=4` | - | 1 | ok | 4.64e-07 | 2e-02 | | `gdn_recurrent_update` | `ref_gdn_recurrent_update` | libref | host | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=4` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gdn_recurrent_update` | `avx_gdn_recurrent_update` | libavx | host | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=8` | - | 1 | ok | 3.73e-06 | 2e-02 | +| `gdn_recurrent_update` | `avx_gdn_recurrent_update` | libavx | host | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=8` | - | 1 | ok | 8.66e-06 | 2e-02 | | `gdn_recurrent_update` | `gdn_recurrent_update_k128_v128_bf16_fp32state` | libr4d | device | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=8` | - | 1 | ok | 9.67e-06 | 2e-02 | | `gdn_recurrent_update` | `ref_gdn_recurrent_update` | libref | host | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=8` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gdn_recurrent_update` | `avx_gdn_recurrent_update` | libavx | host | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=16` | - | 1 | ok | 9.82e-05 | 2e-02 | +| `gdn_recurrent_update` | `avx_gdn_recurrent_update` | libavx | host | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=16` | - | 1 | ok | 1.00e-04 | 2e-02 | | `gdn_recurrent_update` | `gdn_recurrent_update_k128_v128_bf16_fp32state` | libr4d | device | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=16` | - | 1 | ok | 4.06e-05 | 2e-02 | | `gdn_recurrent_update` | `ref_gdn_recurrent_update` | libref | host | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=16` | - | 1 | ok | 0.00e+00 | 0e+00 | | `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=6144 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | @@ -981,83 +1582,83 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=6144 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 1e-06 | | `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=6144 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 1e-06 | | `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=6144 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 1.76e-08 | 5e-03 | | `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=6144 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 2.37e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=6144 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 7.25e-10 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 2.93e-06 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=6144 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 2.38e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 1.08e-09 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=6144 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 8.85e-06 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 9.23e-06 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=6144 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 8.76e-07 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 9.25e-08 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=6144 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 5.91e-06 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 6.10e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=6144 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 6.18e-06 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 5.77e-06 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=6144 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 5.45e-06 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 8.80e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=6144 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 4.79e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 1.13e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=6144 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 8.04e-06 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 4.73e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=6144 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 8.90e-06 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 1.25e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=6144 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 3.16e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 9.17e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=6144 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 1.38e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 1.83e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=6144 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 1.76e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 1.52e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=6144 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 7.05e-06 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 2.51e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=5120 K=6144 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 6.98e-06 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 3.10e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=5120 K=6144 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 1.67e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 1.54e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=5120 K=6144 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 2.04e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 8.60e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=5120 K=6144 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 1.89e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 2.07e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=5120 K=6144 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 1.82e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 1.55e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=5120 K=6144 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 2.16e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 1.08e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=5120 K=6144 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 1.36e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 6.74e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=5120 K=6144 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 1.14e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 2.13e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=5120 K=6144 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 1.75e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 7.90e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=5120 K=6144 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 1.93e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=6144 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 4.13e-06 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 4.14e-06 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 1.07e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 3.66e-06 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 1.95e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 1.19e-09 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 3.36e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 4.71e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 3.11e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 3.14e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 7.04e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 4.65e-06 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 1.01e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 8.70e-06 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 2.89e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 2.29e-06 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 1.96e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 1.39e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 6.50e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 1.95e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 1.36e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 1.78e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 7.58e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 2.32e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 1.11e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 9.79e-06 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 7.21e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 1.71e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 1.57e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 1.71e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 6.64e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 2.08e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 1.72e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 2.16e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 7.62e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 2.19e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 1.73e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 1.37e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 5.70e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 1.44e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 1.59e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 1.28e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 8.12e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 2.16e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 1.41e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 1.67e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 8.04e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 1.93e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 1.91e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 1.37e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 8.19e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 2.04e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=34816 K=5120 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | | `gated_quant_fp8` | `avx_gated_quant_fp8` | libavx | host | `n=17408 group=128 dtype=bf16 act=silu M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | | `gated_quant_fp8` | `gated_quant_fp8` | libr4d | device | `n=17408 group=128 dtype=bf16 act=silu M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | @@ -1089,143 +1690,143 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `gated_quant_fp8` | `avx_gated_quant_fp8` | libavx | host | `n=17408 group=128 dtype=bf16 act=silu M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | | `gated_quant_fp8` | `gated_quant_fp8` | libr4d | device | `n=17408 group=128 dtype=bf16 act=silu M=512` | - | 1 | ok | 6.40e-05 | 6e-03 | | `gated_quant_fp8` | `ref_gated_quant_fp8` | libref | host | `n=17408 group=128 dtype=bf16 act=silu M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=1` | - | 1 | ok | 1.07e-05 | 3e-02 | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=1` | - | 1 | ok | 1.48e-04 | 3e-02 | | `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=1` | - | 1 | ok | 0.00e+00 | 3e-02 | | `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | host | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=2` | - | 1 | ok | 9.06e-06 | 3e-02 | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=2` | - | 1 | ok | 6.86e-06 | 3e-02 | | `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=2` | - | 1 | ok | 9.06e-06 | 3e-02 | | `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | host | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=4` | - | 1 | ok | 4.32e-05 | 3e-02 | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=4` | - | 1 | ok | 3.51e-05 | 3e-02 | | `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=4` | - | 1 | ok | 4.33e-05 | 3e-02 | | `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | host | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=8` | - | 1 | ok | 4.47e-06 | 3e-02 | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=8` | - | 1 | ok | 4.65e-05 | 3e-02 | | `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=8` | - | 1 | ok | 9.43e-06 | 3e-02 | | `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | host | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=16` | - | 1 | ok | 8.53e-05 | 3e-02 | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=16` | - | 1 | ok | 8.64e-05 | 3e-02 | | `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=16` | - | 1 | ok | 9.05e-05 | 3e-02 | | `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | host | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=32` | - | 1 | ok | 3.10e-05 | 3e-02 | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=32` | - | 1 | ok | 3.10e-04 | 3e-02 | | `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=32` | - | 1 | ok | 2.70e-05 | 3e-02 | | `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | host | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=64` | - | 1 | ok | 1.68e-05 | 3e-02 | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | host | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=64` | - | 1 | ok | 4.26e-04 | 3e-02 | | `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | device | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=64` | - | 1 | ok | 2.16e-05 | 3e-02 | | `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | host | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 5.20e-06 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 5.21e-06 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 9.51e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 5.18e-06 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 4.54e-07 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 6.42e-07 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 2.81e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 4.40e-07 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 2.11e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 2.47e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 4.00e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 2.06e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 8.85e-07 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 8.85e-07 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 5.50e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 4.04e-06 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 1.44e-06 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 2.91e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 1.85e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 2.71e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 8.01e-06 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 4.67e-06 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 5.57e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 7.07e-06 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 1.57e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 2.64e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 1.08e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 1.47e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 3.16e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 3.33e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 8.70e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 1.95e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 2.15e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 1.37e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 8.94e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 2.40e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 2.10e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 2.13e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 7.07e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 2.65e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 2.17e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 2.66e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 8.31e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 1.81e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 2.48e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 2.45e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 1.12e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 3.66e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 2.29e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 1.65e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 9.75e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=5120 K=17408 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 2.13e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=17408 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 4.97e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 6.57e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 9.70e-08 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 3.24e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 3.58e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 3.27e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 2.08e-06 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 2.43e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 2.71e-06 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 2.41e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 2.17e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 2.54e-07 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 5.17e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 1.62e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 4.97e-07 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 1.73e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 6.36e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 1.01e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 2.59e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 2.30e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 7.83e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 2.40e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 2.05e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 2.20e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 8.19e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 1.35e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 2.29e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 2.63e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 5.44e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 2.35e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 1.77e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 2.23e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 8.91e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 2.33e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 3.13e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 2.09e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 7.16e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 2.38e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 1.43e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 1.69e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 8.14e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 2.39e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 1.59e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 1.76e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 6.64e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 2.03e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 1.56e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 1.87e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 1.62e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=12288 K=5120 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 1.97e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=12288 K=5120 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 8.69e-05 | 5e-03 | | `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=1024 K=5120 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 2.84e-05 | 5e-03 | | `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=1024 K=5120 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 2.84e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 2.36e-04 | 5e-03 | | `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=1024 K=5120 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 0.00e+00 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 2.25e-07 | 5e-03 | | `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=1024 K=5120 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 0.00e+00 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 5.48e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=1024 K=5120 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 1.70e-06 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 3.40e-06 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=1024 K=5120 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 0.00e+00 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 8.06e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=1024 K=5120 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 2.01e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 8.47e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=1024 K=5120 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 4.82e-06 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 1.43e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=1024 K=5120 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 1.39e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 7.41e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=1024 K=5120 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 1.37e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=36` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 4.14e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 1.65e-04 | 5e-03 | | `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=1024 K=5120 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 4.14e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 2.03e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=1024 K=5120 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 1.91e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 6.37e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=1024 K=5120 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 2.45e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 3.68e-06 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=1024 K=5120 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 3.56e-06 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 6.85e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=1024 K=5120 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 4.36e-06 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 3.61e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=1024 K=5120 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 5.77e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 1.04e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=1024 K=5120 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 1.39e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 1.05e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=1024 K=5120 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 9.33e-06 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 1.03e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=1024 K=5120 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 9.08e-06 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 2.50e-05 | 5e-03 | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=1024 K=5120 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 2.03e-05 | 5e-03 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 6.62e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=1024 K=5120 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 1.91e-05 | 5e-03 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | | `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 4e-03 | | `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 4e-03 | @@ -1272,7 +1873,7 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `rope` | `avx_rope` | libavx | host | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=16` | - | 1 | ok | 0.00e+00 | 2e-03 | | `rope` | `rope_bf16` | libr4d | device | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=16` | - | 1 | ok | 0.00e+00 | 2e-03 | | `rope` | `ref_rope` | libref | host | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `rope` | `avx_rope` | libavx | host | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=32` | - | 1 | ok | 0.00e+00 | 2e-03 | +| `rope` | `avx_rope` | libavx | host | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=32` | - | 1 | ok | 3.43e-08 | 2e-03 | | `rope` | `rope_bf16` | libr4d | device | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=32` | - | 1 | ok | 2.20e-06 | 2e-03 | | `rope` | `ref_rope` | libref | host | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | | `rope` | `avx_rope` | libavx | host | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=64` | - | 1 | ok | 0.00e+00 | 2e-03 | @@ -1324,34 +1925,34 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 1 | ok | 1.77e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 1 | ok | 8.52e-05 | 2e-02 | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 1 | ok | 2.20e-03 | 2e-02 | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 1 | ok | 2.18e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 1 | ok | 0.00e+00 | 2e-02 | | `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 1 | ok | 8.24e-04 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 1 | ok | 4.01e-05 | 2e-02 | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 1 | ok | 2.02e-03 | 2e-02 | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 1 | ok | 1.86e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 1 | ok | 1.49e-04 | 2e-02 | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 1 | ok | 1.90e-03 | 2e-02 | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 1 | ok | 1.89e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 1 | ok | 7.64e-09 | 2e-02 | | `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 1 | ok | 1.35e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 1 | ok | 1.10e-04 | 2e-02 | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 1 | ok | 2.32e-03 | 2e-02 | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 1 | ok | 2.30e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 1 | ok | 1.24e-04 | 2e-02 | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 1 | ok | 2.06e-03 | 2e-02 | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 1 | ok | 2.17e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 1 | ok | 0.00e+00 | 2e-02 | | `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 1 | ok | 1.16e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 1 | ok | 3.09e-05 | 2e-02 | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 1 | ok | 2.11e-03 | 2e-02 | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 1 | ok | 2.06e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 1 | ok | 1.11e-04 | 2e-02 | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 1 | ok | 2.34e-03 | 2e-02 | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 1 | ok | 2.48e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | - | 1 | ok | 1.81e-06 | 2e-02 | | `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | - | 1 | ok | 1.39e-03 | 2e-02 | @@ -1383,7 +1984,7 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=10 splits=0` | - | 1 | ok | 4.85e-05 | 2e-02 | | `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=10 splits=0` | - | 1 | ok | 1.72e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=10 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=10 splits=0` | - | 1 | ok | 6.80e-05 | 2e-02 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=10 splits=0` | - | 1 | ok | 6.82e-05 | 2e-02 | | `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=10 splits=0` | - | 1 | ok | 1.88e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=10 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=10 splits=0` | - | 1 | ok | 5.76e-05 | 2e-02 | @@ -1393,19 +1994,19 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=11` | - | 1 | ok | 7.52e-04 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=11` | - | 1 | ok | 0.00e+00 | 0e+00 | | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=11` | - | 1 | ok | 3.19e-05 | 2e-02 | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=11` | - | 1 | ok | 1.64e-03 | 2e-02 | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=11` | - | 1 | ok | 1.61e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=11` | - | 1 | ok | 0.00e+00 | 0e+00 | | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=11` | - | 1 | ok | 5.29e-05 | 2e-02 | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=11` | - | 1 | ok | 1.64e-03 | 2e-02 | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=11` | - | 1 | ok | 1.63e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=11` | - | 1 | ok | 0.00e+00 | 0e+00 | | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | - | 1 | ok | 3.49e-07 | 2e-02 | | `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | - | 1 | ok | 8.67e-04 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | - | 1 | ok | 0.00e+00 | 0e+00 | | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | - | 1 | ok | 3.93e-05 | 2e-02 | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | - | 1 | ok | 1.55e-03 | 2e-02 | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | - | 1 | ok | 1.41e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | - | 1 | ok | 0.00e+00 | 0e+00 | | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | - | 1 | ok | 1.08e-04 | 2e-02 | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | - | 1 | ok | 1.79e-03 | 2e-02 | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | - | 1 | ok | 1.82e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | - | 1 | ok | 0.00e+00 | 0e+00 | | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=17` | - | 1 | ok | 1.15e-05 | 2e-02 | | `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=17` | - | 1 | ok | 1.04e-03 | 2e-02 | @@ -1413,61 +2014,61 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=17` | - | 1 | ok | 3.81e-05 | 2e-02 | | `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=17` | - | 1 | ok | 1.80e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=17` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=17` | - | 1 | ok | 6.23e-05 | 2e-02 | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=17` | - | 1 | ok | 1.74e-03 | 2e-02 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=17` | - | 1 | ok | 6.22e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=17` | - | 1 | ok | 1.82e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=17` | - | 1 | ok | 0.00e+00 | 0e+00 | | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | - | 1 | ok | 3.43e-06 | 2e-02 | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | - | 1 | ok | 1.00e-03 | 2e-02 | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | - | 1 | ok | 1.01e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | - | 1 | ok | 5.74e-05 | 2e-02 | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | - | 1 | ok | 2.03e-03 | 2e-02 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | - | 1 | ok | 5.58e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | - | 1 | ok | 1.84e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | - | 1 | ok | 0.00e+00 | 0e+00 | | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | - | 1 | ok | 1.04e-04 | 2e-02 | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | - | 1 | ok | 1.60e-03 | 2e-02 | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | - | 1 | ok | 1.68e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | - | 1 | ok | 0.00e+00 | 0e+00 | | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | - | 1 | ok | 2.49e-05 | 2e-02 | | `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | - | 1 | ok | 9.41e-04 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | - | 1 | ok | 3.76e-05 | 2e-02 | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | - | 1 | ok | 1.79e-03 | 2e-02 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | - | 1 | ok | 3.75e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | - | 1 | ok | 1.92e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | - | 1 | ok | 6.82e-05 | 2e-02 | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | - | 1 | ok | 1.82e-03 | 2e-02 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | - | 1 | ok | 7.20e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | - | 1 | ok | 1.71e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | - | 1 | ok | 1.31e-05 | 2e-02 | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | - | 1 | ok | 1.22e-03 | 2e-02 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | - | 1 | ok | 1.30e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | - | 1 | ok | 1.15e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | - | 1 | ok | 5.68e-05 | 2e-02 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | - | 1 | ok | 5.83e-05 | 2e-02 | | `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | - | 1 | ok | 1.79e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | - | 1 | ok | 8.06e-05 | 2e-02 | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | - | 1 | ok | 1.47e-03 | 2e-02 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | - | 1 | ok | 8.03e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | - | 1 | ok | 1.58e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | - | 1 | ok | 0.00e+00 | 0e+00 | | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | - | 1 | ok | 2.16e-05 | 2e-02 | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | - | 1 | ok | 9.77e-04 | 2e-02 | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | - | 1 | ok | 1.06e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | - | 1 | ok | 4.56e-05 | 2e-02 | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | - | 1 | ok | 1.61e-03 | 2e-02 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | - | 1 | ok | 4.67e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | - | 1 | ok | 1.53e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | - | 1 | ok | 8.58e-05 | 2e-02 | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | - | 1 | ok | 1.66e-03 | 2e-02 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | - | 1 | ok | 8.52e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | - | 1 | ok | 1.92e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | - | 1 | ok | 0.00e+00 | 0e+00 | | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | - | 1 | ok | 2.02e-05 | 2e-02 | | `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | - | 1 | ok | 1.68e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | - | 1 | ok | 3.92e-05 | 2e-02 | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | - | 1 | ok | 1.60e-03 | 2e-02 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | - | 1 | ok | 3.86e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | - | 1 | ok | 1.86e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | - | 1 | ok | 9.41e-05 | 2e-02 | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | - | 1 | ok | 1.82e-03 | 2e-02 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | - | 1 | ok | 9.46e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | - | 1 | ok | 1.76e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | - | 1 | ok | 1.66e-05 | 2e-02 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | - | 1 | ok | 1.72e-05 | 2e-02 | | `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | - | 1 | ok | 1.31e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | - | 1 | ok | 3.90e-05 | 2e-02 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | - | 1 | ok | 3.95e-05 | 2e-02 | | `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | - | 1 | ok | 1.59e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | - | 1 | ok | 8.37e-05 | 2e-02 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | - | 1 | ok | 8.58e-05 | 2e-02 | | `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | device | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | - | 1 | ok | 1.69e-03 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | - | 1 | ok | 0.00e+00 | 0e+00 | | `kv_store` | `avx_kv_store` | libavx | host | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | @@ -1551,13 +2152,13 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=64` | - | 1 | ok | 1.04e-04 | 4e-03 | | `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=64` | - | 1 | ok | 1.12e-04 | 4e-03 | | `rmsnorm` | `ref_rmsnorm` | libref | host | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=128` | - | 1 | ok | 1.02e-04 | 4e-03 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=128` | - | 1 | ok | 1.01e-04 | 4e-03 | | `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=128` | - | 1 | ok | 1.03e-04 | 4e-03 | | `rmsnorm` | `ref_rmsnorm` | libref | host | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=256` | - | 1 | ok | 1.22e-04 | 4e-03 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=256` | - | 1 | ok | 1.20e-04 | 4e-03 | | `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=256` | - | 1 | ok | 1.19e-04 | 4e-03 | | `rmsnorm` | `ref_rmsnorm` | libref | host | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=512` | - | 1 | ok | 9.96e-05 | 4e-03 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=512` | - | 1 | ok | 9.66e-05 | 4e-03 | | `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=512` | - | 1 | ok | 1.04e-04 | 4e-03 | | `rmsnorm` | `ref_rmsnorm` | libref | host | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | | `gather_rows` | `avx_gather_rows` | libavx | host | `n=5120 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | @@ -1581,27 +2182,27 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `gather_rows` | `avx_gather_rows` | libavx | host | `n=5120 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | | `gather_rows` | `gather_rows_bf16` | libr4d | device | `n=5120 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | | `gather_rows` | `ref_gather_rows` | libref | host | `n=5120 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `logits_gemm` | `avx_logits_gemm` | libavx | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=1` | - | 1 | ok | 8.22e-07 | 8e-03 | +| `logits_gemm` | `avx_logits_gemm` | libavx | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=1` | - | 1 | ok | 1.58e-03 | 8e-03 | | `logits_gemm` | `logits_gemm_fp8` | libr4d | device | `n_vocab=248320 n_embd=5120 dtype=bf16 M=1` | - | 1 | ok | 1.58e-03 | 8e-03 | -| `logits_gemm` | `ref_logits_gemm` | libref | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `logits_gemm` | `avx_logits_gemm` | libavx | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=2` | - | 1 | ok | 7.62e-07 | 8e-03 | +| `logits_gemm` | `ref_logits_gemm` | libref | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=1` | - | 1 | ok | 1.58e-03 | 8e-03 | +| `logits_gemm` | `avx_logits_gemm` | libavx | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=2` | - | 1 | ok | 1.61e-03 | 8e-03 | | `logits_gemm` | `logits_gemm_fp8` | libr4d | device | `n_vocab=248320 n_embd=5120 dtype=bf16 M=2` | - | 1 | ok | 1.61e-03 | 8e-03 | -| `logits_gemm` | `ref_logits_gemm` | libref | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `logits_gemm` | `avx_logits_gemm` | libavx | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=4` | - | 1 | ok | 7.71e-07 | 8e-03 | +| `logits_gemm` | `ref_logits_gemm` | libref | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=2` | - | 1 | ok | 1.61e-03 | 8e-03 | +| `logits_gemm` | `avx_logits_gemm` | libavx | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=4` | - | 1 | ok | 1.55e-03 | 8e-03 | | `logits_gemm` | `logits_gemm_fp8` | libr4d | device | `n_vocab=248320 n_embd=5120 dtype=bf16 M=4` | - | 1 | ok | 1.55e-03 | 8e-03 | -| `logits_gemm` | `ref_logits_gemm` | libref | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `logits_gemm` | `avx_logits_gemm` | libavx | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=8` | - | 1 | ok | 7.54e-07 | 8e-03 | +| `logits_gemm` | `ref_logits_gemm` | libref | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=4` | - | 1 | ok | 1.55e-03 | 8e-03 | +| `logits_gemm` | `avx_logits_gemm` | libavx | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=8` | - | 1 | ok | 1.62e-03 | 8e-03 | | `logits_gemm` | `logits_gemm_fp8` | libr4d | device | `n_vocab=248320 n_embd=5120 dtype=bf16 M=8` | - | 1 | ok | 1.62e-03 | 8e-03 | -| `logits_gemm` | `ref_logits_gemm` | libref | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `logits_gemm` | `avx_logits_gemm` | libavx | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=16` | - | 1 | ok | 7.35e-07 | 8e-03 | +| `logits_gemm` | `ref_logits_gemm` | libref | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=8` | - | 1 | ok | 1.62e-03 | 8e-03 | +| `logits_gemm` | `avx_logits_gemm` | libavx | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=16` | - | 1 | ok | 1.82e-03 | 8e-03 | | `logits_gemm` | `logits_gemm_fp8` | libr4d | device | `n_vocab=248320 n_embd=5120 dtype=bf16 M=16` | - | 1 | ok | 1.82e-03 | 8e-03 | -| `logits_gemm` | `ref_logits_gemm` | libref | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `logits_gemm` | `avx_logits_gemm` | libavx | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=32` | - | 1 | ok | 9.10e-07 | 8e-03 | +| `logits_gemm` | `ref_logits_gemm` | libref | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=16` | - | 1 | ok | 1.82e-03 | 8e-03 | +| `logits_gemm` | `avx_logits_gemm` | libavx | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=32` | - | 1 | ok | 1.63e-03 | 8e-03 | | `logits_gemm` | `logits_gemm_fp8` | libr4d | device | `n_vocab=248320 n_embd=5120 dtype=bf16 M=32` | - | 1 | ok | 1.63e-03 | 8e-03 | -| `logits_gemm` | `ref_logits_gemm` | libref | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `logits_gemm` | `avx_logits_gemm` | libavx | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=64` | - | 1 | ok | 8.28e-07 | 8e-03 | +| `logits_gemm` | `ref_logits_gemm` | libref | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=32` | - | 1 | ok | 1.63e-03 | 8e-03 | +| `logits_gemm` | `avx_logits_gemm` | libavx | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=64` | - | 1 | ok | 1.63e-03 | 8e-03 | | `logits_gemm` | `logits_gemm_fp8` | libr4d | device | `n_vocab=248320 n_embd=5120 dtype=bf16 M=64` | - | 1 | ok | 1.63e-03 | 8e-03 | -| `logits_gemm` | `ref_logits_gemm` | libref | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `logits_gemm` | `ref_logits_gemm` | libref | host | `n_vocab=248320 n_embd=5120 dtype=bf16 M=64` | - | 1 | ok | 1.63e-03 | 8e-03 | | `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 1 | ok | 0.00e+00 | 2e-02 | | `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | device | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 1 | ok | 0.00e+00 | 2e-02 | | `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | @@ -1686,44 +2287,44 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=25600 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 1e-06 | | `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=25600 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 1e-06 | | `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=25600 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 1.48e-04 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 2.35e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | device | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 1.84e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 5.67e-06 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 5.70e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | device | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 5.43e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 8.81e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 9.07e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | device | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 9.30e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 1.14e-04 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 9.97e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | device | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 6.35e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 6.58e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 1.36e-04 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | device | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 6.53e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 7.46e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 1.20e-04 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | device | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 7.23e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 3.84e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 1.15e-04 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | device | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 4.92e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 4.86e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 1.08e-04 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | device | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 3.64e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=65 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=65 ks=0 bk=0 nt=0` | - | 1 | ok | 4.45e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=65 ks=0 bk=0 nt=0` | - | 1 | ok | 8.94e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=65 ks=0 bk=0 nt=0` | - | 1 | ok | 3.98e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=65 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=128 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=128 ks=0 bk=0 nt=0` | - | 1 | ok | 3.58e-04 | 3e-02 | | `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=128 ks=0 bk=0 nt=0` | - | 1 | ok | 1.60e-04 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=128 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=129 tn=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_tiled` | libr4d | device | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=129 tn=0` | - | 1 | ok | 5.22e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=129 tn=0` | - | 1 | ok | 9.58e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_tiled` | libr4d | device | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=129 tn=0` | - | 1 | ok | 5.38e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=129 tn=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=258 tn=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_tiled` | libr4d | device | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=258 tn=0` | - | 1 | ok | 6.80e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=258 tn=0` | - | 1 | ok | 1.61e-04 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_tiled` | libr4d | device | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=258 tn=0` | - | 1 | ok | 3.21e-04 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=258 tn=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=512 tn=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_tiled` | libr4d | device | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=512 tn=0` | - | 1 | ok | 5.18e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=512 tn=0` | - | 1 | ok | 1.34e-04 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_tiled` | libr4d | device | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=512 tn=0` | - | 1 | ok | 4.88e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=512 tn=0` | - | 1 | ok | 0.00e+00 | 0e+00 | | `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=1` | - | 1 | ok | 1.35e-04 | 4e-03 | | `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=1` | - | 1 | ok | 1.35e-04 | 4e-03 | @@ -1740,19 +2341,19 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=16` | - | 1 | ok | 1.23e-04 | 4e-03 | | `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=16` | - | 1 | ok | 1.23e-04 | 4e-03 | | `rmsnorm` | `ref_rmsnorm` | libref | host | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=32` | - | 1 | ok | 8.15e-05 | 4e-03 | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=32` | - | 1 | ok | 8.04e-05 | 4e-03 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=32` | - | 1 | ok | 8.04e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=32` | - | 1 | ok | 8.15e-05 | 4e-03 | | `rmsnorm` | `ref_rmsnorm` | libref | host | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | | `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=64` | - | 1 | ok | 7.83e-05 | 4e-03 | | `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=64` | - | 1 | ok | 7.83e-05 | 4e-03 | | `rmsnorm` | `ref_rmsnorm` | libref | host | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=128` | - | 1 | ok | 1.38e-04 | 4e-03 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=128` | - | 1 | ok | 1.27e-04 | 4e-03 | | `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=128` | - | 1 | ok | 1.46e-04 | 4e-03 | | `rmsnorm` | `ref_rmsnorm` | libref | host | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=256` | - | 1 | ok | 9.85e-05 | 4e-03 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=256` | - | 1 | ok | 9.73e-05 | 4e-03 | | `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=256` | - | 1 | ok | 9.86e-05 | 4e-03 | | `rmsnorm` | `ref_rmsnorm` | libref | host | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=512` | - | 1 | ok | 1.06e-04 | 4e-03 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=512` | - | 1 | ok | 1.08e-04 | 4e-03 | | `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=512` | - | 1 | ok | 1.06e-04 | 4e-03 | | `rmsnorm` | `ref_rmsnorm` | libref | host | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | | `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=5120 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | @@ -1786,74 +2387,74 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=5120 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 1e-06 | | `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=5120 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | | `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 1.54e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 1.32e-08 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 1.54e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 9.02e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 8.81e-08 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 9.64e-07 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 5.65e-09 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 2.22e-08 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 3.68e-04 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 1.49e-08 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 3.14e-07 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 1.05e-04 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 4.22e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 1.57e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 5.85e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 1.74e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 2.48e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 8.82e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 1.48e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=65 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=65 ks=0 bk=0 nt=0` | - | 1 | ok | 9.62e-06 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=65 ks=0 bk=0 nt=0` | - | 1 | ok | 6.30e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=65 ks=0 bk=0 nt=0` | - | 1 | ok | 1.14e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=65 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=128 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=128 ks=0 bk=0 nt=0` | - | 1 | ok | 2.44e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=128 ks=0 bk=0 nt=0` | - | 1 | ok | 8.04e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=128 ks=0 bk=0 nt=0` | - | 1 | ok | 3.25e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=128 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=129 tn=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_tiled` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=129 tn=0` | - | 1 | ok | 3.30e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=129 tn=0` | - | 1 | ok | 4.34e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_tiled` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=129 tn=0` | - | 1 | ok | 2.39e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=129 tn=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=258 tn=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_tiled` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=258 tn=0` | - | 1 | ok | 6.33e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=258 tn=0` | - | 1 | ok | 7.54e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_tiled` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=258 tn=0` | - | 1 | ok | 5.94e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=258 tn=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=512 tn=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_tiled` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=512 tn=0` | - | 1 | ok | 2.20e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=512 tn=0` | - | 1 | ok | 6.51e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_tiled` | libr4d | device | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=512 tn=0` | - | 1 | ok | 2.78e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=512 tn=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 4e-03 | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 4e-03 | -| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 4e-03 | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 4e-03 | -| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 4e-03 | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 4e-03 | -| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 4e-03 | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 4e-03 | -| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 4e-03 | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 4e-03 | -| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 4e-03 | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 4e-03 | -| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 4e-03 | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 4e-03 | -| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 4e-03 | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=128` | - | 1 | ok | 3.89e-06 | 4e-03 | -| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=256` | - | 1 | ok | 5.47e-06 | 4e-03 | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 4e-03 | -| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 4e-03 | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 4e-03 | -| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=1` | - | 2 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=1` | - | 2 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=1` | - | 2 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=2` | - | 2 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=2` | - | 2 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=2` | - | 2 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=4` | - | 2 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=4` | - | 2 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=4` | - | 2 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=8` | - | 2 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=8` | - | 2 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=8` | - | 2 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=16` | - | 2 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=16` | - | 2 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=16` | - | 2 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=32` | - | 2 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=32` | - | 2 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=32` | - | 2 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=64` | - | 2 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=64` | - | 2 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=64` | - | 2 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=128` | - | 2 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=128` | - | 2 | ok | 3.89e-06 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=128` | - | 2 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=256` | - | 2 | ok | 5.47e-06 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=256` | - | 2 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=256` | - | 2 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=512` | - | 2 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=512` | - | 2 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=512` | - | 2 | ok | 0.00e+00 | 0e+00 | | `rope` | `avx_rope` | libavx | host | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=1` | - | 1 | ok | 0.00e+00 | 2e-03 | | `rope` | `rope_bf16` | libr4d | device | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=1` | - | 1 | ok | 0.00e+00 | 2e-03 | | `rope` | `ref_rope` | libref | host | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | @@ -1914,27 +2515,27 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `kv_store` | `avx_kv_store` | libavx | host | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | | `kv_store` | `kv_store_fp8` | libr4d | device | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | | `kv_store` | `ref_kv_store` | libref | host | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=4096 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=4096 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=4096 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=4096 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=4096 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=4096 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=4096 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=4096 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=4096 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=4096 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=4096 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=4096 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=4096 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=4096 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=4096 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=4096 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=4096 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=4096 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=4096 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=4096 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=4096 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=4096 group=128 dtype=bf16 M=1` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=4096 group=128 dtype=bf16 M=1` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=4096 group=128 dtype=bf16 M=1` | - | 2 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=4096 group=128 dtype=bf16 M=2` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=4096 group=128 dtype=bf16 M=2` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=4096 group=128 dtype=bf16 M=2` | - | 2 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=4096 group=128 dtype=bf16 M=4` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=4096 group=128 dtype=bf16 M=4` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=4096 group=128 dtype=bf16 M=4` | - | 2 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=4096 group=128 dtype=bf16 M=8` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=4096 group=128 dtype=bf16 M=8` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=4096 group=128 dtype=bf16 M=8` | - | 2 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=4096 group=128 dtype=bf16 M=16` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=4096 group=128 dtype=bf16 M=16` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=4096 group=128 dtype=bf16 M=16` | - | 2 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=4096 group=128 dtype=bf16 M=32` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=4096 group=128 dtype=bf16 M=32` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=4096 group=128 dtype=bf16 M=32` | - | 2 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=4096 group=128 dtype=bf16 M=64` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=4096 group=128 dtype=bf16 M=64` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=4096 group=128 dtype=bf16 M=64` | - | 2 | ok | 0.00e+00 | 0e+00 | | `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=17408 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | | `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=17408 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | | `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=17408 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | @@ -1965,116 +2566,116 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1280 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=1280 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 3.80e-07 | 8e-03 | | `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1280 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1280 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 5.39e-07 | 8e-03 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1280 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 2.17e-04 | 8e-03 | | `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=1280 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 6.31e-07 | 8e-03 | | `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1280 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1280 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 6.02e-05 | 8e-03 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1280 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=1280 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 5.49e-05 | 8e-03 | | `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1280 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1280 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 2.40e-05 | 8e-03 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1280 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=1280 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 1.04e-04 | 8e-03 | | `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1280 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1280 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 2.46e-05 | 8e-03 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1280 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=1280 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 8.34e-06 | 8e-03 | | `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1280 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1280 K=5120 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 3.01e-05 | 8e-03 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1280 K=5120 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=1280 K=5120 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 6.58e-05 | 8e-03 | | `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1280 K=5120 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 1.45e-06 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 8.37e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | device | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 9.26e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 1.53e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | device | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 1.51e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 4.55e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 9.45e-06 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | device | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 3.57e-07 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 3.10e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 4.36e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | device | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 3.04e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 2.29e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 6.08e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | device | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 8.50e-06 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 4.50e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 9.27e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | device | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 4.36e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 4.19e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 5.16e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | device | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 3.81e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 2.12e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 4.82e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | device | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 3.45e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 3.63e-07 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 3.75e-07 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | device | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 3.75e-07 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 3.65e-06 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 1.77e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | device | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 3.75e-09 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 2.35e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | device | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 7.21e-07 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 3.04e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 5.11e-06 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | device | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 3.04e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 9.10e-06 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 9.41e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | device | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 4.82e-06 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 5.36e-06 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 5.19e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | device | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 6.08e-06 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 4.19e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 8.11e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | device | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 2.42e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 2.92e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 6.94e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | device | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 3.17e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 3.15e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 2.48e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | device | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 1.58e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 5.94e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 4.63e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | device | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 5.74e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 2.42e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 4.68e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | device | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 4.31e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 8.96e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 3.62e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | device | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 8.96e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 3.57e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 6.97e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | device | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 2.94e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 2.45e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 8.25e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | device | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 2.38e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 4.77e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 3.63e-04 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | device | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 4.18e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 3.54e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 7.10e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | device | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 2.74e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 4.28e-08 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 2.19e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | device | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 9.41e-07 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 2.87e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | device | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 6.56e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 6.72e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | device | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 6.48e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 3.81e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 5.22e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | device | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 3.97e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 8.90e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 1.08e-04 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | device | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 6.41e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 3.97e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 8.85e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | device | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 3.65e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 4.71e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 1.11e-04 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | device | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 5.53e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 3e-02 | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | device | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 4.82e-05 | 3e-02 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 8.92e-05 | 3e-02 | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | device | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 4.92e-05 | 3e-02 | | `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 1 | ok | 0.00e+00 | 0e+00 | | `rope` | `avx_rope` | libavx | host | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=1` | - | 1 | ok | 0.00e+00 | 2e-03 | | `rope` | `rope_bf16` | libr4d | device | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=1` | - | 1 | ok | 0.00e+00 | 2e-03 | @@ -2094,28 +2695,28 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `rope` | `avx_rope` | libavx | host | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=32` | - | 1 | ok | 1.05e-08 | 2e-03 | | `rope` | `rope_bf16` | libr4d | device | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=32` | - | 1 | ok | 1.10e-05 | 2e-03 | | `rope` | `ref_rope` | libref | host | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `rope` | `avx_rope` | libavx | host | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=64` | - | 1 | ok | 3.94e-07 | 2e-03 | -| `rope` | `rope_bf16` | libr4d | device | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=64` | - | 1 | ok | 6.38e-06 | 2e-03 | +| `rope` | `avx_rope` | libavx | host | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=64` | - | 1 | ok | 2.38e-07 | 2e-03 | +| `rope` | `rope_bf16` | libr4d | device | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=64` | - | 1 | ok | 6.39e-06 | 2e-03 | | `rope` | `ref_rope` | libref | host | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `silu_mul` | `avx_silu_mul` | libavx | host | `n=17408 dtype=bf16 M=1` | - | 1 | ok | 2.65e-04 | 6e-03 | +| `silu_mul` | `avx_silu_mul` | libavx | host | `n=17408 dtype=bf16 M=1` | - | 1 | ok | 1.51e-03 | 6e-03 | | `silu_mul` | `silu_mul_bf16` | libr4d | device | `n=17408 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | | `silu_mul` | `ref_silu_mul` | libref | host | `n=17408 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `silu_mul` | `avx_silu_mul` | libavx | host | `n=17408 dtype=bf16 M=2` | - | 1 | ok | 2.49e-04 | 6e-03 | +| `silu_mul` | `avx_silu_mul` | libavx | host | `n=17408 dtype=bf16 M=2` | - | 1 | ok | 4.11e-04 | 6e-03 | | `silu_mul` | `silu_mul_bf16` | libr4d | device | `n=17408 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | | `silu_mul` | `ref_silu_mul` | libref | host | `n=17408 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `silu_mul` | `avx_silu_mul` | libavx | host | `n=17408 dtype=bf16 M=4` | - | 1 | ok | 3.14e-04 | 6e-03 | +| `silu_mul` | `avx_silu_mul` | libavx | host | `n=17408 dtype=bf16 M=4` | - | 1 | ok | 7.01e-04 | 6e-03 | | `silu_mul` | `silu_mul_bf16` | libr4d | device | `n=17408 dtype=bf16 M=4` | - | 1 | ok | 1.22e-05 | 6e-03 | | `silu_mul` | `ref_silu_mul` | libref | host | `n=17408 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `silu_mul` | `avx_silu_mul` | libavx | host | `n=17408 dtype=bf16 M=8` | - | 1 | ok | 5.65e-04 | 6e-03 | +| `silu_mul` | `avx_silu_mul` | libavx | host | `n=17408 dtype=bf16 M=8` | - | 1 | ok | 7.49e-04 | 6e-03 | | `silu_mul` | `silu_mul_bf16` | libr4d | device | `n=17408 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | | `silu_mul` | `ref_silu_mul` | libref | host | `n=17408 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `silu_mul` | `avx_silu_mul` | libavx | host | `n=17408 dtype=bf16 M=16` | - | 1 | ok | 2.54e-04 | 6e-03 | +| `silu_mul` | `avx_silu_mul` | libavx | host | `n=17408 dtype=bf16 M=16` | - | 1 | ok | 4.62e-04 | 6e-03 | | `silu_mul` | `silu_mul_bf16` | libr4d | device | `n=17408 dtype=bf16 M=16` | - | 1 | ok | 6.46e-06 | 6e-03 | | `silu_mul` | `ref_silu_mul` | libref | host | `n=17408 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `silu_mul` | `avx_silu_mul` | libavx | host | `n=17408 dtype=bf16 M=32` | - | 1 | ok | 2.65e-04 | 6e-03 | +| `silu_mul` | `avx_silu_mul` | libavx | host | `n=17408 dtype=bf16 M=32` | - | 1 | ok | 7.60e-04 | 6e-03 | | `silu_mul` | `silu_mul_bf16` | libr4d | device | `n=17408 dtype=bf16 M=32` | - | 1 | ok | 9.34e-06 | 6e-03 | | `silu_mul` | `ref_silu_mul` | libref | host | `n=17408 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `silu_mul` | `avx_silu_mul` | libavx | host | `n=17408 dtype=bf16 M=64` | - | 1 | ok | 2.48e-04 | 6e-03 | +| `silu_mul` | `avx_silu_mul` | libavx | host | `n=17408 dtype=bf16 M=64` | - | 1 | ok | 6.27e-04 | 6e-03 | | `silu_mul` | `silu_mul_bf16` | libr4d | device | `n=17408 dtype=bf16 M=64` | - | 1 | ok | 5.43e-06 | 6e-03 | | `silu_mul` | `ref_silu_mul` | libref | host | `n=17408 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | | `gather_rows` | `avx_gather_rows` | libavx | host | `n=5120 dtype=bf16 M=56` | - | 1 | ok | 0.00e+00 | 0e+00 | @@ -2172,19 +2773,19 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=256 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=256 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt` | `ref_gemm_nt` | libref | host | `N=256 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=256 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 3.95e-05 | 8e-03 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=256 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 2.16e-07 | 8e-03 | | `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=256 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 2.16e-07 | 8e-03 | | `gemm_nt` | `ref_gemm_nt` | libref | host | `N=256 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=256 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 5.44e-05 | 8e-03 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=256 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=256 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 8.43e-07 | 8e-03 | | `gemm_nt` | `ref_gemm_nt` | libref | host | `N=256 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=256 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 6.65e-06 | 8e-03 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=256 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=256 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 2.08e-07 | 8e-03 | | `gemm_nt` | `ref_gemm_nt` | libref | host | `N=256 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=256 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 1.11e-04 | 8e-03 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=256 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=256 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 1.11e-04 | 8e-03 | | `gemm_nt` | `ref_gemm_nt` | libref | host | `N=256 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=256 K=5120 dtype=bf16 M=56 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 1.24e-04 | 8e-03 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=256 K=5120 dtype=bf16 M=56 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=256 K=5120 dtype=bf16 M=56 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 1.29e-04 | 8e-03 | | `gemm_nt` | `ref_gemm_nt` | libref | host | `N=256 K=5120 dtype=bf16 M=56 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | | `dflash_select` | `avx_dflash_select` | libavx | host | `steps=7 top_k=16 rank=256 n_vocab=248320 anchor_stride=8 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | @@ -2211,23 +2812,23 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=1536 dtype=bf16 act=none M=8` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=1536 dtype=bf16 act=none M=8` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1152 K=1536 dtype=bf16 act=none M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=1536 dtype=bf16 act=none M=16` | - | 1 | ok | 2.15e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=1536 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=1536 dtype=bf16 act=none M=16` | - | 1 | ok | 2.17e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1152 K=1536 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | | `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=1536 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=1536 dtype=bf16 act=none M=32` | - | 1 | ok | 2.21e-06 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1152 K=1536 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=1536 dtype=bf16 act=none M=64` | - | 1 | ok | 1.20e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=1536 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=1536 dtype=bf16 act=none M=64` | - | 1 | ok | 1.74e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1152 K=1536 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=1536 dtype=bf16 act=none M=128` | - | 1 | ok | 1.30e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=1536 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=1536 dtype=bf16 act=none M=128` | - | 1 | ok | 1.55e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1152 K=1536 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=1536 dtype=bf16 act=none M=256` | - | 1 | ok | 2.58e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=1536 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=1536 dtype=bf16 act=none M=256` | - | 1 | ok | 6.45e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1152 K=1536 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=1536 dtype=bf16 act=none M=512` | - | 1 | ok | 3.31e-05 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=1536 dtype=bf16 act=none M=512` | - | 1 | ok | 2.86e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=1536 dtype=bf16 act=none M=512` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=1536 dtype=bf16 act=none M=512` | - | 1 | ok | 3.52e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1152 K=1536 dtype=bf16 act=none M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | | `grid_embed` | `avx_grid_embed` | libavx | host | `n=1152 side=48 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | | `grid_embed` | `grid_embed_bf16` | libr4d | device | `n=1152 side=48 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | @@ -2244,19 +2845,19 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `grid_embed` | `avx_grid_embed` | libavx | host | `n=1152 side=48 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | | `grid_embed` | `grid_embed_bf16` | libr4d | device | `n=1152 side=48 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | | `grid_embed` | `ref_grid_embed` | libref | host | `n=1152 side=48 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `grid_embed` | `avx_grid_embed` | libavx | host | `n=1152 side=48 dtype=bf16 M=32` | - | 1 | ok | 7.83e-05 | 6e-03 | +| `grid_embed` | `avx_grid_embed` | libavx | host | `n=1152 side=48 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | | `grid_embed` | `grid_embed_bf16` | libr4d | device | `n=1152 side=48 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | | `grid_embed` | `ref_grid_embed` | libref | host | `n=1152 side=48 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `grid_embed` | `avx_grid_embed` | libavx | host | `n=1152 side=48 dtype=bf16 M=64` | - | 1 | ok | 4.88e-05 | 6e-03 | +| `grid_embed` | `avx_grid_embed` | libavx | host | `n=1152 side=48 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | | `grid_embed` | `grid_embed_bf16` | libr4d | device | `n=1152 side=48 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | | `grid_embed` | `ref_grid_embed` | libref | host | `n=1152 side=48 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `grid_embed` | `avx_grid_embed` | libavx | host | `n=1152 side=48 dtype=bf16 M=128` | - | 1 | ok | 5.29e-05 | 6e-03 | +| `grid_embed` | `avx_grid_embed` | libavx | host | `n=1152 side=48 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | | `grid_embed` | `grid_embed_bf16` | libr4d | device | `n=1152 side=48 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | | `grid_embed` | `ref_grid_embed` | libref | host | `n=1152 side=48 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `grid_embed` | `avx_grid_embed` | libavx | host | `n=1152 side=48 dtype=bf16 M=256` | - | 1 | ok | 4.16e-05 | 6e-03 | +| `grid_embed` | `avx_grid_embed` | libavx | host | `n=1152 side=48 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | | `grid_embed` | `grid_embed_bf16` | libr4d | device | `n=1152 side=48 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | | `grid_embed` | `ref_grid_embed` | libref | host | `n=1152 side=48 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `grid_embed` | `avx_grid_embed` | libavx | host | `n=1152 side=48 dtype=bf16 M=512` | - | 1 | ok | 5.67e-05 | 6e-03 | +| `grid_embed` | `avx_grid_embed` | libavx | host | `n=1152 side=48 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | | `grid_embed` | `grid_embed_bf16` | libr4d | device | `n=1152 side=48 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | | `grid_embed` | `ref_grid_embed` | libref | host | `n=1152 side=48 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | | `layernorm` | `avx_layernorm` | libavx | host | `n=1152 eps=1e-06 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | @@ -2274,19 +2875,19 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `layernorm` | `avx_layernorm` | libavx | host | `n=1152 eps=1e-06 dtype=bf16 M=16` | - | 1 | ok | 4.74e-07 | 6e-03 | | `layernorm` | `layernorm_bf16` | libr4d | device | `n=1152 eps=1e-06 dtype=bf16 M=16` | - | 1 | ok | 4.74e-07 | 6e-03 | | `layernorm` | `ref_layernorm` | libref | host | `n=1152 eps=1e-06 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `layernorm` | `avx_layernorm` | libavx | host | `n=1152 eps=1e-06 dtype=bf16 M=32` | - | 1 | ok | 2.93e-05 | 6e-03 | +| `layernorm` | `avx_layernorm` | libavx | host | `n=1152 eps=1e-06 dtype=bf16 M=32` | - | 1 | ok | 1.42e-05 | 6e-03 | | `layernorm` | `layernorm_bf16` | libr4d | device | `n=1152 eps=1e-06 dtype=bf16 M=32` | - | 1 | ok | 1.46e-05 | 6e-03 | | `layernorm` | `ref_layernorm` | libref | host | `n=1152 eps=1e-06 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `layernorm` | `avx_layernorm` | libavx | host | `n=1152 eps=1e-06 dtype=bf16 M=64` | - | 1 | ok | 2.00e-05 | 6e-03 | +| `layernorm` | `avx_layernorm` | libavx | host | `n=1152 eps=1e-06 dtype=bf16 M=64` | - | 1 | ok | 1.25e-06 | 6e-03 | | `layernorm` | `layernorm_bf16` | libr4d | device | `n=1152 eps=1e-06 dtype=bf16 M=64` | - | 1 | ok | 1.25e-06 | 6e-03 | | `layernorm` | `ref_layernorm` | libref | host | `n=1152 eps=1e-06 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `layernorm` | `avx_layernorm` | libavx | host | `n=1152 eps=1e-06 dtype=bf16 M=128` | - | 1 | ok | 2.12e-05 | 6e-03 | +| `layernorm` | `avx_layernorm` | libavx | host | `n=1152 eps=1e-06 dtype=bf16 M=128` | - | 1 | ok | 2.10e-05 | 6e-03 | | `layernorm` | `layernorm_bf16` | libr4d | device | `n=1152 eps=1e-06 dtype=bf16 M=128` | - | 1 | ok | 2.14e-05 | 6e-03 | | `layernorm` | `ref_layernorm` | libref | host | `n=1152 eps=1e-06 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `layernorm` | `avx_layernorm` | libavx | host | `n=1152 eps=1e-06 dtype=bf16 M=256` | - | 1 | ok | 2.09e-05 | 6e-03 | +| `layernorm` | `avx_layernorm` | libavx | host | `n=1152 eps=1e-06 dtype=bf16 M=256` | - | 1 | ok | 3.50e-05 | 6e-03 | | `layernorm` | `layernorm_bf16` | libr4d | device | `n=1152 eps=1e-06 dtype=bf16 M=256` | - | 1 | ok | 2.11e-05 | 6e-03 | | `layernorm` | `ref_layernorm` | libref | host | `n=1152 eps=1e-06 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `layernorm` | `avx_layernorm` | libavx | host | `n=1152 eps=1e-06 dtype=bf16 M=512` | - | 1 | ok | 2.49e-05 | 6e-03 | +| `layernorm` | `avx_layernorm` | libavx | host | `n=1152 eps=1e-06 dtype=bf16 M=512` | - | 1 | ok | 2.24e-05 | 6e-03 | | `layernorm` | `layernorm_bf16` | libr4d | device | `n=1152 eps=1e-06 dtype=bf16 M=512` | - | 1 | ok | 2.34e-05 | 6e-03 | | `layernorm` | `ref_layernorm` | libref | host | `n=1152 eps=1e-06 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | | `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3456 K=1152 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 8e-03 | @@ -2295,29 +2896,29 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3456 K=1152 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3456 K=1152 dtype=bf16 act=none M=2` | - | 1 | ok | 2.17e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3456 K=1152 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3456 K=1152 dtype=bf16 act=none M=4` | - | 1 | ok | 3.89e-06 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3456 K=1152 dtype=bf16 act=none M=4` | - | 1 | ok | 1.56e-05 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3456 K=1152 dtype=bf16 act=none M=4` | - | 1 | ok | 1.56e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3456 K=1152 dtype=bf16 act=none M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3456 K=1152 dtype=bf16 act=none M=8` | - | 1 | ok | 3.77e-06 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3456 K=1152 dtype=bf16 act=none M=8` | - | 1 | ok | 2.43e-05 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3456 K=1152 dtype=bf16 act=none M=8` | - | 1 | ok | 1.13e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3456 K=1152 dtype=bf16 act=none M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3456 K=1152 dtype=bf16 act=none M=16` | - | 1 | ok | 1.68e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3456 K=1152 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3456 K=1152 dtype=bf16 act=none M=16` | - | 1 | ok | 2.28e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3456 K=1152 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3456 K=1152 dtype=bf16 act=none M=32` | - | 1 | ok | 3.29e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3456 K=1152 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3456 K=1152 dtype=bf16 act=none M=32` | - | 1 | ok | 4.24e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3456 K=1152 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3456 K=1152 dtype=bf16 act=none M=64` | - | 1 | ok | 4.51e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3456 K=1152 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3456 K=1152 dtype=bf16 act=none M=64` | - | 1 | ok | 3.05e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3456 K=1152 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3456 K=1152 dtype=bf16 act=none M=128` | - | 1 | ok | 3.53e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3456 K=1152 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3456 K=1152 dtype=bf16 act=none M=128` | - | 1 | ok | 3.43e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3456 K=1152 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3456 K=1152 dtype=bf16 act=none M=256` | - | 1 | ok | 2.25e-05 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3456 K=1152 dtype=bf16 act=none M=256` | - | 1 | ok | 2.89e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3456 K=1152 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3456 K=1152 dtype=bf16 act=none M=256` | - | 1 | ok | 4.55e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3456 K=1152 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3456 K=1152 dtype=bf16 act=none M=512` | - | 1 | ok | 3.59e-05 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3456 K=1152 dtype=bf16 act=none M=512` | - | 1 | ok | 3.11e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3456 K=1152 dtype=bf16 act=none M=512` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3456 K=1152 dtype=bf16 act=none M=512` | - | 1 | ok | 4.35e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3456 K=1152 dtype=bf16 act=none M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | | `rope` | `avx_rope` | libavx | host | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=1` | - | 1 | ok | 0.00e+00 | 2e-03 | | `rope` | `rope_bf16` | libr4d | device | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=1` | - | 1 | ok | 0.00e+00 | 2e-03 | @@ -2370,10 +2971,10 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `attn_dense` | `avx_attn_dense` | libavx | host | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=64` | - | 1 | ok | 0.00e+00 | 2e-02 | | `attn_dense` | `attn_vit_h72_bf16` | libr4d | device | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=64` | - | 1 | ok | 1.40e-03 | 2e-02 | | `attn_dense` | `ref_attn_dense` | libref | host | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `attn_dense` | `avx_attn_dense` | libavx | host | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=128` | - | 1 | ok | 2.17e-06 | 2e-02 | +| `attn_dense` | `avx_attn_dense` | libavx | host | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=128` | - | 1 | ok | 0.00e+00 | 2e-02 | | `attn_dense` | `attn_vit_h72_bf16` | libr4d | device | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=128` | - | 1 | ok | 1.61e-03 | 2e-02 | | `attn_dense` | `ref_attn_dense` | libref | host | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `attn_dense` | `avx_attn_dense` | libavx | host | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=256` | - | 1 | ok | 4.86e-06 | 2e-02 | +| `attn_dense` | `avx_attn_dense` | libavx | host | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=256` | - | 1 | ok | 1.16e-05 | 2e-02 | | `attn_dense` | `attn_vit_h72_bf16` | libr4d | device | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=256` | - | 1 | ok | 1.56e-03 | 2e-02 | | `attn_dense` | `ref_attn_dense` | libref | host | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | | `attn_dense` | `avx_attn_dense` | libavx | host | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=512` | - | 1 | ok | 7.27e-05 | 2e-02 | @@ -2394,20 +2995,20 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=1152 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=1152 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1152 K=1152 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=1152 dtype=bf16 act=none M=32` | - | 1 | ok | 4.96e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=1152 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=1152 dtype=bf16 act=none M=32` | - | 1 | ok | 4.62e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1152 K=1152 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=1152 dtype=bf16 act=none M=64` | - | 1 | ok | 1.40e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=1152 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=1152 dtype=bf16 act=none M=64` | - | 1 | ok | 1.49e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1152 K=1152 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=1152 dtype=bf16 act=none M=128` | - | 1 | ok | 1.84e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=1152 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=1152 dtype=bf16 act=none M=128` | - | 1 | ok | 4.07e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1152 K=1152 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=1152 dtype=bf16 act=none M=256` | - | 1 | ok | 1.83e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=1152 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=1152 dtype=bf16 act=none M=256` | - | 1 | ok | 1.48e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1152 K=1152 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=1152 dtype=bf16 act=none M=512` | - | 1 | ok | 3.03e-05 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=1152 dtype=bf16 act=none M=512` | - | 1 | ok | 3.52e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=1152 dtype=bf16 act=none M=512` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=1152 dtype=bf16 act=none M=512` | - | 1 | ok | 4.68e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1152 K=1152 dtype=bf16 act=none M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | | `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=1` | - | 1 | ok | 1.71e-04 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=1` | - | 1 | ok | 0.00e+00 | 8e-03 | @@ -2416,28 +3017,28 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=2` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | | `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=4` | - | 1 | ok | 2.46e-06 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=4` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=4` | - | 1 | ok | 2.46e-06 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | | `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=8` | - | 1 | ok | 4.45e-06 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=8` | - | 1 | ok | 3.49e-06 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=8` | - | 1 | ok | 1.33e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=16` | - | 1 | ok | 2.46e-06 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=16` | - | 1 | ok | 1.56e-07 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=16` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=16` | - | 1 | ok | 3.84e-08 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=32` | - | 1 | ok | 8.50e-06 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=32` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=32` | - | 1 | ok | 8.15e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=64` | - | 1 | ok | 4.14e-05 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=64` | - | 1 | ok | 4.34e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=64` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=64` | - | 1 | ok | 4.56e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=128` | - | 1 | ok | 2.26e-05 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=128` | - | 1 | ok | 2.66e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=128` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=128` | - | 1 | ok | 4.17e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=256` | - | 1 | ok | 4.17e-05 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=256` | - | 1 | ok | 3.84e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=256` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=256` | - | 1 | ok | 3.68e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=512` | - | 1 | ok | 3.74e-05 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=512` | - | 1 | ok | 3.75e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=512` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=512` | - | 1 | ok | 4.76e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | | `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=4304 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=4304 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 8e-03 | @@ -2445,89 +3046,89 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=4304 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=4304 dtype=bf16 act=none M=2` | - | 1 | ok | 5.87e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1152 K=4304 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=4304 dtype=bf16 act=none M=4` | - | 1 | ok | 1.27e-04 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=4304 dtype=bf16 act=none M=4` | - | 1 | ok | 8.67e-05 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=4304 dtype=bf16 act=none M=4` | - | 1 | ok | 1.32e-04 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1152 K=4304 dtype=bf16 act=none M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=4304 dtype=bf16 act=none M=8` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=4304 dtype=bf16 act=none M=8` | - | 1 | ok | 1.36e-06 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=4304 dtype=bf16 act=none M=8` | - | 1 | ok | 5.58e-06 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1152 K=4304 dtype=bf16 act=none M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=4304 dtype=bf16 act=none M=16` | - | 1 | ok | 5.71e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=4304 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=4304 dtype=bf16 act=none M=16` | - | 1 | ok | 7.96e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1152 K=4304 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=4304 dtype=bf16 act=none M=32` | - | 1 | ok | 6.39e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=4304 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=4304 dtype=bf16 act=none M=32` | - | 1 | ok | 2.97e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1152 K=4304 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=4304 dtype=bf16 act=none M=64` | - | 1 | ok | 3.79e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=4304 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=4304 dtype=bf16 act=none M=64` | - | 1 | ok | 8.73e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1152 K=4304 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=4304 dtype=bf16 act=none M=128` | - | 1 | ok | 4.64e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=4304 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=4304 dtype=bf16 act=none M=128` | - | 1 | ok | 5.17e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1152 K=4304 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=4304 dtype=bf16 act=none M=256` | - | 1 | ok | 3.50e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=4304 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=4304 dtype=bf16 act=none M=256` | - | 1 | ok | 5.95e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1152 K=4304 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=4304 dtype=bf16 act=none M=512` | - | 1 | ok | 1.25e-04 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=4304 dtype=bf16 act=none M=512` | - | 1 | ok | 5.45e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1152 K=4304 dtype=bf16 act=none M=512` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1152 K=4304 dtype=bf16 act=none M=512` | - | 1 | ok | 5.26e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1152 K=4304 dtype=bf16 act=none M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | | `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4608 K=4608 dtype=bf16 act=gelu M=1` | - | 1 | ok | 0.00e+00 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4608 K=4608 dtype=bf16 act=gelu M=1` | - | 1 | ok | 1.19e-06 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4608 K=4608 dtype=bf16 act=gelu M=1` | - | 1 | ok | 0.00e+00 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=4608 K=4608 dtype=bf16 act=gelu M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | | `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4608 K=4608 dtype=bf16 act=gelu M=2` | - | 1 | ok | 1.72e-04 | 8e-03 | | `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4608 K=4608 dtype=bf16 act=gelu M=2` | - | 1 | ok | 5.46e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=4608 K=4608 dtype=bf16 act=gelu M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4608 K=4608 dtype=bf16 act=gelu M=4` | - | 1 | ok | 4.74e-05 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4608 K=4608 dtype=bf16 act=gelu M=4` | - | 1 | ok | 5.44e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4608 K=4608 dtype=bf16 act=gelu M=4` | - | 1 | ok | 7.59e-05 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4608 K=4608 dtype=bf16 act=gelu M=4` | - | 1 | ok | 4.73e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=4608 K=4608 dtype=bf16 act=gelu M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4608 K=4608 dtype=bf16 act=gelu M=8` | - | 1 | ok | 3.99e-05 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4608 K=4608 dtype=bf16 act=gelu M=8` | - | 1 | ok | 5.42e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4608 K=4608 dtype=bf16 act=gelu M=8` | - | 1 | ok | 2.49e-06 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4608 K=4608 dtype=bf16 act=gelu M=8` | - | 1 | ok | 1.02e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=4608 K=4608 dtype=bf16 act=gelu M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4608 K=4608 dtype=bf16 act=gelu M=16` | - | 1 | ok | 4.94e-05 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4608 K=4608 dtype=bf16 act=gelu M=16` | - | 1 | ok | 4.78e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4608 K=4608 dtype=bf16 act=gelu M=16` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4608 K=4608 dtype=bf16 act=gelu M=16` | - | 1 | ok | 6.43e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=4608 K=4608 dtype=bf16 act=gelu M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4608 K=4608 dtype=bf16 act=gelu M=32` | - | 1 | ok | 7.35e-05 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4608 K=4608 dtype=bf16 act=gelu M=32` | - | 1 | ok | 5.98e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4608 K=4608 dtype=bf16 act=gelu M=32` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4608 K=4608 dtype=bf16 act=gelu M=32` | - | 1 | ok | 7.62e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=4608 K=4608 dtype=bf16 act=gelu M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4608 K=4608 dtype=bf16 act=gelu M=64` | - | 1 | ok | 4.99e-05 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4608 K=4608 dtype=bf16 act=gelu M=64` | - | 1 | ok | 4.52e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4608 K=4608 dtype=bf16 act=gelu M=64` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4608 K=4608 dtype=bf16 act=gelu M=64` | - | 1 | ok | 5.94e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=4608 K=4608 dtype=bf16 act=gelu M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4608 K=4608 dtype=bf16 act=gelu M=128` | - | 1 | ok | 6.17e-05 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4608 K=4608 dtype=bf16 act=gelu M=128` | - | 1 | ok | 5.56e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4608 K=4608 dtype=bf16 act=gelu M=128` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4608 K=4608 dtype=bf16 act=gelu M=128` | - | 1 | ok | 6.96e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=4608 K=4608 dtype=bf16 act=gelu M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4608 K=4608 dtype=bf16 act=gelu M=256` | - | 1 | ok | 6.50e-05 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4608 K=4608 dtype=bf16 act=gelu M=256` | - | 1 | ok | 4.42e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4608 K=4608 dtype=bf16 act=gelu M=256` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4608 K=4608 dtype=bf16 act=gelu M=256` | - | 1 | ok | 6.34e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=4608 K=4608 dtype=bf16 act=gelu M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4608 K=4608 dtype=bf16 act=gelu M=512` | - | 1 | ok | 7.39e-05 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4608 K=4608 dtype=bf16 act=gelu M=512` | - | 1 | ok | 5.50e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=4608 K=4608 dtype=bf16 act=gelu M=512` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=4608 K=4608 dtype=bf16 act=gelu M=512` | - | 1 | ok | 5.79e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=4608 K=4608 dtype=bf16 act=gelu M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | | `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=4608 dtype=bf16 act=none M=1` | - | 1 | ok | 3.29e-06 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=4608 dtype=bf16 act=none M=1` | - | 1 | ok | 3.31e-06 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=4608 dtype=bf16 act=none M=1` | - | 1 | ok | 3.29e-06 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=5120 K=4608 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=4608 dtype=bf16 act=none M=2` | - | 1 | ok | 8.96e-05 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=4608 dtype=bf16 act=none M=2` | - | 1 | ok | 8.96e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=4608 dtype=bf16 act=none M=2` | - | 1 | ok | 3.64e-05 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=4608 dtype=bf16 act=none M=2` | - | 1 | ok | 9.05e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=5120 K=4608 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=4608 dtype=bf16 act=none M=4` | - | 1 | ok | 6.08e-05 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=4608 dtype=bf16 act=none M=4` | - | 1 | ok | 4.02e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=4608 dtype=bf16 act=none M=4` | - | 1 | ok | 6.66e-05 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=4608 dtype=bf16 act=none M=4` | - | 1 | ok | 8.11e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=5120 K=4608 dtype=bf16 act=none M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=4608 dtype=bf16 act=none M=8` | - | 1 | ok | 1.61e-05 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=4608 dtype=bf16 act=none M=8` | - | 1 | ok | 1.91e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=4608 dtype=bf16 act=none M=8` | - | 1 | ok | 3.88e-05 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=4608 dtype=bf16 act=none M=8` | - | 1 | ok | 2.33e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=5120 K=4608 dtype=bf16 act=none M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=4608 dtype=bf16 act=none M=16` | - | 1 | ok | 5.75e-05 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=4608 dtype=bf16 act=none M=16` | - | 1 | ok | 5.42e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=4608 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=4608 dtype=bf16 act=none M=16` | - | 1 | ok | 2.70e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=5120 K=4608 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=4608 dtype=bf16 act=none M=32` | - | 1 | ok | 8.34e-05 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=4608 dtype=bf16 act=none M=32` | - | 1 | ok | 8.01e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=4608 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=4608 dtype=bf16 act=none M=32` | - | 1 | ok | 8.36e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=5120 K=4608 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=4608 dtype=bf16 act=none M=64` | - | 1 | ok | 5.04e-05 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=4608 dtype=bf16 act=none M=64` | - | 1 | ok | 6.18e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=4608 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=4608 dtype=bf16 act=none M=64` | - | 1 | ok | 1.16e-04 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=5120 K=4608 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=4608 dtype=bf16 act=none M=128` | - | 1 | ok | 4.18e-05 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=4608 dtype=bf16 act=none M=128` | - | 1 | ok | 6.17e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=4608 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=4608 dtype=bf16 act=none M=128` | - | 1 | ok | 6.01e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=5120 K=4608 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=4608 dtype=bf16 act=none M=256` | - | 1 | ok | 5.00e-05 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=4608 dtype=bf16 act=none M=256` | - | 1 | ok | 5.00e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=4608 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=4608 dtype=bf16 act=none M=256` | - | 1 | ok | 5.52e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=5120 K=4608 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=4608 dtype=bf16 act=none M=512` | - | 1 | ok | 5.78e-05 | 8e-03 | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=4608 dtype=bf16 act=none M=512` | - | 1 | ok | 6.37e-05 | 8e-03 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=4608 dtype=bf16 act=none M=512` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=4608 dtype=bf16 act=none M=512` | - | 1 | ok | 7.76e-05 | 8e-03 | | `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=5120 K=4608 dtype=bf16 act=none M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | | `sample_penalties` | `avx_sample_penalties` | libavx | host | `n_vocab=248320 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | | `sample_penalties` | `sample_penalties_f32` | libr4d | device | `n_vocab=248320 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | @@ -2655,153 +3256,3003 @@ container and were drawn instead, so the case checks the arithmetic, not the art | `sample_argmax` | `avx_sample_argmax` | libavx | host | `n_vocab=248320 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | | `sample_argmax` | `sample_argmax_f32` | libr4d | device | `n_vocab=248320 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | | `sample_argmax` | `ref_sample_argmax` | libref | host | `n_vocab=248320 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_topp` | `avx_sample_topp` | libavx | host | `n_cand=1024 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_topp` | `sample_topp_f32` | libr4d | device | `n_cand=1024 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_topp` | `ref_sample_topp` | libref | host | `n_cand=1024 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_topp` | `avx_sample_topp` | libavx | host | `n_cand=1024 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_topp` | `sample_topp_f32` | libr4d | device | `n_cand=1024 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_topp` | `ref_sample_topp` | libref | host | `n_cand=1024 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_topp` | `avx_sample_topp` | libavx | host | `n_cand=1024 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_topp` | `sample_topp_f32` | libr4d | device | `n_cand=1024 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_topp` | `ref_sample_topp` | libref | host | `n_cand=1024 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_topp` | `avx_sample_topp` | libavx | host | `n_cand=1024 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_topp` | `sample_topp_f32` | libr4d | device | `n_cand=1024 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_topp` | `ref_sample_topp` | libref | host | `n_cand=1024 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_topp` | `avx_sample_topp` | libavx | host | `n_cand=1024 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_topp` | `sample_topp_f32` | libr4d | device | `n_cand=1024 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_topp` | `ref_sample_topp` | libref | host | `n_cand=1024 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_topp` | `avx_sample_topp` | libavx | host | `n_cand=1024 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_topp` | `sample_topp_f32` | libr4d | device | `n_cand=1024 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_topp` | `ref_sample_topp` | libref | host | `n_cand=1024 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_topp` | `avx_sample_topp` | libavx | host | `n_cand=1024 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_topp` | `sample_topp_f32` | libr4d | device | `n_cand=1024 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_topp` | `ref_sample_topp` | libref | host | `n_cand=1024 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_minp` | `avx_sample_minp` | libavx | host | `n_cand=1024 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_minp` | `sample_minp_f32` | libr4d | device | `n_cand=1024 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_minp` | `ref_sample_minp` | libref | host | `n_cand=1024 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_minp` | `avx_sample_minp` | libavx | host | `n_cand=1024 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_minp` | `sample_minp_f32` | libr4d | device | `n_cand=1024 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_minp` | `ref_sample_minp` | libref | host | `n_cand=1024 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_minp` | `avx_sample_minp` | libavx | host | `n_cand=1024 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_minp` | `sample_minp_f32` | libr4d | device | `n_cand=1024 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_minp` | `ref_sample_minp` | libref | host | `n_cand=1024 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_minp` | `avx_sample_minp` | libavx | host | `n_cand=1024 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_minp` | `sample_minp_f32` | libr4d | device | `n_cand=1024 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_minp` | `ref_sample_minp` | libref | host | `n_cand=1024 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_minp` | `avx_sample_minp` | libavx | host | `n_cand=1024 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_minp` | `sample_minp_f32` | libr4d | device | `n_cand=1024 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_minp` | `ref_sample_minp` | libref | host | `n_cand=1024 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_minp` | `avx_sample_minp` | libavx | host | `n_cand=1024 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_minp` | `sample_minp_f32` | libr4d | device | `n_cand=1024 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_minp` | `ref_sample_minp` | libref | host | `n_cand=1024 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_minp` | `avx_sample_minp` | libavx | host | `n_cand=1024 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_minp` | `sample_minp_f32` | libr4d | device | `n_cand=1024 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_minp` | `ref_sample_minp` | libref | host | `n_cand=1024 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_typical` | `avx_sample_typical` | libavx | host | `n_cand=1024 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_typical` | `sample_typical_f32` | libr4d | device | `n_cand=1024 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_typical` | `ref_sample_typical` | libref | host | `n_cand=1024 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_typical` | `avx_sample_typical` | libavx | host | `n_cand=1024 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_typical` | `sample_typical_f32` | libr4d | device | `n_cand=1024 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_typical` | `ref_sample_typical` | libref | host | `n_cand=1024 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_typical` | `avx_sample_typical` | libavx | host | `n_cand=1024 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_typical` | `sample_typical_f32` | libr4d | device | `n_cand=1024 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_typical` | `ref_sample_typical` | libref | host | `n_cand=1024 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_typical` | `avx_sample_typical` | libavx | host | `n_cand=1024 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_typical` | `sample_typical_f32` | libr4d | device | `n_cand=1024 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_typical` | `ref_sample_typical` | libref | host | `n_cand=1024 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_typical` | `avx_sample_typical` | libavx | host | `n_cand=1024 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_typical` | `sample_typical_f32` | libr4d | device | `n_cand=1024 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_typical` | `ref_sample_typical` | libref | host | `n_cand=1024 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_typical` | `avx_sample_typical` | libavx | host | `n_cand=1024 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_typical` | `sample_typical_f32` | libr4d | device | `n_cand=1024 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_typical` | `ref_sample_typical` | libref | host | `n_cand=1024 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_typical` | `avx_sample_typical` | libavx | host | `n_cand=1024 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_typical` | `sample_typical_f32` | libr4d | device | `n_cand=1024 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_typical` | `ref_sample_typical` | libref | host | `n_cand=1024 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_xtc` | `avx_sample_xtc` | libavx | host | `n_cand=1024 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_xtc` | `sample_xtc_f32` | libr4d | device | `n_cand=1024 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_xtc` | `ref_sample_xtc` | libref | host | `n_cand=1024 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_xtc` | `avx_sample_xtc` | libavx | host | `n_cand=1024 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_xtc` | `sample_xtc_f32` | libr4d | device | `n_cand=1024 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_xtc` | `ref_sample_xtc` | libref | host | `n_cand=1024 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_xtc` | `avx_sample_xtc` | libavx | host | `n_cand=1024 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_xtc` | `sample_xtc_f32` | libr4d | device | `n_cand=1024 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_xtc` | `ref_sample_xtc` | libref | host | `n_cand=1024 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_xtc` | `avx_sample_xtc` | libavx | host | `n_cand=1024 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_xtc` | `sample_xtc_f32` | libr4d | device | `n_cand=1024 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_xtc` | `ref_sample_xtc` | libref | host | `n_cand=1024 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_xtc` | `avx_sample_xtc` | libavx | host | `n_cand=1024 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_xtc` | `sample_xtc_f32` | libr4d | device | `n_cand=1024 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_xtc` | `ref_sample_xtc` | libref | host | `n_cand=1024 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_xtc` | `avx_sample_xtc` | libavx | host | `n_cand=1024 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_xtc` | `sample_xtc_f32` | libr4d | device | `n_cand=1024 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_xtc` | `ref_sample_xtc` | libref | host | `n_cand=1024 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_xtc` | `avx_sample_xtc` | libavx | host | `n_cand=1024 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_xtc` | `sample_xtc_f32` | libr4d | device | `n_cand=1024 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_xtc` | `ref_sample_xtc` | libref | host | `n_cand=1024 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_pick` | `avx_sample_pick` | libavx | host | `n_cand=1024 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_pick` | `sample_pick_f32` | libr4d | device | `n_cand=1024 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_pick` | `ref_sample_pick` | libref | host | `n_cand=1024 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_pick` | `avx_sample_pick` | libavx | host | `n_cand=1024 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_pick` | `sample_pick_f32` | libr4d | device | `n_cand=1024 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_pick` | `ref_sample_pick` | libref | host | `n_cand=1024 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_pick` | `avx_sample_pick` | libavx | host | `n_cand=1024 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_pick` | `sample_pick_f32` | libr4d | device | `n_cand=1024 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_pick` | `ref_sample_pick` | libref | host | `n_cand=1024 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_pick` | `avx_sample_pick` | libavx | host | `n_cand=1024 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_pick` | `sample_pick_f32` | libr4d | device | `n_cand=1024 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_pick` | `ref_sample_pick` | libref | host | `n_cand=1024 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_pick` | `avx_sample_pick` | libavx | host | `n_cand=1024 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_pick` | `sample_pick_f32` | libr4d | device | `n_cand=1024 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_pick` | `ref_sample_pick` | libref | host | `n_cand=1024 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_pick` | `avx_sample_pick` | libavx | host | `n_cand=1024 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_pick` | `sample_pick_f32` | libr4d | device | `n_cand=1024 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_pick` | `ref_sample_pick` | libref | host | `n_cand=1024 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_pick` | `avx_sample_pick` | libavx | host | `n_cand=1024 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_pick` | `sample_pick_f32` | libr4d | device | `n_cand=1024 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_pick` | `ref_sample_pick` | libref | host | `n_cand=1024 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_temp` | `avx_sample_temp` | libavx | host | `n_vocab=1024 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_temp` | `sample_temp_f32` | libr4d | device | `n_vocab=1024 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_temp` | `ref_sample_temp` | libref | host | `n_vocab=1024 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `sample_temp` | `avx_sample_temp` | libavx | host | `n_vocab=1024 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_temp` | `sample_temp_f32` | libr4d | device | `n_vocab=1024 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_temp` | `ref_sample_temp` | libref | host | `n_vocab=1024 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `sample_temp` | `avx_sample_temp` | libavx | host | `n_vocab=1024 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_temp` | `sample_temp_f32` | libr4d | device | `n_vocab=1024 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_temp` | `ref_sample_temp` | libref | host | `n_vocab=1024 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `sample_temp` | `avx_sample_temp` | libavx | host | `n_vocab=1024 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_temp` | `sample_temp_f32` | libr4d | device | `n_vocab=1024 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_temp` | `ref_sample_temp` | libref | host | `n_vocab=1024 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `sample_temp` | `avx_sample_temp` | libavx | host | `n_vocab=1024 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_temp` | `sample_temp_f32` | libr4d | device | `n_vocab=1024 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_temp` | `ref_sample_temp` | libref | host | `n_vocab=1024 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `sample_temp` | `avx_sample_temp` | libavx | host | `n_vocab=1024 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_temp` | `sample_temp_f32` | libr4d | device | `n_vocab=1024 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_temp` | `ref_sample_temp` | libref | host | `n_vocab=1024 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `sample_temp` | `avx_sample_temp` | libavx | host | `n_vocab=1024 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_temp` | `sample_temp_f32` | libr4d | device | `n_vocab=1024 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | -| `sample_temp` | `ref_sample_temp` | libref | host | `n_vocab=1024 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=248320 k=21 M=1` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `sample_topp` | `avx_sample_topp` | libavx | host | `n_cand=1024 M=1` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_topp` | `sample_topp_f32` | libr4d | device | `n_cand=1024 M=1` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_topp` | `ref_sample_topp` | libref | host | `n_cand=1024 M=1` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_topp` | `avx_sample_topp` | libavx | host | `n_cand=1024 M=2` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_topp` | `sample_topp_f32` | libr4d | device | `n_cand=1024 M=2` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_topp` | `ref_sample_topp` | libref | host | `n_cand=1024 M=2` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_topp` | `avx_sample_topp` | libavx | host | `n_cand=1024 M=4` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_topp` | `sample_topp_f32` | libr4d | device | `n_cand=1024 M=4` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_topp` | `ref_sample_topp` | libref | host | `n_cand=1024 M=4` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_topp` | `avx_sample_topp` | libavx | host | `n_cand=1024 M=8` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_topp` | `sample_topp_f32` | libr4d | device | `n_cand=1024 M=8` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_topp` | `ref_sample_topp` | libref | host | `n_cand=1024 M=8` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_topp` | `avx_sample_topp` | libavx | host | `n_cand=1024 M=16` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_topp` | `sample_topp_f32` | libr4d | device | `n_cand=1024 M=16` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_topp` | `ref_sample_topp` | libref | host | `n_cand=1024 M=16` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_topp` | `avx_sample_topp` | libavx | host | `n_cand=1024 M=32` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_topp` | `sample_topp_f32` | libr4d | device | `n_cand=1024 M=32` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_topp` | `ref_sample_topp` | libref | host | `n_cand=1024 M=32` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_topp` | `avx_sample_topp` | libavx | host | `n_cand=1024 M=64` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_topp` | `sample_topp_f32` | libr4d | device | `n_cand=1024 M=64` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_topp` | `ref_sample_topp` | libref | host | `n_cand=1024 M=64` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_minp` | `avx_sample_minp` | libavx | host | `n_cand=1024 M=1` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_minp` | `sample_minp_f32` | libr4d | device | `n_cand=1024 M=1` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_minp` | `ref_sample_minp` | libref | host | `n_cand=1024 M=1` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_minp` | `avx_sample_minp` | libavx | host | `n_cand=1024 M=2` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_minp` | `sample_minp_f32` | libr4d | device | `n_cand=1024 M=2` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_minp` | `ref_sample_minp` | libref | host | `n_cand=1024 M=2` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_minp` | `avx_sample_minp` | libavx | host | `n_cand=1024 M=4` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_minp` | `sample_minp_f32` | libr4d | device | `n_cand=1024 M=4` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_minp` | `ref_sample_minp` | libref | host | `n_cand=1024 M=4` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_minp` | `avx_sample_minp` | libavx | host | `n_cand=1024 M=8` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_minp` | `sample_minp_f32` | libr4d | device | `n_cand=1024 M=8` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_minp` | `ref_sample_minp` | libref | host | `n_cand=1024 M=8` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_minp` | `avx_sample_minp` | libavx | host | `n_cand=1024 M=16` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_minp` | `sample_minp_f32` | libr4d | device | `n_cand=1024 M=16` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_minp` | `ref_sample_minp` | libref | host | `n_cand=1024 M=16` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_minp` | `avx_sample_minp` | libavx | host | `n_cand=1024 M=32` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_minp` | `sample_minp_f32` | libr4d | device | `n_cand=1024 M=32` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_minp` | `ref_sample_minp` | libref | host | `n_cand=1024 M=32` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_minp` | `avx_sample_minp` | libavx | host | `n_cand=1024 M=64` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_minp` | `sample_minp_f32` | libr4d | device | `n_cand=1024 M=64` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_minp` | `ref_sample_minp` | libref | host | `n_cand=1024 M=64` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_typical` | `avx_sample_typical` | libavx | host | `n_cand=1024 M=1` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_typical` | `sample_typical_f32` | libr4d | device | `n_cand=1024 M=1` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_typical` | `ref_sample_typical` | libref | host | `n_cand=1024 M=1` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_typical` | `avx_sample_typical` | libavx | host | `n_cand=1024 M=2` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_typical` | `sample_typical_f32` | libr4d | device | `n_cand=1024 M=2` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_typical` | `ref_sample_typical` | libref | host | `n_cand=1024 M=2` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_typical` | `avx_sample_typical` | libavx | host | `n_cand=1024 M=4` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_typical` | `sample_typical_f32` | libr4d | device | `n_cand=1024 M=4` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_typical` | `ref_sample_typical` | libref | host | `n_cand=1024 M=4` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_typical` | `avx_sample_typical` | libavx | host | `n_cand=1024 M=8` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_typical` | `sample_typical_f32` | libr4d | device | `n_cand=1024 M=8` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_typical` | `ref_sample_typical` | libref | host | `n_cand=1024 M=8` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_typical` | `avx_sample_typical` | libavx | host | `n_cand=1024 M=16` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_typical` | `sample_typical_f32` | libr4d | device | `n_cand=1024 M=16` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_typical` | `ref_sample_typical` | libref | host | `n_cand=1024 M=16` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_typical` | `avx_sample_typical` | libavx | host | `n_cand=1024 M=32` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_typical` | `sample_typical_f32` | libr4d | device | `n_cand=1024 M=32` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_typical` | `ref_sample_typical` | libref | host | `n_cand=1024 M=32` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_typical` | `avx_sample_typical` | libavx | host | `n_cand=1024 M=64` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_typical` | `sample_typical_f32` | libr4d | device | `n_cand=1024 M=64` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_typical` | `ref_sample_typical` | libref | host | `n_cand=1024 M=64` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_xtc` | `avx_sample_xtc` | libavx | host | `n_cand=1024 M=1` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_xtc` | `sample_xtc_f32` | libr4d | device | `n_cand=1024 M=1` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_xtc` | `ref_sample_xtc` | libref | host | `n_cand=1024 M=1` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_xtc` | `avx_sample_xtc` | libavx | host | `n_cand=1024 M=2` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_xtc` | `sample_xtc_f32` | libr4d | device | `n_cand=1024 M=2` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_xtc` | `ref_sample_xtc` | libref | host | `n_cand=1024 M=2` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_xtc` | `avx_sample_xtc` | libavx | host | `n_cand=1024 M=4` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_xtc` | `sample_xtc_f32` | libr4d | device | `n_cand=1024 M=4` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_xtc` | `ref_sample_xtc` | libref | host | `n_cand=1024 M=4` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_xtc` | `avx_sample_xtc` | libavx | host | `n_cand=1024 M=8` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_xtc` | `sample_xtc_f32` | libr4d | device | `n_cand=1024 M=8` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_xtc` | `ref_sample_xtc` | libref | host | `n_cand=1024 M=8` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_xtc` | `avx_sample_xtc` | libavx | host | `n_cand=1024 M=16` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_xtc` | `sample_xtc_f32` | libr4d | device | `n_cand=1024 M=16` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_xtc` | `ref_sample_xtc` | libref | host | `n_cand=1024 M=16` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_xtc` | `avx_sample_xtc` | libavx | host | `n_cand=1024 M=32` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_xtc` | `sample_xtc_f32` | libr4d | device | `n_cand=1024 M=32` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_xtc` | `ref_sample_xtc` | libref | host | `n_cand=1024 M=32` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_xtc` | `avx_sample_xtc` | libavx | host | `n_cand=1024 M=64` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_xtc` | `sample_xtc_f32` | libr4d | device | `n_cand=1024 M=64` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_xtc` | `ref_sample_xtc` | libref | host | `n_cand=1024 M=64` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_pick` | `avx_sample_pick` | libavx | host | `n_cand=1024 M=1` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_pick` | `sample_pick_f32` | libr4d | device | `n_cand=1024 M=1` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_pick` | `ref_sample_pick` | libref | host | `n_cand=1024 M=1` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_pick` | `avx_sample_pick` | libavx | host | `n_cand=1024 M=2` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_pick` | `sample_pick_f32` | libr4d | device | `n_cand=1024 M=2` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_pick` | `ref_sample_pick` | libref | host | `n_cand=1024 M=2` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_pick` | `avx_sample_pick` | libavx | host | `n_cand=1024 M=4` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_pick` | `sample_pick_f32` | libr4d | device | `n_cand=1024 M=4` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_pick` | `ref_sample_pick` | libref | host | `n_cand=1024 M=4` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_pick` | `avx_sample_pick` | libavx | host | `n_cand=1024 M=8` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_pick` | `sample_pick_f32` | libr4d | device | `n_cand=1024 M=8` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_pick` | `ref_sample_pick` | libref | host | `n_cand=1024 M=8` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_pick` | `avx_sample_pick` | libavx | host | `n_cand=1024 M=16` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_pick` | `sample_pick_f32` | libr4d | device | `n_cand=1024 M=16` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_pick` | `ref_sample_pick` | libref | host | `n_cand=1024 M=16` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_pick` | `avx_sample_pick` | libavx | host | `n_cand=1024 M=32` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_pick` | `sample_pick_f32` | libr4d | device | `n_cand=1024 M=32` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_pick` | `ref_sample_pick` | libref | host | `n_cand=1024 M=32` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_pick` | `avx_sample_pick` | libavx | host | `n_cand=1024 M=64` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_pick` | `sample_pick_f32` | libr4d | device | `n_cand=1024 M=64` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_pick` | `ref_sample_pick` | libref | host | `n_cand=1024 M=64` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `avx_sample_temp` | libavx | host | `n_vocab=1024 M=1` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `sample_temp_f32` | libr4d | device | `n_vocab=1024 M=1` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `ref_sample_temp` | libref | host | `n_vocab=1024 M=1` | - | 2 | ok | 0.00e+00 | 0e+00 | +| `sample_temp` | `avx_sample_temp` | libavx | host | `n_vocab=1024 M=2` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `sample_temp_f32` | libr4d | device | `n_vocab=1024 M=2` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `ref_sample_temp` | libref | host | `n_vocab=1024 M=2` | - | 2 | ok | 0.00e+00 | 0e+00 | +| `sample_temp` | `avx_sample_temp` | libavx | host | `n_vocab=1024 M=4` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `sample_temp_f32` | libr4d | device | `n_vocab=1024 M=4` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `ref_sample_temp` | libref | host | `n_vocab=1024 M=4` | - | 2 | ok | 0.00e+00 | 0e+00 | +| `sample_temp` | `avx_sample_temp` | libavx | host | `n_vocab=1024 M=8` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `sample_temp_f32` | libr4d | device | `n_vocab=1024 M=8` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `ref_sample_temp` | libref | host | `n_vocab=1024 M=8` | - | 2 | ok | 0.00e+00 | 0e+00 | +| `sample_temp` | `avx_sample_temp` | libavx | host | `n_vocab=1024 M=16` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `sample_temp_f32` | libr4d | device | `n_vocab=1024 M=16` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `ref_sample_temp` | libref | host | `n_vocab=1024 M=16` | - | 2 | ok | 0.00e+00 | 0e+00 | +| `sample_temp` | `avx_sample_temp` | libavx | host | `n_vocab=1024 M=32` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `sample_temp_f32` | libr4d | device | `n_vocab=1024 M=32` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `ref_sample_temp` | libref | host | `n_vocab=1024 M=32` | - | 2 | ok | 0.00e+00 | 0e+00 | +| `sample_temp` | `avx_sample_temp` | libavx | host | `n_vocab=1024 M=64` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `sample_temp_f32` | libr4d | device | `n_vocab=1024 M=64` | - | 2 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `ref_sample_temp` | libref | host | `n_vocab=1024 M=64` | - | 2 | ok | 0.00e+00 | 0e+00 | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=248320 k=21 M=1` | - | 1 | ok | 6.03e-10 | 1e-05 | | `sample_logprobs` | `sample_logprobs_f32` | libr4d | device | `n_vocab=248320 k=21 M=1` | - | 1 | ok | 0.00e+00 | 1e-05 | | `sample_logprobs` | `ref_sample_logprobs` | libref | host | `n_vocab=248320 k=21 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=248320 k=21 M=2` | - | 1 | ok | 8.62e-10 | 1e-05 | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=248320 k=21 M=2` | - | 1 | ok | 1.34e-09 | 1e-05 | | `sample_logprobs` | `sample_logprobs_f32` | libr4d | device | `n_vocab=248320 k=21 M=2` | - | 1 | ok | 1.09e-09 | 1e-05 | | `sample_logprobs` | `ref_sample_logprobs` | libref | host | `n_vocab=248320 k=21 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=248320 k=21 M=4` | - | 1 | ok | 6.30e-10 | 1e-05 | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=248320 k=21 M=4` | - | 1 | ok | 4.40e-10 | 1e-05 | | `sample_logprobs` | `sample_logprobs_f32` | libr4d | device | `n_vocab=248320 k=21 M=4` | - | 1 | ok | 2.72e-10 | 1e-05 | | `sample_logprobs` | `ref_sample_logprobs` | libref | host | `n_vocab=248320 k=21 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=248320 k=21 M=8` | - | 1 | ok | 9.99e-10 | 1e-05 | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=248320 k=21 M=8` | - | 1 | ok | 1.13e-09 | 1e-05 | | `sample_logprobs` | `sample_logprobs_f32` | libr4d | device | `n_vocab=248320 k=21 M=8` | - | 1 | ok | 5.27e-10 | 1e-05 | | `sample_logprobs` | `ref_sample_logprobs` | libref | host | `n_vocab=248320 k=21 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=248320 k=21 M=16` | - | 1 | ok | 6.26e-10 | 1e-05 | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=248320 k=21 M=16` | - | 1 | ok | 2.17e-09 | 1e-05 | | `sample_logprobs` | `sample_logprobs_f32` | libr4d | device | `n_vocab=248320 k=21 M=16` | - | 1 | ok | 5.67e-10 | 1e-05 | | `sample_logprobs` | `ref_sample_logprobs` | libref | host | `n_vocab=248320 k=21 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=248320 k=21 M=32` | - | 1 | ok | 1.06e-09 | 1e-05 | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=248320 k=21 M=32` | - | 1 | ok | 1.52e-09 | 1e-05 | | `sample_logprobs` | `sample_logprobs_f32` | libr4d | device | `n_vocab=248320 k=21 M=32` | - | 1 | ok | 6.50e-10 | 1e-05 | | `sample_logprobs` | `ref_sample_logprobs` | libref | host | `n_vocab=248320 k=21 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | -| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=248320 k=21 M=64` | - | 1 | ok | 1.21e-09 | 1e-05 | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=248320 k=21 M=64` | - | 1 | ok | 2.13e-09 | 1e-05 | | `sample_logprobs` | `sample_logprobs_f32` | libr4d | device | `n_vocab=248320 k=21 M=64` | - | 1 | ok | 7.06e-10 | 1e-05 | | `sample_logprobs` | `ref_sample_logprobs` | libref | host | `n_vocab=248320 k=21 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `avx_embed_lookup` | libavx | host | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | device | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `ref_embed_lookup` | libref | host | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `avx_embed_lookup` | libavx | host | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | device | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `ref_embed_lookup` | libref | host | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `avx_embed_lookup` | libavx | host | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | device | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `ref_embed_lookup` | libref | host | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `avx_embed_lookup` | libavx | host | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | device | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `ref_embed_lookup` | libref | host | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `avx_embed_lookup` | libavx | host | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | device | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `ref_embed_lookup` | libref | host | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `avx_embed_lookup` | libavx | host | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | device | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `ref_embed_lookup` | libref | host | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `avx_embed_lookup` | libavx | host | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | device | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `ref_embed_lookup` | libref | host | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `avx_embed_lookup` | libavx | host | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | device | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `ref_embed_lookup` | libref | host | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `avx_embed_lookup` | libavx | host | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | device | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `ref_embed_lookup` | libref | host | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `avx_embed_lookup` | libavx | host | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | device | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `ref_embed_lookup` | libref | host | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1280 K=2304 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=1280 K=2304 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1280 K=2304 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1280 K=2304 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 2.63e-05 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=1280 K=2304 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 2.63e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1280 K=2304 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1280 K=2304 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=1280 K=2304 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 4.53e-06 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1280 K=2304 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1280 K=2304 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 6.42e-06 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=1280 K=2304 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 6.40e-06 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1280 K=2304 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1280 K=2304 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=1280 K=2304 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 3.66e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1280 K=2304 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1280 K=2304 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=1280 K=2304 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 9.06e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1280 K=2304 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1280 K=2304 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=1280 K=2304 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 2.62e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1280 K=2304 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1280 K=2304 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=1280 K=2304 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 1.91e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1280 K=2304 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1280 K=2304 dtype=bf16 M=65 tile=0` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | device | `N=1280 K=2304 dtype=bf16 M=65 tile=0` | - | 1 | ok | 8.01e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1280 K=2304 dtype=bf16 M=65 tile=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1280 K=2304 dtype=bf16 M=130 tile=0` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | device | `N=1280 K=2304 dtype=bf16 M=130 tile=0` | - | 1 | ok | 3.94e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1280 K=2304 dtype=bf16 M=130 tile=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1280 K=2304 dtype=bf16 M=260 tile=0` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | device | `N=1280 K=2304 dtype=bf16 M=260 tile=0` | - | 1 | ok | 3.63e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1280 K=2304 dtype=bf16 M=260 tile=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1280 K=2304 dtype=bf16 M=512 tile=0` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | device | `N=1280 K=2304 dtype=bf16 M=512 tile=0` | - | 1 | ok | 3.67e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1280 K=2304 dtype=bf16 M=512 tile=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `grid_embed_cpe` | `avx_grid_embed_cpe` | libavx | host | `n=1280 side=128 n_prefix=10 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `grid_embed_cpe` | `grid_embed_cpe_bf16` | libr4d | device | `n=1280 side=128 n_prefix=10 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `grid_embed_cpe` | `ref_grid_embed_cpe` | libref | host | `n=1280 side=128 n_prefix=10 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `grid_embed_cpe` | `avx_grid_embed_cpe` | libavx | host | `n=1280 side=128 n_prefix=10 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `grid_embed_cpe` | `grid_embed_cpe_bf16` | libr4d | device | `n=1280 side=128 n_prefix=10 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `grid_embed_cpe` | `ref_grid_embed_cpe` | libref | host | `n=1280 side=128 n_prefix=10 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `grid_embed_cpe` | `avx_grid_embed_cpe` | libavx | host | `n=1280 side=128 n_prefix=10 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `grid_embed_cpe` | `grid_embed_cpe_bf16` | libr4d | device | `n=1280 side=128 n_prefix=10 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `grid_embed_cpe` | `ref_grid_embed_cpe` | libref | host | `n=1280 side=128 n_prefix=10 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `grid_embed_cpe` | `avx_grid_embed_cpe` | libavx | host | `n=1280 side=128 n_prefix=10 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `grid_embed_cpe` | `grid_embed_cpe_bf16` | libr4d | device | `n=1280 side=128 n_prefix=10 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `grid_embed_cpe` | `ref_grid_embed_cpe` | libref | host | `n=1280 side=128 n_prefix=10 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `grid_embed_cpe` | `avx_grid_embed_cpe` | libavx | host | `n=1280 side=128 n_prefix=10 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `grid_embed_cpe` | `grid_embed_cpe_bf16` | libr4d | device | `n=1280 side=128 n_prefix=10 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `grid_embed_cpe` | `ref_grid_embed_cpe` | libref | host | `n=1280 side=128 n_prefix=10 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `grid_embed_cpe` | `avx_grid_embed_cpe` | libavx | host | `n=1280 side=128 n_prefix=10 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `grid_embed_cpe` | `grid_embed_cpe_bf16` | libr4d | device | `n=1280 side=128 n_prefix=10 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `grid_embed_cpe` | `ref_grid_embed_cpe` | libref | host | `n=1280 side=128 n_prefix=10 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `grid_embed_cpe` | `avx_grid_embed_cpe` | libavx | host | `n=1280 side=128 n_prefix=10 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `grid_embed_cpe` | `grid_embed_cpe_bf16` | libr4d | device | `n=1280 side=128 n_prefix=10 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `grid_embed_cpe` | `ref_grid_embed_cpe` | libref | host | `n=1280 side=128 n_prefix=10 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `grid_embed_cpe` | `avx_grid_embed_cpe` | libavx | host | `n=1280 side=128 n_prefix=10 dtype=bf16 M=128` | - | 1 | ok | 8.07e-06 | 6e-03 | +| `grid_embed_cpe` | `grid_embed_cpe_bf16` | libr4d | device | `n=1280 side=128 n_prefix=10 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `grid_embed_cpe` | `ref_grid_embed_cpe` | libref | host | `n=1280 side=128 n_prefix=10 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `grid_embed_cpe` | `avx_grid_embed_cpe` | libavx | host | `n=1280 side=128 n_prefix=10 dtype=bf16 M=256` | - | 1 | ok | 1.41e-05 | 6e-03 | +| `grid_embed_cpe` | `grid_embed_cpe_bf16` | libr4d | device | `n=1280 side=128 n_prefix=10 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `grid_embed_cpe` | `ref_grid_embed_cpe` | libref | host | `n=1280 side=128 n_prefix=10 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `grid_embed_cpe` | `avx_grid_embed_cpe` | libavx | host | `n=1280 side=128 n_prefix=10 dtype=bf16 M=512` | - | 1 | ok | 1.04e-04 | 6e-03 | +| `grid_embed_cpe` | `grid_embed_cpe_bf16` | libr4d | device | `n=1280 side=128 n_prefix=10 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `grid_embed_cpe` | `ref_grid_embed_cpe` | libref | host | `n=1280 side=128 n_prefix=10 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `iota` | `avx_iota` | libavx | host | `start=0 step=1 M=1` | - | 1 | vacuous | 0.00e+00 | 2e-02 | +| `iota` | `iota` | libr4d | device | `start=0 step=1 M=1` | - | 1 | vacuous | 0.00e+00 | 2e-02 | +| `iota` | `ref_iota` | libref | host | `start=0 step=1 M=1` | - | 1 | vacuous | 0.00e+00 | 2e-02 | +| `iota` | `avx_iota` | libavx | host | `start=0 step=1 M=2` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `iota` | libr4d | device | `start=0 step=1 M=2` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `ref_iota` | libref | host | `start=0 step=1 M=2` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `avx_iota` | libavx | host | `start=0 step=1 M=4` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `iota` | libr4d | device | `start=0 step=1 M=4` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `ref_iota` | libref | host | `start=0 step=1 M=4` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `avx_iota` | libavx | host | `start=0 step=1 M=8` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `iota` | libr4d | device | `start=0 step=1 M=8` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `ref_iota` | libref | host | `start=0 step=1 M=8` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `avx_iota` | libavx | host | `start=0 step=1 M=16` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `iota` | libr4d | device | `start=0 step=1 M=16` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `ref_iota` | libref | host | `start=0 step=1 M=16` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `avx_iota` | libavx | host | `start=0 step=1 M=32` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `iota` | libr4d | device | `start=0 step=1 M=32` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `ref_iota` | libref | host | `start=0 step=1 M=32` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `avx_iota` | libavx | host | `start=0 step=1 M=64` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `iota` | libr4d | device | `start=0 step=1 M=64` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `ref_iota` | libref | host | `start=0 step=1 M=64` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `avx_iota` | libavx | host | `start=0 step=1 M=128` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `iota` | libr4d | device | `start=0 step=1 M=128` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `ref_iota` | libref | host | `start=0 step=1 M=128` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `avx_iota` | libavx | host | `start=0 step=1 M=256` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `iota` | libr4d | device | `start=0 step=1 M=256` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `ref_iota` | libref | host | `start=0 step=1 M=256` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `avx_iota` | libavx | host | `start=0 step=1 M=512` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `iota` | libr4d | device | `start=0 step=1 M=512` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `iota` | `ref_iota` | libref | host | `start=0 step=1 M=512` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `layernorm` | `avx_layernorm` | libavx | host | `n=1280 eps=1e-06 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `layernorm` | `layernorm_bf16` | libr4d | device | `n=1280 eps=1e-06 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `layernorm` | `ref_layernorm` | libref | host | `n=1280 eps=1e-06 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `layernorm` | `avx_layernorm` | libavx | host | `n=1280 eps=1e-06 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `layernorm` | `layernorm_bf16` | libr4d | device | `n=1280 eps=1e-06 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `layernorm` | `ref_layernorm` | libref | host | `n=1280 eps=1e-06 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `layernorm` | `avx_layernorm` | libavx | host | `n=1280 eps=1e-06 dtype=bf16 M=4` | - | 1 | ok | 1.64e-07 | 6e-03 | +| `layernorm` | `layernorm_bf16` | libr4d | device | `n=1280 eps=1e-06 dtype=bf16 M=4` | - | 1 | ok | 1.64e-07 | 6e-03 | +| `layernorm` | `ref_layernorm` | libref | host | `n=1280 eps=1e-06 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `layernorm` | `avx_layernorm` | libavx | host | `n=1280 eps=1e-06 dtype=bf16 M=8` | - | 1 | ok | 2.61e-08 | 6e-03 | +| `layernorm` | `layernorm_bf16` | libr4d | device | `n=1280 eps=1e-06 dtype=bf16 M=8` | - | 1 | ok | 1.66e-09 | 6e-03 | +| `layernorm` | `ref_layernorm` | libref | host | `n=1280 eps=1e-06 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `layernorm` | `avx_layernorm` | libavx | host | `n=1280 eps=1e-06 dtype=bf16 M=16` | - | 1 | ok | 9.67e-06 | 6e-03 | +| `layernorm` | `layernorm_bf16` | libr4d | device | `n=1280 eps=1e-06 dtype=bf16 M=16` | - | 1 | ok | 9.68e-06 | 6e-03 | +| `layernorm` | `ref_layernorm` | libref | host | `n=1280 eps=1e-06 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `layernorm` | `avx_layernorm` | libavx | host | `n=1280 eps=1e-06 dtype=bf16 M=32` | - | 1 | ok | 2.14e-07 | 6e-03 | +| `layernorm` | `layernorm_bf16` | libr4d | device | `n=1280 eps=1e-06 dtype=bf16 M=32` | - | 1 | ok | 2.14e-07 | 6e-03 | +| `layernorm` | `ref_layernorm` | libref | host | `n=1280 eps=1e-06 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `layernorm` | `avx_layernorm` | libavx | host | `n=1280 eps=1e-06 dtype=bf16 M=64` | - | 1 | ok | 2.85e-06 | 6e-03 | +| `layernorm` | `layernorm_bf16` | libr4d | device | `n=1280 eps=1e-06 dtype=bf16 M=64` | - | 1 | ok | 2.85e-06 | 6e-03 | +| `layernorm` | `ref_layernorm` | libref | host | `n=1280 eps=1e-06 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `layernorm` | `avx_layernorm` | libavx | host | `n=1280 eps=1e-06 dtype=bf16 M=128` | - | 1 | ok | 9.80e-06 | 6e-03 | +| `layernorm` | `layernorm_bf16` | libr4d | device | `n=1280 eps=1e-06 dtype=bf16 M=128` | - | 1 | ok | 9.63e-06 | 6e-03 | +| `layernorm` | `ref_layernorm` | libref | host | `n=1280 eps=1e-06 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `layernorm` | `avx_layernorm` | libavx | host | `n=1280 eps=1e-06 dtype=bf16 M=256` | - | 1 | ok | 1.45e-05 | 6e-03 | +| `layernorm` | `layernorm_bf16` | libr4d | device | `n=1280 eps=1e-06 dtype=bf16 M=256` | - | 1 | ok | 1.48e-05 | 6e-03 | +| `layernorm` | `ref_layernorm` | libref | host | `n=1280 eps=1e-06 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `layernorm` | `avx_layernorm` | libavx | host | `n=1280 eps=1e-06 dtype=bf16 M=512` | - | 1 | ok | 2.64e-05 | 6e-03 | +| `layernorm` | `layernorm_bf16` | libr4d | device | `n=1280 eps=1e-06 dtype=bf16 M=512` | - | 1 | ok | 2.68e-05 | 6e-03 | +| `layernorm` | `ref_layernorm` | libref | host | `n=1280 eps=1e-06 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3840 K=1280 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3840 K=1280 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3840 K=1280 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3840 K=1280 dtype=bf16 act=none M=2` | - | 1 | ok | 7.97e-05 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3840 K=1280 dtype=bf16 act=none M=2` | - | 1 | ok | 7.97e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3840 K=1280 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3840 K=1280 dtype=bf16 act=none M=4` | - | 1 | ok | 1.96e-05 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3840 K=1280 dtype=bf16 act=none M=4` | - | 1 | ok | 1.40e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3840 K=1280 dtype=bf16 act=none M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3840 K=1280 dtype=bf16 act=none M=8` | - | 1 | ok | 1.94e-05 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3840 K=1280 dtype=bf16 act=none M=8` | - | 1 | ok | 4.26e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3840 K=1280 dtype=bf16 act=none M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3840 K=1280 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3840 K=1280 dtype=bf16 act=none M=16` | - | 1 | ok | 6.70e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3840 K=1280 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3840 K=1280 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3840 K=1280 dtype=bf16 act=none M=32` | - | 1 | ok | 3.29e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3840 K=1280 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3840 K=1280 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3840 K=1280 dtype=bf16 act=none M=64` | - | 1 | ok | 4.64e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3840 K=1280 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3840 K=1280 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3840 K=1280 dtype=bf16 act=none M=128` | - | 1 | ok | 4.46e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3840 K=1280 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3840 K=1280 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3840 K=1280 dtype=bf16 act=none M=256` | - | 1 | ok | 3.12e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3840 K=1280 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3840 K=1280 dtype=bf16 act=none M=512` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3840 K=1280 dtype=bf16 act=none M=512` | - | 1 | ok | 4.67e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3840 K=1280 dtype=bf16 act=none M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_dense` | `avx_attn_dense` | libavx | host | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=1` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `attn_dense` | `attn_dense_h80_bf16` | libr4d | device | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=1` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `attn_dense` | `ref_attn_dense` | libref | host | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_dense` | `avx_attn_dense` | libavx | host | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=2` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `attn_dense` | `attn_dense_h80_bf16` | libr4d | device | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=2` | - | 1 | ok | 7.28e-04 | 2e-02 | +| `attn_dense` | `ref_attn_dense` | libref | host | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_dense` | `avx_attn_dense` | libavx | host | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=4` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `attn_dense` | `attn_dense_h80_bf16` | libr4d | device | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=4` | - | 1 | ok | 1.35e-03 | 2e-02 | +| `attn_dense` | `ref_attn_dense` | libref | host | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_dense` | `avx_attn_dense` | libavx | host | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=8` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `attn_dense` | `attn_dense_h80_bf16` | libr4d | device | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=8` | - | 1 | ok | 7.49e-04 | 2e-02 | +| `attn_dense` | `ref_attn_dense` | libref | host | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_dense` | `avx_attn_dense` | libavx | host | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=16` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `attn_dense` | `attn_dense_h80_bf16` | libr4d | device | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=16` | - | 1 | ok | 1.22e-03 | 2e-02 | +| `attn_dense` | `ref_attn_dense` | libref | host | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_dense` | `avx_attn_dense` | libavx | host | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=32` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `attn_dense` | `attn_dense_h80_bf16` | libr4d | device | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=32` | - | 1 | ok | 1.29e-03 | 2e-02 | +| `attn_dense` | `ref_attn_dense` | libref | host | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_dense` | `avx_attn_dense` | libavx | host | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=64` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `attn_dense` | `attn_dense_h80_bf16` | libr4d | device | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=64` | - | 1 | ok | 1.41e-03 | 2e-02 | +| `attn_dense` | `ref_attn_dense` | libref | host | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_dense` | `avx_attn_dense` | libavx | host | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=128` | - | 1 | ok | 1.67e-05 | 2e-02 | +| `attn_dense` | `attn_dense_h80_bf16` | libr4d | device | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=128` | - | 1 | ok | 1.56e-03 | 2e-02 | +| `attn_dense` | `ref_attn_dense` | libref | host | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_dense` | `avx_attn_dense` | libavx | host | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=256` | - | 1 | ok | 2.60e-05 | 2e-02 | +| `attn_dense` | `attn_dense_h80_bf16` | libr4d | device | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=256` | - | 1 | ok | 1.56e-03 | 2e-02 | +| `attn_dense` | `ref_attn_dense` | libref | host | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_dense` | `avx_attn_dense` | libavx | host | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=512` | - | 1 | ok | 3.62e-06 | 2e-02 | +| `attn_dense` | `attn_dense_h80_bf16` | libr4d | device | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=512` | - | 1 | ok | 1.88e-03 | 2e-02 | +| `attn_dense` | `ref_attn_dense` | libref | host | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1280 K=1280 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1280 K=1280 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1280 K=1280 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1280 K=1280 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1280 K=1280 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1280 K=1280 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1280 K=1280 dtype=bf16 act=none M=4` | - | 1 | ok | 3.77e-07 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1280 K=1280 dtype=bf16 act=none M=4` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1280 K=1280 dtype=bf16 act=none M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1280 K=1280 dtype=bf16 act=none M=8` | - | 1 | ok | 2.15e-06 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1280 K=1280 dtype=bf16 act=none M=8` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1280 K=1280 dtype=bf16 act=none M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1280 K=1280 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1280 K=1280 dtype=bf16 act=none M=16` | - | 1 | ok | 1.21e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1280 K=1280 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1280 K=1280 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1280 K=1280 dtype=bf16 act=none M=32` | - | 1 | ok | 5.06e-06 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1280 K=1280 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1280 K=1280 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1280 K=1280 dtype=bf16 act=none M=64` | - | 1 | ok | 1.40e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1280 K=1280 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1280 K=1280 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1280 K=1280 dtype=bf16 act=none M=128` | - | 1 | ok | 5.59e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1280 K=1280 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1280 K=1280 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1280 K=1280 dtype=bf16 act=none M=256` | - | 1 | ok | 1.58e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1280 K=1280 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1280 K=1280 dtype=bf16 act=none M=512` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1280 K=1280 dtype=bf16 act=none M=512` | - | 1 | ok | 4.18e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1280 K=1280 dtype=bf16 act=none M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=1280 dtype=bf16 act=gelu M=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=1280 dtype=bf16 act=gelu M=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=5120 K=1280 dtype=bf16 act=gelu M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=1280 dtype=bf16 act=gelu M=2` | - | 1 | ok | 3.83e-07 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=1280 dtype=bf16 act=gelu M=2` | - | 1 | ok | 1.24e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=5120 K=1280 dtype=bf16 act=gelu M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=1280 dtype=bf16 act=gelu M=4` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=1280 dtype=bf16 act=gelu M=4` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=5120 K=1280 dtype=bf16 act=gelu M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=1280 dtype=bf16 act=gelu M=8` | - | 1 | ok | 7.60e-07 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=1280 dtype=bf16 act=gelu M=8` | - | 1 | ok | 1.66e-06 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=5120 K=1280 dtype=bf16 act=gelu M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=1280 dtype=bf16 act=gelu M=16` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=1280 dtype=bf16 act=gelu M=16` | - | 1 | ok | 6.81e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=5120 K=1280 dtype=bf16 act=gelu M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=1280 dtype=bf16 act=gelu M=32` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=1280 dtype=bf16 act=gelu M=32` | - | 1 | ok | 8.48e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=5120 K=1280 dtype=bf16 act=gelu M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=1280 dtype=bf16 act=gelu M=64` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=1280 dtype=bf16 act=gelu M=64` | - | 1 | ok | 4.30e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=5120 K=1280 dtype=bf16 act=gelu M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=1280 dtype=bf16 act=gelu M=128` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=1280 dtype=bf16 act=gelu M=128` | - | 1 | ok | 4.86e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=5120 K=1280 dtype=bf16 act=gelu M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=1280 dtype=bf16 act=gelu M=256` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=1280 dtype=bf16 act=gelu M=256` | - | 1 | ok | 3.61e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=5120 K=1280 dtype=bf16 act=gelu M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=5120 K=1280 dtype=bf16 act=gelu M=512` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=5120 K=1280 dtype=bf16 act=gelu M=512` | - | 1 | ok | 4.30e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=5120 K=1280 dtype=bf16 act=gelu M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1280 K=5120 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1280 K=5120 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1280 K=5120 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1280 K=5120 dtype=bf16 act=none M=2` | - | 1 | ok | 8.89e-06 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1280 K=5120 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1280 K=5120 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1280 K=5120 dtype=bf16 act=none M=4` | - | 1 | ok | 1.21e-05 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1280 K=5120 dtype=bf16 act=none M=4` | - | 1 | ok | 1.21e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1280 K=5120 dtype=bf16 act=none M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1280 K=5120 dtype=bf16 act=none M=8` | - | 1 | ok | 6.99e-05 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1280 K=5120 dtype=bf16 act=none M=8` | - | 1 | ok | 7.33e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1280 K=5120 dtype=bf16 act=none M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1280 K=5120 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1280 K=5120 dtype=bf16 act=none M=16` | - | 1 | ok | 4.91e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1280 K=5120 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1280 K=5120 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1280 K=5120 dtype=bf16 act=none M=32` | - | 1 | ok | 9.53e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1280 K=5120 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1280 K=5120 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1280 K=5120 dtype=bf16 act=none M=64` | - | 1 | ok | 2.17e-04 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1280 K=5120 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1280 K=5120 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1280 K=5120 dtype=bf16 act=none M=128` | - | 1 | ok | 3.84e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1280 K=5120 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1280 K=5120 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1280 K=5120 dtype=bf16 act=none M=256` | - | 1 | ok | 7.04e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1280 K=5120 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1280 K=5120 dtype=bf16 act=none M=512` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1280 K=5120 dtype=bf16 act=none M=512` | - | 1 | ok | 1.11e-04 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1280 K=5120 dtype=bf16 act=none M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `avx_gather_rows` | libavx | host | `n=1280 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `gather_rows_bf16` | libr4d | device | `n=1280 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `ref_gather_rows` | libref | host | `n=1280 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `avx_gather_rows` | libavx | host | `n=1280 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `gather_rows_bf16` | libr4d | device | `n=1280 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `ref_gather_rows` | libref | host | `n=1280 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `avx_gather_rows` | libavx | host | `n=1280 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `gather_rows_bf16` | libr4d | device | `n=1280 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `ref_gather_rows` | libref | host | `n=1280 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `avx_gather_rows` | libavx | host | `n=1280 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `gather_rows_bf16` | libr4d | device | `n=1280 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `ref_gather_rows` | libref | host | `n=1280 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `avx_gather_rows` | libavx | host | `n=1280 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `gather_rows_bf16` | libr4d | device | `n=1280 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `ref_gather_rows` | libref | host | `n=1280 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `avx_gather_rows` | libavx | host | `n=1280 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `gather_rows_bf16` | libr4d | device | `n=1280 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `ref_gather_rows` | libref | host | `n=1280 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `avx_gather_rows` | libavx | host | `n=1280 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `gather_rows_bf16` | libr4d | device | `n=1280 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `ref_gather_rows` | libref | host | `n=1280 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `avx_gather_rows` | libavx | host | `n=1280 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `gather_rows_bf16` | libr4d | device | `n=1280 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `ref_gather_rows` | libref | host | `n=1280 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `avx_gather_rows` | libavx | host | `n=1280 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `gather_rows_bf16` | libr4d | device | `n=1280 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `ref_gather_rows` | libref | host | `n=1280 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `avx_gather_rows` | libavx | host | `n=1280 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `gather_rows_bf16` | libr4d | device | `n=1280 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `ref_gather_rows` | libref | host | `n=1280 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-05 dtype=bf16 M=1` | - | 1 | ok | 5.45e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=5120 eps=1e-05 dtype=bf16 M=1` | - | 1 | ok | 5.45e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=5120 eps=1e-05 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-05 dtype=bf16 M=2` | - | 1 | ok | 3.10e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=5120 eps=1e-05 dtype=bf16 M=2` | - | 1 | ok | 3.10e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=5120 eps=1e-05 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-05 dtype=bf16 M=4` | - | 1 | ok | 1.57e-04 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=5120 eps=1e-05 dtype=bf16 M=4` | - | 1 | ok | 1.57e-04 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=5120 eps=1e-05 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-05 dtype=bf16 M=8` | - | 1 | ok | 7.75e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=5120 eps=1e-05 dtype=bf16 M=8` | - | 1 | ok | 7.75e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=5120 eps=1e-05 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-05 dtype=bf16 M=16` | - | 1 | ok | 9.75e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=5120 eps=1e-05 dtype=bf16 M=16` | - | 1 | ok | 9.80e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=5120 eps=1e-05 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-05 dtype=bf16 M=32` | - | 1 | ok | 5.04e-04 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=5120 eps=1e-05 dtype=bf16 M=32` | - | 1 | ok | 5.04e-04 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=5120 eps=1e-05 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-05 dtype=bf16 M=64` | - | 1 | ok | 7.12e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=5120 eps=1e-05 dtype=bf16 M=64` | - | 1 | ok | 8.21e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=5120 eps=1e-05 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-05 dtype=bf16 M=128` | - | 1 | ok | 9.77e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=5120 eps=1e-05 dtype=bf16 M=128` | - | 1 | ok | 9.97e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=5120 eps=1e-05 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-05 dtype=bf16 M=256` | - | 1 | ok | 1.10e-04 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=5120 eps=1e-05 dtype=bf16 M=256` | - | 1 | ok | 1.14e-04 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=5120 eps=1e-05 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=5120 eps=1e-05 dtype=bf16 M=512` | - | 1 | ok | 1.20e-04 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=5120 eps=1e-05 dtype=bf16 M=512` | - | 1 | ok | 1.19e-04 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=5120 eps=1e-05 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=20480 K=5120 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 4.70e-05 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=20480 K=5120 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 8.45e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=20480 K=5120 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=20480 K=5120 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 3.17e-05 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=20480 K=5120 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 3.13e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=20480 K=5120 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=20480 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 5.50e-05 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=20480 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 6.86e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=20480 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=20480 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 6.81e-05 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=20480 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 5.77e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=20480 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=20480 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=20480 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 6.53e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=20480 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=20480 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=20480 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 1.05e-04 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=20480 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=20480 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=20480 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 8.20e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=20480 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=20480 K=5120 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=20480 K=5120 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 6.98e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=20480 K=5120 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=20480 K=5120 dtype=bf16 M=65 tile=0` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | device | `N=20480 K=5120 dtype=bf16 M=65 tile=0` | - | 1 | ok | 2.21e-04 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=20480 K=5120 dtype=bf16 M=65 tile=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=20480 K=5120 dtype=bf16 M=130 tile=0` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | device | `N=20480 K=5120 dtype=bf16 M=130 tile=0` | - | 1 | ok | 4.45e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=20480 K=5120 dtype=bf16 M=130 tile=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=20480 K=5120 dtype=bf16 M=260 tile=0` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | device | `N=20480 K=5120 dtype=bf16 M=260 tile=0` | - | 1 | ok | 6.44e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=20480 K=5120 dtype=bf16 M=260 tile=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=20480 K=5120 dtype=bf16 M=512 tile=0` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | device | `N=20480 K=5120 dtype=bf16 M=512 tile=0` | - | 1 | ok | 5.10e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=20480 K=5120 dtype=bf16 M=512 tile=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=20480 act=relu dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=20480 act=relu dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=20480 act=relu dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=20480 act=relu dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=20480 act=relu dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=20480 act=relu dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=20480 act=relu dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=20480 act=relu dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=20480 act=relu dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=20480 act=relu dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=20480 act=relu dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=20480 act=relu dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=20480 act=relu dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=20480 act=relu dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=20480 act=relu dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=20480 act=relu dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=20480 act=relu dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=20480 act=relu dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=20480 act=relu dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=20480 act=relu dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=20480 act=relu dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=20480 act=relu dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=20480 act=relu dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=20480 act=relu dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=20480 act=relu dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=20480 act=relu dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=20480 act=relu dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=20480 act=relu dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=20480 act=relu dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=20480 act=relu dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=4096 K=20480 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 2.71e-05 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=4096 K=20480 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 6.19e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=4096 K=20480 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=4096 K=20480 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 7.54e-05 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=4096 K=20480 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 1.94e-04 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=4096 K=20480 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=4096 K=20480 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 1.34e-04 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=4096 K=20480 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 1.71e-04 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=4096 K=20480 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=4096 K=20480 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 8.43e-05 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=4096 K=20480 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 1.29e-04 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=4096 K=20480 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=4096 K=20480 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=4096 K=20480 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 1.56e-04 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=4096 K=20480 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=4096 K=20480 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=4096 K=20480 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 1.50e-04 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=4096 K=20480 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=4096 K=20480 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=4096 K=20480 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 1.46e-04 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=4096 K=20480 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=4096 K=20480 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=4096 K=20480 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 1.34e-04 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=4096 K=20480 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=4096 K=20480 dtype=bf16 M=65 tile=0` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | device | `N=4096 K=20480 dtype=bf16 M=65 tile=0` | - | 1 | ok | 1.14e-04 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=4096 K=20480 dtype=bf16 M=65 tile=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=4096 K=20480 dtype=bf16 M=130 tile=0` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | device | `N=4096 K=20480 dtype=bf16 M=130 tile=0` | - | 1 | ok | 1.46e-04 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=4096 K=20480 dtype=bf16 M=130 tile=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=4096 K=20480 dtype=bf16 M=260 tile=0` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | device | `N=4096 K=20480 dtype=bf16 M=260 tile=0` | - | 1 | ok | 1.58e-04 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=4096 K=20480 dtype=bf16 M=260 tile=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=4096 K=20480 dtype=bf16 M=512 tile=0` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | device | `N=4096 K=20480 dtype=bf16 M=512 tile=0` | - | 1 | ok | 1.35e-04 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=4096 K=20480 dtype=bf16 M=512 tile=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `avx_scatter_rows` | libavx | host | `n=4096 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | device | `n=4096 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `ref_scatter_rows` | libref | host | `n=4096 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `avx_scatter_rows` | libavx | host | `n=4096 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | device | `n=4096 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `ref_scatter_rows` | libref | host | `n=4096 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `avx_scatter_rows` | libavx | host | `n=4096 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | device | `n=4096 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `ref_scatter_rows` | libref | host | `n=4096 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `avx_scatter_rows` | libavx | host | `n=4096 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | device | `n=4096 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `ref_scatter_rows` | libref | host | `n=4096 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `avx_scatter_rows` | libavx | host | `n=4096 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | device | `n=4096 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `ref_scatter_rows` | libref | host | `n=4096 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `avx_scatter_rows` | libavx | host | `n=4096 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | device | `n=4096 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `ref_scatter_rows` | libref | host | `n=4096 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `avx_scatter_rows` | libavx | host | `n=4096 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | device | `n=4096 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `ref_scatter_rows` | libref | host | `n=4096 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `avx_scatter_rows` | libavx | host | `n=4096 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | device | `n=4096 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `ref_scatter_rows` | libref | host | `n=4096 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `avx_scatter_rows` | libavx | host | `n=4096 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | device | `n=4096 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `ref_scatter_rows` | libref | host | `n=4096 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `avx_scatter_rows` | libavx | host | `n=4096 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | device | `n=4096 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `scatter_rows` | `ref_scatter_rows` | libref | host | `n=4096 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `cast` | `avx_cast` | libavx | host | `n=4096 from=bf16 to=bf16 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `cast` | `cast_bf16_bf16` | libr4d | device | `n=4096 from=bf16 to=bf16 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `cast` | `ref_cast` | libref | host | `n=4096 from=bf16 to=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `cast` | `avx_cast` | libavx | host | `n=4096 from=bf16 to=bf16 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `cast` | `cast_bf16_bf16` | libr4d | device | `n=4096 from=bf16 to=bf16 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `cast` | `ref_cast` | libref | host | `n=4096 from=bf16 to=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `cast` | `avx_cast` | libavx | host | `n=4096 from=bf16 to=bf16 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `cast` | `cast_bf16_bf16` | libr4d | device | `n=4096 from=bf16 to=bf16 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `cast` | `ref_cast` | libref | host | `n=4096 from=bf16 to=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `cast` | `avx_cast` | libavx | host | `n=4096 from=bf16 to=bf16 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `cast` | `cast_bf16_bf16` | libr4d | device | `n=4096 from=bf16 to=bf16 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `cast` | `ref_cast` | libref | host | `n=4096 from=bf16 to=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `cast` | `avx_cast` | libavx | host | `n=4096 from=bf16 to=bf16 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `cast` | `cast_bf16_bf16` | libr4d | device | `n=4096 from=bf16 to=bf16 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `cast` | `ref_cast` | libref | host | `n=4096 from=bf16 to=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `cast` | `avx_cast` | libavx | host | `n=4096 from=bf16 to=bf16 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `cast` | `cast_bf16_bf16` | libr4d | device | `n=4096 from=bf16 to=bf16 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `cast` | `ref_cast` | libref | host | `n=4096 from=bf16 to=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `cast` | `avx_cast` | libavx | host | `n=4096 from=bf16 to=bf16 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `cast` | `cast_bf16_bf16` | libr4d | device | `n=4096 from=bf16 to=bf16 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `cast` | `ref_cast` | libref | host | `n=4096 from=bf16 to=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `cast` | `avx_cast` | libavx | host | `n=4096 from=bf16 to=bf16 M=128` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `cast` | `cast_bf16_bf16` | libr4d | device | `n=4096 from=bf16 to=bf16 M=128` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `cast` | `ref_cast` | libref | host | `n=4096 from=bf16 to=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `cast` | `avx_cast` | libavx | host | `n=4096 from=bf16 to=bf16 M=256` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `cast` | `cast_bf16_bf16` | libr4d | device | `n=4096 from=bf16 to=bf16 M=256` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `cast` | `ref_cast` | libref | host | `n=4096 from=bf16 to=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `cast` | `avx_cast` | libavx | host | `n=4096 from=bf16 to=bf16 M=512` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `cast` | `cast_bf16_bf16` | libr4d | device | `n=4096 from=bf16 to=bf16 M=512` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `cast` | `ref_cast` | libref | host | `n=4096 from=bf16 to=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | host | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=1` | - | 1 | ok | 3.55e-05 | 4e-03 | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | device | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=1` | - | 1 | ok | 3.55e-05 | 4e-03 | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | host | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | host | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=2` | - | 1 | ok | 1.03e-04 | 4e-03 | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | device | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=2` | - | 1 | ok | 1.03e-04 | 4e-03 | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | host | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | host | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=4` | - | 1 | ok | 4.78e-04 | 4e-03 | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | device | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=4` | - | 1 | ok | 4.78e-04 | 4e-03 | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | host | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | host | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=8` | - | 1 | ok | 8.95e-04 | 4e-03 | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | device | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=8` | - | 1 | ok | 8.95e-04 | 4e-03 | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | host | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | host | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=16` | - | 1 | ok | 1.84e-04 | 4e-03 | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | device | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=16` | - | 1 | ok | 1.84e-04 | 4e-03 | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | host | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | host | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=32` | - | 1 | ok | 1.07e-03 | 4e-03 | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | device | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=32` | - | 1 | ok | 1.07e-03 | 4e-03 | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | host | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | host | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=64` | - | 1 | ok | 4.68e-04 | 4e-03 | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | device | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=64` | - | 1 | ok | 5.07e-04 | 4e-03 | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | host | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | host | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=128` | - | 1 | ok | 6.89e-04 | 4e-03 | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | device | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=128` | - | 1 | ok | 7.26e-04 | 4e-03 | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | host | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | host | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=256` | - | 1 | ok | 6.77e-04 | 4e-03 | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | device | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=256` | - | 1 | ok | 6.78e-04 | 4e-03 | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | host | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | host | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=512` | - | 1 | ok | 7.39e-04 | 4e-03 | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | device | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=512` | - | 1 | ok | 7.46e-04 | 4e-03 | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | host | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 4.40e-06 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=8192 K=4096 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 6.01e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=8192 K=4096 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 4.50e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 2.64e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=8192 K=4096 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 8.53e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 4.28e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=8192 K=4096 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 1.75e-07 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 8.05e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=8192 K=4096 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 1.08e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 4.42e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=8192 K=4096 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 9.90e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 5.56e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=8192 K=4096 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 2.43e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 7.55e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=8192 K=4096 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 1.43e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 8.29e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=8192 K=4096 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 2.35e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 7.39e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=8192 K=4096 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 1.14e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 6.66e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=8192 K=4096 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 1.41e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 8.18e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=8192 K=4096 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 2.04e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 8.20e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=8192 K=4096 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 2.80e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 7.12e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=8192 K=4096 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 1.88e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=8192 K=4096 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 1.54e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=10240 K=4096 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 5.32e-06 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=10240 K=4096 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 2.46e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 1.69e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=10240 K=4096 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 1.22e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 4.27e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=10240 K=4096 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 1.93e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 8.96e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=10240 K=4096 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 1.93e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 1.82e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=10240 K=4096 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 7.44e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 6.20e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=10240 K=4096 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 9.47e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 6.81e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=10240 K=4096 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 1.17e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 7.84e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=10240 K=4096 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 1.63e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 8.52e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=10240 K=4096 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 1.60e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 5.94e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=10240 K=4096 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 1.93e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 5.98e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=10240 K=4096 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 2.30e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 3.69e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=10240 K=4096 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 1.88e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 8.43e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=10240 K=4096 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 1.80e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=10240 K=4096 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=128 K=4096 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=128 K=4096 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=128 K=4096 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=128 K=4096 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=128 K=4096 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=128 K=4096 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=128 K=4096 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=128 K=4096 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=128 K=4096 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=128 K=4096 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=128 K=4096 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=128 K=4096 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=128 K=4096 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=128 K=4096 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 3.34e-07 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=128 K=4096 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=128 K=4096 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=128 K=4096 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 1.05e-08 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=128 K=4096 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=128 K=4096 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=128 K=4096 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 7.67e-06 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=128 K=4096 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=128 K=4096 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=128 K=4096 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 3.35e-07 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=128 K=4096 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=128 K=4096 dtype=bf16 M=65 tile=0` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | device | `N=128 K=4096 dtype=bf16 M=65 tile=0` | - | 1 | ok | 2.19e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=128 K=4096 dtype=bf16 M=65 tile=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=128 K=4096 dtype=bf16 M=130 tile=0` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | device | `N=128 K=4096 dtype=bf16 M=130 tile=0` | - | 1 | ok | 3.08e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=128 K=4096 dtype=bf16 M=130 tile=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=128 K=4096 dtype=bf16 M=260 tile=0` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | device | `N=128 K=4096 dtype=bf16 M=260 tile=0` | - | 1 | ok | 4.36e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=128 K=4096 dtype=bf16 M=260 tile=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=128 K=4096 dtype=bf16 M=512 tile=0` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | device | `N=128 K=4096 dtype=bf16 M=512 tile=0` | - | 1 | ok | 3.54e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=128 K=4096 dtype=bf16 M=512 tile=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `ple_conv_bias` | `avx_ple_conv_bias` | libavx | host | `n=10240 width=4 dilation=1 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `ple_conv_bias` | `ple_conv_bias_bf16` | libr4d | device | `n=10240 width=4 dilation=1 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `ple_conv_bias` | `ref_ple_conv_bias` | libref | host | `n=10240 width=4 dilation=1 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `ple_conv_bias` | `avx_ple_conv_bias` | libavx | host | `n=10240 width=4 dilation=1 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `ple_conv_bias` | `ple_conv_bias_bf16` | libr4d | device | `n=10240 width=4 dilation=1 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `ple_conv_bias` | `ref_ple_conv_bias` | libref | host | `n=10240 width=4 dilation=1 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `ple_conv_bias` | `avx_ple_conv_bias` | libavx | host | `n=10240 width=4 dilation=1 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `ple_conv_bias` | `ple_conv_bias_bf16` | libr4d | device | `n=10240 width=4 dilation=1 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `ple_conv_bias` | `ref_ple_conv_bias` | libref | host | `n=10240 width=4 dilation=1 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `ple_conv_bias` | `avx_ple_conv_bias` | libavx | host | `n=10240 width=4 dilation=1 dtype=bf16 M=8` | - | 1 | ok | 1.85e-09 | 6e-03 | +| `ple_conv_bias` | `ple_conv_bias_bf16` | libr4d | device | `n=10240 width=4 dilation=1 dtype=bf16 M=8` | - | 1 | ok | 1.85e-09 | 6e-03 | +| `ple_conv_bias` | `ref_ple_conv_bias` | libref | host | `n=10240 width=4 dilation=1 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `ple_conv_bias` | `avx_ple_conv_bias` | libavx | host | `n=10240 width=4 dilation=1 dtype=bf16 M=16` | - | 1 | ok | 2.13e-05 | 6e-03 | +| `ple_conv_bias` | `ple_conv_bias_bf16` | libr4d | device | `n=10240 width=4 dilation=1 dtype=bf16 M=16` | - | 1 | ok | 2.13e-05 | 6e-03 | +| `ple_conv_bias` | `ref_ple_conv_bias` | libref | host | `n=10240 width=4 dilation=1 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `ple_conv_bias` | `avx_ple_conv_bias` | libavx | host | `n=10240 width=4 dilation=1 dtype=bf16 M=32` | - | 1 | ok | 1.08e-05 | 6e-03 | +| `ple_conv_bias` | `ple_conv_bias_bf16` | libr4d | device | `n=10240 width=4 dilation=1 dtype=bf16 M=32` | - | 1 | ok | 7.77e-06 | 6e-03 | +| `ple_conv_bias` | `ref_ple_conv_bias` | libref | host | `n=10240 width=4 dilation=1 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `ple_conv_bias` | `avx_ple_conv_bias` | libavx | host | `n=10240 width=4 dilation=1 dtype=bf16 M=64` | - | 1 | ok | 1.61e-06 | 6e-03 | +| `ple_conv_bias` | `ple_conv_bias_bf16` | libr4d | device | `n=10240 width=4 dilation=1 dtype=bf16 M=64` | - | 1 | ok | 1.61e-06 | 6e-03 | +| `ple_conv_bias` | `ref_ple_conv_bias` | libref | host | `n=10240 width=4 dilation=1 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `ple_conv_bias` | `avx_ple_conv_bias` | libavx | host | `n=10240 width=4 dilation=1 dtype=bf16 M=128` | - | 1 | ok | 1.15e-05 | 6e-03 | +| `ple_conv_bias` | `ple_conv_bias_bf16` | libr4d | device | `n=10240 width=4 dilation=1 dtype=bf16 M=128` | - | 1 | ok | 1.15e-05 | 6e-03 | +| `ple_conv_bias` | `ref_ple_conv_bias` | libref | host | `n=10240 width=4 dilation=1 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `ple_conv_bias` | `avx_ple_conv_bias` | libavx | host | `n=10240 width=4 dilation=1 dtype=bf16 M=256` | - | 1 | ok | 2.07e-06 | 6e-03 | +| `ple_conv_bias` | `ple_conv_bias_bf16` | libr4d | device | `n=10240 width=4 dilation=1 dtype=bf16 M=256` | - | 1 | ok | 2.07e-06 | 6e-03 | +| `ple_conv_bias` | `ref_ple_conv_bias` | libref | host | `n=10240 width=4 dilation=1 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `ple_conv_bias` | `avx_ple_conv_bias` | libavx | host | `n=10240 width=4 dilation=1 dtype=bf16 M=512` | - | 1 | ok | 8.70e-06 | 6e-03 | +| `ple_conv_bias` | `ple_conv_bias_bf16` | libr4d | device | `n=10240 width=4 dilation=1 dtype=bf16 M=512` | - | 1 | ok | 8.70e-06 | 6e-03 | +| `ple_conv_bias` | `ref_ple_conv_bias` | libref | host | `n=10240 width=4 dilation=1 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=8192 act=silu dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=8192 act=silu dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=8192 act=silu dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=8192 act=silu dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=8192 act=silu dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=8192 act=silu dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=8192 act=silu dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=8192 act=silu dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=8192 act=silu dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=8192 act=silu dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=8192 act=silu dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=8192 act=silu dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=8192 act=silu dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=8192 act=silu dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=8192 act=silu dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=8192 act=silu dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=8192 act=silu dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=8192 act=silu dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=8192 act=silu dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=8192 act=silu dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=8192 act=silu dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=8192 act=silu dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=8192 act=silu dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=8192 act=silu dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=8192 act=silu dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=8192 act=silu dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=8192 act=silu dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=8192 act=silu dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=8192 act=silu dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=8192 act=silu dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=1024 eps=1e-05 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=1024 eps=1e-05 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=1024 eps=1e-05 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=1024 eps=1e-05 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=1024 eps=1e-05 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=1024 eps=1e-05 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=1024 eps=1e-05 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=1024 eps=1e-05 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=1024 eps=1e-05 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=1024 eps=1e-05 dtype=bf16 M=8` | - | 1 | ok | 1.46e-04 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=1024 eps=1e-05 dtype=bf16 M=8` | - | 1 | ok | 1.46e-04 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=1024 eps=1e-05 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=1024 eps=1e-05 dtype=bf16 M=16` | - | 1 | ok | 8.41e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=1024 eps=1e-05 dtype=bf16 M=16` | - | 1 | ok | 8.41e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=1024 eps=1e-05 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=1024 eps=1e-05 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=1024 eps=1e-05 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=1024 eps=1e-05 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=1024 eps=1e-05 dtype=bf16 M=64` | - | 1 | ok | 5.84e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=1024 eps=1e-05 dtype=bf16 M=64` | - | 1 | ok | 5.84e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=1024 eps=1e-05 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=1024 eps=1e-05 dtype=bf16 M=128` | - | 1 | ok | 1.81e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=1024 eps=1e-05 dtype=bf16 M=128` | - | 1 | ok | 1.81e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=1024 eps=1e-05 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=1024 eps=1e-05 dtype=bf16 M=256` | - | 1 | ok | 9.51e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=1024 eps=1e-05 dtype=bf16 M=256` | - | 1 | ok | 9.25e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=1024 eps=1e-05 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=1024 eps=1e-05 dtype=bf16 M=512` | - | 1 | ok | 3.76e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=1024 eps=1e-05 dtype=bf16 M=512` | - | 1 | ok | 3.38e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=1024 eps=1e-05 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `mul_weight` | `avx_mul_weight` | libavx | host | `n=8192 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `mul_weight` | `mul_weight_bf16` | libr4d | device | `n=8192 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `mul_weight` | `ref_mul_weight` | libref | host | `n=8192 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `mul_weight` | `avx_mul_weight` | libavx | host | `n=8192 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `mul_weight` | `mul_weight_bf16` | libr4d | device | `n=8192 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `mul_weight` | `ref_mul_weight` | libref | host | `n=8192 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `mul_weight` | `avx_mul_weight` | libavx | host | `n=8192 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `mul_weight` | `mul_weight_bf16` | libr4d | device | `n=8192 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `mul_weight` | `ref_mul_weight` | libref | host | `n=8192 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `mul_weight` | `avx_mul_weight` | libavx | host | `n=8192 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `mul_weight` | `mul_weight_bf16` | libr4d | device | `n=8192 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `mul_weight` | `ref_mul_weight` | libref | host | `n=8192 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `mul_weight` | `avx_mul_weight` | libavx | host | `n=8192 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `mul_weight` | `mul_weight_bf16` | libr4d | device | `n=8192 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `mul_weight` | `ref_mul_weight` | libref | host | `n=8192 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `mul_weight` | `avx_mul_weight` | libavx | host | `n=8192 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `mul_weight` | `mul_weight_bf16` | libr4d | device | `n=8192 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `mul_weight` | `ref_mul_weight` | libref | host | `n=8192 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `mul_weight` | `avx_mul_weight` | libavx | host | `n=8192 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `mul_weight` | `mul_weight_bf16` | libr4d | device | `n=8192 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `mul_weight` | `ref_mul_weight` | libref | host | `n=8192 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `mul_weight` | `avx_mul_weight` | libavx | host | `n=8192 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `mul_weight` | `mul_weight_bf16` | libr4d | device | `n=8192 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `mul_weight` | `ref_mul_weight` | libref | host | `n=8192 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `mul_weight` | `avx_mul_weight` | libavx | host | `n=8192 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `mul_weight` | `mul_weight_bf16` | libr4d | device | `n=8192 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `mul_weight` | `ref_mul_weight` | libref | host | `n=8192 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `mul_weight` | `avx_mul_weight` | libavx | host | `n=8192 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `mul_weight` | `mul_weight_bf16` | libr4d | device | `n=8192 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `mul_weight` | `ref_mul_weight` | libref | host | `n=8192 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=8192 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=8192 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=8192 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=8192 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=8192 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=8192 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=8192 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=8192 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=8192 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=8192 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=8192 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=8192 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=8192 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=8192 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=8192 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=8192 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=8192 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=8192 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=8192 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=8192 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=8192 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=8192 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=8192 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=8192 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=8192 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=8192 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=8192 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=8192 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=8192 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=8192 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 1.74e-08 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=8192 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 1.17e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=8192 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 5.87e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 5.01e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=8192 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 2.70e-07 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 1.22e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=8192 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 1.17e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 5.67e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=8192 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 2.23e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 1.33e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=8192 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 1.58e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 6.01e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=8192 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 2.37e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 8.39e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=8192 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 1.38e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 7.27e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=8192 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 2.05e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 1.00e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4096 K=8192 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 1.96e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 1.32e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4096 K=8192 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 1.69e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 9.77e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4096 K=8192 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 2.26e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 8.77e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4096 K=8192 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 2.26e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 8.66e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4096 K=8192 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 2.01e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=8192 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `add` | `avx_add` | libavx | host | `n=4096 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `add` | `add_bf16` | libr4d | device | `n=4096 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `add` | `ref_add` | libref | host | `n=4096 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `add` | `avx_add` | libavx | host | `n=4096 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `add` | `add_bf16` | libr4d | device | `n=4096 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `add` | `ref_add` | libref | host | `n=4096 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `add` | `avx_add` | libavx | host | `n=4096 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `add` | `add_bf16` | libr4d | device | `n=4096 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `add` | `ref_add` | libref | host | `n=4096 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `add` | `avx_add` | libavx | host | `n=4096 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `add` | `add_bf16` | libr4d | device | `n=4096 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `add` | `ref_add` | libref | host | `n=4096 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `add` | `avx_add` | libavx | host | `n=4096 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `add` | `add_bf16` | libr4d | device | `n=4096 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `add` | `ref_add` | libref | host | `n=4096 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `add` | `avx_add` | libavx | host | `n=4096 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `add` | `add_bf16` | libr4d | device | `n=4096 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `add` | `ref_add` | libref | host | `n=4096 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `add` | `avx_add` | libavx | host | `n=4096 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `add` | `add_bf16` | libr4d | device | `n=4096 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `add` | `ref_add` | libref | host | `n=4096 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `add` | `avx_add` | libavx | host | `n=4096 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `add` | `add_bf16` | libr4d | device | `n=4096 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `add` | `ref_add` | libref | host | `n=4096 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `add` | `avx_add` | libavx | host | `n=4096 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `add` | `add_bf16` | libr4d | device | `n=4096 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `add` | `ref_add` | libref | host | `n=4096 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `add` | `avx_add` | libavx | host | `n=4096 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `add` | `add_bf16` | libr4d | device | `n=4096 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `add` | `ref_add` | libref | host | `n=4096 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=1024 K=4096 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=1024 K=4096 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 1.24e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=1024 K=4096 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 4.75e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=1024 K=4096 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 2.06e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=1024 K=4096 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 9.55e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 7.59e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=1024 K=4096 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 4.56e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 3.85e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=1024 K=4096 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 1.67e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 6.23e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=1024 K=4096 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 6.47e-08 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 5.57e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=1024 K=4096 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 2.38e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 8.66e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=1024 K=4096 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 9.56e-08 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 5.70e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=1024 K=4096 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 9.73e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 9.67e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=1024 K=4096 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 9.55e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 8.19e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=1024 K=4096 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 1.06e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 5.52e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=1024 K=4096 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 1.18e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=1024 K=4096 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=1024 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=1024 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=1024 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=1024 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=1024 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=1024 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=1024 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=1024 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=1024 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=1024 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=1024 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=1024 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=1024 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=1024 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=1024 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=1024 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=1024 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=1024 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=1024 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=1024 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=1024 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=1024 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=1024 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=1024 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=1024 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=1024 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=1024 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=1024 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=1024 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=1024 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | host | `N=240 K=4096 dtype=bf16 M=1` | - | 1 | ok | 5.80e-07 | 8e-03 | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | device | `N=240 K=4096 dtype=bf16 M=1` | - | 1 | ok | 5.65e-07 | 8e-03 | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | host | `N=240 K=4096 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | host | `N=240 K=4096 dtype=bf16 M=2` | - | 1 | ok | 6.02e-07 | 8e-03 | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | device | `N=240 K=4096 dtype=bf16 M=2` | - | 1 | ok | 5.89e-07 | 8e-03 | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | host | `N=240 K=4096 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | host | `N=240 K=4096 dtype=bf16 M=4` | - | 1 | ok | 7.02e-07 | 8e-03 | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | device | `N=240 K=4096 dtype=bf16 M=4` | - | 1 | ok | 6.48e-07 | 8e-03 | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | host | `N=240 K=4096 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | host | `N=240 K=4096 dtype=bf16 M=8` | - | 1 | ok | 6.32e-07 | 8e-03 | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | device | `N=240 K=4096 dtype=bf16 M=8` | - | 1 | ok | 6.08e-07 | 8e-03 | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | host | `N=240 K=4096 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | host | `N=240 K=4096 dtype=bf16 M=16` | - | 1 | ok | 6.40e-07 | 8e-03 | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | device | `N=240 K=4096 dtype=bf16 M=16` | - | 1 | ok | 6.26e-07 | 8e-03 | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | host | `N=240 K=4096 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | host | `N=240 K=4096 dtype=bf16 M=32` | - | 1 | ok | 6.26e-07 | 8e-03 | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | device | `N=240 K=4096 dtype=bf16 M=32` | - | 1 | ok | 5.84e-07 | 8e-03 | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | host | `N=240 K=4096 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | host | `N=240 K=4096 dtype=bf16 M=64` | - | 1 | ok | 6.92e-07 | 8e-03 | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | device | `N=240 K=4096 dtype=bf16 M=64` | - | 1 | ok | 6.66e-07 | 8e-03 | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | host | `N=240 K=4096 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | host | `N=240 K=4096 dtype=bf16 M=128` | - | 1 | ok | 6.77e-07 | 8e-03 | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | device | `N=240 K=4096 dtype=bf16 M=128` | - | 1 | ok | 6.90e-07 | 8e-03 | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | host | `N=240 K=4096 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | host | `N=240 K=4096 dtype=bf16 M=256` | - | 1 | ok | 5.81e-07 | 8e-03 | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | device | `N=240 K=4096 dtype=bf16 M=256` | - | 1 | ok | 5.63e-07 | 8e-03 | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | host | `N=240 K=4096 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | host | `N=240 K=4096 dtype=bf16 M=512` | - | 1 | ok | 6.43e-07 | 8e-03 | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | device | `N=240 K=4096 dtype=bf16 M=512` | - | 1 | ok | 6.32e-07 | 8e-03 | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | host | `N=240 K=4096 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | host | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=1` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | device | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=1` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | host | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=1` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | host | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=2` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | device | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=2` | - | 1 | ok | 1.18e-08 | 1e-05 | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | host | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=2` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | host | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=4` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | device | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=4` | - | 1 | ok | 2.12e-09 | 1e-05 | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | host | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=4` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | host | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=8` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | device | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=8` | - | 1 | ok | 2.97e-08 | 1e-05 | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | host | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=8` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | host | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=16` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | device | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=16` | - | 1 | ok | 2.29e-08 | 1e-05 | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | host | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=16` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | host | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=32` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | device | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=32` | - | 1 | ok | 1.55e-08 | 1e-05 | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | host | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=32` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | host | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=64` | - | 1 | ok | 4.28e-09 | 1e-05 | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | device | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=64` | - | 1 | ok | 2.06e-08 | 1e-05 | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | host | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=64` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | host | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=128` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | device | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=128` | - | 1 | ok | 1.39e-08 | 1e-05 | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | host | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=128` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | host | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=256` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | device | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=256` | - | 1 | ok | 2.10e-08 | 1e-05 | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | host | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=256` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | host | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=512` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | device | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=512` | - | 1 | ok | 1.94e-08 | 1e-05 | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | host | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=512` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `moe_scatter` | `avx_moe_scatter` | libavx | host | `n_expert=240 top_k=9 expert_base=0 M=1` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `moe_scatter_i32` | libr4d | device | `n_expert=240 top_k=9 expert_base=0 M=1` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `ref_moe_scatter` | libref | host | `n_expert=240 top_k=9 expert_base=0 M=1` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `avx_moe_scatter` | libavx | host | `n_expert=240 top_k=9 expert_base=0 M=2` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `moe_scatter_i32` | libr4d | device | `n_expert=240 top_k=9 expert_base=0 M=2` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `ref_moe_scatter` | libref | host | `n_expert=240 top_k=9 expert_base=0 M=2` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `avx_moe_scatter` | libavx | host | `n_expert=240 top_k=9 expert_base=0 M=4` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `moe_scatter_i32` | libr4d | device | `n_expert=240 top_k=9 expert_base=0 M=4` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `ref_moe_scatter` | libref | host | `n_expert=240 top_k=9 expert_base=0 M=4` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `avx_moe_scatter` | libavx | host | `n_expert=240 top_k=9 expert_base=0 M=8` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `moe_scatter_i32` | libr4d | device | `n_expert=240 top_k=9 expert_base=0 M=8` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `ref_moe_scatter` | libref | host | `n_expert=240 top_k=9 expert_base=0 M=8` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `avx_moe_scatter` | libavx | host | `n_expert=240 top_k=9 expert_base=0 M=16` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `moe_scatter_i32` | libr4d | device | `n_expert=240 top_k=9 expert_base=0 M=16` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `ref_moe_scatter` | libref | host | `n_expert=240 top_k=9 expert_base=0 M=16` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `avx_moe_scatter` | libavx | host | `n_expert=240 top_k=9 expert_base=0 M=32` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `moe_scatter_i32` | libr4d | device | `n_expert=240 top_k=9 expert_base=0 M=32` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `ref_moe_scatter` | libref | host | `n_expert=240 top_k=9 expert_base=0 M=32` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `avx_moe_scatter` | libavx | host | `n_expert=240 top_k=9 expert_base=0 M=64` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `moe_scatter_i32` | libr4d | device | `n_expert=240 top_k=9 expert_base=0 M=64` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `ref_moe_scatter` | libref | host | `n_expert=240 top_k=9 expert_base=0 M=64` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `avx_moe_scatter` | libavx | host | `n_expert=240 top_k=9 expert_base=0 M=128` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `moe_scatter_i32` | libr4d | device | `n_expert=240 top_k=9 expert_base=0 M=128` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `ref_moe_scatter` | libref | host | `n_expert=240 top_k=9 expert_base=0 M=128` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `avx_moe_scatter` | libavx | host | `n_expert=240 top_k=9 expert_base=0 M=256` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `moe_scatter_i32` | libr4d | device | `n_expert=240 top_k=9 expert_base=0 M=256` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `ref_moe_scatter` | libref | host | `n_expert=240 top_k=9 expert_base=0 M=256` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `avx_moe_scatter` | libavx | host | `n_expert=240 top_k=9 expert_base=0 M=512` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `moe_scatter_i32` | libr4d | device | `n_expert=240 top_k=9 expert_base=0 M=512` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `ref_moe_scatter` | libref | host | `n_expert=240 top_k=9 expert_base=0 M=512` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=1024 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=1024 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=1024 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=1024 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=1024 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=1024 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=1024 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=1024 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=1024 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=1024 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=1024 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=1024 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=1024 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=1024 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=1024 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=1024 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=1024 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=1024 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=1024 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=1024 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=1024 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=1024 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=1024 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=1024 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=1024 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=1024 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=1024 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=1024 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=1024 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=1024 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=2048 act=relu dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=2048 act=relu dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=2048 act=relu dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=2048 act=relu dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=2048 act=relu dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=2048 act=relu dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=2048 act=relu dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=2048 act=relu dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=2048 act=relu dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=2048 act=relu dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=2048 act=relu dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=2048 act=relu dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=2048 act=relu dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=2048 act=relu dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=2048 act=relu dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=2048 act=relu dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=2048 act=relu dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=2048 act=relu dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=2048 act=relu dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=2048 act=relu dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=2048 act=relu dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=2048 act=relu dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=2048 act=relu dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=2048 act=relu dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=2048 act=relu dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=2048 act=relu dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=2048 act=relu dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=2048 act=relu dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=2048 act=relu dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=2048 act=relu dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=2048 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=2048 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=2048 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=2048 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=2048 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=2048 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=2048 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=2048 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=2048 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=2048 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=2048 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=2048 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=2048 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=2048 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=2048 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=2048 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=2048 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=2048 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=2048 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=2048 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=2048 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=2048 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=2048 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=2048 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=2048 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=2048 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=2048 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=2048 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=2048 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=2048 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `moe_gather` | `avx_moe_gather` | libavx | host | `n=1024 top_k=9 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `moe_gather` | `moe_gather_bf16` | libr4d | device | `n=1024 top_k=9 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `moe_gather` | `ref_moe_gather` | libref | host | `n=1024 top_k=9 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `moe_gather` | `avx_moe_gather` | libavx | host | `n=1024 top_k=9 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `moe_gather` | `moe_gather_bf16` | libr4d | device | `n=1024 top_k=9 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `moe_gather` | `ref_moe_gather` | libref | host | `n=1024 top_k=9 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `moe_gather` | `avx_moe_gather` | libavx | host | `n=1024 top_k=9 dtype=bf16 act=none M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `moe_gather` | `moe_gather_bf16` | libr4d | device | `n=1024 top_k=9 dtype=bf16 act=none M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `moe_gather` | `ref_moe_gather` | libref | host | `n=1024 top_k=9 dtype=bf16 act=none M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `moe_gather` | `avx_moe_gather` | libavx | host | `n=1024 top_k=9 dtype=bf16 act=none M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `moe_gather` | `moe_gather_bf16` | libr4d | device | `n=1024 top_k=9 dtype=bf16 act=none M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `moe_gather` | `ref_moe_gather` | libref | host | `n=1024 top_k=9 dtype=bf16 act=none M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `moe_gather` | `avx_moe_gather` | libavx | host | `n=1024 top_k=9 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `moe_gather` | `moe_gather_bf16` | libr4d | device | `n=1024 top_k=9 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `moe_gather` | `ref_moe_gather` | libref | host | `n=1024 top_k=9 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `moe_gather` | `avx_moe_gather` | libavx | host | `n=1024 top_k=9 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `moe_gather` | `moe_gather_bf16` | libr4d | device | `n=1024 top_k=9 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `moe_gather` | `ref_moe_gather` | libref | host | `n=1024 top_k=9 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `moe_gather` | `avx_moe_gather` | libavx | host | `n=1024 top_k=9 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `moe_gather` | `moe_gather_bf16` | libr4d | device | `n=1024 top_k=9 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `moe_gather` | `ref_moe_gather` | libref | host | `n=1024 top_k=9 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `moe_gather` | `avx_moe_gather` | libavx | host | `n=1024 top_k=9 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `moe_gather` | `moe_gather_bf16` | libr4d | device | `n=1024 top_k=9 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `moe_gather` | `ref_moe_gather` | libref | host | `n=1024 top_k=9 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `moe_gather` | `avx_moe_gather` | libavx | host | `n=1024 top_k=9 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `moe_gather` | `moe_gather_bf16` | libr4d | device | `n=1024 top_k=9 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `moe_gather` | `ref_moe_gather` | libref | host | `n=1024 top_k=9 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `moe_gather` | `avx_moe_gather` | libavx | host | `n=1024 top_k=9 dtype=bf16 act=none M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `moe_gather` | `moe_gather_bf16` | libr4d | device | `n=1024 top_k=9 dtype=bf16 act=none M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `moe_gather` | `ref_moe_gather` | libref | host | `n=1024 top_k=9 dtype=bf16 act=none M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 4.31e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=1024 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 2.39e-08 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=1024 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=1024 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 8.64e-06 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=1024 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 1.09e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 6.89e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=1024 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 5.37e-07 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 2.38e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=1024 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 2.86e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 4.49e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=1024 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 9.65e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 3.76e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=1024 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 4.55e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 2.70e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=1024 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 3.55e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 3.04e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4096 K=1024 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 1.08e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 7.31e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4096 K=1024 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 2.12e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 4.23e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4096 K=1024 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 1.09e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 4.10e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4096 K=1024 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 1.20e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 5.32e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4096 K=1024 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 1.02e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=1024 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 3.43e-07 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5376 K=4096 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 1.06e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5376 K=4096 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 1.23e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5376 K=4096 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 2.12e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 2.99e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5376 K=4096 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 1.38e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 4.88e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5376 K=4096 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 5.47e-08 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 6.98e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5376 K=4096 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 3.10e-08 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 7.79e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5376 K=4096 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 3.07e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 5.91e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5376 K=4096 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 7.38e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 6.80e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=5376 K=4096 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 1.94e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 6.03e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=5376 K=4096 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 1.29e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 8.60e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=5376 K=4096 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 7.29e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 7.13e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=5376 K=4096 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 1.90e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 7.28e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=5376 K=4096 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 1.44e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 5.75e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=5376 K=4096 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 1.63e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=5376 K=4096 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=5376 act=relu dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=5376 act=relu dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=5376 act=relu dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=5376 act=relu dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=5376 act=relu dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=5376 act=relu dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=5376 act=relu dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=5376 act=relu dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=5376 act=relu dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=5376 act=relu dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=5376 act=relu dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=5376 act=relu dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=5376 act=relu dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=5376 act=relu dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=5376 act=relu dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=5376 act=relu dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=5376 act=relu dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=5376 act=relu dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=5376 act=relu dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=5376 act=relu dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=5376 act=relu dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=5376 act=relu dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=5376 act=relu dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=5376 act=relu dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=5376 act=relu dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=5376 act=relu dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=5376 act=relu dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=5376 act=relu dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=5376 act=relu dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=5376 act=relu dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=5376 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=5376 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=5376 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=5376 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=5376 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=5376 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=5376 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=5376 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=5376 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=5376 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=5376 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=5376 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=5376 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=5376 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=5376 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=5376 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=5376 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=5376 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=5376 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=5376 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=5376 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=5376 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=5376 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=5376 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=5376 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=5376 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=5376 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=5376 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=5376 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=5376 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 4.25e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=5376 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 1.74e-06 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=5376 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 4.67e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=5376 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 1.00e-08 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 7.22e-06 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=5376 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 2.18e-07 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 7.15e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=5376 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 1.36e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 1.03e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=5376 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 9.81e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 6.52e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=5376 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 1.78e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 5.36e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=5376 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 1.79e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 6.35e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=5376 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 1.01e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 4.08e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4096 K=5376 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 1.99e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 6.44e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4096 K=5376 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 1.11e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 1.56e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4096 K=5376 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 1.26e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 1.00e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4096 K=5376 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 3.34e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 8.10e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4096 K=5376 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 1.77e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=5376 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=1536 act=relu dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=1536 act=relu dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=1536 act=relu dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=1536 act=relu dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=1536 act=relu dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=1536 act=relu dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=1536 act=relu dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=1536 act=relu dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=1536 act=relu dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=1536 act=relu dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=1536 act=relu dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=1536 act=relu dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=1536 act=relu dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=1536 act=relu dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=1536 act=relu dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=1536 act=relu dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=1536 act=relu dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=1536 act=relu dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=1536 act=relu dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=1536 act=relu dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=1536 act=relu dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=1536 act=relu dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=1536 act=relu dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=1536 act=relu dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=1536 act=relu dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=1536 act=relu dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=1536 act=relu dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=1536 act=relu dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=1536 act=relu dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=1536 act=relu dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=1536 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=1536 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=1536 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=1536 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=1536 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=1536 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=1536 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=1536 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=1536 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=1536 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=1536 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=1536 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=1536 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=1536 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=1536 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=1536 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=1536 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=1536 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=1536 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=1536 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=1536 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=1536 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=1536 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=1536 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=1536 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=1536 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=1536 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=1536 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=1536 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=1536 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 1.84e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4608 K=4096 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 5.71e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 1.48e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4608 K=4096 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 3.01e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4608 K=4096 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 5.57e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 2.17e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4608 K=4096 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 3.70e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 6.53e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4608 K=4096 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 3.67e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 5.85e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4608 K=4096 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 5.17e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 9.96e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4608 K=4096 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 1.53e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 6.33e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4608 K=4096 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 9.44e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 8.84e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4608 K=4096 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 1.67e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 1.83e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4608 K=4096 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 6.70e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 6.02e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4608 K=4096 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 1.47e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 8.65e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4608 K=4096 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 8.94e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 6.16e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4608 K=4096 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 1.71e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 7.41e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4608 K=4096 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 2.11e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4608 K=4096 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1 splits=0` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1 splits=0` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1 splits=0` | - | 1 | ok | 1.16e-06 | 2e-02 | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1 splits=0` | - | 1 | ok | 2.20e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1 splits=0` | - | 1 | ok | 1.08e-04 | 2e-02 | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1 splits=0` | - | 1 | ok | 2.40e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2 splits=0` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2 splits=0` | - | 1 | ok | 9.03e-04 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2 splits=0` | - | 1 | ok | 3.97e-05 | 2e-02 | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2 splits=0` | - | 1 | ok | 1.89e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2 splits=0` | - | 1 | ok | 5.24e-05 | 2e-02 | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2 splits=0` | - | 1 | ok | 2.20e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4 splits=0` | - | 1 | ok | 1.79e-08 | 2e-02 | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4 splits=0` | - | 1 | ok | 1.47e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4 splits=0` | - | 1 | ok | 6.74e-06 | 2e-02 | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4 splits=0` | - | 1 | ok | 2.48e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4 splits=0` | - | 1 | ok | 5.92e-05 | 2e-02 | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4 splits=0` | - | 1 | ok | 1.94e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=5 splits=0` | - | 1 | ok | 3.58e-05 | 2e-02 | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=5 splits=0` | - | 1 | ok | 1.11e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=5 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=5 splits=0` | - | 1 | ok | 6.34e-05 | 2e-02 | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=5 splits=0` | - | 1 | ok | 2.10e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=5 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=5 splits=0` | - | 1 | ok | 6.19e-05 | 2e-02 | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=5 splits=0` | - | 1 | ok | 1.93e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=5 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=6 splits=0` | - | 1 | ok | 2.80e-07 | 2e-02 | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=6 splits=0` | - | 1 | ok | 1.65e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=6 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=6 splits=0` | - | 1 | ok | 1.06e-04 | 2e-02 | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=6 splits=0` | - | 1 | ok | 2.07e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=6 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=6 splits=0` | - | 1 | ok | 9.13e-05 | 2e-02 | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=6 splits=0` | - | 1 | ok | 2.13e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=6 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8 splits=0` | - | 1 | ok | 1.93e-06 | 2e-02 | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8 splits=0` | - | 1 | ok | 1.40e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8 splits=0` | - | 1 | ok | 1.31e-04 | 2e-02 | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8 splits=0` | - | 1 | ok | 1.88e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8 splits=0` | - | 1 | ok | 1.34e-04 | 2e-02 | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8 splits=0` | - | 1 | ok | 2.15e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8 splits=0` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=9` | - | 1 | ok | 8.06e-06 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=9` | - | 1 | ok | 7.00e-04 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=9` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=9` | - | 1 | ok | 7.19e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=9` | - | 1 | ok | 1.86e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=9` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=9` | - | 1 | ok | 5.45e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=9` | - | 1 | ok | 2.01e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=9` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=10` | - | 1 | ok | 1.56e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=10` | - | 1 | ok | 9.06e-04 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=10` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=10` | - | 1 | ok | 5.11e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=10` | - | 1 | ok | 1.63e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=10` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=10` | - | 1 | ok | 8.12e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=10` | - | 1 | ok | 1.70e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=10` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=11` | - | 1 | ok | 7.42e-07 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=11` | - | 1 | ok | 7.42e-04 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=11` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=11` | - | 1 | ok | 2.94e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=11` | - | 1 | ok | 1.62e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=11` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=11` | - | 1 | ok | 1.26e-04 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=11` | - | 1 | ok | 1.41e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=11` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=16` | - | 1 | ok | 1.36e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=16` | - | 1 | ok | 9.28e-04 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=16` | - | 1 | ok | 2.10e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=16` | - | 1 | ok | 1.42e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=16` | - | 1 | ok | 7.59e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=16` | - | 1 | ok | 1.74e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=17` | - | 1 | ok | 1.46e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=17` | - | 1 | ok | 8.91e-04 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=17` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=17` | - | 1 | ok | 4.27e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=17` | - | 1 | ok | 1.52e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=17` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=17` | - | 1 | ok | 8.30e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=17` | - | 1 | ok | 1.77e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=17` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=32` | - | 1 | ok | 3.61e-06 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=32` | - | 1 | ok | 9.38e-04 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=32` | - | 1 | ok | 4.29e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=32` | - | 1 | ok | 1.83e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=32` | - | 1 | ok | 8.46e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=32` | - | 1 | ok | 1.66e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=33` | - | 1 | ok | 6.46e-06 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=33` | - | 1 | ok | 1.08e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=33` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=33` | - | 1 | ok | 1.45e-04 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=33` | - | 1 | ok | 1.29e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=33` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=33` | - | 1 | ok | 1.02e-04 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=33` | - | 1 | ok | 1.60e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=33` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=64` | - | 1 | ok | 2.33e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=64` | - | 1 | ok | 9.77e-04 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=64` | - | 1 | ok | 5.31e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=64` | - | 1 | ok | 1.70e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=64` | - | 1 | ok | 6.79e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=64` | - | 1 | ok | 1.87e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=65` | - | 1 | ok | 9.99e-06 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=65` | - | 1 | ok | 9.51e-04 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=65` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=65` | - | 1 | ok | 4.58e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=65` | - | 1 | ok | 1.56e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=65` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=65` | - | 1 | ok | 1.11e-04 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=65` | - | 1 | ok | 2.01e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=65` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=130` | - | 1 | ok | 2.45e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=130` | - | 1 | ok | 1.23e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=130` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=130` | - | 1 | ok | 5.46e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=130` | - | 1 | ok | 1.46e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=130` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=130` | - | 1 | ok | 1.02e-04 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=130` | - | 1 | ok | 1.61e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=130` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=260` | - | 1 | ok | 1.96e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=260` | - | 1 | ok | 1.47e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=260` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=260` | - | 1 | ok | 6.47e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=260` | - | 1 | ok | 1.85e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=260` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=260` | - | 1 | ok | 1.06e-04 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=260` | - | 1 | ok | 1.87e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=260` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=512` | - | 1 | ok | 2.39e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=512` | - | 1 | ok | 1.25e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=512` | - | 1 | ok | 3.99e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=512` | - | 1 | ok | 1.71e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged` | `avx_attn_paged` | libavx | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=512` | - | 1 | ok | 8.05e-05 | 2e-02 | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=512` | - | 1 | ok | 1.83e-03 | 2e-02 | +| `attn_paged` | `ref_attn_paged` | libref | host | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `avx_kv_store` | libavx | host | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `kv_store_bf16` | libr4d | device | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `ref_kv_store` | libref | host | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `avx_kv_store` | libavx | host | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `kv_store_bf16` | libr4d | device | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `ref_kv_store` | libref | host | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `avx_kv_store` | libavx | host | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `kv_store_bf16` | libr4d | device | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `ref_kv_store` | libref | host | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `avx_kv_store` | libavx | host | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `kv_store_bf16` | libr4d | device | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `ref_kv_store` | libref | host | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `avx_kv_store` | libavx | host | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `kv_store_bf16` | libr4d | device | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `ref_kv_store` | libref | host | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `avx_kv_store` | libavx | host | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `kv_store_bf16` | libr4d | device | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `ref_kv_store` | libref | host | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `avx_kv_store` | libavx | host | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `kv_store_bf16` | libr4d | device | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `ref_kv_store` | libref | host | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `avx_kv_store` | libavx | host | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `kv_store_bf16` | libr4d | device | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `ref_kv_store` | libref | host | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `avx_kv_store` | libavx | host | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `kv_store_bf16` | libr4d | device | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `ref_kv_store` | libref | host | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `avx_kv_store` | libavx | host | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `kv_store_bf16` | libr4d | device | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `kv_store` | `ref_kv_store` | libref | host | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=4096 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=4096 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=4096 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=4096 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=4096 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=4096 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=4096 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=4096 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=4096 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=4096 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 3.18e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=4096 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 5.06e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=4096 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 1.19e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 3.65e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=4096 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 5.59e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=4096 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 1.56e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 4.29e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=4096 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 1.10e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 8.17e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=4096 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 2.00e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 6.49e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=4096 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 3.38e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 7.78e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=4096 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 2.56e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 7.26e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4096 K=4096 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 2.14e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 7.40e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4096 K=4096 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 1.19e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 7.77e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4096 K=4096 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 1.48e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 5.88e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4096 K=4096 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 1.43e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 5.38e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4096 K=4096 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 1.02e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=4096 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | host | `N=304 K=4096 dtype=bf16 M=1` | - | 1 | ok | 6.12e-07 | 8e-03 | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | device | `N=304 K=4096 dtype=bf16 M=1` | - | 1 | ok | 5.87e-07 | 8e-03 | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | host | `N=304 K=4096 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | host | `N=304 K=4096 dtype=bf16 M=2` | - | 1 | ok | 6.40e-07 | 8e-03 | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | device | `N=304 K=4096 dtype=bf16 M=2` | - | 1 | ok | 6.32e-07 | 8e-03 | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | host | `N=304 K=4096 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | host | `N=304 K=4096 dtype=bf16 M=4` | - | 1 | ok | 6.92e-07 | 8e-03 | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | device | `N=304 K=4096 dtype=bf16 M=4` | - | 1 | ok | 6.49e-07 | 8e-03 | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | host | `N=304 K=4096 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | host | `N=304 K=4096 dtype=bf16 M=8` | - | 1 | ok | 7.17e-07 | 8e-03 | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | device | `N=304 K=4096 dtype=bf16 M=8` | - | 1 | ok | 6.90e-07 | 8e-03 | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | host | `N=304 K=4096 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | host | `N=304 K=4096 dtype=bf16 M=16` | - | 1 | ok | 6.18e-07 | 8e-03 | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | device | `N=304 K=4096 dtype=bf16 M=16` | - | 1 | ok | 6.02e-07 | 8e-03 | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | host | `N=304 K=4096 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | host | `N=304 K=4096 dtype=bf16 M=32` | - | 1 | ok | 6.36e-07 | 8e-03 | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | device | `N=304 K=4096 dtype=bf16 M=32` | - | 1 | ok | 6.18e-07 | 8e-03 | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | host | `N=304 K=4096 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | host | `N=304 K=4096 dtype=bf16 M=64` | - | 1 | ok | 6.58e-07 | 8e-03 | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | device | `N=304 K=4096 dtype=bf16 M=64` | - | 1 | ok | 6.37e-07 | 8e-03 | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | host | `N=304 K=4096 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | host | `N=304 K=4096 dtype=bf16 M=128` | - | 1 | ok | 6.12e-07 | 8e-03 | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | device | `N=304 K=4096 dtype=bf16 M=128` | - | 1 | ok | 6.23e-07 | 8e-03 | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | host | `N=304 K=4096 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | host | `N=304 K=4096 dtype=bf16 M=256` | - | 1 | ok | 6.16e-07 | 8e-03 | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | device | `N=304 K=4096 dtype=bf16 M=256` | - | 1 | ok | 6.12e-07 | 8e-03 | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | host | `N=304 K=4096 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | host | `N=304 K=4096 dtype=bf16 M=512` | - | 1 | ok | 7.00e-07 | 8e-03 | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | device | `N=304 K=4096 dtype=bf16 M=512` | - | 1 | ok | 6.95e-07 | 8e-03 | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | host | `N=304 K=4096 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | host | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=1` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | device | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=1` | - | 1 | ok | 1.75e-08 | 1e-05 | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | host | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=1` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | host | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=2` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | device | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=2` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | host | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=2` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | host | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=4` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | device | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=4` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | host | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=4` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | host | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=8` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | device | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=8` | - | 1 | ok | 1.71e-08 | 1e-05 | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | host | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=8` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | host | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=16` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | device | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=16` | - | 1 | ok | 6.34e-09 | 1e-05 | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | host | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=16` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | host | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=32` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | device | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=32` | - | 1 | ok | 9.67e-09 | 1e-05 | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | host | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=32` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | host | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=64` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | device | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=64` | - | 1 | ok | 2.45e-08 | 1e-05 | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | host | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=64` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | host | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=128` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | device | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=128` | - | 1 | ok | 2.08e-08 | 1e-05 | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | host | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=128` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | host | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=256` | - | 1 | ok | 1.07e-09 | 1e-05 | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | device | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=256` | - | 1 | ok | 2.21e-08 | 1e-05 | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | host | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=256` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | host | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=512` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | device | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=512` | - | 1 | ok | 2.35e-08 | 1e-05 | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | host | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=512` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `moe_scatter` | `avx_moe_scatter` | libavx | host | `n_expert=304 top_k=9 expert_base=0 M=1` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `moe_scatter_i32` | libr4d | device | `n_expert=304 top_k=9 expert_base=0 M=1` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `ref_moe_scatter` | libref | host | `n_expert=304 top_k=9 expert_base=0 M=1` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `avx_moe_scatter` | libavx | host | `n_expert=304 top_k=9 expert_base=0 M=2` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `moe_scatter_i32` | libr4d | device | `n_expert=304 top_k=9 expert_base=0 M=2` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `ref_moe_scatter` | libref | host | `n_expert=304 top_k=9 expert_base=0 M=2` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `avx_moe_scatter` | libavx | host | `n_expert=304 top_k=9 expert_base=0 M=4` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `moe_scatter_i32` | libr4d | device | `n_expert=304 top_k=9 expert_base=0 M=4` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `ref_moe_scatter` | libref | host | `n_expert=304 top_k=9 expert_base=0 M=4` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `avx_moe_scatter` | libavx | host | `n_expert=304 top_k=9 expert_base=0 M=8` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `moe_scatter_i32` | libr4d | device | `n_expert=304 top_k=9 expert_base=0 M=8` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `ref_moe_scatter` | libref | host | `n_expert=304 top_k=9 expert_base=0 M=8` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `avx_moe_scatter` | libavx | host | `n_expert=304 top_k=9 expert_base=0 M=16` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `moe_scatter_i32` | libr4d | device | `n_expert=304 top_k=9 expert_base=0 M=16` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `ref_moe_scatter` | libref | host | `n_expert=304 top_k=9 expert_base=0 M=16` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `avx_moe_scatter` | libavx | host | `n_expert=304 top_k=9 expert_base=0 M=32` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `moe_scatter_i32` | libr4d | device | `n_expert=304 top_k=9 expert_base=0 M=32` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `ref_moe_scatter` | libref | host | `n_expert=304 top_k=9 expert_base=0 M=32` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `avx_moe_scatter` | libavx | host | `n_expert=304 top_k=9 expert_base=0 M=64` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `moe_scatter_i32` | libr4d | device | `n_expert=304 top_k=9 expert_base=0 M=64` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `ref_moe_scatter` | libref | host | `n_expert=304 top_k=9 expert_base=0 M=64` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `avx_moe_scatter` | libavx | host | `n_expert=304 top_k=9 expert_base=0 M=128` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `moe_scatter_i32` | libr4d | device | `n_expert=304 top_k=9 expert_base=0 M=128` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `ref_moe_scatter` | libref | host | `n_expert=304 top_k=9 expert_base=0 M=128` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `avx_moe_scatter` | libavx | host | `n_expert=304 top_k=9 expert_base=0 M=256` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `moe_scatter_i32` | libr4d | device | `n_expert=304 top_k=9 expert_base=0 M=256` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `ref_moe_scatter` | libref | host | `n_expert=304 top_k=9 expert_base=0 M=256` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `avx_moe_scatter` | libavx | host | `n_expert=304 top_k=9 expert_base=0 M=512` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `moe_scatter_i32` | libr4d | device | `n_expert=304 top_k=9 expert_base=0 M=512` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `moe_scatter` | `ref_moe_scatter` | libref | host | `n_expert=304 top_k=9 expert_base=0 M=512` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=2304 act=relu dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=2304 act=relu dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=2304 act=relu dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=2304 act=relu dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=2304 act=relu dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=2304 act=relu dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=2304 act=relu dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=2304 act=relu dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=2304 act=relu dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=2304 act=relu dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=2304 act=relu dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=2304 act=relu dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=2304 act=relu dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=2304 act=relu dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=2304 act=relu dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=2304 act=relu dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=2304 act=relu dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=2304 act=relu dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=2304 act=relu dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=2304 act=relu dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=2304 act=relu dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=2304 act=relu dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=2304 act=relu dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=2304 act=relu dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=2304 act=relu dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=2304 act=relu dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=2304 act=relu dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `act_mul` | `avx_act_mul` | libavx | host | `n=2304 act=relu dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `act_mul_bf16` | libr4d | device | `n=2304 act=relu dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `act_mul` | `ref_act_mul` | libref | host | `n=2304 act=relu dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=2304 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=2304 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=2304 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=2304 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=2304 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=2304 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=2304 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=2304 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=2304 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=2304 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=2304 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=2304 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=2304 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=2304 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=2304 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=2304 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=2304 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=2304 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=2304 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=2304 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=2304 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=2304 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=2304 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=2304 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=2304 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=2304 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=2304 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | host | `n=2304 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | device | `n=2304 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | host | `n=2304 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=4096 eps=1e-05 dtype=bf16 M=1` | - | 1 | ok | 2.44e-04 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=4096 eps=1e-05 dtype=bf16 M=1` | - | 1 | ok | 2.44e-04 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=4096 eps=1e-05 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=4096 eps=1e-05 dtype=bf16 M=2` | - | 1 | ok | 2.21e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=4096 eps=1e-05 dtype=bf16 M=2` | - | 1 | ok | 2.21e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=4096 eps=1e-05 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=4096 eps=1e-05 dtype=bf16 M=4` | - | 1 | ok | 1.69e-04 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=4096 eps=1e-05 dtype=bf16 M=4` | - | 1 | ok | 1.69e-04 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=4096 eps=1e-05 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=4096 eps=1e-05 dtype=bf16 M=8` | - | 1 | ok | 1.17e-04 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=4096 eps=1e-05 dtype=bf16 M=8` | - | 1 | ok | 1.17e-04 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=4096 eps=1e-05 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=4096 eps=1e-05 dtype=bf16 M=16` | - | 1 | ok | 4.31e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=4096 eps=1e-05 dtype=bf16 M=16` | - | 1 | ok | 6.19e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=4096 eps=1e-05 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=4096 eps=1e-05 dtype=bf16 M=32` | - | 1 | ok | 1.04e-04 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=4096 eps=1e-05 dtype=bf16 M=32` | - | 1 | ok | 1.04e-04 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=4096 eps=1e-05 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=4096 eps=1e-05 dtype=bf16 M=64` | - | 1 | ok | 1.03e-04 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=4096 eps=1e-05 dtype=bf16 M=64` | - | 1 | ok | 1.04e-04 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=4096 eps=1e-05 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=4096 eps=1e-05 dtype=bf16 M=128` | - | 1 | ok | 6.73e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=4096 eps=1e-05 dtype=bf16 M=128` | - | 1 | ok | 6.76e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=4096 eps=1e-05 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=4096 eps=1e-05 dtype=bf16 M=256` | - | 1 | ok | 8.38e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=4096 eps=1e-05 dtype=bf16 M=256` | - | 1 | ok | 8.74e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=4096 eps=1e-05 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=4096 eps=1e-05 dtype=bf16 M=512` | - | 1 | ok | 1.12e-04 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=4096 eps=1e-05 dtype=bf16 M=512` | - | 1 | ok | 1.19e-04 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=4096 eps=1e-05 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `avx_gather_rows` | libavx | host | `n=4096 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `gather_rows_bf16` | libr4d | device | `n=4096 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `ref_gather_rows` | libref | host | `n=4096 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `avx_gather_rows` | libavx | host | `n=4096 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `gather_rows_bf16` | libr4d | device | `n=4096 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `ref_gather_rows` | libref | host | `n=4096 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `avx_gather_rows` | libavx | host | `n=4096 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `gather_rows_bf16` | libr4d | device | `n=4096 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `ref_gather_rows` | libref | host | `n=4096 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `avx_gather_rows` | libavx | host | `n=4096 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `gather_rows_bf16` | libr4d | device | `n=4096 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `ref_gather_rows` | libref | host | `n=4096 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `avx_gather_rows` | libavx | host | `n=4096 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `gather_rows_bf16` | libr4d | device | `n=4096 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `ref_gather_rows` | libref | host | `n=4096 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `avx_gather_rows` | libavx | host | `n=4096 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `gather_rows_bf16` | libr4d | device | `n=4096 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `ref_gather_rows` | libref | host | `n=4096 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `avx_gather_rows` | libavx | host | `n=4096 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `gather_rows_bf16` | libr4d | device | `n=4096 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `ref_gather_rows` | libref | host | `n=4096 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `logits_gemm` | `avx_logits_gemm` | libavx | host | `n_vocab=131072 n_embd=4096 dtype=bf16 M=1` | - | 1 | ok | 6.27e-07 | 8e-03 | +| `logits_gemm` | `logits_gemm_bf16_cols` | libr4d | device | `n_vocab=131072 n_embd=4096 dtype=bf16 M=1` | - | 1 | ok | 6.16e-07 | 8e-03 | +| `logits_gemm` | `ref_logits_gemm` | libref | host | `n_vocab=131072 n_embd=4096 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `logits_gemm` | `avx_logits_gemm` | libavx | host | `n_vocab=131072 n_embd=4096 dtype=bf16 M=2` | - | 1 | ok | 6.43e-07 | 8e-03 | +| `logits_gemm` | `logits_gemm_bf16_cols` | libr4d | device | `n_vocab=131072 n_embd=4096 dtype=bf16 M=2` | - | 1 | ok | 6.23e-07 | 8e-03 | +| `logits_gemm` | `ref_logits_gemm` | libref | host | `n_vocab=131072 n_embd=4096 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `logits_gemm` | `avx_logits_gemm` | libavx | host | `n_vocab=131072 n_embd=4096 dtype=bf16 M=4` | - | 1 | ok | 6.83e-07 | 8e-03 | +| `logits_gemm` | `logits_gemm_bf16_cols` | libr4d | device | `n_vocab=131072 n_embd=4096 dtype=bf16 M=4` | - | 1 | ok | 6.59e-07 | 8e-03 | +| `logits_gemm` | `ref_logits_gemm` | libref | host | `n_vocab=131072 n_embd=4096 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `logits_gemm` | `avx_logits_gemm` | libavx | host | `n_vocab=131072 n_embd=4096 dtype=bf16 M=8` | - | 1 | ok | 6.73e-07 | 8e-03 | +| `logits_gemm` | `logits_gemm_bf16_cols` | libr4d | device | `n_vocab=131072 n_embd=4096 dtype=bf16 M=8` | - | 1 | ok | 6.44e-07 | 8e-03 | +| `logits_gemm` | `ref_logits_gemm` | libref | host | `n_vocab=131072 n_embd=4096 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `logits_gemm` | `avx_logits_gemm` | libavx | host | `n_vocab=131072 n_embd=4096 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `logits_gemm` | `logits_gemm_bf16_cols` | libr4d | device | `n_vocab=131072 n_embd=4096 dtype=bf16 M=16` | - | 1 | ok | 5.94e-07 | 8e-03 | +| `logits_gemm` | `ref_logits_gemm` | libref | host | `n_vocab=131072 n_embd=4096 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `logits_gemm` | `avx_logits_gemm` | libavx | host | `n_vocab=131072 n_embd=4096 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `logits_gemm` | `logits_gemm_bf16_cols` | libr4d | device | `n_vocab=131072 n_embd=4096 dtype=bf16 M=32` | - | 1 | ok | 6.02e-07 | 8e-03 | +| `logits_gemm` | `ref_logits_gemm` | libref | host | `n_vocab=131072 n_embd=4096 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `logits_gemm` | `avx_logits_gemm` | libavx | host | `n_vocab=131072 n_embd=4096 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `logits_gemm` | `logits_gemm_bf16_cols` | libr4d | device | `n_vocab=131072 n_embd=4096 dtype=bf16 M=64` | - | 1 | ok | 6.32e-07 | 8e-03 | +| `logits_gemm` | `ref_logits_gemm` | libref | host | `n_vocab=131072 n_embd=4096 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged_sink` | `avx_attn_paged_sink` | libavx | host | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `attn_paged_sink` | `attn_window_sink_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `attn_paged_sink` | `ref_attn_paged_sink` | libref | host | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged_sink` | `avx_attn_paged_sink` | libavx | host | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1` | - | 1 | ok | 2.61e-07 | 2e-02 | +| `attn_paged_sink` | `attn_window_sink_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1` | - | 1 | ok | 2.61e-07 | 2e-02 | +| `attn_paged_sink` | `ref_attn_paged_sink` | libref | host | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged_sink` | `avx_attn_paged_sink` | libavx | host | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1` | - | 1 | ok | 7.47e-05 | 2e-02 | +| `attn_paged_sink` | `attn_window_sink_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1` | - | 1 | ok | 7.47e-05 | 2e-02 | +| `attn_paged_sink` | `ref_attn_paged_sink` | libref | host | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged_sink` | `avx_attn_paged_sink` | libavx | host | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `attn_paged_sink` | `attn_window_sink_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2` | - | 1 | ok | 4.58e-09 | 2e-02 | +| `attn_paged_sink` | `ref_attn_paged_sink` | libref | host | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged_sink` | `avx_attn_paged_sink` | libavx | host | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2` | - | 1 | ok | 2.66e-06 | 2e-02 | +| `attn_paged_sink` | `attn_window_sink_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2` | - | 1 | ok | 2.66e-06 | 2e-02 | +| `attn_paged_sink` | `ref_attn_paged_sink` | libref | host | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged_sink` | `avx_attn_paged_sink` | libavx | host | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2` | - | 1 | ok | 5.65e-05 | 2e-02 | +| `attn_paged_sink` | `attn_window_sink_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2` | - | 1 | ok | 1.98e-04 | 2e-02 | +| `attn_paged_sink` | `ref_attn_paged_sink` | libref | host | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged_sink` | `avx_attn_paged_sink` | libavx | host | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4` | - | 1 | ok | 2.83e-05 | 2e-02 | +| `attn_paged_sink` | `attn_window_sink_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4` | - | 1 | ok | 0.00e+00 | 2e-02 | +| `attn_paged_sink` | `ref_attn_paged_sink` | libref | host | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged_sink` | `avx_attn_paged_sink` | libavx | host | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4` | - | 1 | ok | 5.92e-05 | 2e-02 | +| `attn_paged_sink` | `attn_window_sink_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4` | - | 1 | ok | 5.92e-05 | 2e-02 | +| `attn_paged_sink` | `ref_attn_paged_sink` | libref | host | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged_sink` | `avx_attn_paged_sink` | libavx | host | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4` | - | 1 | ok | 3.77e-05 | 2e-02 | +| `attn_paged_sink` | `attn_window_sink_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4` | - | 1 | ok | 4.53e-05 | 2e-02 | +| `attn_paged_sink` | `ref_attn_paged_sink` | libref | host | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged_sink` | `avx_attn_paged_sink` | libavx | host | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8` | - | 1 | ok | 6.07e-06 | 2e-02 | +| `attn_paged_sink` | `attn_window_sink_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8` | - | 1 | ok | 6.36e-06 | 2e-02 | +| `attn_paged_sink` | `ref_attn_paged_sink` | libref | host | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged_sink` | `avx_attn_paged_sink` | libavx | host | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8` | - | 1 | ok | 2.57e-05 | 2e-02 | +| `attn_paged_sink` | `attn_window_sink_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8` | - | 1 | ok | 9.88e-05 | 2e-02 | +| `attn_paged_sink` | `ref_attn_paged_sink` | libref | host | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `attn_paged_sink` | `avx_attn_paged_sink` | libavx | host | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8` | - | 1 | ok | 7.28e-05 | 2e-02 | +| `attn_paged_sink` | `attn_window_sink_h128_gqa16_bf16kv` | libr4d | device | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8` | - | 1 | ok | 3.50e-05 | 2e-02 | +| `attn_paged_sink` | `ref_attn_paged_sink` | libref | host | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=24576 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=24576 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=24576 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=24576 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=24576 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=24576 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=24576 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=24576 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=24576 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=24576 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=24576 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=24576 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=24576 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=24576 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=24576 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=24576 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=24576 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=24576 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=24576 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=24576 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=24576 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=24576 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=24576 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=24576 group=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=24576 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=24576 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=24576 group=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=24576 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=24576 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=24576 group=128 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 7.97e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=24576 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 7.90e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 6.41e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=24576 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 6.46e-09 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 7.80e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=24576 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 5.11e-09 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 6.55e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=24576 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 3.69e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 1.26e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=24576 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 2.60e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 1.02e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=24576 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 3.41e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 1.12e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=24576 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 6.62e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 1.03e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=24576 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 1.72e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 1.53e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=24576 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 2.24e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 1.42e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4096 K=24576 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 2.08e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 1.15e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4096 K=24576 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 4.72e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 1.16e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4096 K=24576 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 1.59e-04 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 3.05e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4096 K=24576 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 3.48e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 1.57e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=4096 K=24576 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 2.04e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=24576 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=1` | - | 1 | ok | 1.22e-04 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=1` | - | 1 | ok | 1.22e-04 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=4` | - | 1 | ok | 6.51e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=4` | - | 1 | ok | 6.51e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=8` | - | 1 | ok | 1.46e-04 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=8` | - | 1 | ok | 1.46e-04 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=16` | - | 1 | ok | 7.74e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=16` | - | 1 | ok | 7.74e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=32` | - | 1 | ok | 1.03e-04 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=32` | - | 1 | ok | 1.07e-04 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=64` | - | 1 | ok | 1.23e-04 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=64` | - | 1 | ok | 1.19e-04 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=128` | - | 1 | ok | 6.72e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=128` | - | 1 | ok | 6.72e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=256` | - | 1 | ok | 1.06e-04 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=256` | - | 1 | ok | 1.09e-04 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=512` | - | 1 | ok | 9.53e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=512` | - | 1 | ok | 9.59e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=256 K=4096 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 1.85e-08 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=256 K=4096 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=256 K=4096 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=256 K=4096 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=256 K=4096 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=256 K=4096 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=256 K=4096 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 1.10e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=256 K=4096 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=256 K=4096 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=256 K=4096 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=256 K=4096 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=256 K=4096 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=256 K=4096 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 3.84e-06 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=256 K=4096 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=256 K=4096 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=256 K=4096 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 2.96e-06 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=256 K=4096 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=256 K=4096 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=256 K=4096 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 1.00e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=256 K=4096 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 1.75e-07 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=256 K=4096 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=256 K=4096 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 1.82e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=256 K=4096 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=256 K=4096 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=256 K=4096 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 2.38e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=256 K=4096 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 1.83e-04 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=256 K=4096 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=256 K=4096 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 2.45e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=256 K=4096 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 1.05e-07 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=256 K=4096 group=128 dtype=fp8a8 M=65` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=256 K=4096 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 9.99e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=256 K=4096 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 3.40e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=256 K=4096 group=128 dtype=fp8a8 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=256 K=4096 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 9.88e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=256 K=4096 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 2.55e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=256 K=4096 group=128 dtype=fp8a8 M=129` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=256 K=4096 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 9.82e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=256 K=4096 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 4.21e-07 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=256 K=4096 group=128 dtype=fp8a8 M=258` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=256 K=4096 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 4.67e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | device | `N=256 K=4096 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 7.98e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=256 K=4096 group=128 dtype=fp8a8 M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rope` | `avx_rope` | libavx | host | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=1` | - | 1 | ok | 0.00e+00 | 2e-03 | +| `rope` | `rope_bf16` | libr4d | device | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=1` | - | 1 | ok | 0.00e+00 | 2e-03 | +| `rope` | `ref_rope` | libref | host | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rope` | `avx_rope` | libavx | host | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=2` | - | 1 | ok | 0.00e+00 | 2e-03 | +| `rope` | `rope_bf16` | libr4d | device | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=2` | - | 1 | ok | 0.00e+00 | 2e-03 | +| `rope` | `ref_rope` | libref | host | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rope` | `avx_rope` | libavx | host | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=4` | - | 1 | ok | 0.00e+00 | 2e-03 | +| `rope` | `rope_bf16` | libr4d | device | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=4` | - | 1 | ok | 0.00e+00 | 2e-03 | +| `rope` | `ref_rope` | libref | host | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rope` | `avx_rope` | libavx | host | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=8` | - | 1 | ok | 0.00e+00 | 2e-03 | +| `rope` | `rope_bf16` | libr4d | device | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=8` | - | 1 | ok | 0.00e+00 | 2e-03 | +| `rope` | `ref_rope` | libref | host | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rope` | `avx_rope` | libavx | host | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=16` | - | 1 | ok | 0.00e+00 | 2e-03 | +| `rope` | `rope_bf16` | libr4d | device | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=16` | - | 1 | ok | 0.00e+00 | 2e-03 | +| `rope` | `ref_rope` | libref | host | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rope` | `avx_rope` | libavx | host | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=32` | - | 1 | ok | 0.00e+00 | 2e-03 | +| `rope` | `rope_bf16` | libr4d | device | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=32` | - | 1 | ok | 0.00e+00 | 2e-03 | +| `rope` | `ref_rope` | libref | host | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rope` | `avx_rope` | libavx | host | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=64` | - | 1 | ok | 0.00e+00 | 2e-03 | +| `rope` | `rope_bf16` | libr4d | device | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=64` | - | 1 | ok | 0.00e+00 | 2e-03 | +| `rope` | `ref_rope` | libref | host | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rope` | `avx_rope` | libavx | host | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=128` | - | 1 | ok | 0.00e+00 | 2e-03 | +| `rope` | `rope_bf16` | libr4d | device | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=128` | - | 1 | ok | 1.29e-07 | 2e-03 | +| `rope` | `ref_rope` | libref | host | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rope` | `avx_rope` | libavx | host | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=256` | - | 1 | ok | 7.59e-06 | 2e-03 | +| `rope` | `rope_bf16` | libr4d | device | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=256` | - | 1 | ok | 1.74e-05 | 2e-03 | +| `rope` | `ref_rope` | libref | host | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rope` | `avx_rope` | libavx | host | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=512` | - | 1 | ok | 3.42e-07 | 2e-03 | +| `rope` | `rope_bf16` | libr4d | device | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=512` | - | 1 | ok | 6.87e-05 | 2e-03 | +| `rope` | `ref_rope` | libref | host | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=512` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=12288 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=12288 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=12288 group=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=12288 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=12288 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=12288 group=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=12288 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=12288 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=12288 group=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=12288 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=12288 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=12288 group=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=12288 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=12288 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=12288 group=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=12288 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=12288 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=12288 group=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | host | `n=12288 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | device | `n=12288 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | host | `n=12288 group=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1024 K=4096 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 7.35e-09 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=1024 K=4096 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 7.35e-09 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1024 K=4096 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1024 K=4096 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 4.68e-05 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=1024 K=4096 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1024 K=4096 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1024 K=4096 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=1024 K=4096 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1024 K=4096 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1024 K=4096 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 5.34e-06 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=1024 K=4096 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 1.14e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1024 K=4096 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1024 K=4096 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | device | `N=1024 K=4096 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 1.10e-06 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1024 K=4096 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1024 K=4096 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=1024 K=4096 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 2.96e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1024 K=4096 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1024 K=4096 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=1024 K=4096 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 3.14e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1024 K=4096 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt` | `avx_gemm_nt` | libavx | host | `N=1024 K=4096 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | device | `N=1024 K=4096 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 3.49e-05 | 8e-03 | +| `gemm_nt` | `ref_gemm_nt` | libref | host | `N=1024 K=4096 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=24576 K=4096 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 1.90e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=24576 K=4096 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 1.97e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=24576 K=4096 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=24576 K=4096 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 2.65e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=24576 K=4096 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 1.61e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=24576 K=4096 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=24576 K=4096 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 1.51e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=24576 K=4096 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 5.44e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=24576 K=4096 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=24576 K=4096 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 6.10e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=24576 K=4096 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 6.16e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=24576 K=4096 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=24576 K=4096 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 6.97e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=24576 K=4096 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 3.13e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=24576 K=4096 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=24576 K=4096 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 1.88e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=24576 K=4096 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 1.30e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=24576 K=4096 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=24576 K=4096 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 7.61e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=24576 K=4096 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 1.84e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=24576 K=4096 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=24576 K=4096 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 1.83e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=24576 K=4096 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 1.24e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=24576 K=4096 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=24576 K=4096 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 8.69e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=24576 K=4096 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 1.15e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=24576 K=4096 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | host | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=1` | - | 1 | ok | 2.62e-05 | 3e-02 | +| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | device | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=1` | - | 1 | ok | 0.00e+00 | 3e-02 | +| `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | host | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | host | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=2` | - | 1 | ok | 1.04e-05 | 3e-02 | +| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | device | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=2` | - | 1 | ok | 4.99e-09 | 3e-02 | +| `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | host | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | host | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=4` | - | 1 | ok | 3.20e-05 | 3e-02 | +| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | device | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=4` | - | 1 | ok | 9.74e-07 | 3e-02 | +| `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | host | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | host | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=8` | - | 1 | ok | 3.60e-05 | 3e-02 | +| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | device | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=8` | - | 1 | ok | 7.14e-06 | 3e-02 | +| `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | host | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | host | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=16` | - | 1 | ok | 3.63e-04 | 3e-02 | +| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | device | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=16` | - | 1 | ok | 2.21e-05 | 3e-02 | +| `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | host | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | host | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=32` | - | 1 | ok | 6.96e-04 | 3e-02 | +| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | device | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=32` | - | 1 | ok | 2.85e-04 | 3e-02 | +| `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | host | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | host | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=64` | - | 1 | ok | 7.33e-04 | 3e-02 | +| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | device | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=64` | - | 1 | ok | 1.66e-05 | 3e-02 | +| `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | host | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=12288 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 1.82e-06 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=12288 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=12288 group=128 dtype=fp8a8 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=12288 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 3.87e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=12288 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 9.39e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=12288 group=128 dtype=fp8a8 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=12288 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 6.04e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=12288 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 1.34e-08 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=12288 group=128 dtype=fp8a8 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=12288 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 1.06e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=12288 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 4.64e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=12288 group=128 dtype=fp8a8 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=12288 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 1.11e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=12288 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 8.81e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=12288 group=128 dtype=fp8a8 M=9` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=12288 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 7.64e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=12288 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 2.49e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=12288 group=128 dtype=fp8a8 M=18` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=12288 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 1.08e-04 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=12288 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 5.49e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=12288 group=128 dtype=fp8a8 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=12288 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 8.10e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=12288 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 2.35e-06 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=12288 group=128 dtype=fp8a8 M=33` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | host | `N=4096 K=12288 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 8.26e-05 | 5e-03 | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | device | `N=4096 K=12288 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 3.84e-05 | 5e-03 | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | host | `N=4096 K=12288 group=128 dtype=fp8a8 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rope` | `avx_rope` | libavx | host | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=1` | - | 1 | ok | 0.00e+00 | 2e-03 | +| `rope` | `rope_bf16` | libr4d | device | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=1` | - | 1 | ok | 0.00e+00 | 2e-03 | +| `rope` | `ref_rope` | libref | host | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rope` | `avx_rope` | libavx | host | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=2` | - | 1 | ok | 0.00e+00 | 2e-03 | +| `rope` | `rope_bf16` | libr4d | device | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=2` | - | 1 | ok | 0.00e+00 | 2e-03 | +| `rope` | `ref_rope` | libref | host | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rope` | `avx_rope` | libavx | host | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=4` | - | 1 | ok | 0.00e+00 | 2e-03 | +| `rope` | `rope_bf16` | libr4d | device | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=4` | - | 1 | ok | 0.00e+00 | 2e-03 | +| `rope` | `ref_rope` | libref | host | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rope` | `avx_rope` | libavx | host | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=8` | - | 1 | ok | 0.00e+00 | 2e-03 | +| `rope` | `rope_bf16` | libr4d | device | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=8` | - | 1 | ok | 0.00e+00 | 2e-03 | +| `rope` | `ref_rope` | libref | host | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rope` | `avx_rope` | libavx | host | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=16` | - | 1 | ok | 1.54e-05 | 2e-03 | +| `rope` | `rope_bf16` | libr4d | device | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=16` | - | 1 | ok | 1.92e-06 | 2e-03 | +| `rope` | `ref_rope` | libref | host | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rope` | `avx_rope` | libavx | host | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=32` | - | 1 | ok | 3.36e-07 | 2e-03 | +| `rope` | `rope_bf16` | libr4d | device | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=32` | - | 1 | ok | 2.06e-07 | 2e-03 | +| `rope` | `ref_rope` | libref | host | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rope` | `avx_rope` | libavx | host | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=64` | - | 1 | ok | 2.05e-06 | 2e-03 | +| `rope` | `rope_bf16` | libr4d | device | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=64` | - | 1 | ok | 8.83e-06 | 2e-03 | +| `rope` | `ref_rope` | libref | host | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu_mul` | `avx_silu_mul` | libavx | host | `n=12288 dtype=bf16 M=1` | - | 1 | ok | 7.37e-04 | 6e-03 | +| `silu_mul` | `silu_mul_bf16` | libr4d | device | `n=12288 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu_mul` | `ref_silu_mul` | libref | host | `n=12288 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu_mul` | `avx_silu_mul` | libavx | host | `n=12288 dtype=bf16 M=2` | - | 1 | ok | 5.90e-04 | 6e-03 | +| `silu_mul` | `silu_mul_bf16` | libr4d | device | `n=12288 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu_mul` | `ref_silu_mul` | libref | host | `n=12288 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu_mul` | `avx_silu_mul` | libavx | host | `n=12288 dtype=bf16 M=4` | - | 1 | ok | 7.86e-04 | 6e-03 | +| `silu_mul` | `silu_mul_bf16` | libr4d | device | `n=12288 dtype=bf16 M=4` | - | 1 | ok | 2.89e-05 | 6e-03 | +| `silu_mul` | `ref_silu_mul` | libref | host | `n=12288 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu_mul` | `avx_silu_mul` | libavx | host | `n=12288 dtype=bf16 M=8` | - | 1 | ok | 1.70e-03 | 6e-03 | +| `silu_mul` | `silu_mul_bf16` | libr4d | device | `n=12288 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu_mul` | `ref_silu_mul` | libref | host | `n=12288 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu_mul` | `avx_silu_mul` | libavx | host | `n=12288 dtype=bf16 M=16` | - | 1 | ok | 5.67e-04 | 6e-03 | +| `silu_mul` | `silu_mul_bf16` | libr4d | device | `n=12288 dtype=bf16 M=16` | - | 1 | ok | 1.74e-05 | 6e-03 | +| `silu_mul` | `ref_silu_mul` | libref | host | `n=12288 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu_mul` | `avx_silu_mul` | libavx | host | `n=12288 dtype=bf16 M=32` | - | 1 | ok | 6.80e-04 | 6e-03 | +| `silu_mul` | `silu_mul_bf16` | libr4d | device | `n=12288 dtype=bf16 M=32` | - | 1 | ok | 1.05e-05 | 6e-03 | +| `silu_mul` | `ref_silu_mul` | libref | host | `n=12288 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu_mul` | `avx_silu_mul` | libavx | host | `n=12288 dtype=bf16 M=64` | - | 1 | ok | 6.32e-04 | 6e-03 | +| `silu_mul` | `silu_mul_bf16` | libr4d | device | `n=12288 dtype=bf16 M=64` | - | 1 | ok | 1.41e-05 | 6e-03 | +| `silu_mul` | `ref_silu_mul` | libref | host | `n=12288 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `avx_gather_rows` | libavx | host | `n=4096 dtype=bf16 M=56` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `gather_rows_bf16` | libr4d | device | `n=4096 dtype=bf16 M=56` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gather_rows` | `ref_gather_rows` | libref | host | `n=4096 dtype=bf16 M=56` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `logits_gemm` | `avx_logits_gemm` | libavx | host | `n_vocab=131072 n_embd=4096 dtype=bf16 M=56` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `logits_gemm` | `logits_gemm_bf16_cols` | libr4d | device | `n_vocab=131072 n_embd=4096 dtype=bf16 M=56` | - | 1 | ok | 6.03e-07 | 8e-03 | +| `logits_gemm` | `ref_logits_gemm` | libref | host | `n_vocab=131072 n_embd=4096 dtype=bf16 M=56` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=131072 k=9 M=1` | - | 1 | ok | 9.89e-10 | 1e-05 | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | device | `n_vocab=131072 k=9 M=1` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `sample_logprobs` | `ref_sample_logprobs` | libref | host | `n_vocab=131072 k=9 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=131072 k=9 M=2` | - | 1 | ok | 3.43e-09 | 1e-05 | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | device | `n_vocab=131072 k=9 M=2` | - | 1 | ok | 6.86e-10 | 1e-05 | +| `sample_logprobs` | `ref_sample_logprobs` | libref | host | `n_vocab=131072 k=9 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=131072 k=9 M=4` | - | 1 | ok | 2.71e-09 | 1e-05 | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | device | `n_vocab=131072 k=9 M=4` | - | 1 | ok | 1.41e-09 | 1e-05 | +| `sample_logprobs` | `ref_sample_logprobs` | libref | host | `n_vocab=131072 k=9 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=131072 k=9 M=8` | - | 1 | ok | 1.20e-09 | 1e-05 | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | device | `n_vocab=131072 k=9 M=8` | - | 1 | ok | 7.60e-10 | 1e-05 | +| `sample_logprobs` | `ref_sample_logprobs` | libref | host | `n_vocab=131072 k=9 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=131072 k=9 M=16` | - | 1 | ok | 2.94e-09 | 1e-05 | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | device | `n_vocab=131072 k=9 M=16` | - | 1 | ok | 1.48e-09 | 1e-05 | +| `sample_logprobs` | `ref_sample_logprobs` | libref | host | `n_vocab=131072 k=9 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=131072 k=9 M=32` | - | 1 | ok | 1.57e-09 | 1e-05 | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | device | `n_vocab=131072 k=9 M=32` | - | 1 | ok | 1.33e-09 | 1e-05 | +| `sample_logprobs` | `ref_sample_logprobs` | libref | host | `n_vocab=131072 k=9 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=131072 k=9 M=56` | - | 1 | ok | 2.56e-09 | 1e-05 | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | device | `n_vocab=131072 k=9 M=56` | - | 1 | ok | 1.16e-09 | 1e-05 | +| `sample_logprobs` | `ref_sample_logprobs` | libref | host | `n_vocab=131072 k=9 M=56` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=4096 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=4096 dtype=bf16 act=none M=1` | - | 1 | ok | 7.98e-06 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=4096 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=4096 dtype=bf16 act=none M=2` | - | 1 | ok | 2.13e-05 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=4096 dtype=bf16 act=none M=2` | - | 1 | ok | 2.13e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=4096 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=4096 dtype=bf16 act=none M=4` | - | 1 | ok | 1.52e-05 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=4096 dtype=bf16 act=none M=4` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=4096 dtype=bf16 act=none M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=4096 dtype=bf16 act=none M=8` | - | 1 | ok | 1.74e-04 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=4096 dtype=bf16 act=none M=8` | - | 1 | ok | 1.74e-04 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=4096 dtype=bf16 act=none M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=4096 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=4096 dtype=bf16 act=none M=16` | - | 1 | ok | 9.69e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=4096 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=4096 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=4096 dtype=bf16 act=none M=32` | - | 1 | ok | 7.37e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=4096 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=4096 dtype=bf16 act=none M=56` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=4096 dtype=bf16 act=none M=56` | - | 1 | ok | 2.81e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=4096 dtype=bf16 act=none M=56` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `avx_embed_lookup` | libavx | host | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=448` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | device | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=448` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `embed_lookup` | `ref_embed_lookup` | libref | host | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=448` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=4096 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=4096 dtype=bf16 act=none M=64` | - | 1 | ok | 3.89e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=4096 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=4096 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=4096 dtype=bf16 act=none M=128` | - | 1 | ok | 6.60e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=4096 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=4096 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=4096 dtype=bf16 act=none M=256` | - | 1 | ok | 6.64e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=4096 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=4096 dtype=bf16 act=none M=448` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=4096 dtype=bf16 act=none M=448` | - | 1 | ok | 6.37e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=4096 dtype=bf16 act=none M=448` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=1024 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=1024 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=1024 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=1024 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=1024 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=1024 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=1024 dtype=bf16 act=none M=4` | - | 1 | ok | 6.08e-05 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=1024 dtype=bf16 act=none M=4` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=1024 dtype=bf16 act=none M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=1024 dtype=bf16 act=none M=8` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=1024 dtype=bf16 act=none M=8` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=1024 dtype=bf16 act=none M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=1024 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=1024 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=1024 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=1024 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=1024 dtype=bf16 act=none M=32` | - | 1 | ok | 5.39e-06 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=1024 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=1024 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=1024 dtype=bf16 act=none M=64` | - | 1 | ok | 8.09e-06 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=1024 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=1024 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=1024 dtype=bf16 act=none M=128` | - | 1 | ok | 6.75e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=1024 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=1024 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=1024 dtype=bf16 act=none M=256` | - | 1 | ok | 2.15e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=1024 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=1024 dtype=bf16 act=none M=448` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=1024 dtype=bf16 act=none M=448` | - | 1 | ok | 4.03e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=1024 dtype=bf16 act=none M=448` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=1024 eps=1e-06 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=1024 eps=1e-06 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=1024 eps=1e-06 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=1024 eps=1e-06 dtype=bf16 M=2` | - | 1 | ok | 4.92e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=1024 eps=1e-06 dtype=bf16 M=2` | - | 1 | ok | 4.92e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=1024 eps=1e-06 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=1024 eps=1e-06 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=1024 eps=1e-06 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=1024 eps=1e-06 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=1024 eps=1e-06 dtype=bf16 M=8` | - | 1 | ok | 3.62e-04 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=1024 eps=1e-06 dtype=bf16 M=8` | - | 1 | ok | 3.62e-04 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=1024 eps=1e-06 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=1024 eps=1e-06 dtype=bf16 M=16` | - | 1 | ok | 6.36e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=1024 eps=1e-06 dtype=bf16 M=16` | - | 1 | ok | 6.36e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=1024 eps=1e-06 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=1024 eps=1e-06 dtype=bf16 M=32` | - | 1 | ok | 2.10e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=1024 eps=1e-06 dtype=bf16 M=32` | - | 1 | ok | 2.10e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=1024 eps=1e-06 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=1024 eps=1e-06 dtype=bf16 M=64` | - | 1 | ok | 8.45e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=1024 eps=1e-06 dtype=bf16 M=64` | - | 1 | ok | 8.45e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=1024 eps=1e-06 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=1024 eps=1e-06 dtype=bf16 M=128` | - | 1 | ok | 5.04e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=1024 eps=1e-06 dtype=bf16 M=128` | - | 1 | ok | 4.48e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=1024 eps=1e-06 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=1024 eps=1e-06 dtype=bf16 M=256` | - | 1 | ok | 8.83e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=1024 eps=1e-06 dtype=bf16 M=256` | - | 1 | ok | 8.87e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=1024 eps=1e-06 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `rmsnorm` | `avx_rmsnorm` | libavx | host | `n=1024 eps=1e-06 dtype=bf16 M=448` | - | 1 | ok | 6.98e-05 | 4e-03 | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | device | `n=1024 eps=1e-06 dtype=bf16 M=448` | - | 1 | ok | 7.25e-05 | 4e-03 | +| `rmsnorm` | `ref_rmsnorm` | libref | host | `n=1024 eps=1e-06 dtype=bf16 M=448` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3072 K=1024 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3072 K=1024 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3072 K=1024 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3072 K=1024 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3072 K=1024 dtype=bf16 act=none M=2` | - | 1 | ok | 1.34e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3072 K=1024 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3072 K=1024 dtype=bf16 act=none M=4` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3072 K=1024 dtype=bf16 act=none M=4` | - | 1 | ok | 5.46e-07 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3072 K=1024 dtype=bf16 act=none M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3072 K=1024 dtype=bf16 act=none M=8` | - | 1 | ok | 6.21e-06 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3072 K=1024 dtype=bf16 act=none M=8` | - | 1 | ok | 2.45e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3072 K=1024 dtype=bf16 act=none M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3072 K=1024 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3072 K=1024 dtype=bf16 act=none M=16` | - | 1 | ok | 3.52e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3072 K=1024 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3072 K=1024 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3072 K=1024 dtype=bf16 act=none M=32` | - | 1 | ok | 7.69e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3072 K=1024 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3072 K=1024 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3072 K=1024 dtype=bf16 act=none M=64` | - | 1 | ok | 2.44e-04 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3072 K=1024 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3072 K=1024 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3072 K=1024 dtype=bf16 act=none M=128` | - | 1 | ok | 3.71e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3072 K=1024 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3072 K=1024 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3072 K=1024 dtype=bf16 act=none M=256` | - | 1 | ok | 4.41e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3072 K=1024 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=3072 K=1024 dtype=bf16 act=none M=448` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=3072 K=1024 dtype=bf16 act=none M=448` | - | 1 | ok | 3.72e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=3072 K=1024 dtype=bf16 act=none M=448` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=2048 K=1024 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=2048 K=1024 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=2048 K=1024 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=2048 K=1024 dtype=bf16 act=none M=2` | - | 1 | ok | 1.17e-04 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=2048 K=1024 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=2048 K=1024 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=2048 K=1024 dtype=bf16 act=none M=4` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=2048 K=1024 dtype=bf16 act=none M=4` | - | 1 | ok | 2.15e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=2048 K=1024 dtype=bf16 act=none M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=2048 K=1024 dtype=bf16 act=none M=8` | - | 1 | ok | 3.08e-05 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=2048 K=1024 dtype=bf16 act=none M=8` | - | 1 | ok | 9.56e-07 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=2048 K=1024 dtype=bf16 act=none M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=2048 K=1024 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=2048 K=1024 dtype=bf16 act=none M=16` | - | 1 | ok | 2.12e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=2048 K=1024 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=2048 K=1024 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=2048 K=1024 dtype=bf16 act=none M=32` | - | 1 | ok | 3.01e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=2048 K=1024 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=2048 K=1024 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=2048 K=1024 dtype=bf16 act=none M=64` | - | 1 | ok | 1.96e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=2048 K=1024 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=2048 K=1024 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=2048 K=1024 dtype=bf16 act=none M=128` | - | 1 | ok | 2.56e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=2048 K=1024 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=2048 K=1024 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=2048 K=1024 dtype=bf16 act=none M=256` | - | 1 | ok | 3.15e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=2048 K=1024 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=2048 K=1024 dtype=bf16 act=none M=448` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=2048 K=1024 dtype=bf16 act=none M=448` | - | 1 | ok | 2.11e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=2048 K=1024 dtype=bf16 act=none M=448` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=2048 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=2048 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=2048 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=2048 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=2048 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=2048 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=2048 dtype=bf16 act=none M=4` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=2048 dtype=bf16 act=none M=4` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=2048 dtype=bf16 act=none M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=2048 dtype=bf16 act=none M=8` | - | 1 | ok | 2.25e-06 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=2048 dtype=bf16 act=none M=8` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=2048 dtype=bf16 act=none M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=2048 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=2048 dtype=bf16 act=none M=16` | - | 1 | ok | 4.26e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=2048 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=2048 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=2048 dtype=bf16 act=none M=32` | - | 1 | ok | 5.00e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=2048 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=2048 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=2048 dtype=bf16 act=none M=64` | - | 1 | ok | 3.15e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=2048 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=2048 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=2048 dtype=bf16 act=none M=128` | - | 1 | ok | 3.09e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=2048 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=2048 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=2048 dtype=bf16 act=none M=256` | - | 1 | ok | 4.70e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=2048 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=2048 dtype=bf16 act=none M=448` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=2048 dtype=bf16 act=none M=448` | - | 1 | ok | 3.93e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=2048 dtype=bf16 act=none M=448` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `lili_attn` | `avx_lili_attn` | libavx | host | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=1` | - | 1 | ok | 3.15e-05 | 6e-03 | +| `lili_attn` | `lili_attn_bf16` | libr4d | device | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=1` | - | 1 | ok | 1.86e-06 | 6e-03 | +| `lili_attn` | `ref_lili_attn` | libref | host | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `lili_attn` | `avx_lili_attn` | libavx | host | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=2` | - | 1 | ok | 3.83e-06 | 6e-03 | +| `lili_attn` | `lili_attn_bf16` | libr4d | device | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=2` | - | 1 | ok | 9.20e-10 | 6e-03 | +| `lili_attn` | `ref_lili_attn` | libref | host | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `lili_attn` | `avx_lili_attn` | libavx | host | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=4` | - | 1 | ok | 1.02e-06 | 6e-03 | +| `lili_attn` | `lili_attn_bf16` | libr4d | device | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_attn` | `ref_lili_attn` | libref | host | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `lili_attn` | `avx_lili_attn` | libavx | host | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=8` | - | 1 | ok | 1.81e-05 | 6e-03 | +| `lili_attn` | `lili_attn_bf16` | libr4d | device | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=8` | - | 1 | ok | 6.03e-05 | 6e-03 | +| `lili_attn` | `ref_lili_attn` | libref | host | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `lili_attn` | `avx_lili_attn` | libavx | host | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=16` | - | 1 | ok | 9.86e-06 | 6e-03 | +| `lili_attn` | `lili_attn_bf16` | libr4d | device | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_attn` | `ref_lili_attn` | libref | host | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `lili_attn` | `avx_lili_attn` | libavx | host | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=32` | - | 1 | ok | 3.42e-05 | 6e-03 | +| `lili_attn` | `lili_attn_bf16` | libr4d | device | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=32` | - | 1 | ok | 3.61e-09 | 6e-03 | +| `lili_attn` | `ref_lili_attn` | libref | host | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `lili_attn` | `avx_lili_attn` | libavx | host | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=64` | - | 1 | ok | 8.64e-06 | 6e-03 | +| `lili_attn` | `lili_attn_bf16` | libr4d | device | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=64` | - | 1 | ok | 7.18e-06 | 6e-03 | +| `lili_attn` | `ref_lili_attn` | libref | host | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `lili_attn` | `avx_lili_attn` | libavx | host | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=128` | - | 1 | ok | 9.75e-06 | 6e-03 | +| `lili_attn` | `lili_attn_bf16` | libr4d | device | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=128` | - | 1 | ok | 2.69e-07 | 6e-03 | +| `lili_attn` | `ref_lili_attn` | libref | host | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `lili_attn` | `avx_lili_attn` | libavx | host | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=256` | - | 1 | ok | 8.44e-06 | 6e-03 | +| `lili_attn` | `lili_attn_bf16` | libr4d | device | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=256` | - | 1 | ok | 4.87e-07 | 6e-03 | +| `lili_attn` | `ref_lili_attn` | libref | host | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `lili_attn` | `avx_lili_attn` | libavx | host | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=448` | - | 1 | ok | 1.35e-05 | 6e-03 | +| `lili_attn` | `lili_attn_bf16` | libr4d | device | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=448` | - | 1 | ok | 1.42e-06 | 6e-03 | +| `lili_attn` | `ref_lili_attn` | libref | host | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=448` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu` | `avx_silu` | libavx | host | `n=2048 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `silu_bf16` | libr4d | device | `n=2048 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `ref_silu` | libref | host | `n=2048 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu` | `avx_silu` | libavx | host | `n=2048 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `silu_bf16` | libr4d | device | `n=2048 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `ref_silu` | libref | host | `n=2048 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu` | `avx_silu` | libavx | host | `n=2048 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `silu_bf16` | libr4d | device | `n=2048 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `ref_silu` | libref | host | `n=2048 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu` | `avx_silu` | libavx | host | `n=2048 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `silu_bf16` | libr4d | device | `n=2048 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `ref_silu` | libref | host | `n=2048 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu` | `avx_silu` | libavx | host | `n=2048 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `silu_bf16` | libr4d | device | `n=2048 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `ref_silu` | libref | host | `n=2048 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu` | `avx_silu` | libavx | host | `n=2048 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `silu_bf16` | libr4d | device | `n=2048 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `ref_silu` | libref | host | `n=2048 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu` | `avx_silu` | libavx | host | `n=2048 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `silu_bf16` | libr4d | device | `n=2048 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `ref_silu` | libref | host | `n=2048 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu` | `avx_silu` | libavx | host | `n=2048 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `silu_bf16` | libr4d | device | `n=2048 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `ref_silu` | libref | host | `n=2048 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu` | `avx_silu` | libavx | host | `n=2048 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `silu_bf16` | libr4d | device | `n=2048 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `ref_silu` | libref | host | `n=2048 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu` | `avx_silu` | libavx | host | `n=2048 dtype=bf16 M=448` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `silu_bf16` | libr4d | device | `n=2048 dtype=bf16 M=448` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `ref_silu` | libref | host | `n=2048 dtype=bf16 M=448` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `lili_factor` | `avx_lili_factor` | libavx | host | `L=56 n=1024 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_factor` | `lili_factor_bf16` | libr4d | device | `L=56 n=1024 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_factor` | `ref_lili_factor` | libref | host | `L=56 n=1024 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `lili_factor` | `avx_lili_factor` | libavx | host | `L=56 n=1024 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_factor` | `lili_factor_bf16` | libr4d | device | `L=56 n=1024 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_factor` | `ref_lili_factor` | libref | host | `L=56 n=1024 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `lili_factor` | `avx_lili_factor` | libavx | host | `L=56 n=1024 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_factor` | `lili_factor_bf16` | libr4d | device | `L=56 n=1024 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_factor` | `ref_lili_factor` | libref | host | `L=56 n=1024 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `lili_factor` | `avx_lili_factor` | libavx | host | `L=56 n=1024 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_factor` | `lili_factor_bf16` | libr4d | device | `L=56 n=1024 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_factor` | `ref_lili_factor` | libref | host | `L=56 n=1024 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `lili_factor` | `avx_lili_factor` | libavx | host | `L=56 n=1024 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_factor` | `lili_factor_bf16` | libr4d | device | `L=56 n=1024 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_factor` | `ref_lili_factor` | libref | host | `L=56 n=1024 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `lili_factor` | `avx_lili_factor` | libavx | host | `L=56 n=1024 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_factor` | `lili_factor_bf16` | libr4d | device | `L=56 n=1024 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_factor` | `ref_lili_factor` | libref | host | `L=56 n=1024 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `lili_factor` | `avx_lili_factor` | libavx | host | `L=56 n=1024 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_factor` | `lili_factor_bf16` | libr4d | device | `L=56 n=1024 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_factor` | `ref_lili_factor` | libref | host | `L=56 n=1024 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `lili_factor` | `avx_lili_factor` | libavx | host | `L=56 n=1024 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_factor` | `lili_factor_bf16` | libr4d | device | `L=56 n=1024 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_factor` | `ref_lili_factor` | libref | host | `L=56 n=1024 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `lili_factor` | `avx_lili_factor` | libavx | host | `L=56 n=1024 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_factor` | `lili_factor_bf16` | libr4d | device | `L=56 n=1024 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_factor` | `ref_lili_factor` | libref | host | `L=56 n=1024 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `lili_factor` | `avx_lili_factor` | libavx | host | `L=56 n=1024 dtype=bf16 M=448` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_factor` | `lili_factor_bf16` | libr4d | device | `L=56 n=1024 dtype=bf16 M=448` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_factor` | `ref_lili_factor` | libref | host | `L=56 n=1024 dtype=bf16 M=448` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=3072 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=3072 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=3072 dtype=bf16 act=none M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=3072 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=3072 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=3072 dtype=bf16 act=none M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=3072 dtype=bf16 act=none M=4` | - | 1 | ok | 7.07e-05 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=3072 dtype=bf16 act=none M=4` | - | 1 | ok | 2.20e-06 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=3072 dtype=bf16 act=none M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=3072 dtype=bf16 act=none M=8` | - | 1 | ok | 2.05e-04 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=3072 dtype=bf16 act=none M=8` | - | 1 | ok | 2.05e-04 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=3072 dtype=bf16 act=none M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=3072 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=3072 dtype=bf16 act=none M=16` | - | 1 | ok | 7.04e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=3072 dtype=bf16 act=none M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=3072 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=3072 dtype=bf16 act=none M=32` | - | 1 | ok | 8.65e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=3072 dtype=bf16 act=none M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=3072 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=3072 dtype=bf16 act=none M=64` | - | 1 | ok | 5.76e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=3072 dtype=bf16 act=none M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=3072 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=3072 dtype=bf16 act=none M=128` | - | 1 | ok | 4.24e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=3072 dtype=bf16 act=none M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=3072 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=3072 dtype=bf16 act=none M=256` | - | 1 | ok | 5.94e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=3072 dtype=bf16 act=none M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | host | `N=1024 K=3072 dtype=bf16 act=none M=448` | - | 1 | ok | 0.00e+00 | 8e-03 | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | device | `N=1024 K=3072 dtype=bf16 act=none M=448` | - | 1 | ok | 7.17e-05 | 8e-03 | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | host | `N=1024 K=3072 dtype=bf16 act=none M=448` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu` | `avx_silu` | libavx | host | `n=1024 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `silu_bf16` | libr4d | device | `n=1024 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `ref_silu` | libref | host | `n=1024 dtype=bf16 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu` | `avx_silu` | libavx | host | `n=1024 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `silu_bf16` | libr4d | device | `n=1024 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `ref_silu` | libref | host | `n=1024 dtype=bf16 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu` | `avx_silu` | libavx | host | `n=1024 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `silu_bf16` | libr4d | device | `n=1024 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `ref_silu` | libref | host | `n=1024 dtype=bf16 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu` | `avx_silu` | libavx | host | `n=1024 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `silu_bf16` | libr4d | device | `n=1024 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `ref_silu` | libref | host | `n=1024 dtype=bf16 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu` | `avx_silu` | libavx | host | `n=1024 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `silu_bf16` | libr4d | device | `n=1024 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `ref_silu` | libref | host | `n=1024 dtype=bf16 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu` | `avx_silu` | libavx | host | `n=1024 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `silu_bf16` | libr4d | device | `n=1024 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `ref_silu` | libref | host | `n=1024 dtype=bf16 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu` | `avx_silu` | libavx | host | `n=1024 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `silu_bf16` | libr4d | device | `n=1024 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `ref_silu` | libref | host | `n=1024 dtype=bf16 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu` | `avx_silu` | libavx | host | `n=1024 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `silu_bf16` | libr4d | device | `n=1024 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `ref_silu` | libref | host | `n=1024 dtype=bf16 M=128` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu` | `avx_silu` | libavx | host | `n=1024 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `silu_bf16` | libr4d | device | `n=1024 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `ref_silu` | libref | host | `n=1024 dtype=bf16 M=256` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `silu` | `avx_silu` | libavx | host | `n=1024 dtype=bf16 M=448` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `silu_bf16` | libr4d | device | `n=1024 dtype=bf16 M=448` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `silu` | `ref_silu` | libref | host | `n=1024 dtype=bf16 M=448` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `lili_walk` | `avx_lili_walk` | libavx | host | `steps=7 k=8 n=1024 dtype=bf16 eps=0.0001 scale=8 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_walk` | `lili_walk_bf16` | libr4d | device | `steps=7 k=8 n=1024 dtype=bf16 eps=0.0001 scale=8 M=1` | - | 1 | ok | 1.88e-06 | 6e-03 | +| `lili_walk` | `ref_lili_walk` | libref | host | `steps=7 k=8 n=1024 dtype=bf16 eps=0.0001 scale=8 M=1` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_walk` | `avx_lili_walk` | libavx | host | `steps=7 k=8 n=1024 dtype=bf16 eps=0.0001 scale=8 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_walk` | `lili_walk_bf16` | libr4d | device | `steps=7 k=8 n=1024 dtype=bf16 eps=0.0001 scale=8 M=2` | - | 1 | ok | 1.89e-06 | 6e-03 | +| `lili_walk` | `ref_lili_walk` | libref | host | `steps=7 k=8 n=1024 dtype=bf16 eps=0.0001 scale=8 M=2` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_walk` | `avx_lili_walk` | libavx | host | `steps=7 k=8 n=1024 dtype=bf16 eps=0.0001 scale=8 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_walk` | `lili_walk_bf16` | libr4d | device | `steps=7 k=8 n=1024 dtype=bf16 eps=0.0001 scale=8 M=4` | - | 1 | ok | 1.55e-06 | 6e-03 | +| `lili_walk` | `ref_lili_walk` | libref | host | `steps=7 k=8 n=1024 dtype=bf16 eps=0.0001 scale=8 M=4` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_walk` | `avx_lili_walk` | libavx | host | `steps=7 k=8 n=1024 dtype=bf16 eps=0.0001 scale=8 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `lili_walk` | `lili_walk_bf16` | libr4d | device | `steps=7 k=8 n=1024 dtype=bf16 eps=0.0001 scale=8 M=8` | - | 1 | ok | 1.62e-06 | 6e-03 | +| `lili_walk` | `ref_lili_walk` | libref | host | `steps=7 k=8 n=1024 dtype=bf16 eps=0.0001 scale=8 M=8` | - | 1 | ok | 0.00e+00 | 6e-03 | +| `sample_penalties` | `avx_sample_penalties` | libavx | host | `n_vocab=131072 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_penalties` | `sample_penalties_f32` | libr4d | device | `n_vocab=131072 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_penalties` | `ref_sample_penalties` | libref | host | `n_vocab=131072 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_penalties` | `avx_sample_penalties` | libavx | host | `n_vocab=131072 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_penalties` | `sample_penalties_f32` | libr4d | device | `n_vocab=131072 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_penalties` | `ref_sample_penalties` | libref | host | `n_vocab=131072 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_penalties` | `avx_sample_penalties` | libavx | host | `n_vocab=131072 M=4` | - | 1 | ok | 9.54e-10 | 1e-06 | +| `sample_penalties` | `sample_penalties_f32` | libr4d | device | `n_vocab=131072 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_penalties` | `ref_sample_penalties` | libref | host | `n_vocab=131072 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_penalties` | `avx_sample_penalties` | libavx | host | `n_vocab=131072 M=8` | - | 1 | ok | 3.69e-10 | 1e-06 | +| `sample_penalties` | `sample_penalties_f32` | libr4d | device | `n_vocab=131072 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_penalties` | `ref_sample_penalties` | libref | host | `n_vocab=131072 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_penalties` | `avx_sample_penalties` | libavx | host | `n_vocab=131072 M=16` | - | 1 | ok | 8.09e-10 | 1e-06 | +| `sample_penalties` | `sample_penalties_f32` | libr4d | device | `n_vocab=131072 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_penalties` | `ref_sample_penalties` | libref | host | `n_vocab=131072 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_penalties` | `avx_sample_penalties` | libavx | host | `n_vocab=131072 M=32` | - | 1 | ok | 6.36e-10 | 1e-06 | +| `sample_penalties` | `sample_penalties_f32` | libr4d | device | `n_vocab=131072 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_penalties` | `ref_sample_penalties` | libref | host | `n_vocab=131072 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_penalties` | `avx_sample_penalties` | libavx | host | `n_vocab=131072 M=64` | - | 1 | ok | 6.84e-10 | 1e-06 | +| `sample_penalties` | `sample_penalties_f32` | libr4d | device | `n_vocab=131072 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_penalties` | `ref_sample_penalties` | libref | host | `n_vocab=131072 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_dry` | `avx_sample_dry` | libavx | host | `n_vocab=131072 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_dry` | `sample_dry_f32` | libr4d | device | `n_vocab=131072 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_dry` | `ref_sample_dry` | libref | host | `n_vocab=131072 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_dry` | `avx_sample_dry` | libavx | host | `n_vocab=131072 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_dry` | `sample_dry_f32` | libr4d | device | `n_vocab=131072 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_dry` | `ref_sample_dry` | libref | host | `n_vocab=131072 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_dry` | `avx_sample_dry` | libavx | host | `n_vocab=131072 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_dry` | `sample_dry_f32` | libr4d | device | `n_vocab=131072 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_dry` | `ref_sample_dry` | libref | host | `n_vocab=131072 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_dry` | `avx_sample_dry` | libavx | host | `n_vocab=131072 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_dry` | `sample_dry_f32` | libr4d | device | `n_vocab=131072 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_dry` | `ref_sample_dry` | libref | host | `n_vocab=131072 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_dry` | `avx_sample_dry` | libavx | host | `n_vocab=131072 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_dry` | `sample_dry_f32` | libr4d | device | `n_vocab=131072 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_dry` | `ref_sample_dry` | libref | host | `n_vocab=131072 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_dry` | `avx_sample_dry` | libavx | host | `n_vocab=131072 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_dry` | `sample_dry_f32` | libr4d | device | `n_vocab=131072 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_dry` | `ref_sample_dry` | libref | host | `n_vocab=131072 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_dry` | `avx_sample_dry` | libavx | host | `n_vocab=131072 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_dry` | `sample_dry_f32` | libr4d | device | `n_vocab=131072 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_dry` | `ref_sample_dry` | libref | host | `n_vocab=131072 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_ngram_ban` | `avx_sample_ngram_ban` | libavx | host | `n_vocab=131072 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_ngram_ban` | `sample_ngram_ban_f32` | libr4d | device | `n_vocab=131072 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_ngram_ban` | `ref_sample_ngram_ban` | libref | host | `n_vocab=131072 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_ngram_ban` | `avx_sample_ngram_ban` | libavx | host | `n_vocab=131072 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_ngram_ban` | `sample_ngram_ban_f32` | libr4d | device | `n_vocab=131072 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_ngram_ban` | `ref_sample_ngram_ban` | libref | host | `n_vocab=131072 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_ngram_ban` | `avx_sample_ngram_ban` | libavx | host | `n_vocab=131072 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_ngram_ban` | `sample_ngram_ban_f32` | libr4d | device | `n_vocab=131072 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_ngram_ban` | `ref_sample_ngram_ban` | libref | host | `n_vocab=131072 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_ngram_ban` | `avx_sample_ngram_ban` | libavx | host | `n_vocab=131072 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_ngram_ban` | `sample_ngram_ban_f32` | libr4d | device | `n_vocab=131072 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_ngram_ban` | `ref_sample_ngram_ban` | libref | host | `n_vocab=131072 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_ngram_ban` | `avx_sample_ngram_ban` | libavx | host | `n_vocab=131072 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_ngram_ban` | `sample_ngram_ban_f32` | libr4d | device | `n_vocab=131072 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_ngram_ban` | `ref_sample_ngram_ban` | libref | host | `n_vocab=131072 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_ngram_ban` | `avx_sample_ngram_ban` | libavx | host | `n_vocab=131072 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_ngram_ban` | `sample_ngram_ban_f32` | libr4d | device | `n_vocab=131072 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_ngram_ban` | `ref_sample_ngram_ban` | libref | host | `n_vocab=131072 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_ngram_ban` | `avx_sample_ngram_ban` | libavx | host | `n_vocab=131072 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_ngram_ban` | `sample_ngram_ban_f32` | libr4d | device | `n_vocab=131072 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_ngram_ban` | `ref_sample_ngram_ban` | libref | host | `n_vocab=131072 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_temp` | `avx_sample_temp` | libavx | host | `n_vocab=131072 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `sample_temp_f32` | libr4d | device | `n_vocab=131072 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `ref_sample_temp` | libref | host | `n_vocab=131072 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_temp` | `avx_sample_temp` | libavx | host | `n_vocab=131072 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `sample_temp_f32` | libr4d | device | `n_vocab=131072 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `ref_sample_temp` | libref | host | `n_vocab=131072 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_temp` | `avx_sample_temp` | libavx | host | `n_vocab=131072 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `sample_temp_f32` | libr4d | device | `n_vocab=131072 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `ref_sample_temp` | libref | host | `n_vocab=131072 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_temp` | `avx_sample_temp` | libavx | host | `n_vocab=131072 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `sample_temp_f32` | libr4d | device | `n_vocab=131072 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `ref_sample_temp` | libref | host | `n_vocab=131072 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_temp` | `avx_sample_temp` | libavx | host | `n_vocab=131072 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `sample_temp_f32` | libr4d | device | `n_vocab=131072 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `ref_sample_temp` | libref | host | `n_vocab=131072 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_temp` | `avx_sample_temp` | libavx | host | `n_vocab=131072 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `sample_temp_f32` | libr4d | device | `n_vocab=131072 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `ref_sample_temp` | libref | host | `n_vocab=131072 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_temp` | `avx_sample_temp` | libavx | host | `n_vocab=131072 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `sample_temp_f32` | libr4d | device | `n_vocab=131072 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_temp` | `ref_sample_temp` | libref | host | `n_vocab=131072 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_mask` | `avx_sample_mask` | libavx | host | `n_vocab=131072 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_mask` | `sample_mask_f32` | libr4d | device | `n_vocab=131072 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_mask` | `ref_sample_mask` | libref | host | `n_vocab=131072 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_mask` | `avx_sample_mask` | libavx | host | `n_vocab=131072 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_mask` | `sample_mask_f32` | libr4d | device | `n_vocab=131072 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_mask` | `ref_sample_mask` | libref | host | `n_vocab=131072 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_mask` | `avx_sample_mask` | libavx | host | `n_vocab=131072 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_mask` | `sample_mask_f32` | libr4d | device | `n_vocab=131072 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_mask` | `ref_sample_mask` | libref | host | `n_vocab=131072 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_mask` | `avx_sample_mask` | libavx | host | `n_vocab=131072 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_mask` | `sample_mask_f32` | libr4d | device | `n_vocab=131072 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_mask` | `ref_sample_mask` | libref | host | `n_vocab=131072 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_mask` | `avx_sample_mask` | libavx | host | `n_vocab=131072 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_mask` | `sample_mask_f32` | libr4d | device | `n_vocab=131072 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_mask` | `ref_sample_mask` | libref | host | `n_vocab=131072 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_mask` | `avx_sample_mask` | libavx | host | `n_vocab=131072 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_mask` | `sample_mask_f32` | libr4d | device | `n_vocab=131072 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_mask` | `ref_sample_mask` | libref | host | `n_vocab=131072 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_mask` | `avx_sample_mask` | libavx | host | `n_vocab=131072 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_mask` | `sample_mask_f32` | libr4d | device | `n_vocab=131072 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_mask` | `ref_sample_mask` | libref | host | `n_vocab=131072 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_topk` | `avx_sample_topk` | libavx | host | `n_vocab=131072 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_topk` | `sample_topk_f32` | libr4d | device | `n_vocab=131072 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_topk` | `ref_sample_topk` | libref | host | `n_vocab=131072 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_topk` | `avx_sample_topk` | libavx | host | `n_vocab=131072 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_topk` | `sample_topk_f32` | libr4d | device | `n_vocab=131072 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_topk` | `ref_sample_topk` | libref | host | `n_vocab=131072 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_topk` | `avx_sample_topk` | libavx | host | `n_vocab=131072 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_topk` | `sample_topk_f32` | libr4d | device | `n_vocab=131072 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_topk` | `ref_sample_topk` | libref | host | `n_vocab=131072 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_topk` | `avx_sample_topk` | libavx | host | `n_vocab=131072 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_topk` | `sample_topk_f32` | libr4d | device | `n_vocab=131072 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_topk` | `ref_sample_topk` | libref | host | `n_vocab=131072 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_topk` | `avx_sample_topk` | libavx | host | `n_vocab=131072 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_topk` | `sample_topk_f32` | libr4d | device | `n_vocab=131072 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_topk` | `ref_sample_topk` | libref | host | `n_vocab=131072 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_topk` | `avx_sample_topk` | libavx | host | `n_vocab=131072 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_topk` | `sample_topk_f32` | libr4d | device | `n_vocab=131072 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_topk` | `ref_sample_topk` | libref | host | `n_vocab=131072 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_topk` | `avx_sample_topk` | libavx | host | `n_vocab=131072 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_topk` | `sample_topk_f32` | libr4d | device | `n_vocab=131072 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_topk` | `ref_sample_topk` | libref | host | `n_vocab=131072 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_argmax` | `avx_sample_argmax` | libavx | host | `n_vocab=131072 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_argmax` | `sample_argmax_f32` | libr4d | device | `n_vocab=131072 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_argmax` | `ref_sample_argmax` | libref | host | `n_vocab=131072 M=1` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_argmax` | `avx_sample_argmax` | libavx | host | `n_vocab=131072 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_argmax` | `sample_argmax_f32` | libr4d | device | `n_vocab=131072 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_argmax` | `ref_sample_argmax` | libref | host | `n_vocab=131072 M=2` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_argmax` | `avx_sample_argmax` | libavx | host | `n_vocab=131072 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_argmax` | `sample_argmax_f32` | libr4d | device | `n_vocab=131072 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_argmax` | `ref_sample_argmax` | libref | host | `n_vocab=131072 M=4` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_argmax` | `avx_sample_argmax` | libavx | host | `n_vocab=131072 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_argmax` | `sample_argmax_f32` | libr4d | device | `n_vocab=131072 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_argmax` | `ref_sample_argmax` | libref | host | `n_vocab=131072 M=8` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_argmax` | `avx_sample_argmax` | libavx | host | `n_vocab=131072 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_argmax` | `sample_argmax_f32` | libr4d | device | `n_vocab=131072 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_argmax` | `ref_sample_argmax` | libref | host | `n_vocab=131072 M=16` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_argmax` | `avx_sample_argmax` | libavx | host | `n_vocab=131072 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_argmax` | `sample_argmax_f32` | libr4d | device | `n_vocab=131072 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_argmax` | `ref_sample_argmax` | libref | host | `n_vocab=131072 M=32` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_argmax` | `avx_sample_argmax` | libavx | host | `n_vocab=131072 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_argmax` | `sample_argmax_f32` | libr4d | device | `n_vocab=131072 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_argmax` | `ref_sample_argmax` | libref | host | `n_vocab=131072 M=64` | - | 1 | ok | 0.00e+00 | 1e-06 | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=131072 k=21 M=1` | - | 1 | ok | 6.65e-10 | 1e-05 | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | device | `n_vocab=131072 k=21 M=1` | - | 1 | ok | 0.00e+00 | 1e-05 | +| `sample_logprobs` | `ref_sample_logprobs` | libref | host | `n_vocab=131072 k=21 M=1` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=131072 k=21 M=2` | - | 1 | ok | 2.27e-09 | 1e-05 | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | device | `n_vocab=131072 k=21 M=2` | - | 1 | ok | 4.53e-10 | 1e-05 | +| `sample_logprobs` | `ref_sample_logprobs` | libref | host | `n_vocab=131072 k=21 M=2` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=131072 k=21 M=4` | - | 1 | ok | 1.75e-09 | 1e-05 | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | device | `n_vocab=131072 k=21 M=4` | - | 1 | ok | 8.84e-10 | 1e-05 | +| `sample_logprobs` | `ref_sample_logprobs` | libref | host | `n_vocab=131072 k=21 M=4` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=131072 k=21 M=8` | - | 1 | ok | 7.49e-10 | 1e-05 | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | device | `n_vocab=131072 k=21 M=8` | - | 1 | ok | 5.11e-10 | 1e-05 | +| `sample_logprobs` | `ref_sample_logprobs` | libref | host | `n_vocab=131072 k=21 M=8` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=131072 k=21 M=16` | - | 1 | ok | 2.06e-09 | 1e-05 | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | device | `n_vocab=131072 k=21 M=16` | - | 1 | ok | 1.00e-09 | 1e-05 | +| `sample_logprobs` | `ref_sample_logprobs` | libref | host | `n_vocab=131072 k=21 M=16` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=131072 k=21 M=32` | - | 1 | ok | 1.08e-09 | 1e-05 | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | device | `n_vocab=131072 k=21 M=32` | - | 1 | ok | 1.22e-09 | 1e-05 | +| `sample_logprobs` | `ref_sample_logprobs` | libref | host | `n_vocab=131072 k=21 M=32` | - | 1 | ok | 0.00e+00 | 0e+00 | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | host | `n_vocab=131072 k=21 M=64` | - | 1 | ok | 1.31e-09 | 1e-05 | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | device | `n_vocab=131072 k=21 M=64` | - | 1 | ok | 7.08e-10 | 1e-05 | +| `sample_logprobs` | `ref_sample_logprobs` | libref | host | `n_vocab=131072 k=21 M=64` | - | 1 | ok | 0.00e+00 | 0e+00 | ## Speed @@ -2845,1482 +6296,5063 @@ Device timing and its calibration: > > cold: each launch reads its weights, weight tables and inputs of 8.00 MiB or more from one of a set of copies spanning 256.00 MiB, so from memory; smaller inputs stay warm, as the previous op leaves them; in-place operands are restored before every launch and the restores' own time subtracted > -> launch floor: 2.14 us a launch back to back in a batch, 4.84 us alone between two events (the backend's own 4-byte fill, the cheapest kernel a tool can launch); a batch lasts at least 1000 us +> launch floor: 2.44 us a launch back to back in a batch, 6.12 us alone between two events (the backend's own 4-byte fill, the cheapest kernel a tool can launch); a batch lasts at least 1000 us > -> read bandwidth (ranged copies into a 1 MiB ring, so the writes stay in the cache), warm / cold: 4.00 MiB 320 / 324 GB/s; 16.00 MiB 1417 / 480 GB/s; 64.00 MiB 1764 / 602 GB/s; 256.00 MiB 629 / 629 GB/s +> read bandwidth (ranged copies into a 1 MiB ring, so the writes stay in the cache), warm / cold: 4.00 MiB 206 / 203 GB/s; 16.00 MiB 1444 / 393 GB/s; 64.00 MiB 1759 / 570 GB/s; 256.00 MiB 628 / 624 GB/s > -> clock: 3245 MHz averaged graphics clock after a 2000 ms warm-up (gpu_metrics); on at idle, not counted: TEMP_HOTSPOT; on under the warm-up's load, binding throughout and not counted: PPT0; a batch during which another throttler came on is repeated +> clock: 3232 MHz averaged graphics clock after a 2000 ms warm-up (gpu_metrics); on at idle, not counted: TEMP_HOTSPOT; on under the warm-up's load, binding throughout and not counted: PPT0; a batch during which another throttler came on is repeated | op | kernel | library | geometry | device us | host us | min | p90 | n | ±% | MHz | operands | notes | |---|---|---|---|---|---|---|---|---|---|---|---|---| -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | - | 6279838.66 | 6279838.66 | 6279838.66 | 1 | - | - | 44.00 MiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=512 tn=0` | - | 4155022.72 | 4155022.72 | 4155022.72 | 1 | - | - | 88.20 MiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | - | 2888453.88 | 2888453.88 | 2888453.88 | 1 | - | - | 38.19 MiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=258 tn=0` | - | 2106871.18 | 2106871.18 | 2106871.18 | 1 | - | - | 79.33 MiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | - | 1732679.63 | 1705393.49 | 1759965.77 | 2 | 1.6 | - | 35.10 MiB | 32 thread(s); 2 timed launch(es) within the 2 s host budget | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=129 tn=0` | - | 1082439.92 | 1068723.95 | 1096155.89 | 2 | 1.3 | - | 74.82 MiB | 32 thread(s); 2 timed launch(es) within the 2 s host budget | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=128 ks=0 bk=0 nt=0` | - | 1039280.58 | 1038198.86 | 1040362.29 | 2 | 0.1 | - | 74.79 MiB | 32 thread(s); 2 timed launch(es) within the 2 s host budget | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | - | 888574.31 | 859059.82 | 889376.71 | 3 | 1.7 | - | 33.55 MiB | 32 thread(s); 3 timed launch(es) within the 2 s host budget | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=65 ks=0 bk=0 nt=0` | - | 549367.37 | 549256.47 | 549603.38 | 4 | 0.0 | - | 72.58 MiB | 32 thread(s); 4 timed launch(es) within the 2 s host budget | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 518622.97 | 518516.85 | 519228.34 | 4 | 0.1 | - | 72.55 MiB | 32 thread(s); 4 timed launch(es) within the 2 s host budget | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | - | 442653.59 | 442568.03 | 443207.98 | 5 | 0.1 | - | 32.78 MiB | 32 thread(s); 5 timed launch(es) within the 2 s host budget | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | - | 429693.71 | 429168.88 | 430590.52 | 5 | 0.2 | - | 32.75 MiB | 32 thread(s); 5 timed launch(es) within the 2 s host budget | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 351854.86 | 351417.26 | 351939.64 | 6 | 0.1 | - | 49.53 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=512` | - | 328291.96 | 327900.26 | 328705.11 | 6 | 0.1 | - | 206.60 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 327875.47 | 326741.53 | 377330.25 | 6 | 7.7 | - | 100.20 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 291904.77 | 291713.86 | 292211.07 | 6 | 0.1 | - | 71.57 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=512` | - | 215410.27 | 215100.46 | 215614.23 | 6 | 0.1 | - | 98.78 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 198358.57 | 198117.88 | 198474.15 | 6 | 0.1 | - | 48.78 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 178054.62 | 169525.51 | 200811.86 | 11 | 8.8 | - | 98.20 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=258` | - | 170942.02 | 170415.47 | 172283.14 | 6 | 0.5 | - | 188.45 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 160638.71 | 160502.32 | 160722.14 | 6 | 0.1 | - | 70.94 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=512` | - | 154888.66 | 154819.00 | 155233.69 | 6 | 0.1 | - | 98.59 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=512` | - | 119795.34 | 119665.60 | 119843.12 | 6 | 0.1 | - | 74.59 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 109097.75 | 109007.77 | 109131.72 | 6 | 0.1 | - | 48.30 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=258` | - | 108465.62 | 107933.77 | 108620.79 | 6 | 0.3 | - | 91.95 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 104865.56 | 104748.85 | 105065.96 | 6 | 0.2 | - | 96.91 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 94401.70 | 94360.47 | 94535.94 | 6 | 0.1 | - | 70.63 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=129` | - | 82474.04 | 82426.54 | 82594.74 | 6 | 0.1 | - | 179.24 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=128` | - | 82209.80 | 81840.95 | 82507.37 | 6 | 0.4 | - | 179.17 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=258` | - | 78245.42 | 78231.86 | 78562.90 | 6 | 0.2 | - | 89.37 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=512 tn=0` | - | 75485.50 | 75424.78 | 75515.79 | 6 | 0.1 | - | 6.39 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 64705.77 | 64677.23 | 64772.02 | 6 | 0.1 | - | 70.59 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=512` | - | 64570.37 | 64551.29 | 64699.21 | 6 | 0.1 | - | 38.10 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 64192.15 | 64101.63 | 64229.47 | 6 | 0.1 | - | 48.05 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=258` | - | 60304.27 | 60109.47 | 60370.85 | 6 | 0.2 | - | 67.35 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=129` | - | 54814.38 | 54703.52 | 54986.91 | 6 | 0.3 | - | 88.48 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=128` | - | 54258.37 | 54002.21 | 55001.78 | 6 | 0.9 | - | 88.45 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 53011.12 | 52816.02 | 53078.79 | 6 | 0.2 | - | 96.27 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 50106.70 | 50017.83 | 53553.75 | 20 | 1.6 | - | 96.20 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | - | 49994.63 | 42676.96 | 56218.13 | 20 | 8.9 | - | 10.19 MiB | 32 thread(s) | -| `logits_gemm` | `avx_logits_gemm` | libavx | `n_vocab=248320 n_embd=5120 dtype=bf16 M=64` | - | 49238.59 | 49041.81 | 49319.85 | 6 | 0.3 | - | 2.43 GiB | 32 thread(s) | -| `logits_gemm` | `avx_logits_gemm` | libavx | `n_vocab=248320 n_embd=5120 dtype=bf16 M=16` | - | 46504.59 | 46468.01 | 46542.55 | 6 | 0.1 | - | 2.38 GiB | 32 thread(s) | -| `logits_gemm` | `avx_logits_gemm` | libavx | `n_vocab=248320 n_embd=5120 dtype=bf16 M=32` | - | 46168.73 | 46123.00 | 46268.50 | 6 | 0.2 | - | 2.40 GiB | 32 thread(s) | -| `logits_gemm` | `avx_logits_gemm` | libavx | `n_vocab=248320 n_embd=5120 dtype=bf16 M=8` | - | 44313.69 | 44193.56 | 44508.82 | 6 | 0.4 | - | 2.38 GiB | 32 thread(s) | -| `logits_gemm` | `avx_logits_gemm` | libavx | `n_vocab=248320 n_embd=5120 dtype=bf16 M=4` | - | 44126.68 | 44041.87 | 44172.62 | 6 | 0.1 | - | 2.37 GiB | 32 thread(s) | -| `logits_gemm` | `avx_logits_gemm` | libavx | `n_vocab=248320 n_embd=5120 dtype=bf16 M=1` | - | 44092.88 | 43813.02 | 44306.72 | 6 | 0.6 | - | 2.37 GiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 44010.38 | 43943.00 | 44063.86 | 6 | 0.1 | - | 48.03 MiB | 32 thread(s) | -| `logits_gemm` | `avx_logits_gemm` | libavx | `n_vocab=248320 n_embd=5120 dtype=bf16 M=2` | - | 43586.54 | 43540.05 | 43723.01 | 6 | 0.2 | - | 2.37 GiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 43359.08 | 43290.80 | 43404.92 | 6 | 0.1 | - | 95.91 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=65` | - | 42289.78 | 42102.32 | 42349.13 | 6 | 0.3 | - | 174.66 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | - | 42099.14 | 40270.51 | 57081.93 | 20 | 8.7 | - | 16.00 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=64` | - | 41666.52 | 41307.89 | 41709.87 | 6 | 0.5 | - | 174.59 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 41301.72 | 41267.07 | 41457.89 | 6 | 0.2 | - | 95.77 MiB | 32 thread(s) | -| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=64` | - | 40465.42 | 40417.82 | 40639.25 | 6 | 0.3 | - | 173.56 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 39693.70 | 39567.76 | 39866.84 | 6 | 0.4 | - | 95.70 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=129` | - | 39133.14 | 39011.23 | 39318.62 | 6 | 0.4 | - | 84.69 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 38875.41 | 38814.38 | 38887.78 | 6 | 0.1 | - | 12.07 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=128` | - | 38793.61 | 38641.71 | 38878.47 | 6 | 0.3 | - | 84.65 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=258 tn=0` | - | 38307.60 | 38250.19 | 38725.86 | 6 | 0.6 | - | 4.62 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 32365.44 | 32309.80 | 32420.97 | 6 | 0.2 | - | 70.45 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=258` | - | 32340.91 | 31474.55 | 32398.43 | 11 | 0.9 | - | 34.08 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 30911.62 | 30833.33 | 34301.53 | 20 | 2.6 | - | 70.38 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 30275.42 | 30149.27 | 30305.58 | 6 | 0.3 | - | 12.13 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=129` | - | 30269.63 | 30189.27 | 30350.88 | 6 | 0.3 | - | 63.68 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=128` | - | 30014.27 | 29863.73 | 30037.22 | 6 | 0.3 | - | 63.65 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 29511.96 | 29469.99 | 29537.88 | 6 | 0.1 | - | 70.35 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=65` | - | 27787.97 | 27758.75 | 28041.79 | 6 | 0.5 | - | 86.76 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=64` | - | 27055.37 | 27019.58 | 27122.99 | 6 | 0.2 | - | 86.73 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | - | 25094.49 | 19795.50 | 28553.08 | 20 | 10.3 | - | 7.09 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=36` | - | 22831.94 | 22695.01 | 22961.41 | 6 | 0.6 | - | 172.59 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 22034.31 | 21977.85 | 25298.99 | 19 | 0.1 | - | 47.92 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 21021.28 | 20949.69 | 22645.57 | 14 | 0.6 | - | 47.87 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=65` | - | 20622.69 | 19848.82 | 20708.32 | 19 | 0.2 | - | 82.37 MiB | 32 thread(s) | -| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=32` | - | 20370.77 | 20300.95 | 20489.65 | 6 | 0.5 | - | 171.79 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 20318.18 | 20176.38 | 25330.90 | 20 | 12.1 | - | 11.75 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 20222.66 | 20178.15 | 22059.20 | 14 | 0.1 | - | 11.71 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 20094.03 | 20039.49 | 20149.54 | 11 | 0.3 | - | 47.84 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=64` | - | 19613.62 | 19479.94 | 19646.86 | 11 | 0.1 | - | 82.33 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=129 tn=0` | - | 19186.80 | 19104.93 | 19266.86 | 6 | 0.4 | - | 3.71 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=128 ks=0 bk=0 nt=0` | - | 19065.87 | 19037.33 | 19244.74 | 6 | 0.5 | - | 3.71 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | - | 17701.40 | 17504.04 | 18368.57 | 16 | 0.7 | - | 5.55 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=129` | - | 16218.91 | 16147.07 | 16284.71 | 11 | 0.4 | - | 32.04 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=128` | - | 15809.08 | 15638.36 | 15878.55 | 6 | 0.8 | - | 32.03 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=36` | - | 15305.98 | 15253.77 | 23834.21 | 14 | 0.6 | - | 85.98 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=65` | - | 14972.51 | 14869.96 | 19458.31 | 14 | 0.3 | - | 61.86 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=64` | - | 14614.20 | 14551.34 | 14631.23 | 6 | 0.3 | - | 61.83 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=17` | - | 14053.32 | 14003.33 | 18429.84 | 16 | 0.3 | - | 32.40 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | - | 12849.68 | 12448.54 | 12924.99 | 14 | 0.8 | - | 32.38 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 12514.79 | 12420.19 | 12540.15 | 6 | 0.5 | - | 11.50 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 12461.48 | 12406.13 | 12537.80 | 6 | 0.5 | - | 11.48 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=18` | - | 12094.05 | 12078.00 | 12191.45 | 6 | 0.5 | - | 171.31 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=9 splits=0` | - | 12002.43 | 8467.67 | 12283.43 | 20 | 15.5 | - | 32.21 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=512` | - | 11417.08 | 11311.06 | 16866.86 | 19 | 0.5 | - | 8.58 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=36` | - | 11159.90 | 11060.76 | 16880.61 | 19 | 0.2 | - | 81.32 MiB | 32 thread(s) | -| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=16` | - | 10760.19 | 10733.02 | 16663.62 | 16 | 0.4 | - | 170.91 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=65 ks=0 bk=0 nt=0` | - | 10206.59 | 10125.99 | 10275.97 | 11 | 0.5 | - | 3.27 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 10160.29 | 10035.26 | 10187.16 | 11 | 0.3 | - | 3.26 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | - | 9144.90 | 8980.83 | 9261.28 | 20 | 1.0 | - | 4.77 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | - | 9071.00 | 8982.39 | 9175.31 | 11 | 1.0 | - | 4.75 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | - | 9065.15 | 8959.90 | 9110.98 | 6 | 0.8 | - | 32.19 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=4608 dtype=bf16 act=none M=512` | - | 8779.54 | 8579.50 | 8997.17 | 19 | 0.9 | - | 59.51 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=11` | - | 8667.47 | 8622.13 | 13714.88 | 20 | 23.9 | - | 32.26 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=10 splits=0` | - | 8656.79 | 8475.00 | 8722.50 | 11 | 0.9 | - | 32.24 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4608 K=4608 dtype=bf16 act=gelu M=512` | - | 8535.17 | 8008.35 | 10277.93 | 20 | 8.4 | - | 54.01 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=65` | - | 8241.16 | 8064.95 | 8260.28 | 11 | 0.8 | - | 31.03 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=64` | - | 8098.22 | 7866.78 | 8140.62 | 19 | 0.3 | - | 31.02 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=36` | - | 8092.43 | 8022.27 | 8110.35 | 11 | 0.5 | - | 61.03 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=18` | - | 8074.35 | 8016.94 | 8096.97 | 11 | 0.4 | - | 85.49 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | - | 8065.13 | 8032.14 | 10007.14 | 20 | 10.8 | - | 13.00 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 7298.69 | 7280.22 | 7311.46 | 6 | 0.2 | - | 32.12 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 6480.71 | 6454.71 | 6508.01 | 6 | 0.4 | - | 3.06 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 6451.49 | 5936.40 | 7248.79 | 20 | 9.8 | - | 11.36 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 6320.68 | 6253.17 | 7608.16 | 14 | 0.6 | - | 11.37 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 6309.34 | 6205.30 | 6340.68 | 11 | 0.9 | - | 11.37 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=9` | - | 6297.13 | 6232.45 | 8842.41 | 14 | 0.4 | - | 170.66 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4608 K=4608 dtype=bf16 act=gelu M=256` | - | 6269.07 | 5759.48 | 6832.21 | 20 | 4.0 | - | 47.26 MiB | 32 thread(s) | -| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=512` | - | 6019.46 | 5989.82 | 6044.60 | 6 | 0.5 | - | 288.01 KiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 5932.29 | 5918.34 | 5958.64 | 6 | 0.3 | - | 11.35 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=258` | - | 5798.89 | 5743.29 | 8184.74 | 20 | 20.0 | - | 6.80 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=18` | - | 5773.27 | 5740.70 | 8951.51 | 20 | 17.5 | - | 80.66 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | - | 5758.83 | 5659.24 | 5848.11 | 16 | 0.6 | - | 32.14 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=4608 dtype=bf16 act=none M=256` | - | 5680.98 | 5463.24 | 6871.94 | 20 | 7.4 | - | 52.26 MiB | 32 thread(s) | -| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=8` | - | 5454.27 | 5410.62 | 5484.79 | 11 | 0.6 | - | 170.46 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=8` | - | 5410.44 | 5369.15 | 5437.19 | 11 | 0.6 | - | 170.59 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 5168.15 | 5152.80 | 5899.83 | 20 | 4.8 | - | 11.31 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 5142.00 | 5129.44 | 5147.51 | 6 | 0.2 | - | 11.30 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 5122.39 | 5110.83 | 5158.52 | 6 | 0.5 | - | 11.26 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 4935.73 | 4905.02 | 4937.38 | 6 | 0.3 | - | 11.28 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 4907.77 | 4886.83 | 5459.09 | 19 | 0.3 | - | 11.28 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 4734.36 | 4716.24 | 5192.35 | 20 | 4.7 | - | 11.26 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=18` | - | 4652.41 | 4603.64 | 6709.87 | 19 | 0.2 | - | 60.52 MiB | 32 thread(s) | -| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | `head_k=128 head_v=128 scale=0.0883883 M=512 chunk=64` | - | 4599.36 | 3786.59 | 5140.46 | 20 | 12.0 | - | 25.19 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=36` | - | 4491.21 | 4469.66 | 4589.56 | 14 | 1.0 | - | 30.57 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=9` | - | 4455.98 | 4405.58 | 4466.12 | 11 | 0.5 | - | 85.25 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 4423.60 | 4386.39 | 4457.66 | 6 | 0.8 | - | 32.10 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=512` | - | 3984.69 | 3945.42 | 4010.66 | 6 | 0.8 | - | 19.00 MiB | 32 thread(s) | -| `sample_topk` | `avx_sample_topk` | libavx | `n_vocab=248320 M=64` | - | 3903.93 | 3792.34 | 4132.83 | 20 | 2.2 | - | 60.69 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 3877.06 | 3869.06 | 3906.11 | 6 | 0.5 | - | 2.94 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=4608 dtype=bf16 act=none M=128` | - | 3850.22 | 3612.64 | 4230.71 | 20 | 3.5 | - | 48.63 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=8` | - | 3505.89 | 3471.76 | 3524.58 | 6 | 0.8 | - | 85.23 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=1` | - | 3421.69 | 2466.94 | 3768.87 | 20 | 9.9 | - | 170.09 MiB | 32 thread(s) | -| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=1` | - | 3320.49 | 3216.01 | 3621.38 | 20 | 4.1 | - | 170.08 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4608 K=4608 dtype=bf16 act=gelu M=128` | - | 3311.52 | 3132.93 | 3904.94 | 20 | 6.0 | - | 43.88 MiB | 32 thread(s) | -| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=4` | - | 3267.49 | 3235.43 | 3546.49 | 19 | 0.6 | - | 170.24 MiB | 32 thread(s) | -| `row_topk` | `avx_row_topk` | libavx | `N=248320 R=32 dtype=bf16 M=56 nch=0 pt1=8` | - | 3252.70 | 3206.28 | 3267.77 | 6 | 0.9 | - | 26.55 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=4` | - | 3249.03 | 3211.30 | 3312.43 | 16 | 0.8 | - | 170.31 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | - | 3096.83 | 3038.86 | 3111.84 | 16 | 0.8 | - | 6.72 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 3073.27 | 2967.23 | 3165.46 | 20 | 2.1 | - | 32.03 MiB | 32 thread(s) | -| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=2` | - | 3070.49 | 2913.10 | 4067.99 | 14 | 0.8 | - | 170.13 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 2955.39 | 2905.45 | 3084.64 | 20 | 1.4 | - | 32.05 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=9` | - | 2949.23 | 2229.80 | 3495.48 | 20 | 21.1 | - | 60.26 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=4` | - | 2947.67 | 1761.59 | 3328.71 | 20 | 3.8 | - | 85.12 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=9` | - | 2946.56 | 2928.74 | 3027.75 | 16 | 0.7 | - | 80.34 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=129` | - | 2893.57 | 2880.69 | 2909.50 | 11 | 0.4 | - | 5.90 MiB | 32 thread(s) | -| `logits_gemm` | `logits_gemm_fp8` | libr4d | `n_vocab=248320 n_embd=5120 dtype=bf16 M=64` | 2886.61 | - | 2771.39 | 2900.39 | 14 | 0.9 | 2148 | 2.43 GiB | | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=128` | - | 2876.31 | 2830.52 | 4261.58 | 20 | 23.0 | - | 5.90 MiB | 32 thread(s) | -| `gdn_conv_update` | `avx_gdn_conv_update` | libavx | `head_k=128 head_v=128 conv_width=4 q_len=512` | - | 2701.45 | 2605.74 | 2778.01 | 20 | 1.8 | - | 30.12 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3456 K=1152 dtype=bf16 act=none M=512` | - | 2701.14 | 2686.26 | 2723.97 | 6 | 0.7 | - | 15.48 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=2` | - | 2598.22 | 2412.55 | 2976.88 | 20 | 5.8 | - | 170.16 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=8` | - | 2581.41 | 2538.67 | 2771.88 | 20 | 1.7 | - | 80.30 MiB | 32 thread(s) | -| `sample_typical` | `avx_sample_typical` | libavx | `n_cand=1024 M=64` | - | 2493.07 | 2489.33 | 2547.49 | 14 | 0.5 | - | 518.00 KiB | 32 thread(s) | -| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | `head_k=128 head_v=128 scale=0.0883883 M=256 chunk=64` | - | 2484.39 | 2468.43 | 2517.70 | 6 | 1.0 | - | 15.59 MiB | 32 thread(s) | -| `sample_topk` | `avx_sample_topk` | libavx | `n_vocab=248320 M=32` | - | 2467.16 | 2119.59 | 2659.33 | 20 | 7.0 | - | 30.35 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=18` | - | 2396.19 | 2226.42 | 2563.14 | 20 | 5.8 | - | 30.29 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=256` | - | 2280.76 | 2141.07 | 2369.27 | 20 | 1.9 | - | 14.23 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=2` | - | 2270.51 | 2219.32 | 2299.08 | 20 | 1.1 | - | 85.06 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=4` | - | 2242.88 | 2184.64 | 2272.52 | 20 | 1.3 | - | 80.15 MiB | 32 thread(s) | -| `logits_gemm` | `logits_gemm_fp8` | libr4d | `n_vocab=248320 n_embd=5120 dtype=bf16 M=32` | 2196.66 | - | 2185.06 | 2202.58 | 6 | 0.4 | 2592 | 2.40 GiB | | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=4304 dtype=bf16 act=none M=512` | - | 2167.96 | 1941.83 | 2364.31 | 20 | 8.0 | - | 15.91 MiB | 32 thread(s) | -| `logits_gemm` | `logits_gemm_fp8` | libr4d | `n_vocab=248320 n_embd=5120 dtype=bf16 M=16` | 2124.50 | - | 2123.10 | 2126.18 | 6 | 0.1 | 2938 | 2.38 GiB | | -| `logits_gemm` | `logits_gemm_fp8` | libr4d | `n_vocab=248320 n_embd=5120 dtype=bf16 M=8` | 2097.06 | - | 2095.94 | 2098.54 | 6 | 0.1 | 3071 | 2.38 GiB | | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=64` | - | 2096.43 | 2083.71 | 2111.25 | 6 | 0.7 | - | 5.45 MiB | 32 thread(s) | -| `logits_gemm` | `logits_gemm_fp8` | libr4d | `n_vocab=248320 n_embd=5120 dtype=bf16 M=4` | 2079.53 | - | 2078.98 | 2082.18 | 6 | 0.1 | 3076 | 2.37 GiB | | -| `logits_gemm` | `logits_gemm_fp8` | libr4d | `n_vocab=248320 n_embd=5120 dtype=bf16 M=2` | 2054.41 | - | 2053.14 | 2059.18 | 6 | 0.1 | 3109 | 2.37 GiB | | -| `logits_gemm` | `logits_gemm_fp8` | libr4d | `n_vocab=248320 n_embd=5120 dtype=bf16 M=1` | 2036.80 | - | 2036.14 | 2039.02 | 6 | 0.1 | 3397 | 2.37 GiB | | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 1956.10 | 1952.36 | 1964.78 | 6 | 0.3 | - | 2.88 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=8` | - | 1927.15 | 1912.54 | 1982.61 | 19 | 1.0 | - | 60.24 MiB | 32 thread(s) | -| `sample_topk` | `avx_sample_topk` | libavx | `n_vocab=248320 M=16` | - | 1913.64 | 1869.29 | 1966.23 | 19 | 0.8 | - | 15.17 MiB | 32 thread(s) | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | 1880.68 | - | 1823.26 | 1886.34 | 14 | 0.8 | 2598 | 44.00 MiB | | -| `row_topk` | `avx_row_topk` | libavx | `N=248320 R=32 dtype=bf16 M=32 nch=0 pt1=8` | - | 1862.83 | 1850.13 | 1872.43 | 11 | 0.5 | - | 15.17 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 1834.20 | 1829.04 | 1838.16 | 6 | 0.2 | - | 2.87 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=17` | - | 1717.62 | 1706.37 | 1735.08 | 11 | 0.8 | - | 4.40 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=1` | - | 1710.19 | 1528.03 | 1840.42 | 20 | 6.7 | - | 80.05 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=9` | - | 1654.02 | 1247.10 | 1717.10 | 20 | 13.2 | - | 30.15 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=4608 dtype=bf16 act=none M=64` | - | 1638.63 | 1635.05 | 1663.44 | 6 | 0.9 | - | 46.82 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 1626.47 | 1618.94 | 1645.46 | 6 | 0.8 | - | 2.84 MiB | 32 thread(s) | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | 1618.38 | - | 1569.74 | 1630.34 | 11 | 1.0 | 3022 | 38.19 MiB | | -| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=248320 M=64` | - | 1606.84 | 1397.36 | 2993.10 | 20 | 15.5 | - | 60.63 MiB | 32 thread(s) | -| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | `head_k=128 head_v=128 scale=0.0883883 M=128 chunk=64` | - | 1583.66 | 1578.56 | 1585.93 | 6 | 0.2 | - | 10.80 MiB | 32 thread(s) | -| `gdn_conv_update` | `avx_gdn_conv_update` | libavx | `head_k=128 head_v=128 conv_width=4 q_len=256` | - | 1569.99 | 1564.06 | 1590.86 | 11 | 0.8 | - | 15.12 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | - | 1565.26 | 1515.29 | 2272.71 | 19 | 0.8 | - | 4.38 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 1530.14 | 1506.48 | 1552.12 | 16 | 1.0 | - | 2.83 MiB | 32 thread(s) | -| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=256` | - | 1522.34 | 1520.16 | 1527.69 | 6 | 0.2 | - | 144.01 KiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=65` | - | 1503.88 | 1460.18 | 2121.86 | 20 | 2.0 | - | 5.45 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3456 K=1152 dtype=bf16 act=none M=256` | - | 1472.64 | 1437.33 | 1502.34 | 16 | 0.8 | - | 11.54 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=2` | - | 1452.79 | 1401.28 | 1504.62 | 20 | 1.3 | - | 80.08 MiB | 32 thread(s) | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | 1436.34 | - | 1409.62 | 1481.01 | 20 | 1.7 | 3364 | 35.10 MiB | | -| `sample_topk` | `avx_sample_topk` | libavx | `n_vocab=248320 M=8` | - | 1432.52 | 1427.50 | 1440.95 | 6 | 0.5 | - | 7.59 MiB | 32 thread(s) | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | 1429.38 | - | 1406.10 | 1451.14 | 16 | 0.9 | 3417 | 32.78 MiB | | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | 1425.73 | - | 1411.26 | 1461.90 | 19 | 0.6 | 3414 | 33.55 MiB | | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | 1425.70 | - | 1410.25 | 1444.42 | 14 | 0.9 | 3415 | 32.38 MiB | | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=11` | 1424.41 | - | 1409.65 | 1450.73 | 14 | 1.0 | 3412 | 32.26 MiB | | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | 1421.23 | - | 1410.22 | 1441.14 | 16 | 0.9 | 3414 | 32.75 MiB | | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=17` | 1419.70 | - | 1408.41 | 1434.98 | 11 | 0.9 | 3421 | 32.40 MiB | | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=4304 dtype=bf16 act=none M=256` | - | 1416.00 | 1302.42 | 1445.35 | 20 | 2.7 | - | 12.69 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=1` | - | 1411.49 | 1168.28 | 2061.53 | 20 | 27.7 | - | 85.04 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | - | 1344.09 | 1338.34 | 1351.23 | 6 | 0.5 | - | 3.38 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4608 K=4608 dtype=bf16 act=gelu M=64` | - | 1341.51 | 1083.19 | 1404.01 | 20 | 4.6 | - | 42.20 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 1334.01 | 1326.22 | 1344.36 | 6 | 0.7 | - | 2.82 MiB | 32 thread(s) | -| `sample_typical` | `avx_sample_typical` | libavx | `n_cand=1024 M=32` | - | 1318.26 | 1305.74 | 1393.23 | 20 | 1.9 | - | 259.00 KiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=1` | - | 1292.81 | 1142.66 | 1451.08 | 20 | 7.8 | - | 60.04 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=128` | - | 1284.87 | 1229.99 | 1326.86 | 19 | 0.7 | - | 11.85 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=512` | 1218.55 | - | 1118.05 | 1258.93 | 20 | 2.7 | 2187 | 206.60 MiB | | -| `gated_quant_fp8` | `avx_gated_quant_fp8` | libavx | `n=17408 group=128 dtype=bf16 act=silu M=512` | - | 1206.69 | 1077.54 | 1443.07 | 20 | 9.8 | - | 59.77 MiB | 32 thread(s) | -| `sample_topk` | `avx_sample_topk` | libavx | `n_vocab=248320 M=4` | - | 1191.73 | 1109.75 | 1608.78 | 20 | 20.0 | - | 3.79 MiB | 32 thread(s) | -| `sample_argmax` | `avx_sample_argmax` | libavx | `n_vocab=248320 M=64` | - | 1190.62 | 1012.77 | 1276.07 | 20 | 4.6 | - | 60.63 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=4` | - | 1189.13 | 1168.15 | 1294.34 | 20 | 1.4 | - | 60.12 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=36` | - | 1182.61 | 1161.44 | 1193.84 | 11 | 0.7 | - | 5.25 MiB | 32 thread(s) | -| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=248320 k=21 M=64` | - | 1155.71 | 1044.77 | 1241.17 | 20 | 5.5 | - | 60.64 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | - | 1145.12 | 1141.44 | 1149.21 | 6 | 0.3 | - | 4.19 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=8` | - | 1115.04 | 1034.01 | 1473.45 | 20 | 17.6 | - | 30.13 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=4608 dtype=bf16 act=none M=32` | - | 1100.34 | 1092.13 | 1117.30 | 11 | 0.9 | - | 45.92 MiB | 32 thread(s) | -| `gdn_conv_update` | `avx_gdn_conv_update` | libavx | `head_k=128 head_v=128 conv_width=4 q_len=128` | - | 1085.04 | 1075.82 | 1097.42 | 6 | 1.0 | - | 7.62 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=10 splits=0` | - | 1076.61 | 1048.46 | 1503.27 | 20 | 20.4 | - | 4.23 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=2` | - | 1072.08 | 902.90 | 1440.56 | 20 | 22.1 | - | 60.06 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=11` | - | 1070.45 | 1061.12 | 1993.24 | 20 | 21.2 | - | 4.26 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1536 dtype=bf16 act=none M=512` | - | 1057.68 | 874.98 | 1079.46 | 20 | 3.6 | - | 7.13 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | - | 1039.64 | 1033.22 | 1054.65 | 11 | 0.9 | - | 32.13 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=9 splits=0` | - | 1018.72 | 1004.31 | 1466.04 | 20 | 11.6 | - | 4.21 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=4608 dtype=bf16 act=none M=16` | - | 1007.68 | 1003.19 | 1011.94 | 11 | 0.4 | - | 45.46 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | - | 1001.25 | 996.75 | 1012.24 | 6 | 0.8 | - | 4.13 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=4608 dtype=bf16 act=none M=8` | - | 990.01 | 973.70 | 992.36 | 6 | 0.9 | - | 45.24 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=4608 dtype=bf16 act=none M=2` | - | 955.37 | 749.33 | 1037.97 | 20 | 12.1 | - | 45.07 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=4608 dtype=bf16 act=none M=1` | - | 946.51 | 626.55 | 992.29 | 20 | 6.4 | - | 45.04 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4608 K=4608 dtype=bf16 act=gelu M=32` | - | 917.18 | 692.16 | 955.31 | 20 | 5.6 | - | 41.35 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1152 dtype=bf16 act=none M=512` | - | 902.15 | 877.33 | 921.06 | 20 | 1.1 | - | 5.91 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=4` | - | 901.89 | 866.34 | 915.78 | 20 | 1.7 | - | 30.07 MiB | 32 thread(s) | -| `grid_embed` | `avx_grid_embed` | libavx | `n=1152 side=48 dtype=bf16 M=512` | - | 891.89 | 885.05 | 894.99 | 6 | 0.6 | - | 6.20 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=4304 dtype=bf16 act=none M=128` | - | 891.54 | 791.58 | 919.57 | 20 | 3.1 | - | 11.07 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=258` | 888.80 | - | 863.45 | 916.69 | 20 | 1.5 | 2426 | 188.45 MiB | | -| `row_topk` | `avx_row_topk` | libavx | `N=248320 R=32 dtype=bf16 M=16 nch=0 pt1=8` | - | 865.99 | 864.02 | 868.56 | 6 | 0.3 | - | 7.59 MiB | 32 thread(s) | -| `sample_topk` | `avx_sample_topk` | libavx | `n_vocab=248320 M=1` | - | 857.82 | 857.56 | 865.80 | 6 | 0.5 | - | 971.09 KiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3456 K=1152 dtype=bf16 act=none M=128` | - | 848.89 | 794.80 | 949.37 | 20 | 8.1 | - | 9.57 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4608 K=4608 dtype=bf16 act=gelu M=4` | - | 847.92 | 751.79 | 917.75 | 20 | 6.0 | - | 40.61 MiB | 32 thread(s) | -| `sample_mask` | `avx_sample_mask` | libavx | `n_vocab=248320 M=64` | - | 845.77 | 732.77 | 1019.57 | 20 | 11.2 | - | 62.53 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4608 K=4608 dtype=bf16 act=gelu M=8` | - | 832.41 | 732.38 | 965.71 | 20 | 8.7 | - | 40.72 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4608 K=4608 dtype=bf16 act=gelu M=2` | - | 830.12 | 798.85 | 917.49 | 20 | 5.9 | - | 40.56 MiB | 32 thread(s) | -| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=248320 M=16` | - | 827.35 | 489.44 | 908.55 | 20 | 21.8 | - | 15.16 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | - | 819.64 | 661.18 | 850.18 | 20 | 8.9 | - | 32.10 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4608 K=4608 dtype=bf16 act=gelu M=16` | - | 816.93 | 669.62 | 1032.24 | 20 | 15.2 | - | 40.93 MiB | 32 thread(s) | -| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | `head_k=128 M=512 chunk=64` | - | 814.16 | 804.16 | 819.71 | 6 | 1.0 | - | 5.19 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=4608 dtype=bf16 act=none M=4` | - | 808.42 | 681.63 | 1042.61 | 20 | 9.2 | - | 45.12 MiB | 32 thread(s) | -| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | `head_k=128 head_v=128 scale=0.0883883 M=64 chunk=64` | - | 799.88 | 795.52 | 802.19 | 6 | 0.4 | - | 8.40 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 799.86 | 786.45 | 839.71 | 20 | 2.5 | - | 32.08 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4608 K=4608 dtype=bf16 act=gelu M=1` | - | 797.95 | 762.01 | 880.74 | 20 | 6.1 | - | 40.54 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_mxfp4a8_tiled` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=512 tn=0` | 767.05 | - | 730.47 | 788.49 | 20 | 1.7 | 2463 | 88.20 MiB | | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=2` | - | 757.47 | 704.61 | 818.05 | 20 | 3.6 | - | 30.04 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | - | 737.00 | 732.43 | 745.99 | 6 | 0.9 | - | 4.09 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | - | 724.53 | 703.47 | 739.64 | 19 | 0.9 | - | 4.14 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_mxfp4a8_tiled` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=258 tn=0` | 697.31 | - | 665.05 | 703.47 | 16 | 1.0 | 2593 | 79.33 MiB | | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 660.06 | 653.52 | 663.85 | 11 | 0.6 | - | 4.12 MiB | 32 thread(s) | -| `sample_typical` | `avx_sample_typical` | libavx | `n_cand=1024 M=16` | - | 653.58 | 650.90 | 662.96 | 6 | 0.9 | - | 129.50 KiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=1` | - | 651.44 | 596.90 | 709.93 | 20 | 4.5 | - | 30.02 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=18` | - | 637.02 | 611.41 | 882.38 | 20 | 5.6 | - | 5.13 MiB | 32 thread(s) | -| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=248320 k=21 M=32` | - | 631.42 | 574.95 | 690.77 | 20 | 5.6 | - | 30.32 MiB | 32 thread(s) | -| `sample_typical` | `avx_sample_typical` | libavx | `n_cand=1024 M=8` | - | 625.11 | 622.69 | 628.30 | 6 | 0.4 | - | 64.75 KiB | 32 thread(s) | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=25600 group=128 dtype=bf16 M=512` | - | 623.72 | 570.42 | 680.63 | 20 | 4.9 | - | 37.89 MiB | 32 thread(s) | -| `sample_typical` | `avx_sample_typical` | libavx | `n_cand=1024 M=2` | - | 623.49 | 621.47 | 626.71 | 6 | 0.4 | - | 16.19 KiB | 32 thread(s) | -| `sample_typical` | `avx_sample_typical` | libavx | `n_cand=1024 M=4` | - | 618.09 | 613.69 | 623.02 | 6 | 0.8 | - | 32.38 KiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1536 dtype=bf16 act=none M=256` | - | 598.53 | 516.18 | 626.00 | 20 | 4.3 | - | 5.25 MiB | 32 thread(s) | -| `sample_typical` | `avx_sample_typical` | libavx | `n_cand=1024 M=1` | - | 598.31 | 597.61 | 606.63 | 6 | 0.8 | - | 8.09 KiB | 32 thread(s) | -| `sample_mask` | `avx_sample_mask` | libavx | `n_vocab=248320 M=16` | - | 594.04 | 490.01 | 599.62 | 19 | 0.4 | - | 15.63 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=64` | - | 593.87 | 580.54 | 601.48 | 14 | 0.7 | - | 10.66 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1152 dtype=bf16 act=none M=256` | - | 590.65 | 545.29 | 622.18 | 20 | 3.7 | - | 4.22 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=512` | 589.59 | - | 555.31 | 620.45 | 20 | 3.8 | 2348 | 98.78 MiB | | -| `row_topk` | `avx_row_topk` | libavx | `N=248320 R=32 dtype=bf16 M=4 nch=0 pt1=8` | - | 580.62 | 558.35 | 596.92 | 20 | 2.5 | - | 1.90 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 579.14 | 570.91 | 655.82 | 20 | 1.3 | - | 4.08 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=129` | 573.27 | - | 555.57 | 582.95 | 16 | 0.9 | 2487 | 179.24 MiB | | -| `row_topk` | `avx_row_topk` | libavx | `N=248320 R=32 dtype=bf16 M=8 nch=0 pt1=8` | - | 569.50 | 551.27 | 590.38 | 20 | 2.6 | - | 3.79 MiB | 32 thread(s) | -| `row_topk` | `avx_row_topk` | libavx | `N=248320 R=32 dtype=bf16 M=2 nch=0 pt1=8` | - | 560.72 | 526.16 | 586.97 | 20 | 1.1 | - | 971.00 KiB | 32 thread(s) | -| `sample_argmax` | `avx_sample_argmax` | libavx | `n_vocab=248320 M=32` | - | 558.73 | 479.85 | 624.92 | 20 | 8.6 | - | 30.32 MiB | 32 thread(s) | -| `gated_quant_fp8` | `avx_gated_quant_fp8` | libavx | `n=17408 group=128 dtype=bf16 act=silu M=256` | - | 551.03 | 516.13 | 652.89 | 20 | 8.7 | - | 29.88 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 543.28 | 541.66 | 546.19 | 6 | 0.4 | - | 4.02 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 529.08 | 521.02 | 542.94 | 19 | 0.9 | - | 32.07 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=512` | 528.85 | - | 511.33 | 545.65 | 20 | 1.3 | 2384 | 98.59 MiB | | -| `gdn_conv_update` | `avx_gdn_conv_update` | libavx | `head_k=128 head_v=128 conv_width=4 q_len=64` | - | 524.95 | 520.77 | 534.34 | 14 | 0.7 | - | 3.87 MiB | 32 thread(s) | -| `sample_typical` | `sample_typical_f32` | libr4d | `n_cand=1024 M=64` | 522.64 | - | 521.82 | 525.72 | 6 | 0.4 | 3580 | 518.00 KiB | restore 1% | -| `sample_typical` | `sample_typical_f32` | libr4d | `n_cand=1024 M=16` | 502.86 | - | 501.94 | 504.62 | 6 | 0.3 | 3583 | 129.50 KiB | restore 1% | -| `sample_typical` | `sample_typical_f32` | libr4d | `n_cand=1024 M=32` | 502.18 | - | 492.84 | 505.66 | 11 | 0.5 | 3581 | 259.00 KiB | restore 1% | -| `sample_typical` | `sample_typical_f32` | libr4d | `n_cand=1024 M=8` | 502.06 | - | 500.54 | 503.78 | 6 | 0.3 | 3583 | 64.75 KiB | restore 1% | -| `sample_typical` | `sample_typical_f32` | libr4d | `n_cand=1024 M=4` | 501.24 | - | 489.70 | 502.08 | 11 | 0.2 | 3584 | 32.38 KiB | restore 1% | -| `sample_typical` | `sample_typical_f32` | libr4d | `n_cand=1024 M=1` | 500.94 | - | 500.32 | 503.40 | 6 | 0.3 | 3580 | 8.09 KiB | restore 1% | -| `sample_typical` | `sample_typical_f32` | libr4d | `n_cand=1024 M=2` | 500.94 | - | 500.70 | 502.52 | 6 | 0.2 | 3582 | 16.19 KiB | restore 1% | -| `gdn_conv_update` | `gdn_conv_update_w4_h128_bf16` | libr4d | `head_k=128 head_v=128 conv_width=4 q_len=512` | 500.42 | - | 497.10 | 503.50 | 6 | 0.6 | 3408 | 30.12 MiB | restore 4% | -| `row_topk` | `avx_row_topk` | libavx | `N=248320 R=32 dtype=bf16 M=1 nch=0 pt1=8` | - | 485.84 | 482.85 | 487.57 | 6 | 0.5 | - | 485.50 KiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 485.81 | 483.11 | 487.92 | 6 | 0.5 | - | 4.06 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=258` | 468.49 | - | 447.66 | 480.90 | 20 | 1.6 | 2598 | 91.95 MiB | | -| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=512` | - | 452.10 | 431.35 | 505.51 | 16 | 0.9 | - | 17.59 MiB | 32 thread(s) | -| `grid_embed` | `avx_grid_embed` | libavx | `n=1152 side=48 dtype=bf16 M=256` | - | 436.06 | 431.19 | 440.43 | 11 | 1.0 | - | 5.63 MiB | 32 thread(s) | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=5120 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 416.08 | 403.73 | 431.95 | 20 | 2.1 | - | 13.28 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=258` | 406.86 | - | 392.14 | 415.62 | 20 | 1.8 | 2506 | 89.37 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=512` | 402.12 | - | 376.64 | 417.84 | 20 | 2.5 | 2390 | 74.59 MiB | | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 385.75 | 376.81 | 393.33 | 20 | 1.5 | - | 4.09 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_mxfp4a8_tiled` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=129 tn=0` | 385.10 | - | 383.40 | 391.10 | 6 | 1.0 | 2907 | 74.82 MiB | | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 384.39 | 353.17 | 781.10 | 20 | 51.5 | - | 4.05 MiB | 32 thread(s) | -| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=128` | - | 383.94 | 383.24 | 387.50 | 6 | 0.6 | - | 72.01 KiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3456 K=1152 dtype=bf16 act=none M=64` | - | 382.23 | 319.13 | 398.44 | 20 | 8.6 | - | 8.58 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1536 dtype=bf16 act=none M=128` | - | 374.76 | 358.45 | 389.57 | 20 | 1.8 | - | 4.31 MiB | 32 thread(s) | -| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=248320 k=21 M=16` | - | 374.13 | 300.09 | 413.46 | 20 | 6.2 | - | 15.16 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | - | 365.60 | 328.89 | 407.69 | 20 | 5.3 | - | 1.70 MiB | 32 thread(s) | -| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | `head_k=128 head_v=128 scale=0.0883883 M=32 chunk=64` | - | 364.51 | 360.56 | 367.35 | 6 | 0.9 | - | 7.20 MiB | 32 thread(s) | -| `sample_mask` | `avx_sample_mask` | libavx | `n_vocab=248320 M=8` | - | 351.65 | 269.01 | 357.10 | 20 | 2.4 | - | 7.82 MiB | 32 thread(s) | -| `sample_argmax` | `avx_sample_argmax` | libavx | `n_vocab=248320 M=16` | - | 351.24 | 221.39 | 400.37 | 20 | 3.3 | - | 15.16 MiB | 32 thread(s) | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 350.71 | 317.72 | 362.51 | 20 | 3.4 | - | 12.92 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=32` | - | 348.43 | 339.95 | 367.25 | 20 | 2.6 | - | 10.06 MiB | 32 thread(s) | -| `gdn_recurrent_update` | `avx_gdn_recurrent_update` | libavx | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=16` | - | 345.14 | 315.03 | 358.19 | 20 | 4.6 | - | 48.69 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=128` | 340.66 | - | 337.48 | 346.38 | 14 | 0.7 | 2516 | 179.17 MiB | | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=9` | - | 335.64 | 322.70 | 348.13 | 20 | 3.1 | - | 5.06 MiB | 32 thread(s) | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=25600 group=128 dtype=bf16 M=256` | - | 332.99 | 315.39 | 342.81 | 20 | 1.8 | - | 18.95 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=65` | 330.58 | - | 320.38 | 333.82 | 20 | 1.4 | 2669 | 174.66 MiB | | -| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | `head_k=128 M=256 chunk=64` | - | 329.40 | 313.19 | 348.31 | 20 | 3.7 | - | 2.59 MiB | 32 thread(s) | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=96 K=5120 dtype=bf16 M=512 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 328.93 | 323.71 | 334.13 | 14 | 0.9 | - | 6.03 MiB | 32 thread(s) | -| `sample_topk` | `avx_sample_topk` | libavx | `n_vocab=248320 M=2` | - | 328.91 | 328.49 | 333.12 | 6 | 0.7 | - | 1.90 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 327.66 | 282.50 | 369.93 | 20 | 8.8 | - | 32.02 MiB | 32 thread(s) | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=96 K=5120 dtype=bf16 M=260 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 326.63 | 292.10 | 365.35 | 20 | 5.2 | - | 3.52 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 323.67 | 303.34 | 345.53 | 20 | 4.6 | - | 32.04 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1152 dtype=bf16 act=none M=128` | - | 321.10 | 300.06 | 329.31 | 20 | 2.4 | - | 3.38 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=129` | 319.97 | - | 317.26 | 322.72 | 6 | 0.9 | 2809 | 88.48 MiB | | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 314.54 | 250.20 | 348.70 | 20 | 5.6 | - | 4.02 MiB | 32 thread(s) | -| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=64` | 313.03 | - | 309.97 | 320.22 | 14 | 0.5 | 3163 | 173.56 MiB | | -| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=248320 M=32` | - | 312.91 | 280.06 | 322.87 | 20 | 2.4 | - | 30.32 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=64` | 312.22 | - | 310.01 | 313.55 | 11 | 0.4 | 3046 | 174.59 MiB | | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 307.86 | 244.44 | 320.46 | 20 | 2.3 | - | 12.60 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=16` | - | 306.30 | 265.03 | 316.86 | 20 | 5.1 | - | 9.76 MiB | 32 thread(s) | -| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=248320 M=8` | - | 305.64 | 108.86 | 309.26 | 20 | 16.9 | - | 7.58 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=4304 dtype=bf16 act=none M=8` | - | 305.32 | 279.09 | 334.97 | 20 | 5.3 | - | 9.56 MiB | 32 thread(s) | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=5120 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 304.88 | 224.81 | 314.90 | 20 | 3.1 | - | 12.52 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=36` | 303.91 | - | 300.66 | 308.30 | 14 | 0.9 | 3240 | 172.59 MiB | | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=4304 dtype=bf16 act=none M=64` | - | 301.92 | 282.77 | 324.81 | 20 | 2.4 | - | 10.27 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=258` | 301.59 | - | 291.93 | 305.78 | 20 | 1.5 | 2584 | 67.35 MiB | | -| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=16` | 297.02 | - | 294.41 | 305.04 | 14 | 0.8 | 3364 | 170.91 MiB | | -| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=32` | 296.37 | - | 295.43 | 309.43 | 14 | 0.5 | 3362 | 171.79 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=18` | 295.75 | - | 294.70 | 300.05 | 11 | 0.8 | 3403 | 171.31 MiB | | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=96 K=5120 dtype=bf16 M=130 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 293.94 | 172.93 | 303.00 | 20 | 13.4 | - | 2.23 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=9` | 293.65 | - | 292.95 | 294.46 | 11 | 0.2 | 3423 | 170.66 MiB | | -| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=8` | 293.65 | - | 290.72 | 306.20 | 14 | 0.8 | 3362 | 170.46 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=8` | 293.38 | - | 292.30 | 294.28 | 11 | 0.3 | 3426 | 170.59 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=128 ks=0 bk=0 nt=0` | 293.28 | - | 291.12 | 294.83 | 6 | 0.6 | 2900 | 74.79 MiB | | -| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=4` | 292.43 | - | 290.22 | 294.61 | 11 | 0.6 | 3358 | 170.24 MiB | | -| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=2` | 291.85 | - | 289.88 | 294.60 | 11 | 0.8 | 3368 | 170.13 MiB | | -| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=1` | 291.25 | - | 289.78 | 293.63 | 11 | 0.6 | 3366 | 170.08 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=4` | 290.72 | - | 289.60 | 294.97 | 11 | 0.8 | 3436 | 170.31 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=2` | 289.21 | - | 288.26 | 298.21 | 14 | 0.2 | 3374 | 170.16 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4608 K=4608 dtype=bf16 act=gelu M=512` | 289.13 | - | 277.97 | 292.14 | 20 | 1.1 | 2952 | 54.01 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=1` | 288.76 | - | 288.34 | 289.82 | 6 | 0.3 | 2787 | 170.09 MiB | | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 287.15 | 183.92 | 308.89 | 20 | 13.1 | - | 12.70 MiB | 32 thread(s) | -| `gated_quant_fp8` | `avx_gated_quant_fp8` | libavx | `n=17408 group=128 dtype=bf16 act=silu M=128` | - | 286.78 | 270.00 | 303.39 | 20 | 3.4 | - | 14.94 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=8` | - | 286.36 | 276.96 | 306.16 | 20 | 2.3 | - | 5.06 MiB | 32 thread(s) | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=4608 dtype=bf16 act=none M=512` | 285.93 | - | 271.91 | 289.51 | 20 | 1.2 | 2873 | 59.51 MiB | | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=5120 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 284.28 | 213.54 | 297.19 | 20 | 4.1 | - | 12.51 MiB | 32 thread(s) | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 284.07 | 254.48 | 289.54 | 20 | 1.4 | - | 12.71 MiB | 32 thread(s) | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 281.48 | 231.13 | 352.26 | 20 | 4.9 | - | 12.55 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=1` | - | 272.05 | 179.04 | 286.27 | 20 | 3.4 | - | 9.48 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=2` | - | 268.33 | 265.19 | 273.31 | 16 | 0.6 | - | 9.50 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=8` | - | 267.23 | 213.51 | 275.29 | 20 | 1.6 | - | 9.61 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=129` | 264.96 | - | 258.92 | 270.47 | 14 | 1.0 | 2666 | 84.69 MiB | | -| `scatter_rows` | `avx_scatter_rows` | libavx | `n=5120 dtype=bf16 M=512` | - | 264.70 | 263.81 | 265.19 | 6 | 0.3 | - | 25.00 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 249.37 | 217.85 | 256.04 | 19 | 1.0 | - | 4.03 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=4` | - | 247.15 | 243.26 | 252.95 | 20 | 1.3 | - | 9.54 MiB | 32 thread(s) | -| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=256` | - | 245.09 | 229.45 | 280.11 | 20 | 7.2 | - | 8.80 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3456 K=1152 dtype=bf16 act=none M=32` | - | 238.51 | 214.15 | 269.05 | 20 | 5.3 | - | 8.09 MiB | 32 thread(s) | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=4` | - | 236.90 | 221.83 | 241.33 | 20 | 3.1 | - | 5.03 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3456 K=1152 dtype=bf16 act=none M=4` | - | 236.68 | 226.32 | 248.01 | 20 | 1.8 | - | 7.66 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=4304 dtype=bf16 act=none M=4` | - | 235.41 | 209.56 | 239.77 | 19 | 0.8 | - | 9.51 MiB | 32 thread(s) | -| `gdn_conv_update` | `avx_gdn_conv_update` | libavx | `head_k=128 head_v=128 conv_width=4 q_len=32` | - | 235.14 | 229.97 | 288.84 | 20 | 2.8 | - | 1.99 MiB | 32 thread(s) | -| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=248320 k=21 M=64` | 232.14 | - | 231.89 | 232.43 | 6 | 0.1 | 3547 | 60.64 MiB | | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=4304 dtype=bf16 act=none M=32` | - | 225.35 | 198.83 | 230.88 | 20 | 1.3 | - | 9.86 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=4304 dtype=bf16 act=none M=2` | - | 223.68 | 210.22 | 228.12 | 20 | 2.0 | - | 9.48 MiB | 32 thread(s) | -| `grid_embed` | `avx_grid_embed` | libavx | `n=1152 side=48 dtype=bf16 M=128` | - | 223.12 | 216.82 | 230.79 | 20 | 1.1 | - | 5.35 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=128` | 220.63 | - | 211.89 | 224.07 | 20 | 1.5 | 2883 | 88.45 MiB | | -| `sample_topk` | `sample_topk_f32` | libr4d | `n_vocab=248320 M=64` | 220.09 | - | 218.23 | 220.64 | 6 | 0.5 | 3518 | 60.69 MiB | | -| `sample_mask` | `avx_sample_mask` | libavx | `n_vocab=248320 M=32` | - | 219.13 | 154.97 | 224.23 | 20 | 2.8 | - | 31.26 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=4304 dtype=bf16 act=none M=1` | - | 217.43 | 175.19 | 219.52 | 16 | 0.8 | - | 9.47 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3456 K=1152 dtype=bf16 act=none M=2` | - | 215.46 | 166.75 | 254.30 | 20 | 7.0 | - | 7.63 MiB | 32 thread(s) | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | 214.56 | - | 198.20 | 219.09 | 20 | 1.6 | 3024 | 16.00 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=65` | 214.19 | - | 208.50 | 217.51 | 16 | 0.8 | 3072 | 86.76 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | 205.57 | - | 203.58 | 207.19 | 6 | 0.9 | 2899 | 100.20 MiB | | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=4304 dtype=bf16 act=none M=16` | - | 204.35 | 185.19 | 212.78 | 20 | 3.1 | - | 9.66 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=129` | 202.10 | - | 195.49 | 207.26 | 20 | 1.3 | 2650 | 63.68 MiB | | -| `gdn_recurrent_update` | `avx_gdn_recurrent_update` | libavx | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=8` | - | 201.08 | 196.28 | 213.17 | 20 | 1.7 | - | 24.35 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3456 K=1152 dtype=bf16 act=none M=8` | - | 199.95 | 191.73 | 214.36 | 20 | 3.5 | - | 7.72 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3456 K=1152 dtype=bf16 act=none M=1` | - | 199.76 | 112.72 | 211.82 | 20 | 4.2 | - | 7.62 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=512` | 199.36 | - | 190.60 | 203.19 | 20 | 1.5 | 2486 | 38.10 MiB | | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1536 dtype=bf16 act=none M=64` | - | 199.03 | 183.59 | 205.69 | 20 | 3.4 | - | 3.85 MiB | 32 thread(s) | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | 197.51 | - | 196.73 | 198.72 | 6 | 0.5 | 3438 | 4.77 MiB | | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=11` | 197.34 | - | 195.04 | 198.44 | 11 | 0.5 | 3438 | 4.26 MiB | | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | 197.14 | - | 193.12 | 198.01 | 14 | 1.0 | 3439 | 4.75 MiB | | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=17` | 197.07 | - | 192.48 | 197.99 | 14 | 0.9 | 3437 | 4.40 MiB | | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | 197.01 | - | 196.40 | 198.24 | 6 | 0.5 | 3440 | 4.38 MiB | | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3456 K=1152 dtype=bf16 act=none M=16` | - | 193.66 | 181.85 | 205.37 | 20 | 4.5 | - | 7.85 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=65 ks=0 bk=0 nt=0` | 187.40 | - | 182.42 | 190.80 | 20 | 1.0 | 2900 | 72.58 MiB | | -| `row_topk` | `rowtopk_bf16` | libr4d | `N=248320 R=32 dtype=bf16 M=56 nch=0 pt1=8` | 187.00 | - | 185.74 | 188.32 | 6 | 0.7 | 3443 | 26.55 MiB | | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | 184.08 | - | 182.78 | 185.81 | 6 | 0.8 | 3408 | 10.19 MiB | | -| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | `head_k=128 head_v=128 scale=0.0883883 M=16 chunk=64` | - | 181.36 | 177.14 | 258.81 | 19 | 1.0 | - | 6.60 MiB | 32 thread(s) | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | 177.57 | - | 176.25 | 178.62 | 6 | 0.7 | 3421 | 7.09 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=65` | 177.26 | - | 173.21 | 179.56 | 16 | 0.6 | 2937 | 82.37 MiB | | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | 175.95 | - | 175.57 | 177.34 | 6 | 0.5 | 3432 | 5.55 MiB | | -| `gdn_conv_update` | `gdn_conv_update_w4_h128_bf16` | libr4d | `head_k=128 head_v=128 conv_width=4 q_len=256` | 174.84 | - | 174.04 | 176.19 | 6 | 0.6 | 3408 | 15.12 MiB | restore 5% | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=128` | 173.86 | - | 166.74 | 177.28 | 20 | 1.4 | 2761 | 84.65 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | 171.34 | - | 170.32 | 173.08 | 6 | 0.8 | 3063 | 98.20 MiB | | -| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | `head_k=128 M=128 chunk=64` | - | 169.43 | 156.29 | 201.98 | 20 | 12.5 | - | 1.30 MiB | 32 thread(s) | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4608 K=4608 dtype=bf16 act=gelu M=256` | 165.32 | - | 160.21 | 167.54 | 14 | 0.9 | 3144 | 47.26 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=4608 dtype=bf16 act=none M=256` | 164.64 | - | 153.33 | 168.04 | 19 | 0.8 | 3078 | 52.26 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=258` | 163.99 | - | 158.78 | 166.89 | 19 | 1.0 | 2789 | 34.08 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | 161.82 | - | 161.66 | 162.08 | 6 | 0.1 | 3273 | 96.91 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=64` | 159.92 | - | 159.44 | 160.28 | 11 | 0.2 | 3235 | 86.73 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | 158.50 | - | 157.61 | 160.32 | 6 | 0.9 | 3116 | 72.55 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=36` | 156.37 | - | 155.63 | 159.46 | 14 | 0.3 | 3359 | 85.98 MiB | | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1152 dtype=bf16 act=none M=64` | - | 155.73 | 149.29 | 162.33 | 20 | 3.1 | - | 2.96 MiB | 32 thread(s) | -| `gdn_conv_update` | `avx_gdn_conv_update` | libavx | `head_k=128 head_v=128 conv_width=4 q_len=16` | - | 153.99 | 150.45 | 162.61 | 20 | 1.4 | - | 1.05 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | 153.17 | - | 153.06 | 153.45 | 11 | 0.1 | 3321 | 96.27 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | 152.90 | - | 152.77 | 153.79 | 6 | 0.3 | 3314 | 96.20 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | 150.47 | - | 150.16 | 150.88 | 11 | 0.2 | 3327 | 95.91 MiB | | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=2` | - | 150.36 | 143.13 | 151.94 | 20 | 1.1 | - | 5.01 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=18` | 149.38 | - | 148.74 | 158.51 | 14 | 0.4 | 3361 | 85.49 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | 149.31 | - | 149.18 | 149.80 | 6 | 0.2 | 3315 | 95.77 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | 148.63 | - | 148.49 | 149.00 | 6 | 0.2 | 3401 | 95.70 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=64` | 147.06 | - | 146.64 | 147.38 | 11 | 0.2 | 3304 | 82.33 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=8` | 146.70 | - | 146.38 | 153.31 | 14 | 0.2 | 3364 | 85.23 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=9` | 146.66 | - | 146.12 | 158.57 | 14 | 0.3 | 3367 | 85.25 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=4` | 146.09 | - | 145.46 | 153.90 | 14 | 0.3 | 3362 | 85.12 MiB | | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5120 group=128 dtype=bf16 M=512` | - | 145.91 | 142.74 | 146.67 | 11 | 0.7 | - | 7.58 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=1` | 145.45 | - | 145.14 | 165.28 | 14 | 0.4 | 3223 | 85.04 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=2` | 145.37 | - | 145.00 | 151.06 | 14 | 0.1 | 3366 | 85.06 MiB | | -| `gdn_recurrent_update` | `avx_gdn_recurrent_update` | libavx | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=4` | - | 144.34 | 138.17 | 167.26 | 20 | 4.9 | - | 18.17 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=36` | 143.76 | - | 143.37 | 144.38 | 11 | 0.3 | 3416 | 81.32 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | 140.39 | - | 139.45 | 141.91 | 6 | 0.9 | 3336 | 71.57 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=18` | 140.13 | - | 139.95 | 141.42 | 11 | 0.5 | 3418 | 80.66 MiB | | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1536 dtype=bf16 act=none M=8` | - | 140.12 | 126.97 | 150.30 | 20 | 5.9 | - | 3.44 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=9` | 138.83 | - | 138.55 | 144.07 | 14 | 0.1 | 3406 | 80.34 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=8` | 138.44 | - | 138.28 | 141.92 | 14 | 0.3 | 3416 | 80.30 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=4` | 137.75 | - | 137.48 | 143.69 | 14 | 0.1 | 3404 | 80.15 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=2` | 137.11 | - | 136.92 | 139.34 | 11 | 0.9 | 3410 | 80.08 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=1` | 137.03 | - | 136.87 | 137.27 | 11 | 0.1 | 3407 | 80.05 MiB | | -| `grid_embed` | `avx_grid_embed` | libavx | `n=1152 side=48 dtype=bf16 M=64` | - | 137.01 | 123.27 | 159.01 | 20 | 4.1 | - | 5.20 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | 136.78 | - | 136.48 | 136.91 | 6 | 0.2 | 3334 | 70.94 MiB | | -| `gdn_recurrent_update` | `avx_gdn_recurrent_update` | libavx | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=2` | - | 136.42 | 98.48 | 174.31 | 20 | 8.6 | - | 18.09 MiB | 32 thread(s) | -| `row_topk` | `rowtopk_bf16` | libr4d | `N=248320 R=32 dtype=bf16 M=32 nch=0 pt1=8` | 134.50 | - | 133.62 | 136.28 | 6 | 1.0 | 3447 | 15.17 MiB | | -| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=248320 k=21 M=8` | 133.29 | - | 128.50 | 133.70 | 16 | 1.0 | 3582 | 7.58 MiB | | -| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=248320 k=21 M=4` | 133.20 | - | 130.59 | 133.79 | 16 | 0.3 | 3583 | 3.79 MiB | | -| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=248320 k=21 M=2` | 132.84 | - | 132.68 | 133.22 | 6 | 0.2 | 3588 | 1.90 MiB | | -| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=248320 k=21 M=1` | 132.67 | - | 131.02 | 133.08 | 6 | 0.8 | 3584 | 970.27 KiB | | -| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=248320 k=21 M=32` | 132.61 | - | 132.13 | 133.56 | 6 | 0.5 | 3564 | 30.32 MiB | | -| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=1` | - | 129.89 | 109.93 | 132.42 | 20 | 1.7 | - | 5.01 MiB | 32 thread(s) | -| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=248320 k=21 M=16` | 127.96 | - | 127.52 | 128.81 | 6 | 0.5 | 3576 | 15.16 MiB | | -| `sample_topp` | `sample_topp_f32` | libr4d | `n_cand=1024 M=64` | 127.45 | - | 126.42 | 127.97 | 6 | 0.6 | 3564 | 518.00 KiB | restore 4% | -| `sample_topp` | `sample_topp_f32` | libr4d | `n_cand=1024 M=16` | 127.32 | - | 127.22 | 127.40 | 6 | 0.1 | 3562 | 129.50 KiB | restore 4% | -| `sample_topp` | `sample_topp_f32` | libr4d | `n_cand=1024 M=32` | 126.63 | - | 123.88 | 127.56 | 14 | 0.9 | 3560 | 259.00 KiB | restore 4% | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=25600 group=128 dtype=bf16 M=128` | - | 126.52 | 124.06 | 140.36 | 19 | 1.0 | - | 9.47 MiB | 32 thread(s) | -| `sample_topp` | `sample_topp_f32` | libr4d | `n_cand=1024 M=1` | 125.50 | - | 115.49 | 126.06 | 16 | 1.0 | 3540 | 8.09 KiB | restore 4% | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | 123.92 | - | 123.82 | 124.18 | 6 | 0.1 | 3364 | 70.63 MiB | | -| `sample_topp` | `sample_topp_f32` | libr4d | `n_cand=1024 M=8` | 123.82 | - | 120.90 | 124.05 | 11 | 1.0 | 3560 | 64.75 KiB | restore 4% | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4608 K=4608 dtype=bf16 act=gelu M=128` | 123.73 | - | 118.46 | 127.55 | 20 | 2.3 | 3376 | 43.88 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=128` | 123.66 | - | 122.33 | 124.57 | 11 | 0.9 | 2806 | 63.65 MiB | | -| `sample_topk` | `sample_topk_f32` | libr4d | `n_vocab=248320 M=8` | 123.43 | - | 121.22 | 123.57 | 6 | 1.0 | 3520 | 7.59 MiB | | -| `sample_topk` | `sample_topk_f32` | libr4d | `n_vocab=248320 M=4` | 123.20 | - | 118.37 | 123.63 | 19 | 0.4 | 3521 | 3.79 MiB | | -| `sample_topp` | `sample_topp_f32` | libr4d | `n_cand=1024 M=4` | 122.93 | - | 120.15 | 123.36 | 16 | 0.8 | 3551 | 32.38 KiB | restore 4% | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | 122.72 | - | 122.55 | 122.84 | 6 | 0.1 | 3358 | 70.59 MiB | | -| `sample_topk` | `sample_topk_f32` | libr4d | `n_vocab=248320 M=1` | 122.61 | - | 118.45 | 123.07 | 11 | 0.4 | 3513 | 971.09 KiB | | -| `sample_topk` | `sample_topk_f32` | libr4d | `n_vocab=248320 M=2` | 121.91 | - | 119.71 | 122.61 | 14 | 0.8 | 3518 | 1.90 MiB | | -| `sample_topk` | `sample_topk_f32` | libr4d | `n_vocab=248320 M=32` | 120.70 | - | 120.48 | 121.41 | 6 | 0.4 | 3522 | 30.35 MiB | | -| `gdn_recurrent_update` | `avx_gdn_recurrent_update` | libavx | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=1` | - | 120.64 | 106.87 | 169.65 | 20 | 14.4 | - | 18.04 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=65` | 120.37 | - | 119.11 | 121.05 | 11 | 0.5 | 3153 | 61.86 MiB | | -| `sample_pick` | `sample_pick_f32` | libr4d | `n_cand=1024 M=64` | 120.27 | - | 115.65 | 120.72 | 19 | 0.9 | 3584 | 518.25 KiB | | -| `gated_quant_fp8` | `avx_gated_quant_fp8` | libavx | `n=17408 group=128 dtype=bf16 act=silu M=64` | - | 119.66 | 118.73 | 121.44 | 11 | 1.0 | - | 7.47 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1152 dtype=bf16 act=none M=8` | - | 119.66 | 113.80 | 125.93 | 20 | 3.1 | - | 2.59 MiB | 32 thread(s) | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=4608 dtype=bf16 act=none M=128` | 119.61 | - | 115.50 | 125.05 | 20 | 1.9 | 3296 | 48.63 MiB | | -| `sample_pick` | `sample_pick_f32` | libr4d | `n_cand=1024 M=8` | 118.81 | - | 116.32 | 118.90 | 11 | 0.2 | 3586 | 64.78 KiB | | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=6144 group=128 dtype=bf16 M=512` | - | 118.79 | 116.01 | 171.77 | 20 | 1.1 | - | 9.09 MiB | 32 thread(s) | -| `sample_pick` | `sample_pick_f32` | libr4d | `n_cand=1024 M=32` | 118.67 | - | 118.44 | 119.01 | 11 | 0.2 | 3585 | 259.12 KiB | | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | - | 118.06 | 110.02 | 139.06 | 20 | 4.3 | - | 888.02 KiB | 32 thread(s) | -| `row_topk` | `rowtopk_bf16` | libr4d | `N=248320 R=32 dtype=bf16 M=8 nch=0 pt1=8` | 117.53 | - | 114.66 | 118.00 | 16 | 0.5 | 3457 | 3.79 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | 116.87 | - | 114.81 | 117.66 | 14 | 0.9 | 3005 | 49.53 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4608 K=4608 dtype=bf16 act=gelu M=64` | 116.79 | - | 115.42 | 119.12 | 14 | 0.7 | 3453 | 42.20 MiB | | -| `sample_pick` | `sample_pick_f32` | libr4d | `n_cand=1024 M=16` | 116.77 | - | 111.51 | 117.17 | 19 | 0.2 | 3586 | 129.56 KiB | | -| `sample_topk` | `sample_topk_f32` | libr4d | `n_vocab=248320 M=16` | 116.62 | - | 116.38 | 117.09 | 6 | 0.3 | 3522 | 15.17 MiB | | -| `sample_mask` | `sample_mask_f32` | libr4d | `n_vocab=248320 M=64` | 116.22 | - | 115.26 | 118.68 | 14 | 0.9 | 3505 | 62.53 MiB | restore 65% | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=129` | 116.20 | - | 114.09 | 116.60 | 11 | 0.9 | 2900 | 32.04 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | 115.88 | - | 115.49 | 116.99 | 6 | 0.6 | 3362 | 70.45 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=4608 dtype=bf16 act=none M=64` | 115.51 | - | 114.51 | 116.29 | 6 | 0.8 | 3416 | 46.82 MiB | | -| `row_topk` | `rowtopk_bf16` | libr4d | `N=248320 R=32 dtype=bf16 M=16 nch=0 pt1=8` | 112.60 | - | 109.02 | 113.12 | 14 | 0.8 | 3452 | 7.59 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | 112.53 | - | 112.21 | 113.33 | 6 | 0.5 | 3352 | 70.38 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=64` | 111.61 | - | 110.74 | 112.22 | 11 | 0.5 | 3348 | 61.83 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4608 K=4608 dtype=bf16 act=gelu M=32` | 111.53 | - | 108.85 | 113.70 | 19 | 0.9 | 3430 | 41.35 MiB | | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1536 dtype=bf16 act=none M=4` | - | 111.37 | 90.31 | 116.63 | 20 | 4.2 | - | 3.41 MiB | 32 thread(s) | -| `sample_topp` | `sample_topp_f32` | libr4d | `n_cand=1024 M=2` | 111.37 | - | 108.92 | 111.72 | 20 | 1.1 | 3552 | 16.19 KiB | restore 4% | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | 110.87 | - | 110.68 | 111.03 | 11 | 0.1 | 3344 | 70.35 MiB | | -| `add` | `avx_add` | libavx | `n=5120 dtype=bf16 M=512` | - | 110.76 | 107.78 | 112.33 | 16 | 0.9 | - | 15.00 MiB | 32 thread(s) | -| `row_topk` | `rowtopk_bf16` | libr4d | `N=248320 R=32 dtype=bf16 M=4 nch=0 pt1=8` | 110.60 | - | 110.37 | 110.83 | 6 | 0.2 | 3456 | 1.90 MiB | | -| `gdn_conv_update` | `gdn_conv_update_w4_h128_bf16` | libr4d | `head_k=128 head_v=128 conv_width=4 q_len=128` | 109.87 | - | 104.83 | 110.25 | 19 | 0.7 | 3396 | 7.62 MiB | restore 3% | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=4608 dtype=bf16 act=none M=32` | 109.50 | - | 108.71 | 110.89 | 6 | 1.0 | 3467 | 45.92 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=36` | 109.34 | - | 109.06 | 109.85 | 11 | 0.4 | 3353 | 61.03 MiB | | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1536 dtype=bf16 act=none M=32` | - | 107.27 | 92.40 | 121.14 | 20 | 4.0 | - | 3.61 MiB | 32 thread(s) | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=4608 dtype=bf16 act=none M=8` | 106.85 | - | 105.48 | 107.33 | 6 | 0.9 | 3452 | 45.24 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=4608 dtype=bf16 act=none M=1` | 106.57 | - | 103.19 | 111.33 | 20 | 3.1 | 3263 | 45.04 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=4608 dtype=bf16 act=none M=16` | 106.35 | - | 105.93 | 107.57 | 6 | 0.8 | 3458 | 45.46 MiB | | -| `sample_argmax` | `sample_argmax_f32` | libr4d | `n_vocab=248320 M=64` | 106.35 | - | 106.17 | 106.64 | 6 | 0.2 | 3534 | 60.63 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4608 K=4608 dtype=bf16 act=gelu M=16` | 106.09 | - | 105.37 | 106.58 | 6 | 0.6 | 3502 | 40.93 MiB | | -| `grid_embed` | `avx_grid_embed` | libavx | `n=1152 side=48 dtype=bf16 M=8` | - | 105.61 | 105.04 | 108.09 | 14 | 0.4 | - | 5.08 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=18` | 105.59 | - | 105.43 | 105.65 | 11 | 0.1 | 3352 | 60.52 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4608 K=4608 dtype=bf16 act=gelu M=8` | 105.28 | - | 104.89 | 106.23 | 6 | 0.6 | 3484 | 40.72 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=4608 dtype=bf16 act=none M=4` | 105.18 | - | 104.62 | 106.62 | 11 | 0.8 | 3422 | 45.12 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=4608 dtype=bf16 act=none M=2` | 104.52 | - | 103.66 | 105.28 | 6 | 0.8 | 3443 | 45.07 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=9` | 104.32 | - | 104.25 | 104.91 | 11 | 0.3 | 3357 | 60.26 MiB | | -| `gated_quant_fp8` | `gated_quant_fp8` | libr4d | `n=17408 group=128 dtype=bf16 act=silu M=512` | 104.25 | - | 103.95 | 104.38 | 11 | 0.2 | 3341 | 59.77 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=8` | 104.16 | - | 104.04 | 104.32 | 11 | 0.1 | 3359 | 60.24 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4608 K=4608 dtype=bf16 act=gelu M=1` | 104.04 | - | 103.03 | 104.43 | 6 | 0.7 | 3412 | 40.54 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4608 K=4608 dtype=bf16 act=gelu M=4` | 103.99 | - | 103.72 | 104.41 | 6 | 0.3 | 3464 | 40.61 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4608 K=4608 dtype=bf16 act=gelu M=2` | 103.96 | - | 103.09 | 104.72 | 6 | 0.8 | 3454 | 40.56 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=4` | 103.63 | - | 103.51 | 105.57 | 11 | 1.0 | 3361 | 60.12 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=1` | 103.53 | - | 102.99 | 117.00 | 14 | 0.2 | 2831 | 60.04 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=2` | 103.52 | - | 103.33 | 105.95 | 14 | 0.1 | 3361 | 60.06 MiB | | -| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | `head_k=128 M=64 chunk=64` | - | 103.19 | 101.52 | 104.45 | 20 | 1.1 | - | 664.01 KiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | 101.73 | - | 101.22 | 102.59 | 11 | 0.7 | 3208 | 48.78 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=4304 dtype=bf16 act=none M=512` | 100.40 | - | 98.95 | 102.68 | 19 | 0.8 | 3357 | 15.91 MiB | | -| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=64` | - | 99.78 | 99.00 | 101.88 | 20 | 1.0 | - | 36.01 KiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1152 dtype=bf16 act=none M=4` | - | 99.70 | 62.23 | 112.18 | 20 | 10.4 | - | 2.56 MiB | 32 thread(s) | -| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=512` | - | 97.97 | 96.94 | 99.15 | 14 | 0.7 | - | 3.06 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1536 dtype=bf16 act=none M=2` | - | 97.23 | 78.85 | 101.07 | 20 | 5.4 | - | 3.39 MiB | 32 thread(s) | -| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | `head_k=128 head_v=128 scale=0.0883883 M=8 chunk=64` | - | 95.58 | 94.40 | 140.24 | 19 | 0.9 | - | 6.30 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1536 dtype=bf16 act=none M=1` | - | 95.31 | 59.44 | 144.63 | 20 | 7.0 | - | 3.38 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | - | 94.71 | 93.30 | 98.07 | 20 | 1.5 | - | 832.01 KiB | 32 thread(s) | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=256 K=5120 dtype=bf16 M=56 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 94.00 | 83.82 | 97.73 | 20 | 4.2 | - | 3.07 MiB | 32 thread(s) | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | 92.67 | - | 92.40 | 93.22 | 6 | 0.4 | 3394 | 32.05 MiB | | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | 92.04 | - | 91.73 | 92.32 | 6 | 0.3 | 3400 | 32.03 MiB | | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1536 dtype=bf16 act=none M=16` | - | 90.73 | 73.67 | 96.50 | 20 | 2.9 | - | 3.49 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | 90.39 | - | 90.30 | 90.92 | 6 | 0.3 | 3313 | 48.30 MiB | | -| `gdn_conv_update` | `avx_gdn_conv_update` | libavx | `head_k=128 head_v=128 conv_width=4 q_len=8` | - | 89.54 | 88.61 | 131.41 | 20 | 2.6 | - | 600.04 KiB | 32 thread(s) | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=512` | 87.87 | - | 85.61 | 88.48 | 14 | 0.9 | 3174 | 19.00 MiB | | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=25600 group=128 dtype=bf16 M=64` | - | 87.60 | 81.51 | 92.30 | 20 | 3.6 | - | 4.74 MiB | 32 thread(s) | -| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=128` | - | 86.23 | 84.21 | 96.04 | 20 | 2.1 | - | 4.40 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1152 dtype=bf16 act=none M=32` | - | 85.76 | 77.23 | 89.78 | 20 | 5.4 | - | 2.74 MiB | 32 thread(s) | -| `sample_pick` | `sample_pick_f32` | libr4d | `n_cand=1024 M=1` | 84.25 | - | 82.99 | 84.66 | 11 | 0.9 | 3586 | 8.10 KiB | | -| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=248320 M=64` | 84.23 | - | 83.97 | 84.32 | 6 | 0.2 | 3485 | 60.63 MiB | restore 72% | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | 81.69 | - | 81.54 | 81.94 | 11 | 0.2 | 3360 | 48.05 MiB | | -| `row_topk` | `rowtopk_bf16` | libr4d | `N=248320 R=32 dtype=bf16 M=1 nch=0 pt1=8` | 81.56 | - | 79.64 | 81.83 | 16 | 1.0 | 3457 | 485.50 KiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | 81.30 | - | 81.06 | 81.69 | 11 | 0.3 | 3317 | 48.03 MiB | | -| `scatter_rows` | `avx_scatter_rows` | libavx | `n=5120 dtype=bf16 M=256` | - | 80.86 | 79.16 | 82.72 | 14 | 0.7 | - | 12.50 MiB | 32 thread(s) | -| `row_topk` | `rowtopk_bf16` | libr4d | `N=248320 R=32 dtype=bf16 M=2 nch=0 pt1=8` | 80.76 | - | 79.81 | 81.35 | 6 | 1.0 | 3455 | 971.00 KiB | | -| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=512` | - | 79.98 | 78.81 | 97.84 | 20 | 2.3 | - | 6.01 MiB | 32 thread(s) | -| `grid_embed` | `avx_grid_embed` | libavx | `n=1152 side=48 dtype=bf16 M=32` | - | 78.91 | 78.48 | 79.29 | 6 | 0.5 | - | 5.13 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=65` | 78.78 | - | 75.69 | 80.27 | 20 | 1.7 | 3217 | 31.03 MiB | | -| `rope` | `avx_rope` | libavx | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=512` | - | 78.72 | 78.03 | 87.74 | 16 | 0.6 | - | 3.38 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | 78.50 | - | 78.29 | 78.67 | 11 | 0.2 | 3352 | 47.92 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=128` | 78.44 | - | 76.86 | 79.71 | 14 | 1.0 | 3056 | 32.03 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | 77.43 | - | 77.13 | 77.97 | 11 | 0.4 | 2989 | 47.84 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | 77.36 | - | 77.17 | 78.07 | 6 | 0.6 | 3289 | 47.87 MiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=25600 group=128 dtype=bf16 M=512` | 74.80 | - | 74.62 | 75.18 | 6 | 0.4 | 3351 | 37.89 MiB | | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=10 splits=0` | 74.79 | - | 74.70 | 75.30 | 6 | 0.4 | 3397 | 32.24 MiB | | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=256 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 74.73 | 62.57 | 81.19 | 20 | 1.9 | - | 2.58 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1152 dtype=bf16 act=none M=2` | - | 74.68 | 65.20 | 93.48 | 20 | 10.3 | - | 2.55 MiB | 32 thread(s) | -| `sample_pick` | `sample_pick_f32` | libr4d | `n_cand=1024 M=4` | 74.64 | - | 72.92 | 74.85 | 14 | 0.4 | 3587 | 32.39 KiB | | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | 74.35 | - | 74.04 | 74.72 | 6 | 0.5 | 3392 | 32.12 MiB | | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=9 splits=0` | 74.04 | - | 73.94 | 74.26 | 6 | 0.2 | 3382 | 32.21 MiB | | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | 73.51 | - | 73.41 | 74.10 | 6 | 0.5 | 3393 | 32.10 MiB | | -| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=248320 k=21 M=2` | - | 73.46 | 72.96 | 75.14 | 20 | 1.3 | - | 1.90 MiB | 32 thread(s) | -| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=248320 k=21 M=8` | - | 73.31 | 71.15 | 74.67 | 20 | 1.8 | - | 7.58 MiB | 32 thread(s) | -| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=248320 k=21 M=1` | - | 73.16 | 70.61 | 77.23 | 20 | 3.7 | - | 970.27 KiB | 32 thread(s) | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=256 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 72.23 | 61.44 | 82.41 | 20 | 11.4 | - | 2.85 MiB | 32 thread(s) | -| `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | `head_k=128 head_v=128 scale=0.0883883 M=512 chunk=64` | 71.61 | - | 71.37 | 72.22 | 6 | 0.6 | 3351 | 25.19 MiB | | -| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=248320 k=21 M=4` | - | 71.41 | 70.01 | 73.55 | 19 | 1.0 | - | 3.79 MiB | 32 thread(s) | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | 71.22 | - | 70.95 | 71.68 | 6 | 0.5 | 3389 | 32.19 MiB | | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1152 dtype=bf16 act=none M=16` | - | 71.09 | 60.11 | 76.68 | 20 | 6.6 | - | 2.64 MiB | 32 thread(s) | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=256 K=5120 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 70.69 | 62.62 | 93.68 | 20 | 13.7 | - | 2.52 MiB | 32 thread(s) | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | 68.97 | - | 68.86 | 69.34 | 6 | 0.3 | 3387 | 32.14 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3456 K=1152 dtype=bf16 act=none M=512` | 67.30 | - | 64.15 | 67.97 | 20 | 1.7 | 3268 | 15.48 MiB | | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=256 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 64.18 | 42.30 | 65.19 | 20 | 1.1 | - | 2.54 MiB | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=512` | - | 64.11 | 61.95 | 91.79 | 20 | 1.7 | - | 10.01 MiB | 32 thread(s) | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=4304 dtype=bf16 act=none M=256` | 63.93 | - | 60.99 | 65.21 | 20 | 1.8 | 3412 | 12.69 MiB | | -| `gdn_conv_update` | `gdn_conv_update_w4_h128_bf16` | libr4d | `head_k=128 head_v=128 conv_width=4 q_len=64` | 63.40 | - | 52.96 | 63.59 | 11 | 0.3 | 3396 | 3.87 MiB | restore 4% | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=512` | - | 62.95 | 61.45 | 88.42 | 20 | 5.4 | - | 10.01 MiB | 32 thread(s) | -| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1152 dtype=bf16 act=none M=1` | - | 62.80 | 49.52 | 65.88 | 16 | 0.6 | - | 2.54 MiB | 32 thread(s) | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=256 K=5120 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 61.75 | 36.84 | 93.16 | 20 | 9.3 | - | 2.51 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=128 ks=0 bk=0 nt=0` | 61.45 | - | 60.37 | 61.48 | 11 | 0.1 | 3374 | 3.71 MiB | | -| `gdn_conv_update` | `avx_gdn_conv_update` | libavx | `head_k=128 head_v=128 conv_width=4 q_len=2` | - | 61.35 | 60.93 | 61.79 | 6 | 0.7 | - | 240.02 KiB | 32 thread(s) | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=17408 group=128 dtype=bf16 M=64` | - | 60.70 | 55.25 | 63.15 | 20 | 4.1 | - | 3.22 MiB | 32 thread(s) | -| `gated_quant_fp8` | `avx_gated_quant_fp8` | libavx | `n=17408 group=128 dtype=bf16 act=silu M=32` | - | 59.97 | 59.13 | 62.03 | 20 | 1.4 | - | 3.74 MiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=256` | - | 59.74 | 59.38 | 60.68 | 11 | 1.0 | - | 3.00 MiB | 32 thread(s) | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=6144 group=128 dtype=bf16 M=256` | - | 59.60 | 58.21 | 60.53 | 20 | 1.3 | - | 4.55 MiB | 32 thread(s) | -| `kv_store` | `avx_kv_store` | libavx | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=512` | - | 59.13 | 57.82 | 61.26 | 16 | 1.0 | - | 3.06 MiB | 32 thread(s) | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | 58.81 | - | 58.55 | 61.55 | 16 | 0.7 | 3273 | 13.00 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=64` | 57.76 | - | 57.58 | 57.99 | 11 | 0.3 | 3439 | 31.02 MiB | | -| `gdn_conv_update` | `avx_gdn_conv_update` | libavx | `head_k=128 head_v=128 conv_width=4 q_len=4` | - | 56.95 | 55.96 | 82.40 | 20 | 1.1 | - | 360.03 KiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=36` | 56.47 | - | 56.37 | 56.52 | 11 | 0.1 | 3445 | 30.57 MiB | | -| `add` | `avx_add` | libavx | `n=5120 dtype=bf16 M=256` | - | 56.31 | 56.19 | 57.29 | 6 | 1.0 | - | 7.50 MiB | 32 thread(s) | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=256 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 56.24 | 54.66 | 58.73 | 20 | 2.0 | - | 2.67 MiB | 32 thread(s) | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=256 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 55.63 | 39.38 | 57.42 | 20 | 2.1 | - | 2.66 MiB | 32 thread(s) | -| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | `head_k=128 head_v=128 scale=0.0883883 M=4 chunk=64` | - | 55.40 | 54.66 | 79.23 | 20 | 1.4 | - | 6.15 MiB | 32 thread(s) | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=96 K=5120 dtype=bf16 M=65 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 55.28 | 42.96 | 89.90 | 20 | 35.0 | - | 1.58 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=18` | 54.95 | - | 54.82 | 55.17 | 11 | 0.3 | 3442 | 30.29 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=8` | 54.07 | - | 54.04 | 54.12 | 11 | 0.1 | 3444 | 30.13 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=9` | 53.99 | - | 53.90 | 54.03 | 11 | 0.1 | 3447 | 30.15 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=2` | 53.79 | - | 53.71 | 53.84 | 11 | 0.1 | 3443 | 30.04 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=4` | 53.66 | - | 53.62 | 53.69 | 11 | 0.1 | 3435 | 30.07 MiB | | -| `grid_embed` | `avx_grid_embed` | libavx | `n=1152 side=48 dtype=bf16 M=4` | - | 53.63 | 53.13 | 54.39 | 11 | 0.9 | - | 5.07 MiB | 32 thread(s) | -| `gated_quant_fp8` | `gated_quant_fp8` | libr4d | `n=17408 group=128 dtype=bf16 act=silu M=256` | 53.56 | - | 53.45 | 54.01 | 11 | 0.5 | 3347 | 29.88 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=1` | 53.52 | - | 53.50 | 53.54 | 6 | 0.0 | 3417 | 30.02 MiB | | -| `sample_argmax` | `sample_argmax_f32` | libr4d | `n_vocab=248320 M=32` | 53.01 | - | 53.00 | 53.05 | 6 | 0.0 | 3534 | 30.32 MiB | | -| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=64` | - | 51.29 | 48.91 | 56.79 | 20 | 6.3 | - | 2.21 MiB | 32 thread(s) | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=256` | 51.07 | - | 48.92 | 51.81 | 20 | 1.5 | 3316 | 14.23 MiB | | -| `sample_minp` | `avx_sample_minp` | libavx | `n_cand=1024 M=64` | - | 50.86 | 46.53 | 52.77 | 20 | 1.5 | - | 518.00 KiB | 32 thread(s) | -| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=248320 M=2` | - | 48.05 | 47.97 | 48.25 | 6 | 0.3 | - | 1.89 MiB | 32 thread(s) | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=96 K=5120 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 47.16 | 44.92 | 54.34 | 20 | 7.9 | - | 1.57 MiB | 32 thread(s) | -| `rope` | `rope_bf16` | libr4d | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=512` | 47.08 | - | 44.74 | 47.30 | 11 | 0.8 | 3464 | 3.38 MiB | restore 8% | -| `rope` | `avx_rope` | libavx | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=256` | - | 45.88 | 44.69 | 52.17 | 14 | 0.9 | - | 1.69 MiB | 32 thread(s) | -| `silu_mul` | `avx_silu_mul` | libavx | `n=17408 dtype=bf16 M=64` | - | 44.85 | 44.29 | 65.37 | 16 | 0.9 | - | 6.38 MiB | 32 thread(s) | -| `gdn_recurrent_update` | `gdn_recurrent_update_k128_v128_bf16_fp32state` | libr4d | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=16` | 44.70 | - | 29.12 | 45.16 | 11 | 0.9 | 3428 | 48.69 MiB | restore 79%; restore-dominated (79% of the batch): an order of magnitude | -| `gdn_conv_update` | `gdn_conv_update_w4_h128_bf16` | libr4d | `head_k=128 head_v=128 conv_width=4 q_len=32` | 44.61 | - | 39.25 | 44.67 | 14 | 0.2 | 3397 | 1.99 MiB | restore 6% | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=258` | 44.04 | - | 43.57 | 44.38 | 6 | 0.9 | 3345 | 6.80 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=129` | 43.62 | - | 43.29 | 44.04 | 6 | 0.9 | 3354 | 5.90 MiB | | -| `sample_xtc` | `avx_sample_xtc` | libavx | `n_cand=1024 M=64` | - | 43.57 | 43.15 | 59.89 | 16 | 0.3 | - | 518.00 KiB | 32 thread(s) | -| `gdn_conv_update` | `avx_gdn_conv_update` | libavx | `head_k=128 head_v=128 conv_width=4 q_len=1` | - | 43.50 | 30.54 | 44.98 | 20 | 1.9 | - | 180.02 KiB | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=256` | - | 43.27 | 33.61 | 47.77 | 20 | 14.7 | - | 5.01 MiB | 32 thread(s) | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=96 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 42.75 | 40.39 | 47.04 | 20 | 5.2 | - | 1.02 MiB | 32 thread(s) | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=4304 dtype=bf16 act=none M=128` | 42.58 | - | 42.40 | 43.00 | 6 | 0.7 | 3535 | 11.07 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_tiled` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=512 tn=0` | 42.54 | - | 42.19 | 42.96 | 6 | 0.9 | 3352 | 6.39 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=65` | 42.05 | - | 41.91 | 42.16 | 11 | 0.2 | 3366 | 5.45 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=512` | 41.91 | - | 39.91 | 43.64 | 20 | 2.3 | 3255 | 8.58 MiB | | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | 40.89 | - | 23.37 | 41.02 | 20 | 1.2 | 3435 | 3.38 MiB | | -| `gated_quant_fp8` | `avx_gated_quant_fp8` | libavx | `n=17408 group=128 dtype=bf16 act=silu M=8` | - | 40.82 | 39.09 | 47.22 | 20 | 5.6 | - | 956.25 KiB | 32 thread(s) | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1536 dtype=bf16 act=none M=512` | 40.80 | - | 40.59 | 41.14 | 11 | 0.6 | 3479 | 7.13 MiB | | -| `scatter_rows` | `avx_scatter_rows` | libavx | `n=5120 dtype=bf16 M=128` | - | 40.53 | 37.87 | 40.83 | 16 | 0.8 | - | 6.25 MiB | 32 thread(s) | -| `grid_embed` | `avx_grid_embed` | libavx | `n=1152 side=48 dtype=bf16 M=16` | - | 40.51 | 40.27 | 40.86 | 6 | 0.7 | - | 5.10 MiB | 32 thread(s) | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=25600 group=128 dtype=bf16 M=256` | 39.82 | - | 39.35 | 40.32 | 11 | 0.9 | 3355 | 18.95 MiB | | -| `sample_topp` | `avx_sample_topp` | libavx | `n_cand=1024 M=64` | - | 39.81 | 39.43 | 56.07 | 20 | 20.1 | - | 518.00 KiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_mxfp4a8_tiled` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=258 tn=0` | 39.75 | - | 39.62 | 40.31 | 6 | 0.9 | 3368 | 4.62 MiB | | -| `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | `head_k=128 head_v=128 scale=0.0883883 M=256 chunk=64` | 39.68 | - | 39.46 | 39.80 | 6 | 0.4 | 3346 | 15.59 MiB | | -| `cast` | `avx_cast` | libavx | `n=5120 from=bf16 to=bf16 M=512` | - | 39.16 | 37.66 | 40.04 | 20 | 2.1 | - | 10.00 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_mxfp4a8_tiled` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=129 tn=0` | 38.77 | - | 38.53 | 38.84 | 6 | 0.4 | 3368 | 3.71 MiB | | -| `sample_mask` | `sample_mask_f32` | libr4d | `n_vocab=248320 M=32` | 38.72 | - | 38.40 | 39.11 | 11 | 0.7 | 3490 | 31.26 MiB | restore 51% | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=128` | 38.58 | - | 38.45 | 38.69 | 6 | 0.3 | 3557 | 11.85 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=128` | 37.71 | - | 37.61 | 37.97 | 11 | 0.4 | 3368 | 5.90 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | 37.60 | - | 37.32 | 37.67 | 6 | 0.5 | 3410 | 12.13 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3456 K=1152 dtype=bf16 act=none M=256` | 37.25 | - | 36.73 | 37.50 | 11 | 0.8 | 3435 | 11.54 MiB | | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5120 group=128 dtype=bf16 M=128` | - | 37.22 | 36.93 | 37.51 | 6 | 0.8 | - | 1.89 MiB | 32 thread(s) | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=64` | 36.87 | - | 36.61 | 37.06 | 6 | 0.6 | 3550 | 10.66 MiB | | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=96 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 36.80 | 35.06 | 39.50 | 20 | 4.5 | - | 1.28 MiB | 32 thread(s) | -| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | `head_k=128 head_v=128 scale=0.0883883 M=2 chunk=64` | - | 36.27 | 35.21 | 51.68 | 20 | 13.3 | - | 6.07 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | 36.11 | - | 35.87 | 36.32 | 6 | 0.6 | 3454 | 12.07 MiB | | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5120 group=128 dtype=bf16 M=256` | - | 35.73 | 33.84 | 47.27 | 20 | 3.7 | - | 3.79 MiB | 32 thread(s) | -| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=256` | - | 35.57 | 35.44 | 36.40 | 14 | 0.6 | - | 1.56 MiB | 32 thread(s) | -| `sample_pick` | `avx_sample_pick` | libavx | `n_cand=1024 M=64` | - | 35.03 | 34.76 | 35.37 | 6 | 0.9 | - | 518.25 KiB | 32 thread(s) | -| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=248320 M=4` | - | 34.90 | 34.84 | 35.46 | 6 | 0.9 | - | 3.79 MiB | 32 thread(s) | -| `sample_xtc` | `avx_sample_xtc` | libavx | `n_cand=1024 M=32` | - | 34.65 | 34.48 | 34.76 | 11 | 0.4 | - | 259.00 KiB | 32 thread(s) | -| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=1280 K=5120 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | 34.62 | - | 34.55 | 34.72 | 6 | 0.2 | 3458 | 13.28 MiB | | -| `gated_quant_fp8` | `avx_gated_quant_fp8` | libavx | `n=17408 group=128 dtype=bf16 act=silu M=16` | - | 33.59 | 32.40 | 50.42 | 20 | 24.1 | - | 1.87 MiB | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=256` | - | 33.57 | 32.84 | 47.92 | 20 | 13.2 | - | 5.01 MiB | 32 thread(s) | -| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=248320 M=1` | - | 33.12 | 33.03 | 33.57 | 6 | 0.8 | - | 970.09 KiB | 32 thread(s) | -| `gated_quant_fp8` | `gated_quant_fp8` | libr4d | `n=17408 group=128 dtype=bf16 act=silu M=128` | 32.99 | - | 32.37 | 33.63 | 16 | 0.8 | 3352 | 14.94 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1152 dtype=bf16 act=none M=512` | 32.64 | - | 32.34 | 33.20 | 14 | 0.9 | 3519 | 5.91 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=32` | 32.58 | - | 32.47 | 32.73 | 6 | 0.4 | 3550 | 10.06 MiB | | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=96 K=5120 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 32.25 | 29.17 | 35.07 | 20 | 6.9 | - | 980.38 KiB | 32 thread(s) | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=25600 group=128 dtype=bf16 M=32` | - | 32.06 | 31.92 | 32.64 | 14 | 0.9 | - | 2.37 MiB | 32 thread(s) | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=96 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 31.70 | 17.66 | 35.43 | 20 | 7.8 | - | 1000.75 KiB | 32 thread(s) | -| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=32` | - | 30.55 | 29.80 | 31.67 | 20 | 1.7 | - | 1.11 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | 30.54 | - | 30.40 | 30.78 | 6 | 0.6 | 3476 | 11.75 MiB | | -| `kv_store` | `avx_kv_store` | libavx | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=256` | - | 30.52 | 29.44 | 31.49 | 20 | 1.9 | - | 1.56 MiB | 32 thread(s) | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=6144 group=128 dtype=bf16 M=128` | - | 30.51 | 30.10 | 44.83 | 20 | 21.3 | - | 2.27 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | 30.47 | - | 30.29 | 30.63 | 6 | 0.6 | 3457 | 11.71 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=8` | 30.43 | - | 30.28 | 30.70 | 6 | 0.7 | 3542 | 9.61 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=16` | 30.43 | - | 30.27 | 30.69 | 6 | 0.7 | 3546 | 9.76 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=4304 dtype=bf16 act=none M=64` | 30.37 | - | 30.32 | 30.52 | 6 | 0.3 | 3554 | 10.27 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=4304 dtype=bf16 act=none M=32` | 30.13 | - | 30.09 | 30.22 | 6 | 0.2 | 3558 | 9.86 MiB | | -| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=1280 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | 29.60 | - | 29.54 | 29.68 | 6 | 0.2 | 3464 | 12.92 MiB | | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | 29.58 | - | 29.40 | 29.74 | 6 | 0.6 | 3407 | 6.72 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=4` | 29.28 | - | 29.19 | 29.46 | 6 | 0.5 | 3549 | 9.54 MiB | | -| `add` | `avx_add` | libavx | `n=5120 dtype=bf16 M=128` | - | 29.08 | 28.61 | 38.64 | 20 | 4.1 | - | 3.75 MiB | 32 thread(s) | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=2` | 28.96 | - | 28.72 | 29.10 | 6 | 0.7 | 3558 | 9.50 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=1` | 28.86 | - | 28.68 | 28.95 | 6 | 0.5 | 3548 | 9.48 MiB | | -| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=256` | - | 28.77 | 28.02 | 34.42 | 20 | 9.7 | - | 513.00 KiB | 32 thread(s) | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=4304 dtype=bf16 act=none M=16` | 28.67 | - | 28.57 | 28.72 | 6 | 0.3 | 3556 | 9.66 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=4304 dtype=bf16 act=none M=8` | 28.48 | - | 28.44 | 28.62 | 6 | 0.3 | 3554 | 9.56 MiB | | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=96 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 28.47 | 23.05 | 32.90 | 20 | 6.5 | - | 1.10 MiB | 32 thread(s) | -| `sample_argmax` | `sample_argmax_f32` | libr4d | `n_vocab=248320 M=16` | 28.45 | - | 28.43 | 28.62 | 6 | 0.3 | 3540 | 15.16 MiB | | -| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=248320 M=32` | 28.04 | - | 27.86 | 28.17 | 6 | 0.6 | 3474 | 30.32 MiB | restore 59% | -| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=512` | - | 28.02 | 25.42 | 30.63 | 20 | 8.3 | - | 1.00 MiB | 32 thread(s) | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=4304 dtype=bf16 act=none M=4` | 27.85 | - | 27.75 | 27.96 | 6 | 0.4 | 3558 | 9.51 MiB | | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=96 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 27.61 | 20.91 | 33.04 | 20 | 10.2 | - | 1.11 MiB | 32 thread(s) | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=4304 dtype=bf16 act=none M=2` | 27.51 | - | 27.42 | 27.57 | 6 | 0.3 | 3556 | 9.48 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=4304 dtype=bf16 act=none M=1` | 27.42 | - | 27.27 | 27.94 | 14 | 0.6 | 3516 | 9.47 MiB | | -| `grid_embed` | `avx_grid_embed` | libavx | `n=1152 side=48 dtype=bf16 M=2` | - | 27.34 | 27.02 | 28.13 | 16 | 0.8 | - | 5.07 MiB | 32 thread(s) | -| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=1280 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | 26.97 | - | 26.93 | 27.08 | 6 | 0.3 | 3468 | 12.70 MiB | | -| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=1280 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | 26.63 | - | 26.60 | 26.66 | 6 | 0.1 | 3467 | 12.71 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | 26.38 | - | 26.29 | 26.51 | 6 | 0.4 | 3492 | 11.50 MiB | | -| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=1280 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | 26.37 | - | 26.34 | 26.53 | 6 | 0.4 | 3472 | 12.60 MiB | | -| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=1280 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | 26.15 | - | 26.12 | 26.17 | 6 | 0.1 | 3470 | 12.55 MiB | | -| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | `head_k=128 head_v=128 scale=0.0883883 M=1 chunk=64` | - | 26.14 | 25.72 | 26.58 | 20 | 1.0 | - | 6.04 MiB | 32 thread(s) | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3456 K=1152 dtype=bf16 act=none M=128` | 26.06 | - | 25.71 | 26.26 | 11 | 1.0 | 3467 | 9.57 MiB | | -| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=1280 K=5120 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | 26.06 | - | 26.05 | 26.28 | 6 | 0.4 | 3464 | 12.52 MiB | | -| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=1280 K=5120 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | 26.05 | - | 26.04 | 26.10 | 6 | 0.1 | 3461 | 12.51 MiB | | -| `sample_topp` | `avx_sample_topp` | libavx | `n_cand=1024 M=32` | - | 25.92 | 25.48 | 26.83 | 16 | 0.7 | - | 259.00 KiB | 32 thread(s) | -| `gemm_nt` | `avx_gemm_nt` | libavx | `N=96 K=5120 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 25.35 | 21.21 | 29.32 | 20 | 10.4 | - | 970.19 KiB | 32 thread(s) | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1536 dtype=bf16 act=none M=256` | 25.06 | - | 24.78 | 25.33 | 14 | 0.8 | 3482 | 5.25 MiB | | -| `gated_quant_fp8` | `avx_gated_quant_fp8` | libavx | `n=17408 group=128 dtype=bf16 act=silu M=4` | - | 25.05 | 24.47 | 33.32 | 20 | 11.4 | - | 478.12 KiB | 32 thread(s) | -| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=32` | - | 24.58 | 24.53 | 25.14 | 16 | 1.0 | - | 18.01 KiB | 32 thread(s) | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=512` | 24.49 | - | 24.37 | 24.57 | 6 | 0.4 | 3356 | 10.01 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | 24.47 | - | 24.37 | 24.80 | 6 | 0.9 | 3460 | 11.48 MiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=512` | 24.46 | - | 24.38 | 24.60 | 6 | 0.5 | 3377 | 10.01 MiB | | -| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=128` | - | 24.33 | 23.66 | 26.24 | 20 | 4.4 | - | 1.50 MiB | 32 thread(s) | -| `gdn_recurrent_update` | `gdn_recurrent_update_k128_v128_bf16_fp32state` | libr4d | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=8` | 24.27 | - | 23.10 | 24.33 | 11 | 0.3 | 3399 | 24.35 MiB | restore 58% | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | 24.24 | - | 24.21 | 24.47 | 6 | 0.5 | 3492 | 11.37 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | 24.10 | - | 24.07 | 24.19 | 6 | 0.2 | 3484 | 11.36 MiB | | -| `sample_minp` | `avx_sample_minp` | libavx | `n_cand=1024 M=32` | - | 24.09 | 22.27 | 26.18 | 20 | 6.7 | - | 259.00 KiB | 32 thread(s) | -| `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | `head_k=128 head_v=128 scale=0.0883883 M=128 chunk=64` | 23.87 | - | 23.77 | 24.03 | 6 | 0.5 | 3346 | 10.80 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | 23.65 | - | 23.64 | 23.80 | 6 | 0.3 | 3486 | 11.31 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=65 ks=0 bk=0 nt=0` | 23.63 | - | 23.49 | 23.76 | 6 | 0.6 | 3368 | 3.27 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=64` | 23.58 | - | 23.51 | 23.70 | 11 | 0.4 | 3361 | 5.45 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | 23.42 | - | 23.39 | 23.57 | 6 | 0.4 | 3484 | 11.28 MiB | | -| `silu_mul` | `avx_silu_mul` | libavx | `n=17408 dtype=bf16 M=32` | - | 23.36 | 22.87 | 32.83 | 20 | 2.7 | - | 3.19 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | 23.28 | - | 23.24 | 23.40 | 6 | 0.3 | 3458 | 11.26 MiB | | -| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=512` | 22.96 | - | 22.82 | 23.15 | 6 | 0.7 | 3315 | 17.59 MiB | restore 28% | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=17408 group=128 dtype=bf16 M=32` | - | 22.83 | 22.48 | 23.56 | 20 | 1.3 | - | 1.61 MiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=128` | - | 22.62 | 21.73 | 25.16 | 20 | 6.1 | - | 865.00 KiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=64` | - | 22.62 | 22.47 | 22.81 | 6 | 0.7 | - | 512.25 KiB | 32 thread(s) | -| `gated_quant_fp8` | `avx_gated_quant_fp8` | libavx | `n=17408 group=128 dtype=bf16 act=silu M=2` | - | 22.36 | 22.25 | 22.90 | 20 | 1.0 | - | 239.06 KiB | 32 thread(s) | -| `gated_quant_fp8` | `avx_gated_quant_fp8` | libavx | `n=17408 group=128 dtype=bf16 act=silu M=1` | - | 22.23 | 22.10 | 22.62 | 16 | 0.4 | - | 119.53 KiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | 22.12 | - | 22.09 | 22.17 | 6 | 0.2 | 3472 | 11.37 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | 22.00 | - | 21.97 | 22.23 | 6 | 0.6 | 3470 | 11.35 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | 21.69 | - | 20.97 | 22.30 | 20 | 2.6 | 3360 | 3.26 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | 21.49 | - | 21.46 | 21.77 | 6 | 0.7 | 3472 | 11.30 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | 21.25 | - | 21.23 | 21.30 | 6 | 0.2 | 3474 | 11.28 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | 21.13 | - | 21.10 | 21.37 | 6 | 0.6 | 3467 | 11.26 MiB | | -| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=8` | - | 20.99 | 20.53 | 21.36 | 16 | 0.8 | - | 291.25 KiB | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=128` | - | 20.73 | 19.45 | 27.25 | 20 | 17.3 | - | 2.51 MiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=17` | - | 20.65 | 20.50 | 21.27 | 20 | 1.2 | - | 472.01 KiB | 32 thread(s) | -| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | `head_k=128 M=32 chunk=64` | - | 20.49 | 19.42 | 21.69 | 20 | 3.5 | - | 332.01 KiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=36` | 20.46 | - | 20.34 | 20.54 | 11 | 0.5 | 3364 | 5.25 MiB | | -| `sample_minp` | `avx_sample_minp` | libavx | `n_cand=1024 M=16` | - | 20.20 | 13.39 | 21.22 | 20 | 8.0 | - | 129.50 KiB | 32 thread(s) | -| `cast` | `avx_cast` | libavx | `n=5120 from=bf16 to=bf16 M=256` | - | 20.04 | 19.94 | 20.15 | 6 | 0.5 | - | 5.00 MiB | 32 thread(s) | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3456 K=1152 dtype=bf16 act=none M=64` | 20.02 | - | 20.01 | 20.12 | 6 | 0.3 | 3537 | 8.58 MiB | | -| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=512` | - | 19.73 | 19.19 | 20.20 | 20 | 1.1 | - | 1.01 MiB | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=128` | - | 19.58 | 18.90 | 27.06 | 20 | 11.0 | - | 2.51 MiB | 32 thread(s) | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1152 dtype=bf16 act=none M=256` | 19.54 | - | 19.24 | 19.88 | 14 | 0.7 | 3512 | 4.22 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3456 K=1152 dtype=bf16 act=none M=32` | 19.28 | - | 19.23 | 19.28 | 6 | 0.1 | 3539 | 8.09 MiB | | -| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=16` | - | 18.87 | 18.30 | 19.23 | 20 | 1.4 | - | 572.50 KiB | 32 thread(s) | -| `sample_pick` | `avx_sample_pick` | libavx | `n_cand=1024 M=32` | - | 18.75 | 18.36 | 19.11 | 20 | 1.5 | - | 259.12 KiB | 32 thread(s) | -| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=128` | - | 18.70 | 18.02 | 19.53 | 20 | 1.7 | - | 832.50 KiB | 32 thread(s) | -| `sample_mask` | `avx_sample_mask` | libavx | `n_vocab=248320 M=4` | - | 18.66 | 18.55 | 18.73 | 6 | 0.5 | - | 3.91 MiB | 32 thread(s) | -| `kv_store` | `avx_kv_store` | libavx | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=128` | - | 18.64 | 15.28 | 19.19 | 20 | 7.6 | - | 832.50 KiB | 32 thread(s) | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1536 dtype=bf16 act=none M=128` | 18.55 | - | 18.46 | 18.59 | 6 | 0.3 | 3494 | 4.31 MiB | | -| `sample_argmax` | `avx_sample_argmax` | libavx | `n_vocab=248320 M=2` | - | 18.51 | 18.47 | 19.01 | 16 | 0.4 | - | 1.89 MiB | 32 thread(s) | -| `add` | `add_bf16` | libr4d | `n=5120 dtype=bf16 M=512` | 18.30 | - | 18.27 | 18.46 | 6 | 0.5 | 3326 | 15.00 MiB | | -| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=248320 M=16` | 18.27 | - | 18.15 | 18.32 | 6 | 0.5 | 3473 | 15.16 MiB | restore 53% | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=6144 group=128 dtype=bf16 M=512` | 18.06 | - | 17.96 | 18.18 | 6 | 0.6 | 3388 | 9.09 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3456 K=1152 dtype=bf16 act=none M=16` | 17.91 | - | 17.84 | 17.95 | 6 | 0.3 | 3544 | 7.85 MiB | | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=25600 group=128 dtype=bf16 M=16` | - | 17.83 | 17.26 | 30.60 | 20 | 25.4 | - | 1.18 MiB | 32 thread(s) | -| `scatter_rows` | `avx_scatter_rows` | libavx | `n=5120 dtype=bf16 M=64` | - | 17.80 | 16.69 | 18.24 | 20 | 2.4 | - | 3.13 MiB | 32 thread(s) | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3456 K=1152 dtype=bf16 act=none M=8` | 17.67 | - | 17.64 | 17.79 | 6 | 0.4 | 3536 | 7.72 MiB | | -| `rope` | `avx_rope` | libavx | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=64` | - | 17.51 | 15.58 | 19.08 | 20 | 4.6 | - | 432.50 KiB | 32 thread(s) | -| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=512` | 17.50 | - | 17.43 | 17.57 | 6 | 0.4 | 3192 | 2.37 GiB | | -| `sample_minp` | `avx_sample_minp` | libavx | `n_cand=1024 M=8` | - | 17.43 | 13.61 | 19.58 | 20 | 13.5 | - | 64.75 KiB | 32 thread(s) | -| `sample_argmax` | `avx_sample_argmax` | libavx | `n_vocab=248320 M=8` | - | 17.36 | 16.81 | 17.90 | 20 | 2.2 | - | 7.58 MiB | 32 thread(s) | -| `sample_xtc` | `avx_sample_xtc` | libavx | `n_cand=1024 M=16` | - | 17.27 | 16.74 | 17.94 | 20 | 2.4 | - | 129.50 KiB | 32 thread(s) | -| `layernorm` | `layernorm_bf16` | libr4d | `n=1152 eps=1e-06 dtype=bf16 M=512` | 17.16 | - | 17.14 | 17.17 | 6 | 0.1 | 3538 | 2.25 MiB | | -| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=4` | - | 17.14 | 16.83 | 17.89 | 16 | 1.0 | - | 150.62 KiB | 32 thread(s) | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3456 K=1152 dtype=bf16 act=none M=4` | 17.11 | - | 17.07 | 17.17 | 6 | 0.3 | 3534 | 7.66 MiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5120 group=128 dtype=bf16 M=512` | 17.02 | - | 16.97 | 17.10 | 6 | 0.4 | 3343 | 7.58 MiB | | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=6144 group=128 dtype=bf16 M=64` | - | 16.87 | 16.61 | 23.55 | 20 | 19.4 | - | 1.14 MiB | 32 thread(s) | -| `layernorm` | `avx_layernorm` | libavx | `n=1152 eps=1e-06 dtype=bf16 M=512` | - | 16.78 | 16.46 | 22.91 | 20 | 3.0 | - | 2.25 MiB | 32 thread(s) | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3456 K=1152 dtype=bf16 act=none M=2` | 16.75 | - | 16.71 | 16.82 | 6 | 0.3 | 3532 | 7.63 MiB | | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=10 splits=0` | 16.61 | - | 16.50 | 16.73 | 6 | 0.7 | 3404 | 4.23 MiB | | -| `sample_argmax` | `avx_sample_argmax` | libavx | `n_vocab=248320 M=1` | - | 16.61 | 16.53 | 16.99 | 20 | 1.3 | - | 970.10 KiB | 32 thread(s) | -| `sample_dry` | `sample_dry_f32` | libr4d | `n_vocab=248320 M=64` | 16.57 | - | 15.53 | 17.06 | 20 | 2.0 | 3471 | 60.65 MiB | restore 93%; restore-dominated (93% of the batch): an order of magnitude | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3456 K=1152 dtype=bf16 act=none M=1` | 16.52 | - | 16.49 | 16.60 | 6 | 0.3 | 3525 | 7.62 MiB | | -| `sample_argmax` | `avx_sample_argmax` | libavx | `n_vocab=248320 M=4` | - | 16.42 | 15.91 | 17.12 | 20 | 1.7 | - | 3.79 MiB | 32 thread(s) | -| `add` | `avx_add` | libavx | `n=5120 dtype=bf16 M=64` | - | 16.27 | 13.54 | 22.19 | 20 | 17.1 | - | 1.88 MiB | 32 thread(s) | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=9 splits=0` | 16.23 | - | 16.18 | 16.36 | 6 | 0.6 | 3414 | 4.21 MiB | | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=64` | - | 16.06 | 14.99 | 17.21 | 20 | 5.1 | - | 1.26 MiB | 32 thread(s) | -| `sample_topp` | `avx_sample_topp` | libavx | `n_cand=1024 M=16` | - | 16.05 | 15.47 | 16.40 | 20 | 1.7 | - | 129.50 KiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | 15.69 | - | 15.64 | 15.80 | 6 | 0.5 | 3356 | 3.06 MiB | | -| `sample_xtc` | `avx_sample_xtc` | libavx | `n_cand=1024 M=4` | - | 15.66 | 15.26 | 19.50 | 20 | 7.5 | - | 32.38 KiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=18` | 15.62 | - | 15.58 | 15.67 | 11 | 0.2 | 3364 | 5.13 MiB | | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | 15.61 | - | 15.57 | 15.64 | 6 | 0.2 | 3400 | 4.02 MiB | | -| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=256` | 15.59 | - | 15.54 | 15.62 | 6 | 0.3 | 3343 | 8.80 MiB | restore 16% | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | 15.58 | - | 15.54 | 15.62 | 6 | 0.3 | 3400 | 4.05 MiB | | -| `gdn_recurrent_update` | `gdn_recurrent_update_k128_v128_bf16_fp32state` | libr4d | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=4` | 15.55 | - | 15.07 | 15.69 | 11 | 0.7 | 3406 | 18.17 MiB | restore 61% | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1536 dtype=bf16 act=none M=64` | 15.24 | - | 15.21 | 15.28 | 6 | 0.2 | 3505 | 3.85 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1536 dtype=bf16 act=none M=32` | 15.24 | - | 15.17 | 15.28 | 6 | 0.4 | 3502 | 3.61 MiB | | -| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=512` | 15.07 | - | 14.97 | 15.13 | 6 | 0.5 | 3367 | 25.00 MiB | restore 64% | -| `sample_penalties` | `sample_penalties_f32` | libr4d | `n_vocab=248320 M=64` | 15.00 | - | 13.06 | 15.12 | 20 | 1.6 | 3457 | 60.65 MiB | restore 94%; restore-dominated (94% of the batch): an order of magnitude | -| `sample_mask` | `avx_sample_mask` | libavx | `n_vocab=248320 M=1` | - | 14.73 | 14.32 | 15.20 | 20 | 1.6 | - | 1000.41 KiB | 32 thread(s) | -| `sample_xtc` | `avx_sample_xtc` | libavx | `n_cand=1024 M=8` | - | 14.61 | 14.32 | 15.47 | 20 | 3.0 | - | 64.75 KiB | 32 thread(s) | -| `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | `head_k=128 head_v=128 scale=0.0883883 M=64 chunk=64` | 14.58 | - | 14.56 | 14.66 | 6 | 0.3 | 3347 | 8.40 MiB | | -| `sample_mask` | `sample_mask_f32` | libr4d | `n_vocab=248320 M=16` | 14.55 | - | 14.50 | 14.66 | 6 | 0.5 | 3487 | 15.63 MiB | restore 58% | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1152 dtype=bf16 act=none M=128` | 14.55 | - | 14.43 | 14.70 | 6 | 0.9 | 3556 | 3.38 MiB | | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | - | 14.40 | 14.03 | 21.25 | 20 | 23.8 | - | 416.01 KiB | 32 thread(s) | -| `rope` | `rope_bf16` | libr4d | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=256` | 14.39 | - | 14.35 | 14.59 | 6 | 0.8 | 3514 | 1.69 MiB | restore 16% | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1536 dtype=bf16 act=none M=16` | 14.32 | - | 14.28 | 14.35 | 6 | 0.3 | 3502 | 3.49 MiB | | -| `rope` | `rope_bf16` | libr4d | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=64` | 14.32 | - | 13.91 | 14.43 | 11 | 0.7 | 3537 | 432.50 KiB | restore 13% | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1536 dtype=bf16 act=none M=8` | 14.31 | - | 14.29 | 14.37 | 6 | 0.3 | 3502 | 3.44 MiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=512` | 14.30 | - | 13.81 | 14.31 | 11 | 0.2 | 3366 | 512.50 KiB | | -| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=64` | - | 14.24 | 13.83 | 14.56 | 20 | 1.3 | - | 768.75 KiB | 32 thread(s) | -| `grid_embed` | `avx_grid_embed` | libavx | `n=1152 side=48 dtype=bf16 M=1` | - | 14.10 | 13.88 | 14.44 | 19 | 0.9 | - | 5.06 MiB | 32 thread(s) | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | 14.06 | - | 13.96 | 14.12 | 6 | 0.6 | 3397 | 4.19 MiB | | -| `sample_mask` | `sample_mask_f32` | libr4d | `n_vocab=248320 M=2` | 14.06 | - | 14.00 | 14.16 | 6 | 0.6 | 3481 | 1.95 MiB | restore 17% | -| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=248320 M=2` | 13.95 | - | 13.92 | 13.98 | 6 | 0.2 | 3472 | 1.89 MiB | restore 17% | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5120 group=128 dtype=bf16 M=64` | - | 13.90 | 13.71 | 19.73 | 20 | 1.2 | - | 970.00 KiB | 32 thread(s) | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1536 dtype=bf16 act=none M=4` | 13.90 | - | 13.84 | 13.94 | 6 | 0.4 | 3500 | 3.41 MiB | | -| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=512` | - | 13.85 | 13.72 | 14.66 | 16 | 1.0 | - | 2.37 GiB | 32 thread(s) | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1536 dtype=bf16 act=none M=2` | 13.72 | - | 13.68 | 13.74 | 6 | 0.2 | 3496 | 3.39 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1536 dtype=bf16 act=none M=1` | 13.66 | - | 13.62 | 14.53 | 14 | 0.4 | 3491 | 3.38 MiB | | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | 13.64 | - | 13.57 | 13.70 | 6 | 0.4 | 3408 | 4.14 MiB | | -| `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | `head_k=128 M=512 chunk=64` | 13.57 | - | 13.54 | 13.59 | 6 | 0.2 | 3253 | 5.19 MiB | | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | 13.44 | - | 13.26 | 13.50 | 6 | 0.9 | 3425 | 1.70 MiB | | -| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=256` | 13.36 | - | 13.33 | 13.37 | 6 | 0.1 | 3281 | 2.37 GiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=9` | 13.34 | - | 13.29 | 13.39 | 11 | 0.2 | 3367 | 5.06 MiB | | -| `attn_dense` | `attn_vit_h72_bf16` | libr4d | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=512` | 13.32 | - | 13.30 | 13.39 | 11 | 0.3 | 3559 | 288.01 KiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=25600 group=128 dtype=bf16 M=128` | 13.31 | - | 13.19 | 13.38 | 6 | 0.7 | 3346 | 9.47 MiB | | -| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=96 K=5120 dtype=bf16 M=512 wv=1 sk=0 mb=0 npw=1 nt=1` | 13.31 | - | 12.97 | 13.76 | 20 | 2.0 | 3288 | 6.03 MiB | | -| `add` | `add_bf16` | libr4d | `n=5120 dtype=bf16 M=256` | 13.31 | - | 13.30 | 13.33 | 6 | 0.1 | 3296 | 7.50 MiB | | -| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=128` | 13.28 | - | 13.25 | 13.35 | 6 | 0.4 | 3412 | 256.50 KiB | restore 15% | -| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=256` | 13.26 | - | 13.23 | 13.27 | 6 | 0.1 | 3399 | 1.56 MiB | restore 15% | -| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=256` | 13.26 | - | 13.24 | 13.28 | 6 | 0.1 | 3388 | 515.00 KiB | restore 15% | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | 13.24 | - | 13.20 | 13.30 | 6 | 0.4 | 3405 | 4.12 MiB | | -| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=256` | 13.21 | - | 13.13 | 13.24 | 6 | 0.4 | 3440 | 1.56 MiB | restore 15% | -| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | 13.20 | - | 13.15 | 13.23 | 6 | 0.3 | 3363 | 32.07 MiB | | -| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=32` | 13.19 | - | 13.15 | 13.30 | 6 | 0.6 | 3447 | 256.12 KiB | restore 15% | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=8` | 13.17 | - | 13.14 | 13.22 | 11 | 0.3 | 3368 | 5.06 MiB | | -| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=248320 M=1` | 13.16 | - | 13.09 | 13.18 | 6 | 0.3 | 3478 | 970.09 KiB | restore 16% | -| `grid_embed` | `grid_embed_bf16` | libr4d | `n=1152 side=48 dtype=bf16 M=256` | 13.14 | - | 13.03 | 13.23 | 6 | 0.8 | 3468 | 5.63 MiB | restore 15% | -| `sample_mask` | `sample_mask_f32` | libr4d | `n_vocab=248320 M=1` | 13.13 | - | 13.09 | 13.20 | 6 | 0.4 | 3493 | 1000.41 KiB | restore 16% | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5120 group=128 dtype=bf16 M=256` | 13.13 | - | 13.11 | 13.16 | 6 | 0.2 | 3353 | 3.79 MiB | | -| `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | `head_k=128 head_v=128 scale=0.0883883 M=32 chunk=64` | 13.11 | - | 13.07 | 13.16 | 6 | 0.4 | 3347 | 7.20 MiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=256` | 13.10 | - | 12.77 | 13.12 | 11 | 0.2 | 3365 | 256.50 KiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=256` | 13.06 | - | 13.03 | 13.06 | 6 | 0.1 | 3362 | 5.01 MiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=6144 group=128 dtype=bf16 M=256` | 13.05 | - | 13.04 | 13.12 | 6 | 0.3 | 3411 | 4.55 MiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=256` | 13.04 | - | 13.03 | 13.08 | 6 | 0.2 | 3403 | 128.25 KiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=256` | 13.03 | - | 13.01 | 13.17 | 6 | 0.6 | 3381 | 5.01 MiB | | -| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=256` | 12.97 | - | 12.91 | 13.02 | 6 | 0.4 | 3365 | 12.50 MiB | restore 52% | -| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=1024 M=64` | 12.96 | - | 12.92 | 12.98 | 6 | 0.3 | 3585 | 262.00 KiB | restore 14% | -| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | 12.94 | - | 12.94 | 13.00 | 6 | 0.2 | 3364 | 32.04 MiB | | -| `sample_topp` | `avx_sample_topp` | libavx | `n_cand=1024 M=4` | - | 12.94 | 12.19 | 13.79 | 20 | 5.4 | - | 32.38 KiB | 32 thread(s) | -| `layernorm` | `layernorm_bf16` | libr4d | `n=1152 eps=1e-06 dtype=bf16 M=256` | 12.92 | - | 12.89 | 12.98 | 6 | 0.3 | 3541 | 1.13 MiB | | -| `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | `head_k=128 head_v=128 scale=0.0883883 M=16 chunk=64` | 12.86 | - | 12.80 | 12.93 | 6 | 0.5 | 3348 | 6.60 MiB | | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | 12.86 | - | 12.81 | 12.90 | 6 | 0.3 | 3411 | 4.09 MiB | | -| `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | `head_k=128 head_v=128 scale=0.0883883 M=8 chunk=64` | 12.86 | - | 12.81 | 12.91 | 6 | 0.4 | 3355 | 6.30 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=4` | 12.81 | - | 12.78 | 12.83 | 11 | 0.2 | 3370 | 5.03 MiB | | -| `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | `head_k=128 head_v=128 scale=0.0883883 M=4 chunk=64` | 12.80 | - | 12.73 | 12.88 | 6 | 0.6 | 3353 | 6.15 MiB | | -| `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | `head_k=128 head_v=128 scale=0.0883883 M=2 chunk=64` | 12.80 | - | 12.75 | 12.87 | 6 | 0.5 | 3350 | 6.07 MiB | | -| `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | `head_k=128 head_v=128 scale=0.0883883 M=1 chunk=64` | 12.78 | - | 12.71 | 12.85 | 6 | 0.5 | 3196 | 6.04 MiB | | -| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | 12.74 | - | 12.67 | 12.77 | 6 | 0.4 | 3352 | 32.13 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=1` | 12.72 | - | 12.63 | 14.33 | 20 | 4.1 | 2889 | 5.01 MiB | | -| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | 12.62 | - | 12.57 | 12.75 | 6 | 0.7 | 3352 | 32.10 MiB | | -| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=2` | 12.60 | - | 12.55 | 12.65 | 11 | 0.3 | 3362 | 5.01 MiB | | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=17408 group=128 dtype=bf16 M=16` | - | 12.57 | 12.34 | 17.26 | 20 | 2.5 | - | 824.50 KiB | 32 thread(s) | -| `sample_topp` | `avx_sample_topp` | libavx | `n_cand=1024 M=8` | - | 12.57 | 12.15 | 13.02 | 19 | 0.8 | - | 64.75 KiB | 32 thread(s) | -| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | 12.45 | - | 12.41 | 12.56 | 6 | 0.6 | 3352 | 32.08 MiB | | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=25600 group=128 dtype=bf16 M=8` | - | 12.45 | 12.24 | 15.41 | 20 | 6.6 | - | 606.25 KiB | 32 thread(s) | -| `gdn_conv_update` | `gdn_conv_update_w4_h128_bf16` | libr4d | `head_k=128 head_v=128 conv_width=4 q_len=16` | 12.39 | - | 12.32 | 12.43 | 6 | 0.4 | 3399 | 1.05 MiB | restore 16% | -| `silu_mul` | `avx_silu_mul` | libavx | `n=17408 dtype=bf16 M=16` | - | 12.38 | 12.22 | 16.99 | 20 | 18.7 | - | 1.59 MiB | 32 thread(s) | -| `sample_topp` | `avx_sample_topp` | libavx | `n_cand=1024 M=2` | - | 12.35 | 12.13 | 12.70 | 19 | 0.9 | - | 16.19 KiB | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=64` | - | 12.31 | 11.87 | 12.77 | 20 | 1.5 | - | 1.26 MiB | 32 thread(s) | -| `quant_act_i8` | `avx_quant_act_i8` | libavx | `n=5120 group=128 dtype=bf16 M=56` | - | 12.30 | 11.90 | 12.82 | 20 | 2.4 | - | 850.22 KiB | 32 thread(s) | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=25600 group=128 dtype=bf16 M=4` | - | 12.27 | 12.00 | 14.64 | 20 | 9.5 | - | 303.12 KiB | 32 thread(s) | -| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=512` | 12.18 | - | 12.12 | 12.26 | 6 | 0.6 | 3331 | 6.01 MiB | restore 43% | -| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | 12.09 | - | 12.06 | 12.19 | 6 | 0.5 | 3364 | 32.02 MiB | | -| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=128` | - | 12.04 | 11.70 | 12.61 | 20 | 2.6 | - | 256.50 KiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=32` | - | 12.02 | 8.93 | 12.51 | 20 | 5.9 | - | 216.25 KiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=256` | - | 11.98 | 10.96 | 12.15 | 20 | 2.0 | - | 515.00 KiB | 32 thread(s) | -| `sample_xtc` | `avx_sample_xtc` | libavx | `n_cand=1024 M=2` | - | 11.95 | 11.46 | 15.21 | 20 | 8.2 | - | 16.19 KiB | 32 thread(s) | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=17408 group=128 dtype=bf16 M=8` | - | 11.80 | 11.69 | 16.86 | 20 | 16.6 | - | 412.25 KiB | 32 thread(s) | -| `sample_minp` | `avx_sample_minp` | libavx | `n_cand=1024 M=4` | - | 11.72 | 11.53 | 11.93 | 19 | 1.0 | - | 32.38 KiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | 11.70 | - | 11.67 | 11.73 | 6 | 0.3 | 3356 | 2.94 MiB | | -| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | 11.62 | - | 11.59 | 11.66 | 6 | 0.3 | 3366 | 4.06 MiB | | -| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | 11.58 | - | 11.54 | 11.60 | 6 | 0.3 | 3356 | 4.13 MiB | | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=25600 group=128 dtype=bf16 M=2` | - | 11.55 | 11.33 | 11.78 | 20 | 1.1 | - | 151.56 KiB | 32 thread(s) | -| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | 11.48 | - | 11.43 | 11.54 | 6 | 0.5 | 3360 | 4.03 MiB | | -| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | 11.44 | - | 11.39 | 11.47 | 6 | 0.4 | 3362 | 4.02 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1152 dtype=bf16 act=none M=64` | 11.40 | - | 11.38 | 11.43 | 6 | 0.2 | 3572 | 2.96 MiB | | -| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | 11.40 | - | 11.37 | 11.42 | 6 | 0.2 | 3356 | 4.09 MiB | | -| `sample_argmax` | `sample_argmax_f32` | libr4d | `n_vocab=248320 M=8` | 11.37 | - | 11.33 | 11.46 | 6 | 0.6 | 3534 | 7.58 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1152 dtype=bf16 act=none M=32` | 11.35 | - | 11.34 | 11.38 | 6 | 0.2 | 3566 | 2.74 MiB | | -| `sample_argmax` | `sample_argmax_f32` | libr4d | `n_vocab=248320 M=4` | 11.33 | - | 11.31 | 11.39 | 6 | 0.4 | 3531 | 3.79 MiB | | -| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | 11.29 | - | 11.25 | 11.34 | 6 | 0.4 | 3358 | 4.08 MiB | | -| `sample_argmax` | `sample_argmax_f32` | libr4d | `n_vocab=248320 M=2` | 11.27 | - | 11.24 | 11.33 | 6 | 0.4 | 3534 | 1.89 MiB | | -| `sample_argmax` | `sample_argmax_f32` | libr4d | `n_vocab=248320 M=1` | 11.26 | - | 11.22 | 11.32 | 6 | 0.4 | 3525 | 970.10 KiB | | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=25600 group=128 dtype=bf16 M=1` | - | 11.21 | 11.10 | 11.43 | 16 | 0.9 | - | 75.78 KiB | 32 thread(s) | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=128` | 11.17 | - | 11.16 | 11.20 | 6 | 0.2 | 3364 | 2.51 MiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=128` | 11.13 | - | 11.10 | 11.14 | 6 | 0.2 | 3385 | 2.51 MiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=25600 group=128 dtype=bf16 M=64` | 11.05 | - | 10.98 | 11.08 | 6 | 0.5 | 3364 | 4.74 MiB | | -| `gdn_recurrent_update` | `gdn_recurrent_update_k128_v128_bf16_fp32state` | libr4d | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=2` | 10.82 | - | 10.54 | 10.96 | 14 | 0.8 | 3402 | 18.09 MiB | restore 70% | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=10 splits=0` | 10.80 | - | 10.76 | 10.84 | 6 | 0.4 | 3415 | 272.01 KiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=25600 group=128 dtype=bf16 M=32` | 10.66 | - | 10.61 | 10.71 | 6 | 0.5 | 3368 | 2.37 MiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=25600 group=128 dtype=bf16 M=16` | 10.64 | - | 10.60 | 10.66 | 6 | 0.3 | 3369 | 1.18 MiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=25600 group=128 dtype=bf16 M=8` | 10.62 | - | 10.58 | 10.65 | 6 | 0.3 | 3372 | 606.25 KiB | | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=9 splits=0` | 10.59 | - | 10.56 | 10.60 | 6 | 0.2 | 3417 | 248.01 KiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=25600 group=128 dtype=bf16 M=4` | 10.58 | - | 10.56 | 10.61 | 6 | 0.2 | 3371 | 303.12 KiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=25600 group=128 dtype=bf16 M=2` | 10.55 | - | 10.54 | 10.57 | 6 | 0.2 | 3371 | 151.56 KiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=25600 group=128 dtype=bf16 M=1` | 10.51 | - | 10.49 | 10.64 | 6 | 0.8 | 3358 | 75.78 KiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1152 dtype=bf16 act=none M=8` | 10.49 | - | 10.46 | 10.51 | 6 | 0.2 | 3564 | 2.59 MiB | | -| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=1024 M=64` | - | 10.49 | 10.04 | 11.13 | 20 | 1.8 | - | 262.00 KiB | 32 thread(s) | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1152 dtype=bf16 act=none M=16` | 10.48 | - | 10.44 | 10.52 | 6 | 0.4 | 3562 | 2.64 MiB | | -| `sample_pick` | `avx_sample_pick` | libavx | `n_cand=1024 M=16` | - | 10.44 | 10.13 | 10.75 | 20 | 1.7 | - | 129.56 KiB | 32 thread(s) | -| `sample_minp` | `avx_sample_minp` | libavx | `n_cand=1024 M=2` | - | 10.36 | 9.99 | 14.48 | 20 | 19.5 | - | 16.19 KiB | 32 thread(s) | -| `sample_pick` | `avx_sample_pick` | libavx | `n_cand=1024 M=8` | - | 10.31 | 10.25 | 10.76 | 19 | 0.8 | - | 64.78 KiB | 32 thread(s) | -| `sample_mask` | `avx_sample_mask` | libavx | `n_vocab=248320 M=2` | - | 10.26 | 9.95 | 10.58 | 20 | 2.4 | - | 1.95 MiB | 32 thread(s) | -| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | `head_k=128 M=16 chunk=64` | - | 10.25 | 10.12 | 10.46 | 20 | 1.1 | - | 166.01 KiB | 32 thread(s) | -| `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | `head_k=128 M=256 chunk=64` | 10.24 | - | 10.21 | 10.29 | 6 | 0.4 | 3364 | 2.59 MiB | | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=32` | - | 10.17 | 9.76 | 10.67 | 20 | 2.7 | - | 650.00 KiB | 32 thread(s) | -| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=64` | - | 10.15 | 9.81 | 10.68 | 20 | 2.7 | - | 448.25 KiB | 32 thread(s) | -| `gated_quant_fp8` | `gated_quant_fp8` | libr4d | `n=17408 group=128 dtype=bf16 act=silu M=64` | 10.11 | - | 10.07 | 10.13 | 6 | 0.3 | 3304 | 7.47 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1152 dtype=bf16 act=none M=4` | 10.05 | - | 10.04 | 10.11 | 6 | 0.3 | 3565 | 2.56 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1152 dtype=bf16 act=none M=2` | 9.90 | - | 9.86 | 9.92 | 6 | 0.3 | 3564 | 2.55 MiB | | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | 9.80 | - | 9.80 | 9.88 | 6 | 0.4 | 3360 | 2.88 MiB | | -| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1152 dtype=bf16 act=none M=1` | 9.79 | - | 9.76 | 9.81 | 6 | 0.2 | 3560 | 2.54 MiB | | -| `layernorm` | `avx_layernorm` | libavx | `n=1152 eps=1e-06 dtype=bf16 M=256` | - | 9.74 | 9.54 | 10.59 | 20 | 2.8 | - | 1.13 MiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | 9.64 | - | 9.62 | 9.69 | 6 | 0.3 | 3360 | 2.87 MiB | | -| `sample_xtc` | `avx_sample_xtc` | libavx | `n_cand=1024 M=1` | - | 9.61 | 9.53 | 9.79 | 14 | 0.5 | - | 8.09 KiB | 32 thread(s) | -| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=248320 M=8` | 9.58 | - | 9.56 | 9.61 | 6 | 0.3 | 3462 | 7.58 MiB | restore 53% | -| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=2` | - | 9.52 | 9.20 | 9.99 | 20 | 2.1 | - | 80.31 KiB | 32 thread(s) | -| `sample_mask` | `sample_mask_f32` | libr4d | `n_vocab=248320 M=8` | 9.42 | - | 9.38 | 9.49 | 6 | 0.6 | 3424 | 7.82 MiB | restore 54% | -| `dflash_select` | `dflash_select_bf16` | libr4d | `steps=7 top_k=16 rank=256 n_vocab=248320 anchor_stride=8 dtype=bf16 M=8` | 9.26 | - | 9.24 | 9.30 | 11 | 0.3 | 3495 | 242.53 MiB | | -| `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | `head_k=128 M=128 chunk=64` | 9.26 | - | 9.25 | 9.28 | 6 | 0.2 | 3369 | 1.30 MiB | | -| `dflash_select` | `dflash_select_bf16` | libr4d | `steps=7 top_k=16 rank=256 n_vocab=248320 anchor_stride=8 dtype=bf16 M=4` | 9.23 | - | 9.21 | 9.35 | 6 | 0.8 | 3497 | 242.52 MiB | | -| `silu_mul` | `avx_silu_mul` | libavx | `n=17408 dtype=bf16 M=2` | - | 9.17 | 8.78 | 9.44 | 20 | 2.2 | - | 204.00 KiB | 32 thread(s) | -| `dflash_select` | `dflash_select_bf16` | libr4d | `steps=7 top_k=16 rank=256 n_vocab=248320 anchor_stride=8 dtype=bf16 M=2` | 9.17 | - | 9.15 | 9.23 | 11 | 0.4 | 3489 | 242.51 MiB | | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | 9.14 | - | 9.12 | 9.15 | 6 | 0.2 | 3417 | 224.01 KiB | | -| `dflash_select` | `dflash_select_bf16` | libr4d | `steps=7 top_k=16 rank=256 n_vocab=248320 anchor_stride=8 dtype=bf16 M=1` | 9.13 | - | 9.12 | 9.18 | 6 | 0.4 | 3485 | 242.50 MiB | | -| `gdn_recurrent_update` | `gdn_recurrent_update_k128_v128_bf16_fp32state` | libr4d | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=1` | 9.11 | - | 8.94 | 9.24 | 14 | 0.8 | 3397 | 18.04 MiB | restore 73% | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=6144 group=128 dtype=bf16 M=32` | - | 9.10 | 8.94 | 10.73 | 20 | 2.8 | - | 582.00 KiB | 32 thread(s) | -| `silu_mul` | `avx_silu_mul` | libavx | `n=17408 dtype=bf16 M=8` | - | 9.09 | 8.79 | 9.98 | 20 | 3.8 | - | 816.00 KiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | 9.01 | - | 9.00 | 9.06 | 6 | 0.3 | 3360 | 2.84 MiB | | -| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=32` | - | 8.94 | 8.56 | 9.11 | 20 | 2.5 | - | 384.38 KiB | 32 thread(s) | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=4096 group=128 dtype=bf16 M=64` | - | 8.91 | 8.67 | 10.05 | 20 | 1.1 | - | 776.00 KiB | 32 thread(s) | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | 8.86 | - | 8.84 | 8.87 | 6 | 0.2 | 3415 | 176.01 KiB | | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=17408 group=128 dtype=bf16 M=4` | - | 8.86 | 8.61 | 10.24 | 20 | 8.5 | - | 206.12 KiB | 32 thread(s) | -| `add` | `avx_add` | libavx | `n=5120 dtype=bf16 M=32` | - | 8.84 | 8.61 | 10.23 | 20 | 8.2 | - | 960.00 KiB | 32 thread(s) | -| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=96 K=5120 dtype=bf16 M=260 wv=1 sk=0 mb=0 npw=1 nt=1` | 8.82 | - | 8.77 | 8.89 | 11 | 0.6 | 3336 | 3.52 MiB | | -| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=64` | - | 8.81 | 8.19 | 9.04 | 20 | 3.1 | - | 128.25 KiB | 32 thread(s) | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=17408 group=128 dtype=bf16 M=1` | - | 8.77 | 8.34 | 8.99 | 20 | 2.2 | - | 51.53 KiB | 32 thread(s) | -| `silu_mul` | `avx_silu_mul` | libavx | `n=17408 dtype=bf16 M=4` | - | 8.74 | 8.63 | 9.48 | 20 | 2.2 | - | 408.00 KiB | 32 thread(s) | -| `sample_pick` | `avx_sample_pick` | libavx | `n_cand=1024 M=4` | - | 8.74 | 8.56 | 8.94 | 20 | 1.6 | - | 32.39 KiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | 8.71 | - | 8.70 | 8.75 | 6 | 0.3 | 3356 | 2.83 MiB | | -| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=512` | 8.64 | - | 8.57 | 8.68 | 6 | 0.6 | 3387 | 1.00 MiB | restore 22% | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | 8.59 | - | 8.55 | 8.60 | 6 | 0.2 | 3396 | 56.01 KiB | | -| `gdn_gated_rmsnorm` | `avx_gdn_gated_rmsnorm` | libavx | `channels=128 eps=1e-06 act=silu M=512` | - | 8.56 | 7.54 | 10.30 | 20 | 15.3 | - | 384.50 KiB | 32 thread(s) | -| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | 8.56 | - | 8.55 | 8.57 | 6 | 0.2 | 3357 | 2.82 MiB | | -| `kv_store` | `avx_kv_store` | libavx | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=64` | - | 8.52 | 8.01 | 9.36 | 20 | 3.9 | - | 448.25 KiB | 32 thread(s) | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | 8.47 | - | 8.44 | 8.53 | 6 | 0.5 | 3438 | 888.02 KiB | | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | 8.46 | - | 8.45 | 8.49 | 6 | 0.2 | 3408 | 80.01 KiB | | -| `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | `head_k=128 M=64 chunk=64` | 8.44 | - | 8.42 | 8.46 | 6 | 0.2 | 3368 | 664.01 KiB | | -| `rope` | `rope_bf16` | libr4d | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=128` | 8.44 | - | 8.40 | 8.57 | 11 | 1.0 | 3507 | 865.00 KiB | restore 21% | -| `sample_topp` | `avx_sample_topp` | libavx | `n_cand=1024 M=1` | - | 8.41 | 8.39 | 8.47 | 11 | 0.5 | - | 8.09 KiB | 32 thread(s) | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | 8.35 | - | 8.33 | 8.40 | 6 | 0.4 | 3438 | 832.01 KiB | | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | 8.35 | - | 8.34 | 8.38 | 6 | 0.2 | 3415 | 152.01 KiB | | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=11` | - | 8.35 | 8.22 | 11.32 | 20 | 16.9 | - | 296.01 KiB | 32 thread(s) | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=17408 group=128 dtype=bf16 M=2` | - | 8.31 | 8.22 | 8.43 | 14 | 0.9 | - | 103.06 KiB | 32 thread(s) | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5120 group=128 dtype=bf16 M=32` | - | 8.20 | 7.93 | 10.62 | 20 | 7.9 | - | 485.00 KiB | 32 thread(s) | -| `quant_act_i8` | `quant_act_i8` | libr4d | `n=5120 group=128 dtype=bf16 M=56` | 8.17 | - | 8.14 | 8.19 | 6 | 0.3 | 3446 | 850.22 KiB | | -| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | 8.15 | - | 8.15 | 8.17 | 6 | 0.2 | 3414 | 128.01 KiB | | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | 8.11 | - | 8.10 | 8.19 | 6 | 0.6 | 3428 | 416.01 KiB | | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=11` | 8.09 | - | 8.05 | 8.15 | 6 | 0.6 | 3414 | 296.01 KiB | | -| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=17` | 8.08 | - | 8.06 | 8.15 | 6 | 0.5 | 3423 | 472.01 KiB | | -| `scatter_rows` | `avx_scatter_rows` | libavx | `n=5120 dtype=bf16 M=32` | - | 8.07 | 7.20 | 9.07 | 20 | 4.7 | - | 1.56 MiB | 32 thread(s) | -| `sample_pick` | `avx_sample_pick` | libavx | `n_cand=1024 M=1` | - | 8.06 | 7.82 | 8.25 | 19 | 0.7 | - | 8.10 KiB | 32 thread(s) | -| `sample_penalties` | `avx_sample_penalties` | libavx | `n_vocab=248320 M=64` | - | 8.03 | 6.82 | 9.05 | 20 | 4.5 | - | 60.65 MiB | 32 thread(s) | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=17408 group=128 dtype=bf16 M=64` | 8.02 | - | 7.97 | 8.06 | 6 | 0.5 | 3454 | 3.22 MiB | | -| `attn_dense` | `attn_vit_h72_bf16` | libr4d | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=256` | 7.96 | - | 7.94 | 7.98 | 6 | 0.2 | 3564 | 144.01 KiB | | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=32` | - | 7.87 | 7.77 | 8.32 | 20 | 1.5 | - | 650.00 KiB | 32 thread(s) | -| `sample_xtc` | `sample_xtc_f32` | libr4d | `n_cand=1024 M=64` | 7.85 | - | 7.76 | 7.91 | 11 | 0.7 | 3584 | 518.00 KiB | restore 36% | -| `quant_act_i8` | `avx_quant_act_i8` | libavx | `n=5120 group=128 dtype=bf16 M=32` | - | 7.85 | 7.64 | 8.64 | 20 | 3.8 | - | 485.12 KiB | 32 thread(s) | -| `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | `head_k=128 M=32 chunk=64` | 7.77 | - | 7.75 | 7.78 | 6 | 0.2 | 3375 | 332.01 KiB | | -| `sample_dry` | `sample_dry_f32` | libr4d | `n_vocab=248320 M=4` | 7.76 | - | 7.69 | 7.82 | 6 | 0.8 | 3388 | 3.79 MiB | restore 35% | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=17408 group=128 dtype=bf16 M=32` | 7.76 | - | 7.71 | 7.77 | 6 | 0.4 | 3459 | 1.61 MiB | | -| `sample_xtc` | `sample_xtc_f32` | libr4d | `n_cand=1024 M=4` | 7.74 | - | 7.73 | 7.76 | 6 | 0.2 | 3586 | 32.38 KiB | restore 35% | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=17408 group=128 dtype=bf16 M=16` | 7.72 | - | 7.70 | 7.76 | 6 | 0.4 | 3460 | 824.50 KiB | | -| `sample_xtc` | `sample_xtc_f32` | libr4d | `n_cand=1024 M=32` | 7.71 | - | 7.66 | 7.76 | 6 | 0.6 | 3587 | 259.00 KiB | restore 36% | -| `cast` | `cast_bf16_bf16` | libr4d | `n=5120 from=bf16 to=bf16 M=512` | 7.70 | - | 7.68 | 7.75 | 6 | 0.5 | 3342 | 10.00 MiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=17408 group=128 dtype=bf16 M=8` | 7.70 | - | 7.68 | 7.71 | 6 | 0.2 | 3464 | 412.25 KiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=17408 group=128 dtype=bf16 M=2` | 7.67 | - | 7.66 | 7.68 | 6 | 0.2 | 3456 | 103.06 KiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=17408 group=128 dtype=bf16 M=4` | 7.66 | - | 7.63 | 7.67 | 6 | 0.2 | 3463 | 206.12 KiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=17408 group=128 dtype=bf16 M=1` | 7.64 | - | 7.62 | 7.66 | 6 | 0.3 | 3451 | 51.53 KiB | | -| `sample_xtc` | `sample_xtc_f32` | libr4d | `n_cand=1024 M=2` | 7.60 | - | 7.51 | 7.64 | 6 | 0.9 | 3586 | 16.19 KiB | restore 36% | -| `sample_dry` | `sample_dry_f32` | libr4d | `n_vocab=248320 M=2` | 7.57 | - | 7.56 | 7.59 | 6 | 0.2 | 3441 | 1.90 MiB | restore 27% | -| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=32` | - | 7.56 | 7.26 | 8.47 | 20 | 3.2 | - | 256.12 KiB | 32 thread(s) | -| `sample_dry` | `sample_dry_f32` | libr4d | `n_vocab=248320 M=1` | 7.53 | - | 7.51 | 7.55 | 6 | 0.2 | 3458 | 970.41 KiB | restore 24% | -| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=256` | 7.43 | - | 7.43 | 7.45 | 6 | 0.2 | 3337 | 3.00 MiB | restore 30% | -| `sample_xtc` | `sample_xtc_f32` | libr4d | `n_cand=1024 M=16` | 7.43 | - | 7.37 | 7.49 | 6 | 0.8 | 3586 | 129.50 KiB | restore 37% | -| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=256 K=5120 dtype=bf16 M=56 wv=1 sk=0 mb=0 npw=1 nt=1` | 7.42 | - | 7.41 | 7.45 | 6 | 0.3 | 3474 | 3.07 MiB | | -| `sample_xtc` | `sample_xtc_f32` | libr4d | `n_cand=1024 M=8` | 7.41 | - | 7.39 | 7.43 | 6 | 0.3 | 3585 | 64.75 KiB | restore 37% | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=9 splits=0` | - | 7.38 | 7.31 | 7.58 | 20 | 1.1 | - | 248.01 KiB | 32 thread(s) | -| `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | `head_k=128 M=16 chunk=64` | 7.38 | - | 7.37 | 7.39 | 6 | 0.1 | 3373 | 166.01 KiB | | -| `sample_dry` | `sample_dry_f32` | libr4d | `n_vocab=248320 M=8` | 7.38 | - | 7.31 | 7.41 | 6 | 0.7 | 3444 | 7.58 MiB | restore 60% | -| `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | `head_k=128 M=8 chunk=64` | 7.33 | - | 7.31 | 7.34 | 6 | 0.2 | 3380 | 83.01 KiB | | -| `silu_mul` | `avx_silu_mul` | libavx | `n=17408 dtype=bf16 M=1` | - | 7.32 | 7.28 | 7.42 | 6 | 1.0 | - | 102.00 KiB | 32 thread(s) | -| `layernorm` | `avx_layernorm` | libavx | `n=1152 eps=1e-06 dtype=bf16 M=128` | - | 7.30 | 7.17 | 8.47 | 20 | 7.5 | - | 580.50 KiB | 32 thread(s) | -| `cast` | `avx_cast` | libavx | `n=5120 from=bf16 to=bf16 M=128` | - | 7.20 | 6.96 | 9.53 | 20 | 15.5 | - | 2.50 MiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=128` | - | 7.20 | 6.92 | 7.38 | 20 | 1.9 | - | 257.50 KiB | 32 thread(s) | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=4096 group=128 dtype=bf16 M=32` | - | 7.19 | 7.12 | 8.44 | 20 | 2.0 | - | 388.00 KiB | 32 thread(s) | -| `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | `head_k=128 M=4 chunk=64` | 7.18 | - | 7.17 | 7.19 | 6 | 0.1 | 3382 | 41.51 KiB | | -| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | 7.16 | - | 7.14 | 7.17 | 6 | 0.2 | 3368 | 128.01 KiB | | -| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=256 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | 7.14 | - | 7.13 | 7.15 | 6 | 0.1 | 3472 | 2.85 MiB | | -| `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | `head_k=128 M=1 chunk=64` | 7.14 | - | 7.11 | 7.32 | 14 | 0.1 | 3372 | 10.38 KiB | | -| `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | `head_k=128 M=2 chunk=64` | 7.14 | - | 7.13 | 7.15 | 6 | 0.1 | 3381 | 20.76 KiB | | -| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | 7.03 | - | 7.01 | 7.05 | 6 | 0.3 | 3369 | 112.01 KiB | | -| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=256` | - | 7.01 | 6.94 | 7.45 | 19 | 0.7 | - | 2.37 GiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=10 splits=0` | - | 6.98 | 6.75 | 7.80 | 20 | 5.0 | - | 272.01 KiB | 32 thread(s) | -| `sample_xtc` | `sample_xtc_f32` | libr4d | `n_cand=1024 M=1` | 6.98 | - | 6.94 | 6.99 | 6 | 0.3 | 3588 | 8.09 KiB | restore 37% | -| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=256 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | 6.93 | - | 6.92 | 6.96 | 6 | 0.3 | 3486 | 2.66 MiB | | -| `rope` | `avx_rope` | libavx | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=8` | - | 6.90 | 6.54 | 7.19 | 20 | 3.4 | - | 54.06 KiB | 32 thread(s) | -| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=256 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | 6.88 | - | 6.88 | 6.89 | 6 | 0.1 | 3470 | 2.58 MiB | | -| `rope` | `avx_rope` | libavx | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=16` | - | 6.88 | 5.52 | 7.06 | 20 | 2.6 | - | 108.12 KiB | 32 thread(s) | -| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=256 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | 6.88 | - | 6.87 | 6.92 | 6 | 0.4 | 3480 | 2.67 MiB | | -| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | 6.88 | - | 6.86 | 6.89 | 6 | 0.2 | 3368 | 96.01 KiB | | -| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=256 K=5120 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | 6.86 | - | 6.86 | 6.91 | 6 | 0.4 | 3470 | 2.52 MiB | | -| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=256 K=5120 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | 6.86 | - | 6.85 | 6.89 | 11 | 0.3 | 3469 | 2.51 MiB | | -| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | 6.86 | - | 6.83 | 7.98 | 20 | 3.9 | 3280 | 48.01 KiB | | -| `sample_pick` | `avx_sample_pick` | libavx | `n_cand=1024 M=2` | - | 6.86 | 6.77 | 6.99 | 14 | 0.8 | - | 16.20 KiB | 32 thread(s) | -| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=256 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | 6.86 | - | 6.85 | 6.90 | 6 | 0.4 | 3472 | 2.54 MiB | | -| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=16` | - | 6.80 | 6.74 | 7.03 | 20 | 1.3 | - | 9.01 KiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=16` | - | 6.80 | 6.16 | 7.15 | 20 | 5.0 | - | 128.06 KiB | 32 thread(s) | -| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | 6.79 | - | 6.78 | 6.80 | 6 | 0.1 | 3369 | 64.01 KiB | | -| `sample_pick` | `sample_pick_f32` | libr4d | `n_cand=1024 M=2` | 6.77 | - | 6.75 | 6.80 | 6 | 0.3 | 3584 | 16.20 KiB | | -| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=1024 M=32` | - | 6.72 | 6.44 | 6.91 | 20 | 2.3 | - | 131.00 KiB | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=16` | - | 6.71 | 6.55 | 7.17 | 20 | 3.1 | - | 330.00 KiB | 32 thread(s) | -| `sample_dry` | `sample_dry_f32` | libr4d | `n_vocab=248320 M=16` | 6.67 | - | 6.55 | 6.71 | 14 | 0.7 | 3448 | 15.16 MiB | restore 75% | -| `sample_minp` | `avx_sample_minp` | libavx | `n_cand=1024 M=1` | - | 6.66 | 6.57 | 7.03 | 16 | 1.0 | - | 8.09 KiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=16` | - | 6.64 | 6.19 | 7.25 | 20 | 4.5 | - | 192.19 KiB | 32 thread(s) | -| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | 6.62 | - | 6.58 | 6.66 | 6 | 0.6 | 3362 | 160.01 KiB | | -| `grid_embed` | `grid_embed_bf16` | libr4d | `n=1152 side=48 dtype=bf16 M=512` | 6.62 | - | 6.60 | 6.64 | 6 | 0.3 | 3415 | 6.20 MiB | restore 27% | -| `silu_mul` | `silu_mul_bf16` | libr4d | `n=17408 dtype=bf16 M=64` | 6.62 | - | 6.58 | 6.64 | 6 | 0.4 | 3379 | 6.38 MiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=64` | 6.60 | - | 6.58 | 6.61 | 6 | 0.2 | 3365 | 1.26 MiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=64` | 6.58 | - | 6.56 | 6.59 | 6 | 0.2 | 3385 | 1.26 MiB | | -| `layernorm` | `avx_layernorm` | libavx | `n=1152 eps=1e-06 dtype=bf16 M=64` | - | 6.49 | 6.11 | 7.06 | 20 | 3.4 | - | 292.50 KiB | 32 thread(s) | -| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=128` | 6.44 | - | 6.40 | 6.52 | 6 | 0.9 | 3365 | 4.40 MiB | restore 28% | -| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=32` | - | 6.38 | 5.79 | 6.67 | 20 | 4.0 | - | 256.12 KiB | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=8` | - | 6.27 | 5.83 | 6.82 | 20 | 4.0 | - | 170.00 KiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | - | 6.23 | 6.05 | 6.50 | 16 | 1.0 | - | 224.01 KiB | 32 thread(s) | -| `quant_act_i8` | `avx_quant_act_i8` | libavx | `n=5120 group=128 dtype=bf16 M=16` | - | 6.12 | 5.71 | 6.38 | 20 | 2.5 | - | 242.56 KiB | 32 thread(s) | -| `dflash_select` | `avx_dflash_select` | libavx | `steps=7 top_k=16 rank=256 n_vocab=248320 anchor_stride=8 dtype=bf16 M=2` | - | 6.03 | 5.41 | 6.51 | 20 | 6.9 | - | 242.51 MiB | 32 thread(s) | -| `dflash_select` | `avx_dflash_select` | libavx | `steps=7 top_k=16 rank=256 n_vocab=248320 anchor_stride=8 dtype=bf16 M=8` | - | 6.03 | 5.82 | 6.70 | 20 | 6.0 | - | 242.53 MiB | 32 thread(s) | -| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=96 K=5120 dtype=bf16 M=130 wv=1 sk=0 mb=0 npw=1 nt=1` | 6.00 | - | 5.97 | 6.02 | 11 | 0.3 | 3339 | 2.23 MiB | | -| `quant_act_i8` | `quant_act_i8` | libr4d | `n=5120 group=128 dtype=bf16 M=32` | 5.98 | - | 5.95 | 5.99 | 6 | 0.3 | 3453 | 485.12 KiB | | -| `quant_act_i8` | `quant_act_i8` | libr4d | `n=5120 group=128 dtype=bf16 M=16` | 5.96 | - | 5.94 | 6.00 | 6 | 0.6 | 3441 | 242.56 KiB | | -| `sample_penalties` | `sample_penalties_f32` | libr4d | `n_vocab=248320 M=4` | 5.96 | - | 5.93 | 6.01 | 6 | 0.6 | 3327 | 3.79 MiB | restore 42% | -| `quant_act_i8` | `quant_act_i8` | libr4d | `n=5120 group=128 dtype=bf16 M=8` | 5.95 | - | 5.93 | 5.97 | 6 | 0.3 | 3441 | 122.53 KiB | | -| `quant_act_i8` | `quant_act_i8` | libr4d | `n=5120 group=128 dtype=bf16 M=4` | 5.93 | - | 5.92 | 5.94 | 6 | 0.1 | 3443 | 62.52 KiB | | -| `quant_act_i8` | `quant_act_i8` | libr4d | `n=5120 group=128 dtype=bf16 M=2` | 5.88 | - | 5.87 | 5.88 | 6 | 0.1 | 3443 | 32.51 KiB | | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | - | 5.85 | 5.70 | 6.00 | 20 | 1.4 | - | 160.01 KiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=32` | - | 5.84 | 5.51 | 6.01 | 20 | 2.4 | - | 64.12 KiB | 32 thread(s) | -| `sample_dry` | `sample_dry_f32` | libr4d | `n_vocab=248320 M=32` | 5.81 | - | 5.35 | 5.89 | 20 | 1.0 | 3448 | 30.33 MiB | restore 87%; restore-dominated (87% of the batch): an order of magnitude | -| `quant_act_i8` | `quant_act_i8` | libr4d | `n=5120 group=128 dtype=bf16 M=1` | 5.80 | - | 5.79 | 5.87 | 6 | 0.6 | 3438 | 17.50 KiB | | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=4` | - | 5.75 | 5.20 | 6.40 | 20 | 7.0 | - | 90.00 KiB | 32 thread(s) | -| `gated_quant_fp8` | `gated_quant_fp8` | libr4d | `n=17408 group=128 dtype=bf16 act=silu M=32` | 5.74 | - | 5.73 | 5.76 | 6 | 0.3 | 3340 | 3.74 MiB | | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=16` | - | 5.69 | 5.52 | 7.08 | 20 | 11.5 | - | 330.00 KiB | 32 thread(s) | -| `layernorm` | `layernorm_bf16` | libr4d | `n=1152 eps=1e-06 dtype=bf16 M=128` | 5.69 | - | 5.68 | 5.72 | 6 | 0.3 | 3548 | 580.50 KiB | | -| `layernorm` | `layernorm_bf16` | libr4d | `n=1152 eps=1e-06 dtype=bf16 M=1` | 5.68 | - | 5.67 | 5.72 | 6 | 0.4 | 3468 | 9.00 KiB | | -| `layernorm` | `layernorm_bf16` | libr4d | `n=1152 eps=1e-06 dtype=bf16 M=2` | 5.66 | - | 5.65 | 5.70 | 6 | 0.4 | 3542 | 13.50 KiB | | -| `layernorm` | `layernorm_bf16` | libr4d | `n=1152 eps=1e-06 dtype=bf16 M=64` | 5.65 | - | 5.64 | 5.67 | 6 | 0.2 | 3550 | 292.50 KiB | | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=6144 group=128 dtype=bf16 M=16` | - | 5.65 | 5.57 | 7.03 | 20 | 2.6 | - | 291.00 KiB | 32 thread(s) | -| `sample_penalties` | `sample_penalties_f32` | libr4d | `n_vocab=248320 M=2` | 5.64 | - | 5.58 | 5.68 | 11 | 0.7 | 3452 | 1.90 MiB | restore 33% | -| `layernorm` | `layernorm_bf16` | libr4d | `n=1152 eps=1e-06 dtype=bf16 M=4` | 5.64 | - | 5.63 | 5.66 | 6 | 0.3 | 3543 | 22.50 KiB | | -| `layernorm` | `layernorm_bf16` | libr4d | `n=1152 eps=1e-06 dtype=bf16 M=32` | 5.63 | - | 5.61 | 5.66 | 6 | 0.4 | 3540 | 148.50 KiB | | -| `sample_penalties` | `sample_penalties_f32` | libr4d | `n_vocab=248320 M=1` | 5.63 | - | 5.61 | 5.88 | 16 | 0.1 | 3478 | 970.34 KiB | restore 30% | -| `layernorm` | `layernorm_bf16` | libr4d | `n=1152 eps=1e-06 dtype=bf16 M=8` | 5.62 | - | 5.62 | 5.64 | 6 | 0.2 | 3541 | 40.50 KiB | | -| `layernorm` | `layernorm_bf16` | libr4d | `n=1152 eps=1e-06 dtype=bf16 M=16` | 5.62 | - | 5.61 | 5.65 | 6 | 0.3 | 3541 | 76.50 KiB | | -| `dflash_select` | `avx_dflash_select` | libavx | `steps=7 top_k=16 rank=256 n_vocab=248320 anchor_stride=8 dtype=bf16 M=4` | - | 5.60 | 5.53 | 5.90 | 20 | 2.4 | - | 242.52 MiB | 32 thread(s) | -| `gated_quant_fp8` | `gated_quant_fp8` | libr4d | `n=17408 group=128 dtype=bf16 act=silu M=1` | 5.60 | - | 5.46 | 7.20 | 20 | 11.4 | 2815 | 119.53 KiB | | -| `gated_quant_fp8` | `gated_quant_fp8` | libr4d | `n=17408 group=128 dtype=bf16 act=silu M=16` | 5.58 | - | 5.54 | 5.60 | 6 | 0.5 | 3376 | 1.87 MiB | | -| `sample_penalties` | `sample_penalties_f32` | libr4d | `n_vocab=248320 M=8` | 5.55 | - | 5.49 | 5.57 | 6 | 0.7 | 3446 | 7.58 MiB | restore 66% | -| `dflash_select` | `avx_dflash_select` | libavx | `steps=7 top_k=16 rank=256 n_vocab=248320 anchor_stride=8 dtype=bf16 M=1` | - | 5.54 | 5.39 | 6.33 | 20 | 5.4 | - | 242.50 MiB | 32 thread(s) | -| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=256` | 5.54 | - | 5.53 | 5.56 | 6 | 0.3 | 3402 | 513.00 KiB | restore 29% | -| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=64` | 5.52 | - | 5.47 | 5.54 | 6 | 0.6 | 3429 | 512.25 KiB | restore 29% | -| `gated_quant_fp8` | `gated_quant_fp8` | libr4d | `n=17408 group=128 dtype=bf16 act=silu M=8` | 5.51 | - | 5.50 | 5.54 | 6 | 0.4 | 3372 | 956.25 KiB | | -| `gated_quant_fp8` | `gated_quant_fp8` | libr4d | `n=17408 group=128 dtype=bf16 act=silu M=4` | 5.50 | - | 5.48 | 5.52 | 6 | 0.3 | 3383 | 478.12 KiB | | -| `gated_quant_fp8` | `gated_quant_fp8` | libr4d | `n=17408 group=128 dtype=bf16 act=silu M=2` | 5.48 | - | 5.47 | 5.49 | 6 | 0.2 | 3380 | 239.06 KiB | | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=512` | - | 5.47 | 5.37 | 6.06 | 20 | 5.6 | - | 512.50 KiB | 32 thread(s) | -| `attn_dense` | `attn_vit_h72_bf16` | libr4d | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=32` | 5.45 | - | 5.42 | 5.47 | 6 | 0.4 | 3560 | 18.01 KiB | | -| `attn_dense` | `attn_vit_h72_bf16` | libr4d | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=16` | 5.44 | - | 5.43 | 5.46 | 6 | 0.3 | 3559 | 9.01 KiB | | -| `attn_dense` | `attn_vit_h72_bf16` | libr4d | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=64` | 5.44 | - | 5.43 | 5.45 | 6 | 0.2 | 3562 | 36.01 KiB | | -| `gdn_conv_update` | `gdn_conv_update_w4_h128_bf16` | libr4d | `head_k=128 head_v=128 conv_width=4 q_len=8` | 5.44 | - | 5.36 | 5.45 | 6 | 0.8 | 3400 | 600.04 KiB | restore 30% | -| `attn_dense` | `attn_vit_h72_bf16` | libr4d | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=4` | 5.42 | - | 5.40 | 5.43 | 6 | 0.2 | 3551 | 2.26 KiB | | -| `scatter_rows` | `avx_scatter_rows` | libavx | `n=5120 dtype=bf16 M=16` | - | 5.42 | 4.69 | 7.25 | 20 | 17.5 | - | 800.06 KiB | 32 thread(s) | -| `attn_dense` | `attn_vit_h72_bf16` | libr4d | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=8` | 5.39 | - | 5.38 | 5.40 | 6 | 0.1 | 3551 | 4.51 KiB | | -| `attn_dense` | `attn_vit_h72_bf16` | libr4d | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=1` | 5.39 | - | 5.38 | 5.41 | 6 | 0.3 | 3500 | 584 B | | -| `attn_dense` | `attn_vit_h72_bf16` | libr4d | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=2` | 5.39 | - | 5.38 | 5.40 | 6 | 0.2 | 3551 | 1.13 KiB | | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=8` | - | 5.38 | 5.28 | 6.63 | 20 | 2.5 | - | 170.00 KiB | 32 thread(s) | -| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=1` | - | 5.37 | 5.20 | 5.73 | 20 | 2.6 | - | 45.16 KiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=8` | - | 5.36 | 4.66 | 6.40 | 20 | 10.8 | - | 64.03 KiB | 32 thread(s) | -| `add` | `avx_add` | libavx | `n=5120 dtype=bf16 M=2` | - | 5.35 | 5.29 | 5.45 | 16 | 1.0 | - | 60.00 KiB | 32 thread(s) | -| `sample_penalties` | `avx_sample_penalties` | libavx | `n_vocab=248320 M=32` | - | 5.32 | 4.96 | 6.62 | 20 | 5.2 | - | 30.32 MiB | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=4` | - | 5.30 | 5.18 | 5.77 | 20 | 2.8 | - | 90.00 KiB | 32 thread(s) | -| `kv_store` | `avx_kv_store` | libavx | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=32` | - | 5.29 | 4.96 | 6.21 | 20 | 4.8 | - | 256.12 KiB | 32 thread(s) | -| `add` | `avx_add` | libavx | `n=5120 dtype=bf16 M=16` | - | 5.26 | 5.14 | 6.52 | 20 | 12.5 | - | 480.00 KiB | 32 thread(s) | -| `attn_dense` | `attn_vit_h72_bf16` | libr4d | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=128` | 5.20 | - | 5.19 | 5.22 | 6 | 0.3 | 3559 | 72.01 KiB | | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | - | 5.10 | 5.06 | 5.17 | 11 | 0.8 | - | 128.01 KiB | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=512` | - | 5.08 | 4.86 | 5.21 | 20 | 2.8 | - | 256.25 KiB | 32 thread(s) | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=6144 group=128 dtype=bf16 M=2` | - | 5.06 | 4.99 | 5.35 | 20 | 3.1 | - | 36.38 KiB | 32 thread(s) | -| `add` | `avx_add` | libavx | `n=5120 dtype=bf16 M=8` | - | 5.05 | 4.80 | 5.21 | 20 | 2.3 | - | 240.00 KiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=4` | - | 5.04 | 4.95 | 5.06 | 11 | 0.8 | - | 27.03 KiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=64` | - | 5.02 | 4.63 | 5.34 | 20 | 4.0 | - | 128.75 KiB | 32 thread(s) | -| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=128` | 5.02 | - | 4.98 | 5.03 | 6 | 0.4 | 3349 | 1.50 MiB | restore 34% | -| `sample_penalties` | `sample_penalties_f32` | libr4d | `n_vocab=248320 M=16` | 5.01 | - | 4.89 | 5.06 | 11 | 0.7 | 3458 | 15.16 MiB | restore 80%; restore-dominated (80% of the batch): an order of magnitude | -| `cast` | `avx_cast` | libavx | `n=5120 from=bf16 to=bf16 M=64` | - | 5.01 | 4.90 | 6.29 | 20 | 4.6 | - | 1.25 MiB | 32 thread(s) | -| `sample_dry` | `avx_sample_dry` | libavx | `n_vocab=248320 M=64` | - | 5.00 | 4.00 | 5.72 | 20 | 10.9 | - | 60.65 MiB | 32 thread(s) | -| `rope_table` | `avx_rope_table` | libavx | `rot=64 theta=1e+07 scale=1 dtype=f32 M=64` | - | 4.93 | 4.92 | 5.12 | 16 | 0.4 | - | 16.25 KiB | 32 thread(s) | -| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=96 K=5120 dtype=bf16 M=65 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.91 | - | 4.89 | 4.93 | 11 | 0.3 | 3375 | 1.58 MiB | | -| `gdn_gated_rmsnorm` | `avx_gdn_gated_rmsnorm` | libavx | `channels=128 eps=1e-06 act=silu M=64` | - | 4.81 | 4.78 | 4.91 | 20 | 1.0 | - | 48.50 KiB | 32 thread(s) | -| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=1024 M=16` | - | 4.80 | 4.63 | 5.15 | 20 | 2.6 | - | 65.50 KiB | 32 thread(s) | -| `gdn_gated_rmsnorm` | `avx_gdn_gated_rmsnorm` | libavx | `channels=128 eps=1e-06 act=silu M=256` | - | 4.80 | 4.68 | 5.84 | 20 | 3.1 | - | 192.50 KiB | 32 thread(s) | -| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=96 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.78 | - | 4.75 | 4.80 | 11 | 0.3 | 3383 | 1.28 MiB | | -| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=96 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.76 | - | 4.73 | 4.77 | 11 | 0.3 | 3399 | 1.11 MiB | | -| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=96 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.74 | - | 4.73 | 4.76 | 11 | 0.3 | 3400 | 1.10 MiB | | -| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=96 K=5120 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.72 | - | 4.71 | 4.74 | 11 | 0.3 | 3376 | 1.57 MiB | | -| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=32` | - | 4.68 | 4.62 | 4.83 | 20 | 1.6 | - | 64.38 KiB | 32 thread(s) | -| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=8` | - | 4.67 | 4.62 | 4.73 | 14 | 1.0 | - | 128.03 KiB | 32 thread(s) | -| `layernorm` | `avx_layernorm` | libavx | `n=1152 eps=1e-06 dtype=bf16 M=32` | - | 4.66 | 4.47 | 4.93 | 20 | 2.1 | - | 148.50 KiB | 32 thread(s) | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=1` | 4.66 | - | 4.64 | 5.10 | 20 | 1.9 | 3334 | 30.00 KiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=32` | 4.65 | - | 4.65 | 4.66 | 6 | 0.1 | 3368 | 650.00 KiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=1` | 4.65 | - | 4.63 | 4.65 | 6 | 0.2 | 3363 | 30.00 KiB | | -| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=96 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.64 | - | 4.61 | 4.66 | 11 | 0.3 | 3402 | 1.02 MiB | | -| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | `head_k=128 M=8 chunk=64` | - | 4.64 | 4.31 | 4.79 | 20 | 4.0 | - | 83.01 KiB | 32 thread(s) | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=32` | 4.64 | - | 4.63 | 4.67 | 6 | 0.4 | 3389 | 650.00 KiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=2` | 4.63 | - | 4.63 | 4.65 | 6 | 0.3 | 3372 | 50.00 KiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=16` | 4.63 | - | 4.62 | 4.65 | 6 | 0.3 | 3371 | 330.00 KiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=4` | 4.63 | - | 4.62 | 4.65 | 6 | 0.3 | 3369 | 90.00 KiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=8` | 4.62 | - | 4.62 | 4.64 | 6 | 0.2 | 3372 | 170.00 KiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=2` | 4.62 | - | 4.62 | 4.65 | 6 | 0.3 | 3378 | 50.00 KiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=8` | 4.62 | - | 4.61 | 4.65 | 6 | 0.5 | 3382 | 170.00 KiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=4` | 4.62 | - | 4.61 | 4.63 | 6 | 0.2 | 3384 | 90.00 KiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=16` | 4.60 | - | 4.59 | 4.61 | 6 | 0.2 | 3390 | 330.00 KiB | | -| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=64` | 4.59 | - | 4.57 | 4.61 | 6 | 0.5 | 3385 | 2.21 MiB | restore 34% | -| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=96 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.55 | - | 4.53 | 4.56 | 11 | 0.3 | 3399 | 1000.75 KiB | | -| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=96 K=5120 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.53 | - | 4.49 | 5.19 | 20 | 3.6 | 3052 | 970.19 KiB | | -| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=96 K=5120 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.52 | - | 4.50 | 4.54 | 11 | 0.4 | 3402 | 980.38 KiB | | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=4096 group=128 dtype=bf16 M=16` | - | 4.50 | 4.09 | 4.62 | 20 | 2.1 | - | 194.00 KiB | 32 thread(s) | -| `quant_act_i8` | `avx_quant_act_i8` | libavx | `n=5120 group=128 dtype=bf16 M=8` | - | 4.49 | 4.24 | 4.85 | 20 | 3.2 | - | 122.53 KiB | 32 thread(s) | -| `kv_store` | `avx_kv_store` | libavx | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=8` | - | 4.49 | 4.42 | 4.80 | 16 | 0.8 | - | 128.03 KiB | 32 thread(s) | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5120 group=128 dtype=bf16 M=16` | - | 4.48 | 4.41 | 5.78 | 20 | 3.3 | - | 242.50 KiB | 32 thread(s) | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=6144 group=128 dtype=bf16 M=128` | 4.47 | - | 4.45 | 4.47 | 6 | 0.2 | 3420 | 2.27 MiB | | -| `sample_penalties` | `avx_sample_penalties` | libavx | `n_vocab=248320 M=8` | - | 4.46 | 4.23 | 5.10 | 20 | 4.5 | - | 7.58 MiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=16` | - | 4.42 | 4.18 | 4.67 | 20 | 2.7 | - | 32.06 KiB | 32 thread(s) | -| `gdn_conv_update` | `gdn_conv_update_w4_h128_bf16` | libr4d | `head_k=128 head_v=128 conv_width=4 q_len=4` | 4.42 | - | 4.41 | 4.43 | 6 | 0.2 | 3392 | 360.03 KiB | restore 34% | -| `add` | `avx_add` | libavx | `n=5120 dtype=bf16 M=4` | - | 4.40 | 4.25 | 4.55 | 20 | 1.3 | - | 120.00 KiB | 32 thread(s) | -| `layernorm` | `avx_layernorm` | libavx | `n=1152 eps=1e-06 dtype=bf16 M=16` | - | 4.40 | 4.21 | 4.73 | 20 | 2.7 | - | 76.50 KiB | 32 thread(s) | -| `silu_mul` | `silu_mul_bf16` | libr4d | `n=17408 dtype=bf16 M=32` | 4.40 | - | 4.38 | 4.41 | 6 | 0.3 | 3414 | 3.19 MiB | | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=6144 group=128 dtype=bf16 M=4` | - | 4.29 | 4.17 | 4.39 | 20 | 1.1 | - | 72.75 KiB | 32 thread(s) | -| `cast` | `avx_cast` | libavx | `n=5120 from=bf16 to=bf16 M=32` | - | 4.25 | 4.17 | 5.63 | 20 | 10.3 | - | 640.00 KiB | 32 thread(s) | -| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=128` | - | 4.25 | 4.18 | 4.89 | 20 | 2.1 | - | 2.37 GiB | 32 thread(s) | -| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=512` | 4.22 | - | 4.21 | 4.23 | 6 | 0.2 | 3388 | 1.01 MiB | restore 36% | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=6144 group=128 dtype=bf16 M=64` | 4.22 | - | 4.21 | 4.22 | 6 | 0.2 | 3436 | 1.14 MiB | | -| `quant_act_i8` | `avx_quant_act_i8` | libavx | `n=5120 group=128 dtype=bf16 M=4` | - | 4.17 | 3.98 | 4.38 | 20 | 2.8 | - | 62.52 KiB | 32 thread(s) | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5120 group=128 dtype=bf16 M=128` | 4.15 | - | 4.14 | 4.16 | 6 | 0.2 | 3357 | 1.89 MiB | | -| `sample_mask` | `sample_mask_f32` | libr4d | `n_vocab=248320 M=4` | 4.13 | - | 4.12 | 4.15 | 6 | 0.4 | 3274 | 3.91 MiB | restore 52% | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=6144 group=128 dtype=bf16 M=8` | - | 4.11 | 4.03 | 4.21 | 20 | 1.1 | - | 145.50 KiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=8` | - | 4.11 | 4.08 | 4.22 | 19 | 0.9 | - | 16.03 KiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=4` | - | 4.11 | 3.94 | 4.70 | 20 | 4.4 | - | 32.02 KiB | 32 thread(s) | -| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=16` | - | 4.09 | 3.70 | 4.64 | 20 | 5.5 | - | 160.06 KiB | 32 thread(s) | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=6144 group=128 dtype=bf16 M=32` | 4.09 | - | 4.08 | 4.11 | 6 | 0.4 | 3431 | 582.00 KiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=6144 group=128 dtype=bf16 M=16` | 4.09 | - | 4.08 | 4.09 | 6 | 0.1 | 3432 | 291.00 KiB | | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | - | 4.09 | 3.90 | 4.25 | 20 | 1.7 | - | 176.01 KiB | 32 thread(s) | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=6144 group=128 dtype=bf16 M=8` | 4.08 | - | 4.07 | 4.09 | 6 | 0.3 | 3434 | 145.50 KiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=6144 group=128 dtype=bf16 M=4` | 4.07 | - | 4.06 | 4.08 | 6 | 0.3 | 3432 | 72.75 KiB | | -| `sample_penalties` | `avx_sample_penalties` | libavx | `n_vocab=248320 M=16` | - | 4.06 | 3.69 | 4.35 | 20 | 3.8 | - | 15.16 MiB | 32 thread(s) | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=6144 group=128 dtype=bf16 M=1` | 4.06 | - | 4.05 | 4.08 | 6 | 0.4 | 3430 | 18.19 KiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=6144 group=128 dtype=bf16 M=2` | 4.06 | - | 4.06 | 4.09 | 6 | 0.4 | 3432 | 36.38 KiB | | -| `sample_penalties` | `sample_penalties_f32` | libr4d | `n_vocab=248320 M=32` | 3.99 | - | 3.59 | 4.05 | 16 | 1.0 | 3448 | 30.32 MiB | restore 91%; restore-dominated (91% of the batch): an order of magnitude | -| `add` | `add_bf16` | libr4d | `n=5120 dtype=bf16 M=128` | 3.98 | - | 3.98 | 4.00 | 6 | 0.3 | 3372 | 3.75 MiB | | -| `rope` | `rope_bf16` | libr4d | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=32` | 3.97 | - | 3.96 | 3.99 | 6 | 0.4 | 3549 | 216.25 KiB | restore 36% | -| `sample_minp` | `sample_minp_f32` | libr4d | `n_cand=1024 M=64` | 3.97 | - | 3.94 | 3.98 | 6 | 0.6 | 3581 | 518.00 KiB | restore 52% | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5120 group=128 dtype=bf16 M=8` | - | 3.94 | 3.88 | 4.03 | 16 | 1.0 | - | 121.25 KiB | 32 thread(s) | -| `gdn_conv_update` | `gdn_conv_update_w4_h128_bf16` | libr4d | `head_k=128 head_v=128 conv_width=4 q_len=2` | 3.94 | - | 3.92 | 4.00 | 6 | 1.0 | 3390 | 240.02 KiB | restore 36% | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5120 group=128 dtype=bf16 M=64` | 3.92 | - | 3.91 | 3.93 | 6 | 0.2 | 3365 | 970.00 KiB | | -| `sample_minp` | `sample_minp_f32` | libr4d | `n_cand=1024 M=16` | 3.91 | - | 3.90 | 3.92 | 6 | 0.3 | 3576 | 129.50 KiB | restore 52% | -| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=8` | - | 3.91 | 3.87 | 3.93 | 11 | 0.6 | - | 96.09 KiB | 32 thread(s) | -| `sample_minp` | `sample_minp_f32` | libr4d | `n_cand=1024 M=32` | 3.91 | - | 3.87 | 3.91 | 6 | 0.5 | 3582 | 259.00 KiB | restore 52% | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5120 group=128 dtype=bf16 M=4` | - | 3.89 | 3.88 | 4.44 | 20 | 2.1 | - | 60.62 KiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 3.89 | 3.89 | 4.04 | 14 | 1.0 | - | 112.01 KiB | 32 thread(s) | -| `sample_minp` | `sample_minp_f32` | libr4d | `n_cand=1024 M=8` | 3.89 | - | 3.87 | 3.90 | 6 | 0.4 | 3574 | 64.75 KiB | restore 52% | -| `sample_minp` | `sample_minp_f32` | libr4d | `n_cand=1024 M=2` | 3.87 | - | 3.86 | 3.87 | 6 | 0.2 | 3572 | 16.19 KiB | restore 52% | -| `sample_minp` | `sample_minp_f32` | libr4d | `n_cand=1024 M=4` | 3.87 | - | 3.85 | 3.88 | 6 | 0.4 | 3572 | 32.38 KiB | restore 52% | -| `sample_minp` | `sample_minp_f32` | libr4d | `n_cand=1024 M=1` | 3.84 | - | 3.83 | 3.85 | 6 | 0.2 | 3572 | 8.09 KiB | restore 52% | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 3.81 | 3.68 | 3.89 | 20 | 1.8 | - | 96.01 KiB | 32 thread(s) | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5120 group=128 dtype=bf16 M=32` | 3.81 | - | 3.81 | 3.83 | 6 | 0.2 | 3370 | 485.00 KiB | | -| `sample_dry` | `avx_sample_dry` | libavx | `n_vocab=248320 M=32` | - | 3.80 | 3.41 | 4.34 | 20 | 8.9 | - | 30.33 MiB | 32 thread(s) | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5120 group=128 dtype=bf16 M=16` | 3.80 | - | 3.80 | 3.81 | 6 | 0.2 | 3371 | 242.50 KiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5120 group=128 dtype=bf16 M=8` | 3.80 | - | 3.79 | 3.80 | 6 | 0.1 | 3371 | 121.25 KiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5120 group=128 dtype=bf16 M=2` | 3.79 | - | 3.77 | 3.79 | 6 | 0.3 | 3370 | 30.31 KiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5120 group=128 dtype=bf16 M=4` | 3.78 | - | 3.77 | 3.80 | 6 | 0.4 | 3373 | 60.62 KiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5120 group=128 dtype=bf16 M=1` | 3.78 | - | 3.77 | 3.82 | 6 | 0.7 | 3371 | 15.16 KiB | | -| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=64` | 3.77 | - | 3.76 | 3.79 | 6 | 0.4 | 3361 | 768.75 KiB | restore 39% | -| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=32` | 3.77 | - | 3.73 | 3.78 | 6 | 0.6 | 3394 | 1.11 MiB | restore 37% | -| `sample_dry` | `avx_sample_dry` | libavx | `n_vocab=248320 M=2` | - | 3.76 | 2.81 | 4.18 | 20 | 14.2 | - | 1.90 MiB | 32 thread(s) | -| `gdn_gated_rmsnorm` | `avx_gdn_gated_rmsnorm` | libavx | `channels=128 eps=1e-06 act=silu M=128` | - | 3.73 | 3.58 | 4.14 | 20 | 5.8 | - | 96.50 KiB | 32 thread(s) | -| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=16` | 3.73 | - | 3.72 | 3.75 | 6 | 0.4 | 3401 | 572.50 KiB | restore 37% | -| `gdn_conv_update` | `gdn_conv_update_w4_h128_bf16` | libr4d | `head_k=128 head_v=128 conv_width=4 q_len=1` | 3.71 | - | 3.68 | 3.72 | 6 | 0.5 | 3391 | 180.02 KiB | restore 38% | -| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=8` | 3.71 | - | 3.69 | 3.71 | 6 | 0.4 | 3402 | 291.25 KiB | restore 37% | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 3.71 | 3.58 | 3.83 | 20 | 1.9 | - | 128.01 KiB | 32 thread(s) | -| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=2` | 3.71 | - | 3.68 | 3.72 | 6 | 0.5 | 3393 | 80.31 KiB | restore 38% | -| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=4` | 3.70 | - | 3.68 | 3.71 | 6 | 0.4 | 3401 | 150.62 KiB | restore 38% | -| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=1` | 3.70 | - | 3.68 | 3.71 | 6 | 0.4 | 3392 | 45.16 KiB | restore 38% | -| `sample_penalties` | `avx_sample_penalties` | libavx | `n_vocab=248320 M=2` | - | 3.69 | 3.39 | 4.03 | 20 | 5.2 | - | 1.90 MiB | 32 thread(s) | -| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=512` | 3.63 | - | 3.63 | 3.65 | 6 | 0.3 | 3384 | 3.06 MiB | restore 40% | -| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=512` | 3.61 | - | 3.59 | 3.62 | 6 | 0.5 | 3419 | 3.06 MiB | restore 40% | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5120 group=128 dtype=bf16 M=2` | - | 3.60 | 3.59 | 3.70 | 16 | 0.2 | - | 30.31 KiB | 32 thread(s) | -| `add` | `add_bf16` | libr4d | `n=5120 dtype=bf16 M=64` | 3.60 | - | 3.59 | 3.60 | 6 | 0.1 | 3384 | 1.88 MiB | | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=4096 group=128 dtype=bf16 M=2` | - | 3.51 | 3.37 | 3.63 | 20 | 2.5 | - | 24.25 KiB | 32 thread(s) | -| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=248320 M=4` | 3.49 | - | 3.41 | 3.55 | 19 | 1.0 | 3346 | 3.79 MiB | restore 55% | -| `add` | `add_bf16` | libr4d | `n=5120 dtype=bf16 M=32` | 3.49 | - | 3.49 | 3.51 | 6 | 0.3 | 3388 | 960.00 KiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=4096 group=128 dtype=bf16 M=64` | 3.49 | - | 3.49 | 3.49 | 6 | 0.1 | 3452 | 776.00 KiB | | -| `grid_embed` | `grid_embed_bf16` | libr4d | `n=1152 side=48 dtype=bf16 M=128` | 3.47 | - | 3.43 | 3.66 | 16 | 0.8 | 3499 | 5.35 MiB | restore 38% | -| `add` | `add_bf16` | libr4d | `n=5120 dtype=bf16 M=16` | 3.47 | - | 3.47 | 3.48 | 6 | 0.2 | 3390 | 480.00 KiB | | -| `add` | `add_bf16` | libr4d | `n=5120 dtype=bf16 M=8` | 3.46 | - | 3.45 | 3.46 | 6 | 0.2 | 3390 | 240.00 KiB | | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=256` | - | 3.45 | 3.38 | 4.21 | 20 | 6.5 | - | 256.50 KiB | 32 thread(s) | -| `add` | `add_bf16` | libr4d | `n=5120 dtype=bf16 M=4` | 3.45 | - | 3.44 | 3.45 | 6 | 0.1 | 3392 | 120.00 KiB | | -| `add` | `add_bf16` | libr4d | `n=5120 dtype=bf16 M=2` | 3.44 | - | 3.43 | 3.45 | 6 | 0.2 | 3392 | 60.00 KiB | | -| `add` | `add_bf16` | libr4d | `n=5120 dtype=bf16 M=1` | 3.43 | - | 3.42 | 3.44 | 6 | 0.2 | 3384 | 30.00 KiB | | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=4096 group=128 dtype=bf16 M=8` | - | 3.42 | 3.35 | 3.44 | 11 | 0.8 | - | 97.00 KiB | 32 thread(s) | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=4096 group=128 dtype=bf16 M=32` | 3.41 | - | 3.39 | 3.41 | 6 | 0.2 | 3456 | 388.00 KiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=4096 group=128 dtype=bf16 M=16` | 3.40 | - | 3.39 | 3.41 | 6 | 0.2 | 3456 | 194.00 KiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=4096 group=128 dtype=bf16 M=8` | 3.39 | - | 3.38 | 3.41 | 6 | 0.4 | 3452 | 97.00 KiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=4096 group=128 dtype=bf16 M=2` | 3.39 | - | 3.39 | 3.41 | 6 | 0.3 | 3444 | 24.25 KiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=4096 group=128 dtype=bf16 M=4` | 3.39 | - | 3.38 | 3.40 | 6 | 0.2 | 3452 | 48.50 KiB | | -| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=4096 group=128 dtype=bf16 M=1` | 3.38 | - | 3.38 | 3.40 | 6 | 0.4 | 3430 | 12.12 KiB | | -| `silu_mul` | `silu_mul_bf16` | libr4d | `n=17408 dtype=bf16 M=16` | 3.35 | - | 3.35 | 3.37 | 6 | 0.3 | 3426 | 1.59 MiB | | -| `sample_penalties` | `avx_sample_penalties` | libavx | `n_vocab=248320 M=4` | - | 3.31 | 2.96 | 3.66 | 20 | 6.4 | - | 3.79 MiB | 32 thread(s) | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=512` | 3.29 | - | 3.28 | 3.30 | 6 | 0.3 | 3402 | 256.25 KiB | | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 3.28 | 3.22 | 3.40 | 20 | 1.7 | - | 152.01 KiB | 32 thread(s) | -| `rope` | `rope_bf16` | libr4d | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=16` | 3.27 | - | 3.27 | 3.27 | 6 | 0.1 | 3553 | 108.12 KiB | restore 40% | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=4096 group=128 dtype=bf16 M=4` | - | 3.24 | 3.12 | 3.31 | 20 | 1.6 | - | 48.50 KiB | 32 thread(s) | -| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=64` | 3.20 | - | 3.19 | 3.20 | 6 | 0.2 | 3414 | 128.25 KiB | restore 41% | -| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=16` | 3.19 | - | 3.17 | 3.19 | 6 | 0.3 | 3447 | 128.06 KiB | restore 40% | -| `kv_store` | `avx_kv_store` | libavx | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=16` | - | 3.19 | 2.84 | 3.45 | 20 | 7.1 | - | 160.06 KiB | 32 thread(s) | -| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=128` | 3.17 | - | 3.13 | 3.19 | 6 | 0.9 | 3359 | 6.25 MiB | restore 73% | -| `cast` | `avx_cast` | libavx | `n=5120 from=bf16 to=bf16 M=16` | - | 3.14 | 3.07 | 4.03 | 20 | 13.7 | - | 320.00 KiB | 32 thread(s) | -| `cast` | `cast_bf16_bf16` | libr4d | `n=5120 from=bf16 to=bf16 M=256` | 3.14 | - | 3.13 | 3.15 | 6 | 0.3 | 3354 | 5.00 MiB | | -| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=64` | 3.11 | - | 3.09 | 3.13 | 6 | 0.6 | 3350 | 3.13 MiB | restore 48% | -| `grid_embed` | `grid_embed_bf16` | libr4d | `n=1152 side=48 dtype=bf16 M=64` | 3.10 | - | 3.10 | 3.12 | 6 | 0.4 | 3526 | 5.20 MiB | restore 41% | -| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=32` | 3.10 | - | 3.09 | 3.10 | 6 | 0.2 | 3368 | 384.38 KiB | restore 42% | -| `scatter_rows` | `avx_scatter_rows` | libavx | `n=5120 dtype=bf16 M=4` | - | 3.09 | 2.60 | 3.66 | 20 | 13.1 | - | 200.02 KiB | 32 thread(s) | -| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=32` | 3.09 | - | 3.06 | 3.10 | 6 | 0.7 | 3374 | 1.56 MiB | restore 45% | -| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=8` | 3.08 | - | 3.07 | 3.09 | 6 | 0.2 | 3374 | 400.03 KiB | restore 42% | -| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=4` | 3.08 | - | 3.07 | 3.09 | 6 | 0.3 | 3373 | 200.02 KiB | restore 42% | -| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=16` | 3.08 | - | 3.07 | 3.08 | 6 | 0.2 | 3373 | 800.06 KiB | restore 43% | -| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | `head_k=128 M=4 chunk=64` | - | 3.08 | 2.68 | 3.12 | 20 | 1.3 | - | 41.51 KiB | 32 thread(s) | -| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=2` | 3.07 | - | 3.05 | 3.08 | 6 | 0.5 | 3370 | 100.01 KiB | restore 42% | -| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=1` | 3.05 | - | 3.03 | 3.05 | 6 | 0.4 | 3364 | 50.00 KiB | restore 43% | -| `grid_embed` | `grid_embed_bf16` | libr4d | `n=1152 side=48 dtype=bf16 M=32` | 3.04 | - | 3.02 | 3.07 | 6 | 0.7 | 3523 | 5.13 MiB | restore 42% | -| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=128` | 3.02 | - | 3.01 | 3.04 | 6 | 0.4 | 3353 | 2.37 GiB | | -| `rope` | `rope_bf16` | libr4d | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=8` | 3.00 | - | 2.99 | 3.01 | 6 | 0.3 | 3559 | 54.06 KiB | restore 42% | -| `sample_dry` | `avx_sample_dry` | libavx | `n_vocab=248320 M=4` | - | 2.96 | 2.74 | 3.17 | 20 | 3.9 | - | 3.79 MiB | 32 thread(s) | -| `grid_embed` | `grid_embed_bf16` | libr4d | `n=1152 side=48 dtype=bf16 M=16` | 2.93 | - | 2.92 | 2.96 | 6 | 0.7 | 3523 | 5.10 MiB | restore 43% | -| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=128` | 2.93 | - | 2.92 | 2.94 | 6 | 0.4 | 3388 | 257.50 KiB | restore 43% | -| `rope` | `rope_bf16` | libr4d | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=4` | 2.91 | - | 2.88 | 2.91 | 6 | 0.5 | 3560 | 27.03 KiB | restore 43% | -| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=16` | 2.90 | - | 2.88 | 2.90 | 6 | 0.4 | 3370 | 192.19 KiB | restore 44% | -| `rope` | `rope_bf16` | libr4d | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=2` | 2.89 | - | 2.88 | 2.90 | 6 | 0.4 | 3562 | 13.52 KiB | restore 43% | -| `cast` | `avx_cast` | libavx | `n=5120 from=bf16 to=bf16 M=4` | - | 2.89 | 2.85 | 2.99 | 16 | 0.8 | - | 80.00 KiB | 32 thread(s) | -| `rope` | `rope_bf16` | libr4d | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=1` | 2.89 | - | 2.88 | 2.90 | 6 | 0.3 | 3376 | 6.76 KiB | restore 42% | -| `grid_embed` | `grid_embed_bf16` | libr4d | `n=1152 side=48 dtype=bf16 M=8` | 2.87 | - | 2.86 | 2.89 | 6 | 0.6 | 3522 | 5.08 MiB | restore 43% | -| `grid_embed` | `grid_embed_bf16` | libr4d | `n=1152 side=48 dtype=bf16 M=4` | 2.87 | - | 2.85 | 2.90 | 6 | 0.9 | 3523 | 5.07 MiB | restore 43% | -| `grid_embed` | `grid_embed_bf16` | libr4d | `n=1152 side=48 dtype=bf16 M=2` | 2.87 | - | 2.86 | 2.91 | 6 | 0.9 | 3517 | 5.07 MiB | restore 42% | -| `grid_embed` | `grid_embed_bf16` | libr4d | `n=1152 side=48 dtype=bf16 M=1` | 2.86 | - | 2.84 | 2.87 | 11 | 0.3 | 3517 | 5.06 MiB | restore 41% | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=6144 group=128 dtype=bf16 M=1` | - | 2.86 | 2.74 | 3.06 | 20 | 4.6 | - | 18.19 KiB | 32 thread(s) | -| `gather_rows` | `avx_gather_rows` | libavx | `n=5120 dtype=bf16 M=64` | - | 2.85 | 2.72 | 3.17 | 20 | 2.8 | - | 3.13 MiB | 32 thread(s) | -| `add` | `avx_add` | libavx | `n=5120 dtype=bf16 M=1` | - | 2.83 | 2.81 | 2.91 | 20 | 1.5 | - | 30.00 KiB | 32 thread(s) | -| `silu_mul` | `silu_mul_bf16` | libr4d | `n=17408 dtype=bf16 M=8` | 2.83 | - | 2.82 | 2.84 | 6 | 0.3 | 3438 | 816.00 KiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=32` | 2.82 | - | 2.80 | 2.83 | 6 | 0.5 | 3373 | 32.50 KiB | | -| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=64` | 2.81 | - | 2.81 | 2.82 | 6 | 0.2 | 3369 | 2.37 GiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=16` | 2.81 | - | 2.79 | 2.82 | 6 | 0.5 | 3367 | 16.50 KiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=8` | 2.80 | - | 2.78 | 2.81 | 6 | 0.5 | 3371 | 8.50 KiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=1` | 2.80 | - | 2.79 | 2.92 | 16 | 0.4 | 3357 | 1.50 KiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=2` | 2.80 | - | 2.79 | 2.81 | 6 | 0.3 | 3370 | 2.50 KiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=4` | 2.80 | - | 2.78 | 2.80 | 6 | 0.4 | 3372 | 4.50 KiB | | -| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=32` | 2.79 | - | 2.78 | 2.80 | 6 | 0.3 | 3416 | 64.12 KiB | restore 44% | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=2` | - | 2.79 | 2.78 | 2.85 | 16 | 0.9 | - | 50.00 KiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=2` | - | 2.79 | 2.76 | 2.91 | 16 | 0.5 | - | 13.52 KiB | 32 thread(s) | -| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=8` | 2.78 | - | 2.77 | 2.78 | 6 | 0.3 | 3459 | 64.03 KiB | restore 43% | -| `gather_rows` | `gather_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=64` | 2.78 | - | 2.77 | 2.79 | 6 | 0.3 | 3396 | 3.13 MiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=32` | 2.78 | - | 2.77 | 2.79 | 6 | 0.3 | 3404 | 16.25 KiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=64` | 2.77 | - | 2.77 | 2.79 | 6 | 0.3 | 3368 | 64.50 KiB | | -| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=64` | 2.77 | - | 2.77 | 2.79 | 6 | 0.3 | 3392 | 128.75 KiB | restore 44% | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=128` | 2.77 | - | 2.75 | 2.77 | 6 | 0.4 | 3366 | 128.50 KiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=4` | 2.77 | - | 2.76 | 2.78 | 6 | 0.3 | 3392 | 2.25 KiB | | -| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=32` | 2.77 | - | 2.76 | 2.78 | 6 | 0.2 | 3372 | 2.37 GiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=16` | 2.77 | - | 2.76 | 2.78 | 6 | 0.4 | 3402 | 8.25 KiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=8` | 2.76 | - | 2.76 | 2.77 | 6 | 0.2 | 3396 | 4.25 KiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=2` | 2.76 | - | 2.76 | 2.78 | 6 | 0.4 | 3392 | 1.25 KiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=1` | 2.76 | - | 2.75 | 2.78 | 6 | 0.5 | 3400 | 768 B | | -| `gather_rows` | `gather_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=56` | 2.75 | - | 2.75 | 2.76 | 6 | 0.2 | 3424 | 2.73 MiB | | -| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=16` | 2.75 | - | 2.75 | 2.76 | 6 | 0.2 | 3370 | 2.37 GiB | | -| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=8` | 2.75 | - | 2.74 | 2.78 | 6 | 0.8 | 3373 | 96.09 KiB | restore 45% | -| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=8` | 2.74 | - | 2.74 | 2.75 | 6 | 0.3 | 3372 | 2.37 GiB | | -| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=4` | 2.74 | - | 2.74 | 2.75 | 6 | 0.3 | 3372 | 2.37 GiB | | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=256` | - | 2.74 | 2.63 | 3.15 | 20 | 2.5 | - | 128.25 KiB | 32 thread(s) | -| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=16` | 2.74 | - | 2.73 | 2.74 | 6 | 0.2 | 3392 | 32.19 KiB | restore 44% | -| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=32` | 2.74 | - | 2.70 | 2.74 | 6 | 0.7 | 3394 | 64.38 KiB | restore 44% | -| `gather_rows` | `gather_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=32` | 2.73 | - | 2.73 | 2.74 | 6 | 0.2 | 3404 | 1.56 MiB | | -| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=4` | 2.73 | - | 2.72 | 2.74 | 6 | 0.3 | 3372 | 48.05 KiB | restore 45% | -| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=2` | 2.73 | - | 2.70 | 2.73 | 6 | 0.6 | 3372 | 24.02 KiB | restore 46% | -| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=64` | - | 2.73 | 2.61 | 2.86 | 20 | 3.3 | - | 2.37 GiB | 32 thread(s) | -| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=2` | 2.73 | - | 2.72 | 2.75 | 6 | 0.5 | 3370 | 2.37 GiB | | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=64` | 2.73 | - | 2.72 | 2.75 | 6 | 0.4 | 3403 | 32.25 KiB | | -| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=16` | - | 2.73 | 2.69 | 2.82 | 14 | 0.9 | - | 32.19 KiB | 32 thread(s) | -| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=1` | 2.72 | - | 2.71 | 2.75 | 6 | 0.7 | 3366 | 12.01 KiB | restore 46% | -| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=1` | 2.72 | - | 2.71 | 2.73 | 6 | 0.3 | 3356 | 2.37 GiB | | -| `rope_table` | `avx_rope_table` | libavx | `rot=64 theta=1e+07 scale=1 dtype=f32 M=32` | - | 2.72 | 2.69 | 2.79 | 14 | 0.7 | - | 8.12 KiB | 32 thread(s) | -| `gather_rows` | `gather_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=16` | 2.72 | - | 2.71 | 2.73 | 6 | 0.3 | 3404 | 800.06 KiB | | -| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=8` | 2.72 | - | 2.68 | 2.73 | 6 | 0.9 | 3379 | 16.09 KiB | restore 45% | -| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=2` | 2.72 | - | 2.69 | 2.72 | 6 | 0.6 | 3380 | 4.02 KiB | restore 44% | -| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=4` | 2.71 | - | 2.71 | 2.72 | 6 | 0.3 | 3379 | 8.05 KiB | restore 45% | -| `gather_rows` | `gather_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=8` | 2.71 | - | 2.70 | 2.72 | 6 | 0.2 | 3405 | 400.03 KiB | | -| `sample_dry` | `avx_sample_dry` | libavx | `n_vocab=248320 M=16` | - | 2.71 | 2.40 | 2.93 | 20 | 6.1 | - | 15.16 MiB | 32 thread(s) | -| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=128` | 2.70 | - | 2.70 | 2.71 | 6 | 0.3 | 3400 | 64.25 KiB | | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=128` | - | 2.70 | 2.61 | 3.07 | 20 | 4.0 | - | 128.50 KiB | 32 thread(s) | -| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=1` | 2.70 | - | 2.68 | 2.71 | 6 | 0.6 | 3367 | 2.01 KiB | restore 44% | -| `gather_rows` | `gather_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=4` | 2.70 | - | 2.69 | 2.71 | 6 | 0.3 | 3404 | 200.02 KiB | | -| `gather_rows` | `gather_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=2` | 2.70 | - | 2.69 | 2.71 | 6 | 0.3 | 3403 | 100.01 KiB | | -| `gather_rows` | `gather_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=1` | 2.69 | - | 2.69 | 2.73 | 6 | 0.7 | 3397 | 50.00 KiB | | -| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=128` | 2.67 | - | 2.65 | 2.68 | 6 | 0.5 | 3401 | 832.50 KiB | restore 46% | -| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=128` | 2.66 | - | 2.65 | 2.67 | 6 | 0.2 | 3440 | 832.50 KiB | restore 45% | -| `cast` | `avx_cast` | libavx | `n=5120 from=bf16 to=bf16 M=8` | - | 2.66 | 2.60 | 3.95 | 19 | 0.9 | - | 160.00 KiB | 32 thread(s) | -| `cast` | `cast_bf16_bf16` | libr4d | `n=5120 from=bf16 to=bf16 M=128` | 2.65 | - | 2.65 | 2.66 | 6 | 0.2 | 3364 | 2.50 MiB | | -| `scatter_rows` | `avx_scatter_rows` | libavx | `n=5120 dtype=bf16 M=8` | - | 2.65 | 2.23 | 3.20 | 20 | 5.7 | - | 400.03 KiB | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=2` | - | 2.62 | 2.60 | 2.67 | 19 | 0.8 | - | 50.00 KiB | 32 thread(s) | -| `gdn_gated_rmsnorm` | `avx_gdn_gated_rmsnorm` | libavx | `channels=128 eps=1e-06 act=silu M=32` | - | 2.61 | 2.59 | 2.66 | 16 | 0.9 | - | 24.50 KiB | 32 thread(s) | -| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=16` | 2.60 | - | 2.60 | 2.61 | 6 | 0.2 | 3414 | 32.06 KiB | restore 45% | -| `silu_mul` | `silu_mul_bf16` | libr4d | `n=17408 dtype=bf16 M=4` | 2.60 | - | 2.60 | 2.61 | 6 | 0.3 | 3452 | 408.00 KiB | | -| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=4` | 2.60 | - | 2.59 | 2.61 | 6 | 0.3 | 3464 | 32.02 KiB | restore 45% | -| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=1` | 2.60 | - | 2.59 | 2.61 | 6 | 0.4 | 3408 | 2.00 KiB | restore 45% | -| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=4` | - | 2.59 | 2.53 | 2.71 | 20 | 1.7 | - | 112.02 KiB | 32 thread(s) | -| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=2` | 2.59 | - | 2.59 | 2.61 | 6 | 0.4 | 3418 | 4.01 KiB | restore 44% | -| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=4` | 2.59 | - | 2.58 | 2.61 | 6 | 0.5 | 3416 | 8.02 KiB | restore 46% | -| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=8` | 2.59 | - | 2.59 | 2.60 | 6 | 0.2 | 3416 | 16.03 KiB | restore 46% | -| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=1` | 2.59 | - | 2.54 | 2.59 | 11 | 0.4 | 3462 | 8.00 KiB | restore 45% | -| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=2` | 2.58 | - | 2.58 | 2.59 | 6 | 0.2 | 3463 | 16.01 KiB | restore 45% | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 2.57 | 2.52 | 2.68 | 20 | 1.4 | - | 80.01 KiB | 32 thread(s) | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 2.56 | 2.52 | 2.78 | 20 | 1.4 | - | 56.01 KiB | 32 thread(s) | -| `quant_act_i8` | `avx_quant_act_i8` | libavx | `n=5120 group=128 dtype=bf16 M=2` | - | 2.55 | 2.54 | 2.61 | 14 | 0.3 | - | 32.51 KiB | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=64` | - | 2.53 | 2.52 | 2.58 | 16 | 1.0 | - | 32.25 KiB | 32 thread(s) | -| `sample_dry` | `avx_sample_dry` | libavx | `n_vocab=248320 M=8` | - | 2.53 | 2.22 | 3.03 | 20 | 9.1 | - | 7.58 MiB | 32 thread(s) | -| `rope_table` | `rope_table_f32` | libr4d | `rot=64 theta=1e+07 scale=1 dtype=f32 M=64` | 2.52 | - | 2.51 | 2.53 | 6 | 0.4 | 3394 | 16.25 KiB | | -| `gdn_gated_rmsnorm` | `gdn_gated_rmsnorm_h128_bf16` | libr4d | `channels=128 eps=1e-06 act=silu M=512` | 2.51 | - | 2.50 | 2.53 | 6 | 0.5 | 3388 | 384.50 KiB | | -| `rope_table` | `rope_table_f32` | libr4d | `rot=64 theta=1e+07 scale=1 dtype=f32 M=32` | 2.51 | - | 2.50 | 2.52 | 6 | 0.3 | 3393 | 8.12 KiB | | -| `rope_table` | `rope_table_f32` | libr4d | `rot=64 theta=1e+07 scale=1 dtype=f32 M=16` | 2.51 | - | 2.50 | 2.51 | 6 | 0.3 | 3392 | 4.06 KiB | | -| `rope_table` | `rope_table_f32` | libr4d | `rot=64 theta=1e+07 scale=1 dtype=f32 M=8` | 2.50 | - | 2.50 | 2.50 | 6 | 0.2 | 3395 | 2.03 KiB | | -| `rope_table` | `rope_table_f32` | libr4d | `rot=64 theta=1e+07 scale=1 dtype=f32 M=2` | 2.50 | - | 2.49 | 2.50 | 6 | 0.3 | 3386 | 520 B | | -| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=64` | 2.50 | - | 2.49 | 2.50 | 6 | 0.2 | 3439 | 448.25 KiB | restore 47% | -| `rope_table` | `rope_table_f32` | libr4d | `rot=64 theta=1e+07 scale=1 dtype=f32 M=4` | 2.50 | - | 2.49 | 2.51 | 6 | 0.3 | 3391 | 1.02 KiB | | -| `rope_table` | `rope_table_f32` | libr4d | `rot=64 theta=1e+07 scale=1 dtype=f32 M=1` | 2.49 | - | 2.49 | 2.51 | 6 | 0.6 | 3365 | 260 B | | -| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=64` | 2.49 | - | 2.49 | 2.52 | 6 | 0.7 | 3403 | 448.25 KiB | restore 47% | -| `gdn_gated_rmsnorm` | `gdn_gated_rmsnorm_h128_bf16` | libr4d | `channels=128 eps=1e-06 act=silu M=256` | 2.49 | - | 2.48 | 2.49 | 6 | 0.2 | 3391 | 192.50 KiB | | -| `silu_mul` | `silu_mul_bf16` | libr4d | `n=17408 dtype=bf16 M=2` | 2.49 | - | 2.48 | 2.52 | 6 | 0.7 | 3454 | 204.00 KiB | | -| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | `head_k=128 M=2 chunk=64` | - | 2.48 | 2.44 | 2.55 | 20 | 1.7 | - | 20.76 KiB | 32 thread(s) | -| `kv_store` | `avx_kv_store` | libavx | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=4` | - | 2.48 | 2.43 | 2.56 | 20 | 1.8 | - | 112.02 KiB | 32 thread(s) | -| `gdn_gated_rmsnorm` | `gdn_gated_rmsnorm_h128_bf16` | libr4d | `channels=128 eps=1e-06 act=silu M=128` | 2.47 | - | 2.46 | 2.48 | 6 | 0.4 | 3389 | 96.50 KiB | | -| `gdn_gated_rmsnorm` | `gdn_gated_rmsnorm_h128_bf16` | libr4d | `channels=128 eps=1e-06 act=silu M=16` | 2.46 | - | 2.46 | 2.47 | 6 | 0.1 | 3379 | 12.50 KiB | | -| `gdn_gated_rmsnorm` | `gdn_gated_rmsnorm_h128_bf16` | libr4d | `channels=128 eps=1e-06 act=silu M=64` | 2.46 | - | 2.45 | 2.47 | 6 | 0.3 | 3394 | 48.50 KiB | | -| `gdn_gated_rmsnorm` | `gdn_gated_rmsnorm_h128_bf16` | libr4d | `channels=128 eps=1e-06 act=silu M=8` | 2.46 | - | 2.46 | 2.47 | 6 | 0.3 | 3382 | 6.50 KiB | | -| `gdn_gated_rmsnorm` | `gdn_gated_rmsnorm_h128_bf16` | libr4d | `channels=128 eps=1e-06 act=silu M=32` | 2.46 | - | 2.45 | 2.47 | 6 | 0.4 | 3392 | 24.50 KiB | | -| `gdn_gated_rmsnorm` | `gdn_gated_rmsnorm_h128_bf16` | libr4d | `channels=128 eps=1e-06 act=silu M=4` | 2.46 | - | 2.45 | 2.47 | 6 | 0.4 | 3382 | 3.50 KiB | | -| `gdn_gated_rmsnorm` | `gdn_gated_rmsnorm_h128_bf16` | libr4d | `channels=128 eps=1e-06 act=silu M=2` | 2.45 | - | 2.45 | 2.47 | 6 | 0.4 | 3380 | 2.00 KiB | | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=128` | - | 2.45 | 2.35 | 2.72 | 20 | 7.0 | - | 64.25 KiB | 32 thread(s) | -| `gdn_gated_rmsnorm` | `gdn_gated_rmsnorm_h128_bf16` | libr4d | `channels=128 eps=1e-06 act=silu M=1` | 2.45 | - | 2.45 | 2.46 | 6 | 0.2 | 3372 | 1.25 KiB | | -| `silu_mul` | `silu_mul_bf16` | libr4d | `n=17408 dtype=bf16 M=1` | 2.44 | - | 2.44 | 2.45 | 6 | 0.2 | 3441 | 102.00 KiB | | -| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=32` | 2.44 | - | 2.43 | 2.46 | 6 | 0.6 | 3432 | 256.12 KiB | restore 47% | -| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=32` | 2.43 | - | 2.43 | 2.45 | 6 | 0.5 | 3404 | 256.12 KiB | restore 47% | -| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=16` | 2.43 | - | 2.43 | 2.45 | 6 | 0.4 | 3416 | 160.06 KiB | restore 47% | -| `layernorm` | `avx_layernorm` | libavx | `n=1152 eps=1e-06 dtype=bf16 M=8` | - | 2.43 | 2.43 | 2.50 | 16 | 0.6 | - | 40.50 KiB | 32 thread(s) | -| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=16` | 2.43 | - | 2.42 | 2.44 | 6 | 0.3 | 3434 | 160.06 KiB | restore 47% | -| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=8` | 2.43 | - | 2.41 | 2.44 | 6 | 0.6 | 3414 | 128.03 KiB | restore 47% | -| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=8` | 2.43 | - | 2.42 | 2.43 | 6 | 0.3 | 3435 | 128.03 KiB | restore 47% | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=64` | - | 2.42 | 2.36 | 2.63 | 20 | 4.0 | - | 64.50 KiB | 32 thread(s) | -| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=4` | 2.42 | - | 2.42 | 2.43 | 6 | 0.2 | 3415 | 112.02 KiB | restore 47% | -| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=1` | 2.42 | - | 2.39 | 2.43 | 11 | 0.7 | 3404 | 100.00 KiB | restore 47% | -| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=4` | 2.42 | - | 2.41 | 2.42 | 6 | 0.2 | 3434 | 112.02 KiB | restore 47% | -| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=2` | 2.42 | - | 2.41 | 2.44 | 6 | 0.5 | 3415 | 104.01 KiB | restore 47% | -| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=1` | 2.41 | - | 2.41 | 2.42 | 6 | 0.3 | 3416 | 100.00 KiB | restore 47% | -| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=2` | 2.41 | - | 2.41 | 2.42 | 6 | 0.2 | 3432 | 104.01 KiB | restore 47% | -| `cast` | `cast_bf16_bf16` | libr4d | `n=5120 from=bf16 to=bf16 M=64` | 2.39 | - | 2.38 | 2.39 | 6 | 0.2 | 3370 | 1.25 MiB | | -| `gather_rows` | `avx_gather_rows` | libavx | `n=5120 dtype=bf16 M=56` | - | 2.37 | 2.34 | 2.44 | 20 | 1.5 | - | 2.73 MiB | 32 thread(s) | -| `gather_rows` | `avx_gather_rows` | libavx | `n=5120 dtype=bf16 M=8` | - | 2.32 | 2.24 | 2.34 | 14 | 1.0 | - | 400.03 KiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=4` | - | 2.32 | 2.29 | 2.40 | 16 | 0.9 | - | 8.02 KiB | 32 thread(s) | -| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=1024 M=32` | 2.32 | - | 2.31 | 2.33 | 6 | 0.4 | 3587 | 131.00 KiB | restore 47% | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 2.31 | 2.29 | 2.40 | 19 | 0.4 | - | 64.01 KiB | 32 thread(s) | -| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=1024 M=16` | 2.29 | - | 2.29 | 2.30 | 6 | 0.3 | 3585 | 65.50 KiB | restore 47% | -| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=4` | - | 2.29 | 2.13 | 2.35 | 16 | 0.7 | - | 2.37 GiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=4` | - | 2.29 | 2.24 | 2.35 | 20 | 1.1 | - | 48.05 KiB | 32 thread(s) | -| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=1024 M=8` | 2.27 | - | 2.27 | 2.28 | 6 | 0.3 | 3586 | 32.75 KiB | restore 48% | -| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=32` | - | 2.27 | 2.23 | 2.43 | 20 | 3.9 | - | 2.37 GiB | 32 thread(s) | -| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=1024 M=4` | 2.27 | - | 2.26 | 2.28 | 6 | 0.3 | 3585 | 16.38 KiB | restore 48% | -| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=1024 M=2` | 2.27 | - | 2.26 | 2.28 | 6 | 0.3 | 3587 | 8.19 KiB | restore 48% | -| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=1024 M=1` | 2.27 | - | 2.23 | 2.28 | 11 | 0.5 | 3584 | 4.09 KiB | restore 47% | -| `cast` | `cast_bf16_bf16` | libr4d | `n=5120 from=bf16 to=bf16 M=32` | 2.26 | - | 2.26 | 2.27 | 6 | 0.2 | 3366 | 640.00 KiB | | -| `cast` | `cast_bf16_bf16` | libr4d | `n=5120 from=bf16 to=bf16 M=16` | 2.23 | - | 2.23 | 2.24 | 6 | 0.3 | 3372 | 320.00 KiB | | -| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=2` | - | 2.23 | 2.15 | 2.58 | 20 | 4.5 | - | 16.01 KiB | 32 thread(s) | -| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=8` | - | 2.22 | 2.21 | 2.28 | 20 | 1.0 | - | 4.51 KiB | 32 thread(s) | -| `cast` | `cast_bf16_bf16` | libr4d | `n=5120 from=bf16 to=bf16 M=8` | 2.20 | - | 2.20 | 2.21 | 6 | 0.3 | 3371 | 160.00 KiB | | -| `gather_rows` | `avx_gather_rows` | libavx | `n=5120 dtype=bf16 M=4` | - | 2.19 | 1.93 | 2.35 | 20 | 5.4 | - | 200.02 KiB | 32 thread(s) | -| `cast` | `cast_bf16_bf16` | libr4d | `n=5120 from=bf16 to=bf16 M=4` | 2.19 | - | 2.19 | 2.21 | 6 | 0.4 | 3375 | 80.00 KiB | | -| `cast` | `cast_bf16_bf16` | libr4d | `n=5120 from=bf16 to=bf16 M=2` | 2.19 | - | 2.18 | 2.20 | 6 | 0.3 | 3356 | 40.00 KiB | | -| `cast` | `cast_bf16_bf16` | libr4d | `n=5120 from=bf16 to=bf16 M=1` | 2.18 | - | 2.18 | 2.20 | 6 | 0.6 | 3310 | 20.00 KiB | | -| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 2.14 | 2.10 | 2.23 | 20 | 2.6 | - | 48.01 KiB | 32 thread(s) | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=4096 group=128 dtype=bf16 M=1` | - | 2.00 | 1.89 | 2.06 | 20 | 1.6 | - | 12.12 KiB | 32 thread(s) | -| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5120 group=128 dtype=bf16 M=1` | - | 1.99 | 1.97 | 2.05 | 20 | 1.3 | - | 15.16 KiB | 32 thread(s) | -| `gather_rows` | `avx_gather_rows` | libavx | `n=5120 dtype=bf16 M=16` | - | 1.98 | 1.95 | 2.09 | 20 | 1.9 | - | 800.06 KiB | 32 thread(s) | -| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=16` | - | 1.96 | 1.94 | 2.02 | 19 | 0.9 | - | 2.37 GiB | 32 thread(s) | -| `gather_rows` | `avx_gather_rows` | libavx | `n=5120 dtype=bf16 M=32` | - | 1.95 | 1.94 | 2.04 | 20 | 1.5 | - | 1.56 MiB | 32 thread(s) | -| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | `head_k=128 M=1 chunk=64` | - | 1.95 | 1.94 | 2.01 | 16 | 0.6 | - | 10.38 KiB | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=1` | - | 1.94 | 1.86 | 1.98 | 20 | 1.9 | - | 30.00 KiB | 32 thread(s) | -| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=8` | - | 1.91 | 1.88 | 2.00 | 14 | 0.9 | - | 2.37 GiB | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=32` | - | 1.90 | 1.89 | 1.94 | 14 | 0.8 | - | 32.50 KiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=1` | - | 1.85 | 1.77 | 1.88 | 20 | 2.2 | - | 6.76 KiB | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=1` | - | 1.76 | 1.74 | 1.80 | 20 | 1.1 | - | 30.00 KiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=2` | - | 1.73 | 1.68 | 1.85 | 20 | 3.8 | - | 4.01 KiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=8` | - | 1.72 | 1.65 | 1.80 | 20 | 2.6 | - | 16.09 KiB | 32 thread(s) | -| `rope_table` | `avx_rope_table` | libavx | `rot=64 theta=1e+07 scale=1 dtype=f32 M=16` | - | 1.61 | 1.61 | 1.66 | 14 | 0.9 | - | 4.06 KiB | 32 thread(s) | -| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=2` | - | 1.56 | 1.53 | 1.67 | 20 | 2.9 | - | 104.01 KiB | 32 thread(s) | -| `cast` | `avx_cast` | libavx | `n=5120 from=bf16 to=bf16 M=2` | - | 1.54 | 1.53 | 1.57 | 16 | 0.2 | - | 40.00 KiB | 32 thread(s) | -| `kv_store` | `avx_kv_store` | libavx | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=2` | - | 1.52 | 1.50 | 1.68 | 16 | 0.7 | - | 104.01 KiB | 32 thread(s) | -| `gdn_gated_rmsnorm` | `avx_gdn_gated_rmsnorm` | libavx | `channels=128 eps=1e-06 act=silu M=16` | - | 1.51 | 1.50 | 1.54 | 11 | 0.9 | - | 12.50 KiB | 32 thread(s) | -| `layernorm` | `avx_layernorm` | libavx | `n=1152 eps=1e-06 dtype=bf16 M=4` | - | 1.50 | 1.49 | 1.53 | 14 | 0.5 | - | 22.50 KiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=1` | - | 1.49 | 1.43 | 2.31 | 20 | 7.7 | - | 8.00 KiB | 32 thread(s) | -| `quant_act_i8` | `avx_quant_act_i8` | libavx | `n=5120 group=128 dtype=bf16 M=1` | - | 1.48 | 1.48 | 1.51 | 6 | 1.0 | - | 17.50 KiB | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=32` | - | 1.46 | 1.45 | 1.50 | 16 | 0.7 | - | 16.25 KiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=2` | - | 1.45 | 1.43 | 1.49 | 20 | 1.0 | - | 24.02 KiB | 32 thread(s) | -| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=1` | - | 1.28 | 1.19 | 1.38 | 20 | 5.1 | - | 100.00 KiB | 32 thread(s) | -| `sample_penalties` | `avx_sample_penalties` | libavx | `n_vocab=248320 M=1` | - | 1.22 | 1.18 | 1.48 | 19 | 0.8 | - | 970.34 KiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=4` | - | 1.21 | 1.17 | 1.27 | 20 | 3.7 | - | 8.05 KiB | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=16` | - | 1.17 | 1.16 | 1.20 | 14 | 0.9 | - | 16.50 KiB | 32 thread(s) | -| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=1024 M=8` | - | 1.16 | 1.14 | 1.19 | 20 | 1.3 | - | 32.75 KiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=1` | - | 1.12 | 1.09 | 1.18 | 20 | 2.7 | - | 12.01 KiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=1` | - | 1.12 | 1.09 | 1.24 | 20 | 2.2 | - | 2.00 KiB | 32 thread(s) | -| `rope_table` | `avx_rope_table` | libavx | `rot=64 theta=1e+07 scale=1 dtype=f32 M=8` | - | 1.07 | 1.06 | 1.13 | 16 | 0.5 | - | 2.03 KiB | 32 thread(s) | -| `sample_dry` | `avx_sample_dry` | libavx | `n_vocab=248320 M=1` | - | 1.03 | 0.99 | 1.15 | 16 | 1.0 | - | 970.41 KiB | 32 thread(s) | -| `layernorm` | `avx_layernorm` | libavx | `n=1152 eps=1e-06 dtype=bf16 M=2` | - | 1.01 | 0.99 | 1.04 | 20 | 1.3 | - | 13.50 KiB | 32 thread(s) | -| `kv_store` | `avx_kv_store` | libavx | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=1` | - | 0.97 | 0.95 | 1.01 | 20 | 1.5 | - | 100.00 KiB | 32 thread(s) | -| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=4` | - | 0.97 | 0.96 | 1.02 | 16 | 0.8 | - | 2.26 KiB | 32 thread(s) | -| `cast` | `avx_cast` | libavx | `n=5120 from=bf16 to=bf16 M=1` | - | 0.96 | 0.96 | 0.99 | 16 | 0.3 | - | 20.00 KiB | 32 thread(s) | -| `gdn_gated_rmsnorm` | `avx_gdn_gated_rmsnorm` | libavx | `channels=128 eps=1e-06 act=silu M=8` | - | 0.96 | 0.96 | 0.98 | 14 | 0.9 | - | 6.50 KiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=2` | - | 0.96 | 0.94 | 1.04 | 20 | 3.6 | - | 4.02 KiB | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=16` | - | 0.92 | 0.91 | 0.94 | 20 | 1.1 | - | 8.25 KiB | 32 thread(s) | -| `layernorm` | `avx_layernorm` | libavx | `n=1152 eps=1e-06 dtype=bf16 M=1` | - | 0.86 | 0.84 | 0.89 | 16 | 0.8 | - | 9.00 KiB | 32 thread(s) | -| `rope_table` | `avx_rope_table` | libavx | `rot=64 theta=1e+07 scale=1 dtype=f32 M=4` | - | 0.85 | 0.85 | 0.87 | 16 | 0.9 | - | 1.02 KiB | 32 thread(s) | -| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=1` | - | 0.83 | 0.79 | 0.88 | 20 | 3.6 | - | 2.01 KiB | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=8` | - | 0.80 | 0.79 | 0.83 | 20 | 1.8 | - | 8.50 KiB | 32 thread(s) | -| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=2` | - | 0.72 | 0.69 | 0.74 | 20 | 1.9 | - | 2.37 GiB | 32 thread(s) | -| `gdn_gated_rmsnorm` | `avx_gdn_gated_rmsnorm` | libavx | `channels=128 eps=1e-06 act=silu M=4` | - | 0.69 | 0.68 | 0.70 | 14 | 0.8 | - | 3.50 KiB | 32 thread(s) | -| `scatter_rows` | `avx_scatter_rows` | libavx | `n=5120 dtype=bf16 M=2` | - | 0.69 | 0.66 | 0.75 | 20 | 5.1 | - | 100.01 KiB | 32 thread(s) | -| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=1024 M=4` | - | 0.68 | 0.64 | 0.73 | 20 | 3.7 | - | 16.38 KiB | 32 thread(s) | -| `rope_table` | `avx_rope_table` | libavx | `rot=64 theta=1e+07 scale=1 dtype=f32 M=2` | - | 0.68 | 0.66 | 0.71 | 16 | 0.7 | - | 520 B | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=8` | - | 0.67 | 0.66 | 0.68 | 20 | 1.6 | - | 4.25 KiB | 32 thread(s) | -| `gather_rows` | `avx_gather_rows` | libavx | `n=5120 dtype=bf16 M=2` | - | 0.63 | 0.62 | 0.65 | 20 | 1.3 | - | 100.01 KiB | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=4` | - | 0.61 | 0.60 | 0.63 | 19 | 0.7 | - | 4.50 KiB | 32 thread(s) | -| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=2` | - | 0.61 | 0.60 | 0.62 | 19 | 0.6 | - | 1.13 KiB | 32 thread(s) | -| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=1` | - | 0.61 | 0.49 | 0.74 | 20 | 20.1 | - | 584 B | 32 thread(s) | -| `rope_table` | `avx_rope_table` | libavx | `rot=64 theta=1e+07 scale=1 dtype=f32 M=1` | - | 0.58 | 0.58 | 0.60 | 14 | 0.5 | - | 260 B | 32 thread(s) | -| `scatter_rows` | `avx_scatter_rows` | libavx | `n=5120 dtype=bf16 M=1` | - | 0.57 | 0.52 | 0.63 | 20 | 7.0 | - | 50.00 KiB | 32 thread(s) | -| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=1` | - | 0.56 | 0.56 | 0.68 | 20 | 2.7 | - | 2.37 GiB | 32 thread(s) | -| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=1024 M=2` | - | 0.56 | 0.53 | 0.57 | 20 | 1.8 | - | 8.19 KiB | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=4` | - | 0.55 | 0.54 | 0.56 | 20 | 1.1 | - | 2.25 KiB | 32 thread(s) | -| `gdn_gated_rmsnorm` | `avx_gdn_gated_rmsnorm` | libavx | `channels=128 eps=1e-06 act=silu M=2` | - | 0.55 | 0.54 | 0.56 | 19 | 0.5 | - | 2.00 KiB | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=2` | - | 0.51 | 0.51 | 0.53 | 20 | 1.1 | - | 2.50 KiB | 32 thread(s) | -| `gather_rows` | `avx_gather_rows` | libavx | `n=5120 dtype=bf16 M=1` | - | 0.51 | 0.50 | 0.52 | 20 | 1.2 | - | 50.00 KiB | 32 thread(s) | -| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=1024 M=1` | - | 0.50 | 0.48 | 0.55 | 20 | 5.0 | - | 4.09 KiB | 32 thread(s) | -| `gdn_gated_rmsnorm` | `avx_gdn_gated_rmsnorm` | libavx | `channels=128 eps=1e-06 act=silu M=1` | - | 0.49 | 0.49 | 0.51 | 20 | 1.4 | - | 1.25 KiB | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=2` | - | 0.48 | 0.48 | 0.49 | 14 | 0.4 | - | 1.25 KiB | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=1` | - | 0.47 | 0.47 | 0.48 | 20 | 1.2 | - | 1.50 KiB | 32 thread(s) | -| `rmsnorm` | `avx_rmsnorm` | libavx | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=1` | - | 0.46 | 0.45 | 0.47 | 20 | 1.3 | - | 768 B | 32 thread(s) | +| `logits_gemm` | `ref_logits_gemm` | libref | `n_vocab=248320 n_embd=5120 dtype=bf16 M=64` | - | 14464166.35 | 14464166.35 | 14464166.35 | 1 | - | - | 2.43 GiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | +| `logits_gemm` | `ref_logits_gemm` | libref | `n_vocab=248320 n_embd=5120 dtype=bf16 M=2` | - | 14041705.15 | 14041705.15 | 14041705.15 | 1 | - | - | 2.37 GiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | +| `logits_gemm` | `ref_logits_gemm` | libref | `n_vocab=248320 n_embd=5120 dtype=bf16 M=8` | - | 13888205.39 | 13888205.39 | 13888205.39 | 1 | - | - | 2.38 GiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | +| `logits_gemm` | `ref_logits_gemm` | libref | `n_vocab=248320 n_embd=5120 dtype=bf16 M=32` | - | 13887074.36 | 13887074.36 | 13887074.36 | 1 | - | - | 2.40 GiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | +| `logits_gemm` | `ref_logits_gemm` | libref | `n_vocab=248320 n_embd=5120 dtype=bf16 M=16` | - | 13872701.76 | 13872701.76 | 13872701.76 | 1 | - | - | 2.38 GiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | +| `logits_gemm` | `ref_logits_gemm` | libref | `n_vocab=248320 n_embd=5120 dtype=bf16 M=4` | - | 13647266.80 | 13647266.80 | 13647266.80 | 1 | - | - | 2.37 GiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | +| `logits_gemm` | `ref_logits_gemm` | libref | `n_vocab=248320 n_embd=5120 dtype=bf16 M=1` | - | 13619546.89 | 13619546.89 | 13619546.89 | 1 | - | - | 2.37 GiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | +| `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=64` | - | 8056807.62 | 8056807.62 | 8056807.62 | 1 | - | - | 173.56 MiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | - | 6457280.08 | 6457280.08 | 6457280.08 | 1 | - | - | 44.00 MiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | - | 5312458.60 | 5312458.60 | 5312458.60 | 1 | - | - | 44.00 MiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | +| `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=32` | - | 3742630.19 | 3742630.19 | 3742630.19 | 1 | - | - | 171.79 MiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=512` | - | 3679439.16 | 3679439.16 | 3679439.16 | 1 | - | - | 24.00 MiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | - | 3667163.42 | 3667163.42 | 3667163.42 | 1 | - | - | 38.19 MiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=64` | - | 3666787.98 | 3666787.98 | 3666787.98 | 1 | - | - | 17.00 MiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=512` | - | 3315333.20 | 3315333.20 | 3315333.20 | 1 | - | - | 24.00 MiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | - | 3060927.29 | 3060927.29 | 3060927.29 | 1 | - | - | 38.19 MiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=260` | - | 2418045.59 | 2418045.59 | 2418045.59 | 1 | - | - | 20.07 MiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=130` | - | 2199495.52 | 2199495.52 | 2199495.52 | 1 | - | - | 18.04 MiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | - | 2113189.38 | 2113189.38 | 2113189.38 | 1 | - | - | 35.10 MiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | - | 2053159.01 | 2053159.01 | 2053159.01 | 1 | - | - | 35.10 MiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | +| `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=64` | - | 2050876.25 | 2050876.25 | 2050876.25 | 1 | - | - | 98.54 MiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | +| `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=16` | - | 2001998.67 | 2001998.67 | 2001998.67 | 1 | - | - | 170.91 MiB | 32 thread(s); 1 timed launch(es) within the 2 s host budget | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | - | 1961987.42 | 1815739.31 | 2108235.54 | 2 | 7.5 | - | 33.55 MiB | 32 thread(s); 2 timed launch(es) within the 2 s host budget | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=260` | - | 1813822.26 | 1706653.55 | 1920990.98 | 2 | 5.9 | - | 20.07 MiB | 32 thread(s); 2 timed launch(es) within the 2 s host budget | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=34816 K=5120 group=128 dtype=fp8a8 M=512` | - | 1681812.74 | 1633617.49 | 1730008.00 | 2 | 2.9 | - | 206.60 MiB | 32 thread(s); 2 timed launch(es) within the 2 s host budget | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=32` | - | 1670060.99 | 1640962.01 | 1699159.98 | 2 | 1.7 | - | 16.50 MiB | 32 thread(s); 2 timed launch(es) within the 2 s host budget | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=65` | - | 1644271.27 | 1636142.67 | 1652399.87 | 2 | 0.5 | - | 17.02 MiB | 32 thread(s); 2 timed launch(es) within the 2 s host budget | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=33` | - | 1604620.96 | 1581389.22 | 1627852.71 | 2 | 1.4 | - | 16.52 MiB | 32 thread(s); 2 timed launch(es) within the 2 s host budget | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=512 tn=0` | - | 1522410.39 | 1344819.00 | 1700001.77 | 2 | 11.7 | - | 88.20 MiB | 32 thread(s); 2 timed launch(es) within the 2 s host budget | +| `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=8` | - | 1339401.91 | 1329301.02 | 1349502.80 | 2 | 0.8 | - | 170.46 MiB | 32 thread(s); 2 timed launch(es) within the 2 s host budget | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | - | 1080489.69 | 1039974.35 | 1121005.04 | 2 | 3.7 | - | 33.55 MiB | 32 thread(s); 2 timed launch(es) within the 2 s host budget | +| `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=32` | - | 1074177.69 | 1033427.34 | 1114928.04 | 2 | 3.8 | - | 97.28 MiB | 32 thread(s); 2 timed launch(es) within the 2 s host budget | +| `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=1` | - | 1069195.62 | 1055670.00 | 1082721.24 | 2 | 1.3 | - | 170.08 MiB | 32 thread(s); 2 timed launch(es) within the 2 s host budget | +| `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=4` | - | 1060405.35 | 1039788.65 | 1081022.06 | 2 | 1.9 | - | 170.24 MiB | 32 thread(s); 2 timed launch(es) within the 2 s host budget | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=20480 K=5120 dtype=bf16 M=512 tile=0` | - | 1022995.43 | 968996.10 | 1098001.50 | 3 | 6.3 | - | 225.00 MiB | 32 thread(s); 3 timed launch(es) within the 2 s host budget | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | - | 929603.22 | 899991.97 | 1032731.01 | 3 | 7.1 | - | 32.75 MiB | 32 thread(s); 3 timed launch(es) within the 2 s host budget | +| `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=2` | - | 927738.80 | 921488.36 | 981161.04 | 3 | 3.2 | - | 170.13 MiB | 32 thread(s); 3 timed launch(es) within the 2 s host budget | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | - | 920002.28 | 801590.53 | 1077369.95 | 3 | 15.0 | - | 32.78 MiB | 32 thread(s); 3 timed launch(es) within the 2 s host budget | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=130` | - | 905002.15 | 891981.65 | 1195986.49 | 3 | 16.8 | - | 18.04 MiB | 32 thread(s); 3 timed launch(es) within the 2 s host budget | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=16384 K=5120 group=128 dtype=fp8a8 M=512` | - | 862876.42 | 794994.57 | 1123985.23 | 3 | 19.1 | - | 98.59 MiB | 32 thread(s); 3 timed launch(es) within the 2 s host budget | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=34816 K=5120 group=128 dtype=fp8a8 M=258` | - | 850590.46 | 844987.17 | 936998.99 | 3 | 5.4 | - | 188.45 MiB | 32 thread(s); 3 timed launch(es) within the 2 s host budget | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=17408 group=128 dtype=fp8a8 M=512` | - | 784004.15 | 761996.11 | 841014.47 | 3 | 5.0 | - | 98.78 MiB | 32 thread(s); 3 timed launch(es) within the 2 s host budget | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=4096 K=20480 dtype=bf16 M=512 tile=0` | - | 768993.45 | 700998.58 | 998008.07 | 3 | 19.3 | - | 184.00 MiB | 32 thread(s); 3 timed launch(es) within the 2 s host budget | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | - | 767938.30 | 574006.71 | 953991.74 | 3 | 24.7 | - | 16.00 MiB | 32 thread(s); 3 timed launch(es) within the 2 s host budget | +| `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=16` | - | 668547.83 | 618854.60 | 700035.50 | 4 | 6.1 | - | 96.64 MiB | 32 thread(s); 4 timed launch(es) within the 2 s host budget | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=258 tn=0` | - | 632005.53 | 585352.99 | 789983.58 | 3 | 16.2 | - | 79.33 MiB | 32 thread(s); 3 timed launch(es) within the 2 s host budget | +| `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=8` | - | 597493.93 | 565003.56 | 682996.92 | 4 | 9.9 | - | 96.33 MiB | 32 thread(s); 4 timed launch(es) within the 2 s host budget | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | - | 595997.60 | 525007.96 | 697999.60 | 4 | 14.5 | - | 32.78 MiB | 32 thread(s); 4 timed launch(es) within the 2 s host budget | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | - | 569494.96 | 503988.65 | 619985.99 | 4 | 10.2 | - | 32.75 MiB | 32 thread(s); 4 timed launch(es) within the 2 s host budget | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=12288 K=5120 group=128 dtype=fp8a8 M=512` | - | 561500.29 | 510995.49 | 640002.33 | 4 | 11.5 | - | 74.59 MiB | 32 thread(s); 4 timed launch(es) within the 2 s host budget | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=65` | - | 533981.67 | 503001.42 | 561996.53 | 4 | 5.5 | - | 17.02 MiB | 32 thread(s); 4 timed launch(es) within the 2 s host budget | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=24576 group=128 dtype=fp8a8 M=512` | - | 533500.22 | 434987.52 | 594006.00 | 4 | 14.9 | - | 112.39 MiB | 32 thread(s); 4 timed launch(es) within the 2 s host budget | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=34816 K=5120 group=128 dtype=fp8a8 M=129` | - | 524489.88 | 489005.18 | 620001.17 | 4 | 12.5 | - | 179.24 MiB | 32 thread(s); 4 timed launch(es) within the 2 s host budget | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=16384 K=5120 group=128 dtype=fp8a8 M=258` | - | 519800.70 | 409996.46 | 606321.85 | 4 | 18.9 | - | 89.37 MiB | 32 thread(s); 4 timed launch(es) within the 2 s host budget | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=20480 K=5120 dtype=bf16 M=260 tile=0` | - | 517985.50 | 327004.84 | 643998.68 | 4 | 30.6 | - | 212.70 MiB | 32 thread(s); 4 timed launch(es) within the 2 s host budget | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=34816 K=5120 group=128 dtype=fp8a8 M=128` | - | 512021.19 | 442639.03 | 529990.66 | 5 | 8.5 | - | 179.17 MiB | 32 thread(s); 5 timed launch(es) within the 2 s host budget | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=64` | - | 505011.75 | 466016.10 | 514986.66 | 5 | 4.8 | - | 17.00 MiB | 32 thread(s); 5 timed launch(es) within the 2 s host budget | +| `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=4` | - | 503496.94 | 497465.44 | 527606.16 | 4 | 3.0 | - | 96.17 MiB | 32 thread(s); 4 timed launch(es) within the 2 s host budget | +| `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=2` | - | 497619.18 | 492614.51 | 500158.63 | 5 | 0.8 | - | 96.09 MiB | 32 thread(s); 5 timed launch(es) within the 2 s host budget | +| `gemm_nt_q_gated` | `ref_gemm_nt_q_gated` | libref | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=1` | - | 488584.49 | 479645.39 | 495787.56 | 5 | 1.7 | - | 96.05 MiB | 32 thread(s); 5 timed launch(es) within the 2 s host budget | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=4096 K=20480 dtype=bf16 M=260 tile=0` | - | 458001.31 | 289000.38 | 606001.03 | 5 | 34.6 | - | 172.19 MiB | 32 thread(s); 5 timed launch(es) within the 2 s host budget | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=17408 group=128 dtype=fp8a8 M=258` | - | 440003.71 | 395996.17 | 589993.89 | 5 | 22.0 | - | 91.95 MiB | 32 thread(s); 5 timed launch(es) within the 2 s host budget | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | - | 430998.61 | 251992.55 | 519005.26 | 6 | 31.0 | - | 10.19 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=129 tn=0` | - | 409489.26 | 345000.03 | 447732.01 | 6 | 12.5 | - | 74.82 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=10240 K=4096 group=128 dtype=fp8a8 M=512` | - | 402995.26 | 365035.01 | 542003.74 | 5 | 22.0 | - | 52.07 MiB | 32 thread(s); 5 timed launch(es) within the 2 s host budget | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=6144 group=128 dtype=fp8a8 M=512` | - | 388060.78 | 371003.51 | 496991.95 | 5 | 16.2 | - | 38.10 MiB | 32 thread(s); 5 timed launch(es) within the 2 s host budget | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 385497.37 | 257999.40 | 465001.35 | 6 | 26.8 | - | 100.20 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=128 ks=0 bk=0 nt=0` | - | 385497.01 | 246981.81 | 464990.44 | 6 | 28.3 | - | 74.79 MiB | 32 thread(s) | +| `logits_gemm` | `ref_logits_gemm` | libref | `n_vocab=131072 n_embd=4096 dtype=bf16 M=64` | - | 379002.78 | 319003.04 | 407980.88 | 6 | 11.7 | - | 1.03 GiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=8192 group=128 dtype=fp8a8 M=512` | - | 373764.71 | 269986.93 | 428957.17 | 6 | 21.3 | - | 40.13 MiB | 32 thread(s) | +| `sample_topk` | `ref_sample_topk` | libref | `n_vocab=248320 M=64` | - | 367844.86 | 234736.91 | 463294.02 | 6 | 31.1 | - | 60.69 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=8192 K=4096 group=128 dtype=fp8a8 M=512` | - | 359501.70 | 255992.96 | 409995.25 | 6 | 21.4 | - | 42.07 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=17408 group=128 dtype=fp8a8 M=128` | - | 359492.43 | 273990.35 | 414986.59 | 6 | 19.6 | - | 88.45 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 355066.64 | 290993.80 | 445853.11 | 6 | 21.8 | - | 98.20 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=512` | - | 351641.94 | 322703.11 | 451985.09 | 6 | 18.4 | - | 206.60 MiB | 32 thread(s) | +| `logits_gemm` | `avx_logits_gemm` | libavx | `n_vocab=248320 n_embd=5120 dtype=bf16 M=32` | - | 350523.34 | 314985.28 | 411971.54 | 6 | 13.8 | - | 2.40 GiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=512 tn=0` | - | 348994.28 | 315996.64 | 387985.58 | 6 | 10.3 | - | 88.20 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=16384 K=5120 group=128 dtype=fp8a8 M=129` | - | 347762.60 | 229571.25 | 419905.30 | 6 | 27.4 | - | 84.69 MiB | 32 thread(s) | +| `logits_gemm` | `ref_logits_gemm` | libref | `n_vocab=131072 n_embd=4096 dtype=bf16 M=56` | - | 337989.48 | 300012.69 | 377001.70 | 7 | 11.4 | - | 1.03 GiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=20480 K=5120 dtype=bf16 M=130 tile=0` | - | 323985.45 | 272002.53 | 373004.82 | 7 | 15.6 | - | 206.35 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=12288 K=5120 group=128 dtype=fp8a8 M=258` | - | 321001.05 | 258992.02 | 364993.26 | 7 | 16.5 | - | 67.35 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=16384 K=5120 group=128 dtype=fp8a8 M=128` | - | 320016.97 | 233986.90 | 442994.63 | 7 | 32.7 | - | 84.65 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=512` | - | 316997.69 | 244985.98 | 351986.22 | 7 | 16.9 | - | 10.00 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=17` | - | 308991.75 | 217011.85 | 398997.69 | 7 | 29.4 | - | 32.40 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=34816 K=5120 group=128 dtype=fp8a8 M=64` | - | 304986.96 | 255997.90 | 417001.40 | 7 | 26.4 | - | 174.59 MiB | 32 thread(s) | +| `logits_gemm` | `avx_logits_gemm` | libavx | `n_vocab=248320 n_embd=5120 dtype=bf16 M=64` | - | 302988.02 | 252002.23 | 405002.62 | 7 | 25.2 | - | 2.43 GiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=24576 group=128 dtype=fp8a8 M=258` | - | 301014.17 | 221995.40 | 343997.50 | 7 | 20.3 | - | 104.26 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=34816 K=5120 group=128 dtype=fp8a8 M=65` | - | 295996.31 | 236983.96 | 384993.29 | 7 | 25.0 | - | 174.66 MiB | 32 thread(s) | +| `logits_gemm` | `avx_logits_gemm` | libavx | `n_vocab=248320 n_embd=5120 dtype=bf16 M=16` | - | 295000.16 | 199983.31 | 341998.29 | 7 | 24.1 | - | 2.38 GiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 294995.59 | 217997.58 | 320997.16 | 7 | 17.5 | - | 96.91 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=4096 K=20480 dtype=bf16 M=512 tile=0` | - | 290495.19 | 220985.04 | 316003.68 | 8 | 16.4 | - | 184.00 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=5120 K=4608 dtype=bf16 act=none M=512` | - | 289463.88 | 213974.11 | 372001.29 | 7 | 27.3 | - | 59.51 MiB | 32 thread(s) | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | `N=240 K=4096 dtype=bf16 M=512` | - | 285683.05 | 184668.85 | 360495.02 | 8 | 30.8 | - | 8.22 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=4096 K=20480 dtype=bf16 M=130 tile=0` | - | 283097.78 | 215991.48 | 379990.46 | 8 | 29.0 | - | 166.09 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 278035.30 | 128973.63 | 313002.08 | 9 | 33.1 | - | 72.55 MiB | 32 thread(s) | +| `logits_gemm` | `avx_logits_gemm` | libavx | `n_vocab=248320 n_embd=5120 dtype=bf16 M=8` | - | 272017.82 | 188008.99 | 348989.88 | 8 | 29.6 | - | 2.38 GiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | - | 271928.44 | 169995.89 | 323991.16 | 8 | 28.3 | - | 32.38 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=65 ks=0 bk=0 nt=0` | - | 267195.67 | 117000.45 | 310983.88 | 9 | 36.3 | - | 72.58 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=17408 group=128 dtype=fp8a8 M=129` | - | 266985.52 | 146994.74 | 325997.10 | 8 | 33.5 | - | 88.48 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=10240 K=4096 group=128 dtype=fp8a8 M=258` | - | 262486.07 | 216998.52 | 310992.40 | 8 | 17.9 | - | 46.08 MiB | 32 thread(s) | +| `row_topk` | `ref_row_topk` | libref | `N=248320 R=32 dtype=bf16 M=56 nch=0 pt1=8` | - | 257554.95 | 186571.78 | 310938.56 | 8 | 24.1 | - | 26.55 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=33` | - | 256487.57 | 182992.64 | 302003.97 | 8 | 23.2 | - | 16.52 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 254007.34 | 210999.46 | 299992.73 | 9 | 17.5 | - | 49.53 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 250980.08 | 226997.24 | 296997.33 | 8 | 13.9 | - | 96.20 MiB | 32 thread(s) | +| `logits_gemm` | `avx_logits_gemm` | libavx | `n_vocab=248320 n_embd=5120 dtype=bf16 M=4` | - | 248991.45 | 142998.25 | 292996.78 | 9 | 30.1 | - | 2.37 GiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=10 splits=0` | - | 248481.40 | 196002.40 | 322994.13 | 8 | 25.6 | - | 32.24 MiB | 32 thread(s) | +| `attn_dense` | `ref_attn_dense` | libref | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=512` | - | 248149.66 | 228593.46 | 319011.18 | 8 | 18.2 | - | 320.01 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 247009.06 | 194997.39 | 284985.90 | 9 | 18.2 | - | 96.27 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=5376 group=128 dtype=fp8a8 M=512` | - | 242493.49 | 197992.89 | 347009.98 | 8 | 30.7 | - | 27.71 MiB | 32 thread(s) | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | `N=304 K=4096 dtype=bf16 M=512` | - | 240114.92 | 189582.08 | 259998.67 | 9 | 14.7 | - | 9.34 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=32` | - | 237998.61 | 181931.46 | 304999.53 | 9 | 25.9 | - | 16.50 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 232971.96 | 212992.97 | 257004.26 | 9 | 9.4 | - | 95.91 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=34816 K=5120 group=128 dtype=fp8a8 M=36` | - | 231995.35 | 150963.85 | 297019.93 | 9 | 31.5 | - | 172.59 MiB | 32 thread(s) | +| `attn_dense` | `ref_attn_dense` | libref | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=512` | - | 230543.64 | 204719.39 | 252154.78 | 9 | 10.3 | - | 288.01 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=512` | - | 227988.91 | 125959.23 | 326992.07 | 9 | 44.1 | - | 98.78 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=4608 K=4608 dtype=bf16 act=gelu M=512` | - | 224984.14 | 176987.65 | 281067.73 | 9 | 23.1 | - | 54.01 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5376 K=4096 group=128 dtype=fp8a8 M=512` | - | 223972.79 | 102990.10 | 286008.64 | 10 | 51.8 | - | 28.32 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=6144 group=128 dtype=fp8a8 M=258` | - | 222959.32 | 180994.98 | 334993.02 | 9 | 34.5 | - | 34.08 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 222007.33 | 219001.56 | 242995.61 | 9 | 5.4 | - | 95.77 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 221513.31 | 188995.34 | 243998.85 | 10 | 16.7 | - | 95.70 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=17408 group=128 dtype=fp8a8 M=65` | - | 212495.90 | 152850.88 | 215147.64 | 10 | 18.9 | - | 86.76 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=20480 K=5120 dtype=bf16 M=512 tile=0` | - | 211467.76 | 156679.24 | 251982.54 | 10 | 28.4 | - | 225.00 MiB | 32 thread(s) | +| `sample_topk` | `ref_sample_topk` | libref | `n_vocab=248320 M=32` | - | 211113.72 | 159276.96 | 255994.57 | 10 | 30.0 | - | 30.35 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=8192 group=128 dtype=fp8a8 M=258` | - | 210989.03 | 134985.49 | 293995.37 | 10 | 43.1 | - | 36.10 MiB | 32 thread(s) | +| `gdn_chunk_scan` | `ref_gdn_chunk_scan` | libref | `head_k=128 head_v=128 scale=0.0883883 M=512 chunk=64` | - | 204883.50 | 141716.30 | 250993.43 | 11 | 25.8 | - | 25.19 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 204793.62 | 119984.63 | 253999.25 | 10 | 37.6 | - | 71.57 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=258` | - | 203997.62 | 147998.11 | 234000.29 | 10 | 24.3 | - | 188.45 MiB | 32 thread(s) | +| `logits_gemm` | `ref_logits_gemm` | libref | `n_vocab=131072 n_embd=4096 dtype=bf16 M=32` | - | 203991.53 | 161994.65 | 223998.99 | 10 | 17.2 | - | 1.02 GiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=8192 K=4096 group=128 dtype=fp8a8 M=258` | - | 201996.48 | 163019.03 | 340009.64 | 9 | 43.8 | - | 37.07 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | - | 201546.96 | 130669.02 | 262548.86 | 10 | 33.7 | - | 16.00 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=20480 K=5120 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 200999.40 | 133998.53 | 258999.72 | 11 | 27.1 | - | 203.12 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=12288 K=5120 group=128 dtype=fp8a8 M=129` | - | 199486.07 | 144003.15 | 251990.89 | 10 | 29.8 | - | 63.68 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=260` | - | 199026.03 | 139974.97 | 249205.33 | 11 | 20.2 | - | 6.06 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=24576 group=128 dtype=fp8a8 M=129` | - | 198999.88 | 121000.96 | 307001.45 | 11 | 45.5 | - | 100.14 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=24576 group=128 dtype=fp8a8 M=512` | - | 196982.99 | 160999.58 | 212993.29 | 11 | 8.4 | - | 112.39 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=11` | - | 193996.40 | 99998.29 | 334028.12 | 10 | 67.0 | - | 32.26 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=16384 K=5120 group=128 dtype=fp8a8 M=64` | - | 193995.18 | 125984.39 | 244995.85 | 11 | 22.9 | - | 82.33 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=16384 K=5120 group=128 dtype=fp8a8 M=65` | - | 191994.71 | 108975.60 | 249008.83 | 12 | 36.2 | - | 82.37 MiB | 32 thread(s) | +| `logits_gemm` | `avx_logits_gemm` | libavx | `n_vocab=248320 n_embd=5120 dtype=bf16 M=1` | - | 190991.72 | 131985.45 | 244000.66 | 11 | 28.0 | - | 2.37 GiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 189000.21 | 134986.57 | 225031.90 | 11 | 21.2 | - | 48.78 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=20480 K=5120 dtype=bf16 M=65 tile=0` | - | 186980.40 | 122998.62 | 229987.08 | 11 | 25.9 | - | 203.17 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | - | 184307.40 | 158987.74 | 224996.82 | 11 | 17.1 | - | 7.09 MiB | 32 thread(s) | +| `logits_gemm` | `avx_logits_gemm` | libavx | `n_vocab=248320 n_embd=5120 dtype=bf16 M=2` | - | 182228.20 | 121016.60 | 239984.81 | 12 | 26.6 | - | 2.37 GiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=258 tn=0` | - | 179997.18 | 83995.41 | 197985.62 | 13 | 20.0 | - | 79.33 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=9 splits=0` | - | 177985.13 | 131997.38 | 233993.33 | 11 | 26.4 | - | 32.21 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=17408 group=128 dtype=fp8a8 M=64` | - | 176009.46 | 153986.39 | 223012.80 | 11 | 19.6 | - | 86.73 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=512` | - | 175984.71 | 146018.14 | 299959.99 | 11 | 42.3 | - | 98.59 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=8192 K=4096 group=128 dtype=fp8a8 M=129` | - | 175493.19 | 96995.70 | 200003.65 | 12 | 27.6 | - | 34.54 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=4096 K=20480 dtype=bf16 M=260 tile=0` | - | 174990.16 | 120987.76 | 224987.88 | 12 | 26.3 | - | 172.19 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | - | 174002.97 | 104010.82 | 230988.48 | 11 | 30.2 | - | 32.19 MiB | 32 thread(s) | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | `N=240 K=4096 dtype=bf16 M=256` | - | 173405.09 | 131085.07 | 193228.46 | 12 | 16.2 | - | 5.98 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=5120 K=4608 dtype=bf16 act=none M=256` | - | 173003.27 | 82437.81 | 221998.23 | 12 | 36.2 | - | 52.26 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=4096 K=20480 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 172983.62 | 77004.52 | 243997.94 | 13 | 43.9 | - | 163.00 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=258` | - | 166995.26 | 124998.93 | 186421.66 | 13 | 15.1 | - | 91.95 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=5120 K=1280 dtype=bf16 act=gelu M=512` | - | 166914.98 | 128899.15 | 200011.23 | 13 | 21.1 | - | 23.76 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=6144 group=128 dtype=fp8a8 M=128` | - | 159997.32 | 67675.33 | 214016.58 | 13 | 33.0 | - | 32.03 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=10240 K=4096 group=128 dtype=fp8a8 M=129` | - | 159004.05 | 144987.96 | 184995.81 | 13 | 11.6 | - | 43.04 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=12288 K=5120 group=128 dtype=fp8a8 M=128` | - | 158971.05 | 95007.26 | 239976.79 | 13 | 43.7 | - | 63.65 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=5376 group=128 dtype=fp8a8 M=258` | - | 157001.82 | 96000.56 | 194977.01 | 13 | 25.8 | - | 24.38 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 156134.05 | 128994.28 | 186015.69 | 13 | 17.3 | - | 70.94 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=4608 K=4608 dtype=bf16 act=gelu M=256` | - | 156072.35 | 80937.07 | 200702.31 | 13 | 24.6 | - | 47.26 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=24576 group=128 dtype=fp8a8 M=128` | - | 154991.02 | 98995.83 | 239985.88 | 11 | 33.2 | - | 100.11 MiB | 32 thread(s) | +| `sample_topk` | `ref_sample_topk` | libref | `n_vocab=248320 M=16` | - | 153998.25 | 100971.74 | 184998.92 | 14 | 18.4 | - | 15.17 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | - | 151490.12 | 97027.91 | 196982.67 | 14 | 17.2 | - | 32.14 MiB | 32 thread(s) | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | `N=304 K=4096 dtype=bf16 M=256` | - | 151195.30 | 104569.36 | 192045.27 | 14 | 20.5 | - | 7.05 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=16` | - | 150988.94 | 101998.82 | 197996.85 | 14 | 25.2 | - | 16.25 MiB | 32 thread(s) | +| `row_topk` | `ref_row_topk` | libref | `N=248320 R=32 dtype=bf16 M=32 nch=0 pt1=8` | - | 150762.54 | 113980.20 | 166373.54 | 14 | 13.7 | - | 15.17 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=10240 K=4096 group=128 dtype=fp8a8 M=128` | - | 149508.92 | 88000.92 | 194998.44 | 14 | 28.8 | - | 43.02 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=8192 K=4096 group=128 dtype=fp8a8 M=128` | - | 147998.19 | 103965.85 | 170021.88 | 14 | 14.2 | - | 34.52 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | - | 147618.39 | 105846.62 | 191803.96 | 14 | 23.4 | - | 10.19 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=6144 group=128 dtype=fp8a8 M=129` | - | 146995.58 | 94996.54 | 168009.85 | 14 | 11.6 | - | 32.04 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=4096 K=20480 dtype=bf16 M=65 tile=0` | - | 146952.62 | 80982.53 | 207006.51 | 14 | 35.4 | - | 163.05 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=16384 K=5120 group=128 dtype=fp8a8 M=36` | - | 145013.42 | 90026.35 | 164993.74 | 14 | 16.6 | - | 81.32 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 142994.81 | 94003.74 | 177030.57 | 15 | 14.3 | - | 48.30 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=17` | - | 142490.20 | 98980.48 | 218013.38 | 14 | 30.2 | - | 16.27 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=5120 K=4608 dtype=bf16 act=none M=128` | - | 137960.19 | 74782.52 | 163800.73 | 15 | 16.4 | - | 48.63 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=34816 K=5120 group=128 dtype=fp8a8 M=18` | - | 137486.05 | 99007.84 | 188998.43 | 14 | 23.3 | - | 171.31 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4608 K=4096 group=128 dtype=fp8a8 M=512` | - | 136996.76 | 93000.38 | 157002.57 | 16 | 15.7 | - | 24.56 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 136000.61 | 86018.33 | 162997.57 | 16 | 11.9 | - | 48.05 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 135462.41 | 60995.12 | 178996.47 | 16 | 19.9 | - | 32.12 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 134998.87 | 96012.85 | 180994.26 | 15 | 17.0 | - | 70.63 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 133000.90 | 70007.69 | 164995.43 | 16 | 19.5 | - | 70.45 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1280 K=5120 dtype=bf16 act=none M=512` | - | 132124.42 | 79120.42 | 170175.01 | 16 | 15.5 | - | 20.00 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=17408 group=128 dtype=fp8a8 M=36` | - | 130990.22 | 94970.89 | 158979.88 | 16 | 14.9 | - | 85.98 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=8192 group=128 dtype=fp8a8 M=129` | - | 130984.60 | 88994.44 | 174993.25 | 16 | 20.6 | - | 34.05 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=8192 group=128 dtype=fp8a8 M=512` | - | 130973.29 | 109006.32 | 140992.26 | 16 | 3.4 | - | 40.13 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | - | 128996.96 | 73993.28 | 179006.47 | 17 | 20.9 | - | 5.55 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5376 K=4096 group=128 dtype=fp8a8 M=258` | - | 128008.42 | 63999.76 | 184973.96 | 17 | 18.4 | - | 24.69 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=129` | - | 127994.17 | 89011.31 | 184001.21 | 15 | 27.0 | - | 179.24 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 127992.83 | 78020.95 | 154413.87 | 17 | 14.2 | - | 48.03 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=64` | - | 127570.33 | 121551.21 | 131127.10 | 16 | 1.2 | - | 3.00 MiB | 32 thread(s) | +| `logits_gemm` | `ref_logits_gemm` | libref | `n_vocab=131072 n_embd=4096 dtype=bf16 M=16` | - | 126988.47 | 87987.93 | 145990.41 | 16 | 10.2 | - | 1.01 GiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | - | 125994.08 | 80989.01 | 153992.55 | 17 | 25.0 | - | 13.00 MiB | 32 thread(s) | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=64` | - | 125982.37 | 103501.98 | 135540.18 | 17 | 5.0 | - | 173.56 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 124490.20 | 85990.00 | 163998.59 | 16 | 25.3 | - | 70.59 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=8192 group=128 dtype=fp8a8 M=128` | - | 123637.54 | 82994.22 | 161003.52 | 16 | 16.1 | - | 34.04 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=4608 dtype=bf16 act=none M=512` | - | 122461.16 | 79855.00 | 160557.91 | 17 | 18.5 | - | 59.51 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=258` | - | 122435.29 | 77988.08 | 170993.65 | 16 | 17.6 | - | 89.37 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=20480 K=5120 dtype=bf16 M=260 tile=0` | - | 121989.75 | 71993.84 | 170997.31 | 16 | 16.7 | - | 212.70 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 121978.59 | 55007.42 | 155008.67 | 18 | 22.1 | - | 70.35 MiB | 32 thread(s) | +| `sample_topk` | `ref_sample_topk` | libref | `n_vocab=131072 M=64` | - | 120915.76 | 107062.42 | 134991.15 | 17 | 7.1 | - | 32.07 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=512` | - | 119724.54 | 86363.30 | 139980.40 | 17 | 10.7 | - | 10.00 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=128` | - | 119000.88 | 72721.03 | 158997.55 | 17 | 19.3 | - | 179.17 MiB | 32 thread(s) | +| `ple_conv_bias` | `avx_ple_conv_bias` | libavx | `n=10240 width=4 dilation=1 dtype=bf16 M=512` | - | 118278.21 | 76223.91 | 138516.94 | 18 | 15.6 | - | 40.14 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 117990.74 | 63991.60 | 173008.92 | 17 | 27.5 | - | 70.38 MiB | 32 thread(s) | +| `attn_dense` | `ref_attn_dense` | libref | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=256` | - | 117207.97 | 76138.70 | 153984.56 | 17 | 15.4 | - | 160.01 KiB | 32 thread(s) | +| `gdn_chunk_scan` | `ref_gdn_chunk_scan` | libref | `head_k=128 head_v=128 scale=0.0883883 M=256 chunk=64` | - | 117022.82 | 59993.96 | 177998.28 | 18 | 29.0 | - | 15.59 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=512` | - | 116008.00 | 57995.13 | 188991.68 | 16 | 33.6 | - | 74.59 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=20480 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 116004.32 | 76001.20 | 154989.84 | 17 | 16.8 | - | 201.66 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3840 K=1280 dtype=bf16 act=none M=512` | - | 116002.17 | 88409.76 | 146987.76 | 17 | 10.9 | - | 18.13 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=34816 K=5120 group=128 dtype=fp8a8 M=8` | - | 113995.13 | 50995.97 | 144486.21 | 19 | 14.9 | - | 170.59 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=4096 K=20480 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 112002.55 | 54000.93 | 143989.87 | 19 | 20.1 | - | 161.59 MiB | 32 thread(s) | +| `row_topk` | `ref_row_topk` | libref | `N=248320 R=32 dtype=bf16 M=16 nch=0 pt1=8` | - | 111255.17 | 65385.99 | 139009.20 | 19 | 14.7 | - | 7.59 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=24576 group=128 dtype=fp8a8 M=65` | - | 111002.49 | 63002.65 | 207995.01 | 17 | 15.8 | - | 98.09 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 110996.34 | 64996.61 | 146996.63 | 18 | 18.0 | - | 47.87 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 110977.85 | 62995.16 | 147003.77 | 19 | 15.8 | - | 32.10 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=10240 K=4096 group=128 dtype=fp8a8 M=512` | - | 110049.13 | 78996.59 | 131997.99 | 19 | 11.8 | - | 52.07 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | - | 110018.49 | 77294.71 | 166157.42 | 17 | 15.9 | - | 7.09 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=34816 K=5120 group=128 dtype=fp8a8 M=9` | - | 109999.39 | 57995.47 | 143001.94 | 18 | 23.6 | - | 170.66 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 109998.70 | 71987.79 | 139013.87 | 19 | 15.9 | - | 47.84 MiB | 32 thread(s) | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=32` | - | 109595.18 | 72224.26 | 140692.98 | 18 | 11.0 | - | 171.79 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | - | 109027.31 | 59908.01 | 130205.59 | 20 | 18.4 | - | 5.55 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=260` | - | 108724.40 | 75330.36 | 136865.44 | 19 | 17.4 | - | 6.06 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=512 tn=0` | - | 108509.36 | 66008.97 | 167000.77 | 18 | 34.1 | - | 6.39 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=5376 group=128 dtype=fp8a8 M=129` | - | 107999.83 | 56991.09 | 123991.40 | 20 | 18.0 | - | 22.69 MiB | 32 thread(s) | +| `sample_topk` | `ref_sample_topk` | libref | `n_vocab=248320 M=4` | - | 107996.43 | 81988.70 | 146242.52 | 19 | 18.5 | - | 3.79 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=64` | - | 107984.99 | 83996.33 | 132998.33 | 19 | 9.3 | - | 174.59 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=11` | - | 107977.49 | 65986.97 | 144998.25 | 19 | 23.1 | - | 16.18 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=4304 dtype=bf16 act=none M=512` | - | 107071.93 | 76946.37 | 149944.38 | 18 | 15.2 | - | 15.91 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=130` | - | 107001.65 | 80512.04 | 114997.48 | 20 | 9.4 | - | 4.03 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 106990.45 | 60006.53 | 147985.52 | 19 | 21.0 | - | 47.92 MiB | 32 thread(s) | +| `sample_topk` | `ref_sample_topk` | libref | `n_vocab=248320 M=8` | - | 106964.41 | 82800.26 | 169551.49 | 17 | 29.1 | - | 7.59 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=512` | - | 105222.97 | 45522.51 | 124879.61 | 20 | 21.2 | - | 19.00 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=6144 group=128 dtype=fp8a8 M=64` | - | 104021.80 | 80991.89 | 134995.52 | 19 | 7.2 | - | 31.02 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=12288 K=5120 group=128 dtype=fp8a8 M=65` | - | 103981.39 | 70997.29 | 153990.39 | 19 | 27.4 | - | 61.86 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=512` | - | 103494.67 | 68997.19 | 121001.10 | 20 | 12.6 | - | 38.10 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=8192 K=4096 group=128 dtype=fp8a8 M=65` | - | 102999.97 | 69989.53 | 130009.65 | 20 | 19.9 | - | 33.28 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=1280 dtype=bf16 act=gelu M=512` | - | 102929.82 | 36356.95 | 131983.15 | 20 | 19.6 | - | 23.76 MiB | 32 thread(s) | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | `N=240 K=4096 dtype=bf16 M=128` | - | 102549.92 | 48725.96 | 126634.25 | 20 | 20.0 | - | 4.87 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 102500.95 | 90985.65 | 114995.58 | 20 | 7.3 | - | 12.13 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4608 K=4608 dtype=bf16 act=gelu M=512` | - | 102129.96 | 47998.30 | 110997.18 | 20 | 13.5 | - | 54.01 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=24576 group=128 dtype=fp8a8 M=64` | - | 101995.17 | 56992.24 | 170987.99 | 18 | 27.0 | - | 98.06 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=4608 K=4608 dtype=bf16 act=gelu M=128` | - | 101989.10 | 84600.19 | 117977.76 | 20 | 11.3 | - | 43.88 MiB | 32 thread(s) | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=16` | - | 100378.65 | 70089.43 | 131990.76 | 20 | 14.2 | - | 170.91 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=5120 K=1280 dtype=bf16 act=gelu M=256` | - | 100202.71 | 44085.72 | 124979.65 | 20 | 19.2 | - | 18.13 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=4096 group=128 dtype=fp8a8 M=512` | - | 100001.29 | 77980.57 | 148431.43 | 19 | 17.5 | - | 22.06 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=24576 K=4096 group=128 dtype=fp8a8 M=64` | - | 99496.09 | 65012.49 | 105996.96 | 20 | 17.1 | - | 99.27 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=24576 group=128 dtype=fp8a8 M=258` | - | 98993.00 | 63991.03 | 110996.52 | 20 | 9.1 | - | 104.26 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 97997.17 | 77983.42 | 118977.86 | 20 | 12.3 | - | 100.20 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=8192 K=4096 group=128 dtype=fp8a8 M=512` | - | 97498.78 | 61009.52 | 123973.55 | 20 | 19.0 | - | 42.07 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=5376 group=128 dtype=fp8a8 M=128` | - | 97484.42 | 59982.00 | 138004.55 | 20 | 27.2 | - | 22.68 MiB | 32 thread(s) | +| `ple_conv_bias` | `ref_ple_conv_bias` | libref | `n=10240 width=4 dilation=1 dtype=bf16 M=512` | - | 96467.29 | 53806.17 | 101800.87 | 20 | 16.5 | - | 40.14 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=65` | - | 95996.39 | 56001.56 | 108015.39 | 20 | 14.1 | - | 174.66 MiB | 32 thread(s) | +| `logits_gemm` | `ref_logits_gemm` | libref | `n_vocab=131072 n_embd=4096 dtype=bf16 M=8` | - | 95478.14 | 63010.95 | 107999.59 | 20 | 17.8 | - | 1.00 GiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=129` | - | 95009.74 | 74982.83 | 175817.88 | 18 | 16.3 | - | 84.69 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=16384 K=5120 group=128 dtype=fp8a8 M=18` | - | 94504.74 | 53023.08 | 111002.96 | 20 | 15.9 | - | 80.66 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=20480 K=5120 dtype=bf16 M=130 tile=0` | - | 94488.71 | 45999.53 | 113979.18 | 20 | 16.4 | - | 206.35 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=17` | - | 93647.92 | 53568.82 | 140932.82 | 20 | 26.0 | - | 32.40 MiB | 32 thread(s) | +| `logits_gemm` | `avx_logits_gemm` | libavx | `n_vocab=131072 n_embd=4096 dtype=bf16 M=64` | - | 93635.08 | 62985.70 | 114983.18 | 20 | 10.1 | - | 1.03 GiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=34816 K=5120 group=128 dtype=fp8a8 M=4` | - | 93369.58 | 41993.75 | 111002.77 | 20 | 18.1 | - | 170.31 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=12288 K=5120 group=128 dtype=fp8a8 M=64` | - | 92989.88 | 58998.44 | 145988.50 | 19 | 26.4 | - | 61.83 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3456 K=1152 dtype=bf16 act=none M=512` | - | 92713.33 | 35007.80 | 115592.76 | 20 | 22.6 | - | 15.48 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1280 K=5120 dtype=bf16 act=none M=256` | - | 92523.61 | 62994.46 | 129999.15 | 20 | 13.0 | - | 16.25 MiB | 32 thread(s) | +| `sample_topk` | `avx_sample_topk` | libavx | `n_vocab=248320 M=64` | - | 91751.24 | 63038.00 | 147161.43 | 20 | 21.3 | - | 60.69 MiB | 32 thread(s) | +| `sample_topk` | `ref_sample_topk` | libref | `n_vocab=248320 M=1` | - | 91650.35 | 63270.86 | 114168.09 | 20 | 12.8 | - | 971.09 KiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=10` | - | 91482.53 | 63986.38 | 130008.07 | 20 | 26.8 | - | 16.16 MiB | 32 thread(s) | +| `gdn_conv_update` | `ref_gdn_conv_update` | libref | `head_k=128 head_v=128 conv_width=4 q_len=512` | - | 91248.77 | 48432.04 | 109281.65 | 20 | 12.2 | - | 30.12 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=5120 K=4608 dtype=bf16 act=none M=32` | - | 90606.57 | 53988.84 | 107994.38 | 20 | 19.0 | - | 45.92 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=8192 K=4096 group=128 dtype=fp8a8 M=129` | - | 90003.82 | 60005.40 | 105001.55 | 20 | 5.0 | - | 34.54 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=10240 K=4096 group=128 dtype=fp8a8 M=65` | - | 89998.69 | 39993.99 | 122008.31 | 20 | 30.0 | - | 41.54 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=129` | - | 89989.80 | 62996.14 | 98999.90 | 20 | 13.3 | - | 88.48 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=18` | - | 88998.03 | 59997.23 | 99997.34 | 20 | 15.2 | - | 171.31 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 87996.89 | 62006.71 | 96989.66 | 20 | 10.8 | - | 98.20 MiB | 32 thread(s) | +| `row_topk` | `ref_row_topk` | libref | `N=248320 R=32 dtype=bf16 M=8 nch=0 pt1=8` | - | 87829.42 | 50023.58 | 106884.23 | 20 | 17.0 | - | 3.79 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=9` | - | 87501.59 | 59985.63 | 113978.89 | 20 | 16.0 | - | 16.14 MiB | 32 thread(s) | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=8` | - | 87491.99 | 65102.38 | 104002.08 | 20 | 13.7 | - | 170.46 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3840 K=1280 dtype=bf16 act=none M=512` | - | 87396.78 | 69193.30 | 103833.13 | 20 | 13.4 | - | 18.13 MiB | 32 thread(s) | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=1` | - | 86999.45 | 31999.66 | 142014.21 | 20 | 32.8 | - | 170.08 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | - | 86759.69 | 48299.08 | 131489.24 | 20 | 41.9 | - | 32.38 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=128 dtype=fp8a8 M=512` | - | 86017.13 | 54000.88 | 111966.21 | 20 | 22.7 | - | 8.58 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=10240 K=4096 group=128 dtype=fp8a8 M=64` | - | 86001.18 | 59446.01 | 105011.21 | 20 | 14.0 | - | 41.51 MiB | 32 thread(s) | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=4` | - | 85854.78 | 47992.07 | 106274.66 | 20 | 14.0 | - | 170.24 MiB | 32 thread(s) | +| `logits_gemm` | `avx_logits_gemm` | libavx | `n_vocab=131072 n_embd=4096 dtype=bf16 M=56` | - | 84996.56 | 56996.06 | 92999.98 | 20 | 16.5 | - | 1.03 GiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 84994.83 | 64997.34 | 113982.88 | 20 | 11.8 | - | 11.75 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=17408 group=128 dtype=fp8a8 M=18` | - | 83999.42 | 61994.24 | 116995.71 | 20 | 14.9 | - | 85.49 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=4304 dtype=bf16 act=none M=256` | - | 83995.86 | 58980.94 | 97907.21 | 20 | 12.5 | - | 12.69 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=129 tn=0` | - | 83995.39 | 44006.89 | 98995.31 | 20 | 15.5 | - | 74.82 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=8` | - | 83992.41 | 53001.64 | 95993.29 | 20 | 7.7 | - | 170.59 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=8192 K=4096 group=128 dtype=fp8a8 M=64` | - | 83504.86 | 60001.20 | 98999.07 | 20 | 16.2 | - | 33.26 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=20480 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 83471.98 | 35218.66 | 108005.45 | 20 | 34.1 | - | 200.78 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=130` | - | 83441.43 | 71395.66 | 99707.67 | 20 | 10.7 | - | 4.03 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=6144 group=128 dtype=fp8a8 M=65` | - | 82985.38 | 52977.71 | 126880.06 | 20 | 24.2 | - | 31.03 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3840 K=1280 dtype=bf16 act=none M=256` | - | 82328.52 | 54024.97 | 95990.59 | 20 | 15.0 | - | 13.76 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=10 splits=0` | - | 82083.56 | 37462.37 | 130768.37 | 20 | 25.2 | - | 32.24 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=8192 group=128 dtype=fp8a8 M=64` | - | 81993.24 | 56985.10 | 103997.20 | 20 | 11.4 | - | 33.02 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=8192 K=4096 group=128 dtype=fp8a8 M=128` | - | 81992.17 | 60012.35 | 88996.22 | 20 | 8.5 | - | 34.52 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=5120 K=4608 dtype=bf16 act=none M=16` | - | 81718.96 | 33046.54 | 97543.66 | 20 | 9.8 | - | 45.46 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 81504.52 | 54001.89 | 104990.71 | 20 | 14.1 | - | 12.07 MiB | 32 thread(s) | +| `gdn_chunk_scan` | `ref_gdn_chunk_scan` | libref | `head_k=128 head_v=128 scale=0.0883883 M=128 chunk=64` | - | 81277.15 | 49176.93 | 101843.24 | 20 | 12.7 | - | 10.80 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1280 K=2304 dtype=bf16 M=512 tile=0` | - | 80994.51 | 53994.53 | 96001.21 | 20 | 6.8 | - | 9.12 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=8192 group=128 dtype=fp8a8 M=65` | - | 80992.71 | 51007.46 | 88999.24 | 20 | 11.7 | - | 33.04 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=128 ks=0 bk=0 nt=0` | - | 80989.81 | 38004.36 | 95996.14 | 20 | 16.7 | - | 74.79 MiB | 32 thread(s) | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | `N=304 K=4096 dtype=bf16 M=128` | - | 80975.27 | 55083.17 | 88110.93 | 20 | 10.1 | - | 5.90 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=5120 K=4608 dtype=bf16 act=none M=64` | - | 80517.06 | 48005.50 | 98915.12 | 20 | 14.2 | - | 46.82 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=128` | - | 80502.05 | 47995.92 | 114005.49 | 20 | 23.6 | - | 84.65 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=11` | - | 80190.49 | 40526.61 | 119001.86 | 20 | 28.2 | - | 32.26 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=20480 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 80026.90 | 40001.70 | 104982.14 | 20 | 20.6 | - | 200.83 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=4608 dtype=bf16 act=none M=256` | - | 79721.89 | 47994.93 | 113001.29 | 20 | 29.5 | - | 52.26 MiB | 32 thread(s) | +| `attn_dense` | `ref_attn_dense` | libref | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=256` | - | 79386.22 | 61288.01 | 89304.27 | 20 | 11.4 | - | 144.01 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=4096 group=128 dtype=fp8a8 M=512` | - | 78999.03 | 49094.18 | 99978.30 | 20 | 22.1 | - | 7.06 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=4304 dtype=bf16 act=none M=512` | - | 78786.71 | 49991.59 | 91009.23 | 20 | 11.4 | - | 15.91 MiB | 32 thread(s) | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=2` | - | 78600.69 | 56012.65 | 84994.40 | 20 | 6.3 | - | 170.13 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=9` | - | 78486.40 | 51003.96 | 95296.55 | 20 | 12.8 | - | 170.66 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=65` | - | 78217.17 | 71416.15 | 101567.91 | 20 | 4.5 | - | 3.02 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=1280 dtype=bf16 act=gelu M=256` | - | 77960.95 | 30337.94 | 96099.01 | 20 | 24.6 | - | 18.13 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3840 K=1280 dtype=bf16 act=none M=256` | - | 77675.46 | 62998.23 | 92227.12 | 20 | 12.0 | - | 13.76 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | - | 77490.59 | 55016.26 | 89991.06 | 20 | 18.1 | - | 4.75 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=36` | - | 77482.94 | 43006.13 | 89013.87 | 20 | 11.0 | - | 172.59 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=65` | - | 76869.48 | 61994.54 | 89988.41 | 20 | 15.0 | - | 82.37 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=12288 K=5120 group=128 dtype=fp8a8 M=36` | - | 76506.13 | 42995.23 | 101985.67 | 20 | 20.9 | - | 61.03 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 76373.59 | 51981.57 | 92991.17 | 20 | 8.5 | - | 96.91 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=128` | - | 76003.60 | 53993.24 | 93988.75 | 20 | 17.1 | - | 88.45 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | - | 75987.29 | 58989.86 | 89987.85 | 20 | 9.9 | - | 4.77 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=64` | - | 75785.29 | 44074.47 | 89978.06 | 20 | 17.2 | - | 82.33 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3840 K=1280 dtype=bf16 act=none M=64` | - | 75510.94 | 62993.38 | 85966.02 | 20 | 10.5 | - | 10.48 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1280 K=5120 dtype=bf16 act=none M=512` | - | 75235.48 | 52758.49 | 89995.96 | 20 | 17.0 | - | 20.00 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=8192 K=4096 group=128 dtype=fp8a8 M=65` | - | 75002.94 | 59996.06 | 89985.48 | 20 | 12.6 | - | 33.28 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=10240 K=4096 group=128 dtype=fp8a8 M=258` | - | 74998.90 | 55989.18 | 89995.58 | 20 | 7.3 | - | 46.08 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1280 K=1280 dtype=bf16 act=none M=512` | - | 74992.72 | 38456.04 | 99000.55 | 20 | 9.2 | - | 6.88 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5376 group=128 dtype=fp8a8 M=512` | - | 74989.45 | 47993.12 | 90013.44 | 20 | 18.7 | - | 27.71 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 74953.93 | 53205.93 | 92967.56 | 20 | 9.9 | - | 11.36 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=24576 group=128 dtype=fp8a8 M=32` | - | 74505.52 | 31999.47 | 101004.41 | 20 | 22.1 | - | 97.04 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8 splits=0` | - | 74503.18 | 48910.29 | 94982.61 | 20 | 24.8 | - | 16.13 MiB | 32 thread(s) | +| `gated_quant_fp8` | `ref_gated_quant_fp8` | libref | `n=17408 group=128 dtype=bf16 act=silu M=512` | - | 74203.79 | 43693.03 | 101996.65 | 20 | 22.4 | - | 59.77 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=4608 K=4608 dtype=bf16 act=gelu M=64` | - | 74109.32 | 44217.19 | 83217.49 | 20 | 14.7 | - | 42.20 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=256` | - | 74046.39 | 34623.74 | 96654.73 | 20 | 22.0 | - | 14.23 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=512` | - | 74016.63 | 41076.91 | 96700.07 | 20 | 14.2 | - | 19.00 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3840 K=1280 dtype=bf16 act=none M=8` | - | 73529.94 | 61991.80 | 90055.81 | 20 | 9.9 | - | 9.52 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=258` | - | 72992.38 | 56001.20 | 94993.76 | 20 | 15.1 | - | 34.08 MiB | 32 thread(s) | +| `logits_gemm` | `ref_logits_gemm` | libref | `n_vocab=131072 n_embd=4096 dtype=bf16 M=4` | - | 72473.50 | 40995.19 | 87996.00 | 20 | 29.0 | - | 1.00 GiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4608 K=4096 group=128 dtype=fp8a8 M=258` | - | 72069.87 | 43995.48 | 86012.49 | 20 | 23.6 | - | 21.31 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 71998.15 | 49949.84 | 88990.70 | 20 | 16.6 | - | 49.53 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 71997.42 | 61013.85 | 81020.30 | 20 | 11.1 | - | 96.20 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=20480 K=5120 dtype=bf16 M=65 tile=0` | - | 71997.27 | 35998.62 | 86012.81 | 20 | 13.2 | - | 203.17 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1280 K=1280 dtype=bf16 act=none M=512` | - | 71992.78 | 44969.48 | 89854.18 | 20 | 14.1 | - | 6.88 MiB | 32 thread(s) | +| `sample_topk` | `avx_sample_topk` | libavx | `n_vocab=248320 M=32` | - | 71992.29 | 46006.09 | 80984.91 | 20 | 16.5 | - | 30.35 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3840 K=1280 dtype=bf16 act=none M=128` | - | 71988.19 | 62996.38 | 86006.30 | 20 | 8.3 | - | 11.57 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4608 K=4608 dtype=bf16 act=gelu M=256` | - | 71486.32 | 53993.13 | 80996.60 | 20 | 8.0 | - | 47.26 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 71470.95 | 59999.19 | 77986.52 | 20 | 6.3 | - | 96.27 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=1280 dtype=bf16 act=gelu M=128` | - | 71154.80 | 35992.63 | 93312.84 | 20 | 14.7 | - | 15.32 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 71007.21 | 44019.36 | 84106.30 | 20 | 14.8 | - | 11.71 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=20480 K=5120 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 70996.51 | 35989.21 | 80999.12 | 20 | 8.4 | - | 203.12 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=128` | - | 70987.71 | 51004.52 | 89998.18 | 20 | 13.7 | - | 32.03 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1280 K=5120 dtype=bf16 act=none M=128` | - | 70978.67 | 43028.03 | 86355.43 | 20 | 19.7 | - | 14.38 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1280 K=1280 dtype=bf16 act=none M=256` | - | 70967.91 | 35000.71 | 93766.93 | 20 | 23.4 | - | 5.00 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1280 K=5120 dtype=bf16 act=none M=64` | - | 70942.86 | 38999.92 | 82050.77 | 20 | 14.7 | - | 13.44 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3456 K=1152 dtype=bf16 act=none M=256` | - | 70743.85 | 37084.90 | 95072.06 | 20 | 23.6 | - | 11.54 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=4` | - | 70728.71 | 28999.76 | 92000.74 | 20 | 25.4 | - | 170.31 MiB | 32 thread(s) | +| `moe_gather` | `ref_moe_gather` | libref | `n=1024 top_k=9 dtype=bf16 act=none M=512` | - | 70604.25 | 49851.01 | 100075.72 | 20 | 19.2 | - | 11.03 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=258` | - | 70498.86 | 35992.12 | 83008.60 | 20 | 19.1 | - | 67.35 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=8192 K=4096 group=128 dtype=fp8a8 M=258` | - | 70498.23 | 53979.08 | 90995.99 | 20 | 24.8 | - | 37.07 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=4096 K=20480 dtype=bf16 M=65 tile=0` | - | 70491.34 | 51990.83 | 84003.78 | 20 | 14.9 | - | 163.05 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4608 K=4608 dtype=bf16 act=gelu M=16` | - | 70486.56 | 17074.93 | 78795.25 | 20 | 15.0 | - | 40.93 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=128` | - | 70402.13 | 51986.83 | 77995.33 | 20 | 10.1 | - | 63.65 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=4608 dtype=bf16 act=none M=128` | - | 70041.77 | 48952.13 | 97998.41 | 20 | 18.0 | - | 48.63 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=24576 group=128 dtype=fp8a8 M=33` | - | 70000.77 | 40983.83 | 116003.11 | 20 | 27.1 | - | 97.07 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=6144 group=128 dtype=fp8a8 M=36` | - | 69998.22 | 25904.38 | 86005.43 | 20 | 26.4 | - | 30.57 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=36` | - | 69965.10 | 43994.37 | 81001.21 | 20 | 12.9 | - | 81.32 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1536 dtype=bf16 act=none M=128` | - | 69906.76 | 57084.95 | 76995.95 | 20 | 10.6 | - | 4.31 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1280 K=5120 dtype=bf16 act=none M=256` | - | 69887.76 | 48800.52 | 87861.02 | 20 | 13.5 | - | 16.25 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1280 K=5120 dtype=bf16 act=none M=16` | - | 69470.08 | 17993.61 | 77985.14 | 20 | 18.0 | - | 12.74 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=64` | - | 69381.20 | 41989.31 | 82994.63 | 20 | 15.9 | - | 86.73 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=18` | - | 69012.43 | 54005.61 | 88972.18 | 20 | 16.0 | - | 80.66 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=4096 group=128 dtype=fp8a8 M=258` | - | 69007.45 | 36997.72 | 80996.36 | 20 | 23.2 | - | 19.06 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=258 tn=0` | - | 68991.92 | 42003.40 | 80002.51 | 20 | 13.8 | - | 4.62 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 68986.10 | 56984.90 | 74002.51 | 20 | 8.0 | - | 95.91 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1280 K=1280 dtype=bf16 act=none M=128` | - | 68934.71 | 41998.56 | 82986.33 | 20 | 17.4 | - | 4.06 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=16384 K=5120 group=128 dtype=fp8a8 M=9` | - | 68764.30 | 47001.77 | 93010.58 | 20 | 14.6 | - | 80.34 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=8192 group=128 dtype=fp8a8 M=33` | - | 68513.30 | 54828.46 | 77997.63 | 20 | 8.8 | - | 32.53 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=512` | - | 68498.79 | 41989.36 | 87008.77 | 20 | 19.0 | - | 8.50 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=12288 group=128 dtype=fp8a8 M=64` | - | 68491.37 | 48003.31 | 78002.09 | 20 | 8.8 | - | 49.28 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3840 K=1280 dtype=bf16 act=none M=16` | - | 68481.26 | 41899.47 | 92012.60 | 20 | 23.4 | - | 9.66 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=1536 dtype=bf16 act=none M=512` | - | 68396.19 | 23110.15 | 75157.95 | 20 | 9.4 | - | 7.13 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=4304 dtype=bf16 act=none M=256` | - | 67896.78 | 48195.02 | 83776.48 | 20 | 19.9 | - | 12.69 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=4096 K=20480 dtype=bf16 M=130 tile=0` | - | 67500.01 | 51983.72 | 84005.23 | 20 | 20.0 | - | 166.09 MiB | 32 thread(s) | +| `logits_gemm` | `avx_logits_gemm` | libavx | `n_vocab=131072 n_embd=4096 dtype=bf16 M=16` | - | 67488.44 | 46980.26 | 82977.30 | 20 | 17.8 | - | 1.01 GiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5376 K=4096 group=128 dtype=fp8a8 M=129` | - | 67488.20 | 29943.38 | 108016.35 | 20 | 31.1 | - | 22.84 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5376 K=4096 group=128 dtype=fp8a8 M=128` | - | 67486.20 | 43991.79 | 123997.17 | 20 | 31.1 | - | 22.83 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 67485.43 | 44234.05 | 95992.31 | 20 | 27.4 | - | 32.03 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=1280 dtype=bf16 act=gelu M=16` | - | 67367.07 | 49224.99 | 80988.84 | 20 | 12.1 | - | 12.86 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=1280 dtype=bf16 act=gelu M=64` | - | 67333.45 | 31168.58 | 83985.26 | 20 | 16.1 | - | 13.92 MiB | 32 thread(s) | +| `row_topk` | `ref_row_topk` | libref | `N=248320 R=32 dtype=bf16 M=4 nch=0 pt1=8` | - | 67283.63 | 40453.65 | 99971.50 | 20 | 25.6 | - | 1.90 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=24576 K=4096 group=128 dtype=fp8a8 M=33` | - | 67006.27 | 37995.91 | 72984.36 | 20 | 8.2 | - | 97.69 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=4096 K=20480 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 67000.97 | 43997.64 | 80999.40 | 20 | 11.2 | - | 160.75 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=8` | - | 66996.77 | 44993.68 | 80994.15 | 20 | 13.4 | - | 80.30 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=16384 K=5120 group=128 dtype=fp8a8 M=8` | - | 66503.98 | 43001.29 | 80008.26 | 20 | 18.1 | - | 80.30 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=129` | - | 66499.76 | 53997.95 | 72232.38 | 20 | 7.5 | - | 32.04 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=33` | - | 66492.01 | 64069.84 | 67731.78 | 20 | 1.0 | - | 2.52 MiB | 32 thread(s) | +| `ple_conv_bias` | `avx_ple_conv_bias` | libavx | `n=10240 width=4 dilation=1 dtype=bf16 M=256` | - | 66389.38 | 45712.38 | 81286.62 | 20 | 20.5 | - | 20.14 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 65995.59 | 50986.01 | 80992.28 | 20 | 18.2 | - | 95.70 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1280 K=1280 dtype=bf16 act=none M=16` | - | 65991.29 | 37037.49 | 79001.34 | 20 | 19.7 | - | 3.24 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=5120 K=1280 dtype=bf16 act=gelu M=128` | - | 65988.10 | 42324.70 | 80983.58 | 20 | 13.5 | - | 15.32 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=1` | - | 65813.83 | 41992.74 | 75002.98 | 20 | 12.2 | - | 170.09 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=65` | - | 65487.08 | 44986.46 | 84018.36 | 20 | 13.8 | - | 86.76 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1280 K=5120 dtype=bf16 act=none M=128` | - | 65068.04 | 18103.80 | 98996.03 | 20 | 41.5 | - | 14.38 MiB | 32 thread(s) | +| `row_topk` | `ref_row_topk` | libref | `N=248320 R=32 dtype=bf16 M=1 nch=0 pt1=8` | - | 64994.74 | 41320.49 | 79822.94 | 20 | 18.5 | - | 485.50 KiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3840 K=1280 dtype=bf16 act=none M=128` | - | 64985.50 | 42008.32 | 72105.68 | 20 | 7.7 | - | 11.57 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4608 K=4608 dtype=bf16 act=gelu M=128` | - | 64690.07 | 44996.04 | 74581.62 | 20 | 13.9 | - | 43.88 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=64` | - | 64496.55 | 57986.51 | 69988.10 | 20 | 7.0 | - | 3.00 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=4608 dtype=bf16 act=none M=32` | - | 64453.87 | 42999.71 | 100710.24 | 20 | 30.2 | - | 45.92 MiB | 32 thread(s) | +| `row_topk` | `avx_row_topk` | libavx | `N=248320 R=32 dtype=bf16 M=56 nch=0 pt1=8` | - | 64306.97 | 49849.89 | 75466.68 | 20 | 14.0 | - | 26.55 MiB | 32 thread(s) | +| `logits_gemm` | `ref_logits_gemm` | libref | `n_vocab=131072 n_embd=4096 dtype=bf16 M=2` | - | 63999.26 | 38996.10 | 76983.59 | 20 | 15.6 | - | 1.00 GiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=20480 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 63998.85 | 41005.50 | 74013.78 | 20 | 13.3 | - | 200.78 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=4304 dtype=bf16 act=none M=128` | - | 63530.44 | 49052.74 | 88923.52 | 20 | 14.5 | - | 11.07 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1280 K=1280 dtype=bf16 act=none M=32` | - | 63505.69 | 54010.06 | 77952.35 | 20 | 9.4 | - | 3.36 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=24576 K=4096 group=128 dtype=fp8a8 M=32` | - | 63497.54 | 31000.08 | 77989.90 | 20 | 26.0 | - | 97.64 MiB | 32 thread(s) | +| `row_topk` | `ref_row_topk` | libref | `N=248320 R=32 dtype=bf16 M=2 nch=0 pt1=8` | - | 63050.71 | 37691.17 | 85326.80 | 20 | 19.9 | - | 971.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3840 K=1280 dtype=bf16 act=none M=32` | - | 63004.34 | 39085.27 | 77000.52 | 20 | 11.1 | - | 9.93 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=8192 K=4096 group=128 dtype=fp8a8 M=32` | - | 62998.05 | 53989.52 | 75004.06 | 20 | 9.5 | - | 32.63 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1280 K=5120 dtype=bf16 act=none M=32` | - | 62996.39 | 35998.14 | 80995.50 | 20 | 22.8 | - | 12.97 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=1536 dtype=bf16 act=none M=256` | - | 62995.57 | 41991.01 | 83994.33 | 20 | 16.6 | - | 5.25 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=34816 K=5120 group=128 dtype=fp8a8 M=1` | - | 62995.08 | 44999.70 | 83978.81 | 20 | 10.3 | - | 170.09 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4608 K=4608 dtype=bf16 act=gelu M=8` | - | 62994.30 | 44998.14 | 78002.90 | 20 | 13.5 | - | 40.72 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=8` | - | 62993.30 | 47996.49 | 82016.29 | 20 | 11.9 | - | 85.23 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=4304 dtype=bf16 act=none M=16` | - | 62993.26 | 45001.05 | 77989.02 | 20 | 12.7 | - | 9.66 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=4096 K=20480 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 62993.17 | 37997.87 | 71993.68 | 20 | 11.1 | - | 163.00 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=65` | - | 62993.03 | 39995.54 | 72989.88 | 20 | 19.0 | - | 3.02 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=256` | - | 62992.62 | 18623.16 | 72992.45 | 20 | 13.7 | - | 14.23 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1536 dtype=bf16 act=none M=64` | - | 62991.34 | 35991.67 | 74049.62 | 20 | 16.7 | - | 3.85 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 62990.98 | 53990.44 | 69999.99 | 20 | 6.3 | - | 95.77 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=4096 K=20480 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 62990.76 | 42997.06 | 99014.81 | 20 | 30.9 | - | 160.80 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=8192 group=128 dtype=fp8a8 M=258` | - | 62988.23 | 44995.66 | 71997.54 | 20 | 4.8 | - | 36.10 MiB | 32 thread(s) | +| `sample_topk` | `ref_sample_topk` | libref | `n_vocab=131072 M=32` | - | 62880.42 | 42783.93 | 75447.10 | 20 | 16.4 | - | 16.03 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1152 dtype=bf16 act=none M=512` | - | 62660.93 | 35965.26 | 81990.01 | 20 | 14.4 | - | 5.91 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=65` | - | 62510.19 | 44994.80 | 80946.12 | 20 | 14.4 | - | 31.03 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | - | 62490.33 | 46985.08 | 74986.59 | 20 | 13.6 | - | 6.72 MiB | 32 thread(s) | +| `logits_gemm` | `avx_logits_gemm` | libavx | `n_vocab=131072 n_embd=4096 dtype=bf16 M=32` | - | 62489.02 | 47995.84 | 105991.52 | 20 | 30.4 | - | 1.02 GiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1280 K=1280 dtype=bf16 act=none M=64` | - | 62424.54 | 24053.42 | 77917.31 | 20 | 14.4 | - | 3.60 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3456 K=1152 dtype=bf16 act=none M=256` | - | 62192.60 | 45628.85 | 69629.95 | 20 | 8.3 | - | 11.54 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 62001.22 | 53995.29 | 117696.64 | 20 | 30.6 | - | 32.05 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=20480 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 61998.49 | 31000.42 | 77990.81 | 20 | 25.0 | - | 200.83 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=34816 K=5120 group=128 dtype=fp8a8 M=2` | - | 61993.27 | 46004.93 | 74993.71 | 20 | 13.7 | - | 170.16 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 61985.84 | 46647.17 | 64335.46 | 20 | 7.3 | - | 11.28 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=32` | - | 61621.46 | 61530.29 | 62463.16 | 11 | 0.8 | - | 2.50 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1536 dtype=bf16 act=none M=256` | - | 61611.89 | 42940.78 | 83993.46 | 20 | 9.8 | - | 5.25 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=4304 dtype=bf16 act=none M=128` | - | 61527.35 | 40441.65 | 85031.21 | 20 | 13.0 | - | 11.07 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=17408 group=128 dtype=fp8a8 M=9` | - | 61496.64 | 50980.36 | 70003.46 | 20 | 11.4 | - | 85.25 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=4608 dtype=bf16 act=none M=8` | - | 61488.86 | 33991.69 | 83007.72 | 20 | 21.1 | - | 45.24 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | - | 61160.50 | 46996.45 | 97290.92 | 20 | 31.4 | - | 4.75 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=129` | - | 60995.37 | 41994.21 | 80997.94 | 20 | 18.0 | - | 63.68 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=10240 K=4096 group=128 dtype=fp8a8 M=33` | - | 60994.14 | 20993.96 | 69996.22 | 20 | 20.5 | - | 40.78 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=1024 group=128 dtype=fp8a8 M=512` | - | 60990.88 | 23003.81 | 90027.05 | 20 | 36.1 | - | 8.52 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=65 ks=0 bk=0 nt=0` | - | 60983.83 | 44990.74 | 80992.08 | 20 | 20.5 | - | 72.58 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=9` | - | 60908.36 | 41987.42 | 78000.39 | 20 | 14.1 | - | 85.25 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3456 K=1152 dtype=bf16 act=none M=512` | - | 60836.49 | 35435.05 | 82740.72 | 20 | 28.7 | - | 15.48 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=5 splits=0` | - | 60635.67 | 35942.49 | 77985.81 | 20 | 14.0 | - | 16.08 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 60502.14 | 32044.57 | 77996.06 | 20 | 17.4 | - | 48.05 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=34816 K=5120 group=128 dtype=fp8a8 M=2` | - | 60500.70 | 39973.11 | 77992.74 | 20 | 18.2 | - | 170.16 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3840 K=1280 dtype=bf16 act=none M=64` | - | 60496.65 | 42062.06 | 77997.05 | 20 | 10.8 | - | 10.48 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=20480 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 60486.07 | 28976.53 | 66989.48 | 20 | 11.6 | - | 200.39 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4608 K=4608 dtype=bf16 act=gelu M=64` | - | 60297.50 | 41992.52 | 77630.90 | 20 | 9.8 | - | 42.20 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=128` | - | 60232.98 | 36009.86 | 71477.18 | 20 | 7.5 | - | 11.85 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3456 K=1152 dtype=bf16 act=none M=16` | - | 60037.03 | 36047.94 | 69914.70 | 20 | 14.9 | - | 7.85 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 60025.76 | 42969.36 | 72017.67 | 20 | 11.8 | - | 11.37 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=1280 dtype=bf16 act=gelu M=4` | - | 60019.81 | 36019.25 | 77999.29 | 20 | 15.0 | - | 12.60 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=8192 K=4096 group=128 dtype=fp8a8 M=33` | - | 60008.87 | 40027.89 | 82993.42 | 20 | 20.8 | - | 32.65 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1536 dtype=bf16 act=none M=32` | - | 60008.05 | 48015.34 | 76971.73 | 20 | 14.1 | - | 3.61 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=4304 dtype=bf16 act=none M=32` | - | 59997.39 | 40009.99 | 99005.25 | 20 | 25.0 | - | 9.86 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=4608 dtype=bf16 act=none M=16` | - | 59994.66 | 29723.14 | 77989.56 | 20 | 15.0 | - | 45.46 MiB | 32 thread(s) | +| `gdn_chunk_scan` | `ref_gdn_chunk_scan` | libref | `head_k=128 head_v=128 scale=0.0883883 M=64 chunk=64` | - | 59994.16 | 35675.90 | 74842.08 | 20 | 17.5 | - | 8.40 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=8192 group=128 dtype=fp8a8 M=128` | - | 59993.54 | 48001.26 | 60007.73 | 11 | 0.0 | - | 34.04 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 59993.36 | 47981.65 | 71999.61 | 20 | 19.1 | - | 48.78 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=10240 K=4096 group=128 dtype=fp8a8 M=129` | - | 59992.76 | 45002.35 | 72010.80 | 20 | 15.0 | - | 43.04 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=17408 group=128 dtype=fp8a8 M=1` | - | 59991.29 | 43004.15 | 71993.77 | 20 | 14.2 | - | 85.04 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3840 K=1280 dtype=bf16 act=none M=32` | - | 59990.31 | 47032.64 | 73027.71 | 20 | 12.5 | - | 9.93 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 59989.07 | 47989.07 | 71992.78 | 20 | 6.7 | - | 11.50 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 59986.97 | 44992.29 | 74991.29 | 20 | 21.7 | - | 12.55 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=1280 dtype=bf16 act=gelu M=8` | - | 59983.52 | 48198.95 | 72001.61 | 20 | 7.3 | - | 12.69 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=4304 dtype=bf16 act=none M=64` | - | 59967.91 | 51031.21 | 69992.52 | 20 | 8.3 | - | 10.27 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=8` | - | 59597.64 | 36147.96 | 72163.48 | 20 | 11.8 | - | 9.61 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=64` | - | 59590.22 | 53629.77 | 67010.09 | 20 | 7.2 | - | 10.66 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=1280 dtype=bf16 act=gelu M=32` | - | 59492.22 | 17998.14 | 80781.57 | 20 | 34.7 | - | 13.21 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 59490.18 | 43999.47 | 71996.99 | 20 | 15.1 | - | 72.55 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1280 K=1280 dtype=bf16 act=none M=256` | - | 59110.41 | 39877.45 | 81984.29 | 20 | 24.7 | - | 5.00 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=5120 K=1280 dtype=bf16 act=gelu M=16` | - | 58993.23 | 26987.56 | 80984.37 | 20 | 17.8 | - | 12.86 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | - | 58947.30 | 30001.99 | 79007.40 | 20 | 16.5 | - | 32.19 MiB | 32 thread(s) | +| `sample_topk` | `avx_sample_topk` | libavx | `n_vocab=248320 M=16` | - | 58747.65 | 26471.56 | 75019.03 | 20 | 20.6 | - | 15.17 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=5120 K=1280 dtype=bf16 act=gelu M=64` | - | 58670.91 | 33008.19 | 72048.16 | 20 | 23.0 | - | 13.92 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=4096 K=20480 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 58496.78 | 17997.71 | 64019.88 | 20 | 10.3 | - | 160.38 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4608 K=4608 dtype=bf16 act=gelu M=32` | - | 58383.93 | 43209.09 | 66001.85 | 20 | 11.8 | - | 41.35 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=128 dtype=fp8a8 M=258` | - | 57999.61 | 30003.76 | 72997.93 | 20 | 16.2 | - | 6.80 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 57993.76 | 37988.23 | 66996.37 | 20 | 11.2 | - | 11.48 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3456 K=1152 dtype=bf16 act=none M=8` | - | 57992.45 | 37995.33 | 80991.84 | 20 | 22.4 | - | 7.72 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 57990.62 | 40994.13 | 75000.76 | 20 | 13.8 | - | 48.03 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=10240 K=4096 group=128 dtype=fp8a8 M=128` | - | 57870.29 | 41994.17 | 69968.30 | 20 | 13.0 | - | 43.02 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 57796.07 | 19299.85 | 73379.96 | 20 | 22.0 | - | 32.12 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1536 dtype=bf16 act=none M=512` | - | 57618.68 | 37391.31 | 75746.83 | 20 | 13.4 | - | 7.13 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=4608 dtype=bf16 act=none M=64` | - | 57557.56 | 41909.51 | 77991.84 | 20 | 23.2 | - | 46.82 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=20480 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 57495.57 | 41996.59 | 71995.23 | 20 | 15.7 | - | 201.66 MiB | 32 thread(s) | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | `N=240 K=4096 dtype=bf16 M=64` | - | 57142.07 | 26681.22 | 71993.64 | 20 | 18.4 | - | 4.31 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=1152 dtype=bf16 act=none M=512` | - | 57081.04 | 20994.76 | 72997.82 | 20 | 21.2 | - | 5.91 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=128` | - | 56993.03 | 30995.46 | 73007.56 | 20 | 17.4 | - | 11.85 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1536 dtype=bf16 act=none M=16` | - | 56992.93 | 38987.73 | 71989.62 | 20 | 10.6 | - | 3.49 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=9` | - | 56987.22 | 29996.87 | 71998.51 | 20 | 11.4 | - | 80.34 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3456 K=1152 dtype=bf16 act=none M=32` | - | 56985.66 | 34939.98 | 71990.08 | 20 | 16.6 | - | 8.09 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=36` | - | 56985.10 | 41000.53 | 64993.31 | 20 | 16.7 | - | 85.98 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=12288 K=5120 group=128 dtype=fp8a8 M=18` | - | 56480.69 | 22000.00 | 80987.64 | 20 | 28.3 | - | 60.52 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=4096 dtype=bf16 act=none M=448` | - | 56426.10 | 39118.81 | 66996.21 | 20 | 16.0 | - | 13.25 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=20480 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 56356.62 | 30881.56 | 82987.51 | 20 | 26.6 | - | 200.39 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=6 splits=0` | - | 55992.95 | 38986.11 | 72001.82 | 20 | 24.1 | - | 16.10 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 55956.29 | 40001.47 | 65998.65 | 20 | 13.4 | - | 48.30 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3456 K=1152 dtype=bf16 act=none M=128` | - | 55953.92 | 22125.86 | 71991.80 | 20 | 30.4 | - | 9.57 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=17408 group=128 dtype=fp8a8 M=8` | - | 55509.71 | 36994.76 | 68986.34 | 20 | 8.1 | - | 85.23 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5376 K=4096 group=128 dtype=fp8a8 M=512` | - | 55500.02 | 45995.44 | 66995.73 | 20 | 11.7 | - | 28.32 MiB | 32 thread(s) | +| `logits_gemm` | `ref_logits_gemm` | libref | `n_vocab=131072 n_embd=4096 dtype=bf16 M=1` | - | 55494.00 | 33995.61 | 71008.24 | 20 | 25.2 | - | 1.00 GiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1280 K=5120 dtype=bf16 act=none M=64` | - | 55490.78 | 37973.78 | 72970.74 | 20 | 18.9 | - | 13.44 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=4` | - | 55487.51 | 35987.43 | 71997.64 | 20 | 21.6 | - | 9.54 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=4608 K=4608 dtype=bf16 act=gelu M=16` | - | 55442.01 | 29993.89 | 68120.47 | 20 | 18.9 | - | 40.93 MiB | 32 thread(s) | +| `sample_logprobs` | `ref_sample_logprobs` | libref | `n_vocab=248320 k=21 M=64` | - | 55106.80 | 42134.70 | 78471.87 | 20 | 25.6 | - | 60.64 MiB | 32 thread(s) | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=64` | - | 55016.85 | 24285.78 | 63914.46 | 20 | 18.2 | - | 98.54 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4608 K=4608 dtype=bf16 act=gelu M=4` | - | 54998.99 | 39154.03 | 80777.62 | 20 | 21.8 | - | 40.61 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=4096 group=128 dtype=fp8a8 M=129` | - | 54998.76 | 38000.88 | 59993.01 | 20 | 11.8 | - | 17.53 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=9 splits=0` | - | 54813.86 | 27123.62 | 111613.70 | 20 | 49.5 | - | 32.21 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3456 K=1152 dtype=bf16 act=none M=64` | - | 54581.14 | 38143.59 | 71882.90 | 20 | 20.0 | - | 8.58 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1152 dtype=bf16 act=none M=128` | - | 54552.71 | 40888.66 | 65992.57 | 20 | 12.0 | - | 3.38 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=1536 dtype=bf16 act=none M=128` | - | 54505.29 | 34927.03 | 64966.42 | 20 | 10.0 | - | 4.31 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1152 dtype=bf16 act=none M=64` | - | 54504.48 | 23985.76 | 76045.19 | 20 | 17.4 | - | 2.96 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 54501.63 | 39002.35 | 65997.09 | 20 | 18.3 | - | 11.30 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=12288 K=5120 group=128 dtype=fp8a8 M=9` | - | 54500.58 | 28992.78 | 68993.86 | 20 | 24.8 | - | 60.26 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=17` | - | 54500.49 | 35995.24 | 63005.76 | 20 | 16.5 | - | 4.40 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1152 dtype=bf16 act=none M=256` | - | 54498.77 | 44996.16 | 69785.44 | 20 | 16.5 | - | 4.22 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=2304 dtype=bf16 M=512 tile=0` | - | 54492.85 | 35995.18 | 74010.06 | 20 | 13.8 | - | 9.12 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=10240 K=4096 group=128 dtype=fp8a8 M=32` | - | 54486.94 | 25986.42 | 79998.57 | 20 | 25.7 | - | 40.76 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=8` | - | 54472.72 | 9997.18 | 63030.43 | 20 | 16.5 | - | 30.13 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | - | 54221.23 | 26002.16 | 85990.91 | 20 | 34.0 | - | 32.14 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=4096 K=20480 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 54010.25 | 17993.41 | 63002.25 | 20 | 19.4 | - | 160.75 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=4096 K=20480 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 54003.14 | 36000.51 | 65987.54 | 20 | 16.7 | - | 161.59 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=17408 group=128 dtype=fp8a8 M=4` | - | 54002.95 | 35988.84 | 63000.91 | 20 | 15.7 | - | 85.12 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=8192 K=4096 group=128 dtype=fp8a8 M=64` | - | 53999.25 | 31988.24 | 73004.27 | 20 | 25.9 | - | 33.26 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=3072 dtype=bf16 act=none M=32` | - | 53998.31 | 53935.92 | 54059.66 | 6 | 0.1 | - | 6.31 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 53998.20 | 37991.36 | 63005.94 | 20 | 16.7 | - | 11.75 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=4304 dtype=bf16 act=none M=64` | - | 53997.33 | 36038.05 | 63069.97 | 20 | 16.3 | - | 10.27 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=5376 group=128 dtype=fp8a8 M=65` | - | 53997.01 | 34001.81 | 70982.37 | 20 | 17.6 | - | 21.85 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=18` | - | 53996.43 | 35999.35 | 62999.29 | 20 | 15.7 | - | 85.49 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3072 K=1024 dtype=bf16 act=none M=64` | - | 53996.10 | 53988.41 | 54994.39 | 6 | 0.9 | - | 6.88 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=4608 dtype=bf16 act=none M=4` | - | 53994.66 | 43986.02 | 65986.28 | 20 | 15.7 | - | 45.12 MiB | 32 thread(s) | +| `logits_gemm` | `avx_logits_gemm` | libavx | `n_vocab=131072 n_embd=4096 dtype=bf16 M=8` | - | 53994.46 | 38998.02 | 65997.25 | 20 | 13.9 | - | 1.00 GiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1152 dtype=bf16 act=none M=32` | - | 53994.39 | 42016.95 | 72987.88 | 20 | 13.9 | - | 2.74 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=6144 group=128 dtype=fp8a8 M=18` | - | 53994.25 | 25998.29 | 62185.52 | 20 | 14.8 | - | 30.29 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 53992.92 | 30994.27 | 72005.73 | 20 | 26.9 | - | 47.84 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=8192 group=128 dtype=fp8a8 M=9` | - | 53990.87 | 35987.28 | 71579.32 | 20 | 19.4 | - | 32.15 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | - | 53988.08 | 28006.16 | 54028.83 | 20 | 8.3 | - | 4.38 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=18` | - | 53984.59 | 42002.67 | 65993.73 | 20 | 12.0 | - | 60.52 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5376 group=128 dtype=fp8a8 M=258` | - | 53982.18 | 47987.00 | 60002.65 | 20 | 5.9 | - | 24.38 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=20480 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 53981.34 | 29994.26 | 68003.83 | 20 | 12.0 | - | 200.20 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=5376 group=128 dtype=fp8a8 M=64` | - | 53977.17 | 27986.75 | 66022.89 | 20 | 23.1 | - | 21.84 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1280 K=1280 dtype=bf16 act=none M=64` | - | 53972.75 | 29656.22 | 62990.31 | 20 | 10.5 | - | 3.60 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3840 K=1280 dtype=bf16 act=none M=1` | - | 53963.21 | 28957.59 | 67013.88 | 20 | 13.9 | - | 9.40 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=4608 K=4608 dtype=bf16 act=gelu M=32` | - | 53929.59 | 22858.08 | 71997.16 | 20 | 31.4 | - | 41.35 MiB | 32 thread(s) | +| `sample_typical` | `ref_sample_typical` | libref | `n_cand=1024 M=64` | - | 53921.67 | 38396.42 | 66191.29 | 20 | 10.5 | - | 518.00 KiB | 32 thread(s) | +| `sample_typical` | `avx_sample_typical` | libavx | `n_cand=1024 M=64` | - | 53900.72 | 17121.54 | 56380.65 | 40 | 12.2 | - | 518.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=9` | - | 53506.81 | 33996.44 | 62998.19 | 20 | 16.8 | - | 30.15 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 53492.60 | 41979.03 | 62998.80 | 20 | 14.9 | - | 11.26 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=16384 K=5120 group=128 dtype=fp8a8 M=4` | - | 53492.47 | 34981.36 | 62997.37 | 20 | 8.4 | - | 80.15 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=8192 K=4096 group=128 dtype=fp8a8 M=32` | - | 53488.21 | 35996.43 | 71993.08 | 20 | 11.2 | - | 32.63 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=8192 K=4096 group=128 dtype=fp8a8 M=18` | - | 53476.56 | 40982.23 | 77992.96 | 20 | 27.1 | - | 32.36 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 53475.78 | 37017.01 | 71016.68 | 20 | 11.2 | - | 11.28 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=32` | - | 53170.51 | 36982.70 | 75007.42 | 20 | 14.1 | - | 10.06 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=17408 group=128 dtype=fp8a8 M=2` | - | 52991.75 | 35978.70 | 60988.96 | 20 | 12.6 | - | 85.06 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 52991.60 | 41991.68 | 63004.01 | 20 | 11.3 | - | 11.37 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=512` | - | 52990.71 | 24984.44 | 59991.56 | 20 | 21.7 | - | 8.58 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=65` | - | 52988.32 | 38941.02 | 67008.24 | 20 | 22.6 | - | 61.86 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=24576 group=128 dtype=fp8a8 M=129` | - | 52987.64 | 28991.14 | 66271.52 | 20 | 25.5 | - | 100.14 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=8192 group=128 dtype=fp8a8 M=2` | - | 52973.50 | 41975.02 | 60987.88 | 20 | 17.0 | - | 32.04 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5376 K=4096 group=128 dtype=fp8a8 M=65` | - | 52958.65 | 36995.71 | 79006.43 | 20 | 19.8 | - | 21.93 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=16` | - | 52895.13 | 35994.60 | 67205.90 | 20 | 18.0 | - | 9.76 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3456 K=1152 dtype=bf16 act=none M=128` | - | 52849.38 | 18004.11 | 71699.79 | 20 | 36.0 | - | 9.57 MiB | 32 thread(s) | +| `gdn_conv_update` | `ref_gdn_conv_update` | libref | `head_k=128 head_v=128 conv_width=4 q_len=256` | - | 52702.77 | 37041.68 | 65295.39 | 20 | 16.9 | - | 15.12 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=8192 K=4096 group=128 dtype=fp8a8 M=4` | - | 52528.70 | 32020.38 | 60001.42 | 20 | 9.1 | - | 32.08 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=4` | - | 52498.66 | 37503.62 | 77996.85 | 20 | 21.9 | - | 30.07 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=96 K=5120 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 52498.43 | 26997.15 | 71999.14 | 20 | 32.4 | - | 980.38 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 52496.52 | 23993.42 | 60000.93 | 20 | 19.0 | - | 70.63 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=8` | - | 52493.70 | 30017.53 | 72008.53 | 20 | 19.0 | - | 60.24 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 52493.44 | 35995.30 | 59994.38 | 20 | 10.4 | - | 12.13 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=8192 group=128 dtype=fp8a8 M=129` | - | 52493.03 | 35997.80 | 56991.69 | 20 | 8.6 | - | 34.05 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=18` | - | 52492.43 | 29997.98 | 59998.12 | 20 | 17.1 | - | 30.29 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 52486.63 | 19996.90 | 59999.82 | 20 | 16.2 | - | 70.59 MiB | 32 thread(s) | +| `gdn_conv_update` | `avx_gdn_conv_update` | libavx | `head_k=128 head_v=128 conv_width=4 q_len=512` | - | 52193.56 | 34224.68 | 72287.67 | 20 | 15.8 | - | 30.12 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=4096 K=20480 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 51998.64 | 25999.43 | 61012.53 | 20 | 18.3 | - | 160.19 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=4096 K=20480 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 51996.83 | 17993.22 | 74998.66 | 20 | 44.2 | - | 160.80 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 51996.56 | 24990.65 | 71983.20 | 20 | 19.2 | - | 70.94 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=1` | - | 51988.15 | 36004.90 | 60985.65 | 20 | 9.6 | - | 85.04 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=1` | - | 51809.62 | 32991.22 | 72009.76 | 20 | 27.0 | - | 30.02 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=1536 dtype=bf16 act=none M=64` | - | 51522.57 | 27007.43 | 64983.50 | 20 | 11.6 | - | 3.85 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=2304 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 51500.61 | 36995.76 | 63001.15 | 20 | 14.6 | - | 5.65 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=2304 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 51498.72 | 34985.61 | 70975.66 | 20 | 20.4 | - | 5.63 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1152 dtype=bf16 act=none M=16` | - | 51496.08 | 19996.63 | 71979.09 | 20 | 19.4 | - | 2.64 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=10 splits=0` | - | 51492.89 | 35995.98 | 61942.41 | 20 | 13.5 | - | 4.23 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=129 tn=0` | - | 51447.26 | 34987.11 | 62990.28 | 20 | 21.4 | - | 3.71 MiB | 32 thread(s) | +| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | `head_k=128 head_v=128 scale=0.0883883 M=512 chunk=64` | - | 51227.79 | 36468.74 | 68993.51 | 20 | 22.1 | - | 25.19 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1280 K=1280 dtype=bf16 act=none M=128` | - | 51024.24 | 34931.03 | 71989.21 | 20 | 22.3 | - | 4.06 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=2304 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 50998.42 | 34978.24 | 62997.75 | 20 | 16.7 | - | 5.64 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 50996.78 | 31005.85 | 66001.99 | 20 | 15.3 | - | 11.35 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=8192 group=128 dtype=fp8a8 M=9` | - | 50995.71 | 35989.92 | 64005.46 | 20 | 17.6 | - | 32.15 MiB | 32 thread(s) | +| `sample_topk` | `ref_sample_topk` | libref | `n_vocab=131072 M=16` | - | 50895.26 | 32622.39 | 59125.66 | 20 | 15.5 | - | 8.02 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=5120 K=4608 dtype=bf16 act=none M=8` | - | 50685.75 | 36011.50 | 63000.14 | 20 | 12.9 | - | 45.24 MiB | 32 thread(s) | +| `sample_topk` | `avx_sample_topk` | libavx | `n_vocab=248320 M=8` | - | 50564.24 | 28395.08 | 69254.09 | 20 | 23.3 | - | 7.59 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=8192 K=4096 group=128 dtype=fp8a8 M=18` | - | 50501.34 | 30003.78 | 60986.89 | 20 | 11.9 | - | 32.36 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=8192 K=4096 group=128 dtype=fp8a8 M=1` | - | 50494.77 | 29969.13 | 59989.33 | 20 | 15.8 | - | 32.02 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=96 K=5120 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 50492.78 | 39007.82 | 67695.58 | 20 | 18.7 | - | 970.19 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 50489.40 | 27423.00 | 63800.33 | 20 | 18.4 | - | 32.10 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3840 K=1280 dtype=bf16 act=none M=2` | - | 50484.88 | 29996.47 | 56989.78 | 20 | 9.9 | - | 9.42 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 50001.85 | 44990.50 | 55005.16 | 20 | 7.1 | - | 11.50 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=36` | - | 49994.28 | 28993.40 | 80991.13 | 20 | 11.0 | - | 30.57 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=8192 K=4096 group=128 dtype=fp8a8 M=8` | - | 49993.01 | 36996.52 | 60996.18 | 20 | 20.0 | - | 32.16 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=4096 K=20480 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 49991.91 | 22911.98 | 53997.88 | 20 | 13.0 | - | 160.09 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | - | 49777.80 | 27565.52 | 75987.28 | 20 | 34.4 | - | 4.77 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=5120 K=1280 dtype=bf16 act=gelu M=32` | - | 49657.72 | 30956.37 | 78024.81 | 20 | 25.2 | - | 13.21 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=4096 K=20480 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 49499.71 | 26002.40 | 58973.51 | 20 | 15.1 | - | 160.38 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4608 K=4096 group=128 dtype=fp8a8 M=128` | - | 49497.85 | 26977.34 | 60003.60 | 20 | 30.3 | - | 19.64 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 49491.67 | 35993.62 | 64995.18 | 20 | 17.2 | - | 11.37 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1280 K=2304 dtype=bf16 M=260 tile=0` | - | 49486.90 | 32985.73 | 54005.19 | 20 | 15.2 | - | 7.40 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=4096 group=128 dtype=fp8a8 M=258` | - | 49482.11 | 26993.71 | 62999.00 | 20 | 28.3 | - | 5.54 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=1152 dtype=bf16 act=none M=256` | - | 49481.49 | 39066.79 | 60993.13 | 20 | 16.2 | - | 4.22 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 49013.42 | 34980.61 | 60013.19 | 20 | 17.3 | - | 11.35 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 49010.21 | 35994.92 | 59997.38 | 20 | 14.3 | - | 47.92 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=1024 group=128 dtype=fp8a8 M=258` | - | 48995.40 | 31967.85 | 60002.80 | 20 | 20.4 | - | 6.28 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5376 K=4096 group=128 dtype=fp8a8 M=258` | - | 48994.64 | 29998.37 | 52975.21 | 20 | 9.2 | - | 24.69 MiB | 32 thread(s) | +| `gated_quant_fp8` | `ref_gated_quant_fp8` | libref | `n=17408 group=128 dtype=bf16 act=silu M=256` | - | 48980.94 | 30061.59 | 63000.74 | 20 | 15.3 | - | 29.88 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=8192 K=4096 group=128 dtype=fp8a8 M=8` | - | 48759.83 | 34456.68 | 54000.81 | 20 | 9.2 | - | 32.16 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3840 K=1280 dtype=bf16 act=none M=4` | - | 48543.92 | 28992.43 | 60929.43 | 20 | 22.6 | - | 9.45 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=8192 K=4096 group=128 dtype=fp8a8 M=9` | - | 48501.57 | 38007.84 | 59993.85 | 20 | 12.4 | - | 32.18 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=24576 group=128 dtype=fp8a8 M=128` | - | 48496.78 | 42012.08 | 75990.85 | 20 | 25.8 | - | 100.11 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4 splits=0` | - | 48495.73 | 31984.32 | 53001.85 | 20 | 14.4 | - | 16.07 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 48495.62 | 23994.95 | 59995.86 | 20 | 10.3 | - | 12.70 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=4096 K=20480 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 48494.32 | 37000.32 | 57001.62 | 20 | 12.4 | - | 160.19 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5376 K=4096 group=128 dtype=fp8a8 M=64` | - | 48493.55 | 26985.12 | 74002.86 | 20 | 22.7 | - | 21.92 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=64` | - | 48491.60 | 25222.85 | 79005.99 | 20 | 40.2 | - | 31.02 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 48490.48 | 38986.35 | 65973.71 | 20 | 12.4 | - | 11.26 MiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=64` | - | 48171.53 | 19266.54 | 64702.97 | 20 | 23.9 | - | 2.21 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=4304 dtype=bf16 act=none M=8` | - | 48005.66 | 36019.95 | 53999.57 | 20 | 9.4 | - | 9.56 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 48000.64 | 35989.41 | 61009.23 | 20 | 25.0 | - | 12.60 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=96 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 48000.39 | 36001.87 | 59992.75 | 20 | 15.6 | - | 1.11 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 47999.72 | 26995.45 | 59989.00 | 20 | 9.4 | - | 47.87 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=96 K=5120 dtype=bf16 M=512 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 47998.40 | 35986.56 | 59993.89 | 20 | 20.8 | - | 6.03 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=8192 K=4096 group=128 dtype=fp8a8 M=33` | - | 47998.07 | 35001.00 | 62017.91 | 20 | 4.2 | - | 32.65 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=4` | - | 47997.81 | 33015.08 | 60003.63 | 20 | 16.7 | - | 85.12 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=2` | - | 47997.74 | 22983.73 | 62994.30 | 20 | 18.8 | - | 5.01 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=6144 group=128 dtype=fp8a8 M=9` | - | 47996.60 | 29997.23 | 66004.33 | 20 | 21.5 | - | 30.15 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 47995.60 | 25022.85 | 50995.14 | 20 | 15.7 | - | 11.31 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=5120 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 47995.17 | 26989.69 | 57007.24 | 20 | 9.4 | - | 12.52 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=96 K=5120 dtype=bf16 M=65 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 47994.94 | 35987.05 | 59982.25 | 20 | 2.1 | - | 1.58 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 47994.37 | 29994.99 | 57004.78 | 20 | 6.3 | - | 11.31 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3456 K=1152 dtype=bf16 act=none M=32` | - | 47994.31 | 27033.80 | 54024.70 | 20 | 12.5 | - | 8.09 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=256 K=5120 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 47994.26 | 35995.15 | 53997.68 | 20 | 12.5 | - | 2.52 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=2304 dtype=bf16 M=260 tile=0` | - | 47994.07 | 35991.76 | 59988.73 | 20 | 1.0 | - | 7.40 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=10240 K=4096 group=128 dtype=fp8a8 M=64` | - | 47993.33 | 41993.82 | 60998.88 | 20 | 10.4 | - | 41.51 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 47993.02 | 35987.51 | 60000.24 | 20 | 15.6 | - | 11.36 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=128 ks=0 bk=0 nt=0` | - | 47992.94 | 35982.80 | 63000.23 | 20 | 17.7 | - | 3.71 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=8192 group=128 dtype=fp8a8 M=33` | - | 47991.67 | 30994.48 | 59988.25 | 20 | 13.5 | - | 32.53 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=2304 dtype=bf16 M=65 tile=0` | - | 47985.30 | 26986.06 | 60004.69 | 20 | 18.8 | - | 6.07 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=8192 group=128 dtype=fp8a8 M=32` | - | 47981.04 | 35994.14 | 57985.84 | 20 | 12.5 | - | 32.51 MiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=16` | - | 47978.42 | 26685.50 | 72112.29 | 20 | 37.5 | - | 572.50 KiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 47975.67 | 36006.98 | 56993.39 | 20 | 12.5 | - | 12.71 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=1152 dtype=bf16 act=none M=128` | - | 47973.47 | 22988.24 | 54028.50 | 20 | 17.7 | - | 3.38 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=4096 group=128 dtype=fp8a8 M=128` | - | 47872.14 | 20970.80 | 71005.88 | 20 | 32.4 | - | 17.52 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=256 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 47759.68 | 36996.22 | 61958.32 | 20 | 10.5 | - | 2.67 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 47503.32 | 29986.02 | 56004.75 | 20 | 12.6 | - | 11.26 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=8192 group=128 dtype=fp8a8 M=18` | - | 47502.01 | 32988.39 | 70996.84 | 20 | 33.7 | - | 32.29 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=20480 K=5120 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 47500.04 | 31017.49 | 59984.72 | 20 | 11.6 | - | 200.10 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=8192 K=4096 group=128 dtype=fp8a8 M=9` | - | 47498.62 | 29003.95 | 53961.63 | 20 | 11.6 | - | 32.18 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=512 tn=0` | - | 47495.63 | 35999.46 | 53996.85 | 20 | 7.4 | - | 6.39 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=16384 K=5120 group=128 dtype=fp8a8 M=2` | - | 47487.26 | 16988.34 | 57986.19 | 20 | 13.7 | - | 80.08 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=5120 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 47472.26 | 37038.48 | 74992.02 | 20 | 24.2 | - | 12.51 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=25600 group=128 dtype=bf16 M=512` | - | 47461.02 | 23999.69 | 54102.99 | 20 | 11.2 | - | 37.89 MiB | 32 thread(s) | +| `ple_conv_bias` | `ref_ple_conv_bias` | libref | `n=10240 width=4 dilation=1 dtype=bf16 M=256` | - | 47141.27 | 36650.40 | 52758.10 | 20 | 8.2 | - | 20.14 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 47011.02 | 27001.45 | 53997.63 | 20 | 9.6 | - | 11.30 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=96 K=5120 dtype=bf16 M=260 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 47006.57 | 24002.37 | 61981.21 | 20 | 17.9 | - | 3.52 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 47004.88 | 35997.52 | 68007.96 | 20 | 17.0 | - | 71.57 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=10240 K=4096 group=128 dtype=fp8a8 M=32` | - | 47003.22 | 32989.78 | 53002.15 | 20 | 13.0 | - | 40.76 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=2048 dtype=bf16 act=none M=64` | - | 46990.30 | 17996.00 | 49995.32 | 20 | 12.8 | - | 4.50 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1280 K=5120 dtype=bf16 act=none M=1` | - | 46986.55 | 29998.35 | 60011.72 | 20 | 26.6 | - | 12.52 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1280 K=1280 dtype=bf16 act=none M=4` | - | 46984.22 | 29999.43 | 54085.82 | 20 | 19.2 | - | 3.16 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=2048 K=1024 dtype=bf16 act=none M=448` | - | 46898.88 | 17751.51 | 54137.20 | 20 | 12.8 | - | 8.38 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 46492.60 | 29991.73 | 55001.67 | 20 | 11.8 | - | 11.37 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1536 dtype=bf16 act=none M=2` | - | 46489.94 | 35975.66 | 48001.54 | 20 | 10.7 | - | 3.39 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1280 K=1280 dtype=bf16 act=none M=1` | - | 46473.36 | 32987.25 | 59966.25 | 20 | 11.9 | - | 3.13 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=20480 K=5120 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 46201.23 | 24998.08 | 58000.21 | 20 | 20.6 | - | 200.05 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4608 K=4608 dtype=bf16 act=gelu M=1` | - | 46003.01 | 28448.33 | 53983.85 | 20 | 17.4 | - | 40.54 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=96 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 45998.52 | 24001.02 | 65999.64 | 20 | 30.4 | - | 1.02 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=16` | - | 45980.85 | 31155.55 | 59994.42 | 20 | 20.6 | - | 9.76 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=4096 K=20480 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 45845.90 | 30010.46 | 61000.39 | 20 | 22.9 | - | 160.05 MiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=128` | - | 45839.77 | 17808.62 | 59581.94 | 20 | 30.7 | - | 4.40 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=64` | - | 45622.91 | 17996.67 | 56998.10 | 20 | 17.1 | - | 10.66 MiB | 32 thread(s) | +| `ple_conv_bias` | `avx_ple_conv_bias` | libavx | `n=10240 width=4 dilation=1 dtype=bf16 M=128` | - | 45567.86 | 35586.49 | 59204.51 | 20 | 10.2 | - | 10.14 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4608 K=4608 dtype=bf16 act=gelu M=2` | - | 45508.54 | 30254.15 | 54025.04 | 20 | 13.3 | - | 40.56 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=96 K=5120 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 45507.41 | 30008.32 | 53981.61 | 20 | 11.0 | - | 1.57 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=24576 group=128 dtype=fp8a8 M=18` | - | 45502.14 | 31001.94 | 55449.55 | 20 | 15.4 | - | 96.59 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=2304 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 45502.01 | 35989.54 | 59999.00 | 20 | 16.5 | - | 5.74 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=12288 K=5120 group=128 dtype=fp8a8 M=8` | - | 45497.81 | 28852.70 | 54988.63 | 20 | 15.2 | - | 60.24 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=2` | - | 45496.42 | 28003.58 | 62997.88 | 20 | 25.0 | - | 80.08 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=4304 dtype=bf16 act=none M=1` | - | 45496.29 | 29987.69 | 57990.77 | 20 | 16.5 | - | 9.47 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 45484.07 | 28984.24 | 58998.38 | 20 | 20.9 | - | 11.28 MiB | 32 thread(s) | +| `gdn_kkt_solve` | `ref_gdn_kkt_solve` | libref | `head_k=128 M=512 chunk=64` | - | 45373.42 | 29956.06 | 59980.81 | 20 | 19.2 | - | 5.19 MiB | 32 thread(s) | +| `row_topk` | `avx_row_topk` | libavx | `N=248320 R=32 dtype=bf16 M=32 nch=0 pt1=8` | - | 45270.51 | 35993.14 | 60707.10 | 20 | 19.4 | - | 15.17 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=64` | - | 45196.84 | 29990.63 | 69005.07 | 20 | 17.3 | - | 61.83 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=1280 dtype=bf16 act=gelu M=2` | - | 45068.62 | 30012.09 | 60004.63 | 20 | 17.3 | - | 12.55 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3456 K=1152 dtype=bf16 act=none M=64` | - | 45024.11 | 15986.16 | 59997.39 | 20 | 29.7 | - | 8.58 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 45001.99 | 26979.43 | 62989.81 | 20 | 20.0 | - | 70.45 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=2304 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 45001.29 | 29017.62 | 53997.59 | 20 | 10.0 | - | 5.86 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5376 group=128 dtype=fp8a8 M=129` | - | 45000.41 | 35981.46 | 56989.33 | 20 | 13.4 | - | 22.69 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=5376 group=128 dtype=fp8a8 M=33` | - | 44999.36 | 27986.23 | 62981.87 | 20 | 20.0 | - | 21.43 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=4096 K=20480 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 44998.96 | 36012.28 | 56999.83 | 20 | 7.8 | - | 160.09 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=5376 group=128 dtype=fp8a8 M=32` | - | 44997.90 | 26986.62 | 53997.65 | 20 | 11.1 | - | 21.42 MiB | 32 thread(s) | +| `sample_topk` | `ref_sample_topk` | libref | `n_vocab=131072 M=4` | - | 44997.24 | 28667.67 | 51178.36 | 20 | 11.6 | - | 2.00 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=4` | - | 44996.16 | 23995.14 | 60000.81 | 20 | 18.9 | - | 80.15 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=96 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 44995.59 | 35990.32 | 61010.83 | 20 | 24.4 | - | 1000.75 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=6144 group=128 dtype=fp8a8 M=8` | - | 44994.80 | 25981.87 | 54992.61 | 20 | 13.3 | - | 30.13 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=6144 group=128 dtype=fp8a8 M=1` | - | 44994.22 | 29982.24 | 47633.73 | 20 | 10.4 | - | 30.02 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5376 group=128 dtype=fp8a8 M=64` | - | 44991.92 | 28021.21 | 51979.96 | 20 | 13.3 | - | 21.84 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=96 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 44991.53 | 27013.81 | 61000.71 | 20 | 18.9 | - | 1.10 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=2304 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 44984.49 | 37017.17 | 57000.79 | 20 | 13.3 | - | 5.68 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=9` | - | 44982.56 | 14999.79 | 62880.95 | 20 | 26.7 | - | 60.26 MiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=64` | - | 44624.91 | 20660.39 | 61565.97 | 20 | 22.6 | - | 2.21 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=10240 K=4096 group=128 dtype=fp8a8 M=65` | - | 44511.33 | 15992.06 | 58989.59 | 20 | 13.5 | - | 41.54 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=36` | - | 44499.15 | 26978.99 | 59986.05 | 20 | 25.8 | - | 61.03 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=5120 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 44496.54 | 26998.21 | 59997.83 | 20 | 14.6 | - | 13.28 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=2304 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 44494.88 | 27377.25 | 53998.59 | 20 | 20.2 | - | 5.73 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=8192 group=128 dtype=fp8a8 M=32` | - | 44491.94 | 34750.35 | 62999.86 | 20 | 19.1 | - | 32.51 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=8192 K=4096 group=128 dtype=fp8a8 M=2` | - | 44491.85 | 28779.64 | 54001.14 | 20 | 19.1 | - | 32.04 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=8192 group=128 dtype=fp8a8 M=4` | - | 44491.61 | 26991.97 | 48022.82 | 20 | 13.5 | - | 32.07 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=4096 group=128 dtype=fp8a8 M=512` | - | 44487.11 | 35996.83 | 52004.12 | 20 | 7.9 | - | 22.06 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 44481.13 | 35983.92 | 48001.03 | 20 | 13.5 | - | 11.48 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=4096 group=128 dtype=fp8a8 M=1` | - | 44476.60 | 35986.09 | 52991.54 | 20 | 14.6 | - | 4.01 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=1280 dtype=bf16 act=gelu M=1` | - | 44465.33 | 35985.00 | 52013.33 | 20 | 9.0 | - | 12.53 MiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=32` | - | 44202.52 | 26952.38 | 62923.17 | 20 | 25.6 | - | 1.11 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=128 dtype=fp8a8 M=128` | - | 44035.40 | 29991.59 | 54919.85 | 20 | 19.3 | - | 5.90 MiB | 32 thread(s) | +| `ple_conv_bias` | `avx_ple_conv_bias` | libavx | `n=10240 width=4 dilation=1 dtype=bf16 M=4` | - | 44002.43 | 32025.80 | 53968.47 | 20 | 9.1 | - | 460.02 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=16384 K=5120 group=128 dtype=fp8a8 M=1` | - | 44001.59 | 27990.28 | 53995.98 | 20 | 12.5 | - | 80.05 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=32` | - | 43998.74 | 23996.22 | 48008.40 | 20 | 25.0 | - | 2.50 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=10240 K=4096 group=128 dtype=fp8a8 M=18` | - | 43993.75 | 28805.25 | 62999.11 | 20 | 17.1 | - | 40.43 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1280 K=1280 dtype=bf16 act=none M=1` | - | 43983.54 | 26000.87 | 61023.82 | 20 | 17.0 | - | 3.13 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=8192 group=128 dtype=fp8a8 M=65` | - | 43978.18 | 26993.58 | 48016.52 | 20 | 13.6 | - | 33.04 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=2048 K=1024 dtype=bf16 act=none M=128` | - | 43959.69 | 17996.05 | 50980.73 | 20 | 25.0 | - | 5.25 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1536 dtype=bf16 act=none M=8` | - | 43941.25 | 30011.83 | 48010.73 | 20 | 12.5 | - | 3.44 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 43914.05 | 29010.68 | 62993.21 | 20 | 13.7 | - | 12.07 MiB | 32 thread(s) | +| `moe_gather` | `ref_moe_gather` | libref | `n=1024 top_k=9 dtype=bf16 act=none M=256` | - | 43779.52 | 26895.44 | 60601.31 | 20 | 22.3 | - | 5.51 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=32` | - | 43646.48 | 29996.95 | 59995.32 | 20 | 27.5 | - | 10.06 MiB | 32 thread(s) | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=4` | - | 43579.04 | 18136.33 | 52816.28 | 20 | 16.1 | - | 96.17 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=256 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 43498.52 | 34992.70 | 57007.51 | 20 | 13.8 | - | 2.58 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 43490.25 | 33006.00 | 51002.49 | 20 | 13.8 | - | 11.26 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=6144 group=128 dtype=fp8a8 M=2` | - | 43472.88 | 35986.41 | 70971.69 | 20 | 20.7 | - | 30.04 MiB | 32 thread(s) | +| `sample_topk` | `ref_sample_topk` | libref | `n_vocab=248320 M=2` | - | 43428.18 | 36855.51 | 58730.45 | 20 | 12.5 | - | 1.90 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=20480 K=5120 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 43004.44 | 30990.88 | 56995.73 | 20 | 20.9 | - | 200.10 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 42998.31 | 17990.28 | 59989.07 | 20 | 11.6 | - | 70.35 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=96 K=5120 dtype=bf16 M=130 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 42994.77 | 23985.13 | 53997.81 | 20 | 22.1 | - | 2.23 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=2304 dtype=bf16 M=130 tile=0` | - | 42993.07 | 31963.20 | 51971.75 | 20 | 14.0 | - | 6.51 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5376 K=4096 group=128 dtype=fp8a8 M=128` | - | 42991.24 | 18024.94 | 53995.87 | 20 | 12.8 | - | 22.83 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=2304 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 42988.06 | 33006.74 | 50005.89 | 20 | 7.0 | - | 6.06 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 42985.34 | 28988.14 | 47979.62 | 20 | 18.6 | - | 3.26 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1280 K=5120 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 42974.04 | 31997.74 | 53979.27 | 20 | 12.8 | - | 13.28 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1280 K=5120 dtype=bf16 act=none M=2` | - | 42507.03 | 35995.41 | 47981.89 | 20 | 10.6 | - | 12.53 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4608 K=4096 group=128 dtype=fp8a8 M=129` | - | 42502.65 | 26982.35 | 55013.05 | 20 | 18.8 | - | 19.66 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 42502.38 | 12996.56 | 53998.01 | 20 | 25.9 | - | 70.38 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5376 group=128 dtype=fp8a8 M=128` | - | 42498.93 | 35003.02 | 51975.20 | 20 | 12.9 | - | 22.68 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=1152 dtype=bf16 act=none M=64` | - | 42495.14 | 32995.22 | 55019.79 | 20 | 16.5 | - | 2.96 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=4096 dtype=bf16 act=none M=448` | - | 42096.58 | 20995.66 | 50894.85 | 20 | 9.5 | - | 13.25 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=2048 K=1024 dtype=bf16 act=none M=8` | - | 42003.10 | 16951.71 | 48000.64 | 20 | 10.8 | - | 4.08 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=8192 group=128 dtype=fp8a8 M=8` | - | 42002.65 | 30000.00 | 68558.15 | 20 | 11.9 | - | 32.13 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=33` | - | 42002.04 | 28321.90 | 53986.39 | 20 | 13.1 | - | 2.52 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=8192 group=128 dtype=fp8a8 M=64` | - | 42001.08 | 31006.19 | 57995.46 | 20 | 16.7 | - | 33.02 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1152 dtype=bf16 act=none M=2` | - | 41998.45 | 26028.88 | 47998.87 | 20 | 8.3 | - | 2.55 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=10240 K=4096 group=128 dtype=fp8a8 M=1` | - | 41998.28 | 29989.61 | 49996.44 | 20 | 14.3 | - | 40.03 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1536 dtype=bf16 act=none M=4` | - | 41996.36 | 35026.76 | 46004.49 | 20 | 5.7 | - | 3.41 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=4304 dtype=bf16 act=none M=2` | - | 41996.35 | 34973.22 | 51004.96 | 20 | 13.1 | - | 9.48 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=128 K=4096 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 41993.71 | 27968.14 | 58563.87 | 20 | 22.6 | - | 1.03 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=24576 group=128 dtype=fp8a8 M=32` | - | 41993.51 | 29991.60 | 50995.69 | 20 | 14.3 | - | 97.04 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=256 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 41990.59 | 32993.37 | 53986.58 | 20 | 14.3 | - | 2.54 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1280 K=2304 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 41987.21 | 35972.76 | 43997.12 | 20 | 8.3 | - | 5.86 MiB | 32 thread(s) | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=1` | - | 41987.20 | 17994.49 | 50992.37 | 20 | 12.9 | - | 96.05 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=4` | - | 41984.18 | 23944.90 | 53001.76 | 20 | 19.0 | - | 5.03 MiB | 32 thread(s) | +| `ple_conv_bias` | `avx_ple_conv_bias` | libavx | `n=10240 width=4 dilation=1 dtype=bf16 M=8` | - | 41966.66 | 29971.95 | 53955.13 | 20 | 14.3 | - | 780.02 KiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=32` | - | 41955.80 | 38941.27 | 56963.44 | 20 | 20.2 | - | 1.11 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=6144 group=128 dtype=fp8a8 M=2` | - | 41947.65 | 23980.19 | 52197.46 | 20 | 17.8 | - | 30.04 MiB | 32 thread(s) | +| `sample_topk` | `avx_sample_topk` | libavx | `n_vocab=248320 M=4` | - | 41531.24 | 24655.10 | 62033.57 | 20 | 22.3 | - | 3.79 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=1024 group=128 dtype=fp8a8 M=512` | - | 41499.94 | 29993.92 | 47995.66 | 20 | 12.1 | - | 8.52 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=129` | - | 41496.24 | 23980.22 | 46981.89 | 20 | 18.1 | - | 5.90 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 41494.78 | 29993.34 | 56986.74 | 20 | 21.7 | - | 11.71 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=8192 group=128 dtype=fp8a8 M=8` | - | 41492.17 | 29991.33 | 42007.69 | 20 | 7.2 | - | 32.13 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1280 K=1280 dtype=bf16 act=none M=8` | - | 41491.38 | 26869.12 | 51971.35 | 20 | 22.9 | - | 3.19 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=4096 group=128 dtype=fp8a8 M=258` | - | 41491.15 | 29965.14 | 52197.56 | 20 | 14.4 | - | 19.06 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=65` | - | 41488.72 | 32004.72 | 55002.18 | 20 | 18.1 | - | 5.45 MiB | 32 thread(s) | +| `sample_logprobs` | `ref_sample_logprobs` | libref | `n_vocab=248320 k=21 M=32` | - | 41226.66 | 22235.64 | 53994.91 | 20 | 18.5 | - | 30.32 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=20480 K=5120 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 41023.99 | 23987.90 | 59998.14 | 20 | 30.5 | - | 200.05 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1280 K=1280 dtype=bf16 act=none M=2` | - | 41018.96 | 21994.30 | 54035.13 | 20 | 19.5 | - | 3.14 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4608 K=4096 group=128 dtype=fp8a8 M=512` | - | 41007.07 | 23976.06 | 64429.41 | 20 | 29.2 | - | 24.56 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=258` | - | 41003.35 | 36966.36 | 52015.67 | 20 | 13.4 | - | 6.80 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5376 group=128 dtype=fp8a8 M=33` | - | 40999.63 | 33977.35 | 52001.39 | 20 | 14.6 | - | 21.43 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1152 dtype=bf16 act=none M=1` | - | 40995.95 | 24000.64 | 48000.10 | 20 | 9.8 | - | 2.54 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1280 K=2304 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 40990.31 | 29988.82 | 50988.03 | 20 | 11.0 | - | 5.73 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5376 K=4096 group=128 dtype=fp8a8 M=129` | - | 40985.59 | 18000.78 | 55007.25 | 20 | 19.5 | - | 22.84 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5376 group=128 dtype=fp8a8 M=32` | - | 40983.43 | 30982.47 | 51977.50 | 20 | 13.4 | - | 21.42 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1280 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 40728.73 | 27005.08 | 44997.79 | 20 | 11.1 | - | 12.92 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1280 K=5120 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 40598.64 | 23987.80 | 61000.00 | 20 | 29.6 | - | 12.51 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=2048 K=1024 dtype=bf16 act=none M=16` | - | 40510.57 | 15050.52 | 47995.23 | 20 | 28.9 | - | 4.16 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=5376 group=128 dtype=fp8a8 M=18` | - | 40502.36 | 25980.25 | 46018.52 | 20 | 12.4 | - | 21.24 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=1` | - | 40499.57 | 28000.40 | 51996.22 | 20 | 17.3 | - | 5.01 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=10240 K=4096 group=128 dtype=fp8a8 M=33` | - | 40499.42 | 28997.52 | 53993.20 | 20 | 13.6 | - | 40.78 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1280 K=5120 dtype=bf16 act=none M=4` | - | 40498.26 | 35995.67 | 62015.72 | 20 | 22.3 | - | 12.56 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | - | 40495.54 | 23990.65 | 50996.26 | 20 | 9.9 | - | 4.14 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=24576 K=4096 group=128 dtype=fp8a8 M=18` | - | 40494.12 | 22002.16 | 45017.17 | 20 | 14.8 | - | 96.93 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5376 K=4096 group=128 dtype=fp8a8 M=65` | - | 40491.83 | 29991.93 | 49231.60 | 20 | 11.1 | - | 21.93 MiB | 32 thread(s) | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=32` | - | 40491.60 | 29976.06 | 50981.96 | 20 | 17.5 | - | 97.28 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=256 K=5120 dtype=bf16 M=56 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 40482.66 | 34994.27 | 51001.80 | 20 | 14.8 | - | 3.07 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=258 tn=0` | - | 40479.70 | 30987.15 | 53986.61 | 20 | 16.1 | - | 4.62 MiB | 32 thread(s) | +| `sample_topk` | `ref_sample_topk` | libref | `n_vocab=131072 M=1` | - | 40275.97 | 31670.41 | 50065.72 | 20 | 12.7 | - | 513.09 KiB | 32 thread(s) | +| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | `head_k=128 head_v=128 scale=0.0883883 M=256 chunk=64` | - | 40243.32 | 27871.76 | 44998.06 | 20 | 16.4 | - | 15.59 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=2` | - | 40100.57 | 23992.29 | 54001.07 | 20 | 22.5 | - | 60.06 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=4096 dtype=bf16 act=none M=256` | - | 40041.06 | 22946.95 | 49991.18 | 20 | 13.8 | - | 11.00 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1280 K=5120 dtype=bf16 act=none M=8` | - | 39998.29 | 30002.43 | 54116.52 | 20 | 18.8 | - | 12.62 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=1` | - | 39996.48 | 29988.65 | 55012.79 | 20 | 16.3 | - | 60.04 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=24576 group=128 dtype=fp8a8 M=65` | - | 39995.23 | 19997.57 | 51994.50 | 20 | 31.3 | - | 98.09 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=24576 group=128 dtype=fp8a8 M=64` | - | 39992.86 | 23994.72 | 56996.90 | 20 | 41.3 | - | 98.06 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5376 K=4096 group=128 dtype=fp8a8 M=32` | - | 39991.78 | 29986.60 | 59997.29 | 20 | 21.3 | - | 21.46 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1280 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 39989.38 | 21998.60 | 51002.30 | 20 | 23.7 | - | 12.70 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=11` | - | 39988.12 | 28990.26 | 54000.21 | 20 | 20.0 | - | 4.26 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4608 K=4096 group=128 dtype=fp8a8 M=1` | - | 39986.37 | 29838.09 | 60071.50 | 20 | 13.8 | - | 18.02 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3456 K=1152 dtype=bf16 act=none M=4` | - | 39511.10 | 28028.04 | 48046.44 | 20 | 15.2 | - | 7.66 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=4096 group=128 dtype=fp8a8 M=128` | - | 39498.19 | 26993.85 | 51009.24 | 20 | 26.6 | - | 4.77 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=10240 K=4096 group=128 dtype=fp8a8 M=18` | - | 39496.59 | 31955.70 | 53549.22 | 20 | 8.6 | - | 40.43 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=10240 K=4096 group=128 dtype=fp8a8 M=2` | - | 39494.07 | 29590.35 | 48002.75 | 20 | 17.7 | - | 40.05 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=10240 K=4096 group=128 dtype=fp8a8 M=8` | - | 39488.65 | 17987.84 | 45999.32 | 20 | 16.5 | - | 40.19 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1536 dtype=bf16 act=none M=1` | - | 39486.45 | 26994.90 | 50994.14 | 20 | 11.4 | - | 3.38 MiB | 32 thread(s) | +| `ple_conv_bias` | `avx_ple_conv_bias` | libavx | `n=10240 width=4 dilation=1 dtype=bf16 M=1` | - | 39416.82 | 23990.02 | 49959.38 | 20 | 10.2 | - | 220.02 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=8192 K=4096 group=128 dtype=fp8a8 M=1` | - | 39016.11 | 24005.23 | 51989.57 | 20 | 16.7 | - | 32.02 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5376 K=4096 group=128 dtype=fp8a8 M=64` | - | 39006.51 | 26996.87 | 53994.23 | 20 | 17.9 | - | 21.92 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=8192 group=128 dtype=fp8a8 M=1` | - | 39003.95 | 30973.72 | 56965.33 | 20 | 21.8 | - | 32.02 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3072 K=1024 dtype=bf16 act=none M=128` | - | 39003.54 | 15995.88 | 46041.84 | 20 | 24.4 | - | 7.76 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1280 K=5120 dtype=bf16 act=none M=2` | - | 39002.42 | 23006.19 | 42995.64 | 20 | 15.4 | - | 12.53 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=128 K=4096 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 39000.74 | 26990.30 | 44999.94 | 20 | 16.7 | - | 1.01 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=4096 group=128 dtype=fp8a8 M=512` | - | 38999.47 | 28066.67 | 58997.04 | 20 | 21.8 | - | 7.06 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=9 splits=0` | - | 38998.67 | 23989.41 | 45990.26 | 20 | 18.1 | - | 4.21 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=8192 K=4096 group=128 dtype=fp8a8 M=4` | - | 38997.71 | 24000.37 | 50995.77 | 20 | 17.9 | - | 32.08 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=12288 K=5120 group=128 dtype=fp8a8 M=4` | - | 38996.87 | 32003.31 | 49991.48 | 20 | 11.5 | - | 60.12 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=8192 group=128 dtype=fp8a8 M=18` | - | 38995.02 | 23997.00 | 42708.81 | 20 | 9.0 | - | 32.29 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=256 K=5120 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 38994.71 | 24009.54 | 48995.56 | 20 | 23.1 | - | 2.51 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3840 K=1280 dtype=bf16 act=none M=1` | - | 38993.93 | 26988.45 | 57001.38 | 20 | 16.7 | - | 9.40 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=4304 dtype=bf16 act=none M=4` | - | 38993.76 | 28999.26 | 48002.32 | 20 | 14.1 | - | 9.51 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=10240 K=4096 group=128 dtype=fp8a8 M=8` | - | 38993.20 | 25002.10 | 45017.53 | 20 | 12.4 | - | 40.19 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=4096 dtype=bf16 act=none M=128` | - | 38991.07 | 18085.53 | 45977.90 | 20 | 25.6 | - | 9.50 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=10 splits=0` | - | 38990.75 | 18006.74 | 41991.60 | 20 | 20.5 | - | 272.01 KiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1280 K=1280 dtype=bf16 act=none M=4` | - | 38987.83 | 10994.08 | 64244.23 | 20 | 34.6 | - | 3.16 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3840 K=1280 dtype=bf16 act=none M=4` | - | 38986.64 | 24006.12 | 50030.56 | 20 | 18.0 | - | 9.45 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | - | 38985.20 | 26985.84 | 48999.78 | 20 | 20.5 | - | 32.13 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1280 K=2304 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 38983.72 | 19992.46 | 50995.09 | 20 | 15.4 | - | 5.65 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=96 K=5120 dtype=bf16 M=260 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 38982.80 | 22988.43 | 48004.59 | 20 | 14.1 | - | 3.52 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5376 group=128 dtype=fp8a8 M=65` | - | 38981.89 | 28009.83 | 50879.81 | 20 | 10.3 | - | 21.85 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1280 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 38979.79 | 20986.44 | 47995.07 | 20 | 8.9 | - | 12.60 MiB | 32 thread(s) | +| `sample_typical` | `ref_sample_typical` | libref | `n_cand=1024 M=32` | - | 38922.08 | 28347.10 | 41968.67 | 20 | 7.2 | - | 259.00 KiB | 32 thread(s) | +| `sample_topk` | `avx_sample_topk` | libavx | `n_vocab=248320 M=1` | - | 38792.85 | 16041.10 | 42862.24 | 20 | 4.6 | - | 971.09 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 38698.74 | 26991.89 | 53990.93 | 20 | 10.3 | - | 11.28 MiB | 32 thread(s) | +| `sample_logprobs` | `ref_sample_logprobs` | libref | `n_vocab=248320 k=21 M=16` | - | 38530.99 | 29989.28 | 45016.92 | 20 | 10.4 | - | 15.16 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=12288 group=128 dtype=fp8a8 M=32` | - | 38501.18 | 24993.84 | 58989.30 | 20 | 23.4 | - | 48.64 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1280 K=2304 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 38500.09 | 30994.93 | 47985.65 | 20 | 14.3 | - | 6.06 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=24576 K=4096 group=128 dtype=fp8a8 M=64` | - | 38493.52 | 20000.19 | 46771.33 | 20 | 24.7 | - | 99.27 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=4608 dtype=bf16 act=none M=1` | - | 38492.20 | 13988.82 | 47606.46 | 20 | 15.6 | - | 45.04 MiB | 32 thread(s) | +| `cast` | `ref_cast` | libref | `n=5120 from=bf16 to=bf16 M=16` | - | 38395.87 | 15017.54 | 48007.93 | 20 | 31.3 | - | 320.00 KiB | 32 thread(s) | +| `attn_dense` | `ref_attn_dense` | libref | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=128` | - | 38254.04 | 26453.61 | 54762.52 | 20 | 22.4 | - | 72.01 KiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=96 K=5120 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 38212.06 | 17995.61 | 77993.32 | 20 | 31.4 | - | 970.19 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=4096 group=128 dtype=fp8a8 M=64` | - | 38134.84 | 23996.44 | 42002.56 | 20 | 7.9 | - | 4.38 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=256 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 37999.01 | 22007.94 | 52000.78 | 20 | 26.3 | - | 2.66 MiB | 32 thread(s) | +| `logits_gemm` | `avx_logits_gemm` | libavx | `n_vocab=131072 n_embd=4096 dtype=bf16 M=4` | - | 37998.25 | 29994.72 | 47998.75 | 20 | 14.5 | - | 1.00 GiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=36` | - | 37998.13 | 12001.90 | 47995.83 | 20 | 21.0 | - | 5.25 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=256 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 37994.65 | 26026.47 | 39993.66 | 20 | 11.9 | - | 2.67 MiB | 32 thread(s) | +| `ple_conv_bias` | `avx_ple_conv_bias` | libavx | `n=10240 width=4 dilation=1 dtype=bf16 M=2` | - | 37992.82 | 29983.29 | 44990.09 | 20 | 11.8 | - | 300.02 KiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2 splits=0` | - | 37978.77 | 17996.79 | 42001.59 | 20 | 7.9 | - | 16.04 MiB | 32 thread(s) | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | `N=304 K=4096 dtype=bf16 M=64` | - | 37709.21 | 30843.76 | 43731.01 | 20 | 8.1 | - | 5.32 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=4096 group=128 dtype=fp8a8 M=4` | - | 37504.87 | 16991.77 | 44995.08 | 20 | 10.7 | - | 4.02 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1280 K=2304 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 37504.70 | 27224.65 | 46995.82 | 20 | 10.7 | - | 5.68 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=16384 K=5120 group=128 dtype=fp8a8 M=1` | - | 37503.55 | 26999.75 | 48003.96 | 20 | 16.0 | - | 80.05 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=1024 dtype=bf16 act=none M=32` | - | 37498.48 | 17998.26 | 40987.46 | 20 | 5.3 | - | 2.19 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=4096 group=128 dtype=fp8a8 M=258` | - | 37496.86 | 11988.80 | 59995.96 | 20 | 31.8 | - | 5.54 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=128 K=4096 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 37494.93 | 13994.16 | 48978.69 | 20 | 22.7 | - | 1.14 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=12288 K=5120 group=128 dtype=fp8a8 M=2` | - | 37493.99 | 20995.90 | 47991.24 | 20 | 22.7 | - | 60.06 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=10240 K=4096 group=128 dtype=fp8a8 M=9` | - | 37493.31 | 12996.43 | 56992.88 | 20 | 28.1 | - | 40.22 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=2` | - | 37064.36 | 11963.32 | 47940.17 | 20 | 28.4 | - | 9.50 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=4608 K=4608 dtype=bf16 act=gelu M=8` | - | 37041.97 | 30142.99 | 44075.60 | 20 | 12.6 | - | 40.72 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1152 dtype=bf16 act=none M=4` | - | 37011.40 | 24997.12 | 50999.33 | 20 | 22.9 | - | 2.56 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=128 K=4096 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 37004.39 | 25987.87 | 47993.42 | 20 | 9.5 | - | 1.13 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=10240 K=4096 group=128 dtype=fp8a8 M=4` | - | 36993.70 | 25001.30 | 51958.27 | 20 | 14.8 | - | 40.10 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3072 K=1024 dtype=bf16 act=none M=448` | - | 36985.84 | 29020.78 | 47141.48 | 20 | 14.2 | - | 12.13 MiB | 32 thread(s) | +| `attn_dense` | `ref_attn_dense` | libref | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=128` | - | 36804.18 | 21891.40 | 50218.98 | 20 | 26.0 | - | 80.01 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 36692.61 | 23999.06 | 40590.59 | 20 | 13.6 | - | 2.88 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=128` | - | 36653.51 | 29981.71 | 47996.21 | 20 | 16.0 | - | 5.90 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=128 K=4096 dtype=bf16 M=260 tile=0` | - | 36504.06 | 25865.48 | 46983.68 | 20 | 11.9 | - | 3.09 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=8` | - | 36502.64 | 26996.04 | 44997.24 | 20 | 14.9 | - | 5.06 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 36501.08 | 26995.05 | 52991.29 | 20 | 13.7 | - | 2.94 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=96 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 36499.80 | 23991.62 | 59997.61 | 20 | 34.4 | - | 1.28 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1280 K=2304 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 36491.33 | 24003.20 | 39998.72 | 20 | 15.1 | - | 5.74 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=2048 K=1024 dtype=bf16 act=none M=128` | - | 36489.06 | 14983.81 | 39000.11 | 20 | 13.7 | - | 5.25 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3072 K=1024 dtype=bf16 act=none M=8` | - | 36482.67 | 17987.05 | 39980.38 | 20 | 29.4 | - | 6.12 MiB | 32 thread(s) | +| `row_topk` | `avx_row_topk` | libavx | `N=248320 R=32 dtype=bf16 M=4 nch=0 pt1=8` | - | 36477.40 | 23949.88 | 48002.96 | 20 | 16.4 | - | 1.90 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=2048 dtype=bf16 act=none M=448` | - | 36147.21 | 17994.25 | 39707.51 | 20 | 30.0 | - | 7.50 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5120 K=6144 group=128 dtype=fp8a8 M=4` | - | 36042.92 | 28015.24 | 41991.90 | 20 | 11.1 | - | 30.07 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=1024 group=128 dtype=fp8a8 M=2` | - | 36035.91 | 24971.97 | 47973.61 | 20 | 15.3 | - | 4.02 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5376 K=4096 group=128 dtype=fp8a8 M=18` | - | 36017.51 | 21981.10 | 48030.37 | 20 | 18.0 | - | 21.26 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=128 dtype=fp8a8 M=9` | - | 36010.90 | 29981.66 | 42003.67 | 20 | 11.1 | - | 5.06 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=3072 dtype=bf16 act=none M=64` | - | 36010.57 | 24018.52 | 39000.91 | 20 | 4.2 | - | 6.63 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=96 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 36004.47 | 17998.14 | 52997.17 | 20 | 22.2 | - | 1.02 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=20480 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 36003.74 | 15994.29 | 69000.80 | 20 | 36.1 | - | 200.20 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 36003.10 | 25000.72 | 44991.75 | 20 | 20.8 | - | 3.06 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=1024 group=128 dtype=fp8a8 M=128` | - | 36002.90 | 26989.28 | 44982.65 | 20 | 12.5 | - | 5.13 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=129 tn=0` | - | 36002.80 | 26992.41 | 41996.26 | 20 | 5.6 | - | 3.71 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=4096 group=128 dtype=fp8a8 M=9` | - | 36001.88 | 34009.94 | 44996.13 | 20 | 9.7 | - | 4.05 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=10240 K=4096 group=128 dtype=fp8a8 M=9` | - | 36001.52 | 28072.54 | 41996.15 | 20 | 12.5 | - | 40.22 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=20480 act=relu dtype=bf16 M=512` | - | 36001.39 | 27005.26 | 52188.70 | 20 | 3.9 | - | 60.00 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3072 K=1024 dtype=bf16 act=none M=32` | - | 35999.27 | 15126.25 | 42979.14 | 20 | 4.3 | - | 6.44 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=2048 dtype=bf16 act=none M=256` | - | 35998.95 | 27045.65 | 38989.01 | 14 | 0.2 | - | 6.00 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=4096 group=128 dtype=fp8a8 M=32` | - | 35998.93 | 35995.98 | 36001.21 | 11 | 0.0 | - | 4.19 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=4096 dtype=bf16 act=none M=16` | - | 35998.69 | 15989.51 | 47992.88 | 20 | 33.3 | - | 8.19 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4608 K=4096 group=128 dtype=fp8a8 M=8` | - | 35998.43 | 35982.38 | 36009.22 | 6 | 0.0 | - | 18.10 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=4096 dtype=bf16 act=none M=56` | - | 35998.29 | 35980.21 | 36000.93 | 6 | 0.0 | - | 8.66 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=3072 dtype=bf16 act=none M=16` | - | 35998.02 | 16994.39 | 38006.05 | 20 | 18.0 | - | 6.16 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=2048 K=1024 dtype=bf16 act=none M=32` | - | 35997.98 | 35993.21 | 36005.30 | 6 | 0.0 | - | 4.32 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 35997.94 | 29010.64 | 47983.67 | 20 | 11.1 | - | 2.87 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=4096 group=128 dtype=fp8a8 M=65` | - | 35997.78 | 12994.08 | 45007.07 | 20 | 25.0 | - | 4.39 MiB | 32 thread(s) | +| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=4` | - | 35997.43 | 16026.53 | 55001.74 | 20 | 25.9 | - | 2.37 GiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=64` | - | 35997.39 | 18000.16 | 49999.88 | 20 | 26.4 | - | 5.45 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=1024 group=128 dtype=fp8a8 M=129` | - | 35997.16 | 23006.20 | 41968.88 | 20 | 15.2 | - | 5.14 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | - | 35997.09 | 19997.37 | 46987.74 | 20 | 20.9 | - | 2.94 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5120 K=17408 group=128 dtype=fp8a8 M=2` | - | 35996.94 | 26989.07 | 63003.90 | 20 | 26.3 | - | 85.06 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=4096 K=20480 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 35996.92 | 12005.33 | 56994.61 | 20 | 36.1 | - | 160.05 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=96 K=5120 dtype=bf16 M=130 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 35996.60 | 34968.42 | 47997.77 | 20 | 11.1 | - | 2.23 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=9` | - | 35996.58 | 25000.70 | 40994.35 | 20 | 1.4 | - | 5.06 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=65 ks=0 bk=0 nt=0` | - | 35996.37 | 26989.72 | 49029.91 | 20 | 18.0 | - | 3.27 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=4096 dtype=bf16 act=none M=64` | - | 35996.34 | 35990.49 | 35999.46 | 6 | 0.0 | - | 8.75 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=96 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 35996.28 | 26986.76 | 45010.60 | 20 | 23.6 | - | 1.11 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=1024 group=128 dtype=fp8a8 M=64` | - | 35995.72 | 26997.23 | 43988.33 | 20 | 13.9 | - | 4.56 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=256 K=5120 dtype=bf16 M=56 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 35995.55 | 26993.77 | 43978.37 | 20 | 15.2 | - | 3.07 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=8192 group=128 dtype=fp8a8 M=4` | - | 35994.98 | 23995.11 | 40994.77 | 20 | 8.3 | - | 32.07 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=128 K=4096 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 35994.77 | 12005.46 | 45000.68 | 20 | 19.4 | - | 1.52 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=4096 group=128 dtype=fp8a8 M=18` | - | 35994.49 | 26996.14 | 46120.83 | 19 | 0.0 | - | 4.11 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=1024 group=128 dtype=fp8a8 M=4` | - | 35994.37 | 23990.93 | 42000.30 | 20 | 13.9 | - | 4.04 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | - | 35992.28 | 26986.65 | 44991.42 | 20 | 19.4 | - | 4.13 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=2048 dtype=bf16 act=none M=16` | - | 35992.23 | 35971.47 | 36013.00 | 6 | 0.1 | - | 4.13 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1280 K=2304 dtype=bf16 M=65 tile=0` | - | 35992.11 | 23004.47 | 41001.95 | 20 | 15.3 | - | 6.07 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5376 group=128 dtype=fp8a8 M=8` | - | 35991.70 | 17996.64 | 44995.98 | 20 | 22.2 | - | 21.11 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 35991.36 | 23986.18 | 43991.16 | 20 | 13.9 | - | 2.83 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 35990.45 | 26997.39 | 44993.24 | 20 | 12.5 | - | 2.84 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=128 K=4096 dtype=bf16 M=65 tile=0` | - | 35988.92 | 20012.10 | 44987.10 | 20 | 16.6 | - | 1.52 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5376 K=4096 group=128 dtype=fp8a8 M=4` | - | 35987.71 | 8056.76 | 41989.46 | 20 | 34.8 | - | 21.06 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=12288 K=5120 group=128 dtype=fp8a8 M=1` | - | 35986.29 | 17987.60 | 36020.94 | 20 | 12.5 | - | 60.04 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=1024 group=128 dtype=fp8a8 M=258` | - | 35985.76 | 24000.17 | 38000.60 | 20 | 9.7 | - | 6.28 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=128 dtype=fp8a8 M=64` | - | 35982.62 | 19992.96 | 36010.84 | 20 | 16.7 | - | 5.45 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5376 group=128 dtype=fp8a8 M=9` | - | 35971.01 | 26001.37 | 45011.38 | 20 | 15.3 | - | 21.12 MiB | 32 thread(s) | +| `ple_conv_bias` | `avx_ple_conv_bias` | libavx | `n=10240 width=4 dilation=1 dtype=bf16 M=16` | - | 35962.10 | 21953.49 | 47962.43 | 20 | 21.9 | - | 1.39 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=1536 dtype=bf16 act=none M=32` | - | 35933.06 | 26953.78 | 36118.94 | 20 | 12.6 | - | 3.61 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=4096 group=128 dtype=fp8a8 M=64` | - | 35921.35 | 20578.09 | 53001.03 | 20 | 35.6 | - | 16.76 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=512` | - | 35887.04 | 21492.18 | 42983.83 | 20 | 18.5 | - | 8.50 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3840 K=1280 dtype=bf16 act=none M=16` | - | 35882.57 | 27227.57 | 36209.51 | 20 | 9.8 | - | 9.66 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=1024 dtype=bf16 act=none M=448` | - | 35863.96 | 23976.76 | 41005.01 | 20 | 12.4 | - | 4.63 MiB | 32 thread(s) | +| `ple_conv_bias` | `avx_ple_conv_bias` | libavx | `n=10240 width=4 dilation=1 dtype=bf16 M=32` | - | 35858.62 | 35779.94 | 35956.15 | 6 | 0.2 | - | 2.64 MiB | 32 thread(s) | +| `sample_logprobs` | `ref_sample_logprobs` | libref | `n_vocab=248320 k=21 M=8` | - | 35620.92 | 23997.41 | 46062.32 | 20 | 21.2 | - | 7.58 MiB | 32 thread(s) | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | `N=240 K=4096 dtype=bf16 M=32` | - | 35542.42 | 26995.74 | 35998.20 | 20 | 11.8 | - | 4.03 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3456 K=1152 dtype=bf16 act=none M=2` | - | 35515.41 | 21968.70 | 53997.38 | 20 | 21.1 | - | 7.63 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1280 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 35501.46 | 17983.42 | 45001.09 | 20 | 24.0 | - | 12.71 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=12288 group=128 dtype=fp8a8 M=33` | - | 35500.90 | 20979.34 | 41998.72 | 20 | 9.9 | - | 48.66 MiB | 32 thread(s) | +| `sample_typical` | `avx_sample_typical` | libavx | `n_cand=1024 M=32` | - | 35495.05 | 12302.97 | 45679.23 | 40 | 22.6 | - | 259.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 35494.28 | 27985.60 | 42018.56 | 20 | 15.5 | - | 2.82 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=96 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 35492.79 | 9958.70 | 45009.83 | 20 | 24.5 | - | 1.28 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=4096 group=128 dtype=fp8a8 M=129` | - | 35489.55 | 26991.91 | 44996.01 | 20 | 25.3 | - | 4.77 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | - | 35482.75 | 23989.29 | 51007.29 | 20 | 22.5 | - | 3.06 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5376 K=4096 group=128 dtype=fp8a8 M=18` | - | 35479.33 | 24002.23 | 52985.66 | 20 | 16.9 | - | 21.26 MiB | 32 thread(s) | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=2` | - | 35473.81 | 18081.15 | 38002.27 | 20 | 24.0 | - | 96.09 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=96 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 35466.99 | 23990.36 | 44980.58 | 20 | 18.3 | - | 1.10 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 35282.72 | 16185.57 | 62191.06 | 20 | 46.2 | - | 32.05 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1280 K=5120 dtype=bf16 act=none M=32` | - | 35281.02 | 25002.76 | 42970.02 | 20 | 18.4 | - | 12.97 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=128 K=4096 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 35191.90 | 21989.84 | 54003.53 | 20 | 38.3 | - | 1.27 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=5120 K=4608 dtype=bf16 act=none M=2` | - | 35025.89 | 22982.01 | 41991.72 | 20 | 17.1 | - | 45.07 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1280 K=5120 dtype=bf16 act=none M=16` | - | 35007.30 | 25971.66 | 42623.58 | 20 | 14.3 | - | 12.74 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1152 K=1152 dtype=bf16 act=none M=8` | - | 35002.86 | 19995.15 | 41011.58 | 20 | 14.3 | - | 2.59 MiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=512` | - | 35002.74 | 25481.66 | 44073.27 | 20 | 23.8 | - | 17.59 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1280 K=2304 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 35001.36 | 23968.28 | 36995.03 | 20 | 15.7 | - | 5.63 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=65 ks=0 bk=0 nt=0` | - | 34995.77 | 25893.51 | 47991.32 | 20 | 18.6 | - | 3.27 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1280 K=2304 dtype=bf16 M=130 tile=0` | - | 34992.49 | 26003.98 | 41972.87 | 20 | 17.1 | - | 6.51 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=8192 group=128 dtype=fp8a8 M=2` | - | 34990.66 | 26981.99 | 42990.42 | 20 | 12.9 | - | 32.04 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=256 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 34988.05 | 17826.70 | 45002.41 | 20 | 10.0 | - | 2.66 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=128 K=4096 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 34983.76 | 19008.03 | 35998.64 | 20 | 12.9 | - | 1.06 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=3072 dtype=bf16 act=none M=128` | - | 34898.56 | 17998.73 | 41994.50 | 20 | 14.6 | - | 7.25 MiB | 32 thread(s) | +| `sample_typical` | `avx_sample_typical` | libavx | `n_cand=1024 M=16` | - | 34810.36 | 11722.49 | 35971.38 | 40 | 21.9 | - | 129.50 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | - | 34760.13 | 17996.16 | 61537.38 | 20 | 50.4 | - | 13.00 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3072 K=1024 dtype=bf16 act=none M=128` | - | 34632.74 | 17425.72 | 36282.94 | 20 | 13.0 | - | 7.76 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=128 K=4096 dtype=bf16 M=260 tile=0` | - | 34570.46 | 17986.58 | 38009.05 | 20 | 13.0 | - | 3.09 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=96 K=5120 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 34512.71 | 23992.20 | 45022.23 | 20 | 26.0 | - | 1.57 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=256 K=5120 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 34510.39 | 23988.55 | 42218.16 | 20 | 11.6 | - | 2.51 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 34498.70 | 21993.19 | 40939.30 | 20 | 13.1 | - | 32.07 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4608 K=4096 group=128 dtype=fp8a8 M=4` | - | 34498.68 | 27010.12 | 40004.17 | 20 | 11.6 | - | 18.05 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=128 K=4096 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 34498.27 | 18715.76 | 43030.50 | 20 | 15.9 | - | 1.02 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=4096 group=128 dtype=fp8a8 M=128` | - | 34493.04 | 15989.57 | 40003.85 | 20 | 19.2 | - | 4.77 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=96 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 34491.78 | 17990.97 | 47990.09 | 20 | 13.1 | - | 1000.75 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4608 K=4096 group=128 dtype=fp8a8 M=2` | - | 34489.21 | 26063.50 | 39020.77 | 20 | 13.0 | - | 18.03 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=96 K=5120 dtype=bf16 M=65 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 34488.40 | 20009.30 | 36005.57 | 20 | 11.6 | - | 1.58 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=96 K=5120 dtype=bf16 M=512 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 34480.89 | 9998.74 | 50976.25 | 20 | 29.1 | - | 6.03 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=1` | - | 34480.61 | 14963.40 | 49991.08 | 20 | 26.1 | - | 9.48 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3072 K=1024 dtype=bf16 act=none M=256` | - | 34469.12 | 17941.99 | 39015.04 | 20 | 30.4 | - | 9.51 MiB | 32 thread(s) | +| `moe_gather` | `ref_moe_gather` | libref | `n=1024 top_k=9 dtype=bf16 act=none M=128` | - | 34366.29 | 21828.37 | 52031.79 | 20 | 23.2 | - | 2.76 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=128 K=4096 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 34255.31 | 21006.26 | 41007.83 | 20 | 16.0 | - | 1.27 MiB | 32 thread(s) | +| `gdn_conv_update` | `avx_gdn_conv_update` | libavx | `head_k=128 head_v=128 conv_width=4 q_len=256` | - | 34233.47 | 22587.90 | 46772.77 | 20 | 17.0 | - | 15.12 MiB | 32 thread(s) | +| `sample_topk` | `avx_sample_topk` | libavx | `n_vocab=131072 M=64` | - | 34209.14 | 27753.80 | 39664.38 | 20 | 11.8 | - | 32.07 MiB | 32 thread(s) | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | `N=240 K=4096 dtype=bf16 M=512` | - | 34150.87 | 17960.24 | 36996.72 | 20 | 15.8 | - | 8.22 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 34008.71 | 16980.76 | 44990.80 | 20 | 9.6 | - | 4.05 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 34002.46 | 21008.81 | 43996.31 | 20 | 16.1 | - | 4.09 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1280 K=1280 dtype=bf16 act=none M=8` | - | 33995.97 | 18002.55 | 42983.39 | 20 | 16.2 | - | 3.19 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=2048 dtype=bf16 act=none M=256` | - | 33994.34 | 19999.40 | 43002.70 | 20 | 17.6 | - | 6.00 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=128 K=4096 dtype=bf16 M=130 tile=0` | - | 33992.97 | 21007.14 | 36006.95 | 20 | 13.2 | - | 2.05 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5376 K=4096 group=128 dtype=fp8a8 M=33` | - | 33985.43 | 12988.15 | 47000.42 | 20 | 27.9 | - | 21.47 MiB | 32 thread(s) | +| `gdn_chunk_scan` | `ref_gdn_chunk_scan` | libref | `head_k=128 head_v=128 scale=0.0883883 M=8 chunk=64` | - | 33984.92 | 16322.37 | 50998.59 | 20 | 35.4 | - | 6.30 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=256 K=5120 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 33984.54 | 25988.12 | 37008.66 | 20 | 10.3 | - | 2.52 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 33978.17 | 17999.49 | 35999.57 | 20 | 13.2 | - | 128.01 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5376 K=4096 group=128 dtype=fp8a8 M=9` | - | 33952.56 | 22065.23 | 36004.30 | 20 | 13.3 | - | 21.13 MiB | 32 thread(s) | +| `sample_topk` | `ref_sample_topk` | libref | `n_vocab=131072 M=8` | - | 33938.60 | 28592.18 | 46564.87 | 20 | 12.7 | - | 4.01 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=2048 K=1024 dtype=bf16 act=none M=64` | - | 33881.84 | 16993.58 | 41928.26 | 20 | 12.0 | - | 4.63 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 33643.95 | 26978.06 | 38724.00 | 20 | 11.9 | - | 32.08 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=8192 K=4096 group=128 dtype=fp8a8 M=2` | - | 33498.44 | 24994.13 | 47990.94 | 20 | 13.4 | - | 32.04 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | - | 33498.02 | 21997.90 | 50993.13 | 20 | 16.4 | - | 4.19 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=1024 group=128 dtype=fp8a8 M=128` | - | 33497.89 | 14039.85 | 45003.82 | 20 | 25.4 | - | 5.13 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=24576 group=128 dtype=fp8a8 M=9` | - | 33474.71 | 22021.89 | 42049.18 | 20 | 13.5 | - | 96.30 MiB | 32 thread(s) | +| `gdn_conv_update` | `ref_gdn_conv_update` | libref | `head_k=128 head_v=128 conv_width=4 q_len=128` | - | 33464.46 | 17066.52 | 44670.15 | 20 | 10.4 | - | 7.62 MiB | 32 thread(s) | +| `sample_typical` | `ref_sample_typical` | libref | `n_cand=1024 M=16` | - | 33124.30 | 14967.07 | 40671.52 | 20 | 26.2 | - | 129.50 KiB | 32 thread(s) | +| `ple_conv_bias` | `avx_ple_conv_bias` | libavx | `n=10240 width=4 dilation=1 dtype=bf16 M=64` | - | 33032.61 | 24075.34 | 42585.42 | 20 | 8.9 | - | 5.14 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=1024 dtype=bf16 act=none M=256` | - | 33026.38 | 14994.85 | 38984.90 | 20 | 9.1 | - | 3.50 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=24576 K=4096 group=128 dtype=fp8a8 M=9` | - | 33004.09 | 25998.50 | 41994.50 | 20 | 12.1 | - | 96.47 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 33002.03 | 23987.64 | 39982.70 | 20 | 16.7 | - | 32.04 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3072 K=1024 dtype=bf16 act=none M=16` | - | 33000.12 | 17991.07 | 37955.74 | 20 | 18.2 | - | 6.22 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=4096 group=128 dtype=fp8a8 M=8` | - | 32999.63 | 23990.14 | 42995.21 | 20 | 10.6 | - | 4.05 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=128 ks=0 bk=0 nt=0` | - | 32998.70 | 24005.35 | 57018.03 | 20 | 27.3 | - | 3.71 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=10240 K=4096 group=128 dtype=fp8a8 M=1` | - | 32997.33 | 17813.67 | 36013.18 | 20 | 9.1 | - | 40.03 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=3072 dtype=bf16 act=none M=448` | - | 32997.08 | 32034.80 | 33013.52 | 11 | 0.1 | - | 10.38 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=4608 K=4608 dtype=bf16 act=gelu M=2` | - | 32997.03 | 25002.66 | 39989.62 | 20 | 9.2 | - | 40.56 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=256 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 32995.92 | 18018.31 | 43995.17 | 20 | 22.7 | - | 2.54 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=1024 group=128 dtype=fp8a8 M=32` | - | 32995.68 | 21001.78 | 38997.88 | 20 | 13.6 | - | 4.28 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=4096 group=128 dtype=fp8a8 M=129` | - | 32995.13 | 24038.95 | 46997.18 | 20 | 18.2 | - | 4.77 MiB | 32 thread(s) | +| `logits_gemm` | `avx_logits_gemm` | libavx | `n_vocab=131072 n_embd=4096 dtype=bf16 M=1` | - | 32995.11 | 23994.72 | 38997.20 | 20 | 9.1 | - | 1.00 GiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=1024 group=128 dtype=fp8a8 M=1` | - | 32991.38 | 22000.66 | 39980.67 | 20 | 15.2 | - | 4.01 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=5120 K=1280 dtype=bf16 act=gelu M=8` | - | 32989.17 | 20981.63 | 62968.10 | 20 | 36.3 | - | 12.69 MiB | 32 thread(s) | +| `sample_typical` | `avx_sample_typical` | libavx | `n_cand=1024 M=8` | - | 32982.12 | 5700.18 | 40843.42 | 40 | 36.0 | - | 64.75 KiB | 32 thread(s) | +| `cast` | `avx_cast` | libavx | `n=5120 from=bf16 to=bf16 M=32` | - | 32981.04 | 14984.23 | 40003.00 | 20 | 21.3 | - | 640.00 KiB | 32 thread(s) | +| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=256` | - | 32977.81 | 18009.27 | 43969.60 | 20 | 16.6 | - | 2.37 GiB | 32 thread(s) | +| `row_topk` | `avx_row_topk` | libavx | `N=248320 R=32 dtype=bf16 M=8 nch=0 pt1=8` | - | 32640.51 | 14590.48 | 47042.20 | 20 | 15.0 | - | 3.79 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=4096 group=128 dtype=fp8a8 M=32` | - | 32564.12 | 17996.56 | 41993.62 | 20 | 14.2 | - | 16.38 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5376 group=128 dtype=fp8a8 M=4` | - | 32509.25 | 25029.15 | 35988.72 | 20 | 9.2 | - | 21.05 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | - | 32500.44 | 19993.76 | 40000.43 | 20 | 15.4 | - | 32.10 MiB | 32 thread(s) | +| `gdn_chunk_scan` | `ref_gdn_chunk_scan` | libref | `head_k=128 head_v=128 scale=0.0883883 M=32 chunk=64` | - | 32488.36 | 19611.04 | 48781.00 | 20 | 34.2 | - | 7.20 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5376 group=128 dtype=fp8a8 M=2` | - | 32488.11 | 23994.49 | 37869.83 | 20 | 13.9 | - | 21.03 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=256 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 32486.47 | 25026.58 | 47985.35 | 20 | 24.6 | - | 2.85 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=256 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 32471.74 | 25979.67 | 38987.05 | 20 | 13.8 | - | 2.58 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3072 K=1024 dtype=bf16 act=none M=448` | - | 32328.81 | 17864.80 | 46005.50 | 20 | 35.6 | - | 12.13 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=4096 group=128 dtype=fp8a8 M=2` | - | 32328.03 | 10031.45 | 38015.72 | 20 | 32.5 | - | 4.01 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=8192 group=128 dtype=fp8a8 M=1` | - | 32002.84 | 20980.84 | 42005.89 | 20 | 17.2 | - | 32.02 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1280 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 32002.62 | 18983.77 | 43797.70 | 20 | 25.0 | - | 12.55 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=5120 K=1280 dtype=bf16 act=gelu M=2` | - | 32001.03 | 17926.95 | 48065.17 | 20 | 18.8 | - | 12.55 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=4608 K=4608 dtype=bf16 act=gelu M=4` | - | 32000.85 | 18988.30 | 39002.50 | 20 | 12.5 | - | 40.61 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=24576 K=4096 group=128 dtype=fp8a8 M=1` | - | 31995.75 | 23993.63 | 35700.44 | 20 | 7.8 | - | 96.06 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=24576 K=4096 group=128 dtype=fp8a8 M=18` | - | 31994.16 | 20016.52 | 34005.42 | 20 | 10.9 | - | 96.93 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=4304 dtype=bf16 act=none M=4` | - | 31987.04 | 25003.33 | 38005.22 | 20 | 11.0 | - | 9.51 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=4096 group=128 dtype=fp8a8 M=4` | - | 31732.39 | 8991.04 | 41987.04 | 20 | 34.6 | - | 4.02 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 31563.37 | 16257.93 | 48851.04 | 20 | 37.9 | - | 32.03 MiB | 32 thread(s) | +| `cast` | `avx_cast` | libavx | `n=5120 from=bf16 to=bf16 M=4` | - | 31523.93 | 21012.84 | 39994.55 | 20 | 19.2 | - | 80.00 KiB | 32 thread(s) | +| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=248320 M=8` | - | 31523.25 | 14846.85 | 31912.71 | 20 | 9.5 | - | 7.58 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1280 K=5120 dtype=bf16 act=none M=8` | - | 31510.54 | 17995.10 | 39012.81 | 20 | 23.8 | - | 12.62 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=1024 group=128 dtype=fp8a8 M=33` | - | 31508.20 | 26975.07 | 42947.82 | 20 | 14.3 | - | 4.29 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=1024 dtype=bf16 act=none M=256` | - | 31504.75 | 17960.94 | 42931.29 | 20 | 28.7 | - | 3.50 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=4304 dtype=bf16 act=none M=1` | - | 31502.08 | 23988.71 | 39027.85 | 20 | 19.1 | - | 9.47 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=256 K=4096 group=128 dtype=fp8a8 M=33` | - | 31497.09 | 9997.99 | 34988.46 | 20 | 30.1 | - | 1.15 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5376 K=4096 group=128 dtype=fp8a8 M=8` | - | 31495.81 | 11999.46 | 41995.06 | 20 | 41.3 | - | 21.12 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5376 group=128 dtype=fp8a8 M=1` | - | 31485.17 | 24009.82 | 38007.51 | 20 | 11.1 | - | 21.02 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=12288 K=5120 group=128 dtype=fp8a8 M=4` | - | 31467.30 | 11995.27 | 50996.68 | 20 | 33.4 | - | 60.12 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=17` | - | 31397.71 | 24193.51 | 36109.64 | 20 | 11.6 | - | 16.27 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=1024 dtype=bf16 act=none M=64` | - | 31023.88 | 17994.76 | 39938.10 | 20 | 28.9 | - | 2.38 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=1152 dtype=bf16 act=none M=1` | - | 31014.93 | 17996.00 | 33995.55 | 20 | 12.9 | - | 2.54 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1280 K=5120 dtype=bf16 act=none M=1` | - | 31014.22 | 20004.16 | 41994.97 | 20 | 14.4 | - | 12.52 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=4608 K=4608 dtype=bf16 act=gelu M=1` | - | 31008.18 | 18006.34 | 36007.28 | 20 | 19.3 | - | 40.54 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=4096 group=128 dtype=fp8a8 M=33` | - | 31006.96 | 20000.63 | 42000.97 | 20 | 19.3 | - | 4.20 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1280 K=1280 dtype=bf16 act=none M=16` | - | 31003.50 | 20995.27 | 42011.86 | 20 | 19.4 | - | 3.24 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=10240 K=4096 group=128 dtype=fp8a8 M=4` | - | 30998.99 | 8997.03 | 53999.42 | 20 | 29.1 | - | 40.10 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | - | 30994.99 | 16709.70 | 39006.42 | 20 | 11.3 | - | 2.84 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | - | 30994.35 | 19003.17 | 38004.20 | 20 | 9.7 | - | 4.09 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=1536 dtype=bf16 act=none M=1` | - | 30987.96 | 21001.69 | 42005.69 | 20 | 6.5 | - | 3.38 MiB | 32 thread(s) | +| `sample_temp` | `ref_sample_temp` | libref | `n_vocab=248320 M=1` | - | 30917.22 | 13962.63 | 36960.14 | 20 | 16.2 | - | 970.09 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5376 K=4096 group=128 dtype=fp8a8 M=1` | - | 30868.76 | 17001.60 | 36988.56 | 20 | 17.4 | - | 21.02 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=1024 group=128 dtype=fp8a8 M=129` | - | 30506.76 | 12008.44 | 41988.09 | 20 | 31.2 | - | 5.14 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1280 K=5120 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 30504.66 | 25004.91 | 36006.83 | 20 | 13.1 | - | 12.52 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=256 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 30502.86 | 17986.19 | 40977.79 | 20 | 13.1 | - | 2.85 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=4096 group=128 dtype=fp8a8 M=65` | - | 30494.05 | 10983.44 | 39004.86 | 20 | 32.8 | - | 4.39 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=128 K=4096 dtype=bf16 M=65 tile=0` | - | 30493.80 | 17999.23 | 50001.55 | 20 | 31.1 | - | 1.52 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | - | 30493.32 | 26010.14 | 42000.74 | 20 | 18.0 | - | 3.26 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5376 K=4096 group=128 dtype=fp8a8 M=32` | - | 30491.27 | 11996.82 | 42000.90 | 20 | 32.8 | - | 21.46 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1280 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 30487.60 | 20992.92 | 45991.79 | 20 | 34.5 | - | 12.92 MiB | 32 thread(s) | +| `cast` | `avx_cast` | libavx | `n=5120 from=bf16 to=bf16 M=128` | - | 30063.07 | 17574.13 | 37987.33 | 20 | 14.2 | - | 2.50 MiB | 32 thread(s) | +| `cast` | `avx_cast` | libavx | `n=5120 from=bf16 to=bf16 M=64` | - | 30040.41 | 17014.85 | 42576.46 | 20 | 23.3 | - | 1.25 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=5120 K=1280 dtype=bf16 act=gelu M=1` | - | 30030.24 | 12037.75 | 45026.59 | 20 | 31.6 | - | 12.53 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=1024 group=128 dtype=fp8a8 M=8` | - | 30014.15 | 19999.72 | 39964.50 | 20 | 16.7 | - | 4.07 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=1152 dtype=bf16 act=none M=16` | - | 30012.42 | 19992.76 | 39003.71 | 20 | 26.6 | - | 2.64 MiB | 32 thread(s) | +| `sample_logprobs` | `ref_sample_logprobs` | libref | `n_vocab=248320 k=21 M=4` | - | 30012.36 | 22731.75 | 39308.59 | 20 | 13.7 | - | 3.79 MiB | 32 thread(s) | +| `cast` | `ref_cast` | libref | `n=5120 from=bf16 to=bf16 M=32` | - | 30007.58 | 13055.52 | 43938.27 | 20 | 21.2 | - | 640.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=10240 K=4096 group=128 dtype=fp8a8 M=2` | - | 30005.89 | 23983.13 | 43003.17 | 20 | 30.0 | - | 40.05 MiB | 32 thread(s) | +| `embed_lookup` | `ref_embed_lookup` | libref | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=128` | - | 30004.71 | 15089.50 | 44872.36 | 20 | 26.7 | - | 2.37 GiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=5376 group=128 dtype=fp8a8 M=18` | - | 30003.82 | 19979.86 | 49002.61 | 20 | 30.0 | - | 21.24 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | - | 30003.49 | 24007.37 | 35994.57 | 20 | 8.3 | - | 2.82 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=3072 dtype=bf16 act=none M=64` | - | 30002.48 | 14993.13 | 41997.14 | 20 | 35.0 | - | 6.63 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=8192 act=silu dtype=bf16 M=512` | - | 30001.54 | 23084.80 | 35998.50 | 20 | 11.5 | - | 24.00 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4608 K=4096 group=128 dtype=fp8a8 M=1` | - | 30001.10 | 19996.30 | 35998.64 | 20 | 5.0 | - | 18.02 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1280 K=2304 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 30001.09 | 24248.36 | 33002.12 | 20 | 6.7 | - | 5.64 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=4096 group=128 dtype=fp8a8 M=32` | - | 29999.80 | 27001.58 | 38990.72 | 16 | 0.0 | - | 4.19 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=1024 group=128 dtype=fp8a8 M=65` | - | 29999.55 | 23987.38 | 39993.44 | 20 | 16.6 | - | 4.57 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=24576 K=4096 group=128 dtype=fp8a8 M=33` | - | 29999.33 | 20997.65 | 41994.18 | 20 | 15.0 | - | 97.69 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=128 dtype=fp8a8 M=65` | - | 29998.67 | 16999.12 | 45002.44 | 20 | 26.6 | - | 5.45 MiB | 32 thread(s) | +| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=16` | - | 29997.56 | 14982.14 | 44986.37 | 16 | 0.0 | - | 2.37 GiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=1` | - | 29997.38 | 15981.50 | 33018.16 | 20 | 10.0 | - | 9.48 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=3072 dtype=bf16 act=none M=448` | - | 29997.10 | 15311.75 | 49720.26 | 20 | 43.4 | - | 10.38 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=2048 dtype=bf16 act=none M=64` | - | 29997.02 | 14997.38 | 38998.96 | 20 | 20.0 | - | 4.50 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=4304 dtype=bf16 act=none M=8` | - | 29996.84 | 18004.71 | 41978.00 | 20 | 30.0 | - | 9.56 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=8192 act=silu dtype=bf16 M=64` | - | 29996.30 | 21379.56 | 41998.40 | 20 | 23.9 | - | 3.00 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 29995.85 | 18991.71 | 35993.82 | 20 | 11.7 | - | 64.01 KiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=128 K=4096 dtype=bf16 M=512 tile=0` | - | 29994.90 | 17998.28 | 35997.74 | 20 | 15.0 | - | 5.12 MiB | 32 thread(s) | +| `logits_gemm` | `avx_logits_gemm` | libavx | `n_vocab=131072 n_embd=4096 dtype=bf16 M=2` | - | 29994.07 | 23997.39 | 37002.72 | 20 | 11.6 | - | 1.00 GiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=1536 dtype=bf16 act=none M=2` | - | 29993.79 | 20884.95 | 37827.12 | 20 | 20.0 | - | 3.39 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | - | 29993.66 | 16990.77 | 39002.04 | 20 | 25.0 | - | 160.01 KiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3456 K=1152 dtype=bf16 act=none M=1` | - | 29992.56 | 15008.69 | 42010.44 | 20 | 33.7 | - | 7.62 MiB | 32 thread(s) | +| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | `head_k=128 M=256 chunk=64` | - | 29992.55 | 12013.48 | 41994.74 | 20 | 27.3 | - | 2.59 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=1536 dtype=bf16 act=none M=8` | - | 29992.36 | 19000.40 | 36005.45 | 20 | 16.6 | - | 3.44 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=2048 K=1024 dtype=bf16 act=none M=256` | - | 29991.86 | 17971.53 | 34619.21 | 20 | 21.7 | - | 6.50 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=128 dtype=fp8a8 M=129` | - | 29991.62 | 13996.27 | 38995.26 | 20 | 30.0 | - | 5.90 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=4096 group=128 dtype=fp8a8 M=1` | - | 29990.54 | 25009.98 | 35991.98 | 20 | 8.3 | - | 4.01 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=4096 group=128 dtype=fp8a8 M=2` | - | 29990.29 | 17987.29 | 32996.89 | 20 | 15.0 | - | 4.01 MiB | 32 thread(s) | +| `cast` | `avx_cast` | libavx | `n=5120 from=bf16 to=bf16 M=256` | - | 29990.06 | 18031.53 | 50965.36 | 20 | 21.6 | - | 5.00 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1280 K=5120 dtype=bf16 act=none M=4` | - | 29989.60 | 16840.28 | 42943.01 | 20 | 18.4 | - | 12.56 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1024 K=4096 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 29989.10 | 11997.18 | 30006.58 | 20 | 15.0 | - | 8.04 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=260` | - | 29987.91 | 20987.90 | 37997.96 | 20 | 13.4 | - | 4.33 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 29987.87 | 12976.14 | 41992.40 | 20 | 38.3 | - | 4.12 MiB | 32 thread(s) | +| `cast` | `ref_cast` | libref | `n=4096 from=bf16 to=bf16 M=64` | - | 29987.73 | 14999.67 | 29997.68 | 20 | 23.2 | - | 1.00 MiB | 32 thread(s) | +| `gdn_conv_update` | `avx_gdn_conv_update` | libavx | `head_k=128 head_v=128 conv_width=4 q_len=4` | - | 29987.40 | 12055.81 | 35987.64 | 20 | 20.1 | - | 360.03 KiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=1024 dtype=bf16 act=none M=448` | - | 29986.83 | 17109.31 | 35874.68 | 20 | 28.9 | - | 4.63 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=1152 dtype=bf16 act=none M=2` | - | 29985.02 | 17984.11 | 45019.38 | 20 | 28.3 | - | 2.55 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | - | 29984.43 | 17888.97 | 38971.54 | 20 | 8.3 | - | 888.02 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5120 group=128 dtype=bf16 M=16` | - | 29984.21 | 14001.02 | 30003.32 | 20 | 25.0 | - | 242.50 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=1024 group=128 dtype=fp8a8 M=1` | - | 29983.98 | 17986.64 | 35998.11 | 20 | 5.0 | - | 4.01 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=1024 group=128 dtype=fp8a8 M=4` | - | 29983.23 | 20995.83 | 30992.59 | 20 | 12.2 | - | 4.04 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=24576 K=4096 group=128 dtype=fp8a8 M=4` | - | 29981.62 | 14994.64 | 30005.03 | 20 | 10.0 | - | 96.22 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=24576 group=128 dtype=fp8a8 M=2` | - | 29977.97 | 15013.69 | 33012.26 | 20 | 8.3 | - | 96.08 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=24576 group=128 dtype=bf16 M=512` | - | 29968.01 | 22656.39 | 34704.92 | 20 | 13.7 | - | 36.38 MiB | 32 thread(s) | +| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=1024 M=32` | - | 29967.34 | 5969.65 | 31985.07 | 40 | 14.4 | - | 131.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=6144 group=128 dtype=bf16 M=64` | - | 29959.80 | 14998.17 | 29999.00 | 20 | 24.9 | - | 1.14 MiB | 32 thread(s) | +| `layernorm` | `ref_layernorm` | libref | `n=1280 eps=1e-06 dtype=bf16 M=128` | - | 29938.42 | 18003.63 | 35863.95 | 20 | 10.0 | - | 645.00 KiB | 32 thread(s) | +| `sample_mask` | `ref_sample_mask` | libref | `n_vocab=248320 M=1` | - | 29897.80 | 22853.55 | 41875.20 | 20 | 15.2 | - | 1000.41 KiB | 32 thread(s) | +| `sample_mask` | `avx_sample_mask` | libavx | `n_vocab=248320 M=1` | - | 29878.44 | 18332.02 | 34701.94 | 16 | 0.1 | - | 1000.41 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=8192 group=128 dtype=bf16 M=64` | - | 29842.66 | 14991.90 | 29995.63 | 20 | 24.5 | - | 1.52 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=2048 dtype=bf16 act=none M=448` | - | 29825.50 | 20976.52 | 42984.23 | 20 | 28.1 | - | 7.50 MiB | 32 thread(s) | +| `sample_typical` | `avx_sample_typical` | libavx | `n_cand=1024 M=2` | - | 29796.26 | 3689.74 | 39040.64 | 40 | 44.7 | - | 16.19 KiB | 32 thread(s) | +| `sample_dry` | `avx_sample_dry` | libavx | `n_vocab=248320 M=2` | - | 29767.94 | 22828.25 | 35789.33 | 20 | 20.1 | - | 1.90 MiB | 32 thread(s) | +| `embed_lookup` | `ref_embed_lookup` | libref | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=256` | - | 29708.98 | 17172.54 | 41066.39 | 20 | 23.4 | - | 2.37 GiB | 32 thread(s) | +| `row_topk` | `avx_row_topk` | libavx | `N=248320 R=32 dtype=bf16 M=1 nch=0 pt1=8` | - | 29648.80 | 13726.65 | 38883.23 | 20 | 15.2 | - | 485.50 KiB | 32 thread(s) | +| `cast` | `ref_cast` | libref | `n=5120 from=bf16 to=bf16 M=64` | - | 29561.71 | 16150.87 | 41999.15 | 20 | 20.3 | - | 1.25 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 29503.15 | 9995.81 | 35990.82 | 20 | 32.2 | - | 4.08 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4608 K=4096 group=128 dtype=fp8a8 M=258` | - | 29496.76 | 18000.43 | 33996.63 | 20 | 18.6 | - | 21.31 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=24576 group=128 dtype=fp8a8 M=8` | - | 29496.34 | 19993.50 | 44012.51 | 20 | 16.9 | - | 96.27 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=4096 group=128 dtype=fp8a8 M=128` | - | 29493.99 | 12999.46 | 35997.47 | 20 | 30.5 | - | 17.52 MiB | 32 thread(s) | +| `cast` | `ref_cast` | libref | `n=4096 from=bf16 to=bf16 M=32` | - | 29493.58 | 11035.64 | 33000.37 | 20 | 25.6 | - | 512.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5376 K=4096 group=128 dtype=fp8a8 M=2` | - | 29490.67 | 11981.94 | 35989.18 | 20 | 16.9 | - | 21.03 MiB | 32 thread(s) | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | `N=240 K=4096 dtype=bf16 M=8` | - | 29483.91 | 11998.26 | 35989.40 | 20 | 17.2 | - | 3.82 MiB | 32 thread(s) | +| `ple_conv_bias` | `ref_ple_conv_bias` | libref | `n=10240 width=4 dilation=1 dtype=bf16 M=128` | - | 29473.38 | 19967.46 | 35640.57 | 20 | 16.3 | - | 10.14 MiB | 32 thread(s) | +| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=248320 M=4` | - | 29445.92 | 11519.79 | 32517.64 | 20 | 25.2 | - | 3.79 MiB | 32 thread(s) | +| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | `head_k=128 M=512 chunk=64` | - | 29445.55 | 13080.99 | 36562.40 | 20 | 28.1 | - | 5.19 MiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=512` | - | 29422.96 | 14368.51 | 38422.41 | 20 | 20.6 | - | 14.07 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=17408 group=128 dtype=bf16 M=4` | - | 29264.09 | 14983.88 | 30006.33 | 20 | 24.9 | - | 206.12 KiB | 32 thread(s) | +| `cast` | `avx_cast` | libavx | `n=5120 from=bf16 to=bf16 M=512` | - | 29175.40 | 15050.11 | 38904.56 | 20 | 27.4 | - | 10.00 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=2048 K=1024 dtype=bf16 act=none M=448` | - | 29138.35 | 20989.92 | 35040.37 | 20 | 16.5 | - | 8.38 MiB | 32 thread(s) | +| `embed_lookup` | `ref_embed_lookup` | libref | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=16` | - | 29010.56 | 13818.83 | 35997.02 | 20 | 25.3 | - | 2.37 GiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=1024 group=128 dtype=fp8a8 M=9` | - | 29002.65 | 18008.46 | 35999.25 | 20 | 15.5 | - | 4.08 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 28999.74 | 14000.00 | 31005.24 | 20 | 13.8 | - | 4.06 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=3072 dtype=bf16 act=none M=256` | - | 28999.29 | 22014.19 | 36019.66 | 20 | 20.7 | - | 8.50 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=128 dtype=fp8a8 M=18` | - | 28998.88 | 11991.05 | 37984.37 | 20 | 20.7 | - | 5.13 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=24576 group=128 dtype=fp8a8 M=9` | - | 28998.79 | 17975.26 | 38616.83 | 20 | 27.6 | - | 96.30 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=128 K=4096 dtype=bf16 M=512 tile=0` | - | 28995.58 | 11991.26 | 41996.85 | 20 | 37.9 | - | 5.12 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3072 K=1024 dtype=bf16 act=none M=4` | - | 28995.46 | 11981.65 | 31995.88 | 20 | 19.0 | - | 6.06 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=128 K=4096 dtype=bf16 M=130 tile=0` | - | 28992.86 | 11510.35 | 38026.40 | 20 | 25.8 | - | 2.05 MiB | 32 thread(s) | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=16` | - | 28992.75 | 22842.20 | 42985.81 | 20 | 31.0 | - | 96.64 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=128 dtype=fp8a8 M=4` | - | 28990.59 | 23010.44 | 37001.85 | 20 | 15.5 | - | 5.03 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4608 K=4096 group=128 dtype=fp8a8 M=65` | - | 28987.81 | 9956.36 | 34069.21 | 20 | 15.5 | - | 18.84 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=1024 group=128 dtype=fp8a8 M=32` | - | 28981.29 | 18976.48 | 30002.50 | 20 | 10.4 | - | 4.28 MiB | 32 thread(s) | +| `sample_mask` | `ref_sample_mask` | libref | `n_vocab=248320 M=2` | - | 28976.15 | 10838.12 | 35775.43 | 20 | 25.9 | - | 1.95 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | - | 28950.18 | 11996.45 | 47027.50 | 20 | 44.9 | - | 3.38 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=17408 group=128 dtype=bf16 M=64` | - | 28773.44 | 16780.63 | 33001.18 | 20 | 21.3 | - | 3.22 MiB | 32 thread(s) | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | `N=304 K=4096 dtype=bf16 M=16` | - | 28713.85 | 15762.91 | 37147.57 | 20 | 24.4 | - | 4.89 MiB | 32 thread(s) | +| `scatter_rows` | `ref_scatter_rows` | libref | `n=4096 dtype=bf16 M=512` | - | 28561.30 | 19438.88 | 40072.36 | 20 | 15.8 | - | 20.00 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=4096 group=128 dtype=fp8a8 M=9` | - | 28514.01 | 15007.61 | 30005.21 | 20 | 10.5 | - | 16.11 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=17408 group=128 dtype=bf16 M=8` | - | 28500.47 | 14007.93 | 35982.57 | 20 | 13.9 | - | 412.25 KiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1280 K=1280 dtype=bf16 act=none M=2` | - | 28498.48 | 20008.27 | 48571.71 | 20 | 15.8 | - | 3.14 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=4096 group=128 dtype=fp8a8 M=33` | - | 28496.00 | 18004.17 | 31007.08 | 20 | 10.5 | - | 4.20 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=4304 dtype=bf16 act=none M=16` | - | 28495.66 | 18001.84 | 45053.72 | 20 | 15.9 | - | 9.66 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=12288 group=128 dtype=fp8a8 M=33` | - | 28493.88 | 14001.88 | 33007.27 | 20 | 24.6 | - | 48.66 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3456 K=1152 dtype=bf16 act=none M=1` | - | 28481.66 | 12000.27 | 39980.58 | 20 | 28.1 | - | 7.62 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 28259.37 | 15992.20 | 34820.92 | 20 | 7.0 | - | 112.01 KiB | 32 thread(s) | +| `sample_logprobs` | `ref_sample_logprobs` | libref | `n_vocab=248320 k=21 M=1` | - | 28076.22 | 11016.62 | 31717.65 | 20 | 18.0 | - | 970.27 KiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=5120 K=1280 dtype=bf16 act=gelu M=4` | - | 28054.82 | 18083.32 | 36086.35 | 20 | 16.1 | - | 12.60 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=5 splits=0` | - | 28027.24 | 18243.65 | 32868.99 | 20 | 11.6 | - | 16.08 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=1536 dtype=bf16 act=none M=4` | - | 28016.05 | 12987.25 | 33008.86 | 20 | 5.4 | - | 3.41 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=1536 dtype=bf16 act=none M=16` | - | 28011.53 | 19996.81 | 37008.53 | 20 | 17.9 | - | 3.49 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | - | 28002.95 | 18000.90 | 38993.89 | 20 | 19.6 | - | 2.83 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=24576 K=4096 group=128 dtype=fp8a8 M=8` | - | 28001.18 | 22991.31 | 34984.17 | 20 | 5.4 | - | 96.42 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=1024 group=128 dtype=fp8a8 M=33` | - | 27999.56 | 20998.85 | 39402.05 | 20 | 22.1 | - | 4.29 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | - | 27998.43 | 12000.13 | 34103.47 | 20 | 12.5 | - | 224.01 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=128 dtype=fp8a8 M=2` | - | 27997.89 | 16988.82 | 36994.17 | 20 | 25.0 | - | 5.01 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=96 K=5120 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 27997.35 | 19005.26 | 43983.74 | 20 | 23.2 | - | 980.38 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=12288 group=128 dtype=fp8a8 M=8` | - | 27991.66 | 11968.45 | 29999.85 | 20 | 10.7 | - | 48.17 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=128 dtype=fp8a8 M=36` | - | 27991.31 | 15988.52 | 40995.07 | 20 | 28.6 | - | 5.25 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=256 K=4096 group=128 dtype=fp8a8 M=512` | - | 27989.44 | 12001.29 | 34995.49 | 20 | 19.7 | - | 3.31 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 27987.06 | 8006.25 | 32009.77 | 20 | 16.6 | - | 80.01 KiB | 32 thread(s) | +| `sample_temp` | `ref_sample_temp` | libref | `n_vocab=248320 M=2` | - | 27985.42 | 11457.14 | 30797.29 | 20 | 13.4 | - | 1.89 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=4304 dtype=bf16 act=none M=32` | - | 27983.48 | 20014.18 | 34015.62 | 20 | 12.4 | - | 9.86 MiB | 32 thread(s) | +| `scatter_rows` | `avx_scatter_rows` | libavx | `n=5120 dtype=bf16 M=4` | - | 27958.13 | 16078.55 | 39492.19 | 20 | 9.0 | - | 200.02 KiB | 32 thread(s) | +| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=248320 M=1` | - | 27898.63 | 15862.30 | 35885.23 | 20 | 28.4 | - | 970.09 KiB | 32 thread(s) | +| `lili_attn` | `ref_lili_attn` | libref | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=448` | - | 27771.50 | 21612.46 | 29925.07 | 20 | 8.6 | - | 3.50 MiB | 32 thread(s) | +| `sample_typical` | `avx_sample_typical` | libavx | `n_cand=1024 M=4` | - | 27677.90 | 5409.24 | 35970.17 | 40 | 31.3 | - | 32.38 KiB | 32 thread(s) | +| `sample_logprobs` | `ref_sample_logprobs` | libref | `n_vocab=248320 k=21 M=2` | - | 27604.91 | 21255.20 | 38086.83 | 20 | 20.9 | - | 1.90 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4608 K=4096 group=128 dtype=fp8a8 M=2` | - | 27546.11 | 17859.89 | 36976.54 | 20 | 12.7 | - | 18.03 MiB | 32 thread(s) | +| `gated_quant_fp8` | `ref_gated_quant_fp8` | libref | `n=17408 group=128 dtype=bf16 act=silu M=16` | - | 27539.77 | 13893.05 | 32991.62 | 20 | 26.7 | - | 1.87 MiB | 32 thread(s) | +| `gated_quant_fp8` | `ref_gated_quant_fp8` | libref | `n=17408 group=128 dtype=bf16 act=silu M=128` | - | 27526.91 | 19205.85 | 44997.48 | 20 | 27.3 | - | 14.94 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=128 K=4096 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 27524.63 | 14980.53 | 33005.93 | 20 | 10.9 | - | 1.14 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3840 K=1280 dtype=bf16 act=none M=8` | - | 27511.95 | 20001.17 | 45000.31 | 20 | 17.0 | - | 9.52 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=12288 group=128 dtype=fp8a8 M=64` | - | 27500.99 | 19999.10 | 30982.01 | 20 | 12.7 | - | 49.28 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=5376 group=128 dtype=fp8a8 M=9` | - | 27499.94 | 17996.24 | 43002.36 | 20 | 16.4 | - | 21.12 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3840 K=1280 dtype=bf16 act=none M=2` | - | 27498.49 | 17990.81 | 35986.29 | 20 | 16.3 | - | 9.42 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4608 K=4096 group=128 dtype=fp8a8 M=128` | - | 27497.33 | 14995.23 | 30998.39 | 20 | 27.3 | - | 19.64 MiB | 32 thread(s) | +| `attn_dense` | `ref_attn_dense` | libref | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=32` | - | 27494.60 | 18009.88 | 32995.89 | 20 | 21.8 | - | 20.01 KiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=3072 dtype=bf16 act=none M=256` | - | 27491.74 | 17999.47 | 37125.81 | 20 | 16.4 | - | 8.50 MiB | 32 thread(s) | +| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | `head_k=128 M=16 chunk=64` | - | 27464.91 | 14037.21 | 29997.53 | 20 | 19.9 | - | 166.01 KiB | 32 thread(s) | +| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=512` | - | 27082.23 | 16005.50 | 38285.78 | 20 | 29.6 | - | 2.37 GiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=5376 group=128 dtype=fp8a8 M=8` | - | 27012.33 | 18995.25 | 35977.96 | 20 | 14.8 | - | 21.11 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=2048 K=1024 dtype=bf16 act=none M=4` | - | 27005.76 | 9972.62 | 31008.44 | 20 | 24.0 | - | 4.04 MiB | 32 thread(s) | +| `cast` | `avx_cast` | libavx | `n=4096 from=bf16 to=bf16 M=64` | - | 27002.60 | 15010.16 | 42990.70 | 20 | 31.5 | - | 1.00 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=1024 group=128 dtype=fp8a8 M=65` | - | 27002.46 | 17994.52 | 35997.78 | 20 | 16.6 | - | 4.57 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=128 K=4096 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 27001.39 | 16456.77 | 33991.89 | 20 | 20.3 | - | 1.02 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=1152 dtype=bf16 act=none M=4` | - | 27001.08 | 17995.70 | 36008.43 | 20 | 29.6 | - | 2.56 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 27000.43 | 15000.15 | 36001.43 | 20 | 22.2 | - | 4.02 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=4096 dtype=bf16 act=none M=128` | - | 27000.27 | 20996.25 | 38992.31 | 20 | 20.3 | - | 9.50 MiB | 32 thread(s) | +| `dflash_select` | `avx_dflash_select` | libavx | `steps=7 top_k=16 rank=256 n_vocab=248320 anchor_stride=8 dtype=bf16 M=4` | - | 27000.12 | 17006.48 | 31985.02 | 20 | 11.1 | - | 242.52 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=2048 dtype=bf16 act=none M=1` | - | 27000.07 | 12004.51 | 28996.03 | 20 | 3.7 | - | 4.01 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=128 K=4096 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 26999.05 | 19006.49 | 36003.68 | 20 | 12.3 | - | 1.52 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=4096 group=128 dtype=fp8a8 M=18` | - | 26998.83 | 17944.33 | 38022.89 | 20 | 20.4 | - | 4.11 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=4096 group=128 dtype=fp8a8 M=8` | - | 26998.54 | 18991.84 | 32991.86 | 20 | 7.4 | - | 4.05 MiB | 32 thread(s) | +| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=256` | - | 26998.09 | 14995.47 | 32991.79 | 20 | 14.8 | - | 1.00 GiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=4096 group=128 dtype=fp8a8 M=2` | - | 26998.06 | 26997.33 | 27000.01 | 6 | 0.0 | - | 16.03 MiB | 32 thread(s) | +| `embed_lookup` | `ref_embed_lookup` | libref | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=512` | - | 26997.95 | 20611.92 | 41647.17 | 20 | 16.7 | - | 2.37 GiB | 32 thread(s) | +| `row_topk` | `avx_row_topk` | libavx | `N=248320 R=32 dtype=bf16 M=16 nch=0 pt1=8` | - | 26997.69 | 18066.31 | 39354.99 | 20 | 21.6 | - | 7.59 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | - | 26997.47 | 17998.56 | 36002.60 | 20 | 20.4 | - | 2.88 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=4096 dtype=bf16 act=none M=4` | - | 26997.27 | 8992.25 | 32475.49 | 19 | 0.0 | - | 8.05 MiB | 32 thread(s) | +| `cast` | `avx_cast` | libavx | `n=5120 from=bf16 to=bf16 M=8` | - | 26996.99 | 17000.35 | 41993.59 | 20 | 9.3 | - | 160.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=4096 group=128 dtype=fp8a8 M=64` | - | 26996.84 | 15003.11 | 30972.02 | 20 | 11.1 | - | 16.76 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4608 K=4096 group=128 dtype=fp8a8 M=64` | - | 26996.65 | 11041.15 | 38980.94 | 20 | 46.3 | - | 18.82 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=128 dtype=fp8a8 M=8` | - | 26996.40 | 17991.41 | 28993.90 | 20 | 16.7 | - | 5.06 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=128 K=4096 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 26996.15 | 17996.68 | 42992.85 | 20 | 37.0 | - | 1.13 MiB | 32 thread(s) | +| `sample_pick` | `avx_sample_pick` | libavx | `n_cand=1024 M=4` | - | 26996.14 | 5991.92 | 35999.56 | 26 | 5.6 | - | 32.39 KiB | 32 thread(s) | +| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | `head_k=128 head_v=128 scale=0.0883883 M=128 chunk=64` | - | 26996.11 | 14991.44 | 38987.16 | 20 | 20.4 | - | 10.80 MiB | 32 thread(s) | +| `sample_pick` | `avx_sample_pick` | libavx | `n_cand=1024 M=32` | - | 26995.71 | 5996.90 | 32994.03 | 40 | 25.0 | - | 259.12 KiB | 32 thread(s) | +| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | `head_k=128 M=32 chunk=64` | - | 26995.67 | 17985.58 | 35010.67 | 19 | 0.2 | - | 332.01 KiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 26995.60 | 16996.40 | 33996.57 | 20 | 22.2 | - | 4.02 MiB | 32 thread(s) | +| `cast` | `ref_cast` | libref | `n=4096 from=bf16 to=bf16 M=128` | - | 26994.66 | 13988.14 | 34992.56 | 20 | 16.7 | - | 2.00 MiB | 32 thread(s) | +| `gated_quant_fp8` | `avx_gated_quant_fp8` | libavx | `n=17408 group=128 dtype=bf16 act=silu M=4` | - | 26994.57 | 13007.12 | 35991.34 | 20 | 22.2 | - | 478.12 KiB | 32 thread(s) | +| `cast` | `avx_cast` | libavx | `n=5120 from=bf16 to=bf16 M=16` | - | 26993.92 | 13000.50 | 37007.04 | 20 | 20.4 | - | 320.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=1024 dtype=bf16 act=none M=1` | - | 26993.32 | 11990.35 | 32981.01 | 20 | 20.4 | - | 2.01 MiB | 32 thread(s) | +| `mul_weight` | `avx_mul_weight` | libavx | `n=8192 dtype=bf16 M=32` | - | 26993.25 | 14983.25 | 30007.61 | 20 | 25.9 | - | 1.02 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=20480 act=relu dtype=bf16 M=256` | - | 26992.69 | 17991.34 | 35991.93 | 20 | 27.5 | - | 30.00 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=128 K=4096 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 26992.29 | 17989.12 | 36001.46 | 20 | 18.5 | - | 1.06 MiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=4` | - | 26992.10 | 15024.00 | 35994.00 | 20 | 11.1 | - | 120.50 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=1024 group=128 dtype=fp8a8 M=9` | - | 26990.90 | 11995.65 | 37005.98 | 20 | 22.2 | - | 4.08 MiB | 32 thread(s) | +| `scatter_rows` | `avx_scatter_rows` | libavx | `n=4096 dtype=bf16 M=4` | - | 26990.39 | 11961.08 | 30995.83 | 20 | 27.7 | - | 160.02 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4608 K=4096 group=128 dtype=fp8a8 M=4` | - | 26989.68 | 17994.73 | 37990.52 | 20 | 16.7 | - | 18.05 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=4096 group=128 dtype=fp8a8 M=64` | - | 26988.84 | 14997.35 | 41989.81 | 20 | 33.3 | - | 4.38 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=6144 group=128 dtype=bf16 M=128` | - | 26988.22 | 17991.86 | 31587.41 | 20 | 12.9 | - | 2.27 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=4096 dtype=bf16 act=none M=256` | - | 26987.31 | 20979.77 | 37021.00 | 20 | 22.3 | - | 11.00 MiB | 32 thread(s) | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=248320 k=21 M=2` | - | 26987.04 | 11972.93 | 27008.13 | 20 | 19.2 | - | 1.90 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=32` | - | 26987.03 | 11990.96 | 29992.70 | 20 | 17.7 | - | 650.00 KiB | 32 thread(s) | +| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=1024 M=16` | - | 26984.99 | 5980.95 | 37973.65 | 40 | 36.5 | - | 65.50 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 26982.98 | 9618.19 | 27007.54 | 20 | 22.2 | - | 152.01 KiB | 32 thread(s) | +| `sample_pick` | `ref_sample_pick` | libref | `n_cand=1024 M=16` | - | 26977.89 | 17992.78 | 29952.42 | 20 | 13.0 | - | 129.56 KiB | 32 thread(s) | +| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | `head_k=128 M=2 chunk=64` | - | 26975.64 | 11990.60 | 29988.33 | 20 | 16.7 | - | 20.76 KiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3456 K=1152 dtype=bf16 act=none M=8` | - | 26973.90 | 18935.37 | 36036.70 | 20 | 18.5 | - | 7.72 MiB | 32 thread(s) | +| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=1024 M=64` | - | 26958.76 | 5979.88 | 29970.90 | 40 | 19.3 | - | 262.00 KiB | 32 thread(s) | +| `grid_embed_cpe` | `ref_grid_embed_cpe` | libref | `n=1280 side=128 n_prefix=10 dtype=bf16 M=128` | - | 26946.61 | 17950.86 | 35940.68 | 20 | 11.5 | - | 40.34 MiB | 32 thread(s) | +| `grid_embed_cpe` | `avx_grid_embed_cpe` | libavx | `n=1280 side=128 n_prefix=10 dtype=bf16 M=32` | - | 26939.11 | 14037.39 | 31912.20 | 20 | 5.8 | - | 40.10 MiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=64` | - | 26937.00 | 23912.28 | 35866.39 | 20 | 5.6 | - | 1.77 MiB | 32 thread(s) | +| `scatter_rows` | `avx_scatter_rows` | libavx | `n=4096 dtype=bf16 M=16` | - | 26933.48 | 22938.59 | 35920.54 | 20 | 7.3 | - | 640.06 KiB | 32 thread(s) | +| `embed_lookup` | `ref_embed_lookup` | libref | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=32` | - | 26931.04 | 19011.42 | 35988.92 | 20 | 18.5 | - | 1.00 GiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=64` | - | 26927.36 | 18282.32 | 33559.09 | 20 | 14.8 | - | 1.77 MiB | 32 thread(s) | +| `sample_penalties` | `avx_sample_penalties` | libavx | `n_vocab=248320 M=8` | - | 26925.34 | 14037.04 | 40963.43 | 20 | 16.9 | - | 7.58 MiB | 32 thread(s) | +| `sample_dry` | `ref_sample_dry` | libref | `n_vocab=248320 M=1` | - | 26895.27 | 13928.94 | 56820.66 | 20 | 44.5 | - | 970.41 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-05 dtype=bf16 M=512` | - | 26877.09 | 17990.50 | 27000.68 | 20 | 16.6 | - | 10.01 MiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=32` | - | 26858.68 | 17958.21 | 26962.51 | 20 | 16.3 | - | 908.00 KiB | 32 thread(s) | +| `cast` | `ref_cast` | libref | `n=4096 from=bf16 to=bf16 M=256` | - | 26834.71 | 11978.37 | 34988.80 | 20 | 18.8 | - | 4.00 MiB | 32 thread(s) | +| `gated_quant_fp8` | `avx_gated_quant_fp8` | libavx | `n=17408 group=128 dtype=bf16 act=silu M=256` | - | 26794.07 | 17996.94 | 35999.04 | 20 | 29.0 | - | 29.88 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=2048 act=relu dtype=bf16 M=256` | - | 26705.24 | 11886.00 | 38999.79 | 20 | 21.4 | - | 3.00 MiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=256` | - | 26697.17 | 10848.06 | 29722.08 | 20 | 7.7 | - | 7.04 MiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=256` | - | 26668.76 | 17648.58 | 26719.45 | 20 | 16.7 | - | 7.04 MiB | 32 thread(s) | +| `attn_dense` | `ref_attn_dense` | libref | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=64` | - | 26563.90 | 12920.37 | 37861.08 | 20 | 18.1 | - | 40.01 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=9` | - | 26543.95 | 23214.00 | 31650.75 | 20 | 9.4 | - | 16.14 MiB | 32 thread(s) | +| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=8` | - | 26511.02 | 17963.02 | 35998.54 | 20 | 33.9 | - | 1.00 GiB | 32 thread(s) | +| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=32` | - | 26502.76 | 17993.78 | 31025.74 | 20 | 18.8 | - | 2.37 GiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=3072 dtype=bf16 act=none M=128` | - | 26500.89 | 15003.17 | 28999.42 | 20 | 13.2 | - | 7.25 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=4096 group=128 dtype=fp8a8 M=129` | - | 26492.53 | 13018.48 | 29999.05 | 20 | 26.8 | - | 17.53 MiB | 32 thread(s) | +| `sample_argmax` | `avx_sample_argmax` | libavx | `n_vocab=248320 M=1` | - | 26492.36 | 17985.36 | 27000.68 | 20 | 17.0 | - | 970.10 KiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1280 K=1280 dtype=bf16 act=none M=32` | - | 26490.70 | 17987.11 | 35976.38 | 20 | 20.9 | - | 3.36 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3456 K=1152 dtype=bf16 act=none M=4` | - | 26486.66 | 17996.38 | 29994.15 | 20 | 18.8 | - | 7.66 MiB | 32 thread(s) | +| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=16` | - | 26485.45 | 11985.71 | 38721.53 | 20 | 17.0 | - | 1.00 GiB | 32 thread(s) | +| `sample_temp` | `ref_sample_temp` | libref | `n_vocab=1024 M=64` | - | 26481.85 | 14944.75 | 31951.29 | 20 | 17.0 | - | 262.00 KiB | 32 thread(s) | +| `sample_topp` | `avx_sample_topp` | libavx | `n_cand=1024 M=8` | - | 26475.86 | 5991.28 | 32992.46 | 40 | 20.7 | - | 64.75 KiB | 32 thread(s) | +| `mul_weight` | `ref_mul_weight` | libref | `n=8192 dtype=bf16 M=64` | - | 26466.62 | 17996.10 | 27007.49 | 20 | 16.7 | - | 2.02 MiB | 32 thread(s) | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=16` | - | 26457.74 | 16971.00 | 35959.63 | 20 | 17.0 | - | 160.06 KiB | 32 thread(s) | +| `sample_pick` | `ref_sample_pick` | libref | `n_cand=1024 M=64` | - | 26454.17 | 16053.21 | 37949.07 | 20 | 5.7 | - | 518.25 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=256` | - | 26445.23 | 12018.24 | 27014.33 | 20 | 15.0 | - | 256.50 KiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=8192 act=silu dtype=bf16 M=128` | - | 26440.57 | 13077.70 | 30007.34 | 20 | 20.7 | - | 6.00 MiB | 32 thread(s) | +| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | `head_k=128 M=4 chunk=64` | - | 26409.37 | 11979.79 | 38986.57 | 20 | 28.4 | - | 41.51 KiB | 32 thread(s) | +| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=8` | - | 26365.67 | 13996.00 | 35994.53 | 20 | 19.0 | - | 2.37 GiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=20480 act=relu dtype=bf16 M=128` | - | 26330.19 | 10313.29 | 35999.43 | 20 | 23.8 | - | 15.00 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=17408 group=128 dtype=bf16 M=32` | - | 26324.49 | 23988.58 | 36002.79 | 20 | 22.8 | - | 1.61 MiB | 32 thread(s) | +| `ple_conv_bias` | `ref_ple_conv_bias` | libref | `n=10240 width=4 dilation=1 dtype=bf16 M=32` | - | 26117.71 | 22279.01 | 29926.09 | 20 | 11.4 | - | 2.64 MiB | 32 thread(s) | +| `gated_quant_fp8` | `avx_gated_quant_fp8` | libavx | `n=17408 group=128 dtype=bf16 act=silu M=8` | - | 26102.08 | 17996.39 | 34950.33 | 20 | 21.0 | - | 956.25 KiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=4304 dtype=bf16 act=none M=2` | - | 26027.67 | 20996.60 | 35993.74 | 20 | 21.1 | - | 9.48 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=10` | - | 26019.60 | 22030.03 | 28452.32 | 20 | 8.2 | - | 16.16 MiB | 32 thread(s) | +| `gdn_gated_rmsnorm` | `avx_gdn_gated_rmsnorm` | libavx | `channels=128 eps=1e-06 act=silu M=128` | - | 26013.34 | 13990.29 | 34951.55 | 20 | 23.1 | - | 96.50 KiB | 32 thread(s) | +| `sample_dry` | `ref_sample_dry` | libref | `n_vocab=248320 M=8` | - | 26011.68 | 8989.44 | 43976.38 | 20 | 36.5 | - | 7.58 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=8` | - | 26006.50 | 17973.58 | 35875.38 | 20 | 15.4 | - | 9.61 MiB | 32 thread(s) | +| `cast` | `avx_cast` | libavx | `n=4096 from=bf16 to=bf16 M=128` | - | 26005.12 | 11990.50 | 36979.73 | 20 | 30.7 | - | 2.00 MiB | 32 thread(s) | +| `cast` | `avx_cast` | libavx | `n=4096 from=bf16 to=bf16 M=32` | - | 25999.86 | 11990.55 | 31925.25 | 20 | 17.2 | - | 512.00 KiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 25996.61 | 16982.46 | 32004.47 | 20 | 15.3 | - | 56.01 KiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | - | 25992.64 | 17991.90 | 36003.61 | 20 | 15.4 | - | 1.70 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3456 K=1152 dtype=bf16 act=none M=2` | - | 25990.28 | 16245.85 | 34028.91 | 20 | 17.3 | - | 7.63 MiB | 32 thread(s) | +| `layernorm` | `avx_layernorm` | libavx | `n=1280 eps=1e-06 dtype=bf16 M=64` | - | 25988.74 | 11009.89 | 34973.13 | 20 | 19.3 | - | 325.00 KiB | 32 thread(s) | +| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=64` | - | 25986.50 | 8985.23 | 35977.27 | 20 | 17.3 | - | 1.00 GiB | 32 thread(s) | +| `embed_lookup` | `ref_embed_lookup` | libref | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=32` | - | 25983.18 | 12005.76 | 40893.24 | 20 | 23.1 | - | 2.37 GiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=1152 dtype=bf16 act=none M=32` | - | 25975.52 | 18974.62 | 35046.01 | 20 | 17.4 | - | 2.74 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=5120 K=4608 dtype=bf16 act=none M=4` | - | 25975.27 | 11998.40 | 37000.34 | 20 | 30.8 | - | 45.12 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | - | 25969.56 | 17983.20 | 36007.84 | 20 | 17.3 | - | 2.87 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=4096 group=128 dtype=bf16 M=16` | - | 25954.55 | 6536.35 | 27000.28 | 40 | 28.1 | - | 194.00 KiB | 32 thread(s) | +| `sample_minp` | `avx_sample_minp` | libavx | `n_cand=1024 M=16` | - | 25935.31 | 4979.20 | 35950.83 | 40 | 49.9 | - | 129.50 KiB | 32 thread(s) | +| `ple_conv_bias` | `ref_ple_conv_bias` | libref | `n=10240 width=4 dilation=1 dtype=bf16 M=4` | - | 25932.06 | 14035.83 | 29980.51 | 20 | 17.3 | - | 460.02 KiB | 32 thread(s) | +| `sample_pick` | `avx_sample_pick` | libavx | `n_cand=1024 M=64` | - | 25927.05 | 5980.10 | 28083.11 | 31 | 11.5 | - | 518.25 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=11` | - | 25924.37 | 17995.78 | 36040.69 | 20 | 22.7 | - | 4.26 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=6144 group=128 dtype=bf16 M=512` | - | 25922.81 | 17994.19 | 39993.68 | 20 | 34.7 | - | 9.09 MiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=16` | - | 25894.13 | 17971.81 | 29263.41 | 20 | 15.4 | - | 458.00 KiB | 32 thread(s) | +| `gdn_chunk_scan` | `ref_gdn_chunk_scan` | libref | `head_k=128 head_v=128 scale=0.0883883 M=16 chunk=64` | - | 25833.06 | 17997.13 | 36025.03 | 20 | 22.5 | - | 6.60 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=6144 group=128 dtype=bf16 M=64` | - | 25823.94 | 14997.34 | 37031.68 | 20 | 31.8 | - | 1.14 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=16` | - | 25625.42 | 17911.15 | 34441.75 | 20 | 11.7 | - | 16.25 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=20480 act=relu dtype=bf16 M=128` | - | 25579.07 | 10391.58 | 34611.22 | 20 | 17.6 | - | 15.00 MiB | 32 thread(s) | +| `sample_pick` | `avx_sample_pick` | libavx | `n_cand=1024 M=16` | - | 25536.65 | 4042.45 | 35940.16 | 36 | 17.5 | - | 129.56 KiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=4096 dtype=bf16 act=none M=64` | - | 25501.84 | 13020.31 | 34999.27 | 20 | 31.4 | - | 8.75 MiB | 32 thread(s) | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=248320 k=21 M=16` | - | 25493.99 | 18323.96 | 30009.82 | 20 | 17.7 | - | 15.16 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=5376 group=128 dtype=fp8a8 M=1` | - | 25493.36 | 17990.04 | 35979.45 | 20 | 21.6 | - | 21.02 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5376 K=4096 group=128 dtype=fp8a8 M=9` | - | 25492.53 | 7998.97 | 38012.92 | 20 | 33.3 | - | 21.13 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=5376 group=128 dtype=fp8a8 M=2` | - | 25491.40 | 17983.88 | 30021.80 | 20 | 21.6 | - | 21.03 MiB | 32 thread(s) | +| `sample_xtc` | `avx_sample_xtc` | libavx | `n_cand=1024 M=2` | - | 25490.34 | 5988.21 | 34994.51 | 26 | 18.7 | - | 16.19 KiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=3072 dtype=bf16 act=none M=4` | - | 25487.18 | 7000.26 | 38985.56 | 20 | 47.1 | - | 6.04 MiB | 32 thread(s) | +| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | `head_k=128 M=1 chunk=64` | - | 25478.59 | 12019.98 | 34990.47 | 20 | 17.6 | - | 10.38 KiB | 32 thread(s) | +| `cast` | `ref_cast` | libref | `n=5120 from=bf16 to=bf16 M=512` | - | 25459.67 | 11976.37 | 45609.71 | 20 | 36.8 | - | 10.00 MiB | 32 thread(s) | +| `grid_embed_cpe` | `avx_grid_embed_cpe` | libavx | `n=1280 side=128 n_prefix=10 dtype=bf16 M=64` | - | 25446.72 | 11949.63 | 35805.10 | 20 | 33.4 | - | 40.18 MiB | 32 thread(s) | +| `grid_embed_cpe` | `avx_grid_embed_cpe` | libavx | `n=1280 side=128 n_prefix=10 dtype=bf16 M=128` | - | 25418.50 | 11942.20 | 35604.65 | 20 | 21.1 | - | 40.34 MiB | 32 thread(s) | +| `sample_temp` | `ref_sample_temp` | libref | `n_vocab=248320 M=8` | - | 25385.62 | 10851.01 | 37850.24 | 20 | 21.6 | - | 7.58 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=5120 K=4608 dtype=bf16 act=none M=2` | - | 25288.82 | 17993.45 | 33431.34 | 20 | 17.8 | - | 45.07 MiB | 32 thread(s) | +| `row_topk` | `avx_row_topk` | libavx | `N=248320 R=32 dtype=bf16 M=2 nch=0 pt1=8` | - | 25236.21 | 12010.78 | 41998.62 | 20 | 35.3 | - | 971.00 KiB | 32 thread(s) | +| `layernorm` | `ref_layernorm` | libref | `n=1280 eps=1e-06 dtype=bf16 M=64` | - | 25063.02 | 17998.44 | 29999.39 | 20 | 14.1 | - | 325.00 KiB | 32 thread(s) | +| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | `head_k=128 M=64 chunk=64` | - | 25042.90 | 15149.34 | 29990.45 | 20 | 21.6 | - | 664.01 KiB | 32 thread(s) | +| `embed_lookup` | `ref_embed_lookup` | libref | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=256` | - | 25030.93 | 11983.46 | 29992.69 | 20 | 13.6 | - | 1.00 GiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=512` | - | 25025.93 | 11805.91 | 29613.94 | 20 | 21.3 | - | 1.00 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=2` | - | 25016.07 | 18958.95 | 33053.89 | 20 | 19.9 | - | 9.50 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4608 K=4096 group=128 dtype=fp8a8 M=64` | - | 25013.23 | 19014.45 | 29042.48 | 20 | 8.0 | - | 18.82 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=3072 dtype=bf16 act=none M=8` | - | 25011.84 | 10998.74 | 30005.00 | 20 | 36.0 | - | 6.08 MiB | 32 thread(s) | +| `attn_dense` | `ref_attn_dense` | libref | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=16` | - | 25008.68 | 11987.36 | 29989.59 | 20 | 20.0 | - | 10.01 KiB | 32 thread(s) | +| `cast` | `avx_cast` | libavx | `n=4096 from=bf16 to=bf16 M=8` | - | 25005.96 | 11990.91 | 35988.16 | 20 | 36.0 | - | 128.00 KiB | 32 thread(s) | +| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=128` | - | 25005.83 | 18018.96 | 32959.21 | 20 | 20.0 | - | 1.00 GiB | 32 thread(s) | +| `gemm_nt_q_gated` | `avx_gemm_nt_q_gated` | libavx | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=8` | - | 25002.07 | 23993.86 | 29839.32 | 20 | 10.0 | - | 96.33 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 24997.48 | 17980.81 | 32006.22 | 20 | 22.0 | - | 32.02 MiB | 32 thread(s) | +| `dflash_select` | `avx_dflash_select` | libavx | `steps=7 top_k=16 rank=256 n_vocab=248320 anchor_stride=8 dtype=bf16 M=2` | - | 24995.62 | 14980.51 | 37975.03 | 20 | 36.0 | - | 242.51 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 24986.02 | 17956.40 | 34986.45 | 20 | 22.0 | - | 48.01 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4608 K=4096 group=128 dtype=fp8a8 M=65` | - | 24982.28 | 20981.07 | 29973.40 | 20 | 14.0 | - | 18.84 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=5120 K=4608 dtype=bf16 act=none M=1` | - | 24978.72 | 7999.66 | 37559.05 | 20 | 34.9 | - | 45.04 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=1024 group=128 dtype=fp8a8 M=64` | - | 24975.60 | 16028.99 | 30990.03 | 20 | 18.0 | - | 4.56 MiB | 32 thread(s) | +| `gdn_conv_update` | `ref_gdn_conv_update` | libref | `head_k=128 head_v=128 conv_width=4 q_len=16` | - | 24967.94 | 19321.89 | 30329.33 | 20 | 10.0 | - | 1.05 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 24857.37 | 15975.05 | 34985.22 | 20 | 12.1 | - | 96.01 KiB | 32 thread(s) | +| `add` | `ref_add` | libref | `n=4096 dtype=bf16 M=256` | - | 24840.31 | 11993.10 | 26995.67 | 20 | 27.5 | - | 6.00 MiB | 32 thread(s) | +| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=248320 M=2` | - | 24820.62 | 8880.14 | 26761.89 | 20 | 27.8 | - | 1.89 MiB | 32 thread(s) | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=248320 k=21 M=4` | - | 24648.49 | 18000.02 | 32989.36 | 20 | 18.3 | - | 3.79 MiB | 32 thread(s) | +| `gdn_conv_update` | `ref_gdn_conv_update` | libref | `head_k=128 head_v=128 conv_width=4 q_len=32` | - | 24604.17 | 13585.10 | 29882.73 | 20 | 19.9 | - | 1.99 MiB | 32 thread(s) | +| `gdn_conv_update` | `ref_gdn_conv_update` | libref | `head_k=128 head_v=128 conv_width=4 q_len=8` | - | 24588.71 | 14951.47 | 29913.32 | 20 | 12.2 | - | 600.04 KiB | 32 thread(s) | +| `mul_weight` | `ref_mul_weight` | libref | `n=8192 dtype=bf16 M=256` | - | 24560.02 | 13426.51 | 31575.80 | 20 | 20.6 | - | 8.02 MiB | 32 thread(s) | +| `gather_rows` | `ref_gather_rows` | libref | `n=1280 dtype=bf16 M=128` | - | 24557.67 | 17997.72 | 32994.74 | 20 | 18.3 | - | 1.56 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=12288 group=128 dtype=fp8a8 M=2` | - | 24506.19 | 10994.94 | 30000.15 | 20 | 10.2 | - | 48.05 MiB | 32 thread(s) | +| `gdn_gated_rmsnorm` | `ref_gdn_gated_rmsnorm` | libref | `channels=128 eps=1e-06 act=silu M=512` | - | 24505.38 | 17981.07 | 30070.39 | 20 | 20.0 | - | 384.50 KiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=17` | - | 24502.87 | 17973.85 | 34995.24 | 20 | 20.4 | - | 472.01 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=24576 K=4096 group=128 dtype=fp8a8 M=32` | - | 24500.90 | 22999.24 | 35988.43 | 20 | 10.2 | - | 97.64 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=1024 group=128 dtype=fp8a8 M=18` | - | 24500.24 | 11993.60 | 38998.83 | 20 | 44.9 | - | 4.16 MiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=4` | - | 24498.90 | 9998.93 | 33995.30 | 20 | 22.4 | - | 32.02 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=4096 group=128 dtype=fp8a8 M=8` | - | 24498.71 | 17996.14 | 29996.01 | 20 | 12.2 | - | 16.10 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=4096 group=128 dtype=fp8a8 M=4` | - | 24497.18 | 11995.64 | 27001.02 | 20 | 6.1 | - | 16.05 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=5376 group=128 dtype=fp8a8 M=4` | - | 24496.59 | 17980.31 | 42185.01 | 20 | 32.6 | - | 21.05 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=128 K=4096 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 24496.52 | 16994.72 | 35996.87 | 20 | 22.4 | - | 1.01 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3072 K=1024 dtype=bf16 act=none M=1` | - | 24494.68 | 11002.51 | 30016.48 | 20 | 30.6 | - | 6.02 MiB | 32 thread(s) | +| `embed_lookup` | `ref_embed_lookup` | libref | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=16` | - | 24477.11 | 11998.59 | 30975.80 | 20 | 16.4 | - | 1.00 GiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=20480 act=relu dtype=bf16 M=32` | - | 24475.92 | 9040.57 | 29897.57 | 20 | 18.2 | - | 3.75 MiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=512` | - | 24443.78 | 8589.55 | 27510.75 | 20 | 18.5 | - | 3.38 MiB | 32 thread(s) | +| `sample_mask` | `avx_sample_mask` | libavx | `n_vocab=248320 M=2` | - | 24312.79 | 17808.69 | 33708.87 | 20 | 18.5 | - | 1.95 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=6 splits=0` | - | 24133.33 | 23170.14 | 29929.22 | 20 | 4.8 | - | 16.10 MiB | 32 thread(s) | +| `gated_quant_fp8` | `avx_gated_quant_fp8` | libavx | `n=17408 group=128 dtype=bf16 act=silu M=512` | - | 24121.97 | 13847.22 | 35991.48 | 20 | 26.7 | - | 59.77 MiB | 32 thread(s) | +| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | `head_k=128 M=128 chunk=64` | - | 24077.52 | 12004.33 | 34819.26 | 20 | 18.7 | - | 1.30 MiB | 32 thread(s) | +| `gated_quant_fp8` | `avx_gated_quant_fp8` | libavx | `n=17408 group=128 dtype=bf16 act=silu M=16` | - | 24047.53 | 11992.36 | 35888.07 | 20 | 22.8 | - | 1.87 MiB | 32 thread(s) | +| `cast` | `ref_cast` | libref | `n=5120 from=bf16 to=bf16 M=256` | - | 24031.85 | 14435.80 | 35006.99 | 20 | 22.3 | - | 5.00 MiB | 32 thread(s) | +| `layernorm` | `avx_layernorm` | libavx | `n=1280 eps=1e-06 dtype=bf16 M=256` | - | 24027.06 | 17993.34 | 29961.61 | 20 | 14.5 | - | 1.25 MiB | 32 thread(s) | +| `layernorm` | `ref_layernorm` | libref | `n=1280 eps=1e-06 dtype=bf16 M=256` | - | 24018.21 | 17998.25 | 30015.99 | 20 | 16.1 | - | 1.25 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5376 K=4096 group=128 dtype=fp8a8 M=2` | - | 24011.66 | 11994.64 | 29993.66 | 20 | 18.7 | - | 21.03 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=24576 group=128 dtype=fp8a8 M=1` | - | 24009.48 | 12985.60 | 32991.52 | 20 | 24.9 | - | 96.04 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=24576 K=4096 group=128 dtype=fp8a8 M=4` | - | 24008.00 | 14005.55 | 31002.73 | 20 | 20.8 | - | 96.22 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=17408 group=128 dtype=bf16 M=16` | - | 24007.59 | 12034.03 | 27013.92 | 20 | 18.7 | - | 824.50 KiB | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=1280 dtype=bf16 M=32` | - | 24002.43 | 12008.62 | 30985.04 | 20 | 14.7 | - | 400.12 KiB | 32 thread(s) | +| `gdn_chunk_scan` | `ref_gdn_chunk_scan` | libref | `head_k=128 head_v=128 scale=0.0883883 M=1 chunk=64` | - | 24002.20 | 11983.41 | 30002.11 | 20 | 25.0 | - | 6.04 MiB | 32 thread(s) | +| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | `head_k=128 head_v=128 scale=0.0883883 M=1 chunk=64` | - | 24001.12 | 17021.59 | 38942.50 | 20 | 27.0 | - | 6.04 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=12288 group=128 dtype=fp8a8 M=1` | - | 24001.01 | 22575.52 | 31400.17 | 20 | 6.2 | - | 48.03 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=4096 dtype=bf16 act=none M=4` | - | 24000.80 | 23974.60 | 24015.66 | 6 | 0.1 | - | 8.05 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4608 K=4096 group=128 dtype=fp8a8 M=18` | - | 23999.91 | 23996.28 | 24016.33 | 6 | 0.0 | - | 18.23 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=6144 group=128 dtype=bf16 M=16` | - | 23999.73 | 17913.64 | 31982.13 | 20 | 12.5 | - | 291.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=4096 group=128 dtype=fp8a8 M=33` | - | 23999.54 | 23993.94 | 24002.90 | 6 | 0.0 | - | 16.39 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=256 K=4096 group=128 dtype=fp8a8 M=32` | - | 23999.35 | 23990.76 | 24006.67 | 11 | 0.0 | - | 1.14 MiB | 32 thread(s) | +| `embed_lookup` | `ref_embed_lookup` | libref | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=512` | - | 23999.29 | 12012.85 | 35650.66 | 20 | 22.2 | - | 1.00 GiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=256 K=4096 group=128 dtype=fp8a8 M=9` | - | 23999.17 | 21988.71 | 24009.99 | 11 | 0.0 | - | 1.04 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=1024 eps=1e-05 dtype=bf16 M=256` | - | 23999.17 | 14996.14 | 30002.92 | 20 | 31.2 | - | 1.00 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=256 K=4096 group=128 dtype=fp8a8 M=129` | - | 23999.12 | 23995.40 | 24001.92 | 6 | 0.0 | - | 1.58 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 23999.05 | 17986.21 | 29001.94 | 20 | 4.2 | - | 4.03 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=4096 group=128 dtype=fp8a8 M=8` | - | 23999.05 | 23990.93 | 24007.24 | 11 | 0.0 | - | 16.10 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1024 K=4096 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 23998.97 | 23985.24 | 33003.23 | 19 | 0.0 | - | 8.62 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1024 K=4096 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 23998.91 | 14996.61 | 25999.39 | 20 | 6.3 | - | 8.08 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-05 dtype=bf16 M=128` | - | 23998.86 | 11995.22 | 34784.61 | 20 | 2.6 | - | 2.51 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=256 K=4096 group=128 dtype=fp8a8 M=65` | - | 23998.73 | 23998.24 | 24001.74 | 6 | 0.0 | - | 1.29 MiB | 32 thread(s) | +| `gdn_kkt_solve` | `ref_gdn_kkt_solve` | libref | `head_k=128 M=4 chunk=64` | - | 23998.51 | 13992.02 | 36003.53 | 20 | 27.2 | - | 41.51 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=6144 group=128 dtype=bf16 M=32` | - | 23998.50 | 11998.64 | 29993.81 | 20 | 25.0 | - | 582.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=12288 group=128 dtype=fp8a8 M=18` | - | 23998.47 | 17007.61 | 26007.92 | 20 | 6.3 | - | 48.36 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=5376 act=relu dtype=bf16 M=128` | - | 23998.27 | 11997.08 | 34632.27 | 16 | 0.0 | - | 3.94 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=1024 eps=1e-05 dtype=bf16 M=128` | - | 23998.09 | 17045.94 | 35929.09 | 20 | 12.4 | - | 512.00 KiB | 32 thread(s) | +| `cast` | `ref_cast` | libref | `n=5120 from=bf16 to=bf16 M=128` | - | 23998.07 | 13206.54 | 29996.36 | 20 | 14.3 | - | 2.50 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=12288 group=128 dtype=fp8a8 M=18` | - | 23997.79 | 20000.48 | 32992.94 | 20 | 4.2 | - | 48.36 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=2048 dtype=bf16 act=none M=4` | - | 23997.65 | 23992.42 | 24016.55 | 6 | 0.1 | - | 4.03 MiB | 32 thread(s) | +| `gdn_gated_rmsnorm` | `avx_gdn_gated_rmsnorm` | libavx | `channels=128 eps=1e-06 act=silu M=512` | - | 23997.51 | 11990.54 | 27013.50 | 20 | 12.5 | - | 384.50 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=1024 eps=1e-05 dtype=bf16 M=128` | - | 23997.43 | 17997.12 | 30001.79 | 20 | 9.8 | - | 512.00 KiB | 32 thread(s) | +| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | `head_k=128 head_v=128 scale=0.0883883 M=4 chunk=64` | - | 23997.17 | 14996.39 | 30988.10 | 20 | 2.3 | - | 6.15 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=256 K=4096 group=128 dtype=fp8a8 M=8` | - | 23997.15 | 23990.54 | 23999.49 | 6 | 0.0 | - | 1.04 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=4096 dtype=bf16 act=none M=2` | - | 23997.04 | 10998.45 | 30000.59 | 20 | 37.5 | - | 8.03 MiB | 32 thread(s) | +| `mul_weight` | `avx_mul_weight` | libavx | `n=8192 dtype=bf16 M=512` | - | 23997.03 | 11987.08 | 35887.49 | 20 | 45.3 | - | 16.02 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=12288 group=128 dtype=fp8a8 M=32` | - | 23997.02 | 17992.14 | 28991.83 | 20 | 20.9 | - | 48.64 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=256 K=4096 group=128 dtype=fp8a8 M=2` | - | 23997.01 | 22996.53 | 24005.26 | 11 | 0.0 | - | 1.01 MiB | 32 thread(s) | +| `layernorm` | `ref_layernorm` | libref | `n=1280 eps=1e-06 dtype=bf16 M=512` | - | 23996.86 | 18360.93 | 29992.27 | 20 | 14.8 | - | 2.50 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=2048 K=1024 dtype=bf16 act=none M=32` | - | 23996.39 | 14991.21 | 32006.58 | 20 | 31.3 | - | 4.32 MiB | 32 thread(s) | +| `silu_mul` | `avx_silu_mul` | libavx | `n=17408 dtype=bf16 M=4` | - | 23996.35 | 8982.68 | 29992.88 | 20 | 24.9 | - | 408.00 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-05 dtype=bf16 M=32` | - | 23996.35 | 16982.17 | 31047.98 | 20 | 20.7 | - | 650.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=4096 group=128 dtype=fp8a8 M=65` | - | 23996.21 | 20001.27 | 24997.63 | 20 | 2.1 | - | 16.77 MiB | 32 thread(s) | +| `silu_mul` | `ref_silu_mul` | libref | `n=17408 dtype=bf16 M=16` | - | 23996.06 | 9998.75 | 28499.46 | 20 | 12.5 | - | 1.59 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=2048 dtype=bf16 act=none M=8` | - | 23996.06 | 23972.02 | 24026.34 | 6 | 0.1 | - | 4.06 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | - | 23995.89 | 11982.11 | 24009.08 | 20 | 22.9 | - | 832.01 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4608 K=4096 group=128 dtype=fp8a8 M=33` | - | 23995.89 | 10278.17 | 35998.73 | 20 | 36.0 | - | 18.43 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=8192 group=128 dtype=bf16 M=4` | - | 23995.88 | 11983.78 | 34003.70 | 20 | 22.9 | - | 97.00 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | - | 23995.59 | 13022.17 | 35975.19 | 19 | 0.7 | - | 176.01 KiB | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=5120 dtype=bf16 M=32` | - | 23995.56 | 11998.53 | 35825.12 | 20 | 10.4 | - | 1.56 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=8` | - | 23995.46 | 11994.65 | 24000.01 | 11 | 0.0 | - | 170.00 KiB | 32 thread(s) | +| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | `head_k=128 head_v=128 scale=0.0883883 M=32 chunk=64` | - | 23994.61 | 11991.51 | 26999.60 | 20 | 19.9 | - | 7.20 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=2048 act=relu dtype=bf16 M=512` | - | 23994.60 | 12542.08 | 33483.49 | 16 | 0.0 | - | 6.00 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=9 splits=0` | - | 23994.33 | 23950.34 | 23999.32 | 6 | 0.1 | - | 248.01 KiB | 32 thread(s) | +| `cast` | `ref_cast` | libref | `n=4096 from=bf16 to=bf16 M=16` | - | 23994.30 | 12035.70 | 32981.41 | 20 | 23.0 | - | 256.00 KiB | 32 thread(s) | +| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=4` | - | 23994.21 | 13981.17 | 34000.50 | 20 | 41.7 | - | 1.00 GiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=512` | - | 23994.02 | 11992.32 | 24073.82 | 19 | 0.2 | - | 512.50 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=1024 K=5120 group=128 dtype=fp8a8 M=18` | - | 23993.94 | 11983.02 | 32924.07 | 20 | 33.5 | - | 5.13 MiB | 32 thread(s) | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=248320 k=21 M=32` | - | 23993.57 | 13288.07 | 35705.41 | 20 | 12.6 | - | 30.32 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=25600 group=128 dtype=bf16 M=256` | - | 23993.29 | 11998.98 | 29991.68 | 20 | 19.5 | - | 18.95 MiB | 32 thread(s) | +| `add` | `ref_add` | libref | `n=4096 dtype=bf16 M=64` | - | 23992.74 | 12060.25 | 24057.10 | 11 | 0.3 | - | 1.50 MiB | 32 thread(s) | +| `gated_quant_fp8` | `avx_gated_quant_fp8` | libavx | `n=17408 group=128 dtype=bf16 act=silu M=128` | - | 23992.69 | 11991.23 | 25217.79 | 20 | 2.3 | - | 14.94 MiB | 32 thread(s) | +| `mul_weight` | `ref_mul_weight` | libref | `n=8192 dtype=bf16 M=128` | - | 23992.27 | 13357.09 | 33015.97 | 19 | 0.7 | - | 4.02 MiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=1536 act=relu dtype=bf16 M=128` | - | 23992.16 | 15012.89 | 27965.04 | 20 | 4.2 | - | 1.12 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=1024 eps=1e-05 dtype=bf16 M=16` | - | 23991.79 | 11996.34 | 29982.78 | 20 | 12.5 | - | 64.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=4096 group=128 dtype=bf16 M=8` | - | 23991.17 | 3944.07 | 24950.96 | 40 | 37.6 | - | 97.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=256 K=4096 group=128 dtype=fp8a8 M=128` | - | 23990.91 | 13011.04 | 30006.54 | 20 | 18.8 | - | 1.58 MiB | 32 thread(s) | +| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=128` | - | 23990.86 | 12000.00 | 24995.33 | 20 | 19.0 | - | 2.37 GiB | 32 thread(s) | +| `sample_topp` | `avx_sample_topp` | libavx | `n_cand=1024 M=2` | - | 23990.74 | 5993.67 | 27013.72 | 40 | 33.3 | - | 16.19 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=1024 group=128 dtype=bf16 M=16` | - | 23990.58 | 11990.70 | 25114.06 | 20 | 25.0 | - | 48.50 KiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=4096 dtype=bf16 act=none M=8` | - | 23990.06 | 11081.78 | 30032.01 | 20 | 27.1 | - | 8.10 MiB | 32 thread(s) | +| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=32` | - | 23989.58 | 11986.79 | 26994.79 | 20 | 18.8 | - | 1.00 GiB | 32 thread(s) | +| `dflash_select` | `avx_dflash_select` | libavx | `steps=7 top_k=16 rank=256 n_vocab=248320 anchor_stride=8 dtype=bf16 M=8` | - | 23989.50 | 11992.70 | 24003.42 | 20 | 20.9 | - | 242.53 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=256 K=4096 group=128 dtype=fp8a8 M=18` | - | 23989.40 | 11996.48 | 31998.69 | 20 | 10.5 | - | 1.08 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=128` | - | 23988.83 | 9001.09 | 24007.21 | 31 | 2.2 | - | 64.25 KiB | 32 thread(s) | +| `silu_mul` | `avx_silu_mul` | libavx | `n=17408 dtype=bf16 M=32` | - | 23988.63 | 8999.22 | 29986.38 | 20 | 25.0 | - | 3.19 MiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=8192 act=silu dtype=bf16 M=8` | - | 23988.35 | 11979.90 | 35994.90 | 20 | 27.1 | - | 384.00 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=16` | - | 23988.30 | 12022.06 | 29984.85 | 20 | 16.6 | - | 330.00 KiB | 32 thread(s) | +| `sample_argmax` | `avx_sample_argmax` | libavx | `n_vocab=248320 M=32` | - | 23988.06 | 14988.81 | 31833.88 | 20 | 15.1 | - | 30.32 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=6144 group=128 dtype=bf16 M=512` | - | 23987.97 | 13173.51 | 33842.12 | 20 | 20.4 | - | 9.09 MiB | 32 thread(s) | +| `attn_dense` | `ref_attn_dense` | libref | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=16` | - | 23987.29 | 11954.04 | 29997.34 | 20 | 20.9 | - | 9.01 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=256 K=4096 group=128 dtype=fp8a8 M=1` | - | 23986.05 | 11992.21 | 26985.11 | 20 | 25.0 | - | 1.00 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=11` | - | 23985.74 | 16318.17 | 30807.72 | 20 | 23.5 | - | 16.18 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5376 K=4096 group=128 dtype=fp8a8 M=4` | - | 23985.53 | 17996.85 | 25013.82 | 20 | 6.3 | - | 21.06 MiB | 32 thread(s) | +| `gated_quant_fp8` | `ref_gated_quant_fp8` | libref | `n=17408 group=128 dtype=bf16 act=silu M=8` | - | 23985.01 | 11131.50 | 30990.98 | 20 | 17.4 | - | 956.25 KiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1024 K=4096 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 23984.58 | 11996.60 | 25008.68 | 20 | 25.0 | - | 8.33 MiB | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=5120 dtype=bf16 M=8` | - | 23984.28 | 11984.25 | 24006.50 | 20 | 25.0 | - | 400.03 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=1536 group=128 dtype=bf16 M=64` | - | 23983.81 | 11985.12 | 29981.49 | 20 | 30.8 | - | 291.00 KiB | 32 thread(s) | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | `N=240 K=4096 dtype=bf16 M=4` | - | 23981.51 | 17981.08 | 35966.52 | 20 | 30.3 | - | 3.78 MiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=8192 act=silu dtype=bf16 M=2` | - | 23981.49 | 12023.98 | 35993.03 | 20 | 2.1 | - | 96.00 KiB | 32 thread(s) | +| `sample_xtc` | `avx_sample_xtc` | libavx | `n_cand=1024 M=4` | - | 23981.17 | 5989.37 | 24010.39 | 26 | 24.9 | - | 32.38 KiB | 32 thread(s) | +| `grid_embed` | `avx_grid_embed` | libavx | `n=1152 side=48 dtype=bf16 M=64` | - | 23980.75 | 11983.81 | 26964.85 | 20 | 18.4 | - | 5.20 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1 splits=0` | - | 23979.29 | 17993.64 | 30973.26 | 20 | 18.8 | - | 16.02 MiB | 32 thread(s) | +| `gdn_conv_update` | `ref_gdn_conv_update` | libref | `head_k=128 head_v=128 conv_width=4 q_len=4` | - | 23975.73 | 11979.98 | 38836.06 | 20 | 21.1 | - | 360.03 KiB | 32 thread(s) | +| `layernorm` | `avx_layernorm` | libavx | `n=1280 eps=1e-06 dtype=bf16 M=32` | - | 23974.71 | 17984.07 | 28979.00 | 20 | 18.7 | - | 165.00 KiB | 32 thread(s) | +| `sample_topk` | `avx_sample_topk` | libavx | `n_vocab=248320 M=2` | - | 23972.74 | 17652.87 | 27375.63 | 20 | 16.2 | - | 1.90 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-05 dtype=bf16 M=32` | - | 23970.60 | 12003.87 | 23997.98 | 20 | 22.8 | - | 650.00 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=32` | - | 23968.31 | 11971.76 | 32974.92 | 20 | 33.6 | - | 256.12 KiB | 32 thread(s) | +| `grid_embed_cpe` | `ref_grid_embed_cpe` | libref | `n=1280 side=128 n_prefix=10 dtype=bf16 M=64` | - | 23968.10 | 8973.87 | 29968.63 | 20 | 8.6 | - | 40.18 MiB | 32 thread(s) | +| `sample_topp` | `avx_sample_topp` | libavx | `n_cand=1024 M=32` | - | 23966.48 | 5958.10 | 29980.83 | 26 | 12.6 | - | 259.00 KiB | 32 thread(s) | +| `ple_conv_bias` | `ref_ple_conv_bias` | libref | `n=10240 width=4 dilation=1 dtype=bf16 M=8` | - | 23966.44 | 17095.62 | 29753.54 | 20 | 14.4 | - | 780.02 KiB | 32 thread(s) | +| `sample_minp` | `ref_sample_minp` | libref | `n_cand=1024 M=16` | - | 23959.92 | 11965.00 | 26979.56 | 20 | 6.3 | - | 129.50 KiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=32` | - | 23958.73 | 12996.91 | 32955.62 | 20 | 18.8 | - | 908.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1152 K=1152 dtype=bf16 act=none M=8` | - | 23950.68 | 7004.76 | 32004.87 | 20 | 39.6 | - | 2.59 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=17408 group=128 dtype=bf16 M=64` | - | 23943.90 | 16965.23 | 26952.13 | 20 | 12.4 | - | 3.22 MiB | 32 thread(s) | +| `gather_rows` | `ref_gather_rows` | libref | `n=5120 dtype=bf16 M=56` | - | 23940.72 | 11994.14 | 34936.71 | 20 | 18.8 | - | 2.73 MiB | 32 thread(s) | +| `add` | `avx_add` | libavx | `n=4096 dtype=bf16 M=128` | - | 23939.90 | 18013.23 | 26979.20 | 20 | 10.5 | - | 3.00 MiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=20480 act=relu dtype=bf16 M=512` | - | 23927.99 | 11996.33 | 29863.92 | 20 | 17.0 | - | 60.00 MiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=8192 act=silu dtype=bf16 M=256` | - | 23922.82 | 15994.28 | 29017.56 | 20 | 22.1 | - | 12.00 MiB | 32 thread(s) | +| `scatter_rows` | `ref_scatter_rows` | libref | `n=5120 dtype=bf16 M=16` | - | 23922.17 | 11922.17 | 27324.64 | 20 | 13.4 | - | 800.06 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=512` | - | 23913.90 | 11988.88 | 27009.85 | 20 | 25.0 | - | 10.01 MiB | 32 thread(s) | +| `embed_lookup` | `ref_embed_lookup` | libref | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=128` | - | 23898.85 | 15080.49 | 28001.65 | 20 | 16.3 | - | 1.00 GiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=20480 act=relu dtype=bf16 M=32` | - | 23889.82 | 12213.71 | 30017.86 | 20 | 21.0 | - | 3.75 MiB | 32 thread(s) | +| `sample_xtc` | `ref_sample_xtc` | libref | `n_cand=1024 M=32` | - | 23882.52 | 18035.57 | 29954.10 | 20 | 10.4 | - | 259.00 KiB | 32 thread(s) | +| `sample_argmax` | `avx_sample_argmax` | libavx | `n_vocab=248320 M=16` | - | 23880.04 | 15117.02 | 36995.08 | 20 | 16.7 | - | 15.16 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=20480 act=relu dtype=bf16 M=16` | - | 23878.67 | 11997.77 | 35998.97 | 20 | 18.7 | - | 1.88 MiB | 32 thread(s) | +| `gdn_recurrent_update` | `ref_gdn_recurrent_update` | libref | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=16` | - | 23876.08 | 7076.41 | 34805.27 | 20 | 32.7 | - | 48.69 MiB | 32 thread(s) | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=256` | - | 23873.59 | 11883.63 | 23906.35 | 20 | 25.0 | - | 1.56 MiB | 32 thread(s) | +| `kv_store` | `ref_kv_store` | libref | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=128` | - | 23852.78 | 9047.70 | 23930.69 | 20 | 24.8 | - | 832.50 KiB | 32 thread(s) | +| `scatter_rows` | `ref_scatter_rows` | libref | `n=4096 dtype=bf16 M=32` | - | 23848.87 | 14839.42 | 26859.84 | 20 | 20.9 | - | 1.25 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=128` | - | 23843.88 | 11976.81 | 30004.62 | 20 | 32.9 | - | 2.51 MiB | 32 thread(s) | +| `grid_embed_cpe` | `ref_grid_embed_cpe` | libref | `n=1280 side=128 n_prefix=10 dtype=bf16 M=512` | - | 23793.45 | 11831.68 | 23819.34 | 16 | 0.1 | - | 41.28 MiB | 32 thread(s) | +| `sample_temp` | `ref_sample_temp` | libref | `n_vocab=248320 M=16` | - | 23758.89 | 10872.76 | 43179.07 | 20 | 30.6 | - | 15.16 MiB | 32 thread(s) | +| `grid_embed_cpe` | `avx_grid_embed_cpe` | libavx | `n=1280 side=128 n_prefix=10 dtype=bf16 M=512` | - | 23736.81 | 12582.06 | 24622.56 | 20 | 2.5 | - | 41.28 MiB | 32 thread(s) | +| `sample_dry` | `avx_sample_dry` | libavx | `n_vocab=248320 M=16` | - | 23733.82 | 13581.09 | 29838.63 | 20 | 15.0 | - | 15.16 MiB | 32 thread(s) | +| `scatter_rows` | `ref_scatter_rows` | libref | `n=4096 dtype=bf16 M=128` | - | 23708.42 | 11301.36 | 33370.45 | 20 | 5.9 | - | 5.00 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3072 K=1024 dtype=bf16 act=none M=256` | - | 23701.38 | 18296.00 | 28696.48 | 20 | 6.3 | - | 9.51 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8 splits=0` | - | 23691.23 | 15126.46 | 30956.29 | 20 | 23.3 | - | 16.13 MiB | 32 thread(s) | +| `sample_penalties` | `avx_sample_penalties` | libavx | `n_vocab=248320 M=2` | - | 23683.44 | 6667.02 | 29678.07 | 20 | 13.8 | - | 1.90 MiB | 32 thread(s) | +| `sample_penalties` | `ref_sample_penalties` | libref | `n_vocab=248320 M=2` | - | 23622.53 | 8840.54 | 23847.77 | 20 | 25.4 | - | 1.90 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=1024 eps=1e-05 dtype=bf16 M=512` | - | 23616.16 | 11200.46 | 30917.51 | 20 | 21.2 | - | 2.00 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=8192 group=128 dtype=bf16 M=16` | - | 23552.18 | 14579.34 | 27975.97 | 20 | 12.7 | - | 388.00 KiB | 32 thread(s) | +| `scatter_rows` | `ref_scatter_rows` | libref | `n=5120 dtype=bf16 M=64` | - | 23518.97 | 14569.00 | 29552.07 | 20 | 23.3 | - | 3.13 MiB | 32 thread(s) | +| `sample_penalties` | `ref_sample_penalties` | libref | `n_vocab=248320 M=4` | - | 23501.70 | 7749.01 | 32422.63 | 20 | 28.3 | - | 3.79 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=6 splits=0` | - | 23498.87 | 11990.42 | 26004.11 | 20 | 4.3 | - | 2.09 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=12288 group=128 dtype=fp8a8 M=9` | - | 23496.35 | 12993.63 | 28004.11 | 20 | 27.6 | - | 48.18 MiB | 32 thread(s) | +| `gdn_kkt_solve` | `ref_gdn_kkt_solve` | libref | `head_k=128 M=256 chunk=64` | - | 23495.21 | 17979.60 | 32985.34 | 20 | 23.4 | - | 2.59 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=4096 group=128 dtype=fp8a8 M=32` | - | 23494.76 | 13007.39 | 28997.52 | 20 | 19.1 | - | 16.38 MiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=128` | - | 23492.97 | 17788.14 | 27326.27 | 20 | 15.1 | - | 3.52 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=24576 group=128 dtype=fp8a8 M=4` | - | 23492.86 | 19974.67 | 32934.36 | 20 | 19.2 | - | 96.14 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=24576 group=128 dtype=fp8a8 M=33` | - | 23492.30 | 18997.68 | 42980.40 | 20 | 40.5 | - | 97.07 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=4` | - | 23492.29 | 17994.38 | 33052.86 | 20 | 25.5 | - | 9.54 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 23489.34 | 17984.28 | 29998.99 | 20 | 19.2 | - | 152.01 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | - | 23488.27 | 12004.95 | 35249.85 | 20 | 21.8 | - | 3.38 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=1024 group=128 dtype=bf16 M=64` | - | 23487.30 | 12023.58 | 24005.34 | 20 | 12.8 | - | 194.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=1024 group=128 dtype=fp8a8 M=8` | - | 23487.01 | 16988.22 | 31007.99 | 20 | 25.5 | - | 4.07 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5120 group=128 dtype=bf16 M=4` | - | 23483.97 | 11992.64 | 29995.80 | 20 | 36.2 | - | 60.62 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=4096 group=128 dtype=fp8a8 M=9` | - | 23483.56 | 16987.94 | 33002.55 | 20 | 25.5 | - | 4.05 MiB | 32 thread(s) | +| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | `head_k=128 head_v=128 scale=0.0883883 M=8 chunk=64` | - | 23481.03 | 12121.81 | 29998.94 | 20 | 25.5 | - | 6.30 MiB | 32 thread(s) | +| `gdn_kkt_solve` | `avx_gdn_kkt_solve` | libavx | `head_k=128 M=8 chunk=64` | - | 23470.05 | 14986.97 | 32984.00 | 20 | 19.2 | - | 83.01 KiB | 32 thread(s) | +| `mul_weight` | `avx_mul_weight` | libavx | `n=8192 dtype=bf16 M=4` | - | 23468.93 | 13797.41 | 47987.43 | 20 | 53.2 | - | 144.00 KiB | 32 thread(s) | +| `sample_dry` | `ref_sample_dry` | libref | `n_vocab=248320 M=4` | - | 23453.42 | 11367.71 | 35473.21 | 20 | 21.5 | - | 3.79 MiB | 32 thread(s) | +| `add` | `avx_add` | libavx | `n=4096 dtype=bf16 M=512` | - | 23450.14 | 11987.95 | 23999.42 | 20 | 23.3 | - | 12.00 MiB | 32 thread(s) | +| `scatter_rows` | `avx_scatter_rows` | libavx | `n=4096 dtype=bf16 M=8` | - | 23436.38 | 14969.00 | 32969.19 | 20 | 22.8 | - | 320.03 KiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=20480 act=relu dtype=bf16 M=8` | - | 23420.38 | 12210.66 | 26365.79 | 20 | 5.1 | - | 960.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=6144 group=128 dtype=bf16 M=32` | - | 23384.19 | 11997.92 | 30000.03 | 20 | 25.7 | - | 582.00 KiB | 32 thread(s) | +| `dflash_select` | `ref_dflash_select` | libref | `steps=7 top_k=16 rank=256 n_vocab=248320 anchor_stride=8 dtype=bf16 M=8` | - | 23374.44 | 14994.48 | 32991.57 | 20 | 26.9 | - | 242.53 MiB | 32 thread(s) | +| `gdn_conv_update` | `avx_gdn_conv_update` | libavx | `head_k=128 head_v=128 conv_width=4 q_len=64` | - | 23352.31 | 13010.24 | 34109.46 | 20 | 34.0 | - | 3.87 MiB | 32 thread(s) | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=248320 k=21 M=8` | - | 23349.14 | 18008.08 | 33000.76 | 20 | 25.7 | - | 7.58 MiB | 32 thread(s) | +| `moe_gather` | `avx_moe_gather` | libavx | `n=1024 top_k=9 dtype=bf16 act=none M=512` | - | 23348.24 | 11982.35 | 23995.31 | 20 | 24.3 | - | 11.03 MiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=512` | - | 23265.82 | 13821.72 | 26855.33 | 20 | 25.9 | - | 1.00 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=8192 group=128 dtype=bf16 M=32` | - | 23264.08 | 11021.91 | 25312.96 | 20 | 6.5 | - | 776.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=25600 group=128 dtype=bf16 M=32` | - | 23248.51 | 15374.46 | 33000.67 | 20 | 23.7 | - | 2.37 MiB | 32 thread(s) | +| `scatter_rows` | `avx_scatter_rows` | libavx | `n=4096 dtype=bf16 M=64` | - | 23211.03 | 12769.45 | 26741.15 | 20 | 19.4 | - | 2.50 MiB | 32 thread(s) | +| `scatter_rows` | `avx_scatter_rows` | libavx | `n=5120 dtype=bf16 M=512` | - | 23181.25 | 9749.85 | 27808.15 | 20 | 31.2 | - | 25.00 MiB | 32 thread(s) | +| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=248320 M=16` | - | 23178.05 | 16524.26 | 34433.08 | 20 | 25.5 | - | 15.16 MiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=16` | - | 23174.15 | 11981.37 | 29984.30 | 20 | 32.3 | - | 108.12 KiB | 32 thread(s) | +| `mul_weight` | `ref_mul_weight` | libref | `n=8192 dtype=bf16 M=32` | - | 23071.85 | 11982.73 | 30928.25 | 20 | 19.5 | - | 1.02 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | - | 23065.33 | 5998.45 | 26992.44 | 20 | 37.4 | - | 4.14 MiB | 32 thread(s) | +| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=64` | - | 23010.17 | 16974.21 | 41954.75 | 20 | 38.2 | - | 2.37 GiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=8192 group=128 dtype=bf16 M=32` | - | 23005.76 | 16012.29 | 29997.45 | 20 | 13.1 | - | 776.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=6144 group=128 dtype=bf16 M=8` | - | 23005.69 | 14995.15 | 33959.03 | 20 | 28.3 | - | 145.50 KiB | 32 thread(s) | +| `grid_embed_cpe` | `ref_grid_embed_cpe` | libref | `n=1280 side=128 n_prefix=10 dtype=bf16 M=16` | - | 23002.95 | 11051.22 | 27951.97 | 20 | 10.8 | - | 40.06 MiB | 32 thread(s) | +| `gather_rows` | `ref_gather_rows` | libref | `n=1280 dtype=bf16 M=64` | - | 23000.24 | 12001.04 | 26998.92 | 20 | 23.9 | - | 800.25 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=24576 group=128 dtype=fp8a8 M=4` | - | 22992.75 | 17991.14 | 29977.01 | 20 | 17.4 | - | 96.14 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=2048 dtype=bf16 act=none M=2` | - | 22992.43 | 17995.05 | 29994.55 | 20 | 19.6 | - | 4.02 MiB | 32 thread(s) | +| `gated_quant_fp8` | `avx_gated_quant_fp8` | libavx | `n=17408 group=128 dtype=bf16 act=silu M=2` | - | 22985.14 | 14994.57 | 26994.07 | 20 | 13.4 | - | 239.06 KiB | 32 thread(s) | +| `layernorm` | `avx_layernorm` | libavx | `n=1280 eps=1e-06 dtype=bf16 M=128` | - | 22975.69 | 17983.33 | 23997.38 | 20 | 13.0 | - | 645.00 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=256` | - | 22938.72 | 11691.92 | 30970.88 | 20 | 23.8 | - | 5.01 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-05 dtype=bf16 M=64` | - | 22930.03 | 17988.79 | 29996.21 | 20 | 21.5 | - | 1.26 MiB | 32 thread(s) | +| `silu_mul` | `avx_silu_mul` | libavx | `n=17408 dtype=bf16 M=16` | - | 22927.44 | 12036.47 | 29994.81 | 20 | 19.8 | - | 1.59 MiB | 32 thread(s) | +| `gdn_conv_update` | `ref_gdn_conv_update` | libref | `head_k=128 head_v=128 conv_width=4 q_len=2` | - | 22921.90 | 17927.26 | 27919.55 | 20 | 15.2 | - | 240.02 KiB | 32 thread(s) | +| `sample_dry` | `avx_sample_dry` | libavx | `n_vocab=248320 M=4` | - | 22909.55 | 14371.45 | 35438.90 | 20 | 28.1 | - | 3.79 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5120 group=128 dtype=bf16 M=512` | - | 22863.94 | 11987.34 | 24002.44 | 20 | 25.9 | - | 7.58 MiB | 32 thread(s) | +| `gdn_conv_update` | `avx_gdn_conv_update` | libavx | `head_k=128 head_v=128 conv_width=4 q_len=128` | - | 22792.95 | 16163.75 | 28099.31 | 20 | 13.2 | - | 7.62 MiB | 32 thread(s) | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | `N=240 K=4096 dtype=bf16 M=32` | - | 22782.32 | 5996.78 | 24930.39 | 20 | 26.5 | - | 4.03 MiB | 32 thread(s) | +| `sample_mask` | `avx_sample_mask` | libavx | `n_vocab=248320 M=4` | - | 22771.20 | 17749.62 | 31346.50 | 20 | 16.4 | - | 3.91 MiB | 32 thread(s) | +| `gdn_kkt_solve` | `ref_gdn_kkt_solve` | libref | `head_k=128 M=128 chunk=64` | - | 22717.11 | 13843.80 | 32129.52 | 20 | 17.1 | - | 1.30 MiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=20480 act=relu dtype=bf16 M=4` | - | 22655.10 | 17990.74 | 34675.64 | 20 | 17.6 | - | 480.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=17408 group=128 dtype=bf16 M=16` | - | 22640.08 | 14014.01 | 24992.56 | 20 | 13.7 | - | 824.50 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=5120 group=128 dtype=bf16 M=512` | - | 22572.61 | 11982.08 | 34086.17 | 20 | 26.9 | - | 7.58 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=128 K=4096 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 22525.81 | 7948.51 | 29965.46 | 20 | 20.0 | - | 1.03 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=1024 group=128 dtype=fp8a8 M=18` | - | 22508.40 | 15984.07 | 32994.67 | 20 | 18.9 | - | 4.16 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=6144 group=128 dtype=bf16 M=128` | - | 22505.32 | 14972.24 | 34549.22 | 20 | 23.4 | - | 2.27 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5376 K=4096 group=128 dtype=fp8a8 M=8` | - | 22503.41 | 4967.81 | 30987.22 | 20 | 26.7 | - | 21.12 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-05 dtype=bf16 M=128` | - | 22499.28 | 17980.71 | 27005.09 | 20 | 20.0 | - | 2.51 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3456 K=1152 dtype=bf16 act=none M=16` | - | 22497.38 | 17982.89 | 39131.43 | 20 | 31.2 | - | 7.85 MiB | 32 thread(s) | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=248320 k=21 M=1` | - | 22489.46 | 17999.42 | 29995.88 | 20 | 15.6 | - | 970.27 KiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | - | 22487.07 | 11814.66 | 32982.68 | 20 | 26.7 | - | 416.01 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-05 dtype=bf16 M=256` | - | 22475.47 | 13566.81 | 37408.89 | 20 | 40.1 | - | 5.01 MiB | 32 thread(s) | +| `gdn_conv_update` | `avx_gdn_conv_update` | libavx | `head_k=128 head_v=128 conv_width=4 q_len=8` | - | 22474.90 | 10182.12 | 30973.28 | 20 | 22.7 | - | 600.04 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1 splits=0` | - | 22463.98 | 11523.31 | 25925.00 | 20 | 13.4 | - | 16.02 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=128` | - | 22462.01 | 17993.18 | 30009.97 | 20 | 11.1 | - | 2.51 MiB | 32 thread(s) | +| `gdn_kkt_solve` | `ref_gdn_kkt_solve` | libref | `head_k=128 M=8 chunk=64` | - | 22460.75 | 17991.48 | 26989.40 | 20 | 11.2 | - | 83.01 KiB | 32 thread(s) | +| `quant_act_i8` | `ref_quant_act_i8` | libref | `n=5120 group=128 dtype=bf16 M=32` | - | 22460.67 | 6059.40 | 31053.13 | 20 | 26.7 | - | 485.12 KiB | 32 thread(s) | +| `gdn_gated_rmsnorm` | `avx_gdn_gated_rmsnorm` | libavx | `channels=128 eps=1e-06 act=silu M=256` | - | 22456.92 | 16992.10 | 26999.60 | 20 | 19.9 | - | 192.50 KiB | 32 thread(s) | +| `sample_xtc` | `avx_sample_xtc` | libavx | `n_cand=1024 M=64` | - | 22405.43 | 4930.13 | 26935.58 | 40 | 37.9 | - | 518.00 KiB | 32 thread(s) | +| `sample_argmax` | `ref_sample_argmax` | libref | `n_vocab=248320 M=32` | - | 22404.60 | 10828.14 | 38774.46 | 20 | 29.0 | - | 30.32 MiB | 32 thread(s) | +| `gdn_kkt_solve` | `ref_gdn_kkt_solve` | libref | `head_k=128 M=1 chunk=64` | - | 22394.62 | 11976.06 | 29982.09 | 20 | 17.8 | - | 10.38 KiB | 32 thread(s) | +| `quant_act_i8` | `avx_quant_act_i8` | libavx | `n=5120 group=128 dtype=bf16 M=16` | - | 22375.95 | 11992.45 | 35486.20 | 20 | 26.8 | - | 242.56 KiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=8192 act=silu dtype=bf16 M=256` | - | 22232.76 | 14102.53 | 31617.67 | 20 | 22.5 | - | 12.00 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=256` | - | 22218.18 | 9904.38 | 23994.08 | 34 | 11.1 | - | 128.25 KiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=512` | - | 22209.21 | 16769.96 | 29470.74 | 20 | 24.9 | - | 14.07 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 22164.05 | 11994.66 | 24001.62 | 20 | 22.0 | - | 4.12 MiB | 32 thread(s) | +| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | `head_k=128 head_v=128 scale=0.0883883 M=64 chunk=64` | - | 22160.58 | 14615.32 | 32991.96 | 20 | 25.6 | - | 8.40 MiB | 32 thread(s) | +| `sample_typical` | `ref_sample_typical` | libref | `n_cand=1024 M=8` | - | 22155.90 | 21775.37 | 23244.94 | 20 | 1.9 | - | 64.75 KiB | 32 thread(s) | +| `gdn_recurrent_update` | `avx_gdn_recurrent_update` | libavx | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=4` | - | 22130.15 | 11028.08 | 33156.28 | 20 | 13.8 | - | 18.17 MiB | 32 thread(s) | +| `gdn_kkt_solve` | `ref_gdn_kkt_solve` | libref | `head_k=128 M=64 chunk=64` | - | 22123.62 | 11986.46 | 26997.89 | 20 | 23.2 | - | 664.01 KiB | 32 thread(s) | +| `gdn_chunk_scan` | `ref_gdn_chunk_scan` | libref | `head_k=128 head_v=128 scale=0.0883883 M=4 chunk=64` | - | 22088.01 | 12353.94 | 35007.02 | 20 | 27.8 | - | 6.15 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | - | 22069.69 | 14518.32 | 29394.67 | 20 | 25.6 | - | 4.38 MiB | 32 thread(s) | +| `gdn_recurrent_update` | `avx_gdn_recurrent_update` | libavx | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=8` | - | 22068.84 | 12295.42 | 34591.74 | 20 | 25.9 | - | 24.35 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=4096 dtype=bf16 act=none M=32` | - | 22021.56 | 17985.77 | 36002.53 | 20 | 40.9 | - | 8.38 MiB | 32 thread(s) | +| `mul_weight` | `ref_mul_weight` | libref | `n=8192 dtype=bf16 M=16` | - | 22019.56 | 13087.27 | 25078.31 | 20 | 11.1 | - | 528.00 KiB | 32 thread(s) | +| `sample_pick` | `ref_sample_pick` | libref | `n_cand=1024 M=32` | - | 22007.01 | 14981.42 | 31979.21 | 20 | 18.2 | - | 259.12 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=256 K=4096 group=128 dtype=fp8a8 M=64` | - | 22004.41 | 11993.55 | 27000.22 | 20 | 15.9 | - | 1.29 MiB | 32 thread(s) | +| `gated_quant_fp8` | `ref_gated_quant_fp8` | libref | `n=17408 group=128 dtype=bf16 act=silu M=4` | - | 22004.12 | 9989.01 | 28995.55 | 20 | 20.5 | - | 478.12 KiB | 32 thread(s) | +| `attn_paged_sink` | `ref_attn_paged_sink` | libref | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8` | - | 22000.39 | 11002.94 | 25009.60 | 20 | 15.9 | - | 2.13 MiB | 32 thread(s) | +| `gated_quant_fp8` | `ref_gated_quant_fp8` | libref | `n=17408 group=128 dtype=bf16 act=silu M=32` | - | 21999.56 | 11980.22 | 27001.12 | 20 | 31.8 | - | 3.74 MiB | 32 thread(s) | +| `sample_penalties` | `avx_sample_penalties` | libavx | `n_vocab=248320 M=16` | - | 21997.27 | 4179.12 | 37276.04 | 20 | 39.4 | - | 15.16 MiB | 32 thread(s) | +| `sample_argmax` | `ref_sample_argmax` | libref | `n_vocab=248320 M=2` | - | 21996.45 | 16996.23 | 24989.34 | 20 | 13.6 | - | 1.89 MiB | 32 thread(s) | +| `attn_dense` | `ref_attn_dense` | libref | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=64` | - | 21994.46 | 13010.74 | 24145.01 | 20 | 11.3 | - | 36.01 KiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=1024 dtype=bf16 act=none M=8` | - | 21992.51 | 11962.43 | 30993.41 | 20 | 34.2 | - | 2.05 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=24576 group=128 dtype=fp8a8 M=18` | - | 21990.46 | 17996.28 | 29998.65 | 20 | 20.5 | - | 96.59 MiB | 32 thread(s) | +| `add` | `ref_add` | libref | `n=4096 dtype=bf16 M=32` | - | 21976.04 | 11982.94 | 26990.04 | 20 | 29.5 | - | 768.00 KiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=8192 act=silu dtype=bf16 M=64` | - | 21951.12 | 13949.25 | 26035.22 | 20 | 13.6 | - | 3.00 MiB | 32 thread(s) | +| `attn_paged_sink` | `ref_attn_paged_sink` | libref | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8` | - | 21945.49 | 10993.75 | 25033.04 | 20 | 3.6 | - | 16.13 MiB | 32 thread(s) | +| `scatter_rows` | `ref_scatter_rows` | libref | `n=4096 dtype=bf16 M=16` | - | 21944.54 | 11931.25 | 30003.57 | 20 | 10.0 | - | 640.06 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=4096 group=128 dtype=bf16 M=64` | - | 21818.46 | 9201.84 | 29988.50 | 20 | 23.0 | - | 776.00 KiB | 32 thread(s) | +| `gated_quant_fp8` | `avx_gated_quant_fp8` | libavx | `n=17408 group=128 dtype=bf16 act=silu M=64` | - | 21679.84 | 8540.64 | 27902.76 | 20 | 25.1 | - | 7.47 MiB | 32 thread(s) | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=248320 k=21 M=64` | - | 21630.47 | 11341.32 | 27055.03 | 20 | 27.7 | - | 60.64 MiB | 32 thread(s) | +| `sample_xtc` | `avx_sample_xtc` | libavx | `n_cand=1024 M=8` | - | 21515.50 | 5987.64 | 25991.48 | 26 | 14.0 | - | 64.75 KiB | 32 thread(s) | +| `cast` | `avx_cast` | libavx | `n=4096 from=bf16 to=bf16 M=512` | - | 21513.85 | 17942.24 | 29992.77 | 20 | 16.1 | - | 8.00 MiB | 32 thread(s) | +| `silu_mul` | `ref_silu_mul` | libref | `n=17408 dtype=bf16 M=64` | - | 21512.43 | 9111.69 | 29994.43 | 20 | 23.4 | - | 6.38 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-05 dtype=bf16 M=16` | - | 21505.68 | 16978.32 | 26989.08 | 20 | 16.3 | - | 330.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=8192 group=128 dtype=bf16 M=2` | - | 21503.47 | 17987.42 | 29994.41 | 20 | 14.0 | - | 48.50 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=6144 group=128 dtype=bf16 M=256` | - | 21496.74 | 17054.58 | 29969.75 | 20 | 23.2 | - | 4.55 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=256 K=4096 group=128 dtype=fp8a8 M=4` | - | 21492.78 | 8993.09 | 25005.91 | 20 | 18.6 | - | 1.02 MiB | 32 thread(s) | +| `add` | `avx_add` | libavx | `n=4096 dtype=bf16 M=4` | - | 21492.57 | 15010.85 | 27980.01 | 20 | 18.6 | - | 96.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4608 K=4096 group=128 dtype=fp8a8 M=32` | - | 21488.88 | 13995.36 | 28999.61 | 20 | 21.0 | - | 18.41 MiB | 32 thread(s) | +| `sample_minp` | `avx_sample_minp` | libavx | `n_cand=1024 M=2` | - | 21487.85 | 3327.16 | 36009.27 | 40 | 66.5 | - | 16.19 KiB | 32 thread(s) | +| `quant_act_i8` | `avx_quant_act_i8` | libavx | `n=5120 group=128 dtype=bf16 M=56` | - | 21482.55 | 11991.66 | 30021.50 | 20 | 23.2 | - | 850.22 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-05 dtype=bf16 M=64` | - | 21475.93 | 14046.80 | 35992.17 | 20 | 37.2 | - | 1.26 MiB | 32 thread(s) | +| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=248320 M=32` | - | 21469.35 | 9409.49 | 27418.12 | 20 | 35.8 | - | 30.32 MiB | 32 thread(s) | +| `sample_minp` | `ref_sample_minp` | libref | `n_cand=1024 M=64` | - | 21467.78 | 12953.81 | 32834.70 | 20 | 16.3 | - | 518.00 KiB | 32 thread(s) | +| `sample_topp` | `ref_sample_topp` | libref | `n_cand=1024 M=16` | - | 21455.75 | 13000.69 | 28929.57 | 20 | 9.3 | - | 129.50 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=4096 group=128 dtype=fp8a8 M=1` | - | 21429.84 | 12116.56 | 25243.01 | 20 | 21.8 | - | 16.01 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | - | 21397.17 | 11982.17 | 27975.67 | 20 | 30.3 | - | 224.01 KiB | 32 thread(s) | +| `gated_quant_fp8` | `ref_gated_quant_fp8` | libref | `n=17408 group=128 dtype=bf16 act=silu M=64` | - | 21335.17 | 17983.08 | 26997.15 | 20 | 20.7 | - | 7.47 MiB | 32 thread(s) | +| `scatter_rows` | `avx_scatter_rows` | libavx | `n=5120 dtype=bf16 M=128` | - | 21318.45 | 11006.15 | 28465.06 | 20 | 14.3 | - | 6.25 MiB | 32 thread(s) | +| `sample_temp` | `ref_sample_temp` | libref | `n_vocab=248320 M=32` | - | 21226.02 | 11576.19 | 26917.74 | 20 | 30.0 | - | 30.32 MiB | 32 thread(s) | +| `gdn_conv_update` | `avx_gdn_conv_update` | libavx | `head_k=128 head_v=128 conv_width=4 q_len=32` | - | 21218.79 | 13378.05 | 27901.69 | 20 | 16.9 | - | 1.99 MiB | 32 thread(s) | +| `gdn_chunk_scan` | `ref_gdn_chunk_scan` | libref | `head_k=128 head_v=128 scale=0.0883883 M=2 chunk=64` | - | 21209.65 | 12527.17 | 33701.14 | 20 | 28.3 | - | 6.07 MiB | 32 thread(s) | +| `sample_argmax` | `ref_sample_argmax` | libref | `n_vocab=248320 M=8` | - | 21194.32 | 13791.65 | 30978.42 | 20 | 14.6 | - | 7.58 MiB | 32 thread(s) | +| `scatter_rows` | `ref_scatter_rows` | libref | `n=5120 dtype=bf16 M=256` | - | 21171.00 | 7379.19 | 28247.31 | 20 | 23.3 | - | 12.50 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=8192 act=silu dtype=bf16 M=8` | - | 21148.80 | 12001.16 | 30008.41 | 20 | 18.9 | - | 384.00 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | - | 21111.47 | 15166.12 | 32995.66 | 20 | 29.0 | - | 6.72 MiB | 32 thread(s) | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | `N=240 K=4096 dtype=bf16 M=1` | - | 21049.25 | 11614.30 | 29953.76 | 20 | 31.8 | - | 3.76 MiB | 32 thread(s) | +| `attn_paged_sink` | `ref_attn_paged_sink` | libref | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4` | - | 21037.00 | 17997.92 | 25001.34 | 20 | 14.3 | - | 16.07 MiB | 32 thread(s) | +| `gdn_recurrent_update` | `avx_gdn_recurrent_update` | libavx | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=2` | - | 21032.05 | 16181.78 | 25125.69 | 20 | 14.4 | - | 18.09 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=1536 act=relu dtype=bf16 M=256` | - | 21025.49 | 13116.94 | 26997.52 | 20 | 25.5 | - | 2.25 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=8192 group=128 dtype=bf16 M=256` | - | 21020.28 | 12160.18 | 29892.78 | 20 | 6.9 | - | 6.06 MiB | 32 thread(s) | +| `sample_argmax` | `ref_sample_argmax` | libref | `n_vocab=248320 M=64` | - | 21014.88 | 14672.41 | 30002.07 | 20 | 19.8 | - | 60.63 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=8192 group=128 dtype=bf16 M=64` | - | 21014.61 | 14983.17 | 33958.98 | 20 | 40.3 | - | 1.52 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=17408 group=128 dtype=bf16 M=4` | - | 21006.23 | 17977.39 | 29999.72 | 20 | 16.7 | - | 206.12 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=1024 eps=1e-05 dtype=bf16 M=32` | - | 21003.97 | 8988.71 | 29006.49 | 20 | 21.4 | - | 128.00 KiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=8192 act=silu dtype=bf16 M=32` | - | 21002.29 | 17984.68 | 29995.18 | 20 | 7.1 | - | 1.50 MiB | 32 thread(s) | +| `embed_lookup` | `ref_embed_lookup` | libref | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=64` | - | 21001.82 | 14060.85 | 32987.83 | 20 | 31.1 | - | 1.00 GiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | - | 20998.71 | 7996.81 | 32979.35 | 20 | 19.1 | - | 832.01 KiB | 32 thread(s) | +| `silu_mul` | `avx_silu_mul` | libavx | `n=17408 dtype=bf16 M=1` | - | 20998.47 | 17990.97 | 31000.63 | 20 | 21.4 | - | 102.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=8192 group=128 dtype=bf16 M=8` | - | 20998.07 | 10973.99 | 29992.43 | 20 | 23.3 | - | 194.00 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 20997.77 | 8979.39 | 26971.26 | 20 | 20.6 | - | 4.02 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=4096 group=128 dtype=fp8a8 M=18` | - | 20997.09 | 12001.05 | 26990.64 | 20 | 14.3 | - | 16.22 MiB | 32 thread(s) | +| `quant_act_i8` | `avx_quant_act_i8` | libavx | `n=5120 group=128 dtype=bf16 M=32` | - | 20996.78 | 7739.98 | 26988.32 | 20 | 24.7 | - | 485.12 KiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1024 K=4096 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 20996.65 | 8997.42 | 25001.08 | 20 | 14.3 | - | 8.01 MiB | 32 thread(s) | +| `embed_lookup` | `ref_embed_lookup` | libref | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=64` | - | 20996.63 | 12011.74 | 30053.65 | 20 | 23.8 | - | 2.37 GiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=8192 group=128 dtype=bf16 M=256` | - | 20996.53 | 10212.46 | 26887.38 | 20 | 14.0 | - | 6.06 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=17408 group=128 dtype=bf16 M=2` | - | 20996.43 | 10968.03 | 28168.64 | 20 | 35.6 | - | 103.06 KiB | 32 thread(s) | +| `gather_rows` | `ref_gather_rows` | libref | `n=1280 dtype=bf16 M=256` | - | 20996.23 | 11991.72 | 31872.12 | 20 | 21.3 | - | 3.13 MiB | 32 thread(s) | +| `silu_mul` | `ref_silu_mul` | libref | `n=17408 dtype=bf16 M=4` | - | 20996.19 | 11999.81 | 35986.96 | 20 | 21.5 | - | 408.00 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=512` | - | 20995.82 | 14152.26 | 35997.35 | 20 | 28.6 | - | 512.50 KiB | 32 thread(s) | +| `quant_act_i8` | `avx_quant_act_i8` | libavx | `n=5120 group=128 dtype=bf16 M=4` | - | 20995.38 | 11989.48 | 32989.15 | 20 | 33.4 | - | 62.52 KiB | 32 thread(s) | +| `add` | `ref_add` | libref | `n=5120 dtype=bf16 M=64` | - | 20994.98 | 4956.99 | 21917.11 | 20 | 26.2 | - | 1.88 MiB | 32 thread(s) | +| `add` | `avx_add` | libavx | `n=4096 dtype=bf16 M=32` | - | 20994.26 | 13999.14 | 24002.32 | 20 | 14.2 | - | 768.00 KiB | 32 thread(s) | +| `moe_gather` | `avx_moe_gather` | libavx | `n=1024 top_k=9 dtype=bf16 act=none M=2` | - | 20993.75 | 13006.98 | 27995.62 | 20 | 15.3 | - | 44.11 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=4096 group=128 dtype=fp8a8 M=18` | - | 20992.80 | 17993.05 | 24007.65 | 20 | 14.3 | - | 16.22 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=20480 act=relu dtype=bf16 M=4` | - | 20992.63 | 5998.23 | 34987.99 | 20 | 40.1 | - | 480.00 KiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=20480 act=relu dtype=bf16 M=64` | - | 20992.44 | 11117.92 | 26863.89 | 20 | 21.3 | - | 7.50 MiB | 32 thread(s) | +| `quant_act_i8` | `avx_quant_act_i8` | libavx | `n=5120 group=128 dtype=bf16 M=8` | - | 20992.34 | 10001.82 | 27993.59 | 20 | 23.8 | - | 122.53 KiB | 32 thread(s) | +| `add` | `ref_add` | libref | `n=4096 dtype=bf16 M=128` | - | 20992.14 | 6816.35 | 29824.49 | 20 | 28.7 | - | 3.00 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=6144 group=128 dtype=bf16 M=16` | - | 20992.02 | 8986.83 | 28969.94 | 20 | 19.0 | - | 291.00 KiB | 32 thread(s) | +| `sample_minp` | `avx_sample_minp` | libavx | `n_cand=1024 M=4` | - | 20991.77 | 3998.49 | 29993.42 | 28 | 0.0 | - | 32.38 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=17408 group=128 dtype=bf16 M=32` | - | 20990.35 | 11997.84 | 29987.02 | 20 | 23.7 | - | 1.61 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=64` | - | 20990.12 | 8998.01 | 23001.54 | 20 | 11.9 | - | 1.06 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=5376 act=relu dtype=bf16 M=512` | - | 20990.04 | 15025.08 | 27557.21 | 20 | 19.2 | - | 15.75 MiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=8` | - | 20989.91 | 9093.99 | 32890.87 | 20 | 28.6 | - | 233.00 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | - | 20988.96 | 3006.93 | 23999.98 | 20 | 28.6 | - | 160.01 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=16` | - | 20988.34 | 13035.49 | 24960.75 | 20 | 14.3 | - | 330.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=5120 group=128 dtype=bf16 M=32` | - | 20987.73 | 12023.24 | 28070.63 | 20 | 14.3 | - | 485.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=8192 group=128 dtype=bf16 M=512` | - | 20986.56 | 17982.12 | 24013.36 | 20 | 6.9 | - | 12.12 MiB | 32 thread(s) | +| `layernorm` | `avx_layernorm` | libavx | `n=1280 eps=1e-06 dtype=bf16 M=16` | - | 20986.24 | 12999.92 | 24023.25 | 20 | 11.9 | - | 85.00 KiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=8192 act=silu dtype=bf16 M=4` | - | 20985.87 | 8992.24 | 26000.01 | 20 | 19.1 | - | 192.00 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=512` | - | 20985.49 | 9019.14 | 26997.06 | 20 | 28.6 | - | 256.25 KiB | 32 thread(s) | +| `sample_minp` | `avx_sample_minp` | libavx | `n_cand=1024 M=8` | - | 20984.86 | 5990.75 | 25924.06 | 26 | 14.4 | - | 64.75 KiB | 32 thread(s) | +| `moe_gather` | `avx_moe_gather` | libavx | `n=1024 top_k=9 dtype=bf16 act=none M=16` | - | 20984.57 | 17984.73 | 26049.16 | 20 | 2.2 | - | 352.88 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 20983.73 | 11986.50 | 35995.40 | 20 | 14.3 | - | 128.01 KiB | 32 thread(s) | +| `gdn_conv_update` | `avx_gdn_conv_update` | libavx | `head_k=128 head_v=128 conv_width=4 q_len=1` | - | 20983.57 | 10987.58 | 32978.80 | 20 | 23.5 | - | 180.02 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=32` | - | 20980.46 | 10997.80 | 30973.36 | 20 | 9.6 | - | 64.12 KiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=256` | - | 20975.78 | 10849.69 | 28341.83 | 20 | 22.0 | - | 8.80 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=8192 group=128 dtype=bf16 M=128` | - | 20974.69 | 15681.53 | 30239.73 | 20 | 15.0 | - | 3.03 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=5120 group=128 dtype=bf16 M=64` | - | 20971.64 | 9184.54 | 28806.29 | 20 | 28.1 | - | 970.00 KiB | 32 thread(s) | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | `N=304 K=4096 dtype=bf16 M=32` | - | 20970.46 | 17994.98 | 23994.83 | 20 | 4.4 | - | 5.04 MiB | 32 thread(s) | +| `kv_store` | `ref_kv_store` | libref | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=32` | - | 20970.24 | 11017.29 | 32923.42 | 20 | 7.1 | - | 256.12 KiB | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=5120 dtype=bf16 M=56` | - | 20969.85 | 12015.86 | 25022.90 | 20 | 16.8 | - | 2.73 MiB | 32 thread(s) | +| `ple_conv_bias` | `ref_ple_conv_bias` | libref | `n=10240 width=4 dilation=1 dtype=bf16 M=64` | - | 20968.56 | 14297.63 | 30445.54 | 20 | 14.6 | - | 5.14 MiB | 32 thread(s) | +| `sample_minp` | `ref_sample_minp` | libref | `n_cand=1024 M=32` | - | 20968.43 | 17918.57 | 32941.21 | 20 | 28.6 | - | 259.00 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=32` | - | 20966.07 | 10999.50 | 29941.39 | 20 | 30.7 | - | 256.12 KiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=1536 act=relu dtype=bf16 M=256` | - | 20962.71 | 9026.58 | 29996.50 | 20 | 28.5 | - | 2.25 MiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=128` | - | 20960.98 | 17938.18 | 29840.75 | 20 | 7.3 | - | 256.50 KiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=16` | - | 20958.50 | 17970.22 | 23019.58 | 20 | 7.2 | - | 458.00 KiB | 32 thread(s) | +| `sample_mask` | `ref_sample_mask` | libref | `n_vocab=248320 M=8` | - | 20956.63 | 11915.00 | 25855.18 | 20 | 21.2 | - | 7.82 MiB | 32 thread(s) | +| `kv_store` | `ref_kv_store` | libref | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=64` | - | 20956.38 | 16217.57 | 21974.21 | 20 | 4.6 | - | 448.25 KiB | 32 thread(s) | +| `gdn_conv_update` | `ref_gdn_conv_update` | libref | `head_k=128 head_v=128 conv_width=4 q_len=64` | - | 20956.33 | 13046.34 | 28744.75 | 20 | 21.7 | - | 3.87 MiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=64` | - | 20949.61 | 16932.60 | 35918.17 | 20 | 25.6 | - | 512.25 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=2048 group=128 dtype=bf16 M=8` | - | 20938.95 | 9047.49 | 26990.67 | 20 | 23.8 | - | 48.50 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=128` | - | 20935.13 | 8936.42 | 24903.30 | 20 | 7.2 | - | 257.50 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=25600 group=128 dtype=bf16 M=128` | - | 20912.95 | 9541.68 | 23875.24 | 20 | 23.4 | - | 9.47 MiB | 32 thread(s) | +| `sample_topp` | `ref_sample_topp` | libref | `n_cand=1024 M=64` | - | 20904.90 | 11964.16 | 26904.12 | 20 | 7.2 | - | 518.00 KiB | 32 thread(s) | +| `sample_xtc` | `ref_sample_xtc` | libref | `n_cand=1024 M=64` | - | 20901.74 | 11957.96 | 29817.32 | 20 | 33.3 | - | 518.00 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=256` | - | 20900.93 | 11097.67 | 32890.29 | 16 | 0.3 | - | 513.00 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=64` | - | 20899.93 | 3855.80 | 29877.75 | 20 | 37.1 | - | 768.75 KiB | 32 thread(s) | +| `scatter_rows` | `avx_scatter_rows` | libavx | `n=4096 dtype=bf16 M=32` | - | 20895.49 | 11935.13 | 29870.07 | 20 | 23.9 | - | 1.25 MiB | 32 thread(s) | +| `sample_topp` | `avx_sample_topp` | libavx | `n_cand=1024 M=64` | - | 20877.97 | 8915.28 | 22958.08 | 40 | 50.0 | - | 518.00 KiB | 32 thread(s) | +| `scatter_rows` | `avx_scatter_rows` | libavx | `n=5120 dtype=bf16 M=32` | - | 20815.62 | 8810.07 | 30581.06 | 20 | 28.9 | - | 1.56 MiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=128` | - | 20765.36 | 5793.71 | 29807.12 | 20 | 45.6 | - | 1.50 MiB | 32 thread(s) | +| `sample_topk` | `ref_sample_topk` | libref | `n_vocab=131072 M=2` | - | 20738.62 | 11921.32 | 28388.98 | 20 | 34.3 | - | 1.00 MiB | 32 thread(s) | +| `sample_mask` | `ref_sample_mask` | libref | `n_vocab=248320 M=16` | - | 20713.59 | 15718.27 | 24698.01 | 20 | 14.3 | - | 15.63 MiB | 32 thread(s) | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | `N=240 K=4096 dtype=bf16 M=16` | - | 20686.08 | 17951.39 | 32992.46 | 20 | 21.7 | - | 3.89 MiB | 32 thread(s) | +| `mul_weight` | `avx_mul_weight` | libavx | `n=8192 dtype=bf16 M=2` | - | 20639.87 | 14002.07 | 29972.29 | 20 | 24.2 | - | 80.00 KiB | 32 thread(s) | +| `silu_mul` | `avx_silu_mul` | libavx | `n=17408 dtype=bf16 M=64` | - | 20632.87 | 11998.39 | 29995.01 | 20 | 29.7 | - | 6.38 MiB | 32 thread(s) | +| `sample_topp` | `avx_sample_topp` | libavx | `n_cand=1024 M=16` | - | 20577.47 | 6979.20 | 24943.07 | 40 | 25.1 | - | 129.50 KiB | 32 thread(s) | +| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | `head_k=128 head_v=128 scale=0.0883883 M=2 chunk=64` | - | 20537.40 | 8985.16 | 39004.75 | 20 | 48.5 | - | 6.07 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=32` | - | 20517.83 | 10071.01 | 30939.00 | 20 | 17.8 | - | 650.00 KiB | 32 thread(s) | +| `silu_mul` | `avx_silu_mul` | libavx | `n=17408 dtype=bf16 M=8` | - | 20503.98 | 11968.45 | 30004.86 | 20 | 22.0 | - | 816.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=4096 group=128 dtype=bf16 M=4` | - | 20502.19 | 5997.07 | 33997.39 | 26 | 29.2 | - | 48.50 KiB | 32 thread(s) | +| `layernorm` | `avx_layernorm` | libavx | `n=1152 eps=1e-06 dtype=bf16 M=512` | - | 20501.86 | 12013.09 | 27003.42 | 20 | 21.9 | - | 2.25 MiB | 32 thread(s) | +| `sample_argmax` | `avx_sample_argmax` | libavx | `n_vocab=248320 M=8` | - | 20495.60 | 12006.87 | 26012.24 | 20 | 12.2 | - | 7.58 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=24576 group=128 dtype=fp8a8 M=8` | - | 20495.40 | 17997.13 | 32982.42 | 20 | 12.2 | - | 96.27 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=16` | - | 20494.79 | 16007.76 | 22998.29 | 20 | 9.7 | - | 2.25 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 20493.61 | 8994.41 | 26985.85 | 20 | 26.7 | - | 56.01 KiB | 32 thread(s) | +| `cast` | `avx_cast` | libavx | `n=4096 from=bf16 to=bf16 M=256` | - | 20489.70 | 11096.76 | 29595.85 | 20 | 19.4 | - | 4.00 MiB | 32 thread(s) | +| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=512` | - | 20472.50 | 8994.71 | 21979.31 | 20 | 9.7 | - | 1.00 GiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=2048 group=128 dtype=bf16 M=4` | - | 20463.27 | 5996.65 | 24001.46 | 20 | 22.0 | - | 24.25 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5120 group=128 dtype=bf16 M=64` | - | 20461.93 | 12023.56 | 25998.40 | 20 | 19.4 | - | 970.00 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=1536 group=128 dtype=bf16 M=256` | - | 20448.91 | 10186.73 | 29999.76 | 20 | 23.8 | - | 1.14 MiB | 32 thread(s) | +| `gdn_chunk_scan` | `avx_gdn_chunk_scan` | libavx | `head_k=128 head_v=128 scale=0.0883883 M=16 chunk=64` | - | 20446.41 | 5724.26 | 29993.50 | 20 | 23.8 | - | 6.60 MiB | 32 thread(s) | +| `sample_mask` | `ref_sample_mask` | libref | `n_vocab=248320 M=64` | - | 20354.84 | 10052.26 | 35407.23 | 20 | 18.9 | - | 62.53 MiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=256` | - | 20344.39 | 11933.18 | 23665.13 | 20 | 15.3 | - | 1.69 MiB | 32 thread(s) | +| `silu_mul` | `ref_silu_mul` | libref | `n=17408 dtype=bf16 M=8` | - | 20285.86 | 8997.36 | 32995.02 | 20 | 31.1 | - | 816.00 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=16` | - | 20154.30 | 11967.82 | 29968.29 | 20 | 32.3 | - | 32.06 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=256` | - | 20130.31 | 14620.28 | 25052.72 | 20 | 14.2 | - | 3.00 MiB | 32 thread(s) | +| `mul_weight` | `ref_mul_weight` | libref | `n=8192 dtype=bf16 M=512` | - | 20107.14 | 11993.05 | 24346.41 | 20 | 14.1 | - | 16.02 MiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=2048 act=relu dtype=bf16 M=32` | - | 20064.43 | 6826.54 | 20999.16 | 20 | 10.0 | - | 384.00 KiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=20480 act=relu dtype=bf16 M=2` | - | 20055.16 | 17716.15 | 26982.90 | 20 | 20.0 | - | 240.00 KiB | 32 thread(s) | +| `grid_embed_cpe` | `ref_grid_embed_cpe` | libref | `n=1280 side=128 n_prefix=10 dtype=bf16 M=32` | - | 20050.60 | 11977.93 | 22923.46 | 20 | 9.8 | - | 40.10 MiB | 32 thread(s) | +| `sample_temp` | `ref_sample_temp` | libref | `n_vocab=248320 M=64` | - | 20048.85 | 8781.07 | 38472.17 | 20 | 42.5 | - | 60.63 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=8192 group=128 dtype=bf16 M=128` | - | 20043.36 | 15000.26 | 32962.66 | 20 | 17.1 | - | 3.03 MiB | 32 thread(s) | +| `gdn_conv_update` | `avx_gdn_conv_update` | libavx | `head_k=128 head_v=128 conv_width=4 q_len=16` | - | 20028.11 | 11960.08 | 23964.70 | 20 | 15.0 | - | 1.05 MiB | 32 thread(s) | +| `add` | `avx_add` | libavx | `n=5120 dtype=bf16 M=64` | - | 20027.92 | 11972.42 | 24008.33 | 20 | 24.1 | - | 1.88 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=1024 eps=1e-05 dtype=bf16 M=64` | - | 20016.56 | 16980.23 | 23999.57 | 20 | 15.0 | - | 256.00 KiB | 32 thread(s) | +| `gather_rows` | `ref_gather_rows` | libref | `n=5120 dtype=bf16 M=16` | - | 20015.97 | 10028.86 | 26938.31 | 20 | 22.4 | - | 800.06 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=17408 group=128 dtype=bf16 M=1` | - | 20014.99 | 17975.64 | 24987.11 | 20 | 17.4 | - | 51.53 KiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=2048 act=relu dtype=bf16 M=64` | - | 20012.40 | 15988.54 | 26965.58 | 20 | 17.4 | - | 768.00 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=64` | - | 20009.48 | 11999.11 | 23997.28 | 20 | 12.5 | - | 64.50 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=64` | - | 20008.45 | 16002.51 | 23947.89 | 20 | 14.9 | - | 128.25 KiB | 32 thread(s) | +| `sample_xtc` | `avx_sample_xtc` | libavx | `n_cand=1024 M=32` | - | 20006.97 | 5948.20 | 23920.59 | 26 | 12.4 | - | 259.00 KiB | 32 thread(s) | +| `silu_mul` | `avx_silu_mul` | libavx | `n=17408 dtype=bf16 M=2` | - | 20005.83 | 10007.53 | 28988.68 | 20 | 29.6 | - | 204.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4608 K=4096 group=128 dtype=fp8a8 M=8` | - | 20001.05 | 12978.53 | 27007.93 | 20 | 17.5 | - | 18.10 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4608 K=4096 group=128 dtype=fp8a8 M=33` | - | 20000.72 | 14995.93 | 23995.69 | 20 | 12.5 | - | 18.43 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=24576 K=4096 group=128 dtype=fp8a8 M=9` | - | 19998.61 | 17992.94 | 22916.39 | 20 | 4.8 | - | 96.47 MiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=20480 act=relu dtype=bf16 M=256` | - | 19994.65 | 9385.22 | 26997.39 | 20 | 22.5 | - | 30.00 MiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=1536 act=relu dtype=bf16 M=16` | - | 19990.51 | 11021.97 | 20998.31 | 20 | 7.5 | - | 144.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=1024 dtype=bf16 act=none M=64` | - | 19989.91 | 10996.22 | 27988.13 | 20 | 22.4 | - | 2.38 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-05 dtype=bf16 M=512` | - | 19988.23 | 10172.06 | 29992.58 | 20 | 33.4 | - | 10.01 MiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=8192 act=silu dtype=bf16 M=32` | - | 19961.73 | 13019.04 | 22957.67 | 20 | 7.5 | - | 1.50 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4 splits=0` | - | 19929.58 | 11992.02 | 30169.65 | 20 | 27.1 | - | 16.07 MiB | 32 thread(s) | +| `scatter_rows` | `avx_scatter_rows` | libavx | `n=4096 dtype=bf16 M=256` | - | 19882.05 | 11906.15 | 34872.45 | 20 | 27.6 | - | 10.00 MiB | 32 thread(s) | +| `scatter_rows` | `avx_scatter_rows` | libavx | `n=4096 dtype=bf16 M=128` | - | 19866.23 | 16423.54 | 32506.01 | 20 | 33.0 | - | 5.00 MiB | 32 thread(s) | +| `sample_dry` | `ref_sample_dry` | libref | `n_vocab=248320 M=32` | - | 19865.21 | 7361.80 | 34881.93 | 20 | 49.3 | - | 30.33 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=10 splits=0` | - | 19809.87 | 16994.44 | 23287.13 | 20 | 9.9 | - | 4.23 MiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=20480 act=relu dtype=bf16 M=8` | - | 19802.10 | 12001.92 | 30001.25 | 20 | 20.4 | - | 960.00 KiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=128` | - | 19723.56 | 10688.48 | 27483.15 | 20 | 27.7 | - | 4.40 MiB | 32 thread(s) | +| `cast` | `avx_cast` | libavx | `n=4096 from=bf16 to=bf16 M=16` | - | 19666.67 | 14659.68 | 32968.64 | 20 | 22.8 | - | 256.00 KiB | 32 thread(s) | +| `gdn_kkt_solve` | `ref_gdn_kkt_solve` | libref | `head_k=128 M=32 chunk=64` | - | 19658.75 | 10072.85 | 29982.49 | 20 | 22.5 | - | 332.01 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=256` | - | 19587.61 | 9757.88 | 20751.75 | 20 | 15.0 | - | 1.69 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=20480 act=relu dtype=bf16 M=64` | - | 19583.81 | 12452.57 | 24451.72 | 20 | 22.2 | - | 7.50 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=8192 act=silu dtype=bf16 M=16` | - | 19583.64 | 9011.48 | 26984.43 | 20 | 20.0 | - | 768.00 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-05 dtype=bf16 M=256` | - | 19540.23 | 11990.80 | 29954.47 | 20 | 15.5 | - | 5.01 MiB | 32 thread(s) | +| `gdn_kkt_solve` | `ref_gdn_kkt_solve` | libref | `head_k=128 M=2 chunk=64` | - | 19523.80 | 11976.25 | 29019.82 | 20 | 30.6 | - | 20.76 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=1024 group=128 dtype=bf16 M=256` | - | 19519.39 | 10050.67 | 26999.99 | 20 | 23.0 | - | 776.00 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-05 dtype=bf16 M=16` | - | 19502.33 | 11984.37 | 23997.08 | 20 | 20.5 | - | 330.00 KiB | 32 thread(s) | +| `gather_rows` | `ref_gather_rows` | libref | `n=5120 dtype=bf16 M=64` | - | 19502.31 | 11057.26 | 32997.06 | 20 | 7.8 | - | 3.13 MiB | 32 thread(s) | +| `add` | `avx_add` | libavx | `n=4096 dtype=bf16 M=256` | - | 19499.46 | 11985.39 | 26966.01 | 20 | 28.0 | - | 6.00 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=256 K=4096 group=128 dtype=fp8a8 M=9` | - | 19498.55 | 8996.30 | 23995.77 | 20 | 22.9 | - | 1.04 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=1024 dtype=bf16 act=none M=128` | - | 19495.97 | 13996.73 | 29999.16 | 20 | 33.3 | - | 2.75 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=24576 K=4096 group=128 dtype=fp8a8 M=2` | - | 19495.31 | 13983.68 | 28005.44 | 20 | 23.1 | - | 96.11 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1024 K=4096 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 19495.11 | 5977.05 | 21009.62 | 20 | 15.4 | - | 8.04 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=1024 group=128 dtype=bf16 M=128` | - | 19493.58 | 10605.99 | 24019.29 | 20 | 7.8 | - | 388.00 KiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | - | 19493.03 | 7998.20 | 29992.98 | 20 | 35.9 | - | 128.01 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=256 K=4096 group=128 dtype=fp8a8 M=258` | - | 19492.07 | 8990.59 | 26996.17 | 20 | 17.9 | - | 2.17 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 19487.88 | 8005.99 | 26002.74 | 20 | 38.5 | - | 112.01 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=6144 group=128 dtype=bf16 M=4` | - | 19484.15 | 11985.15 | 29995.58 | 20 | 23.2 | - | 72.75 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5120 group=128 dtype=bf16 M=256` | - | 19482.96 | 10037.98 | 25909.47 | 20 | 7.8 | - | 3.79 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 19463.52 | 8463.00 | 23997.84 | 20 | 11.0 | - | 32.07 MiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=20480 act=relu dtype=bf16 M=16` | - | 19430.63 | 11986.56 | 27000.33 | 20 | 15.2 | - | 1.88 MiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=64` | - | 19425.89 | 14938.42 | 29900.65 | 20 | 12.9 | - | 512.25 KiB | 32 thread(s) | +| `sample_minp` | `avx_sample_minp` | libavx | `n_cand=1024 M=64` | - | 19425.62 | 4928.48 | 23991.47 | 40 | 42.4 | - | 518.00 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=2048 group=128 dtype=bf16 M=512` | - | 19408.06 | 8995.85 | 21008.92 | 20 | 26.9 | - | 3.03 MiB | 32 thread(s) | +| `scatter_rows` | `ref_scatter_rows` | libref | `n=4096 dtype=bf16 M=256` | - | 19313.78 | 11203.09 | 25989.52 | 20 | 22.4 | - | 10.00 MiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=128` | - | 19252.02 | 11957.81 | 29714.32 | 20 | 33.3 | - | 1.50 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=17` | - | 19242.20 | 11991.71 | 28283.97 | 20 | 18.1 | - | 4.40 MiB | 32 thread(s) | +| `cast` | `ref_cast` | libref | `n=4096 from=bf16 to=bf16 M=512` | - | 19214.49 | 11638.70 | 29991.46 | 20 | 29.4 | - | 8.00 MiB | 32 thread(s) | +| `sample_penalties` | `avx_sample_penalties` | libavx | `n_vocab=248320 M=4` | - | 19207.01 | 5825.56 | 27860.61 | 20 | 30.7 | - | 3.79 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=256` | - | 19199.88 | 9565.23 | 24889.40 | 20 | 17.2 | - | 5.01 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=64` | - | 19151.59 | 16852.28 | 23988.94 | 20 | 12.8 | - | 1.26 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=512` | - | 19151.15 | 17263.18 | 22837.29 | 20 | 12.1 | - | 10.01 MiB | 32 thread(s) | +| `grid_embed` | `ref_grid_embed` | libref | `n=1152 side=48 dtype=bf16 M=512` | - | 19138.53 | 11848.48 | 21971.92 | 20 | 10.7 | - | 6.20 MiB | 32 thread(s) | +| `sample_dry` | `avx_sample_dry` | libavx | `n_vocab=248320 M=8` | - | 19126.18 | 9823.13 | 27977.78 | 20 | 27.5 | - | 7.58 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | - | 19096.58 | 12815.86 | 24575.46 | 20 | 12.7 | - | 32.13 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=4096 group=128 dtype=bf16 M=16` | - | 19084.58 | 17979.29 | 22993.45 | 20 | 12.5 | - | 194.00 KiB | 32 thread(s) | +| `mul_weight` | `avx_mul_weight` | libavx | `n=8192 dtype=bf16 M=256` | - | 19062.40 | 10065.99 | 23965.36 | 20 | 13.0 | - | 8.02 MiB | 32 thread(s) | +| `sample_mask` | `ref_sample_mask` | libref | `n_vocab=248320 M=4` | - | 19058.48 | 13515.36 | 26433.96 | 20 | 18.6 | - | 3.91 MiB | 32 thread(s) | +| `scatter_rows` | `avx_scatter_rows` | libavx | `n=5120 dtype=bf16 M=64` | - | 19057.10 | 11602.85 | 25540.13 | 20 | 18.4 | - | 3.13 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=8192 group=128 dtype=bf16 M=16` | - | 19044.83 | 17036.90 | 26991.91 | 20 | 20.8 | - | 388.00 KiB | 32 thread(s) | +| `add` | `avx_add` | libavx | `n=5120 dtype=bf16 M=512` | - | 19043.11 | 8998.44 | 34892.26 | 20 | 26.6 | - | 15.00 MiB | 32 thread(s) | +| `mul_weight` | `ref_mul_weight` | libref | `n=8192 dtype=bf16 M=8` | - | 19040.87 | 11071.75 | 37990.22 | 20 | 18.5 | - | 272.00 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=16` | - | 19028.49 | 11082.07 | 26982.95 | 20 | 23.6 | - | 128.06 KiB | 32 thread(s) | +| `sample_pick` | `avx_sample_pick` | libavx | `n_cand=1024 M=8` | - | 19024.82 | 5990.92 | 26999.52 | 40 | 25.2 | - | 64.78 KiB | 32 thread(s) | +| `grid_embed` | `avx_grid_embed` | libavx | `n=1152 side=48 dtype=bf16 M=32` | - | 19024.23 | 11986.34 | 23988.67 | 20 | 10.4 | - | 5.13 MiB | 32 thread(s) | +| `kv_store` | `ref_kv_store` | libref | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=32` | - | 19020.15 | 8949.60 | 26962.96 | 20 | 20.9 | - | 256.12 KiB | 32 thread(s) | +| `attn_dense` | `ref_attn_dense` | libref | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=32` | - | 19016.46 | 11628.39 | 30001.08 | 20 | 25.3 | - | 18.01 KiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1024 K=4096 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 19005.67 | 9001.28 | 24383.94 | 20 | 15.8 | - | 8.33 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=9 splits=0` | - | 19003.94 | 7378.83 | 22921.31 | 20 | 25.5 | - | 4.21 MiB | 32 thread(s) | +| `sample_xtc` | `ref_sample_xtc` | libref | `n_cand=1024 M=16` | - | 19001.86 | 14981.74 | 26968.51 | 20 | 20.9 | - | 129.50 KiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=2048 act=relu dtype=bf16 M=16` | - | 18996.19 | 7003.43 | 21005.73 | 20 | 23.7 | - | 192.00 KiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=9` | - | 18989.79 | 5997.02 | 22989.24 | 20 | 26.3 | - | 160.01 KiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=16` | - | 18941.76 | 11987.32 | 23963.69 | 20 | 10.7 | - | 572.50 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=64` | - | 18928.73 | 17898.25 | 22922.56 | 20 | 13.2 | - | 432.50 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=5376 group=128 dtype=bf16 M=256` | - | 18892.60 | 14015.07 | 24061.32 | 20 | 10.6 | - | 3.98 MiB | 32 thread(s) | +| `lili_attn` | `ref_lili_attn` | libref | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=256` | - | 18882.64 | 17084.21 | 23997.57 | 20 | 13.7 | - | 2.19 MiB | 32 thread(s) | +| `scatter_rows` | `ref_scatter_rows` | libref | `n=4096 dtype=bf16 M=64` | - | 18773.84 | 13911.99 | 29740.97 | 20 | 15.8 | - | 2.50 MiB | 32 thread(s) | +| `scatter_rows` | `avx_scatter_rows` | libavx | `n=4096 dtype=bf16 M=512` | - | 18735.96 | 5405.07 | 24337.43 | 20 | 29.5 | - | 20.00 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=25600 group=128 dtype=bf16 M=512` | - | 18717.59 | 9699.16 | 23998.61 | 20 | 32.1 | - | 37.89 MiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=8192 act=silu dtype=bf16 M=512` | - | 18689.03 | 16905.48 | 26006.23 | 20 | 20.5 | - | 24.00 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=17408 group=128 dtype=bf16 M=8` | - | 18657.99 | 11984.58 | 27008.50 | 20 | 16.1 | - | 412.25 KiB | 32 thread(s) | +| `cast` | `avx_cast` | libavx | `n=4096 from=bf16 to=bf16 M=4` | - | 18653.18 | 14026.67 | 32998.10 | 20 | 16.2 | - | 64.00 KiB | 32 thread(s) | +| `add` | `ref_add` | libref | `n=4096 dtype=bf16 M=16` | - | 18533.70 | 13035.94 | 23961.35 | 20 | 10.8 | - | 384.00 KiB | 32 thread(s) | +| `add` | `ref_add` | libref | `n=5120 dtype=bf16 M=16` | - | 18533.59 | 8998.87 | 25919.28 | 20 | 32.4 | - | 480.00 KiB | 32 thread(s) | +| `grid_embed` | `avx_grid_embed` | libavx | `n=1152 side=48 dtype=bf16 M=128` | - | 18528.07 | 13212.75 | 21953.39 | 20 | 10.3 | - | 5.35 MiB | 32 thread(s) | +| `add` | `avx_add` | libavx | `n=4096 dtype=bf16 M=8` | - | 18513.54 | 10985.01 | 26004.46 | 20 | 21.5 | - | 192.00 KiB | 32 thread(s) | +| `grid_embed` | `avx_grid_embed` | libavx | `n=1152 side=48 dtype=bf16 M=16` | - | 18508.05 | 11960.94 | 21923.74 | 20 | 10.7 | - | 5.10 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=11` | - | 18499.01 | 10000.06 | 26987.59 | 20 | 24.4 | - | 296.01 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=24576 K=4096 group=128 dtype=fp8a8 M=8` | - | 18498.90 | 13997.43 | 30995.55 | 20 | 18.9 | - | 96.42 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=9 splits=0` | - | 18492.13 | 5986.66 | 26995.47 | 20 | 37.8 | - | 248.01 KiB | 32 thread(s) | +| `moe_gather` | `ref_moe_gather` | libref | `n=1024 top_k=9 dtype=bf16 act=none M=32` | - | 18491.74 | 7209.56 | 27659.71 | 20 | 33.3 | - | 705.75 KiB | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=1280 dtype=bf16 M=64` | - | 18486.76 | 7048.30 | 23618.30 | 20 | 24.5 | - | 800.25 KiB | 32 thread(s) | +| `add` | `avx_add` | libavx | `n=5120 dtype=bf16 M=256` | - | 18485.91 | 8954.23 | 20994.02 | 20 | 16.2 | - | 7.50 MiB | 32 thread(s) | +| `gdn_kkt_solve` | `ref_gdn_kkt_solve` | libref | `head_k=128 M=16 chunk=64` | - | 18473.72 | 12028.82 | 29996.96 | 20 | 38.4 | - | 166.01 KiB | 32 thread(s) | +| `sample_mask` | `avx_sample_mask` | libavx | `n_vocab=248320 M=64` | - | 18455.36 | 11703.48 | 20999.33 | 20 | 15.0 | - | 62.53 MiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=256` | - | 18443.85 | 10990.89 | 27892.63 | 20 | 18.9 | - | 515.00 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=256` | - | 18430.14 | 11923.13 | 29899.53 | 20 | 27.2 | - | 515.00 KiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=5376 act=relu dtype=bf16 M=64` | - | 18413.56 | 8998.96 | 22885.40 | 20 | 21.2 | - | 1.97 MiB | 32 thread(s) | +| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=512` | - | 18396.22 | 17839.17 | 18989.13 | 20 | 1.3 | - | 320.01 KiB | 32 thread(s) | +| `grid_embed_cpe` | `ref_grid_embed_cpe` | libref | `n=1280 side=128 n_prefix=10 dtype=bf16 M=256` | - | 18364.50 | 11926.08 | 27905.28 | 20 | 26.3 | - | 40.65 MiB | 32 thread(s) | +| `gdn_recurrent_update` | `avx_gdn_recurrent_update` | libavx | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=1` | - | 18284.30 | 8120.40 | 27266.74 | 20 | 27.7 | - | 18.04 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=8192 group=128 dtype=bf16 M=512` | - | 18265.80 | 16172.49 | 23073.23 | 20 | 13.6 | - | 12.12 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | - | 18194.32 | 8988.06 | 24006.58 | 20 | 17.8 | - | 888.02 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=25600 group=128 dtype=bf16 M=16` | - | 18185.80 | 8964.05 | 22998.20 | 20 | 22.0 | - | 1.18 MiB | 32 thread(s) | +| `sample_dry` | `avx_sample_dry` | libavx | `n_vocab=248320 M=32` | - | 18184.11 | 8999.35 | 31080.70 | 20 | 38.1 | - | 30.33 MiB | 32 thread(s) | +| `quant_act_i8` | `ref_quant_act_i8` | libref | `n=5120 group=128 dtype=bf16 M=56` | - | 18129.32 | 11994.64 | 26990.56 | 20 | 38.7 | - | 850.22 KiB | 32 thread(s) | +| `grid_embed_cpe` | `avx_grid_embed_cpe` | libavx | `n=1280 side=128 n_prefix=10 dtype=bf16 M=256` | - | 18117.10 | 9414.27 | 22312.27 | 20 | 7.9 | - | 40.65 MiB | 32 thread(s) | +| `kv_store` | `ref_kv_store` | libref | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=512` | - | 18095.11 | 10250.09 | 26773.13 | 20 | 23.3 | - | 3.06 MiB | 32 thread(s) | +| `gather_rows` | `ref_gather_rows` | libref | `n=1280 dtype=bf16 M=512` | - | 18086.53 | 10101.06 | 30379.99 | 20 | 25.0 | - | 6.25 MiB | 32 thread(s) | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | `N=240 K=4096 dtype=bf16 M=2` | - | 18067.64 | 13900.17 | 23986.59 | 20 | 12.2 | - | 3.77 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=5376 group=128 dtype=bf16 M=16` | - | 18062.59 | 9002.37 | 24972.58 | 20 | 16.7 | - | 254.62 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=5120 group=128 dtype=bf16 M=16` | - | 18056.53 | 11966.95 | 20997.03 | 20 | 5.8 | - | 242.50 KiB | 32 thread(s) | +| `scatter_rows` | `avx_scatter_rows` | libavx | `n=5120 dtype=bf16 M=256` | - | 18038.51 | 8402.09 | 25340.71 | 20 | 24.9 | - | 12.50 MiB | 32 thread(s) | +| `kv_store` | `ref_kv_store` | libref | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=256` | - | 18035.91 | 13868.72 | 29897.14 | 20 | 33.3 | - | 1.56 MiB | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=1280 dtype=bf16 M=512` | - | 18020.65 | 11961.81 | 26252.56 | 20 | 26.8 | - | 6.25 MiB | 32 thread(s) | +| `layernorm` | `avx_layernorm` | libavx | `n=1280 eps=1e-06 dtype=bf16 M=512` | - | 18019.88 | 11994.59 | 25994.05 | 20 | 35.9 | - | 2.50 MiB | 32 thread(s) | +| `mul_weight` | `avx_mul_weight` | libavx | `n=8192 dtype=bf16 M=64` | - | 18019.79 | 17974.10 | 28969.17 | 20 | 16.6 | - | 2.02 MiB | 32 thread(s) | +| `sample_dry` | `avx_sample_dry` | libavx | `n_vocab=248320 M=64` | - | 18019.74 | 10724.84 | 23557.49 | 20 | 27.4 | - | 60.65 MiB | 32 thread(s) | +| `sample_argmax` | `avx_sample_argmax` | libavx | `n_vocab=248320 M=64` | - | 18019.27 | 10778.36 | 23997.64 | 20 | 21.2 | - | 60.63 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=12288 group=128 dtype=fp8a8 M=4` | - | 18015.62 | 8997.24 | 26005.63 | 20 | 16.7 | - | 48.09 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=1024 eps=1e-05 dtype=bf16 M=64` | - | 18013.38 | 11935.49 | 24002.13 | 20 | 13.8 | - | 256.00 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=10 splits=0` | - | 18012.52 | 11797.70 | 28979.29 | 20 | 25.0 | - | 272.01 KiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=5376 act=relu dtype=bf16 M=8` | - | 18010.11 | 14986.16 | 23991.46 | 20 | 16.6 | - | 252.00 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=32` | - | 18009.79 | 12003.12 | 31006.51 | 20 | 27.8 | - | 650.00 KiB | 32 thread(s) | +| `sample_argmax` | `avx_sample_argmax` | libavx | `n_vocab=248320 M=4` | - | 18008.80 | 17580.63 | 27007.21 | 20 | 16.7 | - | 3.79 MiB | 32 thread(s) | +| `add` | `ref_add` | libref | `n=4096 dtype=bf16 M=512` | - | 18008.12 | 17945.98 | 18019.53 | 6 | 0.2 | - | 12.00 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=4096 group=128 dtype=fp8a8 M=65` | - | 18007.80 | 13018.71 | 22991.34 | 20 | 13.8 | - | 16.77 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 18006.59 | 11989.91 | 26015.63 | 20 | 16.6 | - | 4.05 MiB | 32 thread(s) | +| `grid_embed_cpe` | `avx_grid_embed_cpe` | libavx | `n=1280 side=128 n_prefix=10 dtype=bf16 M=16` | - | 18004.73 | 8970.00 | 26976.83 | 20 | 22.0 | - | 40.06 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=64` | - | 18003.95 | 12019.45 | 26969.77 | 20 | 16.7 | - | 1.26 MiB | 32 thread(s) | +| `mul_weight` | `avx_mul_weight` | libavx | `n=8192 dtype=bf16 M=16` | - | 18003.74 | 10953.91 | 29989.15 | 20 | 44.4 | - | 528.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=24576 group=128 dtype=fp8a8 M=2` | - | 18003.59 | 13976.09 | 30003.43 | 20 | 19.5 | - | 96.08 MiB | 32 thread(s) | +| `gated_quant_fp8` | `avx_gated_quant_fp8` | libavx | `n=17408 group=128 dtype=bf16 act=silu M=1` | - | 18003.04 | 9037.10 | 36086.20 | 20 | 25.0 | - | 119.53 KiB | 32 thread(s) | +| `mul_weight` | `avx_mul_weight` | libavx | `n=8192 dtype=bf16 M=128` | - | 18002.88 | 8993.33 | 26949.30 | 20 | 19.7 | - | 4.02 MiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=8192 act=silu dtype=bf16 M=16` | - | 18002.80 | 8020.03 | 21966.31 | 20 | 24.9 | - | 768.00 KiB | 32 thread(s) | +| `sample_argmax` | `ref_sample_argmax` | libref | `n_vocab=248320 M=1` | - | 18001.84 | 8986.13 | 26990.66 | 20 | 2.9 | - | 970.10 KiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=20480 act=relu dtype=bf16 M=1` | - | 18001.57 | 8998.82 | 26995.87 | 20 | 41.6 | - | 120.00 KiB | 32 thread(s) | +| `add` | `avx_add` | libavx | `n=5120 dtype=bf16 M=128` | - | 18001.49 | 12016.20 | 25028.24 | 20 | 16.6 | - | 3.75 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=4096 group=128 dtype=fp8a8 M=9` | - | 18001.47 | 17980.60 | 20980.25 | 14 | 0.1 | - | 16.11 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=1024 group=128 dtype=bf16 M=256` | - | 18001.37 | 14000.77 | 21977.11 | 20 | 5.6 | - | 776.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=1024 group=128 dtype=bf16 M=512` | - | 18000.96 | 14987.88 | 26995.80 | 20 | 21.1 | - | 1.52 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=1024 eps=1e-05 dtype=bf16 M=256` | - | 18000.81 | 17904.82 | 18079.55 | 6 | 0.5 | - | 1.00 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=2048 K=1024 dtype=bf16 act=none M=2` | - | 18000.74 | 9000.40 | 21998.35 | 20 | 11.1 | - | 4.02 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=1024 dtype=bf16 act=none M=16` | - | 18000.67 | 17991.48 | 35996.40 | 20 | 33.3 | - | 2.10 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=5376 act=relu dtype=bf16 M=256` | - | 18000.36 | 11997.55 | 27003.60 | 20 | 18.0 | - | 7.88 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=4` | - | 18000.31 | 8998.86 | 26896.61 | 16 | 0.2 | - | 90.00 KiB | 32 thread(s) | +| `lili_attn` | `ref_lili_attn` | libref | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=2` | - | 18000.18 | 17942.11 | 18031.02 | 6 | 0.2 | - | 448.50 KiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=17` | - | 18000.07 | 15995.67 | 35997.30 | 20 | 33.3 | - | 2.27 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1024 K=4096 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 18000.02 | 17992.24 | 18007.05 | 6 | 0.0 | - | 8.17 MiB | 32 thread(s) | +| `silu_mul` | `ref_silu_mul` | libref | `n=17408 dtype=bf16 M=32` | - | 17999.95 | 11173.78 | 27624.17 | 20 | 39.6 | - | 3.19 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=25600 group=128 dtype=bf16 M=4` | - | 17999.91 | 8998.07 | 26998.07 | 20 | 25.0 | - | 303.12 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=24576 K=4096 group=128 dtype=fp8a8 M=1` | - | 17999.79 | 8992.17 | 24983.20 | 20 | 30.6 | - | 96.06 MiB | 32 thread(s) | +| `moe_gather` | `avx_moe_gather` | libavx | `n=1024 top_k=9 dtype=bf16 act=none M=8` | - | 17999.75 | 9035.15 | 19005.51 | 14 | 0.1 | - | 176.44 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=1536 group=128 dtype=bf16 M=256` | - | 17999.70 | 8979.49 | 24945.74 | 20 | 5.8 | - | 1.14 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=8192 group=128 dtype=bf16 M=8` | - | 17999.68 | 14983.01 | 29999.71 | 20 | 30.5 | - | 194.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=256 K=4096 group=128 dtype=fp8a8 M=33` | - | 17999.55 | 7001.03 | 24996.29 | 20 | 11.2 | - | 1.15 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=4096 group=128 dtype=fp8a8 M=33` | - | 17999.37 | 15999.69 | 21000.97 | 20 | 11.1 | - | 16.39 MiB | 32 thread(s) | +| `mul_weight` | `avx_mul_weight` | libavx | `n=8192 dtype=bf16 M=8` | - | 17999.37 | 16934.40 | 20049.66 | 16 | 0.1 | - | 272.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=2048 dtype=bf16 act=none M=4` | - | 17999.29 | 17990.68 | 19997.16 | 16 | 0.0 | - | 4.03 MiB | 32 thread(s) | +| `attn_paged_sink` | `ref_attn_paged_sink` | libref | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1` | - | 17999.01 | 17993.98 | 18001.63 | 6 | 0.0 | - | 32.13 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=2048 group=128 dtype=bf16 M=128` | - | 17999.00 | 11992.77 | 23999.32 | 20 | 32.7 | - | 776.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=2048 K=1024 dtype=bf16 act=none M=8` | - | 17998.99 | 17995.47 | 24004.33 | 14 | 0.0 | - | 4.08 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=1536 group=128 dtype=bf16 M=32` | - | 17998.94 | 8999.36 | 26343.35 | 19 | 0.2 | - | 145.50 KiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=2048 dtype=bf16 act=none M=8` | - | 17998.94 | 17990.83 | 18009.27 | 6 | 0.1 | - | 4.06 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4608 K=4096 group=128 dtype=fp8a8 M=9` | - | 17998.83 | 8966.00 | 27461.58 | 20 | 29.1 | - | 18.12 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1024 K=4096 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 17998.68 | 17994.31 | 17999.89 | 6 | 0.0 | - | 8.02 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=128` | - | 17998.60 | 10913.07 | 23996.47 | 20 | 30.5 | - | 128.50 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=25600 group=128 dtype=bf16 M=2` | - | 17998.56 | 5963.65 | 24994.91 | 20 | 16.7 | - | 151.56 KiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=3072 dtype=bf16 act=none M=4` | - | 17998.51 | 17992.16 | 18001.67 | 6 | 0.0 | - | 6.04 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1024 K=4096 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 17998.48 | 17993.55 | 18001.61 | 11 | 0.0 | - | 8.62 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=2048 group=128 dtype=bf16 M=8` | - | 17998.38 | 5997.65 | 29861.31 | 20 | 30.6 | - | 48.50 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=256 K=4096 group=128 dtype=fp8a8 M=64` | - | 17998.37 | 17989.19 | 20999.70 | 19 | 0.0 | - | 1.29 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3072 K=1024 dtype=bf16 act=none M=2` | - | 17998.30 | 17993.14 | 18001.63 | 6 | 0.0 | - | 6.03 MiB | 32 thread(s) | +| `layernorm` | `ref_layernorm` | libref | `n=1152 eps=1e-06 dtype=bf16 M=512` | - | 17998.11 | 12033.46 | 24006.89 | 20 | 6.6 | - | 2.25 MiB | 32 thread(s) | +| `attn_paged_sink` | `ref_attn_paged_sink` | libref | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2` | - | 17998.11 | 17983.33 | 24007.93 | 14 | 0.0 | - | 2.03 MiB | 32 thread(s) | +| `sample_pick` | `avx_sample_pick` | libavx | `n_cand=1024 M=2` | - | 17998.07 | 5997.18 | 24984.42 | 40 | 33.4 | - | 16.20 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5376 group=128 dtype=bf16 M=128` | - | 17998.03 | 11048.65 | 26989.63 | 20 | 22.3 | - | 1.99 MiB | 32 thread(s) | +| `attn_paged_sink` | `ref_attn_paged_sink` | libref | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8` | - | 17998.02 | 17979.67 | 23473.51 | 20 | 2.8 | - | 144.13 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=25600 group=128 dtype=bf16 M=128` | - | 17997.96 | 7554.25 | 24128.84 | 20 | 17.7 | - | 9.47 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=2048 dtype=bf16 act=none M=128` | - | 17997.91 | 17974.07 | 18020.33 | 6 | 0.1 | - | 5.00 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=4096 dtype=bf16 act=none M=8` | - | 17997.90 | 17984.75 | 18009.34 | 6 | 0.1 | - | 8.10 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=2048 group=128 dtype=bf16 M=64` | - | 17997.87 | 11990.04 | 24107.59 | 20 | 30.4 | - | 388.00 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | - | 17997.84 | 8999.07 | 26993.63 | 20 | 19.4 | - | 416.01 KiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=32` | - | 17997.81 | 17987.66 | 19005.93 | 14 | 0.0 | - | 544.01 KiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=2048 K=1024 dtype=bf16 act=none M=256` | - | 17997.76 | 17979.69 | 18017.58 | 6 | 0.1 | - | 6.50 MiB | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=4096 dtype=bf16 M=16` | - | 17997.76 | 11994.19 | 23998.80 | 20 | 33.3 | - | 640.06 KiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=1536 act=relu dtype=bf16 M=128` | - | 17997.68 | 8997.47 | 26026.53 | 20 | 25.0 | - | 1.12 MiB | 32 thread(s) | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | `N=304 K=4096 dtype=bf16 M=32` | - | 17997.68 | 17989.81 | 18004.14 | 6 | 0.0 | - | 5.04 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=512` | - | 17997.65 | 17986.71 | 18003.08 | 6 | 0.0 | - | 10.01 MiB | 32 thread(s) | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | `N=240 K=4096 dtype=bf16 M=1` | - | 17997.51 | 17986.74 | 18004.88 | 6 | 0.1 | - | 3.76 MiB | 32 thread(s) | +| `attn_paged_sink` | `ref_attn_paged_sink` | libref | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2` | - | 17997.50 | 17988.64 | 18003.33 | 6 | 0.0 | - | 16.04 MiB | 32 thread(s) | +| `add` | `avx_add` | libavx | `n=4096 dtype=bf16 M=16` | - | 17997.50 | 17012.22 | 26981.28 | 20 | 2.8 | - | 384.00 KiB | 32 thread(s) | +| `sample_topk` | `avx_sample_topk` | libavx | `n_vocab=131072 M=32` | - | 17997.44 | 15620.66 | 18939.81 | 14 | 0.5 | - | 16.03 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=1536 group=128 dtype=bf16 M=8` | - | 17997.41 | 11995.72 | 21002.54 | 20 | 2.3 | - | 36.38 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=64` | - | 17997.35 | 11983.38 | 29993.31 | 20 | 33.2 | - | 1.26 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=1024 dtype=bf16 act=none M=128` | - | 17997.32 | 17968.62 | 20996.46 | 19 | 0.0 | - | 2.75 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=256 K=4096 group=128 dtype=fp8a8 M=18` | - | 17997.30 | 8990.27 | 24991.42 | 20 | 36.1 | - | 1.08 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1024 K=4096 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 17997.27 | 11105.15 | 29993.64 | 20 | 39.3 | - | 8.01 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=12288 group=128 dtype=fp8a8 M=2` | - | 17997.24 | 17994.87 | 17998.89 | 6 | 0.0 | - | 48.05 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=256 K=4096 group=128 dtype=fp8a8 M=4` | - | 17997.24 | 10998.58 | 28996.83 | 20 | 33.3 | - | 1.02 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=2048 dtype=bf16 act=none M=16` | - | 17996.97 | 17986.95 | 18005.67 | 6 | 0.1 | - | 4.13 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1 splits=0` | - | 17996.92 | 17985.76 | 18000.01 | 6 | 0.0 | - | 32.01 KiB | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=1280 dtype=bf16 M=256` | - | 17996.84 | 9003.14 | 26991.07 | 20 | 5.6 | - | 3.13 MiB | 32 thread(s) | +| `lili_attn` | `avx_lili_attn` | libavx | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=1` | - | 17996.83 | 14385.93 | 18000.46 | 11 | 0.0 | - | 448.50 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | - | 17996.77 | 5999.02 | 29342.87 | 20 | 38.9 | - | 4.09 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 17996.57 | 14006.94 | 21994.33 | 20 | 2.8 | - | 32.02 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=2048 K=1024 dtype=bf16 act=none M=1` | - | 17996.57 | 17977.80 | 18010.40 | 11 | 0.1 | - | 4.01 MiB | 32 thread(s) | +| `add` | `avx_add` | libavx | `n=5120 dtype=bf16 M=4` | - | 17996.49 | 17994.14 | 18000.07 | 6 | 0.0 | - | 120.00 KiB | 32 thread(s) | +| `attn_paged_sink` | `ref_attn_paged_sink` | libref | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4` | - | 17996.43 | 8996.48 | 19424.79 | 20 | 2.8 | - | 2.06 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=25600 group=128 dtype=bf16 M=8` | - | 17996.42 | 11997.90 | 19017.12 | 20 | 11.2 | - | 606.25 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=6144 group=128 dtype=bf16 M=256` | - | 17996.35 | 8995.90 | 26923.35 | 20 | 5.8 | - | 4.55 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=128` | - | 17996.23 | 17991.82 | 23991.50 | 16 | 0.0 | - | 2.51 MiB | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=5120 dtype=bf16 M=4` | - | 17996.15 | 11987.52 | 23998.26 | 20 | 16.7 | - | 200.02 KiB | 32 thread(s) | +| `layernorm` | `avx_layernorm` | libavx | `n=1152 eps=1e-06 dtype=bf16 M=128` | - | 17996.08 | 9018.67 | 26985.06 | 20 | 22.2 | - | 580.50 KiB | 32 thread(s) | +| `attn_paged_sink` | `ref_attn_paged_sink` | libref | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1` | - | 17995.93 | 17984.65 | 19992.29 | 14 | 0.1 | - | 2.02 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=1024 group=128 dtype=bf16 M=64` | - | 17995.86 | 11065.77 | 23900.28 | 14 | 0.4 | - | 194.00 KiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=1536 act=relu dtype=bf16 M=64` | - | 17995.59 | 12009.40 | 22977.38 | 20 | 27.6 | - | 576.00 KiB | 32 thread(s) | +| `sample_argmax` | `ref_sample_argmax` | libref | `n_vocab=248320 M=4` | - | 17995.57 | 9998.24 | 25215.32 | 20 | 5.5 | - | 3.79 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=16` | - | 17995.34 | 9069.62 | 24922.28 | 20 | 1.5 | - | 330.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=3072 dtype=bf16 act=none M=32` | - | 17995.30 | 17887.24 | 18107.74 | 6 | 0.6 | - | 6.31 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=2048 dtype=bf16 act=none M=32` | - | 17995.08 | 15990.80 | 18096.54 | 11 | 0.6 | - | 4.25 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=1536 group=128 dtype=bf16 M=512` | - | 17995.08 | 11994.85 | 20983.39 | 20 | 10.9 | - | 2.27 MiB | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=1280 dtype=bf16 M=16` | - | 17995.01 | 12001.81 | 26999.44 | 20 | 27.8 | - | 200.06 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=256 K=4096 group=128 dtype=fp8a8 M=129` | - | 17994.96 | 17983.10 | 18004.53 | 6 | 0.1 | - | 1.58 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=4096 group=128 dtype=bf16 M=32` | - | 17994.75 | 11996.28 | 24005.38 | 20 | 16.4 | - | 388.00 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=256` | - | 17994.73 | 11070.31 | 26997.65 | 20 | 30.8 | - | 5.01 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=12288 group=128 dtype=fp8a8 M=9` | - | 17994.69 | 11998.86 | 28985.69 | 20 | 22.1 | - | 48.18 MiB | 32 thread(s) | +| `layernorm` | `avx_layernorm` | libavx | `n=1152 eps=1e-06 dtype=bf16 M=16` | - | 17994.53 | 11996.82 | 24024.52 | 20 | 30.5 | - | 76.50 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=1536 group=128 dtype=bf16 M=16` | - | 17994.43 | 9018.38 | 19023.02 | 20 | 5.6 | - | 72.75 KiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3072 K=1024 dtype=bf16 act=none M=4` | - | 17994.29 | 17989.57 | 18009.13 | 6 | 0.1 | - | 6.06 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=2048 K=1024 dtype=bf16 act=none M=4` | - | 17993.63 | 17989.97 | 18005.60 | 6 | 0.0 | - | 4.04 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 17993.54 | 8991.84 | 17999.24 | 20 | 11.2 | - | 96.01 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=2048 group=128 dtype=bf16 M=256` | - | 17993.53 | 5999.22 | 23918.11 | 20 | 44.4 | - | 1.52 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=4` | - | 17993.46 | 11981.48 | 29989.50 | 20 | 33.3 | - | 90.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5376 group=128 dtype=bf16 M=64` | - | 17993.45 | 11988.05 | 22002.94 | 20 | 22.2 | - | 1018.50 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=1024 group=128 dtype=fp8a8 M=2` | - | 17993.21 | 8992.86 | 26019.03 | 20 | 33.4 | - | 4.02 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=2048 dtype=bf16 act=none M=32` | - | 17993.10 | 7114.03 | 24005.57 | 20 | 41.3 | - | 4.25 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=5376 group=128 dtype=bf16 M=32` | - | 17992.89 | 9114.69 | 27998.04 | 20 | 22.7 | - | 509.25 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=4096 group=128 dtype=bf16 M=64` | - | 17992.59 | 5998.99 | 18006.42 | 40 | 19.6 | - | 776.00 KiB | 32 thread(s) | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | `N=240 K=4096 dtype=bf16 M=64` | - | 17992.32 | 9001.26 | 24496.59 | 20 | 10.1 | - | 4.31 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=2048 group=128 dtype=bf16 M=512` | - | 17992.27 | 8994.06 | 18069.15 | 20 | 5.7 | - | 3.03 MiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=4` | - | 17992.05 | 8018.82 | 23985.97 | 20 | 16.7 | - | 150.62 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=2048 group=128 dtype=bf16 M=16` | - | 17991.66 | 5997.43 | 21001.81 | 20 | 25.1 | - | 97.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=5120 group=128 dtype=bf16 M=128` | - | 17991.17 | 17985.55 | 18015.22 | 11 | 0.1 | - | 1.89 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=1536 group=128 dtype=bf16 M=32` | - | 17991.13 | 12027.84 | 23968.70 | 20 | 30.3 | - | 145.50 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 17990.39 | 8995.52 | 18003.88 | 20 | 25.0 | - | 64.01 KiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=11` | - | 17989.91 | 14000.07 | 18666.51 | 20 | 2.8 | - | 2.17 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=25600 group=128 dtype=bf16 M=4` | - | 17989.86 | 11993.96 | 28989.45 | 20 | 34.9 | - | 303.12 KiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=33` | - | 17989.75 | 8974.45 | 21981.72 | 20 | 25.0 | - | 576.02 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | - | 17989.62 | 11996.03 | 19997.20 | 20 | 2.8 | - | 128.01 KiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=1024 dtype=bf16 act=none M=16` | - | 17988.85 | 6996.04 | 24005.36 | 20 | 22.2 | - | 2.10 MiB | 32 thread(s) | +| `gdn_conv_update` | `avx_gdn_conv_update` | libavx | `head_k=128 head_v=128 conv_width=4 q_len=2` | - | 17988.73 | 9060.35 | 26992.54 | 20 | 20.7 | - | 240.02 KiB | 32 thread(s) | +| `layernorm` | `ref_layernorm` | libref | `n=1152 eps=1e-06 dtype=bf16 M=128` | - | 17987.73 | 10924.34 | 22879.58 | 20 | 24.4 | - | 580.50 KiB | 32 thread(s) | +| `ple_conv_bias` | `ref_ple_conv_bias` | libref | `n=10240 width=4 dilation=1 dtype=bf16 M=2` | - | 17987.58 | 11989.48 | 23988.03 | 20 | 13.7 | - | 300.02 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=1024 group=128 dtype=bf16 M=32` | - | 17987.41 | 7008.72 | 18016.38 | 20 | 11.2 | - | 97.00 KiB | 32 thread(s) | +| `gather_rows` | `ref_gather_rows` | libref | `n=5120 dtype=bf16 M=32` | - | 17987.40 | 11029.48 | 21001.01 | 20 | 16.6 | - | 1.56 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4608 K=4096 group=128 dtype=fp8a8 M=18` | - | 17987.36 | 12001.18 | 18000.30 | 20 | 16.6 | - | 18.23 MiB | 32 thread(s) | +| `sample_topp` | `avx_sample_topp` | libavx | `n_cand=1024 M=4` | - | 17986.85 | 5995.20 | 23988.64 | 40 | 27.7 | - | 32.38 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=8` | - | 17986.45 | 6102.85 | 24873.47 | 20 | 16.6 | - | 64.03 KiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | - | 17985.67 | 6001.56 | 28970.37 | 20 | 44.5 | - | 176.01 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5376 group=128 dtype=bf16 M=256` | - | 17983.75 | 8995.74 | 17998.85 | 20 | 19.2 | - | 3.98 MiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=1536 act=relu dtype=bf16 M=32` | - | 17982.69 | 8972.98 | 25967.82 | 20 | 5.7 | - | 288.00 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=2048 group=128 dtype=bf16 M=32` | - | 17982.44 | 8981.87 | 26976.17 | 20 | 22.2 | - | 194.00 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=64` | - | 17981.87 | 9996.75 | 24945.15 | 20 | 5.6 | - | 128.75 KiB | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=5120 dtype=bf16 M=16` | - | 17980.34 | 12994.52 | 18991.40 | 20 | 13.6 | - | 800.06 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=2048 group=128 dtype=bf16 M=64` | - | 17979.79 | 8979.44 | 24901.04 | 20 | 25.0 | - | 388.00 KiB | 32 thread(s) | +| `grid_embed` | `ref_grid_embed` | libref | `n=1152 side=48 dtype=bf16 M=64` | - | 17979.38 | 7791.31 | 20984.91 | 20 | 25.0 | - | 5.20 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=5376 group=128 dtype=bf16 M=512` | - | 17978.36 | 13420.54 | 20027.20 | 20 | 9.5 | - | 7.96 MiB | 32 thread(s) | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | `N=304 K=4096 dtype=bf16 M=4` | - | 17977.68 | 17916.83 | 18094.80 | 6 | 0.5 | - | 4.79 MiB | 32 thread(s) | +| `add` | `avx_add` | libavx | `n=5120 dtype=bf16 M=8` | - | 17977.51 | 9007.83 | 28933.31 | 20 | 33.3 | - | 240.00 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=32` | - | 17975.35 | 9003.80 | 26944.11 | 20 | 41.5 | - | 650.00 KiB | 32 thread(s) | +| `kv_store` | `ref_kv_store` | libref | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=64` | - | 17972.92 | 11967.59 | 29975.51 | 20 | 25.0 | - | 448.25 KiB | 32 thread(s) | +| `attn_paged_sink` | `ref_attn_paged_sink` | libref | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4` | - | 17972.73 | 5986.87 | 23997.36 | 20 | 19.5 | - | 80.13 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=64` | - | 17972.67 | 11967.69 | 23954.81 | 20 | 16.7 | - | 128.75 KiB | 32 thread(s) | +| `sample_xtc` | `avx_sample_xtc` | libavx | `n_cand=1024 M=16` | - | 17971.59 | 5978.02 | 22596.29 | 31 | 11.1 | - | 129.50 KiB | 32 thread(s) | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=16` | - | 17970.79 | 8980.04 | 20979.83 | 20 | 11.1 | - | 160.06 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=1024 group=128 dtype=bf16 M=256` | - | 17970.19 | 10980.75 | 26817.96 | 20 | 18.8 | - | 776.00 KiB | 32 thread(s) | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=32` | - | 17969.79 | 6978.07 | 28962.28 | 20 | 33.3 | - | 256.12 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=16` | - | 17969.24 | 14658.58 | 20014.99 | 20 | 2.9 | - | 192.19 KiB | 32 thread(s) | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=32` | - | 17966.65 | 10994.97 | 26934.77 | 20 | 25.0 | - | 256.12 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=1024 group=128 dtype=bf16 M=8` | - | 17965.86 | 11994.26 | 20012.16 | 20 | 13.9 | - | 24.25 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5376 group=128 dtype=bf16 M=32` | - | 17964.18 | 11999.62 | 20733.78 | 20 | 13.9 | - | 509.25 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=64` | - | 17963.66 | 11984.51 | 23964.45 | 20 | 11.2 | - | 128.25 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=128` | - | 17959.63 | 13934.67 | 22970.60 | 20 | 3.0 | - | 256.50 KiB | 32 thread(s) | +| `sample_topp` | `ref_sample_topp` | libref | `n_cand=1024 M=32` | - | 17957.93 | 10006.91 | 27969.69 | 20 | 28.0 | - | 259.00 KiB | 32 thread(s) | +| `kv_store` | `ref_kv_store` | libref | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=128` | - | 17956.25 | 11074.68 | 23906.80 | 20 | 22.3 | - | 832.50 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=25600 group=128 dtype=bf16 M=16` | - | 17949.12 | 8998.33 | 25552.64 | 20 | 14.3 | - | 1.18 MiB | 32 thread(s) | +| `ple_conv_bias` | `ref_ple_conv_bias` | libref | `n=10240 width=4 dilation=1 dtype=bf16 M=16` | - | 17946.95 | 9269.25 | 26673.86 | 20 | 22.6 | - | 1.39 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=2048 group=128 dtype=bf16 M=16` | - | 17943.40 | 10052.05 | 18010.00 | 20 | 5.8 | - | 97.00 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=32` | - | 17934.18 | 8962.81 | 23897.74 | 20 | 22.2 | - | 384.38 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=32` | - | 17932.80 | 9030.33 | 29910.97 | 20 | 27.6 | - | 216.25 KiB | 32 thread(s) | +| `moe_gather` | `avx_moe_gather` | libavx | `n=1024 top_k=9 dtype=bf16 act=none M=64` | - | 17928.87 | 9089.27 | 17999.76 | 20 | 5.9 | - | 1.38 MiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=256` | - | 17923.48 | 12203.90 | 34325.67 | 20 | 2.5 | - | 513.00 KiB | 32 thread(s) | +| `scatter_rows` | `ref_scatter_rows` | libref | `n=5120 dtype=bf16 M=512` | - | 17917.08 | 9053.81 | 22459.79 | 20 | 30.1 | - | 25.00 MiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=128` | - | 17912.03 | 8935.78 | 17952.70 | 20 | 25.1 | - | 257.50 KiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=128` | - | 17906.21 | 7949.94 | 34789.03 | 20 | 17.3 | - | 3.52 MiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=128` | - | 17901.05 | 5898.52 | 29902.96 | 20 | 50.7 | - | 865.00 KiB | 32 thread(s) | +| `grid_embed` | `avx_grid_embed` | libavx | `n=1152 side=48 dtype=bf16 M=256` | - | 17898.18 | 8892.49 | 17916.77 | 20 | 18.3 | - | 5.63 MiB | 32 thread(s) | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=256` | - | 17897.37 | 10857.44 | 22867.22 | 20 | 19.8 | - | 1.56 MiB | 32 thread(s) | +| `sample_topk` | `avx_sample_topk` | libavx | `n_vocab=131072 M=16` | - | 17890.82 | 11936.18 | 24389.71 | 20 | 22.4 | - | 8.02 MiB | 32 thread(s) | +| `scatter_rows` | `ref_scatter_rows` | libref | `n=5120 dtype=bf16 M=32` | - | 17876.58 | 11675.69 | 23823.11 | 20 | 17.2 | - | 1.56 MiB | 32 thread(s) | +| `moe_gather` | `ref_moe_gather` | libref | `n=1024 top_k=9 dtype=bf16 act=none M=64` | - | 17875.92 | 11648.02 | 33378.42 | 20 | 42.0 | - | 1.38 MiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=64` | - | 17857.76 | 11925.99 | 20942.88 | 20 | 11.4 | - | 432.50 KiB | 32 thread(s) | +| `sample_penalties` | `ref_sample_penalties` | libref | `n_vocab=248320 M=1` | - | 17851.82 | 8819.79 | 38813.32 | 20 | 30.0 | - | 970.34 KiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=1536 act=relu dtype=bf16 M=512` | - | 17846.33 | 12000.45 | 20935.77 | 20 | 7.7 | - | 4.50 MiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=128` | - | 17843.70 | 7856.49 | 24891.29 | 20 | 33.6 | - | 865.00 KiB | 32 thread(s) | +| `kv_store` | `ref_kv_store` | libref | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=512` | - | 17839.62 | 11790.64 | 29780.11 | 20 | 40.3 | - | 3.06 MiB | 32 thread(s) | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=512` | - | 17839.57 | 8807.14 | 26809.12 | 20 | 41.9 | - | 3.06 MiB | 32 thread(s) | +| `grid_embed` | `avx_grid_embed` | libavx | `n=1152 side=48 dtype=bf16 M=512` | - | 17828.35 | 11806.06 | 21231.75 | 20 | 11.0 | - | 6.20 MiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=512` | - | 17818.89 | 12916.38 | 23767.59 | 20 | 11.1 | - | 1.01 MiB | 32 thread(s) | +| `sample_mask` | `avx_sample_mask` | libavx | `n_vocab=248320 M=16` | - | 17812.68 | 13791.62 | 34007.46 | 20 | 32.5 | - | 15.63 MiB | 32 thread(s) | +| `sample_dry` | `ref_sample_dry` | libref | `n_vocab=248320 M=2` | - | 17804.11 | 15746.46 | 17874.10 | 11 | 0.5 | - | 1.90 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=1536 act=relu dtype=bf16 M=512` | - | 17797.35 | 8993.18 | 20994.86 | 20 | 21.2 | - | 4.50 MiB | 32 thread(s) | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=512` | - | 17770.74 | 11795.14 | 27689.58 | 20 | 19.3 | - | 3.06 MiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=256` | - | 17766.57 | 11895.30 | 23525.86 | 20 | 3.8 | - | 8.80 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2 splits=0` | - | 17756.54 | 10896.73 | 22103.24 | 20 | 27.1 | - | 16.04 MiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=512` | - | 17689.06 | 11489.42 | 23826.18 | 20 | 19.7 | - | 3.38 MiB | 32 thread(s) | +| `gdn_recurrent_update` | `ref_gdn_recurrent_update` | libref | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=2` | - | 17680.89 | 7653.77 | 26525.80 | 20 | 44.8 | - | 18.09 MiB | 32 thread(s) | +| `lili_attn` | `ref_lili_attn` | libref | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=128` | - | 17633.62 | 12822.09 | 20981.25 | 20 | 16.0 | - | 1.31 MiB | 32 thread(s) | +| `gdn_recurrent_update` | `ref_gdn_recurrent_update` | libref | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=4` | - | 17595.84 | 10694.10 | 23907.41 | 20 | 15.7 | - | 18.17 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 17561.70 | 11993.21 | 18001.97 | 20 | 13.0 | - | 32.08 MiB | 32 thread(s) | +| `sample_temp` | `ref_sample_temp` | libref | `n_vocab=248320 M=4` | - | 17545.45 | 10489.85 | 26515.74 | 20 | 20.0 | - | 3.79 MiB | 32 thread(s) | +| `add` | `ref_add` | libref | `n=5120 dtype=bf16 M=512` | - | 17521.70 | 8993.98 | 18030.47 | 20 | 21.2 | - | 15.00 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=1024 group=128 dtype=bf16 M=128` | - | 17512.51 | 8981.99 | 26989.93 | 20 | 25.7 | - | 388.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5120 group=128 dtype=bf16 M=32` | - | 17510.05 | 9010.53 | 27990.91 | 20 | 37.1 | - | 485.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5120 group=128 dtype=bf16 M=128` | - | 17509.48 | 11032.47 | 24951.61 | 20 | 25.7 | - | 1.89 MiB | 32 thread(s) | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | `N=240 K=4096 dtype=bf16 M=4` | - | 17506.43 | 8023.55 | 18000.10 | 20 | 17.2 | - | 3.78 MiB | 32 thread(s) | +| `layernorm` | `avx_layernorm` | libavx | `n=1152 eps=1e-06 dtype=bf16 M=64` | - | 17504.20 | 11995.46 | 27003.65 | 20 | 37.1 | - | 292.50 KiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=11` | - | 17499.20 | 7038.33 | 23990.19 | 20 | 29.0 | - | 192.01 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=25600 group=128 dtype=bf16 M=64` | - | 17496.58 | 8997.35 | 23914.74 | 20 | 25.7 | - | 4.74 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=4096 dtype=bf16 act=none M=56` | - | 17493.76 | 10012.81 | 24005.70 | 20 | 22.9 | - | 8.66 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=24576 group=128 dtype=fp8a8 M=1` | - | 17487.88 | 13998.18 | 28639.30 | 20 | 22.9 | - | 96.04 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=1024 group=128 dtype=bf16 M=16` | - | 17487.57 | 11004.68 | 28998.12 | 20 | 27.9 | - | 48.50 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=25600 group=128 dtype=bf16 M=8` | - | 17486.36 | 9001.32 | 19538.99 | 20 | 24.1 | - | 606.25 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=1024 group=128 dtype=bf16 M=128` | - | 17486.03 | 11485.91 | 21911.33 | 20 | 14.2 | - | 388.00 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=64` | - | 17485.94 | 11990.46 | 20017.29 | 20 | 14.2 | - | 1.26 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=4096 group=128 dtype=bf16 M=32` | - | 17485.00 | 1423.36 | 23967.56 | 40 | 17.3 | - | 388.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=25600 group=128 dtype=bf16 M=1` | - | 17474.51 | 9028.31 | 17999.54 | 20 | 20.0 | - | 75.78 KiB | 32 thread(s) | +| `gated_quant_fp8` | `avx_gated_quant_fp8` | libavx | `n=17408 group=128 dtype=bf16 act=silu M=32` | - | 17474.13 | 7078.96 | 29997.71 | 20 | 42.9 | - | 3.74 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=128` | - | 17469.58 | 11963.89 | 21044.47 | 20 | 12.4 | - | 2.51 MiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=512` | - | 17457.13 | 9707.43 | 26282.02 | 20 | 25.8 | - | 17.59 MiB | 32 thread(s) | +| `grid_embed` | `ref_grid_embed` | libref | `n=1152 side=48 dtype=bf16 M=16` | - | 17456.05 | 6392.19 | 22631.69 | 20 | 25.8 | - | 5.10 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=1536 group=128 dtype=bf16 M=16` | - | 17445.77 | 8999.29 | 18004.38 | 20 | 19.9 | - | 72.75 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 17437.71 | 4002.38 | 20998.84 | 20 | 34.4 | - | 48.01 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=2048 group=128 dtype=bf16 M=128` | - | 17433.38 | 11981.13 | 27000.85 | 20 | 25.5 | - | 776.00 KiB | 32 thread(s) | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | `N=304 K=4096 dtype=bf16 M=8` | - | 17411.30 | 8816.19 | 22354.55 | 20 | 33.1 | - | 4.82 MiB | 32 thread(s) | +| `sample_minp` | `avx_sample_minp` | libavx | `n_cand=1024 M=32` | - | 17352.15 | 6994.08 | 20902.86 | 40 | 25.9 | - | 259.00 KiB | 32 thread(s) | +| `gdn_recurrent_update` | `ref_gdn_recurrent_update` | libref | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=8` | - | 17295.26 | 10156.61 | 26172.13 | 20 | 15.4 | - | 24.35 MiB | 32 thread(s) | +| `sample_penalties` | `ref_sample_penalties` | libref | `n_vocab=248320 M=8` | - | 17231.87 | 7136.38 | 23398.40 | 20 | 18.7 | - | 7.58 MiB | 32 thread(s) | +| `gdn_recurrent_update` | `ref_gdn_recurrent_update` | libref | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=1` | - | 17179.88 | 15864.81 | 26123.82 | 20 | 25.8 | - | 18.04 MiB | 32 thread(s) | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | `N=304 K=4096 dtype=bf16 M=1` | - | 17139.06 | 11986.12 | 23995.47 | 20 | 22.5 | - | 4.76 MiB | 32 thread(s) | +| `sample_argmax` | `ref_sample_argmax` | libref | `n_vocab=248320 M=16` | - | 17064.85 | 8995.09 | 25987.65 | 20 | 20.9 | - | 15.16 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 17040.10 | 11992.85 | 23301.43 | 20 | 29.3 | - | 4.03 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=5120 group=128 dtype=bf16 M=256` | - | 17016.90 | 12850.77 | 20115.07 | 20 | 11.4 | - | 3.79 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=5376 K=4096 group=128 dtype=fp8a8 M=33` | - | 17008.70 | 12967.19 | 44995.04 | 20 | 85.3 | - | 21.47 MiB | 32 thread(s) | +| `layernorm` | `avx_layernorm` | libavx | `n=1152 eps=1e-06 dtype=bf16 M=256` | - | 17006.59 | 8986.26 | 23997.57 | 20 | 20.6 | - | 1.13 MiB | 32 thread(s) | +| `sample_topk` | `avx_sample_topk` | libavx | `n_vocab=131072 M=1` | - | 17002.79 | 11812.07 | 21330.96 | 20 | 22.7 | - | 513.09 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=1024 group=128 dtype=bf16 M=32` | - | 16994.19 | 8987.03 | 17996.24 | 20 | 26.5 | - | 97.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=1024 group=128 dtype=bf16 M=512` | - | 16992.33 | 8523.85 | 23029.07 | 20 | 20.6 | - | 1.52 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=24576 K=4096 group=128 dtype=fp8a8 M=2` | - | 16992.03 | 12995.91 | 18004.75 | 20 | 11.8 | - | 96.11 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=512` | - | 16990.40 | 11983.35 | 21979.23 | 26 | 17.7 | - | 256.25 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=5376 K=4096 group=128 dtype=fp8a8 M=1` | - | 16989.67 | 7012.14 | 35986.00 | 20 | 38.3 | - | 21.02 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-05 dtype=bf16 M=8` | - | 16986.98 | 8030.25 | 27996.92 | 20 | 44.2 | - | 170.00 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=1024 group=128 dtype=bf16 M=16` | - | 16985.58 | 11988.49 | 22977.73 | 20 | 17.7 | - | 48.50 KiB | 32 thread(s) | +| `layernorm` | `avx_layernorm` | libavx | `n=1152 eps=1e-06 dtype=bf16 M=32` | - | 16981.21 | 10007.23 | 26994.89 | 20 | 14.7 | - | 148.50 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | - | 16975.18 | 11953.01 | 39764.91 | 20 | 25.3 | - | 32.10 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=512` | - | 16970.65 | 11981.56 | 22149.85 | 20 | 23.0 | - | 10.01 MiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=2048 act=relu dtype=bf16 M=512` | - | 16954.45 | 8992.02 | 17997.19 | 20 | 23.4 | - | 6.00 MiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=2048 act=relu dtype=bf16 M=256` | - | 16946.21 | 9058.03 | 17998.26 | 20 | 20.4 | - | 3.00 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=2048 group=128 dtype=bf16 M=32` | - | 16934.90 | 5995.40 | 20092.77 | 20 | 26.6 | - | 194.00 KiB | 32 thread(s) | +| `layernorm` | `ref_layernorm` | libref | `n=1152 eps=1e-06 dtype=bf16 M=256` | - | 16913.69 | 11775.62 | 19208.91 | 20 | 17.2 | - | 1.13 MiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=64` | - | 16910.72 | 8897.45 | 25776.99 | 20 | 35.6 | - | 768.75 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=5376 group=128 dtype=bf16 M=128` | - | 16907.66 | 8991.90 | 20023.25 | 20 | 20.7 | - | 1.99 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=1536 group=128 dtype=bf16 M=128` | - | 16827.75 | 8999.64 | 23998.39 | 20 | 29.2 | - | 582.00 KiB | 32 thread(s) | +| `sample_mask` | `avx_sample_mask` | libavx | `n_vocab=248320 M=8` | - | 16817.40 | 7843.12 | 19732.40 | 20 | 23.9 | - | 7.82 MiB | 32 thread(s) | +| `grid_embed` | `ref_grid_embed` | libref | `n=1152 side=48 dtype=bf16 M=128` | - | 16785.41 | 5931.06 | 26959.41 | 20 | 50.0 | - | 5.35 MiB | 32 thread(s) | +| `sample_logprobs` | `ref_sample_logprobs` | libref | `n_vocab=131072 k=9 M=56` | - | 16767.45 | 11989.29 | 18016.56 | 20 | 14.2 | - | 28.01 MiB | 32 thread(s) | +| `sample_penalties` | `ref_sample_penalties` | libref | `n_vocab=131072 M=16` | - | 16710.38 | 7712.08 | 16807.41 | 20 | 26.9 | - | 8.01 MiB | 32 thread(s) | +| `sample_dry` | `ref_sample_dry` | libref | `n_vocab=248320 M=16` | - | 16706.96 | 16388.01 | 25316.67 | 20 | 23.1 | - | 15.16 MiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=512` | - | 16695.37 | 10941.68 | 21719.00 | 20 | 15.2 | - | 6.01 MiB | 32 thread(s) | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | `N=240 K=4096 dtype=bf16 M=128` | - | 16662.16 | 11990.12 | 25342.51 | 20 | 17.7 | - | 4.87 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | - | 16609.01 | 9228.24 | 20992.53 | 20 | 26.4 | - | 4.13 MiB | 32 thread(s) | +| `sample_argmax` | `avx_sample_argmax` | libavx | `n_vocab=248320 M=2` | - | 16527.02 | 11992.23 | 24991.63 | 20 | 24.2 | - | 1.89 MiB | 32 thread(s) | +| `sample_penalties` | `avx_sample_penalties` | libavx | `n_vocab=248320 M=64` | - | 16511.74 | 7296.19 | 18646.93 | 20 | 21.9 | - | 60.65 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=3072 K=1024 dtype=bf16 act=none M=2` | - | 16503.75 | 10981.91 | 21062.38 | 20 | 27.2 | - | 6.03 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=1536 group=128 dtype=bf16 M=128` | - | 16488.77 | 8978.06 | 18002.35 | 20 | 21.2 | - | 582.00 KiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=8192 act=silu dtype=bf16 M=128` | - | 16266.10 | 11989.69 | 24007.70 | 20 | 33.4 | - | 6.00 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=1024 group=128 dtype=bf16 M=512` | - | 16236.08 | 11978.50 | 18453.49 | 20 | 18.2 | - | 1.52 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=25600 group=128 dtype=bf16 M=256` | - | 16208.58 | 8985.85 | 18007.30 | 20 | 23.6 | - | 18.95 MiB | 32 thread(s) | +| `sample_dry` | `ref_sample_dry` | libref | `n_vocab=131072 M=32` | - | 16156.81 | 7083.78 | 16288.61 | 20 | 27.9 | - | 16.01 MiB | 32 thread(s) | +| `dflash_select` | `avx_dflash_select` | libavx | `steps=7 top_k=16 rank=256 n_vocab=248320 anchor_stride=8 dtype=bf16 M=1` | - | 16145.46 | 11972.71 | 25965.78 | 20 | 30.9 | - | 242.50 MiB | 32 thread(s) | +| `scatter_rows` | `avx_scatter_rows` | libavx | `n=5120 dtype=bf16 M=16` | - | 16118.35 | 9371.83 | 34187.66 | 20 | 58.6 | - | 800.06 KiB | 32 thread(s) | +| `grid_embed` | `ref_grid_embed` | libref | `n=1152 side=48 dtype=bf16 M=256` | - | 16087.31 | 11888.25 | 23918.83 | 20 | 32.0 | - | 5.63 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | - | 16082.81 | 7251.46 | 28400.13 | 20 | 28.4 | - | 4.19 MiB | 32 thread(s) | +| `sample_mask` | `avx_sample_mask` | libavx | `n_vocab=248320 M=32` | - | 16047.38 | 11579.35 | 19372.78 | 20 | 16.6 | - | 31.26 MiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=5376 act=relu dtype=bf16 M=512` | - | 16035.96 | 11977.04 | 23056.42 | 20 | 25.1 | - | 15.75 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=1024 group=128 dtype=bf16 M=512` | - | 16003.30 | 11997.95 | 22927.55 | 20 | 18.9 | - | 1.52 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=256 K=4096 group=128 dtype=fp8a8 M=128` | - | 16000.68 | 6959.63 | 20997.27 | 20 | 18.8 | - | 1.58 MiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=8` | - | 15992.97 | 10985.43 | 17987.07 | 20 | 15.6 | - | 54.06 KiB | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=5120 dtype=bf16 M=64` | - | 15992.84 | 9009.94 | 24012.92 | 20 | 37.5 | - | 3.13 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | - | 15983.26 | 11996.42 | 17999.17 | 20 | 18.4 | - | 1.70 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=1536 group=128 dtype=bf16 M=64` | - | 15982.13 | 11993.11 | 18002.01 | 20 | 15.4 | - | 291.00 KiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=5376 act=relu dtype=bf16 M=16` | - | 15980.74 | 8982.10 | 21954.34 | 20 | 28.2 | - | 504.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5376 group=128 dtype=bf16 M=16` | - | 15967.25 | 11990.40 | 22002.48 | 20 | 12.5 | - | 254.62 KiB | 32 thread(s) | +| `scatter_rows` | `avx_scatter_rows` | libavx | `n=5120 dtype=bf16 M=8` | - | 15965.78 | 11965.36 | 26956.89 | 20 | 43.8 | - | 400.03 KiB | 32 thread(s) | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=64` | - | 15925.66 | 8908.31 | 17974.91 | 20 | 28.2 | - | 448.25 KiB | 32 thread(s) | +| `moe_gather` | `avx_moe_gather` | libavx | `n=1024 top_k=9 dtype=bf16 act=none M=256` | - | 15818.61 | 4563.11 | 35994.09 | 20 | 34.8 | - | 5.51 MiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=512` | - | 15789.81 | 8018.78 | 16914.02 | 20 | 25.0 | - | 6.01 MiB | 32 thread(s) | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | `N=240 K=4096 dtype=bf16 M=8` | - | 15749.04 | 13003.63 | 25992.20 | 20 | 13.6 | - | 3.82 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=256` | - | 15603.76 | 11850.21 | 26372.96 | 20 | 40.2 | - | 5.01 MiB | 32 thread(s) | +| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=248320 M=64` | - | 15602.65 | 7416.82 | 18795.73 | 20 | 17.8 | - | 60.63 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=17` | - | 15508.84 | 12014.60 | 23990.45 | 20 | 9.7 | - | 472.01 KiB | 32 thread(s) | +| `add` | `ref_add` | libref | `n=5120 dtype=bf16 M=128` | - | 15504.36 | 11977.65 | 21010.62 | 20 | 16.1 | - | 3.75 MiB | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=1280 dtype=bf16 M=128` | - | 15498.95 | 11001.24 | 21015.96 | 20 | 22.3 | - | 1.56 MiB | 32 thread(s) | +| `dflash_select` | `ref_dflash_select` | libref | `steps=7 top_k=16 rank=256 n_vocab=248320 anchor_stride=8 dtype=bf16 M=4` | - | 15498.57 | 8989.70 | 22984.36 | 20 | 20.0 | - | 242.52 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-05 dtype=bf16 M=4` | - | 15493.34 | 8897.44 | 27029.44 | 20 | 48.4 | - | 90.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5376 group=128 dtype=bf16 M=8` | - | 15493.23 | 10996.14 | 28003.43 | 20 | 45.2 | - | 127.31 KiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=2048 K=1024 dtype=bf16 act=none M=16` | - | 15487.40 | 9006.78 | 21999.85 | 20 | 29.0 | - | 4.16 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=2048 act=relu dtype=bf16 M=32` | - | 15481.26 | 10967.63 | 19070.31 | 20 | 19.3 | - | 384.00 KiB | 32 thread(s) | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=128` | - | 15479.23 | 11921.87 | 26938.72 | 20 | 45.2 | - | 832.50 KiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=5376 act=relu dtype=bf16 M=64` | - | 15466.46 | 11997.42 | 21003.41 | 20 | 25.7 | - | 1.97 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=1536 group=128 dtype=bf16 M=512` | - | 15345.10 | 11997.03 | 17997.62 | 20 | 12.8 | - | 2.27 MiB | 32 thread(s) | +| `sample_penalties` | `ref_sample_penalties` | libref | `n_vocab=248320 M=16` | - | 15236.20 | 6175.40 | 22308.70 | 20 | 29.4 | - | 15.16 MiB | 32 thread(s) | +| `sample_logprobs` | `ref_sample_logprobs` | libref | `n_vocab=131072 k=21 M=64` | - | 15132.48 | 11842.54 | 18454.45 | 20 | 19.8 | - | 32.02 MiB | 32 thread(s) | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | `N=304 K=4096 dtype=bf16 M=128` | - | 15105.73 | 7109.86 | 17728.57 | 20 | 12.4 | - | 5.90 MiB | 32 thread(s) | +| `quant_act_i8` | `ref_quant_act_i8` | libref | `n=5120 group=128 dtype=bf16 M=16` | - | 15014.47 | 11944.50 | 18014.42 | 20 | 19.9 | - | 242.56 KiB | 32 thread(s) | +| `kv_store` | `ref_kv_store` | libref | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=256` | - | 15009.49 | 11871.67 | 23608.89 | 20 | 37.9 | - | 1.56 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=12288 group=128 dtype=fp8a8 M=1` | - | 15005.10 | 8997.51 | 20991.24 | 20 | 23.3 | - | 48.03 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=3072 dtype=bf16 act=none M=1` | - | 15003.60 | 8993.33 | 20979.87 | 20 | 20.0 | - | 6.01 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1024 K=4096 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 15001.62 | 11996.54 | 24000.29 | 20 | 40.0 | - | 8.02 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=12288 group=128 dtype=fp8a8 M=8` | - | 14999.49 | 13997.79 | 18000.79 | 20 | 6.7 | - | 48.17 MiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=256 K=4096 group=128 dtype=fp8a8 M=512` | - | 14999.42 | 14980.82 | 15004.72 | 6 | 0.1 | - | 3.31 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3072 K=1024 dtype=bf16 act=none M=1` | - | 14999.22 | 8996.81 | 20997.63 | 20 | 30.0 | - | 6.02 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=2048 dtype=bf16 act=none M=128` | - | 14999.09 | 14972.35 | 20996.51 | 19 | 0.1 | - | 5.00 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3072 K=1024 dtype=bf16 act=none M=64` | - | 14998.45 | 14990.40 | 15006.13 | 6 | 0.1 | - | 6.88 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4608 K=4096 group=128 dtype=fp8a8 M=129` | - | 14998.17 | 14996.48 | 15002.43 | 6 | 0.0 | - | 19.66 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=5376 act=relu dtype=bf16 M=32` | - | 14997.45 | 10437.27 | 19998.15 | 20 | 16.6 | - | 1008.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=256 K=4096 group=128 dtype=fp8a8 M=1` | - | 14996.52 | 11988.70 | 18001.39 | 20 | 6.7 | - | 1.00 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3072 K=1024 dtype=bf16 act=none M=32` | - | 14995.75 | 14987.81 | 14999.76 | 6 | 0.0 | - | 6.44 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=1536 act=relu dtype=bf16 M=64` | - | 14995.37 | 11961.53 | 23995.10 | 20 | 16.7 | - | 576.00 KiB | 32 thread(s) | +| `attn_paged_sink` | `ref_attn_paged_sink` | libref | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2` | - | 14993.70 | 8646.10 | 21004.77 | 20 | 20.0 | - | 48.13 KiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=2048 K=1024 dtype=bf16 act=none M=64` | - | 14991.85 | 12998.93 | 15006.35 | 11 | 0.1 | - | 4.63 MiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=16` | - | 14984.38 | 9998.14 | 23969.37 | 20 | 26.8 | - | 128.06 KiB | 32 thread(s) | +| `layernorm` | `ref_layernorm` | libref | `n=1152 eps=1e-06 dtype=bf16 M=64` | - | 14971.11 | 8988.92 | 20999.04 | 20 | 20.0 | - | 292.50 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 14969.67 | 5992.10 | 27000.48 | 20 | 21.5 | - | 4.09 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=1024 dtype=bf16 act=none M=4` | - | 14965.82 | 8997.65 | 18004.37 | 20 | 20.1 | - | 2.03 MiB | 32 thread(s) | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | `N=304 K=4096 dtype=bf16 M=256` | - | 14950.40 | 11856.26 | 16005.56 | 20 | 11.8 | - | 7.05 MiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=32` | - | 14937.63 | 6954.68 | 26961.41 | 20 | 50.0 | - | 384.38 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=260` | - | 14930.29 | 11652.94 | 21754.31 | 20 | 17.4 | - | 4.33 MiB | 32 thread(s) | +| `scatter_rows` | `ref_scatter_rows` | libref | `n=5120 dtype=bf16 M=128` | - | 14719.57 | 11069.98 | 26229.86 | 20 | 41.1 | - | 6.25 MiB | 32 thread(s) | +| `sample_argmax` | `ref_sample_argmax` | libref | `n_vocab=131072 M=2` | - | 14707.38 | 5080.13 | 17998.02 | 20 | 34.0 | - | 1.00 MiB | 32 thread(s) | +| `grid_embed` | `ref_grid_embed` | libref | `n=1152 side=48 dtype=bf16 M=32` | - | 14507.73 | 5978.01 | 23927.90 | 20 | 51.6 | - | 5.13 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=1024 dtype=bf16 act=none M=8` | - | 14497.91 | 8985.33 | 27004.54 | 20 | 62.1 | - | 2.05 MiB | 32 thread(s) | +| `moe_gather` | `avx_moe_gather` | libavx | `n=1024 top_k=9 dtype=bf16 act=none M=128` | - | 14482.51 | 9998.75 | 17057.44 | 20 | 13.8 | - | 2.76 MiB | 32 thread(s) | +| `sample_logprobs` | `ref_sample_logprobs` | libref | `n_vocab=131072 k=21 M=32` | - | 14476.42 | 7120.43 | 18535.98 | 20 | 11.0 | - | 16.01 MiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=32` | - | 14473.40 | 3984.72 | 21936.26 | 20 | 20.8 | - | 216.25 KiB | 32 thread(s) | +| `sample_penalties` | `ref_sample_penalties` | libref | `n_vocab=131072 M=8` | - | 14393.82 | 11391.76 | 17388.12 | 20 | 9.0 | - | 4.00 MiB | 32 thread(s) | +| `add` | `avx_add` | libavx | `n=4096 dtype=bf16 M=64` | - | 14295.69 | 11010.99 | 18015.76 | 20 | 20.9 | - | 1.50 MiB | 32 thread(s) | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | `N=304 K=4096 dtype=bf16 M=512` | - | 14293.74 | 11893.55 | 16234.75 | 20 | 10.7 | - | 9.34 MiB | 32 thread(s) | +| `sample_penalties` | `ref_sample_penalties` | libref | `n_vocab=248320 M=32` | - | 14169.08 | 7210.66 | 22079.97 | 20 | 22.7 | - | 30.32 MiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=8` | - | 14050.61 | 11945.29 | 23990.98 | 20 | 35.6 | - | 291.25 KiB | 32 thread(s) | +| `moe_gather` | `avx_moe_gather` | libavx | `n=1024 top_k=9 dtype=bf16 act=none M=4` | - | 14005.07 | 10000.53 | 20969.82 | 20 | 17.5 | - | 88.22 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=1024 group=128 dtype=bf16 M=32` | - | 14004.74 | 10997.08 | 24023.86 | 20 | 28.5 | - | 97.00 KiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=9` | - | 14001.72 | 11061.83 | 17993.17 | 20 | 17.8 | - | 2.14 MiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=5376 act=relu dtype=bf16 M=32` | - | 14001.63 | 7000.98 | 26974.68 | 20 | 21.5 | - | 1008.00 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=17` | - | 13993.85 | 9992.12 | 17996.44 | 20 | 21.5 | - | 304.01 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 13984.74 | 10936.17 | 23991.28 | 20 | 32.1 | - | 32.04 MiB | 32 thread(s) | +| `moe_gather` | `ref_moe_gather` | libref | `n=1024 top_k=9 dtype=bf16 act=none M=16` | - | 13984.48 | 11001.41 | 21991.77 | 20 | 14.5 | - | 352.88 KiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=2048 act=relu dtype=bf16 M=8` | - | 13983.99 | 8991.38 | 26991.14 | 20 | 21.4 | - | 96.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=25600 group=128 dtype=bf16 M=64` | - | 13937.52 | 5993.77 | 27005.12 | 20 | 64.5 | - | 4.74 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=2304 group=128 dtype=bf16 M=512` | - | 13580.15 | 11975.32 | 17855.06 | 20 | 18.3 | - | 3.41 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=16` | - | 13512.23 | 4954.70 | 23995.16 | 20 | 40.8 | - | 330.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=256 K=4096 group=128 dtype=fp8a8 M=258` | - | 13504.55 | 11994.13 | 30993.88 | 20 | 66.6 | - | 2.17 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=256` | - | 13502.79 | 11989.15 | 17998.20 | 20 | 22.2 | - | 256.50 KiB | 32 thread(s) | +| `lili_factor` | `ref_lili_factor` | libref | `L=56 n=1024 dtype=bf16 M=256` | - | 13497.93 | 8995.19 | 17994.67 | 20 | 32.4 | - | 2.20 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1024 K=4096 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 13497.15 | 9993.58 | 17995.62 | 20 | 18.5 | - | 8.17 MiB | 32 thread(s) | +| `add` | `avx_add` | libavx | `n=5120 dtype=bf16 M=32` | - | 13484.70 | 11987.71 | 17999.24 | 20 | 22.2 | - | 960.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=24576 group=128 dtype=bf16 M=128` | - | 13388.73 | 6001.98 | 17993.14 | 20 | 33.6 | - | 9.09 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=24576 group=128 dtype=bf16 M=256` | - | 13086.55 | 12040.46 | 22411.29 | 20 | 28.4 | - | 18.19 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=2048 act=relu dtype=bf16 M=128` | - | 13070.77 | 11982.82 | 17999.86 | 20 | 18.6 | - | 1.50 MiB | 32 thread(s) | +| `silu` | `ref_silu` | libref | `n=1024 dtype=bf16 M=64` | - | 13050.92 | 5973.93 | 17975.62 | 20 | 19.0 | - | 256.00 KiB | 32 thread(s) | +| `gdn_recurrent_update` | `avx_gdn_recurrent_update` | libavx | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=16` | - | 13012.58 | 10146.34 | 16519.66 | 20 | 14.5 | - | 48.69 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5376 group=128 dtype=bf16 M=4` | - | 13004.66 | 11964.09 | 18023.86 | 20 | 23.0 | - | 63.66 KiB | 32 thread(s) | +| `sample_argmax` | `avx_sample_argmax` | libavx | `n_vocab=131072 M=4` | - | 13002.56 | 11995.21 | 17997.28 | 20 | 23.1 | - | 2.00 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8 splits=0` | - | 12999.33 | 11997.41 | 13994.63 | 16 | 0.1 | - | 2.13 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=1024 group=128 dtype=bf16 M=256` | - | 12998.90 | 8999.36 | 16916.64 | 20 | 11.9 | - | 776.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=256 K=4096 group=128 dtype=fp8a8 M=65` | - | 12996.77 | 7023.28 | 18991.09 | 20 | 32.4 | - | 1.29 MiB | 32 thread(s) | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | `N=240 K=4096 dtype=bf16 M=16` | - | 12994.70 | 5734.17 | 18614.57 | 20 | 46.1 | - | 3.89 MiB | 32 thread(s) | +| `sample_logprobs` | `ref_sample_logprobs` | libref | `n_vocab=131072 k=9 M=16` | - | 12992.28 | 8921.20 | 15013.75 | 20 | 11.4 | - | 8.00 MiB | 32 thread(s) | +| `lili_attn` | `avx_lili_attn` | libavx | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=2` | - | 12894.33 | 11102.95 | 15849.88 | 20 | 9.0 | - | 448.50 KiB | 32 thread(s) | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=131072 k=9 M=16` | - | 12822.51 | 5965.99 | 17205.10 | 20 | 31.9 | - | 8.00 MiB | 32 thread(s) | +| `lili_factor` | `ref_lili_factor` | libref | `L=56 n=1024 dtype=bf16 M=448` | - | 12729.15 | 7298.97 | 23992.95 | 20 | 46.4 | - | 3.52 MiB | 32 thread(s) | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | `N=240 K=4096 dtype=bf16 M=2` | - | 12715.08 | 11989.47 | 23996.70 | 20 | 23.6 | - | 3.77 MiB | 32 thread(s) | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | `N=240 K=4096 dtype=bf16 M=256` | - | 12627.23 | 6991.05 | 20578.87 | 20 | 39.5 | - | 5.98 MiB | 32 thread(s) | +| `lili_walk` | `avx_lili_walk` | libavx | `steps=7 k=8 n=1024 dtype=bf16 eps=0.0001 scale=8 M=8` | - | 12599.72 | 3353.02 | 16996.72 | 20 | 36.2 | - | 1.78 MiB | 32 thread(s) | +| `silu` | `avx_silu` | libavx | `n=2048 dtype=bf16 M=448` | - | 12533.82 | 6596.58 | 20966.90 | 20 | 35.6 | - | 3.50 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=1024 eps=1e-05 dtype=bf16 M=512` | - | 12526.77 | 7042.09 | 29976.23 | 20 | 48.0 | - | 2.00 MiB | 32 thread(s) | +| `sample_topk` | `avx_sample_topk` | libavx | `n_vocab=131072 M=4` | - | 12522.56 | 5998.79 | 20011.65 | 20 | 34.8 | - | 2.00 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=24576 group=128 dtype=bf16 M=32` | - | 12497.67 | 8604.67 | 17999.97 | 20 | 24.0 | - | 2.27 MiB | 32 thread(s) | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=131072 k=21 M=1` | - | 12496.13 | 8988.83 | 13997.60 | 20 | 8.1 | - | 512.27 KiB | 32 thread(s) | +| `silu` | `avx_silu` | libavx | `n=1024 dtype=bf16 M=256` | - | 12493.16 | 5987.96 | 16001.48 | 20 | 36.0 | - | 1.00 MiB | 32 thread(s) | +| `lili_attn` | `avx_lili_attn` | libavx | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=256` | - | 12448.48 | 11983.36 | 16620.36 | 20 | 15.6 | - | 2.19 MiB | 32 thread(s) | +| `sample_mask` | `ref_sample_mask` | libref | `n_vocab=248320 M=32` | - | 12233.89 | 8241.99 | 18772.27 | 20 | 30.5 | - | 31.26 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=130` | - | 12091.67 | 6249.65 | 13311.01 | 20 | 3.5 | - | 2.17 MiB | 32 thread(s) | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | `N=304 K=4096 dtype=bf16 M=1` | - | 12073.05 | 11876.85 | 26555.03 | 20 | 43.6 | - | 4.76 MiB | 32 thread(s) | +| `lili_walk` | `ref_lili_walk` | libref | `steps=7 k=8 n=1024 dtype=bf16 eps=0.0001 scale=8 M=8` | - | 12044.87 | 6928.24 | 15986.50 | 20 | 8.8 | - | 1.78 MiB | 32 thread(s) | +| `lili_factor` | `avx_lili_factor` | libavx | `L=56 n=1024 dtype=bf16 M=1` | - | 12023.06 | 11979.14 | 16967.01 | 20 | 8.4 | - | 450.00 KiB | 32 thread(s) | +| `sample_argmax` | `ref_sample_argmax` | libref | `n_vocab=131072 M=64` | - | 12022.89 | 6449.87 | 14038.07 | 20 | 4.0 | - | 32.01 MiB | 32 thread(s) | +| `sample_topk` | `avx_sample_topk` | libavx | `n_vocab=131072 M=8` | - | 12022.67 | 11856.35 | 14147.66 | 20 | 9.2 | - | 4.01 MiB | 32 thread(s) | +| `lili_attn` | `avx_lili_attn` | libavx | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=64` | - | 12022.50 | 11772.75 | 12117.07 | 14 | 0.6 | - | 896.50 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=17` | - | 12016.33 | 5329.94 | 17332.45 | 20 | 19.7 | - | 2.27 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=12288 group=128 dtype=bf16 M=8` | - | 12014.36 | 8994.64 | 23969.25 | 20 | 62.3 | - | 291.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=4096 dtype=bf16 act=none M=1` | - | 12011.37 | 11752.10 | 35986.08 | 20 | 74.9 | - | 8.01 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=4096 group=128 dtype=fp8a8 M=1` | - | 12011.26 | 11984.80 | 37010.59 | 20 | 82.0 | - | 16.01 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=2304 act=relu dtype=bf16 M=128` | - | 12007.67 | 11978.90 | 12113.82 | 6 | 0.6 | - | 1.69 MiB | 32 thread(s) | +| `lili_factor` | `avx_lili_factor` | libavx | `L=56 n=1024 dtype=bf16 M=4` | - | 12007.16 | 9970.62 | 16944.43 | 20 | 4.1 | - | 450.00 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=8` | - | 12007.15 | 5996.64 | 21973.32 | 20 | 37.6 | - | 170.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=1024 dtype=bf16 act=none M=2` | - | 12005.96 | 8991.94 | 17996.02 | 20 | 12.5 | - | 2.01 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=3072 dtype=bf16 act=none M=16` | - | 12005.90 | 8932.70 | 17005.41 | 20 | 29.2 | - | 6.16 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=10` | - | 12005.51 | 11983.17 | 16993.85 | 20 | 8.3 | - | 2.16 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=16` | - | 12005.25 | 11936.68 | 12044.37 | 11 | 0.4 | - | 264.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=24576 group=128 dtype=bf16 M=256` | - | 12004.81 | 11186.14 | 17429.05 | 20 | 13.2 | - | 18.19 MiB | 32 thread(s) | +| `lili_walk` | `ref_lili_walk` | libref | `steps=7 k=8 n=1024 dtype=bf16 eps=0.0001 scale=8 M=2` | - | 12003.83 | 9006.19 | 15993.15 | 20 | 12.3 | - | 455.99 KiB | 32 thread(s) | +| `lili_attn` | `ref_lili_attn` | libref | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=16` | - | 12003.02 | 11989.86 | 12023.82 | 6 | 0.1 | - | 448.50 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=4096 eps=1e-05 dtype=bf16 M=256` | - | 12002.47 | 11970.92 | 13350.25 | 14 | 0.2 | - | 4.01 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=4096 group=128 dtype=fp8a8 M=2` | - | 12002.07 | 11993.69 | 26000.66 | 20 | 54.2 | - | 16.03 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=4096 dtype=bf16 act=none M=2` | - | 12001.32 | 8008.86 | 15002.85 | 20 | 25.0 | - | 8.03 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=32` | - | 12001.21 | 11977.91 | 12013.26 | 11 | 0.1 | - | 520.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4608 K=4096 group=128 dtype=fp8a8 M=32` | - | 12000.86 | 11972.39 | 12020.73 | 6 | 0.2 | - | 18.41 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=3072 dtype=bf16 act=none M=2` | - | 12000.73 | 11970.07 | 23994.13 | 20 | 50.0 | - | 6.02 MiB | 32 thread(s) | +| `lili_attn` | `avx_lili_attn` | libavx | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=32` | - | 12000.67 | 5979.16 | 13924.30 | 20 | 29.1 | - | 448.50 KiB | 32 thread(s) | +| `lili_factor` | `avx_lili_factor` | libavx | `L=56 n=1024 dtype=bf16 M=128` | - | 12000.59 | 9689.51 | 12046.59 | 11 | 0.3 | - | 1.32 MiB | 32 thread(s) | +| `gather_rows` | `ref_gather_rows` | libref | `n=4096 dtype=bf16 M=64` | - | 12000.45 | 11980.03 | 17981.60 | 19 | 0.3 | - | 2.50 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=4096 eps=1e-05 dtype=bf16 M=64` | - | 12000.38 | 11987.49 | 12004.43 | 6 | 0.1 | - | 1.01 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=2048 K=1024 dtype=bf16 act=none M=1` | - | 12000.36 | 11972.87 | 26041.26 | 20 | 50.0 | - | 4.01 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=5376 group=128 dtype=bf16 M=64` | - | 12000.28 | 11978.67 | 13458.76 | 19 | 0.4 | - | 1018.50 KiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=5376 act=relu dtype=bf16 M=256` | - | 12000.22 | 8059.20 | 17993.62 | 20 | 16.8 | - | 7.88 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=2304 act=relu dtype=bf16 M=512` | - | 12000.20 | 11061.17 | 23997.18 | 20 | 12.5 | - | 6.75 MiB | 32 thread(s) | +| `silu` | `avx_silu` | libavx | `n=1024 dtype=bf16 M=128` | - | 12000.03 | 8006.82 | 17006.22 | 20 | 4.2 | - | 512.00 KiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=2048 act=relu dtype=bf16 M=128` | - | 12000.01 | 11971.56 | 14020.91 | 14 | 0.1 | - | 1.50 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | - | 11999.99 | 5899.83 | 21996.31 | 20 | 16.7 | - | 4.02 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=1024 eps=1e-06 dtype=bf16 M=256` | - | 11999.94 | 11986.99 | 12006.69 | 6 | 0.1 | - | 1.00 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=64` | - | 11999.91 | 11921.22 | 12071.44 | 11 | 0.4 | - | 1.01 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=4096 eps=1e-05 dtype=bf16 M=4` | - | 11999.83 | 11992.17 | 14991.43 | 14 | 0.0 | - | 72.00 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=6 splits=0` | - | 11999.83 | 6000.18 | 13984.75 | 19 | 0.1 | - | 112.01 KiB | 32 thread(s) | +| `silu` | `avx_silu` | libavx | `n=2048 dtype=bf16 M=128` | - | 11999.81 | 10590.83 | 16939.74 | 20 | 8.5 | - | 1.00 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=2304 group=128 dtype=bf16 M=16` | - | 11999.56 | 5985.17 | 17985.63 | 20 | 25.3 | - | 109.12 KiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=2304 act=relu dtype=bf16 M=128` | - | 11999.50 | 5000.22 | 17965.01 | 20 | 37.3 | - | 1.69 MiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=1024 dtype=bf16 act=none M=4` | - | 11999.41 | 10996.03 | 12002.27 | 11 | 0.0 | - | 2.03 MiB | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=4096 dtype=bf16 M=4` | - | 11999.38 | 11996.14 | 23993.19 | 19 | 0.0 | - | 160.02 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=256` | - | 11999.33 | 9400.76 | 18001.59 | 20 | 12.3 | - | 4.01 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=4096 eps=1e-05 dtype=bf16 M=32` | - | 11999.23 | 11038.64 | 12006.89 | 11 | 0.1 | - | 520.00 KiB | 32 thread(s) | +| `add` | `avx_add` | libavx | `n=5120 dtype=bf16 M=16` | - | 11999.23 | 10946.11 | 12612.83 | 14 | 0.1 | - | 480.00 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=128` | - | 11999.17 | 9802.12 | 14993.07 | 20 | 5.5 | - | 2.01 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=4096 group=128 dtype=bf16 M=512` | - | 11999.09 | 11997.95 | 12000.23 | 11 | 0.0 | - | 6.06 MiB | 32 thread(s) | +| `silu` | `avx_silu` | libavx | `n=2048 dtype=bf16 M=256` | - | 11999.08 | 8996.82 | 18008.37 | 20 | 25.1 | - | 2.00 MiB | 32 thread(s) | +| `sample_argmax` | `ref_sample_argmax` | libref | `n_vocab=131072 M=16` | - | 11999.07 | 11566.18 | 14991.95 | 20 | 3.5 | - | 8.00 MiB | 32 thread(s) | +| `gemm_nt` | `avx_gemm_nt` | libavx | `N=1024 K=4096 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 11998.97 | 11995.40 | 12002.31 | 6 | 0.0 | - | 8.16 MiB | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=4096 dtype=bf16 M=64` | - | 11998.84 | 5004.52 | 15988.38 | 20 | 25.0 | - | 2.50 MiB | 32 thread(s) | +| `attn_paged_sink` | `avx_attn_paged_sink` | libavx | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1` | - | 11998.83 | 11990.31 | 14988.63 | 14 | 0.1 | - | 32.13 KiB | 32 thread(s) | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=131072 k=9 M=1` | - | 11998.83 | 8995.82 | 14996.10 | 14 | 0.0 | - | 512.17 KiB | 32 thread(s) | +| `lili_attn` | `avx_lili_attn` | libavx | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=16` | - | 11998.68 | 11997.82 | 11999.69 | 11 | 0.0 | - | 448.50 KiB | 32 thread(s) | +| `lili_factor` | `ref_lili_factor` | libref | `L=56 n=1024 dtype=bf16 M=16` | - | 11998.63 | 11982.68 | 14981.56 | 16 | 0.1 | - | 450.00 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=4096 eps=1e-05 dtype=bf16 M=128` | - | 11998.60 | 11993.60 | 12003.02 | 11 | 0.0 | - | 2.01 MiB | 32 thread(s) | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=131072 k=9 M=32` | - | 11998.59 | 6010.38 | 14015.42 | 20 | 5.0 | - | 16.01 MiB | 32 thread(s) | +| `attn_paged_sink` | `avx_attn_paged_sink` | libavx | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1` | - | 11998.46 | 5992.40 | 14999.83 | 20 | 12.2 | - | 2.02 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=4096 eps=1e-05 dtype=bf16 M=16` | - | 11998.38 | 11989.67 | 12008.46 | 11 | 0.1 | - | 264.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=4096 group=128 dtype=bf16 M=256` | - | 11998.33 | 11997.55 | 12000.46 | 11 | 0.0 | - | 3.03 MiB | 32 thread(s) | +| `attn_paged_sink` | `avx_attn_paged_sink` | libavx | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2` | - | 11998.32 | 11989.79 | 12002.78 | 11 | 0.0 | - | 16.04 MiB | 32 thread(s) | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=131072 k=9 M=2` | - | 11998.30 | 6002.60 | 16994.12 | 20 | 20.9 | - | 1.00 MiB | 32 thread(s) | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=131072 k=21 M=64` | - | 11998.18 | 6281.92 | 12139.45 | 16 | 0.1 | - | 32.02 MiB | 32 thread(s) | +| `attn_paged_sink` | `avx_attn_paged_sink` | libavx | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4` | - | 11998.17 | 11383.53 | 14996.69 | 20 | 2.5 | - | 16.07 MiB | 32 thread(s) | +| `sample_argmax` | `ref_sample_argmax` | libref | `n_vocab=131072 M=4` | - | 11998.15 | 5994.08 | 16998.22 | 20 | 37.5 | - | 2.00 MiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4608 K=4096 group=128 dtype=fp8a8 M=9` | - | 11998.09 | 11973.03 | 23986.28 | 19 | 0.0 | - | 18.12 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=1024 eps=1e-06 dtype=bf16 M=128` | - | 11998.06 | 11986.07 | 12996.18 | 14 | 0.1 | - | 514.00 KiB | 32 thread(s) | +| `lili_factor` | `avx_lili_factor` | libavx | `L=56 n=1024 dtype=bf16 M=448` | - | 11998.05 | 5153.05 | 14957.97 | 20 | 25.8 | - | 3.52 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=65` | - | 11997.97 | 11979.63 | 12005.31 | 11 | 0.1 | - | 1.09 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=1024 eps=1e-06 dtype=bf16 M=64` | - | 11997.94 | 6000.06 | 17998.35 | 19 | 0.0 | - | 258.00 KiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=2304 act=relu dtype=bf16 M=8` | - | 11997.93 | 5993.95 | 14002.85 | 20 | 33.3 | - | 108.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=24576 group=128 dtype=bf16 M=128` | - | 11997.89 | 10128.18 | 12010.08 | 11 | 0.1 | - | 9.09 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=64` | - | 11997.82 | 11988.58 | 12007.74 | 11 | 0.1 | - | 1.01 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=1024 eps=1e-06 dtype=bf16 M=256` | - | 11997.58 | 11979.13 | 12018.05 | 6 | 0.2 | - | 1.00 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=4` | - | 11997.52 | 11996.51 | 12006.03 | 6 | 0.0 | - | 72.00 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=1024 eps=1e-06 dtype=bf16 M=128` | - | 11997.44 | 11992.98 | 12002.98 | 6 | 0.0 | - | 514.00 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=32` | - | 11997.26 | 11744.61 | 12251.95 | 14 | 0.2 | - | 520.00 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=256` | - | 11997.22 | 11955.75 | 15487.46 | 19 | 0.2 | - | 4.01 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8 splits=0` | - | 11997.16 | 5998.96 | 15002.60 | 20 | 16.8 | - | 144.01 KiB | 32 thread(s) | +| `silu` | `ref_silu` | libref | `n=1024 dtype=bf16 M=16` | - | 11997.15 | 8015.34 | 14015.04 | 20 | 8.4 | - | 64.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=1024 dtype=bf16 act=none M=2` | - | 11997.15 | 11991.44 | 12003.36 | 6 | 0.0 | - | 2.01 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=12288 group=128 dtype=bf16 M=16` | - | 11996.94 | 11934.50 | 12002.48 | 6 | 0.3 | - | 582.00 KiB | 32 thread(s) | +| `gather_rows` | `ref_gather_rows` | libref | `n=4096 dtype=bf16 M=32` | - | 11996.93 | 7030.72 | 16969.95 | 20 | 12.2 | - | 1.25 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=12288 group=128 dtype=bf16 M=16` | - | 11996.84 | 8026.12 | 12011.81 | 11 | 0.1 | - | 582.00 KiB | 32 thread(s) | +| `sample_logprobs` | `ref_sample_logprobs` | libref | `n_vocab=131072 k=9 M=2` | - | 11996.74 | 6807.06 | 13007.96 | 20 | 7.3 | - | 1.00 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=4096 eps=1e-05 dtype=bf16 M=8` | - | 11996.66 | 11973.20 | 12019.50 | 6 | 0.2 | - | 136.00 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=4096 eps=1e-05 dtype=bf16 M=128` | - | 11996.66 | 4970.42 | 15994.20 | 20 | 25.0 | - | 2.01 MiB | 32 thread(s) | +| `lili_factor` | `ref_lili_factor` | libref | `L=56 n=1024 dtype=bf16 M=2` | - | 11996.22 | 5991.16 | 16969.89 | 20 | 37.6 | - | 450.00 KiB | 32 thread(s) | +| `silu` | `avx_silu` | libavx | `n=1024 dtype=bf16 M=32` | - | 11996.19 | 7998.83 | 14001.79 | 20 | 8.3 | - | 128.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5120 group=128 dtype=bf16 M=8` | - | 11996.11 | 8996.57 | 16999.18 | 20 | 29.0 | - | 121.25 KiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=2048 K=1024 dtype=bf16 act=none M=2` | - | 11995.96 | 11990.94 | 12007.71 | 6 | 0.1 | - | 4.02 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=12288 group=128 dtype=bf16 M=64` | - | 11995.92 | 8947.86 | 14981.59 | 19 | 0.3 | - | 2.27 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=1024 eps=1e-06 dtype=bf16 M=64` | - | 11995.87 | 5973.84 | 15991.42 | 20 | 33.3 | - | 258.00 KiB | 32 thread(s) | +| `moe_gather` | `avx_moe_gather` | libavx | `n=1024 top_k=9 dtype=bf16 act=none M=32` | - | 11995.73 | 5993.18 | 15961.90 | 20 | 29.3 | - | 705.75 KiB | 32 thread(s) | +| `gemm_nt_bias` | `avx_gemm_nt_bias` | libavx | `N=1024 K=3072 dtype=bf16 act=none M=1` | - | 11995.61 | 11982.87 | 12002.73 | 6 | 0.1 | - | 6.01 MiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=4` | - | 11995.45 | 11992.24 | 11996.59 | 6 | 0.0 | - | 32.02 KiB | 32 thread(s) | +| `lili_attn` | `ref_lili_attn` | libref | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=64` | - | 11995.30 | 11661.55 | 13593.50 | 19 | 0.8 | - | 896.50 KiB | 32 thread(s) | +| `sample_logprobs` | `ref_sample_logprobs` | libref | `n_vocab=131072 k=21 M=1` | - | 11995.13 | 5999.43 | 12004.92 | 20 | 8.4 | - | 512.27 KiB | 32 thread(s) | +| `silu_mul` | `ref_silu_mul` | libref | `n=12288 dtype=bf16 M=32` | - | 11994.88 | 8984.26 | 17993.96 | 20 | 11.8 | - | 2.25 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5376 group=128 dtype=bf16 M=512` | - | 11994.73 | 5977.28 | 23982.82 | 20 | 74.6 | - | 7.96 MiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=2304 act=relu dtype=bf16 M=512` | - | 11993.81 | 5979.89 | 17994.28 | 20 | 28.6 | - | 6.75 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=2048 act=relu dtype=bf16 M=64` | - | 11993.47 | 5992.59 | 12937.53 | 20 | 25.0 | - | 768.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `avx_gemm_nt_q` | libavx | `N=4096 K=12288 group=128 dtype=fp8a8 M=4` | - | 11992.45 | 10998.04 | 12198.89 | 14 | 0.2 | - | 48.09 MiB | 32 thread(s) | +| `sample_argmax` | `avx_sample_argmax` | libavx | `n_vocab=131072 M=32` | - | 11991.59 | 11947.88 | 12013.54 | 6 | 0.3 | - | 16.00 MiB | 32 thread(s) | +| `silu` | `ref_silu` | libref | `n=2048 dtype=bf16 M=256` | - | 11991.50 | 5968.99 | 17819.02 | 20 | 37.1 | - | 2.00 MiB | 32 thread(s) | +| `attn_paged_sink` | `avx_attn_paged_sink` | libavx | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4` | - | 11991.10 | 11976.66 | 12016.61 | 6 | 0.2 | - | 80.13 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=64` | - | 11990.92 | 8989.91 | 17994.41 | 20 | 25.0 | - | 32.25 KiB | 32 thread(s) | +| `add` | `ref_add` | libref | `n=5120 dtype=bf16 M=32` | - | 11990.85 | 5983.05 | 18006.64 | 20 | 50.0 | - | 960.00 KiB | 32 thread(s) | +| `silu_mul` | `avx_silu_mul` | libavx | `n=12288 dtype=bf16 M=2` | - | 11990.16 | 5997.97 | 17984.94 | 20 | 21.0 | - | 144.00 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=8` | - | 11987.89 | 5499.54 | 20973.84 | 20 | 37.6 | - | 64.03 KiB | 32 thread(s) | +| `lili_walk` | `avx_lili_walk` | libavx | `steps=7 k=8 n=1024 dtype=bf16 eps=0.0001 scale=8 M=4` | - | 11987.85 | 6997.92 | 13997.63 | 20 | 16.7 | - | 911.98 KiB | 32 thread(s) | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=131072 k=21 M=32` | - | 11985.28 | 5950.35 | 14992.85 | 20 | 36.7 | - | 16.01 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=2304 group=128 dtype=bf16 M=32` | - | 11982.30 | 5989.41 | 14273.78 | 20 | 25.0 | - | 218.25 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=2304 group=128 dtype=bf16 M=16` | - | 11977.42 | 5992.85 | 12002.31 | 20 | 25.0 | - | 109.12 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=1024 group=128 dtype=bf16 M=128` | - | 11976.49 | 5986.62 | 18964.06 | 20 | 41.9 | - | 388.00 KiB | 32 thread(s) | +| `sample_dry` | `ref_sample_dry` | libref | `n_vocab=131072 M=1` | - | 11976.49 | 10823.26 | 13008.73 | 14 | 0.2 | - | 512.41 KiB | 32 thread(s) | +| `silu` | `avx_silu` | libavx | `n=1024 dtype=bf16 M=448` | - | 11975.74 | 5998.37 | 15993.43 | 20 | 33.5 | - | 1.75 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=24576 group=128 dtype=bf16 M=4` | - | 11974.48 | 5994.14 | 17983.20 | 20 | 25.0 | - | 291.00 KiB | 32 thread(s) | +| `sample_temp` | `ref_sample_temp` | libref | `n_vocab=131072 M=1` | - | 11963.88 | 4981.50 | 16991.91 | 20 | 25.2 | - | 512.09 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=512` | - | 11956.36 | 4979.86 | 12956.22 | 20 | 4.2 | - | 258.00 KiB | 32 thread(s) | +| `lili_walk` | `avx_lili_walk` | libavx | `steps=7 k=8 n=1024 dtype=bf16 eps=0.0001 scale=8 M=2` | - | 11953.49 | 2059.43 | 15996.30 | 20 | 37.4 | - | 455.99 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=32` | - | 11948.57 | 8955.36 | 23970.28 | 20 | 37.2 | - | 256.12 KiB | 32 thread(s) | +| `sample_temp` | `ref_sample_temp` | libref | `n_vocab=131072 M=2` | - | 11924.01 | 11921.01 | 11925.16 | 6 | 0.0 | - | 1.00 MiB | 32 thread(s) | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=128` | - | 11923.44 | 5925.13 | 16928.97 | 20 | 25.0 | - | 832.50 KiB | 32 thread(s) | +| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=131072 M=2` | - | 11893.19 | 11764.58 | 11982.15 | 6 | 0.9 | - | 1.00 MiB | 32 thread(s) | +| `sample_penalties` | `avx_sample_penalties` | libavx | `n_vocab=131072 M=4` | - | 11891.91 | 11774.92 | 16874.92 | 20 | 4.2 | - | 2.00 MiB | 32 thread(s) | +| `sample_penalties` | `avx_sample_penalties` | libavx | `n_vocab=131072 M=2` | - | 11891.45 | 11853.03 | 15879.81 | 20 | 8.5 | - | 1.00 MiB | 32 thread(s) | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=512` | - | 11890.68 | 11877.09 | 11920.45 | 11 | 0.2 | - | 1.03 MiB | 32 thread(s) | +| `sample_ngram_ban` | `avx_sample_ngram_ban` | libavx | `n_vocab=131072 M=4` | - | 11887.99 | 11878.00 | 11897.45 | 6 | 0.1 | - | 2.06 MiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=512` | - | 11879.15 | 11796.19 | 23844.51 | 20 | 25.3 | - | 1.01 MiB | 32 thread(s) | +| `sample_dry` | `ref_sample_dry` | libref | `n_vocab=131072 M=2` | - | 11874.18 | 11841.45 | 16807.23 | 16 | 0.1 | - | 1.00 MiB | 32 thread(s) | +| `sample_mask` | `ref_sample_mask` | libref | `n_vocab=131072 M=4` | - | 11870.00 | 5769.78 | 17848.81 | 20 | 50.0 | - | 2.06 MiB | 32 thread(s) | +| `sample_dry` | `avx_sample_dry` | libavx | `n_vocab=131072 M=8` | - | 11795.54 | 5792.77 | 17101.38 | 20 | 11.3 | - | 4.00 MiB | 32 thread(s) | +| `sample_penalties` | `avx_sample_penalties` | libavx | `n_vocab=248320 M=32` | - | 11776.66 | 5779.16 | 18775.32 | 20 | 34.0 | - | 30.32 MiB | 32 thread(s) | +| `sample_logprobs` | `ref_sample_logprobs` | libref | `n_vocab=131072 k=21 M=16` | - | 11752.23 | 7792.67 | 14513.07 | 20 | 17.1 | - | 8.00 MiB | 32 thread(s) | +| `sample_ngram_ban` | `avx_sample_ngram_ban` | libavx | `n_vocab=131072 M=8` | - | 11721.99 | 11241.34 | 23640.90 | 20 | 51.0 | - | 4.13 MiB | 32 thread(s) | +| `sample_mask` | `avx_sample_mask` | libavx | `n_vocab=131072 M=4` | - | 11697.72 | 8676.00 | 12315.92 | 20 | 4.0 | - | 2.06 MiB | 32 thread(s) | +| `sample_dry` | `ref_sample_dry` | libref | `n_vocab=131072 M=8` | - | 11599.55 | 4786.95 | 20543.04 | 20 | 34.6 | - | 4.00 MiB | 32 thread(s) | +| `sample_mask` | `ref_sample_mask` | libref | `n_vocab=131072 M=8` | - | 11566.38 | 10743.32 | 12395.03 | 20 | 6.4 | - | 4.13 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=4096 group=128 dtype=bf16 M=256` | - | 11533.72 | 4981.07 | 17938.94 | 20 | 30.4 | - | 3.03 MiB | 32 thread(s) | +| `sample_penalties` | `ref_sample_penalties` | libref | `n_vocab=131072 M=32` | - | 11527.25 | 7023.35 | 16148.60 | 20 | 39.2 | - | 16.01 MiB | 32 thread(s) | +| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=512` | - | 11514.10 | 10687.62 | 13869.03 | 20 | 8.6 | - | 288.01 KiB | 32 thread(s) | +| `sample_temp` | `ref_sample_temp` | libref | `n_vocab=131072 M=8` | - | 11504.90 | 5007.12 | 20539.77 | 20 | 47.4 | - | 4.00 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=128` | - | 11500.75 | 5986.64 | 13994.37 | 20 | 17.5 | - | 2.01 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3072 K=1024 dtype=bf16 act=none M=16` | - | 11493.02 | 8895.22 | 17018.83 | 20 | 26.1 | - | 6.22 MiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=256` | - | 11490.52 | 11407.51 | 11547.70 | 11 | 0.5 | - | 3.00 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=3072 K=1024 dtype=bf16 act=none M=8` | - | 11486.06 | 8004.38 | 18008.28 | 20 | 39.2 | - | 6.12 MiB | 32 thread(s) | +| `sample_dry` | `ref_sample_dry` | libref | `n_vocab=248320 M=64` | - | 11478.82 | 9070.75 | 23578.80 | 20 | 25.4 | - | 60.65 MiB | 32 thread(s) | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | `N=304 K=4096 dtype=bf16 M=16` | - | 11429.02 | 5998.66 | 18921.40 | 20 | 36.7 | - | 4.89 MiB | 32 thread(s) | +| `sample_mask` | `avx_sample_mask` | libavx | `n_vocab=131072 M=8` | - | 11419.99 | 11311.75 | 11451.45 | 11 | 0.4 | - | 4.13 MiB | 32 thread(s) | +| `sample_mask` | `avx_sample_mask` | libavx | `n_vocab=131072 M=64` | - | 11417.38 | 2766.70 | 13815.76 | 20 | 16.3 | - | 33.01 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=2304 act=relu dtype=bf16 M=256` | - | 11262.99 | 8992.02 | 15733.66 | 20 | 29.9 | - | 3.38 MiB | 32 thread(s) | +| `attn_paged_sink` | `avx_attn_paged_sink` | libavx | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1` | - | 11236.68 | 8979.13 | 17543.85 | 20 | 37.7 | - | 16.02 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=1024 eps=1e-06 dtype=bf16 M=448` | - | 11169.96 | 8994.62 | 15828.52 | 20 | 30.5 | - | 1.75 MiB | 32 thread(s) | +| `sample_mask` | `avx_sample_mask` | libavx | `n_vocab=131072 M=1` | - | 11162.54 | 4978.82 | 17975.55 | 20 | 38.7 | - | 528.09 KiB | 32 thread(s) | +| `logits_gemm` | `logits_gemm_bf16_cols` | libr4d | `n_vocab=131072 n_embd=4096 dtype=bf16 M=64` | 11056.59 | - | 11019.69 | 11152.85 | 6 | 0.6 | 2332 | 1.03 GiB | | +| `lili_factor` | `avx_lili_factor` | libavx | `L=56 n=1024 dtype=bf16 M=16` | - | 11043.36 | 8991.25 | 15953.49 | 20 | 31.5 | - | 450.00 KiB | 32 thread(s) | +| `sample_dry` | `ref_sample_dry` | libref | `n_vocab=131072 M=16` | - | 11016.03 | 7591.11 | 23046.97 | 20 | 64.6 | - | 8.01 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=24576 group=128 dtype=bf16 M=16` | - | 11008.01 | 5984.11 | 17996.11 | 20 | 31.7 | - | 1.14 MiB | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=4096 dtype=bf16 M=32` | - | 10999.26 | 8997.66 | 16997.02 | 20 | 31.8 | - | 1.25 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=4096 eps=1e-05 dtype=bf16 M=32` | - | 10995.38 | 5000.29 | 17958.49 | 20 | 36.4 | - | 520.00 KiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=5 splits=0` | - | 10993.31 | 7992.32 | 11999.46 | 20 | 4.6 | - | 2.08 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2 splits=0` | - | 10992.47 | 5997.33 | 29997.85 | 20 | 45.6 | - | 2.03 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=2048 dtype=bf16 act=none M=2` | - | 10991.54 | 6994.67 | 18003.42 | 20 | 50.0 | - | 4.02 MiB | 32 thread(s) | +| `sample_mask` | `ref_sample_mask` | libref | `n_vocab=131072 M=1` | - | 10976.83 | 5913.47 | 16347.68 | 20 | 36.2 | - | 528.09 KiB | 32 thread(s) | +| `silu_mul` | `avx_silu_mul` | libavx | `n=12288 dtype=bf16 M=32` | - | 10966.79 | 8020.48 | 12013.61 | 20 | 18.0 | - | 2.25 MiB | 32 thread(s) | +| `lili_attn` | `avx_lili_attn` | libavx | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=4` | - | 10917.88 | 5997.55 | 15924.20 | 20 | 13.7 | - | 448.50 KiB | 32 thread(s) | +| `sample_mask` | `ref_sample_mask` | libref | `n_vocab=131072 M=32` | - | 10917.15 | 3483.25 | 13698.11 | 20 | 26.3 | - | 16.50 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=2304 group=128 dtype=bf16 M=256` | - | 10900.53 | 8998.86 | 17688.04 | 20 | 38.4 | - | 1.71 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=12288 group=128 dtype=bf16 M=32` | - | 10877.22 | 8996.87 | 16981.58 | 20 | 32.1 | - | 1.14 MiB | 32 thread(s) | +| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=131072 M=4` | - | 10842.04 | 6894.01 | 16840.42 | 20 | 32.3 | - | 2.00 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=5376 act=relu dtype=bf16 M=16` | - | 10721.26 | 5253.20 | 17994.58 | 20 | 41.7 | - | 504.00 KiB | 32 thread(s) | +| `lili_factor` | `ref_lili_factor` | libref | `L=56 n=1024 dtype=bf16 M=64` | - | 10688.44 | 4193.50 | 20944.79 | 20 | 64.7 | - | 900.00 KiB | 32 thread(s) | +| `sample_mask` | `avx_sample_mask` | libavx | `n_vocab=131072 M=16` | - | 10654.07 | 4791.89 | 11219.08 | 20 | 29.6 | - | 8.25 MiB | 32 thread(s) | +| `attn_paged_sink` | `avx_attn_paged_sink` | libavx | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2` | - | 10497.49 | 4996.89 | 14989.93 | 20 | 28.6 | - | 2.03 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=10` | - | 10482.39 | 5971.17 | 11989.91 | 20 | 28.4 | - | 176.01 KiB | 32 thread(s) | +| `lili_attn` | `ref_lili_attn` | libref | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=32` | - | 10470.23 | 5683.05 | 16182.82 | 20 | 34.1 | - | 448.50 KiB | 32 thread(s) | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=256` | - | 10450.47 | 8936.22 | 17929.60 | 20 | 38.2 | - | 545.00 KiB | 32 thread(s) | +| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=131072 M=32` | - | 10349.17 | 5341.40 | 13244.41 | 20 | 15.4 | - | 16.00 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=4096 group=128 dtype=bf16 M=128` | - | 10318.39 | 8993.87 | 16690.50 | 20 | 37.2 | - | 1.52 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | - | 10197.83 | 5864.58 | 17274.35 | 20 | 45.8 | - | 4.06 MiB | 32 thread(s) | +| `sample_logprobs` | `ref_sample_logprobs` | libref | `n_vocab=131072 k=9 M=4` | - | 10184.67 | 5934.21 | 12003.73 | 20 | 29.4 | - | 2.00 MiB | 32 thread(s) | +| `lili_factor` | `avx_lili_factor` | libavx | `L=56 n=1024 dtype=bf16 M=256` | - | 10183.40 | 8987.69 | 17770.21 | 20 | 38.4 | - | 2.20 MiB | 32 thread(s) | +| `lili_factor` | `avx_lili_factor` | libavx | `L=56 n=1024 dtype=bf16 M=64` | - | 10069.86 | 8997.43 | 16927.20 | 20 | 39.4 | - | 900.00 KiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4 splits=0` | - | 10016.14 | 7964.04 | 20030.96 | 20 | 30.0 | - | 2.06 MiB | 32 thread(s) | +| `silu` | `avx_silu` | libavx | `n=1024 dtype=bf16 M=16` | - | 10015.83 | 8983.52 | 16985.71 | 20 | 39.8 | - | 64.00 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=1024 eps=1e-06 dtype=bf16 M=16` | - | 10003.82 | 7004.94 | 13999.11 | 20 | 15.0 | - | 66.00 KiB | 32 thread(s) | +| `lili_attn` | `avx_lili_attn` | libavx | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=8` | - | 10003.69 | 5997.36 | 17979.63 | 20 | 44.9 | - | 448.50 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=24576 group=128 dtype=bf16 M=32` | - | 10002.49 | 5952.21 | 20997.97 | 20 | 59.9 | - | 2.27 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=24576 group=128 dtype=bf16 M=2` | - | 10002.26 | 8994.14 | 17981.67 | 20 | 40.0 | - | 145.50 KiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=4096 dtype=bf16 act=none M=1` | - | 9994.07 | 5999.74 | 11995.33 | 20 | 19.9 | - | 8.01 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=65` | - | 9992.10 | 6993.89 | 17988.97 | 20 | 19.9 | - | 1.09 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=512` | - | 9983.32 | 4526.78 | 14130.66 | 20 | 22.4 | - | 8.01 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8 splits=0` | - | 9950.50 | 6005.70 | 11984.66 | 20 | 29.9 | - | 144.01 KiB | 32 thread(s) | +| `lili_attn` | `avx_lili_attn` | libavx | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=448` | - | 9914.60 | 5998.32 | 12014.70 | 20 | 15.2 | - | 3.50 MiB | 32 thread(s) | +| `sample_typical` | `ref_sample_typical` | libref | `n_cand=1024 M=4` | - | 9910.53 | 9509.58 | 10337.83 | 20 | 1.5 | - | 32.38 KiB | 32 thread(s) | +| `lili_walk` | `ref_lili_walk` | libref | `steps=7 k=8 n=1024 dtype=bf16 eps=0.0001 scale=8 M=1` | - | 9865.38 | 5998.60 | 17144.08 | 20 | 41.2 | - | 228.00 KiB | 32 thread(s) | +| `logits_gemm` | `logits_gemm_bf16_cols` | libr4d | `n_vocab=131072 n_embd=4096 dtype=bf16 M=56` | 9660.92 | - | 9394.52 | 9722.21 | 11 | 0.8 | 2342 | 1.03 GiB | | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=1024 eps=1e-06 dtype=bf16 M=448` | - | 9517.60 | 8994.25 | 17998.63 | 20 | 47.2 | - | 1.75 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=3072 dtype=bf16 act=none M=8` | - | 9506.63 | 8978.10 | 29990.86 | 20 | 63.1 | - | 6.08 MiB | 32 thread(s) | +| `embed_lookup` | `ref_embed_lookup` | libref | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=448` | - | 9482.36 | 8992.78 | 17536.80 | 20 | 45.0 | - | 1.00 GiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=24576 group=128 dtype=bf16 M=8` | - | 9472.21 | 8985.80 | 18004.93 | 20 | 45.2 | - | 582.00 KiB | 32 thread(s) | +| `sample_penalties` | `ref_sample_penalties` | libref | `n_vocab=131072 M=2` | - | 9269.85 | 5865.82 | 16441.87 | 20 | 37.8 | - | 1.00 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=12288 group=128 dtype=bf16 M=32` | - | 9251.54 | 5997.64 | 17741.37 | 20 | 47.2 | - | 1.14 MiB | 32 thread(s) | +| `silu` | `ref_silu` | libref | `n=2048 dtype=bf16 M=128` | - | 9220.32 | 5997.33 | 17776.50 | 20 | 58.2 | - | 1.00 MiB | 32 thread(s) | +| `gemm_nt_f32` | `ref_gemm_nt_f32` | libref | `N=304 K=4096 dtype=bf16 M=2` | - | 9053.84 | 8806.91 | 15505.33 | 20 | 4.5 | - | 4.77 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=24576 group=128 dtype=bf16 M=64` | - | 9029.92 | 4005.00 | 17963.13 | 20 | 49.9 | - | 4.55 MiB | 32 thread(s) | +| `attn_paged_sink` | `ref_attn_paged_sink` | libref | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1` | - | 9026.47 | 6956.99 | 25001.72 | 20 | 66.5 | - | 16.02 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=2304 group=128 dtype=bf16 M=128` | - | 9020.05 | 8997.35 | 17979.62 | 20 | 49.8 | - | 873.00 KiB | 32 thread(s) | +| `silu` | `ref_silu` | libref | `n=2048 dtype=bf16 M=16` | - | 9016.42 | 8993.45 | 17978.84 | 20 | 49.7 | - | 128.00 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=16` | - | 9013.40 | 5995.51 | 20988.01 | 20 | 66.0 | - | 272.01 KiB | 32 thread(s) | +| `silu_mul` | `avx_silu_mul` | libavx | `n=12288 dtype=bf16 M=8` | - | 9012.93 | 8995.72 | 17986.33 | 20 | 49.8 | - | 576.00 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1 splits=0` | - | 9012.60 | 8973.26 | 17991.17 | 20 | 49.9 | - | 32.01 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2 splits=0` | - | 9008.28 | 4959.90 | 16999.78 | 20 | 22.3 | - | 48.01 KiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=4096 dtype=bf16 act=none M=32` | - | 9003.94 | 8990.42 | 14992.43 | 16 | 0.1 | - | 8.38 MiB | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=4096 dtype=bf16 M=8` | - | 9003.89 | 5991.63 | 20995.64 | 20 | 83.2 | - | 320.03 KiB | 32 thread(s) | +| `sample_argmax` | `ref_sample_argmax` | libref | `n_vocab=131072 M=8` | - | 9002.83 | 990.05 | 17542.65 | 20 | 24.7 | - | 4.00 MiB | 32 thread(s) | +| `silu` | `avx_silu` | libavx | `n=2048 dtype=bf16 M=32` | - | 9002.17 | 5990.66 | 17993.53 | 20 | 66.6 | - | 256.00 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=4096 eps=1e-05 dtype=bf16 M=512` | - | 9001.25 | 5997.29 | 11969.49 | 20 | 27.8 | - | 8.01 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=2048 dtype=bf16 act=none M=1` | - | 9000.82 | 8988.30 | 9004.41 | 11 | 0.1 | - | 4.01 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=5 splits=0` | - | 9000.38 | 8929.44 | 9071.47 | 6 | 0.8 | - | 96.01 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=256 K=4096 group=128 dtype=fp8a8 M=8` | - | 9000.28 | 6908.47 | 9982.25 | 14 | 0.0 | - | 1.04 MiB | 32 thread(s) | +| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=448` | - | 9000.19 | 5977.94 | 17988.71 | 20 | 16.7 | - | 1.00 GiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=4096 K=4096 group=128 dtype=fp8a8 M=4` | - | 9000.06 | 7993.74 | 20994.82 | 20 | 16.7 | - | 16.05 MiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1024 K=4096 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 9000.05 | 8992.04 | 12001.30 | 20 | 16.7 | - | 8.16 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=1024 group=128 dtype=bf16 M=64` | - | 8999.99 | 5997.93 | 26998.98 | 20 | 66.7 | - | 194.00 KiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=2304 act=relu dtype=bf16 M=64` | - | 8999.97 | 5998.48 | 17949.72 | 20 | 49.7 | - | 864.00 KiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=17` | - | 8999.89 | 8998.15 | 9000.90 | 6 | 0.0 | - | 304.01 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=1024 K=5120 group=128 dtype=fp8a8 M=1` | - | 8999.75 | 8996.91 | 18000.56 | 20 | 49.9 | - | 5.01 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=2304 group=128 dtype=bf16 M=128` | - | 8999.61 | 5203.65 | 16717.70 | 20 | 44.4 | - | 873.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=12288 group=128 dtype=bf16 M=8` | - | 8999.19 | 5336.38 | 17788.24 | 20 | 17.9 | - | 291.00 KiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4 splits=0` | - | 8998.85 | 8871.79 | 9003.96 | 6 | 0.7 | - | 80.01 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=256 K=4096 group=128 dtype=fp8a8 M=32` | - | 8998.83 | 8990.10 | 9998.65 | 14 | 0.1 | - | 1.14 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=6 splits=0` | - | 8998.82 | 8991.54 | 9001.50 | 6 | 0.1 | - | 112.01 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=2304 group=128 dtype=bf16 M=64` | - | 8998.77 | 5972.66 | 17998.31 | 20 | 66.6 | - | 436.50 KiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=11` | - | 8998.71 | 8993.80 | 9005.73 | 11 | 0.1 | - | 296.01 KiB | 32 thread(s) | +| `gemm_nt` | `ref_gemm_nt` | libref | `N=1024 K=4096 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | - | 8998.63 | 8993.54 | 9003.05 | 6 | 0.1 | - | 8.08 MiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2 splits=0` | - | 8998.58 | 8994.17 | 9005.27 | 6 | 0.1 | - | 48.01 KiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1 splits=0` | - | 8998.49 | 5996.72 | 11998.69 | 20 | 33.3 | - | 2.02 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=5 splits=0` | - | 8998.42 | 5006.78 | 17990.24 | 20 | 16.7 | - | 96.01 KiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=1024 dtype=bf16 act=none M=1` | - | 8998.16 | 8988.50 | 9001.32 | 6 | 0.1 | - | 2.01 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=16` | - | 8998.15 | 5995.36 | 13024.23 | 20 | 38.9 | - | 264.00 KiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=130` | - | 8997.47 | 8977.68 | 9010.23 | 6 | 0.2 | - | 2.17 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=12288 group=128 dtype=bf16 M=2` | - | 8997.46 | 5368.31 | 21000.51 | 20 | 33.5 | - | 72.75 KiB | 32 thread(s) | +| `attn_paged` | `ref_attn_paged` | libref | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=16` | - | 8996.85 | 7017.92 | 9007.25 | 14 | 0.2 | - | 272.01 KiB | 32 thread(s) | +| `gemm_nt_q` | `ref_gemm_nt_q` | libref | `N=256 K=4096 group=128 dtype=fp8a8 M=2` | - | 8996.26 | 6999.16 | 10000.88 | 20 | 11.1 | - | 1.01 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=4096 dtype=bf16 act=none M=16` | - | 8996.03 | 8984.05 | 9048.67 | 6 | 0.4 | - | 8.19 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=1024 dtype=bf16 act=none M=32` | - | 8995.99 | 8976.60 | 9021.95 | 6 | 0.3 | - | 2.19 MiB | 32 thread(s) | +| `gemm_nt_bias` | `ref_gemm_nt_bias` | libref | `N=1024 K=3072 dtype=bf16 act=none M=2` | - | 8994.93 | 8988.44 | 9010.47 | 6 | 0.1 | - | 6.02 MiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=256` | - | 8994.47 | 8971.07 | 17975.69 | 20 | 50.0 | - | 129.00 KiB | 32 thread(s) | +| `sample_argmax` | `avx_sample_argmax` | libavx | `n_vocab=131072 M=8` | - | 8993.38 | 3975.92 | 11994.84 | 20 | 33.3 | - | 4.00 MiB | 32 thread(s) | +| `attn_paged_sink` | `avx_attn_paged_sink` | libavx | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2` | - | 8992.99 | 5996.90 | 12005.88 | 20 | 33.3 | - | 48.13 KiB | 32 thread(s) | +| `sample_argmax` | `ref_sample_argmax` | libref | `n_vocab=131072 M=32` | - | 8992.67 | 5008.72 | 20994.81 | 20 | 50.1 | - | 16.00 MiB | 32 thread(s) | +| `kv_store` | `ref_kv_store` | libref | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=512` | - | 8990.95 | 8878.81 | 17869.01 | 20 | 49.5 | - | 1.03 MiB | 32 thread(s) | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=128` | - | 8985.66 | 7490.82 | 17959.47 | 20 | 50.0 | - | 288.50 KiB | 32 thread(s) | +| `lili_factor` | `ref_lili_factor` | libref | `L=56 n=1024 dtype=bf16 M=128` | - | 8983.85 | 5993.74 | 15067.83 | 20 | 33.4 | - | 1.32 MiB | 32 thread(s) | +| `attn_paged_sink` | `avx_attn_paged_sink` | libavx | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8` | - | 8980.83 | 4926.78 | 12007.10 | 20 | 33.4 | - | 16.13 MiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=32` | - | 8969.23 | 5092.37 | 20958.99 | 20 | 33.5 | - | 256.12 KiB | 32 thread(s) | +| `sample_ngram_ban` | `avx_sample_ngram_ban` | libavx | `n_vocab=131072 M=2` | - | 8943.99 | 5831.77 | 17905.66 | 20 | 38.3 | - | 1.03 MiB | 32 thread(s) | +| `sample_temp` | `ref_sample_temp` | libref | `n_vocab=131072 M=32` | - | 8937.21 | 6836.33 | 10211.54 | 20 | 3.1 | - | 16.00 MiB | 32 thread(s) | +| `sample_penalties` | `ref_sample_penalties` | libref | `n_vocab=248320 M=64` | - | 8919.16 | 1437.86 | 15187.50 | 20 | 52.7 | - | 60.65 MiB | 32 thread(s) | +| `sample_penalties` | `ref_sample_penalties` | libref | `n_vocab=131072 M=4` | - | 8912.71 | 3796.53 | 18697.32 | 20 | 33.6 | - | 2.00 MiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=4096 eps=1e-05 dtype=bf16 M=512` | - | 8889.74 | 5998.01 | 11998.42 | 20 | 18.0 | - | 8.01 MiB | 32 thread(s) | +| `attn_paged_sink` | `avx_attn_paged_sink` | libavx | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4` | - | 8879.13 | 4988.79 | 15997.99 | 20 | 50.7 | - | 2.06 MiB | 32 thread(s) | +| `sample_dry` | `avx_sample_dry` | libavx | `n_vocab=131072 M=16` | - | 8875.47 | 7759.46 | 16818.12 | 20 | 50.3 | - | 8.01 MiB | 32 thread(s) | +| `sample_penalties` | `avx_sample_penalties` | libavx | `n_vocab=131072 M=8` | - | 8774.81 | 8588.79 | 17746.67 | 20 | 50.7 | - | 4.00 MiB | 32 thread(s) | +| `sample_dry` | `avx_sample_dry` | libavx | `n_vocab=131072 M=4` | - | 8767.11 | 8682.71 | 17739.77 | 20 | 51.3 | - | 2.00 MiB | 32 thread(s) | +| `sample_dry` | `avx_sample_dry` | libavx | `n_vocab=131072 M=64` | - | 8686.88 | 2546.88 | 14694.03 | 20 | 49.8 | - | 32.03 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=2048 group=128 dtype=bf16 M=256` | - | 8659.69 | 5997.98 | 22626.25 | 20 | 59.9 | - | 1.52 MiB | 32 thread(s) | +| `sample_dry` | `ref_sample_dry` | libref | `n_vocab=131072 M=4` | - | 8607.11 | 8311.20 | 17446.28 | 20 | 52.2 | - | 2.00 MiB | 32 thread(s) | +| `lili_attn` | `ref_lili_attn` | libref | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=1` | - | 8601.59 | 5844.36 | 11730.99 | 20 | 17.3 | - | 448.50 KiB | 32 thread(s) | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=131072 k=9 M=8` | - | 8497.26 | 5903.47 | 15996.50 | 20 | 18.7 | - | 4.00 MiB | 32 thread(s) | +| `sample_logprobs` | `ref_sample_logprobs` | libref | `n_vocab=131072 k=9 M=8` | - | 8405.41 | 5991.95 | 11995.60 | 20 | 25.1 | - | 4.00 MiB | 32 thread(s) | +| `lili_attn` | `avx_lili_attn` | libavx | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=128` | - | 8264.30 | 4922.64 | 12712.98 | 20 | 36.4 | - | 1.31 MiB | 32 thread(s) | +| `silu_mul` | `ref_silu_mul` | libref | `n=12288 dtype=bf16 M=64` | - | 8139.73 | 5988.48 | 23993.63 | 20 | 36.8 | - | 4.50 MiB | 32 thread(s) | +| `sample_penalties` | `avx_sample_penalties` | libavx | `n_vocab=131072 M=16` | - | 8098.69 | 4561.07 | 11022.42 | 20 | 37.0 | - | 8.01 MiB | 32 thread(s) | +| `lili_attn` | `ref_lili_attn` | libref | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=8` | - | 8061.37 | 5966.49 | 9826.36 | 20 | 18.6 | - | 448.50 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=2304 group=128 dtype=bf16 M=512` | - | 8030.62 | 4369.52 | 18854.61 | 20 | 42.1 | - | 3.41 MiB | 32 thread(s) | +| `sample_argmax` | `avx_sample_argmax` | libavx | `n_vocab=131072 M=1` | - | 8001.63 | 5996.07 | 12003.02 | 20 | 37.5 | - | 512.10 KiB | 32 thread(s) | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=131072 k=21 M=2` | - | 8000.73 | 5988.71 | 12000.07 | 20 | 37.4 | - | 1.00 MiB | 32 thread(s) | +| `sample_logprobs` | `ref_sample_logprobs` | libref | `n_vocab=131072 k=9 M=32` | - | 7975.73 | 6975.43 | 9035.50 | 16 | 0.5 | - | 16.01 MiB | 32 thread(s) | +| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=131072 M=16` | - | 7972.91 | 1788.78 | 19751.36 | 20 | 37.6 | - | 8.00 MiB | 32 thread(s) | +| `kv_store` | `ref_kv_store` | libref | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=128` | - | 7950.45 | 3947.01 | 10980.08 | 20 | 37.8 | - | 288.50 KiB | 32 thread(s) | +| `sample_argmax` | `avx_sample_argmax` | libavx | `n_vocab=131072 M=64` | - | 7946.87 | 5942.91 | 14943.33 | 20 | 37.8 | - | 32.01 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=1024 group=128 dtype=bf16 M=64` | - | 7757.73 | 5993.73 | 17988.02 | 20 | 38.7 | - | 194.00 KiB | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=4096 dtype=bf16 M=56` | - | 7624.59 | 5981.44 | 11998.29 | 20 | 32.8 | - | 2.19 MiB | 32 thread(s) | +| `gather_rows` | `ref_gather_rows` | libref | `n=4096 dtype=bf16 M=56` | - | 7520.79 | 5968.79 | 16001.66 | 20 | 46.7 | - | 2.19 MiB | 32 thread(s) | +| `silu` | `ref_silu` | libref | `n=2048 dtype=bf16 M=448` | - | 7512.58 | 2930.60 | 16229.32 | 20 | 64.9 | - | 3.50 MiB | 32 thread(s) | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=64` | - | 7477.56 | 2981.13 | 20967.10 | 20 | 80.0 | - | 448.25 KiB | 32 thread(s) | +| `sample_ngram_ban` | `avx_sample_ngram_ban` | libavx | `n_vocab=131072 M=32` | - | 7455.94 | 4022.72 | 16163.45 | 20 | 50.7 | - | 16.51 MiB | 32 thread(s) | +| `sample_mask` | `ref_sample_mask` | libref | `n_vocab=131072 M=64` | - | 7331.98 | 4000.25 | 8204.69 | 20 | 24.7 | - | 33.01 MiB | 32 thread(s) | +| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=131072 M=1` | - | 7259.37 | 5974.27 | 11972.55 | 20 | 41.1 | - | 512.09 KiB | 32 thread(s) | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=131072 k=21 M=16` | - | 7183.44 | 4812.27 | 17175.23 | 20 | 40.6 | - | 8.00 MiB | 32 thread(s) | +| `sample_argmax` | `avx_sample_argmax` | libavx | `n_vocab=131072 M=16` | - | 7087.41 | 4918.89 | 12002.10 | 20 | 21.1 | - | 8.00 MiB | 32 thread(s) | +| `sample_penalties` | `avx_sample_penalties` | libavx | `n_vocab=131072 M=32` | - | 7029.37 | 3929.45 | 15954.94 | 20 | 42.8 | - | 16.01 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=512` | - | 7012.42 | 5964.71 | 12013.74 | 20 | 42.8 | - | 8.01 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=9` | - | 7008.00 | 5972.74 | 9751.19 | 20 | 25.5 | - | 2.14 MiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=1024 eps=1e-06 dtype=bf16 M=32` | - | 7000.93 | 5995.80 | 14011.38 | 20 | 42.9 | - | 130.00 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8 splits=0` | - | 6995.99 | 5977.68 | 9490.60 | 20 | 10.3 | - | 2.13 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=16` | - | 6661.83 | 5002.30 | 9725.15 | 20 | 8.2 | - | 2.25 MiB | 32 thread(s) | +| `silu` | `ref_silu` | libref | `n=1024 dtype=bf16 M=448` | - | 6614.39 | 5985.75 | 10774.07 | 20 | 36.1 | - | 1.75 MiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=2304 act=relu dtype=bf16 M=64` | - | 6511.62 | 3999.16 | 12000.02 | 20 | 46.0 | - | 864.00 KiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=2304 act=relu dtype=bf16 M=32` | - | 6502.64 | 4007.11 | 15043.21 | 20 | 46.1 | - | 432.00 KiB | 32 thread(s) | +| `sample_typical` | `ref_sample_typical` | libref | `n_cand=1024 M=2` | - | 6271.36 | 6092.12 | 6528.52 | 20 | 2.0 | - | 16.19 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=10` | - | 6219.78 | 4721.23 | 9621.79 | 20 | 8.4 | - | 2.16 MiB | 32 thread(s) | +| `moe_gather` | `ref_moe_gather` | libref | `n=1024 top_k=9 dtype=bf16 act=none M=8` | - | 6199.05 | 5609.62 | 12000.36 | 20 | 47.7 | - | 176.44 KiB | 32 thread(s) | +| `sample_logprobs` | `ref_sample_logprobs` | libref | `n_vocab=131072 k=21 M=4` | - | 6147.30 | 5699.80 | 9288.96 | 20 | 16.2 | - | 2.00 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=24576 group=128 dtype=bf16 M=512` | - | 6022.36 | 5412.91 | 6391.93 | 14 | 1.0 | - | 36.38 MiB | 32 thread(s) | +| `lili_factor` | `ref_lili_factor` | libref | `L=56 n=1024 dtype=bf16 M=1` | - | 6022.11 | 5989.70 | 23993.89 | 20 | 49.9 | - | 450.00 KiB | 32 thread(s) | +| `add` | `ref_add` | libref | `n=5120 dtype=bf16 M=256` | - | 6010.65 | 5974.20 | 12000.08 | 20 | 28.0 | - | 7.50 MiB | 32 thread(s) | +| `silu_mul` | `ref_silu_mul` | libref | `n=12288 dtype=bf16 M=8` | - | 6006.06 | 5889.14 | 6036.25 | 11 | 0.6 | - | 576.00 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=2304 group=128 dtype=bf16 M=32` | - | 6006.00 | 3992.55 | 9993.88 | 20 | 25.5 | - | 218.25 KiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=2304 act=relu dtype=bf16 M=256` | - | 6004.30 | 2533.01 | 9036.95 | 20 | 25.1 | - | 3.38 MiB | 32 thread(s) | +| `lili_factor` | `avx_lili_factor` | libavx | `L=56 n=1024 dtype=bf16 M=2` | - | 6003.82 | 5977.05 | 6020.32 | 11 | 0.3 | - | 450.00 KiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=2304 act=relu dtype=bf16 M=16` | - | 6003.10 | 5994.73 | 9008.43 | 20 | 24.9 | - | 216.00 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1 splits=0` | - | 6002.98 | 5951.35 | 6474.64 | 16 | 0.6 | - | 2.02 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=11` | - | 6002.86 | 4714.94 | 8003.09 | 16 | 0.8 | - | 2.17 MiB | 32 thread(s) | +| `lili_attn` | `ref_lili_attn` | libref | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=4` | - | 6002.48 | 5756.14 | 6216.90 | 20 | 1.3 | - | 448.50 KiB | 32 thread(s) | +| `sample_topk` | `avx_sample_topk` | libavx | `n_vocab=131072 M=2` | - | 6001.91 | 4005.45 | 11992.50 | 20 | 41.7 | - | 1.00 MiB | 32 thread(s) | +| `silu` | `ref_silu` | libref | `n=2048 dtype=bf16 M=8` | - | 6001.52 | 5990.15 | 6002.97 | 6 | 0.1 | - | 64.00 KiB | 32 thread(s) | +| `lili_walk` | `ref_lili_walk` | libref | `steps=7 k=8 n=1024 dtype=bf16 eps=0.0001 scale=8 M=4` | - | 6000.69 | 5992.24 | 6003.99 | 6 | 0.1 | - | 911.98 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=4096 group=128 dtype=bf16 M=128` | - | 6000.67 | 5989.66 | 6009.00 | 11 | 0.2 | - | 1.52 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=12288 group=128 dtype=bf16 M=4` | - | 6000.66 | 5980.52 | 11984.40 | 14 | 0.1 | - | 145.50 KiB | 32 thread(s) | +| `silu` | `ref_silu` | libref | `n=2048 dtype=bf16 M=64` | - | 6000.62 | 5972.47 | 6019.77 | 11 | 0.3 | - | 512.00 KiB | 32 thread(s) | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=131072 k=9 M=4` | - | 6000.34 | 5993.85 | 11997.06 | 20 | 25.0 | - | 2.00 MiB | 32 thread(s) | +| `silu` | `avx_silu` | libavx | `n=2048 dtype=bf16 M=8` | - | 6000.21 | 5924.41 | 6004.63 | 11 | 0.1 | - | 64.00 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=11` | - | 6000.11 | 3932.65 | 11989.05 | 19 | 0.1 | - | 192.01 KiB | 32 thread(s) | +| `silu_mul` | `ref_silu_mul` | libref | `n=12288 dtype=bf16 M=16` | - | 6000.04 | 5993.67 | 6001.98 | 11 | 0.0 | - | 1.12 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=6 splits=0` | - | 5999.99 | 5208.30 | 6007.21 | 11 | 0.2 | - | 2.09 MiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=5376 act=relu dtype=bf16 M=4` | - | 5999.95 | 5996.55 | 6018.05 | 11 | 0.2 | - | 126.00 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=4096 eps=1e-05 dtype=bf16 M=16` | - | 5999.91 | 5029.77 | 11999.13 | 20 | 50.0 | - | 264.00 KiB | 32 thread(s) | +| `silu` | `ref_silu` | libref | `n=1024 dtype=bf16 M=32` | - | 5999.89 | 5990.27 | 6992.77 | 14 | 0.3 | - | 128.00 KiB | 32 thread(s) | +| `sample_argmax` | `ref_sample_argmax` | libref | `n_vocab=131072 M=1` | - | 5999.83 | 5988.03 | 9001.72 | 16 | 0.1 | - | 512.10 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=8` | - | 5999.80 | 5970.96 | 7001.83 | 20 | 8.3 | - | 136.00 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=4096 eps=1e-05 dtype=bf16 M=256` | - | 5999.76 | 5996.58 | 6000.43 | 11 | 0.0 | - | 4.01 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=5 splits=0` | - | 5999.70 | 5009.55 | 6989.35 | 14 | 0.0 | - | 2.08 MiB | 32 thread(s) | +| `silu` | `ref_silu` | libref | `n=2048 dtype=bf16 M=32` | - | 5999.62 | 5983.00 | 12800.14 | 16 | 0.5 | - | 256.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=12288 group=128 dtype=bf16 M=64` | - | 5999.59 | 5985.20 | 6006.29 | 11 | 0.1 | - | 2.27 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4 splits=0` | - | 5999.57 | 5982.62 | 6003.44 | 11 | 0.2 | - | 2.06 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=24576 group=128 dtype=bf16 M=8` | - | 5999.54 | 5620.66 | 8359.41 | 16 | 0.2 | - | 582.00 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4 splits=0` | - | 5999.53 | 5976.80 | 6020.70 | 6 | 0.4 | - | 80.01 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=2304 group=128 dtype=bf16 M=8` | - | 5999.45 | 5995.97 | 6001.40 | 6 | 0.0 | - | 54.56 KiB | 32 thread(s) | +| `silu_mul` | `avx_silu_mul` | libavx | `n=12288 dtype=bf16 M=64` | - | 5999.42 | 5983.36 | 11979.71 | 14 | 0.2 | - | 4.50 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2 splits=0` | - | 5999.37 | 5994.54 | 6004.14 | 6 | 0.1 | - | 2.03 MiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=24576 group=128 dtype=bf16 M=1` | - | 5999.24 | 5990.83 | 6008.46 | 6 | 0.1 | - | 72.75 KiB | 32 thread(s) | +| `lili_factor` | `avx_lili_factor` | libavx | `L=56 n=1024 dtype=bf16 M=8` | - | 5999.22 | 5981.22 | 8998.91 | 14 | 0.3 | - | 450.00 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=9` | - | 5999.20 | 5983.71 | 6015.51 | 6 | 0.3 | - | 160.01 KiB | 32 thread(s) | +| `sample_logprobs` | `ref_sample_logprobs` | libref | `n_vocab=131072 k=9 M=1` | - | 5999.19 | 5231.06 | 6991.76 | 14 | 0.1 | - | 512.17 KiB | 32 thread(s) | +| `lili_factor` | `ref_lili_factor` | libref | `L=56 n=1024 dtype=bf16 M=32` | - | 5999.17 | 5966.29 | 6017.98 | 6 | 0.4 | - | 450.00 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=10` | - | 5999.14 | 5998.64 | 5999.94 | 6 | 0.0 | - | 176.01 KiB | 32 thread(s) | +| `silu` | `avx_silu` | libavx | `n=2048 dtype=bf16 M=16` | - | 5999.13 | 5992.34 | 6000.24 | 6 | 0.1 | - | 128.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=24576 group=128 dtype=bf16 M=4` | - | 5999.09 | 5996.21 | 6000.25 | 11 | 0.0 | - | 291.00 KiB | 32 thread(s) | +| `gather_rows` | `ref_gather_rows` | libref | `n=4096 dtype=bf16 M=16` | - | 5999.03 | 4998.99 | 6000.95 | 11 | 0.0 | - | 640.06 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=4096 eps=1e-05 dtype=bf16 M=64` | - | 5999.02 | 5996.58 | 5999.90 | 11 | 0.0 | - | 1.01 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=2304 act=relu dtype=bf16 M=32` | - | 5999.00 | 5977.56 | 6015.44 | 11 | 0.2 | - | 432.00 KiB | 32 thread(s) | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=131072 k=9 M=56` | - | 5998.97 | 5975.94 | 6010.52 | 11 | 0.1 | - | 28.01 MiB | 32 thread(s) | +| `silu` | `avx_silu` | libavx | `n=1024 dtype=bf16 M=64` | - | 5998.94 | 5990.67 | 6004.52 | 6 | 0.1 | - | 256.00 KiB | 32 thread(s) | +| `silu_mul` | `avx_silu_mul` | libavx | `n=12288 dtype=bf16 M=16` | - | 5998.93 | 5996.70 | 6000.88 | 11 | 0.0 | - | 1.12 MiB | 32 thread(s) | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | `N=304 K=4096 dtype=bf16 M=8` | - | 5998.83 | 5937.76 | 8903.06 | 19 | 0.1 | - | 4.82 MiB | 32 thread(s) | +| `silu_mul` | `avx_silu_mul` | libavx | `n=12288 dtype=bf16 M=4` | - | 5998.81 | 5996.38 | 5999.85 | 6 | 0.0 | - | 288.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=4096 group=128 dtype=bf16 M=512` | - | 5998.79 | 4070.47 | 11999.51 | 20 | 50.0 | - | 6.06 MiB | 32 thread(s) | +| `lili_factor` | `ref_lili_factor` | libref | `L=56 n=1024 dtype=bf16 M=4` | - | 5998.76 | 3047.75 | 6996.75 | 14 | 0.1 | - | 450.00 KiB | 32 thread(s) | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | `N=304 K=4096 dtype=bf16 M=64` | - | 5998.73 | 5997.32 | 6004.68 | 6 | 0.1 | - | 5.32 MiB | 32 thread(s) | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | `N=304 K=4096 dtype=bf16 M=2` | - | 5998.61 | 5994.91 | 6000.73 | 11 | 0.0 | - | 4.77 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=2304 group=128 dtype=bf16 M=8` | - | 5998.58 | 5991.83 | 6005.36 | 6 | 0.1 | - | 54.56 KiB | 32 thread(s) | +| `sample_logprobs` | `ref_sample_logprobs` | libref | `n_vocab=131072 k=21 M=2` | - | 5998.35 | 5734.19 | 8051.02 | 14 | 0.8 | - | 1.00 MiB | 32 thread(s) | +| `attn_paged_sink` | `avx_attn_paged_sink` | libavx | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8` | - | 5998.19 | 5471.24 | 9297.44 | 14 | 0.1 | - | 2.13 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | - | 5998.17 | 4803.42 | 6010.58 | 11 | 0.2 | - | 80.01 KiB | 32 thread(s) | +| `silu` | `avx_silu` | libavx | `n=2048 dtype=bf16 M=64` | - | 5998.10 | 5984.45 | 6010.48 | 11 | 0.2 | - | 512.00 KiB | 32 thread(s) | +| `lili_factor` | `ref_lili_factor` | libref | `L=56 n=1024 dtype=bf16 M=8` | - | 5998.05 | 5986.74 | 6001.11 | 6 | 0.1 | - | 450.00 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=2304 group=128 dtype=bf16 M=256` | - | 5997.96 | 5002.37 | 9010.99 | 16 | 0.1 | - | 1.71 MiB | 32 thread(s) | +| `act_mul` | `avx_act_mul` | libavx | `n=5376 act=relu dtype=bf16 M=128` | - | 5997.85 | 5981.90 | 6002.97 | 11 | 0.1 | - | 3.94 MiB | 32 thread(s) | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=131072 k=21 M=4` | - | 5997.68 | 5946.34 | 6048.21 | 6 | 0.8 | - | 2.00 MiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | - | 5997.52 | 5993.32 | 6002.51 | 6 | 0.1 | - | 4.08 MiB | 32 thread(s) | +| `sample_logprobs` | `avx_sample_logprobs` | libavx | `n_vocab=131072 k=21 M=8` | - | 5997.48 | 5985.15 | 6011.79 | 6 | 0.2 | - | 4.00 MiB | 32 thread(s) | +| `attn_paged_sink` | `avx_attn_paged_sink` | libavx | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8` | - | 5997.43 | 5989.34 | 6001.12 | 6 | 0.1 | - | 144.13 KiB | 32 thread(s) | +| `sample_argmax` | `avx_sample_argmax` | libavx | `n_vocab=131072 M=2` | - | 5997.16 | 5987.86 | 6020.64 | 6 | 0.3 | - | 1.00 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=2304 group=128 dtype=bf16 M=4` | - | 5997.10 | 5992.92 | 6006.97 | 11 | 0.1 | - | 27.28 KiB | 32 thread(s) | +| `silu` | `ref_silu` | libref | `n=1024 dtype=bf16 M=256` | - | 5997.06 | 5961.72 | 6001.77 | 6 | 0.3 | - | 1.00 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=24576 group=128 dtype=bf16 M=16` | - | 5996.29 | 5978.78 | 6025.21 | 11 | 0.3 | - | 1.14 MiB | 32 thread(s) | +| `sample_logprobs` | `ref_sample_logprobs` | libref | `n_vocab=131072 k=21 M=8` | - | 5995.97 | 5350.34 | 6123.51 | 14 | 0.7 | - | 4.00 MiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=24576 group=128 dtype=bf16 M=64` | - | 5995.39 | 4565.77 | 9455.85 | 16 | 0.5 | - | 4.55 MiB | 32 thread(s) | +| `gemm_nt_f32` | `avx_gemm_nt_f32` | libavx | `N=304 K=4096 dtype=bf16 M=4` | - | 5995.38 | 5987.89 | 6991.04 | 14 | 0.1 | - | 4.79 MiB | 32 thread(s) | +| `silu` | `ref_silu` | libref | `n=1024 dtype=bf16 M=128` | - | 5995.25 | 4139.04 | 16937.33 | 19 | 0.1 | - | 512.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=25600 group=128 dtype=bf16 M=32` | - | 5995.22 | 5985.74 | 6016.11 | 6 | 0.3 | - | 2.37 MiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=2304 group=128 dtype=bf16 M=64` | - | 5994.58 | 5957.91 | 6066.73 | 6 | 0.9 | - | 436.50 KiB | 32 thread(s) | +| `lili_factor` | `avx_lili_factor` | libavx | `L=56 n=1024 dtype=bf16 M=32` | - | 5993.85 | 5980.12 | 6007.40 | 11 | 0.2 | - | 450.00 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=128` | - | 5990.14 | 5988.72 | 5991.79 | 6 | 0.0 | - | 64.50 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=256` | - | 5985.53 | 5979.70 | 17956.54 | 20 | 25.3 | - | 129.00 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=16` | - | 5981.20 | 5976.76 | 5984.56 | 6 | 0.1 | - | 128.06 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=16` | - | 5980.87 | 5976.50 | 5984.69 | 6 | 0.1 | - | 128.06 KiB | 32 thread(s) | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=64` | - | 5980.05 | 5977.32 | 5981.76 | 11 | 0.0 | - | 160.25 KiB | 32 thread(s) | +| `sample_penalties` | `ref_sample_penalties` | libref | `n_vocab=131072 M=1` | - | 5978.36 | 5967.31 | 11975.35 | 20 | 50.2 | - | 512.34 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=16` | - | 5978.11 | 5962.92 | 11973.14 | 14 | 0.2 | - | 192.19 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=512` | - | 5969.69 | 5967.01 | 5974.28 | 11 | 0.1 | - | 258.00 KiB | 32 thread(s) | +| `kv_store` | `ref_kv_store` | libref | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=256` | - | 5956.93 | 5945.87 | 11955.97 | 19 | 0.1 | - | 545.00 KiB | 32 thread(s) | +| `sample_dry` | `avx_sample_dry` | libavx | `n_vocab=131072 M=2` | - | 5956.33 | 5948.85 | 5973.68 | 6 | 0.2 | - | 1.00 MiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=64` | - | 5943.54 | 2959.27 | 11945.59 | 14 | 0.1 | - | 512.25 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=64` | - | 5939.58 | 5934.67 | 5944.41 | 11 | 0.1 | - | 512.25 KiB | 32 thread(s) | +| `sample_mask` | `avx_sample_mask` | libavx | `n_vocab=131072 M=2` | - | 5915.00 | 4841.82 | 10286.82 | 20 | 30.2 | - | 1.03 MiB | 32 thread(s) | +| `sample_mask` | `ref_sample_mask` | libref | `n_vocab=131072 M=2` | - | 5875.53 | 3935.45 | 10880.07 | 20 | 26.3 | - | 1.03 MiB | 32 thread(s) | +| `sample_temp` | `ref_sample_temp` | libref | `n_vocab=131072 M=4` | - | 5801.43 | 4654.31 | 11708.11 | 20 | 1.5 | - | 2.00 MiB | 32 thread(s) | +| `sample_ngram_ban` | `avx_sample_ngram_ban` | libavx | `n_vocab=131072 M=64` | - | 5669.71 | 5368.53 | 10632.20 | 20 | 7.2 | - | 33.02 MiB | 32 thread(s) | +| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=131072 M=64` | - | 5630.62 | 5255.32 | 8213.64 | 19 | 0.8 | - | 32.01 MiB | 32 thread(s) | +| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=131072 M=8` | - | 5583.23 | 5403.73 | 11628.73 | 20 | 53.2 | - | 4.00 MiB | 32 thread(s) | +| `logits_gemm` | `logits_gemm_bf16_cols` | libr4d | `n_vocab=131072 n_embd=4096 dtype=bf16 M=32` | 5511.79 | - | 5458.91 | 5608.11 | 14 | 0.8 | 2342 | 1.02 GiB | | +| `sample_penalties` | `ref_sample_penalties` | libref | `n_vocab=131072 M=64` | - | 5445.68 | 4962.38 | 5472.23 | 11 | 0.4 | - | 32.02 MiB | 32 thread(s) | +| `sample_ngram_ban` | `avx_sample_ngram_ban` | libavx | `n_vocab=131072 M=16` | - | 5266.44 | 4913.92 | 11142.73 | 20 | 56.2 | - | 8.26 MiB | 32 thread(s) | +| `sample_temp` | `ref_sample_temp` | libref | `n_vocab=131072 M=16` | - | 5077.80 | 4472.11 | 10787.16 | 20 | 3.6 | - | 8.00 MiB | 32 thread(s) | +| `sample_dry` | `avx_sample_dry` | libavx | `n_vocab=131072 M=32` | - | 4562.86 | 4441.51 | 6131.69 | 20 | 1.2 | - | 16.01 MiB | 32 thread(s) | +| `sample_temp` | `ref_sample_temp` | libref | `n_vocab=131072 M=64` | - | 4545.61 | 3234.40 | 13156.59 | 20 | 6.7 | - | 32.01 MiB | 32 thread(s) | +| `sample_mask` | `avx_sample_mask` | libavx | `n_vocab=131072 M=32` | - | 4533.51 | 2303.32 | 4661.22 | 20 | 1.4 | - | 16.50 MiB | 32 thread(s) | +| `sample_mask` | `ref_sample_mask` | libref | `n_vocab=131072 M=16` | - | 4288.61 | 3860.74 | 4894.62 | 20 | 3.6 | - | 8.25 MiB | 32 thread(s) | +| `sample_typical` | `avx_sample_typical` | libavx | `n_cand=1024 M=1` | - | 4013.33 | 2999.22 | 9117.26 | 40 | 40.9 | - | 8.09 KiB | 32 thread(s) | +| `sample_typical` | `ref_sample_typical` | libref | `n_cand=1024 M=1` | - | 3786.83 | 3313.29 | 4595.20 | 20 | 6.1 | - | 8.09 KiB | 32 thread(s) | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=512` | - | 3775.07 | 3756.16 | 3785.32 | 6 | 0.4 | - | 645.19 KiB | 32 thread(s) | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=512` | - | 3569.82 | 3558.18 | 3584.96 | 6 | 0.4 | - | 645.19 KiB | 32 thread(s) | +| `sample_penalties` | `avx_sample_penalties` | libavx | `n_vocab=131072 M=64` | - | 3316.51 | 2751.25 | 8606.57 | 20 | 55.2 | - | 32.02 MiB | 32 thread(s) | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=512` | - | 3122.94 | 3073.91 | 3226.55 | 20 | 1.3 | - | 516.94 KiB | 32 thread(s) | +| `sample_dry` | `ref_sample_dry` | libref | `n_vocab=131072 M=64` | - | 2955.28 | 2478.00 | 5481.73 | 20 | 41.6 | - | 32.03 MiB | 32 thread(s) | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=512` | - | 2940.68 | 2899.41 | 3065.00 | 20 | 1.1 | - | 516.94 KiB | 32 thread(s) | +| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=256` | - | 2859.42 | 2731.91 | 3011.17 | 20 | 2.2 | - | 160.01 KiB | 32 thread(s) | +| `logits_gemm` | `logits_gemm_fp8` | libr4d | `n_vocab=248320 n_embd=5120 dtype=bf16 M=64` | 2814.81 | - | 2782.49 | 2828.05 | 6 | 0.8 | 2236 | 2.43 GiB | | +| `logits_gemm` | `logits_gemm_bf16_cols` | libr4d | `n_vocab=131072 n_embd=4096 dtype=bf16 M=16` | 2732.67 | - | 2699.61 | 2764.97 | 14 | 0.9 | 2394 | 1.01 GiB | | +| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=256` | - | 2662.28 | 2572.75 | 3595.34 | 20 | 17.6 | - | 144.01 KiB | 32 thread(s) | +| `logits_gemm` | `logits_gemm_fp8` | libr4d | `n_vocab=248320 n_embd=5120 dtype=bf16 M=32` | 2191.25 | - | 2179.93 | 2200.41 | 6 | 0.5 | 2678 | 2.40 GiB | | +| `logits_gemm` | `logits_gemm_fp8` | libr4d | `n_vocab=248320 n_embd=5120 dtype=bf16 M=16` | 2126.03 | - | 2124.13 | 2131.25 | 6 | 0.2 | 2926 | 2.38 GiB | | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=64` | - | 2118.42 | 2113.75 | 2137.70 | 6 | 0.6 | - | 1.06 MiB | 32 thread(s) | +| `logits_gemm` | `logits_gemm_fp8` | libr4d | `n_vocab=248320 n_embd=5120 dtype=bf16 M=8` | 2097.69 | - | 2096.13 | 2099.81 | 6 | 0.1 | 3012 | 2.38 GiB | | +| `logits_gemm` | `logits_gemm_fp8` | libr4d | `n_vocab=248320 n_embd=5120 dtype=bf16 M=4` | 2081.23 | - | 2078.89 | 2084.21 | 6 | 0.1 | 3071 | 2.37 GiB | | +| `logits_gemm` | `logits_gemm_fp8` | libr4d | `n_vocab=248320 n_embd=5120 dtype=bf16 M=2` | 2059.97 | - | 2055.57 | 2065.09 | 6 | 0.2 | 3190 | 2.37 GiB | | +| `logits_gemm` | `logits_gemm_fp8` | libr4d | `n_vocab=248320 n_embd=5120 dtype=bf16 M=1` | 2038.97 | - | 2038.18 | 2044.61 | 6 | 0.2 | 3312 | 2.37 GiB | | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=512` | 1910.63 | - | 1879.37 | 1938.69 | 20 | 1.2 | 2901 | 24.00 MiB | | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=256` | - | 1882.18 | 1866.95 | 1900.57 | 6 | 0.9 | - | 323.19 KiB | 32 thread(s) | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | 1861.75 | - | 1746.59 | 1887.81 | 16 | 0.7 | 2650 | 44.00 MiB | | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=256` | - | 1784.45 | 1770.34 | 1794.04 | 6 | 0.7 | - | 323.19 KiB | 32 thread(s) | +| `logits_gemm` | `logits_gemm_bf16_cols` | libr4d | `n_vocab=131072 n_embd=4096 dtype=bf16 M=8` | 1751.97 | - | 1750.65 | 1754.97 | 6 | 0.1 | 2952 | 1.00 GiB | | +| `logits_gemm` | `logits_gemm_bf16_cols` | libr4d | `n_vocab=131072 n_embd=4096 dtype=bf16 M=4` | 1724.33 | - | 1722.09 | 1727.73 | 11 | 0.1 | 3204 | 1.00 GiB | | +| `logits_gemm` | `logits_gemm_bf16_cols` | libr4d | `n_vocab=131072 n_embd=4096 dtype=bf16 M=2` | 1711.03 | - | 1710.41 | 1711.73 | 6 | 0.0 | 3218 | 1.00 GiB | | +| `logits_gemm` | `logits_gemm_bf16_cols` | libr4d | `n_vocab=131072 n_embd=4096 dtype=bf16 M=1` | 1704.05 | - | 1703.69 | 1709.53 | 6 | 0.2 | 3419 | 1.00 GiB | | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=256` | - | 1614.76 | 1534.86 | 1973.85 | 20 | 5.1 | - | 258.94 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=20480 K=5120 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | 1541.14 | - | 1525.01 | 1546.53 | 6 | 0.7 | 3416 | 203.12 MiB | | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=256` | - | 1463.49 | 1435.00 | 1501.98 | 20 | 1.5 | - | 258.94 KiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=8` | - | 1318.63 | 1293.13 | 1346.26 | 20 | 1.1 | - | 291.25 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=20480 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | 1180.11 | - | 1179.05 | 1187.72 | 6 | 0.4 | 3419 | 201.66 MiB | | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | 1173.08 | - | 1101.77 | 1207.21 | 20 | 2.3 | 2828 | 38.19 MiB | | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=8` | - | 1150.74 | 1104.54 | 4207.23 | 20 | 131.2 | - | 233.00 KiB | 32 thread(s) | +| `gated_quant_fp8` | `ref_gated_quant_fp8` | libref | `n=17408 group=128 dtype=bf16 act=silu M=2` | - | 1073.64 | 1008.53 | 4102.47 | 20 | 4.1 | - | 239.06 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | `N=20480 K=5120 dtype=bf16 M=512 tile=0` | 1048.64 | - | 996.36 | 1070.88 | 20 | 1.1 | 2635 | 225.00 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=4096 K=20480 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | 996.40 | - | 991.70 | 999.68 | 6 | 0.4 | 3378 | 163.00 MiB | | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=6144 group=128 dtype=bf16 M=8` | - | 962.00 | 888.54 | 5947.54 | 20 | 157.9 | - | 145.50 KiB | 32 thread(s) | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=128` | - | 944.03 | 940.59 | 947.81 | 6 | 0.4 | - | 162.19 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=512` | 937.77 | - | 899.20 | 952.08 | 20 | 1.7 | 2260 | 206.60 MiB | | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=5120 group=128 dtype=bf16 M=8` | - | 933.26 | 707.99 | 953.65 | 20 | 10.8 | - | 121.25 KiB | 32 thread(s) | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=260` | 919.02 | - | 880.50 | 943.68 | 20 | 1.8 | 3131 | 20.07 MiB | | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | `N=4096 K=20480 dtype=bf16 M=512 tile=0` | 901.85 | - | 886.74 | 922.16 | 20 | 1.4 | 2664 | 184.00 MiB | | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=128` | - | 890.15 | 876.96 | 891.65 | 6 | 0.8 | - | 162.19 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=25600 group=128 dtype=bf16 M=2` | - | 876.16 | 866.61 | 881.15 | 6 | 0.8 | - | 151.56 KiB | 32 thread(s) | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=130` | 858.34 | - | 844.16 | 884.76 | 20 | 1.9 | 3338 | 18.04 MiB | | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=32` | 855.32 | - | 834.72 | 868.02 | 20 | 1.2 | 3390 | 16.50 MiB | | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=10` | 853.86 | - | 840.58 | 855.98 | 6 | 0.9 | 3394 | 16.16 MiB | | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=64` | 845.01 | - | 835.44 | 857.40 | 16 | 0.8 | 3394 | 17.00 MiB | | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=33` | 844.75 | - | 839.04 | 853.50 | 6 | 0.9 | 3390 | 16.52 MiB | | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=9` | 842.66 | - | 840.14 | 850.48 | 6 | 0.6 | 3390 | 16.14 MiB | | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=65` | 842.33 | - | 836.38 | 857.76 | 16 | 1.0 | 3402 | 17.02 MiB | | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=17` | 841.27 | - | 833.34 | 848.98 | 6 | 0.9 | 3419 | 16.27 MiB | | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=11` | 840.15 | - | 835.82 | 849.62 | 6 | 0.8 | 3384 | 16.18 MiB | | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=24576 group=128 dtype=bf16 M=2` | - | 839.53 | 822.80 | 847.38 | 14 | 0.4 | - | 145.50 KiB | 32 thread(s) | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=16` | 839.44 | - | 833.56 | 860.36 | 20 | 1.1 | 3395 | 16.25 MiB | | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=12288 group=128 dtype=bf16 M=4` | - | 838.33 | 829.62 | 848.53 | 14 | 0.8 | - | 145.50 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=20480 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | 817.60 | - | 815.48 | 821.62 | 6 | 0.4 | 3424 | 200.83 MiB | | +| `ple_conv_bias` | `ref_ple_conv_bias` | libref | `n=10240 width=4 dilation=1 dtype=bf16 M=1` | - | 798.27 | 777.69 | 810.00 | 14 | 1.0 | - | 220.02 KiB | 32 thread(s) | +| `gated_quant_fp8` | `ref_gated_quant_fp8` | libref | `n=17408 group=128 dtype=bf16 act=silu M=1` | - | 798.14 | 772.94 | 810.04 | 20 | 1.2 | - | 119.53 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=16` | - | 777.74 | 764.54 | 793.85 | 16 | 0.9 | - | 108.12 KiB | 32 thread(s) | +| `gdn_conv_update` | `ref_gdn_conv_update` | libref | `head_k=128 head_v=128 conv_width=4 q_len=1` | - | 770.22 | 751.17 | 786.03 | 14 | 1.0 | - | 180.02 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=5376 group=128 dtype=bf16 M=8` | - | 766.75 | 732.19 | 783.01 | 20 | 1.7 | - | 127.31 KiB | 32 thread(s) | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=128` | - | 765.75 | 762.10 | 770.37 | 6 | 0.5 | - | 129.94 KiB | 32 thread(s) | +| `lili_walk` | `avx_lili_walk` | libavx | `steps=7 k=8 n=1024 dtype=bf16 eps=0.0001 scale=8 M=1` | - | 754.56 | 747.45 | 3133.98 | 16 | 0.9 | - | 228.00 KiB | 32 thread(s) | +| `gdn_gated_rmsnorm` | `ref_gdn_gated_rmsnorm` | libref | `channels=128 eps=1e-06 act=silu M=256` | - | 742.94 | 681.66 | 975.25 | 20 | 6.0 | - | 192.50 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=1024 group=128 dtype=bf16 M=32` | - | 732.71 | 699.61 | 765.83 | 20 | 2.0 | - | 97.00 KiB | 32 thread(s) | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=128` | - | 727.90 | 714.08 | 746.79 | 16 | 0.9 | - | 129.94 KiB | 32 thread(s) | +| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=128` | - | 722.53 | 684.82 | 6747.68 | 20 | 415.4 | - | 80.01 KiB | 32 thread(s) | +| `silu_mul` | `ref_silu_mul` | libref | `n=12288 dtype=bf16 M=4` | - | 712.63 | 694.58 | 764.71 | 20 | 1.7 | - | 288.00 KiB | 32 thread(s) | +| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=128` | - | 711.38 | 677.48 | 1116.04 | 20 | 6.3 | - | 72.01 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | `N=20480 K=5120 dtype=bf16 M=260 tile=0` | 709.23 | - | 697.39 | 748.50 | 20 | 2.1 | 2892 | 212.70 MiB | | +| `act_mul` | `ref_act_mul` | libref | `n=8192 act=silu dtype=bf16 M=4` | - | 702.81 | 658.78 | 781.74 | 20 | 7.8 | - | 192.00 KiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=5376 act=relu dtype=bf16 M=8` | - | 694.74 | 452.64 | 737.79 | 20 | 19.5 | - | 252.00 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=32` | - | 692.37 | 413.86 | 5751.69 | 20 | 21.0 | - | 64.12 KiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=4` | - | 687.79 | 594.79 | 710.46 | 20 | 3.4 | - | 120.50 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=4096 K=20480 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | 686.97 | - | 684.34 | 689.86 | 6 | 0.4 | 3374 | 161.59 MiB | | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | 686.64 | - | 658.04 | 702.58 | 20 | 1.7 | 2972 | 35.10 MiB | | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=8192 group=128 dtype=bf16 M=4` | - | 680.23 | 633.46 | 723.20 | 20 | 3.6 | - | 97.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_mxfp4a8_tiled` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=512 tn=0` | 675.45 | - | 658.62 | 688.66 | 20 | 1.6 | 2614 | 88.20 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=258` | 671.67 | - | 647.16 | 687.56 | 20 | 1.4 | 2407 | 188.45 MiB | | +| `act_mul` | `ref_act_mul` | libref | `n=20480 act=relu dtype=bf16 M=2` | - | 668.87 | 654.38 | 687.12 | 19 | 0.9 | - | 240.00 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | `N=4096 K=20480 dtype=bf16 M=260 tile=0` | 639.27 | - | 603.18 | 646.72 | 20 | 2.1 | 2818 | 172.19 MiB | | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=33` | - | 633.88 | 618.52 | 1117.37 | 20 | 20.2 | - | 576.02 KiB | 32 thread(s) | +| `layernorm` | `ref_layernorm` | libref | `n=1280 eps=1e-06 dtype=bf16 M=32` | - | 628.20 | 602.41 | 664.40 | 20 | 2.5 | - | 165.00 KiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=4` | - | 622.62 | 612.20 | 633.40 | 14 | 1.0 | - | 150.62 KiB | 32 thread(s) | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=64` | - | 612.70 | 574.53 | 635.80 | 20 | 2.1 | - | 65.44 KiB | 32 thread(s) | +| `attn_paged` | `avx_attn_paged` | libavx | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=32` | - | 605.64 | 579.75 | 619.11 | 20 | 1.2 | - | 544.01 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=8` | - | 605.04 | 549.17 | 669.44 | 20 | 7.7 | - | 64.03 KiB | 32 thread(s) | +| `layernorm` | `ref_layernorm` | libref | `n=1152 eps=1e-06 dtype=bf16 M=32` | - | 603.63 | 559.92 | 643.52 | 20 | 4.9 | - | 148.50 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=17408 group=128 dtype=bf16 M=2` | - | 594.02 | 582.89 | 606.58 | 20 | 1.0 | - | 103.06 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=4096 group=128 dtype=bf16 M=8` | - | 590.27 | 560.44 | 621.64 | 20 | 2.8 | - | 97.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=6144 group=128 dtype=bf16 M=4` | - | 581.65 | 552.32 | 3625.29 | 20 | 3.0 | - | 72.75 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=8` | - | 571.83 | 554.32 | 580.39 | 20 | 1.4 | - | 170.00 KiB | 32 thread(s) | +| `sample_typical` | `sample_typical_f32` | libr4d | `n_cand=1024 M=64` | 549.94 | - | 521.96 | 551.06 | 31 | 1.4 | 3432 | 518.00 KiB | restore 1% | +| `act_mul` | `ref_act_mul` | libref | `n=1536 act=relu dtype=bf16 M=32` | - | 543.83 | 520.51 | 557.84 | 20 | 2.3 | - | 288.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=12288 group=128 dtype=bf16 M=2` | - | 542.58 | 524.92 | 553.27 | 20 | 2.0 | - | 72.75 KiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=2048 act=relu dtype=bf16 M=16` | - | 533.00 | 466.13 | 551.27 | 20 | 2.1 | - | 192.00 KiB | 32 thread(s) | +| `sample_typical` | `sample_typical_f32` | libr4d | `n_cand=1024 M=32` | 523.92 | - | 522.44 | 524.92 | 12 | 0.2 | 3437 | 259.00 KiB | restore 1% | +| `sample_typical` | `sample_typical_f32` | libr4d | `n_cand=1024 M=16` | 522.18 | - | 513.12 | 523.96 | 12 | 1.0 | 3437 | 129.50 KiB | restore 1% | +| `sample_typical` | `sample_typical_f32` | libr4d | `n_cand=1024 M=8` | 521.79 | - | 505.78 | 524.28 | 31 | 1.1 | 3439 | 64.75 KiB | restore 1% | +| `sample_typical` | `sample_typical_f32` | libr4d | `n_cand=1024 M=4` | 521.54 | - | 505.10 | 524.37 | 26 | 1.2 | 3438 | 32.38 KiB | restore 1% | +| `sample_typical` | `sample_typical_f32` | libr4d | `n_cand=1024 M=1` | 520.95 | - | 505.36 | 521.88 | 20 | 0.9 | 3439 | 8.09 KiB | restore 1% | +| `sample_typical` | `sample_typical_f32` | libr4d | `n_cand=1024 M=2` | 520.56 | - | 499.24 | 524.46 | 34 | 1.4 | 3440 | 16.19 KiB | restore 1% | +| `quant_act_i8` | `ref_quant_act_i8` | libref | `n=5120 group=128 dtype=bf16 M=8` | - | 514.21 | 500.67 | 533.70 | 20 | 1.9 | - | 122.53 KiB | 32 thread(s) | +| `gdn_conv_update` | `gdn_conv_update_w4_h128_bf16` | libr4d | `head_k=128 head_v=128 conv_width=4 q_len=512` | 513.21 | - | 511.58 | 518.00 | 6 | 0.6 | 3266 | 30.12 MiB | restore 4% | +| `act_mul` | `ref_act_mul` | libref | `n=8192 act=silu dtype=bf16 M=2` | - | 507.75 | 487.99 | 529.95 | 20 | 2.4 | - | 96.00 KiB | 32 thread(s) | +| `silu_mul` | `ref_silu_mul` | libref | `n=17408 dtype=bf16 M=2` | - | 500.55 | 492.39 | 519.70 | 20 | 1.9 | - | 204.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4096 K=24576 group=128 dtype=fp8a8 M=512` | 498.46 | - | 480.59 | 506.58 | 16 | 0.9 | 2637 | 112.39 MiB | | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | `N=20480 K=5120 dtype=bf16 M=130 tile=0` | 494.43 | - | 451.30 | 507.39 | 20 | 3.5 | 2878 | 206.35 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_tiled` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=258 tn=0` | 494.33 | - | 469.59 | 499.19 | 20 | 1.2 | 2692 | 79.33 MiB | | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=64` | - | 468.10 | 461.00 | 482.06 | 20 | 2.1 | - | 81.69 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=128` | - | 464.04 | 452.74 | 632.53 | 20 | 3.1 | - | 64.50 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=25600 group=128 dtype=bf16 M=1` | - | 453.51 | 446.19 | 467.57 | 14 | 0.9 | - | 75.78 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=512` | 435.95 | - | 420.93 | 445.11 | 20 | 1.7 | 2574 | 98.78 MiB | | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=64` | - | 435.62 | 433.65 | 452.92 | 20 | 1.7 | - | 81.69 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=129` | 434.46 | - | 383.30 | 445.74 | 20 | 3.7 | 2438 | 179.24 MiB | | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=24576 group=128 dtype=bf16 M=1` | - | 428.54 | 413.38 | 451.29 | 20 | 2.5 | - | 72.75 KiB | 32 thread(s) | +| `kv_store` | `ref_kv_store` | libref | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=16` | - | 425.46 | 406.10 | 522.91 | 20 | 13.3 | - | 160.06 KiB | 32 thread(s) | +| `grid_embed` | `ref_grid_embed` | libref | `n=1152 side=48 dtype=bf16 M=8` | - | 421.96 | 406.99 | 431.25 | 14 | 0.7 | - | 5.08 MiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | `N=4096 K=20480 dtype=bf16 M=130 tile=0` | 418.18 | - | 403.20 | 428.88 | 16 | 0.8 | 3125 | 166.09 MiB | | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | 417.93 | - | 407.44 | 432.75 | 20 | 1.2 | 3034 | 33.55 MiB | | +| `kv_store` | `ref_kv_store` | libref | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=16` | - | 415.47 | 405.56 | 438.22 | 20 | 3.1 | - | 160.06 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-05 dtype=bf16 M=8` | - | 414.64 | 398.97 | 430.05 | 19 | 1.0 | - | 170.00 KiB | 32 thread(s) | +| `cast` | `ref_cast` | libref | `n=5120 from=bf16 to=bf16 M=8` | - | 413.65 | 390.75 | 3464.22 | 20 | 15.2 | - | 160.00 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=8` | - | 411.92 | 400.71 | 433.82 | 20 | 2.9 | - | 64.03 KiB | 32 thread(s) | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=64` | - | 405.80 | 399.44 | 430.41 | 20 | 2.0 | - | 65.44 KiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=2304 act=relu dtype=bf16 M=16` | - | 405.53 | 381.79 | 468.59 | 20 | 5.4 | - | 216.00 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=8` | - | 399.67 | 392.96 | 417.70 | 20 | 2.6 | - | 170.00 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=8` | - | 394.89 | 382.17 | 440.20 | 20 | 2.1 | - | 54.06 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=5376 group=128 dtype=bf16 M=4` | - | 394.78 | 385.32 | 420.93 | 20 | 3.4 | - | 63.66 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | `N=20480 K=5120 dtype=bf16 M=65 tile=0` | 394.09 | - | 391.84 | 394.92 | 6 | 0.4 | 3384 | 203.17 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=20480 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | 391.81 | - | 391.18 | 392.43 | 6 | 0.2 | 3428 | 200.78 MiB | | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=8192 group=128 dtype=bf16 M=2` | - | 390.49 | 375.24 | 1437.21 | 20 | 4.4 | - | 48.50 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=512` | 388.23 | - | 374.40 | 393.32 | 16 | 1.0 | 2772 | 98.59 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=20480 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | 383.47 | - | 381.59 | 384.19 | 6 | 0.3 | 3428 | 200.39 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=20480 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | 375.41 | - | 374.35 | 375.93 | 6 | 0.2 | 3434 | 200.20 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=20480 K=5120 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | 371.01 | - | 370.27 | 371.77 | 6 | 0.2 | 3434 | 200.10 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=20480 K=5120 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | 369.14 | - | 368.34 | 370.16 | 6 | 0.2 | 3432 | 200.05 MiB | | +| `silu_mul` | `ref_silu_mul` | libref | `n=12288 dtype=bf16 M=2` | - | 361.23 | 347.57 | 383.31 | 20 | 3.2 | - | 144.00 KiB | 32 thread(s) | +| `grid_embed_cpe` | `avx_grid_embed_cpe` | libavx | `n=1280 side=128 n_prefix=10 dtype=bf16 M=8` | - | 357.99 | 350.64 | 373.58 | 20 | 2.4 | - | 40.04 MiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4096 K=24576 group=128 dtype=fp8a8 M=258` | 357.13 | - | 342.85 | 367.38 | 20 | 1.9 | 2892 | 104.26 MiB | | +| `layernorm` | `ref_layernorm` | libref | `n=1280 eps=1e-06 dtype=bf16 M=16` | - | 351.53 | 343.63 | 356.76 | 20 | 1.8 | - | 85.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=5120 group=128 dtype=bf16 M=4` | - | 351.12 | 341.19 | 393.00 | 20 | 2.7 | - | 60.62 KiB | 32 thread(s) | +| `grid_embed_cpe` | `ref_grid_embed_cpe` | libref | `n=1280 side=128 n_prefix=10 dtype=bf16 M=8` | - | 351.05 | 315.84 | 378.08 | 20 | 4.9 | - | 40.04 MiB | 32 thread(s) | +| `add` | `ref_add` | libref | `n=5120 dtype=bf16 M=8` | - | 348.38 | 274.41 | 390.88 | 20 | 9.9 | - | 240.00 KiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=2` | - | 347.00 | 335.41 | 353.41 | 20 | 1.8 | - | 64.25 KiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=5376 act=relu dtype=bf16 M=4` | - | 346.43 | 340.66 | 374.76 | 20 | 3.6 | - | 126.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=4096 group=128 dtype=bf16 M=4` | - | 346.38 | 287.01 | 398.63 | 20 | 12.7 | - | 48.50 KiB | 32 thread(s) | +| `moe_gather` | `ref_moe_gather` | libref | `n=1024 top_k=9 dtype=bf16 act=none M=4` | - | 341.76 | 323.82 | 1356.70 | 20 | 3.1 | - | 88.22 KiB | 32 thread(s) | +| `gdn_gated_rmsnorm` | `ref_gdn_gated_rmsnorm` | libref | `channels=128 eps=1e-06 act=silu M=128` | - | 341.42 | 334.53 | 352.18 | 20 | 1.8 | - | 96.50 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | `N=4096 K=20480 dtype=bf16 M=65 tile=0` | 333.49 | - | 319.52 | 341.22 | 20 | 1.8 | 3364 | 163.05 MiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=256` | - | 331.52 | 321.77 | 351.72 | 20 | 2.8 | - | 128.25 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=128` | - | 327.36 | 316.73 | 371.50 | 20 | 5.8 | - | 128.50 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=258` | 326.20 | - | 324.43 | 330.92 | 6 | 1.0 | 2777 | 91.95 MiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=8` | - | 318.32 | 314.51 | 328.81 | 20 | 1.7 | - | 136.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=17408 group=128 dtype=bf16 M=1` | - | 317.60 | 309.44 | 328.39 | 20 | 1.8 | - | 51.53 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=128` | 316.46 | - | 314.55 | 320.03 | 6 | 0.9 | 3171 | 179.17 MiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=1024 eps=1e-06 dtype=bf16 M=32` | - | 315.74 | 314.95 | 342.55 | 20 | 2.8 | - | 130.00 KiB | 32 thread(s) | +| `layernorm` | `ref_layernorm` | libref | `n=1152 eps=1e-06 dtype=bf16 M=16` | - | 315.49 | 294.92 | 360.65 | 20 | 7.4 | - | 76.50 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=4096 eps=1e-05 dtype=bf16 M=8` | - | 314.89 | 314.47 | 329.11 | 20 | 2.2 | - | 136.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=64` | 312.34 | - | 306.74 | 318.27 | 14 | 0.9 | 3254 | 174.59 MiB | | +| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=64` | 311.51 | - | 302.35 | 313.34 | 14 | 0.9 | 3201 | 173.56 MiB | | +| `kv_store` | `ref_kv_store` | libref | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=8` | - | 309.75 | 299.21 | 339.14 | 20 | 3.6 | - | 128.03 KiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=2` | - | 307.43 | 298.52 | 328.95 | 20 | 1.7 | - | 80.31 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=4096 K=20480 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | 305.97 | - | 304.78 | 309.69 | 6 | 0.8 | 3378 | 160.80 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=36` | 305.96 | - | 304.49 | 307.93 | 6 | 0.6 | 3284 | 172.59 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=65` | 304.92 | - | 304.50 | 307.26 | 11 | 0.4 | 3195 | 174.66 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=512` | 300.35 | - | 288.45 | 304.99 | 20 | 1.4 | 2606 | 74.59 MiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=1024 eps=1e-05 dtype=bf16 M=32` | - | 296.17 | 285.97 | 320.26 | 20 | 1.6 | - | 128.00 KiB | 32 thread(s) | +| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=32` | 295.75 | - | 293.11 | 297.93 | 6 | 0.8 | 3232 | 171.79 MiB | | +| `act_mul` | `ref_act_mul` | libref | `n=8192 act=silu dtype=bf16 M=1` | - | 295.29 | 281.93 | 299.64 | 20 | 2.2 | - | 48.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=18` | 293.93 | - | 293.62 | 299.24 | 6 | 1.0 | 3298 | 171.31 MiB | | +| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=16` | 293.77 | - | 293.16 | 294.19 | 6 | 0.2 | 3244 | 170.91 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=9` | 292.97 | - | 291.50 | 293.89 | 6 | 0.4 | 3306 | 170.66 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=8` | 292.12 | - | 291.31 | 294.11 | 6 | 0.5 | 3300 | 170.59 MiB | | +| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=8` | 291.02 | - | 289.90 | 291.22 | 6 | 0.2 | 3244 | 170.46 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=4` | 290.42 | - | 289.90 | 294.98 | 6 | 0.9 | 3311 | 170.31 MiB | | +| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=4` | 289.12 | - | 288.39 | 290.18 | 11 | 0.2 | 3247 | 170.24 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=2` | 288.76 | - | 288.56 | 289.25 | 6 | 0.1 | 3322 | 170.16 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=258` | 288.70 | - | 277.10 | 296.43 | 20 | 2.4 | 2725 | 89.37 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 M=1` | 287.90 | - | 287.01 | 288.13 | 6 | 0.2 | 3315 | 170.09 MiB | | +| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=2` | 287.86 | - | 287.44 | 291.84 | 6 | 0.8 | 3243 | 170.13 MiB | | +| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | `N=34816 K=5120 group=128 dtype=fp8a8 act=silu M=1` | 287.25 | - | 287.20 | 287.83 | 6 | 0.1 | 3242 | 170.08 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=4096 K=20480 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | 279.09 | - | 278.67 | 279.80 | 6 | 0.2 | 3374 | 160.75 MiB | | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=1024 group=128 dtype=bf16 M=16` | - | 277.61 | 270.89 | 298.50 | 20 | 3.4 | - | 48.50 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=4096 K=20480 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | 277.06 | - | 276.39 | 277.19 | 6 | 0.1 | 3373 | 160.38 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=4096 K=20480 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | 275.81 | - | 275.66 | 276.07 | 6 | 0.1 | 3374 | 160.19 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=4096 K=20480 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | 275.41 | - | 275.29 | 276.73 | 6 | 0.3 | 3369 | 160.09 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=4096 K=20480 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | 275.11 | - | 274.84 | 275.87 | 6 | 0.2 | 3373 | 160.05 MiB | | +| `grid_embed` | `avx_grid_embed` | libavx | `n=1152 side=48 dtype=bf16 M=8` | - | 273.64 | 264.17 | 282.08 | 20 | 2.2 | - | 5.08 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=1536 act=relu dtype=bf16 M=16` | - | 273.23 | 257.08 | 364.91 | 20 | 16.1 | - | 144.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_mxfp4a8_tiled` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=129 tn=0` | 266.07 | - | 264.40 | 267.35 | 6 | 0.6 | 2991 | 74.82 MiB | | +| `quant_act_i8` | `ref_quant_act_i8` | libref | `n=5120 group=128 dtype=bf16 M=4` | - | 260.93 | 239.34 | 271.85 | 20 | 3.9 | - | 62.52 KiB | 32 thread(s) | +| `sample_xtc` | `ref_sample_xtc` | libref | `n_cand=1024 M=8` | - | 258.05 | 237.49 | 279.50 | 20 | 5.2 | - | 64.75 KiB | 32 thread(s) | +| `silu_mul` | `ref_silu_mul` | libref | `n=17408 dtype=bf16 M=1` | - | 257.76 | 251.83 | 262.26 | 20 | 1.5 | - | 102.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4096 K=24576 group=128 dtype=fp8a8 M=129` | 247.92 | - | 241.14 | 256.47 | 20 | 2.0 | 2906 | 100.14 MiB | | +| `grid_embed` | `avx_grid_embed` | libavx | `n=1152 side=48 dtype=bf16 M=4` | - | 246.40 | 236.46 | 251.66 | 20 | 2.5 | - | 5.07 MiB | 32 thread(s) | +| `dflash_select` | `ref_dflash_select` | libref | `steps=7 top_k=16 rank=256 n_vocab=248320 anchor_stride=8 dtype=bf16 M=2` | - | 244.41 | 232.29 | 252.09 | 20 | 2.2 | - | 242.51 MiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=129` | 243.77 | - | 233.38 | 247.68 | 20 | 1.5 | 2786 | 88.48 MiB | | +| `moe_gather` | `ref_moe_gather` | libref | `n=1024 top_k=9 dtype=bf16 act=none M=2` | - | 243.21 | 193.33 | 266.17 | 20 | 5.4 | - | 44.11 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=5376 group=128 dtype=bf16 M=2` | - | 242.04 | 239.30 | 260.26 | 20 | 3.2 | - | 31.83 KiB | 32 thread(s) | +| `cast` | `ref_cast` | libref | `n=4096 from=bf16 to=bf16 M=8` | - | 238.20 | 228.88 | 261.01 | 20 | 3.9 | - | 128.00 KiB | 32 thread(s) | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=512` | 237.88 | - | 231.43 | 242.07 | 20 | 1.4 | 3149 | 10.00 MiB | | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=4` | - | 237.33 | 227.63 | 274.62 | 20 | 8.3 | - | 32.02 KiB | 32 thread(s) | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=248320 k=21 M=64` | 232.52 | - | 232.21 | 233.00 | 6 | 0.2 | 3409 | 60.64 MiB | | +| `grid_embed` | `ref_grid_embed` | libref | `n=1152 side=48 dtype=bf16 M=4` | - | 231.10 | 220.19 | 243.95 | 20 | 2.4 | - | 5.07 MiB | 32 thread(s) | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=32` | - | 230.22 | 229.93 | 245.23 | 16 | 0.4 | - | 41.44 KiB | 32 thread(s) | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | 229.31 | - | 210.34 | 231.63 | 19 | 0.7 | 3079 | 32.38 MiB | | +| `gather_rows` | `ref_gather_rows` | libref | `n=4096 dtype=bf16 M=8` | - | 228.48 | 218.87 | 255.96 | 20 | 3.9 | - | 320.03 KiB | 32 thread(s) | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | 227.97 | - | 211.74 | 237.19 | 20 | 2.3 | 3124 | 32.78 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=258` | 227.61 | - | 210.90 | 236.25 | 20 | 3.0 | 2513 | 67.35 MiB | | +| `sample_topk` | `sample_topk_f32` | libr4d | `n_vocab=248320 M=64` | 227.29 | - | 224.46 | 227.83 | 6 | 0.7 | 3418 | 60.69 MiB | | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | 225.60 | - | 211.10 | 237.16 | 20 | 5.0 | 3040 | 32.75 MiB | | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=16` | - | 222.52 | 207.85 | 263.30 | 20 | 7.6 | - | 32.06 KiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=1536 act=relu dtype=bf16 M=8` | - | 222.13 | 205.78 | 238.20 | 20 | 1.3 | - | 72.00 KiB | 32 thread(s) | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=11` | 221.34 | - | 204.94 | 228.59 | 20 | 3.1 | 3128 | 32.26 MiB | | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=64` | - | 221.21 | 219.34 | 233.74 | 20 | 2.8 | - | 32.25 KiB | 32 thread(s) | +| `kv_store` | `ref_kv_store` | libref | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=8` | - | 220.82 | 211.51 | 238.17 | 20 | 2.8 | - | 128.03 KiB | 32 thread(s) | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=17` | 219.39 | - | 206.90 | 232.42 | 20 | 4.1 | 3094 | 32.40 MiB | | +| `sample_minp` | `ref_sample_minp` | libref | `n_cand=1024 M=8` | - | 218.70 | 187.48 | 237.78 | 20 | 4.8 | - | 64.75 KiB | 32 thread(s) | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=32` | - | 216.90 | 216.05 | 230.81 | 20 | 1.5 | - | 41.44 KiB | 32 thread(s) | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=32` | - | 216.41 | 193.40 | 230.43 | 20 | 4.4 | - | 33.19 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=128 ks=0 bk=0 nt=0` | 215.59 | - | 211.29 | 235.53 | 20 | 3.3 | 2948 | 74.79 MiB | | +| `add` | `ref_add` | libref | `n=4096 dtype=bf16 M=8` | - | 212.39 | 209.66 | 224.33 | 20 | 2.1 | - | 192.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=6144 group=128 dtype=bf16 M=2` | - | 211.75 | 209.59 | 225.40 | 20 | 1.9 | - | 36.38 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-05 dtype=bf16 M=4` | - | 211.46 | 210.92 | 228.90 | 20 | 3.9 | - | 90.00 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=4` | - | 211.32 | 209.21 | 221.00 | 20 | 2.3 | - | 90.00 KiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=20480 act=relu dtype=bf16 M=1` | - | 209.29 | 209.16 | 224.38 | 20 | 3.1 | - | 120.00 KiB | 32 thread(s) | +| `cast` | `ref_cast` | libref | `n=4096 from=bf16 to=bf16 M=4` | - | 206.91 | 192.28 | 1723.94 | 20 | 5.1 | - | 64.00 KiB | 32 thread(s) | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | 206.71 | - | 205.87 | 207.42 | 6 | 0.4 | 3168 | 16.00 MiB | | +| `cast` | `ref_cast` | libref | `n=5120 from=bf16 to=bf16 M=4` | - | 206.18 | 196.40 | 2246.35 | 20 | 14.7 | - | 80.00 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=32` | - | 205.42 | 182.03 | 221.10 | 20 | 3.4 | - | 64.38 KiB | 32 thread(s) | +| `mul_weight` | `ref_mul_weight` | libref | `n=8192 dtype=bf16 M=4` | - | 204.97 | 201.16 | 225.27 | 20 | 3.3 | - | 144.00 KiB | 32 thread(s) | +| `kv_store` | `ref_kv_store` | libref | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=64` | - | 204.06 | 203.60 | 218.63 | 19 | 0.6 | - | 160.25 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=129` | 202.78 | - | 190.30 | 213.62 | 20 | 2.5 | 2618 | 84.69 MiB | | +| `lili_attn` | `lili_attn_bf16` | libr4d | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=448` | 202.77 | - | 186.55 | 204.91 | 20 | 2.2 | 3437 | 3.50 MiB | | +| `add` | `ref_add` | libref | `n=5120 dtype=bf16 M=4` | - | 202.73 | 199.71 | 214.32 | 20 | 2.7 | - | 120.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=10240 K=4096 group=128 dtype=fp8a8 M=512` | 201.93 | - | 196.98 | 216.95 | 20 | 3.7 | 2802 | 52.07 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4096 K=24576 group=128 dtype=fp8a8 M=128` | 201.72 | - | 200.53 | 203.53 | 6 | 0.7 | 3287 | 100.11 MiB | | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=12288 group=128 dtype=bf16 M=1` | - | 201.48 | 199.94 | 210.92 | 20 | 2.2 | - | 36.38 KiB | 32 thread(s) | +| `lili_attn` | `lili_attn_bf16` | libr4d | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=256` | 199.76 | - | 184.97 | 204.26 | 20 | 2.2 | 3438 | 2.19 MiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=4` | - | 196.86 | 196.69 | 204.26 | 20 | 1.7 | - | 90.00 KiB | 32 thread(s) | +| `gather_rows` | `ref_gather_rows` | libref | `n=5120 dtype=bf16 M=8` | - | 195.25 | 193.39 | 202.28 | 20 | 1.8 | - | 400.03 KiB | 32 thread(s) | +| `gather_rows` | `ref_gather_rows` | libref | `n=1280 dtype=bf16 M=32` | - | 193.64 | 186.56 | 1333.72 | 20 | 3.5 | - | 400.12 KiB | 32 thread(s) | +| `scatter_rows` | `ref_scatter_rows` | libref | `n=5120 dtype=bf16 M=8` | - | 193.32 | 190.59 | 204.71 | 20 | 3.2 | - | 400.03 KiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=2304 act=relu dtype=bf16 M=8` | - | 189.87 | 188.48 | 197.75 | 20 | 2.3 | - | 108.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4096 K=24576 group=128 dtype=fp8a8 M=65` | 188.54 | - | 185.73 | 190.29 | 16 | 0.8 | 3282 | 98.09 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4608 K=4608 dtype=bf16 act=gelu M=512` | 187.69 | - | 181.99 | 195.66 | 20 | 1.6 | 2860 | 54.01 MiB | | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=5120 group=128 dtype=bf16 M=2` | - | 187.58 | 177.00 | 215.15 | 20 | 7.1 | - | 30.31 KiB | 32 thread(s) | +| `sample_pick` | `ref_sample_pick` | libref | `n_cand=1024 M=8` | - | 183.94 | 178.01 | 197.60 | 20 | 3.4 | - | 64.78 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=24576 group=128 dtype=fp8a8 M=64` | 183.51 | - | 182.91 | 184.46 | 6 | 0.4 | 3302 | 98.06 MiB | | +| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=64` | 183.09 | - | 181.50 | 183.58 | 6 | 0.6 | 3277 | 98.54 MiB | | +| `gdn_conv_update` | `gdn_conv_update_w4_h128_bf16` | libr4d | `head_k=128 head_v=128 conv_width=4 q_len=256` | 182.58 | - | 181.49 | 183.00 | 6 | 0.4 | 3269 | 15.12 MiB | restore 5% | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=32` | - | 182.08 | 175.19 | 188.32 | 20 | 3.2 | - | 33.19 KiB | 32 thread(s) | +| `grid_embed_cpe` | `avx_grid_embed_cpe` | libavx | `n=1280 side=128 n_prefix=10 dtype=bf16 M=4` | - | 180.22 | 163.09 | 189.18 | 20 | 1.2 | - | 40.03 MiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=2048 act=relu dtype=bf16 M=8` | - | 179.93 | 174.09 | 189.45 | 20 | 3.1 | - | 96.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=24576 K=4096 group=128 dtype=fp8a8 M=64` | 179.90 | - | 178.71 | 180.74 | 6 | 0.6 | 3283 | 99.27 MiB | | +| `row_topk` | `rowtopk_bf16` | libr4d | `N=248320 R=32 dtype=bf16 M=56 nch=0 pt1=8` | 179.57 | - | 179.34 | 180.03 | 6 | 0.2 | 3410 | 26.55 MiB | | +| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=64` | - | 179.41 | 174.31 | 191.04 | 20 | 3.1 | - | 40.01 KiB | 32 thread(s) | +| `lili_attn` | `lili_attn_bf16` | libr4d | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=64` | 177.15 | - | 172.85 | 191.73 | 19 | 0.8 | 3439 | 896.50 KiB | | +| `silu_mul` | `ref_silu_mul` | libref | `n=12288 dtype=bf16 M=1` | - | 177.11 | 174.00 | 182.00 | 20 | 2.0 | - | 72.00 KiB | 32 thread(s) | +| `lili_attn` | `lili_attn_bf16` | libr4d | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=128` | 177.09 | - | 173.46 | 181.24 | 14 | 0.2 | 3438 | 1.31 MiB | | +| `lili_attn` | `lili_attn_bf16` | libr4d | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=4` | 177.08 | - | 172.73 | 191.23 | 20 | 2.1 | 3440 | 448.50 KiB | | +| `lili_attn` | `lili_attn_bf16` | libr4d | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=16` | 177.08 | - | 172.85 | 191.13 | 20 | 2.0 | 3439 | 448.50 KiB | | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | `N=304 K=4096 dtype=bf16 M=512` | 177.02 | - | 176.87 | 178.35 | 6 | 0.4 | 3076 | 9.34 MiB | | +| `lili_attn` | `lili_attn_bf16` | libr4d | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=2` | 177.02 | - | 172.57 | 180.86 | 16 | 0.7 | 3439 | 448.50 KiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | 177.00 | - | 173.97 | 186.16 | 20 | 2.7 | 2862 | 100.20 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=24576 K=4096 group=128 dtype=fp8a8 M=32` | 176.99 | - | 176.23 | 178.33 | 6 | 0.6 | 3306 | 97.64 MiB | | +| `lili_attn` | `lili_attn_bf16` | libr4d | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=32` | 176.89 | - | 174.16 | 177.07 | 6 | 0.8 | 3440 | 448.50 KiB | | +| `lili_attn` | `lili_attn_bf16` | libr4d | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=8` | 176.87 | - | 173.43 | 178.15 | 20 | 1.0 | 3440 | 448.50 KiB | | +| `lili_attn` | `lili_attn_bf16` | libr4d | `steps=7 k=8 n_head=8 head_dim=128 dtype=bf16 M=1` | 176.77 | - | 172.65 | 184.34 | 20 | 1.3 | 3440 | 448.50 KiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=24576 K=4096 group=128 dtype=fp8a8 M=33` | 175.86 | - | 175.13 | 177.00 | 11 | 0.5 | 3293 | 97.69 MiB | | +| `gdn_gated_rmsnorm` | `ref_gdn_gated_rmsnorm` | libref | `channels=128 eps=1e-06 act=silu M=64` | - | 175.36 | 170.59 | 178.97 | 20 | 1.6 | - | 48.50 KiB | 32 thread(s) | +| `embed_lookup` | `ref_embed_lookup` | libref | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=8` | - | 175.19 | 172.01 | 3179.34 | 16 | 0.9 | - | 2.37 GiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=4608 dtype=bf16 act=none M=512` | 174.98 | - | 171.44 | 193.00 | 20 | 1.8 | 2924 | 59.51 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=24576 K=4096 group=128 dtype=fp8a8 M=18` | 174.64 | - | 173.35 | 176.47 | 6 | 0.9 | 3308 | 96.93 MiB | | +| `layernorm` | `ref_layernorm` | libref | `n=1280 eps=1e-06 dtype=bf16 M=8` | - | 173.43 | 159.14 | 188.81 | 20 | 5.5 | - | 45.00 KiB | 32 thread(s) | +| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=32` | 172.85 | - | 172.31 | 173.43 | 6 | 0.3 | 3293 | 97.28 MiB | | +| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=16` | 172.00 | - | 171.75 | 172.37 | 6 | 0.2 | 3290 | 96.64 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=24576 group=128 dtype=fp8a8 M=33` | 171.80 | - | 171.69 | 172.19 | 6 | 0.1 | 3314 | 97.07 MiB | | +| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=8` | 170.45 | - | 170.32 | 170.61 | 6 | 0.1 | 3296 | 96.33 MiB | | +| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=64` | - | 170.35 | 165.97 | 174.32 | 20 | 1.5 | - | 36.01 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=24576 K=4096 group=128 dtype=fp8a8 M=9` | 169.85 | - | 169.56 | 170.56 | 11 | 0.3 | 3318 | 96.47 MiB | | +| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=4` | 169.56 | - | 169.21 | 170.44 | 11 | 0.3 | 3292 | 96.17 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=24576 K=4096 group=128 dtype=fp8a8 M=8` | 169.10 | - | 169.02 | 169.29 | 6 | 0.1 | 3318 | 96.42 MiB | | +| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=2` | 168.83 | - | 168.71 | 168.99 | 6 | 0.1 | 3294 | 96.09 MiB | | +| `gemm_nt_q_gated` | `gemm_fp8a8_gated_nt_m16` | libr4d | `N=24576 K=4096 group=128 dtype=fp8a8 act=silu M=1` | 168.79 | - | 168.51 | 168.91 | 6 | 0.1 | 3302 | 96.05 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=128` | 168.50 | - | 166.75 | 169.00 | 6 | 0.7 | 3274 | 84.65 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=24576 K=4096 group=128 dtype=fp8a8 M=4` | 168.19 | - | 167.95 | 168.46 | 6 | 0.2 | 3424 | 96.22 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4096 K=8192 group=128 dtype=fp8a8 M=512` | 168.07 | - | 161.75 | 178.17 | 20 | 3.5 | 2848 | 40.13 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=128` | 167.99 | - | 166.88 | 168.97 | 6 | 0.6 | 3202 | 88.45 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=24576 K=4096 group=128 dtype=fp8a8 M=2` | 167.70 | - | 167.49 | 167.83 | 6 | 0.1 | 3424 | 96.11 MiB | | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | 167.69 | - | 166.01 | 168.59 | 6 | 0.8 | 3199 | 10.19 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=24576 K=4096 group=128 dtype=fp8a8 M=1` | 167.61 | - | 167.46 | 167.73 | 6 | 0.1 | 3426 | 96.06 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=512` | 166.57 | - | 150.83 | 171.67 | 20 | 3.0 | 2822 | 38.10 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=24576 group=128 dtype=fp8a8 M=32` | 164.46 | - | 164.37 | 164.68 | 6 | 0.1 | 3312 | 97.04 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=8192 K=4096 group=128 dtype=fp8a8 M=512` | 164.39 | - | 158.29 | 167.57 | 20 | 1.4 | 2812 | 42.07 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=65` | 164.29 | - | 163.45 | 165.38 | 6 | 0.6 | 3193 | 86.76 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=24576 group=128 dtype=fp8a8 M=18` | 163.45 | - | 163.28 | 163.52 | 6 | 0.1 | 3305 | 96.59 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | 163.04 | - | 162.75 | 163.74 | 6 | 0.3 | 3226 | 98.20 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=24576 group=128 dtype=fp8a8 M=9` | 162.84 | - | 162.63 | 162.97 | 6 | 0.1 | 3308 | 96.30 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=24576 group=128 dtype=fp8a8 M=8` | 162.43 | - | 162.33 | 163.17 | 6 | 0.3 | 3300 | 96.27 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=24576 group=128 dtype=fp8a8 M=4` | 162.20 | - | 162.14 | 162.37 | 6 | 0.1 | 3302 | 96.14 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=24576 group=128 dtype=fp8a8 M=2` | 162.07 | - | 161.98 | 162.13 | 6 | 0.0 | 3301 | 96.08 MiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=64` | - | 161.79 | 158.56 | 163.35 | 20 | 1.3 | - | 64.50 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=65` | 161.76 | - | 158.98 | 163.15 | 14 | 1.0 | 3256 | 82.37 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=24576 group=128 dtype=fp8a8 M=1` | 161.64 | - | 161.60 | 161.72 | 6 | 0.0 | 3294 | 96.04 MiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=1024 eps=1e-06 dtype=bf16 M=16` | - | 160.32 | 157.66 | 163.11 | 20 | 1.4 | - | 66.00 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=128` | - | 160.13 | 160.00 | 167.76 | 20 | 2.1 | - | 64.25 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=8` | - | 159.77 | 158.84 | 181.15 | 20 | 3.0 | - | 96.09 KiB | 32 thread(s) | +| `layernorm` | `ref_layernorm` | libref | `n=1152 eps=1e-06 dtype=bf16 M=8` | - | 159.58 | 154.96 | 162.57 | 20 | 1.1 | - | 40.50 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=4` | - | 158.87 | 157.42 | 164.62 | 20 | 1.5 | - | 72.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=64` | 157.74 | - | 157.60 | 158.27 | 6 | 0.2 | 3240 | 86.73 MiB | | +| `sample_topp` | `ref_sample_topp` | libref | `n_cand=1024 M=8` | - | 157.65 | 156.16 | 175.73 | 20 | 4.1 | - | 64.75 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=4096 eps=1e-05 dtype=bf16 M=4` | - | 157.61 | 157.43 | 163.90 | 20 | 2.0 | - | 72.00 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=4` | - | 157.21 | 145.74 | 179.13 | 20 | 7.1 | - | 32.02 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | 156.11 | - | 156.03 | 156.32 | 6 | 0.1 | 3366 | 96.91 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=10240 K=4096 group=128 dtype=fp8a8 M=258` | 154.97 | - | 150.03 | 180.54 | 20 | 8.4 | 2848 | 46.08 MiB | | +| `grid_embed_cpe` | `ref_grid_embed_cpe` | libref | `n=1280 side=128 n_prefix=10 dtype=bf16 M=4` | - | 154.91 | 150.46 | 166.25 | 20 | 4.1 | - | 40.03 MiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=36` | 154.68 | - | 154.51 | 155.15 | 6 | 0.2 | 3254 | 85.98 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=65 ks=0 bk=0 nt=0` | 153.85 | - | 153.07 | 154.08 | 6 | 0.3 | 3166 | 72.58 MiB | | +| `mul_weight` | `ref_mul_weight` | libref | `n=8192 dtype=bf16 M=2` | - | 153.35 | 137.43 | 159.54 | 20 | 2.6 | - | 80.00 KiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=1` | - | 152.36 | 150.40 | 167.81 | 20 | 3.4 | - | 45.16 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-05 dtype=bf16 M=2` | - | 151.42 | 146.72 | 158.70 | 20 | 3.1 | - | 50.00 KiB | 32 thread(s) | +| `rope_table` | `ref_rope_table` | libref | `rot=64 theta=1e+07 scale=1 dtype=f32 M=64` | - | 151.22 | 143.55 | 155.70 | 20 | 2.6 | - | 16.25 KiB | 32 thread(s) | +| `scatter_rows` | `ref_scatter_rows` | libref | `n=4096 dtype=bf16 M=8` | - | 151.00 | 148.22 | 169.08 | 20 | 4.2 | - | 320.03 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | 150.96 | - | 150.77 | 151.23 | 6 | 0.2 | 3410 | 96.27 MiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=2` | - | 150.93 | 148.63 | 163.25 | 20 | 2.9 | - | 50.00 KiB | 32 thread(s) | +| `ple_conv_bias` | `ple_conv_bias_bf16` | libr4d | `n=10240 width=4 dilation=1 dtype=bf16 M=512` | 150.67 | - | 150.19 | 151.76 | 6 | 0.5 | 3372 | 40.14 MiB | restore 10% | +| `kv_store` | `ref_kv_store` | libref | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=4` | - | 150.58 | 148.47 | 162.35 | 20 | 2.9 | - | 112.02 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | 150.46 | - | 150.29 | 150.77 | 6 | 0.2 | 3411 | 96.20 MiB | | +| `gather_rows` | `ref_gather_rows` | libref | `n=5120 dtype=bf16 M=4` | - | 149.68 | 140.00 | 162.52 | 20 | 3.6 | - | 200.02 KiB | 32 thread(s) | +| `scatter_rows` | `ref_scatter_rows` | libref | `n=5120 dtype=bf16 M=4` | - | 148.02 | 146.74 | 159.11 | 20 | 2.5 | - | 200.02 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | 147.99 | - | 147.93 | 148.58 | 6 | 0.2 | 3414 | 95.91 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=129` | 147.65 | - | 140.80 | 157.30 | 20 | 4.4 | 2903 | 63.68 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | 147.52 | - | 147.27 | 147.96 | 6 | 0.2 | 3045 | 72.55 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=18` | 147.01 | - | 146.68 | 147.29 | 6 | 0.2 | 3258 | 85.49 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | 146.60 | - | 146.51 | 147.19 | 6 | 0.2 | 3420 | 95.77 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=64` | 146.53 | - | 145.88 | 146.67 | 6 | 0.3 | 3321 | 82.33 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | `N=34816 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | 145.95 | - | 145.90 | 146.01 | 6 | 0.0 | 3427 | 95.70 MiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=1024 eps=1e-05 dtype=bf16 M=16` | - | 145.88 | 140.98 | 149.76 | 20 | 2.8 | - | 64.00 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=2` | - | 145.47 | 144.35 | 157.44 | 20 | 3.0 | - | 16.01 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=9` | 144.90 | - | 144.68 | 145.14 | 11 | 0.1 | 3251 | 85.25 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=8` | 144.71 | - | 143.06 | 144.92 | 6 | 0.6 | 3250 | 85.23 MiB | | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | `N=240 K=4096 dtype=bf16 M=512` | 144.62 | - | 126.29 | 145.28 | 20 | 5.1 | 3134 | 8.22 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=4` | 144.10 | - | 143.93 | 144.19 | 11 | 0.1 | 3251 | 85.12 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=2` | 143.89 | - | 143.68 | 145.49 | 6 | 0.6 | 3248 | 85.06 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=17408 group=128 dtype=fp8a8 M=1` | 143.69 | - | 143.57 | 143.78 | 11 | 0.1 | 3247 | 85.04 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=36` | 142.11 | - | 141.87 | 142.71 | 11 | 0.2 | 3318 | 81.32 MiB | | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=8192 group=128 dtype=bf16 M=1` | - | 139.93 | 134.20 | 153.42 | 20 | 1.8 | - | 24.25 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=18` | 139.60 | - | 139.32 | 139.67 | 11 | 0.1 | 3336 | 80.66 MiB | | +| `embed_lookup` | `ref_embed_lookup` | libref | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=8` | - | 139.00 | 134.29 | 145.26 | 20 | 2.4 | - | 1.00 GiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=9` | 138.63 | - | 138.45 | 138.69 | 11 | 0.1 | 3331 | 80.34 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=8` | 138.27 | - | 138.01 | 138.41 | 11 | 0.1 | 3331 | 80.30 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=4` | 137.12 | - | 136.97 | 137.30 | 11 | 0.1 | 3330 | 80.15 MiB | | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=2` | - | 136.99 | 136.48 | 148.18 | 20 | 2.9 | - | 16.01 KiB | 32 thread(s) | +| `gather_rows` | `ref_gather_rows` | libref | `n=1280 dtype=bf16 M=16` | - | 136.63 | 127.21 | 144.73 | 20 | 3.9 | - | 200.06 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=2` | 136.61 | - | 136.34 | 136.74 | 6 | 0.1 | 3324 | 80.08 MiB | | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=248320 k=21 M=32` | 136.49 | - | 136.07 | 137.03 | 6 | 0.4 | 3423 | 30.32 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=16384 K=5120 group=128 dtype=fp8a8 M=1` | 136.44 | - | 136.24 | 136.60 | 6 | 0.1 | 3324 | 80.05 MiB | | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=248320 k=21 M=8` | 134.80 | - | 132.85 | 137.17 | 19 | 1.0 | 3437 | 7.58 MiB | | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=248320 k=21 M=1` | 134.67 | - | 133.18 | 136.74 | 20 | 1.1 | 3439 | 970.27 KiB | | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=248320 k=21 M=4` | 134.59 | - | 133.09 | 137.31 | 20 | 1.0 | 3437 | 3.79 MiB | | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=248320 k=21 M=2` | 134.26 | - | 129.29 | 136.31 | 14 | 1.0 | 3440 | 1.90 MiB | | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=4096 group=128 dtype=bf16 M=2` | - | 133.40 | 130.68 | 148.82 | 20 | 2.8 | - | 24.25 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4096 K=8192 group=128 dtype=fp8a8 M=258` | 132.29 | - | 119.16 | 138.97 | 20 | 2.7 | 2954 | 36.10 MiB | | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=248320 k=21 M=16` | 132.15 | - | 131.94 | 132.33 | 6 | 0.1 | 3434 | 15.16 MiB | | +| `kv_store` | `ref_kv_store` | libref | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=32` | - | 131.85 | 128.60 | 142.90 | 16 | 0.9 | - | 96.12 KiB | 32 thread(s) | +| `cast` | `ref_cast` | libref | `n=5120 from=bf16 to=bf16 M=2` | - | 131.01 | 124.74 | 145.31 | 20 | 3.3 | - | 40.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=1024 group=128 dtype=bf16 M=8` | - | 130.68 | 129.96 | 139.99 | 20 | 2.2 | - | 24.25 KiB | 32 thread(s) | +| `sample_topp` | `sample_topp_f32` | libr4d | `n_cand=1024 M=16` | 130.65 | - | 107.54 | 131.08 | 40 | 1.2 | 3440 | 129.50 KiB | restore 5% | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=5376 K=4096 group=128 dtype=fp8a8 M=512` | 130.52 | - | 124.75 | 139.53 | 20 | 1.3 | 2954 | 28.32 MiB | | +| `sample_topp` | `sample_topp_f32` | libr4d | `n_cand=1024 M=64` | 130.35 | - | 107.53 | 131.55 | 40 | 1.4 | 3439 | 518.00 KiB | restore 5% | +| `row_topk` | `rowtopk_bf16` | libr4d | `N=248320 R=32 dtype=bf16 M=32 nch=0 pt1=8` | 129.91 | - | 129.69 | 130.41 | 6 | 0.3 | 3422 | 15.17 MiB | | +| `silu` | `ref_silu` | libref | `n=2048 dtype=bf16 M=4` | - | 129.13 | 128.48 | 133.98 | 20 | 1.5 | - | 32.00 KiB | 32 thread(s) | +| `silu` | `ref_silu` | libref | `n=1024 dtype=bf16 M=8` | - | 129.11 | 128.65 | 133.78 | 20 | 1.5 | - | 32.00 KiB | 32 thread(s) | +| `sample_topp` | `sample_topp_f32` | libr4d | `n_cand=1024 M=32` | 128.99 | - | 107.32 | 131.14 | 39 | 1.1 | 3439 | 259.00 KiB | restore 5% | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | 128.79 | - | 127.76 | 129.37 | 6 | 0.6 | 3258 | 71.57 MiB | | +| `quant_act_i8` | `ref_quant_act_i8` | libref | `n=5120 group=128 dtype=bf16 M=2` | - | 128.07 | 123.51 | 133.69 | 20 | 2.9 | - | 32.51 KiB | 32 thread(s) | +| `sample_topk` | `sample_topk_f32` | libr4d | `n_vocab=248320 M=8` | 127.66 | - | 122.90 | 129.31 | 20 | 1.1 | 3438 | 7.59 MiB | | +| `sample_topp` | `sample_topp_f32` | libr4d | `n_cand=1024 M=1` | 127.65 | - | 105.50 | 128.85 | 31 | 1.1 | 3438 | 8.09 KiB | restore 5% | +| `sample_temp` | `ref_sample_temp` | libref | `n_vocab=1024 M=32` | - | 127.22 | 124.55 | 136.72 | 20 | 2.8 | - | 131.00 KiB | 32 thread(s) | +| `sample_topp` | `sample_topp_f32` | libr4d | `n_cand=1024 M=8` | 126.31 | - | 104.37 | 127.40 | 26 | 1.1 | 3440 | 64.75 KiB | restore 5% | +| `sample_topk` | `sample_topk_f32` | libr4d | `n_vocab=248320 M=4` | 124.92 | - | 120.87 | 125.94 | 19 | 1.0 | 3438 | 3.79 MiB | | +| `sample_topk` | `sample_topk_f32` | libr4d | `n_vocab=248320 M=32` | 124.92 | - | 123.76 | 125.46 | 6 | 0.7 | 3425 | 30.35 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=8192 K=4096 group=128 dtype=fp8a8 M=258` | 124.30 | - | 117.09 | 141.13 | 20 | 7.5 | 2923 | 37.07 MiB | | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=1536 group=128 dtype=bf16 M=4` | - | 123.95 | 112.66 | 152.64 | 20 | 11.5 | - | 18.19 KiB | 32 thread(s) | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=32` | 123.93 | - | 118.50 | 124.21 | 20 | 1.2 | 3430 | 2.50 MiB | | +| `sample_topp` | `sample_topp_f32` | libr4d | `n_cand=1024 M=4` | 123.87 | - | 103.16 | 126.43 | 40 | 1.2 | 3440 | 32.38 KiB | restore 5% | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=11` | 123.52 | - | 117.42 | 123.85 | 20 | 1.1 | 3415 | 2.17 MiB | | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=16` | 123.30 | - | 118.44 | 123.57 | 16 | 0.9 | 3422 | 2.25 MiB | | +| `rope` | `ref_rope` | libref | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=4` | - | 123.11 | 121.81 | 132.35 | 20 | 3.2 | - | 48.05 KiB | 32 thread(s) | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=17` | 123.08 | - | 118.38 | 123.96 | 20 | 1.2 | 3424 | 2.27 MiB | | +| `sample_pick` | `sample_pick_f32` | libr4d | `n_cand=1024 M=8` | 122.81 | - | 105.86 | 123.17 | 17 | 0.9 | 3441 | 64.78 KiB | | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=33` | 122.69 | - | 118.66 | 123.71 | 14 | 1.0 | 3430 | 2.52 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=258` | 122.69 | - | 115.75 | 129.66 | 20 | 2.1 | 2836 | 34.08 MiB | | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=130` | 122.64 | - | 118.56 | 125.40 | 20 | 1.2 | 3423 | 4.03 MiB | | +| `sample_pick` | `sample_pick_f32` | libr4d | `n_cand=1024 M=64` | 122.62 | - | 101.62 | 124.72 | 40 | 2.7 | 3438 | 518.25 KiB | | +| `rmsnorm_quant_fp8` | `ref_rmsnorm_quant_fp8` | libref | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=1` | - | 122.61 | 120.20 | 128.37 | 20 | 1.9 | - | 36.12 KiB | 32 thread(s) | +| `sample_topk` | `sample_topk_f32` | libr4d | `n_vocab=248320 M=1` | 122.44 | - | 117.26 | 125.10 | 20 | 1.2 | 3437 | 971.09 KiB | | +| `sample_topk` | `sample_topk_f32` | libr4d | `n_vocab=248320 M=2` | 122.18 | - | 121.99 | 124.39 | 6 | 1.0 | 3438 | 1.90 MiB | | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=64` | 122.15 | - | 118.83 | 124.24 | 20 | 1.1 | 3428 | 3.00 MiB | | +| `sample_pick` | `sample_pick_f32` | libr4d | `n_cand=1024 M=32` | 122.07 | - | 104.19 | 122.53 | 40 | 2.4 | 3438 | 259.12 KiB | | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=9` | 121.76 | - | 114.44 | 124.29 | 20 | 1.2 | 3394 | 2.14 MiB | | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=65` | 121.68 | - | 118.91 | 123.86 | 11 | 1.0 | 3429 | 3.02 MiB | | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=10` | 121.45 | - | 119.32 | 123.88 | 16 | 0.9 | 3402 | 2.16 MiB | | +| `sample_topk` | `sample_topk_f32` | libr4d | `n_vocab=131072 M=64` | 121.33 | - | 121.15 | 121.48 | 6 | 0.1 | 3420 | 32.07 MiB | | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=131072 k=21 M=64` | 121.01 | - | 120.68 | 121.25 | 6 | 0.2 | 3420 | 32.02 MiB | | +| `sample_pick` | `sample_pick_f32` | libr4d | `n_cand=1024 M=16` | 120.02 | - | 98.86 | 121.09 | 40 | 2.2 | 3439 | 129.56 KiB | | +| `sample_topk` | `sample_topk_f32` | libr4d | `n_vocab=248320 M=16` | 119.78 | - | 119.61 | 120.19 | 6 | 0.2 | 3434 | 15.17 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=128` | 118.39 | - | 117.48 | 118.95 | 6 | 0.6 | 3181 | 63.65 MiB | | +| `embed_lookup` | `ref_embed_lookup` | libref | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=4` | - | 117.77 | 115.22 | 120.95 | 20 | 1.5 | - | 2.37 GiB | 32 thread(s) | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | `N=304 K=4096 dtype=bf16 M=256` | 117.40 | - | 106.90 | 124.72 | 20 | 2.9 | 3212 | 7.05 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | 116.81 | - | 116.16 | 117.83 | 6 | 0.7 | 3297 | 70.59 MiB | | +| `grid_embed_cpe` | `avx_grid_embed_cpe` | libavx | `n=1280 side=128 n_prefix=10 dtype=bf16 M=2` | - | 116.42 | 113.36 | 128.49 | 20 | 3.5 | - | 40.03 MiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4608 K=4096 group=128 dtype=fp8a8 M=512` | 116.12 | - | 111.47 | 117.80 | 19 | 0.7 | 3049 | 24.56 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | 116.02 | - | 115.25 | 117.52 | 11 | 0.8 | 3297 | 70.63 MiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=2` | - | 115.70 | 104.02 | 138.29 | 20 | 12.7 | - | 50.00 KiB | 32 thread(s) | +| `sample_mask` | `sample_mask_f32` | libr4d | `n_vocab=248320 M=64` | 115.47 | - | 114.72 | 115.81 | 6 | 0.5 | 3431 | 62.53 MiB | restore 65% | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | 115.46 | - | 115.05 | 116.62 | 6 | 0.7 | 3270 | 70.94 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=10240 K=4096 group=128 dtype=fp8a8 M=129` | 115.43 | - | 115.16 | 115.57 | 6 | 0.2 | 3032 | 43.04 MiB | | +| `dflash_select` | `ref_dflash_select` | libref | `steps=7 top_k=16 rank=256 n_vocab=248320 anchor_stride=8 dtype=bf16 M=1` | - | 114.56 | 110.72 | 124.01 | 20 | 2.3 | - | 242.50 MiB | 32 thread(s) | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=16` | - | 114.38 | 114.31 | 122.22 | 20 | 1.2 | - | 21.31 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4608 K=4608 dtype=bf16 act=gelu M=256` | 114.12 | - | 110.76 | 121.01 | 20 | 2.4 | 3054 | 47.26 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=4608 dtype=bf16 act=none M=256` | 113.94 | - | 107.99 | 116.65 | 20 | 1.8 | 3086 | 52.26 MiB | | +| `gdn_conv_update` | `gdn_conv_update_w4_h128_bf16` | libr4d | `head_k=128 head_v=128 conv_width=4 q_len=128` | 112.93 | - | 112.53 | 113.18 | 6 | 0.3 | 3260 | 7.62 MiB | restore 4% | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4096 K=5376 group=128 dtype=fp8a8 M=512` | 112.86 | - | 105.70 | 120.02 | 20 | 4.1 | 2916 | 27.71 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=64` | 112.39 | - | 112.08 | 112.55 | 6 | 0.2 | 3231 | 61.83 MiB | | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=16` | - | 112.24 | 108.89 | 118.05 | 20 | 3.2 | - | 21.31 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=65` | 112.19 | - | 111.94 | 112.25 | 6 | 0.1 | 3172 | 61.86 MiB | | +| `row_topk` | `rowtopk_bf16` | libr4d | `N=248320 R=32 dtype=bf16 M=8 nch=0 pt1=8` | 112.06 | - | 107.50 | 114.62 | 20 | 1.9 | 3428 | 3.79 MiB | | +| `sample_topp` | `sample_topp_f32` | libr4d | `n_cand=1024 M=2` | 111.93 | - | 92.00 | 114.63 | 40 | 1.8 | 3438 | 16.19 KiB | restore 5% | +| `act_mul` | `ref_act_mul` | libref | `n=5376 act=relu dtype=bf16 M=2` | - | 111.72 | 110.23 | 118.07 | 20 | 2.4 | - | 63.00 KiB | 32 thread(s) | +| `row_topk` | `rowtopk_bf16` | libr4d | `N=248320 R=32 dtype=bf16 M=16 nch=0 pt1=8` | 111.59 | - | 109.58 | 111.75 | 6 | 1.0 | 3423 | 7.59 MiB | | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=131072 k=9 M=56` | 111.37 | - | 110.83 | 112.61 | 6 | 0.8 | 3306 | 28.01 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | 110.51 | - | 110.26 | 112.33 | 6 | 0.9 | 3300 | 70.45 MiB | | +| `lili_walk` | `lili_walk_bf16` | libr4d | `steps=7 k=8 n=1024 dtype=bf16 eps=0.0001 scale=8 M=8` | 110.50 | - | 110.39 | 110.89 | 6 | 0.2 | 3437 | 1.78 MiB | | +| `lili_walk` | `lili_walk_bf16` | libr4d | `steps=7 k=8 n=1024 dtype=bf16 eps=0.0001 scale=8 M=4` | 110.33 | - | 110.05 | 113.27 | 20 | 1.1 | 3439 | 911.98 KiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | 110.23 | - | 109.69 | 111.07 | 6 | 0.6 | 3183 | 49.53 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | 109.99 | - | 109.49 | 110.92 | 6 | 0.6 | 3296 | 70.35 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | `N=5120 K=25600 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | 109.84 | - | 109.32 | 110.60 | 6 | 0.6 | 3291 | 70.38 MiB | | +| `lili_walk` | `lili_walk_bf16` | libr4d | `steps=7 k=8 n=1024 dtype=bf16 eps=0.0001 scale=8 M=2` | 109.57 | - | 108.75 | 111.53 | 20 | 1.0 | 3438 | 455.99 KiB | | +| `lili_walk` | `lili_walk_bf16` | libr4d | `steps=7 k=8 n=1024 dtype=bf16 eps=0.0001 scale=8 M=1` | 108.47 | - | 108.16 | 111.18 | 19 | 0.7 | 3438 | 228.00 KiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=36` | 108.38 | - | 107.98 | 109.78 | 6 | 0.8 | 3240 | 61.03 MiB | | +| `scatter_rows` | `ref_scatter_rows` | libref | `n=4096 dtype=bf16 M=4` | - | 108.37 | 98.47 | 122.47 | 20 | 4.6 | - | 160.02 KiB | 32 thread(s) | +| `gather_rows` | `ref_gather_rows` | libref | `n=4096 dtype=bf16 M=4` | - | 107.63 | 107.56 | 115.42 | 20 | 1.2 | - | 160.02 KiB | 32 thread(s) | +| `embed_lookup` | `ref_embed_lookup` | libref | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=4` | - | 107.63 | 90.53 | 120.10 | 20 | 9.7 | - | 1.00 GiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=32` | - | 107.33 | 107.12 | 115.61 | 20 | 1.9 | - | 16.12 KiB | 32 thread(s) | +| `add` | `ref_add` | libref | `n=4096 dtype=bf16 M=4` | - | 107.26 | 106.69 | 111.09 | 20 | 1.6 | - | 96.00 KiB | 32 thread(s) | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | 107.04 | - | 106.54 | 108.50 | 11 | 0.8 | 3241 | 7.09 MiB | | +| `sample_argmax` | `sample_argmax_f32` | libr4d | `n_vocab=248320 M=64` | 106.58 | - | 106.40 | 106.99 | 6 | 0.3 | 3437 | 60.63 MiB | | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=260` | 105.92 | - | 105.60 | 106.42 | 6 | 0.4 | 3377 | 6.06 MiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=20480 act=relu dtype=bf16 M=512` | 105.59 | - | 105.53 | 105.80 | 6 | 0.1 | 3370 | 60.00 MiB | | +| `gated_quant_fp8` | `gated_quant_fp8` | libr4d | `n=17408 group=128 dtype=bf16 act=silu M=512` | 105.23 | - | 104.92 | 105.75 | 6 | 0.4 | 3228 | 59.77 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=18` | 104.96 | - | 104.82 | 106.05 | 6 | 0.6 | 3244 | 60.52 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=9` | 104.15 | - | 104.06 | 105.14 | 6 | 0.5 | 3246 | 60.26 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=8` | 103.88 | - | 103.66 | 103.94 | 11 | 0.1 | 3248 | 60.24 MiB | | +| `act_mul` | `ref_act_mul` | libref | `n=1536 act=relu dtype=bf16 M=4` | - | 103.84 | 99.58 | 111.72 | 20 | 3.7 | - | 36.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=4` | 103.27 | - | 103.18 | 103.78 | 11 | 0.3 | 3248 | 60.12 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=1` | 103.02 | - | 102.92 | 103.49 | 6 | 0.3 | 3043 | 60.04 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=12288 K=5120 group=128 dtype=fp8a8 M=2` | 103.00 | - | 102.95 | 103.04 | 6 | 0.0 | 3255 | 60.06 MiB | | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=8` | - | 102.27 | 102.09 | 102.97 | 6 | 0.4 | - | 16.03 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=4` | - | 101.01 | 100.76 | 108.70 | 20 | 2.6 | - | 27.03 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=6144 group=128 dtype=bf16 M=1` | - | 100.88 | 99.51 | 107.21 | 20 | 2.1 | - | 18.19 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=64` | - | 99.16 | 82.23 | 115.16 | 20 | 14.6 | - | 32.25 KiB | 32 thread(s) | +| `add` | `ref_add` | libref | `n=5120 dtype=bf16 M=2` | - | 98.06 | 97.01 | 105.69 | 20 | 2.6 | - | 60.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=5376 K=4096 group=128 dtype=fp8a8 M=258` | 95.85 | - | 94.92 | 96.07 | 6 | 0.6 | 3098 | 24.69 MiB | | +| `kv_store` | `ref_kv_store` | libref | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=4` | - | 95.75 | 95.42 | 121.64 | 19 | 0.6 | - | 112.02 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4096 K=4096 group=128 dtype=fp8a8 M=512` | 95.20 | - | 93.18 | 99.47 | 20 | 2.3 | 2974 | 22.06 MiB | | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=16` | - | 94.85 | 92.00 | 103.64 | 20 | 4.8 | - | 17.06 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4096 K=8192 group=128 dtype=fp8a8 M=129` | 94.78 | - | 94.16 | 95.02 | 6 | 0.5 | 3166 | 34.05 MiB | | +| `act_mul` | `ref_act_mul` | libref | `n=2304 act=relu dtype=bf16 M=4` | - | 94.57 | 94.44 | 99.84 | 20 | 1.3 | - | 54.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=5376 group=128 dtype=bf16 M=1` | - | 94.34 | 93.78 | 122.80 | 20 | 10.0 | - | 15.91 KiB | 32 thread(s) | +| `grid_embed` | `ref_grid_embed` | libref | `n=1152 side=48 dtype=bf16 M=2` | - | 94.06 | 93.38 | 105.36 | 16 | 0.7 | - | 5.07 MiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=8192 K=4096 group=128 dtype=fp8a8 M=129` | 93.52 | - | 81.80 | 94.24 | 14 | 0.9 | 3118 | 34.54 MiB | | +| `sample_xtc` | `ref_sample_xtc` | libref | `n_cand=1024 M=4` | - | 93.09 | 90.99 | 116.98 | 20 | 7.6 | - | 32.38 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=129` | 91.67 | - | 85.63 | 92.43 | 20 | 2.6 | 3064 | 32.04 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4608 K=4096 group=128 dtype=fp8a8 M=258` | 91.36 | - | 90.57 | 91.85 | 6 | 0.7 | 3102 | 21.31 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=12288 group=128 dtype=fp8a8 M=64` | 89.88 | - | 89.68 | 90.07 | 6 | 0.2 | 3314 | 49.28 MiB | | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=16` | - | 88.71 | 86.94 | 94.47 | 20 | 2.9 | - | 17.06 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=5120 group=128 dtype=bf16 M=1` | - | 88.05 | 80.81 | 103.89 | 20 | 11.0 | - | 15.16 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4096 K=5376 group=128 dtype=fp8a8 M=258` | 87.95 | - | 83.94 | 93.98 | 20 | 3.0 | 2948 | 24.38 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | 87.27 | - | 86.62 | 87.91 | 6 | 0.7 | 3308 | 48.78 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=12288 group=128 dtype=fp8a8 M=33` | 86.18 | - | 86.06 | 86.27 | 11 | 0.1 | 3319 | 48.66 MiB | | +| `gdn_gated_rmsnorm` | `ref_gdn_gated_rmsnorm` | libref | `channels=128 eps=1e-06 act=silu M=32` | - | 85.98 | 82.86 | 119.95 | 20 | 4.3 | - | 24.50 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4608 K=4608 dtype=bf16 act=gelu M=128` | 85.75 | - | 85.35 | 85.99 | 6 | 0.4 | 3392 | 43.88 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=4608 dtype=bf16 act=none M=128` | 85.62 | - | 85.44 | 85.98 | 6 | 0.3 | 3350 | 48.63 MiB | | +| `act_mul` | `ref_act_mul` | libref | `n=2048 act=relu dtype=bf16 M=4` | - | 85.48 | 85.32 | 91.14 | 20 | 2.8 | - | 48.00 KiB | 32 thread(s) | +| `sample_pick` | `sample_pick_f32` | libr4d | `n_cand=1024 M=1` | 85.41 | - | 78.27 | 87.14 | 40 | 1.7 | 3440 | 8.10 KiB | | +| `moe_gather` | `ref_moe_gather` | libref | `n=1024 top_k=9 dtype=bf16 act=none M=1` | - | 85.21 | 79.56 | 126.59 | 20 | 26.7 | - | 22.05 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=10240 K=4096 group=128 dtype=fp8a8 M=128` | 85.02 | - | 84.61 | 85.37 | 6 | 0.4 | 3328 | 43.02 MiB | | +| `layernorm` | `ref_layernorm` | libref | `n=1280 eps=1e-06 dtype=bf16 M=4` | - | 84.90 | 81.01 | 94.10 | 20 | 5.0 | - | 25.00 KiB | 32 thread(s) | +| `row_topk` | `rowtopk_bf16` | libr4d | `N=248320 R=32 dtype=bf16 M=4 nch=0 pt1=8` | 84.75 | - | 81.30 | 89.40 | 20 | 2.7 | 3446 | 1.90 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=12288 group=128 dtype=fp8a8 M=32` | 84.58 | - | 84.37 | 84.69 | 6 | 0.2 | 3312 | 48.64 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=4608 dtype=bf16 act=none M=64` | 84.36 | - | 84.00 | 84.65 | 6 | 0.4 | 3356 | 46.82 MiB | | +| `grid_embed_cpe` | `ref_grid_embed_cpe` | libref | `n=1280 side=128 n_prefix=10 dtype=bf16 M=2` | - | 84.25 | 75.87 | 89.67 | 20 | 6.5 | - | 40.03 MiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=12288 group=128 dtype=fp8a8 M=18` | 83.97 | - | 83.94 | 84.04 | 6 | 0.1 | 3312 | 48.36 MiB | | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=131072 k=9 M=16` | 83.97 | - | 77.84 | 90.22 | 20 | 5.4 | 3320 | 8.00 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4608 K=4608 dtype=bf16 act=gelu M=64` | 83.91 | - | 83.42 | 84.03 | 6 | 0.4 | 3403 | 42.20 MiB | | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=131072 k=9 M=8` | 83.84 | - | 77.50 | 88.20 | 20 | 3.3 | 3329 | 4.00 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=12288 group=128 dtype=fp8a8 M=9` | 83.79 | - | 83.72 | 83.86 | 6 | 0.1 | 3315 | 48.18 MiB | | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=131072 k=21 M=16` | 83.62 | - | 65.99 | 88.66 | 20 | 3.2 | 3430 | 8.00 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=12288 group=128 dtype=fp8a8 M=8` | 83.59 | - | 83.55 | 83.70 | 6 | 0.1 | 3314 | 48.17 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=12288 group=128 dtype=fp8a8 M=4` | 83.46 | - | 83.42 | 83.52 | 6 | 0.1 | 3316 | 48.09 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=12288 group=128 dtype=fp8a8 M=2` | 83.21 | - | 83.18 | 83.32 | 6 | 0.1 | 3305 | 48.05 MiB | | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=131072 k=21 M=2` | 83.17 | - | 76.17 | 87.72 | 20 | 2.0 | 3433 | 1.00 MiB | | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=131072 k=21 M=8` | 83.12 | - | 76.88 | 87.63 | 20 | 3.8 | 3432 | 4.00 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=12288 group=128 dtype=fp8a8 M=1` | 83.11 | - | 83.08 | 83.61 | 6 | 0.3 | 3306 | 48.03 MiB | | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=131072 k=9 M=2` | 83.09 | - | 66.84 | 88.06 | 20 | 3.2 | 3346 | 1.00 MiB | | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=131072 k=9 M=4` | 83.03 | - | 77.61 | 87.94 | 20 | 3.1 | 3336 | 2.00 MiB | | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=131072 k=21 M=1` | 83.02 | - | 74.29 | 87.40 | 20 | 3.3 | 3433 | 512.27 KiB | | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=131072 k=9 M=1` | 82.90 | - | 74.84 | 87.83 | 20 | 2.6 | 3350 | 512.17 KiB | | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=131072 k=21 M=4` | 82.68 | - | 77.73 | 87.93 | 20 | 4.3 | 3432 | 2.00 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=4608 dtype=bf16 act=none M=32` | 82.65 | - | 82.01 | 83.22 | 6 | 0.7 | 3363 | 45.92 MiB | | +| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=248320 M=64` | 82.31 | - | 72.52 | 82.82 | 11 | 0.6 | 3418 | 60.63 MiB | restore 72% | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=1280 dtype=bf16 act=gelu M=512` | 82.27 | - | 82.20 | 83.38 | 6 | 0.7 | 3161 | 23.76 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=4608 dtype=bf16 act=none M=16` | 81.50 | - | 81.32 | 81.71 | 6 | 0.2 | 3374 | 45.46 MiB | | +| `sample_temp` | `ref_sample_temp` | libref | `n_vocab=1024 M=16` | - | 81.24 | 72.96 | 99.82 | 20 | 5.5 | - | 65.50 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=4608 dtype=bf16 act=none M=8` | 81.24 | - | 80.96 | 81.53 | 6 | 0.3 | 3366 | 45.24 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=4608 dtype=bf16 act=none M=4` | 80.94 | - | 80.84 | 81.24 | 6 | 0.2 | 3368 | 45.12 MiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=32` | - | 80.81 | 79.46 | 83.22 | 20 | 1.8 | - | 32.50 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1280 K=5120 dtype=bf16 act=none M=512` | 80.80 | - | 77.42 | 81.07 | 11 | 1.0 | 3234 | 20.00 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=4608 dtype=bf16 act=none M=2` | 80.69 | - | 80.12 | 80.91 | 6 | 0.5 | 3378 | 45.07 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=4608 dtype=bf16 act=none M=1` | 80.53 | - | 80.38 | 80.78 | 6 | 0.3 | 3351 | 45.04 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=10240 K=4096 group=128 dtype=fp8a8 M=65` | 80.48 | - | 80.25 | 80.72 | 6 | 0.3 | 3325 | 41.54 MiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=4096 eps=1e-05 dtype=bf16 M=2` | - | 80.28 | 78.94 | 87.42 | 20 | 3.9 | - | 40.00 KiB | 32 thread(s) | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | `N=240 K=4096 dtype=bf16 M=256` | 79.76 | - | 79.35 | 81.29 | 14 | 0.2 | 3255 | 5.98 MiB | | +| `add` | `ref_add` | libref | `n=4096 dtype=bf16 M=2` | - | 79.73 | 77.47 | 83.06 | 20 | 2.4 | - | 48.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | 79.53 | - | 79.11 | 79.87 | 6 | 0.5 | 3396 | 48.30 MiB | | +| `ple_conv_bias` | `ple_conv_bias_bf16` | libr4d | `n=10240 width=4 dilation=1 dtype=bf16 M=256` | 79.47 | - | 79.03 | 79.84 | 6 | 0.5 | 3375 | 20.14 MiB | restore 11% | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=2` | - | 79.24 | 78.89 | 87.20 | 20 | 3.0 | - | 40.00 KiB | 32 thread(s) | +| `sample_minp` | `ref_sample_minp` | libref | `n_cand=1024 M=4` | - | 79.15 | 78.82 | 95.11 | 19 | 0.7 | - | 32.38 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=1024 eps=1e-06 dtype=bf16 M=8` | - | 79.02 | 78.99 | 83.25 | 20 | 1.9 | - | 34.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4608 K=4608 dtype=bf16 act=gelu M=32` | 78.87 | - | 78.76 | 79.81 | 6 | 0.7 | 3382 | 41.35 MiB | | +| `layernorm` | `ref_layernorm` | libref | `n=1152 eps=1e-06 dtype=bf16 M=4` | - | 78.55 | 77.60 | 80.91 | 20 | 1.4 | - | 22.50 KiB | 32 thread(s) | +| `row_topk` | `rowtopk_bf16` | libr4d | `N=248320 R=32 dtype=bf16 M=1 nch=0 pt1=8` | 78.40 | - | 74.69 | 78.77 | 20 | 1.2 | 3440 | 485.50 KiB | | +| `row_topk` | `rowtopk_bf16` | libr4d | `N=248320 R=32 dtype=bf16 M=2 nch=0 pt1=8` | 78.02 | - | 77.10 | 78.50 | 6 | 0.9 | 3440 | 971.00 KiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | 77.90 | - | 76.89 | 78.47 | 11 | 0.8 | 3414 | 48.03 MiB | | +| `mul_weight` | `ref_mul_weight` | libref | `n=8192 dtype=bf16 M=1` | - | 77.89 | 74.38 | 80.58 | 20 | 2.6 | - | 48.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=25600 group=128 dtype=bf16 M=512` | 77.40 | - | 77.01 | 77.70 | 6 | 0.4 | 3292 | 37.89 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | 77.18 | - | 76.97 | 77.33 | 6 | 0.2 | 3408 | 47.92 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4608 K=4608 dtype=bf16 act=gelu M=16` | 77.18 | - | 76.78 | 77.82 | 6 | 0.7 | 3375 | 40.93 MiB | | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=131072 k=9 M=32` | 77.09 | - | 76.70 | 77.81 | 6 | 0.7 | 3314 | 16.01 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=10240 K=4096 group=128 dtype=fp8a8 M=64` | 77.09 | - | 76.92 | 77.50 | 6 | 0.4 | 3382 | 41.51 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4608 K=4608 dtype=bf16 act=gelu M=4` | 76.73 | - | 76.27 | 77.34 | 6 | 0.7 | 3366 | 40.61 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4608 K=4608 dtype=bf16 act=gelu M=8` | 76.66 | - | 76.50 | 77.32 | 6 | 0.5 | 3352 | 40.72 MiB | | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=10 splits=0` | 76.64 | - | 76.48 | 77.03 | 6 | 0.4 | 3311 | 32.24 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4608 K=4608 dtype=bf16 act=gelu M=2` | 76.38 | - | 75.85 | 77.05 | 6 | 0.8 | 3374 | 40.56 MiB | | +| `sample_logprobs` | `sample_logprobs_f32` | libr4d | `n_vocab=131072 k=21 M=32` | 76.20 | - | 75.79 | 76.55 | 11 | 0.4 | 3424 | 16.01 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4608 K=4608 dtype=bf16 act=gelu M=1` | 76.14 | - | 75.81 | 76.98 | 6 | 0.8 | 3354 | 40.54 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | 76.03 | - | 75.36 | 76.69 | 6 | 0.9 | 3398 | 48.05 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | 75.94 | - | 75.40 | 76.74 | 6 | 0.9 | 3234 | 47.84 MiB | | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=9 splits=0` | 75.89 | - | 75.78 | 76.14 | 6 | 0.2 | 3313 | 32.21 MiB | | +| `gather_rows` | `ref_gather_rows` | libref | `n=1280 dtype=bf16 M=8` | - | 75.78 | 74.18 | 82.19 | 20 | 4.0 | - | 100.03 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | `N=5120 K=17408 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | 75.76 | - | 75.63 | 76.07 | 6 | 0.3 | 3416 | 47.87 MiB | | +| `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | `head_k=128 head_v=128 scale=0.0883883 M=512 chunk=64` | 75.61 | - | 73.85 | 78.33 | 20 | 2.6 | 3178 | 25.19 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=10240 K=4096 group=128 dtype=fp8a8 M=33` | 75.36 | - | 75.27 | 75.70 | 6 | 0.3 | 3394 | 40.78 MiB | | +| `sample_pick` | `sample_pick_f32` | libr4d | `n_cand=1024 M=4` | 74.71 | - | 55.34 | 77.01 | 40 | 2.3 | 3439 | 32.39 KiB | | +| `sample_xtc` | `ref_sample_xtc` | libref | `n_cand=1024 M=2` | - | 74.66 | 74.28 | 83.13 | 20 | 4.7 | - | 16.19 KiB | 32 thread(s) | +| `rope_table` | `ref_rope_table` | libref | `rot=64 theta=1e+07 scale=1 dtype=f32 M=32` | - | 74.50 | 73.47 | 79.81 | 20 | 2.8 | - | 8.12 KiB | 32 thread(s) | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=24576 group=128 dtype=bf16 M=512` | 74.08 | - | 73.37 | 74.49 | 11 | 0.6 | 3282 | 36.38 MiB | | +| `attn_dense` | `ref_attn_dense` | libref | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=8` | - | 74.04 | 65.80 | 82.71 | 20 | 3.9 | - | 5.01 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1280 K=5120 dtype=bf16 act=none M=256` | 73.95 | - | 73.83 | 74.37 | 6 | 0.4 | 3389 | 16.25 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4096 K=4096 group=128 dtype=fp8a8 M=258` | 73.51 | - | 73.29 | 74.14 | 6 | 0.6 | 3091 | 19.06 MiB | | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | 73.30 | - | 73.18 | 73.46 | 6 | 0.2 | 3305 | 32.12 MiB | | +| `sample_topk` | `sample_topk_f32` | libr4d | `n_vocab=131072 M=16` | 73.25 | - | 70.93 | 74.20 | 14 | 1.0 | 3438 | 8.02 MiB | | +| `cast` | `ref_cast` | libref | `n=5120 from=bf16 to=bf16 M=1` | - | 72.57 | 63.49 | 81.94 | 20 | 5.7 | - | 20.00 KiB | 32 thread(s) | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | 72.56 | - | 72.20 | 72.88 | 6 | 0.5 | 3322 | 32.19 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=10240 K=4096 group=128 dtype=fp8a8 M=32` | 72.43 | - | 72.35 | 72.85 | 6 | 0.3 | 3393 | 40.76 MiB | | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | 71.97 | - | 71.67 | 72.19 | 6 | 0.4 | 3316 | 32.05 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=10240 K=4096 group=128 dtype=fp8a8 M=18` | 71.89 | - | 71.81 | 71.98 | 6 | 0.1 | 3397 | 40.43 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=10240 K=4096 group=128 dtype=fp8a8 M=9` | 71.69 | - | 71.64 | 71.83 | 6 | 0.1 | 3408 | 40.22 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=10240 K=4096 group=128 dtype=fp8a8 M=8` | 71.51 | - | 71.25 | 71.65 | 6 | 0.3 | 3408 | 40.19 MiB | | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | 71.28 | - | 71.23 | 71.47 | 6 | 0.2 | 3298 | 32.10 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=10240 K=4096 group=128 dtype=fp8a8 M=1` | 71.24 | - | 71.12 | 71.34 | 6 | 0.2 | 3310 | 40.03 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=10240 K=4096 group=128 dtype=fp8a8 M=4` | 71.17 | - | 71.10 | 71.28 | 6 | 0.1 | 3408 | 40.10 MiB | | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=4096 group=128 dtype=bf16 M=1` | - | 71.16 | 63.86 | 76.24 | 20 | 6.1 | - | 12.12 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=1024 eps=1e-05 dtype=bf16 M=8` | - | 71.10 | 69.10 | 76.06 | 20 | 4.1 | - | 32.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=10240 K=4096 group=128 dtype=fp8a8 M=2` | 71.01 | - | 70.79 | 71.13 | 6 | 0.2 | 3416 | 40.05 MiB | | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | 70.58 | - | 70.49 | 70.81 | 6 | 0.2 | 3308 | 32.14 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=512` | 70.24 | - | 69.55 | 70.62 | 6 | 0.8 | 3262 | 19.00 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=8192 K=4096 group=128 dtype=fp8a8 M=128` | 70.08 | - | 69.41 | 70.83 | 11 | 0.9 | 3202 | 34.52 MiB | | +| `sample_pick` | `ref_sample_pick` | libref | `n_cand=1024 M=4` | - | 70.00 | 69.22 | 73.14 | 20 | 2.1 | - | 32.39 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=2` | - | 69.79 | 68.56 | 87.30 | 20 | 2.2 | - | 13.52 KiB | 32 thread(s) | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | 69.67 | - | 69.58 | 69.78 | 6 | 0.1 | 3299 | 32.03 MiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-05 dtype=bf16 M=1` | - | 69.64 | 66.95 | 74.77 | 20 | 2.5 | - | 30.00 KiB | 32 thread(s) | +| `sample_argmax` | `sample_argmax_f32` | libr4d | `n_vocab=131072 M=64` | 69.39 | - | 62.64 | 70.62 | 20 | 2.2 | 3436 | 32.01 MiB | | +| `sample_topk` | `sample_topk_f32` | libr4d | `n_vocab=131072 M=32` | 69.14 | - | 69.01 | 69.97 | 6 | 0.7 | 3432 | 16.03 MiB | | +| `grid_embed` | `avx_grid_embed` | libavx | `n=1152 side=48 dtype=bf16 M=2` | - | 68.70 | 67.05 | 79.48 | 20 | 4.9 | - | 5.07 MiB | 32 thread(s) | +| `sample_topp` | `ref_sample_topp` | libref | `n_cand=1024 M=4` | - | 67.75 | 67.32 | 76.38 | 16 | 0.9 | - | 32.38 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4096 K=8192 group=128 dtype=fp8a8 M=128` | 67.61 | - | 67.23 | 67.89 | 6 | 0.5 | 3376 | 34.04 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=5376 K=4096 group=128 dtype=fp8a8 M=129` | 67.54 | - | 67.47 | 67.75 | 6 | 0.2 | 3188 | 22.84 MiB | | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=2304 group=128 dtype=bf16 M=2` | - | 67.03 | 65.81 | 76.36 | 20 | 3.1 | - | 13.64 KiB | 32 thread(s) | +| `kv_store` | `ref_kv_store` | libref | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=2` | - | 66.74 | 65.05 | 74.42 | 20 | 2.1 | - | 104.01 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=4304 dtype=bf16 act=none M=512` | 66.46 | - | 65.50 | 67.39 | 11 | 0.9 | 3284 | 15.91 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=8192 K=4096 group=128 dtype=fp8a8 M=65` | 65.66 | - | 65.08 | 66.16 | 6 | 0.8 | 3380 | 33.28 MiB | | +| `sample_topk` | `sample_topk_f32` | libr4d | `n_vocab=131072 M=8` | 65.42 | - | 63.37 | 77.99 | 20 | 3.0 | 3439 | 4.01 MiB | | +| `sample_topk` | `sample_topk_f32` | libr4d | `n_vocab=131072 M=4` | 65.35 | - | 63.80 | 73.64 | 20 | 1.9 | 3438 | 2.00 MiB | | +| `grid_embed` | `avx_grid_embed` | libavx | `n=1152 side=48 dtype=bf16 M=1` | - | 65.20 | 61.93 | 74.64 | 20 | 1.8 | - | 5.06 MiB | 32 thread(s) | +| `kv_store` | `ref_kv_store` | libref | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=16` | - | 65.11 | 62.79 | 67.07 | 20 | 1.6 | - | 64.06 KiB | 32 thread(s) | +| `silu` | `ref_silu` | libref | `n=1024 dtype=bf16 M=4` | - | 64.98 | 64.76 | 68.70 | 20 | 2.1 | - | 16.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=4304 dtype=bf16 act=none M=256` | 64.85 | - | 64.70 | 65.08 | 6 | 0.3 | 3355 | 12.69 MiB | | +| `silu` | `ref_silu` | libref | `n=2048 dtype=bf16 M=2` | - | 64.82 | 64.56 | 68.25 | 20 | 2.0 | - | 16.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4096 K=8192 group=128 dtype=fp8a8 M=65` | 64.63 | - | 64.49 | 64.70 | 6 | 0.2 | 3376 | 33.04 MiB | | +| `embed_lookup` | `ref_embed_lookup` | libref | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=2` | - | 64.39 | 62.58 | 66.44 | 20 | 2.1 | - | 2.37 GiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=8192 group=128 dtype=fp8a8 M=64` | 64.37 | - | 64.28 | 64.55 | 6 | 0.2 | 3406 | 33.02 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=128` | 63.81 | - | 63.30 | 64.50 | 6 | 0.9 | 3266 | 32.03 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4608 K=4096 group=128 dtype=fp8a8 M=129` | 63.65 | - | 63.29 | 63.75 | 6 | 0.4 | 3226 | 19.66 MiB | | +| `gdn_conv_update` | `gdn_conv_update_w4_h128_bf16` | libr4d | `head_k=128 head_v=128 conv_width=4 q_len=64` | 63.58 | - | 58.77 | 64.08 | 20 | 1.3 | 3265 | 3.87 MiB | restore 5% | +| `sample_topk` | `sample_topk_f32` | libr4d | `n_vocab=131072 M=1` | 63.31 | - | 61.58 | 64.26 | 11 | 0.9 | 3439 | 513.09 KiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4096 K=5376 group=128 dtype=fp8a8 M=129` | 62.90 | - | 62.28 | 63.53 | 6 | 1.0 | 3139 | 22.69 MiB | | +| `grid_embed_cpe` | `avx_grid_embed_cpe` | libavx | `n=1280 side=128 n_prefix=10 dtype=bf16 M=1` | - | 62.39 | 61.86 | 62.78 | 6 | 0.7 | - | 40.03 MiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=65` | 61.40 | - | 61.19 | 61.60 | 6 | 0.3 | 3270 | 31.03 MiB | | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | 61.02 | - | 60.96 | 61.28 | 6 | 0.3 | 3255 | 5.55 MiB | | +| `sample_topk` | `sample_topk_f32` | libr4d | `n_vocab=131072 M=2` | 60.88 | - | 60.61 | 61.56 | 6 | 0.8 | 3438 | 1.00 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=8192 K=4096 group=128 dtype=fp8a8 M=64` | 60.58 | - | 60.39 | 60.67 | 6 | 0.2 | 3408 | 33.26 MiB | | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=512` | 60.51 | - | 60.41 | 61.32 | 11 | 0.7 | 3256 | 13.00 MiB | | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=1024 group=128 dtype=bf16 M=4` | - | 60.46 | 60.25 | 64.31 | 20 | 2.0 | - | 12.12 KiB | 32 thread(s) | +| `sample_minp` | `ref_sample_minp` | libref | `n_cand=1024 M=2` | - | 60.23 | 59.00 | 66.70 | 19 | 0.7 | - | 16.19 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=2048 group=128 dtype=bf16 M=2` | - | 59.44 | 57.59 | 64.02 | 20 | 3.5 | - | 12.12 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=8192 K=4096 group=128 dtype=fp8a8 M=33` | 58.53 | - | 58.50 | 58.66 | 6 | 0.1 | 3424 | 32.65 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=8192 group=128 dtype=fp8a8 M=33` | 58.40 | - | 58.34 | 58.46 | 6 | 0.1 | 3422 | 32.53 MiB | | +| `cast` | `ref_cast` | libref | `n=4096 from=bf16 to=bf16 M=2` | - | 58.30 | 56.45 | 59.86 | 20 | 2.1 | - | 32.00 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=1024 group=128 dtype=bf16 M=4` | - | 58.19 | 57.53 | 68.74 | 20 | 3.9 | - | 12.12 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=8192 K=4096 group=128 dtype=fp8a8 M=32` | 58.18 | - | 58.08 | 58.24 | 6 | 0.1 | 3430 | 32.63 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=8192 K=4096 group=128 dtype=fp8a8 M=18` | 57.87 | - | 57.85 | 58.24 | 6 | 0.3 | 3430 | 32.36 MiB | | +| `sample_xtc` | `ref_sample_xtc` | libref | `n_cand=1024 M=1` | - | 57.76 | 57.06 | 69.88 | 20 | 7.7 | - | 8.09 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=128 ks=0 bk=0 nt=0` | 57.73 | - | 55.09 | 60.31 | 20 | 2.4 | 3348 | 3.71 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=8192 K=4096 group=128 dtype=fp8a8 M=9` | 57.56 | - | 57.35 | 57.61 | 6 | 0.2 | 3434 | 32.18 MiB | | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=8` | - | 57.50 | 57.25 | 61.31 | 20 | 1.6 | - | 11.25 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=64` | 57.38 | - | 57.34 | 57.43 | 6 | 0.1 | 3312 | 31.02 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=8192 K=4096 group=128 dtype=fp8a8 M=8` | 57.30 | - | 57.21 | 57.35 | 6 | 0.1 | 3428 | 32.16 MiB | | +| `scatter_rows` | `ref_scatter_rows` | libref | `n=4096 dtype=bf16 M=2` | - | 57.10 | 52.25 | 68.58 | 20 | 2.0 | - | 80.01 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=8192 K=4096 group=128 dtype=fp8a8 M=4` | 56.99 | - | 56.86 | 57.04 | 11 | 0.1 | 3424 | 32.08 MiB | | +| `act_mul` | `ref_act_mul` | libref | `n=5376 act=relu dtype=bf16 M=1` | - | 56.92 | 55.30 | 60.94 | 20 | 4.2 | - | 31.50 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=8192 K=4096 group=128 dtype=fp8a8 M=1` | 56.91 | - | 56.81 | 56.99 | 6 | 0.2 | 3418 | 32.02 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=8192 group=128 dtype=fp8a8 M=32` | 56.91 | - | 56.88 | 56.97 | 6 | 0.1 | 3422 | 32.51 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=8192 K=4096 group=128 dtype=fp8a8 M=2` | 56.82 | - | 56.75 | 56.92 | 6 | 0.1 | 3424 | 32.04 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=8192 group=128 dtype=fp8a8 M=18` | 56.69 | - | 56.61 | 56.86 | 6 | 0.2 | 3426 | 32.29 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=8192 group=128 dtype=fp8a8 M=8` | 56.69 | - | 56.65 | 56.78 | 6 | 0.1 | 3430 | 32.13 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=8192 group=128 dtype=fp8a8 M=9` | 56.69 | - | 56.64 | 56.80 | 6 | 0.1 | 3429 | 32.15 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=8192 group=128 dtype=fp8a8 M=4` | 56.63 | - | 56.59 | 56.66 | 6 | 0.1 | 3430 | 32.07 MiB | | +| `rope` | `ref_rope` | libref | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=2` | - | 56.58 | 56.10 | 57.32 | 11 | 0.8 | - | 24.02 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=8192 group=128 dtype=fp8a8 M=1` | 56.37 | - | 56.33 | 56.42 | 6 | 0.1 | 3428 | 32.02 MiB | | +| `attn_paged_sink` | `attn_window_sink_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8` | 56.36 | - | 51.73 | 56.57 | 20 | 1.1 | 3230 | 16.13 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=8192 group=128 dtype=fp8a8 M=2` | 56.36 | - | 56.31 | 56.43 | 6 | 0.1 | 3430 | 32.04 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=36` | 55.94 | - | 55.81 | 56.29 | 6 | 0.4 | 3318 | 30.57 MiB | | +| `act_mul` | `ref_act_mul` | libref | `n=1536 act=relu dtype=bf16 M=2` | - | 55.83 | 54.93 | 60.20 | 20 | 3.7 | - | 18.00 KiB | 32 thread(s) | +| `ple_conv_bias` | `ple_conv_bias_bf16` | libr4d | `n=10240 width=4 dilation=1 dtype=bf16 M=64` | 55.07 | - | 51.12 | 56.59 | 20 | 1.4 | 3386 | 5.14 MiB | restore 5% | +| `grid_embed` | `ref_grid_embed` | libref | `n=1152 side=48 dtype=bf16 M=1` | - | 54.92 | 54.14 | 63.99 | 16 | 0.7 | - | 5.06 MiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=18` | 54.41 | - | 54.25 | 54.65 | 6 | 0.4 | 3327 | 30.29 MiB | | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=16` | - | 54.35 | 54.26 | 54.79 | 6 | 0.5 | - | 8.06 KiB | 32 thread(s) | +| `attn_paged_sink` | `attn_window_sink_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8` | 54.19 | - | 51.28 | 54.98 | 20 | 1.2 | 3227 | 2.13 MiB | | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=8` | - | 54.07 | 53.96 | 57.69 | 16 | 0.2 | - | 11.25 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=1` | - | 53.95 | 53.89 | 56.32 | 20 | 1.7 | - | 30.00 KiB | 32 thread(s) | +| `gated_quant_fp8` | `gated_quant_fp8` | libr4d | `n=17408 group=128 dtype=bf16 act=silu M=256` | 53.92 | - | 53.83 | 54.05 | 6 | 0.2 | 3224 | 29.88 MiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=20480 act=relu dtype=bf16 M=256` | 53.86 | - | 53.83 | 53.91 | 6 | 0.1 | 3378 | 30.00 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=9` | 53.65 | - | 53.59 | 53.73 | 6 | 0.1 | 3320 | 30.15 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=8` | 53.54 | - | 53.49 | 53.62 | 6 | 0.1 | 3313 | 30.13 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=4` | 53.18 | - | 53.14 | 53.27 | 6 | 0.1 | 3315 | 30.07 MiB | | +| `sample_argmax` | `sample_argmax_f32` | libr4d | `n_vocab=248320 M=32` | 53.11 | - | 53.09 | 53.17 | 6 | 0.1 | 3434 | 30.32 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=2` | 53.07 | - | 53.04 | 53.15 | 6 | 0.1 | 3314 | 30.04 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5120 K=6144 group=128 dtype=fp8a8 M=1` | 53.05 | - | 53.02 | 53.11 | 6 | 0.1 | 3316 | 30.02 MiB | | +| `grid_embed_cpe` | `ref_grid_embed_cpe` | libref | `n=1280 side=128 n_prefix=10 dtype=bf16 M=1` | - | 53.02 | 52.65 | 53.66 | 6 | 1.0 | - | 40.03 MiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3840 K=1280 dtype=bf16 act=none M=512` | 52.90 | - | 52.79 | 53.15 | 6 | 0.3 | 3176 | 18.13 MiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=1` | - | 51.89 | 50.55 | 56.25 | 20 | 3.9 | - | 30.00 KiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=16` | - | 51.88 | 51.80 | 52.50 | 6 | 0.7 | - | 32.19 KiB | 32 thread(s) | +| `gather_rows` | `ref_gather_rows` | libref | `n=5120 dtype=bf16 M=2` | - | 51.69 | 46.58 | 63.85 | 20 | 16.3 | - | 100.01 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1280 K=5120 dtype=bf16 act=none M=128` | 50.93 | - | 50.82 | 51.16 | 6 | 0.3 | 3418 | 14.38 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4096 K=4096 group=128 dtype=fp8a8 M=129` | 50.52 | - | 49.90 | 50.71 | 6 | 0.8 | 3202 | 17.53 MiB | | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=264` | 50.47 | - | 50.17 | 51.05 | 6 | 0.9 | 3243 | 6.72 MiB | | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | `N=304 K=4096 dtype=bf16 M=128` | 50.45 | - | 50.26 | 50.53 | 6 | 0.3 | 3362 | 5.90 MiB | | +| `ple_conv_bias` | `ple_conv_bias_bf16` | libr4d | `n=10240 width=4 dilation=1 dtype=bf16 M=128` | 50.19 | - | 50.06 | 50.60 | 6 | 0.5 | 3370 | 10.14 MiB | restore 8% | +| `add` | `ref_add` | libref | `n=5120 dtype=bf16 M=1` | - | 49.96 | 46.74 | 54.24 | 20 | 2.6 | - | 30.00 KiB | 32 thread(s) | +| `rope_table` | `avx_rope_table` | libavx | `rot=64 theta=1e+07 scale=1 dtype=f32 M=64` | - | 49.08 | 47.88 | 51.48 | 20 | 2.2 | - | 16.25 KiB | 32 thread(s) | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8 splits=0` | 49.04 | - | 49.03 | 49.43 | 6 | 0.4 | 3314 | 16.13 MiB | | +| `attn_paged_sink` | `attn_window_sink_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2` | 48.96 | - | 41.15 | 50.05 | 20 | 2.8 | 3238 | 16.04 MiB | | +| `attn_paged_sink` | `attn_window_sink_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4` | 48.63 | - | 42.05 | 50.37 | 20 | 2.3 | 3246 | 16.07 MiB | | +| `attn_paged_sink` | `attn_window_sink_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4` | 48.22 | - | 45.99 | 50.54 | 19 | 0.4 | 3239 | 2.06 MiB | | +| `scatter_rows` | `ref_scatter_rows` | libref | `n=5120 dtype=bf16 M=2` | - | 48.08 | 48.05 | 48.28 | 11 | 0.2 | - | 100.01 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=5376 K=4096 group=128 dtype=fp8a8 M=128` | 47.77 | - | 47.57 | 47.88 | 6 | 0.3 | 3380 | 22.83 MiB | | +| `act_mul` | `ref_act_mul` | libref | `n=2304 act=relu dtype=bf16 M=2` | - | 47.53 | 47.50 | 50.53 | 20 | 1.1 | - | 27.00 KiB | 32 thread(s) | +| `attn_paged_sink` | `attn_window_sink_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2` | 47.42 | - | 44.26 | 48.04 | 20 | 3.6 | 3237 | 2.03 MiB | | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=8` | - | 47.32 | 46.46 | 50.93 | 20 | 3.3 | - | 9.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3456 K=1152 dtype=bf16 act=none M=512` | 47.21 | - | 46.81 | 47.38 | 6 | 0.6 | 3222 | 15.48 MiB | | +| `mul_weight` | `avx_mul_weight` | libavx | `n=8192 dtype=bf16 M=1` | - | 47.13 | 38.89 | 49.21 | 20 | 2.8 | - | 48.00 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | `N=1280 K=2304 dtype=bf16 M=512 tile=0` | 46.83 | - | 46.67 | 47.51 | 6 | 0.9 | 3361 | 9.12 MiB | | +| `moe_scatter` | `ref_moe_scatter` | libref | `n_expert=240 top_k=9 expert_base=0 M=512` | - | 46.80 | 45.17 | 51.41 | 20 | 3.1 | - | 37.88 KiB | 32 thread(s) | +| `attn_dense` | `ref_attn_dense` | libref | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=8` | - | 46.74 | 46.62 | 48.62 | 20 | 1.9 | - | 4.51 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=1280 dtype=bf16 act=gelu M=256` | 46.71 | - | 46.56 | 46.89 | 6 | 0.4 | 3292 | 18.13 MiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=512` | 46.68 | - | 46.22 | 46.74 | 6 | 0.6 | 3389 | 3.38 MiB | restore 9% | +| `ple_conv_bias` | `ple_conv_bias_bf16` | libr4d | `n=10240 width=4 dilation=1 dtype=bf16 M=32` | 46.54 | - | 44.05 | 48.73 | 20 | 3.3 | 3382 | 2.64 MiB | restore 6% | +| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=32` | - | 46.33 | 44.64 | 61.04 | 20 | 9.7 | - | 20.01 KiB | 32 thread(s) | +| `moe_scatter` | `ref_moe_scatter` | libref | `n_expert=304 top_k=9 expert_base=0 M=512` | - | 45.72 | 45.69 | 48.56 | 20 | 2.8 | - | 38.38 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=5376 K=4096 group=128 dtype=fp8a8 M=65` | 45.68 | - | 45.58 | 45.77 | 6 | 0.2 | 3372 | 21.93 MiB | | +| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=32` | - | 45.56 | 42.98 | 66.52 | 20 | 7.3 | - | 18.01 KiB | 32 thread(s) | +| `gdn_gated_rmsnorm` | `ref_gdn_gated_rmsnorm` | libref | `channels=128 eps=1e-06 act=silu M=16` | - | 45.36 | 42.11 | 50.16 | 20 | 5.0 | - | 12.50 KiB | 32 thread(s) | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=8` | - | 45.19 | 44.88 | 47.74 | 20 | 2.5 | - | 9.00 KiB | 32 thread(s) | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=6 splits=0` | 44.77 | - | 44.68 | 44.88 | 6 | 0.2 | 3335 | 16.10 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=4096 dtype=bf16 act=none M=256` | 44.33 | - | 43.84 | 44.59 | 6 | 0.8 | 3332 | 11.00 MiB | | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | `N=304 K=4096 dtype=bf16 M=64` | 44.29 | - | 42.72 | 46.80 | 20 | 3.5 | 3127 | 5.32 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=4304 dtype=bf16 act=none M=128` | 44.25 | - | 44.01 | 44.63 | 6 | 0.7 | 3392 | 11.07 MiB | | +| `sample_mask` | `sample_mask_f32` | libr4d | `n_vocab=131072 M=64` | 43.96 | - | 43.54 | 44.73 | 14 | 0.6 | 3430 | 33.01 MiB | restore 50% | +| `act_mul` | `act_mul_bf16` | libr4d | `n=8192 act=silu dtype=bf16 M=512` | 43.96 | - | 43.94 | 44.02 | 6 | 0.1 | 3418 | 24.00 MiB | | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | `N=240 K=4096 dtype=bf16 M=128` | 43.83 | - | 43.47 | 44.03 | 6 | 0.6 | 3378 | 4.87 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4608 K=4096 group=128 dtype=fp8a8 M=128` | 43.69 | - | 43.61 | 43.88 | 6 | 0.3 | 3376 | 19.64 MiB | | +| `kv_store` | `ref_kv_store` | libref | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=2` | - | 43.56 | 42.09 | 54.52 | 20 | 12.3 | - | 104.01 KiB | 32 thread(s) | +| `attn_paged_sink` | `attn_window_sink_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1` | 43.48 | - | 38.21 | 44.51 | 20 | 2.5 | 3240 | 2.02 MiB | | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=2048 group=128 dtype=bf16 M=1` | - | 43.44 | 42.65 | 47.79 | 20 | 2.8 | - | 6.06 KiB | 32 thread(s) | +| `gdn_conv_update` | `gdn_conv_update_w4_h128_bf16` | libr4d | `head_k=128 head_v=128 conv_width=4 q_len=32` | 43.27 | - | 41.04 | 43.59 | 20 | 1.5 | 3263 | 1.99 MiB | restore 6% | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=5 splits=0` | 43.26 | - | 43.14 | 43.70 | 6 | 0.7 | 3356 | 16.08 MiB | | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=512` | 42.89 | - | 42.50 | 43.26 | 6 | 0.9 | 3323 | 8.50 MiB | | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=1536 group=128 dtype=bf16 M=2` | - | 42.72 | 41.96 | 46.21 | 20 | 3.6 | - | 9.09 KiB | 32 thread(s) | +| `add` | `ref_add` | libref | `n=4096 dtype=bf16 M=1` | - | 42.64 | 41.15 | 45.69 | 20 | 3.1 | - | 24.00 KiB | 32 thread(s) | +| `act_mul` | `ref_act_mul` | libref | `n=2048 act=relu dtype=bf16 M=2` | - | 42.59 | 42.26 | 46.56 | 19 | 0.8 | - | 24.00 KiB | 32 thread(s) | +| `layernorm` | `ref_layernorm` | libref | `n=1280 eps=1e-06 dtype=bf16 M=2` | - | 42.58 | 40.52 | 46.99 | 20 | 5.4 | - | 15.00 KiB | 32 thread(s) | +| `attn_paged_sink` | `attn_window_sink_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1` | 42.16 | - | 38.97 | 44.14 | 20 | 3.2 | 3240 | 16.02 MiB | | +| `quant_act_i8` | `ref_quant_act_i8` | libref | `n=5120 group=128 dtype=bf16 M=1` | - | 41.99 | 41.30 | 46.50 | 20 | 3.1 | - | 17.50 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4096 K=5376 group=128 dtype=fp8a8 M=128` | 41.95 | - | 41.91 | 42.04 | 6 | 0.2 | 3362 | 22.68 MiB | | +| `gdn_recurrent_update` | `gdn_recurrent_update_k128_v128_bf16_fp32state` | libr4d | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=16` | 41.92 | - | 41.69 | 42.43 | 6 | 0.9 | 3290 | 48.69 MiB | restore 80%; restore-dominated (80% of the batch): an order of magnitude | +| `sample_topp` | `ref_sample_topp` | libref | `n_cand=1024 M=1` | - | 41.89 | 41.60 | 42.09 | 6 | 0.6 | - | 8.09 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4608 K=4096 group=128 dtype=fp8a8 M=65` | 41.82 | - | 41.78 | 41.97 | 6 | 0.2 | 3382 | 18.84 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5376 K=4096 group=128 dtype=fp8a8 M=64` | 41.48 | - | 41.40 | 41.80 | 6 | 0.5 | 3385 | 21.92 MiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=16` | - | 41.22 | 39.90 | 42.96 | 20 | 2.3 | - | 16.50 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=5376 group=128 dtype=fp8a8 M=64` | 41.17 | - | 40.97 | 41.38 | 6 | 0.5 | 3392 | 21.84 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4096 K=5376 group=128 dtype=fp8a8 M=65` | 41.08 | - | 40.99 | 41.15 | 6 | 0.2 | 3342 | 21.85 MiB | | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | `N=240 K=4096 dtype=bf16 M=64` | 41.07 | - | 40.59 | 41.75 | 16 | 0.6 | 3421 | 4.31 MiB | | +| `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | `head_k=128 head_v=128 scale=0.0883883 M=256 chunk=64` | 41.02 | - | 40.93 | 41.15 | 6 | 0.3 | 3232 | 15.59 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=4096 dtype=bf16 act=none M=448` | 40.84 | - | 40.77 | 41.04 | 6 | 0.3 | 3285 | 13.25 MiB | | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4 splits=0` | 40.75 | - | 40.46 | 42.05 | 20 | 1.8 | 3292 | 16.07 MiB | | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | `N=1280 K=2304 dtype=bf16 M=260 tile=0` | 40.69 | - | 40.64 | 40.72 | 6 | 0.1 | 3408 | 7.40 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=256` | 40.47 | - | 40.15 | 40.53 | 6 | 0.5 | 3349 | 14.23 MiB | | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2 splits=0` | 40.26 | - | 40.07 | 40.43 | 6 | 0.5 | 3226 | 16.04 MiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=1024 eps=1e-06 dtype=bf16 M=4` | - | 40.23 | 39.65 | 41.72 | 20 | 2.3 | - | 18.00 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=32` | - | 40.23 | 40.19 | 42.97 | 20 | 1.3 | - | 16.25 KiB | 32 thread(s) | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=25600 group=128 dtype=bf16 M=256` | 39.94 | - | 39.35 | 40.13 | 11 | 0.6 | 3295 | 18.95 MiB | | +| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=131072 M=64` | 39.78 | - | 39.47 | 39.89 | 6 | 0.5 | 3428 | 32.01 MiB | restore 53% | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=5376 group=128 dtype=fp8a8 M=33` | 39.77 | - | 39.67 | 39.83 | 6 | 0.2 | 3404 | 21.43 MiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=4096 eps=1e-05 dtype=bf16 M=1` | - | 39.69 | 39.62 | 43.01 | 20 | 3.9 | - | 24.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4096 K=4096 group=128 dtype=fp8a8 M=128` | 39.64 | - | 39.44 | 39.82 | 6 | 0.5 | 3364 | 17.52 MiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=1` | - | 39.61 | 39.60 | 42.18 | 20 | 2.0 | - | 24.00 KiB | 32 thread(s) | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=260` | 39.60 | - | 36.86 | 42.33 | 20 | 2.6 | 3383 | 4.33 MiB | | +| `sample_mask` | `sample_mask_f32` | libr4d | `n_vocab=248320 M=32` | 39.38 | - | 38.79 | 39.48 | 11 | 0.3 | 3423 | 31.26 MiB | restore 51% | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=1280 dtype=bf16 act=gelu M=128` | 39.32 | - | 39.31 | 39.49 | 6 | 0.2 | 3418 | 15.32 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5376 K=4096 group=128 dtype=fp8a8 M=32` | 39.28 | - | 39.26 | 39.59 | 6 | 0.4 | 3416 | 21.46 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=5376 group=128 dtype=fp8a8 M=32` | 39.22 | - | 39.14 | 39.24 | 6 | 0.1 | 3388 | 21.42 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5376 K=4096 group=128 dtype=fp8a8 M=33` | 39.21 | - | 39.18 | 39.28 | 6 | 0.1 | 3413 | 21.47 MiB | | +| `sample_pick` | `avx_sample_pick` | libavx | `n_cand=1024 M=1` | - | 39.13 | 20.43 | 41.58 | 40 | 6.7 | - | 8.10 KiB | 32 thread(s) | +| `layernorm` | `ref_layernorm` | libref | `n=1152 eps=1e-06 dtype=bf16 M=2` | - | 39.07 | 38.99 | 40.10 | 20 | 1.3 | - | 13.50 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5376 K=4096 group=128 dtype=fp8a8 M=18` | 38.98 | - | 38.94 | 39.04 | 6 | 0.1 | 3425 | 21.26 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=5376 group=128 dtype=fp8a8 M=18` | 38.80 | - | 38.69 | 38.86 | 6 | 0.2 | 3424 | 21.24 MiB | | +| `gather_rows` | `ref_gather_rows` | libref | `n=1280 dtype=bf16 M=4` | - | 38.64 | 37.17 | 541.13 | 20 | 5.6 | - | 50.02 KiB | 32 thread(s) | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | 38.62 | - | 38.39 | 38.68 | 6 | 0.4 | 3277 | 4.77 MiB | | +| `moe_scatter` | `avx_moe_scatter` | libavx | `n_expert=240 top_k=9 expert_base=0 M=512` | - | 38.52 | 37.61 | 42.03 | 20 | 4.2 | - | 37.88 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5376 K=4096 group=128 dtype=fp8a8 M=9` | 38.45 | - | 38.41 | 38.52 | 6 | 0.1 | 3432 | 21.13 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5376 K=4096 group=128 dtype=fp8a8 M=8` | 38.37 | - | 38.33 | 38.40 | 6 | 0.1 | 3426 | 21.12 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=5376 group=128 dtype=fp8a8 M=9` | 38.31 | - | 38.24 | 38.34 | 6 | 0.1 | 3428 | 21.12 MiB | | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | 38.28 | - | 38.24 | 38.42 | 6 | 0.2 | 3312 | 4.75 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=5376 group=128 dtype=fp8a8 M=8` | 38.28 | - | 38.19 | 38.33 | 6 | 0.2 | 3430 | 21.11 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5376 K=4096 group=128 dtype=fp8a8 M=4` | 38.23 | - | 38.19 | 38.24 | 6 | 0.1 | 3432 | 21.06 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5376 K=4096 group=128 dtype=fp8a8 M=1` | 38.21 | - | 38.20 | 38.32 | 6 | 0.2 | 3431 | 21.02 MiB | | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=4` | - | 38.20 | 38.18 | 38.60 | 6 | 0.5 | - | 8.02 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=5376 K=4096 group=128 dtype=fp8a8 M=2` | 38.18 | - | 38.15 | 38.21 | 6 | 0.1 | 3430 | 21.03 MiB | | +| `gated_quant_fp8` | `gated_quant_fp8` | libr4d | `n=17408 group=128 dtype=bf16 act=silu M=128` | 38.17 | - | 38.07 | 38.34 | 6 | 0.4 | 3237 | 14.94 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4096 K=4096 group=128 dtype=fp8a8 M=65` | 38.13 | - | 37.91 | 38.29 | 6 | 0.5 | 3354 | 16.77 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=1280 dtype=bf16 act=gelu M=64` | 38.07 | - | 38.01 | 38.12 | 6 | 0.1 | 3424 | 13.92 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=5376 group=128 dtype=fp8a8 M=4` | 38.06 | - | 37.94 | 38.27 | 6 | 0.4 | 3428 | 21.05 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1280 K=5120 dtype=bf16 act=none M=64` | 38.06 | - | 37.91 | 38.30 | 6 | 0.5 | 3432 | 13.44 MiB | | +| `moe_scatter` | `avx_moe_scatter` | libavx | `n_expert=304 top_k=9 expert_base=0 M=512` | - | 37.95 | 37.92 | 40.12 | 20 | 1.5 | - | 38.38 KiB | 32 thread(s) | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=24576 group=128 dtype=bf16 M=256` | 37.87 | - | 37.75 | 38.28 | 6 | 0.7 | 3288 | 18.19 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=5376 group=128 dtype=fp8a8 M=2` | 37.87 | - | 37.79 | 37.89 | 6 | 0.1 | 3432 | 21.03 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1280 K=5120 dtype=bf16 act=none M=32` | 37.83 | - | 37.61 | 37.93 | 6 | 0.4 | 3434 | 12.97 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=5376 group=128 dtype=fp8a8 M=1` | 37.80 | - | 37.72 | 37.81 | 6 | 0.1 | 3431 | 21.02 MiB | | +| `rope_table` | `ref_rope_table` | libref | `rot=64 theta=1e+07 scale=1 dtype=f32 M=16` | - | 37.72 | 36.53 | 39.43 | 20 | 2.6 | - | 4.06 KiB | 32 thread(s) | +| `sample_topp` | `avx_sample_topp` | libavx | `n_cand=1024 M=1` | - | 37.48 | 18.37 | 49.98 | 30 | 1.0 | - | 8.09 KiB | 32 thread(s) | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1 splits=0` | 37.41 | - | 37.40 | 37.60 | 6 | 0.3 | 3424 | 16.02 MiB | | +| `gather_rows` | `ref_gather_rows` | libref | `n=4096 dtype=bf16 M=2` | - | 37.39 | 37.38 | 40.43 | 20 | 3.2 | - | 80.01 KiB | 32 thread(s) | +| `mul_weight` | `mul_weight_bf16` | libr4d | `n=8192 dtype=bf16 M=512` | 36.80 | - | 36.56 | 36.84 | 6 | 0.4 | 3420 | 16.02 MiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=1024 eps=1e-05 dtype=bf16 M=4` | - | 36.19 | 34.73 | 41.79 | 20 | 8.2 | - | 16.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1280 K=5120 dtype=bf16 act=none M=16` | 36.16 | - | 36.07 | 36.27 | 6 | 0.3 | 3435 | 12.74 MiB | | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | 36.14 | - | 34.84 | 38.46 | 20 | 3.0 | 3302 | 4.38 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1280 K=5120 dtype=bf16 act=none M=8` | 36.13 | - | 36.02 | 36.31 | 6 | 0.4 | 3430 | 12.62 MiB | | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=11` | 35.73 | - | 34.41 | 38.47 | 20 | 4.1 | 3130 | 4.26 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4608 K=4096 group=128 dtype=fp8a8 M=64` | 35.72 | - | 35.65 | 35.76 | 6 | 0.1 | 3392 | 18.82 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3072 K=1024 dtype=bf16 act=none M=448` | 35.53 | - | 35.47 | 35.65 | 6 | 0.2 | 3204 | 12.13 MiB | | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=1` | - | 35.35 | 35.28 | 35.92 | 11 | 0.9 | - | 8.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1280 K=5120 dtype=bf16 act=none M=4` | 35.32 | - | 35.23 | 35.40 | 6 | 0.2 | 3436 | 12.56 MiB | | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=17` | 35.23 | - | 34.89 | 35.50 | 6 | 0.9 | 3312 | 4.40 MiB | | +| `embed_lookup` | `ref_embed_lookup` | libref | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=2` | - | 35.13 | 34.02 | 39.06 | 20 | 2.7 | - | 1.00 GiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=1280 K=5120 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | 35.11 | - | 35.07 | 35.34 | 6 | 0.4 | 3415 | 13.28 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1280 K=5120 dtype=bf16 act=none M=2` | 35.02 | - | 34.97 | 35.23 | 6 | 0.4 | 3431 | 12.53 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_tiled` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=512 tn=0` | 34.91 | - | 34.74 | 35.13 | 6 | 0.6 | 3262 | 6.39 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1280 K=5120 dtype=bf16 act=none M=1` | 34.86 | - | 34.78 | 34.96 | 6 | 0.3 | 3436 | 12.52 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=8192 group=128 dtype=bf16 M=512` | 34.69 | - | 34.50 | 34.85 | 6 | 0.5 | 3426 | 12.12 MiB | | +| `embed_lookup` | `ref_embed_lookup` | libref | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=1` | - | 34.57 | 34.01 | 36.09 | 20 | 2.3 | - | 2.37 GiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=1` | - | 34.25 | 33.73 | 35.28 | 14 | 0.6 | - | 6.76 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4608 K=4096 group=128 dtype=fp8a8 M=33` | 34.17 | - | 34.15 | 34.22 | 6 | 0.1 | 3416 | 18.43 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=3072 dtype=bf16 act=none M=256` | 34.12 | - | 34.00 | 34.33 | 6 | 0.5 | 3396 | 8.50 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4608 K=4096 group=128 dtype=fp8a8 M=32` | 34.10 | - | 34.07 | 34.12 | 6 | 0.1 | 3420 | 18.41 MiB | | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=1` | - | 33.95 | 33.71 | 34.32 | 6 | 0.9 | - | 8.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4608 K=4096 group=128 dtype=fp8a8 M=18` | 33.93 | - | 33.91 | 34.00 | 6 | 0.1 | 3430 | 18.23 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_tiled` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=258 tn=0` | 33.87 | - | 33.70 | 33.95 | 6 | 0.4 | 3302 | 4.62 MiB | | +| `kv_store` | `ref_kv_store` | libref | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=8` | - | 33.78 | 32.60 | 34.37 | 16 | 0.9 | - | 56.03 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4608 K=4096 group=128 dtype=fp8a8 M=9` | 33.39 | - | 33.37 | 33.41 | 6 | 0.1 | 3432 | 18.12 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=128` | 33.32 | - | 33.07 | 33.51 | 6 | 0.7 | 3352 | 11.85 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4608 K=4096 group=128 dtype=fp8a8 M=8` | 33.31 | - | 33.26 | 33.35 | 6 | 0.1 | 3432 | 18.10 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=4096 dtype=bf16 act=none M=128` | 33.31 | - | 33.10 | 33.56 | 6 | 0.7 | 3341 | 9.50 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4608 K=4096 group=128 dtype=fp8a8 M=4` | 33.29 | - | 33.25 | 33.34 | 6 | 0.1 | 3428 | 18.05 MiB | | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=32` | - | 33.29 | 33.27 | 33.88 | 6 | 0.9 | - | 16.12 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4608 K=4096 group=128 dtype=fp8a8 M=2` | 33.22 | - | 33.14 | 33.24 | 6 | 0.1 | 3431 | 18.03 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4608 K=4096 group=128 dtype=fp8a8 M=1` | 33.21 | - | 33.18 | 33.25 | 6 | 0.1 | 3432 | 18.02 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_tiled` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=129 tn=0` | 32.92 | - | 32.81 | 33.00 | 6 | 0.3 | 3356 | 3.71 MiB | | +| `moe_gather` | `avx_moe_gather` | libavx | `n=1024 top_k=9 dtype=bf16 act=none M=1` | - | 32.89 | 31.45 | 35.25 | 20 | 2.5 | - | 22.05 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=4096 dtype=bf16 act=none M=64` | 32.72 | - | 32.35 | 32.79 | 11 | 0.3 | 3349 | 8.75 MiB | | +| `silu` | `ref_silu` | libref | `n=1024 dtype=bf16 M=2` | - | 32.67 | 32.56 | 34.35 | 20 | 2.1 | - | 8.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=65` | 32.57 | - | 32.47 | 32.71 | 6 | 0.4 | 2844 | 5.45 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=4096 group=128 dtype=fp8a8 M=64` | 32.53 | - | 32.51 | 32.55 | 6 | 0.1 | 3384 | 16.76 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=3072 dtype=bf16 act=none M=448` | 32.52 | - | 32.13 | 32.79 | 11 | 0.7 | 3339 | 10.38 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=4096 dtype=bf16 act=none M=56` | 32.51 | - | 32.40 | 32.67 | 6 | 0.4 | 3338 | 8.66 MiB | | +| `silu` | `ref_silu` | libref | `n=2048 dtype=bf16 M=1` | - | 32.30 | 30.66 | 35.44 | 20 | 4.0 | - | 8.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=512` | 32.22 | - | 32.13 | 32.32 | 6 | 0.3 | 3153 | 8.58 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=4096 dtype=bf16 act=none M=32` | 32.00 | - | 31.91 | 32.14 | 6 | 0.4 | 3336 | 8.38 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=64` | 31.74 | - | 31.72 | 31.76 | 6 | 0.1 | 3414 | 10.66 MiB | | +| `kv_store` | `ref_kv_store` | libref | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=1` | - | 31.62 | 29.94 | 35.94 | 20 | 3.0 | - | 100.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=4304 dtype=bf16 act=none M=64` | 31.18 | - | 31.16 | 31.37 | 6 | 0.3 | 3399 | 10.27 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=4096 dtype=bf16 act=none M=16` | 31.05 | - | 30.99 | 31.43 | 6 | 0.7 | 3336 | 8.19 MiB | | +| `act_mul` | `avx_act_mul` | libavx | `n=1536 act=relu dtype=bf16 M=8` | - | 30.98 | 30.70 | 33.17 | 20 | 2.0 | - | 72.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=4096 dtype=bf16 act=none M=8` | 30.97 | - | 30.92 | 31.17 | 6 | 0.4 | 3334 | 8.10 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=4096 group=128 dtype=fp8a8 M=33` | 30.86 | - | 30.85 | 30.87 | 6 | 0.0 | 3396 | 16.39 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=4304 dtype=bf16 act=none M=32` | 30.81 | - | 30.77 | 30.84 | 6 | 0.1 | 3407 | 9.86 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=1280 dtype=bf16 act=gelu M=32` | 30.77 | - | 30.74 | 30.84 | 6 | 0.2 | 3382 | 13.21 MiB | | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=2304 group=128 dtype=bf16 M=1` | - | 30.76 | 29.74 | 33.37 | 20 | 3.8 | - | 6.82 KiB | 32 thread(s) | +| `cast` | `ref_cast` | libref | `n=4096 from=bf16 to=bf16 M=1` | - | 30.72 | 29.46 | 177.80 | 20 | 4.3 | - | 16.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=4096 dtype=bf16 act=none M=4` | 30.67 | - | 30.52 | 30.71 | 6 | 0.3 | 3325 | 8.05 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=4096 group=128 dtype=fp8a8 M=32` | 30.48 | - | 30.46 | 30.49 | 6 | 0.0 | 3379 | 16.38 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=258` | 30.44 | - | 30.03 | 30.61 | 6 | 1.0 | 3211 | 6.80 MiB | | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=512` | 30.40 | - | 30.30 | 30.74 | 6 | 0.7 | 3240 | 17.59 MiB | restore 23% | +| `sample_argmax` | `sample_argmax_f32` | libr4d | `n_vocab=131072 M=32` | 30.27 | - | 30.24 | 30.30 | 6 | 0.1 | 3434 | 16.00 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=4096 group=128 dtype=fp8a8 M=18` | 30.20 | - | 30.17 | 30.30 | 6 | 0.2 | 3398 | 16.22 MiB | | +| `sample_ngram_ban` | `ref_sample_ngram_ban` | libref | `n_vocab=131072 M=64` | - | 30.17 | 26.21 | 36.51 | 20 | 3.9 | - | 33.02 MiB | 32 thread(s) | +| `sample_temp` | `ref_sample_temp` | libref | `n_vocab=1024 M=8` | - | 30.17 | 30.14 | 37.20 | 14 | 0.2 | - | 32.75 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=4096 dtype=bf16 act=none M=2` | 30.16 | - | 30.06 | 30.22 | 6 | 0.3 | 3328 | 8.03 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=4096 group=128 dtype=fp8a8 M=4` | 30.14 | - | 30.08 | 30.18 | 6 | 0.2 | 3394 | 16.05 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=4096 group=128 dtype=fp8a8 M=9` | 30.14 | - | 30.11 | 30.19 | 6 | 0.1 | 3398 | 16.11 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=4096 group=128 dtype=fp8a8 M=8` | 30.09 | - | 30.06 | 30.25 | 6 | 0.3 | 3392 | 16.10 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=4304 dtype=bf16 act=none M=1` | 30.04 | - | 27.80 | 31.93 | 20 | 5.2 | 3064 | 9.47 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=4096 dtype=bf16 act=none M=1` | 30.00 | - | 29.90 | 30.08 | 11 | 0.3 | 3324 | 8.01 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=4096 group=128 dtype=fp8a8 M=2` | 29.95 | - | 29.92 | 30.06 | 6 | 0.2 | 3394 | 16.03 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=4096 group=128 dtype=fp8a8 M=1` | 29.91 | - | 29.90 | 29.96 | 6 | 0.1 | 3384 | 16.01 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3840 K=1280 dtype=bf16 act=none M=128` | 29.50 | - | 29.49 | 29.77 | 6 | 0.5 | 3397 | 11.57 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=129` | 29.46 | - | 29.26 | 29.65 | 6 | 0.7 | 3235 | 5.90 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=1280 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | 29.45 | - | 29.36 | 29.53 | 6 | 0.3 | 3436 | 12.92 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3840 K=1280 dtype=bf16 act=none M=256` | 29.39 | - | 29.09 | 29.43 | 6 | 0.6 | 3327 | 13.76 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=128` | 29.39 | - | 28.65 | 32.61 | 20 | 5.8 | 3168 | 5.90 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | 29.34 | - | 29.16 | 29.44 | 6 | 0.5 | 3418 | 12.13 MiB | | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | `N=128 K=4096 dtype=bf16 M=512 tile=0` | 29.33 | - | 29.25 | 29.44 | 6 | 0.3 | 3356 | 5.12 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=4304 dtype=bf16 act=none M=16` | 29.17 | - | 29.10 | 29.32 | 6 | 0.4 | 3416 | 9.66 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=4304 dtype=bf16 act=none M=8` | 29.14 | - | 29.07 | 29.22 | 6 | 0.3 | 3414 | 9.56 MiB | | +| `moe_gather` | `moe_gather_bf16` | libr4d | `n=1024 top_k=9 dtype=bf16 act=none M=512` | 29.09 | - | 28.65 | 29.53 | 14 | 0.8 | 3432 | 11.03 MiB | | +| `act_mul` | `avx_act_mul` | libavx | `n=8192 act=silu dtype=bf16 M=1` | - | 29.03 | 27.01 | 30.60 | 20 | 3.7 | - | 48.00 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | `N=128 K=4096 dtype=bf16 M=260 tile=0` | 28.96 | - | 28.88 | 29.11 | 6 | 0.4 | 3363 | 3.09 MiB | | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | `N=128 K=4096 dtype=bf16 M=65 tile=0` | 28.94 | - | 28.89 | 29.10 | 6 | 0.4 | 3362 | 1.52 MiB | | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | `N=128 K=4096 dtype=bf16 M=130 tile=0` | 28.91 | - | 28.88 | 28.96 | 6 | 0.2 | 3363 | 2.05 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | 28.80 | - | 28.71 | 28.88 | 6 | 0.3 | 3264 | 12.07 MiB | | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=4` | - | 28.79 | 28.75 | 31.04 | 16 | 0.2 | - | 6.22 KiB | 32 thread(s) | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-05 dtype=bf16 M=512` | 28.78 | - | 26.05 | 30.45 | 20 | 4.1 | 3431 | 10.01 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=1280 dtype=bf16 act=gelu M=16` | 28.70 | - | 28.57 | 28.78 | 6 | 0.4 | 3376 | 12.86 MiB | | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=2` | - | 28.68 | 28.57 | 28.91 | 11 | 0.6 | - | 80.31 KiB | 32 thread(s) | +| `sample_argmax` | `sample_argmax_f32` | libr4d | `n_vocab=248320 M=16` | 28.58 | - | 28.53 | 28.62 | 6 | 0.2 | 3437 | 15.16 MiB | | +| `act_mul` | `ref_act_mul` | libref | `n=1536 act=relu dtype=bf16 M=1` | - | 28.48 | 27.05 | 30.52 | 20 | 2.3 | - | 9.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=1280 dtype=bf16 act=gelu M=8` | 28.46 | - | 28.28 | 28.57 | 6 | 0.5 | 3387 | 12.69 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=4304 dtype=bf16 act=none M=4` | 28.42 | - | 28.38 | 28.46 | 6 | 0.1 | 3411 | 9.51 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=1280 dtype=bf16 act=gelu M=2` | 28.24 | - | 28.18 | 28.30 | 6 | 0.2 | 3385 | 12.55 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=1280 dtype=bf16 act=gelu M=4` | 28.23 | - | 28.18 | 28.31 | 6 | 0.2 | 3372 | 12.60 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=5120 K=1280 dtype=bf16 act=gelu M=1` | 28.16 | - | 28.11 | 28.34 | 6 | 0.4 | 3390 | 12.53 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=4304 dtype=bf16 act=none M=2` | 28.07 | - | 27.98 | 28.16 | 6 | 0.3 | 3424 | 9.48 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4096 K=1024 group=128 dtype=fp8a8 M=512` | 27.99 | - | 27.93 | 28.17 | 6 | 0.4 | 3144 | 8.52 MiB | | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=1536 group=128 dtype=bf16 M=8` | - | 27.82 | 22.86 | 37.47 | 20 | 24.9 | - | 36.38 KiB | 32 thread(s) | +| `sample_pick` | `ref_sample_pick` | libref | `n_cand=1024 M=1` | - | 27.76 | 27.15 | 28.57 | 20 | 1.9 | - | 8.10 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=1024 group=128 dtype=bf16 M=2` | - | 27.75 | 27.49 | 29.32 | 20 | 2.4 | - | 6.06 KiB | 32 thread(s) | +| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=248320 M=32` | 27.74 | - | 27.51 | 27.82 | 11 | 0.2 | 3406 | 30.32 MiB | restore 59% | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=8` | - | 27.49 | 27.38 | 37.53 | 14 | 0.9 | - | 4.03 KiB | 32 thread(s) | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=512` | 27.47 | - | 25.75 | 28.34 | 20 | 2.8 | 3300 | 10.01 MiB | | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=512` | 27.41 | - | 27.17 | 27.62 | 11 | 0.6 | 3327 | 14.07 MiB | restore 43% | +| `embed_lookup` | `ref_embed_lookup` | libref | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=1` | - | 27.23 | 23.31 | 31.23 | 20 | 11.7 | - | 1.00 GiB | 32 thread(s) | +| `rope` | `ref_rope` | libref | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=1` | - | 27.13 | 26.91 | 27.50 | 11 | 0.9 | - | 12.01 KiB | 32 thread(s) | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=512` | 27.12 | - | 25.48 | 29.09 | 20 | 4.0 | 3282 | 10.01 MiB | | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=4` | - | 27.05 | 26.91 | 29.06 | 16 | 0.7 | - | 6.22 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=1280 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | 26.96 | - | 26.89 | 27.00 | 6 | 0.2 | 3444 | 12.70 MiB | | +| `add` | `add_bf16` | libr4d | `n=5120 dtype=bf16 M=512` | 26.89 | - | 24.83 | 27.51 | 20 | 2.0 | 3224 | 15.00 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=1024 K=4096 group=128 dtype=fp8a8 M=512` | 26.85 | - | 26.75 | 27.11 | 6 | 0.7 | 3334 | 7.06 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3456 K=1152 dtype=bf16 act=none M=128` | 26.77 | - | 26.73 | 26.81 | 6 | 0.2 | 3408 | 9.57 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=1280 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | 26.75 | - | 26.73 | 26.79 | 6 | 0.1 | 3440 | 12.71 MiB | | +| `rope` | `ref_rope` | libref | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=8` | - | 26.72 | 26.60 | 27.26 | 14 | 0.6 | - | 16.09 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=1280 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | 26.40 | - | 26.36 | 26.42 | 6 | 0.1 | 3446 | 12.60 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=1280 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | 26.19 | - | 26.16 | 26.21 | 6 | 0.1 | 3447 | 12.55 MiB | | +| `moe_scatter` | `ref_moe_scatter` | libref | `n_expert=240 top_k=9 expert_base=0 M=256` | - | 26.17 | 24.64 | 35.59 | 20 | 20.6 | - | 19.88 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1536 dtype=bf16 act=none M=512` | 26.16 | - | 26.08 | 26.49 | 6 | 0.8 | 3344 | 7.13 MiB | | +| `sample_xtc` | `avx_sample_xtc` | libavx | `n_cand=1024 M=1` | - | 26.11 | 22.45 | 34.03 | 40 | 11.5 | - | 8.09 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=1280 K=5120 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | 26.10 | - | 26.06 | 26.25 | 6 | 0.4 | 3447 | 12.52 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=1280 K=5120 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | 26.07 | - | 26.04 | 26.09 | 6 | 0.1 | 3446 | 12.51 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1536 dtype=bf16 act=none M=256` | 25.99 | - | 25.88 | 26.53 | 14 | 0.6 | 3403 | 5.25 MiB | | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=8` | - | 25.97 | 25.00 | 28.45 | 20 | 1.6 | - | 128.03 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=8` | - | 25.97 | 25.23 | 34.30 | 19 | 0.9 | - | 96.09 KiB | 32 thread(s) | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=132` | 25.90 | - | 25.77 | 26.24 | 6 | 0.9 | 3249 | 3.38 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_decode` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=65 ks=0 bk=0 nt=0` | 25.73 | - | 25.68 | 25.90 | 6 | 0.4 | 3345 | 3.27 MiB | | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=1024 group=128 dtype=bf16 M=2` | - | 25.67 | 25.25 | 29.18 | 20 | 5.3 | - | 6.06 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=2048 K=1024 dtype=bf16 act=none M=448` | 25.40 | - | 25.30 | 25.44 | 6 | 0.3 | 3310 | 8.38 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5376 group=128 dtype=bf16 M=512` | 25.35 | - | 25.32 | 25.45 | 6 | 0.3 | 3394 | 7.96 MiB | | +| `rope_table` | `avx_rope_table` | libavx | `rot=64 theta=1e+07 scale=1 dtype=f32 M=32` | - | 25.30 | 24.92 | 26.79 | 20 | 2.5 | - | 8.12 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=32` | 25.29 | - | 25.15 | 25.42 | 11 | 0.5 | 3413 | 10.06 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3456 K=1152 dtype=bf16 act=none M=256` | 25.29 | - | 25.19 | 25.49 | 6 | 0.6 | 3312 | 11.54 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=6144 group=128 dtype=bf16 M=512` | 25.26 | - | 25.22 | 25.37 | 6 | 0.3 | 3300 | 9.09 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=2048 dtype=bf16 act=none M=256` | 25.17 | - | 25.13 | 25.22 | 6 | 0.2 | 3404 | 6.00 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5120 group=128 dtype=bf16 M=512` | 25.02 | - | 24.99 | 25.08 | 6 | 0.2 | 3256 | 7.58 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=3072 dtype=bf16 act=none M=128` | 24.95 | - | 24.88 | 25.05 | 6 | 0.3 | 3424 | 7.25 MiB | | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | `N=304 K=4096 dtype=bf16 M=32` | 24.82 | - | 23.22 | 25.11 | 20 | 1.6 | 2900 | 5.04 MiB | | +| `sample_minp` | `ref_sample_minp` | libref | `n_cand=1024 M=1` | - | 24.58 | 24.38 | 31.41 | 19 | 1.0 | - | 8.09 KiB | 32 thread(s) | +| `scatter_rows` | `ref_scatter_rows` | libref | `n=5120 dtype=bf16 M=1` | - | 24.56 | 24.53 | 24.66 | 11 | 0.3 | - | 50.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=3072 dtype=bf16 act=none M=64` | 24.50 | - | 24.43 | 24.60 | 6 | 0.3 | 3434 | 6.63 MiB | | +| `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | `head_k=128 head_v=128 scale=0.0883883 M=128 chunk=64` | 24.49 | - | 24.46 | 24.63 | 6 | 0.4 | 3235 | 10.80 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1280 K=1280 dtype=bf16 act=none M=512` | 24.48 | - | 24.05 | 24.71 | 11 | 0.7 | 3312 | 6.88 MiB | | +| `layernorm` | `layernorm_bf16` | libr4d | `n=1152 eps=1e-06 dtype=bf16 M=512` | 24.44 | - | 24.27 | 24.49 | 6 | 0.5 | 3434 | 2.25 MiB | | +| `moe_scatter` | `ref_moe_scatter` | libref | `n_expert=304 top_k=9 expert_base=0 M=256` | - | 24.43 | 24.41 | 25.95 | 20 | 1.7 | - | 20.38 KiB | 32 thread(s) | +| `gdn_gated_rmsnorm` | `avx_gdn_gated_rmsnorm` | libavx | `channels=128 eps=1e-06 act=silu M=64` | - | 24.28 | 24.11 | 26.39 | 20 | 2.3 | - | 48.50 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=3072 dtype=bf16 act=none M=32` | 24.26 | - | 24.21 | 25.21 | 14 | 0.3 | 3437 | 6.31 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=4096 group=128 dtype=bf16 M=512` | 24.25 | - | 24.22 | 24.32 | 6 | 0.2 | 3333 | 6.06 MiB | | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=512` | 24.23 | - | 24.21 | 24.33 | 6 | 0.2 | 3274 | 2.37 GiB | | +| `gather_rows` | `ref_gather_rows` | libref | `n=5120 dtype=bf16 M=1` | - | 24.21 | 23.55 | 24.69 | 20 | 2.1 | - | 50.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=1024 K=4096 group=128 dtype=fp8a8 M=258` | 24.14 | - | 24.08 | 24.33 | 6 | 0.5 | 3400 | 5.54 MiB | | +| `layernorm` | `layernorm_bf16` | libr4d | `n=1280 eps=1e-06 dtype=bf16 M=512` | 24.02 | - | 23.92 | 24.06 | 6 | 0.3 | 3434 | 2.50 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=16` | 24.00 | - | 23.88 | 24.16 | 6 | 0.6 | 3385 | 9.76 MiB | | +| `act_mul` | `ref_act_mul` | libref | `n=2304 act=relu dtype=bf16 M=1` | - | 23.97 | 23.95 | 25.90 | 20 | 3.0 | - | 13.50 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=16` | - | 23.97 | 20.61 | 28.89 | 20 | 14.1 | - | 8.25 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=8` | 23.92 | - | 23.82 | 23.98 | 6 | 0.3 | 3367 | 9.61 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=4` | 23.82 | - | 23.63 | 23.96 | 6 | 0.7 | 3359 | 9.54 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | 23.82 | - | 23.70 | 24.11 | 11 | 0.8 | 3333 | 11.75 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=1` | 23.76 | - | 23.63 | 23.94 | 6 | 0.7 | 3369 | 9.48 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=4304 K=1152 dtype=bf16 act=gelu_tanh M=2` | 23.75 | - | 23.57 | 23.83 | 6 | 0.5 | 3379 | 9.50 MiB | | +| `kv_store` | `ref_kv_store` | libref | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=1` | - | 23.63 | 19.93 | 28.50 | 20 | 15.8 | - | 100.00 KiB | 32 thread(s) | +| `layernorm` | `ref_layernorm` | libref | `n=1152 eps=1e-06 dtype=bf16 M=1` | - | 23.61 | 23.00 | 25.13 | 20 | 2.2 | - | 9.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=1024 K=4096 group=128 dtype=fp8a8 M=129` | 23.51 | - | 23.48 | 23.60 | 6 | 0.2 | 3410 | 4.77 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=256 K=4096 group=128 dtype=fp8a8 M=512` | 23.38 | - | 23.32 | 23.44 | 6 | 0.3 | 3323 | 3.31 MiB | | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=1536 group=128 dtype=bf16 M=1` | - | 23.30 | 18.99 | 25.67 | 20 | 8.4 | - | 4.55 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3840 K=1280 dtype=bf16 act=none M=64` | 23.29 | - | 23.23 | 23.31 | 6 | 0.2 | 3419 | 10.48 MiB | | +| `sample_mask` | `sample_mask_f32` | libr4d | `n_vocab=131072 M=16` | 23.26 | - | 17.57 | 25.58 | 20 | 7.7 | 3430 | 8.25 MiB | restore 52% | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=256 K=4096 group=128 dtype=fp8a8 M=258` | 23.25 | - | 23.16 | 23.33 | 6 | 0.4 | 3326 | 2.17 MiB | | +| `grid_embed_cpe` | `grid_embed_cpe_bf16` | libr4d | `n=1280 side=128 n_prefix=10 dtype=bf16 M=512` | 23.19 | - | 21.89 | 23.97 | 20 | 1.9 | 3396 | 41.28 MiB | restore 10% | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=256 K=4096 group=128 dtype=fp8a8 M=129` | 23.19 | - | 23.01 | 23.27 | 6 | 0.5 | 3316 | 1.58 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=2048 dtype=bf16 act=none M=448` | 23.10 | - | 23.05 | 23.12 | 6 | 0.2 | 3361 | 7.50 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=3072 dtype=bf16 act=none M=16` | 23.09 | - | 23.02 | 23.12 | 6 | 0.2 | 3437 | 6.16 MiB | | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | `N=1280 K=2304 dtype=bf16 M=130 tile=0` | 23.06 | - | 23.01 | 23.13 | 6 | 0.3 | 3416 | 6.51 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=1024 K=4096 group=128 dtype=fp8a8 M=128` | 23.05 | - | 22.99 | 23.20 | 6 | 0.5 | 3428 | 4.77 MiB | | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=4` | - | 22.99 | 22.97 | 24.41 | 20 | 1.4 | - | 4.97 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=1024 K=4096 group=128 dtype=fp8a8 M=65` | 22.97 | - | 22.95 | 23.05 | 6 | 0.2 | 3428 | 4.39 MiB | | +| `gdn_recurrent_update` | `gdn_recurrent_update_k128_v128_bf16_fp32state` | libr4d | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=8` | 22.97 | - | 22.81 | 23.05 | 6 | 0.5 | 3277 | 24.35 MiB | restore 59% | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=256 K=4096 group=128 dtype=fp8a8 M=128` | 22.89 | - | 22.79 | 22.92 | 6 | 0.3 | 3317 | 1.58 MiB | | +| `sample_topp` | `ref_sample_topp` | libref | `n_cand=1024 M=2` | - | 22.88 | 22.76 | 29.13 | 14 | 0.6 | - | 16.19 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=3072 dtype=bf16 act=none M=8` | 22.84 | - | 22.77 | 22.86 | 6 | 0.2 | 3438 | 6.08 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3840 K=1280 dtype=bf16 act=none M=32` | 22.81 | - | 22.78 | 22.85 | 6 | 0.1 | 3428 | 9.93 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=256 K=4096 group=128 dtype=fp8a8 M=65` | 22.74 | - | 22.68 | 22.78 | 6 | 0.2 | 3318 | 1.29 MiB | | +| `gemm_nt` | `gemm_bf16_nt_tiled` | libr4d | `N=1280 K=2304 dtype=bf16 M=65 tile=0` | 22.72 | - | 22.68 | 22.89 | 6 | 0.5 | 3418 | 6.07 MiB | | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=4096 dtype=bf16 M=256` | 22.56 | - | 21.15 | 23.92 | 20 | 5.1 | 3348 | 10.00 MiB | restore 53% | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=4096 dtype=bf16 M=512` | 22.52 | - | 22.49 | 22.71 | 11 | 0.5 | 3353 | 20.00 MiB | restore 50% | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=3072 dtype=bf16 act=none M=4` | 22.49 | - | 22.41 | 22.52 | 6 | 0.2 | 3438 | 6.04 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | 22.48 | - | 21.77 | 22.91 | 20 | 1.5 | 3382 | 11.48 MiB | | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=256` | 22.44 | - | 22.43 | 22.45 | 6 | 0.1 | 3233 | 8.80 MiB | restore 15% | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | 22.42 | - | 22.28 | 22.50 | 6 | 0.5 | 3381 | 11.71 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3072 K=1024 dtype=bf16 act=none M=128` | 22.33 | - | 22.24 | 22.47 | 6 | 0.5 | 3411 | 7.76 MiB | | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=512` | 22.21 | - | 22.10 | 22.30 | 6 | 0.4 | 3282 | 25.00 MiB | restore 55% | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=3072 dtype=bf16 act=none M=2` | 22.19 | - | 22.15 | 22.22 | 6 | 0.1 | 3436 | 6.02 MiB | | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=2` | - | 22.16 | 22.00 | 22.32 | 11 | 0.6 | - | 4.01 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1280 K=1280 dtype=bf16 act=none M=256` | 22.13 | - | 22.02 | 22.24 | 6 | 0.5 | 3412 | 5.00 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=3072 dtype=bf16 act=none M=1` | 22.12 | - | 22.01 | 22.13 | 6 | 0.3 | 3437 | 6.01 MiB | | +| `layernorm` | `ref_layernorm` | libref | `n=1280 eps=1e-06 dtype=bf16 M=1` | - | 22.11 | 21.14 | 23.29 | 20 | 2.8 | - | 10.00 KiB | 32 thread(s) | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=4` | - | 22.07 | 21.11 | 23.98 | 20 | 5.5 | - | 4.97 KiB | 32 thread(s) | +| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=16` | - | 21.98 | 18.15 | 23.50 | 20 | 6.3 | - | 10.01 KiB | 32 thread(s) | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=1024 group=128 dtype=bf16 M=512` | 21.95 | - | 21.90 | 22.02 | 6 | 0.3 | 3387 | 1.52 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3072 K=1024 dtype=bf16 act=none M=256` | 21.94 | - | 21.75 | 21.98 | 6 | 0.5 | 3312 | 9.51 MiB | | +| `gdn_gated_rmsnorm` | `ref_gdn_gated_rmsnorm` | libref | `channels=128 eps=1e-06 act=silu M=8` | - | 21.86 | 21.63 | 23.44 | 20 | 2.4 | - | 6.50 KiB | 32 thread(s) | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=512` | 21.79 | - | 20.64 | 22.27 | 20 | 2.4 | 3280 | 8.01 MiB | | +| `act_mul` | `ref_act_mul` | libref | `n=2048 act=relu dtype=bf16 M=1` | - | 21.76 | 21.65 | 26.48 | 20 | 4.1 | - | 12.00 KiB | 32 thread(s) | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=1280 dtype=bf16 M=512` | 21.73 | - | 21.68 | 21.76 | 6 | 0.2 | 3384 | 6.25 MiB | | +| `act_mul` | `avx_act_mul` | libavx | `n=1536 act=relu dtype=bf16 M=4` | - | 21.71 | 15.65 | 22.93 | 20 | 12.0 | - | 36.00 KiB | 32 thread(s) | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=4096 eps=1e-05 dtype=bf16 M=512` | 21.44 | - | 19.78 | 22.11 | 20 | 3.3 | 3424 | 8.01 MiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=8` | - | 21.41 | 20.44 | 22.83 | 20 | 4.1 | - | 8.50 KiB | 32 thread(s) | +| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=248320 M=2` | 21.41 | - | 21.37 | 21.46 | 6 | 0.2 | 3326 | 1.89 MiB | restore 15% | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | 21.40 | - | 21.29 | 21.54 | 6 | 0.6 | 3366 | 11.50 MiB | | +| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=32` | - | 21.38 | 21.28 | 22.37 | 14 | 0.8 | - | 64.38 KiB | 32 thread(s) | +| `sample_minp` | `avx_sample_minp` | libavx | `n_cand=1024 M=1` | - | 21.34 | 20.21 | 31.40 | 31 | 3.0 | - | 8.09 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1152 dtype=bf16 act=none M=512` | 21.33 | - | 21.26 | 21.42 | 6 | 0.4 | 3342 | 5.91 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | 21.31 | - | 20.61 | 21.58 | 20 | 1.4 | 3405 | 11.31 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=1024 K=4096 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | 21.18 | - | 21.13 | 23.06 | 14 | 0.2 | 3402 | 8.62 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3840 K=1280 dtype=bf16 act=none M=16` | 21.13 | - | 21.08 | 21.14 | 6 | 0.1 | 3422 | 9.66 MiB | | +| `add` | `add_bf16` | libr4d | `n=4096 dtype=bf16 M=512` | 21.09 | - | 20.06 | 22.20 | 20 | 2.0 | 3330 | 12.00 MiB | | +| `sample_mask` | `sample_mask_f32` | libr4d | `n_vocab=248320 M=2` | 21.03 | - | 21.00 | 21.11 | 6 | 0.3 | 3354 | 1.95 MiB | restore 15% | +| `silu` | `silu_bf16` | libr4d | `n=1024 dtype=bf16 M=128` | 21.01 | - | 20.97 | 21.05 | 6 | 0.2 | 3390 | 512.00 KiB | | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=1024 group=128 dtype=bf16 M=512` | 21.00 | - | 19.02 | 22.40 | 20 | 4.5 | 3382 | 1.52 MiB | | +| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=131072 M=32` | 20.97 | - | 20.19 | 22.57 | 20 | 3.2 | 3424 | 16.00 MiB | restore 52% | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4096 K=1024 group=128 dtype=fp8a8 M=258` | 20.94 | - | 20.74 | 21.12 | 11 | 0.7 | 3185 | 6.28 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | 20.90 | - | 20.60 | 21.36 | 20 | 1.5 | 3412 | 11.28 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3840 K=1280 dtype=bf16 act=none M=8` | 20.85 | - | 20.84 | 20.99 | 6 | 0.4 | 3430 | 9.52 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | 20.85 | - | 20.81 | 21.11 | 6 | 0.7 | 3409 | 11.35 MiB | | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=256` | 20.83 | - | 20.76 | 21.17 | 11 | 0.9 | 3275 | 7.04 MiB | restore 15% | +| `sample_ngram_ban` | `ref_sample_ngram_ban` | libref | `n_vocab=131072 M=32` | - | 20.83 | 18.29 | 27.14 | 20 | 13.9 | - | 16.51 MiB | 32 thread(s) | +| `silu` | `silu_bf16` | libr4d | `n=2048 dtype=bf16 M=64` | 20.82 | - | 18.61 | 20.89 | 19 | 0.2 | 3388 | 512.00 KiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | 20.80 | - | 20.77 | 21.07 | 11 | 0.7 | 3410 | 11.37 MiB | | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=256` | 20.78 | - | 20.70 | 20.83 | 6 | 0.3 | 3038 | 1.00 GiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=2048 act=relu dtype=bf16 M=64` | 20.77 | - | 20.73 | 20.83 | 6 | 0.3 | 3430 | 768.00 KiB | | +| `sample_mask` | `sample_mask_f32` | libr4d | `n_vocab=131072 M=2` | 20.75 | - | 20.72 | 20.79 | 6 | 0.2 | 3436 | 1.03 MiB | restore 11% | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | 20.74 | - | 20.67 | 20.86 | 6 | 0.5 | 3412 | 11.26 MiB | | +| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=131072 M=2` | 20.73 | - | 20.70 | 20.83 | 11 | 0.3 | 3433 | 1.00 MiB | restore 11% | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | 20.73 | - | 20.63 | 20.93 | 6 | 0.7 | 3422 | 11.26 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=1024 K=4096 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | 20.72 | - | 20.68 | 20.81 | 6 | 0.3 | 3412 | 8.33 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | 20.72 | - | 20.70 | 20.76 | 6 | 0.2 | 3412 | 11.30 MiB | | +| `add` | `add_bf16` | libr4d | `n=4096 dtype=bf16 M=256` | 20.70 | - | 20.67 | 20.74 | 6 | 0.2 | 3350 | 6.00 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | `N=4096 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | 20.68 | - | 20.65 | 20.74 | 6 | 0.2 | 3411 | 11.28 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | 20.65 | - | 20.61 | 20.83 | 6 | 0.5 | 3402 | 11.37 MiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=32` | 20.61 | - | 20.56 | 20.66 | 6 | 0.2 | 3390 | 256.12 KiB | restore 11% | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | `N=5120 K=4096 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | 20.61 | - | 20.56 | 20.88 | 6 | 0.8 | 3394 | 11.36 MiB | | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=2` | - | 20.61 | 20.39 | 21.28 | 20 | 1.0 | - | 64.25 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=1536 group=128 dtype=bf16 M=256` | 20.59 | - | 20.55 | 20.65 | 6 | 0.3 | 3376 | 1.14 MiB | | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=1280 dtype=bf16 M=256` | 20.57 | - | 20.52 | 20.60 | 6 | 0.2 | 3376 | 3.13 MiB | | +| `add` | `add_bf16` | libr4d | `n=5120 dtype=bf16 M=256` | 20.56 | - | 20.54 | 20.59 | 6 | 0.1 | 3208 | 7.50 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5376 group=128 dtype=bf16 M=256` | 20.56 | - | 20.50 | 20.60 | 6 | 0.2 | 3377 | 3.98 MiB | | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=2048 group=128 dtype=bf16 M=512` | 20.56 | - | 17.54 | 23.29 | 20 | 10.7 | 3379 | 3.03 MiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=128` | 20.52 | - | 20.44 | 20.56 | 6 | 0.3 | 3369 | 256.50 KiB | restore 11% | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=1024 group=128 dtype=bf16 M=256` | 20.52 | - | 20.49 | 20.53 | 6 | 0.1 | 3385 | 776.00 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=6144 group=128 dtype=bf16 M=256` | 20.51 | - | 20.48 | 20.52 | 6 | 0.1 | 3233 | 4.55 MiB | | +| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=248320 M=1` | 20.51 | - | 20.44 | 20.53 | 6 | 0.2 | 3404 | 970.09 KiB | restore 11% | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=2048 group=128 dtype=bf16 M=256` | 20.51 | - | 20.45 | 20.56 | 6 | 0.3 | 3380 | 1.52 MiB | | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=256` | 20.50 | - | 20.47 | 20.52 | 6 | 0.1 | 3212 | 2.37 GiB | | +| `grid_embed` | `grid_embed_bf16` | libr4d | `n=1152 side=48 dtype=bf16 M=256` | 20.50 | - | 20.46 | 20.65 | 6 | 0.5 | 3394 | 5.63 MiB | restore 11% | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=1024 group=128 dtype=bf16 M=256` | 20.49 | - | 20.42 | 20.54 | 6 | 0.3 | 3382 | 776.00 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5120 group=128 dtype=bf16 M=256` | 20.48 | - | 20.37 | 20.56 | 11 | 0.4 | 3254 | 3.79 MiB | | +| `grid_embed_cpe` | `grid_embed_cpe_bf16` | libr4d | `n=1280 side=128 n_prefix=10 dtype=bf16 M=256` | 20.46 | - | 20.40 | 20.51 | 6 | 0.3 | 3424 | 40.65 MiB | restore 11% | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=8192 group=128 dtype=bf16 M=256` | 20.40 | - | 20.38 | 20.42 | 6 | 0.1 | 3372 | 6.06 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=4096 group=128 dtype=bf16 M=256` | 20.39 | - | 20.37 | 20.46 | 6 | 0.2 | 3329 | 3.03 MiB | | +| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=1024 M=64` | 20.39 | - | 19.62 | 20.56 | 12 | 0.5 | 3440 | 262.00 KiB | restore 11% | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=32` | 20.38 | - | 20.36 | 20.46 | 6 | 0.2 | 3300 | 256.12 KiB | restore 11% | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=256` | 20.38 | - | 20.29 | 20.52 | 6 | 0.6 | 3358 | 129.00 KiB | restore 11% | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=2304 group=128 dtype=bf16 M=256` | 20.36 | - | 20.35 | 20.40 | 6 | 0.1 | 3391 | 1.71 MiB | | +| `mul_weight` | `mul_weight_bf16` | libr4d | `n=8192 dtype=bf16 M=256` | 20.36 | - | 20.34 | 20.40 | 6 | 0.2 | 3370 | 8.02 MiB | | +| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=256` | 20.35 | - | 20.24 | 20.40 | 6 | 0.4 | 3246 | 1.56 MiB | restore 11% | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3456 K=1152 dtype=bf16 act=none M=64` | 20.33 | - | 20.30 | 20.37 | 6 | 0.2 | 3427 | 8.58 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1152 dtype=bf16 act=none M=256` | 20.33 | - | 20.23 | 20.41 | 6 | 0.4 | 3413 | 4.22 MiB | | +| `layernorm` | `layernorm_bf16` | libr4d | `n=1152 eps=1e-06 dtype=bf16 M=256` | 20.32 | - | 20.26 | 20.39 | 6 | 0.3 | 3434 | 1.13 MiB | | +| `cast` | `cast_bf16_bf16` | libr4d | `n=4096 from=bf16 to=bf16 M=128` | 20.31 | - | 20.24 | 20.36 | 11 | 0.3 | 3376 | 2.00 MiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=256` | 20.30 | - | 20.24 | 20.35 | 6 | 0.3 | 3302 | 515.00 KiB | restore 11% | +| `kv_store` | `kv_store_bf16` | libr4d | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=256` | 20.27 | - | 20.18 | 20.32 | 6 | 0.3 | 3372 | 545.00 KiB | restore 11% | +| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=256` | 20.26 | - | 20.17 | 20.36 | 6 | 0.5 | 3422 | 1.56 MiB | restore 11% | +| `act_mul` | `act_mul_bf16` | libr4d | `n=2048 act=relu dtype=bf16 M=32` | 20.21 | - | 20.17 | 20.24 | 6 | 0.2 | 3432 | 384.00 KiB | | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | `N=240 K=4096 dtype=bf16 M=32` | 20.18 | - | 20.10 | 20.20 | 6 | 0.3 | 3303 | 4.03 MiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=1024 eps=1e-06 dtype=bf16 M=2` | - | 20.17 | 19.99 | 21.54 | 20 | 2.2 | - | 10.00 KiB | 32 thread(s) | +| `sample_argmax` | `sample_argmax_f32` | libr4d | `n_vocab=131072 M=16` | 20.16 | - | 19.81 | 20.19 | 11 | 0.1 | 3437 | 8.00 MiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=8192 act=silu dtype=bf16 M=8` | 20.16 | - | 20.10 | 20.17 | 6 | 0.2 | 3416 | 384.00 KiB | | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=1024 K=4096 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | 20.15 | - | 20.10 | 20.20 | 6 | 0.3 | 3402 | 8.17 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3840 K=1280 dtype=bf16 act=none M=4` | 20.13 | - | 20.09 | 20.17 | 6 | 0.2 | 3432 | 9.45 MiB | | +| `sample_mask` | `sample_mask_f32` | libr4d | `n_vocab=248320 M=1` | 20.08 | - | 20.01 | 20.11 | 6 | 0.2 | 3436 | 1000.41 KiB | restore 11% | +| `sample_mask` | `sample_mask_f32` | libr4d | `n_vocab=131072 M=1` | 20.03 | - | 20.01 | 20.09 | 6 | 0.2 | 3438 | 528.09 KiB | restore 11% | +| `gather_rows` | `ref_gather_rows` | libref | `n=1280 dtype=bf16 M=2` | - | 20.01 | 19.15 | 20.87 | 20 | 2.8 | - | 25.01 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=1024 K=4096 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | 20.00 | - | 19.93 | 20.01 | 6 | 0.2 | 3402 | 8.16 MiB | | +| `silu` | `silu_bf16` | libr4d | `n=1024 dtype=bf16 M=64` | 19.98 | - | 19.94 | 20.01 | 6 | 0.2 | 3438 | 256.00 KiB | | +| `layernorm` | `layernorm_bf16` | libr4d | `n=1280 eps=1e-06 dtype=bf16 M=256` | 19.92 | - | 19.77 | 20.23 | 16 | 0.9 | 3432 | 1.25 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=1024 K=4096 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | 19.89 | - | 19.82 | 19.98 | 6 | 0.4 | 3404 | 8.08 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3456 K=1152 dtype=bf16 act=none M=32` | 19.86 | - | 19.80 | 19.88 | 6 | 0.2 | 3434 | 8.09 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=1024 K=4096 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | 19.85 | - | 19.78 | 19.94 | 6 | 0.4 | 3407 | 8.04 MiB | | +| `silu` | `silu_bf16` | libr4d | `n=2048 dtype=bf16 M=32` | 19.85 | - | 19.80 | 19.86 | 6 | 0.2 | 3436 | 256.00 KiB | | +| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=131072 M=1` | 19.85 | - | 19.82 | 20.19 | 6 | 0.9 | 3437 | 512.09 KiB | restore 11% | +| `scatter_rows` | `ref_scatter_rows` | libref | `n=4096 dtype=bf16 M=1` | - | 19.81 | 19.78 | 20.07 | 6 | 0.7 | - | 40.00 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=1024 K=4096 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | 19.81 | - | 19.71 | 19.93 | 11 | 0.4 | 3399 | 8.01 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=1024 K=4096 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | 19.79 | - | 19.67 | 19.88 | 6 | 0.5 | 3398 | 8.02 MiB | | +| `moe_scatter` | `avx_moe_scatter` | libavx | `n_expert=304 top_k=9 expert_base=0 M=256` | - | 19.79 | 19.76 | 21.13 | 20 | 3.0 | - | 20.38 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3840 K=1280 dtype=bf16 act=none M=2` | 19.70 | - | 19.68 | 19.79 | 6 | 0.3 | 3432 | 9.42 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=2048 dtype=bf16 act=none M=128` | 19.61 | - | 19.58 | 19.67 | 6 | 0.2 | 3436 | 5.00 MiB | | +| `moe_scatter` | `avx_moe_scatter` | libavx | `n_expert=240 top_k=9 expert_base=0 M=256` | - | 19.55 | 19.46 | 21.39 | 20 | 2.1 | - | 19.88 KiB | 32 thread(s) | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=256` | 19.50 | - | 19.49 | 19.62 | 6 | 0.3 | 3278 | 12.50 MiB | restore 42% | +| `sample_pick` | `ref_sample_pick` | libref | `n_cand=1024 M=2` | - | 19.48 | 18.96 | 19.99 | 20 | 2.3 | - | 16.20 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3840 K=1280 dtype=bf16 act=none M=1` | 19.46 | - | 19.44 | 19.52 | 6 | 0.2 | 3429 | 9.40 MiB | | +| `attn_dense` | `ref_attn_dense` | libref | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=4` | - | 19.29 | 14.95 | 24.21 | 20 | 15.2 | - | 2.51 KiB | 32 thread(s) | +| `rope_table` | `ref_rope_table` | libref | `rot=64 theta=1e+07 scale=1 dtype=f32 M=8` | - | 19.20 | 18.54 | 20.39 | 20 | 3.3 | - | 2.03 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3072 K=1024 dtype=bf16 act=none M=64` | 19.20 | - | 19.17 | 19.24 | 6 | 0.2 | 3424 | 6.88 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=2048 dtype=bf16 act=none M=64` | 19.11 | - | 19.08 | 19.16 | 6 | 0.2 | 3436 | 4.50 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=2048 dtype=bf16 act=none M=32` | 19.08 | - | 19.05 | 19.11 | 6 | 0.2 | 3438 | 4.25 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1536 dtype=bf16 act=none M=128` | 19.00 | - | 18.85 | 19.23 | 11 | 0.9 | 3419 | 4.31 MiB | | +| `gather_rows` | `ref_gather_rows` | libref | `n=4096 dtype=bf16 M=1` | - | 18.96 | 18.93 | 20.39 | 20 | 1.4 | - | 40.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3072 K=1024 dtype=bf16 act=none M=32` | 18.94 | - | 18.89 | 18.98 | 6 | 0.2 | 3428 | 6.44 MiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=8192 act=silu dtype=bf16 M=16` | 18.80 | - | 17.30 | 19.29 | 20 | 2.7 | 3370 | 768.00 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=5376 act=relu dtype=bf16 M=512` | 18.44 | - | 18.35 | 18.54 | 6 | 0.5 | 3400 | 15.75 MiB | | +| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=248320 M=16` | 18.39 | - | 18.33 | 18.48 | 6 | 0.4 | 3389 | 15.16 MiB | restore 53% | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3456 K=1152 dtype=bf16 act=none M=16` | 18.27 | - | 18.22 | 18.30 | 6 | 0.2 | 3434 | 7.85 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=2048 dtype=bf16 act=none M=8` | 18.25 | - | 18.16 | 18.34 | 6 | 0.5 | 3438 | 4.06 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=2048 dtype=bf16 act=none M=16` | 18.15 | - | 18.10 | 18.41 | 6 | 0.8 | 3436 | 4.13 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3072 K=1024 dtype=bf16 act=none M=16` | 18.00 | - | 17.99 | 18.01 | 6 | 0.1 | 3424 | 6.22 MiB | | +| `kv_store` | `ref_kv_store` | libref | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=4` | - | 18.00 | 17.54 | 18.27 | 16 | 1.0 | - | 52.02 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3072 K=1024 dtype=bf16 act=none M=8` | 17.91 | - | 17.88 | 18.00 | 6 | 0.4 | 3420 | 6.12 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3456 K=1152 dtype=bf16 act=none M=8` | 17.89 | - | 17.86 | 17.90 | 6 | 0.1 | 3430 | 7.72 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=2048 dtype=bf16 act=none M=2` | 17.82 | - | 17.48 | 17.89 | 11 | 0.9 | 3439 | 4.02 MiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=1024 eps=1e-05 dtype=bf16 M=2` | - | 17.73 | 17.56 | 19.07 | 20 | 3.3 | - | 8.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=2048 dtype=bf16 act=none M=4` | 17.72 | - | 17.67 | 17.76 | 6 | 0.2 | 3439 | 4.03 MiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=20480 act=relu dtype=bf16 M=128` | 17.71 | - | 17.64 | 17.85 | 6 | 0.6 | 3376 | 15.00 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3072 K=1024 dtype=bf16 act=none M=4` | 17.48 | - | 17.47 | 17.51 | 6 | 0.1 | 3417 | 6.06 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=2048 dtype=bf16 act=none M=1` | 17.42 | - | 17.41 | 17.45 | 6 | 0.1 | 3436 | 4.01 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=2048 K=1024 dtype=bf16 act=none M=128` | 17.38 | - | 17.24 | 17.50 | 6 | 0.7 | 3428 | 5.25 MiB | | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=16` | - | 17.27 | 17.24 | 17.37 | 11 | 0.4 | - | 8.06 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3456 K=1152 dtype=bf16 act=none M=4` | 17.24 | - | 17.22 | 17.28 | 6 | 0.2 | 3430 | 7.66 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3072 K=1024 dtype=bf16 act=none M=2` | 17.22 | - | 17.18 | 17.26 | 6 | 0.2 | 3419 | 6.03 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3072 K=1024 dtype=bf16 act=none M=1` | 17.07 | - | 17.05 | 17.14 | 6 | 0.3 | 3418 | 6.02 MiB | | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=10 splits=0` | 16.97 | - | 16.76 | 17.27 | 14 | 0.9 | 3344 | 4.23 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3456 K=1152 dtype=bf16 act=none M=2` | 16.93 | - | 16.88 | 16.97 | 6 | 0.3 | 3432 | 7.63 MiB | | +| `sample_dry` | `sample_dry_f32` | libr4d | `n_vocab=248320 M=64` | 16.78 | - | 16.33 | 16.97 | 11 | 1.0 | 3402 | 60.65 MiB | restore 93%; restore-dominated (93% of the batch): an order of magnitude | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8 splits=0` | 16.69 | - | 16.65 | 16.69 | 6 | 0.1 | 3304 | 2.13 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=3456 K=1152 dtype=bf16 act=none M=1` | 16.67 | - | 16.63 | 16.71 | 6 | 0.2 | 3432 | 7.62 MiB | | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=9 splits=0` | 16.51 | - | 16.40 | 16.66 | 6 | 0.8 | 3336 | 4.21 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=64` | 16.24 | - | 14.58 | 16.28 | 20 | 4.7 | 2852 | 5.45 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1280 K=1280 dtype=bf16 act=none M=128` | 16.20 | - | 16.16 | 16.23 | 6 | 0.2 | 3430 | 4.06 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=1280 K=2304 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | 16.18 | - | 16.14 | 16.20 | 6 | 0.2 | 3356 | 6.06 MiB | | +| `attn_dense` | `ref_attn_dense` | libref | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=4` | - | 16.14 | 12.81 | 19.65 | 20 | 18.9 | - | 2.26 KiB | 32 thread(s) | +| `act_mul` | `act_mul_bf16` | libr4d | `n=8192 act=silu dtype=bf16 M=256` | 16.02 | - | 16.00 | 16.15 | 6 | 0.5 | 3398 | 12.00 MiB | | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | 15.87 | - | 15.81 | 15.88 | 6 | 0.2 | 3215 | 4.12 MiB | | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | 15.71 | - | 15.12 | 15.82 | 16 | 0.9 | 3263 | 4.19 MiB | | +| `silu` | `ref_silu` | libref | `n=1024 dtype=bf16 M=1` | - | 15.67 | 15.37 | 18.38 | 20 | 4.6 | - | 4.00 KiB | 32 thread(s) | +| `sample_mask` | `sample_mask_f32` | libr4d | `n_vocab=131072 M=32` | 15.60 | - | 15.49 | 16.25 | 14 | 0.3 | 3428 | 16.50 MiB | restore 59% | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1536 dtype=bf16 act=none M=64` | 15.51 | - | 15.48 | 16.20 | 19 | 0.4 | 3432 | 3.85 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1536 dtype=bf16 act=none M=32` | 15.46 | - | 15.41 | 15.51 | 6 | 0.3 | 3436 | 3.61 MiB | | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=32` | - | 15.41 | 15.31 | 15.52 | 6 | 0.7 | - | 96.12 KiB | 32 thread(s) | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=66` | 15.40 | - | 15.34 | 15.47 | 11 | 0.3 | 3321 | 1.70 MiB | | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | `N=304 K=4096 dtype=bf16 M=16` | 15.36 | - | 15.34 | 15.36 | 6 | 0.1 | 3324 | 4.89 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4096 K=1024 group=128 dtype=fp8a8 M=129` | 15.18 | - | 15.18 | 15.22 | 6 | 0.1 | 3234 | 5.14 MiB | | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=1` | - | 15.09 | 14.72 | 15.62 | 20 | 1.7 | - | 45.16 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1152 dtype=bf16 act=none M=128` | 15.08 | - | 15.00 | 15.14 | 6 | 0.5 | 3412 | 3.38 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=2048 K=1024 dtype=bf16 act=none M=256` | 15.07 | - | 15.04 | 15.12 | 6 | 0.3 | 3349 | 6.50 MiB | | +| `gdn_recurrent_update` | `gdn_recurrent_update_k128_v128_bf16_fp32state` | libr4d | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=4` | 14.93 | - | 14.83 | 14.99 | 6 | 0.5 | 3274 | 18.17 MiB | restore 62% | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=1024 dtype=bf16 act=none M=256` | 14.87 | - | 14.81 | 15.02 | 6 | 0.7 | 3360 | 3.50 MiB | | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | 14.83 | - | 14.81 | 14.89 | 6 | 0.3 | 3195 | 4.09 MiB | | +| `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | `head_k=128 head_v=128 scale=0.0883883 M=64 chunk=64` | 14.79 | - | 14.78 | 14.85 | 6 | 0.2 | 3248 | 8.40 MiB | | +| `rope` | `avx_rope` | libavx | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=4` | - | 14.77 | 14.12 | 15.29 | 20 | 2.3 | - | 27.03 KiB | 32 thread(s) | +| `sample_mask` | `sample_mask_f32` | libr4d | `n_vocab=248320 M=16` | 14.69 | - | 14.53 | 14.72 | 6 | 0.6 | 3421 | 15.63 MiB | restore 58% | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=2304 group=128 dtype=bf16 M=4` | - | 14.65 | 13.07 | 16.18 | 20 | 9.6 | - | 27.28 KiB | 32 thread(s) | +| `ple_conv_bias` | `ple_conv_bias_bf16` | libr4d | `n=10240 width=4 dilation=1 dtype=bf16 M=16` | 14.58 | - | 14.25 | 14.64 | 14 | 0.5 | 3375 | 1.39 MiB | restore 14% | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=2` | - | 14.52 | 14.39 | 15.58 | 20 | 2.7 | - | 3.70 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=1024 dtype=bf16 act=none M=448` | 14.49 | - | 14.38 | 14.53 | 6 | 0.5 | 3350 | 4.63 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=2048 K=1024 dtype=bf16 act=none M=64` | 14.49 | - | 14.47 | 14.53 | 6 | 0.2 | 3434 | 4.63 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1536 dtype=bf16 act=none M=16` | 14.49 | - | 14.46 | 14.55 | 6 | 0.3 | 3446 | 3.49 MiB | | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | 14.48 | - | 14.12 | 14.76 | 20 | 1.6 | 3286 | 4.14 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1536 dtype=bf16 act=none M=8` | 14.46 | - | 14.41 | 14.49 | 6 | 0.3 | 3446 | 3.44 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=2048 K=1024 dtype=bf16 act=none M=32` | 14.43 | - | 14.41 | 14.43 | 6 | 0.1 | 3437 | 4.32 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1536 dtype=bf16 act=none M=4` | 14.35 | - | 14.02 | 15.26 | 20 | 2.8 | 3323 | 3.41 MiB | | +| `sample_penalties` | `sample_penalties_f32` | libr4d | `n_vocab=248320 M=64` | 14.08 | - | 13.47 | 14.31 | 20 | 1.3 | 3369 | 60.65 MiB | restore 94%; restore-dominated (94% of the batch): an order of magnitude | +| `attn_paged_sink` | `attn_window_sink_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8` | 14.06 | - | 14.04 | 14.08 | 6 | 0.2 | 3252 | 144.13 KiB | | +| `attn_paged_sink` | `attn_window_sink_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4` | 13.86 | - | 13.80 | 13.87 | 6 | 0.2 | 3238 | 80.13 KiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1536 dtype=bf16 act=none M=2` | 13.85 | - | 13.84 | 13.90 | 6 | 0.2 | 3444 | 3.39 MiB | | +| `act_mul` | `avx_act_mul` | libavx | `n=5376 act=relu dtype=bf16 M=2` | - | 13.85 | 13.81 | 15.08 | 20 | 4.2 | - | 63.00 KiB | 32 thread(s) | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | 13.84 | - | 13.83 | 13.86 | 6 | 0.1 | 3252 | 4.05 MiB | | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=6 splits=0` | 13.80 | - | 13.79 | 13.82 | 6 | 0.1 | 3247 | 2.09 MiB | | +| `moe_scatter` | `ref_moe_scatter` | libref | `n_expert=304 top_k=9 expert_base=0 M=128` | - | 13.80 | 13.78 | 15.23 | 16 | 0.2 | - | 11.38 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1536 dtype=bf16 act=none M=1` | 13.74 | - | 13.70 | 13.80 | 11 | 0.4 | 3446 | 3.38 MiB | | +| `attn_paged_sink` | `attn_window_sink_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2` | 13.71 | - | 13.69 | 13.75 | 6 | 0.2 | 3238 | 48.13 KiB | | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | 13.67 | - | 13.63 | 13.74 | 6 | 0.4 | 3258 | 4.02 MiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=1536 act=relu dtype=bf16 M=128` | 13.58 | - | 12.50 | 15.33 | 20 | 4.9 | 3400 | 1.12 MiB | | +| `attn_dense` | `attn_vit_h72_bf16` | libr4d | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=512` | 13.54 | - | 13.52 | 14.66 | 14 | 1.0 | 3440 | 288.01 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=25600 group=128 dtype=bf16 M=128` | 13.54 | - | 13.45 | 13.59 | 6 | 0.5 | 3278 | 9.47 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=36` | 13.51 | - | 13.47 | 13.54 | 6 | 0.3 | 3243 | 5.25 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=2048 K=1024 dtype=bf16 act=none M=16` | 13.50 | - | 13.49 | 13.52 | 6 | 0.1 | 3437 | 4.16 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=96 K=5120 dtype=bf16 M=512 wv=1 sk=0 mb=0 npw=1 nt=1` | 13.50 | - | 13.42 | 13.58 | 6 | 0.6 | 3228 | 6.03 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=2048 K=1024 dtype=bf16 act=none M=8` | 13.49 | - | 13.46 | 13.51 | 11 | 0.2 | 3437 | 4.08 MiB | | +| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | 13.46 | - | 13.44 | 13.54 | 6 | 0.4 | 3272 | 32.07 MiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=256` | 13.46 | - | 13.36 | 13.58 | 6 | 0.8 | 3356 | 1.69 MiB | restore 21% | +| `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | `head_k=128 M=512 chunk=64` | 13.45 | - | 13.38 | 13.47 | 6 | 0.3 | 3150 | 5.19 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=24576 group=128 dtype=bf16 M=128` | 13.45 | - | 13.39 | 13.57 | 6 | 0.7 | 3272 | 9.09 MiB | | +| `rmsnorm_quant_fp8` | `avx_rmsnorm_quant_fp8` | libavx | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=1` | - | 13.44 | 13.21 | 13.86 | 20 | 1.3 | - | 36.12 KiB | 32 thread(s) | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=2` | - | 13.43 | 13.31 | 14.86 | 20 | 3.0 | - | 3.70 KiB | 32 thread(s) | +| `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | `head_k=128 head_v=128 scale=0.0883883 M=32 chunk=64` | 13.42 | - | 13.40 | 13.45 | 6 | 0.2 | 3250 | 7.20 MiB | | +| `sample_temp` | `ref_sample_temp` | libref | `n_vocab=1024 M=4` | - | 13.42 | 13.40 | 13.75 | 19 | 0.8 | - | 16.38 KiB | 32 thread(s) | +| `quant_act_fp8` | `ref_quant_act_fp8` | libref | `n=1024 group=128 dtype=bf16 M=1` | - | 13.37 | 12.95 | 14.39 | 20 | 3.1 | - | 3.03 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=1280 K=2304 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | 13.29 | - | 13.28 | 13.31 | 6 | 0.1 | 3430 | 5.86 MiB | | +| `rope` | `ref_rope` | libref | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=4` | - | 13.29 | 13.24 | 13.64 | 19 | 1.0 | - | 8.05 KiB | 32 thread(s) | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=4` | - | 13.29 | 12.64 | 13.57 | 20 | 1.3 | - | 112.02 KiB | 32 thread(s) | +| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | 13.27 | - | 13.20 | 13.38 | 6 | 0.7 | 3290 | 32.04 MiB | | +| `moe_scatter` | `ref_moe_scatter` | libref | `n_expert=240 top_k=9 expert_base=0 M=128` | - | 13.27 | 13.26 | 14.50 | 20 | 1.4 | - | 10.88 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=1024 group=128 dtype=bf16 M=8` | - | 13.25 | 12.39 | 17.78 | 20 | 14.2 | - | 24.25 KiB | 32 thread(s) | +| `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | `head_k=128 head_v=128 scale=0.0883883 M=16 chunk=64` | 13.24 | - | 13.23 | 13.28 | 6 | 0.2 | 3254 | 6.60 MiB | | +| `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | `head_k=128 head_v=128 scale=0.0883883 M=8 chunk=64` | 13.15 | - | 13.14 | 13.18 | 6 | 0.1 | 3254 | 6.30 MiB | | +| `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | `head_k=128 head_v=128 scale=0.0883883 M=4 chunk=64` | 13.14 | - | 13.12 | 13.18 | 6 | 0.3 | 3254 | 6.15 MiB | | +| `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | `head_k=128 head_v=128 scale=0.0883883 M=2 chunk=64` | 13.09 | - | 13.07 | 13.12 | 6 | 0.2 | 3264 | 6.07 MiB | | +| `gdn_chunk_scan` | `gdn_chunk_scan_k128_v128_c64_bf16` | libr4d | `head_k=128 head_v=128 scale=0.0883883 M=1 chunk=64` | 13.08 | - | 13.05 | 13.11 | 6 | 0.2 | 3268 | 6.04 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=2048 K=1024 dtype=bf16 act=none M=4` | 13.05 | - | 13.03 | 13.08 | 6 | 0.2 | 3440 | 4.04 MiB | | +| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | 13.04 | - | 12.99 | 13.13 | 6 | 0.5 | 3268 | 32.13 MiB | | +| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | 12.92 | - | 12.87 | 12.97 | 6 | 0.4 | 3259 | 32.10 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=2048 K=1024 dtype=bf16 act=none M=2` | 12.85 | - | 12.85 | 12.87 | 6 | 0.1 | 3436 | 4.02 MiB | | +| `attn_dense` | `attn_dense_h80_bf16` | libr4d | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=512` | 12.85 | - | 12.58 | 12.88 | 11 | 0.2 | 3439 | 320.01 KiB | | +| `gdn_conv_update` | `gdn_conv_update_w4_h128_bf16` | libr4d | `head_k=128 head_v=128 conv_width=4 q_len=16` | 12.79 | - | 12.74 | 12.84 | 6 | 0.4 | 3256 | 1.05 MiB | restore 16% | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=18` | 12.78 | - | 12.76 | 12.86 | 6 | 0.4 | 3246 | 5.13 MiB | | +| `sample_ngram_ban` | `ref_sample_ngram_ban` | libref | `n_vocab=131072 M=16` | - | 12.77 | 9.46 | 14.70 | 20 | 15.9 | - | 8.26 MiB | 32 thread(s) | +| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | 12.76 | - | 12.72 | 12.85 | 6 | 0.5 | 3254 | 32.08 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=2048 K=1024 dtype=bf16 act=none M=1` | 12.76 | - | 12.75 | 12.86 | 6 | 0.4 | 3437 | 4.01 MiB | | +| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=4` | - | 12.73 | 12.65 | 12.86 | 11 | 0.6 | - | 48.05 KiB | 32 thread(s) | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=5 splits=0` | 12.56 | - | 12.49 | 12.67 | 6 | 0.7 | 3283 | 2.08 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=9` | 12.55 | - | 12.52 | 12.65 | 6 | 0.5 | 3246 | 5.06 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=1280 K=2304 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | 12.49 | - | 12.48 | 12.51 | 6 | 0.2 | 3434 | 5.74 MiB | | +| `rope_table` | `avx_rope_table` | libavx | `rot=64 theta=1e+07 scale=1 dtype=f32 M=16` | - | 12.47 | 12.36 | 13.21 | 20 | 2.2 | - | 4.06 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=1280 K=2304 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | 12.45 | - | 12.45 | 12.46 | 6 | 0.1 | 3426 | 5.73 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=8` | 12.45 | - | 12.44 | 12.45 | 6 | 0.1 | 3248 | 5.06 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=1` | 12.45 | - | 12.42 | 12.52 | 11 | 0.4 | 3252 | 5.01 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=4` | 12.45 | - | 12.43 | 12.47 | 6 | 0.1 | 3248 | 5.03 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=1024 K=5120 group=128 dtype=fp8a8 M=2` | 12.44 | - | 12.44 | 12.51 | 6 | 0.3 | 3248 | 5.01 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=1280 K=2304 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | 12.40 | - | 12.39 | 12.42 | 6 | 0.1 | 3426 | 5.68 MiB | | +| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | 12.33 | - | 12.30 | 12.48 | 6 | 0.7 | 3291 | 32.02 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1280 K=1280 dtype=bf16 act=none M=64` | 12.32 | - | 12.30 | 12.37 | 6 | 0.3 | 3430 | 3.60 MiB | | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | `N=240 K=4096 dtype=bf16 M=16` | 12.30 | - | 12.30 | 12.32 | 6 | 0.1 | 3277 | 3.89 MiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=512` | 12.28 | - | 12.26 | 12.32 | 6 | 0.2 | 3254 | 6.01 MiB | restore 42% | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1280 K=1280 dtype=bf16 act=none M=32` | 12.28 | - | 12.26 | 12.32 | 6 | 0.2 | 3434 | 3.36 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=1280 K=2304 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | 12.27 | - | 12.26 | 12.29 | 6 | 0.1 | 3428 | 5.65 MiB | | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=2` | - | 12.26 | 11.92 | 13.74 | 20 | 6.6 | - | 2.95 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=1024 K=4096 group=128 dtype=fp8a8 M=64` | 12.25 | - | 12.23 | 12.33 | 6 | 0.4 | 3412 | 4.38 MiB | | +| `had_quant_act_fp8` | `ref_had_quant_act_fp8` | libref | `n=1024 group=128 dtype=bf16 M=1` | - | 12.23 | 12.14 | 14.00 | 20 | 5.2 | - | 3.03 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=1280 K=2304 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | 12.22 | - | 12.21 | 12.24 | 6 | 0.1 | 3429 | 5.64 MiB | | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=8` | - | 12.22 | 12.07 | 13.69 | 19 | 0.9 | - | 128.03 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=1280 K=2304 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | 12.21 | - | 12.19 | 12.22 | 6 | 0.1 | 3432 | 5.63 MiB | | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=33` | 12.19 | - | 12.15 | 12.35 | 6 | 0.8 | 3344 | 888.02 KiB | | +| `attn_paged_sink` | `attn_window_sink_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=0 window=1024 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1` | 12.13 | - | 12.05 | 13.22 | 16 | 0.1 | 3239 | 32.13 KiB | | +| `silu_mul` | `avx_silu_mul` | libavx | `n=12288 dtype=bf16 M=1` | - | 12.09 | 12.06 | 12.69 | 20 | 2.1 | - | 72.00 KiB | 32 thread(s) | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=32` | 12.07 | - | 12.02 | 12.08 | 6 | 0.2 | 3357 | 832.01 KiB | | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=2048 group=128 dtype=bf16 M=4` | - | 12.02 | 11.87 | 13.63 | 20 | 5.7 | - | 24.25 KiB | 32 thread(s) | +| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=16` | - | 11.97 | 11.69 | 12.36 | 20 | 1.7 | - | 9.01 KiB | 32 thread(s) | +| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | 11.97 | - | 11.90 | 11.98 | 6 | 0.3 | 3262 | 4.13 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=1024 dtype=bf16 act=none M=128` | 11.95 | - | 11.92 | 11.98 | 6 | 0.2 | 3370 | 2.75 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=1024 dtype=bf16 act=none M=64` | 11.90 | - | 11.88 | 11.91 | 6 | 0.2 | 3378 | 2.38 MiB | | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=8` | - | 11.87 | 11.82 | 11.92 | 6 | 0.4 | - | 16.03 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=1024 dtype=bf16 act=none M=32` | 11.84 | - | 11.81 | 11.86 | 6 | 0.2 | 3374 | 2.19 MiB | | +| `act_mul` | `avx_act_mul` | libavx | `n=2304 act=relu dtype=bf16 M=4` | - | 11.82 | 11.80 | 13.40 | 20 | 4.3 | - | 54.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1152 dtype=bf16 act=none M=64` | 11.82 | - | 11.79 | 11.86 | 6 | 0.3 | 3412 | 2.96 MiB | | +| `sample_argmax` | `sample_argmax_f32` | libr4d | `n_vocab=248320 M=8` | 11.80 | - | 11.77 | 11.83 | 6 | 0.3 | 3437 | 7.58 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1152 dtype=bf16 act=none M=32` | 11.77 | - | 11.76 | 11.82 | 6 | 0.3 | 3418 | 2.74 MiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=256` | 11.76 | - | 11.75 | 11.78 | 6 | 0.1 | 3282 | 5.01 MiB | | +| `sample_argmax` | `sample_argmax_f32` | libr4d | `n_vocab=248320 M=4` | 11.72 | - | 11.69 | 11.81 | 6 | 0.5 | 3436 | 3.79 MiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=256` | 11.71 | - | 11.69 | 11.74 | 6 | 0.2 | 3298 | 5.01 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=64 ks=0 bk=0 nt=0` | 11.71 | - | 11.65 | 11.84 | 6 | 0.8 | 3316 | 3.26 MiB | | +| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | 11.70 | - | 11.64 | 11.71 | 6 | 0.3 | 3256 | 4.09 MiB | | +| `sample_argmax` | `sample_argmax_f32` | libr4d | `n_vocab=248320 M=2` | 11.67 | - | 11.64 | 11.70 | 6 | 0.2 | 3436 | 1.89 MiB | | +| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | 11.63 | - | 11.59 | 11.65 | 6 | 0.3 | 3276 | 4.06 MiB | | +| `sample_argmax` | `sample_argmax_f32` | libr4d | `n_vocab=248320 M=1` | 11.60 | - | 11.57 | 11.79 | 6 | 1.0 | 3439 | 970.10 KiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=1024 K=4096 group=128 dtype=fp8a8 M=33` | 11.59 | - | 11.58 | 11.61 | 6 | 0.2 | 3418 | 4.20 MiB | | +| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | 11.52 | - | 11.49 | 11.54 | 6 | 0.2 | 3262 | 4.08 MiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=128` | 11.46 | - | 11.42 | 11.47 | 6 | 0.2 | 3293 | 2.51 MiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=128` | 11.46 | - | 11.44 | 11.47 | 6 | 0.1 | 3288 | 2.51 MiB | | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=2` | - | 11.45 | 11.01 | 12.41 | 20 | 5.0 | - | 2.95 KiB | 32 thread(s) | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-05 dtype=bf16 M=256` | 11.43 | - | 11.40 | 11.47 | 6 | 0.3 | 3430 | 5.01 MiB | | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=17` | 11.41 | - | 11.41 | 11.44 | 6 | 0.2 | 3370 | 472.01 KiB | | +| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | 11.37 | - | 11.33 | 11.42 | 6 | 0.4 | 3286 | 4.03 MiB | | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=16` | 11.35 | - | 11.33 | 11.36 | 6 | 0.2 | 3388 | 416.01 KiB | | +| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | 11.32 | - | 11.27 | 11.37 | 6 | 0.5 | 3290 | 4.02 MiB | | +| `gdn_gated_rmsnorm` | `ref_gdn_gated_rmsnorm` | libref | `channels=128 eps=1e-06 act=silu M=4` | - | 11.31 | 11.22 | 12.05 | 20 | 1.8 | - | 3.50 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1280 K=1280 dtype=bf16 act=none M=16` | 11.29 | - | 11.28 | 11.33 | 6 | 0.2 | 3438 | 3.24 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1280 K=1280 dtype=bf16 act=none M=8` | 11.28 | - | 11.25 | 11.33 | 6 | 0.3 | 3433 | 3.19 MiB | | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=4` | - | 11.28 | 11.26 | 11.46 | 11 | 0.9 | - | 2.02 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=16` | - | 11.20 | 11.11 | 11.41 | 14 | 0.5 | - | 32.19 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=4` | - | 11.18 | 10.56 | 12.04 | 20 | 4.9 | - | 4.50 KiB | 32 thread(s) | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=25600 group=128 dtype=bf16 M=64` | 11.16 | - | 11.11 | 11.25 | 6 | 0.6 | 3292 | 4.74 MiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-05 dtype=bf16 M=128` | 11.15 | - | 11.14 | 11.17 | 6 | 0.1 | 3438 | 2.51 MiB | | +| `act_mul` | `avx_act_mul` | libavx | `n=1536 act=relu dtype=bf16 M=2` | - | 11.11 | 8.29 | 12.04 | 20 | 12.1 | - | 18.00 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=1024 group=128 dtype=fp8a8 M=64` | 11.07 | - | 11.07 | 11.12 | 6 | 0.2 | 3398 | 4.56 MiB | | +| `attn_paged` | `attn_prefill_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=11` | 11.05 | - | 11.02 | 11.08 | 6 | 0.2 | 3387 | 296.01 KiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=1024 K=4096 group=128 dtype=fp8a8 M=32` | 11.04 | - | 11.03 | 11.06 | 6 | 0.1 | 3419 | 4.19 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=1024 dtype=bf16 act=none M=16` | 10.95 | - | 10.87 | 10.97 | 11 | 0.2 | 3371 | 2.10 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=1024 dtype=bf16 act=none M=8` | 10.92 | - | 10.89 | 10.94 | 6 | 0.3 | 3374 | 2.05 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=1024 K=4096 group=128 dtype=fp8a8 M=18` | 10.91 | - | 10.90 | 10.98 | 6 | 0.4 | 3421 | 4.11 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1280 K=1280 dtype=bf16 act=none M=4` | 10.89 | - | 10.86 | 10.92 | 6 | 0.3 | 3438 | 3.16 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=24576 group=128 dtype=bf16 M=64` | 10.84 | - | 10.80 | 10.88 | 11 | 0.3 | 3280 | 4.55 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=25600 group=128 dtype=bf16 M=32` | 10.82 | - | 10.77 | 10.87 | 6 | 0.5 | 3295 | 2.37 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1152 dtype=bf16 act=none M=16` | 10.81 | - | 10.78 | 10.83 | 6 | 0.2 | 3411 | 2.64 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1152 dtype=bf16 act=none M=8` | 10.81 | - | 10.79 | 10.83 | 6 | 0.2 | 3416 | 2.59 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=25600 group=128 dtype=bf16 M=16` | 10.80 | - | 10.78 | 10.83 | 6 | 0.2 | 3288 | 1.18 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=25600 group=128 dtype=bf16 M=8` | 10.76 | - | 10.74 | 10.78 | 6 | 0.2 | 3289 | 606.25 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=25600 group=128 dtype=bf16 M=4` | 10.74 | - | 10.72 | 10.76 | 6 | 0.2 | 3290 | 303.12 KiB | | +| `moe_scatter` | `avx_moe_scatter` | libavx | `n_expert=304 top_k=9 expert_base=0 M=128` | - | 10.74 | 10.73 | 11.77 | 16 | 0.1 | - | 11.38 KiB | 32 thread(s) | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4 splits=0` | 10.73 | - | 10.69 | 10.75 | 6 | 0.3 | 3314 | 2.06 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=25600 group=128 dtype=bf16 M=2` | 10.71 | - | 10.68 | 10.72 | 6 | 0.2 | 3289 | 151.56 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=25600 group=128 dtype=bf16 M=1` | 10.71 | - | 10.67 | 10.73 | 6 | 0.3 | 3278 | 75.78 KiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=1024 K=4096 group=128 dtype=fp8a8 M=9` | 10.70 | - | 10.68 | 10.75 | 6 | 0.3 | 3412 | 4.05 MiB | | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | `N=304 K=4096 dtype=bf16 M=8` | 10.70 | - | 10.69 | 10.71 | 6 | 0.1 | 3403 | 4.82 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4096 K=1024 group=128 dtype=fp8a8 M=128` | 10.69 | - | 10.65 | 10.75 | 11 | 0.4 | 3411 | 5.13 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=1024 K=4096 group=128 dtype=fp8a8 M=2` | 10.67 | - | 10.66 | 10.72 | 6 | 0.3 | 3414 | 4.01 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=1024 K=4096 group=128 dtype=fp8a8 M=1` | 10.66 | - | 10.62 | 10.69 | 6 | 0.3 | 3402 | 4.01 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1280 K=1280 dtype=bf16 act=none M=2` | 10.65 | - | 10.63 | 10.71 | 6 | 0.3 | 3438 | 3.14 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=1024 K=4096 group=128 dtype=fp8a8 M=4` | 10.65 | - | 10.63 | 10.70 | 6 | 0.3 | 3410 | 4.02 MiB | | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | `N=304 K=4096 dtype=bf16 M=4` | 10.63 | - | 10.62 | 10.65 | 6 | 0.1 | 3410 | 4.79 MiB | | +| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=131072 M=16` | 10.63 | - | 9.67 | 12.19 | 20 | 7.3 | 3432 | 8.00 MiB | restore 71% | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | `N=304 K=4096 dtype=bf16 M=2` | 10.62 | - | 10.61 | 10.68 | 6 | 0.3 | 3422 | 4.77 MiB | | +| `gather_rows` | `ref_gather_rows` | libref | `n=1280 dtype=bf16 M=1` | - | 10.62 | 10.02 | 11.33 | 20 | 4.8 | - | 12.50 KiB | 32 thread(s) | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2 splits=0` | 10.61 | - | 10.59 | 10.64 | 6 | 0.2 | 3336 | 2.03 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=1024 K=4096 group=128 dtype=fp8a8 M=8` | 10.60 | - | 10.59 | 10.66 | 6 | 0.3 | 3410 | 4.05 MiB | | +| `gated_quant_fp8` | `gated_quant_fp8` | libr4d | `n=17408 group=128 dtype=bf16 act=silu M=64` | 10.60 | - | 10.57 | 10.64 | 6 | 0.3 | 3095 | 7.47 MiB | | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | `N=304 K=4096 dtype=bf16 M=1` | 10.58 | - | 10.57 | 10.62 | 6 | 0.2 | 3421 | 4.76 MiB | | +| `act_mul` | `avx_act_mul` | libavx | `n=2048 act=relu dtype=bf16 M=4` | - | 10.57 | 10.55 | 11.97 | 20 | 3.4 | - | 48.00 KiB | 32 thread(s) | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=10 splits=0` | 10.55 | - | 10.54 | 10.58 | 6 | 0.2 | 3378 | 272.01 KiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1280 K=1280 dtype=bf16 act=none M=1` | 10.54 | - | 10.54 | 10.57 | 6 | 0.1 | 3434 | 3.13 MiB | | +| `moe_scatter` | `avx_moe_scatter` | libavx | `n_expert=240 top_k=9 expert_base=0 M=128` | - | 10.53 | 10.42 | 11.51 | 20 | 3.2 | - | 10.88 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=1024 dtype=bf16 act=none M=4` | 10.52 | - | 10.50 | 10.53 | 6 | 0.1 | 3372 | 2.03 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=1024 group=128 dtype=fp8a8 M=33` | 10.50 | - | 10.47 | 10.53 | 6 | 0.3 | 3424 | 4.29 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=24576 group=128 dtype=bf16 M=32` | 10.49 | - | 10.47 | 10.52 | 6 | 0.2 | 3288 | 2.27 MiB | | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=130` | 10.49 | - | 10.45 | 10.53 | 6 | 0.4 | 3429 | 2.17 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=24576 group=128 dtype=bf16 M=16` | 10.48 | - | 10.41 | 10.49 | 6 | 0.4 | 3278 | 1.14 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=24576 group=128 dtype=bf16 M=8` | 10.44 | - | 10.43 | 10.45 | 6 | 0.1 | 3278 | 582.00 KiB | | +| `gdn_recurrent_update` | `gdn_recurrent_update_k128_v128_bf16_fp32state` | libr4d | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=2` | 10.44 | - | 10.33 | 10.53 | 6 | 1.0 | 3278 | 18.09 MiB | restore 70% | +| `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | `head_k=128 M=256 chunk=64` | 10.43 | - | 10.42 | 10.44 | 6 | 0.1 | 3261 | 2.59 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=24576 group=128 dtype=bf16 M=4` | 10.41 | - | 10.41 | 10.43 | 6 | 0.1 | 3276 | 291.00 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=24576 group=128 dtype=bf16 M=2` | 10.41 | - | 10.37 | 10.43 | 6 | 0.3 | 3278 | 145.50 KiB | | +| `gemm_nt_q` | `gemm_fp8a8_tiled` | libr4d | `N=4096 K=1024 group=128 dtype=fp8a8 M=65` | 10.40 | - | 10.39 | 10.43 | 6 | 0.2 | 3406 | 4.57 MiB | | +| `rope` | `avx_rope` | libavx | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=2` | - | 10.39 | 10.23 | 10.49 | 11 | 0.9 | - | 13.52 KiB | 32 thread(s) | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=24576 group=128 dtype=bf16 M=1` | 10.39 | - | 10.36 | 10.44 | 11 | 0.3 | 3268 | 72.75 KiB | | +| `add` | `avx_add` | libavx | `n=5120 dtype=bf16 M=2` | - | 10.38 | 10.24 | 11.43 | 20 | 2.0 | - | 60.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1152 dtype=bf16 act=none M=4` | 10.36 | - | 10.32 | 10.41 | 6 | 0.4 | 3418 | 2.56 MiB | | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=9 splits=0` | 10.36 | - | 10.35 | 10.39 | 6 | 0.2 | 3376 | 248.01 KiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=1024 dtype=bf16 act=none M=2` | 10.34 | - | 10.32 | 10.39 | 6 | 0.3 | 3368 | 2.01 MiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=8` | - | 10.33 | 10.30 | 13.52 | 20 | 3.9 | - | 4.25 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=1024 eps=1e-06 dtype=bf16 M=1` | - | 10.21 | 10.12 | 11.20 | 20 | 2.4 | - | 6.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1024 K=1024 dtype=bf16 act=none M=1` | 10.20 | - | 10.17 | 10.21 | 6 | 0.2 | 3362 | 2.01 MiB | | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1152 dtype=bf16 act=none M=2` | 10.20 | - | 10.13 | 10.50 | 20 | 1.2 | 3417 | 2.55 MiB | | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=1` | - | 10.14 | 10.07 | 10.18 | 11 | 0.4 | - | 2.00 KiB | 32 thread(s) | +| `gemm_nt_bias` | `gemm_bf16_nt_bias_tiled` | libr4d | `N=1152 K=1152 dtype=bf16 act=none M=1` | 10.08 | - | 10.05 | 10.09 | 6 | 0.2 | 3424 | 2.54 MiB | | +| `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | `head_k=128 M=64 chunk=64` | 10.07 | - | 8.91 | 10.08 | 20 | 4.7 | 2850 | 664.01 KiB | | +| `moe_scatter` | `moe_scatter_i32` | libr4d | `n_expert=304 top_k=9 expert_base=0 M=512` | 10.05 | - | 10.03 | 10.05 | 6 | 0.1 | 3417 | 38.38 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=256` | 9.97 | - | 9.95 | 9.98 | 6 | 0.2 | 3284 | 4.01 MiB | | +| `moe_scatter` | `moe_scatter_i32` | libr4d | `n_expert=240 top_k=9 expert_base=0 M=512` | 9.95 | - | 9.94 | 9.99 | 6 | 0.2 | 3434 | 37.88 KiB | | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | 9.87 | - | 9.85 | 9.88 | 6 | 0.1 | 3338 | 152.01 KiB | | +| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=248320 M=8` | 9.86 | - | 9.79 | 9.88 | 6 | 0.5 | 3378 | 7.58 MiB | restore 53% | +| `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | `head_k=128 M=128 chunk=64` | 9.78 | - | 9.52 | 10.73 | 20 | 4.5 | 3166 | 1.30 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=1024 group=128 dtype=fp8a8 M=18` | 9.77 | - | 9.76 | 9.84 | 11 | 0.4 | 3428 | 4.16 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=36 ks=0 bk=0 nt=0` | 9.75 | - | 9.71 | 9.77 | 6 | 0.3 | 3324 | 3.06 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=1024 group=128 dtype=fp8a8 M=32` | 9.74 | - | 9.73 | 9.80 | 6 | 0.4 | 3376 | 4.28 MiB | | +| `sample_mask` | `sample_mask_f32` | libr4d | `n_vocab=248320 M=8` | 9.74 | - | 9.64 | 9.76 | 6 | 0.6 | 3404 | 7.82 MiB | restore 53% | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1 splits=0` | 9.72 | - | 9.67 | 9.73 | 6 | 0.3 | 3354 | 2.02 MiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=4096 eps=1e-05 dtype=bf16 M=256` | 9.70 | - | 9.67 | 9.71 | 6 | 0.2 | 3430 | 4.01 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=1024 group=128 dtype=fp8a8 M=9` | 9.69 | - | 9.68 | 9.73 | 6 | 0.3 | 3434 | 4.08 MiB | | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=32` | - | 9.68 | 9.43 | 10.27 | 20 | 2.9 | - | 32.50 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=1024 group=128 dtype=fp8a8 M=8` | 9.68 | - | 9.67 | 9.70 | 6 | 0.1 | 3432 | 4.07 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=1024 group=128 dtype=fp8a8 M=2` | 9.68 | - | 9.66 | 9.72 | 6 | 0.3 | 3432 | 4.02 MiB | | +| `moe_gather` | `moe_gather_bf16` | libr4d | `n=1024 top_k=9 dtype=bf16 act=none M=256` | 9.65 | - | 9.62 | 9.65 | 6 | 0.2 | 3323 | 5.51 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=1024 group=128 dtype=fp8a8 M=1` | 9.64 | - | 9.64 | 9.68 | 6 | 0.2 | 3430 | 4.01 MiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=128` | 9.64 | - | 9.63 | 9.68 | 6 | 0.3 | 3293 | 2.01 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=4096 K=1024 group=128 dtype=fp8a8 M=4` | 9.64 | - | 9.63 | 9.67 | 6 | 0.2 | 3433 | 4.04 MiB | | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | 9.63 | - | 9.62 | 9.66 | 6 | 0.2 | 3334 | 128.01 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=5376 act=relu dtype=bf16 M=256` | 9.63 | - | 9.59 | 9.68 | 6 | 0.5 | 3400 | 7.88 MiB | | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=6144 group=128 dtype=bf16 M=2` | - | 9.63 | 9.58 | 10.15 | 20 | 1.8 | - | 36.38 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=12288 group=128 dtype=bf16 M=1` | - | 9.62 | 9.39 | 10.61 | 20 | 3.0 | - | 36.38 KiB | 32 thread(s) | +| `kv_store` | `ref_kv_store` | libref | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=2` | - | 9.59 | 9.13 | 9.87 | 20 | 1.7 | - | 50.01 KiB | 32 thread(s) | +| `moe_scatter` | `moe_scatter_i32` | libr4d | `n_expert=304 top_k=9 expert_base=0 M=256` | 9.58 | - | 9.58 | 9.60 | 6 | 0.1 | 3414 | 20.38 KiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=512` | 9.54 | - | 9.52 | 9.57 | 6 | 0.3 | 3326 | 1.00 MiB | restore 20% | +| `moe_scatter` | `moe_scatter_i32` | libr4d | `n_expert=240 top_k=9 expert_base=0 M=256` | 9.52 | - | 9.51 | 9.53 | 6 | 0.1 | 3432 | 19.88 KiB | | +| `moe_scatter` | `moe_scatter_i32` | libr4d | `n_expert=304 top_k=9 expert_base=0 M=128` | 9.50 | - | 9.49 | 9.54 | 6 | 0.2 | 3413 | 11.38 KiB | | +| `moe_scatter` | `moe_scatter_i32` | libr4d | `n_expert=240 top_k=9 expert_base=0 M=128` | 9.45 | - | 9.43 | 9.47 | 6 | 0.2 | 3434 | 10.88 KiB | | +| `dflash_select` | `dflash_select_bf16` | libr4d | `steps=7 top_k=16 rank=256 n_vocab=248320 anchor_stride=8 dtype=bf16 M=8` | 9.42 | - | 9.41 | 9.73 | 14 | 0.2 | 3448 | 242.53 MiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=4096 eps=1e-05 dtype=bf16 M=128` | 9.41 | - | 9.40 | 9.45 | 6 | 0.3 | 3432 | 2.01 MiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=128` | 9.31 | - | 9.30 | 9.34 | 6 | 0.2 | 3340 | 865.00 KiB | restore 21% | +| `dflash_select` | `dflash_select_bf16` | libr4d | `steps=7 top_k=16 rank=256 n_vocab=248320 anchor_stride=8 dtype=bf16 M=2` | 9.31 | - | 9.30 | 9.33 | 11 | 0.1 | 3448 | 242.51 MiB | | +| `dflash_select` | `dflash_select_bf16` | libr4d | `steps=7 top_k=16 rank=256 n_vocab=248320 anchor_stride=8 dtype=bf16 M=4` | 9.30 | - | 9.29 | 9.32 | 11 | 0.1 | 3449 | 242.52 MiB | | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=1536 group=128 dtype=bf16 M=4` | - | 9.28 | 9.03 | 10.03 | 20 | 3.7 | - | 18.19 KiB | 32 thread(s) | +| `dflash_select` | `dflash_select_bf16` | libr4d | `steps=7 top_k=16 rank=256 n_vocab=248320 anchor_stride=8 dtype=bf16 M=1` | 9.26 | - | 9.23 | 9.36 | 6 | 0.7 | 3448 | 242.50 MiB | | +| `gdn_recurrent_update` | `gdn_recurrent_update_k128_v128_bf16_fp32state` | libr4d | `head_k=128 head_v=128 n_head_v=48 scale=0.0883883 eps=1e-06 act=silu state_form=anchor q_len=1` | 9.25 | - | 9.13 | 9.31 | 11 | 0.8 | 3268 | 18.04 MiB | restore 72% | +| `quant_act_i8` | `avx_quant_act_i8` | libavx | `n=5120 group=128 dtype=bf16 M=2` | - | 9.24 | 8.98 | 9.80 | 20 | 2.6 | - | 32.51 KiB | 32 thread(s) | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | 9.23 | - | 9.21 | 9.24 | 6 | 0.2 | 3360 | 224.01 KiB | | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | 9.21 | - | 9.19 | 9.24 | 6 | 0.3 | 3328 | 80.01 KiB | | +| `sample_temp` | `ref_sample_temp` | libref | `n_vocab=1024 M=2` | - | 9.18 | 9.16 | 11.98 | 16 | 0.1 | - | 8.19 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=8` | - | 9.17 | 9.16 | 9.32 | 6 | 0.9 | - | 4.03 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=1024 eps=1e-05 dtype=bf16 M=1` | - | 9.10 | 8.93 | 9.73 | 20 | 2.3 | - | 4.00 KiB | 32 thread(s) | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | 9.09 | - | 9.08 | 9.10 | 6 | 0.1 | 3317 | 56.01 KiB | | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | `N=240 K=4096 dtype=bf16 M=8` | 9.08 | - | 9.07 | 9.09 | 6 | 0.1 | 3422 | 3.82 MiB | | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | `N=240 K=4096 dtype=bf16 M=4` | 9.00 | - | 8.99 | 9.06 | 6 | 0.4 | 3430 | 3.78 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=96 K=5120 dtype=bf16 M=260 wv=1 sk=0 mb=0 npw=1 nt=1` | 8.99 | - | 8.96 | 9.01 | 6 | 0.3 | 3285 | 3.52 MiB | | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | `N=240 K=4096 dtype=bf16 M=2` | 8.97 | - | 8.97 | 8.98 | 6 | 0.0 | 3432 | 3.77 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=256 K=4096 group=128 dtype=fp8a8 M=64` | 8.96 | - | 8.94 | 8.97 | 6 | 0.2 | 3310 | 1.29 MiB | | +| `gemm_nt_f32` | `gemm_nt_f32_bf16` | libr4d | `N=240 K=4096 dtype=bf16 M=1` | 8.94 | - | 8.93 | 8.96 | 6 | 0.1 | 3431 | 3.76 MiB | | +| `attn_paged` | `attn_decode_h256_gqa6_fp8kv` | libr4d | `head_dim=256 gqa=6 causal=1 window=0 n_head=24 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | 8.93 | - | 8.92 | 8.95 | 6 | 0.2 | 3346 | 176.01 KiB | | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=512` | 8.91 | - | 8.90 | 8.93 | 6 | 0.2 | 3392 | 645.19 KiB | | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=512` | 8.79 | - | 6.95 | 10.96 | 20 | 10.5 | 3316 | 1.00 GiB | | +| `moe_scatter` | `avx_moe_scatter` | libavx | `n_expert=240 top_k=9 expert_base=0 M=64` | - | 8.79 | 5.90 | 8.79 | 20 | 12.6 | - | 6.38 KiB | 32 thread(s) | +| `add` | `avx_add` | libavx | `n=4096 dtype=bf16 M=2` | - | 8.78 | 8.53 | 9.42 | 20 | 2.2 | - | 48.00 KiB | 32 thread(s) | +| `ple_conv_bias` | `ple_conv_bias_bf16` | libr4d | `n=10240 width=4 dilation=1 dtype=bf16 M=8` | 8.76 | - | 8.72 | 8.78 | 6 | 0.3 | 3369 | 780.02 KiB | restore 22% | +| `act_mul` | `act_mul_bf16` | libr4d | `n=20480 act=relu dtype=bf16 M=64` | 8.68 | - | 8.61 | 8.71 | 6 | 0.6 | 3376 | 7.50 MiB | | +| `silu` | `avx_silu` | libavx | `n=2048 dtype=bf16 M=4` | - | 8.66 | 8.65 | 9.30 | 20 | 1.8 | - | 32.00 KiB | 32 thread(s) | +| `silu` | `avx_silu` | libavx | `n=1024 dtype=bf16 M=8` | - | 8.66 | 8.65 | 9.04 | 20 | 2.0 | - | 32.00 KiB | 32 thread(s) | +| `moe_scatter` | `ref_moe_scatter` | libref | `n_expert=304 top_k=9 expert_base=0 M=64` | - | 8.52 | 8.51 | 9.41 | 20 | 1.2 | - | 6.88 KiB | 32 thread(s) | +| `layernorm` | `avx_layernorm` | libavx | `n=1280 eps=1e-06 dtype=bf16 M=8` | - | 8.51 | 7.29 | 9.59 | 20 | 7.8 | - | 45.00 KiB | 32 thread(s) | +| `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | `head_k=128 M=2 chunk=64` | 8.50 | - | 7.87 | 8.52 | 20 | 3.2 | 2862 | 20.76 KiB | | +| `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | `head_k=128 M=16 chunk=64` | 8.43 | - | 7.69 | 8.80 | 20 | 6.3 | 3028 | 166.01 KiB | | +| `cast` | `cast_bf16_bf16` | libr4d | `n=5120 from=bf16 to=bf16 M=512` | 8.43 | - | 8.19 | 8.44 | 16 | 0.4 | 2838 | 10.00 MiB | | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=256` | 8.41 | - | 8.41 | 8.43 | 6 | 0.1 | 3396 | 323.19 KiB | | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=1` | 8.39 | - | 8.36 | 8.42 | 6 | 0.3 | 3394 | 2.45 KiB | | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5376 group=128 dtype=bf16 M=2` | - | 8.38 | 8.28 | 19.75 | 20 | 55.5 | - | 31.83 KiB | 32 thread(s) | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=4` | 8.37 | - | 8.34 | 8.43 | 6 | 0.5 | 3382 | 6.22 KiB | | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=2` | 8.36 | - | 8.33 | 8.39 | 6 | 0.4 | 3382 | 3.70 KiB | | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=8` | 8.35 | - | 8.33 | 8.36 | 6 | 0.2 | 3382 | 11.25 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=8192 act=silu dtype=bf16 M=128` | 8.33 | - | 8.31 | 8.37 | 6 | 0.4 | 3397 | 6.00 MiB | | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=32` | 8.33 | - | 8.32 | 8.35 | 6 | 0.2 | 3384 | 41.44 KiB | | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5120 group=128 dtype=bf16 M=2` | - | 8.32 | 7.82 | 11.34 | 20 | 15.4 | - | 30.31 KiB | 32 thread(s) | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=16` | 8.32 | - | 8.32 | 8.33 | 6 | 0.1 | 3382 | 21.31 KiB | | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=128` | 8.32 | - | 8.31 | 8.33 | 6 | 0.1 | 3379 | 162.19 KiB | | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=64` | 8.30 | - | 8.29 | 8.32 | 6 | 0.2 | 3384 | 81.69 KiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=256 K=4096 group=128 dtype=fp8a8 M=33` | 8.24 | - | 8.23 | 8.26 | 6 | 0.2 | 3307 | 1.15 MiB | | +| `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | `head_k=128 M=32 chunk=64` | 8.22 | - | 8.07 | 9.18 | 20 | 2.5 | 3214 | 332.01 KiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=18 ks=0 bk=0 nt=0` | 8.20 | - | 8.17 | 8.30 | 6 | 0.8 | 3328 | 2.94 MiB | | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=16` | - | 8.19 | 8.10 | 8.25 | 6 | 0.9 | - | 64.06 KiB | 32 thread(s) | +| `quant_act_i8` | `quant_act_i8` | libr4d | `n=5120 group=128 dtype=bf16 M=56` | 8.19 | - | 8.16 | 8.22 | 6 | 0.4 | 3434 | 850.22 KiB | | +| `moe_gather` | `moe_gather_bf16` | libr4d | `n=1024 top_k=9 dtype=bf16 act=none M=128` | 8.17 | - | 8.15 | 8.17 | 6 | 0.1 | 3429 | 2.76 MiB | | +| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=2` | - | 8.15 | 8.07 | 8.47 | 20 | 1.0 | - | 24.02 KiB | 32 thread(s) | +| `moe_scatter` | `ref_moe_scatter` | libref | `n_expert=240 top_k=9 expert_base=0 M=64` | - | 8.13 | 7.94 | 11.76 | 20 | 8.3 | - | 6.38 KiB | 32 thread(s) | +| `attn_dense` | `attn_vit_h72_bf16` | libr4d | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=256` | 8.07 | - | 8.03 | 9.01 | 20 | 3.7 | 3416 | 144.01 KiB | | +| `sample_xtc` | `sample_xtc_f32` | libr4d | `n_cand=1024 M=64` | 8.04 | - | 7.96 | 8.11 | 12 | 0.7 | 3436 | 518.00 KiB | restore 37% | +| `moe_gather` | `moe_gather_bf16` | libr4d | `n=1024 top_k=9 dtype=bf16 act=none M=64` | 8.03 | - | 8.03 | 8.04 | 6 | 0.1 | 3432 | 1.38 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=17408 group=128 dtype=bf16 M=64` | 7.98 | - | 7.97 | 8.00 | 6 | 0.2 | 3442 | 3.22 MiB | | +| `sample_xtc` | `sample_xtc_f32` | libr4d | `n_cand=1024 M=4` | 7.94 | - | 7.91 | 7.97 | 12 | 0.3 | 3438 | 32.38 KiB | restore 38% | +| `gdn_gated_rmsnorm` | `avx_gdn_gated_rmsnorm` | libavx | `channels=128 eps=1e-06 act=silu M=32` | - | 7.93 | 7.86 | 8.52 | 20 | 2.5 | - | 24.50 KiB | 32 thread(s) | +| `act_mul` | `act_mul_bf16` | libr4d | `n=2304 act=relu dtype=bf16 M=512` | 7.92 | - | 7.91 | 7.94 | 6 | 0.2 | 3418 | 6.75 MiB | | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=65` | 7.88 | - | 7.86 | 7.90 | 6 | 0.3 | 3432 | 1.09 MiB | | +| `sample_xtc` | `sample_xtc_f32` | libr4d | `n_cand=1024 M=32` | 7.87 | - | 4.06 | 7.96 | 22 | 0.8 | 3439 | 259.00 KiB | restore 38% | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=1 ks=0 bk=0 nt=0` | 7.86 | - | 7.84 | 7.87 | 11 | 0.1 | 3316 | 2.82 MiB | | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=2304 group=128 dtype=bf16 M=512` | 7.83 | - | 7.81 | 7.84 | 6 | 0.3 | 3340 | 3.41 MiB | | +| `sample_xtc` | `sample_xtc_f32` | libr4d | `n_cand=1024 M=2` | 7.82 | - | 7.76 | 7.88 | 12 | 0.6 | 3440 | 16.19 KiB | restore 38% | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=2 ks=0 bk=0 nt=0` | 7.80 | - | 7.78 | 7.81 | 11 | 0.2 | 3314 | 2.83 MiB | | +| `sample_dry` | `sample_dry_f32` | libr4d | `n_vocab=248320 M=2` | 7.80 | - | 7.78 | 7.83 | 6 | 0.3 | 3208 | 1.90 MiB | restore 32% | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=8 ks=0 bk=0 nt=0` | 7.78 | - | 7.77 | 7.80 | 11 | 0.2 | 3324 | 2.87 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=4 ks=0 bk=0 nt=0` | 7.78 | - | 7.76 | 7.78 | 11 | 0.1 | 3324 | 2.84 MiB | | +| `gemm_nt_q` | `gemm_mxfp4a8_gemv_wide` | libr4d | `N=1024 K=5120 group=32 dtype=mxfp4a8 M=9 ks=0 bk=0 nt=0` | 7.77 | - | 7.75 | 7.79 | 11 | 0.2 | 3328 | 2.88 MiB | | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=64` | 7.76 | - | 7.75 | 7.80 | 6 | 0.3 | 3432 | 1.06 MiB | | +| `sample_dry` | `sample_dry_f32` | libr4d | `n_vocab=131072 M=2` | 7.74 | - | 7.65 | 7.78 | 6 | 0.8 | 3432 | 1.00 MiB | restore 23% | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=17408 group=128 dtype=bf16 M=32` | 7.71 | - | 7.70 | 7.74 | 6 | 0.2 | 3447 | 1.61 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=17408 group=128 dtype=bf16 M=16` | 7.69 | - | 7.68 | 7.70 | 6 | 0.2 | 3447 | 824.50 KiB | | +| `sample_dry` | `sample_dry_f32` | libr4d | `n_vocab=131072 M=4` | 7.67 | - | 7.66 | 7.69 | 6 | 0.2 | 3260 | 2.00 MiB | restore 32% | +| `sample_dry` | `sample_dry_f32` | libr4d | `n_vocab=248320 M=1` | 7.66 | - | 7.65 | 7.68 | 6 | 0.2 | 3373 | 970.41 KiB | restore 25% | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=17408 group=128 dtype=bf16 M=8` | 7.66 | - | 7.65 | 7.69 | 6 | 0.3 | 3448 | 412.25 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=17408 group=128 dtype=bf16 M=4` | 7.65 | - | 7.64 | 7.68 | 6 | 0.3 | 3448 | 206.12 KiB | | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=6 splits=0` | 7.65 | - | 7.63 | 7.67 | 6 | 0.2 | 3394 | 112.01 KiB | | +| `sample_xtc` | `sample_xtc_f32` | libr4d | `n_cand=1024 M=8` | 7.64 | - | 7.57 | 7.85 | 22 | 0.8 | 3439 | 64.75 KiB | restore 39% | +| `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | `head_k=128 M=8 chunk=64` | 7.63 | - | 7.62 | 7.65 | 6 | 0.2 | 3303 | 83.01 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=17408 group=128 dtype=bf16 M=2` | 7.63 | - | 7.62 | 7.64 | 6 | 0.1 | 3445 | 103.06 KiB | | +| `sample_xtc` | `sample_xtc_f32` | libr4d | `n_cand=1024 M=16` | 7.63 | - | 7.53 | 7.66 | 12 | 0.8 | 3441 | 129.50 KiB | restore 39% | +| `sample_dry` | `sample_dry_f32` | libr4d | `n_vocab=248320 M=4` | 7.63 | - | 7.61 | 7.64 | 6 | 0.2 | 3220 | 3.79 MiB | restore 37% | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=64` | 7.62 | - | 7.61 | 7.63 | 6 | 0.2 | 3292 | 1.26 MiB | | +| `mul_weight` | `mul_weight_bf16` | libr4d | `n=8192 dtype=bf16 M=128` | 7.62 | - | 7.61 | 7.64 | 6 | 0.2 | 3423 | 4.02 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=17408 group=128 dtype=bf16 M=1` | 7.61 | - | 7.60 | 7.62 | 6 | 0.1 | 3447 | 51.53 KiB | | +| `sample_argmax` | `sample_argmax_f32` | libr4d | `n_vocab=131072 M=8` | 7.61 | - | 7.60 | 7.64 | 11 | 0.3 | 3437 | 4.00 MiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=64` | 7.60 | - | 7.59 | 7.60 | 6 | 0.1 | 3294 | 1.26 MiB | | +| `attn_dense` | `attn_dense_h80_bf16` | libr4d | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=256` | 7.59 | - | 7.58 | 7.65 | 6 | 0.5 | 3435 | 160.01 KiB | | +| `sample_dry` | `sample_dry_f32` | libr4d | `n_vocab=131072 M=1` | 7.59 | - | 7.53 | 7.60 | 6 | 0.4 | 3437 | 512.41 KiB | restore 24% | +| `sample_argmax` | `sample_argmax_f32` | libr4d | `n_vocab=131072 M=4` | 7.58 | - | 7.57 | 7.61 | 6 | 0.3 | 3440 | 2.00 MiB | | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=1` | - | 7.54 | 7.53 | 8.05 | 16 | 0.8 | - | 2.45 KiB | 32 thread(s) | +| `sample_argmax` | `sample_argmax_f32` | libr4d | `n_vocab=131072 M=2` | 7.54 | - | 7.53 | 7.56 | 6 | 0.2 | 3438 | 1.00 MiB | | +| `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | `head_k=128 M=4 chunk=64` | 7.50 | - | 7.47 | 7.52 | 6 | 0.4 | 3304 | 41.51 KiB | | +| `sample_argmax` | `sample_argmax_f32` | libr4d | `n_vocab=131072 M=1` | 7.50 | - | 7.48 | 7.50 | 6 | 0.2 | 3440 | 512.10 KiB | | +| `mul_weight` | `mul_weight_bf16` | libr4d | `n=8192 dtype=bf16 M=64` | 7.49 | - | 7.47 | 7.50 | 6 | 0.2 | 3433 | 2.02 MiB | | +| `sample_dry` | `sample_dry_f32` | libr4d | `n_vocab=248320 M=8` | 7.48 | - | 7.43 | 7.50 | 6 | 0.5 | 3380 | 7.58 MiB | restore 59% | +| `sample_dry` | `sample_dry_f32` | libr4d | `n_vocab=131072 M=8` | 7.47 | - | 7.43 | 7.51 | 6 | 0.5 | 3378 | 4.00 MiB | restore 73% | +| `silu_mul` | `silu_mul_bf16` | libr4d | `n=17408 dtype=bf16 M=64` | 7.47 | - | 7.45 | 7.47 | 6 | 0.1 | 3296 | 6.38 MiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=64` | 7.43 | - | 6.48 | 8.03 | 20 | 7.0 | 3328 | 432.50 KiB | restore 24% | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-05 dtype=bf16 M=64` | 7.42 | - | 7.41 | 7.42 | 6 | 0.1 | 3438 | 1.26 MiB | | +| `gdn_kkt_solve` | `gdn_kkt_solve_k128_c64_bf16` | libr4d | `head_k=128 M=1 chunk=64` | 7.42 | - | 7.40 | 7.52 | 6 | 0.8 | 3317 | 10.38 KiB | | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=256 K=5120 dtype=bf16 M=56 wv=1 sk=0 mb=0 npw=1 nt=1` | 7.41 | - | 7.40 | 7.43 | 6 | 0.2 | 3434 | 3.07 MiB | | +| `mul_weight` | `mul_weight_bf16` | libr4d | `n=8192 dtype=bf16 M=1` | 7.41 | - | 7.39 | 7.43 | 6 | 0.3 | 3434 | 48.00 KiB | | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=5 splits=0` | 7.40 | - | 7.39 | 7.42 | 6 | 0.2 | 3404 | 96.01 KiB | | +| `mul_weight` | `mul_weight_bf16` | libr4d | `n=8192 dtype=bf16 M=2` | 7.38 | - | 7.38 | 7.39 | 6 | 0.1 | 3434 | 80.00 KiB | | +| `mul_weight` | `mul_weight_bf16` | libr4d | `n=8192 dtype=bf16 M=32` | 7.37 | - | 7.36 | 7.39 | 6 | 0.2 | 3433 | 1.02 MiB | | +| `mul_weight` | `mul_weight_bf16` | libr4d | `n=8192 dtype=bf16 M=4` | 7.36 | - | 7.35 | 7.40 | 6 | 0.3 | 3434 | 144.00 KiB | | +| `mul_weight` | `mul_weight_bf16` | libr4d | `n=8192 dtype=bf16 M=8` | 7.36 | - | 7.35 | 7.37 | 6 | 0.1 | 3434 | 272.00 KiB | | +| `mul_weight` | `mul_weight_bf16` | libr4d | `n=8192 dtype=bf16 M=16` | 7.36 | - | 7.35 | 7.36 | 6 | 0.1 | 3434 | 528.00 KiB | | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=2` | - | 7.35 | 7.31 | 7.55 | 16 | 0.7 | - | 1.01 KiB | 32 thread(s) | +| `act_mul` | `act_mul_bf16` | libr4d | `n=2048 act=relu dtype=bf16 M=512` | 7.32 | - | 7.30 | 7.35 | 6 | 0.3 | 3414 | 6.00 MiB | | +| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=6 splits=0` | 7.23 | - | 7.23 | 7.24 | 6 | 0.1 | 3264 | 128.01 KiB | | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=8 splits=0` | 7.23 | - | 7.21 | 7.24 | 6 | 0.3 | 3394 | 144.01 KiB | | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=4 splits=0` | 7.20 | - | 7.09 | 7.67 | 20 | 3.2 | 3299 | 80.01 KiB | | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=2` | - | 7.18 | 7.13 | 7.38 | 14 | 0.6 | - | 16.01 KiB | 32 thread(s) | +| `sample_xtc` | `sample_xtc_f32` | libr4d | `n_cand=1024 M=1` | 7.14 | - | 7.12 | 7.26 | 12 | 0.9 | 3440 | 8.09 KiB | restore 40% | +| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=4 splits=0` | 7.14 | - | 7.12 | 7.14 | 6 | 0.1 | 3290 | 96.01 KiB | | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=256 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | 7.11 | - | 7.10 | 7.14 | 6 | 0.3 | 3438 | 2.85 MiB | | +| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=5 splits=0` | 7.10 | - | 7.10 | 7.11 | 6 | 0.1 | 3277 | 112.01 KiB | | +| `act_mul` | `avx_act_mul` | libavx | `n=5376 act=relu dtype=bf16 M=1` | - | 7.10 | 7.07 | 8.17 | 20 | 3.6 | - | 31.50 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=256 K=4096 group=128 dtype=fp8a8 M=32` | 7.10 | - | 7.08 | 7.10 | 6 | 0.1 | 3308 | 1.14 MiB | | +| `grid_embed` | `grid_embed_bf16` | libr4d | `n=1152 side=48 dtype=bf16 M=512` | 7.09 | - | 7.06 | 7.26 | 14 | 0.2 | 3322 | 6.20 MiB | restore 26% | +| `sample_dry` | `sample_dry_f32` | libr4d | `n_vocab=131072 M=16` | 7.09 | - | -80.48 | 8.60 | 20 | 15.9 | 3432 | 8.01 MiB | restore 79%; restore-dominated (79% of the batch): an order of magnitude | +| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=2 splits=0` | 7.08 | - | 7.06 | 7.09 | 6 | 0.3 | 3292 | 64.01 KiB | | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=2 splits=0` | 7.06 | - | 7.04 | 7.27 | 16 | 0.3 | 3422 | 48.01 KiB | | +| `sample_pick` | `sample_pick_f32` | libr4d | `n_cand=1024 M=2` | 7.04 | - | 7.02 | 7.05 | 12 | 0.2 | 3436 | 16.20 KiB | | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=2` | - | 7.04 | 6.62 | 7.23 | 20 | 1.8 | - | 104.01 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=8192 group=128 dtype=bf16 M=1` | - | 7.02 | 6.63 | 7.57 | 20 | 6.4 | - | 24.25 KiB | 32 thread(s) | +| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=1 splits=0` | 7.01 | - | 6.96 | 7.93 | 19 | 0.2 | 3295 | 48.01 KiB | | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=2304 group=128 dtype=bf16 M=2` | - | 6.98 | 6.89 | 7.93 | 20 | 4.6 | - | 13.64 KiB | 32 thread(s) | +| `sample_dry` | `sample_dry_f32` | libr4d | `n_vocab=131072 M=32` | 6.96 | - | 6.89 | 6.97 | 6 | 0.6 | 3431 | 16.01 MiB | restore 76%; restore-dominated (76% of the batch): an order of magnitude | +| `gated_quant_fp8` | `gated_quant_fp8` | libr4d | `n=17408 group=128 dtype=bf16 act=silu M=32` | 6.94 | - | 6.92 | 6.96 | 6 | 0.3 | 3130 | 3.74 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=256 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | 6.93 | - | 6.93 | 6.95 | 6 | 0.2 | 3446 | 2.66 MiB | | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=512` | 6.93 | - | 6.92 | 6.94 | 6 | 0.2 | 3428 | 516.94 KiB | | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=256 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | 6.91 | - | 6.91 | 6.95 | 6 | 0.3 | 3443 | 2.67 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=256 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | 6.89 | - | 6.88 | 6.92 | 6 | 0.3 | 3446 | 2.58 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=256 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | 6.89 | - | 6.88 | 6.91 | 6 | 0.2 | 3446 | 2.54 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=256 K=5120 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | 6.88 | - | 6.88 | 6.91 | 6 | 0.2 | 3447 | 2.51 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=256 K=5120 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | 6.88 | - | 6.87 | 6.90 | 6 | 0.2 | 3448 | 2.52 MiB | | +| `attn_paged` | `attn_decode_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=1 splits=0` | 6.87 | - | 6.85 | 6.99 | 6 | 1.0 | 3432 | 32.01 KiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=256 K=4096 group=128 dtype=fp8a8 M=18` | 6.87 | - | 6.86 | 6.87 | 6 | 0.1 | 3307 | 1.08 MiB | | +| `silu` | `silu_bf16` | libr4d | `n=2048 dtype=bf16 M=448` | 6.84 | - | 6.83 | 6.88 | 11 | 0.4 | 3415 | 3.50 MiB | | +| `rope_table` | `ref_rope_table` | libref | `rot=64 theta=1e+07 scale=1 dtype=f32 M=4` | - | 6.75 | 6.69 | 7.07 | 20 | 2.4 | - | 1.02 KiB | 32 thread(s) | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | `n_expert=304 top_k=9 norm=1 route_scale=5 dtype=f32 M=1` | - | 6.74 | 6.65 | 7.11 | 20 | 2.4 | - | 2.45 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-05 dtype=bf16 M=2` | - | 6.70 | 6.31 | 7.38 | 20 | 4.4 | - | 50.00 KiB | 32 thread(s) | +| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=256` | 6.68 | - | 6.65 | 6.71 | 6 | 0.4 | 3170 | 3.00 MiB | restore 38% | +| `attn_paged` | `attn_decode_h128_gqa4_fp8kv` | libr4d | `head_dim=128 gqa=4 causal=0 window=2048 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=fp8_e4m3 q_len=8 splits=0` | 6.68 | - | 6.68 | 6.69 | 6 | 0.1 | 3276 | 160.01 KiB | | +| `sample_dry` | `sample_dry_f32` | libr4d | `n_vocab=248320 M=16` | 6.67 | - | 6.60 | 6.74 | 11 | 0.9 | 3381 | 15.16 MiB | restore 75%; restore-dominated (75% of the batch): an order of magnitude | +| `rope` | `ref_rope` | libref | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=2` | - | 6.65 | 6.62 | 6.71 | 11 | 0.7 | - | 4.02 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=2` | - | 6.62 | 6.37 | 6.97 | 20 | 2.9 | - | 50.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=1024 group=128 dtype=bf16 M=8` | - | 6.59 | 6.58 | 7.10 | 20 | 3.5 | - | 24.25 KiB | 32 thread(s) | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=64` | 6.57 | - | 6.57 | 6.67 | 6 | 0.8 | 3252 | 512.25 KiB | restore 27% | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=256` | 6.57 | - | 6.52 | 6.60 | 6 | 0.5 | 3296 | 513.00 KiB | restore 27% | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=2` | - | 6.57 | 6.51 | 6.72 | 16 | 1.0 | - | 16.01 KiB | 32 thread(s) | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=256` | 6.56 | - | 6.54 | 6.58 | 6 | 0.3 | 3432 | 258.94 KiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=64` | 6.56 | - | 6.54 | 6.58 | 6 | 0.3 | 3318 | 512.25 KiB | restore 27% | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=1` | 6.55 | - | 6.52 | 6.87 | 16 | 0.3 | 3420 | 1.95 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=64` | 6.54 | - | 6.53 | 6.56 | 6 | 0.2 | 3294 | 1.01 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=256 K=4096 group=128 dtype=fp8a8 M=9` | 6.54 | - | 6.52 | 6.55 | 6 | 0.2 | 3293 | 1.04 MiB | | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=4096 group=128 dtype=bf16 M=2` | - | 6.53 | 6.20 | 7.23 | 40 | 7.4 | - | 24.25 KiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=128` | 6.51 | - | 6.50 | 6.53 | 6 | 0.3 | 3282 | 3.52 MiB | restore 27% | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=4` | 6.50 | - | 6.49 | 6.53 | 11 | 0.2 | 3424 | 4.97 KiB | | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=128` | 6.50 | - | 6.45 | 6.58 | 6 | 1.0 | 3290 | 4.40 MiB | restore 29% | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=2` | 6.50 | - | 6.48 | 6.52 | 6 | 0.3 | 3424 | 2.95 KiB | | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=8` | 6.49 | - | 6.47 | 6.49 | 6 | 0.2 | 3422 | 9.00 KiB | | +| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=8` | - | 6.48 | 5.97 | 7.33 | 20 | 6.3 | - | 5.01 KiB | 32 thread(s) | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=16` | 6.48 | - | 6.46 | 6.49 | 6 | 0.3 | 3424 | 17.06 KiB | | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=2` | - | 6.47 | 5.67 | 6.82 | 20 | 5.5 | - | 50.00 KiB | 32 thread(s) | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=32` | 6.47 | - | 6.45 | 6.49 | 6 | 0.3 | 3426 | 33.19 KiB | | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=128` | 6.47 | - | 6.44 | 6.48 | 6 | 0.3 | 3432 | 129.94 KiB | | +| `router_sigmoid_topk` | `router_sigmoid_topk_f32` | libr4d | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=64` | 6.45 | - | 6.44 | 6.47 | 6 | 0.3 | 3434 | 65.44 KiB | | +| `layernorm` | `avx_layernorm` | libavx | `n=1152 eps=1e-06 dtype=bf16 M=8` | - | 6.43 | 6.39 | 6.65 | 20 | 1.8 | - | 40.50 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=2048 group=128 dtype=bf16 M=2` | - | 6.40 | 6.14 | 7.08 | 20 | 6.6 | - | 12.12 KiB | 32 thread(s) | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=256 K=4096 group=128 dtype=fp8a8 M=4` | 6.39 | - | 6.39 | 6.40 | 6 | 0.1 | 3296 | 1.02 MiB | | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=64` | 6.39 | - | 6.31 | 6.43 | 11 | 0.5 | 3296 | 2.21 MiB | restore 28% | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=256 K=4096 group=128 dtype=fp8a8 M=8` | 6.38 | - | 6.37 | 6.39 | 6 | 0.1 | 3295 | 1.04 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=256 K=4096 group=128 dtype=fp8a8 M=2` | 6.38 | - | 6.37 | 6.39 | 6 | 0.2 | 3296 | 1.01 MiB | | +| `gemm_nt_q` | `gemm_fp8a8_nt_m16` | libr4d | `N=256 K=4096 group=128 dtype=fp8a8 M=1` | 6.37 | - | 6.36 | 6.38 | 6 | 0.1 | 3292 | 1.00 MiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=4096 eps=1e-05 dtype=bf16 M=64` | 6.36 | - | 6.36 | 6.38 | 6 | 0.1 | 3432 | 1.01 MiB | | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=2048 group=128 dtype=bf16 M=1` | - | 6.34 | 6.24 | 7.00 | 16 | 0.8 | - | 6.06 KiB | 32 thread(s) | +| `layernorm` | `avx_layernorm` | libavx | `n=1152 eps=1e-06 dtype=bf16 M=4` | - | 6.33 | 6.00 | 6.53 | 20 | 1.9 | - | 22.50 KiB | 32 thread(s) | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=12288 group=128 dtype=bf16 M=64` | 6.31 | - | 6.31 | 6.33 | 6 | 0.2 | 3395 | 2.27 MiB | | +| `attn_dense` | `ref_attn_dense` | libref | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=2` | - | 6.30 | 6.19 | 6.75 | 20 | 3.1 | - | 1.13 KiB | 32 thread(s) | +| `moe_scatter` | `avx_moe_scatter` | libavx | `n_expert=304 top_k=9 expert_base=0 M=64` | - | 6.30 | 6.29 | 7.35 | 20 | 4.2 | - | 6.88 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=1024 group=128 dtype=bf16 M=4` | - | 6.28 | 6.21 | 6.85 | 20 | 3.7 | - | 12.12 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=8` | - | 6.27 | 6.24 | 6.32 | 11 | 0.6 | - | 16.09 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=64` | - | 6.20 | 6.09 | 6.59 | 40 | 2.3 | - | 32.25 KiB | 32 thread(s) | +| `silu_mul` | `silu_mul_bf16` | libr4d | `n=12288 dtype=bf16 M=64` | 6.17 | - | 5.72 | 6.22 | 19 | 0.6 | 3245 | 4.50 MiB | | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=4` | - | 6.17 | 6.12 | 6.75 | 19 | 0.6 | - | 112.02 KiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=64` | 6.16 | - | 6.14 | 6.22 | 6 | 0.7 | 3285 | 1.77 MiB | restore 28% | +| `quant_act_i8` | `quant_act_i8` | libr4d | `n=5120 group=128 dtype=bf16 M=32` | 6.16 | - | 6.14 | 6.16 | 6 | 0.1 | 3435 | 485.12 KiB | | +| `gdn_gated_rmsnorm` | `ref_gdn_gated_rmsnorm` | libref | `channels=128 eps=1e-06 act=silu M=2` | - | 6.14 | 6.06 | 6.55 | 14 | 0.9 | - | 2.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=12288 group=128 dtype=bf16 M=32` | 6.14 | - | 6.12 | 6.15 | 6 | 0.2 | 3386 | 1.14 MiB | | +| `ple_conv_bias` | `ple_conv_bias_bf16` | libr4d | `n=10240 width=4 dilation=1 dtype=bf16 M=4` | 6.14 | - | 6.11 | 6.16 | 6 | 0.4 | 3370 | 460.02 KiB | restore 28% | +| `sample_dry` | `sample_dry_f32` | libr4d | `n_vocab=131072 M=64` | 6.12 | - | 5.20 | 6.26 | 16 | 0.8 | 3430 | 32.03 MiB | restore 87%; restore-dominated (87% of the batch): an order of magnitude | +| `act_mul` | `avx_act_mul` | libavx | `n=2304 act=relu dtype=bf16 M=2` | - | 6.12 | 6.11 | 6.52 | 20 | 1.3 | - | 27.00 KiB | 32 thread(s) | +| `router_sigmoid_topk` | `ref_router_sigmoid_topk` | libref | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=1` | - | 6.12 | 6.04 | 7.42 | 20 | 4.9 | - | 1.95 KiB | 32 thread(s) | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=12288 group=128 dtype=bf16 M=16` | 6.11 | - | 6.10 | 6.13 | 6 | 0.2 | 3386 | 582.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=1` | 6.11 | - | 6.10 | 6.16 | 6 | 0.5 | 3289 | 30.00 KiB | | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=96 K=5120 dtype=bf16 M=130 wv=1 sk=0 mb=0 npw=1 nt=1` | 6.10 | - | 6.09 | 6.11 | 6 | 0.2 | 3285 | 2.23 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=12288 group=128 dtype=bf16 M=8` | 6.09 | - | 6.08 | 6.11 | 6 | 0.2 | 3386 | 291.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=1` | 6.09 | - | 6.07 | 6.12 | 11 | 0.3 | 3307 | 30.00 KiB | | +| `quant_act_i8` | `quant_act_i8` | libr4d | `n=5120 group=128 dtype=bf16 M=16` | 6.09 | - | 6.08 | 6.12 | 6 | 0.3 | 3439 | 242.56 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=12288 group=128 dtype=bf16 M=4` | 6.08 | - | 6.06 | 6.08 | 6 | 0.1 | 3386 | 145.50 KiB | | +| `quant_act_i8` | `quant_act_i8` | libr4d | `n=5120 group=128 dtype=bf16 M=8` | 6.08 | - | 6.06 | 6.10 | 6 | 0.3 | 3440 | 122.53 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=1536 act=relu dtype=bf16 M=512` | 6.07 | - | 6.04 | 6.10 | 6 | 0.5 | 3392 | 4.50 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=12288 group=128 dtype=bf16 M=2` | 6.07 | - | 6.06 | 6.09 | 6 | 0.2 | 3381 | 72.75 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=2` | 6.07 | - | 6.05 | 6.07 | 6 | 0.2 | 3292 | 50.00 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=12288 group=128 dtype=bf16 M=1` | 6.06 | - | 6.05 | 6.08 | 6 | 0.3 | 3379 | 36.38 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=8` | 6.05 | - | 6.04 | 6.06 | 6 | 0.2 | 3288 | 170.00 KiB | | +| `quant_act_i8` | `quant_act_i8` | libr4d | `n=5120 group=128 dtype=bf16 M=4` | 6.05 | - | 6.05 | 6.06 | 6 | 0.1 | 3439 | 62.52 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=2` | 6.04 | - | 6.04 | 6.06 | 6 | 0.2 | 3307 | 50.00 KiB | | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=4` | - | 6.04 | 6.01 | 6.08 | 11 | 0.6 | - | 8.02 KiB | 32 thread(s) | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=4` | 6.04 | - | 6.03 | 6.05 | 6 | 0.2 | 3288 | 90.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=32` | 6.02 | - | 6.00 | 6.03 | 6 | 0.2 | 3292 | 650.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=32` | 6.02 | - | 6.01 | 6.02 | 6 | 0.1 | 3294 | 650.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=8` | 6.01 | - | 6.00 | 6.03 | 6 | 0.2 | 3296 | 170.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=4` | 6.01 | - | 6.01 | 6.02 | 6 | 0.1 | 3306 | 90.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=16` | 6.00 | - | 5.99 | 6.01 | 6 | 0.1 | 3296 | 330.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=16` | 6.00 | - | 5.99 | 6.02 | 6 | 0.2 | 3292 | 330.00 KiB | | +| `quant_act_i8` | `quant_act_i8` | libr4d | `n=5120 group=128 dtype=bf16 M=2` | 5.98 | - | 5.96 | 6.00 | 6 | 0.3 | 3440 | 32.51 KiB | | +| `sample_penalties` | `sample_penalties_f32` | libr4d | `n_vocab=131072 M=16` | 5.94 | - | 4.38 | 7.51 | 20 | 13.6 | 3432 | 8.01 MiB | restore 80%; restore-dominated (80% of the batch): an order of magnitude | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-05 dtype=bf16 M=1` | 5.92 | - | 5.91 | 5.94 | 6 | 0.2 | 3440 | 30.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-05 dtype=bf16 M=2` | 5.88 | - | 5.87 | 5.90 | 6 | 0.2 | 3440 | 50.00 KiB | | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=32` | 5.87 | - | 5.86 | 5.89 | 6 | 0.3 | 3434 | 544.01 KiB | | +| `sample_penalties` | `sample_penalties_f32` | libr4d | `n_vocab=131072 M=4` | 5.87 | - | 5.81 | 5.98 | 14 | 1.0 | 3224 | 2.00 MiB | restore 38% | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=33` | 5.86 | - | 5.85 | 5.87 | 6 | 0.2 | 3433 | 576.02 KiB | | +| `moe_scatter` | `ref_moe_scatter` | libref | `n_expert=304 top_k=9 expert_base=0 M=32` | - | 5.86 | 5.85 | 6.33 | 16 | 0.4 | - | 4.63 KiB | 32 thread(s) | +| `sample_dry` | `sample_dry_f32` | libr4d | `n_vocab=248320 M=32` | 5.86 | - | 5.58 | 5.92 | 14 | 0.8 | 3390 | 30.33 MiB | restore 87%; restore-dominated (87% of the batch): an order of magnitude | +| `add` | `avx_add` | libavx | `n=5120 dtype=bf16 M=1` | - | 5.85 | 5.67 | 6.31 | 20 | 3.2 | - | 30.00 KiB | 32 thread(s) | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-05 dtype=bf16 M=4` | 5.85 | - | 5.85 | 5.86 | 6 | 0.1 | 3439 | 90.00 KiB | | +| `quant_act_i8` | `quant_act_i8` | libr4d | `n=5120 group=128 dtype=bf16 M=1` | 5.84 | - | 5.83 | 5.87 | 6 | 0.3 | 3436 | 17.50 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-05 dtype=bf16 M=32` | 5.84 | - | 5.83 | 5.85 | 6 | 0.1 | 3438 | 650.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-05 dtype=bf16 M=8` | 5.83 | - | 5.81 | 5.85 | 6 | 0.3 | 3440 | 170.00 KiB | | +| `sample_penalties` | `sample_penalties_f32` | libr4d | `n_vocab=248320 M=4` | 5.83 | - | 5.81 | 5.84 | 6 | 0.3 | 3185 | 3.79 MiB | restore 44% | +| `layernorm` | `layernorm_bf16` | libr4d | `n=1280 eps=1e-06 dtype=bf16 M=128` | 5.82 | - | 5.81 | 5.83 | 6 | 0.1 | 3433 | 645.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=5120 eps=1e-05 dtype=bf16 M=16` | 5.82 | - | 5.81 | 5.83 | 6 | 0.2 | 3440 | 330.00 KiB | | +| `sample_mask` | `sample_mask_f32` | libr4d | `n_vocab=131072 M=8` | 5.82 | - | 5.74 | 5.86 | 6 | 1.0 | 3376 | 4.13 MiB | restore 78%; restore-dominated (78% of the batch): an order of magnitude | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=1024 eps=1e-06 dtype=bf16 M=448` | 5.81 | - | 5.80 | 5.84 | 6 | 0.3 | 3403 | 1.75 MiB | | +| `quant_act_i8` | `avx_quant_act_i8` | libavx | `n=5120 group=128 dtype=bf16 M=1` | - | 5.79 | 5.60 | 6.02 | 20 | 2.5 | - | 17.50 KiB | 32 thread(s) | +| `layernorm` | `layernorm_bf16` | libr4d | `n=1280 eps=1e-06 dtype=bf16 M=1` | 5.78 | - | 5.77 | 5.80 | 6 | 0.3 | 3440 | 10.00 KiB | | +| `sample_penalties` | `sample_penalties_f32` | libr4d | `n_vocab=248320 M=2` | 5.77 | - | 5.77 | 5.79 | 6 | 0.2 | 3180 | 1.90 MiB | restore 39% | +| `layernorm` | `layernorm_bf16` | libr4d | `n=1152 eps=1e-06 dtype=bf16 M=128` | 5.76 | - | 5.76 | 5.77 | 6 | 0.1 | 3434 | 580.50 KiB | | +| `layernorm` | `layernorm_bf16` | libr4d | `n=1152 eps=1e-06 dtype=bf16 M=1` | 5.76 | - | 5.75 | 5.78 | 6 | 0.3 | 3440 | 9.00 KiB | | +| `layernorm` | `layernorm_bf16` | libr4d | `n=1280 eps=1e-06 dtype=bf16 M=64` | 5.75 | - | 5.74 | 5.75 | 6 | 0.1 | 3438 | 325.00 KiB | | +| `layernorm` | `layernorm_bf16` | libr4d | `n=1152 eps=1e-06 dtype=bf16 M=2` | 5.75 | - | 5.73 | 5.76 | 6 | 0.2 | 3439 | 13.50 KiB | | +| `layernorm` | `layernorm_bf16` | libr4d | `n=1280 eps=1e-06 dtype=bf16 M=2` | 5.75 | - | 5.74 | 5.76 | 6 | 0.2 | 3438 | 15.00 KiB | | +| `layernorm` | `layernorm_bf16` | libr4d | `n=1280 eps=1e-06 dtype=bf16 M=8` | 5.74 | - | 5.74 | 5.75 | 6 | 0.1 | 3438 | 45.00 KiB | | +| `layernorm` | `layernorm_bf16` | libr4d | `n=1152 eps=1e-06 dtype=bf16 M=64` | 5.73 | - | 5.72 | 5.74 | 6 | 0.2 | 3440 | 292.50 KiB | | +| `layernorm` | `layernorm_bf16` | libr4d | `n=1280 eps=1e-06 dtype=bf16 M=4` | 5.73 | - | 5.72 | 5.74 | 6 | 0.1 | 3439 | 25.00 KiB | | +| `layernorm` | `layernorm_bf16` | libr4d | `n=1280 eps=1e-06 dtype=bf16 M=32` | 5.73 | - | 5.72 | 5.76 | 6 | 0.4 | 3440 | 165.00 KiB | | +| `layernorm` | `layernorm_bf16` | libr4d | `n=1280 eps=1e-06 dtype=bf16 M=16` | 5.72 | - | 5.71 | 5.73 | 6 | 0.2 | 3440 | 85.00 KiB | | +| `layernorm` | `layernorm_bf16` | libr4d | `n=1152 eps=1e-06 dtype=bf16 M=4` | 5.72 | - | 5.72 | 5.72 | 6 | 0.1 | 3438 | 22.50 KiB | | +| `layernorm` | `layernorm_bf16` | libr4d | `n=1152 eps=1e-06 dtype=bf16 M=32` | 5.71 | - | 5.70 | 5.72 | 6 | 0.2 | 3440 | 148.50 KiB | | +| `sample_penalties` | `sample_penalties_f32` | libr4d | `n_vocab=248320 M=1` | 5.71 | - | 5.71 | 5.74 | 11 | 0.3 | 3382 | 970.34 KiB | restore 31% | +| `layernorm` | `layernorm_bf16` | libr4d | `n=1152 eps=1e-06 dtype=bf16 M=16` | 5.71 | - | 5.71 | 5.72 | 6 | 0.1 | 3438 | 76.50 KiB | | +| `gated_quant_fp8` | `gated_quant_fp8` | libr4d | `n=17408 group=128 dtype=bf16 act=silu M=16` | 5.70 | - | 5.67 | 5.72 | 6 | 0.4 | 3256 | 1.87 MiB | | +| `sample_penalties` | `sample_penalties_f32` | libr4d | `n_vocab=131072 M=1` | 5.70 | - | 5.67 | 5.70 | 6 | 0.3 | 3437 | 512.34 KiB | restore 29% | +| `layernorm` | `layernorm_bf16` | libr4d | `n=1152 eps=1e-06 dtype=bf16 M=8` | 5.69 | - | 5.69 | 5.71 | 6 | 0.2 | 3440 | 40.50 KiB | | +| `sample_penalties` | `sample_penalties_f32` | libr4d | `n_vocab=131072 M=2` | 5.68 | - | 5.67 | 5.69 | 6 | 0.2 | 3434 | 1.00 MiB | restore 30% | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=17` | 5.67 | - | 5.66 | 5.67 | 6 | 0.1 | 3424 | 304.01 KiB | | +| `act_mul` | `avx_act_mul` | libavx | `n=2048 act=relu dtype=bf16 M=2` | - | 5.64 | 5.63 | 6.10 | 16 | 0.2 | - | 24.00 KiB | 32 thread(s) | +| `sample_penalties` | `sample_penalties_f32` | libr4d | `n_vocab=248320 M=8` | 5.64 | - | 5.61 | 5.64 | 6 | 0.3 | 3370 | 7.58 MiB | restore 66% | +| `gated_quant_fp8` | `gated_quant_fp8` | libr4d | `n=17408 group=128 dtype=bf16 act=silu M=8` | 5.62 | - | 5.62 | 5.66 | 6 | 0.3 | 3264 | 956.25 KiB | | +| `gated_quant_fp8` | `gated_quant_fp8` | libr4d | `n=17408 group=128 dtype=bf16 act=silu M=4` | 5.61 | - | 5.60 | 5.63 | 6 | 0.3 | 3267 | 478.12 KiB | | +| `sample_penalties` | `sample_penalties_f32` | libr4d | `n_vocab=131072 M=8` | 5.60 | - | 5.54 | 5.65 | 11 | 0.9 | 3367 | 4.00 MiB | restore 79%; restore-dominated (79% of the batch): an order of magnitude | +| `gated_quant_fp8` | `gated_quant_fp8` | libr4d | `n=17408 group=128 dtype=bf16 act=silu M=2` | 5.60 | - | 5.58 | 5.61 | 6 | 0.2 | 3264 | 239.06 KiB | | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=1` | 5.59 | - | 5.59 | 5.61 | 6 | 0.2 | 3305 | 45.16 KiB | restore 30% | +| `act_mul` | `act_mul_bf16` | libr4d | `n=5376 act=relu dtype=bf16 M=128` | 5.59 | - | 5.56 | 5.61 | 6 | 0.4 | 3404 | 3.94 MiB | | +| `gated_quant_fp8` | `gated_quant_fp8` | libr4d | `n=17408 group=128 dtype=bf16 act=silu M=1` | 5.58 | - | 5.55 | 6.53 | 19 | 0.4 | 3259 | 119.53 KiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=2` | - | 5.58 | 5.52 | 5.80 | 20 | 2.0 | - | 2.50 KiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=32` | 5.57 | - | 5.56 | 5.59 | 6 | 0.3 | 3302 | 1.11 MiB | restore 30% | +| `gdn_conv_update` | `gdn_conv_update_w4_h128_bf16` | libr4d | `head_k=128 head_v=128 conv_width=4 q_len=8` | 5.56 | - | 5.54 | 5.58 | 6 | 0.3 | 3250 | 600.04 KiB | restore 31% | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=2` | 5.54 | - | 5.53 | 5.57 | 6 | 0.3 | 3306 | 80.31 KiB | restore 31% | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=16` | 5.53 | - | 5.52 | 5.55 | 6 | 0.3 | 3425 | 272.01 KiB | | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5376 group=128 dtype=bf16 M=1` | - | 5.52 | 5.40 | 6.02 | 20 | 2.0 | - | 15.91 KiB | 32 thread(s) | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=16` | 5.51 | - | 5.49 | 5.51 | 6 | 0.2 | 3313 | 572.50 KiB | restore 31% | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=4` | 5.51 | - | 5.49 | 5.53 | 6 | 0.3 | 3307 | 150.62 KiB | restore 31% | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=5120 eps=1e-06 group=128 dtype=bf16 wadd=1 M=8` | 5.50 | - | 5.44 | 5.54 | 6 | 0.9 | 3314 | 291.25 KiB | restore 31% | +| `attn_dense` | `attn_vit_h72_bf16` | libr4d | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=64` | 5.44 | - | 5.43 | 5.46 | 6 | 0.2 | 3440 | 36.01 KiB | | +| `add` | `add_bf16` | libr4d | `n=4096 dtype=bf16 M=128` | 5.44 | - | 5.41 | 5.45 | 6 | 0.3 | 3305 | 3.00 MiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=20480 act=relu dtype=bf16 M=32` | 5.43 | - | 5.41 | 5.45 | 6 | 0.4 | 3380 | 3.75 MiB | | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=9` | 5.43 | - | 5.42 | 5.44 | 6 | 0.2 | 3380 | 160.01 KiB | | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=10` | 5.42 | - | 5.39 | 5.42 | 6 | 0.3 | 3394 | 176.01 KiB | | +| `attn_dense` | `attn_vit_h72_bf16` | libr4d | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=32` | 5.42 | - | 5.42 | 5.42 | 6 | 0.1 | 3438 | 18.01 KiB | | +| `router_sigmoid_topk` | `avx_router_sigmoid_topk` | libavx | `n_expert=240 top_k=9 norm=1 route_scale=5 dtype=f32 M=1` | - | 5.42 | 5.35 | 5.86 | 20 | 1.7 | - | 1.95 KiB | 32 thread(s) | +| `moe_scatter` | `ref_moe_scatter` | libref | `n_expert=240 top_k=9 expert_base=0 M=32` | - | 5.40 | 5.32 | 6.24 | 20 | 6.0 | - | 4.13 KiB | 32 thread(s) | +| `attn_paged` | `attn_prefill_h128_gqa16_bf16kv` | libr4d | `head_dim=128 gqa=16 causal=1 window=0 n_head=32 block_size=16 max_seqs=8 max_ctx=262144 q_dtype=bf16 kv_dtype=bf16 q_len=11` | 5.40 | - | 5.39 | 5.42 | 6 | 0.2 | 3412 | 192.01 KiB | | +| `silu_mul` | `silu_mul_bf16` | libr4d | `n=17408 dtype=bf16 M=32` | 5.40 | - | 5.39 | 5.42 | 6 | 0.3 | 3246 | 3.19 MiB | | +| `attn_dense` | `attn_vit_h72_bf16` | libr4d | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=4` | 5.38 | - | 5.37 | 5.39 | 6 | 0.2 | 3441 | 2.26 KiB | | +| `attn_dense` | `attn_vit_h72_bf16` | libr4d | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=16` | 5.38 | - | 5.38 | 5.39 | 6 | 0.1 | 3440 | 9.01 KiB | | +| `attn_dense` | `attn_vit_h72_bf16` | libr4d | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=8` | 5.38 | - | 5.37 | 5.41 | 6 | 0.4 | 3440 | 4.51 KiB | | +| `lili_factor` | `lili_factor_bf16` | libr4d | `L=56 n=1024 dtype=bf16 M=448` | 5.38 | - | 5.36 | 5.38 | 6 | 0.2 | 3273 | 3.52 MiB | | +| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=131072 M=8` | 5.38 | - | 4.88 | 5.51 | 20 | 2.0 | 3366 | 4.00 MiB | restore 79%; restore-dominated (79% of the batch): an order of magnitude | +| `attn_dense` | `attn_vit_h72_bf16` | libr4d | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=1` | 5.37 | - | 5.36 | 5.38 | 6 | 0.2 | 3439 | 584 B | | +| `attn_dense` | `attn_vit_h72_bf16` | libr4d | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=2` | 5.37 | - | 5.36 | 5.40 | 6 | 0.3 | 3439 | 1.13 KiB | | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=448` | 5.36 | - | 5.35 | 5.38 | 6 | 0.3 | 3179 | 1.00 GiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=4` | - | 5.35 | 5.32 | 5.71 | 20 | 3.1 | - | 2.25 KiB | 32 thread(s) | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=1` | 5.35 | - | 5.32 | 5.35 | 11 | 0.2 | 3314 | 24.00 KiB | | +| `kv_store` | `ref_kv_store` | libref | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=1` | - | 5.34 | 5.16 | 5.50 | 20 | 2.3 | - | 49.00 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=2304 group=128 dtype=bf16 M=1` | - | 5.34 | 3.94 | 5.93 | 20 | 3.2 | - | 6.82 KiB | 32 thread(s) | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=2` | 5.32 | - | 5.31 | 5.33 | 6 | 0.2 | 3306 | 40.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=4` | 5.32 | - | 5.32 | 5.33 | 6 | 0.1 | 3308 | 72.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=32` | 5.31 | - | 5.29 | 5.32 | 6 | 0.2 | 3294 | 520.00 KiB | | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=16` | - | 5.30 | 5.22 | 5.65 | 20 | 2.8 | - | 16.50 KiB | 32 thread(s) | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=8` | 5.29 | - | 5.28 | 5.30 | 6 | 0.2 | 3309 | 136.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=16` | 5.28 | - | 5.27 | 5.29 | 6 | 0.2 | 3300 | 264.00 KiB | | +| `sample_penalties` | `sample_penalties_f32` | libr4d | `n_vocab=131072 M=32` | 5.27 | - | 5.17 | 5.27 | 6 | 1.0 | 3428 | 16.01 MiB | restore 81%; restore-dominated (81% of the batch): an order of magnitude | +| `act_mul` | `act_mul_bf16` | libr4d | `n=8192 act=silu dtype=bf16 M=64` | 5.24 | - | 5.22 | 5.26 | 6 | 0.4 | 3409 | 3.00 MiB | | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=5120 group=128 dtype=bf16 M=1` | - | 5.22 | 5.12 | 10.40 | 20 | 33.7 | - | 15.16 KiB | 32 thread(s) | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=4096 eps=1e-05 dtype=bf16 M=1` | 5.21 | - | 5.21 | 5.22 | 6 | 0.2 | 3435 | 24.00 KiB | | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=1536 group=128 dtype=bf16 M=512` | 5.21 | - | 5.15 | 5.54 | 20 | 1.6 | 3402 | 2.27 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=8192 group=128 dtype=bf16 M=128` | 5.20 | - | 5.19 | 5.22 | 6 | 0.3 | 3424 | 3.03 MiB | | +| `attn_dense` | `attn_vit_h72_bf16` | libr4d | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=128` | 5.20 | - | 5.19 | 5.24 | 6 | 0.5 | 3440 | 72.01 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=4096 eps=1e-05 dtype=bf16 M=2` | 5.19 | - | 5.18 | 5.20 | 6 | 0.2 | 3434 | 40.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=4096 eps=1e-05 dtype=bf16 M=4` | 5.17 | - | 5.16 | 5.17 | 6 | 0.1 | 3434 | 72.00 KiB | | +| `sample_penalties` | `sample_penalties_f32` | libr4d | `n_vocab=248320 M=16` | 5.16 | - | 5.10 | 5.22 | 11 | 0.7 | 3368 | 15.16 MiB | restore 79%; restore-dominated (79% of the batch): an order of magnitude | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=4096 eps=1e-05 dtype=bf16 M=8` | 5.16 | - | 5.14 | 5.17 | 6 | 0.2 | 3434 | 136.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=4096 eps=1e-05 dtype=bf16 M=16` | 5.15 | - | 5.14 | 5.18 | 6 | 0.4 | 3432 | 264.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=4096 eps=1e-05 dtype=bf16 M=32` | 5.15 | - | 5.15 | 5.16 | 6 | 0.1 | 3432 | 520.00 KiB | | +| `sample_temp` | `ref_sample_temp` | libref | `n_vocab=1024 M=1` | - | 5.13 | 5.10 | 5.40 | 20 | 1.7 | - | 4.09 KiB | 32 thread(s) | +| `attn_dense` | `attn_dense_h80_bf16` | libr4d | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=128` | 5.11 | - | 5.10 | 5.14 | 6 | 0.4 | 3440 | 80.01 KiB | | +| `lili_factor` | `lili_factor_bf16` | libr4d | `L=56 n=1024 dtype=bf16 M=256` | 5.06 | - | 5.05 | 5.07 | 6 | 0.2 | 3264 | 2.20 MiB | | +| `add` | `add_bf16` | libr4d | `n=5120 dtype=bf16 M=128` | 5.06 | - | 5.05 | 5.07 | 6 | 0.2 | 3242 | 3.75 MiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=2304 act=relu dtype=bf16 M=256` | 5.05 | - | 5.04 | 5.07 | 6 | 0.3 | 3425 | 3.38 MiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=128` | 5.04 | - | 5.01 | 5.07 | 6 | 0.5 | 3249 | 1.50 MiB | restore 35% | +| `moe_scatter` | `moe_scatter_i32` | libr4d | `n_expert=304 top_k=9 expert_base=0 M=64` | 5.03 | - | 5.01 | 5.04 | 6 | 0.3 | 3404 | 6.88 KiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=512` | 5.02 | - | 5.00 | 5.05 | 6 | 0.4 | 3224 | 258.00 KiB | restore 32% | +| `rope` | `rope_bf16` | libr4d | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=32` | 5.01 | - | 4.99 | 5.03 | 6 | 0.4 | 3303 | 216.25 KiB | restore 32% | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=96 K=5120 dtype=bf16 M=65 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.98 | - | 4.97 | 4.99 | 6 | 0.2 | 3304 | 1.58 MiB | | +| `sample_mask` | `sample_mask_f32` | libr4d | `n_vocab=248320 M=4` | 4.96 | - | 4.93 | 4.97 | 11 | 0.4 | 3256 | 3.91 MiB | restore 47% | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=128 K=4096 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.95 | - | 4.95 | 4.97 | 6 | 0.2 | 3358 | 1.27 MiB | | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=6144 group=128 dtype=bf16 M=1` | - | 4.95 | 4.88 | 5.21 | 20 | 2.1 | - | 18.19 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=128 K=4096 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.94 | - | 4.94 | 4.96 | 6 | 0.2 | 3350 | 1.52 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=128 K=4096 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.93 | - | 4.92 | 4.94 | 6 | 0.2 | 3370 | 1.13 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=128 K=4096 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.92 | - | 4.91 | 4.92 | 6 | 0.2 | 3360 | 1.14 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=96 K=5120 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.91 | - | 4.56 | 4.92 | 20 | 2.1 | 2848 | 970.19 KiB | | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=1536 group=128 dtype=bf16 M=2` | - | 4.91 | 4.80 | 5.37 | 20 | 4.9 | - | 9.09 KiB | 32 thread(s) | +| `attn_dense` | `attn_dense_h80_bf16` | libr4d | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=32` | 4.90 | - | 4.89 | 4.92 | 6 | 0.3 | 3440 | 20.01 KiB | | +| `ple_conv_bias` | `ple_conv_bias_bf16` | libr4d | `n=10240 width=4 dilation=1 dtype=bf16 M=2` | 4.90 | - | 4.89 | 4.92 | 6 | 0.3 | 3368 | 300.02 KiB | restore 33% | +| `moe_scatter` | `moe_scatter_i32` | libr4d | `n_expert=240 top_k=9 expert_base=0 M=64` | 4.89 | - | 4.88 | 4.89 | 6 | 0.1 | 3433 | 6.38 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=8192 group=128 dtype=bf16 M=64` | 4.87 | - | 4.85 | 4.88 | 6 | 0.2 | 3430 | 1.52 MiB | | +| `silu_mul` | `silu_mul_bf16` | libr4d | `n=12288 dtype=bf16 M=32` | 4.87 | - | 4.84 | 4.90 | 6 | 0.6 | 3256 | 2.25 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=96 K=5120 dtype=bf16 M=34 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.84 | - | 4.84 | 4.85 | 6 | 0.1 | 3322 | 1.28 MiB | | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=32` | 4.83 | - | 4.80 | 4.90 | 11 | 1.0 | 3390 | 908.00 KiB | restore 33% | +| `attn_dense` | `ref_attn_dense` | libref | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=2` | - | 4.83 | 4.69 | 5.99 | 20 | 5.5 | - | 1.26 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=96 K=5120 dtype=bf16 M=17 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.82 | - | 4.81 | 4.84 | 6 | 0.3 | 3328 | 1.11 MiB | | +| `silu` | `silu_bf16` | libr4d | `n=2048 dtype=bf16 M=256` | 4.81 | - | 4.81 | 4.83 | 6 | 0.2 | 3422 | 2.00 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=96 K=5120 dtype=bf16 M=16 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.81 | - | 4.81 | 4.84 | 6 | 0.3 | 3327 | 1.10 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m64` | libr4d | `N=96 K=5120 dtype=bf16 M=64 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.80 | - | 4.79 | 4.81 | 6 | 0.1 | 3312 | 1.57 MiB | | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=16` | 4.75 | - | 4.74 | 4.76 | 6 | 0.2 | 3399 | 458.00 KiB | restore 33% | +| `act_mul` | `act_mul_bf16` | libr4d | `n=2048 act=relu dtype=bf16 M=256` | 4.74 | - | 4.72 | 4.75 | 6 | 0.3 | 3422 | 3.00 MiB | | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=1` | 4.74 | - | 4.73 | 4.76 | 6 | 0.3 | 3388 | 36.12 KiB | restore 34% | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=2` | 4.73 | - | 4.71 | 4.74 | 6 | 0.3 | 3390 | 64.25 KiB | restore 34% | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=4` | 4.73 | - | 4.71 | 4.77 | 11 | 0.5 | 3392 | 120.50 KiB | restore 33% | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=8192 group=128 dtype=bf16 M=32` | 4.72 | - | 4.71 | 4.77 | 6 | 0.7 | 3433 | 776.00 KiB | | +| `add` | `avx_add` | libavx | `n=4096 dtype=bf16 M=1` | - | 4.72 | 4.68 | 5.02 | 20 | 2.8 | - | 24.00 KiB | 32 thread(s) | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=1024 eps=1e-05 dtype=bf16 M=512` | 4.72 | - | 4.71 | 4.74 | 6 | 0.3 | 3416 | 2.00 MiB | | +| `rmsnorm_quant_fp8` | `rmsnorm_quant_fp8` | libr4d | `n=4096 eps=1e-05 group=128 dtype=bf16 wadd=0 M=8` | 4.71 | - | 4.70 | 4.73 | 6 | 0.3 | 3402 | 233.00 KiB | restore 33% | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=96 K=5120 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.71 | - | 4.71 | 4.73 | 6 | 0.3 | 3328 | 1.02 MiB | | +| `cast` | `avx_cast` | libavx | `n=5120 from=bf16 to=bf16 M=2` | - | 4.71 | 4.46 | 11.14 | 20 | 35.4 | - | 40.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=8192 group=128 dtype=bf16 M=16` | 4.70 | - | 4.70 | 4.73 | 6 | 0.4 | 3434 | 388.00 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=8192 group=128 dtype=bf16 M=8` | 4.70 | - | 4.68 | 4.72 | 6 | 0.4 | 3434 | 194.00 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=8192 group=128 dtype=bf16 M=4` | 4.68 | - | 4.67 | 4.70 | 6 | 0.3 | 3432 | 97.00 KiB | | +| `act_mul` | `avx_act_mul` | libavx | `n=1536 act=relu dtype=bf16 M=1` | - | 4.68 | 4.42 | 5.82 | 20 | 7.7 | - | 9.00 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=4` | - | 4.67 | 4.63 | 4.77 | 14 | 0.7 | - | 2.02 KiB | 32 thread(s) | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=8192 group=128 dtype=bf16 M=2` | 4.67 | - | 4.67 | 4.69 | 6 | 0.3 | 3432 | 48.50 KiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=128 K=4096 dtype=bf16 M=8 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.67 | - | 4.67 | 4.69 | 6 | 0.2 | 3370 | 1.06 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=8192 group=128 dtype=bf16 M=1` | 4.66 | - | 4.65 | 4.69 | 6 | 0.4 | 3432 | 24.25 KiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=128 K=4096 dtype=bf16 M=1 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.65 | - | 4.64 | 4.78 | 14 | 0.1 | 3375 | 1.01 MiB | | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=2` | - | 4.64 | 4.49 | 5.49 | 20 | 4.7 | - | 40.00 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=128 K=4096 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.64 | - | 4.63 | 4.65 | 6 | 0.2 | 3374 | 1.02 MiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=128 K=4096 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.64 | - | 4.63 | 4.66 | 6 | 0.3 | 3372 | 1.03 MiB | | +| `attn_dense` | `attn_dense_h80_bf16` | libr4d | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=16` | 4.62 | - | 4.60 | 4.63 | 6 | 0.3 | 3438 | 10.01 KiB | | +| `rope_table` | `avx_rope_table` | libavx | `rot=64 theta=1e+07 scale=1 dtype=f32 M=8` | - | 4.61 | 4.30 | 6.33 | 20 | 19.6 | - | 2.03 KiB | 32 thread(s) | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=96 K=5120 dtype=bf16 M=4 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.61 | - | 4.61 | 4.63 | 6 | 0.2 | 3328 | 1000.75 KiB | | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=4096 eps=1e-05 dtype=bf16 M=2` | - | 4.61 | 4.40 | 4.99 | 20 | 3.3 | - | 40.00 KiB | 32 thread(s) | +| `attn_dense` | `attn_dense_h80_bf16` | libr4d | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=8` | 4.59 | - | 4.58 | 4.60 | 6 | 0.2 | 3438 | 5.01 KiB | | +| `gemm_nt` | `gemm_bf16_nt_m16` | libr4d | `N=96 K=5120 dtype=bf16 M=2 wv=1 sk=0 mb=0 npw=1 nt=1` | 4.58 | - | 4.57 | 4.84 | 16 | 0.1 | 3332 | 980.38 KiB | | +| `cast` | `cast_bf16_bf16` | libr4d | `n=4096 from=bf16 to=bf16 M=512` | 4.58 | - | 4.57 | 4.59 | 6 | 0.2 | 3202 | 8.00 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=6144 group=128 dtype=bf16 M=128` | 4.56 | - | 4.54 | 4.58 | 6 | 0.4 | 3290 | 2.27 MiB | | +| `gdn_conv_update` | `gdn_conv_update_w4_h128_bf16` | libr4d | `head_k=128 head_v=128 conv_width=4 q_len=4` | 4.55 | - | 4.52 | 4.55 | 6 | 0.4 | 3250 | 360.03 KiB | restore 35% | +| `moe_scatter` | `ref_moe_scatter` | libref | `n_expert=304 top_k=9 expert_base=0 M=16` | - | 4.52 | 4.49 | 4.98 | 16 | 0.6 | - | 3.50 KiB | 32 thread(s) | +| `attn_dense` | `attn_dense_h80_bf16` | libr4d | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=4` | 4.52 | - | 4.50 | 4.53 | 6 | 0.3 | 3442 | 2.51 KiB | | +| `silu` | `silu_bf16` | libr4d | `n=1024 dtype=bf16 M=448` | 4.48 | - | 4.47 | 4.48 | 6 | 0.2 | 3422 | 1.75 MiB | | +| `attn_dense` | `attn_dense_h80_bf16` | libr4d | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=2` | 4.47 | - | 4.46 | 4.48 | 6 | 0.2 | 3440 | 1.26 KiB | | +| `silu` | `avx_silu` | libavx | `n=2048 dtype=bf16 M=2` | - | 4.47 | 4.45 | 4.70 | 20 | 2.1 | - | 16.00 KiB | 32 thread(s) | +| `silu` | `avx_silu` | libavx | `n=1024 dtype=bf16 M=4` | - | 4.47 | 4.46 | 4.69 | 20 | 2.1 | - | 16.00 KiB | 32 thread(s) | +| `attn_dense` | `attn_dense_h80_bf16` | libr4d | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=1` | 4.47 | - | 4.46 | 4.47 | 6 | 0.2 | 3440 | 648 B | | +| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=512` | 4.42 | - | 4.42 | 4.43 | 6 | 0.1 | 3314 | 3.06 MiB | restore 36% | +| `moe_gather` | `moe_gather_bf16` | libr4d | `n=1024 top_k=9 dtype=bf16 act=none M=32` | 4.42 | - | 4.41 | 4.43 | 6 | 0.2 | 3432 | 705.75 KiB | | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=8` | - | 4.38 | 4.27 | 4.46 | 20 | 1.4 | - | 56.03 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=1` | - | 4.37 | 4.35 | 4.46 | 14 | 0.6 | - | 8.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5376 group=128 dtype=bf16 M=128` | 4.33 | - | 4.32 | 4.34 | 6 | 0.2 | 3426 | 1.99 MiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=1024 eps=1e-06 dtype=bf16 M=256` | 4.33 | - | 4.33 | 4.33 | 6 | 0.1 | 3399 | 1.00 MiB | | +| `add` | `add_bf16` | libr4d | `n=5120 dtype=bf16 M=64` | 4.31 | - | 4.30 | 4.31 | 6 | 0.1 | 3261 | 1.88 MiB | | +| `sample_penalties` | `sample_penalties_f32` | libr4d | `n_vocab=248320 M=32` | 4.30 | - | 4.07 | 4.35 | 11 | 0.9 | 3364 | 30.32 MiB | restore 90%; restore-dominated (90% of the batch): an order of magnitude | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=6144 group=128 dtype=bf16 M=64` | 4.29 | - | 4.28 | 4.31 | 6 | 0.3 | 3300 | 1.14 MiB | | +| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=248320 M=4` | 4.28 | - | 4.28 | 4.30 | 6 | 0.3 | 3232 | 3.79 MiB | restore 51% | +| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=512` | 4.26 | - | 4.26 | 4.30 | 6 | 0.5 | 3297 | 1.01 MiB | restore 37% | +| `ple_conv_bias` | `ple_conv_bias_bf16` | libr4d | `n=10240 width=4 dilation=1 dtype=bf16 M=1` | 4.25 | - | 4.24 | 4.29 | 6 | 0.6 | 3364 | 220.02 KiB | restore 36% | +| `silu_mul` | `silu_mul_bf16` | libr4d | `n=17408 dtype=bf16 M=16` | 4.25 | - | 4.23 | 4.27 | 6 | 0.4 | 3213 | 1.59 MiB | | +| `sample_penalties` | `sample_penalties_f32` | libr4d | `n_vocab=131072 M=64` | 4.24 | - | 4.02 | 4.33 | 20 | 1.8 | 3429 | 32.02 MiB | restore 91%; restore-dominated (91% of the batch): an order of magnitude | +| `moe_gather` | `moe_gather_bf16` | libr4d | `n=1024 top_k=9 dtype=bf16 act=none M=16` | 4.19 | - | 4.18 | 4.20 | 6 | 0.2 | 3432 | 352.88 KiB | | +| `rope` | `ref_rope` | libref | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=1` | - | 4.19 | 4.12 | 4.28 | 16 | 0.9 | - | 516 B | 32 thread(s) | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=6144 group=128 dtype=bf16 M=32` | 4.17 | - | 4.16 | 4.18 | 6 | 0.2 | 3302 | 582.00 KiB | | +| `rope` | `avx_rope` | libavx | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=1` | - | 4.17 | 3.78 | 4.46 | 20 | 2.8 | - | 6.76 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=4096 group=128 dtype=bf16 M=1` | - | 4.16 | 3.41 | 4.51 | 40 | 4.9 | - | 12.12 KiB | 32 thread(s) | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5120 group=128 dtype=bf16 M=128` | 4.16 | - | 4.15 | 4.16 | 6 | 0.2 | 3298 | 1.89 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=6144 group=128 dtype=bf16 M=8` | 4.16 | - | 4.14 | 4.16 | 6 | 0.2 | 3293 | 145.50 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=6144 group=128 dtype=bf16 M=16` | 4.15 | - | 4.15 | 4.17 | 6 | 0.2 | 3304 | 291.00 KiB | | +| `moe_gather` | `moe_gather_bf16` | libr4d | `n=1024 top_k=9 dtype=bf16 act=none M=8` | 4.15 | - | 4.14 | 4.18 | 6 | 0.4 | 3432 | 176.44 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=6144 group=128 dtype=bf16 M=4` | 4.15 | - | 4.14 | 4.16 | 6 | 0.2 | 3295 | 72.75 KiB | | +| `moe_gather` | `moe_gather_bf16` | libr4d | `n=1024 top_k=9 dtype=bf16 act=none M=4` | 4.14 | - | 4.14 | 4.15 | 6 | 0.1 | 3434 | 88.22 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=6144 group=128 dtype=bf16 M=2` | 4.14 | - | 4.13 | 4.16 | 6 | 0.3 | 3296 | 36.38 KiB | | +| `grid_embed` | `grid_embed_bf16` | libr4d | `n=1152 side=48 dtype=bf16 M=128` | 4.14 | - | 4.02 | 4.18 | 14 | 0.9 | 3364 | 5.35 MiB | restore 36% | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=6144 group=128 dtype=bf16 M=1` | 4.14 | - | 4.13 | 4.21 | 6 | 1.0 | 3293 | 18.19 KiB | | +| `moe_gather` | `moe_gather_bf16` | libr4d | `n=1024 top_k=9 dtype=bf16 act=none M=2` | 4.13 | - | 4.12 | 4.14 | 6 | 0.2 | 3434 | 44.11 KiB | | +| `moe_scatter` | `ref_moe_scatter` | libref | `n_expert=240 top_k=9 expert_base=0 M=16` | - | 4.13 | 3.97 | 4.86 | 20 | 4.8 | - | 3.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5376 group=128 dtype=bf16 M=64` | 4.12 | - | 4.11 | 4.12 | 6 | 0.1 | 3428 | 1018.50 KiB | | +| `moe_gather` | `moe_gather_bf16` | libr4d | `n=1024 top_k=9 dtype=bf16 act=none M=1` | 4.11 | - | 4.10 | 4.13 | 6 | 0.3 | 3434 | 22.05 KiB | | +| `add` | `add_bf16` | libr4d | `n=5120 dtype=bf16 M=32` | 4.11 | - | 4.10 | 4.11 | 6 | 0.1 | 3262 | 960.00 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=1536 act=relu dtype=bf16 M=256` | 4.10 | - | 4.10 | 4.10 | 6 | 0.1 | 3394 | 2.25 MiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=1024 eps=1e-06 dtype=bf16 M=128` | 4.10 | - | 4.09 | 4.10 | 6 | 0.1 | 3404 | 514.00 KiB | | +| `add` | `add_bf16` | libr4d | `n=5120 dtype=bf16 M=16` | 4.09 | - | 4.08 | 4.13 | 6 | 0.5 | 3256 | 480.00 KiB | | +| `gdn_gated_rmsnorm` | `avx_gdn_gated_rmsnorm` | libavx | `channels=128 eps=1e-06 act=silu M=16` | - | 4.08 | 4.00 | 4.70 | 20 | 5.9 | - | 12.50 KiB | 32 thread(s) | +| `add` | `add_bf16` | libr4d | `n=5120 dtype=bf16 M=8` | 4.08 | - | 4.07 | 4.09 | 6 | 0.2 | 3250 | 240.00 KiB | | +| `sample_ngram_ban` | `ref_sample_ngram_ban` | libref | `n_vocab=131072 M=8` | - | 4.08 | 3.87 | 4.77 | 20 | 3.7 | - | 4.13 MiB | 32 thread(s) | +| `add` | `add_bf16` | libr4d | `n=5120 dtype=bf16 M=4` | 4.07 | - | 4.06 | 4.09 | 6 | 0.3 | 3256 | 120.00 KiB | | +| `add` | `add_bf16` | libr4d | `n=5120 dtype=bf16 M=2` | 4.07 | - | 4.06 | 4.08 | 6 | 0.3 | 3256 | 60.00 KiB | | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=1024 eps=1e-05 dtype=bf16 M=8` | - | 4.06 | 4.00 | 4.38 | 20 | 2.5 | - | 32.00 KiB | 32 thread(s) | +| `add` | `add_bf16` | libr4d | `n=5120 dtype=bf16 M=1` | 4.05 | - | 4.05 | 4.08 | 6 | 0.4 | 3252 | 30.00 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5376 group=128 dtype=bf16 M=32` | 4.04 | - | 4.03 | 4.04 | 6 | 0.1 | 3434 | 509.25 KiB | | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=2` | - | 4.04 | 4.00 | 4.06 | 11 | 0.7 | - | 4.01 KiB | 32 thread(s) | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=16` | 4.03 | - | 3.58 | 4.04 | 20 | 2.2 | 3301 | 128.06 KiB | restore 37% | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5376 group=128 dtype=bf16 M=8` | 4.02 | - | 4.01 | 4.02 | 6 | 0.2 | 3424 | 127.31 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5376 group=128 dtype=bf16 M=16` | 4.02 | - | 4.02 | 4.02 | 6 | 0.0 | 3435 | 254.62 KiB | | +| `rope_table` | `ref_rope_table` | libref | `rot=64 theta=1e+07 scale=1 dtype=f32 M=2` | - | 4.01 | 3.67 | 4.29 | 20 | 4.4 | - | 520 B | 32 thread(s) | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5376 group=128 dtype=bf16 M=4` | 4.01 | - | 4.00 | 4.02 | 6 | 0.3 | 3422 | 63.66 KiB | | +| `gdn_conv_update` | `gdn_conv_update_w4_h128_bf16` | libr4d | `head_k=128 head_v=128 conv_width=4 q_len=2` | 4.01 | - | 3.98 | 4.03 | 6 | 0.6 | 3256 | 240.02 KiB | restore 38% | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5376 group=128 dtype=bf16 M=2` | 4.00 | - | 3.99 | 4.01 | 6 | 0.2 | 3424 | 31.83 KiB | | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=1` | - | 4.00 | 3.98 | 4.24 | 16 | 0.5 | - | 8.00 KiB | 32 thread(s) | +| `sample_minp` | `sample_minp_f32` | libr4d | `n_cand=1024 M=64` | 3.99 | - | 3.96 | 4.10 | 20 | 0.9 | 3437 | 518.00 KiB | restore 54% | +| `moe_scatter` | `avx_moe_scatter` | libavx | `n_expert=304 top_k=9 expert_base=0 M=32` | - | 3.99 | 3.98 | 4.37 | 20 | 3.5 | - | 4.63 KiB | 32 thread(s) | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5376 group=128 dtype=bf16 M=1` | 3.99 | - | 3.98 | 4.02 | 6 | 0.4 | 3426 | 15.91 KiB | | +| `layernorm` | `avx_layernorm` | libavx | `n=1280 eps=1e-06 dtype=bf16 M=4` | - | 3.97 | 3.86 | 4.27 | 20 | 2.7 | - | 25.00 KiB | 32 thread(s) | +| `sample_minp` | `sample_minp_f32` | libr4d | `n_cand=1024 M=32` | 3.94 | - | 3.91 | 3.98 | 12 | 0.8 | 3440 | 259.00 KiB | restore 55% | +| `sample_minp` | `sample_minp_f32` | libr4d | `n_cand=1024 M=16` | 3.94 | - | 3.91 | 4.06 | 22 | 0.6 | 3440 | 129.50 KiB | restore 55% | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5120 group=128 dtype=bf16 M=64` | 3.93 | - | 3.92 | 3.94 | 6 | 0.2 | 3292 | 970.00 KiB | | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=1024 eps=1e-06 dtype=bf16 M=8` | - | 3.92 | 3.87 | 4.08 | 20 | 2.3 | - | 34.00 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-05 dtype=bf16 M=1` | - | 3.91 | 3.76 | 4.31 | 20 | 4.6 | - | 30.00 KiB | 32 thread(s) | +| `sample_minp` | `sample_minp_f32` | libr4d | `n_cand=1024 M=8` | 3.91 | - | 3.89 | 4.05 | 22 | 0.3 | 3439 | 64.75 KiB | restore 55% | +| `sample_minp` | `sample_minp_f32` | libr4d | `n_cand=1024 M=4` | 3.90 | - | 3.86 | 3.90 | 12 | 0.5 | 3438 | 32.38 KiB | restore 55% | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=0 dtype=bf16 M=1` | - | 3.89 | 3.55 | 4.17 | 20 | 5.0 | - | 30.00 KiB | 32 thread(s) | +| `act_mul` | `act_mul_bf16` | libr4d | `n=5376 act=relu dtype=bf16 M=64` | 3.88 | - | 3.88 | 3.89 | 6 | 0.0 | 3407 | 1.97 MiB | | +| `sample_minp` | `sample_minp_f32` | libr4d | `n_cand=1024 M=2` | 3.88 | - | 3.85 | 4.02 | 22 | 0.4 | 3440 | 16.19 KiB | restore 55% | +| `moe_scatter` | `ref_moe_scatter` | libref | `n_expert=304 top_k=9 expert_base=0 M=8` | - | 3.87 | 3.85 | 4.18 | 20 | 3.7 | - | 2.94 KiB | 32 thread(s) | +| `attn_dense` | `attn_dense_h80_bf16` | libr4d | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=64` | 3.85 | - | 3.85 | 3.86 | 6 | 0.1 | 3440 | 40.01 KiB | | +| `sample_minp` | `sample_minp_f32` | libr4d | `n_cand=1024 M=1` | 3.85 | - | 3.79 | 3.97 | 22 | 0.3 | 3440 | 8.09 KiB | restore 55% | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=5120 eps=1e-06 wadd=1 dtype=bf16 M=1` | - | 3.84 | 3.64 | 4.03 | 20 | 2.9 | - | 30.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5120 group=128 dtype=bf16 M=32` | 3.82 | - | 3.81 | 3.83 | 6 | 0.2 | 3293 | 485.00 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5120 group=128 dtype=bf16 M=16` | 3.81 | - | 3.81 | 3.82 | 6 | 0.2 | 3295 | 242.50 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5120 group=128 dtype=bf16 M=8` | 3.81 | - | 3.80 | 3.82 | 6 | 0.3 | 3294 | 121.25 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5120 group=128 dtype=bf16 M=4` | 3.80 | - | 3.80 | 3.81 | 6 | 0.2 | 3292 | 60.62 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5120 group=128 dtype=bf16 M=2` | 3.80 | - | 3.80 | 3.81 | 6 | 0.2 | 3289 | 30.31 KiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=64` | 3.80 | - | 3.77 | 3.83 | 6 | 0.8 | 3256 | 768.75 KiB | restore 40% | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=5120 group=128 dtype=bf16 M=1` | 3.79 | - | 3.79 | 3.83 | 6 | 0.6 | 3290 | 15.16 KiB | | +| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=8` | - | 3.79 | 3.71 | 3.95 | 20 | 2.6 | - | 4.51 KiB | 32 thread(s) | +| `gdn_conv_update` | `gdn_conv_update_w4_h128_bf16` | libr4d | `head_k=128 head_v=128 conv_width=4 q_len=1` | 3.78 | - | 3.77 | 3.79 | 6 | 0.3 | 3254 | 180.02 KiB | restore 39% | +| `rope` | `ref_rope` | libref | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=1` | - | 3.77 | 3.75 | 3.89 | 14 | 0.7 | - | 2.01 KiB | 32 thread(s) | +| `act_mul` | `act_mul_bf16` | libr4d | `n=20480 act=relu dtype=bf16 M=16` | 3.77 | - | 3.76 | 3.77 | 6 | 0.2 | 3392 | 1.88 MiB | | +| `add` | `add_bf16` | libr4d | `n=4096 dtype=bf16 M=64` | 3.76 | - | 3.76 | 3.77 | 6 | 0.2 | 3400 | 1.50 MiB | | +| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=1` | - | 3.74 | 3.68 | 4.00 | 20 | 3.1 | - | 12.01 KiB | 32 thread(s) | +| `grid_embed_cpe` | `grid_embed_cpe_bf16` | libr4d | `n=1280 side=128 n_prefix=10 dtype=bf16 M=128` | 3.71 | - | 3.68 | 3.73 | 6 | 0.6 | 3431 | 40.34 MiB | restore 39% | +| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=4` | - | 3.71 | 3.67 | 3.88 | 20 | 1.8 | - | 8.05 KiB | 32 thread(s) | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=512` | 3.70 | - | 3.70 | 3.71 | 11 | 0.2 | 3245 | 512.50 KiB | | +| `moe_scatter` | `moe_scatter_i32` | libr4d | `n_expert=304 top_k=9 expert_base=0 M=32` | 3.70 | - | 3.69 | 3.71 | 6 | 0.3 | 3402 | 4.63 KiB | | +| `moe_scatter` | `avx_moe_scatter` | libavx | `n_expert=240 top_k=9 expert_base=0 M=32` | - | 3.70 | 3.69 | 4.03 | 20 | 2.1 | - | 4.13 KiB | 32 thread(s) | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=64` | 3.70 | - | 3.42 | 3.90 | 20 | 3.4 | 3316 | 128.25 KiB | restore 39% | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=4096 group=128 dtype=bf16 M=128` | 3.69 | - | 3.69 | 3.70 | 6 | 0.1 | 3372 | 1.52 MiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=8192 act=silu dtype=bf16 M=32` | 3.69 | - | 3.69 | 3.71 | 6 | 0.3 | 3419 | 1.50 MiB | | +| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=512` | 3.67 | - | 3.67 | 3.69 | 6 | 0.3 | 3236 | 3.06 MiB | restore 41% | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=4096 dtype=bf16 M=128` | 3.66 | - | 3.53 | 3.73 | 20 | 1.4 | 3350 | 5.00 MiB | restore 85%; restore-dominated (85% of the batch): an order of magnitude | +| `rope_table` | `avx_rope_table` | libavx | `rot=64 theta=1e+07 scale=1 dtype=f32 M=4` | - | 3.63 | 2.55 | 3.85 | 20 | 2.9 | - | 1.02 KiB | 32 thread(s) | +| `act_mul` | `act_mul_bf16` | libr4d | `n=2304 act=relu dtype=bf16 M=128` | 3.62 | - | 3.61 | 3.63 | 6 | 0.2 | 3428 | 1.69 MiB | | +| `add` | `add_bf16` | libr4d | `n=4096 dtype=bf16 M=32` | 3.61 | - | 3.60 | 3.61 | 6 | 0.2 | 3412 | 768.00 KiB | | +| `add` | `add_bf16` | libr4d | `n=4096 dtype=bf16 M=16` | 3.59 | - | 3.58 | 3.60 | 6 | 0.2 | 3410 | 384.00 KiB | | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=2304 group=128 dtype=bf16 M=128` | 3.58 | - | 3.57 | 3.60 | 6 | 0.4 | 3424 | 873.00 KiB | | +| `add` | `add_bf16` | libr4d | `n=4096 dtype=bf16 M=8` | 3.58 | - | 3.57 | 3.59 | 6 | 0.3 | 3415 | 192.00 KiB | | +| `add` | `add_bf16` | libr4d | `n=4096 dtype=bf16 M=4` | 3.57 | - | 3.57 | 3.58 | 6 | 0.1 | 3414 | 96.00 KiB | | +| `gdn_gated_rmsnorm` | `ref_gdn_gated_rmsnorm` | libref | `channels=128 eps=1e-06 act=silu M=1` | - | 3.55 | 3.47 | 3.67 | 20 | 2.0 | - | 1.25 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=1` | - | 3.55 | 3.50 | 3.83 | 20 | 2.0 | - | 2.00 KiB | 32 thread(s) | +| `add` | `add_bf16` | libr4d | `n=4096 dtype=bf16 M=2` | 3.55 | - | 3.54 | 3.56 | 6 | 0.2 | 3426 | 48.00 KiB | | +| `add` | `add_bf16` | libr4d | `n=4096 dtype=bf16 M=1` | 3.54 | - | 3.54 | 3.55 | 11 | 0.2 | 3424 | 24.00 KiB | | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=1024 group=128 dtype=bf16 M=4` | - | 3.54 | 3.49 | 3.80 | 16 | 0.7 | - | 12.12 KiB | 32 thread(s) | +| `moe_scatter` | `ref_moe_scatter` | libref | `n_expert=304 top_k=9 expert_base=0 M=4` | - | 3.54 | 3.53 | 3.78 | 16 | 0.3 | - | 2.66 KiB | 32 thread(s) | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=128` | 3.54 | - | 3.53 | 3.55 | 6 | 0.2 | 3212 | 1.00 GiB | | +| `sample_ngram_ban` | `sample_ngram_ban_f32` | libr4d | `n_vocab=131072 M=4` | 3.51 | - | 3.51 | 3.52 | 6 | 0.2 | 3210 | 2.06 MiB | restore 50% | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=4096 group=128 dtype=bf16 M=64` | 3.51 | - | 3.45 | 3.52 | 12 | 0.2 | 3443 | 776.00 KiB | | +| `silu` | `silu_bf16` | libr4d | `n=2048 dtype=bf16 M=128` | 3.49 | - | 3.49 | 3.50 | 6 | 0.1 | 3426 | 1.00 MiB | | +| `silu` | `silu_bf16` | libr4d | `n=1024 dtype=bf16 M=256` | 3.49 | - | 3.48 | 3.50 | 6 | 0.2 | 3429 | 1.00 MiB | | +| `moe_scatter` | `ref_moe_scatter` | libref | `n_expert=240 top_k=9 expert_base=0 M=8` | - | 3.49 | 3.32 | 3.92 | 20 | 6.6 | - | 2.44 KiB | 32 thread(s) | +| `sample_mask` | `sample_mask_f32` | libr4d | `n_vocab=131072 M=4` | 3.46 | - | 3.40 | 3.54 | 20 | 1.4 | 3242 | 2.06 MiB | restore 50% | +| `grid_embed` | `grid_embed_bf16` | libr4d | `n=1152 side=48 dtype=bf16 M=64` | 3.46 | - | 3.40 | 3.49 | 11 | 0.7 | 3437 | 5.20 MiB | restore 41% | +| `grid_embed_cpe` | `grid_embed_cpe_bf16` | libr4d | `n=1280 side=128 n_prefix=10 dtype=bf16 M=64` | 3.45 | - | 3.44 | 3.46 | 6 | 0.4 | 3434 | 40.18 MiB | restore 41% | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=1024 eps=1e-06 dtype=bf16 M=64` | 3.44 | - | 3.44 | 3.45 | 11 | 0.3 | 3403 | 258.00 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=2048 act=relu dtype=bf16 M=128` | 3.43 | - | 3.40 | 3.47 | 6 | 1.0 | 3428 | 1.50 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=4096 group=128 dtype=bf16 M=32` | 3.43 | - | 3.36 | 3.44 | 12 | 0.4 | 3446 | 388.00 KiB | | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=2` | - | 3.42 | 3.31 | 3.64 | 20 | 2.3 | - | 104.01 KiB | 32 thread(s) | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=4096 group=128 dtype=bf16 M=8` | 3.41 | - | 3.34 | 3.43 | 12 | 0.3 | 3448 | 97.00 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=4096 group=128 dtype=bf16 M=16` | 3.41 | - | 3.36 | 3.42 | 12 | 0.2 | 3449 | 194.00 KiB | | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=32` | - | 3.40 | 3.27 | 3.70 | 40 | 4.3 | - | 16.25 KiB | 32 thread(s) | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=4096 group=128 dtype=bf16 M=4` | 3.40 | - | 3.34 | 3.42 | 12 | 0.3 | 3448 | 48.50 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=4096 group=128 dtype=bf16 M=2` | 3.40 | - | 3.34 | 3.41 | 12 | 0.3 | 3448 | 24.25 KiB | | +| `grid_embed` | `grid_embed_bf16` | libr4d | `n=1152 side=48 dtype=bf16 M=32` | 3.40 | - | 3.38 | 3.45 | 6 | 1.0 | 3438 | 5.13 MiB | restore 41% | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=1024 eps=1e-05 dtype=bf16 M=256` | 3.40 | - | 3.39 | 3.41 | 6 | 0.3 | 3421 | 1.00 MiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=4096 group=128 dtype=bf16 M=1` | 3.39 | - | 3.33 | 3.41 | 12 | 0.4 | 3449 | 12.12 KiB | | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=2` | - | 3.39 | 3.37 | 3.64 | 16 | 0.7 | - | 1.01 KiB | 32 thread(s) | +| `moe_scatter` | `moe_scatter_i32` | libr4d | `n_expert=240 top_k=9 expert_base=0 M=32` | 3.38 | - | 3.37 | 3.39 | 6 | 0.3 | 3435 | 4.13 KiB | | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=1024 group=128 dtype=bf16 M=2` | - | 3.38 | 3.31 | 3.75 | 20 | 4.9 | - | 6.06 KiB | 32 thread(s) | +| `moe_scatter` | `ref_moe_scatter` | libref | `n_expert=304 top_k=9 expert_base=0 M=2` | - | 3.37 | 3.34 | 4.29 | 20 | 4.3 | - | 2.52 KiB | 32 thread(s) | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=512` | 3.36 | - | 3.33 | 3.36 | 12 | 0.1 | 3388 | 256.25 KiB | | +| `kv_store` | `kv_store_bf16` | libr4d | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=512` | 3.34 | - | 3.32 | 3.35 | 6 | 0.5 | 3360 | 1.03 MiB | restore 42% | +| `moe_scatter` | `ref_moe_scatter` | libref | `n_expert=304 top_k=9 expert_base=0 M=1` | - | 3.32 | 3.30 | 3.62 | 20 | 1.3 | - | 2.45 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=1` | - | 3.30 | 3.02 | 3.57 | 20 | 7.8 | - | 1.50 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=1536 group=128 dtype=bf16 M=1` | - | 3.29 | 3.21 | 3.87 | 20 | 4.0 | - | 4.55 KiB | 32 thread(s) | +| `rope` | `rope_bf16` | libr4d | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=16` | 3.27 | - | 3.27 | 3.27 | 6 | 0.1 | 3434 | 108.12 KiB | restore 42% | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=2048 group=128 dtype=bf16 M=128` | 3.25 | - | 3.24 | 3.26 | 6 | 0.3 | 3425 | 776.00 KiB | | +| `act_mul` | `avx_act_mul` | libavx | `n=2304 act=relu dtype=bf16 M=1` | - | 3.24 | 3.23 | 3.54 | 19 | 0.3 | - | 13.50 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=2304 group=128 dtype=bf16 M=64` | 3.24 | - | 3.23 | 3.25 | 6 | 0.2 | 3429 | 436.50 KiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=16` | 3.22 | - | 3.20 | 3.33 | 16 | 0.8 | 3348 | 128.06 KiB | restore 43% | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=1024 eps=1e-06 dtype=bf16 M=32` | 3.21 | - | 3.21 | 3.22 | 6 | 0.2 | 3400 | 130.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=1024 eps=1e-06 dtype=bf16 M=1` | 3.21 | - | 3.20 | 3.23 | 6 | 0.4 | 3388 | 6.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=1024 eps=1e-06 dtype=bf16 M=16` | 3.21 | - | 3.21 | 3.22 | 6 | 0.2 | 3399 | 66.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=1024 eps=1e-06 dtype=bf16 M=2` | 3.21 | - | 3.20 | 3.22 | 6 | 0.4 | 3390 | 10.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=1024 eps=1e-06 dtype=bf16 M=4` | 3.21 | - | 3.19 | 3.25 | 11 | 0.8 | 3390 | 18.00 KiB | | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=64` | 3.20 | - | 3.19 | 3.21 | 6 | 0.2 | 3026 | 3.13 MiB | restore 55% | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=1024 eps=1e-06 dtype=bf16 M=8` | 3.20 | - | 3.19 | 3.20 | 6 | 0.1 | 3401 | 34.00 KiB | | +| `sample_ngram_ban` | `sample_ngram_ban_f32` | libr4d | `n_vocab=131072 M=8` | 3.19 | - | 3.04 | 3.29 | 20 | 2.3 | 3365 | 4.13 MiB | restore 87%; restore-dominated (87% of the batch): an order of magnitude | +| `grid_embed` | `grid_embed_bf16` | libr4d | `n=1152 side=48 dtype=bf16 M=16` | 3.19 | - | 3.18 | 3.21 | 11 | 0.4 | 3440 | 5.10 MiB | restore 43% | +| `cast` | `cast_bf16_bf16` | libr4d | `n=5120 from=bf16 to=bf16 M=256` | 3.19 | - | 3.18 | 3.54 | 20 | 5.4 | 3249 | 5.00 MiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=1024 eps=1e-05 dtype=bf16 M=128` | 3.19 | - | 3.18 | 3.20 | 6 | 0.2 | 3430 | 512.00 KiB | | +| `grid_embed_cpe` | `grid_embed_cpe_bf16` | libr4d | `n=1280 side=128 n_prefix=10 dtype=bf16 M=32` | 3.15 | - | 3.15 | 3.19 | 6 | 0.7 | 3439 | 40.10 MiB | restore 43% | +| `grid_embed_cpe` | `grid_embed_cpe_bf16` | libr4d | `n=1280 side=128 n_prefix=10 dtype=bf16 M=16` | 3.14 | - | 3.13 | 3.16 | 6 | 0.4 | 3438 | 40.06 MiB | restore 43% | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=32` | 3.14 | - | 3.12 | 3.15 | 6 | 0.4 | 3280 | 1.56 MiB | restore 46% | +| `grid_embed_cpe` | `grid_embed_cpe_bf16` | libr4d | `n=1280 side=128 n_prefix=10 dtype=bf16 M=8` | 3.14 | - | 3.13 | 3.16 | 6 | 0.5 | 3438 | 40.04 MiB | restore 43% | +| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=32` | 3.14 | - | 3.12 | 3.16 | 6 | 0.7 | 3262 | 384.38 KiB | restore 44% | +| `lili_factor` | `lili_factor_bf16` | libr4d | `L=56 n=1024 dtype=bf16 M=128` | 3.14 | - | 3.14 | 3.18 | 11 | 0.7 | 3425 | 1.32 MiB | | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=8` | 3.13 | - | 3.13 | 3.14 | 6 | 0.2 | 3276 | 400.03 KiB | restore 44% | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=16` | 3.13 | - | 3.11 | 3.14 | 6 | 0.4 | 3274 | 800.06 KiB | restore 44% | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=4` | 3.13 | - | 3.12 | 3.13 | 6 | 0.3 | 3275 | 200.02 KiB | restore 44% | +| `grid_embed` | `grid_embed_bf16` | libr4d | `n=1152 side=48 dtype=bf16 M=8` | 3.12 | - | 3.11 | 3.12 | 11 | 0.1 | 3440 | 5.08 MiB | restore 43% | +| `grid_embed` | `grid_embed_bf16` | libr4d | `n=1152 side=48 dtype=bf16 M=2` | 3.12 | - | 3.07 | 3.12 | 11 | 0.4 | 3440 | 5.07 MiB | restore 43% | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=2` | 3.11 | - | 3.11 | 3.12 | 6 | 0.2 | 3275 | 100.01 KiB | restore 44% | +| `grid_embed` | `grid_embed_bf16` | libr4d | `n=1152 side=48 dtype=bf16 M=4` | 3.11 | - | 3.09 | 3.12 | 11 | 0.3 | 3441 | 5.07 MiB | restore 43% | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=2304 group=128 dtype=bf16 M=32` | 3.11 | - | 3.10 | 3.11 | 6 | 0.2 | 3430 | 218.25 KiB | | +| `grid_embed` | `grid_embed_bf16` | libr4d | `n=1152 side=48 dtype=bf16 M=1` | 3.10 | - | 3.07 | 3.11 | 11 | 0.2 | 3430 | 5.06 MiB | restore 43% | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=2304 group=128 dtype=bf16 M=16` | 3.10 | - | 3.09 | 3.11 | 6 | 0.3 | 3434 | 109.12 KiB | | +| `sample_ngram_ban` | `sample_ngram_ban_f32` | libr4d | `n_vocab=131072 M=1` | 3.10 | - | 3.09 | 3.10 | 6 | 0.2 | 3438 | 528.35 KiB | restore 43% | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=1` | 3.09 | - | 3.08 | 3.11 | 6 | 0.4 | 3276 | 50.00 KiB | restore 44% | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=2304 group=128 dtype=bf16 M=8` | 3.09 | - | 3.08 | 3.09 | 6 | 0.2 | 3433 | 54.56 KiB | | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=2304 group=128 dtype=bf16 M=4` | 3.09 | - | 3.08 | 3.09 | 6 | 0.2 | 3433 | 27.28 KiB | | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=2304 group=128 dtype=bf16 M=2` | 3.08 | - | 3.08 | 3.10 | 6 | 0.3 | 3433 | 13.64 KiB | | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=2304 group=128 dtype=bf16 M=1` | 3.08 | - | 3.07 | 3.10 | 6 | 0.5 | 3434 | 6.82 KiB | | +| `grid_embed_cpe` | `grid_embed_cpe_bf16` | libr4d | `n=1280 side=128 n_prefix=10 dtype=bf16 M=4` | 3.07 | - | 3.06 | 3.08 | 6 | 0.3 | 3439 | 40.03 MiB | restore 44% | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=1536 group=128 dtype=bf16 M=128` | 3.07 | - | 3.07 | 3.09 | 6 | 0.3 | 3414 | 582.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=256` | 3.07 | - | 3.06 | 3.08 | 6 | 0.3 | 3246 | 256.50 KiB | | +| `grid_embed_cpe` | `grid_embed_cpe_bf16` | libr4d | `n=1280 side=128 n_prefix=10 dtype=bf16 M=1` | 3.06 | - | 3.05 | 3.07 | 6 | 0.4 | 3438 | 40.03 MiB | restore 44% | +| `act_mul` | `avx_act_mul` | libavx | `n=2048 act=relu dtype=bf16 M=1` | - | 3.06 | 3.02 | 3.28 | 20 | 2.4 | - | 12.00 KiB | 32 thread(s) | +| `grid_embed_cpe` | `grid_embed_cpe_bf16` | libr4d | `n=1280 side=128 n_prefix=10 dtype=bf16 M=2` | 3.06 | - | 3.05 | 3.09 | 6 | 0.6 | 3440 | 40.03 MiB | restore 44% | +| `lili_factor` | `lili_factor_bf16` | libr4d | `L=56 n=1024 dtype=bf16 M=64` | 3.05 | - | 3.05 | 3.06 | 6 | 0.2 | 3432 | 900.00 KiB | | +| `moe_scatter` | `ref_moe_scatter` | libref | `n_expert=240 top_k=9 expert_base=0 M=4` | - | 3.05 | 3.02 | 3.90 | 20 | 9.5 | - | 2.16 KiB | 32 thread(s) | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=128` | 3.04 | - | 3.03 | 3.04 | 6 | 0.3 | 3277 | 6.25 MiB | restore 74% | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=128` | 3.03 | - | 3.03 | 3.05 | 6 | 0.4 | 3268 | 2.37 GiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=5376 act=relu dtype=bf16 M=32` | 3.01 | - | 3.00 | 3.02 | 6 | 0.2 | 3418 | 1008.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=1024 eps=1e-05 dtype=bf16 M=32` | 3.00 | - | 3.00 | 3.01 | 6 | 0.2 | 3431 | 128.00 KiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=8` | 3.00 | - | 2.98 | 3.02 | 6 | 0.7 | 3434 | 54.06 KiB | restore 44% | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=1024 eps=1e-05 dtype=bf16 M=16` | 3.00 | - | 2.99 | 3.00 | 6 | 0.2 | 3434 | 64.00 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=20480 act=relu dtype=bf16 M=8` | 3.00 | - | 2.99 | 3.00 | 6 | 0.2 | 3396 | 960.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=1024 eps=1e-05 dtype=bf16 M=8` | 2.99 | - | 2.99 | 3.00 | 6 | 0.2 | 3434 | 32.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=1024 eps=1e-05 dtype=bf16 M=64` | 2.99 | - | 2.99 | 3.00 | 6 | 0.2 | 3430 | 256.00 KiB | | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=4096 dtype=bf16 M=64` | 2.99 | - | 2.98 | 2.99 | 6 | 0.1 | 3106 | 2.50 MiB | restore 54% | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=1024 eps=1e-05 dtype=bf16 M=4` | 2.99 | - | 2.98 | 3.00 | 6 | 0.3 | 3432 | 16.00 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=1024 eps=1e-05 dtype=bf16 M=2` | 2.98 | - | 2.98 | 2.99 | 6 | 0.3 | 3434 | 8.00 KiB | | +| `silu_mul` | `silu_mul_bf16` | libr4d | `n=12288 dtype=bf16 M=16` | 2.98 | - | 2.97 | 3.01 | 6 | 0.6 | 3355 | 1.12 MiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=1024 eps=1e-05 dtype=bf16 M=1` | 2.97 | - | 2.96 | 3.00 | 6 | 0.6 | 3436 | 4.00 KiB | | +| `lili_factor` | `lili_factor_bf16` | libr4d | `L=56 n=1024 dtype=bf16 M=32` | 2.97 | - | 2.96 | 2.98 | 6 | 0.3 | 3434 | 450.00 KiB | | +| `lili_factor` | `lili_factor_bf16` | libr4d | `L=56 n=1024 dtype=bf16 M=4` | 2.96 | - | 2.96 | 2.97 | 6 | 0.1 | 3436 | 450.00 KiB | | +| `lili_factor` | `lili_factor_bf16` | libr4d | `L=56 n=1024 dtype=bf16 M=8` | 2.96 | - | 2.96 | 3.00 | 11 | 0.8 | 3436 | 450.00 KiB | | +| `lili_factor` | `lili_factor_bf16` | libr4d | `L=56 n=1024 dtype=bf16 M=2` | 2.96 | - | 2.96 | 2.97 | 6 | 0.2 | 3434 | 450.00 KiB | | +| `lili_factor` | `lili_factor_bf16` | libr4d | `L=56 n=1024 dtype=bf16 M=1` | 2.96 | - | 2.96 | 2.97 | 6 | 0.2 | 3437 | 450.00 KiB | | +| `lili_factor` | `lili_factor_bf16` | libr4d | `L=56 n=1024 dtype=bf16 M=16` | 2.96 | - | 2.96 | 2.98 | 6 | 0.4 | 3435 | 450.00 KiB | | +| `moe_scatter` | `moe_scatter_i32` | libr4d | `n_expert=304 top_k=9 expert_base=0 M=8` | 2.96 | - | 2.96 | 2.98 | 6 | 0.3 | 3403 | 2.94 KiB | | +| `moe_scatter` | `moe_scatter_i32` | libr4d | `n_expert=304 top_k=9 expert_base=0 M=16` | 2.96 | - | 2.94 | 2.96 | 6 | 0.4 | 3403 | 3.50 KiB | | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=2048 group=128 dtype=bf16 M=64` | 2.95 | - | 2.95 | 2.96 | 6 | 0.2 | 3428 | 388.00 KiB | | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=2` | - | 2.95 | 2.92 | 3.14 | 20 | 1.7 | - | 1.25 KiB | 32 thread(s) | +| `sample_ngram_ban` | `sample_ngram_ban_f32` | libr4d | `n_vocab=131072 M=32` | 2.94 | - | 2.88 | 2.99 | 20 | 1.1 | 3428 | 16.51 MiB | restore 88%; restore-dominated (88% of the batch): an order of magnitude | +| `rope_table` | `ref_rope_table` | libref | `rot=64 theta=1e+07 scale=1 dtype=f32 M=1` | - | 2.93 | 2.13 | 3.13 | 20 | 4.6 | - | 260 B | 32 thread(s) | +| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=128` | 2.93 | - | 2.92 | 2.94 | 6 | 0.3 | 3302 | 257.50 KiB | restore 45% | +| `sample_ngram_ban` | `sample_ngram_ban_f32` | libr4d | `n_vocab=131072 M=2` | 2.92 | - | 2.92 | 2.94 | 6 | 0.3 | 3432 | 1.03 MiB | restore 45% | +| `attn_dense` | `ref_attn_dense` | libref | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=1` | - | 2.92 | 2.85 | 3.10 | 20 | 3.2 | - | 584 B | 32 thread(s) | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=4096 dtype=bf16 M=32` | 2.92 | - | 2.90 | 2.93 | 6 | 0.5 | 3363 | 1.25 MiB | restore 46% | +| `rope` | `rope_bf16` | libr4d | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=4` | 2.91 | - | 2.91 | 2.93 | 6 | 0.4 | 3438 | 27.03 KiB | restore 45% | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=4096 dtype=bf16 M=16` | 2.91 | - | 2.90 | 2.92 | 6 | 0.2 | 3370 | 640.06 KiB | restore 45% | +| `rope` | `rope_bf16` | libr4d | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=2` | 2.91 | - | 2.90 | 2.92 | 6 | 0.3 | 3440 | 13.52 KiB | restore 45% | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=4096 dtype=bf16 M=8` | 2.91 | - | 2.90 | 2.91 | 6 | 0.3 | 3371 | 320.03 KiB | restore 45% | +| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=131072 M=4` | 2.91 | - | 2.88 | 3.01 | 19 | 0.2 | 3307 | 2.00 MiB | restore 55% | +| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=16` | 2.91 | - | 2.89 | 2.92 | 6 | 0.4 | 3256 | 192.19 KiB | restore 45% | +| `act_mul` | `act_mul_bf16` | libr4d | `n=2304 act=relu dtype=bf16 M=64` | 2.90 | - | 2.90 | 2.91 | 6 | 0.2 | 3428 | 864.00 KiB | | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=4096 dtype=bf16 M=4` | 2.90 | - | 2.89 | 2.91 | 6 | 0.4 | 3374 | 160.02 KiB | restore 45% | +| `rope` | `rope_bf16` | libr4d | `head_dim=72 n_head=16 n_head_kv=16 theta=10000 scale=1 mode=axial rotary_dim=72 sections=18 18 M=1` | 2.90 | - | 2.90 | 2.91 | 6 | 0.2 | 3439 | 6.76 KiB | restore 45% | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=32` | 2.89 | - | 2.88 | 2.91 | 6 | 0.5 | 3251 | 32.50 KiB | | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=4096 dtype=bf16 M=2` | 2.88 | - | 2.88 | 2.91 | 6 | 0.4 | 3378 | 80.01 KiB | restore 45% | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=16` | 2.88 | - | 2.87 | 2.89 | 11 | 0.2 | 3249 | 16.50 KiB | | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=64` | 2.88 | - | 2.88 | 2.89 | 6 | 0.2 | 3282 | 2.37 GiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=8` | 2.88 | - | 2.88 | 2.89 | 6 | 0.2 | 3250 | 8.50 KiB | | +| `scatter_rows` | `scatter_rows_bf16` | libr4d | `n=4096 dtype=bf16 M=1` | 2.88 | - | 2.86 | 2.90 | 11 | 0.6 | 3375 | 40.00 KiB | restore 45% | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=4` | 2.88 | - | 2.88 | 2.89 | 6 | 0.2 | 3250 | 4.50 KiB | | +| `cast` | `cast_bf16_bf16` | libr4d | `n=4096 from=bf16 to=bf16 M=256` | 2.87 | - | 2.87 | 2.89 | 6 | 0.4 | 3362 | 4.00 MiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=1` | 2.87 | - | 2.87 | 2.88 | 11 | 0.2 | 3254 | 1.50 KiB | | +| `moe_scatter` | `moe_scatter_i32` | libr4d | `n_expert=304 top_k=9 expert_base=0 M=4` | 2.87 | - | 2.87 | 2.89 | 6 | 0.4 | 3402 | 2.66 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=2` | 2.87 | - | 2.87 | 2.89 | 6 | 0.4 | 3252 | 2.50 KiB | | +| `moe_scatter` | `moe_scatter_i32` | libr4d | `n_expert=304 top_k=9 expert_base=0 M=2` | 2.87 | - | 2.87 | 2.89 | 6 | 0.3 | 3397 | 2.52 KiB | | +| `moe_scatter` | `avx_moe_scatter` | libavx | `n_expert=304 top_k=9 expert_base=0 M=16` | - | 2.86 | 2.85 | 3.04 | 20 | 2.5 | - | 3.50 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=1536 group=128 dtype=bf16 M=64` | 2.86 | - | 2.85 | 2.86 | 6 | 0.2 | 3418 | 291.00 KiB | | +| `moe_scatter` | `moe_scatter_i32` | libr4d | `n_expert=240 top_k=9 expert_base=0 M=16` | 2.85 | - | 2.84 | 2.87 | 6 | 0.4 | 3434 | 3.00 KiB | | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=64` | 2.85 | - | 2.85 | 2.85 | 6 | 0.1 | 3325 | 3.13 MiB | | +| `moe_scatter` | `ref_moe_scatter` | libref | `n_expert=240 top_k=9 expert_base=0 M=2` | - | 2.85 | 2.83 | 3.18 | 20 | 2.8 | - | 2.02 KiB | 32 thread(s) | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=64` | 2.85 | - | 2.84 | 2.85 | 6 | 0.2 | 3253 | 64.50 KiB | | +| `moe_scatter` | `moe_scatter_i32` | libr4d | `n_expert=304 top_k=9 expert_base=0 M=1` | 2.85 | - | 2.84 | 2.87 | 6 | 0.6 | 3396 | 2.45 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=128` | 2.84 | - | 2.83 | 2.84 | 6 | 0.2 | 3250 | 128.50 KiB | | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=32` | 2.84 | - | 2.83 | 2.84 | 6 | 0.3 | 3286 | 2.37 GiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=32` | 2.82 | - | 2.80 | 2.83 | 12 | 0.4 | 3378 | 16.25 KiB | | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=16` | 2.82 | - | 2.81 | 2.83 | 6 | 0.4 | 3290 | 2.37 GiB | | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=4096 eps=1e-05 dtype=bf16 M=1` | - | 2.82 | 2.68 | 3.06 | 20 | 4.2 | - | 24.00 KiB | 32 thread(s) | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=16` | 2.81 | - | 2.79 | 2.82 | 12 | 0.3 | 3375 | 8.25 KiB | | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=8` | 2.81 | - | 2.81 | 2.82 | 6 | 0.2 | 3295 | 2.37 GiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=4` | 2.81 | - | 2.78 | 2.83 | 12 | 0.5 | 3372 | 2.25 KiB | | +| `moe_scatter` | `moe_scatter_i32` | libr4d | `n_expert=240 top_k=9 expert_base=0 M=8` | 2.81 | - | 2.80 | 2.82 | 6 | 0.4 | 3432 | 2.44 KiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=1` | 2.81 | - | 2.79 | 2.84 | 12 | 0.6 | 3372 | 768 B | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=2` | 2.81 | - | 2.78 | 2.82 | 12 | 0.3 | 3373 | 1.25 KiB | | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=32` | 2.81 | - | 2.80 | 2.81 | 6 | 0.1 | 3328 | 1.56 MiB | | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=4` | 2.81 | - | 2.80 | 2.82 | 6 | 0.5 | 3293 | 2.37 GiB | | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=8` | 2.80 | - | 2.79 | 2.81 | 12 | 0.4 | 3372 | 4.25 KiB | | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=2` | 2.80 | - | 2.79 | 2.81 | 6 | 0.4 | 3295 | 2.37 GiB | | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=8` | 2.80 | - | 2.79 | 2.80 | 6 | 0.3 | 3318 | 400.03 KiB | | +| `silu_mul` | `silu_mul_bf16` | libr4d | `n=17408 dtype=bf16 M=8` | 2.80 | - | 2.79 | 2.81 | 6 | 0.2 | 3427 | 816.00 KiB | | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=16` | 2.80 | - | 2.79 | 2.80 | 6 | 0.2 | 3330 | 800.06 KiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=64` | 2.79 | - | 2.75 | 2.80 | 11 | 0.3 | 3306 | 128.75 KiB | restore 46% | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=256` | 2.79 | - | 2.77 | 2.80 | 12 | 0.4 | 3384 | 128.25 KiB | | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=4` | 2.79 | - | 2.78 | 2.80 | 6 | 0.3 | 3317 | 200.02 KiB | | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=2048 group=128 dtype=bf16 M=32` | 2.79 | - | 2.79 | 2.79 | 6 | 0.1 | 3430 | 194.00 KiB | | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=1` | 2.79 | - | 2.78 | 2.95 | 20 | 1.1 | 3290 | 2.37 GiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=8` | 2.78 | - | 2.19 | 2.81 | 11 | 0.8 | 3254 | 96.09 KiB | restore 47% | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=56` | 2.78 | - | 2.78 | 2.79 | 6 | 0.1 | 3434 | 2.73 MiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=2` | 2.78 | - | 2.77 | 2.79 | 6 | 0.5 | 3252 | 24.02 KiB | restore 47% | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=2` | 2.78 | - | 2.78 | 2.79 | 6 | 0.2 | 3317 | 100.01 KiB | | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=2048 group=128 dtype=bf16 M=16` | 2.78 | - | 2.77 | 2.78 | 6 | 0.2 | 3432 | 97.00 KiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=4` | 2.78 | - | 2.75 | 2.80 | 6 | 0.8 | 3254 | 48.05 KiB | restore 47% | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=2048 group=128 dtype=bf16 M=8` | 2.77 | - | 2.77 | 2.78 | 6 | 0.3 | 3431 | 48.50 KiB | | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=5120 dtype=bf16 M=1` | 2.77 | - | 2.76 | 2.80 | 6 | 0.7 | 3317 | 50.00 KiB | | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=2048 group=128 dtype=bf16 M=4` | 2.77 | - | 2.76 | 2.78 | 6 | 0.3 | 3434 | 24.25 KiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=24 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=1` | 2.77 | - | 2.75 | 2.78 | 6 | 0.5 | 3251 | 12.01 KiB | restore 47% | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=2048 group=128 dtype=bf16 M=2` | 2.77 | - | 2.76 | 2.78 | 6 | 0.3 | 3434 | 12.12 KiB | | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=1536 group=128 dtype=bf16 M=32` | 2.77 | - | 2.76 | 2.78 | 6 | 0.5 | 3421 | 145.50 KiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=8` | 2.77 | - | 2.74 | 2.77 | 6 | 0.4 | 3344 | 64.03 KiB | restore 46% | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=64` | 2.76 | - | 2.74 | 2.77 | 12 | 0.2 | 3377 | 32.25 KiB | | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=2048 group=128 dtype=bf16 M=1` | 2.76 | - | 2.75 | 2.77 | 6 | 0.3 | 3432 | 6.06 KiB | | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=1536 group=128 dtype=bf16 M=16` | 2.76 | - | 2.75 | 2.77 | 6 | 0.4 | 3420 | 72.75 KiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=32` | 2.76 | - | 2.74 | 2.78 | 6 | 0.6 | 3294 | 64.38 KiB | restore 47% | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=128` | 2.76 | - | 2.75 | 2.76 | 6 | 0.3 | 3372 | 64.50 KiB | restore 46% | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=1536 group=128 dtype=bf16 M=8` | 2.75 | - | 2.75 | 2.76 | 6 | 0.2 | 3411 | 36.38 KiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=32` | 2.75 | - | 2.75 | 2.77 | 6 | 0.3 | 3404 | 64.12 KiB | restore 46% | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=4096 eps=1e-06 wadd=0 dtype=bf16 M=1` | - | 2.75 | 2.62 | 2.93 | 20 | 4.4 | - | 24.00 KiB | 32 thread(s) | +| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=16` | 2.75 | - | 2.73 | 2.76 | 6 | 0.5 | 3296 | 32.19 KiB | restore 47% | +| `rmsnorm` | `rmsnorm_bf16` | libr4d | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=128` | 2.75 | - | 2.73 | 2.75 | 12 | 0.3 | 3374 | 64.25 KiB | | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=1536 group=128 dtype=bf16 M=4` | 2.74 | - | 2.74 | 2.76 | 6 | 0.3 | 3414 | 18.19 KiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=8` | 2.74 | - | 2.74 | 2.75 | 6 | 0.3 | 3425 | 64.03 KiB | restore 46% | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=1536 group=128 dtype=bf16 M=2` | 2.74 | - | 2.74 | 2.75 | 6 | 0.2 | 3414 | 9.09 KiB | | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=1536 group=128 dtype=bf16 M=1` | 2.74 | - | 2.73 | 2.76 | 6 | 0.5 | 3416 | 4.55 KiB | | +| `moe_scatter` | `ref_moe_scatter` | libref | `n_expert=240 top_k=9 expert_base=0 M=1` | - | 2.74 | 2.73 | 3.06 | 20 | 3.9 | - | 1.95 KiB | 32 thread(s) | +| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=8` | 2.73 | - | 2.73 | 2.75 | 6 | 0.4 | 3294 | 16.09 KiB | restore 47% | +| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=1` | 2.73 | - | 2.12 | 2.75 | 11 | 0.7 | 3277 | 2.01 KiB | restore 47% | +| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=4` | 2.73 | - | 2.72 | 2.76 | 6 | 0.6 | 3290 | 8.05 KiB | restore 47% | +| `rope` | `rope_bf16` | libr4d | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=2` | 2.72 | - | 2.58 | 2.73 | 11 | 0.3 | 3290 | 4.02 KiB | restore 47% | +| `moe_scatter` | `moe_scatter_i32` | libr4d | `n_expert=240 top_k=9 expert_base=0 M=4` | 2.72 | - | 2.72 | 2.73 | 6 | 0.3 | 3432 | 2.16 KiB | | +| `moe_scatter` | `moe_scatter_i32` | libr4d | `n_expert=240 top_k=9 expert_base=0 M=2` | 2.71 | - | 2.71 | 2.73 | 6 | 0.4 | 3434 | 2.02 KiB | | +| `cast` | `avx_cast` | libavx | `n=4096 from=bf16 to=bf16 M=2` | - | 2.70 | 2.61 | 2.80 | 20 | 2.2 | - | 32.00 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=1024 group=128 dtype=bf16 M=128` | 2.70 | - | 2.69 | 2.71 | 6 | 0.3 | 3425 | 388.00 KiB | | +| `cast` | `cast_bf16_bf16` | libr4d | `n=5120 from=bf16 to=bf16 M=128` | 2.69 | - | 2.69 | 2.74 | 6 | 1.0 | 3298 | 2.50 MiB | | +| `moe_scatter` | `moe_scatter_i32` | libr4d | `n_expert=240 top_k=9 expert_base=0 M=1` | 2.69 | - | 2.68 | 2.70 | 6 | 0.4 | 3434 | 1.95 KiB | | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=4096 dtype=bf16 M=56` | 2.68 | - | 2.68 | 2.73 | 6 | 0.9 | 3383 | 2.19 MiB | | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=64` | 2.67 | - | 2.67 | 2.69 | 6 | 0.3 | 3435 | 1.00 GiB | | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=4096 dtype=bf16 M=64` | 2.67 | - | 2.67 | 2.68 | 6 | 0.2 | 3428 | 2.50 MiB | | +| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=4` | - | 2.67 | 2.61 | 2.80 | 20 | 2.3 | - | 2.26 KiB | 32 thread(s) | +| `gdn_gated_rmsnorm` | `gdn_gated_rmsnorm_h128_bf16` | libr4d | `channels=128 eps=1e-06 act=silu M=512` | 2.67 | - | 2.66 | 2.68 | 6 | 0.4 | 3253 | 384.50 KiB | | +| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=128` | 2.66 | - | 2.66 | 2.67 | 6 | 0.2 | 3249 | 832.50 KiB | restore 48% | +| `act_mul` | `act_mul_bf16` | libr4d | `n=1536 act=relu dtype=bf16 M=64` | 2.66 | - | 2.65 | 2.66 | 6 | 0.2 | 3410 | 576.00 KiB | | +| `layernorm` | `avx_layernorm` | libavx | `n=1280 eps=1e-06 dtype=bf16 M=2` | - | 2.65 | 2.44 | 2.79 | 20 | 2.9 | - | 15.00 KiB | 32 thread(s) | +| `gdn_gated_rmsnorm` | `gdn_gated_rmsnorm_h128_bf16` | libr4d | `channels=128 eps=1e-06 act=silu M=256` | 2.64 | - | 2.64 | 2.66 | 6 | 0.4 | 3248 | 192.50 KiB | | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=4096 dtype=bf16 M=32` | 2.64 | - | 2.63 | 2.65 | 6 | 0.3 | 3432 | 1.25 MiB | | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=32` | 2.64 | - | 2.63 | 2.65 | 6 | 0.3 | 3438 | 1.00 GiB | | +| `gdn_gated_rmsnorm` | `gdn_gated_rmsnorm_h128_bf16` | libr4d | `channels=128 eps=1e-06 act=silu M=128` | 2.63 | - | 2.63 | 2.65 | 6 | 0.5 | 3248 | 96.50 KiB | | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=4096 dtype=bf16 M=16` | 2.63 | - | 2.62 | 2.64 | 6 | 0.2 | 3432 | 640.06 KiB | | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=16` | 2.63 | - | 2.62 | 2.64 | 6 | 0.4 | 3440 | 1.00 GiB | | +| `silu_mul` | `silu_mul_bf16` | libr4d | `n=12288 dtype=bf16 M=8` | 2.63 | - | 2.62 | 2.64 | 6 | 0.4 | 3364 | 576.00 KiB | | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=8` | 2.62 | - | 2.62 | 2.64 | 6 | 0.4 | 3436 | 1.00 GiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=64` | 2.62 | - | 2.62 | 2.63 | 6 | 0.2 | 3370 | 32.25 KiB | restore 48% | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=4096 dtype=bf16 M=8` | 2.62 | - | 2.61 | 2.63 | 6 | 0.3 | 3432 | 320.03 KiB | | +| `gdn_gated_rmsnorm` | `gdn_gated_rmsnorm_h128_bf16` | libr4d | `channels=128 eps=1e-06 act=silu M=64` | 2.62 | - | 2.61 | 2.64 | 6 | 0.5 | 3248 | 48.50 KiB | | +| `gdn_gated_rmsnorm` | `gdn_gated_rmsnorm_h128_bf16` | libr4d | `channels=128 eps=1e-06 act=silu M=16` | 2.62 | - | 2.61 | 2.64 | 6 | 0.5 | 3249 | 12.50 KiB | | +| `gdn_gated_rmsnorm` | `gdn_gated_rmsnorm_h128_bf16` | libr4d | `channels=128 eps=1e-06 act=silu M=8` | 2.62 | - | 2.61 | 2.64 | 6 | 0.7 | 3254 | 6.50 KiB | | +| `gdn_gated_rmsnorm` | `gdn_gated_rmsnorm_h128_bf16` | libr4d | `channels=128 eps=1e-06 act=silu M=32` | 2.61 | - | 2.61 | 2.64 | 6 | 0.5 | 3248 | 24.50 KiB | | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=4` | 2.61 | - | 2.61 | 2.63 | 6 | 0.3 | 3438 | 1.00 GiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=4` | 2.61 | - | 2.60 | 2.62 | 6 | 0.4 | 3348 | 32.02 KiB | restore 48% | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=4096 dtype=bf16 M=4` | 2.61 | - | 2.61 | 2.63 | 6 | 0.3 | 3432 | 160.02 KiB | | +| `gdn_gated_rmsnorm` | `gdn_gated_rmsnorm_h128_bf16` | libr4d | `channels=128 eps=1e-06 act=silu M=4` | 2.61 | - | 2.60 | 2.63 | 6 | 0.6 | 3256 | 3.50 KiB | | +| `rope_table` | `rope_table_f32` | libr4d | `rot=64 theta=1e+07 scale=1 dtype=f32 M=64` | 2.61 | - | 2.61 | 2.62 | 6 | 0.3 | 3305 | 16.25 KiB | | +| `gdn_gated_rmsnorm` | `gdn_gated_rmsnorm_h128_bf16` | libr4d | `channels=128 eps=1e-06 act=silu M=2` | 2.61 | - | 2.60 | 2.64 | 6 | 0.7 | 3254 | 2.00 KiB | | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=2` | 2.61 | - | 2.61 | 2.61 | 6 | 0.1 | 3442 | 1.00 GiB | | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=4096 dtype=bf16 M=2` | 2.61 | - | 2.60 | 2.62 | 6 | 0.3 | 3434 | 80.01 KiB | | +| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=128` | 2.61 | - | 2.61 | 2.62 | 6 | 0.2 | 3444 | 832.50 KiB | restore 47% | +| `rope_table` | `rope_table_f32` | libr4d | `rot=64 theta=1e+07 scale=1 dtype=f32 M=32` | 2.61 | - | 2.60 | 2.62 | 6 | 0.4 | 3302 | 8.12 KiB | | +| `gdn_gated_rmsnorm` | `gdn_gated_rmsnorm_h128_bf16` | libr4d | `channels=128 eps=1e-06 act=silu M=1` | 2.61 | - | 2.60 | 2.62 | 6 | 0.5 | 3256 | 1.25 KiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=16` | 2.61 | - | 2.59 | 2.62 | 6 | 0.5 | 3402 | 32.06 KiB | restore 48% | +| `rope_table` | `rope_table_f32` | libr4d | `rot=64 theta=1e+07 scale=1 dtype=f32 M=16` | 2.60 | - | 2.60 | 2.62 | 6 | 0.4 | 3295 | 4.06 KiB | | +| `rope_table` | `rope_table_f32` | libr4d | `rot=64 theta=1e+07 scale=1 dtype=f32 M=8` | 2.60 | - | 2.59 | 2.61 | 6 | 0.2 | 3296 | 2.03 KiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=4` | 2.60 | - | 2.59 | 2.63 | 6 | 0.7 | 3421 | 32.02 KiB | restore 48% | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=4096 dtype=bf16 M=1` | 2.60 | - | 2.60 | 2.62 | 6 | 0.5 | 3434 | 40.00 KiB | | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=2` | 2.60 | - | 2.59 | 2.71 | 20 | 2.2 | 3337 | 16.01 KiB | restore 48% | +| `embed_lookup` | `embed_lookup_bf16` | libr4d | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=1` | 2.60 | - | 2.60 | 2.60 | 11 | 0.1 | 3439 | 1.00 GiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=5376 act=relu dtype=bf16 M=16` | 2.60 | - | 2.60 | 2.60 | 6 | 0.1 | 3417 | 504.00 KiB | | +| `rope_table` | `rope_table_f32` | libr4d | `rot=64 theta=1e+07 scale=1 dtype=f32 M=4` | 2.60 | - | 2.59 | 2.61 | 6 | 0.4 | 3296 | 1.02 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=20480 act=relu dtype=bf16 M=4` | 2.60 | - | 2.59 | 2.63 | 6 | 0.7 | 3398 | 480.00 KiB | | +| `rope_table` | `rope_table_f32` | libr4d | `rot=64 theta=1e+07 scale=1 dtype=f32 M=2` | 2.59 | - | 2.58 | 2.60 | 6 | 0.4 | 3293 | 520 B | | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=32` | 2.59 | - | 2.58 | 2.59 | 6 | 0.3 | 3371 | 16.12 KiB | restore 48% | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=8` | 2.59 | - | 2.58 | 2.60 | 6 | 0.5 | 3400 | 16.03 KiB | restore 48% | +| `rope_table` | `rope_table_f32` | libr4d | `rot=64 theta=1e+07 scale=1 dtype=f32 M=1` | 2.59 | - | 2.58 | 2.61 | 6 | 0.5 | 3295 | 260 B | | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=4` | 2.58 | - | 2.53 | 2.59 | 11 | 0.4 | 3398 | 8.02 KiB | restore 48% | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=32 n_head_kv=0 theta=10000 scale=1 mode=neox M=1` | 2.58 | - | 2.58 | 2.60 | 6 | 0.4 | 3337 | 8.00 KiB | restore 48% | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=2` | 2.58 | - | 2.57 | 2.62 | 6 | 0.9 | 3389 | 4.01 KiB | restore 48% | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=2` | 2.58 | - | 2.57 | 2.59 | 6 | 0.3 | 3420 | 16.01 KiB | restore 48% | +| `silu_mul` | `silu_mul_bf16` | libr4d | `n=17408 dtype=bf16 M=4` | 2.58 | - | 2.58 | 2.59 | 6 | 0.2 | 3436 | 408.00 KiB | | +| `moe_scatter` | `avx_moe_scatter` | libavx | `n_expert=240 top_k=9 expert_base=0 M=16` | - | 2.58 | 2.54 | 3.03 | 20 | 2.7 | - | 3.00 KiB | 32 thread(s) | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=8 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=1` | 2.58 | - | 2.57 | 2.59 | 6 | 0.4 | 3388 | 2.00 KiB | restore 48% | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=16` | 2.57 | - | 2.57 | 2.58 | 6 | 0.2 | 3372 | 8.06 KiB | restore 48% | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=8` | 2.57 | - | 2.56 | 2.57 | 6 | 0.2 | 3362 | 4.03 KiB | restore 48% | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=32 n_head_kv=0 theta=1e+07 scale=1 mode=neox M=1` | 2.57 | - | 2.56 | 2.59 | 6 | 0.6 | 3421 | 8.00 KiB | restore 48% | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=4` | 2.57 | - | 2.56 | 2.57 | 6 | 0.2 | 3362 | 2.02 KiB | restore 48% | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=2` | 2.57 | - | 2.54 | 2.58 | 6 | 0.8 | 3360 | 1.01 KiB | restore 48% | +| `rope` | `rope_bf16` | libr4d | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=1` | 2.56 | - | 2.55 | 2.57 | 6 | 0.3 | 3362 | 516 B | restore 48% | +| `act_mul` | `act_mul_bf16` | libr4d | `n=2304 act=relu dtype=bf16 M=32` | 2.55 | - | 2.55 | 2.56 | 6 | 0.2 | 3430 | 432.00 KiB | | +| `cast` | `avx_cast` | libavx | `n=5120 from=bf16 to=bf16 M=1` | - | 2.54 | 2.45 | 3.04 | 20 | 5.2 | - | 20.00 KiB | 32 thread(s) | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=4` | - | 2.52 | 2.43 | 2.68 | 20 | 2.8 | - | 52.02 KiB | 32 thread(s) | +| `kv_store` | `kv_store_bf16` | libr4d | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=128` | 2.51 | - | 2.51 | 2.52 | 6 | 0.3 | 3372 | 288.50 KiB | restore 49% | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=1280 dtype=bf16 M=128` | 2.51 | - | 2.51 | 2.52 | 6 | 0.2 | 3434 | 1.56 MiB | | +| `silu_mul` | `silu_mul_bf16` | libr4d | `n=12288 dtype=bf16 M=4` | 2.51 | - | 2.50 | 2.52 | 6 | 0.3 | 3368 | 288.00 KiB | | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=1024 group=128 dtype=bf16 M=64` | 2.50 | - | 2.50 | 2.51 | 6 | 0.1 | 3431 | 194.00 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=1024 group=128 dtype=bf16 M=128` | 2.50 | - | 2.49 | 2.50 | 6 | 0.2 | 3428 | 388.00 KiB | | +| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=64` | 2.47 | - | 2.46 | 2.48 | 6 | 0.2 | 3252 | 448.25 KiB | restore 50% | +| `silu_mul` | `silu_mul_bf16` | libr4d | `n=17408 dtype=bf16 M=2` | 2.47 | - | 2.47 | 2.47 | 6 | 0.1 | 3438 | 204.00 KiB | | +| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=1024 M=4` | 2.46 | - | 2.43 | 2.48 | 17 | 0.8 | 3439 | 16.38 KiB | restore 49% | +| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=1024 M=2` | 2.46 | - | 2.44 | 2.48 | 12 | 0.7 | 3440 | 8.19 KiB | restore 49% | +| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=1024 M=16` | 2.46 | - | 2.44 | 2.47 | 12 | 0.6 | 3440 | 65.50 KiB | restore 49% | +| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=1024 M=8` | 2.46 | - | 2.44 | 2.48 | 12 | 0.8 | 3439 | 32.75 KiB | restore 49% | +| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=1024 M=32` | 2.46 | - | 2.38 | 2.50 | 20 | 0.6 | 3440 | 131.00 KiB | restore 49% | +| `sample_temp` | `sample_temp_f32` | libr4d | `n_vocab=1024 M=1` | 2.45 | - | 0.92 | 2.47 | 17 | 0.8 | 3438 | 4.09 KiB | restore 49% | +| `silu_mul` | `silu_mul_bf16` | libr4d | `n=12288 dtype=bf16 M=2` | 2.45 | - | 2.45 | 2.45 | 6 | 0.1 | 3371 | 144.00 KiB | | +| `silu_mul` | `silu_mul_bf16` | libr4d | `n=12288 dtype=bf16 M=1` | 2.44 | - | 2.44 | 2.45 | 6 | 0.2 | 3370 | 72.00 KiB | | +| `cast` | `cast_bf16_bf16` | libr4d | `n=5120 from=bf16 to=bf16 M=64` | 2.44 | - | 2.43 | 2.45 | 6 | 0.5 | 3296 | 1.25 MiB | | +| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=64` | 2.44 | - | 2.44 | 2.45 | 6 | 0.3 | 3450 | 448.25 KiB | restore 49% | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=1280 dtype=bf16 M=64` | 2.44 | - | 2.44 | 2.45 | 6 | 0.2 | 3434 | 800.25 KiB | | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=1280 dtype=bf16 M=16` | 2.44 | - | 2.43 | 2.45 | 6 | 0.2 | 3440 | 200.06 KiB | | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=1280 dtype=bf16 M=8` | 2.44 | - | 2.43 | 2.44 | 6 | 0.1 | 3439 | 100.03 KiB | | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=1280 dtype=bf16 M=4` | 2.44 | - | 2.44 | 2.45 | 6 | 0.3 | 3436 | 50.02 KiB | | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=1280 dtype=bf16 M=1` | 2.44 | - | 2.43 | 2.46 | 6 | 0.6 | 3438 | 12.50 KiB | | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=1280 dtype=bf16 M=32` | 2.44 | - | 2.43 | 2.44 | 6 | 0.2 | 3439 | 400.12 KiB | | +| `gather_rows` | `gather_rows_bf16` | libr4d | `n=1280 dtype=bf16 M=2` | 2.44 | - | 2.42 | 2.44 | 6 | 0.5 | 3439 | 25.01 KiB | | +| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=16` | 2.43 | - | 2.42 | 2.45 | 6 | 0.6 | 3254 | 160.06 KiB | restore 50% | +| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=2` | 2.43 | - | 2.41 | 2.45 | 6 | 0.7 | 3430 | 104.01 KiB | restore 49% | +| `cast` | `cast_bf16_bf16` | libr4d | `n=5120 from=bf16 to=bf16 M=1` | 2.43 | - | 2.39 | 2.43 | 6 | 0.8 | 3295 | 20.00 KiB | | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=1024 eps=1e-05 dtype=bf16 M=4` | - | 2.43 | 2.32 | 2.60 | 20 | 3.6 | - | 16.00 KiB | 32 thread(s) | +| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=4` | 2.43 | - | 2.39 | 2.44 | 11 | 0.7 | 3266 | 112.02 KiB | restore 50% | +| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=8` | 2.43 | - | 2.43 | 2.44 | 6 | 0.2 | 3268 | 128.03 KiB | restore 50% | +| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=2` | 2.43 | - | 2.41 | 2.44 | 6 | 0.6 | 3270 | 104.01 KiB | restore 50% | +| `cast` | `cast_bf16_bf16` | libr4d | `n=5120 from=bf16 to=bf16 M=2` | 2.43 | - | 2.43 | 2.43 | 6 | 0.2 | 3293 | 40.00 KiB | | +| `cast` | `cast_bf16_bf16` | libr4d | `n=5120 from=bf16 to=bf16 M=4` | 2.43 | - | 2.42 | 2.45 | 6 | 0.6 | 3294 | 80.00 KiB | | +| `cast` | `cast_bf16_bf16` | libr4d | `n=5120 from=bf16 to=bf16 M=8` | 2.43 | - | 2.42 | 2.43 | 6 | 0.1 | 3298 | 160.00 KiB | | +| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=1` | 2.43 | - | 2.33 | 2.44 | 11 | 0.3 | 3277 | 100.00 KiB | restore 50% | +| `cast` | `cast_bf16_bf16` | libr4d | `n=5120 from=bf16 to=bf16 M=16` | 2.43 | - | 2.42 | 2.44 | 6 | 0.2 | 3292 | 320.00 KiB | | +| `cast` | `cast_bf16_bf16` | libr4d | `n=5120 from=bf16 to=bf16 M=32` | 2.43 | - | 2.42 | 2.43 | 6 | 0.2 | 3294 | 640.00 KiB | | +| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=8` | 2.43 | - | 2.42 | 2.44 | 6 | 0.3 | 3438 | 128.03 KiB | restore 49% | +| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=32` | 2.43 | - | 2.42 | 2.44 | 6 | 0.3 | 3255 | 256.12 KiB | restore 50% | +| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=16` | 2.43 | - | 2.40 | 2.44 | 6 | 0.8 | 3440 | 160.06 KiB | restore 49% | +| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=1` | 2.42 | - | 2.41 | 2.44 | 6 | 0.6 | 3428 | 100.00 KiB | restore 49% | +| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=32` | 2.42 | - | 2.41 | 2.44 | 6 | 0.5 | 3440 | 256.12 KiB | restore 49% | +| `silu` | `silu_bf16` | libr4d | `n=1024 dtype=bf16 M=8` | 2.42 | - | 2.41 | 2.43 | 6 | 0.3 | 3436 | 32.00 KiB | | +| `kv_store` | `kv_store_bf16` | libr4d | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=16` | 2.42 | - | 2.41 | 2.44 | 6 | 0.6 | 3383 | 64.06 KiB | restore 50% | +| `kv_store` | `kv_store_bf16` | libr4d | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=4` | 2.42 | - | 2.41 | 2.43 | 6 | 0.4 | 3382 | 52.02 KiB | restore 50% | +| `silu` | `silu_bf16` | libr4d | `n=1024 dtype=bf16 M=32` | 2.42 | - | 2.32 | 2.43 | 19 | 0.2 | 3436 | 128.00 KiB | | +| `silu_mul` | `silu_mul_bf16` | libr4d | `n=17408 dtype=bf16 M=1` | 2.42 | - | 2.42 | 2.43 | 6 | 0.2 | 3437 | 102.00 KiB | | +| `silu` | `silu_bf16` | libr4d | `n=1024 dtype=bf16 M=16` | 2.42 | - | 2.42 | 2.42 | 6 | 0.1 | 3438 | 64.00 KiB | | +| `kv_store` | `kv_store_bf16` | libr4d | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=2` | 2.42 | - | 2.41 | 2.42 | 6 | 0.2 | 3396 | 50.01 KiB | restore 50% | +| `kv_store` | `kv_store_bf16` | libr4d | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=8` | 2.42 | - | 2.41 | 2.43 | 6 | 0.5 | 3383 | 56.03 KiB | restore 50% | +| `kv_store` | `kv_store_fp8` | libr4d | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=4` | 2.42 | - | 2.41 | 2.43 | 6 | 0.4 | 3432 | 112.02 KiB | restore 49% | +| `silu` | `silu_bf16` | libr4d | `n=1024 dtype=bf16 M=4` | 2.42 | - | 2.30 | 2.70 | 16 | 0.4 | 3439 | 16.00 KiB | | +| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=2` | - | 2.42 | 2.39 | 3.01 | 20 | 4.5 | - | 4.02 KiB | 32 thread(s) | +| `silu` | `silu_bf16` | libr4d | `n=1024 dtype=bf16 M=1` | 2.42 | - | 2.41 | 2.42 | 6 | 0.2 | 3440 | 4.00 KiB | | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=1024 group=128 dtype=bf16 M=32` | 2.42 | - | 2.42 | 2.43 | 6 | 0.3 | 3432 | 97.00 KiB | | +| `kv_store` | `kv_store_bf16` | libr4d | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=32` | 2.42 | - | 2.41 | 2.43 | 6 | 0.6 | 3374 | 96.12 KiB | restore 50% | +| `silu` | `silu_bf16` | libr4d | `n=2048 dtype=bf16 M=2` | 2.42 | - | 2.41 | 2.42 | 6 | 0.1 | 3438 | 16.00 KiB | | +| `silu` | `silu_bf16` | libr4d | `n=2048 dtype=bf16 M=1` | 2.42 | - | 2.41 | 2.42 | 6 | 0.1 | 3438 | 8.00 KiB | | +| `kv_store` | `kv_store_bf16` | libr4d | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=1` | 2.42 | - | 2.39 | 2.44 | 6 | 1.0 | 3392 | 49.00 KiB | restore 50% | +| `silu` | `silu_bf16` | libr4d | `n=2048 dtype=bf16 M=16` | 2.42 | - | 2.41 | 2.43 | 6 | 0.2 | 3436 | 128.00 KiB | | +| `cast` | `cast_bf16_bf16` | libr4d | `n=4096 from=bf16 to=bf16 M=2` | 2.42 | - | 2.41 | 2.42 | 6 | 0.2 | 3368 | 32.00 KiB | | +| `cast` | `cast_bf16_bf16` | libr4d | `n=4096 from=bf16 to=bf16 M=4` | 2.42 | - | 2.41 | 2.42 | 6 | 0.2 | 3372 | 64.00 KiB | | +| `silu` | `silu_bf16` | libr4d | `n=2048 dtype=bf16 M=4` | 2.42 | - | 2.41 | 2.42 | 6 | 0.1 | 3438 | 32.00 KiB | | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=1024 group=128 dtype=bf16 M=16` | 2.42 | - | 2.41 | 2.43 | 6 | 0.3 | 3432 | 48.50 KiB | | +| `cast` | `cast_bf16_bf16` | libr4d | `n=4096 from=bf16 to=bf16 M=1` | 2.42 | - | 2.41 | 2.42 | 6 | 0.2 | 3363 | 16.00 KiB | | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=1024 group=128 dtype=bf16 M=4` | 2.42 | - | 2.41 | 2.42 | 6 | 0.3 | 3435 | 12.12 KiB | | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=1024 group=128 dtype=bf16 M=8` | 2.42 | - | 2.41 | 2.42 | 6 | 0.3 | 3434 | 24.25 KiB | | +| `silu` | `silu_bf16` | libr4d | `n=2048 dtype=bf16 M=8` | 2.41 | - | 2.31 | 2.42 | 19 | 0.1 | 3439 | 64.00 KiB | | +| `silu` | `silu_bf16` | libr4d | `n=1024 dtype=bf16 M=2` | 2.41 | - | 2.41 | 2.42 | 6 | 0.2 | 3438 | 8.00 KiB | | +| `kv_store` | `kv_store_bf16` | libr4d | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=64` | 2.41 | - | 2.41 | 2.42 | 6 | 0.4 | 3372 | 160.25 KiB | restore 50% | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=1024 group=128 dtype=bf16 M=2` | 2.41 | - | 2.41 | 2.42 | 6 | 0.3 | 3434 | 6.06 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=1024 group=128 dtype=bf16 M=64` | 2.41 | - | 2.41 | 2.42 | 6 | 0.2 | 3430 | 194.00 KiB | | +| `cast` | `cast_bf16_bf16` | libr4d | `n=4096 from=bf16 to=bf16 M=32` | 2.41 | - | 2.41 | 2.42 | 6 | 0.1 | 3370 | 512.00 KiB | | +| `cast` | `cast_bf16_bf16` | libr4d | `n=4096 from=bf16 to=bf16 M=16` | 2.41 | - | 2.41 | 2.41 | 6 | 0.2 | 3370 | 256.00 KiB | | +| `cast` | `cast_bf16_bf16` | libr4d | `n=4096 from=bf16 to=bf16 M=8` | 2.41 | - | 2.41 | 2.42 | 6 | 0.2 | 3373 | 128.00 KiB | | +| `cast` | `cast_bf16_bf16` | libr4d | `n=4096 from=bf16 to=bf16 M=64` | 2.41 | - | 2.41 | 2.42 | 6 | 0.3 | 3378 | 1.00 MiB | | +| `rope` | `avx_rope` | libavx | `head_dim=128 n_head=2 n_head_kv=0 theta=10000 scale=1 mode=neox M=1` | - | 2.41 | 2.39 | 2.46 | 20 | 1.2 | - | 516 B | 32 thread(s) | +| `had_quant_act_fp8` | `had_quant_act_fp8` | libr4d | `n=1024 group=128 dtype=bf16 M=1` | 2.41 | - | 2.41 | 2.42 | 6 | 0.3 | 3434 | 3.03 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=1536 act=relu dtype=bf16 M=8` | 2.41 | - | 2.40 | 2.41 | 6 | 0.2 | 3416 | 72.00 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=1536 act=relu dtype=bf16 M=32` | 2.41 | - | 2.40 | 2.41 | 6 | 0.1 | 3412 | 288.00 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=5376 act=relu dtype=bf16 M=1` | 2.41 | - | 2.40 | 2.43 | 6 | 0.7 | 3424 | 31.50 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=1536 act=relu dtype=bf16 M=1` | 2.41 | - | 2.40 | 2.42 | 11 | 0.3 | 3421 | 9.00 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=20480 act=relu dtype=bf16 M=1` | 2.41 | - | 2.40 | 2.46 | 14 | 0.1 | 3406 | 120.00 KiB | | +| `iota` | `iota` | libr4d | `start=0 step=1 M=8` | 2.40 | - | 2.40 | 2.41 | 6 | 0.1 | 3438 | 32 B | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=1536 act=relu dtype=bf16 M=16` | 2.40 | - | 2.40 | 2.41 | 6 | 0.2 | 3414 | 144.00 KiB | | +| `iota` | `iota` | libr4d | `start=0 step=1 M=2` | 2.40 | - | 2.40 | 2.41 | 6 | 0.2 | 3438 | 8 B | | +| `iota` | `iota` | libr4d | `start=0 step=1 M=256` | 2.40 | - | 2.40 | 2.41 | 6 | 0.2 | 3440 | 1.00 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=1536 act=relu dtype=bf16 M=4` | 2.40 | - | 2.40 | 2.41 | 6 | 0.1 | 3423 | 36.00 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=20480 act=relu dtype=bf16 M=2` | 2.40 | - | 2.40 | 2.42 | 6 | 0.3 | 3400 | 240.00 KiB | | +| `iota` | `iota` | libr4d | `start=0 step=1 M=16` | 2.40 | - | 2.40 | 2.41 | 6 | 0.3 | 3439 | 64 B | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=5376 act=relu dtype=bf16 M=8` | 2.40 | - | 2.40 | 2.41 | 6 | 0.2 | 3422 | 252.00 KiB | | +| `iota` | `iota` | libr4d | `start=0 step=1 M=512` | 2.40 | - | 2.40 | 2.41 | 6 | 0.3 | 3439 | 2.00 KiB | | +| `iota` | `iota` | libr4d | `start=0 step=1 M=4` | 2.40 | - | 2.39 | 2.41 | 6 | 0.3 | 3437 | 16 B | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=5376 act=relu dtype=bf16 M=4` | 2.40 | - | 2.40 | 2.41 | 6 | 0.2 | 3424 | 126.00 KiB | | +| `iota` | `iota` | libr4d | `start=0 step=1 M=128` | 2.40 | - | 2.40 | 2.41 | 6 | 0.2 | 3436 | 512 B | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=1536 act=relu dtype=bf16 M=2` | 2.40 | - | 2.40 | 2.41 | 6 | 0.2 | 3421 | 18.00 KiB | | +| `iota` | `iota` | libr4d | `start=0 step=1 M=32` | 2.40 | - | 2.40 | 2.40 | 6 | 0.1 | 3436 | 128 B | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=5376 act=relu dtype=bf16 M=2` | 2.40 | - | 2.40 | 2.41 | 6 | 0.2 | 3430 | 63.00 KiB | | +| `iota` | `iota` | libr4d | `start=0 step=1 M=64` | 2.40 | - | 2.40 | 2.41 | 6 | 0.2 | 3440 | 256 B | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=2304 act=relu dtype=bf16 M=1` | 2.40 | - | 2.39 | 2.41 | 6 | 0.3 | 3414 | 13.50 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=1024 group=128 dtype=bf16 M=16` | 2.40 | - | 2.39 | 2.41 | 6 | 0.4 | 3430 | 48.50 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=8192 act=silu dtype=bf16 M=1` | 2.40 | - | 2.40 | 2.41 | 6 | 0.3 | 3410 | 48.00 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=8192 act=silu dtype=bf16 M=4` | 2.40 | - | 2.39 | 2.40 | 6 | 0.2 | 3404 | 192.00 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=1024 group=128 dtype=bf16 M=32` | 2.40 | - | 2.40 | 2.40 | 6 | 0.1 | 3432 | 97.00 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=2304 act=relu dtype=bf16 M=8` | 2.40 | - | 2.39 | 2.41 | 6 | 0.4 | 3424 | 108.00 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=1024 group=128 dtype=bf16 M=4` | 2.40 | - | 2.39 | 2.40 | 6 | 0.2 | 3435 | 12.12 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=2304 act=relu dtype=bf16 M=16` | 2.40 | - | 2.39 | 2.40 | 6 | 0.1 | 3422 | 216.00 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=8192 act=silu dtype=bf16 M=2` | 2.40 | - | 2.39 | 2.40 | 6 | 0.2 | 3406 | 96.00 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=2048 act=relu dtype=bf16 M=8` | 2.40 | - | 2.39 | 2.40 | 6 | 0.1 | 3434 | 96.00 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=1024 group=128 dtype=bf16 M=8` | 2.40 | - | 2.39 | 2.40 | 6 | 0.3 | 3433 | 24.25 KiB | | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=1024 group=128 dtype=bf16 M=2` | 2.40 | - | 2.39 | 2.40 | 6 | 0.3 | 3432 | 6.06 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=2304 act=relu dtype=bf16 M=4` | 2.40 | - | 2.39 | 2.40 | 6 | 0.2 | 3426 | 54.00 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=2304 act=relu dtype=bf16 M=2` | 2.40 | - | 2.39 | 2.40 | 6 | 0.1 | 3426 | 27.00 KiB | | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=8 block_size=16 kv_dtype=fp8_e4m3 M=1` | - | 2.40 | 1.91 | 2.83 | 20 | 16.7 | - | 100.00 KiB | 32 thread(s) | +| `quant_act_fp8` | `quant_act_fp8` | libr4d | `n=1024 group=128 dtype=bf16 M=1` | 2.39 | - | 2.39 | 2.40 | 6 | 0.3 | 3434 | 3.03 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=2048 act=relu dtype=bf16 M=4` | 2.39 | - | 2.39 | 2.40 | 6 | 0.2 | 3436 | 48.00 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=2048 act=relu dtype=bf16 M=1` | 2.39 | - | 2.39 | 2.40 | 6 | 0.2 | 3434 | 12.00 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=2048 act=relu dtype=bf16 M=16` | 2.39 | - | 2.39 | 2.41 | 6 | 0.3 | 3434 | 192.00 KiB | | +| `act_mul` | `act_mul_bf16` | libr4d | `n=2048 act=relu dtype=bf16 M=2` | 2.39 | - | 2.39 | 2.40 | 6 | 0.3 | 3432 | 24.00 KiB | | +| `silu` | `avx_silu` | libavx | `n=1024 dtype=bf16 M=2` | - | 2.39 | 2.38 | 2.58 | 20 | 3.4 | - | 8.00 KiB | 32 thread(s) | +| `layernorm` | `avx_layernorm` | libavx | `n=1152 eps=1e-06 dtype=bf16 M=1` | - | 2.39 | 2.32 | 2.48 | 20 | 2.3 | - | 9.00 KiB | 32 thread(s) | +| `silu` | `avx_silu` | libavx | `n=2048 dtype=bf16 M=1` | - | 2.39 | 2.38 | 2.52 | 20 | 2.1 | - | 8.00 KiB | 32 thread(s) | +| `sample_ngram_ban` | `ref_sample_ngram_ban` | libref | `n_vocab=131072 M=4` | - | 2.34 | 2.04 | 2.79 | 20 | 10.3 | - | 2.06 MiB | 32 thread(s) | +| `sample_ngram_ban` | `sample_ngram_ban_f32` | libr4d | `n_vocab=131072 M=16` | 2.32 | - | 1.03 | 3.99 | 20 | 42.4 | 3432 | 8.26 MiB | restore 91%; restore-dominated (91% of the batch): an order of magnitude | +| `gdn_gated_rmsnorm` | `avx_gdn_gated_rmsnorm` | libavx | `channels=128 eps=1e-06 act=silu M=8` | - | 2.32 | 2.28 | 2.48 | 20 | 2.2 | - | 6.50 KiB | 32 thread(s) | +| `moe_scatter` | `avx_moe_scatter` | libavx | `n_expert=304 top_k=9 expert_base=0 M=8` | - | 2.30 | 2.29 | 2.79 | 20 | 4.0 | - | 2.94 KiB | 32 thread(s) | +| `layernorm` | `avx_layernorm` | libavx | `n=1152 eps=1e-06 dtype=bf16 M=2` | - | 2.28 | 2.22 | 2.35 | 20 | 1.8 | - | 13.50 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=1024 eps=1e-06 dtype=bf16 M=4` | - | 2.24 | 2.21 | 2.33 | 20 | 2.1 | - | 18.00 KiB | 32 thread(s) | +| `iota` | `ref_iota` | libref | `start=0 step=1 M=512` | - | 2.23 | 2.14 | 2.63 | 20 | 5.4 | - | 2.00 KiB | 32 thread(s) | +| `sample_ngram_ban` | `sample_ngram_ban_f32` | libr4d | `n_vocab=131072 M=64` | 2.23 | - | 1.90 | 2.39 | 20 | 4.1 | 3429 | 33.02 MiB | restore 95%; under the launch floor (2.44 us): an order of magnitude | +| `layernorm` | `avx_layernorm` | libavx | `n=1280 eps=1e-06 dtype=bf16 M=1` | - | 2.23 | 2.08 | 2.37 | 20 | 4.6 | - | 10.00 KiB | 32 thread(s) | +| `moe_scatter` | `avx_moe_scatter` | libavx | `n_expert=304 top_k=9 expert_base=0 M=4` | - | 2.05 | 2.01 | 2.17 | 20 | 2.6 | - | 2.66 KiB | 32 thread(s) | +| `moe_scatter` | `avx_moe_scatter` | libavx | `n_expert=240 top_k=9 expert_base=0 M=8` | - | 2.01 | 1.99 | 2.24 | 20 | 4.5 | - | 2.44 KiB | 32 thread(s) | +| `attn_dense` | `ref_attn_dense` | libref | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=1` | - | 2.00 | 1.95 | 2.18 | 20 | 2.7 | - | 648 B | 32 thread(s) | +| `sample_dry` | `avx_sample_dry` | libavx | `n_vocab=248320 M=1` | - | 1.98 | 1.72 | 2.34 | 20 | 7.3 | - | 970.41 KiB | 32 thread(s) | +| `rope` | `avx_rope` | libavx | `head_dim=256 n_head=4 n_head_kv=0 theta=1e+07 scale=1 mode=imrope rotary_dim=64 sections=11 11 10 M=1` | - | 1.92 | 1.86 | 2.38 | 20 | 12.8 | - | 2.01 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=16` | - | 1.92 | 1.80 | 2.05 | 40 | 4.3 | - | 8.25 KiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=1024 group=128 dtype=bf16 M=2` | - | 1.91 | 1.90 | 2.13 | 20 | 4.9 | - | 6.06 KiB | 32 thread(s) | +| `sample_penalties` | `avx_sample_penalties` | libavx | `n_vocab=131072 M=1` | - | 1.88 | 1.65 | 2.00 | 20 | 5.8 | - | 512.34 KiB | 32 thread(s) | +| `had_quant_act_fp8` | `avx_had_quant_act_fp8` | libavx | `n=1024 group=128 dtype=bf16 M=1` | - | 1.86 | 1.83 | 2.07 | 20 | 3.7 | - | 3.03 KiB | 32 thread(s) | +| `moe_scatter` | `avx_moe_scatter` | libavx | `n_expert=304 top_k=9 expert_base=0 M=2` | - | 1.86 | 1.86 | 1.99 | 20 | 2.5 | - | 2.52 KiB | 32 thread(s) | +| `sample_dry` | `avx_sample_dry` | libavx | `n_vocab=131072 M=1` | - | 1.85 | 1.67 | 2.39 | 20 | 6.2 | - | 512.41 KiB | 32 thread(s) | +| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=4` | - | 1.85 | 1.80 | 1.98 | 20 | 1.6 | - | 2.51 KiB | 32 thread(s) | +| `rope_table` | `avx_rope_table` | libavx | `rot=64 theta=1e+07 scale=1 dtype=f32 M=2` | - | 1.82 | 1.66 | 2.20 | 20 | 13.7 | - | 520 B | 32 thread(s) | +| `rope_table` | `avx_rope_table` | libavx | `rot=64 theta=1e+07 scale=1 dtype=f32 M=1` | - | 1.80 | 1.65 | 2.13 | 20 | 9.2 | - | 260 B | 32 thread(s) | +| `moe_scatter` | `avx_moe_scatter` | libavx | `n_expert=304 top_k=9 expert_base=0 M=1` | - | 1.77 | 1.76 | 1.93 | 20 | 3.9 | - | 2.45 KiB | 32 thread(s) | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=256 n_head_kv=4 block_size=16 kv_dtype=fp8_e4m3 M=1` | - | 1.75 | 1.71 | 1.90 | 20 | 1.4 | - | 100.00 KiB | 32 thread(s) | +| `moe_scatter` | `avx_moe_scatter` | libavx | `n_expert=240 top_k=9 expert_base=0 M=4` | - | 1.70 | 1.70 | 1.86 | 14 | 0.2 | - | 2.16 KiB | 32 thread(s) | +| `sample_ngram_ban` | `ref_sample_ngram_ban` | libref | `n_vocab=131072 M=1` | - | 1.69 | 1.61 | 1.82 | 20 | 2.4 | - | 528.35 KiB | 32 thread(s) | +| `sample_penalties` | `avx_sample_penalties` | libavx | `n_vocab=248320 M=1` | - | 1.65 | 1.49 | 1.77 | 20 | 3.0 | - | 970.34 KiB | 32 thread(s) | +| `sample_ngram_ban` | `ref_sample_ngram_ban` | libref | `n_vocab=131072 M=2` | - | 1.63 | 1.58 | 1.80 | 20 | 5.5 | - | 1.03 MiB | 32 thread(s) | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=2` | - | 1.63 | 1.53 | 1.85 | 20 | 4.6 | - | 50.01 KiB | 32 thread(s) | +| `iota` | `ref_iota` | libref | `start=0 step=1 M=256` | - | 1.63 | 1.51 | 2.07 | 20 | 11.2 | - | 1.00 KiB | 32 thread(s) | +| `rmsnorm` | `ref_rmsnorm` | libref | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=1` | - | 1.61 | 1.60 | 1.71 | 20 | 2.2 | - | 768 B | 32 thread(s) | +| `silu` | `avx_silu` | libavx | `n=1024 dtype=bf16 M=1` | - | 1.57 | 1.34 | 1.66 | 20 | 5.8 | - | 4.00 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=1024 eps=1e-05 dtype=bf16 M=2` | - | 1.56 | 1.52 | 1.71 | 20 | 4.6 | - | 8.00 KiB | 32 thread(s) | +| `moe_scatter` | `avx_moe_scatter` | libavx | `n_expert=240 top_k=9 expert_base=0 M=2` | - | 1.55 | 1.54 | 1.71 | 20 | 4.7 | - | 2.02 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=8` | - | 1.54 | 1.46 | 1.62 | 20 | 3.7 | - | 8.50 KiB | 32 thread(s) | +| `cast` | `avx_cast` | libavx | `n=4096 from=bf16 to=bf16 M=1` | - | 1.53 | 1.46 | 1.62 | 20 | 3.5 | - | 16.00 KiB | 32 thread(s) | +| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=2` | - | 1.48 | 1.42 | 1.63 | 20 | 2.9 | - | 1.13 KiB | 32 thread(s) | +| `iota` | `ref_iota` | libref | `start=0 step=1 M=64` | - | 1.48 | 1.08 | 1.68 | 20 | 11.6 | - | 256 B | 32 thread(s) | +| `moe_scatter` | `avx_moe_scatter` | libavx | `n_expert=240 top_k=9 expert_base=0 M=1` | - | 1.46 | 1.46 | 1.66 | 20 | 2.9 | - | 1.95 KiB | 32 thread(s) | +| `iota` | `avx_iota` | libavx | `start=0 step=1 M=512` | - | 1.45 | 1.34 | 1.76 | 20 | 10.8 | - | 2.00 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=1024 eps=1e-06 dtype=bf16 M=2` | - | 1.43 | 1.39 | 1.49 | 20 | 2.4 | - | 10.00 KiB | 32 thread(s) | +| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=1024 M=8` | - | 1.43 | 1.30 | 1.98 | 40 | 9.8 | - | 32.75 KiB | 32 thread(s) | +| `gdn_gated_rmsnorm` | `avx_gdn_gated_rmsnorm` | libavx | `channels=128 eps=1e-06 act=silu M=4` | - | 1.33 | 1.29 | 1.37 | 20 | 2.3 | - | 3.50 KiB | 32 thread(s) | +| `iota` | `ref_iota` | libref | `start=0 step=1 M=128` | - | 1.21 | 1.15 | 1.40 | 20 | 5.5 | - | 512 B | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=8` | - | 1.20 | 1.09 | 1.63 | 40 | 4.0 | - | 4.25 KiB | 32 thread(s) | +| `kv_store` | `avx_kv_store` | libavx | `head_dim=128 n_head_kv=2 block_size=16 kv_dtype=bf16 M=1` | - | 1.15 | 1.07 | 1.22 | 20 | 3.5 | - | 49.00 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=1024 eps=1e-05 dtype=bf16 M=1` | - | 1.13 | 1.08 | 1.24 | 20 | 2.9 | - | 4.00 KiB | 32 thread(s) | +| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=72 gqa=1 causal=0 dtype=bf16 scale=0.117851 max_seqlen=2048 M=1` | - | 1.11 | 1.09 | 1.19 | 20 | 3.2 | - | 584 B | 32 thread(s) | +| `sample_ngram_ban` | `avx_sample_ngram_ban` | libavx | `n_vocab=131072 M=1` | - | 1.10 | 1.05 | 1.19 | 20 | 5.4 | - | 528.35 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=4` | - | 1.10 | 1.01 | 1.30 | 20 | 6.7 | - | 4.50 KiB | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=1280 dtype=bf16 M=8` | - | 1.08 | 1.06 | 17.34 | 16 | 0.6 | - | 100.03 KiB | 32 thread(s) | +| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=2` | - | 1.06 | 1.02 | 1.09 | 20 | 2.7 | - | 2.37 GiB | 32 thread(s) | +| `quant_act_fp8` | `avx_quant_act_fp8` | libavx | `n=1024 group=128 dtype=bf16 M=1` | - | 1.06 | 1.03 | 1.18 | 20 | 3.1 | - | 3.03 KiB | 32 thread(s) | +| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=2` | - | 1.01 | 0.97 | 1.21 | 20 | 5.2 | - | 1.26 KiB | 32 thread(s) | +| `scatter_rows` | `avx_scatter_rows` | libavx | `n=5120 dtype=bf16 M=1` | - | 1.00 | 0.95 | 1.16 | 20 | 8.0 | - | 50.00 KiB | 32 thread(s) | +| `iota` | `ref_iota` | libref | `start=0 step=1 M=32` | - | 0.99 | 0.94 | 1.57 | 20 | 13.7 | - | 128 B | 32 thread(s) | +| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=2` | - | 0.95 | 0.79 | 1.03 | 20 | 6.9 | - | 1.00 GiB | 32 thread(s) | +| `gdn_gated_rmsnorm` | `avx_gdn_gated_rmsnorm` | libavx | `channels=128 eps=1e-06 act=silu M=2` | - | 0.94 | 0.91 | 1.03 | 20 | 4.7 | - | 2.00 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=1024 eps=1e-06 dtype=bf16 M=1` | - | 0.94 | 0.92 | 1.02 | 20 | 4.3 | - | 6.00 KiB | 32 thread(s) | +| `iota` | `ref_iota` | libref | `start=0 step=1 M=16` | - | 0.91 | 0.88 | 0.99 | 20 | 4.7 | - | 64 B | 32 thread(s) | +| `scatter_rows` | `avx_scatter_rows` | libavx | `n=5120 dtype=bf16 M=2` | - | 0.91 | 0.86 | 1.01 | 20 | 6.6 | - | 100.01 KiB | 32 thread(s) | +| `iota` | `ref_iota` | libref | `start=0 step=1 M=4` | - | 0.90 | 0.86 | 0.97 | 20 | 4.5 | - | 16 B | 32 thread(s) | +| `iota` | `ref_iota` | libref | `start=0 step=1 M=8` | - | 0.88 | 0.86 | 1.02 | 20 | 8.4 | - | 32 B | 32 thread(s) | +| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=1024 M=4` | - | 0.87 | 0.78 | 1.02 | 40 | 5.2 | - | 16.38 KiB | 32 thread(s) | +| `iota` | `ref_iota` | libref | `start=0 step=1 M=2` | - | 0.86 | 0.83 | 1.03 | 20 | 7.4 | - | 8 B | 32 thread(s) | +| `attn_dense` | `avx_attn_dense` | libavx | `head_dim=80 gqa=1 causal=0 dtype=bf16 scale=0.111803 max_seqlen=2048 M=1` | - | 0.81 | 0.74 | 1.07 | 20 | 17.0 | - | 648 B | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=1280 dtype=bf16 M=4` | - | 0.79 | 0.77 | 8.55 | 20 | 14.2 | - | 50.02 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=2` | - | 0.79 | 0.76 | 0.85 | 20 | 2.1 | - | 2.50 KiB | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=1280 dtype=bf16 M=2` | - | 0.78 | 0.75 | 0.89 | 20 | 3.9 | - | 25.01 KiB | 32 thread(s) | +| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=1024 M=2` | - | 0.78 | 0.62 | 0.82 | 40 | 2.6 | - | 8.19 KiB | 32 thread(s) | +| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=4096 n_vocab=131072 dtype=bf16 vocab_offset=0 M=1` | - | 0.77 | 0.65 | 0.84 | 20 | 6.4 | - | 1.00 GiB | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=5120 dtype=bf16 M=2` | - | 0.77 | 0.76 | 0.80 | 20 | 1.9 | - | 100.01 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=4` | - | 0.76 | 0.72 | 0.85 | 40 | 5.0 | - | 2.25 KiB | 32 thread(s) | +| `scatter_rows` | `avx_scatter_rows` | libavx | `n=4096 dtype=bf16 M=2` | - | 0.73 | 0.70 | 1.08 | 20 | 6.2 | - | 80.01 KiB | 32 thread(s) | +| `iota` | `avx_iota` | libavx | `start=0 step=1 M=256` | - | 0.70 | 0.67 | 0.96 | 20 | 6.4 | - | 1.00 KiB | 32 thread(s) | +| `gdn_gated_rmsnorm` | `avx_gdn_gated_rmsnorm` | libavx | `channels=128 eps=1e-06 act=silu M=1` | - | 0.68 | 0.64 | 0.74 | 20 | 4.9 | - | 1.25 KiB | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=4096 dtype=bf16 M=2` | - | 0.65 | 0.64 | 0.71 | 20 | 3.3 | - | 80.01 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=2` | - | 0.61 | 0.54 | 0.68 | 40 | 6.1 | - | 1.25 KiB | 32 thread(s) | +| `scatter_rows` | `avx_scatter_rows` | libavx | `n=4096 dtype=bf16 M=1` | - | 0.60 | 0.58 | 0.73 | 20 | 9.1 | - | 40.00 KiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=256 eps=1e-06 wadd=1 dtype=bf16 M=1` | - | 0.55 | 0.52 | 0.62 | 20 | 4.8 | - | 1.50 KiB | 32 thread(s) | +| `sample_temp` | `avx_sample_temp` | libavx | `n_vocab=1024 M=1` | - | 0.51 | 0.46 | 0.91 | 40 | 11.8 | - | 4.09 KiB | 32 thread(s) | +| `embed_lookup` | `avx_embed_lookup` | libavx | `n_embd=5120 n_vocab=248320 dtype=bf16 vocab_offset=0 M=1` | - | 0.50 | 0.48 | 0.53 | 20 | 3.5 | - | 2.37 GiB | 32 thread(s) | +| `rmsnorm` | `avx_rmsnorm` | libavx | `n=128 eps=1e-06 wadd=0 dtype=bf16 M=1` | - | 0.49 | 0.45 | 0.52 | 40 | 3.3 | - | 768 B | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=1280 dtype=bf16 M=1` | - | 0.46 | 0.46 | 0.51 | 20 | 3.5 | - | 12.50 KiB | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=5120 dtype=bf16 M=1` | - | 0.45 | 0.43 | 0.48 | 20 | 3.1 | - | 50.00 KiB | 32 thread(s) | +| `gather_rows` | `avx_gather_rows` | libavx | `n=4096 dtype=bf16 M=1` | - | 0.41 | 0.39 | 0.46 | 20 | 2.2 | - | 40.00 KiB | 32 thread(s) | +| `iota` | `avx_iota` | libavx | `start=0 step=1 M=128` | - | 0.38 | 0.37 | 0.44 | 20 | 5.0 | - | 512 B | 32 thread(s) | +| `iota` | `avx_iota` | libavx | `start=0 step=1 M=64` | - | 0.24 | 0.20 | 0.33 | 20 | 20.0 | - | 256 B | 32 thread(s) | +| `iota` | `avx_iota` | libavx | `start=0 step=1 M=32` | - | 0.14 | 0.13 | 0.15 | 20 | 6.2 | - | 128 B | 32 thread(s) | +| `iota` | `avx_iota` | libavx | `start=0 step=1 M=16` | - | 0.08 | 0.08 | 0.09 | 20 | 3.7 | - | 64 B | 32 thread(s) | +| `iota` | `avx_iota` | libavx | `start=0 step=1 M=8` | - | 0.07 | 0.06 | 0.07 | 20 | 5.2 | - | 32 B | 32 thread(s) | +| `iota` | `avx_iota` | libavx | `start=0 step=1 M=4` | - | 0.06 | 0.05 | 0.07 | 20 | 11.3 | - | 16 B | 32 thread(s) | +| `iota` | `avx_iota` | libavx | `start=0 step=1 M=2` | - | 0.04 | 0.04 | 0.06 | 20 | 11.6 | - | 8 B | 32 thread(s) | ## Memory safety @@ -4332,7 +11364,7 @@ AMD's amdgcn AddressSanitizer (`/opt/rocm/amdgcn/bitcode/asanrtl.bc`) needs `xna page-fault-based shadow, which RDNA does not implement (`rocminfo` reports `XNACK enabled: NO`), so the margins stand in for it. -- 734 case(s) ran inside guarded allocations +- 1743 case(s) ran inside guarded allocations - 0 wrote outside one ## Not covered @@ -4347,52 +11379,6 @@ hangs. They appear in the completeness matrix but carry no correctness or speed | what | cases | |---|---| | logit_rerank (one case needs 14.21 GiB, over the 8.00 GiB budget -- raise --max-bytes to check it) | 7 | - -## Static and dynamic analysis - -Advisory, and generated separately from the measurements above: -`tools/kbench-analysis.sh` runs on a machine that need not have a GPU. - -### clang-tidy - -`bugprone-*`, `clang-analyzer-*` and `performance-*` over every host translation unit -(`libref/`, `core/`, `tools/`). HIP units are excluded: clang-tidy cannot replay the -offload flags and reports `__device__` as an error rather than analysing the body. - -- 358 distinct warning(s) - -| check | count | -|---|---| -| `[bugprone-unchecked-string-to-number-conversion]` | 60 | -| `[bugprone-assignment-in-if-condition]` | 56 | -| `[bugprone-implicit-widening-of-multiplication-result]` | 34 | -| `[performance-inefficient-string-concatenation]` | 31 | -| `[bugprone-suspicious-string-compare]` | 16 | -| `[performance-no-int-to-ptr]` | 15 | -| `[performance-inefficient-vector-operation]` | 14 | -| `[bugprone-misplaced-widening-cast]` | 13 | -| `[bugprone-incorrect-roundings]` | 11 | -| `[bugprone-signed-char-misuse]` | 9 | -| `[bugprone-multi-level-implicit-pointer-conversion]` | 9 | -| `[bugprone-branch-clone]` | 8 | -| `[performance-unnecessary-value-param]` | 6 | -| `[bugprone-switch-missing-default-case]` | 6 | -| `[bugprone-throwing-static-initialization]` | 5 | -| `[bugprone-reserved-identifier]` | 3 | -| `[performance-unnecessary-copy-initialization]` | 2 | -| `[bugprone-return-const-ref-from-parameter]` | 2 | -| `[bugprone-integer-division]` | 2 | -| `[bugprone-exception-escape]` | 2 | -| `[bugprone-empty-catch]` | 2 | -| `[performance-no-automatic-move]` | 1 | -| `[bugprone-random-generator-seed]` | 1 | -| `[bugprone-not-null-terminated-result]` | 1 | -| `[bugprone-forward-declaration-namespace]` | 1 | - -### AddressSanitizer + UndefinedBehaviorSanitizer - -A sanitised replay of the whole fixture. Host code only -- see the note in the -**Memory safety** section for why the device side cannot be sanitised on this card. - -- 0 report(s) - +| vacuous: iota (libavx/avx_iota) | 1 | +| vacuous: iota (libr4d/iota) | 1 | +| vacuous: iota (libref/ref_iota) | 1 | diff --git a/docs/OPS.md b/docs/OPS.md index 6bd7dd8e..9ddd9f69 100644 --- a/docs/OPS.md +++ b/docs/OPS.md @@ -205,10 +205,12 @@ at once. Run it before adding a kernel plugin; the loader names only the first c | `layernorm` | `M`(range) `n` `eps`:f64 `dtype` | `x`, `w`w, `b`w? → `y` | | `grid_embed` | `M`(range) `n` `side` `dtype` | `x`:inout, `table`w, `coord` | | `grid_embed_aa` | `M`(range) `n` `side` `dtype` | `x`:inout, `table`w, `coord` | +| `grid_embed_cpe` | `M`(range) `n` `side` `dtype` `n_prefix`/opt | `x`:inout, `table`w, `coord`, `prefix`w? | | `add` | `M`(range) `n` `dtype` `div`:f64/opt | `a`, `b` → `y` | | `mul` | `M`(range) `n` `dtype` | `a`, `b` → `y` | | `silu_mul` | `M`(range) `n` `dtype` | `gate_up` → `y` (splits `[M,2n]` into gate·up) | | `swiglu_clamped` | `M`(range) `n` `limit`:f64 `dtype` | `gate_up` → `y` | +| `swiglu_step` | `M`(range) `n` `limit`:f64 `dtype` | `gate_up` → `y` | | `mul_weight` | `M`(range) `n` `dtype` `scalar`/opt | `x`, `w`w → `y` (w one element or one row) | | `act_mul` | `M`(range) `n` `act` `dtype` | `a`, `b` → `y` (act(a)·b, two operands) | | `seg_mean` | `M`(range) `n` `dtype` | `x`, `cu_seqlens` → `y` (one mean row a segment) | @@ -266,6 +268,13 @@ clip. libr4d's `swiglu_clamped_bf16` serves bf16 in and out at any width, pitched rows, `M` up to 65535. +`swiglu_step` clips in the other order, as Ling-3.0 is served by vLLM and SGLang (vLLM's +`SwigluStepAndMul`): `min(silu(gate), limit) * clamp(up, -limit, limit)` in f32, rounded once. The +SiLU is taken first and its value clipped above, so a gate far past `limit` gives exactly `limit` +where `swiglu_clamped` gives `silu(limit)` (3.93 at a limit of 4). HF's reference model for Ling-3.0 +ignores the clamp; the served form is the one checkpoints are evaluated with. +libr4d's `swiglu_step_bf16` serves it as `swiglu_clamped_bf16` does. + **`add` and `mul`** broadcast a `b` of exactly `n` elements along the rows of a taller output (a bias add). Nothing else broadcasts, in these or any other elementwise op. `add`'s `div` divides the sum after its rounding, `y = rd(rd(a + b) / div)` with `rd` `y`'s dtype (absent, 1: the plain @@ -285,9 +294,10 @@ weight. **`act_mul`** is `silu_mul` with its halves in two operands, so the multiplier can be any tensor: two column slices of a fused `gate_up`, or a gate and a separate per-layer input (EmbeddingGemma 2's per-layer-embedding block multiplies `gelu_tanh(gate(x))` by one). `act` is `silu`, `gelu` (exact -erf), `gelu_tanh`, `sigmoid` (a GLU: `a` the gate half, `b` the value half) or `quick_gelu` -(`sigmoid` of the bf16-rounded `1.702 a`, the CLIP tower's fused form). The activation is -rounded to `y`'s dtype before the product, as the unfused pair stores it. +erf), `gelu_tanh`, `sigmoid` (a GLU: `a` the gate half, `b` the value half), `quick_gelu` +(`sigmoid` of the bf16-rounded `1.702 a`, the CLIP tower's fused form) or `relu`, which over one +tensor in both operands is `relu(x)²` (Nemotron-H's ungated experts). The activation is rounded +to `y`'s dtype before the product, as the unfused pair stores it. **`seg_mean`** is mean pooling over a ragged batch: row `s` of `y` is the mean of `x`'s rows `[cu[s], cu[s+1])`, summed in double and rounded once. `M` is the step's token count and bands the @@ -333,6 +343,14 @@ half-pixel centres, widened by the scale when the grid is smaller than the table normalised to sum to one; separable, f32, rounded once. A different function from `grid_embed`'s, so a different op rather than a mode a library could ignore. +**`grid_embed_cpe`** is RADIO's cropped position embedding: the table resampled with +`F.interpolate(mode="bilinear", align_corners=False)` and no antialias onto a square whose side is +the grid's larger one, of which the grid keeps the top-left `h x w`. Per axis two taps at +`(i + 0.5) * side / d - 0.5`, clamped at 0 and into the table, blended along the row first as torch's +kernel does; f32, rounded once before the add. A row whose row coordinate is negative is one of +`n_prefix` learned rows a segment carries ahead of its patches (RADIO's class and register tokens), +the column naming which: it gets `prefix[k]` instead. + ### Hyper-connections `hc_project` is the control vector's projection (core/cvec.h): `h[s] -= scale * (h[s] . v) * v` @@ -499,6 +517,20 @@ depth, the position its token takes once its path is committed. Causal layers on `attn_paged_tree`; libr4d `attn_paged_qrow_tree` at h256/gqa2 on the split-KV decode kernel and at every geometry of the windowed kernels, to 64 rows a block. +| op | params | operands | +|---|---|---| +| `attn_paged_ahead` | `q_len`(range) `head_dim` `gqa` `block_size`/der `causal` `window` `q_dtype` `kv_dtype` `scale`:f64/opt `max_ctx`/opt `n_head`/opt `max_seqs`/opt `prefill_fp8`/opt | `q`, `kv_cache`, `block_table`, `seqused`, `k_descale`?, `v_descale`?, `cu_seqlens`? → `out` | +| `attn_paged_qrow_ahead` | `q_len`(range) `head_dim` `gqa` `block_size`/der `causal` `window` `q_dtype` `kv_dtype` `scale`:f64/opt `max_ctx`/opt `n_head`/opt `max_seqs`/opt `prefill_fp8`/opt | `q`, `kv_cache`, `block_table`, `seqused`, `k_descale`?, `v_descale`?, `cu_seqlens`? → `out` | + +`attn_paged_ahead` is `attn_paged` at `causal` 0 with a window that bounds the keys behind a row +only: key `j` is visible to row `i` when `i - j < window` and `j < seqused`, so every key after the +row is. `attn_paged` reads a non-causal window two-sided (`|i - j| < window`). Gemma 4's sliding +layers read a picture's rows this way (transformers' mask is the window AND (causal OR the same +picture)), and the two differ only for a picture longer than the window. `window` is at least 1. +`attn_paged_qrow_ahead` is the same with `q` at its own row pitch, as `attn_paged_qrow`. libr4d +serves both at h256, 1 to 8 queries per kv head, on the windowed kernels; no other library +declares them, so a plugin asking for them learns whether a card serves the geometry. + Of the ops above, libref serves only `attn_paged_tree`, which is not a fusion but `attn_paged`'s tree form. It has no row for any of the fusions, deliberately. An architecture asks for a fusion and declares the chain where it does not resolve (`rad_op_resolved`); a reference row would make it resolve @@ -927,6 +959,8 @@ as the weight's GEMM stored them and claims no form. It changes no value. | op | params | operands | |---|---|---| | `attn_paged` | `q_len`(range) `head_dim` `gqa` `block_size`/der `causal` `window` `q_dtype` `kv_dtype` `scale`:f64/opt `max_ctx`/opt `n_head`/opt `max_seqs`/opt `prefill_fp8`/opt | `q`, `kv_cache`, `block_table`, `seqused`, `k_descale`?, `v_descale`?, `cu_seqlens`? → `out` | +| `attn_paged_anchor_window` | same parameters as `attn_paged` | same operands as `attn_paged` → `out` | +| `attn_paged_sink` | `q_len`(range) `head_dim` `gqa` `block_size`/der `causal` `window` `q_dtype` `kv_dtype` `scale`:f64/opt `max_ctx`/opt `n_head`/opt `max_seqs`/opt `prefill_fp8`/opt | `q`, `kv_cache`, `block_table`, `seqused`, `k_descale`?, `v_descale`?, `cu_seqlens`?, `sinks`w → `out` | | `attn_dense` | `M`(range) `head_dim` `gqa` `causal` `dtype` `scale`:f64/opt `max_seqlen`/opt `window`/opt `cu_div`/opt `block`/opt `window_right`/opt | `q`, `k`, `v`, `cu_seqlens` → `out` | | `attn_cross` | `M`(range) `head_dim` `gqa` `causal` `dtype` `scale`:f64/opt | `q`, `k`, `v`, `cu_seqlens`, `cu_k` → `out` | | `attn_na3d` | `M`(range) `head_dim` `kt` `kh` `kw` `dtype` `scale`:f64/opt | `q`, `k`, `v`, `geom` → `out` | @@ -945,8 +979,18 @@ as the weight's GEMM stored them and claims no form. It changes no value. | `qkv_norm_rope` | `M`(range) `head_dim` `n_head` `n_head_kv` `theta`:f64 `eps`:f64 `scale`:f64/opt `mode`/opt `rotary_dim`/opt `ladder`/opt `wadd`:f64/opt `v_from_k`/opt `v_norm`/opt `dtype` | `q`:inout, `k`:inout, `v`:inout, `positions`, `q_w`w, `k_w`w | | `qkv_norm_rope_kv_store` | `M`(range) `head_dim` `n_head` `n_head_kv` `theta`:f64 `eps`:f64 `scale`:f64/opt `mode`/opt `rotary_dim`/opt `ladder`/opt `wadd`:f64/opt `v_from_k`/opt `dtype` `v_norm`/opt `block_size` `kv_dtype` `k_scale`:f64/opt `v_scale`:f64/opt | `q`:inout, `k`:inout, `v`:inout, `positions`, `q_w`w, `k_w`w, `slot_mapping`, `kv_cache`:inout | +**`attn_paged_sink`** is `attn_paged` with a learned logit a query head beside the keys: `sinks` +`[n_head]` f32, in the scaled-score domain, joins each row's softmax maximum and denominator and +carries no value, so `out = Σ_j p_j v_j` with `p_j = exp(s_j) / (Σ_k exp(s_k) + exp(sink))`. A row +with no visible key stays zero. It has its own name so that no `attn_paged` kernel which does not +know the operand can be chosen for it (LiLiCorr's drafter, and gpt-oss's sinks have the same form). + **`attn_paged`**'s band is `q_len`, not `M`: one query row at decode, `1 + n_spec` at a speculative verify, thousands in a prefill chunk, and libr4d has a different kernel for each band. +`attn_paged_anchor_window` has the same layout but different visibility: the first query position +in each sequence is the shared anchor for every query row, with the lower-bound predicate +`anchor - key < window`; causal mode additionally masks keys after the anchor. It is a distinct op +name so an older plugin cannot silently interpret this as per-query `attn_paged`. `block_size` is read off the resolved kernel, not chosen: declare the group, declare the op, then ask `rad_kv_block_size()` (`spec.md` §7.2). @@ -1908,6 +1952,24 @@ over its encoded rows after the VAE encoder's fold. The weight is a declared con rows at a time, so each item's draws start at `e = 0`. MiniMax-H3: `n` 96, `stream` 2, `aug` 0.999. +## Shape generation + +The op a shape generator (Hunyuan3D-2, `rad_declare_shape_generator`) needs beyond an image +generator's: the embedding of the points its geometry decoder is queried at. Its encoder, denoiser +and decoder are otherwise built of the image and video generators' ops (`rms_mod` `norm` layer, +`gate_add` `act` none, `flow_euler`, `attn_cross`). + +| op | params | operands | +|---|---|---| +| `point_fourier` | `M`(range) `n` `freqs` `pi`/opt `dtype` | `x` → `y` | + +- `point_fourier`: row m of `y` is `[x | sin(x_i f_j) | cos(x_i f_j)]` over `x`'s `n` values, the + sines and then the cosines each `i`-major then `j`, with `f_j = 2^j` for `j < freqs` (times pi + with `pi` 1), so `y` is `[M, n (2 freqs + 1)]`: the shape VAE's FourierEmbedder with its input + included. The products are f32 (exact without pi, a power of two), the sine and cosine f32 and + rounded once to `y`'s dtype. `freqs` is at most 30. libr4d's `point_fourier_f32` serves f32 in + and out with the device's `sinf` and `cosf`. + ## LTX-2 The ops LTX-2's audio-video transformer adds (`libref/ref_ltx.cpp`): its rotary over fractional @@ -2044,6 +2106,7 @@ The VAEs' convolutions are `conv3d_ndhwc` with `tpad` and the audio VAE's `conv2 | `router_gemm_topk_scatter` | `M`(range) `K` `n_expert` `n_local`/opt `top_k` `norm` `dtype` `expert_base`/opt `protect`:str/opt | `a`, `b`w, `gate_b`w? → `logits`, `expert_ids`, `expert_w`, `sorted_tok`, `expert_offset`, `expert_count`, `gate`? | | `moe_gemm` | `M`(range) `N` `K` `n_expert` `top_k` `a_order` `dtype` | `a`, `w`wt, `sorted_tok`, `expert_offset` → `y` | | `router_sigmoid_topk` | `M`(range) `n_expert` `top_k` `norm` `route_scale`:f64 `dtype` | `logits`, `bias`w → `ids`, `weights` | +| `router_sigmoid_group_topk` | `M`(range) `n_expert` `top_k` `n_group` `topk_group` `norm` `route_scale`:f64 `dtype` | `logits`, `bias`w → `ids`, `weights` | | `router_sigmoid_topk_scatter` | `M`(range) `n_expert` `n_local`/opt `top_k` `norm` `route_scale`:f64 `dtype` `expert_base`/opt `protect`:str/opt | `logits`, `bias`w → `ids`, `weights`, `sorted_tok`, `expert_offset`, `expert_count`, `gate`?, `inverse`? | | `moe_scatter_inv` | `M`(range) `n_expert` `top_k` `expert_base`/opt `protect`:str/opt | `expert_ids` → `sorted_tok`, `expert_offset`, `expert_count`, `inverse` | | `moe_gather_inv` | `M`(range) `n` `top_k` `dtype` `act`:str/opt | `y_expert`, `expert_w`, `inverse`, `shared`?, `shared_gate`? → `y` | @@ -2173,8 +2236,8 @@ expert, and the weights are the selected `p`, never the biased ranks. With `norm `p * (route_scale / (sum + 1e-20))` over the row's selected `p`, with `norm` 0 `p * route_scale`; `route_scale` is positive and finite. A rank that is NaN or `-inf` is never selected, and a row with fewer than `top_k` selectable experts has no defined selection (libref refuses it). -Grouped selection (`n_group > 1`) is not this op. GLM-5.3 routes 8 of 288 experts in one group -with `route_scale` 2.5. +Grouped selection (`n_group > 1`) is `router_sigmoid_group_topk`, below. GLM-5.3 routes 8 of 288 +experts in one group with `route_scale` 2.5. libr4d's `router_sigmoid_topk_f32` takes up to 512 experts and `top_k` up to 32, f32 logits, bias and weights, i32 ids, pitched rows, `M` up to 65535. It selects in one wave per row: each lane @@ -2183,6 +2246,16 @@ takes the largest key below round `j-1`'s winner. A row without NaN ranks gives serial scan with a strict `>`. A NaN rank is never selected, and a row with fewer than `top_k` other ranks names expert 0 in its empty slots, weighted by expert 0's `p`. +**`router_sigmoid_group_topk`** is the group-limited form (DeepSeek-V3's `noaux_tc` with +`n_group > 1`, Ling-3.0's 8 groups of 64 experts, 4 kept). The experts fall into `n_group` equal +groups of at least two; a group's rank is the sum of its two largest `p + bias`; the `topk_group` +best groups are kept, ties to the lower group; the selection is `router_sigmoid_topk`'s over the +kept groups' experts only, and the weights are the same. `top_k` is at most the kept experts. + +libr4d's `router_sigmoid_group_topk_f32` is `router_sigmoid_topk_f32`'s wave with the groups ranked +first, a lane a group: up to 512 experts in up to 32 groups, `top_k` up to 32, pitched rows, `M` up +to 65535. + **`router_sigmoid_topk_scatter`** (device-only) is `router_sigmoid_topk` and `moe_scatter` over its `ids` in one launch, and with `gate` `[M, 1]` also the `fill` of an ungated shared arm's gate with 1 (GLM-5.3's shared expert has no gate, and the gather reads one). `n_expert`, `n_local`, @@ -2294,6 +2367,7 @@ wrong. | op | params | operands | |---|---|---| | `kda_update` | `M`(range) `heads` `head_k` `head_v` `lower_bound`:f64 `scale`:f64 `l2_eps`:f64 `mode` `dtype` `state_form`/opt | `q`, `k`, `v`, `a`, `b`, `A_log`w, `dt_bias`w, `state`:inout, `state_idx`, `cu`, `num_accepted`?, `has_init`? → `o` | +| `ssd_update` | `M`(range) `heads` `head_dim` `d_state` `groups` `mode` `dtype` `state_form`/opt | `x`, `B`, `C`, `dt`, `A_log`w, `dt_bias`w, `D`w, `state`:inout, `state_idx`, `cu`, `num_accepted`?, `has_init`? → `o` | | `gdn_conv_prep` | `M`(range) `head_k` `head_v` `chunk`/der `conv_width` `l2_eps`:f64/opt `softplus_thr`:f64/opt | `x`, `w`w, `b`w?, `A_log`w, `dt_bias`w, `conv_state`:inout, `cu`, `a`?, `b_gate`?, `cache_idx`?, `has_init`? → `q`,`k`,`v`,`g`,`beta` | | `gdn_conv_update` | `q_len`(range) `head_k` `head_v` `conv_width` `max_query_len`/opt | `x`, `w`w, `b`w?, `conv_state`:inout, `state_idx`, `num_accepted`, `cu` → `q`,`k`,`v` | | `gdn_kkt_solve` | `M`(range) `head_k` `chunk`/der | `k`, `beta`, `g`, `cu` → `A` | @@ -2336,6 +2410,26 @@ Under `anchor`, `verify` replays the accepted prefix in a separate dispatch befo no value row overwrites factors another is still reading. A sequence whose window or slots are out of bounds is skipped on the device, not refused. +**`ssd_update` is Mamba-2's selective state update** (the SSD recurrence, token by token). Per token +and head `h`, with `g = h / (heads / groups)` the head's B/C group: + + dt' = softplus(dt[h] + dt_bias[h]) A = -exp(A_log[h]) + S = e^{dt' A} S + dt' x[h] B[g]^T o[h] = S C[g] + D[h] x[h] + +It is a delta-net head without the delta: one scalar decay per head and token, no beta and no l2 +norm on B or C, and the skip term `D`, so the gdn ops cannot run it. dt is not clamped: the +checkpoints carry `time_step_limit = (0, inf)`, which mamba_ssm's kernels and vLLM pass, while +transformers' CPU fallback clamps at `time_step_min`, which on a real prompt binds for about one +(token, head) pair in eight. softplus is the identity above 20, as in torch and mamba_ssm. +`state` is f32 `[slots, heads, head_dim, d_state]`; `x` and `o` may be `[M, heads, head_dim]` or +flat, `B` and `C` `[M, groups, d_state]` or flat, `dt` one value per (token, head). Heads read their +group in blocks (heads `0 .. heads/groups - 1` read group 0), the mamba_ssm convention, not +round-robin. `o` excludes the model's gated norm. The rollback contract is `kda_update`'s, in both +forms. Under `anchor` the scratch holds, per head, the replay count and one record per window token: +the decay `e^{dt' A}`, `u = dt' x` (`head_dim`) and `B` (`d_state`), as many as the +`[head_dim, d_state]` block holds and at most 32 (a 64 x 128 head holds 42). The replay applies a +record with the window's own update, so the committed state is the per-candidate one bit for bit. + **Speculative rollback is part of the schema** (`spec.md` §10). The recurrent state and the conv window have already absorbed rejected tokens, so the state cache is a rolling window of `conv_width-1 + n_spec` entries read at the slot the last accepted token left, and a rejection is a @@ -2529,6 +2623,7 @@ whole form elsewhere (the host mailbox included), which keeps every promise `sp` | `ngram_ids` | `M`(range) `heads` `ngram` `eos` | `tok`, `state`:inout, `cu`, `mult`w, `vocab_sizes`w, `offsets`w, `cache_idx`?, `has_init`?, `num_accepted`? → `ids`, `ahead_ids`? | | `ple_gate` | `M`(range) `n` `hc` `eps`:f64 `dtype` `wadd`:f64/opt `gate_eps`:f64/opt | `k`, `q`, `v`, `w_key`w, `w_query`w, `w_conv`w → `gv`, `gvn` | | `ple_conv` | `M`(range) `n` `width` `dilation` `dtype` | `x`, `w`w, `conv_state`:inout, `cu`, `resid`?, `cache_idx`?, `has_init`?, `num_accepted`? → `y` | +| `ple_conv_bias` | `M`(range) `n` `width` `dilation` `dtype` | `x`, `w`w, `conv_state`:inout, `cu`, `resid`?, `cache_idx`?, `has_init`?, `num_accepted`?, `b`w → `y` | | `causal_conv1d` | `M`(range) `n` `width` `dtype` | `x`, `w`w, `conv_state`:inout, `cu`, `cache_idx`?, `has_init`?, `num_accepted`? → `y` | `logits_gemm` is separate from `gemm_nt` because `lm_head` is its own access class @@ -2760,6 +2855,15 @@ prefill's question and `num_accepted` decode's. The residual add is folded in because the reference is `gv + silu(conv(gvn))` and both tensors are `[M, hc*n]`. `resid` absent leaves the plain convolution. +### `ple_conv_bias` + + y[t] = resid[t] + silu( b[c] + sum_j w[c][j] * x[t - (width-1-j)*dilation] ) + +`ple_conv` with `b`, a per-channel bias inside the activation, before `y`. At dilation one with no +`resid` it is Mamba-2's `conv1d` over its `[x | B | C]` channels, so the Mamba block keeps the +window and rollback contract above. It is an op of its own, as `attn_paged_sink` is beside +`attn_paged`, so the architectures that issue `ple_conv` keep their operand list. + ### `causal_conv1d` y[t] = sum_j w[c][j] * x[t - (width-1-j)] @@ -2793,7 +2897,7 @@ resolutions of one op. The one exception is `sample_chain` (below). | `sample_pick` | `M`(range) `n_cand` | `cand_idx`, `cand_val`, `params` → `token` | | `sample_argmax` | `M`(range) `n_vocab` | `logits`, `params` → `token` | | `sample_merge_topk` | `M`(range) `n_cand` | `gathered`, `params` → `cand_idx`, `cand_val` | -| `sample_logprobs` | `M`(range) `n_vocab` `k` `vocab_off`/opt | `logits`, `params` → `stats` | +| `sample_logprobs` | `M`(range) `n_vocab` `k` `vocab_off`/opt | `logits`, `params`? → `stats` | | `mtp_couple_propose` | `M`(range) `n_vocab` `round` `max_rounds` `q_temp`:f64/opt | `idx`:inout, `val`, `seq_ids`, `draw` → `state`:inout | | `mtp_couple_verify` | `M`(range) `n_cand` `n_vocab` | `cand_idx`, `cand_val`, `params`, `state` → `token`:inout | | `dflash_couple_propose` | `M`(range) `steps` `top_k` `rank` `n_vocab` `anchor_stride` `max_rounds` `q_temp`:f64/opt | `cand`, `unary`, `hp`?, `anchor`, `pred`w, `succ`w, `seq_ids`, `draw`, `tokens`:inout → `state`:inout | @@ -2852,7 +2956,8 @@ llama.cpp's: 0 turns the stage off for the row, and a negative value takes the w `sample_logprobs` serves an OpenAI `logprobs` field or llama-server's `n_probs`. It runs on the raw logits, before any stage has touched them, and only for a row whose flags carry `RAD_SP_LOGPROBS`; -other rows are not written. `stats` is `[M, 2 + 2k]` f32: the row's maximum, the sum of +other rows are not written. Without `params` every row is written (a drafter's candidate logprobs, +`lili_cand`). `stats` is `[M, 2 + 2k]` f32: the row's maximum, the sum of `exp(l - max)` over it, and its `k` largest as (id, logit) pairs, descending, ties to the lower id, the id written as a float (exact below 2^24) and global under a split vocabulary (`vocab_off` added). A slot past the vocabulary is id -1, logit -infinity. `k` is geometry, the one width every @@ -2923,7 +3028,8 @@ order, not a slow one. | `dsa_pool` | `M`(range) `n` `ratio` `dtype` `block_size`/opt | `kg`, `ape`w → `q`, `scale`; `page`?, `cache`:inout? | | `dsa_query` | `M`(range) `n` `dtype` | `x` → `q`, `scale` | | `dsa_score` | `M`(range) `n` `heads` `blocks` `seqs` `dtype` `row_part`/opt | `q`, `q_scale`, `gate`, `k`, `k_scale`?, `bt`, `cu`, `nc` → `score`, `cu_part`? | -| `mla_attn` | `M`(range) `latent_dim` `heads` `blocks` `block_size` `scale`:f64 `dtype` | `q`, `kv`, `bt`, `length` → `out` | +| `mla_attn` | `M`(range) `latent_dim` `heads` `blocks` `block_size` `scale`:f64 `dtype` `kv_dtype`/opt | `q`, `kv`, `bt`, `length` → `out` | +| `mla_attn_paged` | `M`(range) `heads` `latent_dim` `rope_dim` `block_size` `scale`:f64 `dtype` | `q`, `q_rope`?, `kv`, `block_table`, `seqused`, `cu_seqlens`, `gate`? → `out` | | `mla_project` | `M`(range) `heads` `head_dim` `latent_dim` `mode` `dtype` | `a`, `b`w → `y` | | `qsa_score` | `M`(range) `n` `heads` `blocks` `seqs` `dtype` | `q`, `bk`, `bt`, `cu`, `nc` → `score` | | `qsa_select` | `M`(range) `blocks` `topk` `ratio` `seqs` `signed`/opt | `score`, `bt`, `nc`, `pos`, `cu` → `sel`, `nsel`, `seqused` | @@ -3248,7 +3354,9 @@ fold only after each head's ReLU. the tail) and is the causal bound: no slot at or past it is read. A missing or out-of-range page contributes nothing, and a row with no visible key outputs zero. The softmax is f32 and `out` is rounded once. `scale` is positive and finite and comes from the original query/key head width, -not the latent width (GLM: `1/sqrt(256)` against a latent of 512). +not the latent width (GLM: `1/sqrt(256)` against a latent of 512). `kv_dtype`, when given, is the +cache's dtype and may differ from `dtype`: `fp8_e4m3` is a cache `kv_store` wrote at its default +descale of 1, so each code is read as the value itself. libr4d has three `mla_attn` rows, all at `latent_dim` 512, `block_size` 4 and up to 64 heads. The matrix row, `mla_attn_matrix_bf16`, ranks above the wave row and takes heads in multiples of 8: the @@ -3275,6 +3383,35 @@ runs the matrix row's kernel instead. It also takes multiples of 32 heads (two g workgroup), which no constraint routes to it. GLM-5.3 splits a prefill's MLA by rows under tensor parallelism, so each rank holds all 64 heads of its rows (ARCHITECTURES.md, `glm5next`). +Each of the three has an E4M3-cache twin (`mla_attn_fp8kv`, `mla_attn_matrix_fp8kv`, +`mla_attn_rows_fp8kv`) on the same constraints plus `kv_dtype` `fp8_e4m3`, ranked above all three +bf16 rows and in their order. The kernels are the bf16 rows' with the key load decoding E4M3: +every E4M3 value is a bf16, so the decoded tile is exact and the rest of the arithmetic is the bf16 +instance's. The bf16 rows state no `kv_dtype` and their launchers refuse an E4M3 cache. +`mla_attn_paged` is the dense, causal form for a model whose MLA keeps a rotary part beside the +latent (Ling-3.0: latent 512, rotary 64, every key visible). A token's cache row is the normed +latent followed by the rotated key part, `latent_dim + rope_dim` wide; it is stored as one KV head +of half that width, its first half in the K slot and the rest in the V slot, so `kv` is +`[pages, 1, block_size, latent_dim + rope_dim]`. `q` is the absorbed query `[M, heads, +latent_dim]` and `q_rope` its rotated part `[M, heads, rope_dim]`, each at its own row and head +pitch. A score is `scale * (q . latent + q_rope . rope)`, `scale` from the original head width +(`(nope + rope)^-0.5`), and the value is the latent. Sequences, positions and the causal bound are +`attn_paged`'s: sequence `s` owns query rows `[cu[s], cu[s+1])`, `seqused[s]` is its context after +the step, row `i` of it sits at position `seqused[s] - qlen + i` and sees keys `0..position` through +`block_table[s]`. An unmapped page contributes nothing and a row with no visible key outputs zero. +With `gate` `[M, >= heads]` (a head's gate logit) the output is +`bf16(bf16(out) * bf16(sigmoid(gate)))`, Ling's head-wise attention gate taken on the latent, ahead +of the expansion. The softmax is f32 and `out` rounded once before the gate. + +libr4d's `mla_attn_paged_bf16` serves `latent_dim` 512 and `rope_dim` 64, up to 64 heads, pages of +up to 256 tokens: a wave a (query row, head), its lanes holding 16 latent and 2 rotary columns each, +so a score is one wave sum. A short batch splits each row's history over waves and joins the f32 +partials. The split count comes from the head count alone, never from the rows of the launch or +its longest table, so a row's bytes do not depend on its batch: a speculative verify of `k + 1` +rows must give, bit for bit, the single-row decodes at the same positions, or greedy output +differs from the run without speculation. That holds up to 32 rows a launch, the rows the scratch +hook sizes for; a larger batch takes as many splits as its scratch holds. + `mla_project` moves a query into the latent and a latent result out of it, through the bf16 weight `b` `[heads*2*head_dim, latent_dim]` that stores each head's key rows, then its value rows. `mode=absorb` multiplies `a` `[M, heads, head_dim]` by the head's key block as stored, @@ -3284,16 +3421,35 @@ accumulate in f32 and round once to bf16. The KV cache stays latent; only this w per-head width. Its rows are head-major, so a tensor-parallel slice of whole heads is a row range. `a` and `y` may also be `[M, heads*width]`, heads contiguous, with their own token pitch. -libr4d's `mla_project_bf16` serves `head_dim` 256 and `latent_dim` 512, up to 64 heads, pitched -tensors. It takes up to eight rows a thread (`absorb`) or a wave (`expand`), loading each weight -element once for them, with every row's sum in the same order whatever the group, so a row's bytes -do not depend on the batch. +libr4d's `mla_project_bf16` serves `head_dim` 128 or 256 and `latent_dim` 512, up to 64 heads, +pitched tensors. It takes up to eight rows a thread (`absorb`) or a wave (`expand`), loading each +weight element once for them, with every row's sum in the same order whatever the group, so a row's +bytes do not depend on the batch. ## Draft heads A drafter is an ordinary graph over ordinary ops except at its two ends: what proposes the candidates, and what enters the head from the trunk. +### DSpark + +| op | params | operands | +|---|---|---| +| `dflash_markov_greedy` | `M` `steps` `rank` `n_vocab` `anchor_stride`/opt `dtype` | BF16 `logits`, `anchor`, `pred`w, `succ`w → `tile_scores`, `tile_tokens`, `tokens` | +| `dflash_markov_greedy_f32` | `M` `steps` `rank` `n_vocab` `anchor_stride`/opt `dtype` | F32 `logits`, `anchor`, `pred`w, `succ`w → `tile_scores`, `tile_tokens`, `tokens` | + +`dflash_markov_greedy` implements the DSpark full-vocabulary greedy walk, not DFlash2's +candidate-lattice selector. For every position it adds `sum_r pred[previous,r] * succ[token,r]` +to every vocabulary logit, chooses the greatest biased score (ties to the lower token id), and +uses that id as the next predecessor. The explicit tile outputs are scratch for the device's +vocabulary-wide reduction; their row pitches may differ. The F32 variant uses the same BF16 +codebooks (`dtype=bf16`) but takes F32 base logits; it is a separate operation so an older BF16-only +kernel cannot silently resolve it. The DSpark graph uses `logits_gemm` and the F32 variant. The +pinned llama.cpp reference also uses F32 base logits, but reduction orders may differ. Its CPU +argmax chooses the last equal maximum; its GPU reduction uses a backend-specific order. This op's +lower-id tie rule is not a claim of reference tie equivalence. Near-tie proposal equivalence is +therefore not established. + ### DFlash2 | op | params | operands | @@ -3351,6 +3507,42 @@ inside one workgroup. Written literally it is `steps` full-vocabulary `[rank, n_ products; through this operand it is a codebook gather. The only approximation is the top-K candidate set, which can cost acceptance and nothing else. +### LiLiCorr + +| op | params | operands | +|---|---|---| +| `lili_cand` | `M`(range) `k` `world` `steps` `n` `dtype` `eps`:f64/opt `row_k`/opt | `stats`, `pas`, `ln_w`w, `ln_b`w, `up_w`w, `up_b`w, `slot`w, `rank`w → `cand`, `feat`, `base` | +| `lili_attn` | `M`(range) `steps` `k` `n_head` `head_dim` `dtype` `scale`:f64/opt | `qkv`, `rel`w, `same`w → `out` | +| `lili_factor` | `M`(range) `L` `n` `dtype` | `h`, `a` → `y` | +| `lili_walk` | `M`(range) `steps` `k` `n` `dtype` `eps`:f64/opt `scale`:f64/opt | `edges`, `aout`, `cand` → `tokens`, `scores`? | + +LiLiCorr (Nemotron-3.5-Bolt's drafter) is a DFlash2 backbone whose head is a candidate correlator: +each draft position keeps the target head's top-k, and a small transformer over all positions' +candidates scores the edges between consecutive positions. A sequence's lattice is `steps` positions +of `k` candidates, row `s * k + j`, the sequences one after another. + +**`lili_cand`** reads `stats` `[M, world * (2 + 2 row_k)]` f32, each rank's `sample_logprobs` row +row-interleaved (`row_k` >= `k` pairs, by default `k`: a caller widens a rank's row to whole 16-byte +words for the all-gather, 9 pairs where it keeps 8), and merges them as one row would be read: the log-normaliser from the maxima and +the rescaled sums, the `k` largest pairs by value, ties to the lower id. `cand` `[M, k]` i32 holds +those ids. With `lp_j = logit_j - lse`, row `m * k + j` of `feat` is +`silu(up_w · layernorm([lp_j, exp lp_j, lp_j - lp_0, j/(k-1), j == 0]; ln_w, ln_b, eps) + up_b)` +and of `base` `pas[m] + slot[m % steps] + rank[j]`: the lattice row's additive part, to which the +token and feature projections are added by their GEMMs' residual operand. + +**`lili_attn`** is attention within each lattice, every row seeing every row: `qkv` is +`[M, 3 * n_head * head_dim]` as q | k | v, and the score is +`q_i · k_j * scale + rel[h][s_i - s_j + steps] + (s_i == s_j ? same[h] : 0)` with `s_i = i / k`. + +**`lili_factor`** writes `[h_i | a_s | h_i * a_s]`, `s = i / L`: a lattice row beside its sequence's +anchor and their product, the input of the factor projection `W [x, a, x * a] + b`. + +**`lili_walk`** normalises each candidate's outgoing and incoming vector (`edges`, `[out | in]`) and +the anchor's outgoing one (`aout`) as `v / max(|v|, eps)`, scores `start[j] = scale * aout · in[0][j]` +and `pair[s][i][j] = scale * out[s][i] · in[s + 1][j]`, and walks greedily from the start, the first +index winning a tie: `tokens[m][s] = cand[m * steps + s][p_s]`. `scores` `[M, steps, k, k]` is the +score tensor vLLM builds (row 0 the start for every `i`), for checking. + ### `mtp_enter` | op | params | operands | diff --git a/docs/SPARK25-IQ8R.md b/docs/SPARK25-IQ8R.md new file mode 100644 index 00000000..6b68b739 --- /dev/null +++ b/docs/SPARK25-IQ8R.md @@ -0,0 +1,177 @@ +# Spark X2.6 4B IQ8R: recipes, provenance, and validation + +`arch/spark25_w8a8` serves Spark X2.6's six dense projections per layer on the `fwht128` rotated +int8 grid. It requires `quantization_config.quant_method=w8a8` and +`quantization_config.fmt=fwht128`; activations use `had_quant_act_i8g` and weights use `gemm_nt_q` +with `dtype=i8a8h`. The embedding and small per-head attention gate stay BF16; norm gains stay +FP32. Calibration is TP=1 so the Gram matrices retain cross-rank terms. + +## Recipe choice + +The container format does not choose a recipe or change a launcher default. Select one explicitly +when converting a BF16 source checkpoint: + +| Allocation | Recipe | Published container size | Measured distribution parity | Performance note | +|---|---|---:|---|---| +| Quality-preferred tested hybrid | `data/recipes/spark-x26-4b-iq8r-keep12.recipe` | 5.67 GiB (6,092,100,608 bytes) | 99.111% top-1 agreement; top-128-plus-tail KL mean 0.000677, p99 0.00923, p99.9 0.04013, max 0.24712 | About 12% less prefill and 17% less decode throughput than full IQ8R in the reported single-card comparison | +| Full IQ8R, explicit speed/size tradeoff | `data/recipes/spark-x26-4b-iq8r.recipe` | 4.52 GiB (4,853,470,208 bytes) | 98.595% top-1 agreement; top-128-plus-tail KL mean 0.004077, p99 0.04960, p99.9 0.34814, max 11.8832; 13 positions exceed 1 nat | Prefill 11.8k / 11.8k / 11.3k tok/s at 1.1k / 4.4k / 9.9k-token prompts; decode 93.7 tok/s at short context and 88.9 tok/s at 4.4k context | +| Source BF16 | no recipe | 8.29 GiB | reference | Baseline | + +For the keep12 allocation, six explicit rules cover each projection in layers 12–35. Layers 0–11 +have no matching rule and retain their BF16 checkpoint encoding. The output head remains RTN in both +IQ8R recipes; unmatched tensors (including the embedding and attention gate) retain their source +encoding. The full recipe is not quality-preferred and is not applied implicitly. Neither measured +allocation establishes task accuracy or universal quality for all prompts and uses. + +The reported KLD values above are **not exact full-vocabulary KL**. They use Radiance's sparse +`--kld-top 128` form: the reference's top 128 token probabilities plus one bucket for all remaining +probability mass, compared with the candidate on the same coarsened support. The 31,391 positions +are from a 32-document held-out evaluation; the keep12 maximum is below one nat on this set, not a +claim about all inputs. Perplexity ratios were 1.00178 (keep12) and 1.00409 (full IQ8R). + +## Calibration and evaluation provenance + +The published calibration dataset is +[`gostar77/spark-x2.6-4b-iq8r-calibration`](https://huggingface.co/datasets/gostar77/spark-x2.6-4b-iq8r-calibration), +revision `4b622fa2ecca376a02a83ef23ec6dfb3b7cdc52b`. Its `CALIBRATION-MANIFEST.json` records +Spark X2.6 4B, `RADGRAM2`, TP=1, all 36 layers and six projection types. It contains 216 validated +Gram files (21,290,294,016 bytes; about 19.83 GiB) accumulated over 65,660 tokens. The prompts +were 100 selected document beginnings from `swift15-public-corpus`, with selection seed `20261031` +and every fourth candidate wrapped in the Spark chat format. The published dataset is CC BY-SA 4.0; +its `SHA256SUMS` covers the Gram files. The local manifest used for this record is +`/mnt/gostar_data/radiance-builds/hf-publish/spark-x2.6-4b-iq8r-calibration/CALIBRATION-MANIFEST.json` +(SHA-256 `f2225de42cfc885dca2720128143487296a5ba8c33cc797de0bac2b2bcebf007`); its local +`SHA256SUMS` has SHA-256 `f8d14fc575875e33045c2231013e87da52da8db4e21f692c363464d858dbbb18`. + +The evaluation manifest is +`/mnt/gostar_data/radiance-builds/spark-x2-6-iq8r/independent-chat-eval.manifest.json` +(SHA-256 `a8528f193986b7267b7ec5b5a447c0d1f5271d5c2f7f004ceb8ba543e5168f4d`). It identifies a +separate held-out source file, `/mnt/gostar_data/radiance-calib/qwen3.8-flash-next-base-w5dn64/corpus/heldout.jsonl` +(source SHA-256 `2c3935512dbf0b09c8fea88be19f7d31447a540de57133a54f97e6e172f15532`), selection seed +`7132026`, and 8 examples each from tools, math, prose, and code. Two high-overlap candidates were +excluded; the manifest describes a sampled 20-gram overlap check against the 100 diverse calibration +documents and the original nine. That check is not proof of zero semantic overlap. Math/tool rows +score assistant continuations; prose/code rows score text after 32 tokens. The resulting local KLD +corpus is `/mnt/gostar_data/radiance-builds/spark-x2-6-iq8r/independent-chat-eval.jsonl` +(SHA-256 `468d9c6037a17475688ba432d804618c10d15288b4d5fe538b7ac4c0ab725ace`). + +The recorded matched-reference artifacts are local and were not copied into this repository: + +- BF16 sparse reference: `/mnt/gostar_data/radiance-builds/spark-x2-6-iq8r/rowfix-bf16-ref128/` + (`kld.json` SHA-256 `b722b8a956b747dd932413204d9ae0775bd2bd50377f0466134cc922ad83b026`). +- Full IQ8R report and per-row file: `rowfix-diverse-kld.json` and + `rowfix-diverse-kld.json.rows` (report SHA-256 + `0f7368c83a3c9a896aa42bcbdf8022db526517f7fc4a9e680747ccd2b66bdee9`). +- Keep12 report and per-row file: `rowfix-keep12-kld.json` and + `rowfix-keep12-kld.json.rows` (report SHA-256 + `d6b577c1e6f7fc5c40814744bea22079998562229eaa2b2a892274544a149dbf`). +- `rowfix-keep12-kld.json` records `ref_form: "top-128 + tail"`, reference `rowfix-bf16-ref128`, + `all.positions: 31391`, mean KL `0.0006770557376511436`, maximum KL `0.2471124678850174`, and + 99.1112% top-1 agreement. These are coarsened top-128-plus-tail KL values, not exact + full-vocabulary KL. `rowfix-diverse-kld.json` uses the same `rowfix-bf16-ref128` reference and + 31,391 positions. The reference metadata records corpus FNV-1a `17d9069a2711c745`; the companion + `.json.rows` files contain the per-position score rows (KL, candidate NLL, reference NLL, top-1 + match). + +The measured rowfix comparison used Radiance source commit `54f2602367eb96ca08674095f7e32506fd7d752b` +(the build tree points to `/mnt/gostar_data/radiance-worktrees/spark-x2-6`), `libr4d@0.5.0`, TP=1, +BF16 KV, `--max-model-len 4096`, `--max-num-seqs 1`, `--max-num-batched-tokens 128`, no speculation, +and prefix cache disabled. The prerequisite shared prefill correction is #362, +`7480da3d46b0475d9d77966e31284cc19072759`. **Those parity figures are for the tree with #362**; +#363's original `5024aea` ancestry did not contain it. Do not attribute these numbers to standalone +#363 or to a build without #362. A fresh GPU TP2 validation is separate and remains outstanding. + +Published container checksums from `/mnt/gostar_data/radiance-builds/hf-publish/SHA256SUMS` +(SHA-256 `3c14ea79cb8b7b3aba8807dd43101aa84110636e914eb2008eb2ba3a387e3d1b`): + +| Container | SHA-256 | +|---|---| +| `spark-x2.6-4b-radiance-bf16.rad` | `39694f258a3bb1e8367690a5d26762061226f3166125e929c6e33a4981583b6c` | +| `spark-x2.6-4b-radiance-iq8r-diverse.rad` | `2f6982f12b43d1e7621326c5c05a3764ef62defbbd4f59c708f9db698a14b0e5` | +| `spark-x2.6-4b-radiance-iq8r-keep12.rad` | `5a12f1f4c6cb1b2a545344bcb800cd829dc53de6cefa7a6bd9d4e2ed9fee2740` | + +## Sharding alignment + +A shard must own whole 128-column scale groups for a column-sharded IQ8R input; the architecture +rejects any computed span whose count is not group-aligned. It splits the FFN in whole 128-channel +units when the model width permits, using a ragged remainder-first partition. For Spark's +10,240-channel FFN there are 80 such units: TP=3 gets 27, 27, and 26 groups (3,456, 3,456, and +3,328 channels), all aligned. TP=3 is **not** categorically unaligned or unsupported. The synthetic +wide fixture checks TP=1..8; actual device support still depends on the selected kernel library and +required collectives. Calibration itself remains TP=1. + +## Reproduce matched KLD and tail replays + +Use a private output directory; the reference is immutable once recorded. The harness hashes the +checkpoint, executable, corpus, evaluation manifest, and **kernel, architecture and optional quantizer +shared-object inventories** into `run.json`. This includes the architecture graph plugin, not only +`libr4d.so`; an optional source revision is context, not proof that a binary was built from it. The +inventory must remain unchanged during the measurement. These probes accept one explicit home, not +a colon-separated home search path. They replay the same corpus against BF16 once and score each +candidate with fixed chunking/cache/TP flags. A reference `provenance.json` binds the BF16 model bytes, +corpus, runtime/plugins, settings and recorded data files. `--reuse-reference` requires this binding +to match; legacy unbound references must be recorded afresh, not relabelled with the supplied model. +The harness snapshots inputs before recording, checks them immediately afterward before publishing +provenance, and checks them again before publishing the run receipt. These checks detect persistent +changes, not a concurrent change that is reverted between checks; keep inputs immutable throughout. +A retry removes any previous `run.json` before measurement, so retain old receipts separately. +Reports and per-position score files are hashed into the run receipt as well: + +```sh +python3 tests/spark25_quality.py \\ + --radiance "$BUILD/bin/radiance" --home "$BUILD/radiance_home" \\ + --reference "$BF16" \\ + --corpus /mnt/gostar_data/radiance-builds/spark-x2-6-iq8r/independent-chat-eval.jsonl \\ + --provenance /mnt/gostar_data/radiance-builds/spark-x2-6-iq8r/independent-chat-eval.manifest.json \\ + --calibration-manifest /mnt/gostar_data/radiance-builds/hf-publish/spark-x2.6-4b-iq8r-calibration/CALIBRATION-MANIFEST.json \\ + --source-root "$PWD" --out "$RUN" \\ + --candidate "full=$FULL_IQ8R" --candidate "keep12=$KEEP12" +``` + +Run that process inside the host's exclusive GPU/device scope for `libr4d`. To replay a candidate's +highest-KL rows, run the following **inside the same kind of device scope**. The tool validates the +report's reference/corpus/model identities, report/row hashes, reference binding, and current runtime, +model and plugin hashes against `run.json`, then starts its own private candidate server with the +scoring run's TP, BF16 KV, model/chunk limits, speculation0 and prefix-cache-off settings. It verifies +the private served ID and the consumed prefix/completion/cache counts. Arbitrary external `--url` +servers are not accepted: a served alias alone cannot prove which checkpoint was loaded. + +```sh +python3 tests/spark25_kld_tail.py \\ + --run "$RUN/run.json" \\ + --reference "$RUN/bf16-top128-ref" --report "$RUN/full-kld.json" \\ + --out "$RUN/full-tail-replay.json" +``` + +The replay compares candidate top-20 log-probabilities with the stored reference top-20 for the +selected rows. The full corpus KLD report remains the top-128-plus-tail metric; top-20 replay is a +focused diagnostic, not a replacement for the full evaluation. + +## Reproducible serving QoS smoke + +Run this separately for each model, one process/container at a time and under an exclusive device +scope. It reuses the same evaluation prompts, disables prefix caching and speculation, and stores +per-request latency plus p50/p95/max and aggregate generated-token throughput at each concurrency. +These are end-to-end request measurements (prefill plus decode and service overhead), not decode-only +throughput or task scores. Every response must report positive integer prompt usage and exactly +`--max-tokens` generated tokens with a `length` finish (EOS is ignored for this fixed-work smoke). +Missing, zero or short counts fail the run rather than producing a successful throughput receipt. +The prompt file is parsed and hashed from the same byte snapshot and rechecked before receipt; the +private server uses a unique served model ID and is checked for identity and liveness. Requests per +repeat must be at least the largest requested concurrency. This is a client concurrency level, not +proof that requests actually overlapped in a server batch. Runtime/model/plugin hashes are also +checked again before writing the receipt; use a fresh `--out`: + +```sh +python3 tests/spark25_qos.py \\ + --radiance "$BUILD/bin/radiance" --home "$BUILD/radiance_home" \\ + --model "$KEEP12" \\ + --prompts /mnt/gostar_data/radiance-builds/spark-x2-6-iq8r/independent-chat-eval.jsonl \\ + --source-root "$PWD" --out "$RUN/keep12-qos" \\ + --concurrency 1,4,8 --requests 16 --repeats 3 --max-tokens 32 +``` + +Use identical flags, prompt file and `RADIANCE_HOME` for BF16 and full IQ8R; run them sequentially +on the same device allocation. This smoke is a reproducible validation command, not a completed +concurrent/long-context QoS certification. The held-out distribution comparison is not an external +benchmark and does not establish universal model quality. diff --git a/docs/TOOLS.md b/docs/TOOLS.md index 6ff59b06..8d2d9508 100644 --- a/docs/TOOLS.md +++ b/docs/TOOLS.md @@ -443,8 +443,8 @@ comparison with the recording runs either way. `--no-cache` runs it regardless. Against a container (`-m`), weight operands are read from it: each weight's canonical planes, which the kernel under test gets through its own `layout`/`relayout` hooks and the oracle gets -decoded, and every expert of a weight table. This is the only test of the artifact and of the -layout hooks. +decoded, and every expert of a weight table, laid out expert by expert and stacked. This is the +only test of the artifact and of the layout hooks. ```sh rad-kbench -m flashnext-w4.rad --home $RADIANCE_HOME --bench --report kbench.md diff --git a/libavx/CMakeLists.txt b/libavx/CMakeLists.txt index cda34e89..a17b6b3e 100644 --- a/libavx/CMakeLists.txt +++ b/libavx/CMakeLists.txt @@ -52,6 +52,7 @@ set(AVX_KERNEL_SRC avx_qsa.cpp avx_moe.cpp avx_gdn.cpp + avx_ssd.cpp avx_sample.cpp avx_misc.cpp avx_gen.cpp @@ -60,6 +61,7 @@ set(AVX_KERNEL_SRC avx_ltx.cpp avx_vsa.cpp avx_audio.cpp + avx_lili.cpp ) # The flag sets, written out because each states which instructions the object may contain. diff --git a/libavx/avx_attn.cpp b/libavx/avx_attn.cpp index f5421048..e334c59e 100644 --- a/libavx/avx_attn.cpp +++ b/libavx/avx_attn.cpp @@ -101,8 +101,23 @@ static inline void axpy(float* acc, const float* v, float w, int64_t n) { * q-block) unit widens the context once into panels and runs its rows from them. Per-row math * (ascending dots, the same rescale points) is the decode form's; the loads differ. q-blocks of 64 * keep enough units for the thread pool. Ragged (cus) inputs always take the decode form. */ -static int attn_paged_prefill(const RadArgs* a, [[maybe_unused]] RadStream stream) { - const RadTensor *q = &a->t[0], *kv = &a->t[1], *bt = &a->t[2], *su = &a->t[3], *o = &a->t[7]; +/* A sink (attn_paged_sink): one more logit in a row's softmax, with no value. Folded in after the + * keys: the maximum moves to it if it is larger, and the sum takes its weight. */ +static inline void sink_fold(float sk, float* acc, int64_t head_dim, float* m, float* l) { + if (*m == -INFINITY) return; /* no visible key: the row stays zero */ + if (sk > *m) { + const float r = sc_exp(*m - sk); + for (int64_t d = 0; d < head_dim; ++d) acc[d] *= r; + *l = *l * r + 1.0f; + *m = sk; + } else { + *l += sc_exp(sk - *m); + } +} + +static int attn_paged_prefill(const RadArgs* a, [[maybe_unused]] RadStream stream, + const RadTensor* sinks, int oi) { + const RadTensor *q = &a->t[0], *kv = &a->t[1], *bt = &a->t[2], *su = &a->t[3], *o = &a->t[oi]; const RadTensor* kdes = rad_arg_in(a, 4); const RadTensor* vdes = rad_arg_in(a, 5); const int64_t head_dim = p_int(a, "head_dim", q->rank >= 3 ? q->shape[q->rank - 1] : 0); @@ -225,6 +240,7 @@ static int attn_paged_prefill(const RadArgs* a, [[maybe_unused]] RadStream strea if (++ntile == AVX_KV_TILE) flush(); } flush(); + if (sinks) sink_fold(ldt(sinks, h), acc, head_dim, &m, &l); if (m == -INFINITY) { for (int64_t d = 0; d < head_dim; ++d) stt(o, ob + d * o_ds, 0.0f); continue; @@ -246,18 +262,25 @@ static int attn_paged_prefill(const RadArgs* a, [[maybe_unused]] RadStream strea return RAD_OK; } +/* attn_paged, and attn_paged_sink with `sinks` (one logit a query head): out at operand `oi`. */ /* attn_paged_tree's ninth operand, `spec_parent` (rad_drafter_tree), is read here too, as libref * reads it: -2 an ordinary causal row; else the row's parent's index within its sequence's rows * (-1 for the block's first). Inside the block such a row sees itself and its ancestors only, and * its window is measured from the block's first position plus its depth. */ -AVX_KERNEL(attn_paged) { - if (a->n_t < 8) return RAD_E_INVAL; - const RadTensor *q = &a->t[0], *kv = &a->t[1], *bt = &a->t[2], *su = &a->t[3], *o = &a->t[7]; +/* `shared_anchor_window` (attn_paged_anchor_window): every row of a sequence measures its window, + * and a causal row its last visible key, from the sequence's first query position instead of its + * own, as libref does (ref_attn.cpp, ref_attn_paged_impl). */ +static int attn_paged_rows(const RadArgs* a, RadStream stream, const RadTensor* sinks, int oi, + bool shared_anchor_window = false) { + if (a->n_t < oi + 1) return RAD_E_INVAL; + const RadTensor *q = &a->t[0], *kv = &a->t[1], *bt = &a->t[2], *su = &a->t[3], *o = &a->t[oi]; const RadTensor* kdes = rad_arg_in(a, 4); const RadTensor* vdes = rad_arg_in(a, 5); const RadTensor* cus = rad_arg_in(a, 6); - const RadTensor* tpar = a->n_t > 8 ? rad_arg_in(a, 8) : nullptr; + /* The tree operand sits where attn_paged_sink keeps its output; a sinked call has none. */ + const RadTensor* tpar = !sinks && a->n_t > 8 ? rad_arg_in(a, 8) : nullptr; if (!q->data || !kv->data || !bt->data || !su->data || !o->data) return RAD_E_INVAL; + if (sinks && !sinks->data) return RAD_E_INVAL; const int64_t head_dim = p_int(a, "head_dim", q->rank >= 3 ? q->shape[q->rank - 1] : 0); const int64_t gqa = p_int(a, "gqa", 1); @@ -266,13 +289,15 @@ AVX_KERNEL(attn_paged) { const int64_t block_size = p_int(a, "block_size", kv->rank == 4 ? kv->shape[2] : 0); const int causal = (int)p_int(a, "causal", 1); const int64_t window = p_int(a, "window", 0); - if (head_dim <= 0 || gqa <= 0 || block_size <= 0) return RAD_E_SHAPE; + if (head_dim <= 0 || gqa <= 0 || block_size <= 0 || (shared_anchor_window && window <= 0)) + return RAD_E_SHAPE; if (head_dim > AVX_HD_MAX) return RAD_E_UNSUPPORTED; const int64_t kv_heads = kv->rank == 4 ? kv->shape[1] : 0; if (kv_heads <= 0) return RAD_E_SHAPE; const int64_t q_heads = gqa * kv_heads; if (q->rank >= 3 && q->shape[q->rank - 2] != q_heads) return RAD_E_SHAPE; + if (sinks && numel(sinks) != q_heads) return RAD_E_SHAPE; const int64_t n_seq = numel(su); const int64_t rows = numel(q) / (q_heads * head_dim); if (n_seq <= 0 || rows <= 0) return RAD_E_SHAPE; @@ -299,7 +324,8 @@ AVX_KERNEL(attn_paged) { const float scale = p_f32(a, "scale", 1.0f / std::sqrt((float)head_dim)); /* Uniform long queries take the panel form; ragged (cus) inputs stay here. */ - if (!cus && q_len >= 32 && !tpar) return attn_paged_prefill(a, stream); + if (!cus && q_len >= 32 && !tpar && !shared_anchor_window) + return attn_paged_prefill(a, stream, sinks, oi); /* Work units are (token, kv-head) groups: the gqa query rows of a group share every key and * value row, so each is widened once for gqa dots/axpys. Per-row arithmetic is unchanged. */ const int64_t total = rows * kv_heads; @@ -415,12 +441,14 @@ AVX_KERNEL(attn_paged) { ntile = 0; }; + const int64_t mask_pos = shared_anchor_window ? base : pos; for (int64_t j = 0; j < ctx; ++j) { - if (causal ? (j > pos) : (j >= ctx)) continue; + if (causal ? (j > mask_pos) : (j >= ctx)) continue; if (tree && j >= base && !((tmask >> (j - base)) & 1)) continue; if (window > 0) { - const int64_t d = wpos - j; - if (causal ? (d >= window) : (d >= window || d <= -window)) continue; + const int64_t d = (shared_anchor_window ? base : wpos) - j; + if (shared_anchor_window ? (d >= window) + : causal ? (d >= window) : (d >= window || d <= -window)) continue; } if (j / block_size >= max_blocks) break; /* past the block table's width */ const int64_t blk = ldi(bt, s * bt_rs + (j / block_size) * bt_cs); @@ -440,6 +468,7 @@ AVX_KERNEL(attn_paged) { const int64_t h = kh * gqa + g; const int64_t ob = tok * o_rs + h * o_hs; float* ac = accs + g * head_dim; + if (sinks) sink_fold(ldt(sinks, h), ac, head_dim, &mm[g], &ll[g]); if (mm[g] == -INFINITY) { for (int64_t d = 0; d < head_dim; ++d) stt(o, ob + d * o_ds, 0.0f); continue; @@ -460,6 +489,11 @@ AVX_KERNEL(attn_paged) { return RAD_OK; } +AVX_KERNEL(attn_paged_sink) { + if (a->n_t < 9 || !a->t[7].data) return RAD_E_INVAL; + return attn_paged_rows(a, stream, &a->t[7], 8); +} + /* ------------------------------------------------------------------ attn_dense, bf16 blocks */ /* Encoder attention is all prefill. The per-query loop in attn_dense parallelises over * (segment, head) only and re-widens every key row for every query (four million row conversions @@ -746,6 +780,15 @@ AVX_BF16_TARGET static bool attn_dense_bf16(const RadTensor* q, const RadTensor* } #endif +AVX_KERNEL(attn_paged) { return attn_paged_rows(a, stream, nullptr, 7, false); } + +/* attn_paged with one window anchor a sequence (DSpark's drafter); no tree operand. */ +AVX_KERNEL(attn_paged_anchor_window) { + if (!a || a->n_t < 8) return RAD_E_INVAL; + if (a->n_t > 8 && rad_arg_in(a, 8)) return RAD_E_UNSUPPORTED; + return attn_paged_rows(a, stream, nullptr, 7, true); +} + /* attn_paged with its tree operand present, which attn_paged reads (see there). Refused without * one, and for a non-causal layer. */ AVX_KERNEL(attn_paged_tree) { diff --git a/libavx/avx_cases.cpp b/libavx/avx_cases.cpp index ae27ab27..f6540219 100644 --- a/libavx/avx_cases.cpp +++ b/libavx/avx_cases.cpp @@ -58,7 +58,7 @@ std::vector build_cases() { add("scale", { HI("M", 6), HI("n", 645), HS("dtype", dt) }, EB(6, 645, w, 2)); add("softmax", { HI("M", 6), HI("n", 645), HS("dtype", dt) }, EB(6, 645, w, 2)); add("gather_rows", { HI("M", 6), HI("n", 640), HS("dtype", dt) }, EB(6, 640, w, 2)); - for (const char* act : { "silu", "gelu", "gelu_tanh", "sigmoid", "quick_gelu" }) + for (const char* act : { "silu", "gelu", "gelu_tanh", "sigmoid", "quick_gelu", "relu" }) add("act_mul", { HI("M", 6), HI("n", 645), HS("act", act), HS("dtype", dt) }, EB(6, 645, w, 3)); add("mul_weight", { HI("M", 9), HI("n", 645), HS("dtype", dt) }, EB(9, 645, w, 2)); @@ -105,6 +105,10 @@ std::vector build_cases() { HS("dtype", dt) }, EB(27, 648, w, 1)); add("pool_cols", { HI("M", 40), HI("n", 256), HI("k", 8), HS("dtype", dt) }, EB(40, 256, w, 1)); + add("point_fourier", { HI("M", 37), HI("n", 3), HI("freqs", 8), HS("dtype", dt) }, + EB(37, 51, w, 1)); + add("point_fourier", { HI("M", 5), HI("n", 4), HI("freqs", 3), HI("pi", 1), + HS("dtype", dt) }, EB(5, 28, w, 1)); add("scatter_rows", { HI("M", 6), HI("n", 645), HS("dtype", dt) }, EB(6, 645, w, 2)); add("scale_rows", { HI("M", 6), HI("n", 645), HS("act", "sigmoid"), HS("dtype", dt) }, EB(6, 645, w, 2)); @@ -135,6 +139,7 @@ std::vector build_cases() { for (const char* dt : { "f32", "bf16" }) { add("hc_enter", { HI("M", 5), HI("n", 128), HI("hc", 4), HS("dtype", dt) }); add("swiglu_clamped", { HI("M", 5), HI("n", 259), HF("limit", 0.5), HS("dtype", dt) }); + add("swiglu_step", { HI("M", 5), HI("n", 259), HF("limit", 0.5), HS("dtype", dt) }); if (!std::strcmp(dt, "bf16")) add("dsa_pool", { HI("M", 7), HI("n", 128), HI("ratio", 4), HS("dtype", "bf16") }); if (!std::strcmp(dt, "bf16")) @@ -161,12 +166,23 @@ std::vector build_cases() { HF("hc_eps", 1e-6), HI("chunk", 129), HS("dtype", dt) }); add("mhc_post", { HI("M", 3), HI("n", 129), HI("hc", 4), HS("dtype", dt) }); add("mhc_contract", { HI("M", 3), HI("n", 129), HI("hc", 4), HS("dtype", dt) }); + for (int norm : { 0, 1 }) + add("router_sigmoid_group_topk", + { HI("M", 5), HI("n_expert", 512), HI("top_k", 8), HI("n_group", 8), + HI("topk_group", 4), HI("norm", norm), HF("route_scale", 2.5), HS("dtype", dt) }); + add("mla_attn_paged", { HI("M", 5), HI("heads", 3), HI("latent_dim", 64), HI("rope_dim", 16), + HI("block_size", 4), HF("scale", 0.0721687836), HI("ctx", 23), + HS("dtype", dt) }); add("mla_attn", { HI("M", 3), HI("latent_dim", 32), HI("heads", 2), HI("blocks", 7), HI("block_size", 4), HF("scale", 0.125), HS("dtype", dt) }); for (const char* mode : { "prefill", "verify" }) add("kda_update", { HI("M", 3), HI("heads", 2), HI("head_k", 32), HI("head_v", 32), HF("lower_bound", -5), HF("scale", 0.1767766952966369), HF("l2_eps", 1e-6), HS("mode", mode), HS("dtype", dt) }); + /* Nemotron-H's per-rank shape at four ranks is 32 heads x 64 over 2 groups of 128. */ + for (const char* mode : { "prefill", "verify" }) + add("ssd_update", { HI("M", 3), HI("heads", 4), HI("head_dim", 16), HI("d_state", 32), + HI("groups", 2), HS("mode", mode), HS("dtype", dt) }); add("hc_write", { HI("M", 5), HI("n", 128), HI("hc", 4), HS("dtype", dt) }); add("hc_project",{ HI("M", 5), HI("n", 128), HI("hc", 4), HF("scale", 1.0), HS("dtype", dt) }); @@ -364,6 +380,13 @@ std::vector build_cases() { HI("block_size", 16), HI("causal", 1), HI("window", window), HS("q_dtype", dt), HS("kv_dtype", dt), HF("scale", 0.125), HI("max_ctx", 128), HI("n_head", 8), HI("max_seqs", 2) }); + /* One anchor a sequence (DSpark's drafter): a window of 8 measured from the first query row. */ + for (const char* dt : { "f32", "bf16" }) + for (int qlen : { 1, 17 }) + add("attn_paged_anchor_window", { HI("q_len", qlen), HI("head_dim", 64), HI("gqa", 4), + HI("block_size", 16), HI("causal", 1), HI("window", 8), + HS("q_dtype", dt), HS("kv_dtype", dt), HF("scale", 0.125), + HI("max_ctx", 128), HI("n_head", 8), HI("max_seqs", 2) }); /* The tree form over the same shapes (its described parents are ordinary rows, -2). */ for (const char* dt : { "f32", "bf16" }) for (int qlen : { 1, 17 }) @@ -371,6 +394,16 @@ std::vector build_cases() { HI("block_size", 16), HI("causal", 1), HI("window", 8), HS("q_dtype", dt), HS("kv_dtype", dt), HF("scale", 0.125), HI("max_ctx", 128), HI("n_head", 8), HI("max_seqs", 2) }); + /* The sink form: a block of 8 non-causal rows (LiLiCorr's query pass), a decode row and the + * prefill panel form, with and without a window. */ + for (const char* dt : { "f32", "bf16" }) + for (int qlen : { 1, 8, 64 }) + for (int window : { 0, 16 }) + add("attn_paged_sink", { HI("q_len", qlen), HI("head_dim", 64), HI("gqa", 4), + HI("block_size", 16), HI("causal", qlen == 8 ? 0 : 1), + HI("window", window), HS("q_dtype", dt), + HS("kv_dtype", dt), HF("scale", 0.125), + HI("max_ctx", 128), HI("n_head", 8), HI("max_seqs", 2) }); for (const char* dt : { "f32", "bf16" }) for (int causal : { 0, 1 }) add("attn_dense", { HI("M", 24), HI("head_dim", 64), HI("gqa", 2), @@ -641,6 +674,20 @@ std::vector build_cases() { * avx_check's hand-built case. */ add("grid_embed_aa", { HI("M", 20), HI("n", 72), HI("side", 16), HS("dtype", dt) }); add("grid_embed_aa", { HI("M", 40), HI("n", 72), HI("side", 4), HS("dtype", dt) }); + add("grid_embed_cpe", { HI("M", 20), HI("n", 72), HI("side", 16), HS("dtype", dt) }); + add("grid_embed_cpe", { HI("M", 40), HI("n", 72), HI("side", 4), HS("dtype", dt) }); + add("grid_embed_cpe", { HI("M", 24), HI("n", 72), HI("side", 8), HI("n_prefix", 3), + HS("dtype", dt) }); + } + + /* LiLiCorr's lattice ops, at its geometry (7 positions of 8 candidates, 8 heads) narrowed in + * width; lili_cand's rows are no draw and are avx_check_hand.cpp's. */ + for (const char* dt : { "f32", "bf16" }) { + add("lili_attn", { HI("M", 112), HI("steps", 7), HI("k", 8), HI("n_head", 8), + HI("head_dim", 16), HS("dtype", dt) }); + add("lili_factor", { HI("M", 112), HI("L", 56), HI("n", 48), HS("dtype", dt) }); + add("lili_walk", { HI("M", 3), HI("steps", 7), HI("k", 8), HI("n", 40), HS("dtype", dt), + HF("eps", 1e-4), HF("scale", 8.0) }); } /* MoE. Both `a_order` spellings, since the two grouped GEMMs of a routed block use @@ -775,6 +822,13 @@ std::vector build_cases() { HI("n_vocab", 300), HI("anchor_stride", 1), HS("dtype", "bf16") }); add("dflash_select", { HI("M", 5), HI("steps", 3), HI("top_k", 12), HI("rank", 37), HI("n_vocab", 97), HI("anchor_stride", 2), HS("dtype", "bf16") }); + /* DSpark's full-vocabulary walk: a ragged last tile (V % 64), rank 37 not whole vectors. */ + for (const char* op : { "dflash_markov_greedy", "dflash_markov_greedy_f32" }) { + add(op, { HI("M", 3), HI("steps", 4), HI("rank", 64), HI("n_vocab", 300), + HI("anchor_stride", 1), HS("dtype", "bf16") }); + add(op, { HI("M", 2), HI("steps", 3), HI("rank", 37), HI("n_vocab", 97), + HI("anchor_stride", 2), HS("dtype", "bf16") }); + } /* The same lattices grown into trees: more nodes than steps, and fewer. */ add("dflash_tree", { HI("M", 3), HI("steps", 4), HI("top_k", 8), HI("rank", 64), HI("n_vocab", 300), HI("anchor_stride", 1), HI("nodes", 6), diff --git a/libavx/avx_check_hand.cpp b/libavx/avx_check_hand.cpp index fb8015a2..ed75056a 100644 --- a/libavx/avx_check_hand.cpp +++ b/libavx/avx_check_hand.cpp @@ -544,6 +544,49 @@ void shape_cases(std::vector& hs) { .pi("M", 6).pi("n", N).pi("side", 4).ps("dtype", "f32"); hs.push_back(std::move(ga)); + /* RADIO's cropped resample: two prefix rows (row -1, the column naming which), three of a + * 3 x 5 grid upsampling the 4 x 4 table and one of a 2 x 2 grid shrinking it. */ + static const int32_t kCpeCrd[4][6] = { { -1, -1, 0, 2, 1, 0 }, { 0, 2, 0, 4, 3, 1 }, + { 3, 3, 3, 3, 3, 2 }, { 5, 5, 5, 5, 5, 2 } }; + Hand gc("prefix rows and a 4 x 4 table onto 3 x 5 and 2 x 2 grids", "grid_embed_cpe", 1e-6); + gc.dense(RAD_F32, { 6, N }, hfill(61), true) + .dense(RAD_F32, { 16, N }, hfill(62)) + .dense(RAD_I32, { 4, 6 }, [](int64_t i) { return (float)kCpeCrd[i / 6][i % 6]; }) + .dense(RAD_F32, { 3, N }, hfill(63)) + .pi("M", 6).pi("n", N).pi("side", 4).pi("n_prefix", 3).ps("dtype", "f32"); + hs.push_back(std::move(gc)); + + /* LiLiCorr's candidates over two ranks' sample_logprobs rows: a merge that interleaves the + * ranks, an equal value on both (the lower id first), a rank with an unfilled slot. Rows + * of (max, sum, 4 (id, logit) pairs descending) a rank, k = 4, steps 3, n = 24. */ + { + constexpr int64_t K = 4, W = 2, M = 3, NW = 24; + static const float kSt[M][W][2 + 2 * K] = { + { { 2.0f, 7.5f, 10, 2.0f, 11, 1.5f, 40, 0.25f, 41, -1.0f }, + { 1.5f, 9.0f, 70, 1.5f, 77, 1.0f, 72, 0.5f, 73, 0.25f } }, + { { 0.5f, 3.0f, 5, 0.5f, 3, 0.25f, 9, 0.0f, 2, -3.0f }, + { 0.5f, 2.0f, 4, 0.5f, 8, 0.4f, -1, -INFINITY, -1, -INFINITY } }, + { { -1.0f, 12.0f, 100, -1.0f, 101, -1.25f, 102, -2.0f, 103, -2.5f }, + { 3.0f, 1.5f, 200, 3.0f, 201, -4.0f, 202, -5.0f, 203, -6.0f } }, + }; + Hand lc("two ranks merged, a tie and an unfilled slot", "lili_cand", 2e-5); + lc.dense(RAD_F32, { M, W * (2 + 2 * K) }, + [](int64_t i) { return (&kSt[0][0][0])[i]; }) + .dense(RAD_F32, { M, NW }, hfill(71)) + .dense(RAD_F32, { 5 }, hfill(72)) + .dense(RAD_F32, { 5 }, hfill(73)) + .dense(RAD_F32, { NW, 5 }, hfill(74)) + .dense(RAD_F32, { NW }, hfill(75)) + .dense(RAD_F32, { 3, NW }, hfill(76)) + .dense(RAD_F32, { K, NW }, hfill(77)) + .dense(RAD_I32, { M, K }, [](int64_t) { return 0.0f; }, true) + .dense(RAD_F32, { M * K, NW }, [](int64_t) { return 0.0f; }, true) + .dense(RAD_F32, { M * K, NW }, [](int64_t) { return 0.0f; }, true) + .pi("M", M).pi("k", K).pi("world", W).pi("steps", 3).pi("n", NW).ps("dtype", "f32") + .pf("eps", 1e-5); + hs.push_back(std::move(lc)); + } + Hand n("M = 64 over 5 rows, verifies of 3 and 2", "ngram_ids", 0.0); n.idx({ 11, 12, 13, 21, 22 }) .dense(RAD_I32, { 2, 2 + 2 }, [](int64_t i) { return (float)(100 + i); }, true) @@ -599,6 +642,46 @@ void shape_cases(std::vector& hs) { .ps("state_form", "anchor"); hs.push_back(std::move(h)); } + /* Nemotron-H's Mamba-2 under the same two-copy state: a scratch holding three records of + * 1 + head_dim + d_state floats (decay, u, B) behind the count. */ + for (const char* mode : { "prefill", "verify" }) + for (int accepted : { 1, 2, 3 }) + for (int cold : { 0, 1 }) { + constexpr int64_t P = 16, N = 32, R = 1 + P + N; + Hand h("SSD anchor accepted-prefix replay", "ssd_update", 0.01); + h.dense(RAD_BF16, { 2, 1, P }, hfill(221, 0.25f)) + .dense(RAD_BF16, { 2, 1, N }, hfill(222, 0.25f)) + .dense(RAD_BF16, { 2, 1, N }, hfill(223, 0.25f)) + .dense(RAD_BF16, { 2, 1 }, hfill(224, 0.25f)) + .dense(RAD_F32, { 1 }, [](int64_t) { return 0.0f; }) + .dense(RAD_F32, { 1 }, [](int64_t) { return -1.0f; }) + .dense(RAD_F32, { 1 }, [](int64_t) { return 0.5f; }) + .dense( + RAD_F32, { 2, 1, P, N }, + [](int64_t i) { + if (i < P * N) return 0.125f; + i -= P * N; + if (!i) return 3.0f; + if (i > 3 * R) return 0.0f; + const int64_t at = (i - 1) % R; + return at == 0 ? 0.75f : at <= P ? 0.01f : 0.125f; + }, + true) + .dense(RAD_I32, { 1, 6 }, [](int64_t i) { return i < 3 ? 0.0f : 1.0f; }) + .idx({ 0, 2 }) + .idx({ accepted }) + .idx({ cold ? 0 : 1 }) + .dense(RAD_BF16, { 2, 1, P }, hfill(225), true) + .pi("M", 2) + .pi("heads", 1) + .pi("head_dim", P) + .pi("d_state", N) + .pi("groups", 1) + .ps("mode", mode) + .ps("dtype", "bf16") + .ps("state_form", "anchor"); + hs.push_back(std::move(h)); + } for (const char* mode : { "absorb", "expand" }) { const bool absorb = !std::strcmp(mode, "absorb"); const int64_t in = absorb ? 17 : 31, out = absorb ? 31 : 17; diff --git a/libavx/avx_elementwise.cpp b/libavx/avx_elementwise.cpp index f6ab2618..197c3a7f 100644 --- a/libavx/avx_elementwise.cpp +++ b/libavx/avx_elementwise.cpp @@ -133,6 +133,7 @@ static inline float act_of(int act, float g, uint32_t dt) { if (act == 0) return g / (1.0f + sc_exp(-g)); if (act == 1) return 0.5f * g * (1.0f + sc_erf(g * 0.70710678118654752f)); if (act == 3) return 1.0f / (1.0f + sc_exp(-g)); + if (act == 5) return g > 0.0f ? g : 0.0f; if (act == 4) // quick_gelu: sigmoid of the 1.702*g the unfused mul would have stored return 1.0f / (1.0f + sc_exp(-round1(dt, g * round1(RAD_BF16, 1.702f)))); const float k0 = 0.7978845608028654f, k1 = 0.044715f; @@ -169,8 +170,8 @@ AVX_KERNEL(act_mul) { if (n <= 0) return RAD_E_SHAPE; const int64_t rows = rows_of(Y, n); if (rows <= 0 || numel(A) < rows * n || numel(B) < rows * n) return RAD_E_SHAPE; - static const char* kActs[] = { "silu", "gelu", "gelu_tanh", "sigmoid", "quick_gelu" }; - const int act = p_enum(a, "act", kActs, 5, -1); + static const char* kActs[] = { "silu", "gelu", "gelu_tanh", "sigmoid", "quick_gelu", "relu" }; + const int act = p_enum(a, "act", kActs, 6, -1); if (act < 0) return RAD_E_INVAL; AVX_PARALLEL_FOR_IF(rows * n >= AVX_PAR_MIN) @@ -634,6 +635,40 @@ AVX_KERNEL(pool_cols) { return RAD_OK; } +/* ------------------------------------------------------------------ point_fourier */ +/* As libref: [x | sin(x_i 2^j) | cos(x_i 2^j)] (times pi with `pi` 1), the products, sines and + * cosines f32 and rounded once into y. Parallel over rows. */ +AVX_KERNEL(point_fourier) { + if (!rad_args_have(a, 2)) return RAD_E_INVAL; + const RadTensor *X = &a->t[0], *Y = &a->t[1]; + const int64_t n = p_int(a, "n", 0), F = p_int(a, "freqs", 0); + const bool pi = p_int(a, "pi", 0) != 0; + if (n <= 0 || F <= 0 || F > 30) return RAD_E_SHAPE; + const int64_t w = n * (2 * F + 1); + const int64_t M = rows_of(X, n); + if (M <= 0 || numel(Y) < M * w) return RAD_E_SHAPE; + float f[30]; + for (int64_t j = 0; j < F; ++j) + f[j] = pi ? (float)std::ldexp(3.14159265358979323846, (int)j) : std::ldexp(1.0f, (int)j); + + AVX_PARALLEL_FOR_IF(M * w >= AVX_PAR_MIN) + for (int64_t r = 0; r < M; ++r) { + float* acc = scratch_f32((size_t)w); + float* sx = scratch_f32_b((size_t)n); + const float* v = in_row(X, rowoff(X, r, n), n, sx); + for (int64_t i = 0; i < n; ++i) { + acc[i] = v[i]; + for (int64_t j = 0; j < F; ++j) { + const float t = v[i] * f[j]; + acc[n + i * F + j] = std::sin(t); + acc[n + n * F + i * F + j] = std::cos(t); + } + } + out_row(Y, rowoff(Y, r, w), w, acc); + } + return RAD_OK; +} + /* ------------------------------------------------------------------ position_scale */ /* Ministral 3's query multiplier is rounded before multiplication, as in libref. */ AVX_KERNEL(position_scale) { diff --git a/libavx/avx_glm.cpp b/libavx/avx_glm.cpp index 5c7d9b5f..783fd8c9 100644 --- a/libavx/avx_glm.cpp +++ b/libavx/avx_glm.cpp @@ -140,6 +140,87 @@ AVX_KERNEL(swiglu_clamped) { return RAD_OK; } +AVX_KERNEL(swiglu_step) { + if (!rad_args_have(a, 2)) return RAD_E_INVAL; + const auto &gu = a->t[0], &y = a->t[1]; + const int64_t n = p_int(a, "n", 0); + const float limit = p_f32(a, "limit", 0); + if (n < 1 || !std::isfinite(limit) || limit <= 0 || gu.rank != 2 || y.rank != 2 || !gu.data || + !y.data || y.shape[0] < 1 || gu.shape[0] != y.shape[0] || gu.shape[1] != 2 * n || + y.shape[1] != n) + return RAD_E_SHAPE; + AVX_PARALLEL_FOR_IF(y.shape[0] * n >= AVX_PAR_MIN) + for (int64_t r = 0; r < y.shape[0]; ++r) { + for (int64_t i = 0; i < n; ++i) { + const int64_t b = rowoff(&gu, r, 2 * n), s = laststride(&gu); + const float x = ldt(&gu, b + i * s); + const float g = std::min(x / (1.0f + std::exp(-x)), limit); + const float u = std::clamp(ldt(&gu, b + (n + i) * s), -limit, limit); + stt(&y, rowoff(&y, r, n) + i * laststride(&y), g * u); + } + } + return RAD_OK; +} + +AVX_KERNEL(router_sigmoid_group_topk) { + if (!rad_args_have(a, 4)) return RAD_E_INVAL; + const auto &lg = a->t[0], &bias = a->t[1], &ids = a->t[2], &w = a->t[3]; + const int64_t ne = p_int(a, "n_expert", 0), k = p_int(a, "top_k", 0), + ng = p_int(a, "n_group", 0), kg = p_int(a, "topk_group", 0); + const float factor = p_f32(a, "route_scale", 0); + if (ne < 1 || ne > 512 || k < 1 || ng < 1 || ne % ng || ne / ng < 2 || kg < 1 || kg > ng || + k > kg * (ne / ng) || !std::isfinite(factor) || factor <= 0 || lg.rank != 2 || + lg.shape[0] < 1 || lg.shape[1] != ne || bias.rank != 1 || bias.shape[0] != ne || + bias.dtype != RAD_F32 || ids.dtype != RAD_I32 || !matrix(ids, lg.shape[0], k) || + !matrix(w, lg.shape[0], k) || !lg.data || !bias.data) + return RAD_E_SHAPE; + const int64_t gs = ne / ng; + for (int64_t r = 0; r < lg.shape[0]; ++r) { + float prob[512], ranked[512], chosen[512], group[512]; + int index[512]; + bool kept[512] = {}; + for (int64_t e = 0; e < ne; ++e) { + prob[e] = 1.0f / (1.0f + std::exp(-ldt(&lg, rowoff(&lg, r, ne) + e * laststride(&lg)))); + ranked[e] = prob[e] + ldt(&bias, e * laststride(&bias)); + } + for (int64_t gi = 0; gi < ng; ++gi) { + float t0 = -INFINITY, t1 = -INFINITY; + for (int64_t e = gi * gs; e < (gi + 1) * gs; ++e) { + if (ranked[e] > t0) { t1 = t0; t0 = ranked[e]; } + else if (ranked[e] > t1) t1 = ranked[e]; + } + group[gi] = t0 + t1; + } + for (int64_t j = 0; j < kg; ++j) { + int winner = -1; + for (int64_t gi = 0; gi < ng; ++gi) + if (group[gi] > -INFINITY && (winner < 0 || group[gi] > group[winner])) + winner = (int)gi; + if (winner < 0) return RAD_E_SHAPE; + for (int64_t e = winner * gs; e < (winner + 1) * gs; ++e) kept[e] = true; + group[winner] = -INFINITY; + } + float total = 0; + for (int64_t j = 0; j < k; ++j) { + int winner = -1; + for (int64_t e = 0; e < ne; ++e) + if (kept[e] && ranked[e] > -INFINITY && (winner < 0 || ranked[e] > ranked[winner])) + winner = (int)e; + if (winner < 0) return RAD_E_SHAPE; + index[j] = winner; + chosen[j] = prob[winner]; + total += chosen[j]; + ranked[winner] = -INFINITY; + } + const float mult = p_int(a, "norm", 0) ? factor / (total + 1e-20f) : factor; + for (int64_t j = 0; j < k; ++j) { + st_int_dt(ids.dtype, ids.data, rowoff(&ids, r, k) + j * laststride(&ids), index[j]); + stt(&w, rowoff(&w, r, k) + j * laststride(&w), chosen[j] * mult); + } + } + return RAD_OK; +} + namespace { int64_t part_stride(int64_t hc) { return (hc * (hc + 2) + 1 + 3) / 4 * 4; } bool pre_params(const RadArgs* a, int64_t* n, int64_t* hc, int64_t* iters, float* eps, diff --git a/libavx/avx_isa.h b/libavx/avx_isa.h index 4f596752..f405b7b9 100644 --- a/libavx/avx_isa.h +++ b/libavx/avx_isa.h @@ -73,22 +73,28 @@ int avx_par_force(int threads); X(hc_read) X(hc_write) X(hc_project) X(mtp_enter) \ X(layernorm) X(mhc_pre) X(mhc_post) X(mhc_contract) \ X(kda_update) X(mhc_pre_partial) X(mhc_pre_finish) \ - X(swiglu_clamped) \ + X(swiglu_clamped) X(ssd_update) \ + X(swiglu_step) \ X(router_sigmoid_topk) \ + X(router_sigmoid_group_topk) \ X(dsa_pool) \ X(dsa_query) \ X(gemm_nt_f32) \ X(mla_project) \ X(dsa_score) \ X(mla_attn) \ + X(mla_attn_paged) \ X(add) X(grid_embed) X(grid_embed_aa) X(causal_conv1d) \ + X(grid_embed_cpe) \ + X(lili_cand) X(lili_attn) X(lili_factor) X(lili_walk) \ X(mul) X(silu_mul) X(gelu_mul) X(gelu) \ X(silu) X(sigmoid) X(logit_softcap) X(gather_rows) \ - X(scatter_rows) X(ngram_ids) \ + X(scatter_rows) X(ngram_ids) X(ple_conv_bias) \ X(ple_gate) X(ple_conv) X(cast) X(softmax) \ X(scale_rows) X(scale) X(fill) X(act_mul) \ X(seg_mean_bf16_sum) \ X(seg_mean) X(mul_weight) X(pool_rows) X(pool_cols) \ + X(point_fourier) \ X(seg_softmax_pool) \ X(relu) X(clamp) X(conv2d) X(conv1d_dw) \ X(rel_sinusoid) X(seg_sinusoid) X(conv2d_unfold) \ @@ -104,7 +110,7 @@ int avx_par_force(int threads); X(gemm_nt_q_gated) X(embed_lookup) X(embed_lookup_q) X(logits_gemm) \ X(lora_shrink) X(lora_expand) X(lora_expand_mm) \ /* ---- attention */ \ - X(attn_paged) X(attn_dense) X(attn_cross) X(attn_na3d) X(table_add) X(mix_rows) X(chan_stats) X(kv_store) X(kv_store_streamed) X(kv_resolve) X(rope) \ + X(attn_paged) X(attn_paged_sink) X(attn_dense) X(attn_cross) X(attn_na3d) X(table_add) X(mix_rows) X(chan_stats) X(kv_store) X(kv_store_streamed) X(kv_resolve) X(rope) \ X(rope_table) X(qk_norm_rope) X(qsa_block_key) X(attn_local_rel) \ X(qsa_score) X(qsa_select) X(qsa_tail_store) X(qsa_work) \ X(sam_attn) \ @@ -148,7 +154,8 @@ int avx_par_force(int threads); X(sample_topp) X(sample_minp) X(sample_typical) X(sample_xtc) \ X(sample_merge_topk) X(sample_mask) X(sample_pick) X(sample_argmax) \ X(sample_ngram_ban) X(sample_logprobs) X(dflash_select) X(dflash_conv) \ - X(dflash_tree) X(attn_paged_tree) + X(dflash_tree) X(attn_paged_tree) X(attn_paged_anchor_window) \ + X(dflash_markov_greedy) X(dflash_markov_greedy_f32) /* One ISA level's table: one member per op, in AVX_OP_LIST order. A missing definition is a link * error from that level's avx_table.cpp object. */ diff --git a/libavx/avx_lili.cpp b/libavx/avx_lili.cpp new file mode 100644 index 00000000..d1a37768 --- /dev/null +++ b/libavx/avx_lili.cpp @@ -0,0 +1,244 @@ +/* avx_lili.cpp -- LiLiCorr's candidate correlator, the contracts of libref/ref_lili.cpp: lili_cand, + * lili_attn, lili_factor and lili_walk. Small ops at a draft step's size (seven positions of eight + * candidates a sequence), so the arithmetic is libref's in its order, with the lattice's rows + * widened once into a panel and the rows or (sequence, head) units shared over the threads. + */ +#include "avx_vec.h" +#include "avx_common.h" + +#include +#include +#include +#include + +using namespace avx; + +/* ------------------------------------------------------------------ lili_cand */ +AVX_KERNEL(lili_cand) { + if (a->n_t < 11) return RAD_E_INVAL; + for (int i = 0; i < 11; ++i) if (!a->t[i].data) return RAD_E_INVAL; + const RadTensor *st = &a->t[0], *pas = &a->t[1], *lnw = &a->t[2], *lnb = &a->t[3]; + const RadTensor *upw = &a->t[4], *upb = &a->t[5], *slot = &a->t[6], *rank = &a->t[7]; + const RadTensor *cand = &a->t[8], *fo = &a->t[9], *bo = &a->t[10]; + const int64_t k = p_int(a, "k", 0), world = p_int(a, "world", 1), steps = p_int(a, "steps", 0); + const int64_t n = p_int(a, "n", 0); + const float eps = p_f32(a, "eps", 1e-5f); + const int64_t rk = p_int(a, "row_k", k); + if (k < 2 || k > 64 || rk < k || world < 1 || world > 16 || steps < 1 || n <= 0) + return RAD_E_SHAPE; + const int64_t w = 2 + 2 * rk; + const int64_t M = rows_of(st, world * w); + if (M <= 0 || rows_of(pas, n) < M || numel(cand) < M * k || rows_of(fo, n) < M * k || + rows_of(bo, n) < M * k) + return RAD_E_SHAPE; + if (numel(lnw) < 5 || numel(lnb) < 5 || numel(upw) < n * 5 || numel(upb) < n || + rows_of(slot, n) < steps || rows_of(rank, n) < k) + return RAD_E_SHAPE; + if (cand->dtype != RAD_I32) return RAD_E_DTYPE; + + /* The up projection widened once: [n, 5] and its bias. */ + std::vector uw((size_t)(n * 5)), ub((size_t)n); + for (int64_t i = 0; i < n * 5; ++i) uw[(size_t)i] = ldt(upw, i); + for (int64_t i = 0; i < n; ++i) ub[(size_t)i] = ldt(upb, i); + float lw[5], lb[5]; + for (int i = 0; i < 5; ++i) { lw[i] = ldt(lnw, i); lb[i] = ldt(lnb, i); } + + AVX_PARALLEL_FOR_IF(M >= 2) + for (int64_t m = 0; m < M; ++m) { + const int64_t sb = rowoff(st, m, world * w), ss = laststride(st); + auto S = [&](int64_t r, int64_t i) { return ldt(st, sb + (r * w + i) * ss); }; + float mx = -INFINITY; + for (int64_t r = 0; r < world; ++r) mx = std::max(mx, S(r, 0)); + double sum = 0.0; + for (int64_t r = 0; r < world; ++r) + if (S(r, 0) > -INFINITY) sum += (double)S(r, 1) * std::exp((double)S(r, 0) - mx); + const double lse = (double)mx + std::log(sum); + /* A world-way merge of lists sorted by value, ties to the lower id. */ + float lp[64]; + int64_t ids[64]; + int64_t at[16] = {}; + for (int64_t j = 0; j < k; ++j) { + int64_t br = -1; + float bv = 0.0f; + int64_t bid = 0; + for (int64_t r = 0; r < world; ++r) { + while (at[r] < k && (int64_t)S(r, 2 + 2 * at[r]) < 0) ++at[r]; + if (at[r] >= k) continue; + const float v = S(r, 3 + 2 * at[r]); + const int64_t id = (int64_t)S(r, 2 + 2 * at[r]); + if (br < 0 || v > bv || (v == bv && id < bid)) { br = r; bv = v; bid = id; } + } + ids[j] = br < 0 ? 0 : bid; + lp[j] = br < 0 ? -1e4f : (float)((double)bv - lse); + if (br >= 0) ++at[br]; + ((int32_t*)cand->data)[rowoff(cand, m, k) + j * laststride(cand)] = (int32_t)ids[j]; + } + const int64_t s = m % steps; + const int64_t pb = rowoff(pas, m, n), ps = laststride(pas); + const int64_t slb = rowoff(slot, s, n), sls = laststride(slot); + for (int64_t j = 0; j < k; ++j) { + const float f[5] = { lp[j], std::exp(lp[j]), lp[j] - lp[0], + (float)j / (float)(k - 1), j == 0 ? 1.0f : 0.0f }; + float mean = 0.0f; + for (int i = 0; i < 5; ++i) mean += f[i]; + mean /= 5.0f; + float var = 0.0f; + for (int i = 0; i < 5; ++i) var += (f[i] - mean) * (f[i] - mean); + var /= 5.0f; + const float rs = 1.0f / std::sqrt(var + eps); + float y[5]; + for (int i = 0; i < 5; ++i) y[i] = (f[i] - mean) * rs * lw[i] + lb[i]; + const int64_t row = m * k + j; + const int64_t fb = rowoff(fo, row, n), fs = laststride(fo); + const int64_t bb = rowoff(bo, row, n), bs = laststride(bo); + const int64_t rb = rowoff(rank, j, n), rks = laststride(rank); + for (int64_t c = 0; c < n; ++c) { + float u = ub[(size_t)c]; + for (int i = 0; i < 5; ++i) u += uw[(size_t)(c * 5 + i)] * y[i]; + stt(fo, fb + c * fs, u / (1.0f + std::exp(-u))); + stt(bo, bb + c * bs, + ldt(pas, pb + c * ps) + ldt(slot, slb + c * sls) + ldt(rank, rb + c * rks)); + } + } + } + return RAD_OK; +} + +/* ------------------------------------------------------------------ lili_attn */ +AVX_KERNEL(lili_attn) { + if (!rad_args_have(a, 4)) return RAD_E_INVAL; + const RadTensor *qkv = &a->t[0], *rel = &a->t[1], *same = &a->t[2], *o = &a->t[3]; + const int64_t steps = p_int(a, "steps", 0), k = p_int(a, "k", 0); + const int64_t nh = p_int(a, "n_head", 0), hd = p_int(a, "head_dim", 0); + if (steps < 1 || k < 1 || nh < 1 || hd < 1) return RAD_E_SHAPE; + const int64_t L = steps * k, n = nh * hd; + const int64_t M = rows_of(qkv, 3 * n); + if (M <= 0 || M % L || rows_of(o, n) < M) return RAD_E_SHAPE; + const int64_t rw = rel->rank ? rel->shape[rel->rank - 1] : 0; + if (rw < 2 * steps - 1 || rows_of(rel, rw) < nh || numel(same) < nh) return RAD_E_SHAPE; + const float scale = p_f32(a, "scale", 1.0f / std::sqrt((float)hd)); + const int64_t qs = laststride(qkv), os = laststride(o); + const int64_t units = (M / L) * nh; + + AVX_PARALLEL_FOR_IF(units >= 2) + for (int64_t u = 0; u < units; ++u) { + const int64_t q0 = u / nh * L, h = u % nh; + /* The lattice's q, k and v of this head, widened once. */ + float* pan = scratch_f32((size_t)(3 * L * hd + L) + 16); + float *Q = pan, *K = pan + L * hd, *V = pan + 2 * L * hd, *sc = pan + 3 * L * hd; + for (int64_t i = 0; i < L; ++i) { + const int64_t b = rowoff(qkv, q0 + i, 3 * n); + for (int64_t d = 0; d < hd; ++d) { + Q[i * hd + d] = ldt(qkv, b + (h * hd + d) * qs); + K[i * hd + d] = ldt(qkv, b + (n + h * hd + d) * qs); + V[i * hd + d] = ldt(qkv, b + (2 * n + h * hd + d) * qs); + } + } + const float sm = ldt(same, h); + const int64_t relb = rowoff(rel, h, rw), rels = laststride(rel); + for (int64_t i = 0; i < L; ++i) { + const int64_t si = i / k; + float mx = -INFINITY; + for (int64_t j = 0; j < L; ++j) { + float dot = 0.0f; + for (int64_t d = 0; d < hd; ++d) dot += Q[i * hd + d] * K[j * hd + d]; + const int64_t sj = j / k; + float b = ldt(rel, relb + (si - sj + steps) * rels); + if (si == sj) b += sm; + sc[j] = dot * scale + b; + mx = std::max(mx, sc[j]); + } + float sum = 0.0f; + for (int64_t j = 0; j < L; ++j) { sc[j] = std::exp(sc[j] - mx); sum += sc[j]; } + const int64_t ob = rowoff(o, q0 + i, n) + h * hd * os; + for (int64_t d = 0; d < hd; ++d) { + float acc = 0.0f; + for (int64_t j = 0; j < L; ++j) acc += sc[j] * V[j * hd + d]; + stt(o, ob + d * os, acc / sum); + } + } + } + return RAD_OK; +} + +/* ------------------------------------------------------------------ lili_factor */ +AVX_KERNEL(lili_factor) { + if (!rad_args_have(a, 3)) return RAD_E_INVAL; + const RadTensor *h = &a->t[0], *an = &a->t[1], *y = &a->t[2]; + const int64_t L = p_int(a, "L", 0), n = p_int(a, "n", 0); + if (L < 1 || n < 1) return RAD_E_SHAPE; + const int64_t M = rows_of(h, n); + if (M <= 0 || M % L || rows_of(an, n) < M / L || rows_of(y, 3 * n) < M) return RAD_E_SHAPE; + AVX_PARALLEL_FOR_IF(M >= 8) + for (int64_t i = 0; i < M; ++i) { + const int64_t hb = rowoff(h, i, n), ab = rowoff(an, i / L, n), yb = rowoff(y, i, 3 * n); + const int64_t hs = laststride(h), as = laststride(an), ys = laststride(y); + for (int64_t c = 0; c < n; ++c) { + const float hv = ldt(h, hb + c * hs), av = ldt(an, ab + c * as); + stt(y, yb + c * ys, hv); + stt(y, yb + (n + c) * ys, av); + stt(y, yb + (2 * n + c) * ys, hv * av); + } + } + return RAD_OK; +} + +/* ------------------------------------------------------------------ lili_walk */ +AVX_KERNEL(lili_walk) { + if (!rad_args_have(a, 4)) return RAD_E_INVAL; + const RadTensor *ed = &a->t[0], *ao = &a->t[1], *cd = &a->t[2], *tk = &a->t[3]; + const RadTensor* sco = a->n_t > 4 && a->t[4].data ? &a->t[4] : nullptr; + const int64_t steps = p_int(a, "steps", 0), k = p_int(a, "k", 0), n = p_int(a, "n", 0); + const float eps = p_f32(a, "eps", 1e-4f), scale = p_f32(a, "scale", 1.0f); + if (steps < 1 || k < 1 || n < 1) return RAD_E_SHAPE; + const int64_t M = rows_of(ao, n); + if (M <= 0 || rows_of(ed, 2 * n) < M * steps * k || numel(cd) < M * steps * k || + numel(tk) < M * steps) + return RAD_E_SHAPE; + if (cd->dtype != RAD_I32 || tk->dtype != RAD_I32) return RAD_E_DTYPE; + if (sco && numel(sco) < M * steps * k * k) return RAD_E_SHAPE; + + AVX_PARALLEL_FOR_IF(M >= 2) + for (int64_t m = 0; m < M; ++m) { + const int64_t R = steps * k; + float* pan = scratch_f32((size_t)((2 * R + 1) * n + R * k) + 16); + float *vo = pan, *vi = pan + R * n, *va = pan + 2 * R * n, *sc = pan + (2 * R + 1) * n; + auto vec = [&](const RadTensor* t, int64_t row, int64_t pitch, int64_t col0, float* v) { + const int64_t b = rowoff(t, row, pitch) + col0 * laststride(t), s = laststride(t); + double ss = 0.0; + for (int64_t c = 0; c < n; ++c) { v[c] = ldt(t, b + c * s); ss += (double)v[c] * v[c]; } + const float inv = 1.0f / std::max((float)std::sqrt(ss), eps); + for (int64_t c = 0; c < n; ++c) v[c] *= inv; + }; + vec(ao, m, n, 0, va); + for (int64_t r = 0; r < R; ++r) { + vec(ed, m * R + r, 2 * n, 0, vo + r * n); + vec(ed, m * R + r, 2 * n, n, vi + r * n); + } + auto dot = [&](const float* x, const float* y) { + float s = 0.0f; + for (int64_t c = 0; c < n; ++c) s += x[c] * y[c]; + return s * scale; + }; + for (int64_t j = 0; j < k; ++j) { + const float v = dot(va, vi + j * n); + for (int64_t i = 0; i < k; ++i) sc[i * k + j] = v; + } + for (int64_t s = 1; s < steps; ++s) + for (int64_t i = 0; i < k; ++i) + for (int64_t j = 0; j < k; ++j) + sc[(s * k + i) * k + j] = dot(vo + ((s - 1) * k + i) * n, vi + (s * k + j) * n); + int64_t prev = 0; + for (int64_t s = 0; s < steps; ++s) { + int64_t best = 0; + for (int64_t j = 1; j < k; ++j) + if (sc[(s * k + prev) * k + j] > sc[(s * k + prev) * k + best]) best = j; + const int64_t id = ldi(cd, rowoff(cd, m * steps + s, k) + best * laststride(cd)); + ((int32_t*)tk->data)[rowoff(tk, m, steps) + s * laststride(tk)] = (int32_t)id; + prev = best; + } + if (sco) + for (int64_t e = 0; e < R * k; ++e) stt(sco, m * R * k + e, sc[e]); + } + return RAD_OK; +} diff --git a/libavx/avx_misc.cpp b/libavx/avx_misc.cpp index 75b5cc6f..6c75714d 100644 --- a/libavx/avx_misc.cpp +++ b/libavx/avx_misc.cpp @@ -157,11 +157,12 @@ AVX_KERNEL(ple_gate) { struct ConvOps { const RadTensor *x, *w, *cs, *cu, *resid, *sidx, *hini, *nacc, *y; bool silu; + const RadTensor* b; /* per-channel bias inside the activation (Mamba-2's conv1d), or null */ }; static int depthwise_causal_conv(const RadArgs* a, const ConvOps& o) { const RadTensor *x = o.x, *w = o.w, *cs = o.cs, *cu = o.cu, *resid = o.resid; - const RadTensor *sidx = o.sidx, *hini = o.hini, *nacc = o.nacc, *y = o.y; + const RadTensor *sidx = o.sidx, *hini = o.hini, *nacc = o.nacc, *y = o.y, *b = o.b; if (!x || !w || !cs || !cu || !y) return RAD_E_INVAL; const int64_t n = p_int(a, "n", 0); @@ -180,6 +181,7 @@ static int depthwise_causal_conv(const RadArgs* a, const ConvOps& o) { if (N <= 0) return RAD_E_SHAPE; if (numel(x) < M * n || numel(y) < M * n || numel(w) < n * wid) return RAD_E_SHAPE; if (resid && numel(resid) < M * n) return RAD_E_SHAPE; + if (b && numel(b) != n) return RAD_E_SHAPE; const int64_t state_len = cs->rank >= 3 ? cs->shape[cs->rank - 1] : hist_len; if (cs->data && state_len < hist_len) return RAD_E_SHAPE; @@ -222,9 +224,10 @@ static int depthwise_causal_conv(const RadArgs* a, const ConvOps& o) { * on the stack, so `width` needs no bound of its own. */ float* tap = scratch_f32((size_t)wid); for (int64_t j = 0; j < wid; ++j) tap[j] = ldt(w, c * wrow + j * wcol); + const float bias = b ? ldt(b, c * laststride(b)) : 0.0f; for (int64_t t = 0; t < slen; ++t) { - float acc = 0.0f; + float acc = bias; for (int64_t j = 0; j < wid; ++j) { const int64_t src = t - hist_len + j * dil; const float vv = src >= 0 ? ldt(x, (bos + src) * xrow + c * xcol) @@ -277,6 +280,16 @@ AVX_KERNEL(ple_conv) { rad_arg_in(a, 6), rad_arg_in(a, 7), rad_arg_in(a, 8), true }); } +/* ple_conv's operands with `b`, a per-channel bias inside the silu, before `y`: Mamba-2's + * conv1d at dilation one. */ +AVX_KERNEL(ple_conv_bias) { + if (a->n_t < 10 || !rad_arg_in(a, 8)) return RAD_E_INVAL; + return depthwise_causal_conv(a, { rad_arg_in(a, 0), rad_arg_in(a, 1), rad_arg_in(a, 2), + rad_arg_in(a, 3), rad_arg_in(a, 4), rad_arg_in(a, 5), + rad_arg_in(a, 6), rad_arg_in(a, 7), rad_arg_in(a, 9), true, + rad_arg_in(a, 8) }); +} + /* ple_conv's operands without `resid`, dilation 1, no activation. */ AVX_KERNEL(causal_conv1d) { if (a->n_t < 8) return RAD_E_INVAL; diff --git a/libavx/avx_mla.cpp b/libavx/avx_mla.cpp index 94c82558..0bade3b5 100644 --- a/libavx/avx_mla.cpp +++ b/libavx/avx_mla.cpp @@ -55,6 +55,98 @@ AVX_KERNEL(mla_project) { return RAD_OK; } +/* libref's mla_attn_paged (libref/ref_mla.cpp): dense causal latent attention over a cache row of + * the latent then the rotated key part, one sequence's page table, an optional head gate. */ +AVX_KERNEL(mla_attn_paged) { + if (a->n_t < 8 || !rad_arg_in(a, 0) || !rad_arg_in(a, 2) || !rad_arg_in(a, 3) || + !rad_arg_in(a, 4) || !rad_arg_in(a, 5) || !rad_arg_in(a, 7)) + return RAD_E_INVAL; + RadTensor q = a->t[0], qr = a->t[1], o = a->t[7]; + const auto &kv = a->t[2], &bt = a->t[3], &su = a->t[4], &cu = a->t[5]; + const RadTensor* gate = rad_arg_in(a, 6); + const int64_t h = p_int(a, "heads", 0), L = p_int(a, "latent_dim", 0), + R = p_int(a, "rope_dim", 0), bs = p_int(a, "block_size", 0); + const float scale = p_f32(a, "scale", 0); + auto heads_view = [&](RadTensor& t, int64_t width) { + if (h > 0 && width > 0 && t.rank == 2 && t.shape[1] == h * width) { + t.rank = 3; + t.shape[1] = h; + t.shape[2] = width; + t.stride[2] = t.stride[1]; + t.stride[1] *= width; + } + }; + heads_view(q, L); + heads_view(qr, R); + heads_view(o, L); + if (h < 1 || L < 1 || L > 2048 || R < 0 || R > 2048 || bs < 1 || !std::isfinite(scale) || + scale <= 0 || q.rank != 3 || q.shape[0] < 1 || q.shape[1] != h || q.shape[2] != L || + (R && (!qr.data || qr.rank != 3 || qr.shape[0] != q.shape[0] || qr.shape[1] != h || + qr.shape[2] != R)) || + kv.rank != 4 || kv.shape[1] != 1 || kv.shape[2] != bs || kv.shape[3] < L + R || + bt.rank != 2 || su.rank != 1 || cu.rank != 1 || numel(&cu) != numel(&su) + 1 || + o.rank != 3 || o.shape[0] != q.shape[0] || o.shape[1] != h || o.shape[2] != L || + (gate && (gate->rank != 2 || gate->shape[0] != q.shape[0] || gate->shape[1] < h))) + return RAD_E_SHAPE; + const int64_t n_seq = numel(&su), rows = q.shape[0]; + auto cu_at = [&](int64_t i) { return ld_int_dt(cu.dtype, cu.data, i * laststride(&cu)); }; + if (cu_at(0) != 0 || cu_at(n_seq) != rows) return RAD_E_SHAPE; + AVX_PARALLEL_FOR_IF(rows * h * (L + R) * bt.shape[1] * bs >= AVX_PAR_MIN) + for (int64_t job = 0; job < rows * h; ++job) { + const int64_t r = job / h, head = job % h; + int64_t s = 0; + while (s + 1 < n_seq && cu_at(s + 1) <= r) ++s; + const int64_t qlen = cu_at(s + 1) - cu_at(s), i = r - cu_at(s); + const int64_t ctx = ld_int_dt(su.dtype, su.data, s * su.stride[0]); + const int64_t live = std::min(ctx - qlen + i + 1, bt.shape[1] * bs); + float *tmp = scratch_f32((size_t)(3 * L + 2 * R)), *query = tmp, *key = tmp + L, + *value = tmp + 2 * L, *qrot = tmp + 3 * L, *krot = qrot + R; + for (int64_t c = 0; c < L; ++c) { + query[c] = ldt(&q, r * q.stride[0] + head * q.stride[1] + c * q.stride[2]); + value[c] = 0; + } + for (int64_t c = 0; c < R; ++c) + qrot[c] = ldt(&qr, r * qr.stride[0] + head * qr.stride[1] + c * qr.stride[2]); + float max = -INFINITY, den = 0; + for (int64_t j = 0; j < live; ++j) { + const int64_t page = + ld_int_dt(bt.dtype, bt.data, s * bt.stride[0] + (j / bs) * bt.stride[1]); + if (page < 0 || page >= kv.shape[0]) continue; + const int64_t base = page * kv.stride[0] + (j % bs) * kv.stride[2]; + for (int64_t c = 0; c < L; ++c) key[c] = ldt(&kv, base + c * kv.stride[3]); + for (int64_t c = 0; c < R; ++c) krot[c] = ldt(&kv, base + (L + c) * kv.stride[3]); + vf acc = vf_zero(); + int64_t c = 0; + for (; c + VF_N <= L; c += VF_N) + acc = vf_fma(vf_loadu(query + c), vf_loadu(key + c), acc); + float score = vf_hsum(acc); + for (; c < L; ++c) score += query[c] * key[c]; + for (c = 0; c < R; ++c) score += qrot[c] * krot[c]; + score *= scale; + const float next = std::max(max, score), old = std::exp(max - next), + w = std::exp(score - next); + den = den * old + w; + max = next; + const vf a = vf_set1(old), b = vf_set1(w); + c = 0; + for (; c + VF_N <= L; c += VF_N) + vf_storeu(value + c, vf_fma(vf_loadu(key + c), b, vf_mul(vf_loadu(value + c), a))); + for (; c < L; ++c) value[c] = value[c] * old + key[c] * w; + } + float g = 1.0f; + if (gate) { + const float x = ldt(gate, r * gate->stride[0] + head * gate->stride[1]); + g = narrow1(RAD_BF16, 1.0f / (1.0f + std::exp(-x))); + } + for (int64_t c = 0; c < L; ++c) { + float v = den > 0 ? value[c] / den : 0; + if (gate) v = narrow1(RAD_BF16, v) * g; + stt(&o, r * o.stride[0] + head * o.stride[1] + c * o.stride[2], v); + } + } + return RAD_OK; +} + AVX_KERNEL(mla_attn) { if (!rad_args_have(a, 5)) return RAD_E_INVAL; const auto &q = a->t[0], &kv = a->t[1], &bt = a->t[2], &len = a->t[3], &out = a->t[4]; diff --git a/libavx/avx_ngram.cpp b/libavx/avx_ngram.cpp index d3fc404f..56ea2562 100644 --- a/libavx/avx_ngram.cpp +++ b/libavx/avx_ngram.cpp @@ -630,6 +630,10 @@ constexpr long long kOnDemandMaxRows = 4096; * below); such a gather never waits on another thread's claim, so the pause cannot close a cycle. */ std::atomic g_urgent_reads{0}; +/* The read-ahead reader thread's owner tag (0 before it starts): a decode gather reads a row that + * thread holds directly instead of waiting on it, so the g_urgent_reads pause cannot close a cycle. */ +std::atomic g_reader_tag{0}; + struct UrgentReads { UrgentReads() { g_urgent_reads.fetch_add(1, std::memory_order_acq_rel); } ~UrgentReads() { @@ -655,6 +659,8 @@ int gather_ondemand(const TableFile& tf, RowCache& rc, ReadRing& rr, const avx:: g.slot.resize((size_t)M); g.reads.clear(); g.again.clear(); + g.waits.clear(); + const uint64_t reader = g_reader_tag.load(std::memory_order_acquire); for (long long m = 0; m < M; ++m) { uint16_t* dst = q.out + m * x_ld; if (pad(row_of(m))) { std::memset(dst, 0, (size_t)ne * sizeof(uint16_t)); continue; } @@ -667,8 +673,13 @@ int gather_ondemand(const TableFile& tf, RowCache& rc, ReadRing& rr, const avx:: g.dst.push_back(dst); g.dm.push_back(m); g.dw.push_back(RowCache::ready(key)); + } else if (f == RowCache::THEIRS && s >= 0 && + ((rc.word[s].load(std::memory_order_acquire) >> 2) & 255) != reader) { + /* Another rank thread is reading it: wait below instead of reading it a second time + * (both ranks gather the same rows, so reading it again doubled decode's reads). */ + g.waits.push_back(m); } else { - /* THEIRS, MINE (a row twice in one call) and NONE are read directly: no wait. */ + /* The reader's THEIRS, MINE (a row twice in one call) and NONE are read directly. */ g.reads.push_back({m, key, f == RowCache::CLAIMED ? s : -1}); } } @@ -686,14 +697,37 @@ int gather_ondemand(const TableFile& tf, RowCache& rc, ReadRing& rr, const avx:: g.dw.push_back(RowCache::ready(r.key)); } } - if (g.src.empty()) return RAD_OK; - /* The seqlock, as gather_rows reads it: a row whose word changed during the decode was taken - * over, and is read again directly. */ - decode(g.src.data(), g.dst.data(), (int64_t)g.src.size(), ne, lut); - std::atomic_thread_fence(std::memory_order_acquire); - for (size_t i = 0; i < g.dm.size(); ++i) - if (rc.word[g.slot[g.dm[i]]].load(std::memory_order_relaxed) != g.dw[i]) - g.again.push_back(g.dm[i]); + /* Wait for the other rank's reads, as gather_rows does. This thread's own reads are done, so no cycle: the other rank reads its claims before it + * waits. A row that turns READY decodes from the cache; one released or taken over is read + * directly below. */ + while (!g.waits.empty()) { + const uint32_t e = rc.published.load(std::memory_order_acquire); + size_t keep = 0; + for (long long m : g.waits) { + const uint64_t key = key_of(m); + const uint64_t x = rc.word[g.slot[m]].load(std::memory_order_acquire); + if (x == RowCache::ready(key)) { + g.src.push_back(rc.data + (size_t)g.slot[m] * (size_t)n); + g.dst.push_back(q.out + m * x_ld); + g.dm.push_back(m); + g.dw.push_back(x); + continue; + } + if ((x & 3) == RowCache::LOADING && (x >> 10) == key) { g.waits[keep++] = m; continue; } + g.again.push_back(m); + } + g.waits.resize(keep); + if (keep) rc.published.wait(e, std::memory_order_acquire); + } + if (!g.src.empty()) { + /* The seqlock, as gather_rows reads it: a row whose word changed during the decode was + * taken over, and is read again directly. */ + decode(g.src.data(), g.dst.data(), (int64_t)g.src.size(), ne, lut); + std::atomic_thread_fence(std::memory_order_acquire); + for (size_t i = 0; i < g.dm.size(); ++i) + if (rc.word[g.slot[g.dm[i]]].load(std::memory_order_relaxed) != g.dw[i]) + g.again.push_back(g.dm[i]); + } if (g.again.empty()) return RAD_OK; g.reads.clear(); for (long long m : g.again) g.reads.push_back({m, key_of(m), -1}); @@ -817,8 +851,8 @@ int gather_rows(const TableFile& tf, RowCache& rc, ReadRing& rr, const avx::RowG * list adds nothing. A list that does not continue the previous one (another request's prompt) * drops the jobs still queued for the previous one. * - * The reader reads in batches of kReaderBatch rows and starts none while a decode-sized gather is - * reading (g_urgent_reads), so a decode step's few reads do not queue in the drive behind a + * The reader keeps up to kReaderBatch reads in the drive, starting one as each lands, and starts + * none while a decode-sized gather is reading (g_urgent_reads), so a decode step's few reads do not queue in the drive behind a * prefetch's thousands. A failed read releases its claims and the next call reads those rows * itself. The reader is detached and never destroyed. */ @@ -833,6 +867,105 @@ constexpr size_t kJobRows = 8192; * the most a decode step's reads can find ahead of them; 128 still keeps an NVMe queue busy. */ constexpr size_t kReaderBatch = 128; +/* The reader's claimed rows `reads[0, total)` (each with a slot), with at most `depth` in the drive + * at once, a new read submitted as each completes, and each row published READY as it lands: waiting + * for whole batches let the drive's queue drain at the end of each (40k reads/s against 46k). While a decode-sized gather is reading, no new read starts; + * the ones in flight drain first, so at most `depth` reads are ever ahead of a decode step's (as + * with the stock batches). On a failed read every unpublished claim is released. */ +int stream_publish(const TableFile& tf, RowCache& rc, ReadRing& rr, Gather& g, + const SpanRead* reads, size_t total, long long n, size_t depth) { + const long long A = tf.align; + const long long stride = ((n + A - 1) / A + 1) * A; + if (depth > rr.entries) depth = rr.entries; + if (depth > 0xffff) depth = 0xffff; + static thread_local std::vector freebuf; + static thread_local std::vector landed; + landed.assign(total, 0); + uint8_t* bounce = g.bounce_for(depth * (size_t)stride, (size_t)A); + int status = bounce ? RAD_OK : RAD_E_NOMEM; + freebuf.clear(); + for (size_t d = 0; d < depth; ++d) freebuf.push_back((uint32_t)(depth - 1 - d)); + size_t next = 0, inflight = 0; + unsigned pending = 0; /* queued in the SQ, not yet submitted */ + while (status == RAD_OK && (next < total || inflight)) { + if (inflight == 0 && pending == 0) + for (int u; (u = g_urgent_reads.load(std::memory_order_acquire)) > 0;) + g_urgent_reads.wait(u, std::memory_order_acquire); + const bool may_start = g_urgent_reads.load(std::memory_order_acquire) == 0; + unsigned tail = __atomic_load_n(rr.sq_tail, __ATOMIC_RELAXED); + unsigned add = 0; + while (may_start && next < total && !freebuf.empty()) { + const uint32_t buf = freebuf.back(); + freebuf.pop_back(); + const SpanRead& r = reads[next]; + const long long a = (long long)r.key & ~(A - 1); + const long long e = ((long long)r.key + n + A - 1) & ~(A - 1); + const unsigned idx = tail & *rr.sq_mask; + io_uring_sqe* s = &rr.sqes[idx]; + std::memset(s, 0, sizeof *s); + s->opcode = IORING_OP_READ; + s->fd = tf.fd; + s->off = (uint64_t)a; + s->addr = (uint64_t)(uintptr_t)(bounce + (size_t)buf * (size_t)stride); + s->len = (unsigned)(e - a); + s->user_data = (uint64_t)next << 16 | buf; + rr.sq_array[idx] = idx; + ++tail; ++add; ++next; ++inflight; + } + if (add) __atomic_store_n(rr.sq_tail, tail, __ATOMIC_RELEASE); + pending += add; + if (!inflight) continue; + const long rc_ = syscall(__NR_io_uring_enter, rr.fd, pending, 1u, IORING_ENTER_GETEVENTS, + nullptr, (size_t)0); + if (rc_ < 0 && errno != EINTR && errno != EAGAIN && errno != EBUSY) { status = RAD_E_IO; break; } + if (rc_ > 0) pending -= (unsigned)rc_ < pending ? (unsigned)rc_ : pending; + unsigned h = __atomic_load_n(rr.cq_head, __ATOMIC_RELAXED); + const unsigned tl = __atomic_load_n(rr.cq_tail, __ATOMIC_ACQUIRE); + unsigned got = 0; + for (; h != tl; ++h) { + const io_uring_cqe& c = rr.cqes[h & *rr.cq_mask]; + const size_t i = (size_t)(c.user_data >> 16); + const uint32_t buf = (uint32_t)(c.user_data & 0xffff); + --inflight; + freebuf.push_back(buf); + const SpanRead& r = reads[i]; + const long long a = (long long)r.key & ~(A - 1); + const long long e = ((long long)r.key + n + A - 1) & ~(A - 1); + if (c.res < 0 || (long long)c.res != e - a) { status = RAD_E_IO; continue; } + const uint8_t* row = bounce + (size_t)buf * (size_t)stride + (r.key & (uint64_t)(A - 1)); + std::memcpy(rc.data + (size_t)r.slot * (size_t)n, row, (size_t)n); + rc.ref[r.slot].store(1, std::memory_order_relaxed); + rc.word[r.slot].store(RowCache::ready(r.key), std::memory_order_release); + landed[i] = 1; + ++got; + } + __atomic_store_n(rr.cq_head, h, __ATOMIC_RELEASE); + if (got) { + g_rows_read.fetch_add(got, std::memory_order_relaxed); + rc.published.fetch_add(1, std::memory_order_release); + rc.published.notify_all(); + } + } + /* After an error, drain what is still in flight so the ring is clean for the next job. */ + while (inflight) { + const long rc_ = syscall(__NR_io_uring_enter, rr.fd, pending, 1u, IORING_ENTER_GETEVENTS, + nullptr, (size_t)0); + if (rc_ < 0 && errno != EINTR && errno != EAGAIN && errno != EBUSY) break; + if (rc_ > 0) pending -= (unsigned)rc_ < pending ? (unsigned)rc_ : pending; + unsigned h = __atomic_load_n(rr.cq_head, __ATOMIC_RELAXED); + const unsigned tl = __atomic_load_n(rr.cq_tail, __ATOMIC_ACQUIRE); + for (; h != tl; ++h) --inflight; + __atomic_store_n(rr.cq_head, h, __ATOMIC_RELEASE); + } + if (status != RAD_OK) { + for (size_t i = 0; i < total; ++i) + if (!landed[i]) rc.word[reads[i].slot].store(RowCache::EMPTY, std::memory_order_release); + rc.published.fetch_add(1, std::memory_order_release); + rc.published.notify_all(); + } + return status; +} + /* Tries at matching a list against the previous one (read_ahead) before it counts as new. */ constexpr int kShiftTries = 64; @@ -883,6 +1016,7 @@ struct AheadReader { Gather& g = gather_state(); ReadRing* rr = read_ring(nullptr); const uint64_t me = owner_tag(); + g_reader_tag.store(me, std::memory_order_release); for (;;) { AheadJob j; { @@ -907,21 +1041,9 @@ struct AheadReader { else if (f == RowCache::NONE && !j.retry) retry.push_back(j.keys[i]); } - /* Every read has a slot, so nothing is decoded and there is no output. */ - for (size_t b = 0; b < g.reads.size(); b += kReaderBatch) { - for (int u; (u = g_urgent_reads.load(std::memory_order_acquire)) > 0;) - g_urgent_reads.wait(u, std::memory_order_acquire); - const size_t cnt = std::min(kReaderBatch, g.reads.size() - b); - if (read_and_publish(*j.tf, *j.rc, *rr, g, &g.reads[b], cnt, j.n, 0, nullptr, - nullptr, nullptr, 0) == RAD_OK) - continue; - /* The failed batch released its own claims; the later batches' go too. */ - for (size_t i = b + cnt; i < g.reads.size(); ++i) - j.rc->word[g.reads[i].slot].store(RowCache::EMPTY, std::memory_order_release); - j.rc->published.fetch_add(1, std::memory_order_release); - j.rc->published.notify_all(); - break; - } + /* Every read has a slot, so nothing is decoded and there is no output; a failed read + * releases every claim not yet published. */ + stream_publish(*j.tf, *j.rc, *rr, g, g.reads.data(), g.reads.size(), j.n, kReaderBatch); if (!retry.empty()) { std::lock_guard lk(mu); AheadJob r; diff --git a/libavx/avx_norm.cpp b/libavx/avx_norm.cpp index 79e95665..cf2876e6 100644 --- a/libavx/avx_norm.cpp +++ b/libavx/avx_norm.cpp @@ -352,3 +352,70 @@ AVX_KERNEL(grid_embed_aa) { } return RAD_OK; } + +/* ------------------------------------------------------------------ grid_embed_cpe */ +/* Adds the table resampled as torch's F.interpolate(bilinear, align_corners=False) does without + * antialias, onto a square of the grid's larger side and cropped to the grid (RADIO's cropped + * position embedding); matches libref's grid_embed_cpe operation for operation. */ +static void cpe_taps(int64_t at, int64_t d, int64_t side, int64_t t[2], float w[2]) { + if (d < 1) d = 1; + at = at < 0 ? 0 : (at >= d ? d - 1 : at); + float src = (float)side / (float)d * ((float)at + 0.5f) - 0.5f; + if (src < 0.0f) src = 0.0f; + int64_t i0 = (int64_t)src; + if (i0 > side - 1) i0 = side - 1; + t[0] = i0; + t[1] = i0 < side - 1 ? i0 + 1 : i0; + w[1] = src - (float)i0; + w[0] = 1.0f - w[1]; +} + +AVX_KERNEL(grid_embed_cpe) { + if (!rad_args_have(a, 3)) return RAD_E_INVAL; + const RadTensor *x = &a->t[0], *tab = &a->t[1], *crd = &a->t[2]; + const int64_t n = p_int(a, "n", tab->rank ? tab->shape[tab->rank - 1] : 0); + const int64_t side = p_int(a, "side", 0); + if (n <= 0 || side <= 0 || numel(tab) < side * side * n) return RAD_E_SHAPE; + const int64_t rows = rows_of(x, n); + if (rows <= 0 || crd->rank != 2 || crd->shape[0] < 4 || crd->shape[1] < rows) + return RAD_E_SHAPE; + const int64_t cs = crd->stride[0], ms = crd->stride[1]; + const int64_t ts = laststride(tab); + + /* The prefix rows, when n_prefix names some; without it the operand is not read. */ + const int64_t npre = p_int(a, "n_prefix", 0); + const RadTensor* pre = npre > 0 && a->n_t > 3 && a->t[3].data ? &a->t[3] : nullptr; + if (npre > 0 && (!pre || numel(pre) < npre * n)) return RAD_E_SHAPE; + + AVX_PARALLEL_FOR_IF(rows * n >= AVX_PAR_MIN) + for (int64_t r = 0; r < rows; ++r) { + int64_t g[4]; + for (int c = 0; c < 4; ++c) g[c] = ldi(crd, c * cs + r * ms); + if (g[0] < 0) { + /* A row ahead of its segment's patches: the learned row its column names. */ + const int64_t k = g[1] < 0 ? 0 : (g[1] >= npre ? npre - 1 : g[1]); + const int64_t xb0 = rowoff(x, r, n), xs0 = laststride(x); + for (int64_t i = 0; npre > 0 && i < n; ++i) { + const float pe = round_act(x->dtype, ldt(pre, rowoff(pre, k, n) + i * laststride(pre))); + stt(x, xb0 + i * xs0, ldt(x, xb0 + i * xs0) + pe); + } + continue; + } + const int64_t d = g[2] > g[3] ? g[2] : g[3]; + int64_t th[2], tw[2]; + float wh[2], ww[2]; + cpe_taps(g[0], d, side, th, wh); + cpe_taps(g[1], d, side, tw, ww); + const int64_t xb = rowoff(x, r, n), xs = laststride(x); + auto at = [&](int64_t y, int64_t c, int64_t i) { + return ldt(tab, rowoff(tab, y * side + c, n) + i * ts); + }; + for (int64_t i = 0; i < n; ++i) { + const float r0 = ww[0] * at(th[0], tw[0], i) + ww[1] * at(th[0], tw[1], i); + const float r1 = ww[0] * at(th[1], tw[0], i) + ww[1] * at(th[1], tw[1], i); + const float pe = round_act(x->dtype, wh[0] * r0 + wh[1] * r1); + stt(x, xb + i * xs, ldt(x, xb + i * xs) + pe); + } + } + return RAD_OK; +} diff --git a/libavx/avx_registry.cpp b/libavx/avx_registry.cpp index 465ef0ae..1dbd2e55 100644 --- a/libavx/avx_registry.cpp +++ b/libavx/avx_registry.cpp @@ -87,6 +87,11 @@ static const RadParamSpec pKdaUpdate[] = { P_INT("M"), P_INT("heads"), P_INT("he static const RadOperandSpec oKdaUpdate[] = { OPD("q"), OPD("k"), OPD("v"), OPD("a"), OPD("b"), WGT("A_log"), WGT("dt_bias"), INOUT("state"), OPD("state_idx"), OPD("cu"), OPD_O("num_accepted"), OPD_O("has_init"), OUT("o") }; +static const RadParamSpec pSsdUpdate[] = { P_INT("M"), P_INT("heads"), P_INT("head_dim"), + P_INT("d_state"), P_INT("groups"), P_STR("mode"), P_STR("dtype"), P_STRO("state_form") }; +static const RadOperandSpec oSsdUpdate[] = { OPD("x"), OPD("B"), OPD("C"), OPD("dt"), + WGT("A_log"), WGT("dt_bias"), WGT("D"), INOUT("state"), OPD("state_idx"), OPD("cu"), + OPD_O("num_accepted"), OPD_O("has_init"), OUT("o") }; static const RadParamSpec pNgramIds[] = { P_INT("M"), P_INT("heads"), P_INT("ngram"), P_INT("eos") }; @@ -106,6 +111,11 @@ static const RadParamSpec pPleConv[] = { P_INT("M"), P_INT("n"), P_INT("width" static const RadOperandSpec oPleConv[] = { OPD("x"), WGT("w"), INOUT("conv_state"), OPD("cu"), OPD_O("resid"), OPD_O("cache_idx"), OPD_O("has_init"), OPD_O("num_accepted"), OUT("y") }; +/* ple_conv's operands with `b`, a per-channel bias inside the silu, before `y`. */ +static const RadOperandSpec oPleConvBias[] = { OPD("x"), WGT("w"), INOUT("conv_state"), OPD("cu"), + OPD_O("resid"), OPD_O("cache_idx"), + OPD_O("has_init"), OPD_O("num_accepted"), WGT("b"), + OUT("y") }; static const RadParamSpec pCausalConv[] = { P_INT("M"), P_INT("n"), P_INT("width"), P_STR("dtype") }; static const RadOperandSpec oCausalConv[] = { OPD("x"), WGT("w"), INOUT("conv_state"), OPD("cu"), @@ -134,14 +144,38 @@ static const RadParamSpec pLayernorm[] = { P_INT("M"), P_INT("n"), P_F64("eps" static const RadOperandSpec oLayernorm[] = { OPD("x"), WGT("w"), WGT_O("b"), OUT("y") }; static const RadParamSpec pGridEmbed[] = { P_INT("M"), P_INT("n"), P_INT("side"), P_STR("dtype") }; static const RadOperandSpec oGridEmbed[] = { INOUT("x"), WGT("table"), OPD("coord") }; +static const RadParamSpec pGridEmbedCpe[] = { P_INT("M"), P_INT("n"), P_INT("side"), P_STR("dtype"), + P_INTO("n_prefix") }; +static const RadOperandSpec oGridEmbedCpe[] = { INOUT("x"), WGT("table"), OPD("coord"), WGT_O("prefix") }; +/* LiLiCorr's correlator (avx_lili.cpp; libref/ref_lili.cpp has the contracts). */ +static const RadParamSpec pLiliCand[] = { P_INT("M"), P_INT("k"), P_INT("world"), P_INT("steps"), + P_INT("n"), P_STR("dtype"), P_F64O("eps"), + P_INTO("row_k") }; +static const RadOperandSpec oLiliCand[] = { OPD("stats"), OPD("pas"), WGT("ln_w"), WGT("ln_b"), + WGT("up_w"), WGT("up_b"), WGT("slot"), WGT("rank"), + OUT("cand"), OUT("feat"), OUT("base") }; +static const RadParamSpec pLiliAttn[] = { P_INT("M"), P_INT("steps"), P_INT("k"), P_INT("n_head"), + P_INT("head_dim"), P_STR("dtype"), P_F64O("scale") }; +static const RadOperandSpec oLiliAttn[] = { OPD("qkv"), WGT("rel"), WGT("same"), OUT("out") }; +static const RadParamSpec pLiliFactor[] = { P_INT("M"), P_INT("L"), P_INT("n"), P_STR("dtype") }; +static const RadOperandSpec oLiliFactor[] = { OPD("h"), OPD("a"), OUT("y") }; +static const RadParamSpec pLiliWalk[] = { P_INT("M"), P_INT("steps"), P_INT("k"), P_INT("n"), + P_STR("dtype"), P_F64O("eps"), P_F64O("scale") }; +static const RadOperandSpec oLiliWalk[] = { OPD("edges"), OPD("aout"), OPD("cand"), OUT("tokens"), + OUT_O("scores") }; static const RadParamSpec pSwigluClamped[] = { P_INT("M"), P_INT("n"), P_F64("limit"), P_STR("dtype") }; static const RadParamSpec pDsaPool[] = { P_INT("M"), P_INT("n"), P_INT("ratio"), P_STR("dtype"), P_INTO("block_size") }; +/* `kv_dtype`: the latent cache's dtype when it is not the query's (fp8_e4m3, at descale 1). */ static const RadParamSpec pMlaAttn[] = { P_INT("M"), P_INT("latent_dim"), P_INT("heads"), - P_INT("blocks"), P_INT("block_size"), P_F64("scale"), P_STR("dtype") }; + P_INT("blocks"), P_INT("block_size"), P_F64("scale"), P_STR("dtype"), P_STRO("kv_dtype") }; static const RadParamSpec pMlaProject[] = { P_INT("M"), P_INT("heads"), P_INT("head_dim"), P_INT("latent_dim"), P_STR("mode"), P_STR("dtype") }; static const RadOperandSpec oMlaAttn[] = { OPD("q"), OPD("kv"), OPD("bt"), OPD("length"), OUT("out") }; +static const RadParamSpec pMlaAttnPaged[] = { P_INT("M"), P_INT("heads"), P_INT("latent_dim"), + P_INT("rope_dim"), P_INT("block_size"), P_F64("scale"), P_STR("dtype") }; +static const RadOperandSpec oMlaAttnPaged[] = { OPD("q"), OPD_O("q_rope"), OPD("kv"), + OPD("block_table"), OPD("seqused"), OPD("cu_seqlens"), OPD_O("gate"), OUT("out") }; static const RadParamSpec pDsaScore[] = { P_INT("M"), P_INT("n"), P_INT("heads"), P_INT("blocks"), P_INT("seqs"), P_STR("dtype"), P_INTO("row_part") }; static const RadOperandSpec oDsaScore[] = { OPD("q"), OPD("q_scale"), OPD("gate"), OPD("k"), @@ -151,6 +185,8 @@ static const RadOperandSpec oDsaPool[] = { OPD("kg"), WGT("ape"), OUT("q"), OUT( static const RadParamSpec pRouterSigmoid[] = { P_INT("M"), P_INT("n_expert"), P_INT("top_k"), P_INT("norm"), P_F64("route_scale"), P_STR("dtype") }; static const RadOperandSpec oRouterSigmoid[] = { OPD("logits"), WGT("bias"), OUT("ids"), OUT("weights") }; +static const RadParamSpec pRouterSigmoidGroup[] = { P_INT("M"), P_INT("n_expert"), P_INT("top_k"), + P_INT("n_group"), P_INT("topk_group"), P_INT("norm"), P_F64("route_scale"), P_STR("dtype") }; static const RadParamSpec pMnD[] = { P_INT("M"), P_INT("n"), P_STR("dtype") }; /* `add`'s `div` divides the rounded sum (libref's pAdd). */ static const RadParamSpec pAdd[] = { P_INT("M"), P_INT("n"), P_STR("dtype"), P_F64O("div") }; @@ -166,6 +202,8 @@ static const RadParamSpec pSegPool[] = { P_INT("M"), P_INT("n"), P_STR("dtype") static const RadOperandSpec oSegPool[] = { OPD("score"), OPD("v"), OPD("cu_seqlens"), OUT("y") }; static const RadParamSpec pPoolRows[] = { P_INT("M"), P_INT("n"), P_INT("k"), P_F64O("mult"), P_STR("dtype") }; +static const RadParamSpec pPointFourier[] = { P_INT("M"), P_INT("n"), P_INT("freqs"), P_INTO("pi"), + P_STR("dtype") }; static const RadOperandSpec oGateUp[] = { OPD("gate_up"), OUT("y") }; static const RadOperandSpec oUnary[] = { OPD("x"), OUT("y") }; /* The audio (USM conformer) tower's operators, as in libref. */ @@ -305,6 +343,12 @@ static const RadOperandSpec oAttnPagedTree[] = { OPD("q"), OPD("kv_cache"), OPD("block_table"), OPD("seqused"), OPD_O("k_descale"), OPD_O("v_descale"), OPD_O("cu_seqlens"), OUT("out"), OPD("spec_parent") }; + +/* attn_paged with a learned sink logit a query head; a name of its own (libref's file comment). */ +static const RadOperandSpec oAttnPagedSink[] = { + OPD("q"), OPD("kv_cache"), OPD("block_table"), OPD("seqused"), + OPD_O("k_descale"), OPD_O("v_descale"), OPD_O("cu_seqlens"), WGT("sinks"), OUT("out") +}; static const RadConstraint cPagedBlock[] = { RAD_CGE("block_size", 1) }; static const RadParamSpec pAttnDense[] = { P_INT("M"), P_INT("head_dim"), P_INT("gqa"), @@ -891,7 +935,7 @@ static const RadOperandSpec oTopk[] = { OPD("logits"), OPD("params"), static const RadOperandSpec oArgmax[] = { OPD("logits"), OPD("params"), OUT("token") }; static const RadParamSpec pLogprobs[] = { P_INT("M"), P_INT("n_vocab"), P_INT("k"), P_INTO("vocab_off") }; -static const RadOperandSpec oLogprobs[] = { OPD("logits"), OPD("params"), OUT("stats") }; +static const RadOperandSpec oLogprobs[] = { OPD("logits"), OPD_O("params"), OUT("stats") }; static const RadOperandSpec oNarrow[] = { INOUT("cand_idx"), INOUT("cand_val"), OPD("params") }; static const RadOperandSpec oPick[] = { OPD("cand_idx"), OPD("cand_val"), OPD("params"), OUT("token") }; @@ -905,6 +949,12 @@ static const RadParamSpec pDflashSelect[] = { P_INT("M"), P_INT("steps"), P_I static const RadOperandSpec oDflashSelect[] = { OPD("cand"), OPD("unary"), OPD_O("hp"), OPD("anchor"), WGT("pred"), WGT("succ"), OUT("tokens") }; +static const RadParamSpec pDflashMarkov[] = { P_INT("M"), P_INT("steps"), P_INT("rank"), + P_INT("n_vocab"), P_INTO("anchor_stride"), + P_STR("dtype") }; +static const RadOperandSpec oDflashMarkov[] = { OPD("logits"), OPD("anchor"), WGT("pred"), + WGT("succ"), OUT("tile_scores"), + OUT("tile_tokens"), OUT("tokens") }; static const RadParamSpec pDflashTree[] = { P_INT("M"), P_INT("steps"), P_INT("top_k"), P_INT("rank"), P_INT("n_vocab"), P_INTO("anchor_stride"), P_INT("nodes"), @@ -941,6 +991,7 @@ static const RadOpSchema kSchemas[] = { { "mhc_post", ARR(pHcWrite), ARR(oMhcPost), "Source-to-destination manifold residual update." }, { "mhc_contract", ARR(pHcWrite), ARR(oMhcContract), "Mean over manifold residual streams." }, { "kda_update", ARR(pKdaUpdate), ARR(oKdaUpdate), "Bounded per-channel KDA with candidate-state rollback." }, +{ "ssd_update", ARR(pSsdUpdate), ARR(oSsdUpdate), "Mamba-2 scalar-decay state update with candidate-state rollback, per_candidate or anchor." }, { "hc_read", ARR(pHcRead), ARR(oHcRead), "The read half of a gated residual: grouped norm, low-rank gate, stream mix, and optionally the " "block-scaled fp8 form of x and its Hadamard-rotated twin. See docs/OPS.md for the three facts " @@ -959,6 +1010,20 @@ static const RadOpSchema kSchemas[] = { "x += a side x side position table resampled bilinearly to the row's grid." }, { "grid_embed_aa", ARR(pGridEmbed), ARR(oGridEmbed), "x += the table resampled as torch's antialiased half-pixel bilinear, SigLIP2's." }, +{ "lili_cand", ARR(pLiliCand), ARR(oLiliCand), + "LiLiCorr's candidates from the ranks' sample_logprobs rows, their rank features through " + "layernorm, the up projection and silu, and the lattice rows' additive part." }, +{ "lili_attn", ARR(pLiliAttn), ARR(oLiliAttn), + "attention over each sequence's candidate lattice with a learned bias on slot distance and the " + "same slot." }, +{ "lili_factor", ARR(pLiliFactor), ARR(oLiliFactor), + "[h | a | h * a] a lattice row, a its sequence's anchor." }, +{ "lili_walk", ARR(pLiliWalk), ARR(oLiliWalk), + "LiLiCorr's normalised edge scores and their greedy walk." }, +{ "grid_embed_cpe", ARR(pGridEmbedCpe), ARR(oGridEmbedCpe), + "x += the table resampled half-pixel bilinear (no antialias) onto a square of the grid's larger " + "side and cropped to the grid: RADIO's cropped position embedding. A row with a negative row " + "coordinate gets the learned prefix row its column names." }, { "add", ARR(pAdd), ARR(oBinary), "y = a + b; a `b` of exactly n elements against a taller output broadcasts along rows. With " "`div`, y = rd(rd(a + b) / div), bit for bit libref's." }, @@ -966,7 +1031,8 @@ static const RadOpSchema kSchemas[] = { { "mul_weight", ARR(pMulWeight), ARR(oMulWeight), "y = x * w, `w` a weight of one element or one row, broadcast; f32 product rounded once." }, { "act_mul", ARR(pActMul), ARR(oBinary), - "y = act(a) * b, act silu / gelu / gelu_tanh, the activation rounded to y's dtype first." }, + "y = act(a) * b, act silu / gelu / gelu_tanh / sigmoid / quick_gelu / relu, the activation " + "rounded to y's dtype first." }, { "seg_mean_bf16_sum", ARR(pSegMean), ARR(oSegMean), "BF16 masked mean: f32 segment sum rounded to BF16 before division, then BF16 output." }, { "seg_mean", ARR(pSegMean), ARR(oSegMean), @@ -992,8 +1058,16 @@ static const RadOpSchema kSchemas[] = { { "pool_cols", ARR(pPoolRows), ARR(oUnary), "y[m][c] = the mean of x[m]'s columns [c*k, c*k + k), rounded to y's dtype, times mult, rounded " "again." }, +{ "point_fourier", ARR(pPointFourier), ARR(oUnary), + "A point's Fourier features: row m of y is [x | sin(x_i f_j) | cos(x_i f_j)] over x's n values, " + "sines then cosines each i-major then j, f_j = 2^j for j < freqs (times pi with `pi` 1); the " + "products f32, the sine and cosine f32 rounded once to y's dtype. y is [M, n (2 freqs + 1)]." }, { "mla_attn", ARR(pMlaAttn), ARR(oMlaAttn), "Softmax over selected latent vectors used as both key and value; per-query page tables and visible lengths." }, +{ "mla_attn_paged", ARR(pMlaAttnPaged), ARR(oMlaAttnPaged), + "Dense causal latent attention over a paged cache whose token row is the latent then the rotated " + "key part: score = scale * (q . latent + q_rope . rope), value = the latent; sequences as in " + "attn_paged. With `gate`, out = bf16(bf16(out) * bf16(sigmoid(gate[head])))." }, { "mla_project", ARR(pMlaProject), ARR(oGemm), "Per-head query absorption or value expansion through the shared [head,(K|V),latent] BF16 matrix." }, { "dsa_score", ARR(pDsaScore), ARR(oDsaScore), @@ -1004,6 +1078,8 @@ static const RadOpSchema kSchemas[] = { "Normalized Hadamard, BF16 boundary and power-of-two E4M3 quantization per query head." }, { "dsa_pool", ARR(pDsaPool), ARR(oDsaPool), "Channel-wise softmax pooling with learned position bias, BF16, normalized Hadamard, BF16, power-of-two FP8." }, +{ "swiglu_step", ARR(pSwigluClamped), ARR(oGateUp), + "min(silu(gate),limit)*clamp(up,-limit,limit); gate is the first half." }, { "swiglu_clamped", ARR(pSwigluClamped), ARR(oGateUp), "silu(min(gate,limit))*clamp(up,-limit,limit); gate is the first half." }, { "silu_mul", ARR(pMnD), ARR(oGateUp), @@ -1021,6 +1097,8 @@ static const RadOpSchema kSchemas[] = { "PLE gate: three grouped norms, a dot, a signed sqrt." }, { "ple_conv", ARR(pPleConv), ARR(oPleConv), "PLE's dilated depthwise conv, silu and residual add." }, +{ "ple_conv_bias", ARR(pPleConv), ARR(oPleConvBias), + "ple_conv with a per-channel bias inside the silu (Mamba-2's conv1d)." }, { "causal_conv1d", ARR(pCausalConv), ARR(oCausalConv), "depthwise causal conv with ple_conv's window, no activation and no residual (LFM2)." }, { "ngram_ids", ARR(pNgramIds), ARR(oNgramIds), "hashed n-gram row ids for PLE." }, @@ -1092,11 +1170,17 @@ static const RadOpSchema kSchemas[] = { { "attn_paged", ARR(pAttnPaged), ARR(oAttnPaged), "paged causal / sliding-window attention, any query length, online-softmax so one pass over the " "cache suffices." }, +{ "attn_paged_anchor_window", ARR(pAttnPaged), ARR(oAttnPaged), + "attn_paged with one window anchor at each sequence's first query position: every row keeps keys " + "with anchor - key < window, and a causal row none after the anchor." }, { "attn_paged_tree", ARR(pAttnPaged), ARR(oAttnPagedTree), "attn_paged over a tree verify (rad_drafter_tree): spec_parent is -2 for an ordinary causal row, " "else the row's parent's index within its sequence's rows (-1 for the block's first). Inside the " "block such a row sees itself and its ancestors only; its window is measured from the block's " "first position plus its depth." }, +{ "attn_paged_sink", ARR(pAttnPaged), ARR(oAttnPagedSink), + "attn_paged with `sinks` [n_head] f32, one logit a query head beside the keys in the softmax's " + "maximum and denominator, with no value." }, { "attn_dense", ARR(pAttnDense), ARR(oAttnDense), "dense varlen attention over cu_seqlens; a non-causal window may reach further right " "(`window_right`)." }, @@ -1159,6 +1243,9 @@ static const RadOpSchema kSchemas[] = { { "qk_norm_rope", ARR(pQkNormRope), ARR(oQkNormRope), "per-head QK norm then rotary embedding." }, { "scale_rows", ARR(pScaleRows), ARR(oScaleRows), "one scalar per row, optionally through an activation, broadcast across the row." }, +{ "router_sigmoid_group_topk", ARR(pRouterSigmoidGroup), ARR(oRouterSigmoid), + "Group-limited sigmoid routing: groups rank by the sum of their two best p + bias, selection " + "runs over the topk_group best groups; correction bias selects, original scores weight." }, { "router_sigmoid_topk", ARR(pRouterSigmoid), ARR(oRouterSigmoid), "Single-group sigmoid routing; correction bias selects experts, original scores weight them." }, { "router_topk", ARR(pRouter), ARR(oRouter), "softmax then exact top-k routing." }, @@ -1436,6 +1523,11 @@ static const RadOpSchema kSchemas[] = { { "dflash_conv", ARR(pDflashConv), ARR(oDflashConv), "DFlash2's grouped dynamic depthwise convolution: out[t][h] = sum over taps j, j == 0 or " "t % block_size >= j, of (base[j][h] + delta[t][j][h / group_size]) * x[t - j][h]." }, +{ "dflash_markov_greedy", ARR(pDflashMarkov), ARR(oDflashMarkov), + "DSpark's walk: every vocabulary id scores draft_logit[token] + sum_r pred[previous][r] * " + "succ[token][r], the greatest wins (lower id on a tie) and is the next predecessor." }, +{ "dflash_markov_greedy_f32", ARR(pDflashMarkov), ARR(oDflashMarkov), + "dflash_markov_greedy with f32 draft logits and bf16 codebooks." }, { "dflash_select", ARR(pDflashSelect), ARR(oDflashSelect), "a greedy walk over a candidate lattice: score[l, c] = unary[l, c] + sum_r pred[pid(l)][r] * " "hp[l][r] * succ[cand[l, c]][r], pid(0) the anchor and pid(l) the walk's own previous pick. " @@ -1576,6 +1668,7 @@ SIMPLE("avx_mhc_pre_finish", "mhc_pre_finish", "norm", "manifold gates from proj SIMPLE("avx_mhc_post", "mhc_post", "norm", "manifold residual update", DT_FLOAT, L(mhc_post)), SIMPLE("avx_mhc_contract", "mhc_contract", "norm", "mean of residual streams", DT_FLOAT, L(mhc_contract)), SIMPLE("avx_kda_update", "kda_update", "gdn", "bounded KDA and candidate-state rollback", DT_FLOAT, L(kda_update)), +SIMPLE("avx_ssd_update", "ssd_update", "gdn", "Mamba-2 recurrence and candidate-state rollback", DT_FLOAT, L(ssd_update)), ROWL("avx_hc_read", "hc_read", "norm", "gated residual read: grouped norm, low-rank gate, stream mix", DT_FLOAT ", or mixing matrices of E4M3 / int8 codes with a scale plane, joined", L(hc_read), @@ -1596,6 +1689,17 @@ SIMPLE("avx_grid_embed", "grid_embed", "elem", SIMPLE("avx_grid_embed_aa", "grid_embed_aa", "elem", "antialiased half-pixel bilinear resample of a position grid, added in", DT_FLOAT, L(grid_embed_aa)), +SIMPLE("avx_grid_embed_cpe", "grid_embed_cpe", "elem", + "half-pixel bilinear resample of a position grid onto a square, cropped, added in", DT_FLOAT, + L(grid_embed_cpe)), +SIMPLE("avx_lili_cand", "lili_cand", "draft", "LiLiCorr candidates and their features", DT_FLOAT, + L(lili_cand)), +SIMPLE("avx_lili_attn", "lili_attn", "draft", "LiLiCorr lattice attention with slot biases", + DT_FLOAT, L(lili_attn)), +SIMPLE("avx_lili_factor", "lili_factor", "draft", "LiLiCorr factor input [h | a | h * a]", + DT_FLOAT, L(lili_factor)), +SIMPLE("avx_lili_walk", "lili_walk", "draft", "LiLiCorr edge scores and greedy walk", DT_FLOAT, + L(lili_walk)), SIMPLE("avx_add", "add", "elem", "elementwise sum", DT_FLOAT, L(add)), SIMPLE("avx_mul", "mul", "elem", "elementwise product, broadcasting b", DT_FLOAT, L(mul)), SIMPLE("avx_act_mul", "act_mul", "elem", "act(a) * b over two operands", DT_FLOAT, L(act_mul)), @@ -1612,6 +1716,8 @@ SIMPLE("avx_pool_rows", "pool_rows", "elem", "mean of every k consecutive rows, DT_FLOAT, L(pool_rows)), SIMPLE("avx_pool_cols", "pool_cols", "elem", "mean of every k consecutive columns, then a " "multiplier", DT_FLOAT, L(pool_cols)), +SIMPLE("avx_point_fourier", "point_fourier", "elem", "a point's sines and cosines at octaves", + DT_FLOAT, L(point_fourier)), SIMPLE("avx_relu", "relu", "elem", "max(x, 0)", DT_FLOAT, L(relu)), SIMPLE("avx_clamp", "clamp", "elem", "x clamped to two weight scalars", DT_FLOAT, L(clamp)), SIMPLE("avx_conv2d", "conv2d", "elem", "segment-wise 2-D convolution, channels innermost", @@ -1629,6 +1735,8 @@ SIMPLE("avx_seg_sinusoid", "seg_sinusoid", "elem", SIMPLE("avx_attn_local_rel", "attn_local_rel", "attn", "local attention with a relative-position term and a softcap", DT_FLOAT, L(attn_local_rel)), +SIMPLE("avx_mla_attn_paged", "mla_attn_paged", "attn", "dense paged latent attention with a rotary part", + DT_FLOAT, L(mla_attn_paged)), SIMPLE("avx_mla_attn", "mla_attn", "attn", "absorbed latent MQA attention", DT_FLOAT, L(mla_attn)), SIMPLE("avx_dsa_score", "dsa_score", "attn", "weighted FP8 index scoring", DT_FLOAT, @@ -1641,6 +1749,8 @@ SIMPLE("avx_gemm_nt_f32", "gemm_nt_f32", "gemm", "F32 routing projection", DT_FL L(gemm_nt_f32)), SIMPLE("avx_mla_project", "mla_project", "attn", "absorbed MLA projections", DT_FLOAT, L(mla_project)), +SIMPLE("avx_swiglu_step", "swiglu_step", "elem", "SwiGLU clipped after the SiLU", DT_FLOAT, + L(swiglu_step)), SIMPLE("avx_swiglu_clamped", "swiglu_clamped", "elem", "asymmetrically clipped SwiGLU", DT_FLOAT, L(swiglu_clamped)), SIMPLE("avx_silu_mul", "silu_mul", "elem", "silu-gated product over a fused gate_up", DT_FLOAT, @@ -1663,6 +1773,9 @@ SIMPLE("avx_ple_gate", "ple_gate", "norm", "PLE gate: three grouped norms, a dot DT_FLOAT, L(ple_gate)), SIMPLE("avx_ple_conv", "ple_conv", "norm", "PLE's dilated depthwise conv, silu and residual add", DT_FLOAT, L(ple_conv)), +SIMPLE("avx_ple_conv_bias", "ple_conv_bias", "norm", + "ple_conv with a per-channel bias inside the silu (Mamba-2's conv1d)", DT_FLOAT, + L(ple_conv_bias)), SIMPLE("avx_causal_conv1d", "causal_conv1d", "conv", "depthwise causal conv, no activation", DT_FLOAT, L(causal_conv1d)), SIMPLE("avx_cast", "cast", "elem", "dtype conversion", DT_ANY, L(cast)), @@ -1743,10 +1856,19 @@ ROW("avx_attn_paged", "attn_paged", "attn", "paged causal / sliding-window attention, any query length", "any q and out dtype; bf16 or fp8 kv cache with optional per-(seq,head) descales", cPagedBlock, (int)(sizeof(cPagedBlock) / sizeof(cPagedBlock[0])), L(attn_paged)), +ROW("avx_attn_paged_anchor_window", "attn_paged_anchor_window", "attn", + "paged attention with one shared anchor-aligned sliding window a sequence", + "any q and out dtype; bf16 or fp8 kv cache with optional per-(seq,head) descales", + cPagedBlock, (int)(sizeof(cPagedBlock) / sizeof(cPagedBlock[0])), + L(attn_paged_anchor_window)), ROW("avx_attn_paged_tree", "attn_paged_tree", "attn", "paged causal / sliding-window attention with a tree verify block (spec_parent)", "any q and out dtype; bf16 or fp8 kv cache with optional per-(seq,head) descales; i32 parents", cPagedBlock, (int)(sizeof(cPagedBlock) / sizeof(cPagedBlock[0])), L(attn_paged_tree)), +ROW("avx_attn_paged_sink", "attn_paged_sink", "attn", + "paged causal / sliding-window attention with a sink logit a head, any query length", + "any q and out dtype; bf16 or fp8 kv cache with optional per-(seq,head) descales; f32 sinks", + cPagedBlock, (int)(sizeof(cPagedBlock) / sizeof(cPagedBlock[0])), L(attn_paged_sink)), SIMPLE("avx_attn_dense", "attn_dense", "attn", "dense varlen attention over cu_seqlens", DT_FLOAT, L(attn_dense)), SIMPLE("avx_attn_cross", "attn_cross", "attn", @@ -1791,6 +1913,8 @@ SIMPLE("avx_qsa_work", "qsa_work", "attn", SIMPLE("avx_router_topk", "router_topk", "moe", "softmax then exact top-k routing", DT_FLOAT, L(router_topk)), +SIMPLE("avx_router_sigmoid_group_topk", "router_sigmoid_group_topk", "moe", + "group-limited sigmoid correction-bias routing", DT_FLOAT, L(router_sigmoid_group_topk)), SIMPLE("avx_router_sigmoid_topk", "router_sigmoid_topk", "moe", "sigmoid correction-bias routing", DT_FLOAT, L(router_sigmoid_topk)), SIMPLE("avx_router_topk_scatter", "router_topk_scatter", "moe", @@ -2053,6 +2177,13 @@ SIMPLE("avx_dflash_conv", "dflash_conv", "draft", SIMPLE("avx_dflash_select", "dflash_select", "draft", "DFlash2's greedy walk over the candidate lattice", "i32 candidates and tokens, float unary and codebooks", L(dflash_select)), +SIMPLE("avx_dflash_markov_greedy", "dflash_markov_greedy", "draft", + "DSpark's full-vocabulary greedy Markov walk", + "bf16 logits and codebooks, f32/i32 tile winners, i32 tokens out", L(dflash_markov_greedy)), +SIMPLE("avx_dflash_markov_greedy_f32", "dflash_markov_greedy_f32", "draft", + "Full-vocabulary greedy Markov walk with f32 draft logits", + "f32 logits, bf16 codebooks, f32/i32 tile winners, i32 tokens out", + L(dflash_markov_greedy_f32)), SIMPLE("avx_dflash_tree", "dflash_tree", "draft", "DFlash2's candidate lattice grown best-first into a tree", "i32 candidates, tokens and parents, float unary and codebooks", L(dflash_tree)), diff --git a/libavx/avx_sample.cpp b/libavx/avx_sample.cpp index 2048fb61..f1228462 100644 --- a/libavx/avx_sample.cpp +++ b/libavx/avx_sample.cpp @@ -685,9 +685,9 @@ AVX_KERNEL(sample_argmax) { * pass the test after the first few thousand columns. * * The sum is f32 in four accumulators. Its terms are in (0, 1] and a logprob carries only its - * relative error, so f32 suffices (libref uses double). */ + * relative error, so f32 suffices (libref uses double). Without `params` every row is written. */ AVX_KERNEL(sample_logprobs) { - if (!rad_args_have(a, 3)) return RAD_E_INVAL; + if (a->n_t < 3 || !a->t[0].data || !a->t[2].data) return RAD_E_INVAL; const RadTensor *lg = &a->t[0], *pr = &a->t[1], *st = &a->t[2]; const int64_t n_vocab = p_int(a, "n_vocab", lg->rank >= 2 ? lg->shape[lg->rank - 1] : 0); const int64_t k = p_int(a, "k", 0); @@ -697,11 +697,11 @@ AVX_KERNEL(sample_logprobs) { const int64_t w = 2 + 2 * k; if (M <= 0 || numel(st) < M * w) return RAD_E_SHAPE; Rows R; - AVX_TRY(rows_of_params(pr, M, &R)); + if (pr->data) AVX_TRY(rows_of_params(pr, M, &R)); AVX_PARALLEL_FOR_IF(M * n_vocab >= AVX_PAR_MIN) for (int64_t m = 0; m < M; ++m) { - if (!(R.p[m].flags & RAD_SP_LOGPROBS)) continue; + if (pr->data && !(R.p[m].flags & RAD_SP_LOGPROBS)) continue; float* buf = scratch_f32((size_t)n_vocab + 2 * (size_t)k); const float* v = in_row(lg, rowoff(lg, m, n_vocab), n_vocab, buf); float* tv = buf + n_vocab; /* the set's values, descending */ @@ -925,6 +925,83 @@ AVX_KERNEL(dflash_select) { return RAD_OK; } +/* ================================================================== dflash_markov_greedy + * + * DSpark's walk over the whole vocabulary (libref ref_quant.cpp, ref_markov_greedy): at each step + * every token scores its draft logit plus sum_r pred[pid][r] * succ[token][r], the greatest wins + * (ties to the lower id) and becomes the next predecessor. The winners of each 64-token tile are + * written too, as the device row's decomposition. Scalar and in libref's order (the bf16 form starts + * the sum at the logit, the f32 form adds it last), so the argmax ties the same way. */ +static int markov_greedy(const RadArgs* a, uint32_t logits_dtype) { + if (a->n_t < 7) return RAD_E_INVAL; + const RadTensor *logits = &a->t[0], *anc = &a->t[1], *pred = &a->t[2], *succ = &a->t[3]; + const RadTensor *tsc = &a->t[4], *ttok = &a->t[5], *out = &a->t[6]; + if (!logits->data || !anc->data || !pred->data || !succ->data || !tsc->data || !ttok->data || + !out->data) + return RAD_E_INVAL; + if (logits->dtype != logits_dtype || pred->dtype != RAD_BF16 || succ->dtype != RAD_BF16 || + tsc->dtype != RAD_F32 || ttok->dtype != RAD_I32 || out->dtype != RAD_I32) + return RAD_E_DTYPE; + if (anc->dtype != RAD_I32) return RAD_E_SHAPE; + + const int64_t steps = p_int(a, "steps", 0); + const int64_t R = p_int(a, "rank", 0); + const int64_t V = p_int(a, "n_vocab", 0); + const int64_t astr = p_int(a, "anchor_stride", 1); + const int64_t M = steps > 0 && V > 0 + ? band_rows(numel(logits) / (steps * V), p_int(a, "M", 0)) : 0; + if (M <= 0 || steps <= 0 || R <= 0 || V <= 0 || astr <= 0) return RAD_E_SHAPE; + if (numel(logits) < M * steps * V || numel(anc) < (M - 1) * astr + 1 || + numel(pred) < V * R || numel(succ) < V * R || numel(out) < M * steps) + return RAD_E_SHAPE; + const int64_t n_tiles = (V + 63) / 64; + if (numel(tsc) < M * n_tiles || numel(ttok) < M * n_tiles) return RAD_E_SHAPE; + + const int64_t ls = laststride(logits), os = laststride(out); + const int64_t tss = laststride(tsc), tis = laststride(ttok); + AVX_PARALLEL_FOR_IF(M * steps * V * R >= AVX_PAR_MIN) + for (int64_t m = 0; m < M; ++m) { + float* prev = scratch_f32((size_t)R); + float* sv = scratch_f32_b((size_t)R); + int64_t pid = ldi(anc, offlin(anc, m * astr)); + for (int64_t l = 0; l < steps; ++l) { + const int64_t row = m * steps + l; + const bool ok = pid >= 0 && pid < V; + if (ok) { + const float* pv = in_row(pred, rowoff(pred, pid, R), R, prev); + if (pv != prev) std::memcpy(prev, pv, (size_t)R * sizeof(float)); + } else { + for (int64_t r = 0; r < R; ++r) prev[r] = 0.0f; + } + const int64_t lb = rowoff(logits, row, V); + float gbest = -INFINITY; + int64_t gtok = 0; + for (int64_t tile = 0; tile < n_tiles; ++tile) { + const int64_t first = tile * 64, end = std::min(first + 64, V); + float best = -INFINITY; + int64_t btok = first; + for (int64_t tok = first; tok < end; ++tok) { + const float base = ldt(logits, lb + tok * ls); + const float* su = in_row(succ, rowoff(succ, tok, R), R, sv); + float s = logits_dtype == RAD_F32 ? 0.0f : base; + for (int64_t r = 0; r < R; ++r) s += prev[r] * su[r]; + if (logits_dtype == RAD_F32) s += base; + if (s > best || (s == best && tok < btok)) { best = s; btok = tok; } + } + stt(tsc, rowoff(tsc, m, n_tiles) + tile * tss, best); + st_int_dt(ttok->dtype, ttok->data, rowoff(ttok, m, n_tiles) + tile * tis, btok); + if (best > gbest || (best == gbest && btok < gtok)) { gbest = best; gtok = btok; } + } + st_int_dt(out->dtype, out->data, rowoff(out, m, steps) + l * os, gtok); + pid = gtok; + } + } + return RAD_OK; +} + +AVX_KERNEL(dflash_markov_greedy) { return markov_greedy(a, RAD_BF16); } +AVX_KERNEL(dflash_markov_greedy_f32) { return markov_greedy(a, RAD_F32); } + /* ================================================================== dflash_tree * * The same lattice grown best-first into a tree of `nodes` nodes (rad_drafter_tree), libref's rule diff --git a/libavx/avx_ssd.cpp b/libavx/avx_ssd.cpp new file mode 100644 index 00000000..72466d90 --- /dev/null +++ b/libavx/avx_ssd.cpp @@ -0,0 +1,194 @@ +/* avx_ssd.cpp -- the Mamba-2 selective state update (ssd_update), libref/ref_ssd.cpp's arithmetic + * with the d_state reduction in this ISA level's vectors, in both state forms. + * + * A token widens its group's B and C rows once; each head then decays and updates its + * [head_dim, d_state] state row by row and reads the row against C in the same pass. The anchor + * form's replay applies a record with the window's own update (row_axpy is row_update without the + * read), so the committed state is this library's per-candidate state bit for bit. */ +#include "avx_vec.h" +#include "avx_common.h" + +#include +#include +#include + +using namespace avx; + +namespace { +bool headed(const RadTensor& t, int64_t tokens, int64_t heads, int64_t width) { + return t.data && t.shape[0] == tokens && + ((t.rank == 3 && t.shape[1] == heads && t.shape[2] == width) || + (t.rank == 2 && t.shape[1] == heads * width)); +} +int64_t off(const RadTensor& t, int64_t token, int64_t head, int64_t d, int64_t width) { + return token * t.stride[0] + head * (t.rank == 3 ? t.stride[1] : width * t.stride[1]) + + d * laststride(&t); +} +float softplus(float v) { return v > 20.0f ? v : std::log1p(std::exp(v)); } + +/* s = s * decay + u * b over one state row, as row_update does it, without the read. */ +void row_axpy(float* s, const float* b, float decay, float u, int64_t n) { + const vf vd = vf_set1(decay), vu = vf_set1(u); + int64_t d = 0; + for (; d + VF_N <= n; d += VF_N) + vf_storeu(s + d, vf_fma(vf_loadu(s + d), vd, vf_mul(vu, vf_loadu(b + d)))); + for (; d < n; ++d) s[d] = s[d] * decay + u * b[d]; +} +int64_t anchor_tokens(int64_t P, int64_t Nst) { + const int64_t fit = (P * Nst - 1) / (1 + P + Nst); + return fit < 32 ? fit : 32; +} + +/* s = s * decay + u * b over one state row, and the row's dot with c. */ +float row_update(float* s, const float* b, const float* c, float decay, float u, int64_t n) { + const vf vd = vf_set1(decay), vu = vf_set1(u); + vf acc = vf_zero(); + int64_t d = 0; + for (; d + VF_N <= n; d += VF_N) { + const vf r = vf_fma(vf_loadu(s + d), vd, vf_mul(vu, vf_loadu(b + d))); + vf_storeu(s + d, r); + acc = vf_fma(r, vf_loadu(c + d), acc); + } + float result = vf_hsum(acc); + for (; d < n; ++d) { + s[d] = s[d] * decay + u * b[d]; + result += s[d] * c[d]; + } + return result; +} +} // namespace + +AVX_KERNEL(ssd_update) { + if (!a || a->n_t < 13) return RAD_E_INVAL; + for (int i = 0; i < 10; ++i) + if (!rad_arg_in(a, i)) return RAD_E_INVAL; + if (!rad_arg_in(a, 12)) return RAD_E_INVAL; + const int64_t H = p_int(a, "heads", 0), P = p_int(a, "head_dim", 0); + const int64_t Nst = p_int(a, "d_state", 0), G = p_int(a, "groups", 0); + const char* mode = p_str(a, "mode", ""); + const bool verify = !std::strcmp(mode, "verify"); + if (!verify && std::strcmp(mode, "prefill")) return RAD_E_INVAL; + const char* form = p_str(a, "state_form", "per_candidate"); + const bool anchor = !std::strcmp(form, "anchor"); + if (!anchor && std::strcmp(form, "per_candidate")) return RAD_E_INVAL; + if (H < 1 || P < 1 || Nst < 1 || G < 1 || H % G) return RAD_E_SHAPE; + const int64_t rec = 1 + P + Nst, deepest = anchor_tokens(P, Nst); + if (anchor && deepest < 1) return RAD_E_SHAPE; + const auto &x = a->t[0], &B = a->t[1], &C = a->t[2], &dt = a->t[3]; + const auto &al = a->t[4], &dtb = a->t[5], &dskip = a->t[6], &s = a->t[7]; + const auto &idx = a->t[8], &cu = a->t[9], &out = a->t[12]; + const auto* accepted = rad_arg_in(a, 10); + const auto* init = rad_arg_in(a, 11); + if (x.rank < 2 || cu.rank != 1 || cu.dtype != RAD_I32 || cu.shape[0] < 2) return RAD_E_SHAPE; + const int64_t T = x.shape[0], N = cu.shape[0] - 1, slots = s.shape[0]; + if (T < 1) return RAD_E_SHAPE; + if (!headed(x, T, H, P) || !headed(B, T, G, Nst) || !headed(C, T, G, Nst) || + !headed(dt, T, H, 1) || !headed(out, T, H, P) || numel(&al) != H || numel(&dtb) != H || + numel(&dskip) != H || s.rank != 4 || s.dtype != RAD_F32 || s.shape[1] != H || + s.shape[2] != P || s.shape[3] != Nst || idx.rank != 2 || idx.dtype != RAD_I32 || + idx.shape[0] < N || idx.shape[1] < 1 || + (accepted && (accepted->dtype != RAD_I32 || numel(accepted) < N)) || + (init && (init->dtype != RAD_I32 || numel(init) < N))) + return RAD_E_SHAPE; + const int64_t width = idx.shape[1]; + for (int64_t seq = 0; seq < N; ++seq) { + const int64_t begin = ldi(&cu, seq * cu.stride[0]); + const int64_t end = ldi(&cu, (seq + 1) * cu.stride[0]); + const int64_t na = accepted ? ldi(accepted, offlin(accepted, seq)) : 1; + const int64_t most = anchor ? deepest : width; + if (begin < 0 || end < begin || end > T || na < 1 || na > most || + (verify && end - begin > most) || (anchor && width < 2)) + return RAD_E_SHAPE; + for (int64_t j = 0; j < width; ++j) + if (ldi(&idx, seq * idx.stride[0] + j * idx.stride[1]) >= slots) return RAD_E_SHAPE; + if (anchor) { + const int64_t read = ldi(&idx, seq * idx.stride[0]); + const int64_t scratch = ldi(&idx, seq * idx.stride[0] + (width / 2) * idx.stride[1]); + if (read >= 0 && (scratch < 0 || scratch == read)) return RAD_E_SHAPE; + if (verify && read >= 0 && (!init || ldi(init, offlin(init, seq)))) + for (int64_t h = 0; h < H; ++h) { + const float count = ldt(&s, scratch * s.stride[0] + h * s.stride[1]); + if (!std::isfinite(count) || count < 0 || count > (float)deepest || + count != std::floor(count) || (count > 0 && na > count)) + return RAD_E_SHAPE; + } + } + } + const int64_t per_group = H / G; + AVX_PARALLEL_FOR_IF(N * H * P * Nst >= AVX_PAR_MIN) + for (int64_t sh = 0; sh < N * H; ++sh) { + const int64_t seq = sh / H, head = sh % H, grp = head / per_group; + const int64_t begin = ldi(&cu, seq * cu.stride[0]); + const int64_t end = ldi(&cu, (seq + 1) * cu.stride[0]); + if (begin == end) continue; + const int64_t na = accepted ? ldi(accepted, offlin(accepted, seq)) : 1; + const int64_t read = + ldi(&idx, seq * idx.stride[0] + (verify && !anchor ? na - 1 : 0) * idx.stride[1]); + if (read < 0) { + for (int64_t t = begin; t < end; ++t) + for (int64_t e = 0; e < P; ++e) stt(&out, off(out, t, head, e, P), 0); + continue; + } + const bool initialized = !init || ldi(init, offlin(init, seq)) != 0; + std::vector S((size_t)(P * Nst)), b((size_t)Nst), c((size_t)Nst); + const int64_t sb = read * s.stride[0] + head * s.stride[1]; + for (int64_t e = 0; e < P; ++e) + for (int64_t d = 0; d < Nst; ++d) + S[e * Nst + d] = initialized ? ldt(&s, sb + e * s.stride[2] + d * s.stride[3]) : 0; + const int64_t scratch = + anchor ? ldi(&idx, seq * idx.stride[0] + (width / 2) * idx.stride[1]) : 0; + auto factor_at = [&](int64_t i) { + return scratch * s.stride[0] + head * s.stride[1] + (i / Nst) * s.stride[2] + + (i % Nst) * s.stride[3]; + }; + if (anchor && verify) { + /* The accepted prefix of the previous window, onto the committed state, published. */ + const int64_t replay = initialized ? (int64_t)ldt(&s, factor_at(0)) : 0; + for (int64_t t = 0; t < (replay ? na : 0); ++t) { + const int64_t f = 1 + t * rec; + const float decay = ldt(&s, factor_at(f)); + for (int64_t d = 0; d < Nst; ++d) b[(size_t)d] = ldt(&s, factor_at(f + 1 + P + d)); + for (int64_t e = 0; e < P; ++e) + row_axpy(&S[e * Nst], b.data(), decay, ldt(&s, factor_at(f + 1 + e)), Nst); + } + for (int64_t e = 0; e < P; ++e) + for (int64_t d = 0; d < Nst; ++d) + stt(&s, sb + e * s.stride[2] + d * s.stride[3], S[e * Nst + d]); + } + const float A = -std::exp(ldt(&al, head * laststride(&al))); + const float bias = ldt(&dtb, head * laststride(&dtb)); + const float skip = ldt(&dskip, head * laststride(&dskip)); + for (int64_t t = begin; t < end; ++t) { + const float step = softplus(ldt(&dt, off(dt, t, head, 0, 1)) + bias); + const float decay = std::exp(step * A); + for (int64_t d = 0; d < Nst; ++d) { + b[d] = ldt(&B, off(B, t, grp, d, Nst)); + c[d] = ldt(&C, off(C, t, grp, d, Nst)); + } + const int64_t f = 1 + (t - begin) * rec; + if (anchor && verify) { + stt(&s, factor_at(f), decay); + for (int64_t d = 0; d < Nst; ++d) stt(&s, factor_at(f + 1 + P + d), b[d]); + } + for (int64_t e = 0; e < P; ++e) { + const float xe = ldt(&x, off(x, t, head, e, P)); + const float u = step * xe; + if (anchor && verify) stt(&s, factor_at(f + 1 + e), u); + const float r = row_update(&S[e * Nst], b.data(), c.data(), decay, u, Nst); + stt(&out, off(out, t, head, e, P), r + skip * xe); + } + if ((verify && !anchor) || (!verify && t + 1 == end)) { + const int64_t write = + ldi(&idx, seq * idx.stride[0] + (verify ? t - begin : 0) * idx.stride[1]); + if (write >= 0) + for (int64_t e = 0; e < P; ++e) + for (int64_t d = 0; d < Nst; ++d) + stt(&s, write * s.stride[0] + head * s.stride[1] + e * s.stride[2] + + d * s.stride[3], + S[e * Nst + d]); + } + } + if (anchor) stt(&s, factor_at(0), verify ? (float)(end - begin) : 0.0f); + } + return RAD_OK; +} diff --git a/libavx/avx_support.cpp b/libavx/avx_support.cpp index edb57a6b..c0a7873c 100644 --- a/libavx/avx_support.cpp +++ b/libavx/avx_support.cpp @@ -170,14 +170,16 @@ float row_sum(const float* x, int64_t n) { return s; } +/* A NaN element is skipped, as libref's std::max(amax, |x|) skips it: vmaxps returns its second + * operand when either is NaN, so the running maximum goes second. */ float row_amax(const float* x, int64_t n) { vf m0 = vf_zero(), m1 = vf_zero(); int64_t i = 0; for (; i + 2 * VF_N <= n; i += 2 * VF_N) { - m0 = vf_max(m0, vf_abs(vf_loadu(x + i))); - m1 = vf_max(m1, vf_abs(vf_loadu(x + i + VF_N))); + m0 = vf_max(vf_abs(vf_loadu(x + i)), m0); + m1 = vf_max(vf_abs(vf_loadu(x + i + VF_N)), m1); } - for (; i + VF_N <= n; i += VF_N) m0 = vf_max(m0, vf_abs(vf_loadu(x + i))); + for (; i + VF_N <= n; i += VF_N) m0 = vf_max(vf_abs(vf_loadu(x + i)), m0); float m = vf_hmax(vf_max(m0, m1)); for (; i < n; ++i) { float av = x[i] < 0 ? -x[i] : x[i]; if (av > m) m = av; } return m; diff --git a/libhalo/README.md b/libhalo/README.md index 7705de71..ad9c5a52 100644 --- a/libhalo/README.md +++ b/libhalo/README.md @@ -16,7 +16,9 @@ Both are built when `RAD_GPU_TARGETS` names gfx1151, and on a Strix Halo libhalo - `rad_plugin_open` (`halo_rows.cpp`) declines every machine whose KFD topology lists no gfx1151, so on another RDNA3 card libhalo is not loaded at all and declares no schema: libr3d serves it alone. The loader would leave libhalo's device rows out there anyway (its code objects are - gfx1151's); declining also keeps its schemas out. + gfx1151's); declining also keeps its schemas out, and keeps rad-convert, which resolves kernels + without that check, from laying weights out for it. A process without `/dev/kfd` (a container + given no card, a machine with no amdgpu) sees no gfx1151 and declines it too. An explicit `--kernels` list orders the libraries as given; name `libhalo` before `libr3d`. diff --git a/libhalo/halo_attn_args.h b/libhalo/halo_attn_args.h index 9d5ac520..adca65ed 100644 --- a/libhalo/halo_attn_args.h +++ b/libhalo/halo_attn_args.h @@ -103,6 +103,8 @@ static inline int fill_paged_row(const RadArgs* a, HaloArgs* r, int expect_head_ if (kv->stride[3] != 1) return HALO_NO(RAD_E_STRIDE); if (kv->stride[2] != row) return HALO_NO(RAD_E_STRIDE); if (kv->shape[3] != row) return HALO_NO(RAD_E_SHAPE); + /* The kernels divide q_heads by kv_heads for the GQA factor. */ + if (kv->shape[1] <= 0) return HALO_NO(RAD_E_SHAPE); /* 16-byte alignment for 128-bit loads. */ if (!halo_aligned(q->data, 16) || !halo_aligned(o->data, 16) || !halo_aligned(kv->data, 16)) diff --git a/libhalo/halo_encoder_bf16.hip b/libhalo/halo_encoder_bf16.hip index 6cc72978..fd00c8f0 100644 --- a/libhalo/halo_encoder_bf16.hip +++ b/libhalo/halo_encoder_bf16.hip @@ -356,6 +356,31 @@ __global__ __launch_bounds__(kThreads) void pool_cols_kernel( } } +// ---------------------------------------------------------------------------- point_fourier +// ref_point_fourier: row m of y is [x | sin(x_i f_j) | cos(x_i f_j)], f_j = 2^j (times pi), the +// sines then the cosines each i-major then j; f32 in and out. A thread an output column. +__global__ __launch_bounds__(kThreads) void point_fourier_kernel( + const float* __restrict__ x, float* __restrict__ y, uint32_t n, uint32_t F, uint32_t pi, + uint32_t x_ld, uint32_t y_ld, uint32_t M) { + const uint32_t w = n * (2 * F + 1); + const uint32_t c = blockIdx.x * kThreads + threadIdx.x; + if (c >= w) return; + for (uint32_t r = blockIdx.y; r < M; r += gridDim.y) { + float v; + if (c < n) { + v = x[(size_t)r * x_ld + c]; + } else { + const uint32_t k = c - n, half = n * F; + const uint32_t i = (k % half) / F, j = (k % half) % F; + const float f = pi ? (float)ldexp(3.14159265358979323846, (int)j) + : ldexpf(1.0f, (int)j); + const float t = x[(size_t)r * x_ld + i] * f; + v = k < half ? sinf(t) : cosf(t); + } + y[(size_t)r * y_ld + c] = v; + } +} + // ---------------------------------------------------------------------------- cast bf16 -> f32 __global__ __launch_bounds__(kThreads) void widen_kernel( const uint16_t* __restrict__ x, float* __restrict__ y, uint32_t n, uint32_t x_ld, @@ -897,6 +922,19 @@ extern "C" int halo_pool_cols_bf16(long x, long y, int rows, int n, int k, float return hipGetLastError() == hipSuccess ? 0 : -4; } +extern "C" int halo_point_fourier_f32(long x, long y, int rows, int n, int freqs, int pi, + int x_ld, int y_ld, long stream) { + if (!x || !y) return -1; + if (rows <= 0 || n <= 0 || freqs <= 0 || freqs > 30) return -2; + const uint32_t w = (uint32_t)(n * (2 * freqs + 1)); + hipLaunchKernelGGL(point_fourier_kernel, + dim3((w + kThreads - 1) / kThreads, grid_rows(rows)), + dim3(kThreads), 0, (hipStream_t)stream, (const float*)x, (float*)y, + (uint32_t)n, (uint32_t)freqs, (uint32_t)(pi != 0), (uint32_t)x_ld, + (uint32_t)y_ld, (uint32_t)rows); + return hipGetLastError() == hipSuccess ? 0 : -4; +} + extern "C" int halo_widen_bf16_f32(long x, long y, int M, int n, int x_ld, int y_ld, long stream) { if (!x || !y) return -1; if (M <= 0 || n <= 0) return -2; @@ -1263,6 +1301,24 @@ extern "C" int halo_rad_pool_cols(const RadArgs* a, RadStream s) { (long)(uintptr_t)s)); } +/* ------------------------------------------------------------------ point_fourier */ +extern "C" int halo_rad_point_fourier(const RadArgs* a, RadStream s) { + const RadTensor* X = halo_opt(a, 0); + const RadTensor* Y = halo_opt(a, 1); + if (!X || !Y) return HALO_NO(RAD_E_INVAL); + if (X->dtype != RAD_F32 || Y->dtype != RAD_F32) return HALO_NO(RAD_E_DTYPE); + const long long n = halo_geti_or(a, "n", 0), F = halo_geti_or(a, "freqs", 0); + if (n <= 0 || F <= 0 || F > 30) return HALO_NO(RAD_E_SHAPE); + long long M = 0, My = 0; + const long long x_ld = halo_rows_pitch(X, n, &M); + const long long y_ld = halo_rows_pitch(Y, n * (2 * F + 1), &My); + if (x_ld < 0 || y_ld < 0) return HALO_NO(RAD_E_STRIDE); + if (M <= 0 || My < M) return HALO_NO(RAD_E_SHAPE); + return enc_status(halo_point_fourier_f32(halo_addr(X), halo_addr(Y), (int)M, (int)n, (int)F, + (int)halo_geti_or(a, "pi", 0), (int)x_ld, (int)y_ld, + (long)(uintptr_t)s)); +} + /* ------------------------------------------------------------------ cast bf16 -> f32 */ extern "C" int halo_rad_cast_widen(const RadArgs* a, RadStream s) { const RadTensor* x = halo_opt(a, 0); diff --git a/libhalo/halo_plugin.h b/libhalo/halo_plugin.h index e47feeac..89da9ae2 100644 --- a/libhalo/halo_plugin.h +++ b/libhalo/halo_plugin.h @@ -735,6 +735,7 @@ int halo_rad_cast_f16 (const RadArgs*, RadStream); int halo_rad_cast_bf16 (const RadArgs*, RadStream); int halo_rad_pool_rows (const RadArgs*, RadStream); int halo_rad_pool_cols (const RadArgs*, RadStream); +int halo_rad_point_fourier (const RadArgs*, RadStream); int halo_rad_relu (const RadArgs*, RadStream); int halo_rad_silu (const RadArgs*, RadStream); int halo_rad_gelu (const RadArgs*, RadStream); diff --git a/libhalo/halo_qsa_tail_store_bf16.hip b/libhalo/halo_qsa_tail_store_bf16.hip index f0a35229..bda2b950 100644 --- a/libhalo/halo_qsa_tail_store_bf16.hip +++ b/libhalo/halo_qsa_tail_store_bf16.hip @@ -36,7 +36,7 @@ __global__ __launch_bounds__(kThreads) void qsa_tail_store_kernel( const uint16_t* __restrict__ k, const int32_t* __restrict__ pos, const int32_t* __restrict__ cu, const int32_t* __restrict__ sidx, uint16_t* __restrict__ state, - int T, int n, int ring, int seqs, int k_ld, int s_slot, int s_row, int sidx_ld) { + int T, int n, int ring, int seqs, int slots, int k_ld, int s_slot, int s_row, int sidx_ld) { const int t = (int)blockIdx.x; if (t >= T) return; @@ -50,9 +50,10 @@ __global__ __launch_bounds__(kThreads) void qsa_tail_store_kernel( /* Only the last `ring` tokens of this sequence's chunk -- see the header. */ if (t < cu[s + 1] - ring) return; - /* Column 0 is the committed slot; -1 marks a sequence with no state. */ + /* Column 0 is the committed slot; -1 marks a sequence with no state. A slot past the + * state plane's would write past its allocation. */ const int si = sidx[(size_t)s * sidx_ld]; - if (si < 0) return; + if (si < 0 || si >= slots) return; const int row = pos[t] % ring; const size_t src = (size_t)t * k_ld; @@ -69,17 +70,17 @@ __global__ __launch_bounds__(kThreads) void qsa_tail_store_kernel( // state [slots][ring][n] bf16, this layer's tail cache; written only, untargeted rows // keep their contents static int halo_qsa_tail_store_bf16_emit(long k, long pos, long cu, long sidx, long state, int T, - int n, int ring, int seqs, int k_ld, int s_slot, int s_row, - int sidx_ld, RadStream stream) { + int n, int ring, int seqs, int slots, int k_ld, int s_slot, + int s_row, int sidx_ld, RadStream stream) { if (!k || !pos || !cu || !sidx || !state) return HALO_NO(RAD_E_INVAL); - if (T <= 0 || n <= 0 || ring <= 0 || seqs <= 0) return HALO_NO(RAD_E_SHAPE); + if (T <= 0 || n <= 0 || ring <= 0 || seqs <= 0 || slots <= 0) return HALO_NO(RAD_E_SHAPE); if (!k_ld) k_ld = n; if (!s_row) s_row = n; if (!sidx_ld) sidx_ld = 1; return HALO_EMIT(stream, qsa_tail_store_kernel, dim3((unsigned)T), dim3(kThreads), 0, (const uint16_t*)k, (const int32_t*)pos, (const int32_t*)cu, - (const int32_t*)sidx, (uint16_t*)state, T, n, ring, seqs, k_ld, s_slot, s_row, - sidx_ld); + (const int32_t*)sidx, (uint16_t*)state, T, n, ring, seqs, slots, k_ld, s_slot, + s_row, sidx_ld); } // ============================================================== the plugin ABI entry point @@ -116,7 +117,7 @@ extern "C" int halo_rad_qsa_tail_store(const RadArgs* a, RadStream stream) { if (k->dtype != RAD_BF16 || st->dtype != RAD_BF16) return HALO_NO(RAD_E_DTYPE); return halo_qsa_tail_store_bf16_emit(halo_addr(k), halo_addr(po), halo_addr(cu), halo_addr(sx), halo_addr(st), (int)T, (int)n, (int)ring, (int)seqs, - (int)kp, (int)st->stride[0], (int)st->stride[2], - (int)sxp, stream); + (int)st->shape[0], (int)kp, (int)st->stride[0], + (int)st->stride[2], (int)sxp, stream); } diff --git a/libhalo/halo_rows.cpp b/libhalo/halo_rows.cpp index 41b2dfc9..af041c8b 100644 --- a/libhalo/halo_rows.cpp +++ b/libhalo/halo_rows.cpp @@ -823,6 +823,10 @@ static const RadParamSpec pGemmNtQ[] = { /* The width whose K split a row slice of a wider linear takes (docs/OPS.md); only the narrow * fp8a8 / i8a8 rows split K by N, and they read it. */ { "split_n", RAD_P_INT, RAD_OPTIONAL }, + /* The weight rows one scale covers (docs/OPS.md). Accepted and ignored: an int8 weight's + * per-row scale plane holds each block's value in every row, and the trellis forms that need + * the count are IQR dtypes, which no row here serves. */ + { "w_rb", RAD_P_INT, RAD_OPTIONAL }, }; /* docs/OPS.md's `gemm_nt_q` is `a`, `a_scale`, `b`w, `b_scale`w -> `y`. Two of libhalo's six * quantised GEMMs need a seventh operand. RadLayout can declare aux streams beside a weight, but @@ -1212,6 +1216,9 @@ static const RadParamSpec pGramAccum[] = { { "n", RAD_P_INT, RAD_REQUIRED }, { "group", RAD_P_INT, RAD_REQUIRED }, { "dtype", RAD_P_STR, RAD_REQUIRED }, + /* 1: only k2 >= k1 need be accumulated (H is symmetric). Accepted and ignored: the whole + * matrix is added, and the entries below the diagonal are then outside the contract. */ + { "upper", RAD_P_INT, RAD_OPTIONAL }, }; static const RadOperandSpec oGramAccum[] = { { "a", RAD_OPD_IN, 0 }, @@ -1904,6 +1911,10 @@ static const RadParamSpec pQkNormRope[] = { static const RadParamSpec pPoolRows[] = { P_INT("M"), P_INT("n"), P_INT("k"), P_F64O("mult"), P_STR("dtype"), }; +/* `n` is the point's values; y has n (2 freqs + 1) columns. */ +static const RadParamSpec pPointFourier[] = { + P_INT("M"), P_INT("n"), P_INT("freqs"), P_INTO("pi"), P_STR("dtype"), +}; /* `positions` may be absent at `rotary_dim` 0 (the norm alone), and an absent gain is a unit * gain. */ static const RadOperandSpec oQkNormRope[] = { @@ -2929,6 +2940,10 @@ static const RadOpSchema kSchemas[] = { "Column c of row m of y is the mean of x[m]'s columns [c*k, c*k + k), summed in f32 and " "rounded, then times `mult` and rounded again. n, the input width, is a multiple of k; " "y has n / k columns."), + SCHEMA("point_fourier", pPointFourier, oUnary, + "A point's Fourier features: row m of y is [x | sin(x_i f_j) | cos(x_i f_j)], f_j = 2^j " + "for j < freqs (times pi with `pi` 1), sines then cosines each i-major then j; y is " + "[M, n (2 freqs + 1)]."), SCHEMA("sigmoid", pMnDtype, oUnary, "y = 1 / (1 + exp(-x))."), SCHEMA("relu", pMnDtype, oUnary, "y = max(x, 0)."), SCHEMA("silu", pMnDtype, oUnary, "y = x * sigmoid(x)."), @@ -5730,6 +5745,15 @@ static const RadKernelInfo kKernels[] = { ROW(cBf16Row), NOTUNE, nullptr, nullptr, halo_rad_pool_cols }, +{ "point_fourier_f32", "point_fourier", "elem", + "a point's Fourier features: x, then its sines and cosines at octaves (a shape decoder's query " + "embedding)", + "any n and freqs up to 30; a thread an output column", + "f32 in and out, the device's sinf and cosf", + RAD_DOMAIN_DEVICE, HALO_PRIO_ONLY, + ROW(cF32Row), NOTUNE, + nullptr, nullptr, halo_rad_point_fourier }, + { "rmsnorm_bf16", "rmsnorm", "norm", "root-mean-square norm with a gain, two passes over the row", "any n; the sum of squares accumulates in f32 and only the store narrows", @@ -9738,19 +9762,21 @@ extern "C" const RadPluginInfo* rad_plugin_info(void) { return &kInfo; } * out entirely, so another RDNA3 card gets libr3d alone. * * The test reads the KFD topology (gfx_target_version 110501 is gfx1151) rather than asking a - * runtime, which open must not initialise. Where the topology cannot be read (no KFD, a sandbox - * without /sys) the library stays: the code-object check is the backstop. */ + * runtime, which open must not initialise. KFD lists only the cards the process may open, so a + * container without /dev/kfd sees the CPU node alone. With no gfx1151 listed, or no topology at + * all, the library declines: rad-convert and the other tools resolve kernels without the + * engine's code-object check, and a library for an absent card would choose the stored form of + * every weight it has a row for. */ extern "C" int rad_plugin_open(void) { const char* root = "/sys/class/kfd/kfd/topology/nodes"; DIR* d = opendir(root); - if (!d) return RAD_OK; - bool readable = false, halo = false; + if (!d) return RAD_E_UNSUPPORTED; + bool halo = false; while (const dirent* e = readdir(d)) { if (e->d_name[0] == '.') continue; const std::string path = std::string(root) + "/" + e->d_name + "/properties"; FILE* f = std::fopen(path.c_str(), "r"); if (!f) continue; - readable = true; char key[64]; unsigned long long v = 0; while (std::fscanf(f, "%63s %llu", key, &v) == 2) @@ -9758,7 +9784,7 @@ extern "C" int rad_plugin_open(void) { std::fclose(f); } closedir(d); - return (!readable || halo) ? RAD_OK : RAD_E_UNSUPPORTED; + return halo ? RAD_OK : RAD_E_UNSUPPORTED; } extern "C" int rad_kernel_schema_count(void) { diff --git a/libhalo/halo_selftest.cpp b/libhalo/halo_selftest.cpp index 0fe49804..a1b4c6a5 100644 --- a/libhalo/halo_selftest.cpp +++ b/libhalo/halo_selftest.cpp @@ -31219,6 +31219,40 @@ static void device_phase(const Plugin& pl) { return v; }; + /* point_fourier: a shape decoder's query points (three values, eight octaves, f32), past + * the 65535 rows one grid row a matrix row would reach, against libm's sinf and cosf. */ + if (sel("point_fourier_f32")) { + if (const RadKernelInfo* r = find(pl, "point_fourier_f32")) { + const int64_t M = 70001, n = 3, F = 8, W = n * (2 * F + 1); + std::vector x = randv((size_t)(M * n), 1.01f); + void* dx = dalloc(x.size() * 4); + void* dy = dalloc((size_t)(M * W) * 4); + if (dx) st_memcpy(dx, x.data(), x.size() * 4, hipMemcpyHostToDevice); + std::vector ts = { T(dx, RAD_F32, { M, n }), T(dy, RAD_F32, { M, W }) }; + std::vector ps = { PI("M", M), PI("n", n), PI("freqs", F), + PS("dtype", "f32") }; + run_case(r, ts, ps); + std::vector got((size_t)(M * W)); + st_memcpy(got.data(), dy, got.size() * 4, hipMemcpyDeviceToHost); + double worst = 0.0; + for (int64_t m = 0; m < M; ++m) + for (int64_t i = 0; i < n; ++i) { + const float v = x[(size_t)(m * n + i)]; + worst = std::max(worst, (double)std::fabs(got[(size_t)(m * W + i)] - v)); + for (int64_t j = 0; j < F; ++j) { + const float t = v * std::ldexp(1.0f, (int)j); + const float* g = &got[(size_t)(m * W)]; + const float es = g[n + i * F + j] - std::sin(t); + const float ec = g[n + n * F + i * F + j] - std::cos(t); + worst = std::max(worst, (double)std::max(std::fabs(es), std::fabs(ec))); + } + } + char d[96]; + std::snprintf(d, sizeof d, "max abs err %.3g", worst); + ok("point_fourier_f32 numerics", worst <= 1e-5, d); + } else ok("point_fourier_f32", false, "row absent"); + } + if (sel("relu_bf16") || sel("silu_bf16") || sel("clamp_bf16")) { const int64_t M = 5, n = 300; std::vector x = randv((size_t)(M * n), 2.0f); diff --git a/libquant/lq_gptq.cpp b/libquant/lq_gptq.cpp index f31ac92d..7376e488 100644 --- a/libquant/lq_gptq.cpp +++ b/libquant/lq_gptq.cpp @@ -181,6 +181,7 @@ struct Slot { std::mutex mu; bool done = false; Gram g; /* null = looked and found nothing */ + std::vector order; /* gptq_factor_ordered's column order */ }; struct Cache { @@ -210,15 +211,32 @@ std::vector gptq_act_order(const char* dir, const char* name, int64_t K return perm; } +namespace { +Gram factor_impl(const char* dir, const char* name, int64_t K, int64_t domain, double damp, + const int32_t* perm, std::vector* order); +} /* namespace */ + Gram gptq_factor(const char* dir, const char* name, int64_t K, int64_t domain, double damp, const int32_t* perm) { + return factor_impl(dir, name, K, domain, damp, perm, nullptr); +} + +Gram gptq_factor_ordered(const char* dir, const char* name, int64_t K, int64_t domain, double damp, + std::vector* order) { + return factor_impl(dir, name, K, domain, damp, nullptr, order); +} + +namespace { +Gram factor_impl(const char* dir, const char* name, int64_t K, int64_t domain, double damp, + const int32_t* perm, std::vector* order) { if (!dir || !*dir || !name || !*name || K <= 0) return nullptr; const std::string stem = calib_resolve(dir, name, K); const bool layer = stem == calib_stem(name); char dk[32]; std::snprintf(dk, sizeof dk, "%.17g", damp); const std::string key = std::string(dir) + "|" + stem + "|" + std::to_string(K) + "|" + - std::to_string(domain) + "|" + dk + (perm ? "|act" : ""); + std::to_string(domain) + "|" + dk + (perm ? "|act" : "") + + (order ? "|ord" : ""); /* A layer's factor is shared by its experts, so it is built once and cached, under a lock of * its own: weights quantised side by side (rad-convert --gpus) factor different layers at @@ -246,15 +264,23 @@ Gram gptq_factor(const char* dir, const char* name, int64_t K, int64_t domain, d slot = it->second; } lk = std::unique_lock(slot->mu); - if (slot->done) return slot->g; + if (slot->done) { + if (order) *order = slot->order; + return slot->g; + } } auto keep = [&](Gram u) { if (slot) { slot->g = u; slot->done = true; + if (order) slot->order = *order; } return u; }; + if (order) { + order->resize((size_t)K); + for (int64_t i = 0; i < K; ++i) (*order)[(size_t)i] = (int32_t)i; + } std::vector acc; const int found = calib_sum(dir, stem, K, domain, &acc); @@ -263,6 +289,14 @@ Gram gptq_factor(const char* dir, const char* name, int64_t K, int64_t domain, d "rounding it to nearest\n", name, dir, stem.c_str()); return keep(nullptr); } + /* gptq_factor_ordered: the order from the same sum (gptq_act_order's: descending diagonal, + * ties in column order), read once for both. */ + if (order) { + std::stable_sort(order->begin(), order->end(), [&](int32_t x, int32_t y) { + return acc[(size_t)x * (size_t)K + (size_t)x] > acc[(size_t)y * (size_t)K + (size_t)y]; + }); + perm = order->data(); + } /* Under act order the factor is of P H P^T, since the recursion runs over columns in * quantisation order. */ if (perm) { @@ -323,6 +357,7 @@ Gram gptq_factor(const char* dir, const char* name, int64_t K, int64_t domain, d "K=%lld\n", stem.c_str(), found, (long long)K); return keep(u); } +} /* namespace */ void gptq_tcq_dyn_scales(const Grid& g, const float* w, int64_t K, Scales& scales, int64_t r0, int64_t r1, int64_t b0, int64_t b1) { @@ -483,6 +518,16 @@ int gptq_quantise(const Grid& g, float* w, int32_t* codes, Scales& scales, int64 gptq_tcq_colf(w, scales, N, K); } if (g.tcq_L) { + /* Only the last run can be short, and one shorter than a state's codes cannot hold its + * seam: the decoder refuses it (grid_tcq_decode), so the encoder does too. */ + const int64_t c = (g.tcq_L + g.tcq_k - 1) / g.tcq_k; + if (N > 0 && N - (N - 1) / g.tcq_rows * g.tcq_rows < c) { + if (why) *why = "the last trellis run is " + + std::to_string(N - (N - 1) / g.tcq_rows * g.tcq_rows) + " row(s) of " + + std::to_string(N) + " (tcq_rows " + std::to_string(g.tcq_rows) + + "), shorter than the " + std::to_string(c) + " a seam state needs"; + return RAD_E_SHAPE; + } if (gpu_enabled()) { std::string w1; const int st = gptq_tcq_gpu(g, w, codes, scales, N, K, u, dynamic, &w1); @@ -613,6 +658,35 @@ void gptq_tcq_refine(const Grid& g, const float* x, float* w, int32_t* codes, co } } /* namespace */ +void gptq_rescale_rows(const float* x, float* w, Scales& scales, int64_t N, int64_t K, + const float* h) { + if (!x || !w || !h || N <= 0 || K <= 0 || scales.nc != 1 || scales.br != 1) return; + std::vector hx((size_t)(N * K)), hw((size_t)(N * K)); + mat_hess(x, N, K, h, hx.data()); + mat_hess(w, N, K, h, hw.data()); +#ifdef _OPENMP +#pragma omp parallel for schedule(static) +#endif + for (int64_t n = 0; n < N; ++n) { + float* wr = w + (size_t)(n * K); + const float* xr = hx.data() + (size_t)(n * K); + const float* qr = hw.data() + (size_t)(n * K); + double num = 0.0, den = 0.0; + for (int64_t j = 0; j < K; ++j) { + num += (double)wr[j] * xr[j]; + den += (double)wr[j] * qr[j]; + } + if (!(num > 0.0) || !(den > 0.0)) continue; + const float a = (float)(num / den); + BlockScale& b = scales.b[(size_t)n]; + b.s *= a; + b.stored *= a; + b.inv = 1.0f / b.s; + b.inv_d = 1.0 / (double)b.s; + for (int64_t j = 0; j < K; ++j) wr[j] *= a; + } +} + void gptq_refine(const Grid& g, const float* x, float* w, int32_t* codes, const Scales& scales, int64_t N, int64_t K, const float* h, double damp, int passes) { if (!x || !w || !codes || !h || N <= 0 || K <= 0 || passes <= 0) return; diff --git a/libquant/lq_gptq.h b/libquant/lq_gptq.h index 9364b424..08244e33 100644 --- a/libquant/lq_gptq.h +++ b/libquant/lq_gptq.h @@ -32,6 +32,11 @@ namespace lq { Gram gptq_factor(const char* dir, const char* name, int64_t K, int64_t domain, double damp, const int32_t* perm = nullptr); +/* gptq_factor in act order (gptq_act_order's), the order into `order`: one read of the calibration + * for both, cached with the factor. */ +Gram gptq_factor_ordered(const char* dir, const char* name, int64_t K, int64_t domain, double damp, + std::vector* order); + /* Act order: columns by descending Hessian diagonal (the input energy each carries), ties in * column order. The identity when `dir` holds nothing for the weight. */ std::vector gptq_act_order(const char* dir, const char* name, int64_t K, int64_t domain); @@ -73,5 +78,14 @@ void gptq_tcq_col_scales(const Grid& g, const Scales& scales, int64_t n0, int64_ void gptq_refine(const Grid& g, const float* x, float* w, int32_t* codes, const Scales& scales, int64_t N, int64_t K, const float* h, double damp, int passes); +/* Each row's scale refitted after the loop, the codes held: the row's decoded values w scaled by + * a = (w H x^T) / (w H w^T), the factor minimising (a w - x) H (a w - x)^T. GPTQ chooses a row's + * codes against a scale fixed beforehand from the weight alone; the refit is the least-squares + * scale for the codes it chose, under the same (undamped) Hessian. Rows with one static scale + * (Scales with one block a row, f32 so the stored value moves exactly); `x`, `w` and `h` as for + * gptq_refine, `w` scaled in place. A factor that is not positive leaves its row alone. */ +void gptq_rescale_rows(const float* x, float* w, Scales& scales, int64_t N, int64_t K, + const float* h); + } /* namespace lq */ diff --git a/libquant/lq_grid.cpp b/libquant/lq_grid.cpp index 9d14664d..c2f688c3 100644 --- a/libquant/lq_grid.cpp +++ b/libquant/lq_grid.cpp @@ -418,21 +418,26 @@ int grid_parse(const RadParam* o, int n_o, Grid* g, std::string* why) { g->tcq_L = (int)L; g->tcq_k = k; g->tcq_rows = rad_param_geti(o, n_o, "tcq_rows", 256); - if (g->tcq_rows < 1) { - if (why) *why = "tcq_rows= is the rows one trellis runs over, 1 or more"; + /* A run holds its seam state in its rows' codes, so it needs at least a state's worth + * of them; the decoder refuses a shorter run. */ + if (g->tcq_rows < (L + k - 1) / k) { + if (why) *why = "tcq_rows= is the rows one trellis runs over, at least the " + + std::to_string((L + k - 1) / k) + " whose codes hold one state"; return RAD_E_INVAL; } const int64_t S = (int64_t)1 << L; double lut_unit = 0.0; if (const char* code = rad_param_gets(o, n_o, "tcq_code", nullptr)) { - if (std::strcmp(code, "mad") != 0 || rad_param_gets(o, n_o, "tcq_lut", nullptr)) { - if (why) *why = "tcq_code=mad computes the states' values: no tcq_lut="; + const bool wide = std::strcmp(code, "mad16") == 0; + if ((!wide && std::strcmp(code, "mad") != 0) || rad_param_gets(o, n_o, "tcq_lut", nullptr)) { + if (why) *why = "tcq_code=mad or mad16 computes the states' values: no tcq_lut="; return RAD_E_INVAL; } - g->tcq_mad = true; + g->tcq_mad = !wide; + g->tcq_wide = wide; g->tcq_a = (uint32_t)rad_param_geti(o, n_o, "tcq_a", 0xB5297B) & 0xFFFFFFu; g->tcq_b = (uint32_t)rad_param_geti(o, n_o, "tcq_b", 0x2545F491); - g->tcq_lut = tcq_lut_mad((int)L, g->tcq_a, g->tcq_b); + g->tcq_lut = tcq_lut_mad((int)L, g->tcq_a, g->tcq_b, wide); } else if (const char* lf = rad_param_gets(o, n_o, "tcq_lut", nullptr)) { /* The states' values, integers in -127..127 separated by white space, in state order; * a line "# unit X" names the units a unit-rms block spans (default: the values' rms). */ @@ -1143,11 +1148,12 @@ void grid_tcq_run(const Grid& g, const float* x, const float* s, int64_t n, int3 } } -std::vector tcq_lut_mad(int L, uint32_t a, uint32_t b) { +std::vector tcq_lut_mad(int L, uint32_t a, uint32_t b, bool wide) { std::vector lut((size_t)1 << L); for (uint32_t st = 0; st < (1u << L); ++st) { - const uint32_t h = (((st & 0xFFFFFFu) * (a & 0xFFFFFFu)) + b) & 0x3F3F3F3Fu; - lut[st] = (float)((int)((h & 0xFFu) + ((h >> 8) & 0xFFu) + ((h >> 16) & 0xFFu) + (h >> 24)) - 126); + const uint32_t h = (((st & 0xFFFFFFu) * (a & 0xFFFFFFu)) + b) & (wide ? 0xFFFFFFFFu : 0x3F3F3F3Fu); + lut[st] = (float)((int)((h & 0xFFu) + ((h >> 8) & 0xFFu) + ((h >> 16) & 0xFFu) + (h >> 24)) - + (wide ? 510 : 126)); } return lut; } diff --git a/libquant/lq_grid.h b/libquant/lq_grid.h index c2be21d0..5ad847e3 100644 --- a/libquant/lq_grid.h +++ b/libquant/lq_grid.h @@ -126,6 +126,10 @@ struct Grid { * table is still stored, A and B beside it ("trellis.mad"). */ bool tcq_mad = false; uint32_t tcq_a = 0, tcq_b = 0; + /* tcq_code=mad16: the same hash with every byte whole, bytesum(h) - 510 (sigma ~148, where mad's + * is ~37): values a 16-bit reader takes exactly (f16 holds integers to 2048), so the code is not + * held to the int8 grid's ~42 dB floor. No int8 encoding can carry it; gptqsim measures it. */ + bool tcq_wide = false; /* The planes of the encoding, by index; -1 when the grid has none. */ int plane_zero() const { return asym ? 2 : -1; } @@ -180,8 +184,9 @@ int grid_code(const Grid& g, const BlockScale& b, float v); int grid_vq_code(const Grid& g, const BlockScale& b, const float* v); float grid_decode(const Grid& g, const BlockScale& b, int code); -/* tcq_code=mad's value of every one of the 2^L states (Grid::tcq_mad). */ -std::vector tcq_lut_mad(int L, uint32_t a, uint32_t b); +/* tcq_code=mad's value of every one of the 2^L states (Grid::tcq_mad); with `wide`, mad16's + * (Grid::tcq_wide). */ +std::vector tcq_lut_mad(int L, uint32_t a, uint32_t b, bool wide = false); /* A trellis grid's search state for one run, reused across runs. */ struct TcqWork { diff --git a/libquant/lq_hess.cpp b/libquant/lq_hess.cpp index b76ed4b1..2ad553d6 100644 --- a/libquant/lq_hess.cpp +++ b/libquant/lq_hess.cpp @@ -254,6 +254,11 @@ std::string calib_stem(const char* name) { if (s[i] < '0' || s[i] > '9') { all_digits = false; break; } if (all_digits) s.resize(dot); } + /* A vocabulary-weighted lm_head's width classes (output.k) are rows of one weight: they + * read the head's input Gram. */ + if (s.size() > 8 && s.compare(0, 8, "output.k") == 0 && + s.find_first_not_of("0123456789", 8) == std::string::npos) + s.resize(6); return s; } diff --git a/libquant/lq_hess.h b/libquant/lq_hess.h index f3ced66c..b4366849 100644 --- a/libquant/lq_hess.h +++ b/libquant/lq_hess.h @@ -36,7 +36,8 @@ namespace lq { using Gram = std::shared_ptr>; /* `blk.7.ffn_gate_up_exps.123.weight` -> `blk.7.ffn_gate_up_exps`: the stem a layer's pooled - * Hessian file is named by. */ + * Hessian file is named by. A vocabulary-weighted head's width class, `output.k4.weight`, pools + * to `output`. */ std::string calib_stem(const char* name); /* The stem `name`'s Hessian is read from in `dir`: the weight's own (the name less `.weight`, diff --git a/libquant/lq_quant.h b/libquant/lq_quant.h index acde3041..a6d07c08 100644 --- a/libquant/lq_quant.h +++ b/libquant/lq_quant.h @@ -33,7 +33,8 @@ { "tcq_rb", RAD_P_INT, "0", \ "R: a trellis's values on the int8 grid of one scale per R rows (the block's largest)" }, \ { "tcq_code", RAD_P_STR, nullptr, \ - "mad: the states' values computed, bytesum((st*A+B) & 0x3F3F3F3F) - 126 (no tcq_lut=)" }, \ + "mad: the states' values computed, bytesum((st*A+B) & 0x3F3F3F3F) - 126 (no tcq_lut=); " \ + "mad16: bytesum(st*A+B) - 510, wider than int8, for the 16-bit path (gptqsim only)" }, \ { "tcq_a", RAD_P_INT, "11872635", "tcq_code=mad's multiplier A (24 bits)" }, \ { "tcq_b", RAD_P_INT, "625341585", "tcq_code=mad's addend B" }, \ { "tcq_colf", RAD_P_INT, "0", \ diff --git a/libquant/lq_registry.cpp b/libquant/lq_registry.cpp index 03b83d6d..3591063e 100644 --- a/libquant/lq_registry.cpp +++ b/libquant/lq_registry.cpp @@ -58,9 +58,15 @@ const RadQuantOption kGptqOptions[] = { { "act_order", RAD_P_INT, "0", "1: quantise the columns by descending input energy, stored in that order with the " "permutation as the encoding's transform (a kernel permutes its activation to match)" }, + { "tcq_order", RAD_P_INT, "0", + "a trellis's column order: 1 runs GPTQ over the columns by descending input energy, the codes " + "stored in column order (each column is its own trellis, so the reader is unchanged)" }, { "cd", RAD_P_INT, "0", "sweeps of coordinate descent after the loop: every code re-chosen at its conditional " "optimum against the same damped Hessian, the other columns held (lq_gptq.h)" }, + { "rescale", RAD_P_INT, "0", + "1: after the loop each row's scale is refitted to its codes, the least-squares factor under " + "the Hessian (one static f32 scale a row; lq_gptq.h gptq_rescale_rows)" }, { "dyn", RAD_P_INT, "0", "1: each 128-column group's scale chosen when the loop reaches it, from the values earlier " "columns' error has moved it to (one scale level, groups of 128)" }, @@ -106,6 +112,9 @@ int gptq_encoding(const RadParam* o, int n_o, const RadQuantWeight* w, RadEncodi Grid g; const int st = grid_of(o, n_o, w, &g, true); if (st != RAD_OK) return st; + if (g.tcq_wide) + return refuse(w, "tcq_code=mad16's values are wider than int8, and no reader decodes them " + "yet (the 16-bit path): quantise it with gptqsim"); *out = grid_encoding(g); if (rad_param_geti(o, n_o, "act_order", 0)) { if (g.fwht) return refuse(w, "act_order=1 and transform= are two transforms, and an " @@ -132,6 +141,8 @@ int gptq_decode(const RadEncoding* e, const RadQuantWeight* w, const void* const return grid_tcq_decode(e, w->rows, w->cols, planes, row0, rows, out); } +/* `planes` null: quantise and leave the decoded values in `src` (the grid's domain, column order), + * storing nothing -- gptqsim's use. */ int gptq_quantize(const RadParam* o, int n_o, const RadQuantWeight* w, float* src, int64_t row0, int64_t rows, void* const* planes) { Grid g; @@ -144,17 +155,28 @@ int gptq_quantize(const RadParam* o, int n_o, const RadQuantWeight* w, float* sr const char* dir = rad_param_gets(o, n_o, "calib", nullptr); const double damp = rad_param_getf(o, n_o, "damp", 0.01); const bool act = rad_param_geti(o, n_o, "act_order", 0) != 0; + /* A trellis's columns are independent codes, so GPTQ may take them in any order while they + * stay stored in column order: the order is the quantiser's alone. */ + const bool tord = g.tcq_L && rad_param_geti(o, n_o, "tcq_order", 0) != 0; std::vector perm; std::vector imp_p; const float* imp = w->importance; - if (act) { - perm = gptq_act_order(dir, w->name, K, g.fwht); + auto permute = [&](float* m, bool inverse) { std::vector row((size_t)K); for (int64_t r = 0; r < N; ++r) { - float* wr = src + r * K; - for (int64_t j = 0; j < K; ++j) row[(size_t)j] = wr[perm[(size_t)j]]; + float* wr = m + r * K; + for (int64_t j = 0; j < K; ++j) { + if (inverse) row[(size_t)perm[(size_t)j]] = wr[j]; + else row[(size_t)j] = wr[perm[(size_t)j]]; + } std::memcpy(wr, row.data(), (size_t)K * sizeof(float)); } + }; + Gram uf; + if (tord) uf = gptq_factor_ordered(dir, w->name, K, g.fwht, damp, &perm); + else if (act) perm = gptq_act_order(dir, w->name, K, g.fwht); + if (act || tord) { + permute(src, false); if (imp) { imp_p.resize((size_t)K); for (int64_t j = 0; j < K; ++j) imp_p[(size_t)j] = imp[perm[(size_t)j]]; @@ -165,19 +187,26 @@ int gptq_quantize(const RadParam* o, int n_o, const RadQuantWeight* w, float* sr /* Scales come first, from the weight as it stands, and stay fixed through the loop -- or with * dyn=1 each group's is chosen again as the loop reaches it (gptq_quantise). */ Scales sc = grid_scales(g, src, N, K, imp); - const Planes p = grid_planes(g, K, planes); + const Planes p = planes ? grid_planes(g, K, planes) : Planes{}; const bool dyn = rad_param_geti(o, n_o, "dyn", 0) != 0; if (dyn && !gptq_dynamic_ok(g, sc)) return refuse(w, "dyn=1 chooses a 128-column group's scale as GPTQ reaches it, which needs " "one scale level per row and 128 columns"); + if (tord && (dyn || sc.bc < K || g.lv2 || g.tcq_rb)) + return refuse(w, "tcq_order=1 runs the columns out of order, so it takes one static scale a " + "row (block=1x*, no dyn, scale2 or row blocks)"); - const Gram uf = gptq_factor(dir, w->name, K, g.fwht, damp, act ? perm.data() : nullptr); + if (!tord) uf = gptq_factor(dir, w->name, K, g.fwht, damp, act ? perm.data() : nullptr); const float* u = uf ? uf->data() : nullptr; std::vector codes((size_t)(N * K)); const int cd = (int)rad_param_geti(o, n_o, "cd", 0); + const bool rescale = rad_param_geti(o, n_o, "rescale", 0) != 0; + if (rescale && (dyn || sc.nc != 1 || sc.br != 1 || g.lv2 || g.tcq_rb || g.scale_dt != RAD_F32)) + return refuse(w, "rescale=1 refits one static f32 scale a row (block=1x*, scale=f32, no dyn, " + "scale2 or row blocks)"); std::vector x0; - if (cd > 0 && u) x0.assign(src, src + (size_t)(N * K)); + if ((cd > 0 || rescale) && u) x0.assign(src, src + (size_t)(N * K)); { std::string why; const int st = gptq_quantise(g, src, codes.data(), sc, N, K, u, dyn && u, &why); @@ -186,11 +215,26 @@ int gptq_quantize(const RadParam* o, int n_o, const RadQuantWeight* w, float* sr return st; } } - grid_store_scales(g, sc, p); - if (!x0.empty()) { + if (tord) { + permute(src, true); + if (!x0.empty()) permute(x0.data(), true); + std::vector row((size_t)K); + for (int64_t r = 0; r < N; ++r) { + int32_t* cr = codes.data() + r * K; + for (int64_t j = 0; j < K; ++j) row[(size_t)perm[(size_t)j]] = cr[j]; + std::memcpy(cr, row.data(), (size_t)K * sizeof(int32_t)); + } + } + if (!x0.empty() && rescale) { + const Gram h = calib_gram(dir, w->name, K, g.fwht, "gptq rescale"); + if (h) gptq_rescale_rows(x0.data(), src, sc, N, K, h->data()); + } + if (planes) grid_store_scales(g, sc, p); + if (!x0.empty() && cd > 0) { const Gram h = calib_gram(dir, w->name, K, g.fwht, "gptq cd"); if (h) gptq_refine(g, x0.data(), src, codes.data(), sc, N, K, h->data(), damp, cd); } + if (!planes) return RAD_OK; const int64_t V = g.vq.empty() ? 1 : g.vdim; /* one code a vector */ #ifdef _OPENMP #pragma omp parallel for schedule(static) if (N * K > (1 << 20)) @@ -252,6 +296,47 @@ int cast_quantize(const RadParam* o, int n_o, const RadQuantWeight* w, float* sr return RAD_OK; } +/* ------------------------------------------------------------------ gptqsim */ +/* gptq on any grid, its decoded values stored as plain bf16 in the weight's own domain (the grid's + * rotation undone): what a reader that decodes the codes to 16 bits and runs a 16-bit GEMM over a + * 16-bit activation computes -- the W16A16 form a selected tensor can take -- measured before that + * reader exists. A plain bf16 linear runs gemm_nt over the bf16 activation, so the engine serves it + * as is. bf16 keeps 8 bits of mantissa, finer than a 7-bit code's error; tcq_code=mad16 is the code + * the 16-bit path can hold that int8 cannot. The container holds 16 bits a weight: a measurement + * sizes the tensor at its grid's bits. */ +int gptqsim_encoding(const RadParam* o, int n_o, const RadQuantWeight* w, RadEncoding* out) { + if (declines(w)) return RAD_E_UNSUPPORTED; + Grid g; + const int st = grid_of(o, n_o, w, &g, true); + if (st != RAD_OK) return st; + if (rad_param_geti(o, n_o, "act_order", 0)) + return refuse(w, "gptqsim stores the values in column order: tcq_order=1, not act_order=1"); + *out = rad_enc_plain(RAD_BF16); + return RAD_OK; +} + +int gptqsim_quantize(const RadParam* o, int n_o, const RadQuantWeight* w, float* src, int64_t row0, + int64_t rows, void* const* planes) { + Grid g; + int st = grid_of(o, n_o, w, &g, true); + if (st != RAD_OK) return st; + st = gptq_quantize(o, n_o, w, src, row0, rows, nullptr); + if (st != RAD_OK) return st; + const int64_t N = w->rows, K = w->cols; + /* The unnormalised Hadamard is its own inverse up to its width: F F = n I. */ + if (g.fwht) { + grid_transform_rows(g, src, N, K); + const float inv = 1.0f / (float)g.fwht; + for (int64_t i = 0; i < N * K; ++i) src[i] *= inv; + } + uint16_t* out = (uint16_t*)planes[0]; +#ifdef _OPENMP +#pragma omp parallel for schedule(static) if (N * K > (1 << 20)) +#endif + for (int64_t i = 0; i < N * K; ++i) out[i] = f32_to_bf16(src[i]); + return RAD_OK; +} + const RadQuantizerInfo kQuantizers[] = { { "rtn", "round to nearest: every value to its nearest point on the grid, the scale of each block " @@ -263,6 +348,11 @@ const RadQuantizerInfo kQuantizers[] = { "over the columns after it, on any grid, the scales fixed from the weight first", kGptqOptions, (int)(sizeof kGptqOptions / sizeof kGptqOptions[0]), gptq_encoding, whole_weight, gptq_quantize, gptq_decode }, + { "gptqsim", + "gptq on any grid with the decoded values stored as plain bf16, the grid's rotation undone: " + "the W16A16 form of a tensor (a 16-bit decode and GEMM), measured before its reader exists", + kGptqOptions, (int)(sizeof kGptqOptions / sizeof kGptqOptions[0]), + gptqsim_encoding, whole_weight, gptqsim_quantize, nullptr }, { "cast", "a float weight converted to another float dtype, to nearest even, with no scale", kCastOptions, (int)(sizeof kCastOptions / sizeof kCastOptions[0]), diff --git a/libquant/lq_tcq_gpu.hip b/libquant/lq_tcq_gpu.hip index 3d9428aa..25094af2 100644 --- a/libquant/lq_tcq_gpu.hip +++ b/libquant/lq_tcq_gpu.hip @@ -56,12 +56,19 @@ struct TcqArgs { /* A thread's E states' table values. With PACK they sit four to a register as the int8 they are * (the table holds integers in -127..127), for the wide forms. */ -template +template struct Lut { + /* PACK 1: four int8 a register; 2: two int16 a register, for a wide code (tcq_code=mad16, + * values past int8); 0: one float a state. */ + static constexpr int NP = PACK == 2 ? E / 2 : PACK ? E / 4 : 1; float f[PACK ? 1 : E]; - uint32_t p[PACK ? E / 4 : 1]; + uint32_t p[NP]; __device__ void set(int e, float v) { - if (PACK) { + if (PACK == 2) { + const uint32_t b = (uint32_t)(uint16_t)(int16_t)(int)v; + if (e % 2 == 0) p[e / 2] = b; + else p[e / 2] |= b << 16; + } else if (PACK) { const uint32_t b = (uint32_t)(uint8_t)(int8_t)(int)v; if (e % 4 == 0) p[e / 4] = b; else p[e / 4] |= b << (8 * (e % 4)); @@ -70,6 +77,7 @@ struct Lut { } } __device__ float at(int e) const { + if (PACK == 2) return (float)(int16_t)(p[e / 2] >> (16 * (e % 2))); if (PACK) return (float)(int8_t)(p[e / 4] >> (8 * (e % 4))); return f[e]; } @@ -97,7 +105,7 @@ __device__ inline bool cheaper(float ac, int ai, float bc, int bi) { * tcq_rb, NB the groups' cheapest held in one LDS buffer or two (one: a second barrier a step, for * the state counts whose two do not fit). The geometry is compile-time, so a state's LDS address * is an immediate offset from the thread's. */ -template +template __global__ void __launch_bounds__((1 << (L - KB)) * SH / M) __attribute__((amdgpu_waves_per_eu(WPE))) tcq_block(TcqArgs a) { /* SH lanes share a group's predecessors, BT each; a thread holds M groups' worth. */ @@ -166,7 +174,7 @@ __attribute__((amdgpu_waves_per_eu(WPE))) tcq_block(TcqArgs a) { * a register a state again. */ if constexpr (PACK) { #pragma unroll - for (int q = 0; q < E / 4; ++q) asm volatile("" : "+v"(lv.p[q])); + for (int q = 0; q < Lut::NP; ++q) asm volatile("" : "+v"(lv.p[q])); } #pragma unroll for (int m = 0; m < M; ++m) { @@ -326,13 +334,15 @@ using BlockKernel = void (*)(TcqArgs); * packed table and an occupancy target (R9700, a 96-run weight of 5120 columns): fewer threads a * run let more runs share a WGP, until the states a thread holds spill. 1024 threads at most, the * wide codes' groups split over lanes. The 2^10-state forms are the default sizing, for tests. */ -struct Form { int L, k; BlockKernel plain, rb; int threads, nb; }; +/* `wide`: the forms for a code whose values pass int8 (tcq_code=mad16), the table packed two int16 + * a register. */ +struct Form { int L, k; BlockKernel plain, rb; int threads, nb; bool wide; }; #define LQ_FORM(l, kb, m, sh, pack, wpe) \ { l, kb, tcq_block, tcq_block, \ - (1 << (l - kb)) * sh / m, 2 } + (1 << (l - kb)) * sh / m, 2, (pack) == 2 } #define LQ_FORM1(l, kb, m, sh, pack, wpe) \ { l, kb, tcq_block, \ - tcq_block, (1 << (l - kb)) * sh / m, 1 } + tcq_block, (1 << (l - kb)) * sh / m, 1, (pack) == 2 } const Form kForms[] = { LQ_FORM(10, 2, 1, 1, false, 1), LQ_FORM(10, 3, 2, 1, false, 1), LQ_FORM(10, 4, 1, 1, false, 1), LQ_FORM(10, 5, 1, 1, false, 1), @@ -344,13 +354,16 @@ const Form kForms[] = { * states at 2 bits in one; not yet swept */ LQ_FORM1(15, 2, 8, 1, true, 1), LQ_FORM1(16, 3, 8, 1, true, 1), LQ_FORM(16, 4, 4, 1, true, 1), LQ_FORM(16, 5, 2, 1, true, 1), LQ_FORM(16, 6, 1, 1, true, 1), LQ_FORM(16, 7, 1, 2, true, 1), + /* the wide code's forms: the sweep's shapes, the table at int16 */ + LQ_FORM1(16, 3, 8, 1, 2, 1), LQ_FORM(16, 4, 4, 1, 2, 1), LQ_FORM(16, 5, 2, 1, 2, 1), + LQ_FORM(16, 6, 1, 1, 2, 1), LQ_FORM(16, 7, 1, 2, 2, 1), }; #undef LQ_FORM #undef LQ_FORM1 -const Form* pick_form(int L, int k) { +const Form* pick_form(int L, int k, bool wide) { for (const Form& f : kForms) - if (f.L == L && f.k == k) return &f; + if (f.L == L && f.k == k && f.wide == wide) return &f; return nullptr; } @@ -577,7 +590,7 @@ bool gpu_enabled() { return !devices().empty(); } int gptq_tcq_gpu(const Grid& g, float* w, int32_t* codes, Scales& scales, int64_t N, int64_t K, const float* u, bool dynamic, std::string* why) { - const Form* f = pick_form(g.tcq_L, g.tcq_k); + const Form* f = pick_form(g.tcq_L, g.tcq_k, g.tcq_wide); const int64_t T = g.tcq_rows; if (!f) { *why = "the card has no trellis kernel for tcq=" + std::to_string(g.tcq_L) + " with " + diff --git a/libr3d/CMakeLists.txt b/libr3d/CMakeLists.txt index 39529746..b7c3fa35 100644 --- a/libr3d/CMakeLists.txt +++ b/libr3d/CMakeLists.txt @@ -115,16 +115,15 @@ set(R3D_UNITS # fragment-order permute is the row's own relayout hook, at load. "r3d_gemm_w4a16_nt_m64|" "r3d_gemm_w5a16_nt_m64|" - # The gated-delta-net chunk preamble: the gram and the blocked inverse of I + the strictly - # lower decayed gram, one 64-chunk a workgroup, the gram per k head. - "r3d_gdn_kkt_solve_c64|" - # The gated-delta-net chunked scan: the chunk's output and its closing state, the recurrent - # state in wave-matrix accumulators across the chunk loop. - "r3d_gdn_chunk_scan_k128_v128_c64|" + # The gated-delta-net chunk preamble, chunked scan and recurrent update: libhalo's kernels + # (r3dh_*, the halo_ -> r3dh_ rename), checked against libref on gfx1151 and compiled here for + # the whole family. The recurrent update serves both state forms (per_candidate and anchor). + "r3dh_gdn_kkt_solve|" + "r3dh_gdn_chunk_scan|" + "r3dh_gdn_recurrent_update|" "r3d_gdn_gated_rmsnorm_h128|" "r3d_gdn_gated_norm_had_quant_i8|" "r3d_gdn_conv_w4_h128|" - "r3d_gdn_recurrent_update_k128_v128|" # Mixture of experts: each routing weight times its expert's own scale, in place. "r3d_expert_scale_bf16|" # The router: softmax over the expert logits, the top_k by value, renormalised if `norm`. @@ -136,6 +135,15 @@ set(R3D_UNITS # The grouped w4a8 GEMM core: int8 activation x two's-complement 4-bit weight, widened to f16 and # run on the f16 wave-matrix, a per-(row, 128-of-K) scale fold. Phase 1: dense rows, no gather. "r3d_moe_gemm_w4a8|" + # The grouped w4a4 GEMM: int4 activation x two-s-complement 4-bit weight, both widened to int8 + # and run on the exact i32 wave-matrix, a per-(row, 128-of-K) scale fold. + "r3d_moe_gemm_w4a4|" + "r3d_dequant_w4_bf16|" + "r3d_rowtopk_merge|" + "r3d_ngram_ids|" + "r3d_gemm_fp8a8_bias|" + "r3d_gemm_fp8a8_short|" + "r3d_moe_gemm_q_mod4|" # The grouped E4M3 x E4M3 GEMM (moe_gemm_q): both operands fp8, staged compact and upcast to f16 # in registers (the FeatherOps bit trick), the f16 wave-matrix, a per-(row, g-of-K) scale fold. "r3d_moe_gemm_q|" diff --git a/libr3d/README.md b/libr3d/README.md index 924788bb..d9f0b4b2 100644 --- a/libr3d/README.md +++ b/libr3d/README.md @@ -8,7 +8,10 @@ the kernel-plugin rows the engine selects from (`r3d_rows.cpp`); `libr3d/CMakeLi every unit and its flags. It claims `^gfx11` where [`libr4d`](../libr4d/README.md) claims `^gfx12`; a card gets one device -library, chosen by the rows, not the name. The kernels are not ports of libr4d's: gfx11 has no +library, chosen by the rows, not the name. `rad_plugin_open` declines a machine whose KFD +topology lists no gfx11 card (a process without `/dev/kfd` sees none), so in an installation that +also carries libr4d the tools, which resolve kernels without the engine's code-object check, never +lay an RDNA4 container's weights out for libr3d. The kernels are not ports of libr4d's: gfx11 has no bf16 pack and no VOPD, and a different integer instruction set, so every arithmetic path is its own. The matrix work splits by dtype: the bf16/f16 GEMM rows (the m64 band and the prefill-tiled form) and every MoE GEMM row run on the 16x16x16 wave-matrix (WMMA) builtins retiled onto a 16x128 @@ -61,11 +64,11 @@ The table groups the rows by family; `r3d_rows.cpp` and `r3d.h` hold the full se | `vocab` | `logits_gemm_bf16`: the head, read once per token, as bf16 or as E4M3 codes with a bf16 scale per 128x128 block; the `impl` axis picks the decode (the LDS table, the per-byte ALU formula) | | `quant` | `quant_act_fp8_bf16`, `quant_act_i8_bf16`, `quant_act_i8g_bf16`, `had_quant_act_{i8,fp8}_bf16` and `had_quant_act_i8g_bf16` (the same with a block Walsh-Hadamard rotation), `gated_had_quant_{i8,i8g,fp8}_bf16`, `gelu_mul_quant_i8_bf16`, `quant_cols_fp8_bf16`, `rmsnorm_quant_{fp8,i8}_bf16` (norm and quantiser in one pass), `gated_quant_fp8_bf16`, `dequant_fp8`, `dequant_e5m2`, `dequant_i8` | | `sample` | pre-filters `sample_{penalties,dry,ngram_ban,mask,logprobs}_f32`; spine `sample_{argmax,temp,topk,pick,topp,minp,typical,xtc}_f32` — f32 logits in and out, the draw the reference's in its order, the top-R scan single-pass (the plane read once) | -| `moe` | `expert_scale_bf16` (the renormalised top-k weight times the expert's per-expert scale, in place), `moe_router_topk_bf16` (softmax top-k, renormalised if `norm`), `moe_router_topk_scatter` (the top-k and the counting sort as one op), `moe_router_sigmoid_topk` (the GLM-style router: sigmoid scores, selection on scores + bias, the kept weights scaled by `route_scale`), `moe_scatter_small` (the routed slots' stable counting sort; histogram in LDS, T ≤ 1024), `moe_gather` (fold the expert outputs back to the token, with the optional shared arm), `moe_gemm_q_e4m3` (grouped E4M3 GEMM; the `impl` axis: 16x16 table decode, 16x16 ALU decode, 16x128 block with the F32 scales folded), `moe_gemm_bf16` (unquantised experts, wave matrix), `moe_gemm_mxfp4a8` (canonical MXFP4 experts), `row_topk_{bf16,f32}` (the reference files the op under `moe`, so the row does too). `r3d_rad_moe_gemm_w4a8` is an exported WIP launcher (packed int4 weights, the i32 wave matrix) that is not a row: no `r3d_rows.cpp` entry, no selftest, per its kernel header | -| `gdn` | `gdn_kkt_solve_c64` (`A = (I + strict_lower(diag(beta) K K^T e^{g_i-g_j}))^-1` per 64-chunk), `gdn_chunk_scan_k128_v128_c64` (the chunked scan: WY recompute, state recurrence and output in one kernel), `gdn_gated_rmsnorm_h128`, `gdn_gated_norm_had_quant_i8` (the gated norm fused with the rotation and quantiser), `gdn_conv_prep_w4_h128` (causal conv, split, l2norm, gating and the per-chunk gate cumsum in one prefill kernel), `gdn_conv_update_w4_h128` (the same convolution at decode over a rolling conv-state buffer), `gdn_recurrent_update_k128_v128` (the decode-time recurrent state update) | +| `moe` | `expert_scale_bf16` (the renormalised top-k weight times the expert's per-expert scale, in place), `moe_router_topk_bf16` (softmax top-k, renormalised if `norm`), `moe_router_topk_scatter` (the top-k and the counting sort as one op), `moe_router_sigmoid_topk` (the GLM-style router: sigmoid scores, selection on scores + bias, the kept weights scaled by `route_scale`), `moe_scatter_small` (the routed slots' stable counting sort: one workgroup up to 1024 slots, three passes over 256-slot tiles above), `moe_gather` (fold the expert outputs back to the token, with the optional shared arm), `moe_gemm_q_e4m3` (grouped E4M3 GEMM; the `impl` axis: 16x16 table decode, 16x16 ALU decode, 16x128 block with the F32 scales folded), `moe_gemm_bf16` (unquantised experts, wave matrix), `moe_gemm_mxfp4a8` (canonical MXFP4 experts), `moe_gemm_w4a8` (int8 activation, packed two's-complement int4 experts: the i32 wave matrix, an f32 a-scale and a bf16 w-scale per (row, 128 of K), token- and sorted-order `a`), `moe_gemm_w4a4` (int4 activation, packed two's-complement int4 experts: both widen to int8 on the i32 wave matrix, an f32 a-scale and a bf16 w-scale per (row, 128 of K), token- and sorted-order `a`), `row_topk_{bf16,f32}` (the reference files the op under `moe`, so the row does too) | +| `gdn` | `gdn_kkt_solve_c64` (`A = (I + strict_lower(diag(beta) K K^T e^{g_i-g_j}))^-1` per 64-chunk; libhalo's kernel), `gdn_chunk_scan_k128_v128_c64` (the chunked scan: WY recompute, state recurrence and output in one kernel; libhalo's), `gdn_gated_rmsnorm_h128`, `gdn_gated_norm_had_quant_i8` (the gated norm fused with the rotation and quantiser), `gdn_conv_prep_w4_h128` (causal conv, split, l2norm, gating and the per-chunk gate cumsum in one prefill kernel), `gdn_conv_update_w4_h128` (the same convolution at decode over a rolling conv-state buffer), `gdn_recurrent_update_k128_v128` (the decode-time recurrent state update, per_candidate or anchor; libhalo's), `gdn_conv_recurrent_update_k128_v128` (the convolution and the recurrent update as one decode kernel, q/k/v never materialised; libhalo's) | | `draft` | `dflash_select_bf16`: the drafter's accept step, a walk over the draft block's candidate lattice | -The table holds 109 rows over 70 schemas; `r3d_selftest` checks every schema slot for slot against +The table holds 111 rows over 72 schemas; `r3d_selftest` checks every schema slot for slot against the `libref.so` beside the plugin. Fourteen rows carry tune axes (see [Tunable params](#tunable-params)); the rest are single-implementation. @@ -300,22 +303,29 @@ The grouped GEMM rows share the run-walk / gather structure: the block walks the weights, rows the run does not own are padding and their output is dropped, and a dropped slot (sorted token < 0) writes zero. `y` is in sorted order. +The experts arrive as weight tables (`RAD_OPD_WTAB`, `r3d_moe_tab.h`): a device array of one +pointer per expert, or a stacked plane, read on the device. `a_order` "token" (gate_up) gathers row +`i` from `a[sorted_tok[i] / top_k]`, "sorted" (down) reads `a[i]`. `moe_gemm_q`'s odd class must +match the even one (`N_odd = N`, `K_odd = K`, as on one card); an uneven class is refused by name, +and `parts` is then the identity. `r3d_selftest` checks each row's values against the reference's +arithmetic on routed batches with dropped slots, an N tail block and both orders. + * `moe_gemm_bf16` — unquantised experts: the bf16 operands stage straight into the bf16 wave-matrix - fragments, f32 accumulate over the whole of K, no scales, `y` bf16. The weight is the checkpoint's - own bytes ([n_expert, N, K] row-major, no layout hook). Tunable over `mrows` (the block's row + fragments, f32 accumulate over the whole of K, no scales, `y` bf16. Each expert is the + checkpoint's own [N, K] row-major plane (no layout hook). Tunable over `mrows` (the block's row count), `vgpr` and `acc`; the compiled points are the legal ones (the `moe_bf16_tune_valid` table), the rest refuse. * `moe_gemm_q_e4m3` — canonical E4M3 experts with F32 block scales, on the `moe_gemm_q` - contract: the even experts in `w` / `w_scale`, the odd in `w_odd` / `w_odd_scale`, at index e/2; - the scales fold in f32 per (grid_rows columns, 128 of K); `y` is f32. The `impl` axis: 0 = the + contract (`dtype` fp8a8f32): expert e is entry e/2 of the even (`w` / `w_scale`) or odd + (`w_odd` / `w_odd_scale`) tables; the scales fold in f32 per 128x128 tile; `y` is bf16. The + `impl` axis (the row's tune, dispatched by `r3d_rad_moe_gemm_q`): 0 = the 16x16 tile with the 512-byte LDS decode table, 1 = the same tile with the per-byte ALU formula (no LDS table), 2 = the 16x128 block with the F32 scales folded in f32 (the `vgpr` and `acc` axes are arm 2's). The E4M3 operands widen exactly to f16, the f16 wave matrix (f32 accumulate) - runs the multiply. The `grid_rows` parameter takes 1 (w4a8's per-row) or 128 (fp8a8's - per-128x128). + runs the multiply. * `moe_gemm_mxfp4a8` — canonical MXFP4 experts: the E4M3 activation and the E2M1 weight (decoded exactly to E4M3) upcast to f16, the f16 wave matrix (f32 accumulate), the E8M0 weight scales fold - in f32 per 32 of K; the even/odd split as above, `y` bf16. + in f32 per (row, 32 of K); the even/odd tables as above, `y` bf16. On the prefill geometry (T = N = K = 4096, 8 experts, best / median of nine launches) the `mrows`/`vgpr` points of `moe_gemm_bf16` run 41.67 ms at (16, 512), 26.19 ms at (32, 128) and @@ -324,12 +334,50 @@ is the default's best point. The `moe_gemm_q_e4m3` 16x128 arm (vgpr 128) is 215 bytes: decode-bound on the E4M3 widen, which is why that row's tile is 16 rows and its arm 2 is the one the prefill geometry reaches for. -`r3d_rad_moe_gemm_w4a8` is the WIP int4-weights / int8-activation launcher behind the same run-walk -structure: a 16x128 block (the eight waves do unique 16-column sub-tiles), the int8 activation and -the packed int4 weight (decoded exactly to int8, the native i32 wave matrix) with the f32 scales -folded per 128 of K; a single weight plane, no even/odd split; `y` f32. It is exported and -value-probed, not a row: the remaining weight forms (the nl64/nl32 magnitude-table nibbles), the -prefill run map and the SK/UW/RS passes are outstanding, per its kernel header. +`moe_gemm_w4a8` — the `moe_gemm_q` row at `dtype=w4a8`: int8 activation, packed two's-complement +int4 experts. The same run-walk structure as the siblings, a 16x128 block (the eight waves do +unique 16-column sub-tiles), the int8 activation and the packed int4 weight (decoded exactly to +int8, the native i32 wave matrix) with the scales folded per 128 of K — an f32 a-scale and a bf16 +w-scale. The experts are two tables by parity (even `w`/`w_scale`, odd `w_odd`/`w_odd_scale`), as +every other `moe_gemm_q` dtype; `y` is bf16. Both token- and sorted-order `a`; the int8 arm folds +each 128-block's exact i32 product sum as `(sub * a_scale) * w_scale` in ascending block order, so +it is bit-exact against the libref reference, and the e4m3 arm is the half-precision wave matrix. +The remaining weight forms (the nl64/nl32 magnitude-table nibbles), the prefill run map and the +SK/UW/RS passes are outstanding, per its kernel header. + +`moe_gemm_w4a4` — the `moe_gemm_q` row at `dtype=w4a4`: int4 activation (packed two per byte), +packed two's-complement int4 experts. Both operands widen exactly to int8 and run the native i32 +wave matrix (no f16 rounding anywhere in the chain); the scales fold per 128 of K — an f32 a-scale +and a bf16 w-scale. The experts are two tables by parity (even `w`/`w_scale`, odd +`w_odd`/`w_odd_scale`); `y` is bf16. Both token- and sorted-order `a`; each 128-block's exact i32 +product sum folds as `(sub * a_scale) * w_scale` in ascending block order, so it is bit-exact +against the libref reference (verified 4/4 on gfx1102). + +`dequant_w4` — the packed 4-bit weight back to a plain row-major bf16 `[N, K]`, for the prefill +path where W4A8 gains nothing. One thread per packed dword scatters its eight nibbles; the scale +dword holds the f16 scale low and `-(1024+zero)` high, so one routine serves the symmetric +(`twos=1`) and asymmetric (`twos=0`) grids. Verified 2048/2048 on gfx1102. + +`row_topk_merge` — the R largest of the all-gathered per-rank candidate sets, the other half of a +vocab-parallel top-R. One wave per row over `world_size * R` (id, value) pairs; a 32-slot top-R +heap per lane with a 5-step xor-butterfly extract. Ties break on the lower id. R <= 32. Verified +16/16 on gfx1102. + +`ngram_ids` — the hashed row ids of the Per-Layer Embedding: `mixed(k) = XOR of t_s * mult[s]` +(64-bit wrapping), `ids[h] = mixed % vocab_sizes[h] + offsets[h]`. One thread a token, looping its +heads; n-gram shifts with an EOS walk; ngram <= 8. Verified 24/24 on gfx1102. + +`gemm_nt_q_bias` — the narrow fp8 GEMM with a per-column bias epilogue: `y = a @ b^T + bias`. +M <= 16, fp8a8 codes and scales, bf16 bias and output. The bias is fused into the GEMM kernel's +store (no second pass). Verified 64/64 on gfx1102. + +`gemm_nt_q_short` — the narrow fp8 GEMM with the short-prompt split rule: unsplit (sk=1) at +N <= 512, K <= 5120, 41..64 rows, where the split's per-slice floors dominate. M <= 64, fp8a8 +codes and scales, bf16 output. Verified 256/256 on gfx1102. + +`moe_gemm_q_mod4` — the grouped quantised GEMM with 4 expert classes: experts route to class +e%4 (entry e/4 within the class). Same E4M3 wave-matrix core as `moe_gemm_q_e4m3`, 8 individual +`R3dTab` parameters (4 weight + 4 scale tables). Verified 2048/2048 on gfx1102. ### Stored weights: the layout hooks @@ -364,6 +412,12 @@ arithmetic is the reference's in the reference's order. ## The GDN, QSA, and MoE plumbing rows +The chunk preamble, the chunked scan and the recurrent update are libhalo's kernels (`r3dh_*.hip`, +the `halo_` -> `r3dh_` rename): libr4d's ported to the gfx11 wave matrix, they compile for +`gfx11-generic` unchanged and pass `rad-kbench` against libref on gfx1151 (the kkt solve to +8e-5, the scan to 4e-3, the update to 6e-5, both state forms). They replace the first wave-matrix +ports of the same kernels, which disagreed with libref and whose scan wrote past its output. + `gdn_kkt_solve_c64` runs the gated-delta-net's chunk preamble: the gram `A = (I + strict_lower(diag(beta) K K^T e^{g_i-g_j}))^-1` per 64-chunk, the gram and the blocked triangular inverse in one kernel, the fp32 gram never reaching memory. `gdn_chunk_scan_k128_v128_c64` @@ -374,11 +428,10 @@ touch HBM. `gdn_gated_rmsnorm_h128` is the layer's own output norm, and per-row int8 quantiser. `gdn_conv_prep_w4_h128` is the causal conv width 4 + silu, the q/k/v split, the qk l2norm, the gating and the per-chunk gate cumsum in one prefill kernel, and `gdn_conv_update_w4_h128` / `gdn_recurrent_update_k128_v128` are the same convolution and the -recurrent state update at decode, over a rolling conv-state buffer and a paged fp32 state cache. -The decode half (`gdn_recurrent_update_k128_v128`) and the single-chunk case of the scan are -value-verified against a CPU reference; the scan's multi-chunk state carry carries a small -documented residual on the development card (its kernel header states the band and the suspected -cause), so the gate there is bounded, not exact. +recurrent state update at decode, over a rolling conv-state buffer and a paged f32 or f16 state +cache, per candidate token or as one committed state with a replay scratch slot (`anchor`). +`gdn_conv_recurrent_update_k128_v128` is the two as one kernel: the fold holds q, k and v in +registers, so they are never written and the step is one launch instead of two. The QSA rows are the indexer's tail: `kv_len_trim_i32` trims each sequence's context lengths by `trim` (the slice's own last row), and `qsa_tail_store_bf16` writes the QSA indexer's tail into a @@ -386,8 +439,10 @@ per-layer linear KV state, ring addressed by position. The MoE plumbing rows are the sort: `moe_router_topk_bf16` (softmax top-k, renormalised if `norm`), `moe_router_sigmoid_topk` (the GLM-style router: sigmoid scores, selection on scores + bias, the kept weights scaled by `route_scale`), `moe_router_topk_scatter` (the top-k and the counting sort -as one op), `moe_scatter_small` (the routed slots' stable counting sort; histogram in LDS, -T ≤ 1024) and `moe_gather` (fold the expert outputs back to the token, +as one op), `moe_scatter_small` (the routed slots' stable counting sort: up to 1024 slots one +workgroup, histogram in LDS; above, libhalo's three passes, a histogram per 256-slot tile into +scratch, the per-expert scan across tiles and the placement) and `moe_gather` (fold the expert +outputs back to the token, `y[t,c] = sum_j expert_w[t,j] * y_expert[slot(t,j),c]`, with the optional shared arm; top_k ≤ 64). `expert_scale_bf16` scales the renormalised top-k weights by the expert's per-expert scale in place, and `dflash_select_bf16` is the drafter's accept step, a walk over the draft block's @@ -547,11 +602,10 @@ recorded seed, over the parameter rows a real request sends. The sampler's draw construction (the reference's order, the reference's `exp`/`log`), but a recording is the proof, and there is no recording harness for the plugin's parameter rows. -**`w4a8` as a row.** `r3d_rad_moe_gemm_w4a8` is a WIP launcher (the i32 wave-matrix core, the -gather and the run structure are verified bit-exact against a CPU reference); the other weight -forms (w4nl64a8h / w4nl32a8h / w5nl64a8h, whose nibbles decode through a magnitude table and a -per-64/32 E4M3 scale), the prefill run map and the SK/UW/RS optimisations are outstanding, per its -kernel header. +**The other `w4a8` weight forms.** The `w4a8` form is now a row (`moe_gemm_w4a8`, bit-exact +against the libref reference); the remaining forms (w4nl64a8h / w4nl32a8h / w5nl64a8h, whose +nibbles decode through a magnitude table and a per-64/32 E4M3 scale), the prefill run map and the +SK/UW/RS optimisations are outstanding, per the kernel header. **A chunked logits path.** The head is the largest read in a decode step, and the sampler reads f32, so the store is typed, not narrowed, and a 2048-row prefill band writes 1.07 GB. Nothing diff --git a/libr3d/r3d.h b/libr3d/r3d.h index 45111fb1..05deb3dc 100644 --- a/libr3d/r3d.h +++ b/libr3d/r3d.h @@ -196,7 +196,7 @@ int r3d_gemm_nt_bf16_tiled(long a, long b, long y, int M, int N, int K, int a_ld * RAD_BF16 reads bf16, anything else (0 included) reads f32. */ int r3d_gemm_nt_q_fp8_ex(long a, long a_scale, long b, long b_scale, long y, int M, int N, int K, int group, int pb1, int pb2, int a_ld, int y_ld, int sk, int nt, - long scratch, int bs_dt, long stream); + long scratch, int bs_dt, long stream, long bias); /* ================================================================== r3d_attn_paged_h128.hip * diff --git a/libr3d/r3d_attn_paged_h128.hip b/libr3d/r3d_attn_paged_h128.hip index 8e3b5753..52473daf 100644 --- a/libr3d/r3d_attn_paged_h128.hip +++ b/libr3d/r3d_attn_paged_h128.hip @@ -1564,8 +1564,7 @@ int attn_shim(const RadArgs* a, RadStream s, bool decode) if (!r3d_aligned(Q->data, 16) || !r3d_aligned(KV->data, 16) || !r3d_aligned(O->data, 16)) return R3D_NO(RAD_E_ALIGN); - int splits = decode ? (int)r3d_geti_or(a, "splits", 0) : 1; - if (splits < 0) return R3D_NO(RAD_E_SHAPE); + int splits = decode ? 0 : 1; /* no `splits` param in the spec: 0 auto-selects via pick_splits */ /* The width the launcher will use; a ragged batch is picked on the average sequence, as in the * entry itself. */ const long long per = ragged ? (rows + n_seq - 1) / n_seq : q_len; diff --git a/libr3d/r3d_dequant_w4_bf16.hip b/libr3d/r3d_dequant_w4_bf16.hip new file mode 100644 index 00000000..5ebb5530 --- /dev/null +++ b/libr3d/r3d_dequant_w4_bf16.hip @@ -0,0 +1,90 @@ +// r3d_dequant_w4_bf16.hip -- dequant_w4: the packed 4-bit weight back to a plain row-major +// bf16 [N, K]. +// +// Used at prefill. W4A8 gains nothing there (iu8 and fp8 matrix rates are within a few percent +// and the shape is compute-bound), and the skinny W4A8 GEMM re-reads the whole weight slice once +// per 64 output rows, so its rate is flat in M. Dequantising one layer into scratch and running +// the tuned bf16 GEMM costs one extra write and read of the bf16 weight, a few percent of the GEMM. +// +// Two encodings share these bytes and differ by bit 3, so the caller must say which. The +// symmetric grid stores a two's complement code, value (n^8)-8, so the int8 GEMM can read the +// high-nibble byte signed and get 16*q. The asymmetric grid stores an unsigned nibble minus a +// per-group zero, corrected in the GEMM by an activation row-sum. Mixing them up agrees for n<8 +// and is off by 16 above. +// +// Nearly lossless: a 4-bit code times an f16 scale fits bf16's 8-bit mantissa to within a ULP. +// +// Fragment order: radiance_w4.pack lays a dword out as [t][kb][lh][r][s] with eight nibbles along +// i, where t = n/16, r = n%16, kb = k/64, s = (k%64)/16, and the k inside the step is +// 4*lh + _KOFF[i] with _KOFF = {0,8,1,9,2,10,3,11}. One thread per dword scatters its eight +// nibbles. The scale dword at [t][g][r] holds the f16 scale low and -(1024+zero) high, so one +// routine serves the symmetric grid (zero == 8) and the asymmetric one. +#include +#include +#include +#include +#include "r3d.h" +#include "r3d_args.h" +#include "r3d_launch.h" + +#define R3D_DQ_KPB 64 +#define R3D_DQ_THREADS 256 + +static const int r3d_dq_koff[8] = {0, 8, 1, 9, 2, 10, 3, 11}; + +__global__ __launch_bounds__(R3D_DQ_THREADS) void r3d_dequant_w4_bf16_kernel( + const unsigned* __restrict__ Wq, const unsigned* __restrict__ Ws, + __hip_bfloat16* __restrict__ Out, int N, int K, int group, int twos) +{ + const long total = (long)N * K / 8; // one thread per packed dword + const int nkb = K / R3D_DQ_KPB, ng = K / group; + for (long idx = blockIdx.x * (long)blockDim.x + threadIdx.x; idx < total; + idx += (long)gridDim.x * blockDim.x) { + // [t][kb][lh][r][s] + const int s = (int)(idx & 3); + const int r = (int)((idx >> 2) & 15); + const int lh = (int)((idx >> 6) & 1); + const int kb = (int)((idx >> 7) % nkb); + const int t = (int)((idx >> 7) / nkb); + const int row_n = t * 16 + r; + const unsigned w = Wq[idx]; + + const int kbase = kb * R3D_DQ_KPB + s * 16 + 4 * lh; + const unsigned sz = Ws[(size_t)(t * ng + kbase / group) * 16 + r]; + const float sc = __half2float(__ushort_as_half((unsigned short)(sz & 0xFFFFu))); + const float nz = __half2float(__ushort_as_half((unsigned short)(sz >> 16))); + const float zero = -nz - 1024.f; // exact for zero in 0..15 + +#pragma unroll + for (int i = 0; i < 8; i++) { + const int n = (int)((w >> (4 * i)) & 0xF); + const float q = twos ? (float)((n ^ 8) - 8) : (float)n; + const int k = kbase + r3d_dq_koff[i]; + Out[(size_t)row_n * K + k] = __float2bfloat16((q - (twos ? 0.f : zero)) * sc); + } + } +} + +extern "C" int r3d_rad_dequant_w4(const RadArgs* a, RadStream s) +{ + const RadTensor* wq = r3d_opt(a, 0), *ws = r3d_opt(a, 1), *y = r3d_opt(a, 2); + if (!r3d_p(wq) || !r3d_p(ws) || !r3d_wp(y)) return R3D_NO(RAD_E_INVAL); + if (y->rank != 2 || y->stride[1] != 1) return R3D_NO(RAD_E_STRIDE); + + const long long N = y->shape[0]; + const long long K = y->shape[1]; + const long long group = r3d_geti_or(a, "group", 128); + const long long twos = r3d_geti_or(a, "twos", 1); + if (N <= 0 || K <= 0 || N % 16 || K % 64) return R3D_NO(RAD_E_SHAPE); + if (group < 1 || K % group) return R3D_NO(RAD_E_SHAPE); + if (twos != 0 && twos != 1) return R3D_NO(RAD_E_INVAL); + + const long long total = N * K / 8; + const int blocks = (int)((total + R3D_DQ_THREADS - 1) / R3D_DQ_THREADS); + dim3 grid(blocks < 65535 ? blocks : 65535), blk(R3D_DQ_THREADS); + R3D_KLAUNCH(r3d_dequant_w4_bf16_kernel, grid, blk, (hipStream_t)s, + (const unsigned*)r3d_p(wq), (const unsigned*)r3d_p(ws), + (__hip_bfloat16*)r3d_wp(y), (int)N, (int)K, (int)group, (int)twos); + return (int)hipGetLastError(); +} + diff --git a/libr3d/r3d_gdn_chunk_scan_k128_v128_c64.hip b/libr3d/r3d_gdn_chunk_scan_k128_v128_c64.hip deleted file mode 100644 index 53d94a01..00000000 --- a/libr3d/r3d_gdn_chunk_scan_k128_v128_c64.hip +++ /dev/null @@ -1,740 +0,0 @@ -/* r3d_gdn_chunk_scan_k128_v128_c64.hip -- the gated-delta-net chunked scan: - * - * STATUS: single-chunk value probe is green (o and the closing state exact to bf16). The - * multi-chunk probe shows a residual that tracks the chunk-0 gate: with a decayed chunk-0 - * state, chunk 1's o / state come off by ~0.2-0.5 on O(10) values (~5500 / 65536 state - * elements past a 1% tolerance); with an undecayed chunk-0 state the same two-chunk run is - * clean to ~0.12. The chunk-1 s.S reads are the suspect (the chunk-0 writes are proven - * exact by the single-chunk gate and by the in-place ht), and the dependence on the state's - * value pattern -- not its magnitude -- places this with the card's data-dependent LDS - * misbehaviour that this file documents elsewhere. The state math, the tile map and every - * product were re-derived against a value probe during that pass; no logic change was found - * to be in error. - * - * The original status: the manual-FMA path is in. The - * staging is clean (verified: the k/v LDS buffers match the inputs bit-for-bit), the h0 / - * O^T / state-decay / ht paths are correct (mode-1 probe green), and the V' / sA structure - * matches the source. The wmma A-operand fragment read of the s.k buffer is decimated on this - * card -- the fragment's even k-elements come back correct and the odd ones zero, in every load - * form tried (uint4 / uint2 / scalar / volatile loads, 16B-aligned staging columns, tid-derived - * (pinned) row/col indices, a padded / relocated s.k, and swapping the operands to P = Q@K^T, - * s.k as the B-operand, which produced NaNs). The raw LDS value s.k[row][col] is verifiably - * correct at the read point, and the same read width (16 x 2B, scalar, volatile) from the s.S - * buffer is exact -- so it is the s.k A-operand path specifically, not the load, the offset, or - * the data. The three products that take s.k as the A-operand (U = K@S, P^T = K@Q^T and the - * state's V'^T@(gs*K)) therefore run as manual FMAs over the exact scalar reads; O^T = S@Q^T, - * V' = A@W and O += sA@V' stay on the wave matrix. - * - * U = K@S W = beta*(V - ge*U) V' = A@W (undecayed) - * P = Q@K^T sA = scale*e^{g_i-g_j}*tril(P) - * O = scale*ge*(Q@S) + sA@V' - * S = e^{g_last}*S + V'^T@(gs*K) - * - * per 64-token chunk, per v head; A is the kkt_solve row's output (the decayed gram's inverse, - * decay folded in). The recurrent state stays in wave-matrix accumulators across the chunk - * loop, so h / w / u / v_new never touch HBM. Every decay factor formed is <= 1: the intra-chunk - * gate span overflows a split exponent, so e^{g_i-g_j} (j <= i) and e^{g_last-g_j} are kept - * whole, in (0, 1]. - * - * ---- the tile map (the port's structural change) ------------------------------------------- - * - * The source row was written for the wave-matrix ISA of the card it was probed on, whose - * 16x16x16 fragment map differs from this card's. This card's map (probed in the bf16 GEMM row, - * r3d_gemm_bf16_nt_m16_wmma.hip): - * - * A fragment: lane L holds row L % 16 of the tile, the 16 k contiguous - * B fragment: lane L holds column L % 16 of the tile, the 16 k contiguous - * C/D: lane L, element e holds D[2e + L / 16][L % 16], eight f32 a lane - * - * so the fragment loads are the GEMM row's 32-byte reads (the source's 16-byte half-K reads, - * doubled), and every accumulator store the source made as one 16-byte vector is here eight - * scalar bf16 stores along the map's stride-2 axis -- the W, sA, V', state and output stores, - * and the h0 / ht state transfers (k = 2e + hi strides two). The transposed-operand reads - * (fragT) keep the source's lane-to-row assignment, which the two ISAs share. - * - * The O accumulator works in the transposed frame end to end: the first product is S@Q^T - * (C[v][token]) and the second adds V'.(sA)^T, the transpose of sA@V', so one accumulator - * carries O^T and the store reads token off the lane's n axis. - */ - -#include - -#include "r3d.h" -#include "r3d_common.h" -#include "r3d_launch.h" -#include "r3d_args.h" -#include "r3d_codecs.h" - -#include -#include -#include - -namespace { - -constexpr int kBT = 64; // chunk -constexpr int kKD = 128; // head_k -constexpr int kVD = 128; // head_v -constexpr int kBV = 64; // v per workgroup; also halves the Q@K^T redundancy -constexpr int kKP = 132; // row pitch of the [.][KD] buffers, in shorts -constexpr int kAP = 68; // row pitch of the [.][BT] buffers, in shorts -constexpr int kNW = 8; // waves; the [4 token][4 v] tile grid is fixed by BT and BV, so - // eight waves carry two tiles each -constexpr int kNTHR = kNW * 32; -constexpr int kNTV = 2; // n tiles per wave in the main / V' / O loops -constexpr int kSKT = 2; // the wave's slice of the 8 k-tile x 4 v-tile state grid is 2 x 2 -constexpr int kSVT = 2; -constexpr int kNST = kSKT * kSVT; - -struct CsSmem { - // k must not sit at a low LDS offset: on this card a 16-element fragment read from the - // first ~16 KB of the block is decimated (odd elements read back zero), while the same - // read from a higher offset is exact. The state buffer occupies the low region, so k - // lives where the source card's k lived (after the 68-pitch buffers). - unsigned short S[kBV][kKP]; // B: state, V-major - unsigned short A[kBT][kAP]; // B-source for sA (written as [i][j]) - unsigned short k[kBT][kKP]; // A: K / B: K^T for P=Q@K^T - unsigned short W[kBV][kAP]; // B: W (transposed) - unsigned short D[kBV][kAP]; // staged V as [token][v]; then V' as [v][token] - float ge[kBT], gv[kBT], gg[kBT], bt[kBT]; -}; - -using v8f = float __attribute__((ext_vector_type(8))); -using v16short = short __attribute__((ext_vector_type(16))); - -/* One 16x16x16 tile, f32 accumulate. */ -__device__ __forceinline__ v8f mmab(const v16short& a, const v16short& b, const v8f& c) -{ - return __builtin_amdgcn_wmma_f32_16x16x16_bf16_w32(a, b, c); -} - -/* A/B fragment from a row pointer already advanced to this lane's row: the 16 k contiguous, - * 32 bytes, two 16-byte reads (the GEMM row's exact form). */ -__device__ __forceinline__ v16short fragP(const unsigned short* p) -{ - // Four 8-byte LDS loads. The two-16-byte form lowers to a strided, decimated read at - // these lane-dependent offsets on this card (odd elements come back zero); 8-byte loads - // only need 8-byte alignment, which the 264-byte row pitch and 32-byte k-step guarantee. - union { uint2 w[4]; v16short f; } u; - u.w[0] = *(const uint2*)(p + 0); - u.w[1] = *(const uint2*)(p + 4); - u.w[2] = *(const uint2*)(p + 8); - u.w[3] = *(const uint2*)(p + 12); - return u.f; -} - -/* Global fragment off a 32-bit element offset split from a uniform base. */ -__device__ __forceinline__ v16short fragGo(const unsigned short* base, unsigned off) -{ - return fragP(base + off); -} - -/* Scalar A-fragment: sixteen 2-byte LDS loads. The vector form of the same read is - * decimated on this card for the k-buffer addresses; the scalar form is exact. */ -__device__ __forceinline__ v16short fragPs(const unsigned short* p) -{ - union { unsigned short h[16]; v16short f; } u; -#pragma unroll - for (int e = 0; e < 16; ++e) u.h[e] = p[e]; - return u.f; -} - -/* Volatile scalar A-fragment: the non-volatile scalar read of the k-buffer has its odd - * k-elements constant-folded to zero on this card; a volatile pointer stops that. */ -__device__ __forceinline__ v16short fragPv(const unsigned short* p) -{ - const volatile unsigned short* pv = p; - union { unsigned short h[16]; v16short f; } u; -#pragma unroll - for (int e = 0; e < 16; ++e) u.h[e] = pv[e]; - return u.f; -} - -/* K-contiguous fragment: src[idx][k], row pitch `pitch` (in elements). */ -__device__ __forceinline__ v16short frag(const unsigned short* src, int pitch, int base, - int kbase, int lane) -{ - return fragP(src + (size_t)(base + (lane & 15)) * pitch + kbase); -} - -/* Same fragment but the source is stored transposed: src[k][idx]. Sixteen scalar reads. */ -__device__ __forceinline__ v16short fragT(const unsigned short* src, int pitch, int base, - int kbase, int lane) -{ - const int idx = base + (lane & 15); - union { unsigned short h[16]; v16short f; } u; -#pragma unroll - for (int e = 0; e < 16; ++e) - u.h[e] = src[(size_t)(kbase + e) * pitch + idx]; - return u.f; -} - -/* A block barrier the backend cannot move; see the GEMM rows' note. */ -#define R3D_BARRIER() do { __syncthreads(); asm volatile("" ::: "memory"); } while (0) - -/* byte offset of buffer[base + lo] from the base of the shared block (the 16-k fragment starts - * at the row's head on this card; the source's + 4*hi half-K offset does not exist here) */ -#define ROWO(buf, pitch, base) \ - ((unsigned)((const char*)&(buf)[0][0] - (const char*)&s) + \ - (unsigned)(((base) + lo) * (pitch) * 2)) - -/* The state cache's element type (0 = fp32, 1 = fp16); all arithmetic is fp32. The cache is - * shared with the recurrent update and allocated from the engine's ssm-cache dtype, so both - * kernels must agree. */ -template struct cs_state { using T = float; }; -template <> struct cs_state<1> { using T = _Float16; }; - -#define PFW 8 // shorts staged per lane per step -#define PFZERO make_uint4(0u, 0u, 0u, 0u) -#define NKB (kBT * kKD / (kNTHR * PFW)) -#define NVB (kBT * kBV / (kNTHR * PFW)) - -template -__global__ __launch_bounds__(kNTHR) void r3d_gdn_chunk_scan_kernel( - const unsigned short* __restrict__ q, const unsigned short* __restrict__ k, - const unsigned short* __restrict__ v, const unsigned short* __restrict__ Amat, - const float* __restrict__ gcs, const float* __restrict__ beta, - const typename cs_state::T* __restrict__ h0, unsigned short* __restrict__ o, - typename cs_state::T* __restrict__ ht, const int* __restrict__ cu, - const int* __restrict__ sidx, long sidx_stride, long st_slot, long st_head, - int H, int Hg, float scale, unsigned short* __restrict__ dbg) -{ - __shared__ CsSmem s; - const int bv = blockIdx.x, hv = blockIdx.y, nq = blockIdx.z; - int tid = threadIdx.x; - asm volatile("" : "+v"(tid)); // pin the hw thread-id vreg before the allocator can reuse it - const int w = tid >> 5, lane = tid & 31; - const int hq = hv / (H / Hg), v0 = bv * kBV; - const int tb = cu[nq], te = cu[nq + 1]; - // The state slot comes from the cache manager (sidx), not the batch position; without sidx - // the kernel uses state[nq], valid only while slots match batch order. - const long si = sidx ? (long)sidx[(size_t)nq * sidx_stride] : (long)nq; - if (si < 0) return; // a padded row owns no state - const size_t st_base = (size_t)si * st_slot + (size_t)hv * st_head; - const int nchunk = (te - tb + kBT - 1) / kBT; - const int lo = lane & 15, hi = lane >> 4; - - const int mt = w >> 1, ntb = (w & 1) * 2; // [BT][BV]: 2 tiles/wave - // The state accumulator is held transposed, C[m=k-dim][n=v]. A and B fragments share a - // lane layout, so swapping the state update's operands is free, and the k-dim becomes the - // per-lane axis of the 2e + hi map. - const int kt0 = (w >> 1) * 2, vt0 = (w & 1) * 2; // 2 x 2 - - uint4 kb[NKB], vb[NVB]; - // Staging index, derived from the pinned tid at every point of use. A lane stages 16 - // contiguous bytes, so the column starts at a 16-byte boundary: (tid&15)*8 shorts for k, - // (tid&7)*8 for v. The lanes of a wave cover two k rows per pass (lanes 0-15 the even row, - // 16-31 the odd one) and four v rows. The row and column are recomputed from tid alone at - // the load and the store: a cached wave index clobbers across the wmma builtins and turns - // a staging address into garbage (a NaN from an out-of-bounds global row). -#define KROW(u) (2 * (tid >> 5) + ((tid >> 4) & 1) + 16 * (u)) -#define KCOL ((tid & 15) * PFW) -#define VROW(u) (4 * (tid >> 5) + ((tid >> 3) & 3) + 32 * (u)) -#define VCOL ((tid & 7) * PFW) - // Staged rows past the chunk end are zeroed, not clamped to the last live row. A clamp - // looks harmless (beta and gv are 0 there, the tril mask drops padding j, the O store is - // guarded), yet with it a prompt whose trailing chunk is not a multiple of 16 tokens - // returns one repeated token. -#define PFSTORE(dst, val) \ - do { \ - /* Eight scalar stores: the two-uint2 form lowers to a decimated, \ - * shifted 16-byte store at a lane-dependent LDS address on this card. \ - */ \ - unsigned short* dp_ = (dst); \ - dp_[0] = (unsigned short)((val).x & 0xffffu); \ - dp_[1] = (unsigned short)((val).x >> 16); \ - dp_[2] = (unsigned short)((val).y & 0xffffu); \ - dp_[3] = (unsigned short)((val).y >> 16); \ - dp_[4] = (unsigned short)((val).z & 0xffffu); \ - dp_[5] = (unsigned short)((val).z >> 16); \ - dp_[6] = (unsigned short)((val).w & 0xffffu); \ - dp_[7] = (unsigned short)((val).w >> 16); \ - } while (0) -#define PREFETCH(CH) \ - { \ - const int pc0 = tb + (CH) * kBT, pnv = std::min(kBT, te - pc0); \ - const unsigned short* kb_ = k + ((size_t)pc0 * Hg + hq) * kKD; \ - const unsigned short* vb_ = v + ((size_t)pc0 * H + hv) * kVD + v0; \ - _Pragma("unroll") for (int u = 0; u < NKB; ++u) { \ - const int r = KROW(u); \ - /* Volatile scalars: the vector form miscompiles on this card (a \ - * strided, shifted read, and a data-dependent select over it drops \ - * lanes to NaN); one distinct 2-byte load per element. \ - */ \ - if (r < pnv) { \ - const volatile unsigned short* kp = kb_ + (unsigned)(r * (Hg * kKD)) + KCOL; \ - kb[u].x = kp[0] | (kp[1] << 16); \ - kb[u].y = kp[2] | (kp[3] << 16); \ - kb[u].z = kp[4] | (kp[5] << 16); \ - kb[u].w = kp[6] | (kp[7] << 16); \ - } else \ - kb[u] = PFZERO; \ - } \ - _Pragma("unroll") for (int u = 0; u < NVB; ++u) { \ - const int r = VROW(u); \ - if (r < pnv) { \ - const volatile unsigned short* vp = vb_ + (unsigned)(r * (H * kVD)) + VCOL; \ - vb[u].x = vp[0] | (vp[1] << 16); \ - vb[u].y = vp[2] | (vp[3] << 16); \ - vb[u].z = vp[4] | (vp[5] << 16); \ - vb[u].w = vp[6] | (vp[7] << 16); \ - } else \ - vb[u] = PFZERO; \ - } \ - } - - v8f St[kNST]; // state: SKT k-tiles x SVT v-tiles -#define KT(t) (kt0 + (t) / kSVT) -#define VT(t) (vt0 + (t) % kSVT) - // This card's D map puts element e at k = 2e + hi: the h0 / ht rows stride two. - if (H0) { -#pragma unroll - for (int t = 0; t < kNST; ++t) { - const typename cs_state::T* p = h0 + st_base + (size_t)(v0 + VT(t) * 16 + lo) * kKD - + KT(t) * 16; -#pragma unroll - for (int e = 0; e < 8; ++e) { - if (SDT) - St[t][e] = (float)p[2 * e + hi]; - else - St[t][e] = p[2 * e + hi]; - } - } - } else { -#pragma unroll - for (int t = 0; t < kNST; ++t) -#pragma unroll - for (int e = 0; e < 8; ++e) St[t][e] = 0.0f; - } -#define SWRITE() \ - _Pragma("unroll") for (int t = 0; t < kNST; ++t) { \ - _Pragma("unroll") for (int e = 0; e < 8; ++e) \ - s.S[VT(t) * 16 + lo][KT(t) * 16 + 2 * e + hi] = f32_to_bf16(St[t][e]); \ - } - SWRITE(); - R3D_BARRIER(); - PREFETCH(0); - - const char* const sbase = (const char*)&s; - // scale goes inside the score exponent, exp(g_i + log(scale) - g_j), saving eight multiplies - // per tile. - const float lgs = __logf(scale); - for (int ci = 0; ci < nchunk; ++ci) { - const int c0 = tb + ci * kBT, nval = std::min(kBT, te - c0); - const int lim = nval - 1; - const unsigned short* qg = q + ((size_t)c0 * Hg + hq) * kKD; - const unsigned short* ag = Amat + ((size_t)c0 * H + hv) * kBT; - const size_t qrs = (size_t)Hg * kKD, ars = (size_t)H * kBT; - const float gl = gcs[(size_t)(c0 + lim) * H + hv]; - - // Issued before the staging store so the LDS writes cover their latency. Only waves 0-1 - // (tid < BT) run this; the others wait at (1). - float ggr = 0.f, btr = 0.f; - if (tid < kBT) { - const bool ok = tid < nval; - ggr = ok ? gcs[(size_t)(c0 + tid) * H + hv] : 0.f; - btr = ok ? beta[(size_t)(c0 + tid) * H + hv] : 0.f; - } - { // consume the previous iteration's prefetch, issued a whole chunk of compute ago -#pragma unroll - for (int u = 0; u < NKB; ++u) PFSTORE(&s.k[KROW(u)][KCOL], kb[u]); -#pragma unroll - for (int u = 0; u < NVB; ++u) PFSTORE(&s.D[VROW(u)][VCOL], vb[u]); - } - if (tid < kBT) { - const bool ok = tid < nval; - s.bt[tid] = btr; - s.ge[tid] = __expf(ggr); - // g is a within-chunk cumsum of log-sigmoid gates, so it is non-increasing and gl is - // its minimum. A padding row gets gl, not 0: it is scored against live j with very - // negative g_j, and g_i = 0 would give exp(+400) = inf in s.A. With gl the exponent - // stays in (0, scale]. The row is discarded anyway (the O store is guarded). - s.gg[tid] = ok ? ggr : gl; - s.gv[tid] = ok ? __expf(gl - ggr) : 0.f; // gs - } - R3D_BARRIER(); // (1) - PREFETCH(std::min(ci + 1, nchunk - 1)); // issue only; consumed next iteration - if (dbg && ci == 0) { - for (int i = tid; i < kBT * (kKD / 4); i += kNTHR) { - const int r = i / (kKD / 4), c = (i % (kKD / 4)) * 4; - unsigned short* o = dbg + 4 * kBT * kBT + (size_t)r * kBT + c; - const unsigned short* a1 = &s.k[r][c]; - o[0] = a1[0]; o[1] = a1[1]; o[2] = a1[2]; o[3] = a1[3]; - } - } - - // ---- U = K@S, O^T = S@Q^T and P^T = K@Q^T share the q and k fragments. - // Tiles above the diagonal (A is unit lower triangular, sA is masked) are computed - // anyway: skipping them is 2.4% slower on the source card, since some wave still - // carries two tiles, so the barrier arrival does not move, and the guards stop - // fragment loads batching ahead of the WMMAs. - v8f O[kNTV], u[kNTV], p[kNTV]; -#pragma unroll - for (int i = 0; i < kNTV; ++i) { O[i] = (v8f){}; u[i] = (v8f){}; p[i] = (v8f){}; } - { - const char* sb = sbase; - unsigned oSn[kNTV]; -#pragma unroll - for (int i = 0; i < kNTV; ++i) { - oSn[i] = ROWO(s.S, kKP, (ntb + i) * 16); - asm volatile("" : "+v"(oSn[i])); - } -#define pSnf(i, ko) fragP((const unsigned short*)(sb + oSn[i] + (ko) * 2u)) - const unsigned qo = (unsigned)std::min(mt * 16 + (lane & 15), lim) * (unsigned)qrs; -#define pqf(ko) fragGo(qg, qo + (ko)) - // O^T = S@Q^T stays on the wave matrix: its s.S B-operand and the global Q read are - // exact. U = K@S and P^T = K@Q^T run as manual FMAs: the s.k A-operand fragment - // read is decimated on this card (the odd k-elements come back zero, in every load - // form tried), while the scalar read of the same buffer is verifiably exact. -#pragma unroll - for (int sk = 0; sk < kKD / 16; ++sk) { - const int ko = sk * 16; - const v16short aq = pqf(ko); -#pragma unroll - for (int i = 0; i < kNTV; ++i) - O[i] = mmab(pSnf(i, ko), aq, O[i]); // O^T: m = v-tile, n = token-tile - } -#pragma unroll - for (int i = 0; i < kNTV; ++i) { - const unsigned short* srow = &s.S[(ntb + i) * 16 + lo][0]; -#pragma unroll - for (int e = 0; e < 8; ++e) { - const unsigned short* krow = &s.k[mt * 16 + 2 * e + hi][0]; - float acc = 0.f; -#pragma unroll - for (int kk = 0; kk < kKD; ++kk) - acc = fmaf(bf16_to_f32(krow[kk]), bf16_to_f32(srow[kk]), acc); - u[i][e] = acc; - } - } - // P^T: the Q row is clamped to the last live token, as the fragment read was. - { - const unsigned short* qrow = - qg + (unsigned)std::min(mt * 16 + lo, lim) * (unsigned)qrs; -#pragma unroll - for (int i = 0; i < kNTV; ++i) { - if (dbg && ci == 0 && i == 0) - dbg[9 * kBT * kBT + lane] = s.k[(ntb) * 16 + lo][0]; // raw LDS value -#pragma unroll - for (int e = 0; e < 8; ++e) { - const unsigned short* krow = &s.k[(ntb + i) * 16 + 2 * e + hi][0]; - float acc = 0.f; -#pragma unroll - for (int kk = 0; kk < kKD; ++kk) - acc = fmaf(bf16_to_f32(krow[kk]), bf16_to_f32(qrow[kk]), acc); - p[i][e] = acc; - } - } - } - } - { - const float g = scale * s.ge[mt * 16 + lo]; // token index is constant per lane -#pragma unroll - for (int i = 0; i < kNTV; ++i) -#pragma unroll - for (int e = 0; e < 8; ++e) O[i][e] *= g; - } - // W = beta * (V - ge*U) (beta folded here: (A*beta_col)@W == A@(beta_row*W)) - { - float wa[kNTV][8]; -#pragma unroll - for (int e = 0; e < 8; ++e) { // the U token is 2e + hi on this card - const int tok = mt * 16 + 2 * e + hi; - const float f = s.bt[tok], g = s.ge[tok]; -#pragma unroll - for (int i = 0; i < kNTV; ++i) - wa[i][e] = f * (bf16_to_f32(s.D[tok][(ntb + i) * 16 + lo]) - g * u[i][e]); - } -#pragma unroll - for (int i = 0; i < kNTV; ++i) -#pragma unroll - for (int e = 0; e < 8; ++e) - s.W[(ntb + i) * 16 + lo][mt * 16 + 2 * e + hi] = f32_to_bf16(wa[i][e]); - } - // sA = scale * e^{g_i-g_j} * tril(P). Row ii is constant per lane and the eight g_j are - // uniform per 16 lanes: eight broadcast LDS reads and a v_exp per tile (log(scale) is - // in the exponent). Where kept, g_i - g_j <= 0, so the exp cannot overflow. - if (dbg && ci == 0) { -#pragma unroll - for (int i = 0; i < kNTV; ++i) -#pragma unroll - for (int e = 0; e < 8; ++e) - dbg[3 * kBT * kBT + (mt * 16 + lo) * kBT + (ntb + i) * 16 + 2 * e + hi] = - f32_to_bf16(p[i][e]); - } - { - const int ii = mt * 16 + lo; - const float gis = s.gg[ii] + lgs; -#pragma unroll - for (int i = 0; i < kNTV; ++i) { - const int j0 = (ntb + i) * 16; - float a[8]; -#pragma unroll - for (int e = 0; e < 8; ++e) { - const int j = j0 + 2 * e + hi; - a[e] = (j <= ii) ? p[i][e] * __expf(gis - s.gg[j]) : 0.f; - } -#pragma unroll - for (int e = 0; e < 8; ++e) - s.A[ii][j0 + 2 * e + hi] = f32_to_bf16(a[e]); - } - } - R3D_BARRIER(); // (2) - - // ---- V' = A @ W -> D (stored [v][token], transposed for the state read) - { - v8f d[kNTV]; -#pragma unroll - for (int i = 0; i < kNTV; ++i) d[i] = (v8f){}; - const unsigned ao = (unsigned)std::min(mt * 16 + (lane & 15), lim) * (unsigned)ars; -#define paf(ko) fragGo(ag, ao + (ko)) - const unsigned short* pwn[kNTV]; -#pragma unroll - for (int i = 0; i < kNTV; ++i) - pwn[i] = &s.W[(ntb + i) * 16 + lo][0]; -#define pwnf(i, ko) fragP(pwn[i] + (ko)) -#pragma unroll - for (int sk = 0; sk < kBT / 16; ++sk) { - const int ko = sk * 16; - const v16short a = paf(ko); -#pragma unroll - for (int i = 0; i < kNTV; ++i) d[i] = mmab(a, pwnf(i, ko), d[i]); - } -#pragma unroll - for (int i = 0; i < kNTV; ++i) -#pragma unroll - for (int e = 0; e < 8; ++e) - s.D[(ntb + i) * 16 + lo][mt * 16 + 2 * e + hi] = f32_to_bf16(d[i][e]); - } - // K <- gs * K in place, for the state's V'^T @ K: (diag(gs) V')^T K == V'^T (diag(gs) K), - // and K is otherwise dead. All raw-K reads (U, P) retired before barrier (2); s.k is - // restaged next chunk; barrier (3) publishes the scaled K. -#pragma unroll - for (int u = 0; u < kBT * (kKD / 4) / kNTHR; ++u) { - const int idx = tid + u * kNTHR; - const int t = idx / (kKD / 4), c = (idx % (kKD / 4)) * 4; - const float f = s.gv[t]; - unsigned short* kp = &s.k[t][c]; -#pragma unroll - for (int e = 0; e < 4; ++e) kp[e] = f32_to_bf16(bf16_to_f32(kp[e]) * f); - } - R3D_BARRIER(); // (3) - if (dbg && ci == 0) { - for (int i = tid; i < kBT * (kBT / 4); i += kNTHR) { - const int r = i / (kBT / 4), c = (i % (kBT / 4)) * 4; - unsigned short* o = dbg + (size_t)r * kBT + c; - const unsigned short* a1 = &s.A[r][c]; - const unsigned short* a2 = &s.W[r][c]; - const unsigned short* a3 = &s.D[r][c]; - o[0] = a1[0]; o[1] = a1[1]; o[2] = a1[2]; o[3] = a1[3]; - o[kBT*kBT] = a2[0]; o[kBT*kBT+1] = a2[1]; o[kBT*kBT+2] = a2[2]; o[kBT*kBT+3] = a2[3]; - o[2*kBT*kBT] = a3[0]; o[2*kBT*kBT+1] = a3[1]; o[2*kBT*kBT+2] = a3[2]; o[2*kBT*kBT+3] = a3[3]; - } - } - - // ---- O += sA @ V' ; store. V' also feeds the state update, unchanged. The product - // runs in the transposed frame (V' as A, sA as B), adding (sA@V')^T to O^T. - { - const unsigned short* pA = &s.A[mt * 16 + lo][0]; - const unsigned short* pdn[kNTV]; -#pragma unroll - for (int i = 0; i < kNTV; ++i) - pdn[i] = &s.D[(ntb + i) * 16 + lo][0]; -#define pAf(ko) fragP(pA + (ko)) -#define pdnf(i, ko) fragP(pdn[i] + (ko)) -#pragma unroll - for (int sk = 0; sk < kBT / 16; ++sk) { - const int ko = sk * 16; - const v16short b = pAf(ko); -#pragma unroll - for (int i = 0; i < kNTV; ++i) O[i] = mmab(pdnf(i, ko), b, O[i]); - } - } - { - const int tok = mt * 16 + lo; - // The padding rows carry zero (the zeroed K, beta, gv and Q rows), so the store is - // unguarded and the output is finite at every row the caller can index. - { - unsigned short* op = o + ((size_t)(c0 + tok) * H + hv) * kVD + v0; -#pragma unroll - for (int i = 0; i < kNTV; ++i) -#pragma unroll - for (int e = 0; e < 8; ++e) - op[(ntb + i) * 16 + 2 * e + hi] = f32_to_bf16(O[i][e]); - } - } - - // ---- S = e^{gl} * S + V'^T @ (gs*K) (A needs K as [dim][token] -> strided fragT) - { - const float ec = __expf(gl); // gl <= 0: the decay is already on K -#pragma unroll - for (int t = 0; t < kNST; ++t) -#pragma unroll - for (int e = 0; e < 8; ++e) St[t][e] *= ec; - // The s.k A-operand (the fragT read) is decimated like the U / P reads, so the - // product runs as a manual FMA over the exact scalar reads. -#pragma unroll - for (int t = 0; t < kNST; ++t) { - const int v = VT(t) * 16 + lo; -#pragma unroll - for (int e = 0; e < 8; ++e) { - const int kx = KT(t) * 16 + 2 * e + hi; - float acc = 0.f; -#pragma unroll - for (int tk = 0; tk < kBT; ++tk) - acc = fmaf(bf16_to_f32(s.k[tk][kx]), bf16_to_f32(s.D[v][tk]), acc); - St[t][e] += acc; - } - } - } - // No barrier before the writeback: s.S aliases nothing, and barrier (2) proves every - // wave finished its U/O reads of s.S this chunk. - SWRITE(); - R3D_BARRIER(); // (4) - } - - if (HT) { - typename cs_state::T* p = ht + st_base; -#pragma unroll - for (int t = 0; t < kNST; ++t) { - typename cs_state::T* pw = p + (size_t)(v0 + VT(t) * 16 + lo) * kKD + KT(t) * 16; -#pragma unroll - for (int e = 0; e < 8; ++e) { - if (SDT) - pw[2 * e + hi] = (typename cs_state::T)St[t][e]; - else - pw[2 * e + hi] = St[t][e]; - } - } - } -} - -int r3d_gdn_chunk_scan_launch(const void* q, const void* k, const void* v, const void* A, - const void* g, const void* beta, const void* h0, void* o, - void* ht, const void* cu, const void* sidx, long sidx_stride, - long st_slot, long st_head, int N, int H, int Hg, int K, int V, - int chunk, float scale, int state_fp16, void* dbg, hipStream_t stream) -{ - if (K != kKD || V != kVD || chunk != kBT) return -1; - if (Hg <= 0 || H % Hg) return -2; - dim3 grid(V / kBV, H, N), blk(kNTHR); -#define CS_LAUNCH(SDTC, H0C, HTC) \ - R3D_KLAUNCH_S(R3D_KNAME((r3d_gdn_chunk_scan_kernel)), grid, blk, 0, stream, \ - (const unsigned short*)q, (const unsigned short*)k, (const unsigned short*)v, \ - (const unsigned short*)A, (const float*)g, (const float*)beta, \ - (const cs_state::T*)h0, (unsigned short*)o, (cs_state::T*)ht, \ - (const int*)cu, (const int*)sidx, sidx_stride, st_slot, st_head, H, Hg, scale, (unsigned short*)dbg) -#define CS_PICK(SDTC) \ - do { if (h0 && ht) CS_LAUNCH(SDTC, true, true); \ - else if (h0) CS_LAUNCH(SDTC, true, false); \ - else if (ht) CS_LAUNCH(SDTC, false, true); \ - else CS_LAUNCH(SDTC, false, false); } while (0) - if (state_fp16) CS_PICK(1); else CS_PICK(0); -#undef CS_PICK -#undef CS_LAUNCH - return (int)hipGetLastError(); -} - -} // namespace - -/* ------------------------------------------------------------------ the raw entry */ - -extern "C" int r3d_gdn_chunk_scan_k128_v128_c64(long q, long k, long v, long A, long g, long beta, - long h0, long o, long ht, long cu, long sidx, - long sidx_stride, long st_slot, long st_head, - int N, int H, int Hg, int K, int V, int chunk, - double scale, int state_fp16, long dbg, long stream) -{ - if (!q || !k || !v || !A || !g || !beta || !cu || !o) return -1; - if (N < 1 || H < 1 || Hg < 1) return -2; - return r3d_gdn_chunk_scan_launch((const void*)q, (const void*)k, (const void*)v, (const void*)A, - (const void*)g, (const void*)beta, (const void*)h0, - (void*)o, (void*)ht, (const void*)cu, (const void*)sidx, - sidx_stride, st_slot, st_head, N, H, Hg, K, V, chunk, - (float)scale, state_fp16, (void*)dbg, (hipStream_t)stream); -} - -/* ------------------------------------------------------------------ the plugin ABI */ - -enum { CS_Q = 0, CS_K, CS_V, CS_A, CS_G, CS_BETA, CS_H0, CS_CU, CS_O, CS_HT, CS_SIDX }; - -extern "C" int r3d_rad_gdn_chunk_scan(const RadArgs* a, RadStream s) -{ - if (!a) return R3D_NO(RAD_E_INVAL); - const RadTensor* qt = r3d_opt(a, CS_Q); - const RadTensor* kt = r3d_opt(a, CS_K); - const RadTensor* vt = r3d_opt(a, CS_V); - const RadTensor* At = r3d_opt(a, CS_A); - const RadTensor* gt = r3d_opt(a, CS_G); - const RadTensor* btt = r3d_opt(a, CS_BETA); - const RadTensor* h0t = r3d_opt(a, CS_H0); - const RadTensor* cut = r3d_opt(a, CS_CU); - const RadTensor* ot = r3d_opt(a, CS_O); - const RadTensor* htt = r3d_opt(a, CS_HT); - const RadTensor* sit = r3d_opt(a, CS_SIDX); - if (!r3d_p(qt) || !r3d_p(kt) || !r3d_p(vt) || !r3d_p(At) || !r3d_p(gt) || !r3d_p(btt) || - !r3d_p(cut) || !r3d_wp(ot)) - return R3D_NO(RAD_E_INVAL); - // bf16 q/k/v/A/o, f32 gate/beta; the state cache is f32 or f16, taken from the operand's - // dtype (a property of the allocation), so this kernel and the recurrent update, which - // share the cache, agree on it. - if (!r3d_is_bf16(qt) || !r3d_is_bf16(kt) || !r3d_is_bf16(vt) || !r3d_is_bf16(At) || - !r3d_is_f32(gt) || !r3d_is_f32(btt) || !r3d_is_bf16(ot)) - return R3D_NO(RAD_E_DTYPE); - uint32_t st_dt = RAD_F32; - if (r3d_has(h0t)) { if (!r3d_is_f32(h0t) && !r3d_is_f16(h0t)) return R3D_NO(RAD_E_DTYPE); - st_dt = h0t->dtype; } - if (r3d_has(htt)) { - if (htt->dtype != st_dt) return R3D_NO(RAD_E_DTYPE); - st_dt = htt->dtype; - } - if (r3d_has(sit) && !r3d_is_i32(sit)) return R3D_NO(RAD_E_DTYPE); - - if (cut->rank != 1 || cut->shape[0] < 2 || !r3d_contig(cut)) return R3D_NO(RAD_E_SHAPE); - const int N = (int)(cut->shape[0] - 1); - - const long long T = r3d_dim(qt, 0), Hg = r3d_dim(qt, 1), K = r3d_dim(qt, 2); - const long long H = r3d_dim(vt, 1), V = r3d_dim(vt, 2); - const long long chunk = r3d_dim(At, 2); - if (r3d_dim(kt, 0) != T || r3d_dim(kt, 1) != Hg || r3d_dim(kt, 2) != K) return R3D_NO(RAD_E_SHAPE); - if (r3d_dim(vt, 0) != T) return R3D_NO(RAD_E_SHAPE); - if (r3d_dim(ot, 0) != T || r3d_dim(ot, 1) != H || r3d_dim(ot, 2) != V) return R3D_NO(RAD_E_SHAPE); - if (r3d_dim(At, 0) != T || r3d_dim(At, 1) != H) return R3D_NO(RAD_E_SHAPE); - if (r3d_dim(gt, 0) != T || r3d_dim(gt, 1) != H) return R3D_NO(RAD_E_SHAPE); - if (r3d_dim(btt, 0) != T || r3d_dim(btt, 1) != H) return R3D_NO(RAD_E_SHAPE); - if (H == 0 || Hg == 0 || H % Hg) return R3D_NO(RAD_E_SHAPE); - // The state slot strides come from the tensor, not from H, V and K, so a cache with padded - // slots is served too. h0 and ht must share strides: the kernel uses one base for both. - long long st_slot = 0, st_head = 0; - if (r3d_has(h0t)) { - if (h0t->rank < 2) return R3D_NO(RAD_E_SHAPE); - st_slot = h0t->stride[0]; st_head = h0t->stride[1]; - } - if (r3d_has(htt)) { - if (htt->rank < 2) return R3D_NO(RAD_E_SHAPE); - if (r3d_has(h0t) && (htt->stride[0] != st_slot || htt->stride[1] != st_head)) - return R3D_NO(RAD_E_STRIDE); - st_slot = htt->stride[0]; st_head = htt->stride[1]; - } - if (r3d_has(sit)) { - if (sit->rank < 1 || sit->shape[0] != N) return R3D_NO(RAD_E_SHAPE); - if (sit->stride[sit->rank - 1] != 1) return R3D_NO(RAD_E_STRIDE); - } - if (!r3d_contig(qt) || !r3d_contig(kt) || !r3d_contig(vt) || !r3d_contig(At) || - !r3d_contig(gt) || !r3d_contig(btt) || !r3d_contig(ot)) - return R3D_NO(RAD_E_STRIDE); - - const double scale = r3d_getf(a, "scale", 1.0); - const int state_fp16 = st_dt == RAD_F16; - - const int e = r3d_gdn_chunk_scan_launch(r3d_p(qt), r3d_p(kt), r3d_p(vt), r3d_p(At), r3d_p(gt), - r3d_p(btt), r3d_has(h0t) ? r3d_p(h0t) : nullptr, r3d_wp(ot), - r3d_has(htt) ? r3d_wp(htt) : nullptr, r3d_p(cut), - r3d_has(sit) ? r3d_p(sit) : nullptr, - r3d_has(sit) && sit->rank >= 2 ? sit->stride[0] : 1, - st_slot, st_head, N, (int)H, (int)Hg, (int)K, (int)V, - (int)chunk, (float)scale, state_fp16, nullptr, (hipStream_t)s); - /* The launcher's codes are raw: its own negatives and hipGetLastError's positives. The - * plugin ABI takes RadStatus, so normalise. */ - if (e < 0) return R3D_NO(RAD_E_INVAL); - return e ? R3D_NO(RAD_E_DEVICE) : RAD_OK; -} diff --git a/libr3d/r3d_gdn_kkt_solve_c64.hip b/libr3d/r3d_gdn_kkt_solve_c64.hip deleted file mode 100644 index bbf0388b..00000000 --- a/libr3d/r3d_gdn_kkt_solve_c64.hip +++ /dev/null @@ -1,475 +0,0 @@ -/* r3d_gdn_kkt_solve_c64.hip -- the gated-delta-net chunk preamble in one kernel: - * - * A = (I + strict_lower(diag(beta) . K K^T . e^{g_i - g_j}))^{-1} per chunk of 64 - * - * The FLA chunk_scaled_dot_kkt_fwd + solve_tril pair, fused: the gram stays in LDS and only the - * bf16 inverse is stored. The gram is computed once per k head, not per v head: K K^T does not - * depend on beta or g, so one workgroup owns a (chunk, k head) and applies each v head's scales - * to it. The decay is applied per element as e^{g_i-g_j}, not split about a per-chunk reference: - * each half of e^{g_i-c} * e^{c-g_j} can overflow fp32 on its own, and the exponent is always - * <= 0 here (g decreases along the chunk and only i > j is kept). - * - * The inverse is blocked 16 -> 32 -> 64. The four diagonal blocks use fp32 forward substitution - * (one wave each, one lane per column), cheaper than a WMMA Neumann series at this size and exact - * in fp32, as in FLA. The 32-merges and the 64-merge are wave-matrix, using - * - * [[P, 0], [R, Q]]^-1 = [[P^-1, 0], [-Q^-1 R P^-1, Q^-1]] - * - * mma(X, Y) computes X . Y^T from two k-contiguous operands, so a left operand is row-major and a - * right operand is stored transposed. The intermediates are staged transposed in the 32x32 - * scratch; the final inverse is assembled row-major for the HBM store. - * - * ---- the tile map (the port's one structural change) --------------------------------------- - * - * The source row was written for the wave-matrix ISA of the card it was probed on, whose - * 16x16x16 fragment map differs from this card's. This card's map (probed in the bf16 GEMM row, - * r3d_gemm_bf16_nt_m16_wmma.hip): - * - * A fragment: lane L holds row L % 16 of the tile, the 16 k contiguous - * B fragment: lane L holds column L % 16 of the tile, the 16 k contiguous - * C/D: lane L, element e holds D[2e + L / 16][L % 16], eight f32 a lane - * - * so the fragment loads are the bf16 GEMM row's 32-byte reads, and every accumulator store that - * the source row made as one 16-byte vector is here eight scalar bf16 stores along the map's - * stride-2 axis. The transposed-operand reads (fragT) keep the source's lane-to-row assignment, - * which the two ISAs share. - * - * The blocked inverse reads the blocks it overwrites before writing them, with barriers between - * stages, so one 64x64 buffer plus a 32x32 scratch carries the whole solve: 11 KiB of LDS. - */ - -#include - -#include "r3d.h" -#include "r3d_common.h" -#include "r3d_launch.h" -#include "r3d_args.h" -#include "r3d_codecs.h" - -#include -#include -#include - -namespace { - -constexpr int kBT = 64; // chunk -constexpr int kKD = 128; // head_k -constexpr int kNBK = 4; // 16x16 blocks per chunk edge -constexpr int kAP = 68; // row pitch of the [BT][BT] buffers, in shorts: 8-byte aligned - // for the store, and 16 rows still cover every bank -constexpr int kNW = 4; -constexpr int kNTHR = kNW * 32; -constexpr int kNTILE = 10; // upper-triangular tiles of a 4x4 tiling -constexpr int kMAXT = (kNTILE + kNW - 1) / kNW; - -using v8f = float __attribute__((ext_vector_type(8))); -using v16short = short __attribute__((ext_vector_type(16))); - -/* One 16x16x16 tile, f32 accumulate. */ -__device__ __forceinline__ v8f mmab(const v16short& a, const v16short& b, const v8f& c) -{ - return __builtin_amdgcn_wmma_f32_16x16x16_bf16_w32(a, b, c); -} - -/* A/B fragment from a row pointer already advanced to this lane's row and half-K: the 16 k - * contiguous, 32 bytes, two 16-byte reads. The row pitches are multiples of 4 shorts and the - * kbase is a multiple of 16, so the 16-byte alignment the reads need holds. */ -__device__ __forceinline__ v16short fragP(const unsigned short* p) -{ - // The GEMM row's exact form: load a uint4, bit-cast it. Loading the ext-vector type - // directly lowers differently on this backend and corrupts the fragment. - union { r3d_u32x4 w[2]; v16short f; } u; - u.w[0] = __builtin_bit_cast(r3d_u32x4, *(const uint4*)p); - u.w[1] = __builtin_bit_cast(r3d_u32x4, *(const uint4*)(p + 8)); - return u.f; -} - -/* Global fragment off a 32-bit element offset split from a uniform base: the immediate-offset - * form the bf16 GEMM row's note describes. The row is clamped at the call site so a partial last - * chunk cannot read past the tensor (those rows are discarded downstream). */ -__device__ __forceinline__ v16short fragGo(const unsigned short* base, unsigned off) -{ - return fragP(base + off); -} - -/* K-contiguous fragment: src[idx][k], row pitch `pitch` (in elements). */ -__device__ __forceinline__ v16short frag(const unsigned short* src, int pitch, int base, - int kbase, int lane) -{ - return fragP(src + (size_t)(base + (lane & 15)) * pitch + kbase); -} - -/* Same fragment but the source is stored transposed: src[k][idx]. Sixteen scalar reads. */ -__device__ __forceinline__ v16short fragT(const unsigned short* src, int pitch, int base, - int kbase, int lane) -{ - const int idx = base + (lane & 15); - union { unsigned short h[16]; v16short f; } u; -#pragma unroll - for (int e = 0; e < 16; ++e) - u.h[e] = src[(size_t)(kbase + e) * pitch + idx]; - return u.f; -} - -/* C[mt*16 .. ][nt*16 .. ] += A[M][K] @ B[N][K]^T over KSTEP 16-wide steps. */ -template -__device__ __forceinline__ v8f gemm16(const unsigned short* A, int Ap, int mt, - const unsigned short* B, int Bp, int nt, - int lane, v8f acc) -{ -#pragma unroll - for (int s = 0; s < KSTEP; ++s) - acc = mmab(frag(A, Ap, mt * 16, s * 16, lane), frag(B, Bp, nt * 16, s * 16, lane), acc); - return acc; -} - -/* A block barrier the backend cannot move; see the GEMM rows' note. */ -#define R3D_BARRIER() do { __syncthreads(); asm volatile("" ::: "memory"); } while (0) - -/* The chunk's buffers. One 64x64 buffer plus a 32x32 scratch. ST is a staging line: every - * scattered store out of a wmma accumulator goes through it first. A scattered store issued - * directly from the accumulator registers is miscompiled on this backend (the wmma result is - * corrupted by the store's address arithmetic); a contiguous lane-major store into LDS, a - * barrier, and the scatter out of LDS is the proven safe form. */ -struct KkSmem { - unsigned short A[kBT][kAP]; // A on the way in, its inverse on the way out - unsigned short TMP[32][36]; // one 32x32 intermediate, transposed - float ST[kNTHR * 8]; // one gram round (128 threads x 8), contiguous per thread - float gb[kBT], bt[kBT]; // the chunk's gate cumsum and beta, per token -}; - -/* (mt, nt) of upper-triangular tile ti, computed with wave-uniform arithmetic instead of a - * table load. */ -__device__ __forceinline__ void kkt_tile(int ti, int* mt, int* nt) -{ - int m = 0, n = ti; - while (n >= kNBK - m) { n -= (kNBK - m); ++m; } - *mt = m; *nt = n + m; -} - -template -__global__ __launch_bounds__(kNTHR) -void r3d_gdn_kkt_solve_kernel(const unsigned short* __restrict__ k, - const float* __restrict__ beta, - const float* __restrict__ g, - unsigned short* __restrict__ Ao, - const int* __restrict__ cu, - int N, int H, int Hg) -{ - __shared__ KkSmem s; - int tid = threadIdx.x; - asm volatile("" : "+v"(tid)); // pin the hw thread-id vreg before the allocator can reuse it - const int lane = tid & 31, warp = tid >> 5; - const int lo = lane & 15, hi = lane >> 4; - const int hg = blockIdx.y; - - // Resolve the flat chunk id to (sequence, chunk). The grid is an upper bound on the chunk - // count, so surplus workgroups exit here; this saves the host a device-to-host sync to size - // the grid exactly. - int n = -1, t0 = 0, bos = 0, rows = 0; - { - int acc = 0, want = blockIdx.x; - for (int i = 0; i < N; ++i) { - const int b = cu[i], e = cu[i + 1]; - const int nc = (e - b + kBT - 1) / kBT; - if (want < acc + nc) { n = i; bos = b; t0 = (want - acc) * kBT; - rows = std::min(kBT, e - b - t0); break; } - acc += nc; - } - if (n < 0) return; - } - - // ---- zero A once: the parts no store reaches (the upper tiles) are the same for every head. - // 16-byte stores (the buffer is 8704 bytes, 16-byte aligned). - for (int i = tid; i < kBT * kAP / 8; i += kNTHR) ((uint4*)&s.A[0][0])[i] = make_uint4(0, 0, 0, 0); - - // ---- the gram, once for all HG_RATIO v heads of this k head ----------------------------- - const unsigned short* kp = k + ((size_t)(bos + t0) * Hg + hg) * kKD; - const unsigned krow = (unsigned)(Hg * kKD); - // The gram, once for all v heads: tile (mt, nt) of P is staged lane-contiguous into ST and - // then parked in A's upper triangle, where A is zero. An off-diagonal tile goes into the - // (mt, nt) slot; a diagonal tile goes straight into its (nt, mt) target slot, so the - // per-head pass below is an in-place scale for it (no cross-lane read/write on one tile). -#pragma unroll - for (int t = 0; t < kMAXT; ++t) { - const int ti = warp + t * kNW; - v8f P = (v8f){0, 0, 0, 0, 0, 0, 0, 0}; - if (ti < kNTILE) { - int mt, nt; kkt_tile(ti, &mt, &nt); - // One 32-bit offset per operand row, hoisted out of the k loop. - const unsigned om = (unsigned)(std::min(mt * 16 + (lane & 15), rows - 1)) * krow; - const unsigned on = (unsigned)(std::min(nt * 16 + (lane & 15), rows - 1)) * krow; -#pragma unroll - for (int sk = 0; sk < kKD / 16; ++sk) { - const v16short fa = fragGo(kp, om + sk * 16); - const v16short fb = fragGo(kp, on + sk * 16); - - P = mmab(fa, fb, P); - } - } - -#pragma unroll - for (int e = 0; e < 8; ++e) s.ST[tid * 8 + e] = P[e]; - R3D_BARRIER(); - if (ti < kNTILE) { - int mt, nt; kkt_tile(ti, &mt, &nt); -#pragma unroll - for (int e = 0; e < 8; ++e) { - if (mt == nt) - s.A[nt * 16 + lo][mt * 16 + 2 * e + hi] = f32_to_bf16(s.ST[tid * 8 + e]); - else - s.A[mt * 16 + 2 * e + hi][nt * 16 + lo] = f32_to_bf16(s.ST[tid * 8 + e]); - } - } - } - R3D_BARRIER(); - - for (int hh = 0; hh < HG_RATIO; ++hh) { - const int hv = hg * HG_RATIO + hh; - - // ---- per-head gate and beta for this chunk - if (tid < kBT) { - const int t = std::min(tid, rows - 1); - s.gb[tid] = g[(size_t)(bos + t0 + t) * H + hv]; - s.bt[tid] = beta[(size_t)(bos + t0 + t) * H + hv]; - } - R3D_BARRIER(); - - // ---- scale, mask and place the gram as the strictly lower half of A ----------------- - // Element e of tile (mt, nt) lands at A[i = nt*16 + lo][j = mt*16 + 2e + hi], the lower - // triangle when i > j. Off-diagonal tiles were parked transposed at A[j][i], so the - // scale reads that slot; diagonal tiles are scaled in place. -#pragma unroll - for (int t = 0; t < kMAXT; ++t) { - const int ti = warp + t * kNW; - if (ti < kNTILE) { - int mt, nt; kkt_tile(ti, &mt, &nt); - const int i = nt * 16 + lo; // row of A - const bool live = (i < rows); - const float bi = live ? s.bt[i] : 0.0f; - const float gi = live ? s.gb[i] : 0.0f; -#pragma unroll - for (int e = 0; e < 8; ++e) { - const int j = mt * 16 + 2 * e + hi; - const float pv = (mt == nt) ? bf16_to_f32(s.A[i][j]) - : bf16_to_f32(s.A[j][i]); - // For a live row, i > j gives g_i <= g_j, so the exponent is never positive. - // Padding rows and columns must be masked to -inf: with gi = 0 the exponent - // -gb[j] is large and positive, 0 * inf = NaN, and the WMMA merges in the - // blocked inverse would spread it into live rows. - const float d = (live && i > j && j < rows) ? (gi - s.gb[j]) : -INFINITY; - s.A[i][j] = f32_to_bf16(bi * __expf(d) * pv); - } - } - } - - R3D_BARRIER(); - - // ---- 1. the four diagonal blocks, by fp32 forward substitution ---------------------- - // D = (I + N)^-1 solves D = I - N D row by row. Lane l owns column l of D, so the dot - // product over j < i is in 16 registers and N[i][j] is a broadcast LDS read. - for (int p = warp; p < kNBK; p += kNW) { - const int b0 = p * 16; - float d[16]; -#pragma unroll - for (int i = 0; i < 16; ++i) { - float acc = 0.0f; -#pragma unroll - for (int j = 0; j < 16; ++j) - if (j < i) acc += bf16_to_f32(s.A[b0 + i][b0 + j]) * d[j]; - d[i] = ((lo == i) ? 1.0f : 0.0f) - acc; - } - if (lane < 16) { -#pragma unroll - for (int i = 0; i < 16; ++i) s.A[b0 + i][b0 + lo] = f32_to_bf16(d[i]); - } - } - R3D_BARRIER(); - - // ---- 2. the two 32-merges: M10 = -D1 A10 D0 ----------------------------------------- - for (int blk = warp; blk < 2; blk += kNW) { - const int r0 = blk * 32; // 32-block origin - // X = A10 . D0 (left A10 row-major, right D0 transposed) - v8f X = (v8f){0, 0, 0, 0, 0, 0, 0, 0}; - const v16short af = frag(&s.A[0][0], kAP, r0 + 16, r0, lane); - X = mmab(af, fragT(&s.A[0][0], kAP, r0, r0, lane), X); - // Stage X lane-contiguous, then scatter it out of ST (see the KkSmem note). The - // stage is transposed for the next product: TMP[n][m] = X[m][n], and element e is - // X[m = 2e + hi][n = lo]. Each of the two merges owns 16 rows of TMP. -#pragma unroll - for (int e = 0; e < 8; ++e) s.ST[tid * 8 + e] = X[e]; - R3D_BARRIER(); -#pragma unroll - for (int e = 0; e < 8; ++e) - s.TMP[blk * 16 + lo][2 * e + hi] = f32_to_bf16(s.ST[tid * 8 + e]); - R3D_BARRIER(); - // M10 = -D1 . X (left D1 row-major, in place in A; right X transposed, in TMP) - v8f Y = (v8f){0, 0, 0, 0, 0, 0, 0, 0}; - Y = mmab(frag(&s.A[0][0], kAP, r0 + 16, r0 + 16, lane), - frag(&s.TMP[0][0], 36, blk * 16, 0, lane), Y); -#pragma unroll - for (int e = 0; e < 8; ++e) s.ST[tid * 8 + e] = Y[e]; - R3D_BARRIER(); - // Element e is A[r0 + 16 + 2e + hi][r0 + lo]. -#pragma unroll - for (int e = 0; e < 8; ++e) - s.A[r0 + 16 + 2 * e + hi][r0 + lo] = f32_to_bf16(-s.ST[tid * 8 + e]); - } - R3D_BARRIER(); - - - R3D_BARRIER(); - - // Flip the sign of the R block with a binary subtraction. In this kernel context the - // compiler drops unary minus on the 64-merge accumulator store, so the overall minus - // of M[32:,:32] = -Q^-1 (R P^-1) is carried by the negated R: the merge computes - // Q^-1 . (-R) . P^-1 and stores it as-is. (Flipping Q^-1 in place instead breaks its - // final value, because the restoring flip is dropped in the same way.) - for (int idx = tid; idx < 32 * 32; idx += kNTHR) { - const int r = 32 + idx / 32, c = idx % 32; - s.A[r][c] = f32_to_bf16(0.0f - bf16_to_f32(s.A[r][c])); - } - R3D_BARRIER(); - - // ---- 3. the 64-merge: M[32:,:32] = -Q^-1 (R P^-1) ----------------------------------- - // Y = R . P^-1, R = A[32:,:32] row-major, P^-1 read transposed out of A[:32,:32] - for (int t = warp; t < 4; t += kNW) { - const int mt = t >> 1, nt = t & 1; - v8f Y = (v8f){0, 0, 0, 0, 0, 0, 0, 0}; -#pragma unroll - for (int sk = 0; sk < 2; ++sk) - Y = mmab(frag(&s.A[0][0], kAP, 32 + mt * 16, sk * 16, lane), - fragT(&s.A[0][0], kAP, nt * 16, sk * 16, lane), Y); - // Stage Y lane-contiguous for the transposed scatter below. -#pragma unroll - for (int e = 0; e < 8; ++e) s.ST[tid * 8 + e] = Y[e]; - } - R3D_BARRIER(); - // TMP[n][m] = Y[m][n]; element e is Y[m = 2e + hi (within the mt tile)][n = lo - // (within the nt tile)]. - for (int t = warp; t < 4; t += kNW) { - const int mt = t >> 1, nt = t & 1; -#pragma unroll - for (int e = 0; e < 8; ++e) - s.TMP[nt * 16 + lo][mt * 16 + 2 * e + hi] = f32_to_bf16(s.ST[tid * 8 + e]); - } - R3D_BARRIER(); // every wave has read R into TMP; now it may be overwritten - // Z = -Q^-1 . Y, Q^-1 = A[32:,32:] row-major, Y transposed = TMP - for (int t = warp; t < 4; t += kNW) { - const int mt = t >> 1, nt = t & 1; - v8f Z = (v8f){0, 0, 0, 0, 0, 0, 0, 0}; -#pragma unroll - for (int sk = 0; sk < 2; ++sk) - Z = mmab(frag(&s.A[0][0], kAP, 32 + mt * 16, 32 + sk * 16, lane), - frag(&s.TMP[0][0], 36, nt * 16, sk * 16, lane), Z); -#pragma unroll - for (int e = 0; e < 8; ++e) s.ST[tid * 8 + e] = Z[e]; - } - R3D_BARRIER(); - for (int t = warp; t < 4; t += kNW) { - const int mt = t >> 1, nt = t & 1; - // Element e is A[32 + mt*16 + 2e + hi][nt*16 + lo]. This wmma instance - // negates its product on this toolchain, so the minus belongs to it: - // store the accumulator as-is. -#pragma unroll - for (int e = 0; e < 8; ++e) - s.A[32 + mt * 16 + 2 * e + hi][nt * 16 + lo] = f32_to_bf16(s.ST[tid * 8 + e]); - } - R3D_BARRIER(); - - // Clear the upper-triangular parking slots (they still hold gram values) so the - // stored matrix is a clean lower-triangular inverse. - for (int idx = tid; idx < 64 * 64; idx += kNTHR) { - const int r = idx / 64, c = idx % 64; - if (c > r) s.A[r][c] = 0; - } - R3D_BARRIER(); - - - // ---- store: one row of the inverse is 64 bf16, contiguous in HBM --------------------- - { - unsigned short* op = Ao + ((size_t)(bos + t0) * H + hv) * kBT; - const size_t orow = (size_t)H * kBT; - for (int r = tid / 8; r < rows; r += kNTHR / 8) { - const int c8 = (tid & 7) * 8; - *(uint4*)(op + (size_t)r * orow + c8) = *(const uint4*)(&s.A[r][c8]); - } - } - if (hh + 1 < HG_RATIO) R3D_BARRIER(); - } -} - -int r3d_gdn_kkt_solve_launch(const void* k, const void* beta, const void* g, void* A, - const void* cu, int N, int T, int H, int Hg, int K, int chunk, - hipStream_t stream) -{ - if (K != kKD || chunk != kBT) return -1; - if (H % Hg) return -2; - const int nchunk_ub = (T + kBT - 1) / kBT + N; // sum of per-sequence chunk counts, bounded - dim3 grid(nchunk_ub, Hg), blk(kNTHR); -#define R3D_KKLAUNCH(R) \ - R3D_KLAUNCH_S(R3D_KNAME((r3d_gdn_kkt_solve_kernel)), grid, blk, 0, stream, \ - (const unsigned short*)k, (const float*)beta, (const float*)g, \ - (unsigned short*)A, (const int*)cu, N, H, Hg) - switch (H / Hg) { - case 1: R3D_KKLAUNCH(1); break; - case 2: R3D_KKLAUNCH(2); break; - case 3: R3D_KKLAUNCH(3); break; - case 4: R3D_KKLAUNCH(4); break; - case 6: R3D_KKLAUNCH(6); break; - case 8: R3D_KKLAUNCH(8); break; - default: return -3; - } -#undef R3D_KKLAUNCH - return (int)hipGetLastError(); -} - -} // namespace - -/* ------------------------------------------------------------------ the raw entry */ - -extern "C" int r3d_gdn_kkt_solve_c64(long k, long beta, long g, long A, long cu, - int N, int T, int H, int Hg, int K, int chunk, - long stream) -{ - if (!k || !beta || !g || !A || !cu) return -1; - if (N < 1 || T < 1) return -2; - if (H < 1 || Hg < 1) return -2; - return r3d_gdn_kkt_solve_launch((const void*)k, (const void*)beta, (const void*)g, (void*)A, - (const void*)cu, N, T, H, Hg, K, chunk, (hipStream_t)stream); -} - -/* ------------------------------------------------------------------ the plugin ABI */ - -enum { QK_K = 0, QK_BETA, QK_G, QK_CU, QK_A }; - -extern "C" int r3d_rad_gdn_kkt_solve(const RadArgs* a, RadStream s) -{ - if (!a) return R3D_NO(RAD_E_INVAL); - const RadTensor* kt = r3d_opt(a, QK_K); - const RadTensor* bt = r3d_opt(a, QK_BETA); - const RadTensor* gt = r3d_opt(a, QK_G); - const RadTensor* cu = r3d_opt(a, QK_CU); - const RadTensor* Ao = r3d_opt(a, QK_A); - if (!r3d_p(kt) || !r3d_p(bt) || !r3d_p(gt) || !r3d_p(cu) || !r3d_wp(Ao)) - return R3D_NO(RAD_E_INVAL); - if (!r3d_is_bf16(kt) || !r3d_is_f32(bt) || !r3d_is_f32(gt) || !r3d_is_i32(cu) || - !r3d_is_bf16(Ao)) - return R3D_NO(RAD_E_DTYPE); - - if (cu->rank != 1 || cu->shape[0] < 2 || !r3d_contig(cu)) return R3D_NO(RAD_E_SHAPE); - const int N = (int)(cu->shape[0] - 1); - - const long long T = r3d_dim(kt, 0), Hg = r3d_dim(kt, 1), K = r3d_dim(kt, 2); - const long long H = r3d_dim(bt, 1), chunk = r3d_dim(Ao, 2); - if (r3d_dim(gt, 0) != T || r3d_dim(gt, 1) != H || r3d_dim(bt, 0) != T) - return R3D_NO(RAD_E_SHAPE); - if (r3d_dim(Ao, 0) != T || r3d_dim(Ao, 1) != H) return R3D_NO(RAD_E_SHAPE); - if (H == 0 || Hg == 0 || H % Hg) return R3D_NO(RAD_E_SHAPE); - if (!r3d_contig(kt) || !r3d_contig(bt) || !r3d_contig(gt) || !r3d_contig(Ao)) - return R3D_NO(RAD_E_STRIDE); - - return r3d_gdn_kkt_solve_launch(r3d_p(kt), r3d_p(bt), r3d_p(gt), r3d_wp(Ao), r3d_p(cu), - N, (int)T, (int)H, (int)Hg, (int)K, (int)chunk, - (hipStream_t)s); -} diff --git a/libr3d/r3d_gdn_recurrent_update_k128_v128.hip b/libr3d/r3d_gdn_recurrent_update_k128_v128.hip deleted file mode 100644 index f1cd2308..00000000 --- a/libr3d/r3d_gdn_recurrent_update_k128_v128.hip +++ /dev/null @@ -1,350 +0,0 @@ -/* r3d_gdn_recurrent_update_k128_v128.hip -- the gated-delta-net recurrent state update, run by - * - * STATUS: the loop-restructure workaround is in; the value probe is the remaining gate. Three - * compiler bugs were found, two worked around outright and the third around by loop shape: - * - * 1. A DPP shuffle (__shfl_xor) inside the token loop miscompiles: 48 of the 256 threads drop - * out and the row's stores never land. Worked around: every cross-lane exchange (the l2 - * norms, the S k / S q closes, the gated-norm wave sum) goes through an __shared__ scratch - * instead of a shuffle. - * - * 2. As a template the kernel's device code is present and the launch - * succeeds, but the kernel never runs (not even a prologue sentinel lands), while a plain - * kernel in the same file runs fine. Worked around: the kernel is plain; norm and ab_bf16 - * are runtime parameters. - * - * 3. With both fixes in, the loop was compiler-sensitive: the fused in-loop pair (the state - * update h[j] += u*kk[j] with the on accumulation) plus the third cross-lane exchange and - * the o write produced a kernel whose token loop did not land its o stores, while - * near-identical variants did. The trigger is a specific interaction of the 64-element - * register state, the LDS exchanges and the o write; it has not been reduced to a minimal - * repro. Worked around: the update and the o dot run as separate loops, and the o store is - * volatile. The value probe is the gate. - * - * decode (prefill runs the chunked scan). One kernel for the whole step: - * - * g = -exp(A_log) . softplus(a + dt_bias) beta = sigmoid(b) q, k l2-normalised - * S *= e^g - * u = beta . (v - S k) S += u k^T o = S q - * - * per token, against a paged state cache: the initial state is read from the slot the step's - * tokens leave, and every token writes its own slot. The state stays in registers: one thread - * owns one v row and half its k range, so - * - * * S k and S q are in-lane dot products closed by a single lane<->lane^1 exchange, not a tree; - * * the outer-product update is 64 independent FMAs with no cross-lane traffic; - * * a thread's 64 state elements are contiguous in k, so the load and every store is eight - * 8-byte accesses over one 256-byte run. - * - * The cross-lane exchanges (the l2 norms, the S k and S q closes, the gated-norm wave sum) go - * through LDS, not a shuffle. A DPP shuffle inside the token loop miscompiles on gfx1102: with - * the lane<->lane^1 __shfl_xor in the loop, 48 of the 256 threads drop out and the row's stores - * never land. Routing the same exchange through a __shared__ scratch (one store, a barrier, one - * read of the neighbour) is correct and costs a barrier per token. - * - * This is the non-speculative core: a step's tokens are the cu window (width 1 for a plain - * decode step), the state cache is fp32, and the gated RMS norm is folded into the epilogue - * (z and norm_w present) or omitted. The speculative anchor, the folded decode convolution and - * the folded out-projection quantiser are not part of this row. - */ - -#include - -#include "r3d.h" -#include "r3d_common.h" -#include "r3d_launch.h" -#include "r3d_args.h" -#include "r3d_codecs.h" - -#include -#include -#include -#include - -namespace { - -constexpr int kK = 128; // head_k -constexpr int kV = 128; // head_v -constexpr int kHK = 64; // k elements per thread (kK / 2) -constexpr int kTHR = kV * 2; // two threads per v row - -typedef float ru_f4 __attribute__((ext_vector_type(4))); - -template -__device__ __forceinline__ void ru_load8(float* d, const float* p) -{ - const ru_f4* q = (const ru_f4*)p; - *(ru_f4*)d = NT ? __builtin_nontemporal_load(q) : *q; - *(ru_f4*)(d + 4) = NT ? __builtin_nontemporal_load(q + 1) : *(q + 1); -} - -template -__device__ __forceinline__ void ru_store8(float* p, const float* d) -{ - ru_f4* q = (ru_f4*)p; - if (NT) { - __builtin_nontemporal_store(*(const ru_f4*)d, q); - __builtin_nontemporal_store(*(const ru_f4*)(d + 4), q + 1); - } else { - *q = *(const ru_f4*)d; - *(q + 1) = *(const ru_f4*)(d + 4); - } -} - -__device__ __forceinline__ float ru_softplus(float x, float thr) -{ - if (x > thr) return x; - return (x > 0.0f) ? (x + __logf(1.0f + __expf(-x))) : __logf(1.0f + __expf(x)); -} - -template -__device__ __forceinline__ float ru_ab(const void* p, size_t i) -{ - return ABF16 ? bf16_to_f32(((const unsigned short*)p)[i]) : ((const float*)p)[i]; -} - -__device__ __forceinline__ float ru_act(float z, int kind) -{ - const float s = 1.0f / (1.0f + __expf(-z)); - return kind ? s : z * s; -} - -#define R3D_BARRIER() do { __syncthreads(); asm volatile("" ::: "memory"); } while (0) - -/* norm: 0 = no epilogue norm, 1 = sigmoid, 2 = silu (the row's `act`). ab_bf16: a/b are bf16. - * A plain kernel, not a template: on gfx1102 the template instantiation miscompiles (the device - * code is present and the launch succeeds, but the kernel never runs -- not even a prologue - * sentinel lands, while a plain kernel in the same file runs fine). */ -__global__ __launch_bounds__(kTHR) -void r3d_gdn_recurrent_update_kernel(const unsigned short* __restrict__ q, - const unsigned short* __restrict__ k, - const unsigned short* __restrict__ v, - const void* __restrict__ av, const void* __restrict__ bv, - long long ab_stride, - const float* __restrict__ A_log, const float* __restrict__ dt_bias, - float* __restrict__ state, - long long st_slot, long long st_head, - const int* __restrict__ sidx, long long sidx_stride, - const unsigned short* __restrict__ zg, long long zg_pitch, - const float* __restrict__ nw, - unsigned short* __restrict__ o, - const int* __restrict__ cu, int H, int Hg, - float scale, float sp_thr, float neps, - int norm, int ab_bf16) -{ - const int tid = threadIdx.x; - const int row = (tid >> 1), half = tid & 1, k0 = half * kHK; - const int n = blockIdx.x, hv = blockIdx.y; - const int bos = cu[n], T = cu[n + 1] - bos; - if (T <= 0) return; - const int hk = hv / (H / Hg); - - /* Read early so their latency overlaps the state load. */ - const float a_log_h = A_log[hv], dtb = dt_bias[hv]; - const float alog = __expf(a_log_h); - - float h[kHK]; - { - const float* p = state + (size_t)sidx[(size_t)n * sidx_stride] * st_slot - + (size_t)hv * st_head + (size_t)row * kK + k0; -#pragma unroll - for (int j = 0; j < kHK; j += 8) ru_load8<0>(&h[j], p + j); - } - - // LDS scratch for the cross-lane exchanges. ex holds the per-thread value being exchanged - // (lane<->lane^1, or a full wave for the gated norm); wsum holds the eight wave sums. - __shared__ float ex[2 * kTHR]; - __shared__ float wsum[kTHR / 32]; - - for (int t = 0; t < T; ++t) { - const int tok = bos + t; - const unsigned short* qp = q + ((size_t)tok * Hg + hk) * kK + k0; - const unsigned short* kp = k + ((size_t)tok * Hg + hk) * kK + k0; - - float qq[kHK], kk[kHK]; - for (int j = 0; j < kHK; ++j) { qq[j] = bf16_to_f32(qp[j]); kk[j] = bf16_to_f32(kp[j]); } - - // l2 norms: 64 in-lane terms, then one exchange with the lane holding the other half. - // (LDS, not a shuffle -- a DPP in this loop miscompiles on gfx1102.) - float sq = 0.0f, sk = 0.0f; - for (int j = 0; j < kHK; ++j) { sq += qq[j] * qq[j]; sk += kk[j] * kk[j]; } - ex[tid] = sq; ex[tid + kTHR] = sk; - R3D_BARRIER(); - sq += ex[tid ^ 1]; sk += ex[tid ^ 1 + kTHR]; - const float qs = __frsqrt_rn(sq + 1e-6f) * scale, ks = __frsqrt_rn(sk + 1e-6f); - for (int j = 0; j < kHK; ++j) { qq[j] *= qs; kk[j] *= ks; } - - const size_t ab_i = (size_t)tok * ab_stride + hv; - const float ra = ab_bf16 ? bf16_to_f32(((const unsigned short*)av)[ab_i]) : ((const float*)av)[ab_i]; - const float rb = ab_bf16 ? bf16_to_f32(((const unsigned short*)bv)[ab_i]) : ((const float*)bv)[ab_i]; - const float g = -alog * ru_softplus(ra + dtb, sp_thr); - const float bt = 1.0f / (1.0f + __expf(-rb)); - const float eg = __expf(g); - - float dot = 0.0f; - for (int j = 0; j < kHK; ++j) { h[j] *= eg; dot += h[j] * kk[j]; } - ex[tid] = dot; - R3D_BARRIER(); - dot += ex[tid ^ 1]; - - const float vraw = bf16_to_f32(v[((size_t)tok * H + hv) * kV + row]); - const float u = (vraw - dot) * bt; - - // The outer-product update and the o dot run as separate loops: fused, with the - // third exchange and the o write live, the token loop's o stores stopped landing on - // gfx1102 (a compiler interaction, not reduced to a minimal repro); split, they land. - for (int j = 0; j < kHK; ++j) h[j] += u * kk[j]; - float on = 0.0f; - for (int j = 0; j < kHK; ++j) on += h[j] * qq[j]; - ex[tid] = on; - R3D_BARRIER(); - on += ex[tid ^ 1]; - - if (norm) { - ex[tid] = (half == 0) ? on * on : 0.0f; - R3D_BARRIER(); - const int wave = tid >> 5; - float s = 0.0f; - for (int i = 0; i < 32; ++i) s += ex[wave * 32 + i]; - if ((tid & 31) == 0) wsum[wave] = s; - R3D_BARRIER(); - float tot = 0.0f; - for (int i = 0; i < kTHR / 32; ++i) tot += wsum[i]; - const float sc = __frsqrt_rn(tot * (1.0f / kV) + neps); - const unsigned short zr = zg[(size_t)tok * zg_pitch + (size_t)hv * kV + row]; - on *= sc * nw[row] * ru_act(bf16_to_f32(zr), norm); - R3D_BARRIER(); - } - - const unsigned short ob = f32_to_bf16(on); - if (half == 0) { - // Volatile: the plain store was the one the compiler dropped in the fused form. - volatile unsigned short* ov = o; - ov[((size_t)tok * H + hv) * kV + row] = ob; - } - - const int so = sidx[(size_t)n * sidx_stride + t]; - if (so >= 0) { - float* p = state + (size_t)so * st_slot + (size_t)hv * st_head - + (size_t)row * kK + k0; - for (int j = 0; j < kHK; j += 8) ru_store8<0>(p + j, &h[j]); - } - } -} - -int r3d_gdn_recurrent_update_launch(const void* q, const void* k, const void* v, const void* a, - const void* b, long long ab_stride, const void* A_log, - const void* dt_bias, void* state, long long st_slot, - long long st_head, const void* sidx, long long sidx_stride, - const void* zg, long long zg_pitch, const void* nw, - void* o, const void* cu, int N, int H, int Hg, int norm, - int ab_bf16, float scale, float sp_thr, float neps, - hipStream_t stream) -{ - dim3 grid(N, H), blk(kTHR); - // A plain kernel: norm and ab_bf16 are runtime parameters, not template arguments. - R3D_KLAUNCH(r3d_gdn_recurrent_update_kernel, grid, blk, stream, - (const unsigned short*)q, (const unsigned short*)k, (const unsigned short*)v, - a, b, ab_stride, (const float*)A_log, (const float*)dt_bias, (float*)state, - st_slot, st_head, (const int*)sidx, sidx_stride, (const unsigned short*)zg, - zg_pitch, (const float*)nw, (unsigned short*)o, (const int*)cu, H, Hg, - scale, sp_thr, neps, norm, ab_bf16); - return (int)hipGetLastError(); -} - -} // namespace - -/* ------------------------------------------------------------------ the plugin ABI */ - -enum { RU_Q = 0, RU_K, RU_V, RU_A, RU_B, RU_ALOG, RU_DTB, RU_STATE, RU_SIDX, RU_NACC, RU_CU, - RU_Z, RU_NORMW, RU_O, RU_OQ, RU_OSCALE }; - -extern "C" int r3d_rad_gdn_recurrent_update(const RadArgs* a, RadStream s) -{ - if (!a) return R3D_NO(RAD_E_INVAL); - const RadTensor* q = r3d_opt(a, RU_Q); - const RadTensor* k = r3d_opt(a, RU_K); - const RadTensor* v = r3d_opt(a, RU_V); - const RadTensor* ta = r3d_opt(a, RU_A); - const RadTensor* tb = r3d_opt(a, RU_B); - const RadTensor* alog = r3d_opt(a, RU_ALOG); - const RadTensor* dtb = r3d_opt(a, RU_DTB); - const RadTensor* st = r3d_opt(a, RU_STATE); - const RadTensor* sidx = r3d_opt(a, RU_SIDX); - const RadTensor* nacc = r3d_opt(a, RU_NACC); - const RadTensor* cu = r3d_opt(a, RU_CU); - const RadTensor* z = r3d_opt(a, RU_Z); - const RadTensor* nw = r3d_opt(a, RU_NORMW); - const RadTensor* o = r3d_opt(a, RU_O); - // o_q and o_scale are the folded quantiser's outputs; this row does not fold it. - if (!r3d_p(q) || !r3d_p(k) || !r3d_p(v) || !r3d_p(ta) || !r3d_p(tb) || !r3d_p(alog) || - !r3d_p(dtb) || !r3d_wp(st) || !r3d_p(sidx) || !r3d_p(cu) || !r3d_wp(o)) - return R3D_NO(RAD_E_INVAL); - - if (q->rank != 3 || k->rank != 3 || v->rank != 3 || st->rank != 4 || o->rank != 3) - return R3D_NO(RAD_E_SHAPE); - if (sidx->rank < 2) return R3D_NO(RAD_E_SHAPE); - - const long long T = q->shape[0]; - const long long Hg = q->shape[1]; - const long long K = q->shape[2]; - const long long H = v->shape[1]; - const long long V = v->shape[2]; - if (k->shape[0] != T || k->shape[1] != Hg || k->shape[2] != K) return R3D_NO(RAD_E_SHAPE); - if (v->shape[0] != T || o->shape[0] != T || o->shape[1] != H || o->shape[2] != V) - return R3D_NO(RAD_E_SHAPE); - if (H == 0 || Hg == 0 || H % Hg) return R3D_NO(RAD_E_SHAPE); - if (K != kK || V != kV) return R3D_NO(RAD_E_SHAPE); - - if (!r3d_is_bf16(q) || !r3d_is_bf16(k) || !r3d_is_bf16(v) || !r3d_is_bf16(o)) - return R3D_NO(RAD_E_DTYPE); - if (!r3d_is_f32(alog) || !r3d_is_f32(dtb)) return R3D_NO(RAD_E_DTYPE); - if (!r3d_is_f32(st)) return R3D_NO(RAD_E_DTYPE); // fp32 state cache - if (ta->dtype != RAD_BF16 && ta->dtype != RAD_F32) return R3D_NO(RAD_E_DTYPE); - if (tb->dtype != ta->dtype) return R3D_NO(RAD_E_DTYPE); - - // state cache [slots, H, V, K]: the per-head and per-slot strides. - if (st->shape[1] != H || st->shape[2] != kV || st->shape[3] != kK) return R3D_NO(RAD_E_SHAPE); - const long long st_head = st->stride[1]; - const long long st_slot = st->stride[0]; - if (st_head != (long long)kV * kK) return R3D_NO(RAD_E_STRIDE); - - // a and b: [T, H] (the ba projection's rows), row pitch in elements. - const long long ab_stride = r3d_row_pitch(ta); - if (ab_stride < 0 || r3d_row_pitch(tb) != ab_stride) return R3D_NO(RAD_E_STRIDE); - - const long long sidx_stride = sidx->stride[sidx->rank - 1] == 1 ? sidx->stride[0] : -1; - if (sidx_stride < 0) return R3D_NO(RAD_E_STRIDE); - - int N = 0; - if (cu->rank != 1 || cu->shape[0] < 2 || !r3d_contig(cu)) return R3D_NO(RAD_E_SHAPE); - N = (int)(cu->shape[0] - 1); - - const float scale = (float)r3d_getf(a, "scale", 1.0 / sqrt((double)kK)); - const float sp_thr = (float)r3d_getf(a, "softplus_thr", 20.0); - const float neps = (float)r3d_getf(a, "eps", 1e-6); - - // The gated RMS norm epilogue: present when both z and norm_w are given. - int norm = 0; - long long zg_pitch = 0; - if (r3d_p(z) && r3d_p(nw)) { - if (z->rank != 3 || z->shape[0] != T || z->shape[1] != H || z->shape[2] != kV) - return R3D_NO(RAD_E_SHAPE); - if (!r3d_is_bf16(z) || !r3d_is_f32(nw) || r3d_numel(nw) != kV) return R3D_NO(RAD_E_DTYPE); - const int act = r3d_act_code(a, "act", nullptr, 0); - if (act != 0 && act != 1) return R3D_NO(RAD_E_INVAL); - norm = (act == 0) ? 2 : 1; // r3d_act_code: 0=silu, 1=sigmoid; kernel: 2=silu, 1=sigmoid - zg_pitch = z->stride[0]; - } - - const int e = r3d_gdn_recurrent_update_launch(r3d_p(q), r3d_p(k), r3d_p(v), r3d_p(ta), r3d_p(tb), - ab_stride, r3d_p(alog), r3d_p(dtb), r3d_wp(st), - st_slot, st_head, r3d_p(sidx), sidx_stride, - r3d_p(z), zg_pitch, r3d_p(nw), r3d_wp(o), r3d_p(cu), - N, (int)H, (int)Hg, norm, (ta->dtype == RAD_BF16), - scale, sp_thr, neps, (hipStream_t)s); - /* The launcher's codes are raw: its own negatives and hipGetLastError's positives. The - * plugin ABI takes RadStatus, so normalise. */ - if (e < 0) return R3D_NO(RAD_E_INVAL); - return e ? R3D_NO(RAD_E_DEVICE) : RAD_OK; -} diff --git a/libr3d/r3d_gemm_fp8a16_nt_m1.hip b/libr3d/r3d_gemm_fp8a16_nt_m1.hip index aa94a412..8e992298 100644 --- a/libr3d/r3d_gemm_fp8a16_nt_m1.hip +++ b/libr3d/r3d_gemm_fp8a16_nt_m1.hip @@ -125,6 +125,7 @@ __global__ __launch_bounds__(kBlockThreads) R3D_WAVES(8) void gemm_q_kernel( const uint8_t* __restrict__ A, const float* __restrict__ AScale, const uint8_t* __restrict__ B, const void* __restrict__ BScale, int bs16, uint16_t* __restrict__ Y, float* __restrict__ Part, + const uint16_t* __restrict__ Bias, int M, int N, int K, int group, int pb1, int a_ld, int y_ld, int kslab, int nkb) { __shared__ uint32_t s_a[kMTMax * kAPitch]; @@ -258,7 +259,8 @@ __global__ __launch_bounds__(kBlockThreads) R3D_WAVES(8) void gemm_q_kernel( if constexpr (SPLIT) { Part[((size_t)blockIdx.y * M + m) * N + n0] = acc; } else { - Y[(size_t)m * y_ld + n0] = f32_to_bf16(acc); + const float bv = Bias ? bf16_to_f32(Bias[n0]) : 0.0f; + Y[(size_t)m * y_ld + n0] = f32_to_bf16(acc + bv); } } @@ -294,7 +296,8 @@ __global__ __launch_bounds__(kBlockThreads) R3D_WAVES(8) void gemm_q_reduce( * 0, -1 a null pointer, -2 an unsupported shape, -3 an unreadable pitch, -4 HIP failed. */ extern "C" int r3d_gemm_nt_q_fp8_ex(long a, long a_scale, long b, long b_scale, long y, int M, int N, int K, int group, int pb1, int pb2, int a_ld, int y_ld, - int sk, int nt, long scratch, int bs_dt, long stream) + int sk, int nt, long scratch, int bs_dt, long stream, + long bias) { if (!a || !b || !b_scale || !y) return -1; if (M < 1 || N < 1 || K < 1) return -2; @@ -318,6 +321,7 @@ extern "C" int r3d_gemm_nt_q_fp8_ex(long a, long a_scale, long b, long b_scale, if (sk > 1 && !scratch) return -1; const int bs16 = (bs_dt == RAD_BF16); /* anything else, 0 included, reads the plane as f32 */ + const uint16_t* bias_p = bias ? (const uint16_t*)(uintptr_t)bias : nullptr; const int mt = M <= 1 ? 1 : M <= 2 ? 2 : M <= 4 ? 4 : M <= 8 ? 8 : kMTMax; const int kslab = K / sk; const int nrowb = (N + pb1 - 1) / pb1; @@ -331,7 +335,8 @@ extern "C" int r3d_gemm_nt_q_fp8_ex(long a, long a_scale, long b, long b_scale, R3D_KLAUNCH(R3D_KNAME((gemm_q_kernel)), grid, dim3_blk, \ (hipStream_t)stream, (const uint8_t*)a, (const float*)a_scale, \ (const uint8_t*)b, (const void*)b_scale, bs16, (uint16_t*)y, \ - (float*)scratch, M, N, K, group, pb1, a_ld, y_ld, kslab, nkb); \ + (float*)scratch, (const uint16_t*)nullptr, \ + M, N, K, group, pb1, a_ld, y_ld, kslab, nkb); \ const int mn = M * N; \ const int nb = std::min((mn + kBlockThreads - 1) / kBlockThreads, 4096); \ R3D_KLAUNCH(gemm_q_reduce, dim3(nb), dim3(kBlockThreads), (hipStream_t)stream, \ @@ -340,7 +345,8 @@ extern "C" int r3d_gemm_nt_q_fp8_ex(long a, long a_scale, long b, long b_scale, R3D_KLAUNCH(R3D_KNAME((gemm_q_kernel)), grid, dim3_blk, \ (hipStream_t)stream, (const uint8_t*)a, (const float*)a_scale, \ (const uint8_t*)b, (const void*)b_scale, bs16, (uint16_t*)y, \ - (float*)nullptr, M, N, K, group, pb1, a_ld, y_ld, kslab, nkb); \ + (float*)nullptr, (const uint16_t*)bias_p, \ + M, N, K, group, pb1, a_ld, y_ld, kslab, nkb); \ } \ } while (0) #define R3D_Q_A8(MTV, A8V) do { if (nt) R3D_Q_NT(MTV, A8V, true); else R3D_Q_NT(MTV, A8V, false); } while (0) @@ -482,7 +488,7 @@ extern "C" int r3d_rad_gemm_nt_q_fp8(const RadArgs* a, RadStream s) (int)pb2, (int)a_ld, (int)y_ld, sk, c.nt, (long)(uintptr_t)(sk > 1 ? a->scratch : nullptr), (int)BS->dtype, /* bf16 weight_scale_inv or f32 */ - (long)(uintptr_t)s); + (long)(uintptr_t)s, 0); if (e == 0) return RAD_OK; return R3D_NO(e == -1 ? RAD_E_INVAL : e == -2 ? RAD_E_SHAPE : e == -3 ? RAD_E_STRIDE : RAD_E_DEVICE); diff --git a/libr3d/r3d_gemm_fp8a8_bias.hip b/libr3d/r3d_gemm_fp8a8_bias.hip new file mode 100644 index 00000000..64b8021b --- /dev/null +++ b/libr3d/r3d_gemm_fp8a8_bias.hip @@ -0,0 +1,47 @@ +// r3d_gemm_fp8a8_bias.hip -- gemm_nt_q_bias: the narrow fp8 GEMM with a per-column bias epilogue. +// Runs r3d_gemm_nt_q_fp8_ex for the GEMM, then a small kernel adds the bias. +#include +#include +#include +#include "r3d.h" +#include "r3d_args.h" +#include "r3d_launch.h" + +// The low-level fp8 GEMM entry point (from r3d_gemm_fp8a16_nt_m1.hip) +extern "C" int r3d_gemm_nt_q_fp8_ex(long a, long a_scale, long b, long b_scale, long y, + int M, int N, int K, int group, int pb1, int pb2, + int a_ld, int y_ld, int sk, int nt, long scratch, + int bs_dt, long stream, long bias); + +extern "C" int r3d_rad_gemm_nt_q_bias_fp8(const RadArgs* a, RadStream s) +{ + enum { Q_A = 0, Q_ASCALE, Q_B, Q_BSCALE, Q_BIAS, Q_Y }; + const RadTensor* A = r3d_opt(a, Q_A); + const RadTensor* AS = r3d_opt(a, Q_ASCALE); + const RadTensor* B = r3d_opt(a, Q_B); + const RadTensor* BS = r3d_opt(a, Q_BSCALE); + const RadTensor* BI = r3d_opt(a, Q_BIAS); + const RadTensor* Y = r3d_opt(a, Q_Y); + if (!r3d_p(A) || !r3d_p(B) || !r3d_p(BS) || !r3d_wp(Y) || !r3d_p(BI)) + return R3D_NO(RAD_E_INVAL); + if (BI->dtype != RAD_BF16) return R3D_NO(RAD_E_DTYPE); + + const int M = (int)(Y->rank >= 1 ? Y->shape[0] : r3d_geti_or(a, "M", 0)); + const int N = (int)(Y->rank >= 2 ? Y->shape[1] : r3d_geti_or(a, "N", 0)); + const int K = (int) r3d_geti_or(a, "K", B->rank >= 2 ? B->shape[B->rank - 1] : 0); + const int group = (int) r3d_geti_or(a, "group", 128); + const int a_ld = (A->rank >= 2) ? (int)A->stride[0] : K; + const int y_ld = (Y->rank >= 2) ? (int)Y->stride[0] : N; + const int bs_dt = BS->dtype; + + // Run the GEMM with bias fused in + int rc = r3d_gemm_nt_q_fp8_ex((long)(uintptr_t)r3d_p(A), + AS ? (long)(uintptr_t)r3d_p(AS) : 0, + (long)(uintptr_t)r3d_p(B), + (long)(uintptr_t)r3d_p(BS), + (long)(uintptr_t)r3d_wp(Y), + M, N, K, group, group, group, a_ld, y_ld, + 0, 1, 0, bs_dt, (long)(uintptr_t)s, + (long)(uintptr_t)r3d_p(BI)); + return rc == 0 ? RAD_OK : R3D_NO(RAD_E_DEVICE); +} diff --git a/libr3d/r3d_gemm_fp8a8_short.hip b/libr3d/r3d_gemm_fp8a8_short.hip new file mode 100644 index 00000000..10997d0f --- /dev/null +++ b/libr3d/r3d_gemm_fp8a8_short.hip @@ -0,0 +1,39 @@ +// r3d_gemm_fp8a8_short.hip -- gemm_nt_q_short: the narrow fp8 GEMM with the short-prompt split rule. +// At N <= 512, K <= 5120 and 41..64 rows the split's per-slice floors dominate, so the row runs +// unsplit (sk=1). +#include +#include +#include "r3d.h" +#include "r3d_args.h" +#include "r3d_launch.h" + +extern "C" int r3d_rad_gemm_nt_q_short_fp8(const RadArgs* a, RadStream s) +{ + enum { Q_A = 0, Q_ASCALE, Q_B, Q_BSCALE, Q_Y }; + const RadTensor* A = r3d_opt(a, Q_A); + const RadTensor* AS = r3d_opt(a, Q_ASCALE); + const RadTensor* B = r3d_opt(a, Q_B); + const RadTensor* BS = r3d_opt(a, Q_BSCALE); + const RadTensor* Y = r3d_opt(a, Q_Y); + if (!r3d_p(A) || !r3d_p(B) || !r3d_p(BS) || !r3d_wp(Y)) return R3D_NO(RAD_E_INVAL); + + const int M = (int)(Y->rank >= 1 ? Y->shape[0] : r3d_geti_or(a, "M", 0)); + const int N = (int)(Y->rank >= 2 ? Y->shape[1] : r3d_geti_or(a, "N", 0)); + const int K = (int) r3d_geti_or(a, "K", B->rank >= 2 ? B->shape[B->rank - 1] : 0); + const int group = (int) r3d_geti_or(a, "group", 128); + const int pb1 = (int) r3d_geti_or(a, "pb1", group); + const int pb2 = (int) r3d_geti_or(a, "pb2", group); + const int a_ld = (A->rank >= 2) ? (int)A->stride[0] : K; + const int y_ld = (Y->rank >= 2) ? (int)Y->stride[0] : N; + const int bs_dt = BS->dtype; + + // Short-prompt rule: force sk=1 (no split) + int rc = r3d_gemm_nt_q_fp8_ex((long)(uintptr_t)r3d_p(A), + AS ? (long)(uintptr_t)r3d_p(AS) : 0, + (long)(uintptr_t)r3d_p(B), + (long)(uintptr_t)r3d_p(BS), + (long)(uintptr_t)r3d_wp(Y), + M, N, K, group, pb1, pb2, a_ld, y_ld, + 1, 1, 0, bs_dt, (long)(uintptr_t)s, 0); + return rc == 0 ? RAD_OK : R3D_NO(RAD_E_DEVICE); +} diff --git a/libr3d/r3d_gemm_fp8a8_tiled.hip b/libr3d/r3d_gemm_fp8a8_tiled.hip index d6628d08..7a2436ad 100644 --- a/libr3d/r3d_gemm_fp8a8_tiled.hip +++ b/libr3d/r3d_gemm_fp8a8_tiled.hip @@ -467,9 +467,25 @@ int launch(long av, long asv, long bvc, long bsv, long yv, int M, int N, int K, const dim3 blk(kBlockThreads); const dim3 grd((unsigned)((N + kTN - 1) / kTN), (unsigned)((M + kTM - 1) / kTM)); - ActQ aq{ (const float*)(uintptr_t)asv, (long long)as_ld, as_ld != 1 }; - WQ h{ (const uint8_t*)(uintptr_t)bvc, (const uint8_t*)(uintptr_t)bsv, - (const uint8_t*)(uintptr_t)zv, b_row, bs_row, z_row, sdt, cdt, srows }; + /* Value-init (not aggregate-init): the tape audit byte-compares the serialized kernel + * arguments, and aggregate-init leaves a struct's trailing padding indeterminate. A padding + * byte that differs between a pass's recording and its audit is read as "the key does not + * carry" this argument and stops the engine (the ActQ/WQ holes are 4 bytes each). Zero the + * whole struct so the padding is deterministic; the kernel reads none of it. */ + ActQ aq{}; + aq.scale = (const float*)(uintptr_t)asv; + aq.row = as_ld; + aq.gmode = as_ld != 1; + WQ h{}; + h.codes = (const uint8_t*)(uintptr_t)bvc; + h.scale = (const uint8_t*)(uintptr_t)bsv; + h.zero = (const uint8_t*)(uintptr_t)zv; + h.code_row = b_row; + h.scale_row = bs_row; + h.zero_row = z_row; + h.sdt = sdt; + h.cdt = cdt; + h.srows = srows; hipStream_t s = (hipStream_t)(uintptr_t)stream; #define R3D_RUN(NT, ARM, CD, AL) \ fp8a8_tiled_kernel<<>>( \ @@ -809,7 +825,7 @@ static int r3d_fp8a8_tiled_dispatch(const RadArgs* args, RadStream s, int alu) r3d_trace_desc("gemm y", Y); } - const int nt = (int)r3d_geti_or(args, "nt", 0); + const int nt = 0; /* no `nt` axis in the row's tune table: the non-temporal stream is fixed off */ const int st = launch(r3d_addr(A), r3d_addr(AS), (long)(uintptr_t)bvc, (long)(uintptr_t)bsv, r3d_addr(Y), (int)M, (int)N, (int)K, (int)group, (int)a_ld, b_row, (int)as_ld, bs_row, (int)y_ld, nt, (long)s, sdt, cdt, 0, 0, 0, 0, alu); @@ -964,7 +980,7 @@ extern "C" int r3d_rad_gemm_nt_q_w2a8_tiled(const RadArgs* args, RadStream s) if (!r3d_aligned(r3d_p(A), 8) || !r3d_aligned(r3d_p(Y), 8) || !r3d_aligned(sv, 2) || !r3d_aligned(zv, 1)) return R3D_NO(RAD_E_ALIGN); - const int nt = (int)r3d_geti_or(args, "nt", 0); + const int nt = 0; /* no `nt` axis in the row's tune table: the non-temporal stream is fixed off */ const int st = launch(r3d_addr(A), r3d_addr(AS), bvc, (long)(uintptr_t)sv, r3d_addr(Y), (int)M, (int)N, (int)K, (int)group, (int)a_ld, c_row, (int)as_ld, s_row, (int)y_ld, nt, (long)(uintptr_t)s, /*sdt*/ 1, cdt, diff --git a/libr3d/r3d_gemm_mxfp4a8.hip b/libr3d/r3d_gemm_mxfp4a8.hip index 759efd7b..a95533e6 100644 --- a/libr3d/r3d_gemm_mxfp4a8.hip +++ b/libr3d/r3d_gemm_mxfp4a8.hip @@ -390,10 +390,13 @@ gemm_mxfp4a8_m16_kernel(const uint8_t* __restrict__ a, const float* __restrict__ /* ================================================================== the launchers */ -static int mt_for(int M) +/* The tile's rows: the power of two that holds M, widened while its chunk (2048 / mt codes) does + * not divide K. The extra rows are idle. At 16 rows the chunk is 128, which the row's constraints + * (K a multiple of 128) always divide. */ +static int mt_for(int M, int K) { int mt = 1; - while (mt < M && mt < kMTMax) mt *= 2; + while ((mt < M || K % (2048 / mt)) && mt < kMTMax) mt *= 2; return mt; } @@ -407,7 +410,7 @@ extern "C" int r3d_gemm_nt_q_mxfp4a8_m16(long a, long a_scale, long b, long b_sc if (group != kGroup) return -2; if (K % kGroup) return -2; /* the activation's scale group */ if (K % kMX) return -2; /* the weight's 32-block */ - const int mt = mt_for(M); + const int mt = mt_for(M, K); const int chunk = 2048 / mt; if (K % chunk) return -2; if (!a_ld) a_ld = K; @@ -433,6 +436,13 @@ extern "C" int r3d_gemm_nt_q_mxfp4a8_m16(long a, long a_scale, long b, long b_sc (const uint8_t*)b_scale, (int)e8_row, (uint16_t*)y, M, N, K, chunk, a_ld, \ y_ld); \ } while (0) + switch (mt) { + case 1: R3D_MXFP4A8_M16(1); break; + case 2: R3D_MXFP4A8_M16(2); break; + case 4: R3D_MXFP4A8_M16(4); break; + case 8: R3D_MXFP4A8_M16(8); break; + default: R3D_MXFP4A8_M16(16); break; + } #undef R3D_MXFP4A8_M16 return hipGetLastError() == hipSuccess ? 0 : -4; } @@ -472,8 +482,18 @@ int launch_mxfp4a8_tiled(long av, long asv, long bvc, long bsv, long yv, int M, const dim3 blk(kBlockThreads); const dim3 grd((unsigned)((N + kTN - 1) / kTN), (unsigned)((M + kTM - 1) / kTM)); - ActQ aq{(const float*)(uintptr_t)asv, (long long)as_ld, 1}; - MxWQ h{(const uint8_t*)(uintptr_t)bvc, (const uint8_t*)(uintptr_t)bsv, b_row, e8_row}; + /* Value-init so the ActQ's 4-byte padding hole is deterministic: the tape audit byte-compares + * the serialized kernel arguments, and aggregate-init leaves that padding indeterminate, which + * reads as "the key does not carry" the argument and stops the engine. See fp8a8's launcher. */ + ActQ aq{}; + aq.scale = (const float*)(uintptr_t)asv; + aq.row = as_ld; + aq.gmode = 1; + MxWQ h{}; + h.codes = (const uint8_t*)(uintptr_t)bvc; + h.e8 = (const uint8_t*)(uintptr_t)bsv; + h.code_row = b_row; + h.e8_row = e8_row; hipStream_t s = (hipStream_t)(uintptr_t)stream; if (alu) { if (nt) mxfp4a8_tiled_kernel<1,1><<>>( @@ -670,7 +690,7 @@ static int r3d_mxfp4a8_tiled_dispatch(const RadArgs* a, RadStream s, int alu) if (!e8_scan_once(r3d_p(BS), N * (K / kMX))) return R3D_NO(RAD_E_INVAL); - const int nt = (int)r3d_geti_or(a, "nt", 0); + const int nt = 0; /* no `nt` axis in the row's tune table: the non-temporal stream is fixed off */ const int rc = r3d_gemm_nt_q_mxfp4a8_tiled(r3d_addr(A), r3d_addr(AS), r3d_addr(B), r3d_addr(BS), r3d_addr(Y), (int)M, (int)N, (int)K, kGroup, (int)ap, cp, (int)as_p, e8p, diff --git a/libr3d/r3d_moe_gather.hip b/libr3d/r3d_moe_gather.hip index a67a965c..ee0a269f 100644 --- a/libr3d/r3d_moe_gather.hip +++ b/libr3d/r3d_moe_gather.hip @@ -12,7 +12,7 @@ * - moe_gather_inv: `slot` is the `inverse` table moe_scatter_inv wrote (read straight). * * An optional shared arm adds `shared[t, c] * act(gate[t])` (two narrows, matching the unfused - * scale_rows pair). `act` is "sigmoid" (the only form we take; "none" is refused, absent = the + * scale_rows pair). `act` is "sigmoid" or "none" (the gate as it is; absent = the * identity). * * The wide-prefill form (a wave per token, 8 cols/lane) is not implemented; this is the decode and @@ -120,9 +120,10 @@ int r3d_rad_moe_gather(const RadArgs* a, RadStream s) if (M <= 0 || n <= 0 || top_k <= 0) return R3D_NO(RAD_E_SHAPE); if (top_k > kGatherSlots) return R3D_NO(RAD_E_SHAPE); // the LDS-cached form only - const uint32_t ye_ld = (uint32_t)(ye->rank >= 2 ? ye->shape[1] : ye->stride[0]); - const uint32_t ew_ld = (uint32_t)(ew->rank >= 2 ? ew->shape[1] : ew->stride[0]); - const uint32_t y_ld = (uint32_t)(y->rank >= 2 ? y->shape[1] : y->stride[0]); + // Row pitches are the tensors' own strides: a view's rows can be wider than its shape. + const uint32_t ye_ld = (uint32_t)ye->stride[0]; + const uint32_t ew_ld = (uint32_t)ew->stride[0]; + const uint32_t y_ld = (uint32_t)y->stride[0]; const uint32_t T = (uint32_t)r3d_numel(sorted); if (T < M * top_k) return R3D_NO(RAD_E_SHAPE); @@ -131,12 +132,13 @@ int r3d_rad_moe_gather(const RadArgs* a, RadStream s) const uint16_t* shp = sh ? (const uint16_t*)r3d_p(sh) : nullptr; const uint16_t* sgp = sg ? (const uint16_t*)r3d_p(sg) : nullptr; if (sh && !sg) return R3D_NO(RAD_E_INVAL); - const uint32_t sh_ld = sh ? (uint32_t)(sh->rank >= 2 ? sh->shape[1] : sh->stride[0]) : 0; - const uint32_t sg_ld = sg ? (uint32_t)(sg->rank >= 1 ? sg->shape[0] : sg->stride[0]) : 1; + // The gate is one value a token ([M] or [M, 1]): its pitch is stride[0], not a shape. + const uint32_t sh_ld = sh ? (uint32_t)sh->stride[0] : 0; + const uint32_t sg_ld = sg ? (uint32_t)sg->stride[0] : 1; int sig = 0; if (const char* act = r3d_gets(a, "act")) { if (std::string(act) == "sigmoid") sig = 1; - else if (std::string(act) == "none") return R3D_NO(RAD_E_INVAL); + else if (std::string(act) != "none") return R3D_NO(RAD_E_INVAL); } const bool f32w = (ew->dtype == RAD_F32); @@ -169,9 +171,10 @@ int r3d_rad_moe_gather_inv(const RadArgs* a, RadStream s) if (M <= 0 || n <= 0 || top_k <= 0) return R3D_NO(RAD_E_SHAPE); if (top_k > kGatherSlots) return R3D_NO(RAD_E_SHAPE); // the LDS-cached form only - const uint32_t ye_ld = (uint32_t)(ye->rank >= 2 ? ye->shape[1] : ye->stride[0]); - const uint32_t ew_ld = (uint32_t)(ew->rank >= 2 ? ew->shape[1] : ew->stride[0]); - const uint32_t y_ld = (uint32_t)(y->rank >= 2 ? y->shape[1] : y->stride[0]); + // Row pitches are the tensors' own strides: a view's rows can be wider than its shape. + const uint32_t ye_ld = (uint32_t)ye->stride[0]; + const uint32_t ew_ld = (uint32_t)ew->stride[0]; + const uint32_t y_ld = (uint32_t)y->stride[0]; const uint32_t T = (uint32_t)r3d_numel(inv); if (T < M * top_k) return R3D_NO(RAD_E_SHAPE); @@ -179,12 +182,13 @@ int r3d_rad_moe_gather_inv(const RadArgs* a, RadStream s) const uint16_t* shp = sh ? (const uint16_t*)r3d_p(sh) : nullptr; const uint16_t* sgp = sg ? (const uint16_t*)r3d_p(sg) : nullptr; if (sh && !sg) return R3D_NO(RAD_E_INVAL); - const uint32_t sh_ld = sh ? (uint32_t)(sh->rank >= 2 ? sh->shape[1] : sh->stride[0]) : 0; - const uint32_t sg_ld = sg ? (uint32_t)(sg->rank >= 1 ? sg->shape[0] : sg->stride[0]) : 1; + // The gate is one value a token ([M] or [M, 1]): its pitch is stride[0], not a shape. + const uint32_t sh_ld = sh ? (uint32_t)sh->stride[0] : 0; + const uint32_t sg_ld = sg ? (uint32_t)sg->stride[0] : 1; int sig = 0; if (const char* act = r3d_gets(a, "act")) { if (std::string(act) == "sigmoid") sig = 1; - else if (std::string(act) == "none") return R3D_NO(RAD_E_INVAL); + else if (std::string(act) != "none") return R3D_NO(RAD_E_INVAL); } const bool f32w = (ew->dtype == RAD_F32); diff --git a/libr3d/r3d_moe_gemm_bf16.hip b/libr3d/r3d_moe_gemm_bf16.hip index 8df7fefd..cadbfb9d 100644 --- a/libr3d/r3d_moe_gemm_bf16.hip +++ b/libr3d/r3d_moe_gemm_bf16.hip @@ -3,8 +3,9 @@ * y[i, n] = sum_k a[tok(i), k] * w_e[n, k], e = the expert of sorted row i * * One block per 16 expert-sorted rows, walking the runs (contiguous rows per expert) in its tile. - * bf16 activation, bf16 weight as the checkpoint stores it ([n_expert, N, K] row-major, no layout - * hook, every expert in class 0), f32 accumulate over the whole of K, bf16 out. The 16-row tile is + * bf16 activation, bf16 weight as the checkpoint stores it (each expert an [N, K] row-major entry + * of one weight table, r3d_moe_tab.h; no layout hook, every expert in class 0), f32 accumulate over + * the whole of K, bf16 out. The 16-row tile is * the same run-walk / gather structure as moe_gemm_q, minus the E4M3 decode and the scale fold: * the operands are bf16, so they stage to LDS and load straight into the bf16 wave-matrix * fragments (v_wmma_f32_16x16x16_bf16, f32 accumulate). @@ -18,6 +19,7 @@ #include "r3d_common.h" #include "r3d_codecs.h" #include "r3d_launch.h" +#include "r3d_moe_tab.h" namespace { @@ -87,11 +89,11 @@ __device__ __forceinline__ float r3d_moe_acc_read(const typename R3dMoeAcc: __global__ __launch_bounds__(kThreads) R3D_WAVES(kWaves) \ __attribute__((amdgpu_num_vgpr(MBE_VGPR))) void MBE_KNAME( \ const uint16_t* __restrict__ a, \ - const int32_t* __restrict__ sorted, const int32_t* __restrict__ off, \ - const uint16_t* __restrict__ w, \ - uint16_t* __restrict__ y, int T, int N, int K, int a_ld, int w_ld, int y_ld, \ - int n_expert, int top_k) \ + const int32_t* __restrict__ sorted, const int32_t* __restrict__ off, R3dTab tw, \ + uint16_t* __restrict__ y, int T, int N, int K, int a_ld, int y_ld, \ + int n_expert, int top_k, int a_sorted) \ { \ + const int w_ld = tw.ld; /* elements between an expert's rows */ \ constexpr int kMBlock = MBE_MR; /* a block is MBE_MR rows x 128 cols */ \ constexpr int kRB = MBE_MR / 16; /* row-blocks a wave accumulates */ \ constexpr int kStageA = MBE_MR * kDW / kThreads; /* dwords a thread stages of the activation */ \ @@ -114,7 +116,7 @@ __attribute__((amdgpu_num_vgpr(MBE_VGPR))) void MBE_KNAME( if (tid < kMBlock) { \ const uint32_t i = r0 + tid; \ const int32_t f = (i < (uint32_t)T) ? sorted[i] : -1; \ - s_tok[tid] = (f < 0) ? -1 : (f / top_k); \ + s_tok[tid] = (f < 0) ? -1 : (a_sorted ? (int32_t)i : f / top_k); \ } \ /* The runs in [r0, r1): each a contiguous set of rows for one expert. The block walks them. */ \ if (tid == 0) { \ @@ -143,7 +145,7 @@ __attribute__((amdgpu_num_vgpr(MBE_VGPR))) void MBE_KNAME( for (int rb = 0; rb < kRB; ++rb) \ acc[rb] = v8float{ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f }; \ if (e >= 0) { \ - const uint16_t* wbase = w + (size_t)e * (size_t)N * w_ld; \ + const uint16_t* wbase = (const uint16_t*)r3d_tab_at(tw, e); \ \ const int ntile = (K + kKT - 1) / kKT; \ /* Prologue: stage tile 0 into buffer 0. */ \ @@ -289,21 +291,19 @@ extern "C" { int r3d_rad_moe_gemm_bf16(const RadArgs* a, RadStream s) { - if (!a || a->n_t < 5) return R3D_NO(RAD_E_INVAL); - const RadTensor* at = r3d_opt(a, 0), *wt = r3d_opt(a, 1), *st = r3d_opt(a, 2), - *ot = r3d_opt(a, 3), *yt = r3d_opt(a, 4); - if (!r3d_p(at) || !r3d_p(wt) || !r3d_p(st) || !r3d_p(ot) || !r3d_wp(yt)) - return R3D_NO(RAD_E_INVAL); - long long M = 0, K = 0; - if (r3d_rows_of(at, &M, &K) != 0) return R3D_NO(RAD_E_INVAL); - const long long T = (st->rank >= 1) ? st->shape[0] : 0; - const long long N = (wt->rank >= 3) ? wt->shape[1] : 0; - if (M <= 0 || T <= 0 || N <= 0 || K <= 0 || (K & 63)) return R3D_NO(RAD_E_SHAPE); // N tail clamps - const int n_expert = (int)r3d_geti_or(a, "n_expert", 1); - const int top_k = (int)r3d_geti_or(a, "top_k", 1); - const int a_ld = (int)at->stride[0]; - const int w_ld = (int)wt->shape[2]; - const int y_ld = (int)yt->stride[0]; + R3dMoeCall mc; + int rc = r3d_moe_call(a, false, &mc); + if (rc != RAD_OK) return rc; + if (mc.a->dtype != RAD_BF16 || mc.y->dtype != RAD_BF16) return R3D_NO(RAD_E_DTYPE); + const long long T = mc.T, N = mc.N, K = mc.K; + if (K & 63) return R3D_NO(RAD_E_SHAPE); // N tail clamps + R3dTab tw; + rc = r3d_tab_of(mc.w, RAD_BF16, 16, mc.n_expert, N, K, &tw); + if (rc != RAD_OK) return rc; + const int n_expert = (int)mc.n_expert, top_k = (int)mc.top_k, a_sorted = mc.a_sorted; + const int a_ld = (int)mc.a->stride[0]; + const int y_ld = (int)mc.y->stride[0]; + const RadTensor *at = mc.a, *st = mc.sorted, *ot = mc.off, *yt = mc.y; R3dMoeCfg c; r3d_cfg_moe(a, &c); // the tune's row count (16, 32 or 64), 64 untuned #define R3D_LM(MR, KERN) \ @@ -311,9 +311,8 @@ int r3d_rad_moe_gemm_bf16(const RadArgs* a, RadStream s) dim3 grid((unsigned)((N + kNBlock - 1) / kNBlock), (unsigned)((T + MR - 1) / MR)), \ blk(kThreads); \ KERN<<>>( \ - (const uint16_t*)r3d_p(at), (const int32_t*)r3d_p(st), (const int32_t*)r3d_p(ot), \ - (const uint16_t*)r3d_p(wt), (uint16_t*)r3d_wp(yt), (int)T, (int)N, (int)K, a_ld, w_ld, \ - y_ld, n_expert, top_k); \ + (const uint16_t*)r3d_p(at), (const int32_t*)r3d_p(st), (const int32_t*)r3d_p(ot), tw, \ + (uint16_t*)r3d_wp(yt), (int)T, (int)N, (int)K, a_ld, y_ld, n_expert, top_k, a_sorted); \ } while (0) if (c.mrows <= 16) { if (c.acc) R3D_LM(16, moe_bf16_kernel16_a1); diff --git a/libr3d/r3d_moe_gemm_fp8_f32scale.hip b/libr3d/r3d_moe_gemm_fp8_f32scale.hip index 5f197f5a..81e93ebc 100644 --- a/libr3d/r3d_moe_gemm_fp8_f32scale.hip +++ b/libr3d/r3d_moe_gemm_fp8_f32scale.hip @@ -1,13 +1,13 @@ /* r3d_moe_gemm_fp8_f32scale.hip -- moe_gemm_q (the wave-matrix form): the grouped GEMM with E4M3 * experts and exact F32 block scales. * - * y[i, n] = sum_g as[tok(i), g] * wsb[e, n/grid_rows][g] * sum_{k in g} a[tok(i), k] * w_e[n, k] + * y[i, n] = sum_g as[tok(i), g] * ws_e[n/128][g] * sum_{k in g} a[tok(i), k] * w_e[n, k] * - * The moe_gemm_q contract: a and the weight planes are E4M3, one F32 scale per (row, 128 of K) - * for the activation and one per (plane expert, n/grid_rows, 128 of K) for the weight; the even - * experts live in w / w_scale and the odd in w_odd / w_odd_scale, at index e/2; y is f32 in sorted - * order. E4M3 activation and E4M3 weight (the checkpoint stores the plane as [n_expert/2, N, K] - * row-major, one byte a code). f32 accumulate over the whole of K. + * The moe_gemm_q contract at fp8a8f32: a and the weight entries are E4M3, one F32 scale per (row, + * 128 of K) for the activation and one per 128x128 tile for the weight; expert e is entry e/2 of + * class e%2's weight tables (r3d_moe_tab.h: a pointer per expert, or a stacked plane), each entry + * the checkpoint's own [N, K] row-major codes; y is bf16 in sorted order. f32 accumulate over the + * whole of K. * * gfx11 has no native FP8 wave-matrix, so the codes widen to f16 (exact: every E4M3 grid point is * an f16 grid point) and the multiply runs on the 16x16x16 f16 tile. K is walked in 128-deep @@ -23,6 +23,7 @@ #include "r3d_codecs.h" #include "r3d_fp8_dequant.h" #include "r3d_launch.h" +#include "r3d_moe_tab.h" namespace { @@ -86,11 +87,9 @@ __device__ __forceinline__ float r3d_moe_acc_f16_read(const typename R3dMoeAccF1 __global__ __launch_bounds__(kThreads) R3D_WAVES(kWaves) \ __attribute__((amdgpu_num_vgpr(MFS_VGPR))) void MFS_KNAME( \ const uint8_t* __restrict__ a, const float* __restrict__ as, \ - const int32_t* __restrict__ sorted, const int32_t* __restrict__ off, \ - const uint8_t* __restrict__ w, const float* __restrict__ ws, \ - const uint8_t* __restrict__ w_odd, const float* __restrict__ w_ws, \ - float* __restrict__ y, int T, int N, int K, int a_ld, int w_ld, int y_ld, \ - int n_expert, int top_k, int grid_rows) \ + const int32_t* __restrict__ sorted, const int32_t* __restrict__ off, R3dMoeTabs tw, \ + uint16_t* __restrict__ y, int T, int N, int K, int a_ld, int as_ld, int y_ld, \ + int n_expert, int top_k, int a_sorted) \ { \ constexpr int kMBlock = 16; \ constexpr int kRB = 1; \ @@ -116,7 +115,7 @@ __attribute__((amdgpu_num_vgpr(MFS_VGPR))) void MFS_KNAME( if (tid < kMBlock) { \ const uint32_t i = r0 + tid; \ const int32_t f = (i < (uint32_t)T) ? sorted[i] : -1; \ - s_tok[tid] = (f < 0) ? -1 : (f / top_k); \ + s_tok[tid] = (f < 0) ? -1 : (a_sorted ? (int32_t)i : f / top_k); \ } \ if (tid == 0) { \ int nruns = 0, i = (int)r0; \ @@ -143,12 +142,12 @@ __attribute__((amdgpu_num_vgpr(MFS_VGPR))) void MFS_KNAME( _Pragma("unroll") \ for (int g = 0; g < 8; ++g) acc[rb][g] = 0.f; \ if (e >= 0) { \ - /* Expert e's plane: even e in w / ws, odd e in w_odd / w_ws, at index e/2. */ \ - const int e2 = e >> 1; \ - const uint8_t* wbase = (e & 1) ? w_odd + (size_t)e2 * (size_t)N * w_ld \ - : w + (size_t)e2 * (size_t)N * w_ld; \ - const float* wsb = (e & 1) ? w_ws + (size_t)e2 * (size_t)(N / grid_rows) * ((K + 127) / 128) \ - : ws + (size_t)e2 * (size_t)(N / grid_rows) * ((K + 127) / 128); \ + /* Expert e's entry: e/2 of class e%2's tables. */ \ + const int cls = e & 1, e2 = e >> 1; \ + const uint8_t* wbase = r3d_tab_at(tw.w[cls], e2); \ + const int w_ld = tw.w[cls].ld; \ + const float* wsb = (const float*)r3d_tab_at(tw.s[cls], e2); \ + const int ws_ld = tw.s[cls].ld; \ \ \ const int ntile = (K + kKT - 1) / kKT; \ @@ -169,8 +168,8 @@ __attribute__((amdgpu_num_vgpr(MFS_VGPR))) void MFS_KNAME( s_w[(size_t)col * kP16 + k] = s_tbl[wbase[(size_t)nn * w_ld + kt + k]]; \ } \ group_barrier(); \ - /* The activation scale for this tile (per row) and the weight scale (per grid_rows cols). */ \ - const float wscale = wsb[(size_t)(n_real / grid_rows) * ((K + 127) / 128) + t]; \ + /* The activation scale for this tile (per row) and the weight scale (per 128x128 tile). */ \ + const float wscale = wsb[(size_t)(n_real / 128) * ws_ld + t]; \ /* Eight 16-wide f16 WMMA steps; f16 values read directly from LDS. The fragment */ \ /* elements are f16 BIT PATTERNS, so the LDS halfs must be bit-cast into the */ \ /* _Float16 vector: any assignment from a uint16_t source into a _Float16 (a plain */ \ @@ -204,21 +203,21 @@ __attribute__((amdgpu_num_vgpr(MFS_VGPR))) void MFS_KNAME( const int row = rb * 16 + g * 2 + (int)(lane >> 4); \ const int src = (rs <= (int)(r0 + row) && (int)(r0 + row) < re) \ ? s_tok[row] : s_tok[rs - (int)r0]; \ - const float ascale = (src < 0) ? 0.f : as[(size_t)src * ((K + 127) / 128) + t] * wscale; \ + const float ascale = (src < 0) ? 0.f : as[(size_t)src * as_ld + t] * wscale; \ acc[rb][g] += r3d_moe_acc_f16_read(blk, g) * ascale; \ } \ } \ group_barrier(); \ } \ } \ - /* Store only the run's rows (f32: the moe_gemm_q contract's output). */ \ + /* Store only the run's rows and the real columns, as bf16. */ \ _Pragma("unroll") \ for (int rb = 0; rb < kRB; ++rb) \ _Pragma("unroll") \ for (int g = 0; g < 8; ++g) { \ const int m = (int)r0 + rb * 16 + g * 2 + (int)(lane >> 4); \ - if (m < re && m >= rs) \ - y[(size_t)m * y_ld + nc] = acc[rb][g]; \ + if (m < re && m >= rs && nc < (uint32_t)N) \ + y[(size_t)m * y_ld + nc] = f32_to_bf16(acc[rb][g]); \ } \ } \ } @@ -246,93 +245,42 @@ R3D_MFS_BODY } // namespace -static int r3d_moe_gemm_fp8_f32scale_v(long a, long as, long sorted, long off, long w, long ws, - long w_odd, long w_ws, long y, - int T, int N, int K, int a_ld, int w_ld, int y_ld, - int n_expert, int top_k, int grid_rows, int vgpr, int acc, - long stream) -{ - if (!a || !as || !sorted || !off || !w || !ws || !w_odd || !w_ws || !y) return -1; - if (T < 1 || N < 1 || K < 1 || grid_rows < 1) return -2; - if (!a_ld) a_ld = K; - if (!w_ld) w_ld = K; - if (!y_ld) y_ld = N; - if (K % kKT) return -2; - const int ntiles = (N + kNBlock - 1) / kNBlock; - const int mrowblk = (T + 16 - 1) / 16; - const dim3 grid(ntiles, mrowblk), block(kThreads); - if (vgpr == 128) { - if (acc) - R3D_KLAUNCH(moe_fp8_f32scale_kernel16_c128_a1, grid, block, (hipStream_t)stream, - (const uint8_t*)a, (const float*)as, (const int32_t*)sorted, - (const int32_t*)off, (const uint8_t*)w, (const float*)ws, - (const uint8_t*)w_odd, (const float*)w_ws, (float*)y, - T, N, K, a_ld, w_ld, y_ld, n_expert, top_k, grid_rows); - else - R3D_KLAUNCH(moe_fp8_f32scale_kernel16_c128, grid, block, (hipStream_t)stream, - (const uint8_t*)a, (const float*)as, (const int32_t*)sorted, - (const int32_t*)off, (const uint8_t*)w, (const float*)ws, - (const uint8_t*)w_odd, (const float*)w_ws, (float*)y, - T, N, K, a_ld, w_ld, y_ld, n_expert, top_k, grid_rows); - } - else { - if (acc) - R3D_KLAUNCH(moe_fp8_f32scale_kernel16_a1, grid, block, (hipStream_t)stream, - (const uint8_t*)a, (const float*)as, (const int32_t*)sorted, - (const int32_t*)off, (const uint8_t*)w, (const float*)ws, - (const uint8_t*)w_odd, (const float*)w_ws, (float*)y, - T, N, K, a_ld, w_ld, y_ld, n_expert, top_k, grid_rows); - else - R3D_KLAUNCH(moe_fp8_f32scale_kernel16, grid, block, (hipStream_t)stream, - (const uint8_t*)a, (const float*)as, (const int32_t*)sorted, - (const int32_t*)off, (const uint8_t*)w, (const float*)ws, - (const uint8_t*)w_odd, (const float*)w_ws, (float*)y, - T, N, K, a_ld, w_ld, y_ld, n_expert, top_k, grid_rows); - } - return hipGetLastError() == hipSuccess ? 0 : -4; -} - -/* The direct launcher: the tune's default budget (128, the 8-wave cap). */ -extern "C" int r3d_moe_gemm_fp8_f32scale(long a, long as, long sorted, long off, long w, long ws, - long w_odd, long w_ws, long y, - int T, int N, int K, int a_ld, int w_ld, int y_ld, - int n_expert, int top_k, int grid_rows, long stream) -{ - return r3d_moe_gemm_fp8_f32scale_v(a, as, sorted, off, w, ws, w_odd, w_ws, y, T, N, K, a_ld, - w_ld, y_ld, n_expert, top_k, grid_rows, 128, 0, stream); -} - -/* The RadArgs dispatch: the row's entry. The tensors are a, a_scale, sorted_tok, expert_offset, - * w, w_scale, w_odd, w_odd_scale, y (the moe_gemm_q contract: even experts in w / w_scale, odd in - * w_odd / w_odd_scale, at index e/2; y is f32). The params are n_expert, top_k, grid_rows. */ +/* The RadArgs dispatch, moe_gemm_q's arm 2 (r3d_moe_gemm_q.hip): the contract's operands + * (r3d_moe_tab.h) at fp8a8f32, the tune's register budget and accumulator. */ extern "C" int r3d_moe_gemm_fp8_f32scale_run(const RadArgs* a, RadStream s, int vgpr, int acc) { - if (!a || a->n_t < 9) return R3D_NO(RAD_E_INVAL); - const RadTensor* at = &a->t[0], *ast = &a->t[1], *st = &a->t[2], *ot = &a->t[3]; - const RadTensor* wt = &a->t[4], *wst = &a->t[5], *wot = &a->t[6], *wost = &a->t[7]; - const RadTensor* yt = &a->t[8]; - if (!r3d_p(at) || !r3d_p(ast) || !r3d_p(st) || !r3d_p(ot) || - !r3d_p(wt) || !r3d_p(wst) || !r3d_p(wot) || !r3d_p(wost) || !r3d_wp(yt)) - return R3D_NO(RAD_E_INVAL); - long long M = 0, K = 0; - if (r3d_rows_of(at, &M, &K) != 0) return R3D_NO(RAD_E_INVAL); - const long long T = (st->rank >= 1) ? st->shape[0] : 0; - const long long N = (wt->rank >= 3) ? wt->shape[1] : 0; // the plane is [n_expert/2, N, K] - const int n_expert = (int)r3d_geti_or(a, "n_expert", 1); - const int top_k = (int)r3d_geti_or(a, "top_k", 1); - const int grid_rows = (int)r3d_geti_or(a, "grid_rows", 1); // 1 (per col) or 128 (per 128) - if (M <= 0 || T <= 0 || N <= 0 || K <= 0 || K % 128 || n_expert <= 0 || top_k <= 0) - return R3D_NO(RAD_E_SHAPE); - const int a_ld = (int)at->stride[0]; - const int w_ld = (int)wt->shape[2]; - const int y_ld = (int)yt->stride[0]; - return r3d_moe_gemm_fp8_f32scale_v((long)(uintptr_t)r3d_p(at), (long)(uintptr_t)r3d_p(ast), - (long)(uintptr_t)r3d_p(st), (long)(uintptr_t)r3d_p(ot), - (long)(uintptr_t)r3d_p(wt), (long)(uintptr_t)r3d_p(wst), - (long)(uintptr_t)r3d_p(wot), (long)(uintptr_t)r3d_p(wost), - (long)(uintptr_t)r3d_wp(yt), (int)T, (int)N, (int)K, a_ld, - w_ld, y_ld, n_expert, top_k, grid_rows, vgpr, acc, - (long)(uintptr_t)s); + R3dMoeCall c; + int rc = r3d_moe_call(a, true, &c); + if (rc != RAD_OK) return rc; + if (!c.a_scale) return R3D_NO(RAD_E_INVAL); + if (c.a->dtype != RAD_F8E4M3 || c.a_scale->dtype != RAD_F32 || c.y->dtype != RAD_BF16) + return R3D_NO(RAD_E_DTYPE); + if (c.K % kKT) return R3D_NO(RAD_E_SHAPE); + R3dMoeTabs tw; + rc = r3d_moe_q_tabs(c, RAD_F8E4M3, 8, RAD_F32, 32, (c.N + 127) / 128, c.K / 128, &tw); + if (rc != RAD_OK) return rc; + const int T = (int)c.T, N = (int)c.N, K = (int)c.K; + const int a_ld = (int)c.a->stride[0], as_ld = (int)c.a_scale->stride[0]; + const int y_ld = (int)c.y->stride[0]; + const uint8_t* pa = (const uint8_t*)r3d_p(c.a); + const float* pas = (const float*)r3d_p(c.a_scale); + const int32_t* ps = (const int32_t*)r3d_p(c.sorted); + const int32_t* po = (const int32_t*)r3d_p(c.off); + uint16_t* py = (uint16_t*)r3d_wp(c.y); + const dim3 grid((N + kNBlock - 1) / kNBlock, (T + 16 - 1) / 16), block(kThreads); +#define R3D_MFS_LAUNCH(KERN) \ + R3D_KLAUNCH(KERN, grid, block, (hipStream_t)s, pa, pas, ps, po, tw, py, T, N, K, a_ld, \ + as_ld, y_ld, (int)c.n_expert, (int)c.top_k, c.a_sorted) + if (vgpr == 128) { + if (acc) R3D_MFS_LAUNCH(moe_fp8_f32scale_kernel16_c128_a1); + else R3D_MFS_LAUNCH(moe_fp8_f32scale_kernel16_c128); + } + else { + if (acc) R3D_MFS_LAUNCH(moe_fp8_f32scale_kernel16_a1); + else R3D_MFS_LAUNCH(moe_fp8_f32scale_kernel16); + } +#undef R3D_MFS_LAUNCH + return (int)hipGetLastError(); } extern "C" int r3d_rad_moe_gemm_fp8_f32scale(const RadArgs* a, RadStream s) diff --git a/libr3d/r3d_moe_gemm_mxfp4a8.hip b/libr3d/r3d_moe_gemm_mxfp4a8.hip index 7ed37c82..3ee7f60c 100644 --- a/libr3d/r3d_moe_gemm_mxfp4a8.hip +++ b/libr3d/r3d_moe_gemm_mxfp4a8.hip @@ -9,8 +9,9 @@ * wave-matrix (f32 accumulate). Each 32-wide E8M0 scale folds into the f32 accumulator per group. * * One block per 16 expert-sorted rows, walking the runs (contiguous rows per expert) in its tile, - * the same run-walk / gather structure as moe_gemm_q. The even experts are `w` / `w_scale`, the - * odd `w_odd` / `w_odd_scale`, at index e/2. K is a multiple of 128; N a multiple of 16. + * the same run-walk / gather structure as moe_gemm_q. Expert e is entry e/2 of the even (`w` / + * `w_scale`) or odd (`w_odd` / `w_odd_scale`) weight tables (r3d_moe_tab.h). K is a multiple of + * 128; the N tail clamps. */ #include @@ -20,6 +21,7 @@ #include "r3d_codecs.h" #include "r3d_launch.h" #include "r3d_fp8_dequant.h" +#include "r3d_moe_tab.h" namespace { @@ -55,11 +57,9 @@ __device__ __forceinline__ _Float16 h16(uint32_t w) { return __builtin_bit_cast( __global__ __launch_bounds__(kThreads) R3D_WAVES(kWaves) void moe_mx_kernel( const uint8_t* __restrict__ a, const float* __restrict__ a_scale, - const int32_t* __restrict__ sorted, const int32_t* __restrict__ off, - const uint8_t* __restrict__ w, const uint8_t* __restrict__ w_scale, - const uint8_t* __restrict__ w_odd, const uint8_t* __restrict__ w_odd_scale, - uint16_t* __restrict__ y, int T, int N, int K, int a_ld, int w_ld_b, int y_ld, - int n_expert, int top_k, int grid_rows) + const int32_t* __restrict__ sorted, const int32_t* __restrict__ off, R3dMoeTabs tw, + uint16_t* __restrict__ y, int T, int N, int K, int a_ld, int as_ld, int y_ld, + int n_expert, int top_k, int a_sorted) { __shared__ __align__(16) uint32_t s_a[16 * kAPitch]; __shared__ __align__(16) uint32_t s_w[kNBlock * kWPitch]; @@ -79,11 +79,12 @@ __global__ __launch_bounds__(kThreads) R3D_WAVES(kWaves) void moe_mx_kernel( const uint32_t n0 = (uint32_t)blockIdx.x * kNBlock; const uint32_t r1 = (r0 + 16 < (uint32_t)T) ? r0 + 16 : (uint32_t)T; - // The block's rows' source tokens (the gather). -1 marks a dropped slot. + // The block's rows' source rows of `a` (the gather, or the row itself under a_order + // "sorted"). -1 marks a dropped slot. if (tid < 16) { const uint32_t i = r0 + tid; const int32_t f = (i < (uint32_t)T) ? sorted[i] : -1; - s_tok[tid] = (f < 0) ? -1 : (f / top_k); + s_tok[tid] = (f < 0) ? -1 : (a_sorted ? (int32_t)i : f / top_k); } // The runs in [r0, r1): each a contiguous set of rows for one expert. The block walks them. if (tid == 0) { @@ -109,11 +110,13 @@ __global__ __launch_bounds__(kThreads) R3D_WAVES(kWaves) void moe_mx_kernel( const int rs = s_rs[run], re = s_re[run], e = s_e[run]; v8float acc = v8float{ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f }; if (e >= 0) { - const int e2 = e >> 1; - const uint8_t* wbase = (e & 1) ? w_odd + (size_t)e2 * (size_t)N * w_ld_b - : w + (size_t)e2 * (size_t)N * w_ld_b; - const uint8_t* wsb = (e & 1) ? w_odd_scale + (size_t)e2 * (size_t)(N / grid_rows) * (K / 32) - : w_scale + (size_t)e2 * (size_t)(N / grid_rows) * (K / 32); + // Expert e is entry e/2 of class e%2's tables: E2M1 codes two a byte, one E8M0 exponent + // per (row, 32 of K). + const int cls = e & 1, e2 = e >> 1; + const uint8_t* wbase = r3d_tab_at(tw.w[cls], e2); + const int w_ld_b = tw.w[cls].ld / 2; + const uint8_t* wsb = r3d_tab_at(tw.s[cls], e2); + const int ws_ld = tw.s[cls].ld; for (int b = 0; b < K / kGroup; ++b) { const int kt = b * kGroup; @@ -138,7 +141,7 @@ __global__ __launch_bounds__(kThreads) R3D_WAVES(kWaves) void moe_mx_kernel( const uint32_t* ap = s_a + (size_t)r * kAPitch; const uint32_t* wp = s_w + (size_t)(wv * 16 + r) * kWPitch; // this wave's 16 cols // The weight scale for this lane's column, per 32-of-K group. - const int wn = (int)(n_real / grid_rows); + const int wn = n_real; #pragma unroll for (int g32 = 0; g32 < 4; ++g32) { v8float blk = v8float{ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f }; @@ -163,13 +166,13 @@ __global__ __launch_bounds__(kThreads) R3D_WAVES(kWaves) void moe_mx_kernel( } group_barrier(); // Fold the g32-group's scales: the weight E8M0 (per 32) and the activation f32 (per 128). - const float sw = e8m0_to_f32((uint32_t)wsb[(size_t)wn * (K / 32) + b * 4 + g32]); + const float sw = e8m0_to_f32((uint32_t)wsb[(size_t)wn * ws_ld + b * 4 + g32]); #pragma unroll for (int g = 0; g < 8; ++g) { const int row = (int)(g * 2 + (lane >> 4)); const int src = (rs <= (int)(r0 + row) && (int)(r0 + row) < re) ? s_tok[row] : s_tok[rs - (int)r0]; - const float sa = a_scale[(size_t)(src < 0 ? 0 : src) * (K / kGroup) + b]; + const float sa = a_scale[(size_t)(src < 0 ? 0 : src) * as_ld + b]; acc[g] += blk[g] * sa * sw; } } @@ -193,31 +196,25 @@ extern "C" { int r3d_rad_moe_gemm_mxfp4a8(const RadArgs* a, RadStream s) { - if (!a || a->n_t < 9) return R3D_NO(RAD_E_INVAL); - const RadTensor* at = r3d_opt(a, 0), *asc = r3d_opt(a, 1), *st = r3d_opt(a, 2), - *ot = r3d_opt(a, 3), *wt = r3d_opt(a, 4), *wsc = r3d_opt(a, 5), - *wot = r3d_opt(a, 6), *wosc = r3d_opt(a, 7), *yt = r3d_opt(a, 8); - if (!r3d_p(at) || !r3d_p(asc) || !r3d_p(st) || !r3d_p(ot) || !r3d_p(wt) || !r3d_p(wsc) || - !r3d_wp(yt)) - return R3D_NO(RAD_E_INVAL); - long long M = 0, K = 0; - if (r3d_rows_of(at, &M, &K) != 0) return R3D_NO(RAD_E_INVAL); - const long long T = (st->rank >= 1) ? st->shape[0] : 0; - const long long N = (wt->rank >= 3) ? wt->shape[1] : 0; - if (M <= 0 || T <= 0 || N <= 0 || K <= 0 || K % 128) return R3D_NO(RAD_E_SHAPE); // N tail clamps - const int n_expert = (int)r3d_geti_or(a, "n_expert", 1); - const int top_k = (int)r3d_geti_or(a, "top_k", 1); - const int grid_rows = (int)r3d_geti_or(a, "grid_rows", 128); - const int a_ld = (int)at->stride[0]; - const int w_ld_b = (int)wt->shape[2]; // the weight's K in bytes (K/2 for E2M1) - const int y_ld = (int)yt->stride[0]; + R3dMoeCall c; + int rc = r3d_moe_call(a, true, &c); + if (rc != RAD_OK) return rc; + if (!c.a_scale) return R3D_NO(RAD_E_INVAL); + if (c.a->dtype != RAD_F8E4M3 || c.a_scale->dtype != RAD_F32 || c.y->dtype != RAD_BF16) + return R3D_NO(RAD_E_DTYPE); + if (c.K % kGroup) return R3D_NO(RAD_E_SHAPE); // the N tail clamps + R3dMoeTabs tw; + rc = r3d_moe_q_tabs(c, RAD_FP4E2M1, 4, RAD_E8M0, 8, c.N, c.K / 32, &tw); + if (rc != RAD_OK) return rc; + if ((tw.w[0].ld | tw.w[1].ld) & 1) return R3D_NO(RAD_E_STRIDE); // whole bytes a row + const int a_ld = (int)c.a->stride[0], as_ld = (int)c.a_scale->stride[0]; + const int y_ld = (int)c.y->stride[0]; - dim3 grid((unsigned)((N + kNBlock - 1) / kNBlock), (unsigned)((T + 15) / 16)), blk(kThreads); + dim3 grid((unsigned)((c.N + kNBlock - 1) / kNBlock), (unsigned)((c.T + 15) / 16)), blk(kThreads); moe_mx_kernel<<>>( - (const uint8_t*)r3d_p(at), (const float*)r3d_p(asc), (const int32_t*)r3d_p(st), - (const int32_t*)r3d_p(ot), (const uint8_t*)r3d_p(wt), (const uint8_t*)r3d_p(wsc), - (const uint8_t*)r3d_p(wot), (const uint8_t*)r3d_p(wosc), (uint16_t*)r3d_wp(yt), - (int)T, (int)N, (int)K, a_ld, w_ld_b, y_ld, n_expert, top_k, grid_rows); + (const uint8_t*)r3d_p(c.a), (const float*)r3d_p(c.a_scale), (const int32_t*)r3d_p(c.sorted), + (const int32_t*)r3d_p(c.off), tw, (uint16_t*)r3d_wp(c.y), (int)c.T, (int)c.N, (int)c.K, + a_ld, as_ld, y_ld, (int)c.n_expert, (int)c.top_k, c.a_sorted); return (int)hipGetLastError(); } diff --git a/libr3d/r3d_moe_gemm_q.hip b/libr3d/r3d_moe_gemm_q.hip index f34bf1f9..dd923647 100644 --- a/libr3d/r3d_moe_gemm_q.hip +++ b/libr3d/r3d_moe_gemm_q.hip @@ -15,9 +15,9 @@ * run structure (the block walks the runs in its 16 rows, so a block spanning several experts * is correct). * - * * Phase 3: the even/odd expert split (expert e's weight is in `w` for even e, `w_odd` for odd - * e, at index e/2) and the dtype-selected scale grid (`grid_rows` = 1 for w4a8's per-row scale, - * 128 for fp8a8's per-128x128 tile). + * * Phase 3: the even/odd expert split (expert e's weight is entry e/2 of `w` for even e and of + * `w_odd` for odd e, each a weight table: r3d_moe_tab.h) and fp8a8f32's scale grid, one f32 + * per 128x128 tile of the weight. * * Verified against a CPU reference for runs of 1, 2, 4 and 16 rows, the even/odd split, and both * scale grids (maxrel ~1e-4, the f16 rounding floor). A row: `moe_gemm_q_e4m3` in r3d_rows.cpp, a @@ -29,7 +29,9 @@ #include "r3d_args.h" #include "r3d_common.h" #include "r3d_launch.h" +#include "r3d_codecs.h" #include "r3d_fp8_dequant.h" +#include "r3d_moe_tab.h" namespace { @@ -45,11 +47,9 @@ __device__ __forceinline__ _Float16 h16(uint32_t w) { return __builtin_bit_cast( template __global__ __launch_bounds__(kThreads) R3D_WAVES(kWaves) void moe_q_kernel( const uint8_t* __restrict__ a, const float* __restrict__ a_scale, - const int32_t* __restrict__ sorted, const int32_t* __restrict__ off, - const uint8_t* __restrict__ w, const float* __restrict__ w_scale, - const uint8_t* __restrict__ w_odd, const float* __restrict__ w_odd_scale, - float* __restrict__ y, int T, int N, int K, int a_ld, int w_ld_b, int y_ld, - int n_expert, int top_k, int grid_rows) + const int32_t* __restrict__ sorted, const int32_t* __restrict__ off, R3dMoeTabs tw, + uint16_t* __restrict__ y, int T, int N, int K, int a_ld, int as_ld, int y_ld, + int n_expert, int top_k, int a_sorted) { __shared__ __align__(16) uint32_t s_a[16 * kPitch]; __shared__ __align__(16) uint32_t s_w[kNBlock * kPitch]; @@ -69,11 +69,12 @@ __global__ __launch_bounds__(kThreads) R3D_WAVES(kWaves) void moe_q_kernel( const uint32_t n0 = (uint32_t)blockIdx.x * kNBlock; const uint32_t r1 = (r0 + 16 < (uint32_t)T) ? r0 + 16 : (uint32_t)T; - // The block's rows' source tokens (the gather). -1 marks a dropped slot. + // The block's rows' source rows of `a` (the gather, or the row itself under a_order + // "sorted"). -1 marks a dropped slot. if (tid < 16) { const uint32_t i = r0 + tid; const int32_t f = (i < (uint32_t)T) ? sorted[i] : -1; - s_tok[tid] = (f < 0) ? -1 : (f / top_k); + s_tok[tid] = (f < 0) ? -1 : (a_sorted ? (int32_t)i : f / top_k); } // The runs in [r0, r1): each a contiguous set of rows for one expert. The block walks them. if (tid == 0) { @@ -95,16 +96,16 @@ __global__ __launch_bounds__(kThreads) R3D_WAVES(kWaves) void moe_q_kernel( // One GEMM per run: the run's rows read the gathered activation and expert e's weight. Rows the // run does not own are padding (reading the run's first row) and their output is dropped. Expert - // e's weight is in `w` (even e) or `w_odd` (odd e) at index e/2. + // e's weight is entry e/2 of class e%2's tables. for (int run = 0; run < nruns; ++run) { const int rs = s_rs[run], re = s_re[run], e = s_e[run]; v8float acc = v8float{ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f }; if (e >= 0) { - const int e2 = e >> 1; - const uint8_t* wbase = (e & 1) ? w_odd + (size_t)e2 * (size_t)N * w_ld_b - : w + (size_t)e2 * (size_t)N * w_ld_b; - const float* wsb = (e & 1) ? w_odd_scale + (size_t)e2 * (size_t)(N / grid_rows) * (K / kGroup) - : w_scale + (size_t)e2 * (size_t)(N / grid_rows) * (K / kGroup); + const int cls = e & 1, e2 = e >> 1; + const uint8_t* wbase = r3d_tab_at(tw.w[cls], e2); + const int w_ld_b = tw.w[cls].ld; + const float* wsb = (const float*)r3d_tab_at(tw.s[cls], e2); + const int ws_ld = tw.s[cls].ld; for (int b = 0; b < K / kGroup; ++b) { const int kt = b * kGroup; @@ -148,14 +149,14 @@ __global__ __launch_bounds__(kThreads) R3D_WAVES(kWaves) void moe_q_kernel( group_barrier(); // Fold the g-block's scales. acc[g] is at row g*2 + lane/16 (varies with g), column r. - // The weight scale is per (grid_rows columns, 128 of K). - const float sw = wsb[(size_t)(n_real / grid_rows) * (K / kGroup) + b]; + // The weight scale is per 128x128 tile. + const float sw = wsb[(size_t)(n_real / kGroup) * ws_ld + b]; #pragma unroll for (int g = 0; g < 8; ++g) { const int row = (int)(g * 2 + (lane >> 4)); const int src = (rs <= (int)(r0 + row) && (int)(r0 + row) < re) ? s_tok[row] : s_tok[rs - (int)r0]; - const float sa = a_scale[(size_t)(src < 0 ? 0 : src) * (K / kGroup) + b]; + const float sa = a_scale[(size_t)(src < 0 ? 0 : src) * as_ld + b]; acc[g] += blk[g] * sa * sw; } } @@ -166,7 +167,7 @@ __global__ __launch_bounds__(kThreads) R3D_WAVES(kWaves) void moe_q_kernel( for (int g = 0; g < 8; ++g) { const int row = (int)(g * 2 + (lane >> 4)); const int m = (int)(r0 + row); - if (rs <= m && m < re && nc < (uint32_t)N) y[(size_t)m * y_ld + nc] = acc[g]; + if (rs <= m && m < re && nc < (uint32_t)N) y[(size_t)m * y_ld + nc] = f32_to_bf16(acc[g]); } } } @@ -177,50 +178,49 @@ extern "C" { static int r3d_moe_gemm_q_dispatch(const RadArgs* a, RadStream s, int alu) { - if (!a || a->n_t < 9) return R3D_NO(RAD_E_INVAL); - const RadTensor* at = r3d_opt(a, 0), *asc = r3d_opt(a, 1), *st = r3d_opt(a, 2), - *ot = r3d_opt(a, 3), *wt = r3d_opt(a, 4), *wsc = r3d_opt(a, 5), - *wot = r3d_opt(a, 6), *wosc = r3d_opt(a, 7), *yt = r3d_opt(a, 8); - if (!r3d_p(at) || !r3d_p(asc) || !r3d_p(st) || !r3d_p(ot) || !r3d_p(wt) || !r3d_p(wsc) || - !r3d_wp(yt)) - return R3D_NO(RAD_E_INVAL); - long long M = 0, K = 0; - if (r3d_rows_of(at, &M, &K) != 0) return R3D_NO(RAD_E_INVAL); - const long long T = (st->rank >= 1) ? st->shape[0] : 0; - const long long N = (wt->rank >= 3) ? wt->shape[1] : 0; - if (M <= 0 || T <= 0 || N <= 0 || K <= 0 || K % 128) return R3D_NO(RAD_E_SHAPE); // N tail clamps - const int n_expert = (int)r3d_geti_or(a, "n_expert", 1); - const int top_k = (int)r3d_geti_or(a, "top_k", 1); - const int grid_rows = (int)r3d_geti_or(a, "grid_rows", 1); // 1 (w4a8) or 128 (fp8a8) - const int a_ld = (int)at->stride[0]; - const int w_ld_b = (int)wt->shape[2]; // the weight's K in bytes - const int y_ld = (int)yt->stride[0]; + R3dMoeCall c; + int rc = r3d_moe_call(a, true, &c); + if (rc != RAD_OK) return rc; + if (!c.a_scale) return R3D_NO(RAD_E_INVAL); + if (c.a->dtype != RAD_F8E4M3 || c.a_scale->dtype != RAD_F32 || c.y->dtype != RAD_BF16) + return R3D_NO(RAD_E_DTYPE); + if (c.K % kGroup) return R3D_NO(RAD_E_SHAPE); // the N tail clamps + R3dMoeTabs tw; + rc = r3d_moe_q_tabs(c, RAD_F8E4M3, 8, RAD_F32, 32, (c.N + kGroup - 1) / kGroup, c.K / kGroup, + &tw); + if (rc != RAD_OK) return rc; + const int a_ld = (int)c.a->stride[0], as_ld = (int)c.a_scale->stride[0]; + const int y_ld = (int)c.y->stride[0]; - dim3 grid((unsigned)((N + kNBlock - 1) / kNBlock), (unsigned)((T + 15) / 16)), blk(kThreads); - const uint8_t* pa = (const uint8_t*)r3d_p(at); - const float* psa = (const float*)r3d_p(asc); - const int32_t* ps = (const int32_t*)r3d_p(st); - const int32_t* po = (const int32_t*)r3d_p(ot); - const uint8_t* pw = (const uint8_t*)r3d_p(wt); - const float* pws = (const float*)r3d_p(wsc); - const uint8_t* pwo = (const uint8_t*)r3d_p(wot); - const float* pwos = (const float*)r3d_p(wosc); - float* py = (float*)r3d_wp(yt); + dim3 grid((unsigned)((c.N + kNBlock - 1) / kNBlock), (unsigned)((c.T + 15) / 16)), blk(kThreads); + const uint8_t* pa = (const uint8_t*)r3d_p(c.a); + const float* psa = (const float*)r3d_p(c.a_scale); + const int32_t* ps = (const int32_t*)r3d_p(c.sorted); + const int32_t* po = (const int32_t*)r3d_p(c.off); + uint16_t* py = (uint16_t*)r3d_wp(c.y); if (alu) - moe_q_kernel<1><<>>(pa, psa, ps, po, pw, pws, pwo, pwos, py, - (int)T, (int)N, (int)K, a_ld, w_ld_b, y_ld, - n_expert, top_k, grid_rows); + moe_q_kernel<1><<>>(pa, psa, ps, po, tw, py, (int)c.T, (int)c.N, + (int)c.K, a_ld, as_ld, y_ld, + (int)c.n_expert, (int)c.top_k, + c.a_sorted); else - moe_q_kernel<0><<>>(pa, psa, ps, po, pw, pws, pwo, pwos, py, - (int)T, (int)N, (int)K, a_ld, w_ld_b, y_ld, - n_expert, top_k, grid_rows); + moe_q_kernel<0><<>>(pa, psa, ps, po, tw, py, (int)c.T, (int)c.N, + (int)c.K, a_ld, as_ld, y_ld, + (int)c.n_expert, (int)c.top_k, + c.a_sorted); return (int)hipGetLastError(); } -/* The two rows share the dispatch: the table decode (ALU=0) and the ALU decode (ALU=1). The tune - * picks the faster per geometry. */ +/* The row's entry: the tune's `impl` arm picks the kernel -- 0 the table decode, 1 the ALU decode, + * 2 the 16x128 block (r3d_moe_gemm_fp8_f32scale.hip) at the tune's register budget and + * accumulator. */ extern "C" int r3d_rad_moe_gemm_q(const RadArgs* a, RadStream s) -{ return r3d_moe_gemm_q_dispatch(a, s, 0); } +{ + R3dMoeQCfg cfg; + r3d_cfg_moe_q(a, &cfg); + if (cfg.impl == 2) return r3d_moe_gemm_fp8_f32scale_run(a, s, cfg.vgpr, cfg.acc); + return r3d_moe_gemm_q_dispatch(a, s, cfg.impl == 1); +} extern "C" int r3d_rad_moe_gemm_q_alu(const RadArgs* a, RadStream s) { return r3d_moe_gemm_q_dispatch(a, s, 1); } diff --git a/libr3d/r3d_moe_gemm_q_mod4.hip b/libr3d/r3d_moe_gemm_q_mod4.hip new file mode 100644 index 00000000..c77e3455 --- /dev/null +++ b/libr3d/r3d_moe_gemm_q_mod4.hip @@ -0,0 +1,256 @@ +/* r3d_moe_gemm_q_mod4.hip -- moe_gemm_q_mod4: the grouped quantised GEMM with 4 expert classes. + * + * Same as r3d_moe_gemm_q.hip but experts route to 4 classes (e%4) instead of 2 (e%2). + * Each class has its own weight table and scale table. + */ +#include + +#include "r3d.h" +#include "r3d_args.h" +#include "r3d_common.h" +#include "r3d_launch.h" +#include "r3d_codecs.h" +#include "r3d_fp8_dequant.h" +#include "r3d_moe_tab.h" + +namespace { + +constexpr int kThreads = 256; +constexpr int kWaves = kThreads / kWave; +constexpr int kNBlock = 128; +constexpr int kGroup = 128; +constexpr int kPitch = 33; + +__device__ __forceinline__ _Float16 h16(uint32_t w) { return __builtin_bit_cast(_Float16, (uint16_t)w); } + +/* Use two 2-class tabs: tw01 for classes 0-1, tw23 for classes 2-3 */ + +template +__global__ __launch_bounds__(WV * kWave) R3D_WAVES(WV) void moe_q_mod4_kernel( + const uint8_t* __restrict__ a, const float* __restrict__ a_scale, + const int32_t* __restrict__ sorted, const int32_t* __restrict__ off, + R3dTab w0, R3dTab w1, R3dTab w2, R3dTab w3, + R3dTab s0, R3dTab s1, R3dTab s2, R3dTab s3, + uint16_t* __restrict__ y, int T, int N, int K, int a_ld, int as_ld, int y_ld, + int n_expert, int top_k, int a_sorted) +{ + __shared__ __align__(16) uint32_t s_a[MR * kPitch]; + __shared__ __align__(16) uint32_t s_w[(WV * 16) * kPitch]; + __shared__ __align__(16) uint16_t s_tbl[R3D_E4M3_TBL]; + __shared__ int32_t s_tok[MR]; + __shared__ int32_t s_nruns; + __shared__ int32_t s_rs[MR], s_re[MR], s_e[MR]; + + const uint32_t tid = threadIdx.x; + const uint32_t lane = tid & (kWave - 1); + const uint32_t wv = tid / kWave; + const uint32_t r = lane & 15; + + if (!ALU) r3d_e4m3_f16_init(s_tbl, (int)tid, WV * kWave); + + const uint32_t r0 = (uint32_t)blockIdx.y * MR; + const uint32_t n0 = (uint32_t)blockIdx.x * (WV * 16); + const uint32_t r1 = (r0 + MR < (uint32_t)T) ? r0 + MR : (uint32_t)T; + + if (tid < 16) { + const uint32_t i = r0 + tid; + const int32_t f = (i < (uint32_t)T) ? sorted[i] : -1; + s_tok[tid] = (f < 0) ? -1 : (a_sorted ? (int32_t)i : f / top_k); + } + if (tid == 0) { + int nruns = 0, i = (int)r0; + while (i < (int)r1) { + int32_t ee = -1; + for (int32_t x = 0; x < n_expert; ++x) if (off[x] <= i && i < off[x + 1]) ee = x; + const int re = (ee < 0) ? (int)r1 : (int)(off[ee + 1] < r1 ? off[ee + 1] : r1); + s_rs[nruns] = i; s_re[nruns] = re; s_e[nruns] = ee; + ++nruns; i = re; + } + s_nruns = nruns; + } + group_barrier(); + const int nruns = s_nruns; + + const uint32_t nc = n0 + wv * 16 + r; + const int n_real = (int)(nc < (uint32_t)N ? nc : (uint32_t)N - 1); + + for (int run = 0; run < nruns; ++run) { + const int rs = s_rs[run], re = s_re[run], e = s_e[run]; + v8float acc = v8float{ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f }; + if (e >= 0) { + /* 4-class routing: expert e is entry e/4 of class e%4 */ + const int cls = e & 3, e4 = e >> 2; + const R3dTab* wtab = (cls == 0) ? &w0 : (cls == 1) ? &w1 : (cls == 2) ? &w2 : &w3; + const R3dTab* stab = (cls == 0) ? &s0 : (cls == 1) ? &s1 : (cls == 2) ? &s2 : &s3; + const uint8_t* wbase = r3d_tab_at(*wtab, e4); + const int w_ld_b = wtab->ld; + const float* wsb = (const float*)r3d_tab_at(*stab, e4); + const int ws_ld = stab->ld; + + for (int b = 0; b < K / kGroup; ++b) { + const int kt = b * kGroup; + + for (int i = (int)tid; i < MR * (kGroup / 4); i += (WV * kWave)) { + const int row = i / (kGroup / 4), d = i % (kGroup / 4); + const int src = (rs <= (int)(r0 + row) && (int)(r0 + row) < re) ? s_tok[row] + : s_tok[rs - (int)r0]; + const int rr = (src < 0) ? 0 : src; + s_a[(size_t)row * kPitch + d] = *(const uint32_t*)(a + (size_t)rr * a_ld + kt + 4 * d); + } + for (int i = (int)tid; i < (WV * 16) * (kGroup / 4); i += (WV * kWave)) { + const int col = i / (kGroup / 4), d = i % (kGroup / 4); + const int nn = (int)(n0 + col < (uint32_t)N ? n0 + col : (uint32_t)N - 1); + s_w[(size_t)col * kPitch + d] = + *(const uint32_t*)(wbase + (size_t)nn * w_ld_b + kt + 4 * d); + } + group_barrier(); + + const uint32_t* ap = s_a + (size_t)r * kPitch; + const uint32_t* wp = s_w + (size_t)(wv * 16 + r) * kPitch; + v8float blk = v8float{ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f }; +#pragma unroll + for (int k = 0; k < kGroup; k += 16) { + uint32_t ain[4], af[8], bin[4], bf[8]; +#pragma unroll + for (int g = 0; g < 4; ++g) ain[g] = ap[k / 4 + g]; + r3d_e4m3x16_decode(s_tbl, ain, af); +#pragma unroll + for (int g = 0; g < 4; ++g) bin[g] = wp[k / 4 + g]; + r3d_e4m3x16_decode(s_tbl, bin, bf); + v16half fa, fb; +#pragma unroll + for (int g = 0; g < 8; ++g) { fa[2 * g] = h16(af[g] & 0xffffu); fa[2 * g + 1] = h16(af[g] >> 16); } +#pragma unroll + for (int g = 0; g < 8; ++g) { fb[2 * g] = h16(bf[g] & 0xffffu); fb[2 * g + 1] = h16(bf[g] >> 16); } + blk = wmma_f16(fa, fb, blk); + } + group_barrier(); + + const float sw = wsb[(size_t)(n_real / kGroup) * ws_ld + b]; +#pragma unroll + for (int g = 0; g < 8; ++g) { + const int row = (int)(g * 2 + (lane >> 4)); + const int src = (rs <= (int)(r0 + row) && (int)(r0 + row) < re) ? s_tok[row] + : s_tok[rs - (int)r0]; + const float sa = a_scale[(size_t)(src < 0 ? 0 : src) * as_ld + b]; + acc[g] += blk[g] * sa * sw; + } + } + + } +#pragma unroll + for (int g = 0; g < 8; ++g) { + const int row = (int)(g * 2 + (lane >> 4)); + const int m = (int)(r0 + row); + if (rs <= m && m < re && nc < (uint32_t)N) y[(size_t)m * y_ld + nc] = f32_to_bf16(acc[g]); + } + } +} + +} // namespace + +extern "C" { + +extern "C" int r3d_rad_moe_gemm_q_mod4(const RadArgs* a, RadStream s) +{ + /* 13 operands: a, a_scale, w, w_scale, sorted_tok, expert_offset, w_1, w_1_scale, + * w_2, w_2_scale, w_3, w_3_scale, y */ + enum { O_A = 0, O_AS, O_W0, O_W0S, O_SORTED, O_OFF, O_W1, O_W1S, + O_W2, O_W2S, O_W3, O_W3S, O_Y }; + const RadTensor* Aq = r3d_opt(a, O_A); + const RadTensor* As = r3d_opt(a, O_AS); + const RadTensor* W0 = r3d_opt(a, O_W0); + const RadTensor* W0S = r3d_opt(a, O_W0S); + const RadTensor* sorted = r3d_opt(a, O_SORTED); + const RadTensor* off = r3d_opt(a, O_OFF); + const RadTensor* W1 = r3d_opt(a, O_W1); + const RadTensor* W1S = r3d_opt(a, O_W1S); + const RadTensor* W2 = r3d_opt(a, O_W2); + const RadTensor* W2S = r3d_opt(a, O_W2S); + const RadTensor* W3 = r3d_opt(a, O_W3); + const RadTensor* W3S = r3d_opt(a, O_W3S); + const RadTensor* Y = r3d_opt(a, O_Y); + if (!Aq || !As || !sorted || !off || !Y) return R3D_NO(RAD_E_INVAL); + if (!W0 || !W0S || !W1 || !W1S || !W2 || !W2S || !W3 || !W3S) return R3D_NO(RAD_E_INVAL); + if (!Aq->data || !As->data || !sorted->data || !off->data || !Y->data) + return R3D_NO(RAD_E_INVAL); + + const long long N = r3d_geti_or(a, "N", 0); + const long long K = r3d_geti_or(a, "K", 0); + const long long n_expert = r3d_geti_or(a, "n_expert", 0); + const long long top_k = r3d_geti_or(a, "top_k", 0); + const long long group = r3d_geti_or(a, "group", 0); + if (N <= 0 || K <= 0 || n_expert <= 0 || top_k <= 0) return R3D_NO(RAD_E_SHAPE); + if (group != kGroup) return R3D_NO(RAD_E_SHAPE); + if (K % kGroup) return R3D_NO(RAD_E_SHAPE); + + /* The class shapes default to class 0's; this kernel reads one N and one K for all four, so + * an unequal class is refused, not approximated (as moe_gemm_q does with N_odd / K_odd). */ + static const char* const kNk[3][2] = { { "N_1", "K_1" }, { "N_2", "K_2" }, { "N_3", "K_3" } }; + for (int q = 0; q < 3; ++q) + if (r3d_geti_or(a, kNk[q][0], N) != N || r3d_geti_or(a, kNk[q][1], K) != K) + return R3D_NO(RAD_E_UNSUPPORTED); + const long long parts = r3d_geti_or(a, "parts", 1); + if (parts < 1 || N % parts) return R3D_NO(RAD_E_SHAPE); + + /* "token" (the default, gate_up): sorted row i reads a[sorted_tok[i] / top_k]. "sorted" (the + * down projection): a already has one row per (token, slot) in the scatter's order. */ + const char* ord = r3d_gets(a, "a_order"); + const int a_sorted = ord && std::strcmp(ord, "sorted") == 0; + if (ord && !a_sorted && std::strcmp(ord, "token") != 0) return R3D_NO(RAD_E_UNSUPPORTED); + + if (Aq->dtype != RAD_F8E4M3 || As->dtype != RAD_F32 || Y->dtype != RAD_BF16) + return R3D_NO(RAD_E_DTYPE); + if (sorted->dtype != RAD_I32 || off->dtype != RAD_I32) return R3D_NO(RAD_E_DTYPE); + + /* The activation's row count is checked, not inferred: a short operand means the caller + * passed the gate_up projection's buffer to the down projection. */ + long long T = 0, yc = 0; + if (r3d_rows_of(Y, &T, &yc) != RAD_OK || yc < N) return R3D_NO(RAD_E_SHAPE); + long long ar = 0, ak = 0; + if (r3d_rows_of(Aq, &ar, &ak) != RAD_OK || ak < K) return R3D_NO(RAD_E_SHAPE); + if (ar < (a_sorted ? T : T / top_k)) return R3D_NO(RAD_E_SHAPE); + if (r3d_numel(sorted) < T || r3d_numel(off) < n_expert + 1) return R3D_NO(RAD_E_SHAPE); + + const int a_ld = (Aq->rank >= 2) ? (int)Aq->stride[0] : (int)K; + const int as_ld = (As->rank >= 2) ? (int)As->stride[0] : (int)(K / kGroup); + const int y_ld = (Y->rank >= 2) ? (int)Y->stride[0] : (int)N; + + /* Build 8 individual tabs */ + R3dTab w0, w1, w2, w3, s0, s1, s2, s3; + const RadTensor* wts[4] = { W0, W1, W2, W3 }; + const RadTensor* wss[4] = { W0S, W1S, W2S, W3S }; + R3dTab* wtabs[4] = { &w0, &w1, &w2, &w3 }; + R3dTab* stabsg[4] = { &s0, &s1, &s2, &s3 }; + for (int q = 0; q < 4; ++q) { + int rc_w = r3d_tab_of(wts[q], RAD_F8E4M3, 8, n_expert / 4, N, K, wtabs[q]); + if (rc_w != RAD_OK) return rc_w; + int rc_s = r3d_tab_of(wss[q], RAD_F32, 32, n_expert / 4, (N + kGroup - 1) / kGroup, K / kGroup, + stabsg[q]); + if (rc_s != RAD_OK) return rc_s; + } + + + const uint8_t* pa = (const uint8_t*)r3d_p(Aq); + const float* psa = (const float*)r3d_p(As); + const int32_t* ps = (const int32_t*)r3d_p(sorted); + const int32_t* po = (const int32_t*)r3d_p(off); + uint16_t* py = (uint16_t*)r3d_wp(Y); + + const int mrows = r3d_geti_or(a, "mrows", 16); + const int wv = r3d_geti_or(a, "wv", 8); + const int ctile = wv * 16; + dim3 grid((unsigned)((N + ctile - 1) / ctile), (unsigned)((T + mrows - 1) / mrows)), blk(wv * kWave); + if (mrows == 8 && wv == 4) + moe_q_mod4_kernel<0,8,4><<>>(pa, psa, ps, po, w0, w1, w2, w3, s0, s1, s2, s3, py, (int)T, (int)N, (int)K, a_ld, as_ld, y_ld, (int)n_expert, (int)top_k, a_sorted); + else if (mrows == 8) + moe_q_mod4_kernel<0,8,8><<>>(pa, psa, ps, po, w0, w1, w2, w3, s0, s1, s2, s3, py, (int)T, (int)N, (int)K, a_ld, as_ld, y_ld, (int)n_expert, (int)top_k, a_sorted); + else if (wv == 4) + moe_q_mod4_kernel<0,16,4><<>>(pa, psa, ps, po, w0, w1, w2, w3, s0, s1, s2, s3, py, (int)T, (int)N, (int)K, a_ld, as_ld, y_ld, (int)n_expert, (int)top_k, a_sorted); + else + moe_q_mod4_kernel<0,16,8><<>>(pa, psa, ps, po, w0, w1, w2, w3, s0, s1, s2, s3, py, (int)T, (int)N, (int)K, a_ld, as_ld, y_ld, (int)n_expert, (int)top_k, a_sorted); + int hrc = (int)hipGetLastError(); + return hrc; +} + +} // extern "C" diff --git a/libr3d/r3d_moe_gemm_w4a4.hip b/libr3d/r3d_moe_gemm_w4a4.hip new file mode 100644 index 00000000..baf2cc09 --- /dev/null +++ b/libr3d/r3d_moe_gemm_w4a4.hip @@ -0,0 +1,225 @@ +/* r3d_moe_gemm_w4a4.hip -- moe_gemm_w4a4: the grouped int4xint4 GEMM over the expert-sorted rows. + * + * y[T,N] = a[sorted_tok[i] / top_k, :] @ w[e(i)]^T, with a per-(row, 128-of-K) scale fold. + * + * Both the activation and the experts are two's-complement int4 (nibbles, -8..7) packed two per + * byte. The activation has one f32 scale per (row, 128 of K); each expert has one bf16 scale per + * (row, 128 of K); the output is bf16 in sorted order. The routed rows are in SORTED order (one row + * per (token, expert slot)); row i reads its activation from `a[sorted_tok[i] / top_k]` (or a[i] + * under a_order "sorted") and its weight from expert e(i)'s table (the parity tables, r3d_moe_tab.h). + * + * The kernel widens both the int4 activation and the int4 weight to int8 and runs the native int8 + * wave-matrix (v_wmma_i32_16x16x16_iu8, exact i32 accumulate): no f16 rounding anywhere in the + * chain. Each 128-wide block of K is accumulated raw, then folded by (sub * scale_a[src][b]) * + * scale_w[e][n][b] in f32 -- the exact order the libref reference runs, so it agrees bit for bit. + * + * Decode band: at most 16 sorted rows per block (M * top_k <= 16); prefill finds no row and falls + * back. The activation stride a_ld is in BYTES (K/2 per row: stride[0] is K int4 nibbles). + */ +#include + +#include "r3d.h" +#include "r3d_args.h" +#include "r3d_common.h" +#include "r3d_launch.h" +#include "r3d_codecs.h" +#include "r3d_moe_tab.h" + +namespace { + +constexpr int kThreads = 256; // eight waves +constexpr int kWaves = kThreads / kWave; +constexpr int kGroup = 128; // a scale block: one k tile, eight wmma steps +constexpr int kPitch = 33; // dwords a staged row: 33 mod 32 = 1, bank-free + +__device__ __forceinline__ int32_t nib_i8(uint32_t nib) +{ + return (nib & 8u) ? (int32_t)nib - 16 : (int32_t)(nib & 7u); +} + +__device__ __forceinline__ float bf16_f32(uint16_t h) { return __builtin_bit_cast(float, uint32_t(h) << 16); } + +// The block's rows' source tokens + the expert runs. `a_sorted` selects the gather (token: sorted +// row i reads a[sorted[i]/top_k]; sorted: a[i]). -1 marks a dropped slot. +__device__ __forceinline__ void moe_w4a4_setup( + const int32_t* __restrict__ sorted, const int32_t* __restrict__ off, uint32_t r0, uint32_t r1, + uint32_t tid, int T, int n_expert, int top_k, int a_sorted, int32_t* s_tok, int32_t* s_nruns, + int32_t* s_rs, int32_t* s_re, int32_t* s_e) +{ + if (tid < 16) { + const uint32_t i = r0 + tid; + const int32_t f = (i < (uint32_t)T) ? sorted[i] : -1; + s_tok[tid] = (f < 0) ? -1 : (a_sorted ? (int32_t)i : f / top_k); + } + if (tid == 0) { + int nruns = 0, i = (int)r0; + while (i < (int)r1) { + int32_t ee = -1; + for (int32_t x = 0; x < n_expert; ++x) if (off[x] <= i && i < off[x + 1]) ee = x; + const int re = (ee < 0) ? (int)r1 : (int)(off[ee + 1] < r1 ? off[ee + 1] : r1); + s_rs[nruns] = i; s_re[nruns] = re; s_e[nruns] = ee; + ++nruns; i = re; + } + *s_nruns = nruns; + } + group_barrier(); +} + +/* ------------------------------------------------------- int4-activation arm (i32 wave-matrix) */ + +template +__global__ __launch_bounds__(WV * kWave) R3D_WAVES(WV) void moe_w4a4_i8_kernel( + const uint8_t* __restrict__ a, const float* __restrict__ a_scale, + const int32_t* __restrict__ sorted, const int32_t* __restrict__ off, R3dMoeTabs tw, + uint16_t* __restrict__ y, int T, int N, int K, int a_ld, int as_ld, int y_ld, + int n_expert, int top_k, int a_sorted) +{ + __shared__ __align__(16) uint32_t s_a[MR * kPitch]; + __shared__ int32_t s_tok[MR]; + __shared__ int32_t s_nruns; + __shared__ int32_t s_rs[MR], s_re[MR], s_e[MR]; + + const uint32_t tid = threadIdx.x; + const uint32_t lane = tid & (kWave - 1); + const uint32_t wave = tid / kWave; + const uint32_t r = lane & 15; + + const uint32_t r0 = (uint32_t)blockIdx.y * MR; + const uint32_t ncol = ((uint32_t)blockIdx.x * WV + wave) * 16; // the wave's 16 columns + const uint32_t r1 = (r0 + MR < (uint32_t)T) ? r0 + MR : (uint32_t)T; + + moe_w4a4_setup(sorted, off, r0, r1, tid, T, n_expert, top_k, a_sorted, s_tok, &s_nruns, s_rs, + s_re, s_e); + const int nruns = s_nruns; + + const uint32_t nc = ncol + r; + const int n_real = (int)(nc < (uint32_t)N ? nc : (uint32_t)N - 1); + + for (int run = 0; run < nruns; ++run) { + const int rs = s_rs[run], re = s_re[run], e = s_e[run]; + v8float acc = v8float{ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f }; + if (e >= 0) { + const int cls = e & 1, e2 = e >> 1; + const uint8_t* wrow = r3d_tab_at(tw.w[cls], e2) + (size_t)n_real * tw.w[cls].ld / 2; + const uint16_t* wsb = (const uint16_t*)r3d_tab_at(tw.s[cls], e2); + const int ws_ld = tw.s[cls].ld; + + for (int b = 0; b < K / kGroup; ++b) { + const int kt = b * kGroup; + + // Stage 16 rows x 128 i4 (as 128 i8) of the gathered activation. Each iteration reads + // 2 bytes = 4 nibbles and widens them to 4 int8 (one dword), so dword d holds i8 [4d..4d+3] + // and the wave-matrix A-fragment's k/4 indexing lands on the right dword; padding rows read + // the run's first. + for (int i = (int)tid; i < MR * (kGroup / 4); i += (WV * kWave)) { + const int row = i / (kGroup / 4), d = i % (kGroup / 4); + const int src = (rs <= (int)(r0 + row) && (int)(r0 + row) < re) ? s_tok[row] + : s_tok[rs - (int)r0]; + const int rr = (src < 0) ? 0 : src; + const uint32_t w = *(const uint16_t*)(a + (size_t)rr * a_ld + (kt + 4 * d) / 2); + int32_t v[4]; +#pragma unroll + for (int j = 0; j < 4; ++j) { + const uint32_t byte = (w >> (8 * (j / 2))) & 0xFFu; + v[j] = nib_i8((j & 1) ? (byte >> 4) : (byte & 0xFu)); + } + s_a[(size_t)row * kPitch + d] = (uint32_t)(v[0] & 0xFF) | (uint32_t)(v[1] & 0xFF) << 8 | + (uint32_t)(v[2] & 0xFF) << 16 | (uint32_t)(v[3] & 0xFF) << 24; + } + group_barrier(); + const uint32_t* ap = s_a + (size_t)r * kPitch; + v8int sub = v8int{ 0, 0, 0, 0, 0, 0, 0, 0 }; +#pragma unroll + for (int k = 0; k < kGroup; k += 16) { + const r3d_u32x4 aq = *(const r3d_u32x4*)(ap + k / 4); + const uint2 wp = *(const uint2*)(wrow + (kt + k) / 2); // 8 bytes = 16 nibbles + int32_t v[16]; +#pragma unroll + for (int j = 0; j < 16; ++j) { + const int byt = j / 2; + const bool high = (j & 1); + const uint32_t byte = (byt < 4) ? ((wp.x >> (8 * byt)) & 0xFFu) + : ((wp.y >> (8 * (byt - 4))) & 0xFFu); + v[j] = nib_i8(high ? (byte >> 4) : (byte & 0xFu)); + } + v4int bf{ (int)((uint32_t)(v[0] & 0xFF) | (uint32_t)(v[1] & 0xFF) << 8 | + (uint32_t)(v[2] & 0xFF) << 16 | (uint32_t)(v[3] & 0xFF) << 24), + (int)((uint32_t)(v[4] & 0xFF) | (uint32_t)(v[5] & 0xFF) << 8 | + (uint32_t)(v[6] & 0xFF) << 16 | (uint32_t)(v[7] & 0xFF) << 24), + (int)((uint32_t)(v[8] & 0xFF) | (uint32_t)(v[9] & 0xFF) << 8 | + (uint32_t)(v[10] & 0xFF) << 16 | (uint32_t)(v[11] & 0xFF) << 24), + (int)((uint32_t)(v[12] & 0xFF) | (uint32_t)(v[13] & 0xFF) << 8 | + (uint32_t)(v[14] & 0xFF) << 16 | (uint32_t)(v[15] & 0xFF) << 24) }; + sub = wmma_i8(v4int{ (int)aq.x, (int)aq.y, (int)aq.z, (int)aq.w }, bf, sub); + } + + // Fold the 128-block's scales: (sub * scale_a[src][b]) * scale_w[e][n][b], libref's order. + const float sw = bf16_f32(wsb[(size_t)n_real * ws_ld + b]); +#pragma unroll + for (int g2 = 0; g2 < 8; ++g2) { + const int row = (int)(g2 * 2 + (lane >> 4)); + const int src = (rs <= (int)(r0 + row) && (int)(r0 + row) < re) ? s_tok[row] + : s_tok[rs - (int)r0]; + const float sa = a_scale[(size_t)(src < 0 ? 0 : src) * as_ld + b]; + acc[g2] += (float)sub[g2] * sa * sw; + } + group_barrier(); + } + + } + // Store only the run's rows. +#pragma unroll + for (int g2 = 0; g2 < 8; ++g2) { + const int row = (int)(g2 * 2 + (lane >> 4)); + const int m = (int)(r0 + row); + if (rs <= m && m < re && nc < (uint32_t)N) y[(size_t)m * y_ld + nc] = f32_to_bf16(acc[g2]); + } + } +} + +} // namespace + +extern "C" { + +/* moe_gemm_w4a4: the grouped int4xint4 GEMM. The activation and the experts are both two's- + * complement int4; the exact i32 wave-matrix widens both to int8. The weight scale is bf16 and the + * output bf16. */ +int r3d_rad_moe_gemm_w4a4(const RadArgs* a, RadStream s) +{ + R3dMoeCall c; + int rc = r3d_moe_call(a, true, &c); + if (rc != RAD_OK) return rc; + if (!c.a_scale) return R3D_NO(RAD_E_INVAL); + if (c.a->dtype != RAD_I4) return R3D_NO(RAD_E_DTYPE); + if (c.a_scale->dtype != RAD_F32 || c.y->dtype != RAD_BF16) return R3D_NO(RAD_E_DTYPE); + if (c.K % kGroup) return R3D_NO(RAD_E_SHAPE); // the N tail clamps + + R3dMoeTabs tw; + rc = r3d_moe_q_tabs(c, RAD_I4, 4, RAD_BF16, 16, c.N, c.K / kGroup, &tw); + if (rc != RAD_OK) return rc; + /* Strides are in elements (abi/rad_types.h): an int4 row of K nibbles is K/2 bytes. */ + const int a_ld = (int)c.a->stride[0] / 2, as_ld = (int)c.a_scale->stride[0]; + const int y_ld = (int)c.y->stride[0]; + + const int mrows = r3d_geti_or(a, "mrows", 16); + const int wv = r3d_geti_or(a, "wv", 8); + const int ctile = wv * 16; + dim3 grid((unsigned)((c.N + ctile - 1) / ctile), (unsigned)((c.T + mrows - 1) / mrows)), blk(wv * kWave); + const int32_t* ps = (const int32_t*)r3d_p(c.sorted); + const int32_t* po = (const int32_t*)r3d_p(c.off); + const float* psa = (const float*)r3d_p(c.a_scale); + uint16_t* py = (uint16_t*)r3d_wp(c.y); + const uint8_t* pa = (const uint8_t*)r3d_p(c.a); + if (mrows == 8 && wv == 4) + moe_w4a4_i8_kernel<8,4><<>>(pa, psa, ps, po, tw, py, (int)c.T, (int)c.N, (int)c.K, a_ld, as_ld, y_ld, (int)c.n_expert, (int)c.top_k, c.a_sorted); + else if (mrows == 8) + moe_w4a4_i8_kernel<8,8><<>>(pa, psa, ps, po, tw, py, (int)c.T, (int)c.N, (int)c.K, a_ld, as_ld, y_ld, (int)c.n_expert, (int)c.top_k, c.a_sorted); + else if (wv == 4) + moe_w4a4_i8_kernel<16,4><<>>(pa, psa, ps, po, tw, py, (int)c.T, (int)c.N, (int)c.K, a_ld, as_ld, y_ld, (int)c.n_expert, (int)c.top_k, c.a_sorted); + else + moe_w4a4_i8_kernel<16,8><<>>(pa, psa, ps, po, tw, py, (int)c.T, (int)c.N, (int)c.K, a_ld, as_ld, y_ld, (int)c.n_expert, (int)c.top_k, c.a_sorted); + return (int)hipGetLastError(); +} + + +} // extern "C" diff --git a/libr3d/r3d_moe_gemm_w4a8.hip b/libr3d/r3d_moe_gemm_w4a8.hip index 26cd2706..c8a9a568 100644 --- a/libr3d/r3d_moe_gemm_w4a8.hip +++ b/libr3d/r3d_moe_gemm_w4a8.hip @@ -1,27 +1,28 @@ -/* r3d_moe_gemm_w4a8.hip -- moe_gemm_w4a8 (Phase 2: the GEMM core + the gather + per-expert weights). +/* r3d_moe_gemm_w4a8.hip -- moe_gemm_q dtype w4a8: the grouped int4 GEMM over the expert-sorted rows. * - * y[T,N] = a[gather(row), :] @ w[e(row), :]^T, with a per-(row, 128-of-K) scale fold. + * y[T,N] = a[sorted_tok[i] / top_k, :] @ w[e(i)]^T, with a per-(row, 128-of-K) scale fold. * * The routed rows are in SORTED order (one row per (token, expert slot)); row i reads its - * activation from `a[sorted[i] / top_k]` and its weight from expert e(i)'s table, where e(i) is the - * expert owning sorted row i (the one whose [off, off') span contains i). `a` is int8 with one f32 - * scale per (row, 128 of K); each expert's weight is a 4-bit two's-complement nibble (-8..7) packed - * two per byte, with one f32 scale per (row, 128 of K). RDNA3's native int8 wave-matrix - * (`v_wmma_i32_16x16x16_iu8`, exact i32 accumulate) takes the int4 weight widened to int8, so no f16 - * rounding. Each 128-wide block of K is accumulated raw in i32, then folded by - * scale_a[src][b] * scale_w[e][n][b]. + * activation from `a[sorted_tok[i] / top_k]` (or a[i] under a_order "sorted") and its weight from + * expert e(i)'s table, where e(i) is the expert owning sorted row i (the one whose [off, off') span + * contains i). The experts are weight tables (RAD_OPD_WTAB, r3d_moe_tab.h): the even experts in + * `w` / `w_scale`, the odd in `w_odd` / `w_odd_scale`, expert e at entry e/2 of class e%2, resolved + * on the device (a pointer array or a stacked plane). * - * STATUS: WIP. Phases 1-3 are verified bit-exact against a CPU reference (the i32 accumulate is - * exact, so the random cases are exact, not just within tolerance): - * * Phase 1: the GEMM core (int8 x widened-int4, the per-(row, 128-of-K) scale fold). - * * Phase 2: the gather (row i reads a[sorted[i]/top_k]) and the per-expert weight tables. - * * Phase 3: the run structure -- the block walks the runs in its 16 rows, so a block spanning - * several experts (short runs, decode) is correct. Verified for runs of 1, 2, 4 and 16 rows. + * The weight is two's-complement int4 (nibbles, -8..7) packed two per byte, with one bf16 scale per + * (row, 128 of K); the output is bf16 in sorted order. Two arms, picked by the activation dtype: + * * int8 a -> the native int8 wave-matrix (v_wmma_i32_16x16x16_iu8, exact i32 accumulate): the + * int4 weight is widened to int8, so no f16 rounding anywhere in the chain. + * * E4M3 a -> the f16 wave-matrix (v_wmma_f32_16x16x16_f16, f32 accumulate): the E4M3 activation + * and the int4 weight are decoded exactly to f16 (libr4d's w4a8 form). + * Each 128-wide block of K is accumulated raw, then folded by (sub * scale_a[src][b]) * + * scale_w[e][n][b] in f32 -- the exact order the libref reference runs, so the int8 arm agrees bit + * for bit. * - * The `w4a8` form (a two's-complement nibble, -8..7) is served. Remaining (Phase 4): the other - * weight forms (w4nl64a8h / w4nl32a8h / w5nl64a8h, whose nibbles decode through a magnitude table - * and a per-64/32 E4M3 scale), the prefill run map, and the SK/UW/RS optimisations. Not yet a row: - * no r3d_rows.cpp entry, no selftest. + * Decode band: at most 16 sorted rows per block (M * top_k <= 16); prefill finds no row and falls + * back. STATUS: the w4a8 form is served (both activation arms). Remaining: the codebook NL forms + * (w4nl64a8h / w4nl32a8h / w5nl64a8h, magnitude-table decode), a prefill path above 16 sorted rows, + * and the SK/UW/RS tuning. */ #include @@ -29,13 +30,16 @@ #include "r3d_args.h" #include "r3d_common.h" #include "r3d_launch.h" +#include "r3d_codecs.h" +#include "r3d_fp8_dequant.h" +#include "r3d_moe_tab.h" namespace { constexpr int kThreads = 256; // eight waves constexpr int kWaves = kThreads / kWave; constexpr int kGroup = 128; // a scale block: one k tile, eight wmma steps -constexpr int kPitch = 33; // dwords a staged a row: 33 mod 32 = 1, bank-free +constexpr int kPitch = 33; // dwords a staged row: 33 mod 32 = 1, bank-free __device__ __forceinline__ int32_t nib_i8(uint32_t nib) @@ -43,34 +47,23 @@ __device__ __forceinline__ int32_t nib_i8(uint32_t nib) return (nib & 8u) ? (int32_t)nib - 16 : (int32_t)(nib & 7u); } -__global__ __launch_bounds__(kThreads) R3D_WAVES(kWaves) void moe_w4a8_kernel( - const int8_t* __restrict__ a, const float* __restrict__ a_scale, - const int32_t* __restrict__ sorted, const int32_t* __restrict__ off, - const uint8_t* __restrict__ w, const float* __restrict__ w_scale, - float* __restrict__ y, int T, int N, int K, int a_ld, int w_ld_b, int y_ld, - int n_expert, int top_k) + +__device__ __forceinline__ float bf16_f32(uint16_t h) { return __builtin_bit_cast(float, uint32_t(h) << 16); } + +__device__ __forceinline__ _Float16 h16(uint32_t w) { return __builtin_bit_cast(_Float16, (uint16_t)w); } + +// The block's rows' source tokens + the expert runs, shared by both arms. `a_sorted` selects the +// gather (token: sorted row i reads a[sorted[i]/top_k]; sorted: a[i]). -1 marks a dropped slot. +__device__ __forceinline__ void moe_w4a8_setup( + const int32_t* __restrict__ sorted, const int32_t* __restrict__ off, uint32_t r0, uint32_t r1, + uint32_t tid, int T, int n_expert, int top_k, int a_sorted, int32_t* s_tok, int32_t* s_nruns, + int32_t* s_rs, int32_t* s_re, int32_t* s_e) { - __shared__ __align__(16) uint32_t s_a[16 * kPitch]; - __shared__ int32_t s_tok[16]; - __shared__ int32_t s_nruns; - __shared__ int32_t s_rs[16], s_re[16], s_e[16]; - - const uint32_t tid = threadIdx.x; - const uint32_t lane = tid & (kWave - 1); - const uint32_t wave = tid / kWave; - const uint32_t r = lane & 15; - - const uint32_t r0 = (uint32_t)blockIdx.y * 16; // the block's sorted rows - const uint32_t ncol = ((uint32_t)blockIdx.x * kWaves + wave) * 16; // the wave's 16 columns - const uint32_t r1 = (r0 + 16 < (uint32_t)T) ? r0 + 16 : (uint32_t)T; - - // The block's rows' source tokens, resolved once (the gather). -1 marks a dropped slot. if (tid < 16) { const uint32_t i = r0 + tid; const int32_t f = (i < (uint32_t)T) ? sorted[i] : -1; - s_tok[tid] = (f < 0) ? -1 : (f / top_k); + s_tok[tid] = (f < 0) ? -1 : (a_sorted ? (int32_t)i : f / top_k); } - // The runs in [r0, r1): each is a contiguous set of rows for one expert. The block walks them. if (tid == 0) { int nruns = 0, i = (int)r0; while (i < (int)r1) { @@ -80,31 +73,58 @@ __global__ __launch_bounds__(kThreads) R3D_WAVES(kWaves) void moe_w4a8_kernel( s_rs[nruns] = i; s_re[nruns] = re; s_e[nruns] = ee; ++nruns; i = re; } - s_nruns = nruns; + *s_nruns = nruns; } group_barrier(); +} + +/* ------------------------------------------------------------------ int8 arm (i32 wave-matrix) */ + +template +__global__ __launch_bounds__(WV * kWave) R3D_WAVES(WV) void moe_w4a8_i8_kernel( + const int8_t* __restrict__ a, const float* __restrict__ a_scale, + const int32_t* __restrict__ sorted, const int32_t* __restrict__ off, R3dMoeTabs tw, + uint16_t* __restrict__ y, int T, int N, int K, int a_ld, int as_ld, int y_ld, + int n_expert, int top_k, int a_sorted) +{ + __shared__ __align__(16) uint32_t s_a[MR * kPitch]; + __shared__ int32_t s_tok[MR]; + __shared__ int32_t s_nruns; + __shared__ int32_t s_rs[MR], s_re[MR], s_e[MR]; + + const uint32_t tid = threadIdx.x; + const uint32_t lane = tid & (kWave - 1); + const uint32_t wave = tid / kWave; + const uint32_t r = lane & 15; + + const uint32_t r0 = (uint32_t)blockIdx.y * MR; + const uint32_t ncol = ((uint32_t)blockIdx.x * WV + wave) * 16; // the wave's 16 columns + const uint32_t r1 = (r0 + MR < (uint32_t)T) ? r0 + MR : (uint32_t)T; + + moe_w4a8_setup(sorted, off, r0, r1, tid, T, n_expert, top_k, a_sorted, s_tok, &s_nruns, s_rs, + s_re, s_e); const int nruns = s_nruns; const uint32_t nc = ncol + r; const int n_real = (int)(nc < (uint32_t)N ? nc : (uint32_t)N - 1); - // One GEMM per run: the run's rows read the gathered activation and expert e's weight. Rows the - // run does not own are padding (they read the run's first row) and their output is dropped. for (int run = 0; run < nruns; ++run) { const int rs = s_rs[run], re = s_re[run], e = s_e[run]; v8float acc = v8float{ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f }; if (e >= 0) { - const uint8_t* wrow = w + (size_t)e * (size_t)N * w_ld_b + (size_t)n_real * w_ld_b; - const float* wsb = w_scale + (size_t)e * (size_t)N * (K / kGroup); + const int cls = e & 1, e2 = e >> 1; + const uint8_t* wrow = r3d_tab_at(tw.w[cls], e2) + (size_t)n_real * tw.w[cls].ld / 2; + const uint16_t* wsb = (const uint16_t*)r3d_tab_at(tw.s[cls], e2); + const int ws_ld = tw.s[cls].ld; for (int b = 0; b < K / kGroup; ++b) { const int kt = b * kGroup; // Stage 16 rows x 128 i8 of the gathered activation; padding rows read the run's first. - for (int i = (int)tid; i < 16 * (kGroup / 4); i += kThreads) { + for (int i = (int)tid; i < MR * (kGroup / 4); i += (WV * kWave)) { const int row = i / (kGroup / 4), d = i % (kGroup / 4); const int src = (rs <= (int)(r0 + row) && (int)(r0 + row) < re) ? s_tok[row] - : s_tok[rs - (int)r0]; + : s_tok[rs - (int)r0]; const int rr = (src < 0) ? 0 : src; s_a[(size_t)row * kPitch + d] = *(const uint32_t*)(a + (size_t)rr * a_ld + kt + 4 * d); } @@ -122,7 +142,7 @@ __global__ __launch_bounds__(kThreads) R3D_WAVES(kWaves) void moe_w4a8_kernel( const int byt = j / 2; const bool high = (j & 1); const uint32_t byte = (byt < 4) ? ((wp.x >> (8 * byt)) & 0xFFu) - : ((wp.y >> (8 * (byt - 4))) & 0xFFu); + : ((wp.y >> (8 * (byt - 4))) & 0xFFu); v[j] = nib_i8(high ? (byte >> 4) : (byte & 0xFu)); } v4int bf{ (int)((uint32_t)(v[0] & 0xFF) | (uint32_t)(v[1] & 0xFF) << 8 | @@ -136,14 +156,14 @@ __global__ __launch_bounds__(kThreads) R3D_WAVES(kWaves) void moe_w4a8_kernel( sub = wmma_i8(v4int{ (int)aq.x, (int)aq.y, (int)aq.z, (int)aq.w }, bf, sub); } - // Fold the 128-block's scales: scale_a[src][b] * scale_w[e][n][b]. - const float sw = wsb[(size_t)n_real * (K / kGroup) + b]; + // Fold the 128-block's scales: (sub * scale_a[src][b]) * scale_w[e][n][b], libref's order. + const float sw = bf16_f32(wsb[(size_t)n_real * ws_ld + b]); #pragma unroll for (int g2 = 0; g2 < 8; ++g2) { const int row = (int)(g2 * 2 + (lane >> 4)); const int src = (rs <= (int)(r0 + row) && (int)(r0 + row) < re) ? s_tok[row] - : s_tok[rs - (int)r0]; - const float sa = a_scale[(size_t)(src < 0 ? 0 : src) * (K / kGroup) + b]; + : s_tok[rs - (int)r0]; + const float sa = a_scale[(size_t)(src < 0 ? 0 : src) * as_ld + b]; acc[g2] += (float)sub[g2] * sa * sw; } group_barrier(); @@ -155,7 +175,123 @@ __global__ __launch_bounds__(kThreads) R3D_WAVES(kWaves) void moe_w4a8_kernel( for (int g2 = 0; g2 < 8; ++g2) { const int row = (int)(g2 * 2 + (lane >> 4)); const int m = (int)(r0 + row); - if (rs <= m && m < re && nc < (uint32_t)N) y[(size_t)m * y_ld + nc] = acc[g2]; + if (rs <= m && m < re && nc < (uint32_t)N) y[(size_t)m * y_ld + nc] = f32_to_bf16(acc[g2]); + } + } +} + +/* ------------------------------------------------------------- E4M3 arm (f16 wave-matrix) */ + +template +__global__ __launch_bounds__(WV * kWave) R3D_WAVES(WV) void moe_w4a8_e4m3_kernel( + const uint8_t* __restrict__ a, const float* __restrict__ a_scale, + const int32_t* __restrict__ sorted, const int32_t* __restrict__ off, R3dMoeTabs tw, + uint16_t* __restrict__ y, int T, int N, int K, int a_ld, int as_ld, int y_ld, + int n_expert, int top_k, int a_sorted) +{ + __shared__ __align__(16) uint32_t s_a[16 * kPitch]; + __shared__ __align__(16) uint32_t s_w[kWaves * 16 * kPitch]; // the block's 128 cols x 128 K + __shared__ __align__(16) uint16_t s_tbl[R3D_E4M3_TBL]; + __shared__ int32_t s_tok[16]; + __shared__ int32_t s_nruns; + __shared__ int32_t s_rs[16], s_re[16], s_e[16]; + + const uint32_t tid = threadIdx.x; + const uint32_t lane = tid & (kWave - 1); + const uint32_t wave = tid / kWave; + const uint32_t r = lane & 15; + + r3d_e4m3_f16_init(s_tbl, (int)tid, kThreads); + + const uint32_t r0 = (uint32_t)blockIdx.y * MR; + const uint32_t n0 = (uint32_t)blockIdx.x * kWaves * 16; + const uint32_t r1 = (r0 + MR < (uint32_t)T) ? r0 + MR : (uint32_t)T; + + moe_w4a8_setup(sorted, off, r0, r1, tid, T, n_expert, top_k, a_sorted, s_tok, &s_nruns, s_rs, + s_re, s_e); + const int nruns = s_nruns; + + const uint32_t nc = n0 + wave * 16 + r; // this wave's output column + const int n_real = (int)(nc < (uint32_t)N ? nc : (uint32_t)N - 1); + + for (int run = 0; run < nruns; ++run) { + const int rs = s_rs[run], re = s_re[run], e = s_e[run]; + v8float acc = v8float{ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f }; + if (e >= 0) { + const int cls = e & 1, e2 = e >> 1; + const uint8_t* wbase = r3d_tab_at(tw.w[cls], e2); + const int w_ld = tw.w[cls].ld; + const uint16_t* wsb = (const uint16_t*)r3d_tab_at(tw.s[cls], e2); + const int ws_ld = tw.s[cls].ld; + + for (int b = 0; b < K / kGroup; ++b) { + const int kt = b * kGroup; + + // Stage 16 rows x 128 E4M3 of the gathered activation; padding rows read the run's first. + for (int i = (int)tid; i < MR * (kGroup / 4); i += (WV * kWave)) { + const int row = i / (kGroup / 4), d = i % (kGroup / 4); + const int src = (rs <= (int)(r0 + row) && (int)(r0 + row) < re) ? s_tok[row] + : s_tok[rs - (int)r0]; + const int rr = (src < 0) ? 0 : src; + s_a[(size_t)row * kPitch + d] = *(const uint32_t*)(a + (size_t)rr * a_ld + kt + 4 * d); + } + // Stage the block's 128 cols x 128 K of the int4 weight (packed nibbles). + for (int i = (int)tid; i < kWaves * 16 * (kGroup / 8); i += (WV * kWave)) { + const int col = i / (kGroup / 8), d = i % (kGroup / 8); + const int nn = (int)(n0 + col < (uint32_t)N ? n0 + col : (uint32_t)N - 1); + s_w[(size_t)col * kPitch + d] = + *(const uint32_t*)(wbase + (size_t)nn * w_ld / 2 + kt / 2 + 4 * d); + } + group_barrier(); + + const uint32_t* ap = s_a + (size_t)r * kPitch; + const uint32_t* wp = s_w + (size_t)(wave * 16 + r) * kPitch; // this wave's 16 cols + v8float blk = v8float{ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f }; +#pragma unroll + for (int k = 0; k < kGroup; k += 16) { + uint32_t ain[4], af[8], bf[8]; +#pragma unroll + for (int g = 0; g < 4; ++g) ain[g] = ap[k / 4 + g]; + r3d_e4m3x16_decode<0>(s_tbl, ain, af); + // Decode the 16 packed int4 weights of this k tile to f16, two per word (as af[8]). + const uint2 wq = *(const uint2*)(wp + k / 8); // 8 bytes = 16 nibbles +#pragma unroll + for (int g = 0; g < 8; ++g) { + const uint32_t byte = (g < 4) ? ((wq.x >> (8 * g)) & 0xFFu) + : ((wq.y >> (8 * (g - 4))) & 0xFFu); + const _Float16 h0 = (_Float16)(float)nib_i8(byte & 0xFu); // weight 2g + const _Float16 h1 = (_Float16)(float)nib_i8((byte >> 4) & 0xFu); // weight 2g+1 + bf[g] = (uint32_t)__builtin_bit_cast(uint16_t, h0) + | ((uint32_t)__builtin_bit_cast(uint16_t, h1) << 16); + } + v16half fa, fb; +#pragma unroll + for (int g = 0; g < 8; ++g) { fa[2 * g] = h16(af[g] & 0xffffu); fa[2 * g + 1] = h16(af[g] >> 16); } +#pragma unroll + for (int g = 0; g < 8; ++g) { fb[2 * g] = h16(bf[g] & 0xffffu); fb[2 * g + 1] = h16(bf[g] >> 16); } + blk = wmma_f16(fa, fb, blk); + } + group_barrier(); + + // Fold the 128-block's scales: (sub * scale_a[src][b]) * scale_w[e][n][b], libref's order. + const float sw = bf16_f32(wsb[(size_t)n_real * ws_ld + b]); +#pragma unroll + for (int g = 0; g < 8; ++g) { + const int row = (int)(g * 2 + (lane >> 4)); + const int src = (rs <= (int)(r0 + row) && (int)(r0 + row) < re) ? s_tok[row] + : s_tok[rs - (int)r0]; + const float sa = a_scale[(size_t)(src < 0 ? 0 : src) * as_ld + b]; + acc[g] += blk[g] * sa * sw; + } + } + + } + // Store only the run's rows. +#pragma unroll + for (int g = 0; g < 8; ++g) { + const int row = (int)(g * 2 + (lane >> 4)); + const int m = (int)(r0 + row); + if (rs <= m && m < re && nc < (uint32_t)N) y[(size_t)m * y_ld + nc] = f32_to_bf16(acc[g]); } } } @@ -164,29 +300,55 @@ __global__ __launch_bounds__(kThreads) R3D_WAVES(kWaves) void moe_w4a8_kernel( extern "C" { +/* moe_gemm_q dtype w4a8: the grouped int4 GEMM. The arm is picked by the activation dtype (int8 -> + * the exact i32 wave-matrix; E4M3 -> the f16 wave-matrix, libr4d's form). The weight scale is bf16 + * and the output bf16 in both arms. */ int r3d_rad_moe_gemm_w4a8(const RadArgs* a, RadStream s) { - if (!a || a->n_t < 7) return R3D_NO(RAD_E_INVAL); - const RadTensor* at = r3d_opt(a, 0), *asc = r3d_opt(a, 1), *st = r3d_opt(a, 2), - *oft = r3d_opt(a, 3), *wt = r3d_opt(a, 4), *wsc = r3d_opt(a, 5), - *yt = r3d_opt(a, 6); - if (!r3d_p(at) || !r3d_p(asc) || !r3d_p(st) || !r3d_p(oft) || !r3d_p(wt) || !r3d_p(wsc) || - !r3d_wp(yt)) - return R3D_NO(RAD_E_INVAL); - const long long ne = r3d_geti_or(a, "n_expert", 0), tk = r3d_geti_or(a, "top_k", 0); - long long M = 0, K = 0, T = 0, N = 0; - if (r3d_rows_of(at, &M, &K) != 0) return R3D_NO(RAD_E_INVAL); - if (r3d_rows_of(yt, &T, &N) != 0) return R3D_NO(RAD_E_INVAL); - if (ne <= 0 || tk <= 0 || M <= 0 || N <= 0 || K <= 0 || K % 128) return R3D_NO(RAD_E_SHAPE); - const int a_ld = (int)(at->rank >= 2 ? at->shape[1] : at->stride[0]); - const int w_ld_b = (int)(wt->rank >= 3 ? wt->shape[2] : wt->stride[2]); // bytes/row = K/2 - const int y_ld = (int)(yt->rank >= 2 ? yt->shape[1] : yt->stride[0]); + R3dMoeCall c; + int rc = r3d_moe_call(a, true, &c); + if (rc != RAD_OK) return rc; + if (!c.a_scale) return R3D_NO(RAD_E_INVAL); + if (c.a->dtype != RAD_I8 && c.a->dtype != RAD_F8E4M3) return R3D_NO(RAD_E_DTYPE); + if (c.a_scale->dtype != RAD_F32 || c.y->dtype != RAD_BF16) return R3D_NO(RAD_E_DTYPE); + if (c.K % kGroup) return R3D_NO(RAD_E_SHAPE); // the N tail clamps - dim3 grid((unsigned)((N + 127) / 128), (unsigned)((T + 15) / 16)), blk(kThreads); - R3D_KLAUNCH(moe_w4a8_kernel, grid, blk, (hipStream_t)s, (const int8_t*)r3d_p(at), - (const float*)r3d_p(asc), (const int32_t*)r3d_p(st), (const int32_t*)r3d_p(oft), - (const uint8_t*)r3d_p(wt), (const float*)r3d_p(wsc), (float*)r3d_wp(yt), (int)T, - (int)N, (int)K, a_ld, w_ld_b, y_ld, (int)ne, (int)tk); + R3dMoeTabs tw; + rc = r3d_moe_q_tabs(c, RAD_I4, 4, RAD_BF16, 16, c.N, c.K / kGroup, &tw); + if (rc != RAD_OK) return rc; + const int a_ld = (int)c.a->stride[0], as_ld = (int)c.a_scale->stride[0]; + const int y_ld = (int)c.y->stride[0]; + + + const int32_t* ps = (const int32_t*)r3d_p(c.sorted); + const int32_t* po = (const int32_t*)r3d_p(c.off); + const float* psa = (const float*)r3d_p(c.a_scale); + uint16_t* py = (uint16_t*)r3d_wp(c.y); + const int mrows = r3d_geti_or(a, "mrows", 16); + const int wv = r3d_geti_or(a, "wv", 8); + const int ctile = wv * 16; + dim3 grid((unsigned)((c.N + ctile - 1) / ctile), (unsigned)((c.T + mrows - 1) / mrows)), blk(wv * kWave); + if (c.a->dtype == RAD_I8) { + const int8_t* pa8 = (const int8_t*)r3d_p(c.a); + if (mrows == 8 && wv == 4) + moe_w4a8_i8_kernel<8,4><<>>( pa8, psa, ps, po, tw, py, (int)c.T, (int)c.N, (int)c.K, a_ld, as_ld, y_ld, (int)c.n_expert, (int)c.top_k, c.a_sorted); + else if (mrows == 8) + moe_w4a8_i8_kernel<8,8><<>>( pa8, psa, ps, po, tw, py, (int)c.T, (int)c.N, (int)c.K, a_ld, as_ld, y_ld, (int)c.n_expert, (int)c.top_k, c.a_sorted); + else if (wv == 4) + moe_w4a8_i8_kernel<16,4><<>>( pa8, psa, ps, po, tw, py, (int)c.T, (int)c.N, (int)c.K, a_ld, as_ld, y_ld, (int)c.n_expert, (int)c.top_k, c.a_sorted); + else + moe_w4a8_i8_kernel<16,8><<>>( pa8, psa, ps, po, tw, py, (int)c.T, (int)c.N, (int)c.K, a_ld, as_ld, y_ld, (int)c.n_expert, (int)c.top_k, c.a_sorted); + } else { + const uint8_t* pa8 = (const uint8_t*)r3d_p(c.a); + if (mrows == 8 && wv == 4) + moe_w4a8_e4m3_kernel<8,4><<>>( pa8, psa, ps, po, tw, py, (int)c.T, (int)c.N, (int)c.K, a_ld, as_ld, y_ld, (int)c.n_expert, (int)c.top_k, c.a_sorted); + else if (mrows == 8) + moe_w4a8_e4m3_kernel<8,8><<>>( pa8, psa, ps, po, tw, py, (int)c.T, (int)c.N, (int)c.K, a_ld, as_ld, y_ld, (int)c.n_expert, (int)c.top_k, c.a_sorted); + else if (wv == 4) + moe_w4a8_e4m3_kernel<16,4><<>>( pa8, psa, ps, po, tw, py, (int)c.T, (int)c.N, (int)c.K, a_ld, as_ld, y_ld, (int)c.n_expert, (int)c.top_k, c.a_sorted); + else + moe_w4a8_e4m3_kernel<16,8><<>>( pa8, psa, ps, po, tw, py, (int)c.T, (int)c.N, (int)c.K, a_ld, as_ld, y_ld, (int)c.n_expert, (int)c.top_k, c.a_sorted); + } return (int)hipGetLastError(); } diff --git a/libr3d/r3d_moe_scatter.hip b/libr3d/r3d_moe_scatter.hip index 10283b0a..565aaf77 100644 --- a/libr3d/r3d_moe_scatter.hip +++ b/libr3d/r3d_moe_scatter.hip @@ -15,7 +15,11 @@ * butterfly (a DPP exchange inside the scan's tile loop miscompiles here). Each wave writes its * lane's count to LDS, barriers, and takes the serial prefix of its 32 lanes. * - * The general (three-pass) form for T > 1024 is not implemented here; the shim declines it. + * Above 1024 slots the sort is three passes (libhalo's general form): a histogram per 256-slot + * tile into the caller's scratch, a per-expert scan across the tiles, and the placement (an + * expert's offset, plus its count in earlier tiles, plus the slot's rank in its own tile). Stable + * too, so both forms give the same bytes. The scan's cross-expert prefix is a serial LDS loop, not + * a wave scan, for the same gfx1102 reason as above. */ #include @@ -142,29 +146,100 @@ __global__ __launch_bounds__(kScatWaves * kSortWave) void scatter_small_kernel( scatter_small_place(sorted, off, cnt, T, n_expert, sl, inv); } -} // namespace +/* ================================================================== the general form */ -extern "C" { +constexpr uint32_t kScatterTile = 256; -int r3d_rad_moe_scatter(const RadArgs* a, RadStream s) +/* Pass 1: each tile's count of every expert, bcnt[tile][expert]. */ +__global__ __launch_bounds__(kScatterTile) void scatter_hist_kernel( + const int32_t* __restrict__ ids, int32_t* __restrict__ bcnt, uint32_t T, uint32_t n_expert, + int32_t base, Protect prot) { + __shared__ int32_t s_h[kMaxExpert]; + const uint32_t tid = threadIdx.x, b = blockIdx.x; + for (uint32_t e = tid; e < n_expert; e += kScatterTile) s_h[e] = 0; + R3D_BARRIER(); + const uint32_t i = b * kScatterTile + tid; + if (i < T) { + const int32_t e = ids[i] - base; + if (e >= 0 && e < (int32_t)n_expert) atomicAdd(&s_h[sort_place(e, n_expert, prot)], 1); + } + R3D_BARRIER(); + for (uint32_t e = tid; e < n_expert; e += kScatterTile) + bcnt[(size_t)b * n_expert + e] = s_h[e]; +} + +/* Pass 2: per expert, the count in earlier tiles (bcnt rewritten in place to it) and the total; + * then the offsets, an exclusive prefix over the totals. */ +__global__ __launch_bounds__(kMaxExpert) void scatter_scan_kernel( + int32_t* __restrict__ bcnt, int32_t* __restrict__ off, int32_t* __restrict__ cnt, + uint32_t n_tile, uint32_t n_expert) { + __shared__ int32_t s_run[kMaxExpert]; + const uint32_t e = threadIdx.x; + int32_t run = 0; + if (e < n_expert) { + for (uint32_t b = 0; b < n_tile; ++b) { + const int32_t v = bcnt[(size_t)b * n_expert + e]; + bcnt[(size_t)b * n_expert + e] = run; + run += v; + } + cnt[e] = run; + } + s_run[e] = run; + R3D_BARRIER(); + if (e == 0) { + int32_t acc = 0; + for (uint32_t x = 0; x < n_expert; ++x) { off[x] = acc; acc += s_run[x]; } + off[n_expert] = acc; + } +} + +/* Pass 3: each routed slot at its expert's offset plus the expert's count in earlier tiles plus + * its rank in this tile. Sorted rows past the live count are -1; no placement lands there. INV + * also writes each slot's row, -1 when dropped. */ +template +__global__ __launch_bounds__(kScatterTile) void scatter_place_kernel( + const int32_t* __restrict__ ids, const int32_t* __restrict__ bcnt, + const int32_t* __restrict__ off, int32_t* __restrict__ sorted, + uint32_t T, uint32_t n_expert, int32_t base, Protect prot, int32_t* __restrict__ inv) { + __shared__ int32_t s_id[kScatterTile]; + const uint32_t tid = threadIdx.x, b = blockIdx.x; + const uint32_t i = b * kScatterTile + tid; + const int32_t l = (i < T) ? ids[i] - base : -1; + const int32_t e = (l >= 0 && l < (int32_t)n_expert) ? sort_place(l, n_expert, prot) : -1; + s_id[tid] = e; + const uint32_t live = (uint32_t)off[n_expert]; + if (i >= live && i < T) sorted[i] = -1; + R3D_BARRIER(); + if (INV && i < T && e < 0) inv[i] = -1; + if (i >= T || e < 0) return; + int32_t rank = 0; + for (uint32_t j = 0; j < tid; ++j) rank += (s_id[j] == e); + const int32_t at = off[e] + bcnt[(size_t)b * n_expert + e] + rank; + sorted[at] = (int32_t)i; + if (INV) inv[i] = at; +} + +/* Both entry points: the small form up to kScatterSmall slots, the three passes above it. */ +int scatter_body(const RadArgs* a, RadStream s, bool with_inv) { - if (!a || a->n_t < 4) return R3D_NO(RAD_E_INVAL); + if (!a || a->n_t < (with_inv ? 5 : 4)) return R3D_NO(RAD_E_INVAL); const RadTensor* ids = r3d_opt(a, 0), *sorted = r3d_opt(a, 1), *off = r3d_opt(a, 2), - *cnt = r3d_opt(a, 3); - if (!r3d_p(ids) || !r3d_wp(sorted) || !r3d_wp(off) || !r3d_wp(cnt)) + *cnt = r3d_opt(a, 3), *inv = with_inv ? r3d_opt(a, 4) : nullptr; + if (!r3d_p(ids) || !r3d_wp(sorted) || !r3d_wp(off) || !r3d_wp(cnt) || + (with_inv && !r3d_wp(inv))) return R3D_NO(RAD_E_INVAL); if (ids->dtype != RAD_I32 || sorted->dtype != RAD_I32 || off->dtype != RAD_I32 || - cnt->dtype != RAD_I32) + cnt->dtype != RAD_I32 || (inv && inv->dtype != RAD_I32)) return R3D_NO(RAD_E_DTYPE); - if (!r3d_contig(ids) || !r3d_contig(sorted) || !r3d_contig(off) || !r3d_contig(cnt)) + if (!r3d_contig(ids) || !r3d_contig(sorted) || !r3d_contig(off) || !r3d_contig(cnt) || + (inv && !r3d_contig(inv))) return R3D_NO(RAD_E_STRIDE); const long long n_expert = r3d_geti_or(a, "n_expert", 0); if (n_expert <= 0 || n_expert > (long long)kMaxExpert) return R3D_NO(RAD_E_SHAPE); const long long T = r3d_numel(ids); if (T <= 0) return R3D_NO(RAD_E_SHAPE); - if (T > (long long)kScatterSmall) return R3D_NO(RAD_E_SHAPE); // the small form only - if (r3d_numel(sorted) < T) return R3D_NO(RAD_E_SHAPE); + if (r3d_numel(sorted) < T || (inv && r3d_numel(inv) < T)) return R3D_NO(RAD_E_SHAPE); if (r3d_numel(off) < n_expert + 1 || r3d_numel(cnt) < n_expert) return R3D_NO(RAD_E_SHAPE); const long long base = r3d_geti_or(a, "expert_base", 0); @@ -192,65 +267,66 @@ int r3d_rad_moe_scatter(const RadArgs* a, RadStream s) int32_t* sp = (int32_t*)r3d_wp(sorted); int32_t* op = (int32_t*)r3d_wp(off); int32_t* cp = (int32_t*)r3d_wp(cnt); + int32_t* ip = inv ? (int32_t*)r3d_wp(inv) : nullptr; - R3D_KLAUNCH(scatter_small_kernel, dim3(1), dim3(kScatWaves * kSortWave), (hipStream_t)s, - idp, sp, op, cp, (uint32_t)T, (uint32_t)n_expert, (int32_t)base, prot, - (int32_t*)nullptr); + if (T <= (long long)kScatterSmall) { + if (ip) + R3D_KLAUNCH(scatter_small_kernel, dim3(1), dim3(kScatWaves * kSortWave), + (hipStream_t)s, idp, sp, op, cp, (uint32_t)T, (uint32_t)n_expert, + (int32_t)base, prot, ip); + else + R3D_KLAUNCH(scatter_small_kernel, dim3(1), dim3(kScatWaves * kSortWave), + (hipStream_t)s, idp, sp, op, cp, (uint32_t)T, (uint32_t)n_expert, + (int32_t)base, prot, ip); + return (int)hipGetLastError(); + } + + const long long n_tile = (T + kScatterTile - 1) / kScatterTile; + const long long need = n_tile * n_expert * (long long)sizeof(int32_t); + if (!a->scratch || a->scratch_bytes < need) return R3D_NO(RAD_E_SCRATCH); + int32_t* bcnt = (int32_t*)a->scratch; + R3D_KLAUNCH(scatter_hist_kernel, dim3((unsigned)n_tile), dim3(kScatterTile), (hipStream_t)s, + idp, bcnt, (uint32_t)T, (uint32_t)n_expert, (int32_t)base, prot); + R3D_KLAUNCH(scatter_scan_kernel, dim3(1), dim3(kMaxExpert), (hipStream_t)s, + bcnt, op, cp, (uint32_t)n_tile, (uint32_t)n_expert); + if (ip) + R3D_KLAUNCH(scatter_place_kernel, dim3((unsigned)n_tile), dim3(kScatterTile), + (hipStream_t)s, idp, bcnt, op, sp, (uint32_t)T, (uint32_t)n_expert, + (int32_t)base, prot, ip); + else + R3D_KLAUNCH(scatter_place_kernel, dim3((unsigned)n_tile), dim3(kScatterTile), + (hipStream_t)s, idp, bcnt, op, sp, (uint32_t)T, (uint32_t)n_expert, + (int32_t)base, prot, ip); return (int)hipGetLastError(); } +} // namespace + +extern "C" { + +int r3d_rad_moe_scatter(const RadArgs* a, RadStream s) +{ + return scatter_body(a, s, false); +} + /* moe_scatter_inv: the same sort, plus the inverse permutation (each slot's row in sorted_tok). */ int r3d_rad_moe_scatter_inv(const RadArgs* a, RadStream s) { - if (!a || a->n_t < 5) return R3D_NO(RAD_E_INVAL); - const RadTensor* ids = r3d_opt(a, 0), *sorted = r3d_opt(a, 1), *off = r3d_opt(a, 2), - *cnt = r3d_opt(a, 3), *inv = r3d_opt(a, 4); - if (!r3d_p(ids) || !r3d_wp(sorted) || !r3d_wp(off) || !r3d_wp(cnt) || !r3d_wp(inv)) - return R3D_NO(RAD_E_INVAL); - if (ids->dtype != RAD_I32 || sorted->dtype != RAD_I32 || off->dtype != RAD_I32 || - cnt->dtype != RAD_I32 || inv->dtype != RAD_I32) - return R3D_NO(RAD_E_DTYPE); - if (!r3d_contig(ids) || !r3d_contig(sorted) || !r3d_contig(off) || !r3d_contig(cnt) || - !r3d_contig(inv)) - return R3D_NO(RAD_E_STRIDE); + return scatter_body(a, s, true); +} +/* The three-pass form's per-tile counts, [n_tile, n_expert] i32; the small form needs none. */ +int64_t r3d_rad_moe_scatter_scratch(const RadArgs* a) +{ + if (!a) return 0; const long long n_expert = r3d_geti_or(a, "n_expert", 0); - if (n_expert <= 0 || n_expert > (long long)kMaxExpert) return R3D_NO(RAD_E_SHAPE); - const long long T = r3d_numel(ids); - if (T <= 0) return R3D_NO(RAD_E_SHAPE); - if (T > (long long)kScatterSmall) return R3D_NO(RAD_E_SHAPE); // the small form only - if (r3d_numel(sorted) < T || r3d_numel(inv) < T) return R3D_NO(RAD_E_SHAPE); - if (r3d_numel(off) < n_expert + 1 || r3d_numel(cnt) < n_expert) return R3D_NO(RAD_E_SHAPE); - - const long long base = r3d_geti_or(a, "expert_base", 0); - if (base < 0) return R3D_NO(RAD_E_SHAPE); - - Protect prot{}; - if (const char* str = r3d_gets(a, "protect")) { - const char* p = str; - long long prev = -1; - while (*p) { - char* end = nullptr; - const long long v = std::strtoll(p, &end, 10); - if (end == p || v <= prev || v >= n_expert || prot.n >= kMaxProtect) - return R3D_NO(RAD_E_SHAPE); - prot.e[prot.n++] = (uint16_t)v; - prev = v; - p = end; - if (*p == ',') ++p; - else if (*p) return R3D_NO(RAD_E_SHAPE); - } - } - - const int32_t* idp = (const int32_t*)r3d_p(ids); - int32_t* sp = (int32_t*)r3d_wp(sorted); - int32_t* op = (int32_t*)r3d_wp(off); - int32_t* cp = (int32_t*)r3d_wp(cnt); - int32_t* ip = (int32_t*)r3d_wp(inv); - - R3D_KLAUNCH(scatter_small_kernel, dim3(1), dim3(kScatWaves * kSortWave), (hipStream_t)s, - idp, sp, op, cp, (uint32_t)T, (uint32_t)n_expert, (int32_t)base, prot, ip); - return (int)hipGetLastError(); + /* Called at declare with the band's bound, when the ids may carry no data yet: then + * M x top_k. */ + const RadTensor* ids = r3d_opt(a, 0); + const long long T = ids ? r3d_numel(ids) : r3d_geti_or(a, "M", 0) * r3d_geti_or(a, "top_k", 1); + if (n_expert <= 0 || T <= (long long)kScatterSmall) return 0; + const long long n_tile = (T + kScatterTile - 1) / kScatterTile; + return n_tile * n_expert * (long long)sizeof(int32_t); } } // extern "C" diff --git a/libr3d/r3d_moe_tab.h b/libr3d/r3d_moe_tab.h new file mode 100644 index 00000000..950deb7f --- /dev/null +++ b/libr3d/r3d_moe_tab.h @@ -0,0 +1,132 @@ +/* r3d_moe_tab.h -- the grouped GEMMs' contract operands: weight tables, `a_order` and the classes. + * + * `moe_gemm` and `moe_gemm_q` take their experts as weight tables (RAD_OPD_WTAB, docs/OPS.md): + * a `[entries, rows, cols]` tensor whose data is a device array of one pointer per entry when + * stride[0] is 0 (each expert is its own movement unit, so the core hands a pointer each), or the + * base of a stacked plane with entries stride[0] elements apart. Both are read through + * r3d_tab_at, resolved on the device: the table lives in device memory and the mover may rewrite + * it between launches. + * + * `moe_gemm_q` holds the even experts in `w`/`w_scale` and the odd in `w_odd`/`w_odd_scale`, + * expert e at entry e/2 of class e%2. The contract lets the odd class be narrower + * (`N_odd`/`K_odd`, a rank holding an uneven slice of every expert); these kernels serve equal + * classes and refuse the rest by name. With equal classes `parts` maps output column n to weight + * row n, so it needs no handling beyond the divisibility check. + */ +#pragma once + +#include "r3d_args.h" + +#include + +/* One class's table as the kernels read it: the table, the bytes between stacked entries (0 for + * a pointer array) and the elements between rows of one entry. */ +struct R3dTab { + const void* const* tab; + unsigned long long s0; + int ld; +}; + +/* Both classes' codes and scales, passed to a kernel by value. Class 1 repeats class 0 when the + * call has a single expert and so no odd entries. */ +struct R3dMoeTabs { + R3dTab w[2]; + R3dTab s[2]; +}; + +#if defined(__HIPCC__) +__device__ __forceinline__ const uint8_t* r3d_tab_at(const R3dTab& t, int i) { + if (t.s0 == 0) return (const uint8_t*)t.tab[i]; + return (const uint8_t*)t.tab + (size_t)i * t.s0; +} +#endif + +/* A weight-table operand of `entries` entries, each at least `rows` x `cols`, with the dtype the + * row reads; `bits` is the element width, so a 4-bit plane's stacked stride keeps its half-byte. */ +static inline int r3d_tab_of(const RadTensor* t, uint32_t dtype, int bits, long long entries, + long long rows, long long cols, R3dTab* out) { + if (!t || !t->data || t->rank != 3) return R3D_NO(RAD_E_SHAPE); + if (t->dtype != dtype) return R3D_NO(RAD_E_DTYPE); + if (t->shape[0] < entries || t->shape[1] < rows || t->shape[2] < cols) + return R3D_NO(RAD_E_SHAPE); + if (t->stride[2] != 1 || t->stride[1] < cols) return R3D_NO(RAD_E_STRIDE); + out->tab = (const void* const*)t->data; + out->s0 = (unsigned long long)((t->stride[0] * (long long)bits) / 8); + out->ld = (int)t->stride[1]; + return RAD_OK; +} + +/* The operands and parameters both grouped GEMMs share, checked against the contract. */ +struct R3dMoeCall { + const RadTensor *a, *a_scale, *sorted, *off, *y; + const RadTensor *w, *w_scale, *w_odd, *w_odd_scale; /* w_scale and the odd class: _q only */ + long long T, N, K, n_expert, top_k; + int a_sorted; +}; + +/* `quant`: moe_gemm_q's nine operands (a, a_scale?, w, w_scale, sorted_tok, expert_offset, w_odd, + * w_odd_scale -> y), else moe_gemm's five (a, w, sorted_tok, expert_offset -> y). */ +static inline int r3d_moe_call(const RadArgs* a, bool quant, R3dMoeCall* c) { + if (!a || a->n_t < (quant ? 9 : 5)) return R3D_NO(RAD_E_INVAL); + *c = R3dMoeCall{}; + c->a = r3d_opt(a, 0); + c->a_scale = quant ? r3d_opt(a, 1) : nullptr; + c->w = r3d_opt(a, quant ? 2 : 1); + c->w_scale = quant ? r3d_opt(a, 3) : nullptr; + c->sorted = r3d_opt(a, quant ? 4 : 2); + c->off = r3d_opt(a, quant ? 5 : 3); + c->w_odd = quant ? r3d_opt(a, 6) : nullptr; + c->w_odd_scale = quant ? r3d_opt(a, 7) : nullptr; + c->y = r3d_opt(a, quant ? 8 : 4); + if (!c->a || !c->w || !c->sorted || !c->off || !r3d_wp(c->y)) return R3D_NO(RAD_E_INVAL); + if (quant && !c->w_scale) return R3D_NO(RAD_E_INVAL); + + /* "token" (the default, gate_up): sorted row i reads a[sorted_tok[i] / top_k]. "sorted" (the + * down projection): a already has one row per (token, slot) in the scatter's order. */ + const char* ord = r3d_gets(a, "a_order"); + c->a_sorted = ord && std::strcmp(ord, "sorted") == 0; + if (ord && !c->a_sorted && std::strcmp(ord, "token") != 0) return R3D_NO(RAD_E_UNSUPPORTED); + + c->N = r3d_geti_or(a, "N", c->w->rank >= 3 ? c->w->shape[1] : 0); + c->K = r3d_geti_or(a, "K", c->w->rank >= 3 ? c->w->shape[2] : 0); + c->n_expert = r3d_geti_or(a, "n_expert", 0); + c->top_k = r3d_geti_or(a, "top_k", 0); + if (c->N <= 0 || c->K <= 0 || c->n_expert <= 0 || c->top_k <= 0) return R3D_NO(RAD_E_SHAPE); + if (quant) { + if (r3d_geti_or(a, "N_odd", c->N) != c->N || r3d_geti_or(a, "K_odd", c->K) != c->K) + return R3D_NO(RAD_E_UNSUPPORTED); + const long long parts = r3d_geti_or(a, "parts", 1); + if (parts < 1 || c->N % parts) return R3D_NO(RAD_E_SHAPE); + if (c->n_expert >= 2 && (!c->w_odd || !c->w_odd_scale)) return R3D_NO(RAD_E_INVAL); + } + + /* One output row per (token, slot), the rows the sort placed. */ + long long yr = 0, yc = 0; + if (r3d_rows_of(c->y, &yr, &yc) != RAD_OK || yc < c->N) return R3D_NO(RAD_E_SHAPE); + c->T = yr; + if (r3d_numel(c->sorted) < c->T || r3d_numel(c->off) < c->n_expert + 1) + return R3D_NO(RAD_E_SHAPE); + long long ar = 0, ak = 0; + if (r3d_rows_of(c->a, &ar, &ak) != RAD_OK || ak < c->K) return R3D_NO(RAD_E_SHAPE); + if (ar < (c->a_sorted ? c->T : c->T / c->top_k)) return R3D_NO(RAD_E_SHAPE); + return RAD_OK; +} + +/* Both classes' tables of a moe_gemm_q call: codes at `wdt`/`wbits`, scales at `sdt` (or u8 for + * an E8M0 plane typed raw) with `srows` x `scols` an entry. */ +static inline int r3d_moe_q_tabs(const R3dMoeCall& c, uint32_t wdt, int wbits, uint32_t sdt, + int sbits, long long srows, long long scols, R3dMoeTabs* t) { + const long long n_even = (c.n_expert + 1) / 2, n_odd = c.n_expert / 2; + auto sdt_of = [&](const RadTensor* x) { + return (sdt == RAD_E8M0 && x && x->dtype == RAD_U8) ? (uint32_t)RAD_U8 : sdt; + }; + int rc = r3d_tab_of(c.w, wdt, wbits, n_even, c.N, c.K, &t->w[0]); + if (rc == RAD_OK) rc = r3d_tab_of(c.w_scale, sdt_of(c.w_scale), sbits, n_even, srows, scols, + &t->s[0]); + if (rc != RAD_OK) return rc; + if (n_odd == 0) { t->w[1] = t->w[0]; t->s[1] = t->s[0]; return RAD_OK; } + rc = r3d_tab_of(c.w_odd, wdt, wbits, n_odd, c.N, c.K, &t->w[1]); + if (rc == RAD_OK) rc = r3d_tab_of(c.w_odd_scale, sdt_of(c.w_odd_scale), sbits, n_odd, srows, + scols, &t->s[1]); + return rc; +} diff --git a/libr3d/r3d_ngram_ids.hip b/libr3d/r3d_ngram_ids.hip new file mode 100644 index 00000000..5ce74d1a --- /dev/null +++ b/libr3d/r3d_ngram_ids.hip @@ -0,0 +1,166 @@ +// r3d_ngram_ids.hip -- the hashed row ids of Qwen4-Exp's Per-Layer Embedding. +// +// mixed(k) = t0*mult[0] ^ t1*mult[1] ^ ... ^ tk*mult[k] int64, wrapping +// ids[h] = mixed(b+1) % vocab_sizes[h] + offsets[h] h in block b +// +// One thread a token, looping its heads. +#include +#include +#include "r3d.h" +#include "r3d_args.h" +#include "r3d_launch.h" + +namespace { + +__device__ __forceinline__ long long ng_wrap_mul(long long a, long long b) { + return (long long)((unsigned long long)a * (unsigned long long)b); +} +__device__ __forceinline__ long long ng_floor_mod(long long a, long long b) { + const long long r = a % b; + return r < 0 ? r + b : r; +} + +enum { kNgMaxShift = 8, kNgThreads = 256 }; + +__global__ __launch_bounds__(kNgThreads) void r3d_ngram_ids_kernel( + const int32_t* __restrict__ tok, int32_t* __restrict__ state, + const int32_t* __restrict__ cu, const long long* __restrict__ mult, + const long long* __restrict__ vsz, const long long* __restrict__ off, + const int32_t* __restrict__ sidx, const int32_t* __restrict__ hini, + const int32_t* __restrict__ nacc, int32_t* __restrict__ ids, + uint32_t heads, uint32_t ngram, uint32_t per, uint32_t W, + long long eos, uint32_t ids_ld, int32_t* __restrict__ ahead, uint32_t n_ahead, + uint32_t ahead_ld) +{ + const uint32_t s = blockIdx.y; + const uint32_t bos = (uint32_t)cu[s]; + const uint32_t eot = (uint32_t)cu[s + 1]; + const uint32_t ctx = ngram - 1u; + if (eot <= bos) return; + const int32_t slot = sidx ? sidx[s] : (int32_t)s; + if (slot < 0) return; + + const uint32_t slen = eot - bos; + const bool warm = !hini || hini[s] != 0; + const long long o = nacc ? (long long)nacc[s] - 1 : 0; + const uint32_t lt = blockIdx.x * kNgThreads + threadIdx.x; + + const uint32_t reach = slen + ((ahead && s + 1u == gridDim.y) ? n_ahead : 0u); + if (lt < reach) { + const uint32_t t = bos + lt; + long long prev[kNgMaxShift]; + for (uint32_t i = 0; i < ctx; ++i) + prev[i] = warm ? (long long)state[(long long)slot * W + o + i] : eos; + + const uint32_t p = ctx + lt; + long long sh[kNgMaxShift]; + sh[0] = (long long)tok[t]; + bool cut = false; + for (uint32_t k = 1; k < ngram; ++k) { + if (cut || sh[k - 1] == eos) { cut = true; sh[k] = eos; continue; } + const uint32_t q = p - k; + sh[k] = q < ctx ? prev[q] : (long long)tok[bos + (q - ctx)]; + } + + long long mixed = 0; + int blk = -1; + for (uint32_t k = 0; k < ngram; ++k) { + const long long term = ng_wrap_mul(sh[k], mult[k]); + mixed = k == 0 ? term : (mixed ^ term); + if (k == 0) continue; + ++blk; + int32_t* const row = lt < slen ? ids + (long long)t * ids_ld + : ahead + (long long)(lt - slen) * ahead_ld; + for (uint32_t j = 0; j < per; ++j) { + const uint32_t h = (uint32_t)blk * per + j; + row[h] = (int32_t)(ng_floor_mod(mixed, vsz[h]) + off[h]); + } + } + } + + __syncthreads(); + if (blockIdx.x != 0 || threadIdx.x != 0) return; + int32_t* const win = state + (long long)slot * W; + if (nacc) { + for (uint32_t k = 0; k + 1 < ctx; ++k) + win[k] = warm ? win[o + k + 1] : (int32_t)eos; + for (uint32_t t = 0; t < slen && ctx - 1u + t < W; ++t) win[ctx - 1u + t] = tok[bos + t]; + return; + } + long long keep[kNgMaxShift]; + for (uint32_t k = 0; k < ctx; ++k) { + const long long src = (long long)slen - (long long)ctx + (long long)k; + keep[k] = src >= 0 ? (long long)tok[bos + src] + : (warm ? (long long)win[o + src + ctx] : eos); + } + for (uint32_t k = 0; k < ctx; ++k) win[k] = (int32_t)keep[k]; +} + +} // namespace + +enum { NG_TOK = 0, NG_STATE, NG_CU, NG_MULT, NG_VSZ, NG_OFF, NG_CIDX, NG_HINIT, NG_NACC, NG_IDS, + NG_AHEAD }; + +extern "C" int r3d_rad_ngram_ids(const RadArgs* a, RadStream s) +{ + const RadTensor* tok = r3d_opt(a, NG_TOK); + const RadTensor* st = r3d_opt(a, NG_STATE); + const RadTensor* cu = r3d_opt(a, NG_CU); + const RadTensor* mult = r3d_opt(a, NG_MULT); + const RadTensor* vsz = r3d_opt(a, NG_VSZ); + const RadTensor* off = r3d_opt(a, NG_OFF); + const RadTensor* cidx = r3d_opt(a, NG_CIDX); + const RadTensor* hini = r3d_opt(a, NG_HINIT); + const RadTensor* nacc = r3d_opt(a, NG_NACC); + const RadTensor* ids = r3d_opt(a, NG_IDS); + const RadTensor* ahd = r3d_opt(a, NG_AHEAD); + if (!r3d_p(tok) || !r3d_wp(st) || !r3d_p(cu) || !r3d_p(mult) || + !r3d_p(vsz) || !r3d_p(off) || !r3d_wp(ids)) return R3D_NO(RAD_E_INVAL); + if (tok->dtype != RAD_I32 || st->dtype != RAD_I32 || ids->dtype != RAD_I32) + return R3D_NO(RAD_E_DTYPE); + if (cu->dtype != RAD_I32) return R3D_NO(RAD_E_DTYPE); + if (mult->dtype != RAD_I64 || vsz->dtype != RAD_I64 || off->dtype != RAD_I64) + return R3D_NO(RAD_E_DTYPE); + + const long long M = r3d_geti_or(a, "M", 0); + const long long heads = r3d_geti_or(a, "heads", 0); + const long long ngram = r3d_geti_or(a, "ngram", 0); + const long long eos = r3d_geti_or(a, "eos", -1); + if (M <= 0 || heads <= 0 || ngram < 2 || eos < 0) return R3D_NO(RAD_E_SHAPE); + if (ngram > kNgMaxShift) return R3D_NO(RAD_E_UNSUPPORTED); + if (heads % (ngram - 1)) return R3D_NO(RAD_E_SHAPE); + const long long per = heads / (ngram - 1), ctx = ngram - 1; + + const long long T = ids->rank >= 1 ? ids->shape[0] : M; + const long long ids_ld = ids->rank >= 2 ? ids->stride[0] : heads; + + long long A = 0, ahead_ld = heads; + if (ahd && r3d_p(ahd)) { + if (ahd->dtype != RAD_I32) return R3D_NO(RAD_E_DTYPE); + A = ahd->rank >= 1 ? ahd->shape[0] : 0; + ahead_ld = ahd->rank >= 2 ? ahd->stride[0] : heads; + } + if ((long long)tok->shape[0] < T + A) return R3D_NO(RAD_E_SHAPE); + if ((long long)mult->shape[0] < ngram || (long long)vsz->shape[0] < heads || + (long long)off->shape[0] < heads) return R3D_NO(RAD_E_SHAPE); + + const long long N = (long long)cu->shape[0] - 1; + if (N <= 0) return R3D_NO(RAD_E_SHAPE); + const long long W = st->rank >= 2 ? st->shape[st->rank - 1] : ctx; + if (W < ctx) return R3D_NO(RAD_E_SHAPE); + + const uint32_t tiles = (uint32_t)((T + A + kNgThreads - 1) / kNgThreads); + dim3 grid(tiles, (uint32_t)N), blk(kNgThreads); + R3D_KLAUNCH(r3d_ngram_ids_kernel, grid, blk, (hipStream_t)s, + (const int32_t*)r3d_p(tok), (int32_t*)r3d_wp(st), + (const int32_t*)r3d_p(cu), (const long long*)r3d_p(mult), + (const long long*)r3d_p(vsz), (const long long*)r3d_p(off), + cidx ? (const int32_t*)r3d_p(cidx) : nullptr, + hini ? (const int32_t*)r3d_p(hini) : nullptr, + nacc ? (const int32_t*)r3d_p(nacc) : nullptr, + (int32_t*)r3d_wp(ids), (uint32_t)heads, (uint32_t)ngram, + (uint32_t)per, (uint32_t)W, eos, (uint32_t)ids_ld, + A > 0 ? (int32_t*)r3d_p(ahd) : nullptr, (uint32_t)A, + (uint32_t)ahead_ld); + return (int)hipGetLastError(); +} diff --git a/libr3d/r3d_plugin.h b/libr3d/r3d_plugin.h index 75fcd997..685dc539 100644 --- a/libr3d/r3d_plugin.h +++ b/libr3d/r3d_plugin.h @@ -163,14 +163,13 @@ int r3d_relayout_gemm_nt_q_w5a16(const RadParam* p, int n_p, int operand, const int64_t dst_bytes); int r3d_rad_gemm_nt_q_fp8 (const RadArgs* a, RadStream s); -/* --- r3d_gdn_kkt_solve_c64.hip: the gated-delta-net chunk preamble, the gram and the blocked - * inverse of I + the strictly lower decayed gram, one 64-chunk a workgroup. --- */ -int r3d_rad_gdn_kkt_solve(const RadArgs* a, RadStream s); +/* --- r3dh_gdn_kkt_solve.hip (libhalo's): the gated-delta-net chunk preamble, the gram and the + * blocked inverse of I + the strictly lower decayed gram, one 64-chunk a workgroup. --- */ +extern "C" int r3dh_rad_gdn_kkt_solve(const RadArgs* a, RadStream s); - -/* --- r3d_gdn_chunk_scan_k128_v128_c64.hip: the gated-delta-net chunked scan, the chunk's - * output and its closing state, the recurrent state in wave-matrix accumulators. --- */ -int r3d_rad_gdn_chunk_scan(const RadArgs* a, RadStream s); +/* --- r3dh_gdn_chunk_scan.hip (libhalo's): the gated-delta-net chunked scan, the chunk's output + * and its closing state, the recurrent state in wave-matrix accumulators. --- */ +extern "C" int r3dh_rad_gdn_chunk_scan(const RadArgs* a, RadStream s); /* --- r3d_gdn_gated_rmsnorm_h128.hip: the gated RMS norm a gated-delta-net layer applies to its * own output, one wave per (token, head) row. */ @@ -185,9 +184,10 @@ int r3d_rad_gdn_gated_norm_hq_i8(const RadArgs* a, RadStream s); int r3d_rad_gdn_conv_prep(const RadArgs* a, RadStream s); int r3d_rad_gdn_conv_update(const RadArgs* a, RadStream s); -/* --- r3d_gdn_recurrent_update_k128_v128.hip: the gated-delta-net recurrent state update at - * decode, the per-token state step against a paged fp32 state cache. */ -int r3d_rad_gdn_recurrent_update(const RadArgs* a, RadStream s); +/* --- r3dh_gdn_recurrent_update.hip (libhalo's): the gated-delta-net recurrent state update at + * decode against the paged state cache, in either state form (per_candidate or anchor). */ +extern "C" int r3dh_rad_gdn_recurrent_update(const RadArgs* a, RadStream s); +extern "C" int r3dh_rad_gdn_conv_recurrent_update(const RadArgs* a, RadStream s); /* --- r3d_expert_scale_bf16.hip: each routing weight times its expert's own scale, in place. */ int r3d_rad_expert_scale_bf16(const RadArgs* a, RadStream s); @@ -198,6 +198,7 @@ int r3d_rad_moe_router_topk_bf16(const RadArgs* a, RadStream s); /* --- r3d_moe_scatter.hip: the routed slots' stable counting sort (small form). */ int r3d_rad_moe_scatter(const RadArgs* a, RadStream s); int r3d_rad_moe_scatter_inv(const RadArgs* a, RadStream s); +int64_t r3d_rad_moe_scatter_scratch(const RadArgs* a); /* --- r3d_moe_gather.hip: fold the expert outputs back to the token. */ int r3d_rad_moe_gather(const RadArgs* a, RadStream s); @@ -215,6 +216,15 @@ int r3d_rad_moe_gemm_mxfp4a8(const RadArgs* a, RadStream s); /* --- r3d_moe_gemm_w4a8.hip: the grouped GEMM with int4-weights / int8-activation experts. */ int r3d_rad_moe_gemm_w4a8(const RadArgs* a, RadStream s); +/* --- r3d_moe_gemm_w4a4.hip: the grouped GEMM with int4-weights / int4-activation experts. */ +int r3d_rad_moe_gemm_w4a4(const RadArgs* a, RadStream s); +int r3d_rad_dequant_w4(const RadArgs* a, RadStream s); +int r3d_rad_row_topk_merge(const RadArgs* a, RadStream s); +int r3d_rad_ngram_ids(const RadArgs* a, RadStream s); +int r3d_rad_gemm_nt_q_bias_fp8(const RadArgs* a, RadStream s); +int r3d_rad_gemm_nt_q_short_fp8(const RadArgs* a, RadStream s); +int r3d_rad_moe_gemm_q_mod4(const RadArgs* a, RadStream s); + /* --- r3d_had_quant_act_i8.hip: a block Hadamard along K, then per-row symmetric int8. */ int r3d_rad_had_quant_act_i8(const RadArgs* a, RadStream s); diff --git a/libr3d/r3d_rows.cpp b/libr3d/r3d_rows.cpp index 4fa09152..322820d0 100644 --- a/libr3d/r3d_rows.cpp +++ b/libr3d/r3d_rows.cpp @@ -48,8 +48,13 @@ #define R3D_BUILD_TARGET "gfx1100 gfx1101 gfx1102 gfx1103 gfx1150 gfx1151" #endif +#include + #include +#include #include +#include +#include #define ROW(a) (a), (int)(sizeof(a) / sizeof((a)[0])) #define NELEM(a) ((int)(sizeof(a) / sizeof((a)[0]))) @@ -58,6 +63,9 @@ #define P_INT(k) { (k), RAD_P_INT, RAD_REQUIRED } #define P_INTO(k) { (k), RAD_P_INT, RAD_OPTIONAL } #define P_INTD(k) { (k), RAD_P_INT, RAD_DERIVED } +/* The sequence-chunk parameter: derived, and the one the core reads by meaning (RAD_PROLE_SEQ_CHUNK). + * Roles are part of a schema, so this must match libref's spelling, not only P_INTD's. */ +#define P_CHUNK(k) { (k), RAD_P_INT, RAD_DERIVED, RAD_PROLE_SEQ_CHUNK } #define P_STR(k) { (k), RAD_P_STR, RAD_REQUIRED } #define P_STRO(k) { (k), RAD_P_STR, RAD_OPTIONAL } #define P_F64(k) { (k), RAD_P_F64, RAD_REQUIRED } @@ -164,18 +172,18 @@ static const RadOperandSpec oRouterTopkScatter[] = { { "logits", RAD_OPD_IN, 0 } { "sorted_tok", RAD_OPD_OUT, 0 }, { "expert_offset", RAD_OPD_OUT, 0 }, { "expert_count", RAD_OPD_OUT, 0 } }; -static const RadParamSpec pRouterTopkScatter[] = { P_INT("M"), P_INT("n_expert"), P_INT("top_k"), - P_INT("n_local"), P_INT("norm"), P_STRO("dtype"), - P_INT("expert_base"), P_STRO("protect") }; +static const RadParamSpec pRouterTopkScatter[] = { P_INT("M"), P_INT("n_expert"), P_INTO("n_local"), + P_INT("top_k"), P_INT("norm"), P_STR("dtype"), + P_INTO("expert_base"), P_STRO("protect") }; /* router_sigmoid_topk: the GLM-style router -- logits, the per-expert correction bias, and the * selection (expert_ids, expert_w). */ static const RadOperandSpec oRouterSigmoid[] = { { "logits", RAD_OPD_IN, 0 }, - { "bias", RAD_OPD_IN, 0 }, - { "expert_ids", RAD_OPD_OUT, 0 }, - { "expert_w", RAD_OPD_OUT, 0 } }; + { "bias", RAD_OPD_WEIGHT, 0 }, + { "ids", RAD_OPD_OUT, 0 }, + { "weights", RAD_OPD_OUT, 0 } }; static const RadParamSpec pRouterSigmoid[] = { P_INT("M"), P_INT("n_expert"), P_INT("top_k"), - P_F64("route_scale"), P_INTO("norm"), P_STRO("dtype") }; + P_INT("norm"), P_F64("route_scale"), P_STR("dtype") }; static const RadOperandSpec oGatedQuant[] = { { "gate_up", RAD_OPD_IN, 0 }, { "q", RAD_OPD_OUT, 0 }, { "scale", RAD_OPD_OUT, 0 }, @@ -212,7 +220,7 @@ static const RadOperandSpec oRmsQuantI8[] = { { "x", RAD_OPD_IN, 0 }, { "scale", RAD_OPD_OUT, 0 }, { "out_bf16", RAD_OPD_OUT, 1 }, { "w_post", RAD_OPD_WEIGHT, 1 }, - { "scalar", RAD_OPD_IN, 1 } }; + { "scalar", RAD_OPD_WEIGHT, 1 } }; static const RadOperandSpec oDequant[] = { { "q", RAD_OPD_IN, 0 }, { "scale", RAD_OPD_IN, 0 }, { "y", RAD_OPD_OUT, 0 } }; @@ -222,9 +230,12 @@ static const RadParamSpec pGemm[] = { P_INT("M"), P_INT("N"), P_INT("K"), P_STR( static const RadOperandSpec oGemm[] = { { "a", RAD_OPD_IN, 0 }, { "b", RAD_OPD_WEIGHT, 0 }, { "y", RAD_OPD_OUT, 0 } }; +/* `w_rb` is libr4d's (docs/OPS.md), accepted and ignored: an int8 weight's per-row scale plane + * holds each block's value in every row, and the trellis forms that need it are IQR dtypes, which + * no row here serves. */ static const RadParamSpec pGemmQ[] = { P_INT("M"), P_INT("N"), P_INT("K"), P_INT("group"), P_STR("dtype"), P_INTO("pb1"), P_INTO("pb2"), - P_INTO("split_n") }; + P_INTO("split_n"), P_INTO("w_rb") }; static const RadOperandSpec oGemmQ[] = { { "a", RAD_OPD_IN, 0 }, { "a_scale", RAD_OPD_IN, 1 }, { "b", RAD_OPD_WEIGHT, 0 }, { "b_scale", RAD_OPD_WEIGHT, 0 }, @@ -232,7 +243,7 @@ static const RadOperandSpec oGemmQ[] = { { "a", RAD_OPD_IN, 0 }, { "a_scale", RA { "b_ref", RAD_OPD_WEIGHT, 1 } }; /* --- gated-delta-net --- */ -static const RadParamSpec pGdnKktSolve[] = { P_INT("M"), P_INT("head_k"), P_INT("chunk") }; +static const RadParamSpec pGdnKktSolve[] = { P_INT("M"), P_INT("head_k"), P_CHUNK("chunk") }; static const RadOperandSpec oGdnKktSolve[] = { { "k", RAD_OPD_IN, 0 }, { "beta", RAD_OPD_IN, 0 }, { "g", RAD_OPD_IN, 0 }, @@ -240,7 +251,7 @@ static const RadOperandSpec oGdnKktSolve[] = { { "k", RAD_OPD_IN, 0 }, { "A", RAD_OPD_OUT, 0 } }; static const RadParamSpec pGdnChunkScan[] = { P_INT("M"), P_INT("head_k"), P_INT("head_v"), - P_INTD("chunk"), P_F64O("scale"), P_INTO("state_fp16") }; + P_CHUNK("chunk"), P_F64O("scale"), P_INTO("state_fp16") }; static const RadOperandSpec oGdnChunkScan[] = { { "q", RAD_OPD_IN, 0 }, { "k", RAD_OPD_IN, 0 }, { "v", RAD_OPD_IN, 0 }, @@ -257,7 +268,7 @@ static const RadParamSpec pGdnGatedRmsnorm[] = { P_INT("M"), P_INT("channels"), P_F64("eps"), P_STR("act") }; static const RadOperandSpec oGdnGatedRmsnorm[] = { { "x", RAD_OPD_IN, 0 }, { "z", RAD_OPD_IN, 0 }, - { "w", RAD_OPD_IN, 0 }, + { "w", RAD_OPD_WEIGHT, 0 }, { "o", RAD_OPD_OUT, 0 } }; static const RadParamSpec pGdnGatedNormHq[] = { P_INT("M"), P_INT("n"), P_INT("head_dim"), @@ -265,18 +276,18 @@ static const RadParamSpec pGdnGatedNormHq[] = { P_INT("M"), P_INT("n"), P_INT("h P_INTO("zgrp"), P_INTO("zblk") }; static const RadOperandSpec oGdnGatedNormHq[] = { { "x", RAD_OPD_IN, 0 }, { "z", RAD_OPD_IN, 0 }, - { "w", RAD_OPD_IN, 0 }, + { "w", RAD_OPD_WEIGHT, 0 }, { "q", RAD_OPD_OUT, 0 }, { "scale", RAD_OPD_OUT, 0 } }; static const RadParamSpec pGdnConvPrep[] = { P_INT("M"), P_INT("head_k"), P_INT("head_v"), - P_INTD("chunk"), P_INT("conv_width"), + P_CHUNK("chunk"), P_INT("conv_width"), P_F64O("l2_eps"), P_F64O("softplus_thr") }; static const RadOperandSpec oGdnConvPrep[] = { { "x", RAD_OPD_IN, 0 }, - { "w", RAD_OPD_IN, 0 }, - { "b", RAD_OPD_IN, 1 }, - { "A_log", RAD_OPD_IN, 0 }, - { "dt_bias", RAD_OPD_IN, 0 }, + { "w", RAD_OPD_WEIGHT, 0 }, + { "b", RAD_OPD_WEIGHT, 1 }, + { "A_log", RAD_OPD_WEIGHT, 0 }, + { "dt_bias", RAD_OPD_WEIGHT, 0 }, { "conv_state", RAD_OPD_INOUT, 0 }, { "cu", RAD_OPD_IN, 0 }, { "a", RAD_OPD_IN, 1 }, @@ -290,13 +301,13 @@ static const RadOperandSpec oGdnConvPrep[] = { { "x", RAD_OPD_IN, 0 }, { "beta", RAD_OPD_OUT, 0 } }; static const RadParamSpec pGdnConvUpdate[] = { P_INT("q_len"), P_INT("head_k"), P_INT("head_v"), - P_INT("conv_width"), P_F64O("max_query_len") }; + P_INT("conv_width"), P_INTO("max_query_len") }; static const RadOperandSpec oGdnConvUpdate[] = { { "x", RAD_OPD_IN, 0 }, - { "w", RAD_OPD_IN, 0 }, - { "b", RAD_OPD_IN, 1 }, + { "w", RAD_OPD_WEIGHT, 0 }, + { "b", RAD_OPD_WEIGHT, 1 }, { "conv_state", RAD_OPD_INOUT, 0 }, { "state_idx", RAD_OPD_IN, 0 }, - { "num_accepted", RAD_OPD_IN, 1 }, + { "num_accepted", RAD_OPD_IN, 0 }, { "cu", RAD_OPD_IN, 0 }, { "q", RAD_OPD_OUT, 0 }, { "k", RAD_OPD_OUT, 0 }, @@ -305,7 +316,7 @@ static const RadOperandSpec oGdnConvUpdate[] = { { "x", RAD_OPD_IN, 0 }, static const RadParamSpec pExpertScale[] = { P_INT("M"), P_INT("n_expert"), P_INT("top_k"), P_STR("dtype") }; static const RadOperandSpec oExpertScale[] = { { "ids", RAD_OPD_IN, 0 }, - { "w_e", RAD_OPD_IN, 0 }, + { "w_e", RAD_OPD_WEIGHT, 0 }, { "ew", RAD_OPD_INOUT, 0 } }; static const RadParamSpec pMoeRouterTopk[] = { P_INT("M"), P_INT("n_expert"), P_INT("top_k"), @@ -325,33 +336,41 @@ static const RadOperandSpec oMoeScatter[] = { { "expert_ids", RAD_OPD_IN, 0 }, static const RadOperandSpec oMoeGather[] = { { "y_expert", RAD_OPD_IN, 0 }, { "expert_w", RAD_OPD_IN, 0 }, { "sorted_tok", RAD_OPD_IN, 0 }, - { "shared", RAD_OPD_IN, 0 }, - { "shared_gate", RAD_OPD_IN, 0 }, + { "shared", RAD_OPD_IN, 1 }, + { "shared_gate", RAD_OPD_IN, 1 }, { "y", RAD_OPD_OUT, 0 } }; -static const RadParamSpec pMoeGather[] = { P_INT("M"), P_INT("n"), P_INT("top_k"), P_STRO("dtype"), +static const RadParamSpec pMoeGather[] = { P_INT("M"), P_INT("n"), P_INT("top_k"), P_STR("dtype"), P_STRO("act") }; -/* moe_gemm_q: the grouped quantised GEMM. a and the weight tables are E4M3 with an f32 scale per - * (row, grid of K); the even experts are `w` / `w_scale`, the odd `w_odd` / `w_odd_scale`. */ +/* moe_gemm_q: the grouped quantised GEMM, libref's schema. The experts are weight tables + * (RAD_OPD_WTAB): the even experts in `w` / `w_scale`, the odd in `w_odd` / `w_odd_scale`, expert e + * at entry e/2 (r3d_moe_tab.h). */ static const RadOperandSpec oMoeGemmQ[] = { { "a", RAD_OPD_IN, 0 }, - { "a_scale", RAD_OPD_IN, 0 }, + { "a_scale", RAD_OPD_IN, 1 }, + { "w", RAD_OPD_WTAB, 0 }, + { "w_scale", RAD_OPD_WTAB, 0 }, { "sorted_tok", RAD_OPD_IN, 0 }, { "expert_offset", RAD_OPD_IN, 0 }, - { "w", RAD_OPD_WEIGHT, 0 }, - { "w_scale", RAD_OPD_WEIGHT, 0 }, - { "w_odd", RAD_OPD_WEIGHT, 0 }, - { "w_odd_scale", RAD_OPD_WEIGHT, 0 }, + { "w_odd", RAD_OPD_WTAB, 0 }, + { "w_odd_scale", RAD_OPD_WTAB, 0 }, { "y", RAD_OPD_OUT, 0 } }; -static const RadParamSpec pMoeGemmQ[] = { P_INT("n_expert"), P_INT("top_k"), P_INTO("grid_rows"), - P_STRO("dtype") }; +static const RadParamSpec pMoeGemmQ[] = { P_INT("M"), P_INT("N"), P_INT("K"), P_INT("n_expert"), + P_INT("top_k"), P_INT("group"), P_STR("a_order"), + P_STR("dtype"), P_INTO("N_odd"), P_INTO("K_odd"), + P_INTO("parts") }; - /* moe_gemm: the grouped GEMM with unquantised bf16 experts. a and w are bf16, no scales. */ +/* moe_gemm_q dtype w4a8: the grouped int4 GEMM (r3d_moe_gemm_w4a8.hip) is a row of the moe_gemm_q + * op above (two's-complement int4 experts, a bf16 scale per (row, 128 of K), bf16 out; the int8 or + * E4M3 activation arm is picked by `a`'s dtype). It reuses moe_gemm_q's nine-operand parity schema. */ + + /* moe_gemm: the grouped GEMM with unquantised experts, libref's schema; one weight table. */ static const RadOperandSpec oMoeGemm[] = { { "a", RAD_OPD_IN, 0 }, - { "w", RAD_OPD_WEIGHT, 0 }, + { "w", RAD_OPD_WTAB, 0 }, { "sorted_tok", RAD_OPD_IN, 0 }, { "expert_offset", RAD_OPD_IN, 0 }, { "y", RAD_OPD_OUT, 0 } }; -static const RadParamSpec pMoeGemm[] = { P_INT("n_expert"), P_INT("top_k") }; +static const RadParamSpec pMoeGemm[] = { P_INT("M"), P_INT("N"), P_INT("K"), P_INT("n_expert"), + P_INT("top_k"), P_STR("a_order"), P_STR("dtype") }; static const RadParamSpec pGdnRecurrent[] = { P_INT("q_len"), P_INT("head_k"), P_INT("head_v"), P_INTO("n_head_v"), P_F64O("scale"), P_F64O("eps"), @@ -362,18 +381,44 @@ static const RadOperandSpec oGdnRecurrent[] = { { "q", RAD_OPD_IN, 0 }, { "v", RAD_OPD_IN, 0 }, { "a", RAD_OPD_IN, 0 }, { "b", RAD_OPD_IN, 0 }, - { "A_log", RAD_OPD_IN, 0 }, - { "dt_bias", RAD_OPD_IN, 0 }, + { "A_log", RAD_OPD_WEIGHT, 0 }, + { "dt_bias", RAD_OPD_WEIGHT, 0 }, { "state", RAD_OPD_INOUT, 0 }, { "state_idx", RAD_OPD_IN, 0 }, - { "num_accepted", RAD_OPD_IN, 1 }, + { "num_accepted", RAD_OPD_IN, 0 }, { "cu", RAD_OPD_IN, 0 }, { "z", RAD_OPD_IN, 1 }, - { "norm_w", RAD_OPD_IN, 1 }, + { "norm_w", RAD_OPD_WEIGHT, 1 }, { "o", RAD_OPD_OUT, 0 }, { "o_q", RAD_OPD_OUT, 1 }, { "o_scale", RAD_OPD_OUT, 1 } }; +/* gdn_conv_recurrent_update: the decode conv and the recurrent update as one kernel, the + * convolution's operands then the recurrence's minus q, k and v (never materialised). */ +static const RadParamSpec pGdnConvRecurrent[] = { P_INT("q_len"), P_INT("head_k"), P_INT("head_v"), + P_INT("conv_width"), P_INTO("n_head_v"), + P_F64O("scale"), P_F64O("eps"), P_F64O("l2_eps"), + P_F64O("softplus_thr"), P_STRO("act"), + P_INTO("state_fp16"), P_STRO("state_form") }; +static const RadOperandSpec oGdnConvRecurrent[] = { { "x", RAD_OPD_IN, 0 }, + { "conv_w", RAD_OPD_WEIGHT, 0 }, + { "conv_b", RAD_OPD_WEIGHT, 1 }, + { "conv_state", RAD_OPD_INOUT, 0 }, + { "conv_idx", RAD_OPD_IN, 0 }, + { "a", RAD_OPD_IN, 0 }, + { "b", RAD_OPD_IN, 0 }, + { "A_log", RAD_OPD_WEIGHT, 0 }, + { "dt_bias", RAD_OPD_WEIGHT, 0 }, + { "state", RAD_OPD_INOUT, 0 }, + { "state_idx", RAD_OPD_IN, 0 }, + { "num_accepted", RAD_OPD_IN, 0 }, + { "cu", RAD_OPD_IN, 0 }, + { "z", RAD_OPD_IN, 0 }, + { "norm_w", RAD_OPD_WEIGHT, 0 }, + { "o", RAD_OPD_OUT, 0 }, + { "o_q", RAD_OPD_OUT, 1 }, + { "o_scale", RAD_OPD_OUT, 1 } }; + /* ================================================================== the vocab and the sampler * @@ -480,7 +525,7 @@ static const RadOperandSpec oArgmax[] = { { "logits", RAD_OPD_IN, 0 }, { "params", RAD_OPD_IN, 0 }, { "token", RAD_OPD_OUT, 0 } }; static const RadOperandSpec oLogprobs[] = { { "logits", RAD_OPD_IN, 0 }, - { "params", RAD_OPD_IN, 0 }, + { "params", RAD_OPD_IN, 1 }, { "stats", RAD_OPD_OUT, 0 } }; static const RadOperandSpec oNarrow[] = { { "cand_idx", RAD_OPD_INOUT, 0 }, { "cand_val", RAD_OPD_INOUT, 0 }, @@ -502,6 +547,57 @@ static const RadOperandSpec oRmsQuantFp8[] = { { "q", RAD_OPD_OUT, 0 }, { "scale", RAD_OPD_OUT, 0 }, { "out_bf16", RAD_OPD_OUT, 1 } }; +/* --- new Tier-1 ops --- */ +static const RadParamSpec pDequantW4[] = { P_INT("N"), P_INT("K"), P_INT("group"), P_STR("dtype"), + P_INT("twos") }; +static const RadOperandSpec oDequantW4[] = { { "wq", RAD_OPD_WEIGHT, 0 }, + { "ws", RAD_OPD_WEIGHT, 0 }, + { "y", RAD_OPD_OUT, 0 } }; +static const RadParamSpec pRowTopkMerge[] = { P_INT("M"), P_INT("R"), P_INT("world_size"), + P_STR("dtype") }; +static const RadOperandSpec oRowTopkMerge[] = { { "gathered", RAD_OPD_IN, 0 }, + { "idx", RAD_OPD_OUT, 0 }, + { "val", RAD_OPD_OUT, 0 } }; +static const RadParamSpec pNgramIds[] = { P_INT("M"), P_INT("heads"), P_INT("ngram"), P_INT("eos") }; +static const RadOperandSpec oNgramIds[] = { { "tok", RAD_OPD_IN, 0 }, + { "state", RAD_OPD_INOUT, 0 }, + { "cu", RAD_OPD_IN, 0 }, + { "mult", RAD_OPD_WEIGHT, 0 }, + { "vocab_sizes", RAD_OPD_WEIGHT, 0 }, + { "offsets", RAD_OPD_WEIGHT, 0 }, + { "cache_idx", RAD_OPD_IN, 1 }, + { "has_init", RAD_OPD_IN, 1 }, + { "num_accepted", RAD_OPD_IN, 1 }, + { "ids", RAD_OPD_OUT, 0 }, + { "ahead_ids", RAD_OPD_OUT, 1 } }; +static const RadParamSpec pGemmQBias[] = { P_INT("M"), P_INT("N"), P_INT("K"), P_INT("group"), P_STR("dtype") }; +static const RadOperandSpec oGemmQBias[] = { { "a", RAD_OPD_IN, 0 }, { "a_scale", RAD_OPD_IN, 0 }, + { "b", RAD_OPD_WEIGHT, 0 }, + { "b_scale", RAD_OPD_WEIGHT, 0 }, + { "bias", RAD_OPD_WEIGHT, 0 }, + { "y", RAD_OPD_OUT, 0 } }; +static const RadParamSpec pGemmQShort[] = { P_INT("M"), P_INT("N"), P_INT("K"), P_INT("group"), + P_STR("dtype"), P_INTO("pb1"), P_INTO("pb2"), + P_INTO("split_n"), P_INTO("w_rb") }; +static const RadOperandSpec oGemmQShort[] = { { "a", RAD_OPD_IN, 0 }, { "a_scale", RAD_OPD_IN, 1 }, + { "b", RAD_OPD_WEIGHT, 0 }, + { "b_scale", RAD_OPD_WEIGHT, 0 }, + { "y", RAD_OPD_OUT, 0 }, + { "a_sum", RAD_OPD_IN, 1 }, + { "b_ref", RAD_OPD_WEIGHT, 1 } }; +static const RadParamSpec pMoeGemmQMod4[] = { P_INT("M"), P_INT("N"), P_INT("K"), + P_INT("n_expert"), P_INT("top_k"), P_INT("group"), + P_STR("a_order"), P_STR("dtype"), P_INTO("N_1"), + P_INTO("K_1"), P_INTO("N_2"), P_INTO("K_2"), + P_INTO("N_3"), P_INTO("K_3"), P_INTO("parts") }; +static const RadOperandSpec oMoeGemmQMod4[] = { { "a", RAD_OPD_IN, 0 }, { "a_scale", RAD_OPD_IN, 1 }, + { "w", RAD_OPD_WTAB, 0 }, { "w_scale", RAD_OPD_WTAB, 0 }, + { "sorted_tok", RAD_OPD_IN, 0 }, { "expert_offset", RAD_OPD_IN, 0 }, + { "w_1", RAD_OPD_WTAB, 0 }, { "w_1_scale", RAD_OPD_WTAB, 0 }, + { "w_2", RAD_OPD_WTAB, 0 }, { "w_2_scale", RAD_OPD_WTAB, 0 }, + { "w_3", RAD_OPD_WTAB, 0 }, { "w_3_scale", RAD_OPD_WTAB, 0 }, + { "y", RAD_OPD_OUT, 0 } }; + static const RadOpSchema kSchemas[] = { SCHEMA("rmsnorm", pRmsNorm, oRmsNorm, "y = x * rsqrt(mean(x^2) + eps) * (w + wadd) * mult. `wadd` is GemmaRMSNorm's `1 +`, " @@ -634,6 +730,11 @@ static const RadOpSchema kSchemas[] = { "dt_bias), beta = sigmoid(b), q/k l2-normalised, S *= e^g, u = beta (v - S k), S += u " "k^T, o = S q, per token against a paged fp32 state cache; the gated RMS norm is " "folded in when `z` and `norm_w` are present."), + + SCHEMA("gdn_conv_recurrent_update", pGdnConvRecurrent, oGdnConvRecurrent, + "gdn_conv_update followed by gdn_recurrent_update, with q, k and v never written: the " + "operands are the convolution's (`conv_idx` is its state_idx) and then the recurrence's " + "without those three."), SCHEMA("expert_scale", pExpertScale, oExpertScale, "Each routing weight times its expert's own per-expert scale, in place: the router's " "renormalised top-k weight scaled by the [n_expert] table, an out-of-table id reading " @@ -750,6 +851,25 @@ static const RadOpSchema kSchemas[] = { "the best `unary + pred[pid] . (hp * succ[cand])` is picked, and becomes the predecessor " "of the next step. `cand`/`unary` have one row per (sequence, step); `anchor` is the " "block's first predecessor, at `m * anchor_stride`."), + + SCHEMA("dequant_w4", pDequantW4, oDequantW4, + "Packed int4 weight to row-major bf16. Each 32-bit word holds 8 codes; the scale is " + "f16 in the low 16 bits, the zero point -(1024+zero) as f16 in the high 16 bits."), + SCHEMA("row_topk_merge", pRowTopkMerge, oRowTopkMerge, + "Top-R of gathered per-rank candidate sets. Each rank contributes a sorted list; the " + "merge selects the top-R global candidates by score."), + SCHEMA("ngram_ids", pNgramIds, oNgramIds, + "Hashed n-gram row ids for PLE. The FNV-1a mix over the ngram-1 token window is " + "folded into each head's embedding table; per, W and the ids pitch derive from the " + "operands, and `eos` cuts the hash window."), + SCHEMA("gemm_nt_q_bias", pGemmQBias, oGemmQBias, + "Narrow fp8 GEMM (M <= 16) with per-column bf16 bias fused into the epilogue."), + SCHEMA("gemm_nt_q_short", pGemmQShort, oGemmQShort, + "Narrow fp8 GEMM (M <= 16) for short-prompt decode, unsplit K."), + SCHEMA("moe_gemm_q_mod4", pMoeGemmQMod4, oMoeGemmQMod4, + "Grouped GEMM over the expert-sorted rows, quantised operands, four classes by " + "expert number mod 4. The E4M3 wave-matrix core over 8 R3dTab tables (class q = " + "entry e/4 of tables q); unequal class shapes are refused."), }; extern "C" int rad_kernel_schema_count(void) { @@ -801,6 +921,12 @@ static const int64_t kImpl3[] = { 0, 1, 2 }; static const int64_t kImpl4[] = { 0, 1, 2, 3 }; /* The MoE GEMM's row block: 16 (decode), 32, 64 (a tall prefill). A taller block reads the weight * T/mrows times, so the tune picks per shape; 64 is the untuned default (the tall band's best). */ +static const int64_t kMrowsMoE[] = { 8, 16 }; +static const int64_t kWvMoE[] = { 4, 8 }; +static const RadTunable tMoeGemmQW4[] = { + { "mrows", kMrowsMoE, NELEM(kMrowsMoE), 16, "rows per block: 8 for decode, 16 for prefill" }, + { "wv", kWvMoE, NELEM(kWvMoE), 8, "waves per block: 8 = 128-col tile, 4 = 64-col tile" }, +}; static const int64_t kMrows[] = { 16, 32, 64 }; static const RadTunable tMoeGemm[] = { { "mrows", kMrows, NELEM(kMrows), 64, "the block's row count; the weight is read T/mrows times" }, @@ -1064,6 +1190,12 @@ static const RadConstraint cActSigmoid[] = { C_IN("act", "sigmoid"), C_IN("dtype /* A fill row is its dtype; the value is a parameter, and every dtype takes every value. */ static const RadConstraint cFillBf16[] = { C_IN("dtype", "bf16") }; static const RadConstraint cFillF32[] = { C_IN("dtype", "f32") }; +static const RadConstraint cDequantW4[] = { C_DIV("N", 16), C_DIV("K", 64) }; +static const RadConstraint cRowTopkMerge[] = { C_GE("R", 1), C_LE("R", 32) }; +static const RadConstraint cNgramIds[] = { C_GE("ngram", 2), C_LE("ngram", 8) }; +static const RadConstraint cGemmQBias[] = { C_IN("dtype", "fp8a8"), C_GE("M", 1), C_LE("M", 16) }; +static const RadConstraint cGemmQShort[] = { C_IN("dtype", "fp8a8"), C_GE("M", 1), C_LE("M", 64) }; +static const RadConstraint cMoeGemmQMod4[] = { C_GE("n_expert", 4) }; static const RadConstraint cFillI32[] = { C_IN("dtype", "i32") }; static const RadConstraint cFillI64[] = { C_IN("dtype", "i64") }; @@ -1167,6 +1299,8 @@ static const RadConstraint cGdnConvUpdW4[] = { C_GE("q_len", 1), C_EQ("head_k", C_EQ("head_v", 128), C_EQ("conv_width", 4) }; static const RadConstraint cGdnRecurrent[] = { C_GE("q_len", 1), C_EQ("head_k", 128), C_EQ("head_v", 128) }; +static const RadConstraint cGdnConvRecurrent[] = { C_GE("q_len", 1), C_EQ("head_k", 128), + C_EQ("head_v", 128), C_EQ("conv_width", 4) }; static const RadConstraint cExpertScaleBf16[] = { C_IN("dtype", "bf16"), C_GE("top_k", 1), C_LE("top_k", 64), C_GE("n_expert", 1) }; static const RadConstraint cMoeRouterTopkBf16[] = { C_IN("dtype", "bf16"), C_GE("top_k", 1), @@ -1181,15 +1315,22 @@ static const RadConstraint cMoeGemmQ[] = { C_IN("dtype", "fp8a8f32"), C_GE("n_ex C_GE("top_k", 1) }; static const RadConstraint cMoeGemmMxfp4[] = { C_IN("dtype", "mxfp4a8"), C_GE("n_expert", 1), C_GE("top_k", 1) }; +static const RadConstraint cMoeGemmQW4A8[] = { C_IN("dtype", "w4a8"), C_GE("n_expert", 1), + C_GE("top_k", 1) }; +static const RadConstraint cMoeGemmW4A4[] = { C_IN("dtype", "w4a4"), C_GE("n_expert", 1), + C_GE("top_k", 1) }; static const RadConstraint cMoeGather[] = { C_GE("M", 1), C_GE("n", 1), C_GE("top_k", 1), C_IN("dtype", "bf16") }; +/* No constraint on `n_local`: it is optional, and a band that leaves it out (every expert local) + * would not resolve to a row that constrains it; the kernel reads it absent as `n_expert`. */ static const RadConstraint cRouterTopkScatter[] = { C_GE("M", 1), C_GE("n_expert", 1), - C_GE("top_k", 1), C_GE("n_local", 1), - C_LE("n_expert", 512), C_IN("dtype", "bf16") }; + C_GE("top_k", 1), C_LE("n_expert", 512), + C_IN("dtype", "bf16") }; static const RadConstraint cRouterSigmoid[] = { C_GE("M", 1), C_GE("n_expert", 1), C_GE("top_k", 1), C_LE("n_expert", 512), C_IN("dtype", "bf16") }; -static const RadConstraint cMoeGemmBf16[] = { C_GE("n_expert", 1), C_GE("top_k", 1) }; +static const RadConstraint cMoeGemmBf16[] = { C_IN("dtype", "bf16"), C_GE("n_expert", 1), + C_GE("top_k", 1) }; /* The vocabulary projection has no `dtype` constraint because its band carries no `dtype` key: the * head's dtype is a property of the weight (libref checks it with a `check_dtypes` hook). A * constraint on a key the band lacks does not hold, which would leave only the host kernel and the @@ -1882,14 +2023,12 @@ static const RadKernelInfo kKernels[] = { */ { "gdn_kkt_solve_c64", "gdn_kkt_solve", "gdn", "A = (I + strict_lower(diag(beta) K K^T e^{g_i - g_j}))^-1 per 64-chunk of a gated delta net", - "head_k 128, chunk 64, H a multiple of head groups; the gram is computed once per k head and " - "scaled per v head, the inverse blocked 16 -> 32 -> 64 with the 16-blocks by fp32 forward " - "substitution and the merges by the card's 16x16x16 wave matrix", - "bf16 k and A, f32 beta and g, i32 cu; the padding rows and columns are masked to -inf so a " - "partial last chunk's NaN cannot ride the WMMA merges into live rows", + "head_k 128, chunk 64, varlen; one gram per k head, applied to every v head of the group, the " + "inverse blocked 16 -> 32 -> 64 on the wave matrix (libhalo's kernel, r3dh_gdn_kkt_solve.hip)", + "bf16 k and A, f32 beta, g, gram and inverse, i32 cu", RAD_DOMAIN_DEVICE, R3D_PRIO_ONLY, ROW(cGdnKktC64), NOTUNE, - nullptr, nullptr, r3d_rad_gdn_kkt_solve, + nullptr, nullptr, r3dh_rad_gdn_kkt_solve, nullptr, nullptr, nullptr, nullptr, nullptr }, @@ -1906,11 +2045,10 @@ static const RadKernelInfo kKernels[] = { "accumulators across the chunk loop, so only q, k, v, A, g, beta, the state cache and o " "touch HBM; two workgroups per v head each carry 64 of the v dimension", "bf16 q, k, v, A and o, f32 g and beta, f32 or f16 state cache (the operand's dtype), i32 cu " - "and the optional state slot index; a row's slot comes from the cache manager, not the batch " - "position, and a padded row owns no state", + "and the optional state slot index (libhalo's kernel, r3dh_gdn_chunk_scan.hip)", RAD_DOMAIN_DEVICE, R3D_PRIO_ONLY, ROW(cGdnChunkScanC64), NOTUNE, - nullptr, nullptr, r3d_rad_gdn_chunk_scan, + nullptr, nullptr, r3dh_rad_gdn_chunk_scan, nullptr, nullptr, nullptr, nullptr, nullptr }, @@ -2029,14 +2167,15 @@ static const RadKernelInfo kKernels[] = { nullptr, nullptr }, { "moe_scatter_small", "moe_scatter", "moe", - "The routed slots' stable counting sort (the small form, one workgroup)", - "histogram in LDS, an exclusive prefix over the expert counts, each slot placed by its rank " - "inside its expert's run; T <= 1024", + "The routed slots' stable counting sort", + "up to 1024 slots one workgroup (histogram in LDS, an exclusive prefix over the expert counts, " + "each slot placed by its rank inside its expert's run); above, three passes over 256-slot tiles " + "(histogram, scan across tiles, placement) with the per-tile counts in scratch", "i32 expert_ids, sorted_tok, expert_offset, expert_count; n_expert <= 512", RAD_DOMAIN_DEVICE, R3D_PRIO_ONLY, ROW(cMoeScatter), NOTUNE, nullptr, nullptr, r3d_rad_moe_scatter, - nullptr, nullptr, nullptr, + r3d_rad_moe_scatter_scratch, nullptr, nullptr, nullptr, nullptr }, /* ------------------------------------------------------------------ r3d_moe_gather.hip */ @@ -2069,10 +2208,9 @@ static const RadKernelInfo kKernels[] = { "table); 2 = the 16x128 block, the E4M3 operands widened exactly to f16 and the F32 scales " "folded in f32 per 128 of K. All arms run the f16 wave-matrix (f32 accumulate) and walk the runs " "in the block's 16 rows, so a block spanning several experts (short runs) is correct; the even " - "experts are `w` / `w_scale`, the odd `w_odd` / `w_odd_scale`, at index e/2", - "E4M3 a and the weight tables, f32 a_scale per (row, 128 of K), f32 w_scale per (grid_rows " - "columns, 128 of K); K % 128; grid_rows 1 (w4a8's per-row) or 128 (fp8a8's per-128x128 tile); " - "y f32 in sorted order", + "experts are entry e/2 of `w` / `w_scale`, the odd of `w_odd` / `w_odd_scale`", + "E4M3 a and the weight tables, f32 a_scale per (row, 128 of K), f32 w_scale per 128x128 tile; " + "K % 128; equal classes (N_odd = N, K_odd = K); token or sorted a; y bf16 in sorted order", RAD_DOMAIN_DEVICE, R3D_PRIO_ONLY, ROW(cMoeGemmQ), tMoeGemmQ, NELEM(tMoeGemmQ), moe_q_tune_valid, nullptr, nullptr, r3d_rad_moe_gemm_q, @@ -2086,9 +2224,10 @@ static const RadKernelInfo kKernels[] = { "of sorted row i", "16x16 tiles through LDS, the bf16 operands staged and loaded straight into the bf16 wave-matrix " "fragments (f32 accumulate over the whole of K); the block walks the runs in its 16 rows, so a " - "block spanning several experts (short runs) is correct; the weight is the checkpoint's own bytes " - "([n_expert, N, K] row-major, no layout hook)", - "bf16 a and w, bf16 y in sorted order; K a multiple of 64, the N tail clamped", + "block spanning several experts (short runs) is correct; the weight is a table of the " + "checkpoint's own [N, K] row-major planes (no layout hook)", + "bf16 a and w, bf16 y in sorted order; token or sorted a; K a multiple of 64, the N tail " + "clamped", RAD_DOMAIN_DEVICE, R3D_PRIO_ONLY, ROW(cMoeGemmBf16), tMoeGemmBf16, NELEM(tMoeGemmBf16), moe_bf16_tune_valid, nullptr, nullptr, r3d_rad_moe_gemm_bf16, @@ -2101,16 +2240,139 @@ static const RadKernelInfo kKernels[] = { "expert of sorted row i", "16x16 tiles through LDS; the E4M3 activation and the E2M1 weight (decoded exactly to E4M3) " "upcast to f16 in registers, the f16 wave-matrix (f32 accumulate); the E8M0 weight scales fold " - "in f32 per 32 of K; the block walks the runs in its 16 rows; the even experts are `w` / " - "`w_scale`, the odd `w_odd` / `w_odd_scale`, at index e/2", + "in f32 per 32 of K; the block walks the runs in its 16 rows; the even experts are entry e/2 " + "of `w` / `w_scale`, the odd of `w_odd` / `w_odd_scale`", "E4M3 a with f32 a_scale per (row, 128 of K); E2M1 (packed, two a byte) weight tables with E8M0 " - "w_scale per (grid_rows columns, 32 of K); K % 128; y bf16 in sorted order", + "w_scale per (row, 32 of K); K % 128; equal classes; token or sorted a; y bf16 in sorted order", RAD_DOMAIN_DEVICE, R3D_PRIO_ONLY, ROW(cMoeGemmMxfp4), NOTUNE, nullptr, nullptr, r3d_rad_moe_gemm_mxfp4a8, nullptr, nullptr, nullptr, nullptr, nullptr }, + /* ------------------------------------------------------------------ r3d_moe_gemm_w4a8.hip + * + * The grouped int4 GEMM: the two's-complement int4 weight (nibbles, -8..7) against an int8 or + * E4M3 activation, one 128-block of K per scale fold. The int8 arm runs the exact i32 wave-matrix + * (no f16 rounding); the E4M3 arm the f16 wave-matrix (libr4d's form). A row of moe_gemm_q, + * selected by dtype=w4a8; the even experts in `w` / `w_scale`, the odd in `w_odd` / `w_odd_scale`. + */ + { "moe_gemm_w4a8", "moe_gemm_q", "moe", + "The grouped int4 GEMM over the expert-sorted rows: y[i] = a[sorted_tok[i]/top_k] @ w_e^T, e the " + "expert of sorted row i; the two's-complement int4 weight (nibbles, -8..7) against an int8 or " + "E4M3 activation, one 128-block of K per scale fold", + "16 sorted rows per block, eight waves of 16 columns; the block walks its expert runs, the " + "padding rows reading the run's first; the decode band (M * top_k <= 16 the tuned point, more " + "runs as extra 16-row blocks, prefill falls back to libavx); K % 128, N % 64; the even experts " + "are entry e/2 of `w` / `w_scale`, the odd of `w_odd` / `w_odd_scale`; token or sorted a", + "I4 (packed, two a byte) weight tables with a bf16 w_scale per (row, 128 of K); int8 a (an f32 " + "a_scale per (row, 128 of K)) or E4M3 a (an f32 a_scale); bf16 y in sorted order; the int8 arm is " + "bit-exact against the reference, the E4M3 arm to the f16 store ulp", + RAD_DOMAIN_DEVICE, R3D_PRIO_ONLY, + ROW(cMoeGemmQW4A8), tMoeGemmQW4, NELEM(tMoeGemmQW4), nullptr, + nullptr, nullptr, r3d_rad_moe_gemm_w4a8, + nullptr, nullptr, nullptr, + nullptr, nullptr }, + /* ------------------------------------------------------------------ r3d_moe_gemm_w4a4.hip + * + * The grouped int4xint4 GEMM: the two's-complement int4 weight AND int4 activation, one 128-block + * of K per scale fold. Both are widened to int8 and run on the exact i32 wave-matrix (no f16 + * rounding). A row of moe_gemm_q, selected by dtype=w4a4; the even experts in `w` / `w_scale`, the + * odd in `w_odd` / `w_odd_scale`. + */ + { "moe_gemm_w4a4", "moe_gemm_q", "moe", + "The grouped int4xint4 GEMM over the expert-sorted rows: y[i] = a[sorted_tok[i]/top_k] @ w_e^T, e " + "the expert of sorted row i; the two's-complement int4 weight and int4 activation, one 128-block " + "of K per scale fold", + "16 sorted rows per block, eight waves of 16 columns; the block walks its expert runs, the " + "padding rows reading the run's first; the decode band (M * top_k <= 16 the tuned point, more " + "runs as extra 16-row blocks, prefill falls back to libavx); K % 128, N % 64; the even experts " + "are entry e/2 of `w` / `w_scale`, the odd of `w_odd` / `w_odd_scale`; token or sorted a", + "I4 (packed, two a byte) weight tables with a bf16 w_scale per (row, 128 of K); int4 a (packed, " + "two a byte, an f32 a_scale per (row, 128 of K)); bf16 y in sorted order; bit-exact against the " + "reference", + RAD_DOMAIN_DEVICE, R3D_PRIO_ONLY, + ROW(cMoeGemmW4A4), tMoeGemmQW4, NELEM(tMoeGemmQW4), nullptr, + nullptr, nullptr, r3d_rad_moe_gemm_w4a4, + nullptr, nullptr, nullptr, + nullptr, nullptr }, + + /* ------------------------------------------------------------------ r3d_dequant_w4_bf16.hip + * + * The packed 4-bit weight back to a plain row-major bf16 [N, K], for the prefill path where + * W4A8 gains nothing. + */ + { "dequant_w4_bf16", "dequant_w4", "quant", + "The packed 4-bit weight back to a plain row-major bf16 [N, K]", + "One thread per packed dword scatters its eight nibbles to row-major bf16; the scale dword holds " + "the f16 scale low and -(1024+zero) high; N % 16, K % 64, group divides K", + "I4 (packed, two a byte) wq with an f16 ws scale per (row, group); bf16 y [N, K]; twos 1 = " + "symmetric two's-complement nibble, 0 = asymmetric unsigned nibble minus a per-group zero", + RAD_DOMAIN_DEVICE, R3D_PRIO_ONLY, + ROW(cDequantW4), NOTUNE, + nullptr, nullptr, r3d_rad_dequant_w4, + nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr }, + + { "rowtopk_merge", "row_topk_merge", "select", + "The R largest of the all-gathered per-rank candidate sets, one wave per row", + "One wave per row over world_size * R pairs; tk_insert into a 32-slot top-R heap, tk_round " + "extracts via a 5-step xor-butterfly; ties break on the lower id; R <= 32", + "f32 g (M * world_size * R * 2), i32 idx (M * R), f32 val (M * R); R <= 32", + RAD_DOMAIN_DEVICE, R3D_PRIO_ONLY, + ROW(cRowTopkMerge), NOTUNE, + nullptr, nullptr, r3d_rad_row_topk_merge, + nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr }, + + { "ngram_ids_i32", "ngram_ids", "vocab", + "The hashed row ids of the Per-Layer Embedding: mixed(k) = XOR of t_s * mult[s], " + "ids[h] = mixed % vocab_sizes[h] + offsets[h]", + "One thread a token, looping its heads; n-gram shifts with EOS walk; 64-bit wrapping " + "multiply and floor-mod; ngram <= 8, heads divisible by (ngram-1)", + "i32 tok, i32 state, i32 cu, i64 mult, i64 vsz, i64 off, i32 ids; " + "optional i32 cidx, hini, nacc, ahead", + RAD_DOMAIN_DEVICE, R3D_PRIO_ONLY, + ROW(cNgramIds), NOTUNE, + nullptr, nullptr, r3d_rad_ngram_ids, + nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr }, + + { "gemm_nt_q_bias_fp8a8_m16", "gemm_nt_q_bias", "gemm", + "The narrow fp8 GEMM with a per-column bias epilogue: y = a @ b^T + bias", + "M <= 16, K a multiple of the block; fp8a8 codes and scales, bf16 bias and output; " + "GEMM then bias-add in two passes", + "fp8_e4m3 a and b, f32 scales, bf16 bias [N], bf16 y [M,N]", + RAD_DOMAIN_DEVICE, R3D_PRIO_GEMM_FP8, + ROW(cGemmQBias), tGemmM16, NELEM(tGemmM16), nullptr, + nullptr, nullptr, r3d_rad_gemm_nt_q_bias_fp8, + nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr }, + + { "gemm_nt_q_short_fp8a8_m16", "gemm_nt_q_short", "gemm", + "The narrow fp8 GEMM with the short-prompt split rule: unsplit at N <= 512, K <= 5120, " + "41..64 rows", + "M <= 64, K a multiple of 128, N a multiple of 16; fp8a8 codes and scales, bf16 output; " + "sk=1 forced (no split)", + "fp8_e4m3 a and b, f32/bf16 scales, bf16 y [M,N]", + RAD_DOMAIN_DEVICE, R3D_PRIO_GEMM_FP8, + ROW(cGemmQShort), tGemmM16, NELEM(tGemmM16), nullptr, + nullptr, nullptr, r3d_rad_gemm_nt_q_short_fp8, + nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr }, + + { "moe_gemm_q_mod4_e4m3", "moe_gemm_q_mod4", "moe", + "The grouped quantised GEMM with 4 expert classes: y[i] = a[sorted_tok[i]/top_k] @ w_e^T, " + "e%4 picks the class", + "same as moe_gemm_q_e4m3 but 4-class routing; group = 128; the class shapes default to N/K " + "and an unequal N_1..K_3 is refused; token or sorted a", + "E4M3 a and weight tables (4 classes), f32 a_scale and w_scale; y bf16 in sorted order", + RAD_DOMAIN_DEVICE, R3D_PRIO_ONLY, + ROW(cMoeGemmQMod4), tMoeGemmQW4, NELEM(tMoeGemmQW4), nullptr, + nullptr, nullptr, r3d_rad_moe_gemm_q_mod4, + nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr }, + /* ------------------------------------------------------------------ r3d_gdn_recurrent_update_k128_v128.hip * * The gated-delta-net recurrent state update at decode: the per-token state step against a paged @@ -2120,13 +2382,27 @@ static const RadKernelInfo kKernels[] = { { "gdn_recurrent_update_k128_v128", "gdn_recurrent_update", "gdn", "The gated-delta-net recurrent state update at decode: S *= e^g, u = beta (v - S k), S += u k^T, " "o = S q per token", - "head_k 128, head_v 128, fp32 state cache; the state stays in registers, one thread per v row " - "and half its k range; the gated RMS norm is folded in when z and norm_w are present", - "bf16 q, k, v, o and a/b (or f32 a/b), f32 A_log, dt_bias and the state cache; `state_idx` the " - "per-token slot, `num_accepted` the window offset", + "head_k 128, head_v 128, paged state in either form: per_candidate (one state per candidate " + "token) or anchor (one committed state and a replay scratch slot a sequence); the gated RMS " + "norm folded in when z and norm_w are present (libhalo's kernel, r3dh_gdn_recurrent_update.hip)", + "bf16 q, k, v and o, f32 a/b, A_log and dt_bias; the state cache is f32 or f16 and the operand " + "says which", RAD_DOMAIN_DEVICE, R3D_PRIO_ONLY, ROW(cGdnRecurrent), NOTUNE, - nullptr, nullptr, r3d_rad_gdn_recurrent_update, + nullptr, nullptr, r3dh_rad_gdn_recurrent_update, + nullptr, nullptr, nullptr, + nullptr, nullptr }, + +{ "gdn_conv_recurrent_update_k128_v128", "gdn_conv_recurrent_update", "gdn", + "The gated-delta-net decode step as one kernel: the rolling-window conv and the recurrent state " + "update, with q, k and v never materialised", + "head_k 128, head_v 128, conv width 4; the speculative window (state_len_max - 2) must fit the " + "register buffer; the gated RMS norm is folded in (z and norm_w are required); the state cache " + "is f32 or f16 (libhalo's kernel, r3dh_gdn_recurrent_update.hip)", + "bf16 x and o, f32 a, b, A_log, dt_bias and norm_w, the conv state bf16, the state f32 or f16", + RAD_DOMAIN_DEVICE, R3D_PRIO_ONLY, + ROW(cGdnConvRecurrent), NOTUNE, + nullptr, nullptr, r3dh_rad_gdn_conv_recurrent_update, nullptr, nullptr, nullptr, nullptr, nullptr }, @@ -2296,7 +2572,7 @@ static const RadKernelInfo kKernels[] = { "one read of the logits plane where the reference reads it three (max, sum, k-list); the sum is " "SUM exp(v - max) in DOUBLE, the reference's law, and a row's k-list is one insertion list in " "registers, not an upper_bound per element; stats is [M][2 + 2k], and rows the flag leaves alone " - "are not written", + "are not written (no params at all: every row runs)", "f32 logits, f32 params, f32 stats; k <= 64 is the pool's depth and above it the shim refuses " "(RAD_E_UNSUPPORTED); on a row that contains a NaN the reference's list freezes at the first k it " "saw: once a NaN sits in the k-list's tail, every later real value fails the tail's compare " @@ -2752,3 +3028,33 @@ static const RadPluginInfo kInfo = { extern "C" uint32_t rad_plugin_abi_version(void) { return RAD_ABI_VERSION; } RAD_PLUGIN_ABI_LAYOUT_EXPORT extern "C" const RadPluginInfo* rad_plugin_info(void) { return &kInfo; } + +/* libr3d declines a machine with no gfx11 card. The loader would leave its device rows out there + * (no code object fits), but rad-convert and the other tools resolve kernels without that check, + * and libr3d, ahead of libr4d in file-name order, would choose the stored form of every weight it + * has a row for: an RDNA4 container laid out for RDNA3 kernels, or one weight wanted in two forms. + * + * The test reads the KFD topology (gfx_target_version 110000..119999 is the gfx11 family) rather + * than asking a runtime, which open must not initialise. KFD lists only the cards the process may + * open, so a container without /dev/kfd sees the CPU node alone; with no topology at all there is + * no card, and the library declines too. */ +extern "C" int rad_plugin_open(void) { + const char* root = "/sys/class/kfd/kfd/topology/nodes"; + DIR* d = opendir(root); + if (!d) return RAD_E_UNSUPPORTED; + bool gfx11 = false; + while (const dirent* e = readdir(d)) { + if (e->d_name[0] == '.') continue; + const std::string path = std::string(root) + "/" + e->d_name + "/properties"; + FILE* f = std::fopen(path.c_str(), "r"); + if (!f) continue; + char key[64]; + unsigned long long v = 0; + while (std::fscanf(f, "%63s %llu", key, &v) == 2) + if (!std::strcmp(key, "gfx_target_version") && v >= 110000ull && v < 120000ull) + gfx11 = true; + std::fclose(f); + } + closedir(d); + return gfx11 ? RAD_OK : RAD_E_UNSUPPORTED; +} diff --git a/libr3d/r3d_rowtopk_merge.hip b/libr3d/r3d_rowtopk_merge.hip new file mode 100644 index 00000000..0dd8e42e --- /dev/null +++ b/libr3d/r3d_rowtopk_merge.hip @@ -0,0 +1,112 @@ +// r3d_rowtopk_merge.hip -- row_topk_merge: the R largest of the all-gathered per-rank candidate +// sets. One wave per row over world_size * R pairs; the cost is its launch, it only has to be +// exact. +#include +#include +#include "r3d.h" +#include "r3d_args.h" +#include "r3d_common.h" +#include "r3d_launch.h" + +#define R3D_TOPK_WAVE 32 +#define R3D_TOPK_PT2 32 // >= R, so a lane can hold the whole answer + +__device__ __forceinline__ unsigned long long r3d_tk_key_f32(float v, unsigned idx) { + unsigned fu = __float_as_uint(v); + fu = (fu & 0x80000000u) ? ~fu : (fu | 0x80000000u); + return ((unsigned long long)fu << 32) | (unsigned)(0xFFFFFFFFu - idx); +} + +__device__ __forceinline__ float r3d_tk_val(unsigned long long k) { + unsigned u = (unsigned)(k >> 32); + u = (u & 0x80000000u) ? (u & 0x7FFFFFFFu) : ~u; + return __uint_as_float(u); +} + +__device__ __forceinline__ int r3d_tk_idx(unsigned long long k) { + return (int)(0xFFFFFFFFu - (unsigned)(k & 0xFFFFFFFFull)); +} + +template +__device__ __forceinline__ unsigned long long r3d_tk_xor_max(unsigned long long m) { + const unsigned long long p = r3d_xor_lane_u64(m); + return p > m ? p : m; +} + +template +__device__ __forceinline__ void r3d_tk_insert(unsigned long long* t, unsigned long long k) { + if (k > t[PT - 1]) { + unsigned long long c = k; +#pragma unroll + for (int q = 0; q < PT; q++) { + const unsigned long long hi = t[q] > c ? t[q] : c; + c = t[q] > c ? c : t[q]; + t[q] = hi; + } + } +} + +template +__device__ __forceinline__ unsigned long long r3d_tk_round(unsigned long long* t) { + unsigned long long m = t[0]; + m = r3d_tk_xor_max<16>(m); + m = r3d_tk_xor_max<8>(m); + m = r3d_tk_xor_max<4>(m); + m = r3d_tk_xor_max<2>(m); + m = r3d_tk_xor_max<1>(m); + if (m == t[0]) { + // Drop the head and re-sort: shift the rest down, 0 at the tail. +#pragma unroll + for (int q = 0; q < PT - 1; q++) t[q] = t[q + 1]; + t[PT - 1] = 0ull; + } + return m; +} + +__global__ __launch_bounds__(R3D_TOPK_WAVE) void r3d_rowtopk_merge_kernel( + const float* __restrict__ G, float* __restrict__ OV, int* __restrict__ OI, int R, int n) +{ + const int m = blockIdx.x; + const int lane = threadIdx.x; + + unsigned long long t[R3D_TOPK_PT2]; +#pragma unroll + for (int q = 0; q < R3D_TOPK_PT2; q++) t[q] = 0ull; + + const float* const row = G + (size_t)m * n * 2; + for (int i = lane; i < n; i += R3D_TOPK_WAVE) { + int id; + __builtin_memcpy(&id, row + (size_t)i * 2, sizeof(int)); + if (id < 0) continue; + r3d_tk_insert(t, r3d_tk_key_f32(row[(size_t)i * 2 + 1], (unsigned)id)); + } + + for (int r = 0; r < R; r++) { + const unsigned long long w = r3d_tk_round(t); + if (lane == 0) { + OV[(size_t)m * R + r] = w ? r3d_tk_val(w) : -INFINITY; + OI[(size_t)m * R + r] = w ? r3d_tk_idx(w) : -1; + } + } +} + +extern "C" int r3d_rad_row_topk_merge(const RadArgs* a, RadStream s) +{ + const RadTensor* g = r3d_opt(a, 0); + const RadTensor* idx = r3d_opt(a, 1); + const RadTensor* val = r3d_opt(a, 2); + if (!r3d_p(g) || !r3d_p(idx) || !r3d_wp(val)) return R3D_NO(RAD_E_INVAL); + if (g->dtype != RAD_F32) return R3D_NO(RAD_E_DTYPE); + + const long long M = (g->rank >= 1) ? g->shape[0] : r3d_geti_or(a, "M", 0); + const long long R = r3d_geti_or(a, "R", 0); + const long long W = r3d_geti_or(a, "world_size", 0); + if (M < 1 || R < 1 || W < 1) return R3D_NO(RAD_E_SHAPE); + if (R > 32) return R3D_NO(RAD_E_SHAPE); + + dim3 grid((unsigned)M), blk(R3D_TOPK_WAVE); + R3D_KLAUNCH(r3d_rowtopk_merge_kernel, grid, blk, (hipStream_t)s, + (const float*)r3d_p(g), (float*)r3d_wp(val), (int*)r3d_wp(idx), + (int)R, (int)(W * R)); + return (int)hipGetLastError(); +} diff --git a/libr3d/r3d_sample_pre_f32.hip b/libr3d/r3d_sample_pre_f32.hip index e48c5568..567fcfe6 100644 --- a/libr3d/r3d_sample_pre_f32.hip +++ b/libr3d/r3d_sample_pre_f32.hip @@ -189,7 +189,7 @@ __global__ __launch_bounds__(THR) void sample_logprobs_kernel( float* __restrict__ st, uint32_t n, uint32_t k, uint32_t lg_ld, uint32_t st_ld, int32_t voff) { const uint32_t row = blockIdx.x; - if (!(pr[row].flags & RAD_SP_LOGPROBS)) return; + if (pr && !(pr[row].flags & RAD_SP_LOGPROBS)) return; /* no params: every row */ Acc a; a.mx = -INFINITY; @@ -570,7 +570,7 @@ static inline int logits_rows(const RadArgs* a, const RadTensor* lg, long long* extern "C" int r3d_sample_logprobs(long lg, long params, long stats, int M, int n_vocab, int k, long long lg_ld, long long stats_ld, int vocab_off, long stream) { - if (!lg || !params || !stats) return -1; + if (!lg || !stats) return -1; if (M <= 0 || n_vocab <= 0 || k <= 0) return -2; if (k > kKMax) return -2; if (!lg_ld) lg_ld = n_vocab; diff --git a/libr3d/r3d_selftest.cpp b/libr3d/r3d_selftest.cpp index bbdb99b2..b0101328 100644 --- a/libr3d/r3d_selftest.cpp +++ b/libr3d/r3d_selftest.cpp @@ -1774,16 +1774,23 @@ static int build_moe_scatter(Case& c, const RadOpSchema* s) { return 0; } +/* moe_gemm_q at fp8a8f32 (the e4m3 row's dtype): E4M3 activation and experts, an f32 scale per + * (row, 128 of K) and per 128x128 tile of each expert, the even/odd weight tables stacked, y bf16. */ static int build_moe_gemm_q(Case& c, const RadOpSchema* s) { - const long long M = 8, N = 128, K = 128, NE = 8, TK = 2, GR = 1; // T = 16; N % 128 - const long long T = M * TK, NE0 = (NE + 1) / 2, NE1 = NE / 2; - if (s->n_operands != 9) { fail("moe_gemm_q: the schema has %d operands, not 9", - s->n_operands); return 1; } + constexpr int NOPD = 9; + const long long M = 8, N = 128, K = 128, NE = 8, TK = 2; // T = 16; N % 128 + const long long T = M * TK, NE0 = (NE + 1) / 2, NE1 = NE / 2, NB = (N + 127) / 128; + if (s->n_operands != NOPD) { fail("moe_gemm_q: the schema has %d operands, not 9", + s->n_operands); return 1; } c.n_p = 0; - const RadParam pp[] = { { "n_expert", RAD_P_INT, NE, 0, nullptr, 0.0 }, + const RadParam pp[] = { { "M", RAD_P_INT, T, 0, nullptr, 0.0 }, + { "N", RAD_P_INT, N, 0, nullptr, 0.0 }, + { "K", RAD_P_INT, K, 0, nullptr, 0.0 }, + { "n_expert", RAD_P_INT, NE, 0, nullptr, 0.0 }, { "top_k", RAD_P_INT, TK, 0, nullptr, 0.0 }, - { "grid_rows", RAD_P_INT, GR, 0, nullptr, 0.0 }, - { "dtype", RAD_P_STR, 0, 0, (const char*)"w4a8", 0.0 } }; + { "group", RAD_P_INT, 128, 0, nullptr, 0.0 }, + { "a_order", RAD_P_STR, 0, 0, (const char*)"token", 0.0 }, + { "dtype", RAD_P_STR, 0, 0, (const char*)"fp8a8f32", 0.0 } }; for (const RadParam& q : pp) c.p[c.n_p++] = q; uint32_t st = 0x0E0E5A1Cu; @@ -1795,8 +1802,8 @@ static int build_moe_gemm_q(Case& c, const RadOpSchema* s) { for (auto& x : ha) x = re4(); for (auto& x : hw0) x = re4(); for (auto& x : hw1) x = re4(); - std::vector hA((size_t)M * (K / 128)), hW0((size_t)NE0 * (N / GR) * (K / 128)), - hW1((size_t)NE1 * (N / GR) * (K / 128)); + std::vector hA((size_t)M * (K / 128)), hW0((size_t)NE0 * NB * (K / 128)), + hW1((size_t)NE1 * NB * (K / 128)); for (auto& x : hA) x = rndf(); for (auto& x : hW0) x = rndf(); for (auto& x : hW1) x = rndf(); @@ -1805,21 +1812,22 @@ static int build_moe_gemm_q(Case& c, const RadOpSchema* s) { for (long long e = 0; e < NE; ++e) ho[e] = (int32_t)(e * (T / NE)); ho[NE] = (int32_t)T; - struct { uint32_t dt; int rank; long long sh[3]; long long nel; } qd[9] = { + // The contract's order: a, a_scale, w, w_scale, sorted_tok, expert_offset, w_odd, w_odd_scale, y. + struct { uint32_t dt; int rank; long long sh[3]; long long nel; } qd[NOPD] = { { RAD_F8E4M3, 2, { M, K, 1 }, M * K }, { RAD_F32, 2, { M, K / 128, 1 }, M * (K / 128) }, + { RAD_F8E4M3, 3, { NE0, N, K }, NE0 * N * K }, + { RAD_F32, 3, { NE0, NB, K / 128 }, NE0 * NB * (K / 128) }, { RAD_I32, 1, { T, 1, 1 }, T }, { RAD_I32, 1, { NE + 1, 1, 1 }, NE + 1 }, - { RAD_F8E4M3, 3, { NE0, N, K }, NE0 * N * K }, - { RAD_F32, 3, { NE0, N / GR, K / 128 }, NE0 * (N / GR) * (K / 128) }, { RAD_F8E4M3, 3, { NE1, N, K }, NE1 * N * K }, - { RAD_F32, 3, { NE1, N / GR, K / 128 }, NE1 * (N / GR) * (K / 128) }, - { RAD_F32, 2, { T, N, 1 }, T * N } }; - const uint32_t bytes_of[] = { 1, 4, 4, 4, 1, 4, 1, 4, 4 }; - const void* src[] = { ha.data(), hA.data(), hs.data(), ho.data(), hw0.data(), hW0.data(), - hw1.data(), hW1.data(), nullptr }; - for (int o = 0; o < 9; ++o) { - const size_t bytes = (size_t)qd[o].nel * bytes_of[o]; + { RAD_F32, 3, { NE1, NB, K / 128 }, NE1 * NB * (K / 128) }, + { RAD_BF16, 2, { T, N, 1 }, T * N } }; + const uint32_t bits_of[NOPD] = { 8, 32, 8, 32, 32, 32, 8, 32, 16 }; + const void* src[NOPD] = { ha.data(), hA.data(), hw0.data(), hW0.data(), hs.data(), ho.data(), + hw1.data(), hW1.data(), nullptr }; + for (int o = 0; o < NOPD; ++o) { + const size_t bytes = (size_t)((qd[o].nel * bits_of[o] + 7) / 8); void* d = nullptr; if (hipMalloc(&d, bytes) != hipSuccess) { fail("moe_gemm_q: hipMalloc(%zu) failed", bytes); return 1; } @@ -1829,19 +1837,25 @@ static int build_moe_gemm_q(Case& c, const RadOpSchema* s) { t = RadTensor{}; t.data = d; t.dtype = qd[o].dt; t.rank = qd[o].rank; for (int r = 0; r < qd[o].rank; ++r) { t.shape[r] = qd[o].sh[r]; t.stride[r] = 1; } - for (int r = 0; r + 1 < qd[o].rank; ++r) t.stride[r] = t.shape[r + 1] * t.stride[r + 1]; + rad_tensor_pack(&t); /* dense row-major: the ascending form computes stride[0] before stride[1] */ } return 0; } static int build_moe_gemm_bf16(Case& c, const RadOpSchema* s) { + constexpr int NOPD = 5; const long long M = 8, N = 128, K = 64, NE = 8, TK = 2; // T = 16; N % 128, K % 64 const long long T = M * TK; - if (s->n_operands != 5) { fail("moe_gemm_bf16: the schema has %d operands, not 5", - s->n_operands); return 1; } + if (s->n_operands != NOPD) { fail("moe_gemm_bf16: the schema has %d operands, not 5", + s->n_operands); return 1; } c.n_p = 0; - const RadParam pp[] = { { "n_expert", RAD_P_INT, NE, 0, nullptr, 0.0 }, - { "top_k", RAD_P_INT, TK, 0, nullptr, 0.0 } }; + const RadParam pp[] = { { "M", RAD_P_INT, T, 0, nullptr, 0.0 }, + { "N", RAD_P_INT, N, 0, nullptr, 0.0 }, + { "K", RAD_P_INT, K, 0, nullptr, 0.0 }, + { "n_expert", RAD_P_INT, NE, 0, nullptr, 0.0 }, + { "top_k", RAD_P_INT, TK, 0, nullptr, 0.0 }, + { "a_order", RAD_P_STR, 0, 0, (const char*)"token", 0.0 }, + { "dtype", RAD_P_STR, 0, 0, (const char*)"bf16", 0.0 } }; for (const RadParam& q : pp) c.p[c.n_p++] = q; uint32_t st = 0x1A2B3C4Du; @@ -1855,16 +1869,17 @@ static int build_moe_gemm_bf16(Case& c, const RadOpSchema* s) { for (long long e = 0; e < NE; ++e) ho[e] = (int32_t)(e * (T / NE)); ho[NE] = (int32_t)T; - struct { uint32_t dt; int rank; long long sh[3]; long long nel; } qd[5] = { + // The contract's order: a, w (one stacked table), sorted_tok, expert_offset, y. + struct { uint32_t dt; int rank; long long sh[3]; long long nel; } qd[NOPD] = { { RAD_BF16, 2, { M, K, 1 }, M * K }, { RAD_BF16, 3, { NE, N, K }, NE * N * K }, { RAD_I32, 1, { T, 1, 1 }, T }, { RAD_I32, 1, { NE + 1, 1, 1 }, NE + 1 }, { RAD_BF16, 2, { T, N, 1 }, T * N } }; - const uint32_t bytes_of[] = { 2, 2, 4, 4, 2 }; - const void* src[] = { ha.data(), hw.data(), hs.data(), ho.data(), nullptr }; - for (int o = 0; o < 5; ++o) { - const size_t bytes = (size_t)qd[o].nel * bytes_of[o]; + const uint32_t bits_of[NOPD] = { 16, 16, 32, 32, 16 }; + const void* src[NOPD] = { ha.data(), hw.data(), hs.data(), ho.data(), nullptr }; + for (int o = 0; o < NOPD; ++o) { + const size_t bytes = (size_t)((qd[o].nel * bits_of[o] + 7) / 8); void* d = nullptr; if (hipMalloc(&d, bytes) != hipSuccess) { fail("moe_gemm_bf16: hipMalloc(%zu) failed", bytes); return 1; } @@ -1874,20 +1889,27 @@ static int build_moe_gemm_bf16(Case& c, const RadOpSchema* s) { t = RadTensor{}; t.data = d; t.dtype = qd[o].dt; t.rank = qd[o].rank; for (int r = 0; r < qd[o].rank; ++r) { t.shape[r] = qd[o].sh[r]; t.stride[r] = 1; } - for (int r = 0; r + 1 < qd[o].rank; ++r) t.stride[r] = t.shape[r + 1] * t.stride[r + 1]; + rad_tensor_pack(&t); /* dense row-major: the ascending form computes stride[0] before stride[1] */ } return 0; } +/* moe_gemm_q at mxfp4a8: E4M3 activation with an f32 scale per (row, 128 of K); E2M1 experts (two + * codes a byte, shaped in codes) with an E8M0 exponent per (row, 32 of K), typed raw u8; y bf16. */ static int build_moe_gemm_mxfp4a8(Case& c, const RadOpSchema* s) { - const long long M = 8, N = 128, K = 128, NE = 8, TK = 2, GR = 1; // T = 16; N % 128 + constexpr int NOPD = 9; + const long long M = 8, N = 128, K = 128, NE = 8, TK = 2; // T = 16; N % 128 const long long T = M * TK, NE0 = (NE + 1) / 2, NE1 = NE / 2; - if (s->n_operands != 9) { fail("moe_gemm_mxfp4a8: the schema has %d operands, not 9", - s->n_operands); return 1; } + if (s->n_operands != NOPD) { fail("moe_gemm_mxfp4a8: the schema has %d operands, not 9", + s->n_operands); return 1; } c.n_p = 0; - const RadParam pp[] = { { "n_expert", RAD_P_INT, NE, 0, nullptr, 0.0 }, + const RadParam pp[] = { { "M", RAD_P_INT, T, 0, nullptr, 0.0 }, + { "N", RAD_P_INT, N, 0, nullptr, 0.0 }, + { "K", RAD_P_INT, K, 0, nullptr, 0.0 }, + { "n_expert", RAD_P_INT, NE, 0, nullptr, 0.0 }, { "top_k", RAD_P_INT, TK, 0, nullptr, 0.0 }, - { "grid_rows", RAD_P_INT, GR, 0, nullptr, 0.0 }, + { "group", RAD_P_INT, 128, 0, nullptr, 0.0 }, + { "a_order", RAD_P_STR, 0, 0, (const char*)"token", 0.0 }, { "dtype", RAD_P_STR, 0, 0, (const char*)"mxfp4a8", 0.0 } }; for (const RadParam& q : pp) c.p[c.n_p++] = q; @@ -1895,15 +1917,14 @@ static int build_moe_gemm_mxfp4a8(Case& c, const RadOpSchema* s) { auto rnd = [&]() { st = st * 1664525u + 1013904223u; return (st >> 8) & 0xffu; }; auto rndf = [&]() { st = st * 1664525u + 1013904223u; return 0.5f + ((st >> 8) & 0xff) / 255.0f; }; auto re4 = [&]() { return (uint8_t)(((rnd() & 0x7) | 1) << 3 | (rnd() & 0x7) | ((rnd() & 1) << 7)); }; - auto re2 = [&]() { return (uint8_t)(rnd() & 0xF); }; // E2M1 code (4 bits) + auto re2x2 = [&]() { return (uint8_t)(rnd() & 0xFF); }; // two E2M1 codes auto re8 = [&]() { return (uint8_t)(120 + (rnd() & 14)); }; // E8M0 near 1.0 (exp 120..133) std::vector ha((size_t)M * K), hw0((size_t)NE0 * N * (K / 2)), hw1((size_t)NE1 * N * (K / 2)); for (auto& x : ha) x = re4(); - for (auto& x : hw0) x = re2(); - for (auto& x : hw1) x = re2(); + for (auto& x : hw0) x = re2x2(); + for (auto& x : hw1) x = re2x2(); std::vector hA((size_t)M * (K / 128)); - std::vector hW0((size_t)NE0 * (N / GR) * (K / 32)), - hW1((size_t)NE1 * (N / GR) * (K / 32)); + std::vector hW0((size_t)NE0 * N * (K / 32)), hW1((size_t)NE1 * N * (K / 32)); for (auto& x : hA) x = rndf(); for (auto& x : hW0) x = re8(); for (auto& x : hW1) x = re8(); @@ -1912,21 +1933,22 @@ static int build_moe_gemm_mxfp4a8(Case& c, const RadOpSchema* s) { for (long long e = 0; e < NE; ++e) ho[e] = (int32_t)(e * (T / NE)); ho[NE] = (int32_t)T; - struct { uint32_t dt; int rank; long long sh[3]; long long nel; } qd[9] = { + // The contract's order: a, a_scale, w, w_scale, sorted_tok, expert_offset, w_odd, w_odd_scale, y. + struct { uint32_t dt; int rank; long long sh[3]; long long nel; } qd[NOPD] = { { RAD_F8E4M3, 2, { M, K, 1 }, M * K }, { RAD_F32, 2, { M, K / 128, 1 }, M * (K / 128) }, + { RAD_FP4E2M1, 3, { NE0, N, K }, NE0 * N * K }, + { RAD_U8, 3, { NE0, N, K / 32 }, NE0 * N * (K / 32) }, { RAD_I32, 1, { T, 1, 1 }, T }, { RAD_I32, 1, { NE + 1, 1, 1 }, NE + 1 }, - { RAD_FP4E2M1, 3, { NE0, N, K / 2 }, NE0 * N * (K / 2) }, - { RAD_U8, 3, { NE0, N / GR, K / 32 }, NE0 * (N / GR) * (K / 32) }, - { RAD_FP4E2M1, 3, { NE1, N, K / 2 }, NE1 * N * (K / 2) }, - { RAD_U8, 3, { NE1, N / GR, K / 32 }, NE1 * (N / GR) * (K / 32) }, + { RAD_FP4E2M1, 3, { NE1, N, K }, NE1 * N * K }, + { RAD_U8, 3, { NE1, N, K / 32 }, NE1 * N * (K / 32) }, { RAD_BF16, 2, { T, N, 1 }, T * N } }; - const uint32_t bytes_of[] = { 1, 4, 4, 4, 1, 1, 1, 1, 2 }; - const void* src[] = { ha.data(), hA.data(), hs.data(), ho.data(), hw0.data(), hW0.data(), - hw1.data(), hW1.data(), nullptr }; - for (int o = 0; o < 9; ++o) { - const size_t bytes = (size_t)qd[o].nel * bytes_of[o]; + const uint32_t bits_of[NOPD] = { 8, 32, 4, 8, 32, 32, 4, 8, 16 }; + const void* src[NOPD] = { ha.data(), hA.data(), hw0.data(), hW0.data(), hs.data(), ho.data(), + hw1.data(), hW1.data(), nullptr }; + for (int o = 0; o < NOPD; ++o) { + const size_t bytes = (size_t)((qd[o].nel * bits_of[o] + 7) / 8); void* d = nullptr; if (hipMalloc(&d, bytes) != hipSuccess) { fail("moe_gemm_mxfp4a8: hipMalloc(%zu) failed", bytes); return 1; } @@ -1936,7 +1958,93 @@ static int build_moe_gemm_mxfp4a8(Case& c, const RadOpSchema* s) { t = RadTensor{}; t.data = d; t.dtype = qd[o].dt; t.rank = qd[o].rank; for (int r = 0; r < qd[o].rank; ++r) { t.shape[r] = qd[o].sh[r]; t.stride[r] = 1; } - for (int r = 0; r + 1 < qd[o].rank; ++r) t.stride[r] = t.shape[r + 1] * t.stride[r + 1]; + rad_tensor_pack(&t); /* dense row-major: the ascending form computes stride[0] before stride[1] */ + } + return 0; +} + +/* moe_gemm_q dtype w4a8: an int8 activation (an f32 scale per (row, 128 of K)) and two's-complement + * int4 experts (a bf16 scale per (row, 128 of K)), two stacked weight tables by parity (the even in + * `w` / `w_scale`, the odd in `w_odd` / `w_odd_scale`), token-order a, y bf16. Every sorted row is + * owned (no dropped slots), so the kernel writes all of y; the NaN prefill catches a launch that + * skips rows. */ +static int build_moe_gemm_w4a8(Case& c, const RadOpSchema* s) { + constexpr int NOPD = 9; + const long long M = 6, N = 96, K = 256, NE = 4, TK = 4; // T = 24, six rows per expert + const long long T = M * TK; + const long long ne0 = (NE + 1) / 2, ne1 = NE / 2; + if (s->n_operands != NOPD) { fail("moe_gemm_w4a8: the schema has %d operands, not 9", + s->n_operands); return 1; } + c.n_p = 0; + const RadParam pp[] = { { "M", RAD_P_INT, M, 0, nullptr, 0.0 }, + { "N", RAD_P_INT, N, 0, nullptr, 0.0 }, + { "K", RAD_P_INT, K, 0, nullptr, 0.0 }, + { "n_expert", RAD_P_INT, NE, 0, nullptr, 0.0 }, + { "top_k", RAD_P_INT, TK, 0, nullptr, 0.0 }, + { "group", RAD_P_INT, 128, 0, nullptr, 0.0 }, + { "a_order", RAD_P_STR, 0, 0, (const char*)"token", 0.0 }, + { "dtype", RAD_P_STR, 0, 0, (const char*)"w4a8", 0.0 }, + { "N_odd", RAD_P_INT, N, 0, nullptr, 0.0 }, + { "K_odd", RAD_P_INT, K, 0, nullptr, 0.0 }, + { "parts", RAD_P_INT, 1, 0, nullptr, 0.0 } }; + for (const RadParam& q : pp) c.p[c.n_p++] = q; + + uint32_t st = 0x74A8C0Deu; + auto rnd = [&]() { st = st * 1664525u + 1013904223u; return (st >> 8) & 0xffu; }; + auto rndf = [&]() { st = st * 1664525u + 1013904223u; return 0.5f + ((st >> 8) & 0xff) / 255.0f; }; + auto to_bf16 = [](float f) { return (uint16_t)(__builtin_bit_cast(uint32_t, f) >> 16); }; + std::vector ha((size_t)M * K); + for (auto& x : ha) x = (int8_t)((rnd() & 7) - 4); // -4..4 + std::vector hA((size_t)M * (K / 128)); + for (auto& x : hA) x = rndf(); + // The weight codes and bf16 scales for all NE experts, then split by parity. + std::vector hw((size_t)NE * N * (K / 2)); + for (auto& x : hw) x = (uint8_t)(rnd() & 0xFFu); + std::vector hsce((size_t)NE * N * (K / 128)); + for (auto& x : hsce) x = to_bf16(rndf()); + std::vector hs(T), ho(NE + 1); + for (long long i = 0; i < T; ++i) hs[i] = (int32_t)i; + for (long long e = 0; e < NE; ++e) ho[e] = (int32_t)(e * (T / NE)); + ho[NE] = (int32_t)T; + std::vector hy((size_t)T * N); + for (auto& x : hy) x = 0x7fc0u; // bf16 NaN prefill + std::vector hwe((size_t)ne0 * N * (K / 2)), hwo((size_t)ne1 * N * (K / 2)); + std::vector hse((size_t)ne0 * N * (K / 128)), hso((size_t)ne1 * N * (K / 128)); + for (long long e = 0; e < NE; ++e) { + const bool odd = e & 1; + const long long ix = e >> 1; + std::memcpy((odd ? hwo.data() : hwe.data()) + (size_t)ix * N * (K / 2), + hw.data() + (size_t)e * N * (K / 2), (size_t)N * (K / 2)); + std::memcpy((odd ? hso.data() : hse.data()) + (size_t)ix * N * (K / 128), + hsce.data() + (size_t)e * N * (K / 128), (size_t)N * (K / 128) * sizeof(uint16_t)); + } + + // The contract's order: a, a_scale, w, w_scale, sorted_tok, expert_offset, w_odd, w_odd_scale, y. + struct { uint32_t dt; int rank; long long sh[3]; long long nel; } qd[NOPD] = { + { RAD_I8, 2, { M, K, 1 }, M * K }, + { RAD_F32, 2, { M, K / 128, 1 }, M * (K / 128) }, + { RAD_I4, 3, { ne0, N, K }, ne0 * N * K }, + { RAD_BF16, 3, { ne0, N, K / 128 }, ne0 * N * (K / 128) }, + { RAD_I32, 1, { T, 1, 1 }, T }, + { RAD_I32, 1, { NE + 1, 1, 1 }, NE + 1 }, + { RAD_I4, 3, { ne1, N, K }, ne1 * N * K }, + { RAD_BF16, 3, { ne1, N, K / 128 }, ne1 * N * (K / 128) }, + { RAD_BF16, 2, { T, N, 1 }, T * N } }; + const uint32_t bits_of[NOPD] = { 8, 32, 4, 16, 32, 32, 4, 16, 16 }; + const void* src[NOPD] = { ha.data(), hA.data(), hwe.data(), hse.data(), hs.data(), ho.data(), + hwo.data(), hso.data(), hy.data() }; + for (int o = 0; o < NOPD; ++o) { + const size_t bytes = (size_t)((qd[o].nel * bits_of[o] + 7) / 8); + void* d = nullptr; + if (hipMalloc(&d, bytes) != hipSuccess) { fail("moe_gemm_w4a8: hipMalloc(%zu) failed", bytes); + return 1; } + c.dev.push_back(d); + if (src[o]) std::memcpy(d, src[o], bytes); + RadTensor& t = c.t[o]; + t = RadTensor{}; + t.data = d; t.dtype = qd[o].dt; t.rank = qd[o].rank; + for (int r = 0; r < qd[o].rank; ++r) { t.shape[r] = qd[o].sh[r]; t.stride[r] = 1; } + rad_tensor_pack(&t); } return 0; } @@ -1995,6 +2103,7 @@ static int build_moe_router_sigmoid(Case& c, const RadOpSchema* s) { const RadParam pp[] = { { "M", RAD_P_INT, M, 0, nullptr, 0.0 }, { "n_expert", RAD_P_INT, NE, 0, nullptr, 0.0 }, { "top_k", RAD_P_INT, TK, 0, nullptr, 0.0 }, + { "norm", RAD_P_INT, 1, 0, nullptr, 0.0 }, { "route_scale", RAD_P_F64, 0, 0, nullptr, 1.0 }, { "dtype", RAD_P_STR, 0, 0, (const char*)"bf16", 0.0 } }; for (const RadParam& q : pp) c.p[c.n_p++] = q; @@ -2077,7 +2186,7 @@ static int build_moe_gather(Case& c, const RadOpSchema* s, int inv) { t = RadTensor{}; t.data = d; t.dtype = qd[o].dt; t.rank = qd[o].rank; for (int r = 0; r < qd[o].rank; ++r) { t.shape[r] = qd[o].sh[r]; t.stride[r] = 1; } - for (int r = 0; r + 1 < qd[o].rank; ++r) t.stride[r] = t.shape[r + 1] * t.stride[r + 1]; + rad_tensor_pack(&t); /* dense row-major: the ascending form computes stride[0] before stride[1] */ } return 0; } @@ -2090,7 +2199,8 @@ static int build_gdn_recurrent(Case& c, const RadOpSchema* s) { c.n_p = 0; const RadParam pp[] = { { "q_len", RAD_P_INT, T, 0, nullptr, 0.0 }, { "head_k", RAD_P_INT, K, 0, nullptr, 0.0 }, - { "head_v", RAD_P_INT, V, 0, nullptr, 0.0 } }; + { "head_v", RAD_P_INT, V, 0, nullptr, 0.0 }, + { "eps", RAD_P_F64, 0, 0, nullptr, 1e-6 } }; for (const RadParam& q : pp) c.p[c.n_p++] = q; uint32_t st = 0x4A7B2C9Du; @@ -2111,7 +2221,9 @@ static int build_gdn_recurrent(Case& c, const RadOpSchema* s) { for (auto& x : hnw) x = (rndf() - 0.5f) * 2.0f; std::vector ho(T*H*V, 0x7fc0u); const int sidxv[T] = { 0, 0, 1, 1 }; - const int nav[1] = { 0 }; + /* num_accepted counts from 1 (docs/OPS.md): the window's history is read at column + * num_accepted - 1, so 1 is the handover out of a prefill. */ + const int nav[1] = { 1 }; const int cuv[2] = { 0, (int)T }; struct { uint32_t dt; long long nel; } qd[16] = { @@ -2181,6 +2293,120 @@ static int build_gdn_recurrent(Case& c, const RadOpSchema* s) { return 0; } +/* gdn_conv_recurrent_update: the conv's inputs (as build_gdn_conv_update) then the recurrence's + * minus q, k and v (as build_gdn_recurrent), one geometry across both halves. */ +static int build_gdn_conv_recurrent(Case& c, const RadOpSchema* s) { + const long long T = 4, Hg = 2, H = 4, K = 128, V = 128, W = 4, SL = 4, SLOTS = 2; + const long long units = 2 * Hg + H, XD = units * K; + if (s->n_operands != 18) { fail("gdn_conv_recurrent_update: the schema has %d operands, not 18", + s->n_operands); return 1; } + c.n_p = 0; + const RadParam pp[] = { { "q_len", RAD_P_INT, T, 0, nullptr, 0.0 }, + { "head_k", RAD_P_INT, K, 0, nullptr, 0.0 }, + { "head_v", RAD_P_INT, V, 0, nullptr, 0.0 }, + { "conv_width", RAD_P_INT, W, 0, nullptr, 0.0 }, + { "eps", RAD_P_F64, 0, 0, nullptr, 1e-6 } }; + for (const RadParam& q : pp) c.p[c.n_p++] = q; + + uint32_t st = 0x5C1D8E3Fu; + auto rndf = [&]() { st = st * 1664525u + 1013904223u; + return (float)((st >> 8) & 0xffffu) / 65536.0f; }; + + std::vector hx(T * XD), hw(XD * W), hb(XD); + for (auto& x : hx) x = f32_to_bf16((rndf() - 0.5f) * 2.0f); + for (auto& x : hw) x = f32_to_bf16((rndf() - 0.5f) * 0.5f); + for (auto& x : hb) x = f32_to_bf16((rndf() - 0.5f) * 0.2f); + std::vector hcs(XD * SL, 0); + for (auto& x : hcs) x = f32_to_bf16((rndf() - 0.5f) * 2.0f); + std::vector ha(T * H), hbb(T * H), hz(T * H * V); + for (auto& x : ha) x = f32_to_bf16((rndf() - 0.5f) * 4.0f); + for (auto& x : hbb) x = f32_to_bf16((rndf() - 0.5f) * 4.0f); + for (auto& x : hz) x = f32_to_bf16((rndf() - 0.5f) * 4.0f); + std::vector halog(H), hdtb(H), hstate(SLOTS * H * V * K), hnw(V); + for (auto& x : halog) x = logf(0.1f + rndf()); + for (auto& x : hdtb) x = (rndf() - 0.5f) * 4.0f; + for (auto& x : hstate) x = (rndf() - 0.5f) * 0.1f; + for (auto& x : hnw) x = (rndf() - 0.5f) * 2.0f; + std::vector ho(T * H * V, 0x7fc0u); + const int cidxv[1] = { 0 }, sidxv[T] = { 0, 0, 1, 1 }; + /* num_accepted counts from 1 (docs/OPS.md): the window's history is read at column + * num_accepted - 1, so 1 is the handover out of a prefill. */ + const int nav[1] = { 1 }; + const int cuv[2] = { 0, (int)T }; + + struct { uint32_t dt; long long nel; } qd[18] = { + { RAD_BF16, T * XD }, // x + { RAD_BF16, XD * W }, // conv_w + { RAD_BF16, XD }, // conv_b + { RAD_BF16, XD * SL }, // conv_state [XD, 1, SL] + { RAD_I32, 1 }, // conv_idx + { RAD_BF16, T * H }, // a + { RAD_BF16, T * H }, // b + { RAD_F32, H }, // A_log + { RAD_F32, H }, // dt_bias + { RAD_F32, SLOTS * H * V * K }, // state + { RAD_I32, T }, // state_idx [1, T] + { RAD_I32, 1 }, // num_accepted + { RAD_I32, 2 }, // cu + { RAD_BF16, T * H * V }, // z + { RAD_F32, V }, // norm_w + { RAD_BF16, T * H * V }, // o + { RAD_I8, 0 }, // o_q: absent + { RAD_F32, 0 } // o_scale: absent + }; + for (int o = 0; o < 16; ++o) { + const size_t bytes = (size_t)qd[o].nel * dt_bytes(qd[o].dt); + void* d = nullptr; + if (hipMalloc(&d, bytes) != hipSuccess) { fail("gdn_conv_recurrent: hipMalloc(%zu) failed", + bytes); return 1; } + c.dev.push_back(d); + switch (o) { + case 0: std::memcpy(d, hx.data(), bytes); break; + case 1: std::memcpy(d, hw.data(), bytes); break; + case 2: std::memcpy(d, hb.data(), bytes); break; + case 3: std::memcpy(d, hcs.data(), bytes); break; + case 4: std::memcpy(d, cidxv, sizeof cidxv); break; + case 5: std::memcpy(d, ha.data(), bytes); break; + case 6: std::memcpy(d, hbb.data(), bytes); break; + case 7: std::memcpy(d, halog.data(), bytes); break; + case 8: std::memcpy(d, hdtb.data(), bytes); break; + case 9: std::memcpy(d, hstate.data(), bytes); break; + case 10: std::memcpy(d, sidxv, sizeof sidxv); break; + case 11: std::memcpy(d, nav, sizeof nav); break; + case 12: std::memcpy(d, cuv, sizeof cuv); break; + case 13: std::memcpy(d, hz.data(), bytes); break; + case 14: std::memcpy(d, hnw.data(), bytes); break; + default: std::memcpy(d, ho.data(), bytes); break; + } + RadTensor& t = c.t[o]; + t = RadTensor{}; + t.data = d; t.dtype = qd[o].dt; + switch (o) { + case 0: t.rank = 2; t.shape[0] = T; t.shape[1] = XD; t.stride[1] = 1; t.stride[0] = XD; break; + case 1: t.rank = 2; t.shape[0] = XD; t.shape[1] = W; t.stride[1] = 1; t.stride[0] = W; break; + case 2: t.rank = 1; t.shape[0] = XD; t.stride[0] = 1; break; + case 3: t.rank = 3; t.shape[0] = XD; t.shape[1] = 1; t.shape[2] = SL; + t.stride[2] = 1; t.stride[1] = SL; t.stride[0] = SL; break; + case 4: t.rank = 1; t.shape[0] = 1; t.stride[0] = 1; break; + case 5: case 6: t.rank = 2; t.shape[0] = T; t.shape[1] = H; t.stride[1] = 1; t.stride[0] = H; break; + case 7: case 8: t.rank = 1; t.shape[0] = H; t.stride[0] = 1; break; + case 9: t.rank = 4; t.shape[0] = SLOTS; t.shape[1] = H; t.shape[2] = V; t.shape[3] = K; + t.stride[3] = 1; t.stride[2] = K; t.stride[1] = V * K; t.stride[0] = H * V * K; break; + case 10: t.rank = 2; t.shape[0] = 1; t.shape[1] = T; t.stride[1] = 1; t.stride[0] = T; break; + case 11: t.rank = 1; t.shape[0] = 1; t.stride[0] = 1; break; + case 12: t.rank = 1; t.shape[0] = 2; t.stride[0] = 1; break; + case 13: t.rank = 3; t.shape[0] = T; t.shape[1] = H; t.shape[2] = V; + t.stride[2] = 1; t.stride[1] = V; t.stride[0] = H * V; break; + case 14: t.rank = 1; t.shape[0] = V; t.stride[0] = 1; break; + default: t.rank = 3; t.shape[0] = T; t.shape[1] = H; t.shape[2] = V; + t.stride[2] = 1; t.stride[1] = V; t.stride[0] = H * V; break; + } + } + c.t[16] = RadTensor{}; // o_q absent + c.t[17] = RadTensor{}; // o_scale absent + return 0; +} + static int run_row(int i) { const RadKernelInfo* k = row_at(i); if (!k) return 1; @@ -2207,6 +2433,7 @@ static int run_row(int i) { : (0 == std::strcmp(k->name, "gdn_conv_prep_w4_h128")) ? 9 : (0 == std::strcmp(k->name, "gdn_conv_update_w4_h128")) ? 10 : (0 == std::strcmp(k->name, "gdn_recurrent_update_k128_v128")) ? 11 + : (0 == std::strcmp(k->name, "gdn_conv_recurrent_update_k128_v128")) ? 23 : (0 == std::strcmp(k->name, "expert_scale_bf16")) ? 12 : (0 == std::strcmp(k->name, "moe_router_topk_bf16")) ? 13 : (0 == std::strcmp(k->name, "moe_scatter_small")) ? 14 @@ -2215,7 +2442,8 @@ static int run_row(int i) { : (0 == std::strcmp(k->name, "moe_gemm_mxfp4a8")) ? 17 : (0 == std::strcmp(k->name, "moe_router_topk_scatter")) ? 18 : (0 == std::strcmp(k->name, "moe_router_sigmoid_topk")) ? 19 - : (0 == std::strcmp(k->name, "moe_gather")) ? 21 : 2; + : (0 == std::strcmp(k->name, "moe_gather")) ? 21 + : (0 == std::strcmp(k->name, "moe_gemm_w4a8")) ? 22 : 2; if (hand == 2) { skip("no operand description, so no buffers to build"); return 0; } const RadOpSchema* s = find_schema(k->op); if (!s) { fail("no schema for '%s'", k->op); return 1; } @@ -2236,6 +2464,7 @@ static int run_row(int i) { : hand == 9 ? build_gdn_conv_prep(c, s) : hand == 10 ? build_gdn_conv_update(c, s) : hand == 11 ? build_gdn_recurrent(c, s) + : hand == 23 ? build_gdn_conv_recurrent(c, s) : hand == 12 ? build_expert_scale(c, s) : hand == 13 ? build_moe_router_topk(c, s) : hand == 14 ? build_moe_scatter(c, s) @@ -2245,6 +2474,7 @@ static int run_row(int i) { : hand == 18 ? build_moe_router_scatter(c, s) : hand == 19 ? build_moe_router_sigmoid(c, s) : hand == 21 ? build_moe_gather(c, s, 0) + : hand == 22 ? build_moe_gemm_w4a8(c, s) : build_gdn_chunk_scan(c, s); if (rc) return 1; goto launched; @@ -2478,6 +2708,279 @@ launched: } /* ================================================================== main */ +/* ================================================================== the grouped GEMMs, by value + * + * The row cases above check that each MoE GEMM runs and writes finite planes; this checks what it + * writes. A routed batch (random ids, some outside the local slice and so dropped, stably sorted + * by expert as moe_scatter sorts them) runs through moe_gemm at bf16 and moe_gemm_q at fp8a8f32 + * (every impl arm) and mxfp4a8, in both a_orders, with the experts as the engine hands them: a + * device table of one pointer per expert (stride[0] 0), even and odd experts in separate classes. + * N is not a multiple of the 128-column block, so the tail block is checked too. The reference is + * libref's arithmetic on the host (the products exact, the sums in double); a dropped row must be + * zero. Agreement is the relative L2 error over y, as rad-kbench measures it. + */ +#ifdef RAD_HAVE_HIP +namespace moenum { + +struct Dev { + std::vector p; + ~Dev() { for (void* x : p) hipFree(x); } + void* put(const void* h, size_t n) { + void* d = nullptr; + if (hipMalloc(&d, n ? n : 4) != hipSuccess) return nullptr; + p.push_back(d); + if (h && n) hipMemcpy(d, h, n, hipMemcpyHostToDevice); + else hipMemset(d, 0, n ? n : 4); + return d; + } +}; + +RadTensor dense(void* d, uint32_t dt, long long r, long long c) { + RadTensor t{}; + t.data = d; t.dtype = dt; t.rank = 2; + t.shape[0] = r; t.shape[1] = c; t.stride[0] = c; t.stride[1] = 1; + return t; +} +RadTensor vec(void* d, uint32_t dt, long long n) { + RadTensor t{}; + t.data = d; t.dtype = dt; t.rank = 1; t.shape[0] = n; t.stride[0] = 1; + return t; +} +/* A weight table of `n` entries, each [rows, cols] (cols in elements): the device array of + * pointers the core builds for a run of separately placed experts. */ +RadTensor table(Dev& dv, const std::vector>& ent, uint32_t dt, long long rows, + long long cols) { + std::vector ptr; + for (const auto& e : ent) ptr.push_back(dv.put(e.data(), e.size())); + if (ptr.empty()) ptr.push_back(dv.put(nullptr, 64)); + RadTensor t{}; + t.data = dv.put(ptr.data(), ptr.size() * sizeof(void*)); + t.dtype = dt; t.rank = 3; + t.shape[0] = (long long)ent.size(); t.shape[1] = rows; t.shape[2] = cols; + t.stride[0] = 0; t.stride[1] = cols; t.stride[2] = 1; + return t; +} + +struct Route { + std::vector sorted, off; + long long T = 0; +}; +/* Each token picks top_k distinct experts out of ne + 1, the last meaning "not on this rank": + * those slots are dropped, sorted to the tail as -1. */ +Route route(long long M, long long top_k, long long ne, uint32_t& st) { + auto rnd = [&]() { st = st * 1664525u + 1013904223u; return st >> 8; }; + Route r; + r.T = M * top_k; + std::vector ids(r.T); + for (long long t = 0; t < M; ++t) + for (long long j = 0; j < top_k; ++j) { + int32_t e; + bool dup; + do { + e = (int32_t)(rnd() % (uint32_t)(ne + 1)); + dup = false; + for (long long q = 0; q < j; ++q) dup |= ids[t * top_k + q] == e; + } while (dup); + ids[t * top_k + j] = e; + } + r.off.assign(ne + 1, 0); + for (int32_t e = 0; e < ne; ++e) { + r.off[e] = (int32_t)r.sorted.size(); + for (long long i = 0; i < r.T; ++i) if (ids[i] == e) r.sorted.push_back((int32_t)i); + } + r.off[ne] = (int32_t)r.sorted.size(); + while ((long long)r.sorted.size() < r.T) r.sorted.push_back(-1); + return r; +} + +int expert_of(const Route& r, long long i, long long ne) { + for (long long e = 0; e < ne; ++e) if (r.off[e] <= i && i < r.off[e + 1]) return (int)e; + return -1; +} + +void compare(const char* what, const std::vector& ref, const std::vector& y, + double tol) { + double num = 0, den = 0, worst_zero = 0; + for (size_t i = 0; i < ref.size(); ++i) { + const double v = bf16_to_f32(y[i]); + num += (v - ref[i]) * (v - ref[i]); + den += ref[i] * ref[i]; + if (ref[i] == 0.0) worst_zero = std::max(worst_zero, std::fabs(v)); + } + const double rel = den > 0 ? std::sqrt(num / den) : std::sqrt(num); + if (rel <= tol && worst_zero == 0.0) ok("%s: rel_l2 %.2e", what, rel); + else fail("%s: rel_l2 %.2e (tolerance %.0e), a dropped row's largest |y| %.3g", what, rel, tol, + worst_zero); +} + +RadParam pi(const char* k, long long v) { return RadParam{ k, RAD_P_INT, v, 0, nullptr, 0.0 }; } +RadParam ps(const char* k, const char* v) { return RadParam{ k, RAD_P_STR, 0, 0, v, 0.0 }; } + +typedef int (*Launch)(const RadArgs*, RadStream); + +} // namespace moenum +#endif + +static void check_moe_numerics() { + std::printf("== the grouped GEMMs, by value\n"); +#ifndef RAD_HAVE_HIP + skip("built without HIP: the grouped GEMMs are not run"); +#else + using namespace moenum; + auto bf16_launch = (Launch)dlsym(g_h, "r3d_rad_moe_gemm_bf16"); + auto q_launch = (Launch)dlsym(g_h, "r3d_rad_moe_gemm_q"); + auto mx_launch = (Launch)dlsym(g_h, "r3d_rad_moe_gemm_mxfp4a8"); + if (!bf16_launch || !q_launch || !mx_launch) { + fail("a grouped GEMM entry point is missing"); + return; + } + + const long long M = 12, TK = 2, NE = 6, N = 192; + for (int sorted_a = 0; sorted_a < 2; ++sorted_a) { + const char* order = sorted_a ? "sorted" : "token"; + uint32_t st = 0x5EED0000u + (uint32_t)sorted_a; + const Route r = route(M, TK, NE, st); + const long long T = r.T, AR = sorted_a ? T : M; + auto rndf = [&]() { + st = st * 1664525u + 1013904223u; + return ((st >> 8) & 0xffffu) / 65536.0f - 0.5f; + }; + auto rnd8 = [&]() { st = st * 1664525u + 1013904223u; return (uint8_t)(st >> 16); }; + /* An E4M3 code in the normal range (exponent 1..14), either sign. */ + auto e4 = [&]() { + return (uint8_t)(((rnd8() & 0x7) | 1) << 3 | (rnd8() & 0x7) | ((rnd8() & 1) << 7)); + }; + auto tok_of = [&](long long i) { return sorted_a ? i : r.sorted[i] / TK; }; + + /* ---- moe_gemm, bf16 experts in one class. */ + { + const long long K = 128; + Dev dv; + std::vector ha(AR * K); + for (auto& x : ha) x = f32_to_bf16(rndf()); + std::vector> we(NE, std::vector(N * K * 2)); + for (auto& e : we) for (long long q = 0; q < N * K; ++q) { + const uint16_t b = f32_to_bf16(rndf()); + std::memcpy(&e[q * 2], &b, 2); + } + RadTensor t[5] = { dense(dv.put(ha.data(), ha.size() * 2), RAD_BF16, AR, K), + table(dv, we, RAD_BF16, N, K), + vec(dv.put(r.sorted.data(), T * 4), RAD_I32, T), + vec(dv.put(r.off.data(), (NE + 1) * 4), RAD_I32, NE + 1), + dense(dv.put(nullptr, T * N * 2), RAD_BF16, T, N) }; + const RadParam p[] = { pi("M", T), pi("N", N), pi("K", K), pi("n_expert", NE), + pi("top_k", TK), ps("a_order", order), ps("dtype", "bf16") }; + RadArgs a{ t, 5, p, (int)(sizeof(p) / sizeof(p[0])), nullptr, 0, nullptr, 0, 1 }; + const int rc = bf16_launch(&a, nullptr); + std::vector y(T * N); + hipDeviceSynchronize(); + hipMemcpy(y.data(), t[4].data, y.size() * 2, hipMemcpyDeviceToHost); + std::vector ref(T * N, 0.0); + for (long long i = 0; i < T; ++i) { + const int e = expert_of(r, i, NE); + if (e < 0) continue; + for (long long n = 0; n < N; ++n) { + double acc = 0; + for (long long k = 0; k < K; ++k) { + uint16_t w; std::memcpy(&w, &we[e][(n * K + k) * 2], 2); + acc += (double)bf16_to_f32(ha[tok_of(i) * K + k]) * bf16_to_f32(w); + } + ref[i * N + n] = acc; + } + } + std::string what = std::string("moe_gemm bf16, a_order ") + order; + if (rc != 0) fail("%s: the launch returned %d", what.c_str(), rc); + else compare(what.c_str(), ref, y, 1e-2); + } + + /* ---- moe_gemm_q at fp8a8f32 (every impl arm) and mxfp4a8: the even and odd classes. */ + for (int mx = 0; mx < 2; ++mx) { + const long long K = 256, NB = (N + 127) / 128; + Dev dv; + std::vector ha(AR * K); + std::vector has(AR * (K / 128)); + for (auto& x : ha) x = e4(); + for (auto& x : has) x = 0.25f + std::fabs(rndf()); + /* Expert e's codes and scales, and their values for the reference. */ + const long long wbytes = mx ? N * K / 2 : N * K; + const long long scols = mx ? K / 32 : K / 128, srows = mx ? N : NB; + std::vector> wc(NE, std::vector(wbytes)), + ws(NE, std::vector(srows * scols * (mx ? 1 : 4))); + for (long long e = 0; e < NE; ++e) { + for (auto& x : wc[e]) x = mx ? rnd8() : e4(); + for (long long q = 0; q < srows * scols; ++q) { + if (mx) { + ws[e][q] = (uint8_t)(120 + (rnd8() & 15)); + } else { + const float f = 0.25f + std::fabs(rndf()); + std::memcpy(&ws[e][q * 4], &f, 4); + } + } + } + auto wval = [&](int e, long long n, long long k) -> double { + if (!mx) { + float sc; std::memcpy(&sc, &ws[e][((n / 128) * scols + k / 128) * 4], 4); + return (double)e4m3_to_f32(wc[e][n * K + k]) * sc; + } + static const float kMag[8] = { 0.0f, 0.5f, 1.0f, 1.5f, 2.0f, 3.0f, 4.0f, 6.0f }; + const uint8_t b = wc[e][(n * K + k) / 2]; + const uint8_t nib = (k & 1) ? (uint8_t)(b >> 4) : (uint8_t)(b & 0xf); + const double v = (nib & 8) ? -kMag[nib & 7] : kMag[nib & 7]; + return v * std::ldexp(1.0, (int)ws[e][n * scols + k / 32] - 127); + }; + std::vector ref(T * N, 0.0); + for (long long i = 0; i < T; ++i) { + const int e = expert_of(r, i, NE); + if (e < 0) continue; + const long long tk = tok_of(i); + for (long long n = 0; n < N; ++n) { + double acc = 0; + for (long long k = 0; k < K; ++k) + acc += (double)e4m3_to_f32(ha[tk * K + k]) * has[tk * (K / 128) + k / 128] * + wval(e, n, k); + ref[i * N + n] = acc; + } + } + std::vector> wc0, wc1, ws0, ws1; + for (long long e = 0; e < NE; ++e) { + (e % 2 ? wc1 : wc0).push_back(wc[e]); + (e % 2 ? ws1 : ws0).push_back(ws[e]); + } + const uint32_t wdt = mx ? (uint32_t)RAD_FP4E2M1 : (uint32_t)RAD_F8E4M3; + const uint32_t sdt = mx ? (uint32_t)RAD_U8 : (uint32_t)RAD_F32; + RadTensor t[9] = { dense(dv.put(ha.data(), ha.size()), RAD_F8E4M3, AR, K), + dense(dv.put(has.data(), has.size() * 4), RAD_F32, AR, K / 128), + table(dv, wc0, wdt, N, K), table(dv, ws0, sdt, srows, scols), + vec(dv.put(r.sorted.data(), T * 4), RAD_I32, T), + vec(dv.put(r.off.data(), (NE + 1) * 4), RAD_I32, NE + 1), + table(dv, wc1, wdt, N, K), table(dv, ws1, sdt, srows, scols), + dense(dv.put(nullptr, T * N * 2), RAD_BF16, T, N) }; + for (int impl = 0; impl < (mx ? 1 : 3); ++impl) { + /* Stale bytes, which a dropped row must not keep. */ + hipMemset(t[8].data, 0xff, T * N * 2); + const RadParam p[] = { pi("M", T), pi("N", N), pi("K", K), pi("n_expert", NE), + pi("top_k", TK), pi("group", 128), ps("a_order", order), + ps("dtype", mx ? "mxfp4a8" : "fp8a8f32"), pi("impl", impl), + pi("vgpr", 128), pi("acc", 0) }; + RadArgs a{ t, 9, p, (int)(sizeof(p) / sizeof(p[0])), nullptr, 0, nullptr, 0, 1 }; + const int rc = (mx ? mx_launch : q_launch)(&a, nullptr); + std::vector y(T * N); + hipDeviceSynchronize(); + hipMemcpy(y.data(), t[8].data, y.size() * 2, hipMemcpyDeviceToHost); + char what[96]; + std::snprintf(what, sizeof what, "moe_gemm_q %s%s, a_order %s", + mx ? "mxfp4a8" : "fp8a8f32", + mx ? "" : (impl == 0 ? " impl 0" : impl == 1 ? " impl 1" : " impl 2"), + order); + if (rc != 0) fail("%s: the launch returned %d", what, rc); + else compare(what, ref, y, 1e-2); + } + } + + } +#endif +} + int main(int argc, char** argv) { /* Unbuffered stdout, so when a row dies the last line printed is the last thing that worked, * even when output goes to a file or pipe. */ @@ -2513,6 +3016,7 @@ int main(int argc, char** argv) { check_reference_schemas(); check_band_reach(); check_shapes(); + check_moe_numerics(); const int n = rows(); int passed = 0, failed = 0; diff --git a/libr3d/r3d_vocab_bf16.hip b/libr3d/r3d_vocab_bf16.hip index 336e8db8..17c86983 100644 --- a/libr3d/r3d_vocab_bf16.hip +++ b/libr3d/r3d_vocab_bf16.hip @@ -95,9 +95,10 @@ * * ---- refusals ----------------------------------------------------------------------------------- * - * sk > 1: the grid is vocab-wide at every M (1020 blocks at the band for the prefill arm, 8160 for - * the decode arm at MT=16), so a split would buy nothing. kb: KC = 32 only, since another pitch is - * a different swizzle. Also refused: K not a multiple of KC, an x pitch not a multiple of 8, a y + * The grid is vocab-wide at every M (1020 blocks at the band for the prefill arm, 8160 for + * the decode arm at MT=16), so a split would buy nothing: sk = 1 fixed. kb: KC = 32 only, since + * another pitch is a different swizzle. Also refused: K not a multiple of KC, an x pitch not a + * multiple of 8, a y * pitch not a multiple of 4 (f32) or 8 (bf16), a non-contiguous weight. The head branch, in order: * a quantised head on the bf16-y row (logits are f32) * a `zero` plane: codes+scale+zero is gemm_nt_q's asymmetric grid (r3d_gemm_nt_q_w2a8.hip) @@ -113,7 +114,7 @@ * planes that do not cover the band (codes N x K, scales ceil(N/128) x ceil(K/128)), or a * row_bytes shorter than the row * The bf16 branch refuses a plain head that is not bf16, wrong x and y dtypes, bad pitches, a short - * or non-contiguous head, absurd shapes, misalignment and sk > 1. The launcher refuses a head with + * or non-contiguous head, absurd shapes and misalignment. The launcher refuses a head with * a null plane, a dtype outside the served set, a row pitch a vector load cannot walk (a 16-bit * scale row is 2 bytes a column, so K = 320, 6 bytes a row, is legal), and misaligned addresses. */ @@ -664,10 +665,9 @@ int rad_gemm_run(const RadArgs* a, RadStream s, int y_is_f32, const char* nkey, if (!r3d_aligned(r3d_p(x), 16) || !r3d_aligned(r3d_p(w), 16) || !r3d_aligned(r3d_p(y), 16)) return R3D_NO(RAD_E_ALIGN); - const int sk = (int)r3d_geti_or(a, "sk", 1); - if (sk > 1) return R3D_NO(RAD_E_SHAPE); /* see the header's refusals */ - const int kb = (int)r3d_geti_or(a, "kb", 0); - const int nt = (int)r3d_geti_or(a, "nt", 0); + /* No `sk`/`kb`/`nt` in the rows' tune tables (impl only): the grid is vocab-wide, KC = 32 and + * the non-temporal stream is off, see the header's refusals. */ + const int sk = 1, kb = 0, nt = 0; const HeadQ* hp = joined ? &h : nullptr; const int e = y_is_f32 diff --git a/libr3d/r3dh.h b/libr3d/r3dh.h new file mode 100644 index 00000000..fea10dc3 --- /dev/null +++ b/libr3d/r3dh.h @@ -0,0 +1,59 @@ +/* r3dh.h -- the entry points of the gated-delta-net kernels ported from libhalo (libhalo/halo.h's + * gated-delta-net section, the halo_ -> r3dh_ rename): the chunk preamble, the chunked scan and the + * recurrent update. libhalo's kernels are libr4d's ported to the gfx11 wave matrix and checked + * against libref on gfx1151 (rad-kbench); they compile for gfx11-generic unchanged, so libr3d + * carries them for the whole family. Plain C ABI on raw device pointers and a stream; an entry + * point returns a negative code for a geometry it was not compiled for. */ +#pragma once +#include + +extern "C" { + +// ---- gated delta net ----------------------------------------------------------------------- +// One chunked scan over N variable-length sequences: the WY recompute, the recurrent state scan +// and the output in one kernel (FLA's recompute_w_u_fwd + chunk_gated_delta_rule_fwd_h + +// chunk_fwd_o). Layouts, all contiguous and bf16 unless stated: +// q,k [T, Hg, K] v,o [T, H, V] A [T, H, bt] g,beta [T, H] fp32 +// h0,ht [N, H, V, K] fp32 cu [N+1] int32 +// K, V and bt must be the compile-time 128/128/64 in the name; a mismatch returns -1. Prefill and +// chunked prefill run this; decode runs the recurrent update. +int r3dh_gdn_chunk_scan_k128_v128_c64_bf16( + const void* q, const void* k, const void* v, const void* A, + const void* g, const void* beta, const void* h0, void* o, void* ht, + const void* cu, int N, int H, int Hg, int K, int V, int bt, + float scale, int state_fp16, void* stream); +// The same scan against a slot-indexed state cache: `ssm_state_indices` [N] names each batch +// row's slot, and the two strides are the cache's, in elements. The call above is this one with a +// null index and packed [N, H, V, K] strides, which is correct only while slot == batch row. +int r3dh_gdn_chunk_scan_k128_v128_c64_bf16_sidx( + const void* q, const void* k, const void* v, const void* A, + const void* g, const void* beta, const void* h0, void* o, void* ht, + const void* cu, const void* ssm_state_indices, long indices_stride, + long state_slot_stride, long state_head_stride, + int N, int H, int Hg, int K, int V, int bt, + float scale, int state_fp16, void* stream); +void r3dh_gdn_dims(int* head_k, int* head_v, int* chunk); + +// The chunk preamble: A = (I + strict_lower(diag(beta) K K^T e^{g_i-g_j}))^-1 per chunk, i.e. +// FLA's chunk_scaled_dot_kkt_fwd then solve_tril, with the fp32 gram kept out of HBM. +// k [T,Hg,K] bf16; beta, g [T,H] fp32 (g already summed along the chunk); A [T,H,64] bf16 out; +// cu [N+1] int32. Returns -1 for a geometry it was not compiled for. +int r3dh_gdn_kkt_solve_k128_c64_bf16(const void* k, const void* beta, const void* g, void* A, + const void* cu, int N, int T, int H, int Hg, int K, int bt, + void* stream); + +// The recurrent delta-rule update decode runs: gating, the qk l2 norm, the state update and the +// output, against the paged state cache. The state is fp32 (per the model config) and one is +// written per candidate token, which dominates the cost. Replaces +// fused_sigmoid_gating_delta_rule_update. +int r3dh_gdn_recurrent_update_k128_v128_bf16_fp32state( + const void* q, const void* k, const void* v, const void* a, const void* b, + long ab_stride, int ab_is_bf16, const void* A_log, const void* dt_bias, void* state, + long state_slot_stride, long state_head_stride, void* o, void* oq, void* os, + long oq_pitch, long os_ld, const void* cu, + const void* ssm_state_indices, long indices_stride, const void* num_accepted, + const void* z_gate, long z_pitch, const void* norm_weight, float norm_eps, int norm_act, + int N, int H, int Hg, int K, int V, float scale, float softplus_thr, int state_fp16, + void* stream); + +} // extern "C" diff --git a/libr3d/r3dh_args.h b/libr3d/r3dh_args.h new file mode 100644 index 00000000..11a539be --- /dev/null +++ b/libr3d/r3dh_args.h @@ -0,0 +1,382 @@ +/* Ported from libhalo/halo_args.h, verbatim but for the halo_ -> r3dh_ rename, so libr3d builds and loads + * on its own. libhalo's gated-delta-net kernels are libr4d's ported to the gfx11 wave matrix and + * checked against libref on gfx1151 (rad-kbench); they compile for gfx11-generic unchanged. */ +/* Derived from libr4d/r4d_args.h by the libhalo rename transform (2026-10-26); + * see libhalo/README.md. Op schemas, row names and stored weight layouts are + * shared with libr4d by design. Everything else in this file is libhalo's own + * and diverges as it is measured on gfx1151. */ +/* r3dh_args.h -- how a libhalo entry point reads its arguments. + * + * There is no adapter layer. An entry point takes `(const RadArgs*, RadStream)` and returns a + * status, the same RadLaunchFn contract every other plugin implements; an out-of-tree author can + * write the same kernel without an adapter they could not reach. + * + * This header holds the shared helpers: reading a parameter, finding an operand, testing + * contiguity. Most are one line over rad_abi.h. + * + * Nothing here includes halo.h or HIP: host translation units (the row table, the layouts, the + * shape hooks) include it too, so those tables compile and can be checked without ROCm. + */ +#ifndef R3DH_ARGS_H +#define R3DH_ARGS_H + +#include "rad_abi.h" +#include "rad_plugin.h" + +#include +#include +#include +#include + +/* ================================================================== parameter access + * + * Forwards to rad_abi.h's static inline helpers, the ones a third-party plugin gets, keeping + * libhalo's spelling at its call sites. */ +static inline int r3dh_geti(const RadArgs* a, const char* k, long long* out) { + return rad_args_geti(a, k, out); +} + +static inline long long r3dh_geti_or(const RadArgs* a, const char* k, long long dflt) { + return rad_args_geti_or(a, k, dflt); +} + +static inline const char* r3dh_gets(const RadArgs* a, const char* k) { + return rad_args_gets(a, k); +} + +/* A float parameter is RAD_P_F64 (rad_types.h, docs/OPS.md "The four rules"), so `dval` arrives + * and the step path runs no strtod. Deliberately laxer than rad_args_getf_or: string and integer + * spellings are still read, because a tool or selftest may call a launch directly with no declare + * to enforce the type. */ +static inline double r3dh_getf(const RadArgs* a, const char* k, double dflt) { + if (!a || !k) return dflt; + for (int i = 0; i < a->n_p; ++i) { + if (!a->p[i].key || std::strcmp(a->p[i].key, k) != 0) continue; + if (a->p[i].kind == RAD_P_F64) return a->p[i].dval; + if (a->p[i].kind == RAD_P_INT) return (double)a->p[i].ival; + if (a->p[i].kind == RAD_P_STR && a->p[i].sval && a->p[i].sval[0]) { + char* end = nullptr; + const double v = std::strtod(a->p[i].sval, &end); + return (end && end != a->p[i].sval) ? v : dflt; + } + return dflt; + } + return dflt; +} + +/* An enumerated parameter: `act` is "silu" or "sigmoid", not 0 or 1, so a --debug-graph dump says + * what runs; the mapping to libhalo's integer lives in the shim. Returns -1 for an unknown name, + * which every caller turns into RAD_E_INVAL. `alt` is libhalo's own integer spelling of the same + * key (`mode` on gated_had_quant_i8), consulted only when the name is absent. */ +static inline int r3dh_act_code(const RadArgs* a, const char* key, const char* alt, int dflt) { + if (const char* s = r3dh_gets(a, key)) { + if (!std::strcmp(s, "silu") || !std::strcmp(s, "swish")) return 0; + if (!std::strcmp(s, "sigmoid")) return 1; + return -1; + } + long long v = 0; + if (alt && r3dh_geti(a, alt, &v)) return (v == 0 || v == 1) ? (int)v : -1; + return dflt; +} + +/* Same, off a bare RadParam list (init() and the layout hooks); forwards to rad_plugin.h's + * rad_param_*. */ +static inline long long r3dh_pgeti_or(const RadParam* p, int n_p, const char* k, long long dflt) { + return rad_param_geti(p, n_p, k, dflt); +} + +static inline const char* r3dh_pgets(const RadParam* p, int n_p, const char* k) { + return rad_param_gets(p, n_p, k, nullptr); +} + +/* ================================================================== operand access + * + * An absent optional operand is a null RadTensor.data (rad_abi.h). r3dh_opt() returns null both + * past the end and for a present-but-null operand, so an optional test is one pointer test. For a + * required operand the caller turns null into RAD_E_INVAL: it is a bug in the issue, not a shape + * the kernel declines. + */ +static inline const RadTensor* r3dh_opt(const RadArgs* a, int i) { return rad_arg_in(a, i); } + +static inline const void* r3dh_p(const RadTensor* t) { return t ? t->data : nullptr; } + +/* The same for an operand a kernel writes, so an output cast reads as one rather than as a + * pointer laundered through `long`. */ +static inline void* r3dh_wp(const RadTensor* t) { return t ? t->data : nullptr; } +static inline long r3dh_addr(const RadTensor* t) { return t ? (long)(uintptr_t)t->data : 0L; } + +static inline long long r3dh_dim(const RadTensor* t, int i) { + if (!t || i < 0 || (uint32_t)i >= t->rank) return 0; + return t->shape[i]; +} + +static inline long long r3dh_stride(const RadTensor* t, int i) { + if (!t || i < 0 || (uint32_t)i >= t->rank) return 0; + return t->stride[i]; +} + +static inline long long r3dh_numel(const RadTensor* t) { return rad_tensor_numel(t); } + +/* [rows..., K] flattened to (M, K). Every per-row kernel in libhalo owns whole rows (one + * workgroup per row), so the leading axes are only a row count. The GEMM makes the same fold + * explicitly (see gemm_ops). */ + +static inline int r3dh_rows_of(const RadTensor* t, long long* M, long long* K) { + if (!t || t->rank < 1) return RAD_E_SHAPE; + *K = t->shape[t->rank - 1]; + *M = 1; + for (uint32_t i = 0; i + 1 < t->rank; ++i) *M *= t->shape[i]; + return (*M >= 1 && *K >= 1) ? RAD_OK : RAD_E_SHAPE; +} + +/* Dense row-major over the whole tensor. libhalo's entry points take at most one pitch, so + * everything else must be tight, and the shim checks it. This is the "necessary condition only" + * boundary of spec §2.1: the constraint table settles geometry, contiguity is a property of the + * call. */ +static inline int r3dh_contig(const RadTensor* t) { return rad_tensor_is_contiguous(t); } + +/* Contiguous in every axis but the leading one, whose stride is the row pitch libhalo takes as an + * explicit argument (`xpitch`, `a_stride`, `xrow`, ...). Returns the pitch in elements, or -1. */ +static inline long long r3dh_row_pitch(const RadTensor* t) { + if (!t || t->rank == 0) return -1; + if (t->rank == 1) return 1; + long long acc = 1; + for (int i = (int)t->rank - 1; i >= 1; --i) { + if (t->shape[i] != 1 && t->stride[i] != acc) return -1; + acc *= t->shape[i]; + } + return t->stride[0]; +} + +/* [rows..., n] read as (rows, n): the leading axes are a row count and only the last is + * structural. Returns the pitch in elements, or -1. + * + * A column slice must refuse. k out of a fused [tok, 2*kv_dim] projection, read as + * [tok*n_head_kv, head_dim] for a per-head norm, has rows `n` apart within a token and a buffer + * row apart between tokens; no single pitch describes that, and the leading stride would make the + * consumer read most heads from garbage. So the trailing axes must cover the whole row. */ +static inline long long r3dh_rows_pitch(const RadTensor* t, long long n, long long* rows) { + if (!t || t->rank < 1 || n <= 0) return -1; + const long long nel = rad_tensor_numel(t); + if (nel % n) return -1; + *rows = nel / n; + if (t->rank == 1) return n; + if (t->shape[t->rank - 1] == n) { + if (t->stride[t->rank - 1] != 1) return -1; + return t->rank >= 2 ? t->stride[t->rank - 2] : n; + } + if (rad_tensor_is_contiguous(t)) return n; + long long trail = 1; + for (int i = 1; i < (int)t->rank; ++i) trail *= t->shape[i]; + return trail == n ? r3dh_row_pitch(t) : -1; +} + +/* An attention operand, [tokens, heads * head_dim] over its trailing axes: the token count, head + * count and row pitch in elements. False when the trailing axes are not whole heads or no single + * pitch describes the rows. */ +static inline bool r3dh_head_rows(const RadTensor* t, long long head_dim, long long* n_tok, + long long* n_head, long long* ld) { + long long width = 1; + for (uint32_t i = 1; i < t->rank; ++i) width *= t->shape[i]; + if (t->rank < 2 || width % head_dim) return false; + *n_head = width / head_dim; + *ld = r3dh_rows_pitch(t, width, n_tok); + return *ld >= 0; +} + +/* 16-byte alignment, needed by every kernel that pushes over P2P or issues a global_load_b128. + * The kernels do not check it, so the shim does. */ +static inline int r3dh_aligned(const void* p, unsigned bytes) { + return p ? (((uintptr_t)p & (uintptr_t)(bytes - 1)) == 0) : 1; +} + +/* ================================================================== which check refused + * + * A shim refuses in many places with the same few codes, so the engine's report names the kernel + * and geometry but not the failing condition. R3DH_NO() wraps a refusal and prints its own line + * when RAD_HALO_TRACE is set; otherwise it is the bare return plus one cached-flag load on a path + * that is failing anyway. */ +static inline int r3dh_trace_on(void) { + static int on = -1; + if (on < 0) { const char* e = std::getenv("RAD_HALO_TRACE"); on = (e && *e && *e != '0'); } + return on; +} +static inline int r3dh_refused(int code, const char* file, int line) { + if (r3dh_trace_on()) std::fprintf(stderr, "[r4d] %s:%d refused -> %d\n", file, line, code); + return code; +} +#define R3DH_NO(code) r3dh_refused((code), __FILE__, __LINE__) + +/* ================================================================== dtype helpers */ +/* Widest world any libhalo all-reduce serves, fixed by the 8-rank entry points' argument lists + * (seven explicit peers). */ +enum { R3DH_MAX_RANKS = 8, R3DH_MAX_PEERS = 7 }; + +/* libhalo's all-reduce dtype code: 0 bf16, 1 fp16, 2 fp32. Returns -1 for anything else. */ +static inline int r3dh_ar_dtype_code(const char* s) { + if (!s) return -1; + if (!std::strcmp(s, "bf16")) return 0; + if (!std::strcmp(s, "fp16") || !std::strcmp(s, "f16")) return 1; + if (!std::strcmp(s, "fp32") || !std::strcmp(s, "f32")) return 2; + return -1; +} + +static inline int r3dh_ar_esize(int code) { return code == 2 ? 4 : 2; } + + +/* ================================================================== weight layout constants + * + * libhalo's compile-time constants, restated because r3dh_layout.cpp is host code built without + * ROCm and cannot include halo.h, and because the .rad container records them in the layout tag. + * r3dh_gemm_args.h static_asserts the group constants against libhalo's macros. + */ +enum { + R3DH_W4_GROUP = 128, /* K per (scale, zero) dword; libhalo R3DH_GEMM_W4_GROUP */ + R3DH_W4_KPB = 64, /* K per packed block: 4 k steps, 16 bytes per lane */ + R3DH_W8_GROUP = 128, /* libhalo R3DH_GEMM_W8_GROUP and R3DH_GEMM_W8A8_GROUP */ + R3DH_W8_KPB = 32, /* K per packed block: 2 k steps, 16 bytes per lane */ + R3DH_W2_GROUP = 128, /* libhalo R3DH_GEMM_W2A8_GROUP */ + R3DH_MXFP4_GROUP = 32, /* K per E8M0 exponent, fixed by the OCP MX format */ + /* The block-scaled fp8 family's block, on both axes. Not a quantiser choice: it is the + * checkpoint's `quantization_config.weight_block_size`, and the bytes on disk follow it. It + * cannot be static_asserted against `r3dh_gemm_fp8a8_block()` (a function, not a macro), so + * r3dh_gemm_fp8a8.hip checks it at launch. */ + R3DH_FP8_BLOCK = 128, + R3DH_WAVE = 32, + R3DH_NTILE = 16 /* output rows per WMMA n-tile */ +}; + +/* Plugin-private dtypes. The core never interprets these: rad_types.h reserves everything at or + * above RAD_DT_PLUGIN_BASE for this, and the layout hook sizes them. */ +enum { + R3DH_DT_W4_FRAG = RAD_DT_PLUGIN_BASE + 0, /* 4-bit codes in WMMA fragment order */ + R3DH_DT_W4_SZ = RAD_DT_PLUGIN_BASE + 1, /* (f16 scale, f16 -(1024+zero)) dwords */ + R3DH_DT_W8_FRAG = RAD_DT_PLUGIN_BASE + 2, /* 8-bit codes in the same fragment order */ + R3DH_DT_W8_S = RAD_DT_PLUGIN_BASE + 3, /* f16-only scale plane (w8a8) */ + R3DH_DT_W2_FRAG = RAD_DT_PLUGIN_BASE + 4, + R3DH_DT_MXFP4_FRAG = RAD_DT_PLUGIN_BASE + 5, + R3DH_DT_E8M0 = RAD_DT_PLUGIN_BASE + 6, /* [K/32][N] shared exponents, and Wref[N] */ + /* The grouped MoE GEMM's 4-bit expert weight: row-major packed nibbles, each a code into a + * sixteen-entry table, expanded to E4M3 on the way into LDS. Not R3DH_DT_W4_FRAG, which is a + * WMMA fragment permutation for a kernel loading its weight from global; this one stages + * through LDS because its rows are gathered. See r3dh_layout.cpp. */ + R3DH_DT_MOEW4 = RAD_DT_PLUGIN_BASE + 7, + /* The same GEMM's 5-bit expert weight: per row, R3DH_DT_MOEW4's nibble plane of the codes' low + * four bits (the magnitude), then the sign bits, one dword per 32 elements in the order the + * kernel merges them (r3dh_layout.cpp, moew5_row). A row is 5K/8 bytes. */ + R3DH_DT_MOEW5 = RAD_DT_PLUGIN_BASE + 8 +}; + +/* The grouped MoE GEMM's code tables, as the four dwords w4_e4m3's byte permutes read + * (r3dh_moe.hip): entries 0..3, 4..7, 8..11 and 12..15, one E4M3 byte an entry, lowest entry in the + * low byte. `w4a8` and `w4a8h` decode a two's complement nibble, -8..7. `w4nla8h` decodes + * libquant's `table=w4nl` (magnitudes ascending, then their negatives); kW4nlTable is that table + * as a container stores it, which the layout hook compares with the container's table plane + * before serving it. */ +static constexpr uint32_t kW4IntPerm[4] = { 0x44403800u, 0x4E4C4A48u, 0xCACCCED0u, 0xB8C0C4C8u }; +static constexpr uint32_t kW4nlPerm[4] = { 0x504B4539u, 0x5B595653u, 0xD0CBC5B9u, 0xDBD9D6D3u }; +static constexpr float kW4nlTable[16] = { 1.125f, 3.25f, 5.5f, 8.0f, 11.0f, 14.0f, 18.0f, 22.0f, + -1.125f, -3.25f, -5.5f, -8.0f, -11.0f, -14.0f, -18.0f, + -22.0f }; + +/* `w5nl64a8h` decodes libquant's `table=w5nl`: thirty-two levels, sixteen magnitudes ascending + * then their negatives, so a code's high bit is its sign and its low four bits index the + * magnitudes. The kernel expands the magnitude from kW5nlMagPerm (their E4M3 bytes in w4_e4m3's + * dword order) and sets the sign bit from the sign plane. Every level is exact in E4M3. */ +static constexpr uint32_t kW5nlMagPerm[4] = { 0x4B484235u, 0x5453514Fu, 0x5A595856u, 0x5F5D5C5Bu }; +static constexpr float kW5nlTable[32] = { + 0.8125f, 2.5f, 4.0f, 5.5f, 7.5f, 9.0f, 11.0f, 12.0f, + 14.0f, 16.0f, 18.0f, 20.0f, 22.0f, 24.0f, 26.0f, 30.0f, + -0.8125f, -2.5f, -4.0f, -5.5f, -7.5f, -9.0f, -11.0f, -12.0f, + -14.0f, -16.0f, -18.0f, -20.0f, -22.0f, -24.0f, -26.0f, -30.0f }; + +/* The fixed second-level scale of `w4nl64a8h`, `w4nl32a8h` and `w5nl64a8h`: it multiplies a + * weight's per-(row, 64 or 32 of K) E4M3 scale. A container states it (libquant's scale2_value=), + * and the layout hook compares it with this before serving. Fixed rather than per row because the + * experts' scales (with the rotation's 1/128 folded in) lie between 2^-15 and 2^-10.6 on + * Qwen3.8-Flash-Next at group 64 (slightly lower at 32, half a binade lower for w5nl). Under + * 2^-13 each is a normal E4M3 value, and E4M3 has three mantissa bits in every binade. */ +static constexpr float kW4G64Scale = 0x1p-13f; + + +/* ================================================================== skinny-GEMM variants + * + * libhalo's five skinny-GEMM knobs, exposed as RadVariant.config so `rad-tune` can walk them and + * `--debug-graph` can name the pick (spec §15). The best setting depends on (N, K) and the M band. + * + * sk == 0 means "choose the largest legal split count at issue". Split-K requires + * K % (SK * group) == 0, so no fixed default is legal at every shape, and an illegal default would + * make an untuned install fail rather than run slowly (spec §15). The sentinel is resolved in one + * place, r3dh_gemm_args.h:pick_sk. + */ +struct HaloGemmCfg { int wv, sk, mb, npw, nt; }; + +/* The tiled and prefill GEMMs take one opaque variant index into libhalo's own switch of compiled + * tile arms; the row's tunable lists the arms a tuner may pick (r3dh_rows.cpp, kTileArms). */ +struct HaloTileCfg { int variant; int bm; int bn; }; + +/* The MXFP4 tiled GEMM's column width in 32-column units per wave: TN=2 gives a 256 x 64 block, + * TN=4 a 256 x 128 one. The crossover depends on M (see r3dh_gemm_mxfp4a8_tiled.hip), so 0, the + * default, decides at issue; a fixed value is for a tuner. */ +struct HaloMxTileCfg { int tn; }; + +/* The MXFP4 decode GEMM's split-K width, K slab and weight-load hint. 0 on each is the rule in + * r3dh_gemm_mxfp4a8_decode.hip (it needs M and the shape, which exist only at issue); `nt` 1 streams + * the weight past L2/MALL, 2 loads it plainly. */ +struct HaloMxDecCfg { int ks; int bk; int nt; }; + +/* Split-KV segment count for the paged decode kernels. 0 is libhalo's split law (table in + * r3dh_attn_paged_h256_gqa6.hip), which needs num_seqs and max_ctx from the issue, so it stays the + * default; fixed counts are for a tuner. RadScratchFn gets the same variant index, so the arena + * is sized for what this picks. */ +struct HaloSplitCfg { int splits; }; + +/* The all-reduce launch geometry, passed to libhalo as nblocks/nthreads/drain/acq (and `pub` at + * width). Defaults: nthreads=1024, drain=3 (s_wait_storecnt, which fine-grained uncached scratch + * requires), acq=0, pub=1, and nblocks scaled by message size and clamped; nblocks == 0 selects + * that rule. */ +struct HaloArCfg { int nblocks; int nthreads; int drain; int acq; int pub; }; + +/* rowtopk: RC is how many candidates a chunk keeps (>= R), NCH the requested chunk width (libhalo + * rounds it up to a multiple of eight columns, so the scratch hook asks r3dh_rowtopk_bf16_chunks() + * for the real one), PT1 the stage-1 thread count. */ +struct HaloTopkCfg { int rc; int nch; int pt1; }; + +/* The block-scaled fp8 matvec's rows a wave. Blocking trades waves for memory-level parallelism, + * so the best value depends on whether the kernel waits on loads or the ALU. The default rule is + * fitted to the current inner loop: any change to it (scale load width, activation dtype) + * requires re-fitting. 0 selects that rule; other values pin it for rad-tune. */ +struct HaloMvCfg { int rb; }; + + + +extern "C" { +/* -- the tuned configuration (r3dh_rows.cpp) -- + * + * The core picked a point in the space the row declared and appended it to RadArgs::p. These read + * it back, falling to the axis's default (defined once, in the RadTunable table) when a caller + * supplied none, so a checker with no tuned key runs what an untuned install runs. They cannot + * fail: the loader refuses a plugin whose default is not one of the axis's values. */ +void r3dh_cfg_gemm (const RadArgs*, struct HaloGemmCfg*); +void r3dh_cfg_tiled (const RadArgs*, struct HaloTileCfg*); +void r3dh_cfg_prefill(const RadArgs*, struct HaloTileCfg*); +void r3dh_cfg_mxfp4_tiled(const RadArgs*, struct HaloMxTileCfg*); +void r3dh_cfg_mxfp4_decode(const RadArgs*, struct HaloMxDecCfg*); +void r3dh_cfg_split (const RadArgs*, struct HaloSplitCfg*); +void r3dh_cfg_ar (const RadArgs*, struct HaloArCfg*); +/* Whether the four-rank fused junction takes its tail form from 5 rows (the row's `tail` axis). */ +int r3dh_cfg_ar_tail(const RadArgs*); +/* The four-rank exact one-shot's size, in elements, from which it takes the exact two-shot instead + * (0: never); the all-reduce rows' `ts_min` axis. */ +long r3dh_cfg_ar_ts_min(const RadArgs*); +/* The prefetch's workgroup count (the row's `nb` axis). */ +int r3dh_cfg_prefetch_nb(const RadArgs*); +void r3dh_cfg_topk (const RadArgs*, struct HaloTopkCfg*); +void r3dh_cfg_mv (const RadArgs*, struct HaloMvCfg*); +/* rmsnorm_quant_i8's decode form: 1 the row's operands in registers before the reductions, 0 the + * pass-per-read kernel; the row's `reg` axis. */ +int r3dh_cfg_rmsq8_reg(const RadArgs*); + +} /* extern "C" */ + +#endif /* R3DH_ARGS_H */ diff --git a/libr3d/r3dh_common.h b/libr3d/r3dh_common.h new file mode 100644 index 00000000..f9315f1f --- /dev/null +++ b/libr3d/r3dh_common.h @@ -0,0 +1,328 @@ +/* Ported from libhalo/halo_common.h, verbatim but for the halo_ -> r3dh_ rename, so libr3d builds and loads + * on its own. libhalo's gated-delta-net kernels are libr4d's ported to the gfx11 wave matrix and + * checked against libref on gfx1151 (rad-kbench); they compile for gfx11-generic unchanged. */ +/* Derived from libr4d/r4d_common.h by the libhalo rename transform (2026-10-26); + * see libhalo/README.md. Op schemas, row names and stored weight layouts are + * shared with libr4d by design. Everything else in this file is libhalo's own + * and diverges as it is measured on gfx1151. */ +// Shared device-side machinery for Halo. The layout algebra here was verified on hardware with +// targeted probes; do not "fix" it from a vendor doc. +#pragma once +#include +#include + +// The W4A8 scale group lives here, not in either GEMM, because both read the same packed weight and +// a disagreement would be silently wrong, not a link error. r3dh_gemm_args.h restates it and checks +// it against the layout constant. +#define R3DH_GEMM_W4A8_GROUP 128 // K per scale + +// ---- ragged query batches ---------------------------------------------------------------------- +// A paged-attention batch may have a different query length per sequence (HaloArgs::cu_q in halo.h). +// These are the two lookups every kernel indexing the dense q or out block needs, plus the inverse +// for the split-KV combine, which walks output rows rather than sequences. With cu_q null they +// compile to one multiply and no load; the branch is wave-uniform (cu_q is a kernel argument). +__device__ __forceinline__ int r3dh_q_off(const int* cu_q, int seq, int q_len) { + return cu_q ? cu_q[seq] : seq * q_len; +} +__device__ __forceinline__ int r3dh_q_len(const int* cu_q, int seq, int q_len) { + return cu_q ? (cu_q[seq + 1] - cu_q[seq]) : q_len; +} +// num_seqs is at most a few tens, so the search is a few scalar loads, once per block. +__device__ __forceinline__ int r3dh_q_seq(const int* cu_q, int num_seqs, int q_len, int tok) { + if (!cu_q) return tok / q_len; + int lo = 0, hi = num_seqs; // invariant: cu_q[lo] <= tok < cu_q[hi] + while (hi - lo > 1) { + const int mid = (lo + hi) >> 1; + if (cu_q[mid] <= tok) lo = mid; else hi = mid; + } + return lo; +} + +// ---- the occupancy a kernel is built for --------------------------------------------------------- +// R3DH_WAVES(n) fixes the waves per SIMD the compiler schedules a kernel for. Otherwise the +// scheduler picks that target itself and the choice moves between compiler releases (LLVM 24 +// serialises a GEMM's loads to win one more wave, paying a load round trip per WMMA). A kernel +// whose speed rests on a register budget states it here. `n` may depend on template arguments. +#define R3DH_WAVES(n) __attribute__((amdgpu_waves_per_eu((n), (n)))) + +typedef short v8s __attribute__((ext_vector_type(8))); +typedef float v8f __attribute__((ext_vector_type(8))); +typedef float v2f __attribute__((ext_vector_type(2))); // what cvt_pk_f32_fp8 actually returns + +/* A 16-byte staging register as a native vector. HIP's uint4 is a class template wrapping a + * union, and an array of them carried across a K loop (the next tile's chunks) is kept in scratch + * by LLVM 22 and 24, adding a scratch store and load per chunk; an ext_vector_type array is + * promoted to registers. Loaded and stored whole only. r3dh_dflash_conv_body.h declares the same + * type for a source also compiled without this header. */ +typedef unsigned int r3dh_u32x4 __attribute__((ext_vector_type(4))); + +// exp2 with the hardware transcendental. + +__device__ __forceinline__ float ex2(float x) { +#if __has_builtin(__builtin_amdgcn_exp2f) + return __builtin_amdgcn_exp2f(x); +#else + return exp2f(x); +#endif +} + +// f32 -> bf16, round-to-nearest-even, in software: gfx1201 has no v_cvt_pk_bf16_f32. +__device__ __forceinline__ uint16_t f32_to_bf16(float f) { + uint32_t u = __builtin_bit_cast(uint32_t, f); + return (uint16_t)((u + 0x7fffu + ((u >> 16) & 1u)) >> 16); +} + +// And back: a shift, since every bf16 is exactly a float. +__device__ __forceinline__ float bf16_to_f32(uint16_t h) { + return __builtin_bit_cast(float, (uint32_t)h << 16); +} + +// ---- 16-bit values held in whole registers ------------------------------------------------------- +// LLVM 24 gives gfx12 real 16-bit registers: a 16-bit value lives in one half of a VGPR. Packing +// two bf16 then costs a shift and a half move per pair instead of one v_perm_b32, widening costs a +// half move and a shift, and a 16-bit load into a half (global_load_d16_b16) depends on the +// register's earlier contents, so the waitcnt pass waits for them. The helpers below keep bf16 data +// in whole 32-bit registers from load to store, which compiles the same under LLVM 22 and 24 and +// gives the same bits as the 16-bit forms. + +// f32 -> bf16 rounded to nearest even, as the high half of a word whose low half is not zero +// (f32_to_bf16 before its final shift). A NaN can round to infinity, as there. +__device__ __forceinline__ uint32_t bf16_hi_rne(float f) { + const uint32_t u = __float_as_uint(f); + return u + 0x7fffu + ((u >> 16) & 1u); +} +// Rounds as (__hip_bfloat16)f does (LLVM's expansion): a NaN stays NaN, quieted; everything else +// rounds to nearest even. Both results are formed before the select so it compiles to one +// v_cndmask; `nan ? u | 0x400000 : u + ...` makes each element an exec-masked branch. +__device__ __forceinline__ uint32_t bf16_hi_rne_nan(float f) { + const uint32_t u = __float_as_uint(f); + const uint32_t r = u + 0x7fffu + ((u >> 16) & 1u), q = u | 0x400000u; + return f != f ? q : r; +} +// Two such words as one bf16 pair, `lo`'s high half in the low half: one byte permute. +__device__ __forceinline__ uint32_t bf16_pack_hi(uint32_t lo, uint32_t hi) { + return __builtin_amdgcn_perm(hi, lo, 0x07060302u); +} +// Two floats as a bf16 pair (`lo` in the low half), rounded as f32_to_bf16 rounds. +__device__ __forceinline__ uint32_t bf16x2_rne(float lo, float hi) { + return bf16_pack_hi(bf16_hi_rne(lo), bf16_hi_rne(hi)); +} +// Two floats as a bf16 pair, rounded as (__hip_bfloat16) rounds. +__device__ __forceinline__ uint32_t bf16x2_rne_nan(float lo, float hi) { + return bf16_pack_hi(bf16_hi_rne_nan(lo), bf16_hi_rne_nan(hi)); +} +// A bf16 pair word's two values as floats: a shift and a mask, no conversion. +__device__ __forceinline__ float bf16w_lo(uint32_t w) { return __uint_as_float(w << 16); } +__device__ __forceinline__ float bf16w_hi(uint32_t w) { return __uint_as_float(w & 0xffff0000u); } + +// One 16-bit element of global memory, zero-extended into a whole register (global_load_u16). +// Loaded as uint16_t it would go into a register half (global_load_d16_b16 or d16_hi_b16) and wait +// for the other half; through a generic pointer it would also be a flat load. The pointer must +// address global memory. +typedef __attribute__((address_space(1))) const uint16_t* r3dh_gu16; +__device__ __forceinline__ uint32_t ldg_u16(const uint16_t* p) { return *(r3dh_gu16)p; } + +// `lane ^ N` without the LDS pipe. `__shfl_xor` lowers to `ds_bpermute_b32` plus `s_wait_dscnt`, +// an LDS round trip that dominates a dependency chain (e.g. a dot product closed in a token loop). +// gfx10+ DPP16 has ROW_XMASK (0x160 | N), so for N < 16 the partner read is a modifier on the +// consuming VALU op (`v_add_f32_dpp ... row_xmask:2`). N = 16 crosses the two 16-lane rows of a +// wave32 and uses v_permlanex16, still one VALU op. Same lane mapping and value as the shuffle, +// provided all lanes are active, which every caller's whole-wave butterfly guarantees. +template +__device__ __forceinline__ uint32_t r3dh_xor_lane_u32(uint32_t v) { + static_assert(N >= 1 && N <= 16 && (N & (N - 1)) == 0, "a lane xor within the wave"); + if constexpr (N < 16) + return (uint32_t)__builtin_amdgcn_update_dpp(0, (int)v, 0x160 | N, 0xf, 0xf, true); + else + return (uint32_t)__builtin_amdgcn_permlanex16((int)v, (int)v, 0x76543210u, 0xFEDCBA98u, + false, false); +} + +template +__device__ __forceinline__ float r3dh_xor_lane(float v) { + return __uint_as_float(r3dh_xor_lane_u32(__float_as_uint(v))); +} + +// A 64-bit value's partner: the halves exchanged separately, as a 64-bit `__shfl_xor` does. +template +__device__ __forceinline__ unsigned long long r3dh_xor_lane_u64(unsigned long long v) { + const uint32_t lo = r3dh_xor_lane_u32((uint32_t)v); + const uint32_t hi = r3dh_xor_lane_u32((uint32_t)(v >> 32)); + return ((unsigned long long)hi << 32) | lo; +} + +// Exchange between lane L and lane L^16 (the two halves a wave32 WMMA fragment splits a row +// across). v_permlanex16_b32 swaps only with identity selectors (each 4-bit field names the source +// lane in the other half; sel0 covers lanes 0-7, sel1 lanes 8-15); zero selectors would silently +// broadcast lane 0. +__device__ __forceinline__ float swap16(float x) { return r3dh_xor_lane<16>(x); } + +// A wave32 sum on DPP instead of the LDS crossbar. `__shfl_xor` is a `ds_bpermute_b32` on gfx1201 +// at any offset, queued behind other LDS traffic; where little arithmetic separates reductions, a +// five-stage shuffle butterfly dominates the run. Offsets 8..1 use row_xmask (dpp_ctrl 0x160 | N) +// as a modifier on the add; 16 uses v_permlanex16_b32 (see swap16). +// +// The lanes exchanged and the order of the adds match the shuffle loop, so this is bit-identical +// and a kernel can move onto it without its output changing. Row and bank masks are all-ones since +// every lane participates; `bound_ctrl` is moot because every lane has a partner. +template +__device__ __forceinline__ float r3dh_dpp_xor_add(float v) { + return v + __builtin_bit_cast(float, + __builtin_amdgcn_update_dpp(0, __builtin_bit_cast(int, v), CTRL, 0xF, 0xF, true)); +} + +__device__ __forceinline__ float r3dh_wave_sum(float v) { + v += swap16(v); /* xor 16 -- crosses the two rows of sixteen */ + v = r3dh_dpp_xor_add<0x168>(v); /* xor 8 -- row_xmask from here down */ + v = r3dh_dpp_xor_add<0x164>(v); /* xor 4 */ + v = r3dh_dpp_xor_add<0x162>(v); /* xor 2 */ + v = r3dh_dpp_xor_add<0x161>(v); /* xor 1 */ + return v; +} + +// The same butterfly over a group of W lanes (W a power of two up to the wave): the exchanges of +// `for (o = W / 2; o; o >>= 1) v = op(v, __shfl_xor(v, o))`, in its order, so bit-identical to +// that loop. +template +__device__ __forceinline__ float r3dh_xor_sum(float v) { + static_assert(W >= 1 && W <= 32 && (W & (W - 1)) == 0, "a power-of-two group within the wave"); + if constexpr (W >= 32) v += r3dh_xor_lane<16>(v); + if constexpr (W >= 16) v += r3dh_xor_lane<8>(v); + if constexpr (W >= 8) v += r3dh_xor_lane<4>(v); + if constexpr (W >= 4) v += r3dh_xor_lane<2>(v); + if constexpr (W >= 2) v += r3dh_xor_lane<1>(v); + return v; +} + +template +__device__ __forceinline__ float r3dh_xor_max(float v) { + static_assert(W >= 1 && W <= 32 && (W & (W - 1)) == 0, "a power-of-two group within the wave"); + if constexpr (W >= 32) v = fmaxf(v, r3dh_xor_lane<16>(v)); + if constexpr (W >= 16) v = fmaxf(v, r3dh_xor_lane<8>(v)); + if constexpr (W >= 8) v = fmaxf(v, r3dh_xor_lane<4>(v)); + if constexpr (W >= 4) v = fmaxf(v, r3dh_xor_lane<2>(v)); + if constexpr (W >= 2) v = fmaxf(v, r3dh_xor_lane<1>(v)); + return v; +} + +__device__ __forceinline__ float r3dh_wave_max(float v) { return r3dh_xor_max<32>(v); } + +/* A wave's inclusive prefix and suffix sums in registers: row_shr (or row_shl) 1, 2, 4 and 8 + * within each row of sixteen, then the other row's total from one readlane. Lane L ends with the + * sum over lanes 0..L (prefix) or L..31 (suffix). Replaces LDS step-doubling scans (two barriers a + * round); integer sums, so combine order does not matter. Every lane must be active. */ +__device__ __forceinline__ uint32_t r3dh_wave_prefix_u32(uint32_t x, int lane) { + x += (uint32_t)__builtin_amdgcn_update_dpp(0, (int)x, 0x111, 0xF, 0xF, true); /* row_shr:1 */ + x += (uint32_t)__builtin_amdgcn_update_dpp(0, (int)x, 0x112, 0xF, 0xF, true); /* row_shr:2 */ + x += (uint32_t)__builtin_amdgcn_update_dpp(0, (int)x, 0x114, 0xF, 0xF, true); /* row_shr:4 */ + x += (uint32_t)__builtin_amdgcn_update_dpp(0, (int)x, 0x118, 0xF, 0xF, true); /* row_shr:8 */ + const uint32_t lo = (uint32_t)__builtin_amdgcn_readlane((int)x, 15); + return lane >= 16 ? x + lo : x; +} + +__device__ __forceinline__ uint32_t r3dh_wave_suffix_u32(uint32_t x, int lane) { + x += (uint32_t)__builtin_amdgcn_update_dpp(0, (int)x, 0x101, 0xF, 0xF, true); /* row_shl:1 */ + x += (uint32_t)__builtin_amdgcn_update_dpp(0, (int)x, 0x102, 0xF, 0xF, true); /* row_shl:2 */ + x += (uint32_t)__builtin_amdgcn_update_dpp(0, (int)x, 0x104, 0xF, 0xF, true); /* row_shl:4 */ + x += (uint32_t)__builtin_amdgcn_update_dpp(0, (int)x, 0x108, 0xF, 0xF, true); /* row_shl:8 */ + const uint32_t hi = (uint32_t)__builtin_amdgcn_readlane((int)x, 16); + return lane < 16 ? x + hi : x; +} + +// 8x8 transpose of 16-bit elements across each group of 8 lanes. Lane j receives element j from +// each of the 8 lanes in its group; the 8 addresses may be arbitrarily strided. +// +// gfx1151 has no global_load_tr_b128, so this loads each lane's 16 B and transposes in registers: +// lane (base+i)'s output element j is lane (base+j)'s loaded element i, eight shuffles of the one +// dword that holds it. Same result, more instructions; a caller on a hot path should say so in +// its header so the transpose can be folded into its addressing instead. +__device__ __forceinline__ v8s load_tr_b128(const void* p) { + const uint4 v = *(const uint4*)p; + const uint32_t w[4] = { v.x, v.y, v.z, v.w }; + const int lane = (int)(threadIdx.x & 31u); + const int base = lane & ~7, i = lane & 7; + uint32_t o[4] = { 0, 0, 0, 0 }; + // A shuffle returns the value the SOURCE lane passed, so a lane cannot ask for "my element i" + // in one shuffle: at lane base+j the argument `w[i >> 1]` is evaluated with THAT lane's i (j), + // not this one's. Fetch all four of the source lane's dwords and select this lane's element + // afterwards -- that is the transpose, and it is 32 shuffles rather than 8. +#pragma unroll + for (int j = 0; j < 8; ++j) { + const uint32_t d0 = (uint32_t)__shfl((int)w[0], base + j, 32); + const uint32_t d1 = (uint32_t)__shfl((int)w[1], base + j, 32); + const uint32_t d2 = (uint32_t)__shfl((int)w[2], base + j, 32); + const uint32_t d3 = (uint32_t)__shfl((int)w[3], base + j, 32); + const int d = i >> 1; + const uint32_t wd = d == 0 ? d0 : d == 1 ? d1 : d == 2 ? d2 : d3; + const uint32_t e = (i & 1) ? (wd >> 16) : (wd & 0xffffu); + o[j >> 1] |= e << (16 * (j & 1)); + } + v8s r; + __builtin_memcpy(&r, o, sizeof(o)); + return r; +} + +// Gather the low (sel=0) or high (sel=1) byte of each of four 16-bit lanes of {w0,w1} into one +// dword. Written so the compiler can contract each to a single v_perm_b32. +__device__ __forceinline__ uint32_t byte_gather(uint32_t w0, uint32_t w1, int sel) { + uint32_t s = (uint32_t)sel * 8u; + return ((w0 >> s) & 0xffu) + | (((w0 >> (16 + s)) & 0xffu) << 8) + | (((w1 >> s) & 0xffu) << 16) + | (((w1 >> (16 + s)) & 0xffu) << 24); +} + +__device__ __forceinline__ void sched_barrier() { __builtin_amdgcn_sched_barrier(0); } + +// __syncthreads() is a workgroup-scope acquire-release fence over all address spaces, so on gfx12 +// it emits `global_inv scope:SCOPE_SE` on both sides, discarding the L0/L1 lines the next tile's +// KV loads would hit. These barriers only order LDS traffic, so the fence is scoped to the local +// address space and the invalidate disappears. +__device__ __forceinline__ void lds_barrier() { + __builtin_amdgcn_fence(__ATOMIC_RELEASE, "workgroup", "local"); + __builtin_amdgcn_s_barrier(); + __builtin_amdgcn_fence(__ATOMIC_ACQUIRE, "workgroup", "local"); +} + +// Two-dword form of swap16. +__device__ __forceinline__ uint2 swap16_u2p(uint2 v) { + return make_uint2(__builtin_bit_cast(uint32_t, swap16(__builtin_bit_cast(float, v.x))), + __builtin_bit_cast(uint32_t, swap16(__builtin_bit_cast(float, v.y)))); +} + +// --------------------------------------------------------------------------------------------- +// Workgroup width for the activation-path kernels +// +// had_quant_act_i8, rmsnorm_had_quant_i8, gated_had_quant_i8 and gdn_gated_norm_had_quant_i8 launch +// one workgroup per row, so at decode batch sizes the grid is a few tens of workgroups on a 64-CU +// part and they are latency bound. Widening the workgroup is the only knob that adds parallelism, +// and it is the large win at small M. +// +// It reverses once the grid alone fills the machine. At 1024 threads there is a residency cliff +// just past M=32 where the wider workgroup stops fitting and the cost roughly doubles, so 1024 is +// used only with clearance below it. +// +// Where 512 stops paying depends on K, because the K floats of LDS a row needs cap how many +// workgroups a CU holds. At K=8704 only one fits at either width, so wider wins out to large M; at +// K=3072 five fit, the grid fills the part, and past M~72 the narrow width is even. The thresholds +// below are those crossovers. +__host__ __device__ __forceinline__ int r3dh_act_threads(int M, int K) { + if (M <= 32) return 1024; + const int lim = K >= 8192 ? (1 << 24) : (K >= 4096 ? 120 : 72); + return M <= lim ? 512 : 256; +} + +// libr4d's r4d_cliff_rows pads a grid past the R9700's full-card cliff (a launch in the last 32 +// wavefronts below a multiple of its 2048 wave slots runs ~5x slower). gfx1151 has no such cliff: +// measured 2026-10-26 with a fixed 200-iteration kernel at 256-thread workgroups, per-launch time +// rises smoothly through both candidate multiples (253..258 blocks: 10.18 -> 10.46 us, against the +// R9700's 27.6 vs 5.2), with only the ordinary second-round step at 161 blocks -- 160 blocks x 8 +// waves = 1280 = 40 CUs x 2 SIMDs x 16 wave slots exactly. So the row count to launch is the row +// count asked for, and this stays a function because every launch site already calls it: if a +// future part or driver grows a cliff, the pad goes back here and nowhere else. +__host__ __device__ __forceinline__ uint32_t r3dh_cliff_rows(uint32_t rows, uint32_t per_row, + uint32_t waves) { + (void)per_row; + (void)waves; + return rows; +} diff --git a/libr3d/r3dh_fp8_frag.h b/libr3d/r3dh_fp8_frag.h new file mode 100644 index 00000000..8a7a0ebc --- /dev/null +++ b/libr3d/r3dh_fp8_frag.h @@ -0,0 +1,44 @@ +/* Ported from libhalo/halo_fp8_frag.h, verbatim but for the halo_ -> r3dh_ rename, so libr3d builds and loads + * on its own. libhalo's gated-delta-net kernels are libr4d's ported to the gfx11 wave matrix and + * checked against libref on gfx1151 (rad-kbench); they compile for gfx11-generic unchanged. */ +/* Derived from libr4d/r4d_fp8_frag.h by the libhalo rename transform (2026-10-26); + * see libhalo/README.md. Op schemas, row names and stored weight layouts are + * shared with libr4d by design. Everything else in this file is libhalo's own + * and diverges as it is measured on gfx1151. */ +// r3dh_fp8_frag.h -- where a byte of a block-scaled FP8 weight lives in WMMA fragment order. Pure +// C++ (no HIP, no halo.h) so the host layout hook and the device kernels share one definition. +// +// Why permute: the fp8a8 GEMMs read operands through r3dh_fp8::frag(), which wants lane `l` to hold +// row `l & 15` of a 16-row tile at k `(l >> 4) * 8`, eight bytes. From a row-major weight those +// sixteen rows are `K` bytes apart, so a wave's load is sixteen transactions; the kernels stage +// through LDS to transpose, at the cost of a barrier, 36 KiB per block and a second pass over the +// weight. In fragment order the bytes are already in lane order. +// +// Why 64 k and not 16: a single fragment (16 rows x 16 k = 256 bytes) gives a wave one 256-byte +// cacheline per request, which loses even to LDS staging. Four fragments give each lane 32 +// contiguous bytes and the wave a 1 KiB request, which beats both at every N and K in the family. +// +// The unit is a (16 row, 64 k) tile of 1024 bytes, laid out as 32 lanes x 32 bytes. Lane `l`'s +// 32 bytes are its four fragments back to back: bytes `8t` are fragment `t`, covering +// k `t*16 + (l>>4)*8` of row `l & 15`. +// +// K must be a multiple of 64 and N of 16; the 128 scale block already guarantees both. +#pragma once +#include + +namespace r3dh_fp8 { + +enum { kFragRows = 16, kFragK = 16, kSuperK = 64, kTileBytes = 1024, kLaneBytes = 32 }; + +// Bytes one [N][K] weight occupies in fragment order: exactly N*K, since this is a permutation. +inline int64_t frag_bytes(int64_t N, int64_t K) { return N * K; } + +// The source (row, k) of a given (tile, lane, fragment, byte). The single definition of the +// permutation: the host transform walks it forwards, the device kernels index it backwards. +inline void frag_src(int64_t rt, int64_t ks, int64_t lane, int64_t t, int64_t j, + int64_t* row, int64_t* k) { + *row = rt * (int64_t)kFragRows + (lane & 15); + *k = ks * (int64_t)kSuperK + t * (int64_t)kFragK + (lane >> 4) * 8 + j; +} + +} // namespace r3dh_fp8 diff --git a/libr3d/r3dh_fp8_wmma.h b/libr3d/r3dh_fp8_wmma.h new file mode 100644 index 00000000..06f57501 --- /dev/null +++ b/libr3d/r3dh_fp8_wmma.h @@ -0,0 +1,123 @@ +/* Ported from libhalo/halo_fp8_wmma.h, verbatim but for the halo_ -> r3dh_ rename, so libr3d builds and loads + * on its own. libhalo's gated-delta-net kernels are libr4d's ported to the gfx11 wave matrix and + * checked against libref on gfx1151 (rad-kbench); they compile for gfx11-generic unchanged. */ +/* Derived from libr4d/r4d_fp8_wmma.h by the libhalo rename transform (2026-10-26); + * see libhalo/README.md. Op schemas, row names and stored weight layouts are + * shared with libr4d by design. Everything else in this file is libhalo's own + * and diverges as it is measured on gfx1151. */ +// Shared device code for the block-scaled FP8 family: the E4M3 decoders and the bf16 block-scale +// load. libr4d's version of this header also carries the gfx12 fp8 WMMA fragment map and its LDS +// staging; gfx1151 has no fp8 matrix instruction, so halo's fp8 GEMMs dequantise to bf16 in +// registers and run on r3dh_wmma.h's bf16 WMMA instead. That machinery lands with the fp8 GEMM +// units, in r3dh_wmma.h's terms; nothing here pretends otherwise. +#pragma once +#include "r3dh_common.h" +#include "r3dh_fp8_frag.h" + +#include +#include + +namespace r3dh_fp8 { + +/* The fp8 matrix machinery (libr4d's mma/mma8, fragment map and staging) is not + * carried over: it names gfx12 instructions and a fragment layout this part does + * not have. The fp8 GEMM units bring their own, built on r3dh_wmma.h. */ + +// ---- E4M3 -> f32 ------------------------------------------------------------------------------- +// +// One instruction on gfx1201 (v_cvt_f32_fp8); the software fallback is ~11 VALU ops. They agree on +// all bytes except 0x7F and 0xFF, E4M3-fn's NaN encodings: hardware returns NaN, the fallback +// +-480. Both quantisers clamp to +-448 = 0x7E, so real data never holds them. +// +// No subnormal-free fast path: a checkpoint weight may hold subnormals, which such a path would +// decode as 2^-7 * 1.MMM instead of MMM * 2^-9. +__device__ __forceinline__ float e4m3(uint32_t b) { +#if __has_builtin(__builtin_amdgcn_cvt_f32_fp8) + return __builtin_amdgcn_cvt_f32_fp8(b, 0); +#else + const uint32_t sign = (b & 0x80u) << 24; + const uint32_t ex = (b >> 3) & 0x0Fu; + const uint32_t mn = b & 0x07u; + const float nrm = __uint_as_float(((ex + 120u) << 23) | (mn << 20)); + const float sub = (float)mn * (1.0f / 512.0f); + return __uint_as_float(__float_as_uint(ex ? nrm : sub) | sign); +#endif +} + +// Two E4M3 bytes of a packed dword to two f32 in one instruction (v_cvt_pk_f32_fp8). `HI` selects +// bytes 2,3 over 0,1 and is a template parameter because the builtin's word select is a constant. +// Returns r3dh_common.h's `v2f`, the builtin's own return type. +template +__device__ __forceinline__ v2f e4m3_pk(uint32_t q) { +#if __has_builtin(__builtin_amdgcn_cvt_pk_f32_fp8) + return __builtin_amdgcn_cvt_pk_f32_fp8(q, HI); +#else + constexpr uint32_t s = HI ? 16u : 0u; + v2f r; + r.x = e4m3((q >> s) & 0xFFu); + r.y = e4m3((q >> (s + 8u)) & 0xFFu); + return r; +#endif +} + +// ---- f32 -> E4M3 ------------------------------------------------------------------------------- +// +// gfx1151 has no v_cvt_pkfp8_f32 (fp8-conversion-insts), so the encode is software. It is a +// transcription of abi/rad_plugin.h's rad_f32_to_fp8e4m3 -- round-to-nearest-even in both the +// normal and subnormal branches, saturating at 448, NaN to 0x7f -- because that function is the +// reference every fp8 store is checked against; a faster form must first be shown to agree with +// it on every input class (the host probe in the unit's bring-up compared 2^31 values). +__device__ __forceinline__ uint32_t f32_to_e4m3(float f) { + const uint32_t u = __builtin_bit_cast(uint32_t, f); + const uint32_t s = (u >> 24) & 0x80u; + const uint32_t a = u & 0x7fffffffu; + if (a > 0x7f800000u) return s | 0x7fu; /* nan */ + if (a >= 0x43e00000u) return s | 0x7eu; /* >= 448: clamp to the largest */ + const int e = (int)(a >> 23) - 127; + uint32_t m = a & 0x7fffffu; + if (e < -10) return s; + if (e < -6) { /* subnormal fp8 */ + const int sh = -6 - e + 20; + m |= 0x800000u; + const uint32_t lo = m & ((1u << sh) - 1u); + uint32_t q = m >> sh; + const uint32_t half = 1u << (sh - 1); + if (lo > half || (lo == half && (q & 1u))) ++q; + return s | q; + } + uint32_t q = m >> 20; + const uint32_t lo = m & 0xfffffu; + if (lo > 0x80000u || (lo == 0x80000u && (q & 1u))) ++q; + int ee = e + 7; + if (q == 0x8u) { q = 0; ++ee; } + if (ee > 15 || (ee == 15 && q >= 7u)) return s | 0x7eu; + return s | ((uint32_t)ee << 3) | q; +} + +/* __builtin_amdgcn_cvt_pk_fp8_f32's shape (two encodes into one half of `old`), so a call site + * moves onto it by name alone. Callers still clamp to +-448 first, as they did for the hardware + * instruction, whose out-of-range result is NaN rather than saturation; with the clamp the bytes + * are the same ones. */ +__device__ __forceinline__ int cvt_pk_fp8_f32(float lo_f, float hi_f, int old, bool word_sel) { + const uint32_t pair = f32_to_e4m3(lo_f) | (f32_to_e4m3(hi_f) << 8); + const uint32_t o = (uint32_t)old; + return (int)(word_sel ? (o & 0x0000ffffu) | (pair << 16) : (o & 0xffff0000u) | pair); +} + +// ---- block scale -------------------------------------------------------------------------------- +// +// The checkpoint's BF16 `weight_scale_inv` (one per 128x128 tile, row-major) is read natively: +// decode is one shift and one bitcast. Converting to UE8M0 would round every tile's gain to a +// power of two and force requantising the E4M3 bytes, for no saving (the scale plane is 21.8 KiB +// against an 89 MiB weight at gate_proj's shape). Unlike UE8M0, bf16 needs no zero test: +// `0u << 16` is +0.0f. +__device__ __forceinline__ float bscale(uint16_t s) { + return __uint_as_float((uint32_t)s << 16); +} +/* The same scale zero-extended in a full register (see u16_load_w in r3dh_moe.hip). The upper + * sixteen bits must be zero. */ +__device__ __forceinline__ float bscale(uint32_t s) { + return __uint_as_float(s << 16); +} + +} // namespace r3dh_fp8 diff --git a/libr3d/r3dh_gdn_args.h b/libr3d/r3dh_gdn_args.h new file mode 100644 index 00000000..2d544348 --- /dev/null +++ b/libr3d/r3dh_gdn_args.h @@ -0,0 +1,67 @@ +/* Ported from libhalo/halo_gdn_args.h, verbatim but for the halo_ -> r3dh_ rename, so libr3d builds and loads + * on its own. libhalo's gated-delta-net kernels are libr4d's ported to the gfx11 wave matrix and + * checked against libref on gfx1151 (rad-kbench); they compile for gfx11-generic unchanged. */ +/* Derived from libr4d/r4d_gdn_args.h by the libhalo rename transform (2026-10-26); + * see libhalo/README.md. Op schemas, row names and stored weight layouts are + * shared with libr4d by design. Everything else in this file is libhalo's own + * and diverges as it is measured on gfx1151. */ +/* r3dh_gdn_args.h -- argument helpers shared by the gated-delta-net kernels (and the DFlash ops): + * dtype checks, num_seqs from cu_seqlens, the compiled-geometry check and a row-pitch reader. + */ +#ifndef R3DH_GDN_ARGS_H +#define R3DH_GDN_ARGS_H + +#include "r3dh.h" +#include "r3dh_args.h" + + +/* Every `const void*` libhalo takes has one element type, cast inside the kernel (e.g. + * r3dh_gdn_conv_prep_w4_h128_bf16 reads `wgt` as bf16 and `A_log` as f32); the signature does not + * say so. A plugin declaring `ssm_conv1d.weight` or the `gdn_kkt` buffer as f32 would be read as + * bf16 on the device, while libref (which honours each operand's dtype) stays correct, so the bug + * would show only on the device path. The shim therefore checks dtypes by name (spec §2.1). */ +static inline int r3dh_dt(const RadTensor* t, uint32_t want) { + if (!t) return RAD_OK; /* an absent optional operand has no dtype */ + return t->dtype == want ? RAD_OK : RAD_E_DTYPE; +} +#define R3DH_DT(t, want) \ + do { const int _d = r3dh_dt((t), (want)); if (_d != RAD_OK) return R3DH_NO(_d); } while (0) + +/* A raw halo.h entry point's result as a RAD status. Those return 0, a negative code for a + * geometry they were not compiled for, or the positive hipError_t of a failed launch. */ +static inline int r3dh_raw_status(int rc, const char* file, int line) { + if (rc == 0) return RAD_OK; + return r3dh_refused(rc < 0 ? RAD_E_SHAPE : RAD_E_DEVICE, file, line); +} +#define R3DH_RAW(rc) r3dh_raw_status((rc), __FILE__, __LINE__) + +/* num_seqs from the [N+1] cu_seqlens tensor, the only operand that carries N. Requiring rank 1 + * keeps an off-by-one N from reaching kernels that index cu[N] unconditionally. */ +static inline int seqs_of(const RadTensor* cu, int* out) { + if (!cu || cu->rank != 1 || cu->shape[0] < 2) return R3DH_NO(RAD_E_SHAPE); + if (!r3dh_contig(cu)) return R3DH_NO(RAD_E_STRIDE); + *out = (int)(cu->shape[0] - 1); + return RAD_OK; +} + +/* libhalo's compiled-in geometry, so a rebuild at a different head size cannot silently change what + * the rows mean. */ +static inline int gdn_dims_ok(void) { + int hk = 0, hv = 0, ch = 0; + r3dh_gdn_dims(&hk, &hv, &ch); + return (hk == 128 && hv == 128 && ch == 64) ? RAD_OK : RAD_E_SHAPE; +} + + +/* Elements between consecutive `width`-wide rows: the second-to-last stride of a [.., heads, width] + * tensor, or `width` for a dense flattened [tokens, heads*width] one. Negative otherwise. */ +static inline long long gn_row_pitch(const RadTensor* t, long long width) { + if (!t || t->rank < 1) return -1; + if (t->shape[t->rank - 1] == width) { + if (t->stride[t->rank - 1] != 1) return -1; + return t->rank >= 2 ? t->stride[t->rank - 2] : width; + } + return r3dh_contig(t) ? width : -1; +} + +#endif /* R3DH_GDN_ARGS_H */ diff --git a/libr3d/r3dh_gdn_chunk_scan.hip b/libr3d/r3dh_gdn_chunk_scan.hip new file mode 100644 index 00000000..f4b0b118 --- /dev/null +++ b/libr3d/r3dh_gdn_chunk_scan.hip @@ -0,0 +1,724 @@ +/* Ported from libhalo/halo_gdn_chunk_scan.hip, verbatim but for the halo_ -> r3dh_ rename, so libr3d builds and loads + * on its own. libhalo's gated-delta-net kernels are libr4d's ported to the gfx11 wave matrix and + * checked against libref on gfx1151 (rad-kbench); they compile for gfx11-generic unchanged. */ +/* Derived from libr4d/r4d_gdn_chunk_scan_k128_v128_c64_bf16.hip by the libhalo rename transform (2026-10-26), + * then ported to gfx1151; see libhalo/README.md. */ +// r3dh_gdn: the gated-delta-net chunked scan, gfx1201 WMMA. Entry point +// r3dh_gdn_chunk_scan_k128_v128_c64_bf16 -- head_k 128, head_v 128, chunk 64, bf16 in. +// Used by prefill and chunked prefill; decode uses the recurrent update kernel. Replaces FLA's +// recompute_w_u_fwd + chunk_gated_delta_rule_fwd_h + chunk_fwd_o: the recurrent state stays in +// WMMA accumulators across the chunk loop, so h / w / u / v_new never touch HBM. +// +// Invariant: every decay factor formed is <= 1. The intra-chunk gate span reaches 558 nats on +// real Qwen3.8 prefill activations, so splitting the exponent about a per-chunk reference c +// (e^{g_i-c} * e^{c-g_j}) overflows fp32 on one side and underflows on the other for any c. +// e^{g_i-g_j} (j <= i) and e^{g_last-g_j} stay in (0, 1]. +// +// ge[j]=e^{g_j} gg[j]=g_j gs[j]=e^{g_last-g_j} +// U = K@S W = beta*(V - ge*U) V' = A@W (undecayed) +// P = Q@K^T sA = scale*e^{g_i-g_j}*tril(P) +// O = scale*ge*(Q@S) + sA@V' +// S = e^{g_last}*S + V'^T@(gs*K) +// A is FLA's solve_tril output (decay folded in), so no decay enters W or V'. The (i,j) weight +// is applied per element in the score step (eight __expf per tile), and the state's +// e^{g_last-g_j} is applied to K, which is otherwise dead by then. V' stays undecayed because its +// consumers need different references (e^{g_i-g_j} for the output, e^{g_last-g_j} for the state), +// and serving both from one scaling would need the unsafe split. +#include +#include "r3dh.h" +#include "r3dh_common.h" +#include "r3dh_gdn_args.h" +#include "r3dh_gdn_wmma.h" +// Barriers are lds_barrier(): __syncthreads() fences all address spaces, so the barrier after the +// global O store would wait on s_wait_storecnt_dscnt 0x0. +// +// ---- gfx1151 port notes --------------------------------------------------------------------- +// r3dh_gdn_wmma.h carries the fragment layer, so the *gathers* port by themselves: rowP/rowG lose +// libr4d's `4*(lane>>4)` k term and fragP reads the lane's whole 16-wide k run. What does NOT port +// is every accumulator write-out: on gfx11 element e is D[2e + (lane>>4)][lane & 15], not +// D[8*(lane>>4) + e][lane & 15], so +// +// * a transposed stage (s.S, s.A's score tile, s.W, s.D's V') keeps libr4d's destination and +// takes its eight values from accPackX(), after scaling them per element -- the two halves of +// the wave own different rows, so nothing can be scaled after the exchange; +// * O needs nothing: its hardware row is the v dim, so accPackX()'s eight consecutive rows are +// eight consecutive v of one token -- the contiguous HBM direction -- and both O loops, the +// per-lane scale and the store stay exactly as libr4d wrote them. +// The per-lane state (St[]) is the one place the wider fragment scatters: a lane's eight k values +// are two apart, so h0/ht go through an f32 LDS tile (see SF) rather than straight to HBM. + +// libr4d's rounding helpers (r4d_gdn_wmma.h) -- f2bf / f2bf2 / bf2f -- are r3dh_gdn_wmma.h's +// (included above): f2bf is round-half-AWAY, one add, so the bf16 stages keep libr4d's bits. +// gfx1151 has no v_cvt_pk_bf16_f32 either. + +// One accumulator stage: the eight elements accPackX() assembles, as two 8-byte stores (every +// buffer here is only 8-byte aligned, so a 16-byte store would be misaligned on odd rows). +// accPackX() packs with halo::pk_bf16's round-to-nearest-even, as accPack() does, where libr4d's +// f2bf4 rounds half away; the two differ only on an exact bf16 tie. It is accPack()'s values +// without its ds_bpermute exchange and per-pack branches (see r3dh_gdn_wmma.h). Both operand +// shapes are offered so a call site reads the same whether it holds a v8f or a float[8]. +__device__ __forceinline__ uint4 accPk(v8f v, int lane) { + union { v8f f; float s[8]; } u; + u.f = v; + return accPackX(u.s, lane); +} +__device__ __forceinline__ void accSt(unsigned short* dst, v8f v, int lane) { + const uint4 w = accPk(v, lane); + *(uint2*)dst = make_uint2(w.x, w.y); + *(uint2*)(dst + 4) = make_uint2(w.z, w.w); +} +__device__ __forceinline__ void accSt(unsigned short* dst, const float v[8], int lane) { + const uint4 w = accPackX(v, lane); + *(uint2*)dst = make_uint2(w.x, w.y); + *(uint2*)(dst + 4) = make_uint2(w.z, w.w); +} + +#define BT 64 +#define KD 128 +#define VD 128 +#define BV 64 // V per workgroup; also halves the Q@K^T redundancy +// Row pitches are multiples of 8 shorts (16 B) because r3dh_gdn_wmma.h's fragP reads a lane's whole +// 16-wide k run as two 16-byte LDS loads. They used KP = 132 / AP = 68 on gfx12, where a fragment is +// two 8-byte reads 16 bytes apart and 8-byte alignment suffices; on gfx1151 a buffer whose pitch is +// 136 B or 264 B puts every odd row 8 bytes off a 16-byte boundary, and a misaligned ds_load_b128 +// returns garbage -- silently, and only for some register allocations (measured: infs in a +// trailing partial chunk with the gfx12 pitches, none with these). +#define KP 136 // row pitch of the [.][KD] buffers, in shorts (272 B) +#define AP 72 // row pitch of the [.][BT] buffers, in shorts (144 B) +#define WP AP +// Waves per workgroup. The [4 token][4 v] tile grid is fixed by BT and BV, so 8 waves carry two +// tiles each. +#define NW 8 +#define NTHR (NW * 32) +#define NTV 2 // n tiles per wave in the main / V' / O loops +// A wave's slice of the 8 k-tile x 4 v-tile state grid is 2 x 2. +#define SKT 2 +#define SVT 2 +#define NST (SKT * SVT) // state tiles per wave + +// gfx1151 register plan. libr4d's plan (state, k/v prefetch, six main-loop accumulators) fits +// gfx12's 4-VGPR fragment; ported as is, with gfx11's 8-VGPR fragment, every instantiation sat at +// 256 VGPRs with 357-379 spilled (1.3 KB of scratch a lane: loop-invariant LDS addresses -- fragT's +// sixteen per-row addresses for the transposed K above all -- hoisted out of the chunk loop and +// reloaded inside it), and ~100 us a chunk. Measured on gfx1151 (kbench, M=512, the two fixture +// head counts: 820 / 493 us before, 155 / 118 after), what replaced it: +// * the state update reads gs*K from a transposed copy, s.KT, written by the pass that used to +// scale K in place, so every fragment in the kernel is a fragP. s.KT shares storage with the +// bf16 state s.S, whose last reader (the main loop) retires at barrier (2); the state is +// restaged at the top of the next chunk, after barrier (4) has retired the s.KT reads, so the +// alias costs no barrier. +// * every per-lane LDS address is one base plus immediates (a wave-uniform term goes in the +// base, never in a per-element index), so nothing is left for LICM to hoist. +// * no divergent branch on the chunk path: the accumulator write-outs use accPackX() (accPack() +// lowers to ds_bpermute + an LDS wait + a branch per pack), the score mask is a select after +// the exp, and the prefetch's zero fill is a select at consumption (-12% together). +// * the triangular work stops at the diagonal (P^T tiles, V' and O += sA@V' k steps): 544 +// WMMAs a chunk instead of 640, and the kernel is WMMA-throughput bound now (dropping P^T +// entirely saved its full share). +// * the first q fragments and the V' A fragments are issued ahead of the barrier that precedes +// their loop, so the first WMMAs do not wait out an HBM round trip (-13% / -4%). +// * h0 / ht pass through LDS (see SF): with element-wise HBM access the state traffic was ~45% +// of a one-chunk call. +// The result is 239-248 VGPRs, no spills, with ROCm 7.2.3 and 7.2.4. The margin is not wide: the +// main loop with its P^T count fixed (one all-tiles body instead of the three below) spills ~150. +// 16 waves of one tile each (<= 192 VGPRs, so two workgroups per WGP still fit) is ~12% slower. +struct Smem { + unsigned short k[BT][KP]; // A: K / B: K^T for P=Q@K^T + unsigned short A[BT][AP]; // B-source for sA (written as [i][j]) + union { + unsigned short S[BV][KP]; // B: state, V-major (matches FLA's [V,K] layout); main loop only + unsigned short KT[KD][AP]; // A: gs*K, transposed ([k][token]); state update only + }; + unsigned short W[BV][WP]; // B: W (transposed) + unsigned short D[BV][AP]; // staged V as [token][v]; then V' as [v][token]. + // V dies in the W update; V' is written after barrier (2). + float ge[BT], gv[BT], gg[BT], bt[BT]; // gv = gs, gg = raw g +}; + +// Choices measured against their alternatives on gfx1201, kept so they are not undone: +// - LDS rows in the main loop are opaque 32-bit byte offsets (fragO), global q / A fragments a +// 32-bit offset off a uniform base (fragGo). +// - k and v are staged eight shorts per lane (global_load_b128), issued as a block before the +// main loop: interleaving them into it is ~5% slower. +// - Every bf16 pack rounds (f2bf2 / accPackX). Truncating W, sA and V' is ~2% faster but +// roughly triples the fp64-oracle error, since they feed the recurrence. +// And on gfx1151: prefetching the gates (g, beta, g_last) with k / v, and sched_barrier fences +// in the main loop, measured neutral; more q fragments ahead of barrier (1) than QP spill. +// Byte offset, from the base of the shared block, of the fragment row this lane reads out of +// buf[base + (lane&15)][...]. r3dh_gdn_wmma.h's rowO is libr4d's ROWO without the `4*hi` k term: +// on gfx1151 the half-wave no longer selects which quarter of the k run a lane holds. +#define ROWO(buf, pitch, base) \ + rowO((unsigned)((const char*)&(buf)[0][0] - (const char*)&s), (pitch), (base), lane) + +// SDT is the state cache's element type (0 = fp32, 1 = fp16) and nothing else; all arithmetic is +// fp32. The cache is shared with the recurrent update (whose time is the state traffic, so it +// favours fp16) and allocated from vLLM's --mamba-ssm-cache-dtype, so both kernels must agree. +template struct cs_state { using T = float; }; +template <> struct cs_state<1> { using T = _Float16; }; + +// H0 / HT: whether the optional initial and final state operands are present (template parameters, +// so the common both-present form has no runtime test). As in libref, no initial state starts from +// zero and no final state stores nothing. +template +__global__ __launch_bounds__(NTHR) void r3dh_gdn_chunk_scan_kernel( + const unsigned short* __restrict__ q, const unsigned short* __restrict__ k, + const unsigned short* __restrict__ v, const unsigned short* __restrict__ Amat, + const float* __restrict__ gcs, const float* __restrict__ beta, + const typename cs_state::T* __restrict__ h0, unsigned short* __restrict__ o, + typename cs_state::T* __restrict__ ht, const int* __restrict__ cu, + const int* __restrict__ sidx, long sidx_stride, long st_slot, long st_head, + int H, int Hg, float scale) +{ + __shared__ Smem s; + const int bv = blockIdx.x, hv = blockIdx.y, nq = blockIdx.z; + const int tid = threadIdx.x, w = tid >> 5, lane = tid & 31; + const int hq = hv / (H / Hg), v0 = bv * BV; + const int tb = cu[nq], te = cu[nq + 1]; + // The state slot comes from the cache manager (sidx), not the batch position; without sidx the + // kernel uses state[nq], valid only while slots match batch order. A row may name several slots + // (speculative decode adds scratch slots); column 0 is the state and the only one used here. + const long si = sidx ? (long)sidx[(size_t)nq * sidx_stride] : (long)nq; + if (si < 0) return; // a padded row owns no state + const size_t st_base = (size_t)si * st_slot + (size_t)hv * st_head; + const int nchunk = (te - tb + BT - 1) / BT; + const int lo = lane & 15, hi = lane >> 4; + + // [BT][BV]: 2 tiles/wave. The token tile mt sets the wave's share of the triangular work (P^T, + // V', O += sA@V' all stop at the diagonal), so waves w and w+4 -- likely one SIMD -- pair + // mt with 3 - mt, and the n-tile pair is chosen to even out the P^T tiles (3, 2, 3, 2). + const int mt = (w >> 1) ^ (w >> 2), ntb = ((w ^ (w >> 2)) & 1) * 2; + // The state accumulator is held transposed, C[m=k-dim][n=v]. A and B fragments share a lane + // layout, so swapping the state update's operands is free, and k-dim becomes the per-lane + // contiguous axis: the per-chunk writeback to s.S is four 8-short stores instead of 32 scalar. + const int kt0 = (w >> 1) * 2, vt0 = (w & 1) * 2; // 2 x 2 + +#define PFW 8 // shorts staged per lane per step +#define NKB (BT * KD / (NTHR * PFW)) +#define NVB (BT * BV / (NTHR * PFW)) + uint4 kb[NKB], vb[NVB]; + // Staging index, split into a wave-uniform row and a loop-invariant lane column. As + // `i = tid*4 + u*NTHR*4; r = i>>7` the row looks divergent to LLVM and each load costs ~13 + // instructions of 64-bit address math; readfirstlane makes the row provably uniform (SALU). + // Identities (exact, since u*NTHR*8 is a multiple of both 128 and 64): + // k: r = 2*(tid>>5) + kh + KRU*u c = (tid*8) & 127 kh = (tid>>4) & 1 + // v: r = 4*(tid>>5) + vh + VRU*u c = (tid*8) & 63 vh = (tid>>3) & 3 + const int wu = __builtin_amdgcn_readfirstlane(tid >> 5); + const int kc = (tid * PFW) & (KD - 1), vc = (tid * PFW) & (BV - 1); + const int kr0 = 2 * wu + ((tid >> 4) & 1), vr0 = 4 * wu + ((tid >> 3) & 3); +#define KRU (2 * NW) +#define VRU (4 * NW) + // Do not change: staged rows past the chunk end are zeroed, not clamped to the last live row + // (~4% faster). A clamp looks harmless (beta and gv are 0 there, the tril mask drops padding j, + // the O store is guarded), yet with it any prompt whose trailing chunk is not a multiple of 16 + // tokens returns one repeated token. Zeroing k alone fixes it, so the leak is through some + // consumer of s.k whose path is not yet understood. + // The load itself is clamped (pnv >= 1 wherever this runs) and the zero selected when the + // staging store consumes it (PFSEL, against that chunk's nval): straight-line code, and a select + // at issue would make the prefetch wait for its own loads. +#define PFSTORE(dst, val) \ + do { \ + unsigned short* dp_ = (dst); \ + *(uint2*)dp_ = make_uint2((val).x, (val).y); \ + *(uint2*)(dp_ + 4) = make_uint2((val).z, (val).w); \ + } while (0) +#define PFSEL(r, val) \ + make_uint4((r) < nval ? (val).x : 0u, (r) < nval ? (val).y : 0u, \ + (r) < nval ? (val).z : 0u, (r) < nval ? (val).w : 0u) +#define PREFETCH(CH) \ + { \ + const int pc0 = tb + (CH) * BT, pnv = min(BT, te - pc0); \ + const unsigned short* kb_ = k + ((size_t)pc0 * Hg + hq) * KD; \ + const unsigned short* vb_ = v + ((size_t)pc0 * H + hv) * VD + v0; \ + _Pragma("unroll") for (int u = 0; u < NKB; ++u) { \ + const int r = kr0 + KRU * u, rc = min(r, pnv - 1); \ + kb[u] = *(const uint4*)(kb_ + (unsigned)(rc * (Hg * KD)) + kc); \ + } \ + _Pragma("unroll") for (int u = 0; u < NVB; ++u) { \ + const int r = vr0 + VRU * u, rc = min(r, pnv - 1); \ + vb[u] = *(const uint4*)(vb_ + (unsigned)(rc * (H * VD)) + vc); \ + } \ + } + + v8f St[NST]; // state: SKT k-tiles x SVT v-tiles +#define KT(t) (kt0 + (t) / SVT) +#define VT(t) (vt0 + (t) % SVT) +// State element e is v = VT*16 + lo, k = KT*16 + 2e + hi on gfx1151 (NOT 8*hi + e): a lane's eight +// values are two apart in the [v][k] state. Read straight from HBM that is 32 scalar loads a lane, +// each wave load touching sixteen rows for 8 bytes apiece; at one or two chunks the state traffic +// is half the kernel. So h0 and ht pass through LDS (free before the chunk loop and after barrier +// (4)) as an f32 [v][k] tile: coalesced 16-byte global accesses on one side, the accumulator +// layout on the other (pitch FP: lanes lo / hi land on banks 4*lo + hi, no conflict). +#define FP (KD + 4) + static_assert(sizeof(Smem) >= sizeof(float) * BV * FP, "the f32 state tile overlays Smem"); + float (*const F)[FP] = reinterpret_cast(&s); +#define SF(t, e) F[VT(t) * 16 + lo][KT(t) * 16 + 2 * (e) + hi] + if constexpr (!H0) { +#pragma unroll + for (int t = 0; t < NST; ++t) +#pragma unroll + for (int e = 0; e < 8; ++e) St[t][e] = 0.0f; + } else { + const typename cs_state::T* p = h0 + st_base + (size_t)v0 * KD; + if constexpr (SDT == 0) { // a row is 32 float4: wave wu takes rows wu + NW*u + float4 r[BV / NW]; +#pragma unroll + for (int u = 0; u < BV / NW; ++u) r[u] = *(const float4*)(p + (wu + NW * u) * KD + lane * 4); +#pragma unroll + for (int u = 0; u < BV / NW; ++u) *(float4*)&F[wu + NW * u][lane * 4] = r[u]; + } else { // a row is 16 x 8 halves: rows tid/16 + (NTHR/16)*u + const int r0 = tid >> 4, c = (tid & 15) * 8; + uint4 r[BV * 16 / NTHR]; +#pragma unroll + for (int u = 0; u < BV * 16 / NTHR; ++u) + r[u] = *(const uint4*)(p + (r0 + (NTHR / 16) * u) * KD + c); +#pragma unroll + for (int u = 0; u < BV * 16 / NTHR; ++u) { + union { uint4 w; _Float16 h[8]; } x; + x.w = r[u]; + float* d = &F[r0 + (NTHR / 16) * u][c]; + *(float4*)d = make_float4(x.h[0], x.h[1], x.h[2], x.h[3]); + *(float4*)(d + 4) = make_float4(x.h[4], x.h[5], x.h[6], x.h[7]); + } + } + lds_barrier(); +#pragma unroll + for (int t = 0; t < NST; ++t) +#pragma unroll + for (int e = 0; e < 8; ++e) St[t][e] = SF(t, e); + lds_barrier(); // the chunk loop's staging overwrites the tile + } + if (nchunk > 0) PREFETCH(0); + + const char* const sbase = (const char*)&s; + // scale goes inside the score exponent, exp(g_i + log(scale) - g_j), saving eight multiplies + // per tile. + const float lgs = __logf(scale); + for (int ci = 0; ci < nchunk; ++ci) { + const int c0 = tb + ci * BT, nval = min(BT, te - c0); + const int lim = nval - 1; + const unsigned short* qg = q + ((size_t)c0 * Hg + hq) * KD; + const unsigned short* ag = Amat + ((size_t)c0 * H + hv) * BT; + const size_t qrs = (size_t)Hg * KD, ars = (size_t)H * BT; + const float gl = gcs[(size_t)(c0 + lim) * H + hv]; + + // Issued before the staging stores so the LDS writes cover their latency. Only waves 0-1 + // (tid < BT) run this; the others wait at (1). + float ggr = 0.f, btr = 0.f; + if (tid < BT) { + bool ok = tid < nval; + ggr = ok ? gcs[(size_t)(c0 + tid) * H + hv] : 0.f; + btr = ok ? beta[(size_t)(c0 + tid) * H + hv] : 0.f; + } + // The main loop's first QP q fragments, issued ahead of the staging and barrier (1) so the + // first WMMAs do not wait out a full HBM round trip. +#define QP 4 + const unsigned qo = rowGo((unsigned)qrs, mt * 16, lim, lane); + v16bf aq0[QP]; +#pragma unroll + for (int sk = 0; sk < QP; ++sk) aq0[sk] = fragGo(qg, qo + sk * 16); + // The bf16 state for this chunk's U and O. s.S aliases s.KT, whose last reads (the previous + // chunk's state update) retired at barrier (4). +#pragma unroll + for (int t = 0; t < NST; ++t) + accSt(&s.S[VT(t) * 16 + lo][KT(t) * 16 + 8 * hi], St[t], lane); + { // consume the previous iteration's prefetch, issued a whole chunk of compute ago +#pragma unroll + for (int u = 0; u < NKB; ++u) PFSTORE(&s.k[kr0 + KRU * u][kc], PFSEL(kr0 + KRU * u, kb[u])); +#pragma unroll + for (int u = 0; u < NVB; ++u) PFSTORE(&s.D[vr0 + VRU * u][vc], PFSEL(vr0 + VRU * u, vb[u])); + } + if (tid < BT) { + bool ok = tid < nval; + s.bt[tid] = btr; + s.ge[tid] = __expf(ggr); + // g is a within-chunk cumsum of log-sigmoid gates, so it is non-increasing and gl is its + // minimum: gl - ggr <= 0, and gs underflowing to 0 is correct. + // A padding row gets gl, not 0: it is scored against live j with very negative g_j, and + // g_i = 0 would give exp(+400) = inf in s.A. With gl (the chunk minimum) the exponent + // stays in (0, scale]. The row is discarded anyway (O store is guarded). + s.gg[tid] = ok ? ggr : gl; + s.gv[tid] = ok ? __expf(gl - ggr) : 0.f; // gs + } + lds_barrier(); // (1) + if (ci + 1 < nchunk) PREFETCH(ci + 1); // issue only; consumed next iteration + + // ---- U = K@S, O^T = S@Q^T and P^T = K@Q^T share the q and k fragments. + // P^T tiles above the diagonal are skipped (sA masks them). On gfx12 that was 2.4% slower -- + // some wave still carries two tiles, so the barrier arrival does not move -- but here the + // kernel is throughput bound with two workgroups per WGP, so the WMMAs saved are time saved. + v8f O[NTV], u[NTV], p[NTV]; +#pragma unroll + for (int i = 0; i < NTV; ++i) { O[i] = (v8f){}; u[i] = (v8f){}; p[i] = (v8f){}; } + { + const char* sb = sbase; + // The two n tiles are 16 rows apart, so one base per buffer serves both (an immediate). + unsigned okm = ROWO(s.k, KP, mt * 16), oSn = ROWO(s.S, KP, ntb * 16), + okn = ROWO(s.k, KP, ntb * 16); + LDSOPAQUE(okm); LDSOPAQUE(oSn); LDSOPAQUE(okn); +#define pSnf(i, ko) fragO(sb, oSn + ((i) * 16 * KP + (ko)) * 2u) +#define pkmf(ko) fragO(sb, okm + (ko) * 2u) +#define pknf(i, ko) fragO(sb, okn + ((i) * 16 * KP + (ko)) * 2u) +#define pqf(ko) ((ko) / 16 < QP ? aq0[min((ko) / 16, QP - 1)] : fragGo(qg, qo + (ko))) + // P^T tile ntb+i is wholly above the diagonal (masked in sA) when ntb + i > mt: only the + // first np tiles are computed. np is wave-uniform, so each count gets its own loop. + auto mainloop = [&](auto npc) { + constexpr int NP = decltype(npc)::value; +#pragma unroll + for (int sk = 0; sk < KD / 16; ++sk) { + const int ko = sk * 16; + v16bf ak = pkmf(ko), aq = pqf(ko); +#pragma unroll + for (int i = 0; i < NTV; ++i) { + v16bf b = pSnf(i, ko); + u[i] = mma(ak, b, u[i]); // U: m = token, n = v-tile + O[i] = mma(b, aq, O[i]); // O^T: m = v-tile, n = token-tile + if (i < NP) p[i] = mma(pknf(i, ko), aq, p[i]); // P^T: m = j + } + } + }; + const int np = __builtin_amdgcn_readfirstlane(min(max(mt - ntb + 1, 0), NTV)); + if (np == NTV) mainloop(std::integral_constant{}); + else if (np) mainloop(std::integral_constant{}); + else mainloop(std::integral_constant{}); + } + { + // O's hardware row is the v dim and its column the token, which is the one place gfx1151 and + // gfx12 agree: accPackX()'s eight consecutive rows are eight consecutive v of one token, so + // this is libr4d's scale and store unchanged (a lane's token is mt*16 + lo). + float g = scale * s.ge[mt * 16 + lo]; // token index is constant per lane +#pragma unroll + for (int i = 0; i < NTV; ++i) +#pragma unroll + for (int e = 0; e < 8; ++e) O[i][e] *= g; + } + // The V' loop's A fragments come from HBM/L2: issued here, their latency is covered by the + // W / sA epilogue and barrier (2) instead of stalling the first V' WMMA. + v16bf af[BT / 16]; + { + const unsigned ao = rowGo((unsigned)ars, mt * 16, lim, lane); +#pragma unroll + for (int sk = 0; sk < BT / 16; ++sk) af[sk] = fragGo(ag, ao + sk * 16); + } + // W = beta * (V - ge*U) (beta folded here: (A*beta_col)@W == A@(beta_row*W)) + { + // Element e is token mt*16 + 2e + hi: one row pointer per lane, e and i are immediates. + const unsigned short* dv = &s.D[mt * 16 + hi][ntb * 16 + lo]; + const float* bp = &s.bt[mt * 16 + hi]; + const float* gp = &s.ge[mt * 16 + hi]; + float wa[NTV][8]; +#pragma unroll + for (int e = 0; e < 8; ++e) { // beta / ge read once for both tiles + const float f = bp[2 * e], g = gp[2 * e]; +#pragma unroll + for (int i = 0; i < NTV; ++i) + wa[i][e] = f * (bf2f(dv[2 * e * AP + i * 16]) - g * u[i][e]); + } +#pragma unroll + for (int i = 0; i < NTV; ++i) + accSt(&s.W[(ntb + i) * 16 + lo][mt * 16 + 8 * hi], wa[i], lane); + } + // sA = scale * e^{g_i-g_j} * tril(P). Row ii is constant per lane and the eight g_j are + // uniform per 16 lanes: eight broadcast LDS reads, v_sub and v_exp per tile (log(scale) is + // in the exponent). Where kept, g_i - g_j <= 0, so the exp cannot overflow. + // gfx1151: element e is the key (ntb+i)*16 + 2e + hi, so j and its mask are per element; the + // 16 consecutive keys of the row are reassembled by accPackX(). + { + const int ii = mt * 16 + lo; + const float gis = s.gg[ii] + lgs; + const float* gj = &s.gg[ntb * 16 + hi]; +#pragma unroll + for (int i = 0; i < NTV; ++i) { + // The exp is taken for every element and the mask applied as a select after it: written + // as one conditional expression it lowers to a divergent branch around each LDS read + // and exp. Above the diagonal the exponent may overflow; the select discards it. + float a[8], x[8]; +#pragma unroll + for (int e = 0; e < 8; ++e) { + x[e] = p[i][e] * __expf(gis - gj[i * 16 + 2 * e]); + asm volatile("" : "+v"(x[e])); // keeps MachineSink from re-forming the branch + } +#pragma unroll + for (int e = 0; e < 8; ++e) { + const int j = (ntb + i) * 16 + 2 * e + hi; + a[e] = (j <= ii) ? x[e] : 0.f; + } + accSt(&s.A[ii][(ntb + i) * 16 + 8 * hi], a, lane); + } + } + lds_barrier(); // (2) + + // ---- V' = gv * (A @ W) -> D (transposed store is one contiguous pair of dwords) + { + v8f d[NTV]; +#pragma unroll + for (int i = 0; i < NTV; ++i) d[i] = (v8f){}; + const unsigned short* pwn = rowP(&s.W[0][0], WP, ntb * 16, lane); +#define pwnf(i, ko) fragP(pwn + (i) * 16 * WP + (ko)) +#pragma unroll + for (int sk = 0; sk < BT / 16; ++sk) { + if (sk <= mt) { // A is lower triangular: A[mt][sk > mt] = 0 + const int ko = sk * 16; +#pragma unroll + for (int i = 0; i < NTV; ++i) d[i] = mma(af[sk], pwnf(i, ko), d[i]); + } + } +#pragma unroll + for (int i = 0; i < NTV; ++i) + accSt(&s.D[(ntb + i) * 16 + lo][mt * 16 + 8 * hi], d[i], lane); + } + // KT = (gs * K)^T, for the state's V'^T @ K: (diag(gs) V')^T K == V'^T (diag(gs) K). All raw-K + // reads (U, P) and s.S reads retired before barrier (2); barrier (3) publishes KT. A lane + // takes a token pair and eight k: two 16-byte row reads, eight dword stores of a [k] row + // (32 lanes, 32 consecutive dwords: no bank conflict). Same rounding as the old in-place + // scale: one f2bf of bf16(k) * gs per element. + { + const int t0 = 2 * lane; + const float f0 = s.gv[t0], f1 = s.gv[t0 + 1]; +#pragma unroll + for (int it = 0; it < KD / (8 * NW); ++it) { + const int c = (it * NW + wu) * 8; + const uint4 a = *(const uint4*)&s.k[t0][c], b = *(const uint4*)&s.k[t0 + 1][c]; + const unsigned av[4] = { a.x, a.y, a.z, a.w }, bw[4] = { b.x, b.y, b.z, b.w }; + unsigned* kt = (unsigned*)&s.KT[c][t0]; +#pragma unroll + for (int h = 0; h < 4; ++h) { + const float a0 = __builtin_bit_cast(float, av[h] << 16); + const float a1 = __builtin_bit_cast(float, av[h] & 0xffff0000u); + const float b0 = __builtin_bit_cast(float, bw[h] << 16); + const float b1 = __builtin_bit_cast(float, bw[h] & 0xffff0000u); + kt[(2 * h) * (AP / 2)] = f2bf2(a0 * f0, b0 * f1); + kt[(2 * h + 1) * (AP / 2)] = f2bf2(a1 * f0, b1 * f1); + } + } + } + lds_barrier(); // (3) + + // ---- O += sA @ V' ; store. V' also feeds the state update, unchanged. + { + const unsigned short* pA = rowP(&s.A[0][0], AP, mt * 16, lane); + const unsigned short* pdn = rowP(&s.D[0][0], AP, ntb * 16, lane); +#define pAf(ko) fragP(pA + (ko)) +#define pdnf(i, ko) fragP(pdn + (i) * 16 * AP + (ko)) +#pragma unroll + for (int sk = 0; sk < BT / 16; ++sk) { + if (sk <= mt) { // sA is masked to j <= i + const int ko = sk * 16; + v16bf b = pAf(ko); +#pragma unroll + for (int i = 0; i < NTV; ++i) O[i] = mma(pdnf(i, ko), b, O[i]); + } + } + } + { + // The half-wave exchange accPackX() does is a wave-wide lane operation (v_permlanex16), so it is + // taken for the whole wave and only the stores are guarded. A trailing partial chunk leaves + // lanes without a token, and a lane op under a divergent exec mask reads an inactive partner: + // measured as infinities in exactly those lanes' rows (see the pitch note above). + const int tok = mt * 16 + lo; + uint4 w[NTV]; +#pragma unroll + for (int i = 0; i < NTV; ++i) w[i] = accPk(O[i], lane); + if (tok < nval) { + // O's eight packed values are eight consecutive v of row tok (see the scale above). + unsigned short* op = o + ((size_t)(c0 + tok) * H + hv) * VD + v0; +#pragma unroll + for (int i = 0; i < NTV; ++i) + *(uint4*)(op + (ntb + i) * 16 + 8 * hi) = w[i]; + } + } + + // ---- S = e^{gl} * S + V'^T @ (gs*K) (A = KT rows, B = V' rows: both k-contiguous) + { + const float ec = __expf(gl); // gl <= 0: no lam, the decay is already on K +#pragma unroll + for (int t = 0; t < NST; ++t) +#pragma unroll + for (int e = 0; e < 8; ++e) St[t][e] *= ec; + const unsigned short* pvn = rowP(&s.D[0][0], AP, vt0 * 16, lane); + const unsigned short* pkt = rowP(&s.KT[0][0], AP, kt0 * 16, lane); +#pragma unroll + for (int sk = 0; sk < BT / 16; ++sk) { + v16bf bv[SVT]; +#pragma unroll + for (int j = 0; j < SVT; ++j) bv[j] = fragP(pvn + j * 16 * AP + sk * 16); +#pragma unroll + for (int ki = 0; ki < SKT; ++ki) { + v16bf ak = fragP(pkt + ki * 16 * AP + sk * 16); // K^T: m = k-dim +#pragma unroll + for (int j = 0; j < SVT; ++j) + St[ki * SVT + j] = mma(ak, bv[j], St[ki * SVT + j]); + } + } + } + lds_barrier(); // (4) + } + + if constexpr (!HT) return; + // Barrier (4) (or, with no chunk, the h0 load's last barrier) has retired every LDS read. +#pragma unroll + for (int t = 0; t < NST; ++t) +#pragma unroll + for (int e = 0; e < 8; ++e) SF(t, e) = St[t][e]; + lds_barrier(); + typename cs_state::T* p = ht + st_base + (size_t)v0 * KD; + if constexpr (SDT == 0) { +#pragma unroll + for (int u = 0; u < BV / NW; ++u) + *(float4*)(p + (wu + NW * u) * KD + lane * 4) = *(const float4*)&F[wu + NW * u][lane * 4]; + } else { + const int r0 = tid >> 4, c = (tid & 15) * 8; +#pragma unroll + for (int u = 0; u < BV * 16 / NTHR; ++u) { + const float* d = &F[r0 + (NTHR / 16) * u][c]; + const float4 a = *(const float4*)d, b = *(const float4*)(d + 4); + union { uint4 w; _Float16 h[8]; } x; + x.h[0] = (_Float16)a.x; x.h[1] = (_Float16)a.y; x.h[2] = (_Float16)a.z; x.h[3] = (_Float16)a.w; + x.h[4] = (_Float16)b.x; x.h[5] = (_Float16)b.y; x.h[6] = (_Float16)b.z; x.h[7] = (_Float16)b.w; + *(uint4*)(p + (r0 + (NTHR / 16) * u) * KD + c) = x.w; + } + } +} + +// Slot-indexed form (the one radiance calls). `sidx` names each batch row's state slot; without +// it the cache is indexed by row. `st_slot` and `st_head` are the cache strides in elements, which +// may exceed H*V*K when a caller pads its slots (vLLM pads to the attention page size). Pass +// sidx = null and strides 0 for the packed [N, H, V, K] layout. +extern "C" int r3dh_gdn_chunk_scan_k128_v128_c64_bf16_sidx( + const void* q, const void* k, const void* v, const void* A, const void* g, + const void* beta, const void* h0, void* o, void* ht, const void* cu, + const void* ssm_state_indices, long indices_stride, long state_slot_stride, + long state_head_stride, + int N, int H, int Hg, int K, int V, int bt, float scale, int state_fp16, void* stream) +{ + if (K != KD || V != VD || bt != BT) return -1; + // hq = hv / (H / Hg) truncates: H not a multiple of Hg would silently map v heads to the wrong + // k heads. Refused with -2, as in the kkt_solve and recurrent_update siblings. + if (Hg <= 0 || H % Hg) return -2; + const long st_head = state_head_stride > 0 ? state_head_stride : (long)VD * KD; + const long st_slot = state_slot_stride > 0 ? state_slot_stride : (long)H * VD * KD; + dim3 grid(V / BV, H, N), blk(NTHR); +#define CS_LAUNCH(SDTC, H0C, HTC) \ + hipLaunchKernelGGL((r3dh_gdn_chunk_scan_kernel), grid, blk, 0, \ + (hipStream_t)stream, \ + (const unsigned short*)q, (const unsigned short*)k, (const unsigned short*)v, \ + (const unsigned short*)A, (const float*)g, (const float*)beta, \ + (const cs_state::T*)h0, (unsigned short*)o, (cs_state::T*)ht, \ + (const int*)cu, (const int*)ssm_state_indices, (indices_stride > 0 ? indices_stride : 1), \ + st_slot, st_head, H, Hg, scale) +#define CS_PICK(SDTC) \ + do { if (h0 && ht) CS_LAUNCH(SDTC, true, true); \ + else if (h0) CS_LAUNCH(SDTC, true, false); \ + else if (ht) CS_LAUNCH(SDTC, false, true); \ + else CS_LAUNCH(SDTC, false, false); } while (0) + if (state_fp16) CS_PICK(1); else CS_PICK(0); +#undef CS_PICK +#undef CS_LAUNCH + return (int)hipGetLastError(); +} + +// Packed-layout entry point for the out-of-tree vLLM caller: one state per batch row, +// [N, H, V, K]. +extern "C" int r3dh_gdn_chunk_scan_k128_v128_c64_bf16( + const void* q, const void* k, const void* v, const void* A, const void* g, + const void* beta, const void* h0, void* o, void* ht, const void* cu, + int N, int H, int Hg, int K, int V, int bt, float scale, int state_fp16, void* stream) +{ + return r3dh_gdn_chunk_scan_k128_v128_c64_bf16_sidx(q, k, v, A, g, beta, h0, o, ht, cu, + nullptr, 0, 0, 0, N, H, Hg, K, V, bt, scale, + state_fp16, stream); +} + +// The compiled geometry, so callers can check a model's GDN shape against it. +extern "C" void r3dh_gdn_dims(int* head_k, int* head_v, int* chunk) { + if (head_k) *head_k = KD; + if (head_v) *head_v = VD; + if (chunk) *chunk = BT; +} + +// ============================================================== the plugin ABI entry points +// Shared operand helpers: r3dh_gdn_args.h. +/* ------------------------------------------------------------------ chunk scan */ + +enum { CS_Q = 0, CS_K, CS_V, CS_A, CS_G, CS_BETA, CS_H0, CS_CU, CS_O, CS_HT, CS_SIDX }; + +extern "C" int r3dh_rad_gdn_chunk_scan(const RadArgs* a, RadStream s) { + if (gdn_dims_ok() != RAD_OK) return R3DH_NO(RAD_E_SHAPE); + const RadTensor* q = r3dh_opt(a, CS_Q); + const RadTensor* k = r3dh_opt(a, CS_K); + const RadTensor* v = r3dh_opt(a, CS_V); + const RadTensor* A = r3dh_opt(a, CS_A); + const RadTensor* g = r3dh_opt(a, CS_G); + const RadTensor* bt = r3dh_opt(a, CS_BETA); + const RadTensor* h0 = r3dh_opt(a, CS_H0); + const RadTensor* cu = r3dh_opt(a, CS_CU); + const RadTensor* o = r3dh_opt(a, CS_O); + const RadTensor* ht = r3dh_opt(a, CS_HT); + const RadTensor* sidx = r3dh_opt(a, CS_SIDX); + if (!q || !k || !v || !A || !g || !bt || !cu || !o) return R3DH_NO(RAD_E_INVAL); + if (q->rank != 3 || k->rank != 3 || v->rank != 3 || o->rank != 3) return R3DH_NO(RAD_E_SHAPE); + if (A->rank != 3 || g->rank != 2 || bt->rank != 2) return R3DH_NO(RAD_E_SHAPE); + + int N = 0; + int rc = seqs_of(cu, &N); + if (rc != RAD_OK) return rc; + + /* The entry point takes no pitches: everything must be dense. */ + if (!r3dh_contig(q) || !r3dh_contig(k) || !r3dh_contig(v) || !r3dh_contig(A) || + !r3dh_contig(g) || !r3dh_contig(bt) || !r3dh_contig(o)) return R3DH_NO(RAD_E_STRIDE); + + /* bf16 q/k/v/A/out, fp32 gate/beta. */ + R3DH_DT(q, RAD_BF16); R3DH_DT(k, RAD_BF16); R3DH_DT(v, RAD_BF16); R3DH_DT(A, RAD_BF16); + R3DH_DT(o, RAD_BF16); R3DH_DT(g, RAD_F32); R3DH_DT(bt, RAD_F32); + /* The state cache is f32 or f16, taken from the operand's dtype (a property of the + * allocation), so this kernel and the recurrent update, which share the cache, agree on it. */ + const uint32_t st_dt = h0 ? h0->dtype : (ht ? ht->dtype : (uint32_t)RAD_F32); + if (st_dt != RAD_F32 && st_dt != RAD_F16) return R3DH_NO(RAD_E_DTYPE); + if (h0) R3DH_DT(h0, st_dt); + if (ht) R3DH_DT(ht, st_dt); + /* Slot strides come from the tensor, not from H, V and K, so a cache with padded slots is + * served too; the engine's own state cache is dense ([n_states, H, V, K] per layer). h0 and + * ht must share strides, since the kernel uses one base offset for both. */ + long long st_slot = 0, st_head = 0; + if (h0) { + if (h0->rank < 2) return R3DH_NO(RAD_E_SHAPE); + st_slot = h0->stride[0]; + st_head = h0->stride[1]; + } + if (ht) { + if (ht->rank < 2) return R3DH_NO(RAD_E_SHAPE); + if (h0 && (ht->stride[0] != st_slot || ht->stride[1] != st_head)) + return R3DH_NO(RAD_E_STRIDE); + st_slot = ht->stride[0]; + st_head = ht->stride[1]; + } + if (sidx) { + R3DH_DT(sidx, RAD_I32); + if (sidx->rank < 1 || sidx->shape[0] != N) return R3DH_NO(RAD_E_SHAPE); + if (sidx->stride[sidx->rank - 1] != 1) return R3DH_NO(RAD_E_STRIDE); + } + + const long long T = q->shape[0]; + const long long Hg = q->shape[1]; + const long long K = q->shape[2]; + const long long H = v->shape[1]; + const long long V = v->shape[2]; + const long long bt_chunk = A->shape[2]; + if (k->shape[0] != T || k->shape[1] != Hg || k->shape[2] != K) return R3DH_NO(RAD_E_SHAPE); + if (v->shape[0] != T || o->shape[0] != T || o->shape[1] != H || o->shape[2] != V) + return R3DH_NO(RAD_E_SHAPE); + if (A->shape[0] != T || A->shape[1] != H) return R3DH_NO(RAD_E_SHAPE); + if (g->shape[0] != T || g->shape[1] != H) return R3DH_NO(RAD_E_SHAPE); + if (bt->shape[0] != T || bt->shape[1] != H) return R3DH_NO(RAD_E_SHAPE); + if (H == 0 || Hg == 0 || H % Hg) return R3DH_NO(RAD_E_SHAPE); + + const float scale = (float)r3dh_getf(a, "scale", 1.0); + const int state_fp16 = st_dt == RAD_F16; + + return R3DH_RAW(r3dh_gdn_chunk_scan_k128_v128_c64_bf16_sidx( + q->data, k->data, v->data, A->data, g->data, bt->data, + h0 ? h0->data : nullptr, o->data, ht ? ht->data : nullptr, cu->data, + sidx ? sidx->data : nullptr, sidx && sidx->rank >= 2 ? (long)sidx->stride[0] : 1, + (long)st_slot, (long)st_head, + N, (int)H, (int)Hg, (int)K, (int)V, (int)bt_chunk, scale, state_fp16, s)); +} + diff --git a/libr3d/r3dh_gdn_conv_tap.h b/libr3d/r3dh_gdn_conv_tap.h new file mode 100644 index 00000000..80c261b3 --- /dev/null +++ b/libr3d/r3dh_gdn_conv_tap.h @@ -0,0 +1,23 @@ +/* Ported from libhalo/halo_gdn_conv_tap.h, verbatim but for the halo_ -> r3dh_ rename, so libr3d builds and loads + * on its own. libhalo's gated-delta-net kernels are libr4d's ported to the gfx11 wave matrix and + * checked against libref on gfx1151 (rad-kbench); they compile for gfx11-generic unchanged. */ +/* Derived from libr4d/r4d_gdn_conv_tap.h by the libhalo rename transform (2026-10-26); + * see libhalo/README.md. Op schemas, row names and stored weight layouts are + * shared with libr4d by design. Everything else in this file is libhalo's own + * and diverges as it is measured on gfx1151. */ +// r3dh_gdn_conv_tap.h -- the arithmetic of one gated-delta-net convolution output, shared by the +// standalone conv kernels (r3dh_gdn_conv_w4_h128_bf16.hip) and the recurrent update that folds the +// decode convolution into its prologue (r3dh_gdn_recurrent_update_k128_v128_bf16_fp32state.hip). +// A single definition keeps the fold byte-identical to the standalone path: the reciprocal form +// below changes the last bit of some bf16 outputs. +#pragma once + +#define R3DH_GDN_CONV_W 4 // conv width; the state holds R3DH_GDN_CONV_W - 1 taps of history + +// The result is rounded to bf16 immediately, so an IEEE-exact divide buys nothing: v_rcp_f32 is +// 1 ULP (~1e-7 relative) against bf16's 2^-8 quantum. The exact form is ~10 dependent instructions +// (v_div_scale, v_rcp, Newton, v_div_fmas, v_div_fixup); this is two. The conv update runs four +// waves on five workgroups, so its time is its instruction count. +__device__ __forceinline__ float cp_silu(float z) { + return z * __builtin_amdgcn_rcpf(1.0f + __expf(-z)); +} diff --git a/libr3d/r3dh_gdn_kkt_solve.hip b/libr3d/r3dh_gdn_kkt_solve.hip new file mode 100644 index 00000000..798c143c --- /dev/null +++ b/libr3d/r3dh_gdn_kkt_solve.hip @@ -0,0 +1,366 @@ +/* Ported from libhalo/halo_gdn_kkt_solve.hip, verbatim but for the halo_ -> r3dh_ rename, so libr3d builds and loads + * on its own. libhalo's gated-delta-net kernels are libr4d's ported to the gfx11 wave matrix and + * checked against libref on gfx1151 (rad-kbench); they compile for gfx11-generic unchanged. */ +/* Derived from libr4d/r4d_gdn_kkt_solve_k128_c64_bf16.hip by the libhalo rename transform (2026-10-26), + * then ported to gfx1151; see libhalo/README.md. */ +// r3dh_gdn_kkt_solve_k128_c64_bf16.hip -- the gated-delta-net chunk preamble in one kernel: +// +// A = (I + strict_lower(diag(beta) . K K^T . e^{g_i - g_j}))^{-1} per chunk of 64 +// +// Replaces FLA's chunk_scaled_dot_kkt_fwd + solve_tril, whose 64x64 fp32 intermediate per +// (chunk, head) round-trips through HBM. Here the gram stays in LDS and only the bf16 inverse is +// stored. Also: +// +// * The gram is computed once per k head, not per v head: K K^T does not depend on beta or g, +// so one workgroup owns a (chunk, k head) and applies each v head's scales to it. +// * The gram is computed as its upper-triangle tiles. K K^T is symmetric, and read transposed +// into A's strictly lower half each accumulator holds eight consecutive columns of one row: +// one 16-byte LDS store instead of eight 2-byte ones. +// +// The decay is applied per element as e^{g_i-g_j}, not split about a per-chunk reference c: each +// half of e^{g_i-c} * e^{c-g_j} can overflow fp32 on its own. Here the exponent is always <= 0 +// (g decreases along the chunk and only i > j is kept), and the eight exps per tile are cheap in +// a memory-bound kernel. +// +// The inverse is blocked 16 -> 32 -> 64. The four diagonal blocks use fp32 forward substitution +// (one wave each, one lane per column), cheaper than a WMMA Neumann series at this size and exact +// in fp32, as in FLA. The 32-merges and the 64-merge are WMMA, using +// +// [[P, 0], [R, Q]]^-1 = [[P^-1, 0], [-Q^-1 R P^-1, Q^-1]] +// +// mma(X, Y) computes X . Y^T from two k-contiguous operands, so a left operand is row-major and a +// right operand is stored transposed. An accumulator writes its transpose contiguously, so the +// intermediates are staged transposed; the final inverse is assembled row-major for the HBM store. +// +// ---- gfx1151 port notes (everything below the gram loop is unchanged in arithmetic) ----------- +// A gfx11 accumulator element e is D[2e + (lane>>4)][lane & 15], not gfx12's D[8*(lane>>4) + e] +// [lane & 15], so NO write-out here can keep libr4d's store arithmetic (r3dh_gdn_wmma.h). Two +// cases, and the kernel is split between them by where the value has to land: +// +// * a TRANSPOSED stage (TMP, and the gram's slice of A) -- eight consecutive rows of one column. +// accPack() reassembles exactly that from the half-pair, so the store is libr4d's (dst[lo] +// [8*hi]) with the eight values coming from accPack instead of f2bf4. The per-element scale +// and mask must be applied BEFORE the exchange: the two halves scale different rows. +// * a ROW-MAJOR stage into A (the two merge results), eight consecutive columns of one row. +// accPack() of the gfx11 accumulator gives rows, so the merge is taken with its two operands +// swapped -- mma is X.Y^T, so swapping them transposes the result and accPack then hands out +// C[lo][8*hi + 0..7]. Same two fragments, read on the other side. +#include +#include "r3dh.h" +#include "r3dh_common.h" // lds_barrier +#include "r3dh_gdn_args.h" +#include "r3dh_gdn_wmma.h" + +// libr4d's rounding helpers (r4d_gdn_wmma.h) -- f2bf / bf2f -- are r3dh_gdn_wmma.h's (included +// above): f2bf is round-half-AWAY, one add, which is what makes this kernel bit-comparable with the +// libr4d path. gfx1151 has no v_cvt_pk_bf16_f32 either. + +// One accumulator stage: the eight elements accPack() assembles, as two 8-byte stores. The buffers +// here are only 8-byte aligned (AP = 68 shorts), so a 16-byte store would be misaligned on odd rows. +// accPack() packs with halo::pk_bf16, i.e. round-to-nearest-even, where libr4d's f2bf4 rounds half +// away; the two differ only on an exact bf16 tie, and these are inverse intermediates. Both operand +// shapes are offered so a call site reads the same whether it holds a v8f or a float[8]. +__device__ __forceinline__ void accSt(unsigned short* dst, v8f v, int lane) { + union { v8f f; float s[8]; } u; + u.f = v; + const uint4 w = accPack(u.s, lane); + *(uint2*)dst = make_uint2(w.x, w.y); + *(uint2*)(dst + 4) = make_uint2(w.z, w.w); +} +__device__ __forceinline__ void accSt(unsigned short* dst, const float v[8], int lane) { + const uint4 w = accPack(v, lane); + *(uint2*)dst = make_uint2(w.x, w.y); + *(uint2*)(dst + 4) = make_uint2(w.z, w.w); +} + +#define BT 64 // chunk +#define KD 128 // head_k +#define NBK 4 // 16x16 blocks per chunk edge +// Row pitches are multiples of 8 shorts (16 B): r3dh_gdn_wmma.h's fragP reads a lane's whole 16-wide +// k run as two 16-byte LDS loads, so a buffer whose pitch is 136 B or 264 B (libr4d's AP = 68 / TMP +// = 36) puts every odd row 8 bytes off a 16-byte boundary, and a misaligned ds_load_b128 returns +// garbage. See r3dh_gdn_chunk_scan.hip's note: measured there as infs in a partial chunk. +#define AP 72 // row pitch of the [BT][BT] buffers, in shorts (144 B), 16-byte + // aligned for the paired stores; 16 rows still cover every bank +#define TMPP 40 // row pitch of the 32x32 transposed scratch, in shorts (80 B) +#define NW 4 +#define NTHR (NW * 32) +#define NTILE 10 // upper-triangular tiles of a 4x4 tiling +#define MAXT ((NTILE + NW - 1) / NW) + +// LDS limits occupancy, and this kernel is memory-bound, so buffers are minimised. No transposed +// inverse is kept (fragT rebuilds the three right operands that need it). The inverse is formed +// in place in A, since each stage reads the block it overwrites before writing it, with barriers +// between stages: +// diagonal p reads A[p][p], writes it after the substitution has finished reading +// 32-merge reads A10 and the two diagonal inverses, writes A10 +// 64-merge reads R = A[32:,:32] into TMP everywhere, barrier, then writes it +// One 64x64 buffer plus a 32x32 scratch: 11 KB instead of 31 KB. +struct KkSmem { + unsigned short A[BT][AP]; // A on the way in, its inverse on the way out + unsigned short TMP[32][TMPP]; // one 32x32 intermediate, transposed + float gb[BT], bt[BT]; // the chunk's gate cumsum and beta, per token +}; + +// (mt, nt) of upper-triangular tile ti, computed with wave-uniform arithmetic instead of a +// __constant__ table load. +__device__ __forceinline__ void kkt_tile(int ti, int* mt, int* nt) { + int m = 0, n = ti; + while (n >= NBK - m) { n -= (NBK - m); ++m; } + *mt = m; *nt = n + m; +} + +// No occupancy hint: at HG_RATIO=3 the kernel uses 190 VGPRs (8 waves per SIMD; LDS would allow +// 10), and forcing 10 waves spills 148 bytes per lane and is ~57% slower. +template +__global__ +__launch_bounds__(NTHR) +void r3dh_gdn_kkt_solve_kernel(const unsigned short* __restrict__ k, + const float* __restrict__ beta, + const float* __restrict__ g, + unsigned short* __restrict__ Ao, + const int* __restrict__ cu, + int N, int H, int Hg) +{ + __shared__ KkSmem s; + const int tid = threadIdx.x, lane = tid & 31, warp = tid >> 5; + const int lo = lane & 15, hi = lane >> 4; + const int hg = blockIdx.y; + + // Resolve the flat chunk id to (sequence, chunk). The grid is an upper bound on the chunk + // count, so surplus workgroups exit here; this saves the host a device-to-host sync to size + // the grid exactly. + int n = -1, t0 = 0, bos = 0, rows = 0; + { + int acc = 0, want = blockIdx.x; + for (int i = 0; i < N; ++i) { + const int b = cu[i], e = cu[i + 1]; + const int nc = (e - b + BT - 1) / BT; + if (want < acc + nc) { n = i; bos = b; t0 = (want - acc) * BT; + rows = min(BT, e - b - t0); break; } + acc += nc; + } + if (n < 0) return; + } + + // ---- zero A once: the parts no store reaches (the upper tiles) are the same for every head. + // 16-byte stores (the buffer is 8704 bytes, 16-byte aligned). + for (int i = tid; i < BT * AP / 8; i += NTHR) ((uint4*)&s.A[0][0])[i] = make_uint4(0, 0, 0, 0); + + // ---- the gram, once for all HG_RATIO v heads of this k head ----------------------------- + const unsigned short* kp = k + ((size_t)(bos + t0) * Hg + hg) * KD; + const unsigned krow = (unsigned)(Hg * KD); + v8f P[MAXT]; +#pragma unroll + for (int t = 0; t < MAXT; ++t) P[t] = (v8f){0, 0, 0, 0, 0, 0, 0, 0}; +#pragma unroll + for (int t = 0; t < MAXT; ++t) { + const int ti = warp + t * NW; + if (ti < NTILE) { + int mt, nt; kkt_tile(ti, &mt, &nt); + // One 32-bit offset per operand row, hoisted out of the k loop (see rowGo/fragGo). + const unsigned om = rowGo(krow, mt * 16, rows - 1, lane); + const unsigned on = rowGo(krow, nt * 16, rows - 1, lane); +#pragma unroll + for (int sk = 0; sk < KD / 16; ++sk) + P[t] = mma(fragGo(kp, om + sk * 16), fragGo(kp, on + sk * 16), P[t]); + } + } + + for (int hh = 0; hh < HG_RATIO; ++hh) { + const int hv = hg * HG_RATIO + hh; + + // ---- per-head gate and beta for this chunk + if (tid < BT) { + const int t = min(tid, rows - 1); + s.gb[tid] = g[(size_t)(bos + t0 + t) * H + hv]; + s.bt[tid] = beta[(size_t)(bos + t0 + t) * H + hv]; + } + lds_barrier(); + + // ---- scale, mask and place the gram as the strictly lower half of A --------------------- + // Tile (mt, nt) holds P[m][n]; the element written is A[n][m], in the lower triangle when + // n > m. n is fixed per lane and m runs over the eight accumulator elements: one row of A, + // one 8-short store. + // + // gfx1151: element e is m = mt*16 + 2e + hi, not mt*16 + 8hi + e, so the eight columns this + // lane owns are two-apart and interleaved with its half-partner's. Each element is scaled by + // its OWN exponent first, and accPack() then reassembles the 16 consecutive columns of row i + // out of the half-pair: this lane keeps columns mt*16 + 8*hi .. +7, as on gfx12. +#pragma unroll + for (int t = 0; t < MAXT; ++t) { + const int ti = warp + t * NW; + if (ti < NTILE) { + int mt, nt; kkt_tile(ti, &mt, &nt); + const int i = nt * 16 + lo; // row of A + const int j0 = mt * 16 + 8 * hi; // first column of A, after the exchange + const bool live = (i < rows); + const float bi = live ? s.bt[i] : 0.0f; + const float gi = live ? s.gb[i] : 0.0f; + float vv[8]; +#pragma unroll + for (int e = 0; e < 8; ++e) { + const int j = mt * 16 + 2 * e + hi; + // For a live row, i > j gives g_i <= g_j, so the exponent is never positive. Padding + // rows and columns must be masked to -inf: with gi = 0 the exponent -gb[j] is large and + // positive, 0 * inf = NaN, and the WMMA merges in the blocked inverse would spread it + // into live rows. + const float d = (live && i > j && j < rows) ? (gi - s.gb[j]) : -INFINITY; + vv[e] = bi * __expf(d) * P[t][e]; + } + accSt(&s.A[i][j0], vv, lane); + } + } + lds_barrier(); + + // ---- 1. the four diagonal blocks, by fp32 forward substitution -------------------------- + // D = (I + N)^-1 solves D = I - N D row by row. Lane l owns column l of D, so the dot product + // over j < i is in 16 registers and N[i][j] is a broadcast LDS read. + for (int p = warp; p < NBK; p += NW) { + const int b0 = p * 16; + float d[16]; +#pragma unroll + for (int i = 0; i < 16; ++i) { + float acc = 0.0f; +#pragma unroll + for (int j = 0; j < 16; ++j) + if (j < i) acc += bf2f(s.A[b0 + i][b0 + j]) * d[j]; + d[i] = ((lo == i) ? 1.0f : 0.0f) - acc; + } + if (lane < 16) { +#pragma unroll + for (int i = 0; i < 16; ++i) s.A[b0 + i][b0 + lo] = f2bf(d[i]); + } + } + lds_barrier(); + + // ---- 2. the two 32-merges: M10 = -D1 A10 D0 -------------------------------------------- + for (int blk = warp; blk < 2; blk += NW) { + const int r0 = blk * 32; // 32-block origin + // X = A10 . D0 (left A10 row-major, right D0 transposed = MT) + v8f X = (v8f){0, 0, 0, 0, 0, 0, 0, 0}; + X = mma(frag(&s.A[0][0], AP, r0 + 16, r0, lane), + fragT(&s.A[0][0], AP, r0, r0, lane), X); + // Stage X transposed for the next product; each of the two merges owns 16 rows of TMP. + accSt(&s.TMP[blk * 16 + lo][8 * hi], X, lane); + // Same wave writes and reads TMP here, and LDS accesses from one wave complete in order. + __builtin_amdgcn_wave_barrier(); + // M10 = -D1 . X (left D1 row-major, in place in A; right X transposed, in TMP) + // Operands swapped on gfx1151: this accumulates Y^T, so accPack() below hands out eight + // consecutive rows of Y -- which is a row-major store into A. TMP already holds X^T (what + // libr4d stages), which is this product's LEFT operand here, and D1 the right one. + v8f Y = (v8f){0, 0, 0, 0, 0, 0, 0, 0}; + Y = mma(frag(&s.TMP[0][0], TMPP, blk * 16, 0, lane), + frag(&s.A[0][0], AP, r0 + 16, r0 + 16, lane), Y); + float yv[8]; +#pragma unroll + for (int e = 0; e < 8; ++e) yv[e] = -Y[e]; + accSt(&s.A[r0 + 16 + lo][r0 + 8 * hi], yv, lane); // rows of M10, 8 columns each + } + lds_barrier(); + + // ---- 3. the 64-merge: M[32:,:32] = -Q^-1 (R P^-1) -------------------------------------- + // Y = R . P^-1, R = A[32:,:32] row-major, P^-1 read transposed out of A[:32,:32] by fragT + for (int t = warp; t < 4; t += NW) { + const int mt = t >> 1, nt = t & 1; + v8f Y = (v8f){0, 0, 0, 0, 0, 0, 0, 0}; +#pragma unroll + for (int sk = 0; sk < 2; ++sk) + Y = mma(frag(&s.A[0][0], AP, 32 + mt * 16, sk * 16, lane), + fragT(&s.A[0][0], AP, nt * 16, sk * 16, lane), Y); + accSt(&s.TMP[nt * 16 + lo][mt * 16 + 8 * hi], Y, lane); + } + lds_barrier(); // every wave has read R into TMP; now it may be overwritten + // Z = -Q^-1 . Y, Q^-1 = A[32:,32:] row-major, Y transposed = TMP + // Swapped, as M10 above: this accumulates Z^T so accPack() gives a row-major store. Y^T sits + // in TMP ([col][row]) and is the left operand here; Q^-1's rows are the right one. + for (int t = warp; t < 4; t += NW) { + const int mt = t >> 1, nt = t & 1; + v8f Z = (v8f){0, 0, 0, 0, 0, 0, 0, 0}; +#pragma unroll + for (int sk = 0; sk < 2; ++sk) + Z = mma(frag(&s.TMP[0][0], TMPP, nt * 16, sk * 16, lane), + frag(&s.A[0][0], AP, 32 + mt * 16, 32 + sk * 16, lane), Z); + float zv[8]; +#pragma unroll + for (int e = 0; e < 8; ++e) zv[e] = -Z[e]; + accSt(&s.A[32 + mt * 16 + lo][nt * 16 + 8 * hi], zv, lane); + } + lds_barrier(); + + // ---- store: one row of the inverse is 64 bf16, contiguous in HBM ----------------------- + { + unsigned short* op = Ao + ((size_t)(bos + t0) * H + hv) * BT; + const size_t orow = (size_t)H * BT; + for (int r = tid / 8; r < rows; r += NTHR / 8) { + const int c8 = (tid & 7) * 8; + *(uint4*)(op + (size_t)r * orow + c8) = *(const uint4*)(&s.A[r][c8]); + } + } + if (hh + 1 < HG_RATIO) lds_barrier(); + } +} + +extern "C" int r3dh_gdn_kkt_solve_k128_c64_bf16(const void* k, const void* beta, const void* g, + void* A, const void* cu, int N, int T, int H, + int Hg, int K, int bt, void* stream) +{ + if (K != KD || bt != BT) return -1; + if (H % Hg) return -2; + const int nchunk_ub = (T + BT - 1) / BT + N; // sum of per-sequence chunk counts, bounded + dim3 grid(nchunk_ub, Hg), blk(NTHR); +#define KK_LAUNCH(R) \ + hipLaunchKernelGGL((r3dh_gdn_kkt_solve_kernel), grid, blk, 0, (hipStream_t)stream, \ + (const unsigned short*)k, (const float*)beta, (const float*)g, \ + (unsigned short*)A, (const int*)cu, N, H, Hg) + switch (H / Hg) { + case 1: KK_LAUNCH(1); break; + case 2: KK_LAUNCH(2); break; + case 3: KK_LAUNCH(3); break; + case 4: KK_LAUNCH(4); break; + case 6: KK_LAUNCH(6); break; + case 8: KK_LAUNCH(8); break; + default: return -3; + } +#undef KK_LAUNCH + return (int)hipGetLastError(); +} + +// ============================================================== the plugin ABI entry points +// Shared operand helpers: r3dh_gdn_args.h. +/* ------------------------------------------------------------------ kkt solve */ + +enum { KS_K = 0, KS_BETA, KS_G, KS_CU, KS_A }; + +extern "C" int r3dh_rad_gdn_kkt_solve(const RadArgs* a, RadStream s) { + if (gdn_dims_ok() != RAD_OK) return R3DH_NO(RAD_E_SHAPE); + const RadTensor* k = r3dh_opt(a, KS_K); + const RadTensor* bt = r3dh_opt(a, KS_BETA); + const RadTensor* g = r3dh_opt(a, KS_G); + const RadTensor* cu = r3dh_opt(a, KS_CU); + const RadTensor* A = r3dh_opt(a, KS_A); + if (!k || !bt || !g || !cu || !A) return R3DH_NO(RAD_E_INVAL); + if (k->rank != 3 || bt->rank != 2 || g->rank != 2 || A->rank != 3) return R3DH_NO(RAD_E_SHAPE); + if (!r3dh_contig(k) || !r3dh_contig(bt) || !r3dh_contig(g) || !r3dh_contig(A)) + return R3DH_NO(RAD_E_STRIDE); + /* bf16 k and A (the output, written as bf16); fp32 beta and gate. */ + R3DH_DT(k, RAD_BF16); R3DH_DT(A, RAD_BF16); R3DH_DT(bt, RAD_F32); R3DH_DT(g, RAD_F32); + + int N = 0; + int rc = seqs_of(cu, &N); + if (rc != RAD_OK) return rc; + + const long long T = k->shape[0]; + const long long Hg = k->shape[1]; + const long long K = k->shape[2]; + const long long H = bt->shape[1]; + const long long chunk = A->shape[2]; + if (g->shape[0] != T || g->shape[1] != H || bt->shape[0] != T) return R3DH_NO(RAD_E_SHAPE); + if (A->shape[0] != T || A->shape[1] != H) return R3DH_NO(RAD_E_SHAPE); + if (H == 0 || Hg == 0 || H % Hg) return R3DH_NO(RAD_E_SHAPE); + + return R3DH_RAW(r3dh_gdn_kkt_solve_k128_c64_bf16(k->data, bt->data, g->data, A->data, + cu->data, N, (int)T, (int)H, (int)Hg, (int)K, + (int)chunk, s)); +} + diff --git a/libr3d/r3dh_gdn_recurrent_update.hip b/libr3d/r3dh_gdn_recurrent_update.hip new file mode 100644 index 00000000..7fd07aff --- /dev/null +++ b/libr3d/r3dh_gdn_recurrent_update.hip @@ -0,0 +1,1229 @@ +/* Ported from libhalo/halo_gdn_recurrent_update_k128_v128_bf16_fp32state.hip, verbatim but for the halo_ -> r3dh_ rename, so libr3d builds and loads + * on its own. libhalo's gated-delta-net kernels are libr4d's ported to the gfx11 wave matrix and + * checked against libref on gfx1151 (rad-kbench); they compile for gfx11-generic unchanged. */ +/* Derived from libr4d/r4d_gdn_recurrent_update_k128_v128_bf16_fp32state.hip by the libhalo rename transform (2026-10-26), + * then ported to gfx1151; see libhalo/README.md. */ +// r3dh_gdn_recurrent_update_k128_v128_bf16_fp32state.hip -- the gated-delta-net recurrent state +// update, run by decode (prefill runs the chunked scan). One kernel for the whole step: +// +// g = -exp(A_log) . softplus(a + dt_bias) beta = sigmoid(b) q, k l2-normalised +// S *= e^g +// u = beta . (v - S k) S += u k^T o = S q +// +// per token, against a paged state cache: the initial state is read from the slot the last +// accepted token wrote, and every candidate token writes its own slot, since which survives +// verification is unknown until after this layer. Replaces FLA's +// fused_sigmoid_gating_delta_rule_update; the non-speculative case is width 1. +// +// State traffic is the whole cost: one fp32 [V,K] state is 64 KB, written per candidate token per +// head (113 MB per layer per rank at width 9, at the memory bandwidth limit). So the design keeps +// the state in registers: one thread owns one v row and half its k range, so +// +// * S k and S q are in-lane dot products closed by a single lane<->lane^1 exchange, not a +// tree reduction; +// * the outer-product update is 64 independent FMAs with no cross-lane traffic at all; +// * a thread's 64 state elements are contiguous in k, so the load and every store is four +// 16-byte accesses over one 256-byte run. +// +// The state cache is fp32 by default (the model's HF config sets mamba_ssm_dtype=float32, which +// vLLM honours); the conv state is bf16. An fp16 state cache is also supported (SDT). +// +// Slot and head strides are arguments, not H*V*K: vLLM's hybrid cache pads a mamba page to the +// attention page size (e.g. 421888 elements per slot vs 393216 from the shape), so a shape-derived +// stride would read every slot but the first at the wrong offset there. +#include +#include "r3dh.h" +#include "r3dh_gdn_args.h" +#include "r3dh_common.h" // bf16_to_f32 / f32_to_bf16, r3dh_xor_lane +#include "r3dh_gdn_conv_tap.h" +#include "r3dh_q8.h" // the 8-bit codes the folded quantiser writes: E4M3 or int8 +#include +#include +#include +#include +#include + +#define RU_K 128 // head_k +#define RU_V 128 // head_v +#define RU_HK 64 // k elements per thread (RU_K / 2) +#define RU_THR (RU_V * 2) // two threads per v row + +// The state written per step (~12 MB a layer, ~660 MB a step) is read again only once, a step +// later, and cannot stay in the 64 MB last-level cache; its write-back slows the next GEMM (a +// (5120, 3072) GEMM goes from 14.9 us to 20.4 us behind a 12 MB write flood, 18.4 us when the +// flood is non-temporal). A non-temporal hint on the state load and store changes no result, and +// whether it pays depends on the flood size, so it is chosen per launch (RU_NT_MB below). +typedef float ru_f4 __attribute__((ext_vector_type(4))); +typedef _Float16 ru_h8 __attribute__((ext_vector_type(8))); + +// SDT is the state cache's element type (0 = fp32, 1 = fp16); all arithmetic is fp32. At eight +// sequences x eight candidates a call is ~68 us, of which ~45 us is 24 MB of state traffic at 88% +// of achievable bandwidth; halving the state width saves about a third. +// +// Cost model (eight sequences, 16k context, anchor state): ~3.2 us per token walked plus ~57 us +// fixed per layer. State traffic largely overlaps the token loop (fp16 state saves only about a +// fifth of what its byte count predicts), and the loop is on the critical path. +// +// Shipped instantiation: 207 VGPRs, 7 waves/SIMD, no spill, 384 B LDS (the gfx1201 numbers; the +// gfx1151 port keeps the same geometry -- the kernel is scalar per thread and carries no WMMA +// fragment, so no lane mapping changes across the two parts). At seven waves the serial +// `dot +=` and `on +=` chains are hidden; splitting them would only change the summation order. +// +// fp16 rather than bf16: state elements are O(0.1) (sums of beta (v - Sk) k^T with l2-normalised +// k), so range is no issue and fp16's mantissa gives ~5e-4 relative round-trip error. vLLM's +// --mamba-ssm-cache-dtype already accepts float16. +template struct ru_state { using T = float; }; +template <> struct ru_state<1> { using T = _Float16; }; + +// Eight elements per call: two 16-byte accesses in fp32, one in fp16. +template +__device__ __forceinline__ void ru_load8(float* d, const typename ru_state::T* p) { + if constexpr (SDT) { + const ru_h8 t = NT ? __builtin_nontemporal_load((const ru_h8*)p) : *(const ru_h8*)p; +#pragma unroll + for (int e = 0; e < 8; ++e) d[e] = (float)t[e]; + } else { + const ru_f4* q = (const ru_f4*)p; + *(ru_f4*)d = NT ? __builtin_nontemporal_load(q) : *q; + *(ru_f4*)(d + 4) = NT ? __builtin_nontemporal_load(q + 1) : *(q + 1); + } +} + +template +__device__ __forceinline__ void ru_store8(typename ru_state::T* p, const float* d) { + if constexpr (SDT) { + ru_h8 t; +#pragma unroll + for (int e = 0; e < 8; ++e) t[e] = (_Float16)d[e]; + if (NT) __builtin_nontemporal_store(t, (ru_h8*)p); + else *(ru_h8*)p = t; + } else { + ru_f4* q = (ru_f4*)p; + if (NT) { + __builtin_nontemporal_store(*(const ru_f4*)d, q); + __builtin_nontemporal_store(*(const ru_f4*)(d + 4), q + 1); + } else { + *q = *(const ru_f4*)d; + *(q + 1) = *(const ru_f4*)(d + 4); + } + } +} +// VS: workgroups sharing a head's 128 v rows. At one sequence the (sequences, heads) grid is 24 +// workgroups on 64 CUs, and the working set fits the last-level cache. v rows are independent +// (dot products contract over k; the update is per (v, k)); only the fused RMS norm spans the +// row, so VS > 1 is compiled without it. +#define WGTARGET 64 // workgroups the v-row split aims for + +// A group's (decay, beta) as the two adjacent factor values the layout names. +// +// gfx1151: with an fp16 state cache these are two 16-bit stores at consecutive addresses, and +// LLVM's store merging fuses them into one dword built by `v_lshl_or_b32` on a 16-bit +// sub-register, which gfx11's encoding does not accept -- the whole unit then fails to compile +// ("Operand has incorrect register class"). Converting the pair as a vector packs it in one +// `v_cvt_pk_f16_f32`, the same round-to-nearest-even as the two stores, and the layout is +// unchanged: libr4d and libref read this block. +template +__device__ __forceinline__ void ru_store_gb(typename ru_state::T* p, float g, float bt) { + if constexpr (SDT) { + typedef float v2fx __attribute__((ext_vector_type(2))); + typedef _Float16 v2hx __attribute__((ext_vector_type(2))); + union { v2hx h; uint32_t u; } q; + q.h = __builtin_convertvector(v2fx{ g, bt }, v2hx); + *(uint32_t*)p = q.u; + } else { + ((float*)p)[0] = g; + ((float*)p)[1] = bt; + } +} + +__device__ __forceinline__ float ru_softplus(float x, float thr) { + if (x > thr) return x; + return (x > 0.0f) ? (x + __logf(1.0f + __expf(-x))) : __logf(1.0f + __expf(x)); +} + +// a and b are a chunk() of the ba projection (see r3dh_gdn_conv_w4_h128_bf16.hip). +template +__device__ __forceinline__ float ru_ab(const void* p, size_t i) { + return ABF16 ? bf16_to_f32(((const unsigned short*)p)[i]) : ((const float*)p)[i]; +} + +// The layer's gated RMS norm, folded into the epilogue: with NORM a workgroup owns one (sequence, +// head) and so the whole 128-channel output row, and the norm is one workgroup reduction per +// token. Prefill owns half a row and uses r3dh_gdn_gated_rmsnorm_h128_bf16 instead. +__device__ __forceinline__ float ru_act(float z, int kind) { + const float s = 1.0f / (1.0f + __expf(-z)); + return kind ? s : z * s; +} + +// One token's replay factors (anchor state), inside the head's block of a factor slot: +// +// [0 .. 4*K) normalised k, FOUR copies -- one per fixed 32-row group +// [4*K .. 4*K+V) the v row, one float per v row +// [4*K+V .. +8) decay and beta, one pair per row group +// +// Four k copies avoid a cross-workgroup barrier: a head's v rows may be split over up to four +// workgroups, and fixed 32-row groups make every byte belong to exactly one workgroup at any split. +// Read-before-write within a workgroup is ordered by a barrier. +#define RU_FSTR (4 * RU_K + RU_V + 8) + +// RU_TMAX bounds the candidate block STG can stage (LDS for four partials and two scales per +// token). The launcher checks the caller's width against it. +#define RU_TMAX 16 + +// RU_ANC_DUP=0 drops the two neighbouring-page copies of the replay factors (and, without the +// marker, of the anchor). Incorrect without RU_ANC_MARK (a moved page index reads an unwritten +// slot). With the marker it writes the factor block once; `-DRU_ANC_MARK=1 -DRU_ANC_DUP=0` is the +// leanest build, since the factor block (RU_TMAX * RU_FSTR) outweighs the state (RU_V * RU_K). +#ifndef RU_ANC_DUP +#define RU_ANC_DUP 1 +#endif + +// Shift marker: instead of writing the anchor three times (one per possible page shift), each of +// the three factor-block copies records the column it was written to. The reader finds `m` at its +// fixed factor column, so the page index moved by `m - 1`, and reads the anchor at the matching +// column; the anchor is written once (6.3 MB a layer instead of 18.9 at eight sequences, roughly a +// fifth of the layer's time). +// +// The marker lies past all factor data (RU_TMAX tokens of RU_FSTR) within one head's slice, so no +// workgroup reads a marker another is writing. Stored values are 1, 2, 3 (one-based; see the read), +// exact in fp16 and fp32. +// +// Invariant: the anchor is written at column 2 and read at 3 - m, never column 0. vLLM's +// precopy_mamba_align_fused_kernel copies state[bt[src_col + num_accepted - 1]] into this window's +// column 0 before the forward on a page crossing, so a read of column 0 (anchor at 1, read at +// 2 - m, shift +1) would see migrated data and degenerate intermittently. +#ifndef RU_ANC_MARK +#define RU_ANC_MARK 1 +#endif +#define RU_MARK_OFF (RU_TMAX * RU_FSTR) + +// RU_ANC_FRD=1 (diagnostic): use the displaced factor read (column 5 - m) while still writing all +// three factor copies, isolating the marker's read-column logic from the write side. +#ifndef RU_ANC_FRD +#define RU_ANC_FRD 0 +#endif + +// Decode convolution folded in (CV). This kernel is gdn_conv_update's only decode reader, so the +// fold saves a launch and a dependent-dispatch gap. Each workgroup computes the convolution its +// token loop reads (its key head's 128 q and 128 k channels and its value head's 128 v channels) +// from the projection rows into LDS; q, k and v never reach memory. The arithmetic is +// gdn_conv_update's (same taps, order, cp_silu and bf16 rounding), so results are byte-identical. +// +// The conv state is rewritten in place, and a key head's channels are read by all H / Hg value-head +// workgroups of its group, so none may rewrite them until all have read the history. Each +// workgroup arrives on a counter after reading; the last arriver rewrites the key head's q and k +// channels and resets the counter (no waiting). A value head's v channels have one reader and are +// rewritten by it. Two launches sharing a counter block must not overlap; blocks are keyed on +// (stream, output), as split_ctr in r3dh_gemm_fp8a8.hip. +struct RuConv { + const unsigned short* x; long xpitch; // the projection's [q | k | v] columns, row pitch + const unsigned short* w; // [conv_dim, R3DH_GDN_CONV_W] + const unsigned short* b; // [conv_dim] or null + unsigned short* cs; // the conv state cache + long cs_seq, cs_dim, cs_tok; + const int* cidx; long ci_stride; // conv state slot per sequence; negative is padding + unsigned int* ctr; // one arrival counter per (sequence, key head) +}; +// Max tokens per sequence for the folded convolution (preloaded into registers, static indices). +#define RU_CVT 8 + +// A channel's conv state rewritten as gdn_conv_update does: shifted by one, the old history's +// tail then this step's tokens. The launcher requires the window split to be R3DH_GDN_CONV_W - 2, +// so these are the same stores. +__device__ __forceinline__ void ru_conv_rewrite(unsigned short* sp, const unsigned short* hist, + const unsigned short* xs, int T, long cs_tok) { + constexpr int NH = R3DH_GDN_CONV_W - 2; +#pragma unroll + for (int i = 0; i < NH; ++i) sp[(size_t)i * cs_tok] = hist[i + 1]; +#pragma unroll + for (int t = 0; t < RU_CVT; ++t) + if (t < T) sp[(size_t)(t + NH) * cs_tok] = xs[t]; +} + +// A workgroup barrier that completes this wave's loads and LDS operations but leaves its global +// stores in flight. __syncthreads' release fence also waits for every store (gfx11 counts stores +// apart, in vscnt), and behind the anchor publish that is the whole 64 KB state write: at one +// sequence the store drain then ran before the token loop instead of under it. From the publish +// on, the workgroup reads no global memory it writes; its barriers order LDS, and the +// read-before-write of the factor block (and of the conv history, before the arrival) needs only +// the reads complete, which vmcnt(0) gives. +__device__ __forceinline__ void ru_sync() { + asm volatile("s_waitcnt vmcnt(0) lgkmcnt(0)\n\ts_barrier" ::: "memory"); +} + +template +__global__ __launch_bounds__(RU_V / VS * 2) +void r3dh_gdn_recurrent_update_kernel(const unsigned short* __restrict__ q, + const unsigned short* __restrict__ k, + const unsigned short* __restrict__ v, + const void* __restrict__ av, + const void* __restrict__ bv, long ab_stride, + const float* __restrict__ A_log, + const float* __restrict__ dt_bias, + typename ru_state::T* __restrict__ state, + long st_slot, long st_head, + unsigned short* __restrict__ o, + unsigned char* __restrict__ oq, + float* __restrict__ os, long oq_pitch, + long os_ld, + const int* __restrict__ cu, + const int* __restrict__ sidx, long sidx_stride, + const int* __restrict__ naccept, + const unsigned short* __restrict__ zg, + long zg_pitch, + const float* __restrict__ nw, float neps, int nact, + int H, int Hg, float scale, float sp_thr, + const RuConv cv) +{ + using ST = typename ru_state::T; + constexpr int NR = RU_V / VS; // v rows this workgroup owns + constexpr int THR = NR * 2; + static_assert(!(NORM && VS > 1), "the fused row norm needs the whole 128-wide row"); + __shared__ float wsum[THR / 32]; + __shared__ float spart[STG ? RU_TMAX * 4 : 1]; // per (token, half): sum q^2, sum k^2 + __shared__ float sscl [STG ? RU_TMAX * 2 : 1]; // per token: the two closed scales + const int n = blockIdx.x, hv = blockIdx.y; + const int bos = cu[n], T = cu[n + 1] - bos; + // With ANC, T == 0 is valid: it folds the previous step's accepted prefix into the anchor before + // something else reads the state cache. Without ANC there is nothing to do. + const bool empty = (T <= 0); + if (empty && !ANC) return; + + const int tid = threadIdx.x; + const int row = (tid >> 1) + (VS > 1 ? blockIdx.z * NR : 0), half = tid & 1, k0 = half * RU_HK; + const int hk = hv / (H / Hg); + /* Read early so their latency overlaps the prologue's loads. */ + const float a_log_h = A_log[hv], dtb = dt_bias[hv]; + + // ---- CV: issue the convolution's inputs first so they are in flight during the anchor replay. + // Thread tid owns one q|k channel of the key head (q below RU_K, k above) and, below RU_V, one v + // channel of the value head. + static_assert(!CV || (NORM && VS == 1 && STG == 0), "the folded convolution is the decode shape"); + static_assert(RU_K == RU_V, "one LDS row pitch serves the q, k and v taps"); + constexpr int CW = R3DH_GDN_CONV_W, CS = R3DH_GDN_CONV_W - 1; + __shared__ unsigned short cvq[CV ? RU_CVT * RU_K : 1], cvk[CV ? RU_CVT * RU_K : 1]; + __shared__ unsigned short cvv[CV ? RU_CVT * RU_V : 1]; + __shared__ int cvlast; + /* The key head's history for the final rewrite (two newest history entries and this step's + * inputs, one channel per thread), parked in LDS: in registers across the token loop they spill. */ + __shared__ unsigned short cvh[CV ? (CS - 1 + RU_CVT) * THR : 1]; + /* The token loop's per-token global reads (a, b and the output gate row) are also staged: at + * decode there is too little occupancy to hide a global load per token. They are issued here, + * parked in LDS at the convolution's barrier and read from there: `ca_b` is one token's a + * (tid < T) or b (T <= tid < 2T), `czg` this thread's strided share of the gate rows. */ + constexpr int ZPT = (RU_CVT * RU_V + THR - 1) / THR; // gate values a thread stages + __shared__ float sab[CV ? 2 * RU_CVT : 1]; + __shared__ unsigned short szg[CV ? RU_CVT * RU_V : 1]; + float ca_b = 0.0f; + unsigned short czg[ZPT]; + const int G = H / Hg; // workgroups that read one key head + float cwa[CW], cwb[CW], cba = 0.0f, cbb = 0.0f; + unsigned short cha[CS], chb[CS], cxa[RU_CVT], cxb[RU_CVT]; + unsigned short* spa = nullptr; + unsigned short* spb = nullptr; + unsigned int arrived = 0; + if constexpr (CV) { + if (!empty) { + const int cslot = cv.cidx[(size_t)n * cv.ci_stride]; + // A negative slot is padding: every workgroup of the sequence leaves here, so none arrives + // on the counter. + if (cslot < 0) return; + const int off = naccept ? naccept[n] - 1 : 0; + const int ca = tid < RU_K ? hk * RU_K + tid : (Hg + hk) * RU_K + (tid - RU_K); + const int cb = (2 * Hg + hv) * RU_V + tid; + const unsigned short* xr = cv.x + (size_t)bos * cv.xpitch; +#pragma unroll + for (int t = 0; t < RU_CVT; ++t) + if (t < T) cxa[t] = xr[(size_t)t * cv.xpitch + ca]; + { + const ushort4 w4 = *(const ushort4*)(cv.w + (size_t)ca * CW); + cwa[0] = bf16_to_f32(w4.x); cwa[1] = bf16_to_f32(w4.y); cwa[2] = bf16_to_f32(w4.z); cwa[3] = bf16_to_f32(w4.w); + if (cv.b) cba = bf16_to_f32(cv.b[ca]); + } + spa = cv.cs + (size_t)cslot * cv.cs_seq + (size_t)ca * cv.cs_dim; +#pragma unroll + for (int i = 0; i < CS; ++i) cha[i] = spa[(size_t)(off + i) * cv.cs_tok]; + if (tid < RU_V) { +#pragma unroll + for (int t = 0; t < RU_CVT; ++t) + if (t < T) cxb[t] = xr[(size_t)t * cv.xpitch + cb]; + const ushort4 w4 = *(const ushort4*)(cv.w + (size_t)cb * CW); + cwb[0] = bf16_to_f32(w4.x); cwb[1] = bf16_to_f32(w4.y); cwb[2] = bf16_to_f32(w4.z); cwb[3] = bf16_to_f32(w4.w); + if (cv.b) cbb = bf16_to_f32(cv.b[cb]); + spb = cv.cs + (size_t)cslot * cv.cs_seq + (size_t)cb * cv.cs_dim; +#pragma unroll + for (int i = 0; i < CS; ++i) chb[i] = spb[(size_t)(off + i) * cv.cs_tok]; + } + if (tid < 2 * T) + ca_b = tid < T ? ru_ab(av, (size_t)(bos + tid) * ab_stride + hv) + : ru_ab(bv, (size_t)(bos + tid - T) * ab_stride + hv); +#pragma unroll + for (int i = 0; i < ZPT; ++i) { + const int zi = tid + i * THR; + if (zi < T * RU_V) + czg[i] = zg[(size_t)(bos + zi / RU_V) * zg_pitch + (size_t)hv * RU_V + (zi % RU_V)]; + } + } + } + + // Without ANC the initial state is the one the last accepted token wrote; with ANC there is one + // state per sequence and the accepted prefix is replayed onto it below. + const int nacc = naccept ? naccept[n] : 1; + // Paged anchor. vLLM addresses mamba state by page, re-derived each step as + // (seq_lens - 1) / block_size, so the column holding a sequence's state can move. seq_lens + // includes this step's query (the draft depth, which varies), so + // start' - start = ((ctx + acc + q') - 1)/bs - ((ctx + q) - 1)/bs + // is +1 when the committed context crosses a page, usually 0, and -1 when a step drafts fewer + // tokens than the previous one. + // + // With the shift in {-1, 0, +1}, a fixed read column works only if all three pages it can land + // on were written. So the anchor is written to columns 0, 1, 2 and read from column 1, and the + // replay factors are written to columns 3, 4, 5 and read from column 4: + // shift -1 -> next column 1 is this column 0 (and next column 4 is this column 3) + // shift 0 -> next column 1 is this column 1 (and next column 4 is this column 4) + // shift +1 -> next column 1 is this column 2 (and next column 4 is this column 5) + // The six columns are distinct writable slots: vLLM's per-candidate path writes to the same + // indices, and indices_stride is num_spec + 1 = 8 whatever the draft depth. + // + // vLLM also migrates state itself: precopy_mamba_align_fused_kernel copies + // state[bt[src_col + num_accepted - 1]] into state[bt[dst_col]] on a page crossing, assuming the + // per-candidate layout. The anchor and factor read columns resolve to pages it never writes. + // Any change to these columns must be re-derived against that kernel too. + // + // Nothing else may write this cache: advancing one copy alone leaves the others stale. Every step + // shape, including non-speculative decode (`kind == "decode1"` in radiance_gdn.py), goes through + // the fused path, and any other step first folds the accepted prefix into a single state. + const int sa0 = ANC ? sidx[(size_t)n * sidx_stride + 0] : 0; // anchor, page before + const int sa1 = ANC ? sidx[(size_t)n * sidx_stride + 1] : 0; // anchor, written here + const int sa2 = ANC ? sidx[(size_t)n * sidx_stride + 2] : 0; // anchor, page after + const int sf0 = ANC ? sidx[(size_t)n * sidx_stride + 3] : 0; // factors, marker 0 + const int sf = ANC ? sidx[(size_t)n * sidx_stride + 4] : 0; // factors, marker 1, read here + const int sf2 = ANC ? sidx[(size_t)n * sidx_stride + 5] : 0; // factors, marker 2 + // A negative slot is padding; 0 is a real slot (as for the per-candidate read below). + if (ANC && (sa0 < 0 || sa1 < 0 || sa2 < 0 || sf0 < 0 || sf < 0 || sf2 < 0)) return; + ST* const fb = ANC ? (state + (size_t)sf * st_slot + (size_t)hv * st_head) : nullptr; + ST* const fb0 = ANC ? (state + (size_t)sf0 * st_slot + (size_t)hv * st_head) : nullptr; + ST* const fb2 = ANC ? (state + (size_t)sf2 * st_slot + (size_t)hv * st_head) : nullptr; + // Anchor column: without markers, column 1 (all three copies written); with them, 3 - m, never 0 + // (column 0 is the migration's target, derived from the committed context; see RU_ANC_MARK). + // A caller whose state does not page (this engine's linear pool: one slot per sequence for its + // life) names the same slot in every column; then duplicates are skipped, saving two thirds of + // the factor traffic. + const bool dup_a = ANC && RU_ANC_DUP && (sa0 != sa2 || sa1 != sa2); + const bool dup_f = ANC && RU_ANC_DUP && (sf0 != sf || sf2 != sf); + int acol = RU_ANC_MARK ? 2 : 1; + int mrk = 1; + if (ANC && RU_ANC_MARK) { + // The marker is one-based so a zeroed (freshly allocated) factor block reads as absent and + // falls back to the default anchor column. Zero-based, it would steer the first read after a + // prefill to column 3, a factor column of zeros, discarding the prefill's state. + const int m = (int)((float)fb[RU_MARK_OFF] + 0.5f) - 1; + mrk = (m >= 0 && m <= 2) ? m : 1; + acol = 3 - mrk; + } + // With RU_ANC_DUP=0 (or RU_ANC_FRD) the factors are read at 5 - m (3, 4 or 5) and written only + // at column 4. The marker itself stays at fixed column 4 and is stamped into all three copies. + const ST* const fr = (ANC && RU_ANC_MARK && (RU_ANC_FRD || !RU_ANC_DUP)) + ? (const ST*)(state + (size_t)(mrk == 0 ? sf2 : (mrk == 1 ? sf : sf0)) * st_slot + + (size_t)hv * st_head) + : (const ST*)fb; + const int si = sidx[(size_t)n * sidx_stride + (ANC ? acol : (nacc - 1))]; + // A negative slot is padding; 0 is a real slot. + if (si < 0) return; + /* Fixed 32-row group (see RU_FSTR), uniform per wave for any VS (a wave is 16 consecutive rows + * from a multiple of 16). readfirstlane makes the factor addresses scalar instead of 64-bit + * VGPR offsets live across the token loop. */ + const int grp = __builtin_amdgcn_readfirstlane(row >> 5); + + float h[RU_HK]; + { + const ST* p = state + (size_t)si * st_slot + (size_t)hv * st_head + + (size_t)row * RU_K + k0; +#pragma unroll + for (int j = 0; j < RU_HK; j += 8) ru_load8(&h[j], p + j); + } + + if (ANC) { + for (int t = 0; t < nacc; ++t) { + const ST* f = fr + (size_t)t * RU_FSTR; + float kk[RU_HK]; +#pragma unroll + for (int j = 0; j < RU_HK; j += 8) ru_load8<0, SDT>(&kk[j], f + grp * RU_K + k0 + j); + const float vv = (float)f[4 * RU_K + row]; + const float eg = __expf((float)f[4 * RU_K + RU_V + 2 * grp]); + const float bt = (float)f[4 * RU_K + RU_V + 2 * grp + 1]; + float dot = 0.0f; +#pragma unroll + for (int j = 0; j < RU_HK; ++j) { h[j] *= eg; dot += h[j] * kk[j]; } + dot += r3dh_xor_lane<1>(dot); // DPP, no LDS round trip + const float u = (vv - dot) * bt; +#pragma unroll + for (int j = 0; j < RU_HK; ++j) h[j] += u * kk[j]; + } + // Publish the advanced anchor, then barrier: every replay read above must complete before the + // token loop overwrites the factor block with this step's factors. + const size_t rowoff = (size_t)hv * st_head + (size_t)row * RU_K + k0; + ST* p = state + (size_t)(RU_ANC_MARK ? sa2 : sa1) * st_slot + rowoff; + ST* p0 = state + (size_t)sa0 * st_slot + rowoff; + ST* p2 = state + (size_t)sa2 * st_slot + rowoff; +#pragma unroll + for (int j = 0; j < RU_HK; j += 8) ru_store8(p + j, &h[j]); + if (dup_a && !RU_ANC_MARK) { +#pragma unroll + for (int j = 0; j < RU_HK; j += 8) ru_store8(p0 + j, &h[j]); +#pragma unroll + for (int j = 0; j < RU_HK; j += 8) ru_store8(p2 + j, &h[j]); + } + ru_sync(); + // Stamp after the barrier: every thread read fb's marker at the top, and stamping earlier + // could steer a late wave to a different column from the rest of the workgroup. + if (RU_ANC_MARK && tid == 0) { // the three copies say where they are + fb0[RU_MARK_OFF] = (ST)1.0f; + fb[RU_MARK_OFF] = (ST)2.0f; + fb2[RU_MARK_OFF] = (ST)3.0f; + } + } + if (empty) return; + + if constexpr (CV) { + // gdn_conv_update's token body, one channel per thread, into LDS instead of q, k and v. + auto conv = [&](const float* wt, float bs, const unsigned short* hist, + const unsigned short* xs, unsigned short* dst) { + float win[CW]; +#pragma unroll + for (int i = 0; i < CS; ++i) win[i] = bf16_to_f32(hist[i]); +#pragma unroll + for (int t = 0; t < RU_CVT; ++t) { + if (t < T) { + win[CW - 1] = bf16_to_f32(xs[t]); + float acc = bs; +#pragma unroll + for (int i = 0; i < CW; ++i) acc += wt[i] * win[i]; + dst[t * RU_K] = f32_to_bf16(cp_silu(acc)); +#pragma unroll + for (int i = 0; i < CW - 1; ++i) win[i] = win[i + 1]; + } + } + }; + conv(cwa, cba, cha, cxa, (tid < RU_K ? cvq : cvk) + (tid & (RU_K - 1))); +#pragma unroll + for (int i = 1; i < CS; ++i) cvh[(i - 1) * THR + tid] = cha[i]; +#pragma unroll + for (int t = 0; t < RU_CVT; ++t) + if (t < T) cvh[(CS - 1 + t) * THR + tid] = cxa[t]; + if (tid < RU_V) { + conv(cwb, cbb, chb, cxb, cvv + tid); + ru_conv_rewrite(spb, chb, cxb, T, cv.cs_tok); + } + if (tid < 2 * T) sab[tid] = ca_b; +#pragma unroll + for (int i = 0; i < ZPT; ++i) { + const int zi = tid + i * THR; + if (zi < T * RU_V) szg[zi] = czg[i]; + } + // All history is consumed (taps are in LDS), so after the barrier this workgroup no longer + // reads the key head's conv state and may arrive on the counter. + ru_sync(); + if (G > 1 && tid == 0) + arrived = __hip_atomic_fetch_add(cv.ctr + (size_t)n * Hg + hk, 1u, __ATOMIC_RELAXED, + __HIP_MEMORY_SCOPE_AGENT); + } + + // CV: every token's q and k l2 norms before the token loop, which then carries only the state's + // two dependent chains. A lane per (token, q|k, half) sums its 64 squares as the loop's lanes do, + // and the two halves close in the loop's exchange order (own half plus the other: commutative, + // so the same sum), so the scales are the same bits. + __shared__ float cvss[CV ? RU_CVT * 4 : 1]; // per (token, q|k, half): the half's sum of squares + __shared__ float cvsc[CV ? RU_CVT * 2 : 1]; // per token: q's scale, k's scale + if constexpr (CV) { + if (tid < 4 * T) { + const int ut = tid >> 2, wk = (tid >> 1) & 1, uh = tid & 1; + const unsigned short* src = (wk ? cvk : cvq) + ut * RU_K + uh * RU_HK; + float ss = 0.0f; +#pragma unroll + for (int j = 0; j < RU_HK; j += 8) { + const uint4 w = *(const uint4*)(src + j); + const unsigned short* e8 = (const unsigned short*)&w; +#pragma unroll + for (int e = 0; e < 8; ++e) { const float f = bf16_to_f32(e8[e]); ss += f * f; } + } + cvss[tid] = ss; + } + ru_sync(); + if (tid < 2 * T) { + const int ut = tid >> 1, wk = tid & 1; + const float ssum = cvss[ut * 4 + wk * 2] + cvss[ut * 4 + wk * 2 + 1]; + cvsc[tid] = wk ? __frsqrt_rn(ssum + 1e-6f) : __frsqrt_rn(ssum + 1e-6f) * scale; + } + ru_sync(); + } + + const float alog = __expf(a_log_h); + + if (STG) { + // One lane per (token, half) computes the same sums each v row computes on the STG=0 path. + if (tid < 2 * T) { + const int ut = tid >> 1, uk0 = (tid & 1) * RU_HK; + const unsigned short* qp = q + ((size_t)(bos + ut) * Hg + hk) * RU_K + uk0; + const unsigned short* kp = k + ((size_t)(bos + ut) * Hg + hk) * RU_K + uk0; + float ssq = 0.0f, ssk = 0.0f; +#pragma unroll + for (int j = 0; j < RU_HK; j += 8) { + const uint4 wq = *(const uint4*)(qp + j), wk = *(const uint4*)(kp + j); + const unsigned short* aq = (const unsigned short*)&wq; + const unsigned short* ak = (const unsigned short*)&wk; +#pragma unroll + for (int e = 0; e < 8; ++e) { + const float fq = bf16_to_f32(aq[e]), fk = bf16_to_f32(ak[e]); + ssq += fq * fq; ssk += fk * fk; + } + } + spart[tid * 2] = ssq; + spart[tid * 2 + 1] = ssk; + } + __syncthreads(); + if (tid < T) { + // Same order as the STG=0 exchange: own half plus the other half. + const float ssq = spart[tid * 4] + spart[tid * 4 + 2]; + const float ssk = spart[tid * 4 + 1] + spart[tid * 4 + 3]; + sscl[tid * 2] = __frsqrt_rn(ssq + 1e-6f) * scale; + sscl[tid * 2 + 1] = __frsqrt_rn(ssk + 1e-6f); + } + __syncthreads(); + } + + for (int t = 0; t < T; ++t) { + const int tok = bos + t; + const unsigned short* qp = CV ? cvq + t * RU_K + k0 : q + ((size_t)tok * Hg + hk) * RU_K + k0; + const unsigned short* kp = CV ? cvk + t * RU_K + k0 : k + ((size_t)tok * Hg + hk) * RU_K + k0; + + // k first, q only once k is consumed: holding both with the state row (three 64-float arrays) + // spilled on gfx1151 (256 VGPRs). Each value meets the same operations in the same order. + float kk[RU_HK]; +#pragma unroll + for (int j = 0; j < RU_HK; j += 8) { + const uint4 wk = *(const uint4*)(kp + j); + const unsigned short* sk = (const unsigned short*)&wk; +#pragma unroll + for (int e = 0; e < 8; ++e) kk[j + e] = bf16_to_f32(sk[e]); + } + + // l2 norm: 64 in-lane terms, then one exchange with the lane holding the other half + float ks; + if (STG) { + ks = sscl[t * 2 + 1]; + } else if (CV) { + ks = cvsc[t * 2 + 1]; + } else { + float sk = 0.0f; +#pragma unroll + for (int j = 0; j < RU_HK; ++j) sk += kk[j] * kk[j]; + sk += r3dh_xor_lane<1>(sk); + ks = __frsqrt_rn(sk + 1e-6f); + } +#pragma unroll + for (int j = 0; j < RU_HK; ++j) kk[j] *= ks; + + const float ra = CV ? sab[t] : ru_ab(av, (size_t)tok * ab_stride + hv); + const float rb = CV ? sab[T + t] : ru_ab(bv, (size_t)tok * ab_stride + hv); + const float g = -alog * ru_softplus(ra + dtb, sp_thr); + const float bt = 1.0f / (1.0f + __expf(-rb)); + const float eg = __expf(g); + + float dot = 0.0f; +#pragma unroll + for (int j = 0; j < RU_HK; ++j) { h[j] *= eg; dot += h[j] * kk[j]; } + dot += r3dh_xor_lane<1>(dot); + + const float vraw = bf16_to_f32(CV ? cvv[t * RU_V + row] : v[((size_t)tok * H + hv) * RU_V + row]); + const float u = (vraw - dot) * bt; + + if (ANC) { + // This step's factors for the next step's replay: one thread pair per row group writes the + // group's k copy and decay/beta; every row writes its own v. + ST* f = fb + (size_t)t * RU_FSTR; + ST* f0 = fb0 + (size_t)t * RU_FSTR; + ST* f2 = fb2 + (size_t)t * RU_FSTR; + if ((row & 31) == 0) { +#pragma unroll + for (int j = 0; j < RU_HK; j += 8) { + float kn[8]; +#pragma unroll + for (int e = 0; e < 8; ++e) kn[e] = kk[j + e]; + ru_store8<0, SDT>(f + grp * RU_K + k0 + j, kn); + if (dup_f) { + ru_store8<0, SDT>(f0 + grp * RU_K + k0 + j, kn); + ru_store8<0, SDT>(f2 + grp * RU_K + k0 + j, kn); + } + } + if (half == 0) { + ru_store_gb(f + 4 * RU_K + RU_V + 2 * grp, g, bt); + if (dup_f) { + ru_store_gb(f0 + 4 * RU_K + RU_V + 2 * grp, g, bt); + ru_store_gb(f2 + 4 * RU_K + RU_V + 2 * grp, g, bt); + } + } + } + if (half == 0) { + f[4 * RU_K + row] = (ST)vraw; + if (dup_f) { f0[4 * RU_K + row] = (ST)vraw; f2[4 * RU_K + row] = (ST)vraw; } + } + } + +#pragma unroll + for (int j = 0; j < RU_HK; ++j) h[j] += u * kk[j]; + + float qq[RU_HK]; +#pragma unroll + for (int j = 0; j < RU_HK; j += 8) { + const uint4 wq = *(const uint4*)(qp + j); + const unsigned short* sq = (const unsigned short*)&wq; +#pragma unroll + for (int e = 0; e < 8; ++e) qq[j + e] = bf16_to_f32(sq[e]); + } + float qs; + if (STG) { + qs = sscl[t * 2]; + } else if (CV) { + qs = cvsc[t * 2]; + } else { + float sq = 0.0f; +#pragma unroll + for (int j = 0; j < RU_HK; ++j) sq += qq[j] * qq[j]; + sq += r3dh_xor_lane<1>(sq); + qs = __frsqrt_rn(sq + 1e-6f) * scale; + } + float on = 0.0f; +#pragma unroll + for (int j = 0; j < RU_HK; ++j) { qq[j] *= qs; on += h[j] * qq[j]; } + on += r3dh_xor_lane<1>(on); + + if (NORM) { + // sum of squares over the row: one channel per thread pair, 16 per wave + float sq = (half == 0) ? on * on : 0.0f; + // compile-time masks: 16 uses v_permlanex16, the rest DPP row_xmask + sq += r3dh_xor_lane<16>(sq); sq += r3dh_xor_lane<8>(sq); sq += r3dh_xor_lane<4>(sq); + sq += r3dh_xor_lane<2>(sq); sq += r3dh_xor_lane<1>(sq); + if ((threadIdx.x & 31) == 0) wsum[threadIdx.x >> 5] = sq; + ru_sync(); + float tot = 0.0f; +#pragma unroll + for (int i = 0; i < THR / 32; ++i) tot += wsum[i]; + const float sc = __frsqrt_rn(tot * (1.0f / RU_V) + neps); + const unsigned short zr = CV ? szg[t * RU_V + row] + : zg[(size_t)tok * zg_pitch + (size_t)hv * RU_V + row]; + on *= sc * nw[row] * ru_act(bf16_to_f32(zr), nact); + ru_sync(); // wsum is reused by the next token + } + + const unsigned short ob = f32_to_bf16(on); + if (half == 0) o[((size_t)tok * H + hv) * RU_V + row] = ob; + + // The out projection's quantiser, folded in (saves 48 launches per decode step, each with less + // work than its launch gap). The quant group (128) is the row and NORM gives one workgroup per + // (token, head), so the amax is a workgroup reduction and the scale index is (tok, hv). + // Bit-identical to the standalone quantiser: it quantises the stored bf16 `ob`, not the f32 + // `on`, with r3dh_fused_quant_fp8.hip's quant_group arithmetic (including the clamp that keeps + // the group maximum from becoming NaN). NORM == 2 writes int8 codes instead (quant_act_i8g: + // scale amax / 127, round to nearest-even). + if (NORM && oq) { + const float ov = bf16_to_f32(ob); + float mv = (half == 0) ? fabsf(ov) : 0.0f; + mv = fmaxf(mv, r3dh_xor_lane<16>(mv)); mv = fmaxf(mv, r3dh_xor_lane<8>(mv)); + mv = fmaxf(mv, r3dh_xor_lane<4>(mv)); mv = fmaxf(mv, r3dh_xor_lane<2>(mv)); + mv = fmaxf(mv, r3dh_xor_lane<1>(mv)); + if ((threadIdx.x & 31) == 0) wsum[threadIdx.x >> 5] = mv; + ru_sync(); + float amax = 0.0f; +#pragma unroll + for (int i = 0; i < THR / 32; ++i) amax = fmaxf(amax, wsum[i]); + const float qs = amax > 0.0f ? amax * (1.0f / q8_top()) : 1.0f; + if (tid == 0) os[(size_t)tok * os_ld + hv] = qs; + if (half == 0) { + unsigned char code; + if constexpr (NORM == 2) { + code = (unsigned char)(int)rintf(fminf(fmaxf(ov * (1.0f / qs), -127.0f), 127.0f)); + } else { + const float cv = fminf(fmaxf(ov * (1.0f / qs), -448.0f), 448.0f); + code = (unsigned char)r3dh_fp8::f32_to_e4m3(cv); /* cvt_pk_fp8_f32's low byte */ + } + oq[(size_t)tok * oq_pitch + (size_t)hv * RU_V + row] = code; + } + ru_sync(); // wsum is reused by the next token + } + + if (!ANC) { + const int so = sidx[(size_t)n * sidx_stride + t]; + // `>= 0`, not `> 0`: a negative slot is padding and 0 is a real slot (a single-sequence + // decode's only slot), as for the read above. + if (so >= 0) { + ST* p = state + (size_t)so * st_slot + (size_t)hv * st_head + + (size_t)row * RU_K + k0; +#pragma unroll + for (int j = 0; j < RU_HK; j += 8) ru_store8(p + j, &h[j]); + } + } + } + + if constexpr (CV) { + // The last arriving reader rewrites the key head's q and k channels. The count was taken + // before the token loop, hiding its latency. + if (G > 1) { + if (tid == 0) { + cvlast = arrived == (unsigned)(G - 1); + if (cvlast) + __hip_atomic_store(cv.ctr + (size_t)n * Hg + hk, 0u, __ATOMIC_RELAXED, + __HIP_MEMORY_SCOPE_AGENT); + } + ru_sync(); + if (!cvlast) return; + } + unsigned short rh[CS], rx[RU_CVT]; + rh[0] = 0; /* never read: the oldest entry is shifted out */ +#pragma unroll + for (int i = 1; i < CS; ++i) rh[i] = cvh[(i - 1) * THR + tid]; +#pragma unroll + for (int t = 0; t < RU_CVT; ++t) + rx[t] = t < T ? cvh[(CS - 1 + t) * THR + tid] : (unsigned short)0; + ru_conv_rewrite(spa, rh, rx, T, cv.cs_tok); + } +} + +// Non-temporal hint on the state load and store (TH_LOAD_NT / TH_STORE_NT): no result changes; +// chosen per launch because its cost and saving land in different kernels. In isolation it makes +// this kernel 43.8% slower (DRAM-write bound), but no state survives the 64 MB last-level cache +// within a step, so the hint only decides who pays for the write-back, and it saves the following +// GEMMs more (about -140 us on the tiled GEMM vs +25 us here under anchor state). +// +// Anchor state: one state per sequence with the accepted prefix replayed onto it. The caller's +// prefill path must zero state slot sidx[n][1] for every sequence it writes. Off (per_candidate), +// every candidate writes its own slot, matching vLLM's Triton path. A radiance caller declares the +// form as the op's `state_form` (ru_state_form); the raw C entry, which vLLM's radiance_gdn.py +// calls, has no op parameters and reads RADIANCE_GDN_ANCHOR, as that caller does. +static bool ru_anchor() { + static const bool v = [] { + const char* e = getenv("RADIANCE_GDN_ANCHOR"); + return e && e[0] == '1'; + }(); + return v; +} + +// STG: the q/k l2 scales are computed once per head and shared by the 128 v rows (bit-identical to +// per row). Folding the scales into the reductions instead is slower and moves about one output in +// 600 by a bf16 ULP. +// +// Flood size (MB of state a launch writes) up to which the non-temporal hint is used. It wins when +// the state would otherwise stay in the last-level cache and become the next GEMM's write-back +// (6.3 MB at one sequence: ~3% of a step) and loses when nothing survives anyway (50 MB at eight: +// ~2% slower). The threshold leaves cache room for the streaming weights. Under anchor state the +// hint nets about -100 us a step; under per-candidate state the flood is ~8x larger. (The gfx1201 +// figures.) +// +// gfx1151 (32 MB last-level cache, writes that go to DRAM either way): the hint never pays. On +// Flash-Next's decode (36 layers, anchor state, MTP 3) it costs the kernel 54 against 46 us at one +// sequence and 179 against 128 at four (--perfgdn), and with it off the engine's step is 0.5 ms +// shorter at one sequence and 0.6 at four (55.7 against 56.2, 64.7 against 65.4 ms; two runs each, +// interleaved). So the threshold is 0: no launch takes the hint. +#define RU_NT_MB 0 + +// `oq_i8` picks the folded quantiser's codes: E4M3 (0) or int8 (1); see the kernel's epilogue. +static int ru_update_launch( + const void* q, const void* k, const void* v, const void* a, const void* b, + long ab_stride, int ab_is_bf16, const void* A_log, const void* dt_bias, void* state, + long state_slot_stride, long state_head_stride, void* o, void* oq, void* os, + long oq_pitch, long os_ld, const void* cu, + const void* ssm_state_indices, long indices_stride, const void* num_accepted, + const void* z_gate, long z_pitch, const void* norm_weight, float norm_eps, int norm_act, + int N, int H, int Hg, int K, int V, float scale, float softplus_thr, int state_fp16, + void* stream, int oq_i8, bool anc) +{ + if (K != RU_K || V != RU_V) return -1; + if (H % Hg) return -2; + const int nm0 = (z_gate && norm_weight) ? 1 : 0; + // Fill the GPU: split a head's v rows until there are at least WGTARGET workgroups, at most + // four ways (64 threads, two waves). + int vs = 1; + if (!nm0) { const int want = (WGTARGET + N * H - 1) / (N * H); + vs = want >= 4 ? 4 : (want >= 2 ? 2 : 1); } + // The shift marker forbids splitting a head: with vs > 1 one workgroup could stamp this step's + // marker before another read the previous one, and they would disagree on the page shift. The + // wave count is the same either way. + if (anc && RU_ANC_MARK) vs = 1; + dim3 grid(N, H, vs), blk(RU_V / vs * 2); + // Every switch is a template parameter; the nested pick macros enumerate the instantiations. +#define RU_LAUNCH(AB, NM, VSC, NTC, ANCC, STGC, SDTC) \ + hipLaunchKernelGGL((r3dh_gdn_recurrent_update_kernel), \ + grid, blk, 0, (hipStream_t)stream, \ + (const unsigned short*)q, (const unsigned short*)k, \ + (const unsigned short*)v, a, b, ab_stride, \ + (const float*)A_log, (const float*)dt_bias, \ + (ru_state::T*)state, state_slot_stride, state_head_stride, \ + (unsigned short*)o, (unsigned char*)oq, (float*)os, oq_pitch, os_ld, \ + (const int*)cu, (const int*)ssm_state_indices, \ + indices_stride, (const int*)num_accepted, \ + (const unsigned short*)z_gate, z_pitch, (const float*)norm_weight, norm_eps, \ + norm_act, H, Hg, scale, softplus_thr, RuConv{}) +#define RU_PICKV(AB, NTC, ANCC, SDTC) \ + do { if (vs == 4) RU_LAUNCH(AB, 0, 4, NTC, ANCC, 0, SDTC); \ + else if (vs == 2) RU_LAUNCH(AB, 0, 2, NTC, ANCC, 0, SDTC); \ + else RU_LAUNCH(AB, 0, 1, NTC, ANCC, 0, SDTC); } while (0) +#define RU_PICKNM(AB, NTC, ANCC, SDTC) \ + do { if (oq_i8) RU_LAUNCH(AB, 2, 1, NTC, ANCC, 0, SDTC); \ + else RU_LAUNCH(AB, 1, 1, NTC, ANCC, 0, SDTC); } while (0) +#define RU_PICKAB(NTC, ANCC, SDTC) \ + do { if (ab_is_bf16) { if (nm0) RU_PICKNM(1, NTC, ANCC, SDTC); \ + else RU_PICKV(1, NTC, ANCC, SDTC); } \ + else { if (nm0) RU_PICKNM(0, NTC, ANCC, SDTC); \ + else RU_PICKV(0, NTC, ANCC, SDTC); } } while (0) +#define RU_PICKNT(ANCC, SDTC) \ + do { if (nt) RU_PICKAB(1, ANCC, SDTC); else RU_PICKAB(0, ANCC, SDTC); } while (0) +#define RU_PICKANC(SDTC) \ + do { if (anc) RU_PICKNT(1, SDTC); else RU_PICKNT(0, SDTC); } while (0) + + // The staged path (STG) is instantiated only for the decode shape: bf16 a/b, no fused row norm, + // VS 1. Everything else uses the per-row path (STG 0). + const int sdt = state_fp16 ? 1 : 0; + // Bytes of state this launch writes: one slot per sequence under the anchor, one per candidate + // without it. + const long slots_written = anc ? 1 : (long)indices_stride; + const long flood = (long)N * slots_written * state_slot_stride * (sdt ? 2 : 4); + const bool nt = flood <= (long)RU_NT_MB * 1024 * 1024; + // Anchor bounds: six columns are addressed (three anchor, three factor), and the factor block + // (indices_stride tokens of RU_FSTR) must fit in one head's slice of a slot. Keep these before + // the staged path, which returns early and is the shipped anchor path. + if (anc && indices_stride < 6) return -4; + if (anc && (long)indices_stride * RU_FSTR > state_head_stride) return -3; + if (ab_is_bf16 && !nm0 && vs == 1 && indices_stride <= RU_TMAX) { +#define RU_PICKSTG2(ANCC, SDTC) \ + do { if (nt) RU_LAUNCH(1, 0, 1, 1, ANCC, 1, SDTC); \ + else RU_LAUNCH(1, 0, 1, 0, ANCC, 1, SDTC); } while (0) +#define RU_PICKSTG(SDTC) do { if (anc) RU_PICKSTG2(1, SDTC); else RU_PICKSTG2(0, SDTC); } while (0) + if (sdt) RU_PICKSTG(1); else RU_PICKSTG(0); +#undef RU_PICKSTG +#undef RU_PICKSTG2 + return (int)hipGetLastError(); + } + if (sdt) RU_PICKANC(1); else RU_PICKANC(0); +#undef RU_PICKANC +#undef RU_PICKNT +#undef RU_PICKAB +#undef RU_PICKNM +#undef RU_PICKV +#undef RU_LAUNCH + return (int)hipGetLastError(); +} + +extern "C" int r3dh_gdn_recurrent_update_k128_v128_bf16_fp32state( + const void* q, const void* k, const void* v, const void* a, const void* b, + long ab_stride, int ab_is_bf16, const void* A_log, const void* dt_bias, void* state, + long state_slot_stride, long state_head_stride, void* o, void* oq, void* os, + long oq_pitch, long os_ld, const void* cu, + const void* ssm_state_indices, long indices_stride, const void* num_accepted, + const void* z_gate, long z_pitch, const void* norm_weight, float norm_eps, int norm_act, + int N, int H, int Hg, int K, int V, float scale, float softplus_thr, int state_fp16, + void* stream) +{ + return ru_update_launch(q, k, v, a, b, ab_stride, ab_is_bf16, A_log, dt_bias, state, + state_slot_stride, state_head_stride, o, oq, os, oq_pitch, os_ld, cu, + ssm_state_indices, indices_stride, num_accepted, z_gate, z_pitch, + norm_weight, norm_eps, norm_act, N, H, Hg, K, V, scale, softplus_thr, + state_fp16, stream, 0, ru_anchor()); +} + +// ============================================================== the folded convolution + +// Arrival counters for the folded convolution: one block per (stream, output), zeroed once and +// reset by the last arriver of each group. As with split_ctr in r3dh_gemm_fp8a8.hip, launches +// sharing a block must not overlap: different streams get different blocks, and launches on one +// stream sharing an output are ordered by their dependency. +constexpr unsigned kMaxConvCtr = 4096; + +static unsigned int* ru_conv_ctr(RadStream s, const void* out) { + static std::mutex m; + static std::map, unsigned int*> blocks; + std::lock_guard lk(m); + const auto key = std::make_pair(s, out); + if (auto it = blocks.find(key); it != blocks.end()) return it->second; + void* p = nullptr; + if (hipMalloc(&p, (size_t)kMaxConvCtr * sizeof(unsigned int)) != hipSuccess) return nullptr; + // Zero before any launch reads it. In the engine hipMemset is the AQL backend's and has finished + // when it returns (core/device/aql.cpp); under HIP's own runtime (r3dh_selftest) it runs on the + // null stream, which a non-blocking stream does not wait for, so wait here. + if (hipMemset(p, 0, (size_t)kMaxConvCtr * sizeof(unsigned int)) != hipSuccess || + hipDeviceSynchronize() != hipSuccess) { + (void)hipFree(p); + return nullptr; + } + blocks.emplace(key, (unsigned int*)p); + return (unsigned int*)p; +} + +// The recurrent update with gdn_conv_update folded in, decode shape only (bf16 a/b, fused row +// norm, one workgroup per (sequence, value head)). State contract, non-temporal choice and +// factor-block bounds are as in ru_update_launch. +static int ru_conv_recurrent_launch(const RuConv& cv, const void* a, const void* b, long ab_stride, + const void* A_log, const void* dt_bias, void* state, + long st_slot, long st_head, void* o, void* oq, void* os, + long oq_pitch, long os_ld, const void* cu, const void* sidx, + long sidx_stride, const void* nacc, const void* z, + long z_pitch, const void* nw, float neps, int nact, int N, + int H, int Hg, float scale, float thr, int state_fp16, + RadStream stream, int oq_i8, bool anc) { + if (anc && sidx_stride < 6) return RAD_E_SHAPE; + if (anc && sidx_stride * RU_FSTR > st_head) return RAD_E_SHAPE; + const int sdt = state_fp16 ? 1 : 0; + const long slots_written = anc ? 1 : sidx_stride; + const long flood = (long)N * slots_written * st_slot * (sdt ? 2 : 4); + const bool nt = flood <= (long)RU_NT_MB * 1024 * 1024; + const dim3 grid(N, H, 1), blk(RU_V * 2); +#define RC_LAUNCH(NTC, ANCC, SDTC) \ + do { if (oq_i8) RC_LAUNCH_NM(2, NTC, ANCC, SDTC); else RC_LAUNCH_NM(1, NTC, ANCC, SDTC); } \ + while (0) +#define RC_LAUNCH_NM(NM, NTC, ANCC, SDTC) \ + hipLaunchKernelGGL((r3dh_gdn_recurrent_update_kernel<1, NM, 1, NTC, ANCC, 0, SDTC, 1>), \ + grid, blk, 0, (hipStream_t)stream, nullptr, nullptr, nullptr, a, b, \ + ab_stride, (const float*)A_log, (const float*)dt_bias, \ + (ru_state::T*)state, st_slot, st_head, (unsigned short*)o, \ + (unsigned char*)oq, (float*)os, oq_pitch, os_ld, (const int*)cu, \ + (const int*)sidx, sidx_stride, (const int*)nacc, \ + (const unsigned short*)z, z_pitch, (const float*)nw, neps, nact, H, Hg, \ + scale, thr, cv) +#define RC_PICKNT(ANCC, SDTC) \ + do { if (nt) RC_LAUNCH(1, ANCC, SDTC); else RC_LAUNCH(0, ANCC, SDTC); } while (0) +#define RC_PICKANC(SDTC) \ + do { if (anc) RC_PICKNT(1, SDTC); else RC_PICKNT(0, SDTC); } while (0) + if (sdt) RC_PICKANC(1); else RC_PICKANC(0); +#undef RC_PICKANC +#undef RC_PICKNT +#undef RC_LAUNCH +#undef RC_LAUNCH_NM + return hipGetLastError() == hipSuccess ? RAD_OK : RAD_E_DEVICE; +} + +// ============================================================== the plugin ABI entry points +// Shared operand helpers: r3dh_gdn_args.h. Operand enums use an OPD_ prefix because RU_K and RU_V +// are kernel constants. +/* ------------------------------------------------------------------ recurrent update */ + +enum { OPD_RU_Q = 0, OPD_RU_K, OPD_RU_V, OPD_RU_A, OPD_RU_B, OPD_RU_ALOG, OPD_RU_DTB, OPD_RU_STATE, OPD_RU_SIDX, OPD_RU_NACC, OPD_RU_CU, + OPD_RU_Z, OPD_RU_NORMW, OPD_RU_O, OPD_RU_OQ, OPD_RU_OS }; + +/* The op's `state_form`: 1 for anchor, 0 for per_candidate (also the default), -1 for a form this + * kernel does not implement. The pool behind `state` was sized for the declared form. */ +static int ru_state_form(const RadArgs* a) { + const char* sf = r3dh_gets(a, "state_form"); + if (!sf || std::strcmp(sf, "per_candidate") == 0) return 0; + return std::strcmp(sf, "anchor") == 0 ? 1 : -1; +} + +extern "C" int r3dh_rad_gdn_recurrent_update(const RadArgs* a, RadStream s) { + if (gdn_dims_ok() != RAD_OK) return R3DH_NO(RAD_E_SHAPE); + const RadTensor* q = r3dh_opt(a, OPD_RU_Q); + const RadTensor* k = r3dh_opt(a, OPD_RU_K); + const RadTensor* v = r3dh_opt(a, OPD_RU_V); + const RadTensor* ta = r3dh_opt(a, OPD_RU_A); + const RadTensor* tb = r3dh_opt(a, OPD_RU_B); + const RadTensor* alog = r3dh_opt(a, OPD_RU_ALOG); + const RadTensor* dtb = r3dh_opt(a, OPD_RU_DTB); + const RadTensor* state = r3dh_opt(a, OPD_RU_STATE); + const RadTensor* sidx = r3dh_opt(a, OPD_RU_SIDX); + const RadTensor* nacc = r3dh_opt(a, OPD_RU_NACC); + const RadTensor* cu = r3dh_opt(a, OPD_RU_CU); + const RadTensor* z = r3dh_opt(a, OPD_RU_Z); + const RadTensor* nw = r3dh_opt(a, OPD_RU_NORMW); + const RadTensor* o = r3dh_opt(a, OPD_RU_O); + const RadTensor* oq = r3dh_opt(a, OPD_RU_OQ); + const RadTensor* os = r3dh_opt(a, OPD_RU_OS); + if (!q || !k || !v || !ta || !tb || !alog || !dtb || !state || !sidx || !cu || !o) + return R3DH_NO(RAD_E_INVAL); + if (q->rank != 3 || k->rank != 3 || v->rank != 3 || o->rank != 3) return R3DH_NO(RAD_E_SHAPE); + if (state->rank < 2 || sidx->rank < 1 || ta->rank != 2 || tb->rank != 2) return R3DH_NO(RAD_E_SHAPE); + + /* N comes from cu (the kernel reads cu[n + 1] for every n in the grid); state_idx is checked + * against it. */ + int N = 0; + int rc = seqs_of(cu, &N); + if (rc != RAD_OK) return rc; + if (sidx->shape[0] != N) return R3DH_NO(RAD_E_SHAPE); + + const long long ab_stride = r3dh_row_pitch(ta); + if (ab_stride < 0 || r3dh_row_pitch(tb) != ab_stride) return R3DH_NO(RAD_E_STRIDE); + if (!r3dh_contig(q) || !r3dh_contig(k) || !r3dh_contig(v) || !r3dh_contig(o)) + return R3DH_NO(RAD_E_STRIDE); + + const long long Hg = q->shape[1]; + const long long K = q->shape[2]; + const long long H = v->shape[1]; + const long long V = v->shape[2]; + if (H == 0 || Hg == 0 || H % Hg) return R3DH_NO(RAD_E_SHAPE); + + const int anc = ru_state_form(a); + if (anc < 0) return R3DH_NO(RAD_E_UNSUPPORTED); + + const float scale = (float)r3dh_getf(a, "scale", 1.0); + const float thr = (float)r3dh_getf(a, "softplus_thr", 20.0); + /* Folded gated norm parameters. */ + const float neps = (float)r3dh_getf(a, "eps", 0.0); + const int nact = r3dh_act_code(a, "act", "norm_act", 0); + if (nact < 0) return R3DH_NO(RAD_E_INVAL); + /* The l2 norm epsilon is compiled in, as in r3dh_rad_gdn_conv_prep. */ + if ((float)r3dh_getf(a, "l2_eps", 1e-6) != 1e-6f) return R3DH_NO(RAD_E_UNSUPPORTED); + /* State width from the cache's dtype, as in the chunk scan. */ + const int sfp16 = state->dtype == RAD_F16; + const int ab_is_bf16 = (ta->dtype == RAD_BF16) ? 1 : 0; + if (tb->dtype != ta->dtype) return R3DH_NO(RAD_E_DTYPE); + /* Optional n_head_v must agree with the value tensor. */ + const long long nhv = r3dh_geti_or(a, "n_head_v", 0); + if (nhv > 0 && nhv != H) return R3DH_NO(RAD_E_SHAPE); + + /* bf16 q/k/v/out/z; f32 or f16 state; fp32 A_log, dt_bias and norm weight. */ + R3DH_DT(q, RAD_BF16); R3DH_DT(k, RAD_BF16); R3DH_DT(v, RAD_BF16); R3DH_DT(o, RAD_BF16); + R3DH_DT(z, RAD_BF16); + if (state->dtype != RAD_F32 && state->dtype != RAD_F16) return R3DH_NO(RAD_E_DTYPE); + R3DH_DT(alog, RAD_F32); R3DH_DT(dtb, RAD_F32); R3DH_DT(nw, RAD_F32); + + /* The folded quantiser needs oq and os together, and the fused norm: without it a head's rows + * may be split across workgroups (VS > 1), and a group amax cannot span workgroups. */ + if ((oq != nullptr) != (os != nullptr)) return R3DH_NO(RAD_E_INVAL); + if (oq) { + if (!z || !nw) return R3DH_NO(RAD_E_UNSUPPORTED); + if (V != 128) return R3DH_NO(RAD_E_SHAPE); + if (oq->dtype != RAD_F8E4M3 && oq->dtype != RAD_I8) return R3DH_NO(RAD_E_DTYPE); + R3DH_DT(os, RAD_F32); + if (!r3dh_contig(oq)) return R3DH_NO(RAD_E_STRIDE); + } + + /* z may be a column view of the fused in-projection (rad_block_gdn_fp8.h): tokens are z_row + * elements apart, not H*V. */ + const long long z_row = z ? gn_row_pitch(z, H * V) : 0; + if (z && z_row < 0) return R3DH_NO(RAD_E_STRIDE); + + /* Slot and head strides come from the tensor, so a cache with padded slots is served too + * (see the header); the engine's own state cache is dense ([n_states, H, V, K] per layer). */ + return R3DH_RAW(ru_update_launch( + q->data, k->data, v->data, ta->data, tb->data, (long)ab_stride, ab_is_bf16, + alog->data, dtb->data, state->data, + (long)state->stride[0], (long)state->stride[1], + o->data, oq ? oq->data : nullptr, os ? os->data : nullptr, + oq ? (long)r3dh_row_pitch(oq) : 0, os ? (long)r3dh_row_pitch(os) : 0, + cu->data, sidx->data, (long)sidx->stride[0], + nacc ? nacc->data : nullptr, z ? z->data : nullptr, (long)z_row, + nw ? nw->data : nullptr, + neps, nact, N, (int)H, (int)Hg, (int)K, (int)V, scale, thr, sfp16, s, + oq && oq->dtype == RAD_I8 ? 1 : 0, anc != 0)); +} + + +/* ------------------------------------------------------------------ conv + recurrent update */ + +/* gdn_conv_update's inputs, then gdn_recurrent_update's minus q, k and v (never materialised). + * Inputs first, outputs last (docs/OPS.md). */ +enum { OPD_CR_X = 0, OPD_CR_CW, OPD_CR_CB, OPD_CR_CSTATE, OPD_CR_CIDX, OPD_CR_A, OPD_CR_B, + OPD_CR_ALOG, OPD_CR_DTB, OPD_CR_STATE, OPD_CR_SIDX, OPD_CR_NACC, OPD_CR_CU, OPD_CR_Z, + OPD_CR_NORMW, OPD_CR_O, OPD_CR_OQ, OPD_CR_OS }; + +extern "C" int r3dh_rad_gdn_conv_recurrent_update(const RadArgs* a, RadStream s) { + if (gdn_dims_ok() != RAD_OK) return R3DH_NO(RAD_E_SHAPE); + const RadTensor* x = r3dh_opt(a, OPD_CR_X); + const RadTensor* cw = r3dh_opt(a, OPD_CR_CW); + const RadTensor* cb = r3dh_opt(a, OPD_CR_CB); + const RadTensor* cst = r3dh_opt(a, OPD_CR_CSTATE); + const RadTensor* cidx = r3dh_opt(a, OPD_CR_CIDX); + const RadTensor* ta = r3dh_opt(a, OPD_CR_A); + const RadTensor* tb = r3dh_opt(a, OPD_CR_B); + const RadTensor* alog = r3dh_opt(a, OPD_CR_ALOG); + const RadTensor* dtb = r3dh_opt(a, OPD_CR_DTB); + const RadTensor* state = r3dh_opt(a, OPD_CR_STATE); + const RadTensor* sidx = r3dh_opt(a, OPD_CR_SIDX); + const RadTensor* nacc = r3dh_opt(a, OPD_CR_NACC); + const RadTensor* cu = r3dh_opt(a, OPD_CR_CU); + const RadTensor* z = r3dh_opt(a, OPD_CR_Z); + const RadTensor* nw = r3dh_opt(a, OPD_CR_NORMW); + const RadTensor* o = r3dh_opt(a, OPD_CR_O); + const RadTensor* oq = r3dh_opt(a, OPD_CR_OQ); + const RadTensor* os = r3dh_opt(a, OPD_CR_OS); + /* The row norm is required: the fold is the decode shape, one workgroup per (sequence, value + * head). */ + if (!x || !cw || !cst || !cidx || !ta || !tb || !alog || !dtb || !state || !sidx || !cu || + !z || !nw || !o) + return R3DH_NO(RAD_E_INVAL); + if ((oq != nullptr) != (os != nullptr)) return R3DH_NO(RAD_E_INVAL); + if (x->rank != 2 || cst->rank != 3 || o->rank != 3 || ta->rank != 2 || tb->rank != 2) + return R3DH_NO(RAD_E_SHAPE); + if (state->rank < 2 || sidx->rank < 1 || cidx->rank < 1) return R3DH_NO(RAD_E_SHAPE); + + int N = 0; + int rc = seqs_of(cu, &N); + if (rc != RAD_OK) return rc; + if (sidx->shape[0] != N) return R3DH_NO(RAD_E_SHAPE); + + /* Head geometry from o ([tokens, H, V]) and x ([q | k | v] columns, 2 Hg K + H V wide). */ + const long long T = o->shape[0]; + const long long H = o->shape[1]; + const long long V = o->shape[2]; + const long long K = r3dh_geti_or(a, "head_k", 0); + if (K != RU_K || V != RU_V || r3dh_geti_or(a, "head_v", 0) != RU_V) return R3DH_NO(RAD_E_SHAPE); + if (x->shape[0] != T) return R3DH_NO(RAD_E_SHAPE); + const long long conv_dim = x->shape[1]; + if (H <= 0 || conv_dim <= H * V || (conv_dim - H * V) % (2 * K)) return R3DH_NO(RAD_E_SHAPE); + const long long Hg = (conv_dim - H * V) / (2 * K); + if (H % Hg) return R3DH_NO(RAD_E_SHAPE); + const long long nhv = r3dh_geti_or(a, "n_head_v", 0); + if (nhv > 0 && nhv != H) return R3DH_NO(RAD_E_SHAPE); + if ((long long)N * Hg > (long long)kMaxConvCtr) return R3DH_NO(RAD_E_SHAPE); + + const long long xpitch = r3dh_row_pitch(x); + if (xpitch < 0) return R3DH_NO(RAD_E_STRIDE); + if (!r3dh_contig(cw) || !r3dh_contig(o)) return R3DH_NO(RAD_E_STRIDE); + const long long ab_stride = r3dh_row_pitch(ta); + if (ab_stride < 0 || r3dh_row_pitch(tb) != ab_stride) return R3DH_NO(RAD_E_STRIDE); + + R3DH_DT(x, RAD_BF16); R3DH_DT(cw, RAD_BF16); R3DH_DT(cb, RAD_BF16); R3DH_DT(cst, RAD_BF16); + R3DH_DT(ta, RAD_BF16); R3DH_DT(tb, RAD_BF16); R3DH_DT(o, RAD_BF16); R3DH_DT(z, RAD_BF16); + R3DH_DT(alog, RAD_F32); R3DH_DT(dtb, RAD_F32); R3DH_DT(nw, RAD_F32); + if (state->dtype != RAD_F32 && state->dtype != RAD_F16) return R3DH_NO(RAD_E_DTYPE); + if (oq) { + if (oq->dtype != RAD_F8E4M3 && oq->dtype != RAD_I8) return R3DH_NO(RAD_E_DTYPE); + R3DH_DT(os, RAD_F32); + if (!r3dh_contig(oq)) return R3DH_NO(RAD_E_STRIDE); + } + + /* The window as in gdn_conv_update: max_query_len = state_len_max - (width - 2), and it must + * fit RU_CVT, since the fold holds the tokens in registers. */ + if (r3dh_geti_or(a, "conv_width", 0) != R3DH_GDN_CONV_W) return R3DH_NO(RAD_E_UNSUPPORTED); + const long long mql = cst->shape[2] - (R3DH_GDN_CONV_W - 2); + if (mql < 1) return R3DH_NO(RAD_E_SHAPE); + if (mql > RU_CVT) return R3DH_NO(RAD_E_UNSUPPORTED); + + /* The recurrent half's checks, as in r3dh_rad_gdn_recurrent_update. */ + const int anc = ru_state_form(a); + if (anc < 0) return R3DH_NO(RAD_E_UNSUPPORTED); + const float scale = (float)r3dh_getf(a, "scale", 1.0); + const float thr = (float)r3dh_getf(a, "softplus_thr", 20.0); + const float neps = (float)r3dh_getf(a, "eps", 0.0); + const int nact = r3dh_act_code(a, "act", "norm_act", 0); + if (nact < 0) return R3DH_NO(RAD_E_INVAL); + if ((float)r3dh_getf(a, "l2_eps", 1e-6) != 1e-6f) return R3DH_NO(RAD_E_UNSUPPORTED); + const long long z_row = gn_row_pitch(z, H * V); + if (z_row < 0) return R3DH_NO(RAD_E_STRIDE); + + RuConv cv{}; + cv.x = (const unsigned short*)x->data; cv.xpitch = (long)xpitch; + cv.w = (const unsigned short*)cw->data; cv.b = cb ? (const unsigned short*)cb->data : nullptr; + cv.cs = (unsigned short*)cst->data; + cv.cs_seq = (long)cst->stride[0]; cv.cs_dim = (long)cst->stride[1]; + cv.cs_tok = (long)cst->stride[2]; + cv.cidx = (const int*)cidx->data; cv.ci_stride = (long)cidx->stride[0]; + cv.ctr = ru_conv_ctr(s, o->data); + if (!cv.ctr) return R3DH_NO(RAD_E_NOMEM); + + return ru_conv_recurrent_launch( + cv, ta->data, tb->data, (long)ab_stride, alog->data, dtb->data, state->data, + (long)state->stride[0], (long)state->stride[1], o->data, oq ? oq->data : nullptr, + os ? os->data : nullptr, oq ? (long)r3dh_row_pitch(oq) : 0, + os ? (long)r3dh_row_pitch(os) : 0, cu->data, sidx->data, (long)sidx->stride[0], + nacc ? nacc->data : nullptr, z->data, (long)z_row, nw->data, neps, nact, N, (int)H, + (int)Hg, scale, thr, state->dtype == RAD_F16 ? 1 : 0, s, + oq && oq->dtype == RAD_I8 ? 1 : 0, anc != 0); +} diff --git a/libr3d/r3dh_gdn_wmma.h b/libr3d/r3dh_gdn_wmma.h new file mode 100644 index 00000000..3726f0e7 --- /dev/null +++ b/libr3d/r3dh_gdn_wmma.h @@ -0,0 +1,221 @@ +/* Ported from libhalo/halo_gdn_wmma.h, verbatim but for the halo_ -> r3dh_ rename, so libr3d builds and loads + * on its own. libhalo's gated-delta-net kernels are libr4d's ported to the gfx11 wave matrix and + * checked against libref on gfx1151 (rad-kbench); they compile for gfx11-generic unchanged. */ +/* Carried over from the strix-halo-vllm project's libhalo, where this layer was + * established and measured on the part; see libhalo/README.md. */ +// Fragment layer for the GDN kernels on gfx1151 / RDNA 3.5. +// +// This is the gfx11 counterpart of libr4d's r4d_gdn_wmma.h, and the difference is +// the whole reason the GDN kernels cannot simply be copied across: +// +// A/B per lane the k that lane's element e holds +// gfx1201 (RDNA4) 8 bf16 k = 8*(e>>2) + 4*(lane>>4) + (e&3) +// gfx1151 (RDNA3.5) 16 bf16 k = e +// +// RDNA 3.5 replicates each operand row across both halves of the wave, so a lane +// holds the WHOLE 16-wide k run. Established on the part itself by +// bench/wmma_layout_probe.hip; see r3dh_wmma.h. +// +// For this layer that is a simplification, not extra work: +// +// * a fragment is ONE 32-byte contiguous read of the row, so two dwordx4 rather +// than libr4d's two 8-byte groups sixteen bytes apart. All of its careful +// ds_read2_b32 / ds_load_2addr_b64 pairing notes are about making THAT split +// addressable in one register; there is no split here to pair. +// * the row pointer loses its k term entirely -- `4 * (lane >> 4)` disappears +// from rowP, rowG and rowGo, because the half-wave no longer selects k. +// +// What does NOT simplify is fragT, the transposed source: a lane needs 16 strided +// scalar reads instead of 8. +#pragma once +#include "r3dh_common.h" +#include "r3dh_wmma.h" + +// ---- the gated residual's own bf16 arithmetic ---------------------------------- +// libr4d's r4d_gdn_wmma.h carries these three and the kernels written against it use them +// (r3dh_ar_hc.h, r3dh_hc_bf16.hip); the port's header lost them, so they are restored here, in +// the same place and with the same rounding libr4d uses (round-half-away: one add + a shift, +// against RTNE's three instructions, and they differ only when the discarded bits are exactly +// 0x8000). halo::f32_to_bf16 is the RTNE form the WMMA helpers pack with; keep them apart. +__device__ __forceinline__ unsigned short f2bf(float f) { + return (unsigned short)((__builtin_bit_cast(unsigned, f) + 0x8000u) >> 16); +} +__device__ __forceinline__ unsigned f2bf2(float a, float b) { + const unsigned ua = __builtin_bit_cast(unsigned, a) + 0x8000u; + const unsigned ub = __builtin_bit_cast(unsigned, b) + 0x8000u; + return __builtin_amdgcn_perm(ub, ua, 0x07060302u); // {b_hi16, a_hi16} +} +__device__ __forceinline__ float bf2f(unsigned short h) { + return __builtin_bit_cast(float, (unsigned)h << 16); +} + +// K-contiguous fragment from a row pointer already advanced to this lane's row. +__device__ __forceinline__ v16bf fragP(const unsigned short* p) { + union { uint4 w[2]; v16bf f; } u; + u.w[0] = ((const uint4*)p)[0]; + u.w[1] = ((const uint4*)p)[1]; + return u.f; +} + +// Row pointer for the fragment above: LDS source, `pitch` in elements. No k term -- +// on gfx11 the lane's half does not select k. +__device__ __forceinline__ const unsigned short* rowP(const unsigned short* src, + int pitch, int base, int lane) { + return src + (size_t)(base + (lane & 15)) * pitch; +} + +// Row pointer for a global source; `lim` clamps so a partial last chunk cannot read +// past the tensor (those rows are discarded downstream). +__device__ __forceinline__ const unsigned short* rowG(const unsigned short* base, + size_t rowstride, int row0, + int lim, int lane) { + int r = row0 + (lane & 15); + r = r < lim ? r : lim; + return base + (size_t)r * rowstride; +} + +// 32-bit element offset for a global fragment source, split from a uniform base: +// keeps the whole k loop as global_load_dwordx4 vdst, voff, s[base] with an +// immediate, instead of rematerialising 64-bit address arithmetic per load. +__device__ __forceinline__ unsigned rowGo(unsigned rowstride, int row0, int lim, + int lane) { + int r = row0 + (lane & 15); + r = r < lim ? r : lim; + return (unsigned)r * rowstride; +} +__device__ __forceinline__ v16bf fragGo(const unsigned short* base, unsigned off) { + return fragP(base + off); +} + +// Fragment from a 32-bit LDS byte offset off the shared-block base. Holding the +// offset in one opaque register keeps the two dwordx4 as immediates rather than +// letting LLVM rematerialise a base add in front of every fragment. +__device__ __forceinline__ v16bf fragO(const char* sb, unsigned off) { + return fragP((const unsigned short*)(sb + off)); +} +#define LDSOPAQUE(x) asm("" : "+v"(x)) + +// K-contiguous fragment: src[idx][k], row pitch `pitch` (in elements) +__device__ __forceinline__ v16bf frag(const unsigned short* src, int pitch, + int base, int kbase, int lane) { + return fragP(rowP(src, pitch, base, lane) + kbase); +} + +// Same fragment, source stored transposed: src[k][idx]. 16 scalar reads on gfx11 +// against 8 on gfx12 -- the one place the wider fragment costs rather than saves. +__device__ __forceinline__ v16bf fragT(const unsigned short* src, int pitch, + int base, int kbase, int lane) { + const int idx = base + (lane & 15); + union { unsigned short h[16]; v16bf f; } u; +#pragma unroll + for (int e = 0; e < 16; ++e) u.h[e] = src[(size_t)(kbase + e) * pitch + idx]; + return u.f; +} + +// Fragment straight from global memory (no LDS staging). `lim` clamps the row so a +// partial last chunk cannot read past the tensor. +__device__ __forceinline__ v16bf fragG(const unsigned short* base, size_t rowstride, + int row0, int lim, int kbase, int lane) { + int r = row0 + (lane & 15); + r = r < lim ? r : lim; + return fragP(base + (size_t)r * rowstride + kbase); +} + +__device__ __forceinline__ v8f mma(v16bf a, v16bf b, v8f c) { + return halo::mma(a, b, c); +} + +// C[mt*16..][nt*16..] += A[M][KA] @ B[N][KA]^T over KSTEP 16-wide steps +template +__device__ __forceinline__ v8f gemm(const unsigned short* A, int Ap, int mt, + const unsigned short* B, int Bp, int nt, + int lane, v8f acc) { +#pragma unroll + for (int s = 0; s < KSTEP; ++s) + acc = mma(frag(A, Ap, mt * 16, s * 16, lane), + frag(B, Bp, nt * 16, s * 16, lane), acc); + return acc; +} + +// Where a result element lives. gfx11 wave32 puts D[2*e + (lane>>4)][lane & 15] in +// element e, which is NOT gfx12's mapping -- any kernel that writes an accumulator +// out by hand has to use these rather than the row/col arithmetic it came with. +__device__ __forceinline__ int accRow(int lane, int e) { return 2 * e + (lane >> 4); } +__device__ __forceinline__ int accCol(int lane) { return lane & 15; } + +// ---- writing an accumulator out ------------------------------------------------ +// gfx11 hands lane l element e the value D[2e + (l>>4)][l & 15]: eight rows of ONE +// column, stride two. libr4d's gfx12 mapping is D[8*(l>>4) + e][l & 15] -- eight +// CONSECUTIVE rows -- which is why every one of its accumulator write-outs is a +// single 16-byte store of a transposed tile. Ported naively that inverts into eight +// strided 2-byte stores. +// +// It need not. The partner lane l^16 holds exactly the eight rows interleaved +// between this lane's, so ONE cross-half exchange per dword reassembles sixteen +// consecutive rows, and each half-wave then owns eight of them -- the same single +// 16-byte store, for four v_permlanex16. +// +// Exchange the half the PARTNER needs rather than the half this lane owns: that is +// what keeps it at four shuffles instead of eight (a shuffle reads one VGPR for the +// whole wave, so the two halves cannot ask for different elements). +// +// v[] must ALREADY be scaled per element, because the two halves are scaling +// different rows -- see the gram store in r3dh_gdn_kkt_solve.hip. +__device__ __forceinline__ uint4 accPack(const float v[8], int lane) { + const int hi = lane >> 4; + uint32_t w[4]; +#pragma unroll + for (int i = 0; i < 4; ++i) { + const float mine = hi ? v[i + 4] : v[i]; // the row this lane already holds + const float send = hi ? v[i] : v[i + 4]; // the row the partner is missing + const float got = halo::swap16(send); + w[i] = hi ? halo::pk_bf16(got, mine) : halo::pk_bf16(mine, got); + } + return make_uint4(w[0], w[1], w[2], w[3]); +} +// First row of the eight accPack() returns for this lane. +__device__ __forceinline__ int accPackRow(int lane) { return 8 * (lane >> 4); } + +// accPack() with the same values and rounding, for a kernel where the write-out sits on the +// critical path. accPack() exchanges four floats per lane through halo::swap16 -- a __shfl_xor, +// so ds_bpermute_b32 and an LDS wait per dword -- and LLVM lowers its +// `hi ? pk(got, mine) : pk(mine, got)` to a divergent branch around each pack. This one rounds +// first (pk_bf16's round-to-nearest-even, the same bits), so the partner's four rows travel as two +// packed dwords over v_permlanex16, and the half-dependent order of the final pairs is a per-lane +// v_perm selector rather than a select per value: +// +// p[i] = {v[2i], v[2i+1]} rows {4i + hi, 4i + 2 + hi} +// lanes 0-15 keep p[0..1] and need the partner's p[0..1] (rows 1, 3, 5, 7) +// lanes 16-31 keep p[2..3] and need the partner's p[2..3] (rows 8, 10, 12, 14) +// +// Same precondition as accPack(): the whole wave is active. +__device__ __forceinline__ uint4 accPackX(const float v[8], int lane) { + const bool hi = (lane >> 4) != 0; + uint32_t r[8], p[4]; +#pragma unroll + for (int e = 0; e < 8; ++e) { // f32_to_bf16's rounding, the result in the high half + const uint32_t u = __builtin_bit_cast(uint32_t, v[e]); + r[e] = u + 0x7fffu + ((u >> 16) & 1u); + } +#pragma unroll + for (int i = 0; i < 4; ++i) p[i] = __builtin_amdgcn_perm(r[2 * i + 1], r[2 * i], 0x07060302u); + const uint32_t k0 = hi ? p[2] : p[0], k1 = hi ? p[3] : p[1]; // kept + const uint32_t g0 = r3dh_xor_lane_u32<16>(hi ? p[0] : p[2]); // got: the partner's kept + const uint32_t g1 = r3dh_xor_lane_u32<16>(hi ? p[1] : p[3]); + // {own, partner} below, {partner, own} above: low halves, then high halves. + const uint32_t sl = hi ? 0x01000504u : 0x05040100u, sh = hi ? 0x03020706u : 0x07060302u; + return make_uint4(__builtin_amdgcn_perm(g0, k0, sl), __builtin_amdgcn_perm(g0, k0, sh), + __builtin_amdgcn_perm(g1, k1, sl), __builtin_amdgcn_perm(g1, k1, sh)); +} + +// Byte offset, from the base of a shared block, of the fragment row this lane reads out +// of `buf[base + (lane&15)][...]` with the given row pitch in elements. +// +// This is the gfx11 form of libr4d's ROWO macro, and the difference is the whole port in +// one line: gfx12 adds `4 * (lane >> 4)` because the half-wave selects which quarter of +// the k run the lane holds, and gfx11 has no such term because the lane holds all of it. +// Every LDS fragment site in a ported kernel goes through here, so getting it wrong is a +// single-point failure rather than a scattered one. +__device__ __forceinline__ unsigned rowO(unsigned buf_off, int pitch, int base, int lane) { + return buf_off + (unsigned)(((base + (lane & 15)) * pitch) * 2); +} diff --git a/libr3d/r3dh_q8.h b/libr3d/r3dh_q8.h new file mode 100644 index 00000000..f16b171f --- /dev/null +++ b/libr3d/r3dh_q8.h @@ -0,0 +1,47 @@ +/* Ported from libhalo/halo_q8.h, verbatim but for the halo_ -> r3dh_ rename, so libr3d builds and loads + * on its own. libhalo's gated-delta-net kernels are libr4d's ported to the gfx11 wave matrix and + * checked against libref on gfx1151 (rad-kbench); they compile for gfx11-generic unchanged. */ +/* Derived from libr4d/r4d_q8.h by the libhalo rename transform (2026-10-26); + * see libhalo/README.md. Op schemas, row names and stored weight layouts are + * shared with libr4d by design. Everything else in this file is libhalo's own + * and diverges as it is measured on gfx1151. */ +// r3dh_q8.h -- the 8-bit activation codes the trunk GEMMs read, written by every quantising producer: +// E4M3 for the fp8a8 GEMMs, int8 for their int8 twins (gemm_i8a8_*). One scale per (row, 128 +// columns); only the largest code and the conversion differ. +// +// E4M3: scale `amax * (1 / 448)`, clamp to +-448, two packed conversions. The clamp is required: +// v_cvt_pk_fp8_f32 returns NaN for out-of-range input instead of saturating, and +// `amax * (1 / scale)` can land an ulp above 448. +// +// Int8: as quant_act_i8g (r3dh_quant_act_fp8.hip), scale `amax * (1 / 127)` and round-to-nearest- +// even into -127..127, so a fused producer writes the same codes as the standalone quantiser. +#pragma once +#include +#include +#include "r3dh_fp8_wmma.h" // r3dh_fp8::cvt_pk_fp8_f32 (no fp8-conversion-insts on gfx1151) + +template +__device__ __forceinline__ constexpr float q8_top() { + return I8 ? 127.0f : 448.0f; +} + +// Four values times `inv` (the reciprocal of the scale), as four codes in one dword, value 0 in +// the low byte. +template +__device__ __forceinline__ uint32_t q8_pack4(float a, float b, float c, float d, float inv) { + if constexpr (I8) { + const int ia = (int)rintf(fminf(fmaxf(a * inv, -127.0f), 127.0f)); + const int ib = (int)rintf(fminf(fmaxf(b * inv, -127.0f), 127.0f)); + const int ic = (int)rintf(fminf(fmaxf(c * inv, -127.0f), 127.0f)); + const int id = (int)rintf(fminf(fmaxf(d * inv, -127.0f), 127.0f)); + return ((uint32_t)ia & 0xFFu) | (((uint32_t)ib & 0xFFu) << 8) | + (((uint32_t)ic & 0xFFu) << 16) | (((uint32_t)id & 0xFFu) << 24); + } else { + int pk = 0; + pk = r3dh_fp8::cvt_pk_fp8_f32(fminf(fmaxf(a * inv, -448.0f), 448.0f), + fminf(fmaxf(b * inv, -448.0f), 448.0f), pk, false); + pk = r3dh_fp8::cvt_pk_fp8_f32(fminf(fmaxf(c * inv, -448.0f), 448.0f), + fminf(fmaxf(d * inv, -448.0f), 448.0f), pk, true); + return (uint32_t)pk; + } +} diff --git a/libr3d/r3dh_wmma.h b/libr3d/r3dh_wmma.h new file mode 100644 index 00000000..796fe8ce --- /dev/null +++ b/libr3d/r3dh_wmma.h @@ -0,0 +1,168 @@ +/* Ported from libhalo/halo_wmma.h, verbatim but for the halo_ -> r3dh_ rename, so libr3d builds and loads + * on its own. libhalo's gated-delta-net kernels are libr4d's ported to the gfx11 wave matrix and + * checked against libref on gfx1151 (rad-kbench); they compile for gfx11-generic unchanged. */ +/* Carried over from the strix-halo-vllm project's libhalo, where this layer was + * established and measured on the part; see libhalo/README.md. */ +// Wave32 WMMA fragment algebra for gfx1151 / RDNA 3.5. +// +// This is the gfx11 counterpart of libr4d's gfx12 fragment layer, and it exists +// because the two architectures do NOT agree on how a wave32 WMMA fragment is +// spread over the wave: +// +// A / B per lane the k a lane's element e holds +// gfx1201 (RDNA4) 8 bf16 (v[0:3]) k = 8*(e>>2) + 4*(lane>>4) + (e&3) +// gfx1151 (RDNA3.5) 16 bf16 (v[0:7]) k = e +// +// RDNA 3.5 replicates each operand row across both halves of the wave, so a lane +// holds the WHOLE 16-wide k run; RDNA4 splits it. Every fragment gather ported +// from libr4d therefore loses its half-wave term -- the port is a simplification +// at the gather sites, and a change of row mapping at the result. +// +// The layout below was established on the part itself by bench/wmma_layout_probe.hip, +// which tests candidate mappings against a host matmul and finds exactly one with +// zero error (the others are off by ~350 on the same data). Do not "fix" any of it +// from a vendor doc -- rerun the probe. +// +// A: lane l holds row (l & 15) of A; element e is k = e (lanes 16-31 replicate) +// B: lane l holds col (l & 15) of B; element e is k = e +// D: lane l, element e -> D[2*e + (l>>4)][l & 15] +// +// Note what the D mapping preserves: the COLUMN is still (lane & 15). libr4d's +// attention kernels are built around a transposed score matrix S^T = K.Q^T so that +// a fragment gives each lane exactly one query row and the softmax is lane-private. +// That property survives here unchanged, which is why those kernels are portable +// at all. +#pragma once +#include +#include +#include "r3dh_common.h" + +/* Byte order of stored fp8 weights along k, inside each group of four, and which + * e4m3 -> bf16 unpack deq16_e4m3 below compiles. In the vLLM libhalo these lived + * in its r3dh_common.h; here the stored layout is radiance's own (r3dh_layout.cpp + * chooses it at load), so the swizzled order is available when a relayout asks + * for it. Defaults: natural order, perm-input unpack. */ +#ifndef R3DH_FP8_SWIZ +#define R3DH_FP8_SWIZ 0 +#endif +#ifndef R3DH_FP8_DEQ +#define R3DH_FP8_DEQ 1 +#endif + +typedef __bf16 v16bf __attribute__((ext_vector_type(16))); +typedef __fp16 v16hf __attribute__((ext_vector_type(16))); // what the f16 WMMA builtin takes +typedef float v8f __attribute__((ext_vector_type(8))); +typedef float v2f __attribute__((ext_vector_type(2))); + +namespace halo { + +// ---- where a lane's data lives ------------------------------------------------ +__device__ __forceinline__ int a_row(int lane) { return lane & 15; } +__device__ __forceinline__ int b_col(int lane) { return lane & 15; } +__device__ __forceinline__ int d_col(int lane) { return lane & 15; } +__device__ __forceinline__ int d_row(int lane, int e) { return 2 * e + (lane >> 4); } +// The half a lane sits in. On gfx12 this selects which k it loads; here it selects +// only which D rows it receives, and the gather does not use it. +__device__ __forceinline__ int half(int lane) { return lane >> 4; } + +// ---- the instruction ---------------------------------------------------------- +__device__ __forceinline__ v8f mma(v16bf a, v16bf b, v8f c) { + return __builtin_amdgcn_wmma_f32_16x16x16_bf16_w32(a, b, c); +} +__device__ __forceinline__ v8f mma(v16hf a, v16hf b, v8f c) { + return __builtin_amdgcn_wmma_f32_16x16x16_f16_w32(a, b, c); +} + +// ---- building a fragment ------------------------------------------------------ +// From eight dwords, i.e. a lane's full 16-wide k run already packed as 16-bit +// pairs. This is the gfx11 replacement for libr4d's DT16::mk(uint2 lo, uint2 hi): +// twice the payload, and no half-wave selection. +template +__device__ __forceinline__ FRAG mk(const uint32_t w[8]) { + union { uint32_t u[8]; FRAG f; } q; +#pragma unroll + for (int i = 0; i < 8; ++i) q.u[i] = w[i]; + return q.f; +} + +// From a 32-byte-aligned pointer to 16 contiguous 16-bit values -- the common case +// once the half-wave split is gone, and two dwordx4 loads. +template +__device__ __forceinline__ FRAG mk_ldg(const void* p) { + union { uint4 v[2]; FRAG f; } q; + q.v[0] = *(const uint4*)p; + q.v[1] = *((const uint4*)p + 1); + return q.f; +} + +// f32 -> bf16, round-to-nearest-even. gfx1151 has no v_cvt_pk_bf16_f32 either, so +// this stays the software form libr4d uses. +__device__ __forceinline__ uint16_t f32_to_bf16(float f) { + uint32_t u = __builtin_bit_cast(uint32_t, f); + return (uint16_t)((u + 0x7fffu + ((u >> 16) & 1u)) >> 16); +} +__device__ __forceinline__ uint32_t pk_bf16(float x, float y) { + return (uint32_t)f32_to_bf16(x) | ((uint32_t)f32_to_bf16(y) << 16); +} +// f16 packs in ONE instruction, which is why libr4d prefers it on the softmax path. +__device__ __forceinline__ uint32_t pk_f16(float x, float y) { + typedef __fp16 v2hf __attribute__((ext_vector_type(2))); // what cvt_pkrtz returns + union { v2hf h; uint32_t u; } q; + q.h = __builtin_amdgcn_cvt_pkrtz(x, y); + return q.u; +} + +// Exchange a value with the lane 16 away -- the two halves a D fragment splits its +// rows across. The one cross-lane step the transposed-score formulation needs. +__device__ __forceinline__ float swap16(float x) { return __shfl_xor(x, 16, 32); } +__device__ __forceinline__ uint32_t swap16_u(uint32_t x) { + return __builtin_bit_cast(uint32_t, swap16(__builtin_bit_cast(float, x))); +} + +// ---- e4m3 -> bf16, one B fragment (16 bytes) ---------------------------------- +// The single copy. It used to be inlined in r3dh_moe_fp8_group and again in +// r3dh_gemm_fp8_nt, and the two had already drifted; they are the same sixteen +// bytes becoming the same fragment, so they are the same function. +// +// A dword holds four e4m3 and must become two dwords of two bf16. Bytes 0 and 2 +// sit at bit 0 and bit 16, so ONE left shift moves both their payloads and one +// more moves both their signs; bytes 1 and 3 sit at bit 8 and 24 and one right +// shift serves both of theirs. Four instructions place all four values -- but +// that pairs k with k+2, and WMMA wants k with k+1. +// +// v_perm_b32 fixes the pairing on the INPUT for one instruction: reorder the +// dword to (b0, b2, b1, b3) and the natural output of the two shifts IS k +// order. Eight instructions per dword against the twelve the mask-and-restitch +// version needs (ten bit ops plus two v_mov_b16 the register allocator adds), +// and -- unlike doing it in storage -- it needs no change to the stored +// weights, which is what makes it shippable: the layout belongs to vLLM's +// Triton fused_experts, which reads the same tensors on every prefill. +// +// The exponent is NOT biased. Every value comes out low by exactly 2^-120, +// which the caller folds into the block scale as R3DH_FP8_FIX; see docs/31. +__device__ __forceinline__ v16bf deq16_e4m3(const uint32_t* __restrict__ w4) { + union { uint32_t u[8]; v16bf f; } q; +#pragma unroll + for (int d = 0; d < 4; ++d) { + const uint32_t w = w4[d]; +#if !R3DH_FP8_DEQ + // The control: mask each byte in place, then restitch the halves into k + // order. Ten bit ops, and the allocator adds two v_mov_b16 on top. + const uint32_t lo = ((w & 0x007F007Fu) << 4) | ((w & 0x00800080u) << 8); + const uint32_t hi = ((w & 0x7F007F00u) >> 4) | (w & 0x80008000u); + q.u[d * 2 + 0] = (lo & 0x0000FFFFu) | (hi << 16); + q.u[d * 2 + 1] = (lo >> 16) | (hi & 0xFFFF0000u); +#else +#if R3DH_FP8_SWIZ + const uint32_t x = w; // stored (k0, k2, k1, k3): no perm needed +#else + const uint32_t x = __builtin_amdgcn_perm(w, w, 0x03010200u); +#endif + q.u[d * 2 + 0] = ((x << 8) & 0x80008000u) | ((x << 4) & 0x07F007F0u); + q.u[d * 2 + 1] = (x & 0x80008000u) | ((x >> 4) & 0x07F007F0u); +#endif + } + return q.f; +} + +} // namespace halo diff --git a/libr4d/CMakeLists.txt b/libr4d/CMakeLists.txt index 5eeed491..5eb1d250 100644 --- a/libr4d/CMakeLists.txt +++ b/libr4d/CMakeLists.txt @@ -68,6 +68,8 @@ set(R4D_UNITS # Two queries per KV head at head_dim 128 only (Qwen3-1.7B's 16 over 8, Qwen3-ASR's decoder): # the gqa8 body with the ratio set. "r4d_attn_paged_h128_gqa2|" + # Sixteen queries per KV head at head_dim 128 (Nemotron-H's 32 over 2 at one or two ranks). + "r4d_attn_paged_h128_gqa16|" "r4d_attn_vit_h72_bf16|" # An encoder's dense attention (bidirectional, GQA in the workgroup, a two-sided window) and # the small ops around it: act_mul, seg_mean, qk_norm_rope with a v norm, the f32 widening. @@ -116,6 +118,8 @@ set(R4D_UNITS "r4d_dsa|" "r4d_mla|" "r4d_kda|" + # Mamba-2's selective state update (Nemotron-H), the KDA kernel's register layout. + "r4d_ssd|" "r4d_moe_mxfp4|" "r4d_fp8_f32scale|" "r4d_ngram_ids|" @@ -160,6 +164,7 @@ set(R4D_UNITS "r4d_gemm_fp8a8|" "r4d_gemm_iqr|" "r4d_iqr_embed|" + "r4d_logits_vocab|" "r4d_quant_act_fp8|" "r4d_givens_rotate|" "r4d_fused_quant_fp8|" @@ -193,6 +198,8 @@ set(R4D_UNITS "r4d_rowtopk_bf16|" # The vocab-sharded draft head's cross-rank top-1, one id a row. "r4d_pair_argmax_f32|" + # LiLiCorr's correlator: candidates, lattice attention, factor input, walk. + "r4d_lili|" # Gemma 4's sandwich-norm joins (norm_add_norm, norm_add_norm_route, join_add_scale) and # expert_scale, each one kernel for a chain of small ones. "r4d_norm_join_bf16|" @@ -201,6 +208,7 @@ set(R4D_UNITS "r4d_lora_bf16|" "r4d_dflash_conv_t2_g16_bf16|" "r4d_dflash_select_bf16|" + "r4d_dflash_markov_bf16|" "r4d_dflash_tree_bf16|" # Routed MoE: router, scatter, the grouped block-scaled fp8 GEMM and gather, in one unit because # the other three only feed the GEMM. diff --git a/libr4d/r4d.h b/libr4d/r4d.h index 9529d9b3..b418bfe8 100644 --- a/libr4d/r4d.h +++ b/libr4d/r4d.h @@ -322,7 +322,7 @@ void r4d_ar_oneshot_2rank_wht6(long peer_scratch, long my_scratch, long peer_fla void r4d_ar_hc_write(long peer_scratch, long my_scratch, long peer_flags, long my_flags, long seq_ctrs, long slot_stride16, long y, long inj, long h, long M, long n, long hc, long irow, long hrow, long stream, long nblocks, long nthreads, - long drain, long acq, long gate, long gate_ctr, long stage = 0); + long drain, long acq, long gate, long gate_ctr, long stage = 0, long chain = 0); // The same with the MoE gather as its prologue: y is produced, not read, from the routed experts' // rows `ye` [M*top_k][ye_ld] summed to token order by weights `ew` [M][ew_ld] and `sorted` // [M*top_k], with the shared arm `sh` [M][sh_ld] and its gate `sg` folded when both are non-zero. @@ -335,7 +335,7 @@ int r4d_ar_gather_hc_write(long peer_scratch, long my_scratch, long peer_flags, long sh, long sg, long ye_ld, long ew_ld, long sh_ld, long sg_ld, long top_k, long sig, long stream, long nblocks, long nthreads, long drain, long acq, long inv, long gate, long gate_ctr, - long stage = 0); + long stage = 0, long chain = 0); // r4d_ar_hc_write and r4d_ar_gather_hc_write on the rotated 6-bit wire (r4d_ar_oneshot_2rank_wht6's // format, loc_pack and scratch split): byte-identical to all_reduce on that wire then hc_write, // with `ye` non-zero preceded by moe_gather. Gather operands as r4d_ar_gather_hc_write; its slot diff --git a/libr4d/r4d_ar_entry.hip b/libr4d/r4d_ar_entry.hip index 65371cc9..d90394d0 100644 --- a/libr4d/r4d_ar_entry.hip +++ b/libr4d/r4d_ar_entry.hip @@ -18,6 +18,7 @@ * with a 60-second timeout and a named error. */ +#include "r4d_chain.h" #include "r4d_args.h" #include "r4d.h" #include "r4d_ar_shards.h" @@ -1715,7 +1716,8 @@ extern "C" int r4d_rad_ar_gather_hc_write(const RadArgs* a, RadStream s) { sh ? r4d_addr(sh) : 0L, sh ? r4d_addr(sg) : 0L, (long)ye_ld, (long)ew_ld, (long)sh_ld, (long)sg_ld, (long)top_k, (long)sig, (long)(uintptr_t)s, nblocks, cfgv.nthreads, cfgv.drain, cfgv.acq, has_inv ? (long)(uintptr_t)a->scratch : 0L, early, - early ? in->gate_ctr : 0L, in->my_stage); + early ? in->gate_ctr : 0L, in->my_stage, + r4d_geti_or(a, "chain", 0) != 0 && r4d_chain_rows_ok(M) ? 1L : 0L); if (rc != 0) return RAD_E_SHAPE; return early ? RAD_LINK_ENDED : RAD_OK; } @@ -1844,7 +1846,8 @@ extern "C" int r4d_rad_ar_hc_write(const RadArgs* a, RadStream s) { in->my_seq, in->slot16, r4d_addr(y), r4d_addr(inj), r4d_addr(h), (long)M, (long)n, (long)hc, (long)irow, (long)hrow, (long)(uintptr_t)s, nblocks, cfgv.nthreads, cfgv.drain, cfgv.acq, early, - early ? in->gate_ctr : 0L, in->my_stage)); + early ? in->gate_ctr : 0L, in->my_stage, + r4d_geti_or(a, "chain", 0) != 0 && r4d_chain_rows_ok(M) ? 1L : 0L)); return early ? RAD_LINK_ENDED : RAD_OK; } diff --git a/libr4d/r4d_ar_oneshot_2rank_exact.hip b/libr4d/r4d_ar_oneshot_2rank_exact.hip index 8a3da1b6..1181d130 100644 --- a/libr4d/r4d_ar_oneshot_2rank_exact.hip +++ b/libr4d/r4d_ar_oneshot_2rank_exact.hip @@ -18,6 +18,7 @@ // * Fine-grained memory (hipDeviceMallocFinegrained) is uncached and posted straight to the // fabric, so system-scope release/acquire skip the L2 writeback. The drain/acq fences are // selectable (default drain=1/acq=0 on fine-grained). +#include "r4d_chain.h" #include "r4d.h" #include "r4d_ar_seq.h" #include "r4d_ar_hc.h" // the gather word and the hc write word, shared with the rotated wire @@ -147,7 +148,7 @@ __global__ void r4d_ar_oneshot_2rank_exact_kernel( // // n is a multiple of eight, so a word never straddles a row and the block that reduces it owns // every stream element behind it. -__global__ void r4d_ar_hc_write_kernel( +__device__ __forceinline__ void r4d_ar_hc_write_kernel_body( int4* __restrict__ y4, int4* peer_base, const int4* my_base, unsigned int* peer_flags, unsigned int* my_flags, unsigned int* seq_ctrs, const unsigned short* __restrict__ inj, unsigned short* __restrict__ h, int n16, int n, int hc, long irow, long hrow, @@ -209,6 +210,26 @@ __global__ void r4d_ar_hc_write_kernel( } } +/* The plain and chained forms (r4d_chain.h): every block leaves through the wrapper. */ +__global__ void r4d_ar_hc_write_kernel( + int4* __restrict__ y4, int4* peer_base, const int4* my_base, unsigned int* peer_flags, + unsigned int* my_flags, unsigned int* seq_ctrs, const unsigned short* __restrict__ inj, + unsigned short* __restrict__ h, int n16, int n, int hc, long irow, long hrow, + int slot_stride16, int drain, int acq, unsigned int nbw, long long* gate, + unsigned int* gate_ctr, long stage) { + r4d_ar_hc_write_kernel_body(y4, peer_base, my_base, peer_flags, my_flags, seq_ctrs, inj, h, n16, n, hc, irow, hrow, slot_stride16, drain, acq, nbw, gate, gate_ctr, stage); +} +__global__ void r4dchain_ar_hc_write( + int4* __restrict__ y4, int4* peer_base, const int4* my_base, unsigned int* peer_flags, + unsigned int* my_flags, unsigned int* seq_ctrs, const unsigned short* __restrict__ inj, + unsigned short* __restrict__ h, int n16, int n, int hc, long irow, long hrow, + int slot_stride16, int drain, int acq, unsigned int nbw, long long* gate, + unsigned int* gate_ctr, long stage) { + r4d_chain_wait(); + r4d_ar_hc_write_kernel_body(y4, peer_base, my_base, peer_flags, my_flags, seq_ctrs, inj, h, n16, n, hc, irow, hrow, slot_stride16, drain, acq, nbw, gate, gate_ctr, stage); + r4d_chain_done(); +} + // The same write with the MoE gather as its prologue. The routed experts' rows go back to token // order, y[t][i] = sum over t's slots, ascending, of w[t][j] * y_expert[slot][i] rounded to bf16, // with the shared arm folded in as moe_gather does; the word is pushed to the peer and kept as this @@ -238,7 +259,7 @@ __global__ void r4d_ar_gather_inv_kernel(int* __restrict__ inv, const int* __res } template -__global__ void r4d_ar_gather_hc_write_kernel( +__device__ __forceinline__ void r4d_ar_gather_hc_write_kernel_body( int4* __restrict__ y4, int4* peer_base, const int4* my_base, unsigned int* peer_flags, unsigned int* my_flags, unsigned int* seq_ctrs, const unsigned short* __restrict__ inj, unsigned short* __restrict__ h, int n16, int n, int hc, long irow, long hrow, @@ -326,6 +347,28 @@ __global__ void r4d_ar_gather_hc_write_kernel( } } +/* The plain and chained forms (r4d_chain.h): every block leaves through the wrapper. */ +template +__global__ void r4d_ar_gather_hc_write_kernel( + int4* __restrict__ y4, int4* peer_base, const int4* my_base, unsigned int* peer_flags, + unsigned int* my_flags, unsigned int* seq_ctrs, const unsigned short* __restrict__ inj, + unsigned short* __restrict__ h, int n16, int n, int hc, long irow, long hrow, + int slot_stride16, int drain, int acq, unsigned int nbw, R4dArGather G, + const int* __restrict__ inv, long long* gate, unsigned int* gate_ctr, long stage) { + r4d_ar_gather_hc_write_kernel_body(y4, peer_base, my_base, peer_flags, my_flags, seq_ctrs, inj, h, n16, n, hc, irow, hrow, slot_stride16, drain, acq, nbw, G, inv, gate, gate_ctr, stage); +} +template +__global__ void r4dchain_ar_gather_hc_write( + int4* __restrict__ y4, int4* peer_base, const int4* my_base, unsigned int* peer_flags, + unsigned int* my_flags, unsigned int* seq_ctrs, const unsigned short* __restrict__ inj, + unsigned short* __restrict__ h, int n16, int n, int hc, long irow, long hrow, + int slot_stride16, int drain, int acq, unsigned int nbw, R4dArGather G, + const int* __restrict__ inv, long long* gate, unsigned int* gate_ctr, long stage) { + r4d_chain_wait(); + r4d_ar_gather_hc_write_kernel_body(y4, peer_base, my_base, peer_flags, my_flags, seq_ctrs, inj, h, n16, n, hc, irow, hrow, slot_stride16, drain, acq, nbw, G, inv, gate, gate_ctr, stage); + r4d_chain_done(); +} + // The IPC handle goes into a caller-owned buffer of R4D_AR_HANDLE_BYTES so this stays a C ABI. static_assert(sizeof(hipIpcMemHandle_t) <= R4D_AR_HANDLE_BYTES, "ipc handle larger than the ABI buffer"); @@ -420,7 +463,7 @@ int r4d_p2p_copy2d(long dst, long src, long dpitch, long spitch, long width, lon void r4d_ar_hc_write(long peer_scratch, long my_scratch, long peer_flags, long my_flags, long seq_ctrs, long slot_stride16, long y, long inj, long h, long M, long n, long hc, long irow, long hrow, long stream_i, long nblocks, long nthreads, - long drain, long acq, long gate, long gate_ctr, long stage) { + long drain, long acq, long gate, long gate_ctr, long stage, long chain) { hipStream_t st = (hipStream_t)stream_i; if (n <= 0 || M <= 0 || n % 8) throw std::runtime_error("ar_hc_write: n must be a positive multiple of 8"); if (hc < 1 || hrow % 8) throw std::runtime_error("ar_hc_write: the streams must be whole 16B words"); @@ -436,7 +479,7 @@ void r4d_ar_hc_write(long peer_scratch, long my_scratch, long peer_flags, long m if (nt < 64) nt = 64; if (nt > 1024) nt = 1024; nt &= ~31; // whole waves: the push check's wave sum reads all 32 lanes - r4d_ar_hc_write_kernel<<>>( + (chain ? r4dchain_ar_hc_write : r4d_ar_hc_write_kernel)<<>>( (int4*)y, (int4*)peer_scratch, (const int4*)my_scratch, (unsigned*)peer_flags, (unsigned*)my_flags, (unsigned*)seq_ctrs, (const unsigned short*)inj, (unsigned short*)h, n16, (int)n, (int)hc, irow, hrow, (int)slot_stride16, (int)drain, (int)acq, nbw, @@ -448,7 +491,8 @@ int r4d_ar_gather_hc_write(long peer_scratch, long my_scratch, long peer_flags, long n, long hc, long irow, long hrow, long ye, long ew, long sorted, long sh, long sg, long ye_ld, long ew_ld, long sh_ld, long sg_ld, long top_k, long sig, long stream_i, long nblocks, long nthreads, - long drain, long acq, long inv, long gate, long gate_ctr, long stage) { + long drain, long acq, long inv, long gate, long gate_ctr, long stage, + long chain) { hipStream_t st = (hipStream_t)stream_i; if (n <= 0 || M <= 0 || n % 8 || hc < 1 || hrow % 8) return -1; if (top_k < 1 || top_k > R4D_ARG_SLOTS) return -2; @@ -488,13 +532,13 @@ int r4d_ar_gather_hc_write(long peer_scratch, long my_scratch, long peer_flags, G.top_k = (int)top_k; G.T = (int)(M * top_k); G.sig = (int)sig; if (by_inv) { r4d_ar_gather_inv_kernel<<<1, 1024, 0, st>>>((int*)inv, (const int*)sorted, G.T); - r4d_ar_gather_hc_write_kernel<<>>( + (chain ? r4dchain_ar_gather_hc_write : r4d_ar_gather_hc_write_kernel)<<>>( (int4*)y, (int4*)peer_scratch, (const int4*)my_scratch, (unsigned*)peer_flags, (unsigned*)my_flags, (unsigned*)seq_ctrs, (const unsigned short*)inj, (unsigned short*)h, n16, (int)n, (int)hc, irow, hrow, (int)slot_stride16, (int)drain, (int)acq, nbw, G, (const int*)inv, (long long*)gate, (unsigned int*)gate_ctr, stage); } else { - r4d_ar_gather_hc_write_kernel<<>>( + (chain ? r4dchain_ar_gather_hc_write : r4d_ar_gather_hc_write_kernel)<<>>( (int4*)y, (int4*)peer_scratch, (const int4*)my_scratch, (unsigned*)peer_flags, (unsigned*)my_flags, (unsigned*)seq_ctrs, (const unsigned short*)inj, (unsigned short*)h, n16, (int)n, (int)hc, irow, hrow, (int)slot_stride16, (int)drain, (int)acq, nbw, G, diff --git a/libr4d/r4d_attn_args.h b/libr4d/r4d_attn_args.h index 667abccc..7e6fc0ac 100644 --- a/libr4d/r4d_attn_args.h +++ b/libr4d/r4d_attn_args.h @@ -99,6 +99,8 @@ static inline int fill_paged_row(const RadArgs* a, R4DArgs* r, int expect_head_d if (kv->stride[3] != 1) return R4D_NO(RAD_E_STRIDE); if (kv->stride[2] != row) return R4D_NO(RAD_E_STRIDE); if (kv->shape[3] != row) return R4D_NO(RAD_E_SHAPE); + /* The kernels divide q_heads by kv_heads for the GQA factor. */ + if (kv->shape[1] <= 0) return R4D_NO(RAD_E_SHAPE); /* 16-byte alignment for 128-bit loads. */ if (!r4d_aligned(q->data, 16) || !r4d_aligned(o->data, 16) || !r4d_aligned(kv->data, 16)) diff --git a/libr4d/r4d_attn_decode_h256_gqa6.hip b/libr4d/r4d_attn_decode_h256_gqa6.hip index ef8d47bb..936cd7e8 100644 --- a/libr4d/r4d_attn_decode_h256_gqa6.hip +++ b/libr4d/r4d_attn_decode_h256_gqa6.hip @@ -72,6 +72,25 @@ __host__ __device__ __forceinline__ int r4d_attn_tiles(int ctx, int tile) { retu __host__ __device__ __forceinline__ int r4d_attn_tps(int ctx, int tile, int splits) { int t = r4d_attn_tiles(ctx, tile); return (t + splits - 1) / splits; } +// Segments the combine reads for output row `tok`. The decode kernel cuts the tiles of the launch's +// context (the last row's) into segments of `tps` tiles. A causal row ends earlier than that: its +// own context is ctx - q_len + 1 + row, and the segments past it hold nothing it needs. Reading +// them anyway changes how the merge groups the live ones (the chains' tail), so a verify row +// would differ in the last bit from the single-row decode at its position, and greedy text with a +// drafter from the text without. `nef` is the launch's tile count after the window's floor, `win` +// whether this is a windowed row (kept as the launch's: its floor is row 0's). Same segments as +// before for a plain decode, a window, a non-causal row and a tree. +__device__ __forceinline__ int r4d_row_segments(const R4DArgs& a, int seq, int tok, int ctx, int tile, + int tps, int nef, int win) { + const int cz = a.causal_seq ? (int)((const unsigned char*)a.causal_seq)[seq] : a.causal; + if (win || !cz || a.spec_parent) return (nef + tps - 1) / tps; + const int qlen = r4d_q_len(a.cu_q, seq, a.q_len); + const int row = tok - r4d_q_off(a.cu_q, seq, a.q_len); + const int rctx = ctx - qlen + 1 + row; + const int tiles = rctx < ctx ? r4d_attn_tiles(rctx > 0 ? rctx : 1, tile) : nef; + return (tiles + tps - 1) / tps; +} + // First KV position query row `qrow` may attend to under a sliding window: the row's // causal limit, less the window, floored at zero. window <= 0 means no window. __host__ __device__ __forceinline__ int r4d_attn_wlo(int ctx, int q_len, int qrow, int window) { @@ -761,7 +780,7 @@ void splitkv_combine_vec_body(const R4DArgs& a, int splits, int tile, const R4DG const int nef = r4d_attn_tiles(ctx, tile) - (WIN ? r4d_attn_wlo(ctx, r4d_q_len(a.cu_q, seq, a.q_len), 0, a.window) / tile : 0); const int tp_ = (nef + splits - 1) / splits; - const int u = (nef + tp_ - 1) / tp_; + const int u = r4d_row_segments(a, seq, tok, ctx, tile, tp_, nef, WIN); const size_t nrow = (size_t)r4d_q_total(a) * a.q_heads * splits; const size_t base = (size_t)job * splits; @@ -934,7 +953,7 @@ void splitkv_combine_body(const R4DArgs& a, int splits, int tile, const R4DGateQ const int nef = r4d_attn_tiles(ctx, tile) - (WIN ? r4d_attn_wlo(ctx, r4d_q_len(a.cu_q, seq, a.q_len), 0, a.window) / tile : 0); const int tp_ = (nef + splits - 1) / splits; - const int u = (nef + tp_ - 1) / tp_; + const int u = r4d_row_segments(a, seq, tok, ctx, tile, tp_, nef, WIN); const size_t nrow = (size_t)r4d_q_total(a) * a.q_heads * splits; const size_t base = (size_t)job * splits; diff --git a/libr4d/r4d_attn_dense_bf16.hip b/libr4d/r4d_attn_dense_bf16.hip index 397d0c3f..17d6a494 100644 --- a/libr4d/r4d_attn_dense_bf16.hip +++ b/libr4d/r4d_attn_dense_bf16.hip @@ -2,7 +2,7 @@ // an optional two-sided window, i - j < window behind and j - i < wright ahead (wright is // `window_right`, or `window` for the symmetric |i - j| < window), or causal with an optional // window behind (a codec's sliding layers, a text encoder's prompt). bf16 in and out, f16 -// operands, f32 accumulate. Head widths 64, 256 and 512 are compiled; each (head_dim, gqa) pair +// operands, f32 accumulate. Head widths 64, 80, 256 and 512 are compiled; each (head_dim, gqa) pair // is a row. // // Core from the vision kernel (r4d_attn_vit_h72_bf16.hip): S^T = K.Q^T, so the wave32 @@ -304,6 +304,7 @@ void r4d_attn_dense_kernel(const uint16_t* __restrict__ gq, const uint16_t* __re // ---- launch ---------------------------------------------------------------------------------- // One instantiation per (head_dim, gqa), at a workgroup shape picked for it: // h64 gqa1: 8 query blocks of 16, K/V tiles of 64 keys (the vision towers' heads) +// h80 gqa1: the same shape, five 16-wide k-tiles a head (C-RADIO's heads) // h256 gqa1: 8 query blocks of 16, tiles of 32 (LDS: 37 KiB) // h256 gqa2, 4, 8: 8, 4, 2 query blocks x the heads, tiles of 32 (LDS: 37 KiB) // h512 gqa2, 4, 8: 4, 2, 1 query blocks x the heads x 2 head halves, tiles of 16 (LDS: 57 KiB) @@ -353,6 +354,10 @@ extern "C" int r4d_attn_dense_bf16(const void* q, const void* k, const void* v, return r4d_attn_dense_launch<64, 1, 8, 1, 64>(q, k, v, o, cu_seqlens, num_seqs, max_seqlen, n_head_kv, scale, window, wright, block, cdiv, causal, q_ld, k_ld, v_ld, o_ld, s); + if (head_dim == 80 && gqa == 1) + return r4d_attn_dense_launch<80, 1, 8, 1, 64>(q, k, v, o, cu_seqlens, num_seqs, max_seqlen, + n_head_kv, scale, window, wright, block, + cdiv, causal, q_ld, k_ld, v_ld, o_ld, s); #define R4D_DENSE(HD, G, NQB, DS, T) \ return r4d_attn_dense_launch(q, k, v, o, cu_seqlens, num_seqs, max_seqlen, \ n_head_kv, scale, window, wright, block, \ diff --git a/libr4d/r4d_attn_paged_gqa8.hip b/libr4d/r4d_attn_paged_gqa8.hip index 6ef8f8e1..34d6efbc 100644 --- a/libr4d/r4d_attn_paged_gqa8.hip +++ b/libr4d/r4d_attn_paged_gqa8.hip @@ -72,7 +72,11 @@ using std::max; #ifndef G8_BLOCK_SIZE #define G8_BLOCK_SIZE 16 #endif -#define G8_MAX_DECODE_ROWS 64 // q_len * gqa a single decode workgroup can hold: q_len <= 8 +/* q_len * gqa a single decode workgroup can hold: q_len <= 8 here. An including unit may raise it + * to 128 (eight waves): gqa 16 then verifies 7 drafts in the decode kernel, as gqa 8 does. */ +#ifndef G8_MAX_DECODE_ROWS +#define G8_MAX_DECODE_ROWS 64 +#endif #define G8_P_NWARPS 24 #define G8_P_TILE 48 @@ -152,6 +156,11 @@ static int g8_decode_launch(const R4DArgs* a, RadStream stream, dim3(splits, a->kv_heads, a->num_seqs), dim3(32), 0, *a, splits); else if (nw == 2) G8_LAUNCH(2); else if (nw == 3) G8_LAUNCH(3); +#if G8_MAX_DECODE_ROWS > 64 + /* Five to eight waves take eight; a wave past the last query row computes a copy of it and + * stores nothing. */ + else if (nw > 4) G8_LAUNCH(8); +#endif else G8_LAUNCH(4); #undef G8_LAUNCH if (emit_rc != RAD_OK) return -5; diff --git a/libr4d/r4d_attn_paged_h128_gqa16.hip b/libr4d/r4d_attn_paged_h128_gqa16.hip new file mode 100644 index 00000000..edba4999 --- /dev/null +++ b/libr4d/r4d_attn_paged_h128_gqa16.hip @@ -0,0 +1,20 @@ +// R4D attention at sixteen queries per KV head, head_dim 128: Nemotron-H's attention layers (32 +// query heads over 2 KV heads) at one and two ranks. Geometry only; r4d_attn_paged_gqa8.hip is the +// body. The ratio changes two bounds, both stated in the row table: +// +// decode verify width 128 / gqa = 8 (a workgroup of eight waves holds 128 (query, head) rows). +// prefill block width 384 / gqa = 24 query positions. +// +// The verify width is the drafter's: LiLiCorr proposes 7, so a verify is 8 query rows. At 64 +// rows (q_len <= 4) those rows ran the query-tiled prefill kernel while a plain decode runs this +// split-KV one, so no verify row was the single-row decode at its position, and greedy text with +// the drafter left the text without it at one and two ranks within a few hundred characters (gqa +// 8, four ranks, already verified here). A wave holds one query's 16 heads in both launches. +// +// No head_dim 256 leg (R4D_ATTN_H256 0): nothing in scope is gqa 16 at 256. Page size 16. +#define R4D_ATTN_GQA 16 +#define G8_MAX_DECODE_ROWS 128 +#define R4D_ATTN_H128 1 +#define R4D_ATTN_H256 0 + +#include "r4d_attn_paged_gqa8.hip" diff --git a/libr4d/r4d_attn_paged_window.hip b/libr4d/r4d_attn_paged_window.hip index 6e144ec5..990ae017 100644 --- a/libr4d/r4d_attn_paged_window.hip +++ b/libr4d/r4d_attn_paged_window.hip @@ -1,5 +1,6 @@ /* r4d_attn_paged_window.hip -- paged attention at head_dim 128, 256 and 512, 1/2/4/8 queries per - * KV head, any sliding window, causal or not, bf16 or fp8-e4m3 cache, q at any row pitch. + * KV head (16 at 512), any sliding window, causal or not, bf16 or fp8-e4m3 cache, q at any row + * pitch. * * head_dim 128 is Unlimited-OCR's decoder (10 query heads over 10 KV heads): the plain MHA case, * served here so its q slice of the fused q|k|v plane is read in place (attn_paged_qrow) instead @@ -7,8 +8,9 @@ * * Gemma 4's text layers: sliding layers are 16 query heads over 8 KV heads at head_dim 256 with a * 1024-token window (gqa 2 at every TP); full layers are 16 over 2 at head_dim 512 (gqa 8 at - * TP1/TP2, 4 at TP4, 2 at TP8). Where this overlaps the library's other h256 legs, the row table - * decides (r4d_rows.cpp). + * TP1/TP2, 4 at TP4, 2 at TP8). The 12B's full layers are 16 over 1 (gqa 16 at TP1; its one KV + * head is replicated at TP2/TP4, gqa 8/4). Where this overlaps the library's other h256 legs, the + * row table decides (r4d_rows.cpp). * * Two kernels behind one entry point: * - Scalar, for decode and verify: a workgroup owns one (sequence, KV head, slice of BQ query @@ -22,9 +24,14 @@ * pos = seqused[s] - q_len(s) + i (seqused INCLUDES this step's queries) * causal key j visible when j <= pos; non-causal when j < seqused[s] * window causal: pos - j < window; non-causal: |pos - j| < window; 0 = none + * ahead non-causal, window > 0: only pos - j < window, the keys after pos unbounded (FWD, below) * a block-table entry < 0 is a missing block: its keys are not visible * no visible key at all -> a zero row * k_descale / v_descale per (sequence, kv head), absent = 1 + * attn_paged_sink: `sinks` [query heads] f32, one logit a head in the scaled-score domain, in + * the softmax's maximum and denominator and with no value (LiLiCorr's drafter). Folded in where + * a row is normalised: the unsplit kernel's store and the merge. The WMMA kernel takes none, + * so a sink launch stays scalar. * * Paged layout: kv_cache[n_blocks, kv_heads, 16, 2*head_dim], K then V per slot, so one block of * one KV head is a contiguous run of 16 * 2 * head_dim elements; a key tile is one or two runs, @@ -191,9 +198,13 @@ struct AttnArgs { const float* vdes; uint16_t* out; long long o_rs, o_hs; float* part; /* split-KV partials, or null */ + const float* sinks; /* [query heads] or null */ int* tinfo; /* [tile] = (first row, positions) */ float qscale; /* softmax scale * log2(e) */ int max_blocks, n_seq, q_len, tps, kv_heads, causal, window, n_split; + int shared_window; /* all query rows use sequence anchor */ + /* 1: a non-causal window bounds the keys behind only (launch_attn's FWD) */ + int ahead; /* A tree verify (attn_paged_qrow_tree): RadBatch::spec_parent, one a query row; read only by * the TREE instances. */ const int* tpar; @@ -302,15 +313,16 @@ __device__ __forceinline__ void attn_body(AttnArgs A) { const int qbase = ctx - qlen + pfirst; /* absolute position of the tile's first query */ const int plast = qbase + npos - 1; const int causal = A.causal, window = A.window; + const int tbase = ctx - qlen; /* first query position, the block anchor */ + const int window_base = A.shared_window ? tbase : ((TREE && A.tpar) ? tbase : qbase); /* ---- the tile's key range, and this split's share of it */ - int hi = causal ? plast + 1 : ctx; - if (!causal && window > 0) hi = imin(hi, plast + window); + int hi = causal ? (A.shared_window ? tbase + 1 : plast + 1) : ctx; + if (!causal && window > 0 && !A.shared_window && !A.ahead) hi = imin(hi, plast + window); hi = imin(imin(hi, ctx), A.max_blocks * 16); /* A tree row's window is measured from the block's first position plus its depth, which can - * be below its own position, so a tree launch starts every tile at the block's first. */ - const int tbase = ctx - qlen; - const int lo = window > 0 ? imax(0, ((TREE && A.tpar) ? tbase : qbase) - window + 1) : 0; + * be below its own position; an anchor-window launch also uses the first row for every query. */ + const int lo = window > 0 ? imax(0, window_base - window + 1) : 0; const int lo_a = lo & ~(BK - 1); const int nkt = hi > lo_a ? (hi - lo_a + BK - 1) / BK : 0; const int per = (nkt + A.n_split - 1) / A.n_split; @@ -434,11 +446,14 @@ __device__ __forceinline__ void attn_body(AttnArgs A) { reduce_scatter<8, BK>(sc, lane); } const int pq = pos[i]; - bool vis = kok && (causal ? kk <= pq : true); + bool vis = kok && (causal ? kk <= (A.shared_window ? tbase : pq) : true); if constexpr (TREE) if (tr[i] && vis && kk >= tbase) vis = ((tm[i] >> (kk - tbase)) & 1ull) != 0; - const int wpq = TREE ? wq[i] : pq; - if (window > 0) vis = vis && (wpq - kk < window) && (causal || kk - wpq < window); + const int wpq = A.shared_window ? tbase : (TREE ? wq[i] : pq); + if (A.shared_window) + vis = vis && (wpq - kk < window); + else if (window > 0) + vis = vis && (wpq - kk < window) && (causal || A.ahead || kk - wpq < window); const float sv = vis ? sc[0] : -__builtin_inff(); const float mn = __builtin_fmaxf(m[i], wave_max(sv)); if (mn == -__builtin_inff()) return; /* nothing visible yet: uniform */ @@ -474,6 +489,21 @@ __device__ __forceinline__ void attn_body(AttnArgs A) { if (!val[i]) continue; const int r = wave * RW + i, p = r / GQA, g = r - p * GQA; if (A.n_split == 1) { + /* A sink joins the row's max and sum with no value (log2 domain, as m and l). */ + if (A.sinks && m[i] != -__builtin_inff()) { + const float s2 = A.sinks[kh * GQA + g] * 1.4426950408889634f; + if (s2 > m[i]) { + const float corr = ex2(m[i] - s2); +#pragma unroll + for (int c = 0; c < NC; ++c) +#pragma unroll + for (int e = 0; e < 4; ++e) o[i][c][e] *= corr; + l[i] = l[i] * corr + 1.0f; + m[i] = s2; + } else { + l[i] += ex2(s2 - m[i]); + } + } const float inv = l[i] > 0.0f ? vds / l[i] : 0.0f; uint16_t* op = A.out + (long long)(tok0 + p) * A.o_rs + (long long)(kh * GQA + g) * A.o_hs; #pragma unroll @@ -632,7 +662,7 @@ __global__ __launch_bounds__(kWThreads) void attn_wmma_kernel(AttnArgs A) { const int plast = qbase + npos - 1; const int causal = A.causal, window = A.window; int hi = causal ? plast + 1 : ctx; - if (!causal && window > 0) hi = imin(hi, plast + window); + if (!causal && window > 0 && !A.ahead) hi = imin(hi, plast + window); hi = imin(imin(hi, ctx), A.max_blocks * 16); const int lo = window > 0 ? imax(0, qbase - window + 1) : 0; const int lo_a = lo & ~15; @@ -823,7 +853,7 @@ __global__ __launch_bounds__(kWThreads) void attn_wmma_kernel(AttnArgs A) { const int kk = k0 + 8 * h + e; bool vis = rval && tok && kk >= lo && kk < hi; if (causal) vis = vis && kk <= pos; - if (window > 0) vis = vis && (pos - kk < window) && (causal || kk - pos < window); + if (window > 0) vis = vis && (pos - kk < window) && (causal || A.ahead || kk - pos < window); sv[e] = vis ? tot[e] * sscale : -__builtin_inff(); mx = __builtin_fmaxf(mx, sv[e]); } @@ -912,8 +942,11 @@ __device__ __forceinline__ void merge_body(AttnArgs A) { for (int c = 0; c < NC; ++c) *(uint2*)(op + c * 128 + lane * 4) = make_uint2(0u, 0u); continue; } - const float w0 = ex2(m0 - mt), w1 = ex2(m1 - mt); /* an empty split: ex2(-inf) = 0 */ - const float lt = wave_sum(__builtin_fmaf(l0, w0, l1 * w1)); + /* A sink joins the max and the sum with no value (log2 domain). */ + const float s2 = A.sinks ? A.sinks[kh * GQA + g] * 1.4426950408889634f : ninf; + const float ms = __builtin_fmaxf(mt, s2); + const float w0 = ex2(m0 - ms), w1 = ex2(m1 - ms); /* an empty split: ex2(-inf) = 0 */ + const float lt = wave_sum(__builtin_fmaf(l0, w0, l1 * w1)) + (A.sinks ? ex2(s2 - ms) : 0.0f); const float inv = lt > 0.0f ? 1.0f / lt : 0.0f; float acc[NC][4]; #pragma unroll @@ -1040,10 +1073,12 @@ __global__ __launch_bounds__(kThreads) void r4dchain_merge_window(AttnArgs A) { r4d_chain_done(); } -template -static int launch_attn(const RadArgs* a, RadStream stream) { +template +static int launch_attn(const RadArgs* a, RadStream stream, bool sink = false) { constexpr int R = Geo::R, BK = Geo::BK, BQ = R / GQA, ESZ = KV8 ? 1 : 2; - if (!a || a->n_t < (TREE ? 9 : 8)) return RAD_E_INVAL; + if (!a || a->n_t < (TREE || sink ? 9 : 8)) return RAD_E_INVAL; + /* attn_paged_sink keeps its output where the tree operand would be: never both. */ + if (TREE && sink) return RAD_E_INVAL; /* attn_paged_qrow_tree's ninth operand: one int32 a query row (docs/OPS.md). Causal only. */ const RadTensor* tp = TREE ? rad_arg_in(a, 8) : nullptr; if (TREE && (!tp || !tp->data)) return RAD_E_INVAL; @@ -1056,8 +1091,9 @@ static int launch_attn(const RadArgs* a, RadStream stream) { const RadTensor* kd = rad_arg_in(a, 4); const RadTensor* vd = rad_arg_in(a, 5); const RadTensor* cu = rad_arg_in(a, 6); - const RadTensor* o = rad_arg_in(a, 7); - if (!q || !kv || !bt || !su || !o) return RAD_E_INVAL; + const RadTensor* sk = sink ? rad_arg_in(a, 7) : nullptr; + const RadTensor* o = rad_arg_in(a, sink ? 8 : 7); + if (!q || !kv || !bt || !su || !o || (sink && !sk)) return RAD_E_INVAL; if (rad_args_geti_or(a, "head_dim", HD) != HD || rad_args_geti_or(a, "gqa", GQA) != GQA || rad_args_geti_or(a, "block_size", 16) != 16) @@ -1065,11 +1101,15 @@ static int launch_attn(const RadArgs* a, RadStream stream) { const long long causal = rad_args_geti_or(a, "causal", 1); const long long window = rad_args_geti_or(a, "window", 0); if ((causal != 0 && causal != 1) || window < 0 || window > (1ll << 30)) return RAD_E_SHAPE; + /* The open-ended window is a non-causal one: a causal row has nothing ahead, and without a + * window there is nothing to bound. */ + if (FWD && (causal != 0 || window == 0)) return RAD_E_SHAPE; if (q->dtype != RAD_BF16 || o->dtype != RAD_BF16) return RAD_E_DTYPE; if (kv->dtype != (uint32_t)(KV8 ? RAD_F8E4M3 : RAD_BF16)) return RAD_E_DTYPE; if (bt->dtype != RAD_I32 || su->dtype != RAD_I32 || (cu && cu->dtype != RAD_I32)) return RAD_E_DTYPE; if ((kd && kd->dtype != RAD_F32) || (vd && vd->dtype != RAD_F32)) return RAD_E_DTYPE; + if (sk && sk->dtype != RAD_F32) return RAD_E_DTYPE; /* the cache: [n_blocks, kv_heads, 16, 2 * head_dim], slots dense */ if (kv->rank != 4 || kv->shape[2] != 16 || kv->shape[3] != 2 * HD) return RAD_E_SHAPE; @@ -1077,6 +1117,7 @@ static int launch_attn(const RadArgs* a, RadStream stream) { const int64_t kvh = kv->shape[1]; if (kvh <= 0 || kvh > 65535) return RAD_E_SHAPE; const int64_t qh = kvh * GQA; + if (sk && rad_tensor_numel(sk) != qh) return RAD_E_SHAPE; int64_t rows = 0, q_rs = 0, q_hs = 0, orows = 0, o_rs = 0, o_hs = 0; if (!head_view(q, qh, HD, &rows, &q_rs, &q_hs) || !head_view(o, qh, HD, &orows, &o_rs, &o_hs)) @@ -1137,10 +1178,11 @@ static int launch_attn(const RadArgs* a, RadStream stream) { if (qmax_w <= 0 || qmax_w > rows) qmax_w = rows; } /* Never a tree: its verify blocks are decode-sized, and only the scalar kernel reads one. */ - const bool shaped = !TREE && qmax_w >= kWmmaMinQ && rows >= n_seq * (kWmmaMinQ / 2); + const bool shaped = !TREE && !SHARED && qmax_w >= kWmmaMinQ && + rows >= n_seq * (kWmmaMinQ / 2); const bool aligned = rad_ptr_aligned(q->data, 16) && rad_ptr_aligned(o->data, 16) && (q_rs | q_hs | o_rs | o_hs) % 8 == 0; - if (shaped && aligned) { + if (shaped && aligned && !sk) { constexpr int BQW = WGeo::R / GQA; int64_t ntw = 0, tpsw = 0; if (!cu) { @@ -1171,6 +1213,8 @@ static int launch_attn(const RadArgs* a, RadStream stream) { W.kv_heads = (int)kvh; W.causal = (int)causal; W.window = (int)window; + W.shared_window = SHARED; + W.ahead = FWD ? 1 : 0; W.n_split = 1; R4D_KLAUNCH(R4D_KNAME(attn_wmma_kernel), dim3((unsigned)ntw, (unsigned)kvh, 1u), dim3(kWThreads), (hipStream_t)stream, W); @@ -1204,6 +1248,7 @@ static int launch_attn(const RadArgs* a, RadStream stream) { A.vdes = vd ? (const float*)vd->data : nullptr; A.out = (uint16_t*)o->data; A.o_rs = o_rs; A.o_hs = o_hs; A.part = ns > 1 ? (float*)a->scratch : nullptr; + A.sinks = sk ? (const float*)sk->data : nullptr; A.tinfo = ns > 1 ? (int*)((char*)a->scratch + part_bytes()) : nullptr; const double scale = rad_args_getf_or(a, "scale", 1.0 / __builtin_sqrt((double)HD)); A.qscale = (float)(scale * 1.4426950408889634); @@ -1214,6 +1259,8 @@ static int launch_attn(const RadArgs* a, RadStream stream) { A.kv_heads = (int)kvh; A.causal = (int)causal; A.window = (int)window; + A.shared_window = SHARED; + A.ahead = FWD ? 1 : 0; A.n_split = (int)ns; A.tpar = TREE ? (const int*)tp->data : nullptr; @@ -1252,9 +1299,21 @@ extern "C" { } R4D_WIN_DEF(128, 1) R4D_WIN_DEF(256, 1) R4D_WIN_DEF(256, 2) R4D_WIN_DEF(256, 4) R4D_WIN_DEF(256, 8) -R4D_WIN_DEF(512, 1) R4D_WIN_DEF(512, 2) R4D_WIN_DEF(512, 4) R4D_WIN_DEF(512, 8) +R4D_WIN_DEF(512, 1) R4D_WIN_DEF(512, 2) R4D_WIN_DEF(512, 4) R4D_WIN_DEF(512, 8) R4D_WIN_DEF(512, 16) #undef R4D_WIN_DEF +/* attn_paged_ahead and attn_paged_qrow_ahead: a non-causal window that bounds the keys behind only + * (FWD), the sliding layers' mask over a picture's rows (docs/OPS.md). */ +#define R4D_WIN_AHEAD_DEF(HD, G) \ + int r4d_rad_attn_window_ahead_h##HD##_gqa##G##_bf16(const RadArgs* a, RadStream s) { \ + return r4d_win::launch_attn(a, s); \ + } \ + int r4d_rad_attn_window_ahead_h##HD##_gqa##G##_fp8(const RadArgs* a, RadStream s) { \ + return r4d_win::launch_attn(a, s); \ + } +R4D_WIN_AHEAD_DEF(256, 1) R4D_WIN_AHEAD_DEF(256, 2) R4D_WIN_AHEAD_DEF(256, 4) R4D_WIN_AHEAD_DEF(256, 8) +#undef R4D_WIN_AHEAD_DEF + /* attn_paged_qrow_tree: the scalar kernel with a tree verify's mask (TREE). */ #define R4D_WIN_TREE_DEF(HD, G) \ int r4d_rad_attn_window_tree_h##HD##_gqa##G##_bf16(const RadArgs* a, RadStream s) { \ @@ -1267,6 +1326,33 @@ R4D_WIN_TREE_DEF(256, 1) R4D_WIN_TREE_DEF(256, 2) R4D_WIN_TREE_DEF(256, 4) R4D_W R4D_WIN_TREE_DEF(512, 1) R4D_WIN_TREE_DEF(512, 2) R4D_WIN_TREE_DEF(512, 4) R4D_WIN_TREE_DEF(512, 8) #undef R4D_WIN_TREE_DEF +/* Exact DSpark mask: every query row uses the first query position as the sliding-window anchor. + * This is a distinct op name so a library without this semantic cannot silently resolve it. */ +#define R4D_WIN_ANCHOR_DEF(HD, G) \ + int r4d_rad_attn_anchor_window_h##HD##_gqa##G##_bf16kv(const RadArgs* a, RadStream s) { \ + return r4d_win::launch_attn(a, s); \ + } \ + int r4d_rad_attn_anchor_window_h##HD##_gqa##G##_fp8kv(const RadArgs* a, RadStream s) { \ + return r4d_win::launch_attn(a, s); \ + } +R4D_WIN_ANCHOR_DEF(128, 1) +R4D_WIN_ANCHOR_DEF(256, 1) R4D_WIN_ANCHOR_DEF(256, 2) R4D_WIN_ANCHOR_DEF(256, 4) R4D_WIN_ANCHOR_DEF(256, 8) +R4D_WIN_ANCHOR_DEF(512, 1) R4D_WIN_ANCHOR_DEF(512, 2) R4D_WIN_ANCHOR_DEF(512, 4) R4D_WIN_ANCHOR_DEF(512, 8) +#undef R4D_WIN_ANCHOR_DEF + +/* attn_paged_sink: LiLiCorr's drafter, 32 query heads over 2 KV heads at head_dim 128 (16 over 1 + * at TP 2: gqa 16 either way; 8 over its replicated head at TP 4: gqa 8), non-causal over its + * block, a 1024-token window. */ +#define R4D_WINSINK_DEF(HD, G) \ + int r4d_rad_attn_window_sink_h##HD##_gqa##G##_bf16(const RadArgs* a, RadStream s) { \ + return r4d_win::launch_attn(a, s, true); \ + } \ + int r4d_rad_attn_window_sink_h##HD##_gqa##G##_fp8(const RadArgs* a, RadStream s) { \ + return r4d_win::launch_attn(a, s, true); \ + } +R4D_WINSINK_DEF(128, 8) R4D_WINSINK_DEF(128, 16) +#undef R4D_WINSINK_DEF + /* Called at declare with no tensors. Partials are capped at kPartBudget (tile, head, split) * triples for any batch, so the size is a constant. */ int64_t r4d_rad_attn_window_h128_scratch(const RadArgs*) { return r4d_win::scratch_need<128>(); } diff --git a/libr4d/r4d_attn_prefill_split.h b/libr4d/r4d_attn_prefill_split.h index 02d44856..5728a07e 100644 --- a/libr4d/r4d_attn_prefill_split.h +++ b/libr4d/r4d_attn_prefill_split.h @@ -13,17 +13,30 @@ // Such launches split the KV and finish in the split-KV merge. #pragma once -// Workgroups the card runs at once: one a WGP. HIP's multiProcessorCount counts WGPs on RDNA (32 on -// the R9700, see want_wg in r4d_hc_bf16.hip); 32 if it cannot be read. -static inline int r4d_prefill_wgps() { - static const int v = [] { - int dev = 0; - hipDeviceProp_t pr{}; - if (hipGetDevice(&dev) != hipSuccess || hipGetDeviceProperties(&pr, dev) != hipSuccess) - return 32; - return pr.multiProcessorCount > 0 ? pr.multiProcessorCount : 32; - }(); - return v; +#include "rad_prefill_split.h" +#include + +// Workgroups the card runs at once: one a WGP. Kernel launches use RadArgs::wgp_count, the same +// per-rank property used by pass-key callbacks. Declaration-time scratch sizing has no Ctx yet, so +// cache that query per HIP device rather than once process-wide (TP ranks can bind unlike cards). +static inline int r4d_prefill_wgps(const RadArgs* a = nullptr) { + if (a && a->wgp_count > 0) return a->wgp_count; + int dev = 0; + if (hipGetDevice(&dev) != hipSuccess || dev < 0) return 32; + static std::atomic cached[64]{}; + if (dev < (int)(sizeof(cached) / sizeof(cached[0]))) { + const int old = cached[dev].load(std::memory_order_relaxed); + if (old > 0) return old; + } + hipDeviceProp_t pr{}; + if (hipGetDeviceProperties(&pr, dev) != hipSuccess) return 32; + const int count = pr.multiProcessorCount > 0 ? pr.multiProcessorCount : 32; + if (dev < (int)(sizeof(cached) / sizeof(cached[0]))) { + int expected = 0; + cached[dev].compare_exchange_strong(expected, count, std::memory_order_relaxed); + return cached[dev].load(std::memory_order_relaxed); + } + return count; } // The split law, at the launch's own geometry: `bq` query positions a workgroup, `tile` keys a KV @@ -36,34 +49,40 @@ static inline int r4d_prefill_wgps() { // rounds / S walks, so take one round (S1 = wgps / units) or two (S2 = 2 wgps / units), whichever // is faster, the smaller S on a tie (fewer partials). At 32 WGPs, gqa 6 with 2 KV heads: 53 rows // -> 16 splits, 80 -> 8, 345 -> 5, 576 -> 3, 1024 and up -> 1; gqa 12 with 1 KV head: up to 32 -// rows -> 32, 53 -> 16, 345 -> 5. Each split keeps at least 8 tiles of max_ctx, the only context -// the host sees. At most 64, the vectorised merge's limit. +// rows -> 32, 53 -> 16, 345 -> 5. Each split keeps at least 8 tiles of the launch's live KV +// (seqused_k, falling back to max_ctx). Using the model bound here over-splits short prefills: +// a 128-token chunk at max_ctx 2048 became 4 splits of ~32 keys, while a 977-token unsplit +// launch of the same prompt did not, and the different reduction order moved logits. At most 64, +// the vectorised merge's limit. static inline int r4d_prefill_splits_law(int bq, int tile, int q_len, int total_q, int num_seqs, int kv_heads, int max_ctx, int wgps) { - const long n = std::max(1, num_seqs); - const long qt = std::min(n * ((std::max(1, q_len) + bq - 1) / bq), - (std::max(1, total_q) + (long)(bq - 1) * n) / bq); - const long units = (long)std::max(1, kv_heads) * std::max(1L, qt); - if (units >= wgps) return 1; - const int s1 = (int)(wgps / units), s2 = (int)(2L * wgps / units); - int sp = s2 > 2 * s1 ? s2 : s1; - const int cap = ((max_ctx > 0 ? max_ctx : (1 << 30) - 1) + tile - 1) / tile / 8; - sp = std::min(sp, std::max(1, cap)); - return std::max(1, std::min(sp, 64)); + return rad_prefill_splits_law(bq, tile, q_len, total_q, num_seqs, kv_heads, max_ctx, wgps); } // The split count of this unit's last prefill launch, 1 unsplit: read by the unit's test hook, which // tells r4d_selftest a split launch from an unsplit one with the same bytes. Not atomic. static int g_prefill_last_splits = 0; +/* RadArgs::kv_used_max_h is the host maximum of the launch's seqused operand (Ctx::issue_body), + * -1 where it cannot be proven, which uses max_ctx below. In a recorded pass of a plugin with no + * pass-key callback (decode, verify, draft) it is the step's keyed context bound instead. Never + * synchronously copy device seqused from a HIP queue independent of the AQL upload queue. */ + /* The KV split's count before the scratch bound: the case's `splits` parameter when it names one * (r4d_selftest; the prefill rows declare no such axis, so the engine passes none), else the law, - * at most 64. */ + * at most 64. Use the runtime's host seqused maximum when exact for this launch; otherwise use the + * declared model bound. The launcher and recording callback share that same rule. */ static inline int r4d_prefill_splits_want(const RadArgs* a, const R4DArgs* r, int bq, int tile) { - const int sp = split_of(a); - if (sp > 0) return std::min(sp, 64); - return r4d_prefill_splits_law(bq, tile, r->q_len, r4d_q_total(*r), r->num_seqs, r->kv_heads, - r->max_ctx, r4d_prefill_wgps()); + const int sp0 = split_of(a); + if (sp0 > 0) return std::min(sp0, 64); + const int wgps = r4d_prefill_wgps(a); + const int qtot = r4d_q_total(*r); + const int used = a->kv_used_max_h; + if (used > 0) + return rad_prefill_splits_for_live(bq, tile, r->q_len, qtot, r->num_seqs, r->kv_heads, + r->max_ctx, used, wgps); + return r4d_prefill_splits_law(bq, tile, r->q_len, qtot, r->num_seqs, r->kv_heads, + r->max_ctx, wgps); } /* The launch's split count, 1 for the plain form: what r4d_prefill_splits_want asks, cut to the @@ -100,7 +119,7 @@ static inline int64_t r4d_prefill_scratch(const RadArgs* a, int head_dim, long l const int kv = (int)std::max(1LL, gqa > 0 ? n_head / gqa : n_head); const int band = (int)std::max(1LL, r4d_geti_or(a, "q_len", 1)); const int mctx = (int)r4d_geti_or(a, "max_ctx", 0); - const int w = r4d_prefill_wgps(); + const int w = r4d_prefill_wgps(a); const int64_t per_row = (int64_t)n_head * (head_dim + 2) * 4; int64_t worst = 0; for (long long n = 1; n <= max_seqs; ++n) diff --git a/libr4d/r4d_chain.h b/libr4d/r4d_chain.h index bf975352..074479c2 100644 --- a/libr4d/r4d_chain.h +++ b/libr4d/r4d_chain.h @@ -83,3 +83,18 @@ __device__ __forceinline__ void r4d_chain_done() { __hip_atomic_fetch_add(r->ctr, 1ull, __ATOMIC_RELEASE, __HIP_MEMORY_SCOPE_AGENT); } #endif /* __HIP__ */ + +/* The launchers given a chained form here take it only at steps of up to 32 token rows: above that + * the waiting blocks hold room a wide predecessor needs. Flash-Next on 2x R9700 at MTP depth 5 with + * the adaptive window, sampled: 32 against 64 rows 214/349/494/654/890 -> 218/355/494/662/893 tok/s + * at 1/2/4/8/16 streams. */ +constexpr long long kR4dChainMaxRows = 32; +inline bool r4d_chain_rows_ok(long long rows) { return rows <= kR4dChainMaxRows; } + +/* A launcher that takes no RadArgs reads its row's `chain` here; the plugin + * ABI entry sets it around the launch only, so a direct C call never chains. */ +inline thread_local bool g_r4d_chain_arg = false; +struct R4dChainArg { + explicit R4dChainArg(bool on) { g_r4d_chain_arg = on; } + ~R4dChainArg() { g_r4d_chain_arg = false; } +}; diff --git a/libr4d/r4d_dflash_markov_bf16.hip b/libr4d/r4d_dflash_markov_bf16.hip new file mode 100644 index 00000000..e6b5af6b --- /dev/null +++ b/libr4d/r4d_dflash_markov_bf16.hip @@ -0,0 +1,223 @@ +// Full-vocabulary DSpark Markov greedy walk. Unlike dflash_select's candidate-lattice walk, this +// operation applies the learned bigram bias to every draft-head logit and greedily selects +// the largest biased score. Separate entry points accept BF16 or F32 base logits. +#include +#include +#include "r4d_gdn_args.h" +#include "r4d_dflash_conv_body.h" // r4d_bf2f, r4d_u16 +#include "r4d_common.h" // r4d_wave_sum + +namespace { + +constexpr int kThreads = 256; +constexpr int kWave = 32; +constexpr int kWarps = kThreads / kWave; +constexpr int kCandidatesPerTile = 64; +constexpr int kCandidatesPerWarp = kCandidatesPerTile / kWarps; +constexpr int kMaxRank = 512; + +// The device computes element offsets in signed long; reject a row span that would overflow. +bool rows_fit(long long rows, long long pitch, long long width, int element_bytes) { + const long long limit = LLONG_MAX / element_bytes; + return rows > 0 && width > 0 && width <= limit && pitch >= width && + (rows == 1 || pitch <= (limit - (width - 1)) / (rows - 1)); +} + +// One CTA scans 64 vocabulary rows, eight at a time (one warp per row). The rank reduction is +// parallel across the warp and codebook loads remain contiguous. Each CTA writes its exact local +// argmax; a second kernel reduces those tile winners before the next dependent position starts. +template +__device__ float load_logit(Logit x); +template<> __device__ float load_logit(r4d_u16 x) { return r4d_bf2f(x); } +template<> __device__ float load_logit(float x) { return x; } + +template +__global__ __launch_bounds__(kThreads) void markov_score_tiles( + const Logit* __restrict__ logits, long logits_pitch, + const int* __restrict__ anchor, long anchor_stride, + const r4d_u16* __restrict__ pred, const r4d_u16* __restrict__ succ, + float* __restrict__ tile_scores, long scores_pitch, + int* __restrict__ tile_tokens, long tokens_pitch, + const int* __restrict__ out, long out_pitch, + int step, int steps, int rank, int vocab, int n_tiles) { + const int seq = blockIdx.y; + const int tile = blockIdx.x; + const int tid = threadIdx.x; + const int lane = tid & (kWave - 1); + const int warp = tid / kWave; + const int prev = step == 0 ? anchor[(long)seq * anchor_stride] + : out[(long)seq * out_pitch + step - 1]; + const bool prev_ok = prev >= 0 && prev < vocab; + + __shared__ float s_pred[kMaxRank]; + __shared__ float s_best[kWarps]; + __shared__ int s_token[kWarps]; + for (int r = tid; r < rank; r += kThreads) + s_pred[r] = prev_ok ? r4d_bf2f(pred[(long)prev * rank + r]) : 0.0f; + __syncthreads(); + + float warp_best = -INFINITY; + int warp_token = tile * kCandidatesPerTile + warp; +#pragma unroll + for (int j = 0; j < kCandidatesPerWarp; ++j) { + const int token = tile * kCandidatesPerTile + warp + j * kWarps; + if (token < vocab) { + float dot = 0.0f; +#pragma unroll 8 + for (int r = lane; r < rank; r += kWave) + dot += s_pred[r] * r4d_bf2f(succ[(long)token * rank + r]); + dot = r4d_wave_sum(dot); + if (lane == 0) { + const float score = load_logit(logits[(long)seq * steps * logits_pitch + + (long)step * logits_pitch + token]) + dot; + if (score > warp_best || (score == warp_best && token < warp_token)) { + warp_best = score; + warp_token = token; + } + } + } + } + if (lane == 0) { + s_best[warp] = warp_best; + s_token[warp] = warp_token; + } + __syncthreads(); + if (tid == 0) { + float best = -INFINITY; + int best_token = tile * kCandidatesPerTile; +#pragma unroll + for (int w = 0; w < kWarps; ++w) { + const float score = s_best[w]; + const int token = s_token[w]; + if (score > best || (score == best && token < best_token)) { + best = score; + best_token = token; + } + } + tile_scores[(long)seq * scores_pitch + tile] = best; + tile_tokens[(long)seq * tokens_pitch + tile] = best_token; + } +} + +__global__ __launch_bounds__(kThreads) void markov_reduce_tiles( + const float* __restrict__ tile_scores, long scores_pitch, + const int* __restrict__ tile_tokens, long tokens_pitch, + int* __restrict__ out, long out_pitch, int step, int n_tiles) { + const int seq = blockIdx.x; + const int tid = threadIdx.x; + __shared__ float s_best[kThreads]; + __shared__ int s_token[kThreads]; + + float best = -INFINITY; + int best_token = INT_MAX; + for (int tile = tid; tile < n_tiles; tile += kThreads) { + const float score = tile_scores[(long)seq * scores_pitch + tile]; + const int token = tile_tokens[(long)seq * tokens_pitch + tile]; + if (score > best || (score == best && token < best_token)) { + best = score; + best_token = token; + } + } + s_best[tid] = best; + s_token[tid] = best_token; + __syncthreads(); + for (int stride = kThreads / 2; stride > 0; stride >>= 1) { + if (tid < stride) { + const float score = s_best[tid + stride]; + const int token = s_token[tid + stride]; + if (score > s_best[tid] || (score == s_best[tid] && token < s_token[tid])) { + s_best[tid] = score; + s_token[tid] = token; + } + } + __syncthreads(); + } + if (tid == 0) out[(long)seq * out_pitch + step] = s_token[0]; +} + +template +int markov_emit(const Logit* logits, long logits_pitch, const int* anchor, long anchor_stride, + const r4d_u16* pred, const r4d_u16* succ, float* tile_scores, long scores_pitch, + int* tile_tokens, long tokens_pitch, int* out, long out_pitch, + int sequences, int steps, int rank, int vocab, + int n_tiles, RadStream stream) { + for (int step = 0; step < steps; ++step) { + hipLaunchKernelGGL((markov_score_tiles), dim3(n_tiles, sequences), dim3(kThreads), 0, + (hipStream_t)stream, logits, logits_pitch, anchor, anchor_stride, pred, + succ, tile_scores, scores_pitch, tile_tokens, tokens_pitch, out, out_pitch, + step, steps, rank, vocab, n_tiles); + hipLaunchKernelGGL(markov_reduce_tiles, dim3(sequences), dim3(kThreads), 0, + (hipStream_t)stream, tile_scores, scores_pitch, tile_tokens, tokens_pitch, + out, out_pitch, step, n_tiles); + } + return (int)hipGetLastError(); +} + +} // namespace + +template +static int markov_launch(const RadArgs* a, RadStream stream, uint32_t logits_dtype) { + constexpr int LOGITS = 0, ANCHOR = 1, PRED = 2, SUCC = 3; + constexpr int TILE_SCORE = 4, TILE_TOKEN = 5, OUT = 6; + const RadTensor* logits = r4d_opt(a, LOGITS); + const RadTensor* anchor = r4d_opt(a, ANCHOR); + const RadTensor* pred = r4d_opt(a, PRED); + const RadTensor* succ = r4d_opt(a, SUCC); + const RadTensor* scores = r4d_opt(a, TILE_SCORE); + const RadTensor* tokens = r4d_opt(a, TILE_TOKEN); + const RadTensor* out = r4d_opt(a, OUT); + if (!logits || !anchor || !pred || !succ || !scores || !tokens || !out) + return R4D_NO(RAD_E_INVAL); + + const long long steps = r4d_geti_or(a, "steps", 0); + const long long rank = r4d_geti_or(a, "rank", 0); + const long long vocab = r4d_geti_or(a, "n_vocab", 0); + const long long anchor_stride = r4d_geti_or(a, "anchor_stride", 1); + if (steps <= 0 || steps > INT_MAX || rank < kWave || rank > kMaxRank || rank % kWave || + vocab <= 0 || vocab > INT_MAX - kCandidatesPerTile || anchor_stride <= 0) + return R4D_NO(RAD_E_INVAL); + + if (out->dtype != RAD_I32 || out->rank != 2 || out->shape[1] < steps) + return R4D_NO(RAD_E_SHAPE); + const long long sequences = out->shape[0]; + const long long out_pitch = r4d_row_pitch(out); + const long long logits_pitch = r4d_row_pitch(logits); + // blockIdx.y is limited to 65535, and all kernel loop indices are int. + if (sequences <= 0 || sequences > 65535 || sequences > LLONG_MAX / steps || + (sequences - 1) > (LLONG_MAX - 1) / anchor_stride || + !rows_fit(sequences, out_pitch, steps, sizeof(int)) || logits->dtype != logits_dtype || + logits->rank != 2 || logits->shape[0] < sequences * steps || logits->shape[1] < vocab || + !rows_fit(sequences * steps, logits_pitch, vocab, sizeof(Logit))) + return R4D_NO(RAD_E_SHAPE); + + if (anchor->dtype != RAD_I32 || !r4d_contig(anchor) || + r4d_numel(anchor) < (sequences - 1) * anchor_stride + 1) + return R4D_NO(RAD_E_SHAPE); + if (pred->dtype != RAD_BF16 || succ->dtype != RAD_BF16 || !r4d_contig(pred) || + !r4d_contig(succ) || r4d_numel(pred) < vocab * rank || r4d_numel(succ) < vocab * rank) + return R4D_NO(RAD_E_SHAPE); + + const long long n_tiles = (vocab + kCandidatesPerTile - 1) / kCandidatesPerTile; + if (scores->dtype != RAD_F32 || tokens->dtype != RAD_I32 || scores->rank != 2 || + tokens->rank != 2 || scores->shape[0] < sequences || tokens->shape[0] < sequences || + scores->shape[1] < n_tiles || tokens->shape[1] < n_tiles || + !rows_fit(sequences, r4d_row_pitch(scores), n_tiles, sizeof(float)) || + !rows_fit(sequences, r4d_row_pitch(tokens), n_tiles, sizeof(int))) + return R4D_NO(RAD_E_SHAPE); + + return R4D_RAW(markov_emit((const Logit*)logits->data, (long)logits_pitch, + (const int*)anchor->data, (long)anchor_stride, + (const r4d_u16*)pred->data, (const r4d_u16*)succ->data, + (float*)scores->data, (long)r4d_row_pitch(scores), + (int*)tokens->data, (long)r4d_row_pitch(tokens), (int*)out->data, + (long)out_pitch, (int)sequences, (int)steps, (int)rank, + (int)vocab, (int)n_tiles, stream)); +} + +extern "C" int r4d_rad_dflash_markov_greedy(const RadArgs* a, RadStream stream) { + return markov_launch(a, stream, RAD_BF16); +} + +extern "C" int r4d_rad_dflash_markov_greedy_f32(const RadArgs* a, RadStream stream) { + return markov_launch(a, stream, RAD_F32); +} diff --git a/libr4d/r4d_encoder_bf16.hip b/libr4d/r4d_encoder_bf16.hip index b0fbd1f7..30a3eb81 100644 --- a/libr4d/r4d_encoder_bf16.hip +++ b/libr4d/r4d_encoder_bf16.hip @@ -28,6 +28,7 @@ __device__ __forceinline__ float act_of(float g) { if (ACT == 0) return g / (1.0f + expf(-g)); if (ACT == 1) return 0.5f * g * (1.0f + erff(g * 0.70710678118654752f)); if (ACT == 3) return 1.0f / (1.0f + expf(-g)); + if (ACT == 5) return fmaxf(g, 0.0f); if (ACT == 4) // quick_gelu: sigmoid of the bf16-rounded 1.702*g, as the unfused mul stores it return 1.0f / (1.0f + expf(-bf2f(f32_to_bf16(g * bf2f(f32_to_bf16(1.702f)))))); return 0.5f * g * (1.0f + tanhf(0.7978845608028654f * (g + 0.044715f * g * g * g))); @@ -354,6 +355,31 @@ __global__ __launch_bounds__(kThreads) void pool_cols_kernel( } } +// ---------------------------------------------------------------------------- point_fourier +// ref_point_fourier: row m of y is [x | sin(x_i f_j) | cos(x_i f_j)], f_j = 2^j (times pi), the +// sines then the cosines each i-major then j; f32 in and out. A thread an output column. +__global__ __launch_bounds__(kThreads) void point_fourier_kernel( + const float* __restrict__ x, float* __restrict__ y, uint32_t n, uint32_t F, uint32_t pi, + uint32_t x_ld, uint32_t y_ld, uint32_t M) { + const uint32_t w = n * (2 * F + 1); + const uint32_t c = blockIdx.x * kThreads + threadIdx.x; + if (c >= w) return; + for (uint32_t r = blockIdx.y; r < M; r += gridDim.y) { + float v; + if (c < n) { + v = x[(size_t)r * x_ld + c]; + } else { + const uint32_t k = c - n, half = n * F; + const uint32_t i = (k % half) / F, j = (k % half) % F; + const float f = pi ? (float)ldexp(3.14159265358979323846, (int)j) + : ldexpf(1.0f, (int)j); + const float t = x[(size_t)r * x_ld + i] * f; + v = k < half ? sinf(t) : cosf(t); + } + y[(size_t)r * y_ld + c] = v; + } +} + // ---------------------------------------------------------------------------- cast bf16 -> f32 __global__ __launch_bounds__(kThreads) void widen_kernel( const uint16_t* __restrict__ x, float* __restrict__ y, uint32_t n, uint32_t x_ld, @@ -757,11 +783,11 @@ __global__ __launch_bounds__(kLrThreads) void attn_local_rel_kernel( // ============================================================== launchers -// act: 0 silu, 1 gelu (erf), 2 gelu_tanh, 3 sigmoid, 4 quick_gelu (sigmoid(bf16(1.702*a))). +// act: 0 silu, 1 gelu (erf), 2 gelu_tanh, 3 sigmoid, 4 quick_gelu (sigmoid(bf16(1.702*a))), 5 relu. extern "C" int r4d_act_mul_bf16(long a, long b, long y, int M, int n, int act, int a_ld, int b_ld, int y_ld, long stream) { if (!a || !b || !y) return -1; - if (M <= 0 || n <= 0 || act < 0 || act > 4) return -2; + if (M <= 0 || n <= 0 || act < 0 || act > 5) return -2; const dim3 grid((uint32_t)((n + kThreads - 1) / kThreads), grid_rows(M)); #define R4D_AM(A) \ hipLaunchKernelGGL(act_mul_kernel, grid, dim3(kThreads), 0, (hipStream_t)stream, \ @@ -771,7 +797,8 @@ extern "C" int r4d_act_mul_bf16(long a, long b, long y, int M, int n, int act, i else if (act == 1) R4D_AM(1); else if (act == 2) R4D_AM(2); else if (act == 3) R4D_AM(3); - else R4D_AM(4); + else if (act == 4) R4D_AM(4); + else R4D_AM(5); #undef R4D_AM return hipGetLastError() == hipSuccess ? 0 : -4; } @@ -923,6 +950,19 @@ extern "C" int r4d_pool_cols_bf16(long x, long y, int rows, int n, int k, float return hipGetLastError() == hipSuccess ? 0 : -4; } +extern "C" int r4d_point_fourier_f32(long x, long y, int rows, int n, int freqs, int pi, + int x_ld, int y_ld, long stream) { + if (!x || !y) return -1; + if (rows <= 0 || n <= 0 || freqs <= 0 || freqs > 30) return -2; + const uint32_t w = (uint32_t)(n * (2 * freqs + 1)); + hipLaunchKernelGGL(point_fourier_kernel, + dim3((w + kThreads - 1) / kThreads, grid_rows(rows)), + dim3(kThreads), 0, (hipStream_t)stream, (const float*)x, (float*)y, + (uint32_t)n, (uint32_t)freqs, (uint32_t)(pi != 0), (uint32_t)x_ld, + (uint32_t)y_ld, (uint32_t)rows); + return hipGetLastError() == hipSuccess ? 0 : -4; +} + extern "C" int r4d_widen_bf16_f32(long x, long y, int M, int n, int x_ld, int y_ld, long stream) { if (!x || !y) return -1; if (M <= 0 || n <= 0) return -2; @@ -1100,6 +1140,7 @@ extern "C" int r4d_rad_act_mul(const RadArgs* a, RadStream s) { else if (act && !std::strcmp(act, "gelu_tanh")) ai = 2; else if (act && !std::strcmp(act, "sigmoid")) ai = 3; else if (act && !std::strcmp(act, "quick_gelu")) ai = 4; + else if (act && !std::strcmp(act, "relu")) ai = 5; if (ai < 0) return R4D_NO(RAD_E_INVAL); const long long n = r4d_geti_or(a, "n", r4d_dim(Y, (int)Y->rank - 1)); if (n <= 0) return R4D_NO(RAD_E_SHAPE); @@ -1312,6 +1353,24 @@ extern "C" int r4d_rad_pool_cols(const RadArgs* a, RadStream s) { (long)(uintptr_t)s)); } +/* ------------------------------------------------------------------ point_fourier */ +extern "C" int r4d_rad_point_fourier(const RadArgs* a, RadStream s) { + const RadTensor* X = r4d_opt(a, 0); + const RadTensor* Y = r4d_opt(a, 1); + if (!X || !Y) return R4D_NO(RAD_E_INVAL); + if (X->dtype != RAD_F32 || Y->dtype != RAD_F32) return R4D_NO(RAD_E_DTYPE); + const long long n = r4d_geti_or(a, "n", 0), F = r4d_geti_or(a, "freqs", 0); + if (n <= 0 || F <= 0 || F > 30) return R4D_NO(RAD_E_SHAPE); + long long M = 0, My = 0; + const long long x_ld = r4d_rows_pitch(X, n, &M); + const long long y_ld = r4d_rows_pitch(Y, n * (2 * F + 1), &My); + if (x_ld < 0 || y_ld < 0) return R4D_NO(RAD_E_STRIDE); + if (M <= 0 || My < M) return R4D_NO(RAD_E_SHAPE); + return enc_status(r4d_point_fourier_f32(r4d_addr(X), r4d_addr(Y), (int)M, (int)n, (int)F, + (int)r4d_geti_or(a, "pi", 0), (int)x_ld, (int)y_ld, + (long)(uintptr_t)s)); +} + /* ------------------------------------------------------------------ cast bf16 -> f32 */ extern "C" int r4d_rad_cast_widen(const RadArgs* a, RadStream s) { const RadTensor* x = r4d_opt(a, 0); diff --git a/libr4d/r4d_fuse.cpp b/libr4d/r4d_fuse.cpp index 43a905a2..7ead3168 100644 --- a/libr4d/r4d_fuse.cpp +++ b/libr4d/r4d_fuse.cpp @@ -594,6 +594,46 @@ extern "C" int r4d_fuse_gemm_nt_q_gated_mx(const RadParam* p, int n_p, uint64_t } } +/* ========================================================================================== + * gemm_nt_q_gated at i8a8h -- the same fold over an IQR gate_up weight (r4d_iqr.h) under the + * rotated int8 trunk. (row: gemm_iqr_gated, M <= 16; kernel: libr4d/r4d_gemm_iqr.hip, the gated + * forms of its GEMV and 16-token tile, each byte-identical to the GEMM row gemm_iqr_nt_m64 serves + * at that M followed by gated_had_quant_i8g.) + * + * Operands: [0] a [1] a_scale [2] b [3] b_scale [4] q [5] scale [6] out_bf16 + * + * As gemm_nt_q_gated's chain, with `dtype` i8a8h on the GEMM and the rotated int8 quantiser. + */ +extern "C" int r4d_fuse_gemm_nt_q_gated_iqr(const RadParam* p, int n_p, uint64_t present, int step, + RadFuseStep* out) { + (void)present; + if (!out) return RAD_E_INVAL; + const int64_t M = pi(p, n_p, "M"), N = pi(p, n_p, "N"), K = pi(p, n_p, "K"); + const char* dt = r4d_pgets(p, n_p, "dtype"); + if (M <= 0 || N <= 0 || K <= 0 || N % 2) return RAD_E_UNSUPPORTED; + if (pi(p, n_p, "group", R4D_FP8_BLOCK) != R4D_FP8_BLOCK) return RAD_E_UNSUPPORTED; + if (!dt || std::strcmp(dt, "i8a8h")) return RAD_E_UNSUPPORTED; + if (!act_is(p, n_p, "silu", "silu")) return RAD_E_UNSUPPORTED; + + switch (step) { + case 0: { + Step s(out, "gemm_nt_q"); + s.mirror(p, n_p, "M").mirror(p, n_p, "N").mirror(p, n_p, "K") + .mirror(p, n_p, "group").mirror(p, n_p, "dtype"); + /* a, a_scale, b, b_scale, y, a_sum, b_ref */ + return s.wire({ 0, 1, 2, 3, RAD_FUSE_TMP(0), RAD_FUSE_NONE, RAD_FUSE_NONE }); + } + case 1: { + Step s(out, "gated_had_quant_i8g"); + s.mirror(p, n_p, "M").pint("n", (long long)(N / 2)).mirror(p, n_p, "group") + .pstr("dtype", "bf16").mirror(p, n_p, "act"); + return s.wire({ RAD_FUSE_TMP(0), 4, 5, 6 }); /* gate_up, q, scale, out_bf16 */ + } + default: + return RAD_E_NOTFOUND; + } +} + /* ========================================================================================== * gdn_conv_recurrent_update -- the decode convolution folded into the recurrent update's prologue. * (row: gdn_conv_recurrent_update_k128_v128_bf16; kernel: libr4d/ diff --git a/libr4d/r4d_fused_quant_fp8.hip b/libr4d/r4d_fused_quant_fp8.hip index 0fde9e8f..be11f9a5 100644 --- a/libr4d/r4d_fused_quant_fp8.hip +++ b/libr4d/r4d_fused_quant_fp8.hip @@ -36,6 +36,7 @@ #include "r4d_ar_seq.h" // the all-reduce sequence step the fused all-reduce + norm takes #include "r4d_fp8_args.h" #include "r4d_emit.h" +#include "r4d_chain.h" #include "r4d_common.h" // r4d_act_threads: the workgroup width, shared with the int8 path #include "r4d_fwht.h" // the in-register rotation the `_had_` forms put before the absmax #include "r4d_q8.h" // the 8-bit codes: E4M3, or int8 for an int8 trunk linear @@ -215,7 +216,7 @@ __global__ __launch_bounds__(THR) void rmsnorm_quant_fp8_kernel( // The launcher sizes the workgroup to the row's groups (capped at r4d_act_threads' width) and the // kernel reads the width from blockDim, so a narrow row does not leave most waves idle. template -__global__ __launch_bounds__(1024) void gated_quant_fp8_kernel( +__device__ __forceinline__ void gated_quant_fp8_kernel_body( const uint16_t* __restrict__ gu, uint16_t* __restrict__ y, uint8_t* __restrict__ q, float* __restrict__ s, uint32_t n, uint32_t nkb, uint32_t gu_ld, uint32_t y_ld, uint32_t q_ld, uint32_t s_ld) { @@ -251,6 +252,24 @@ __global__ __launch_bounds__(1024) void gated_quant_fp8_kernel( } } +/* The plain and chained forms (r4d_chain.h): every block leaves through the wrapper. */ +template +__global__ __launch_bounds__(1024) void gated_quant_fp8_kernel( + const uint16_t* __restrict__ gu, uint16_t* __restrict__ y, uint8_t* __restrict__ q, + float* __restrict__ s, uint32_t n, uint32_t nkb, uint32_t gu_ld, uint32_t y_ld, + uint32_t q_ld, uint32_t s_ld) { + gated_quant_fp8_kernel_body(gu, y, q, s, n, nkb, gu_ld, y_ld, q_ld, s_ld); +} +template +__global__ __launch_bounds__(1024) void r4dchain_gated_quant_fp8( + const uint16_t* __restrict__ gu, uint16_t* __restrict__ y, uint8_t* __restrict__ q, + float* __restrict__ s, uint32_t n, uint32_t nkb, uint32_t gu_ld, uint32_t y_ld, + uint32_t q_ld, uint32_t s_ld) { + r4d_chain_wait(); + gated_quant_fp8_kernel_body(gu, y, q, s, n, nkb, gu_ld, y_ld, q_ld, s_ld); + r4d_chain_done(); +} + // -------------------------------------------------- gate . x -> quant, two source buffers // // The same epilogue with the gate in a separate buffer. For gated attention, `x` is the attention @@ -262,8 +281,12 @@ __global__ __launch_bounds__(1024) void gated_quant_fp8_kernel( // // ACT 2 is the product with no activation: the unfused pair is `mul` then the quantiser, so the // gate is not rounded on its own and the product is rounded once, as mul_bf16 does. -template -__global__ __launch_bounds__(1024) void gate_quant_fp8_kernel( +// +// ROT (with I8: gate_had_quant_i8g) puts the width-128 Hadamard between the bf16-rounded product +// and the absmax, as gated_quant_fp8_kernel's ROT, for an out projection stored rotated: the codes +// are had_quant_act_i8g's over `y`. +template +__device__ __forceinline__ void gate_quant_fp8_kernel_body( const uint16_t* __restrict__ g, const uint16_t* __restrict__ x, uint16_t* __restrict__ y, uint8_t* __restrict__ q, float* __restrict__ s, uint32_t n, uint32_t nkb, uint32_t g_ld, uint32_t x_ld, uint32_t y_ld, uint32_t q_ld, uint32_t s_ld) { @@ -303,10 +326,30 @@ __global__ __launch_bounds__(1024) void gate_quant_fp8_kernel( v[j] = bf2f(h); } } + // The rotated launcher requires n % 128 == 0, so no rotated group contains padding. + if constexpr (ROT) r4d_fwht_wave<(int)kGroup>(v, (int)lane); quant_group(v, s, qr, (size_t)row * s_ld + kb, c0, n, lane); } } +/* The plain and chained forms (r4d_chain.h): every block leaves through the wrapper. */ +template +__global__ __launch_bounds__(1024) void gate_quant_fp8_kernel( + const uint16_t* __restrict__ g, const uint16_t* __restrict__ x, uint16_t* __restrict__ y, + uint8_t* __restrict__ q, float* __restrict__ s, uint32_t n, uint32_t nkb, uint32_t g_ld, + uint32_t x_ld, uint32_t y_ld, uint32_t q_ld, uint32_t s_ld) { + gate_quant_fp8_kernel_body(g, x, y, q, s, n, nkb, g_ld, x_ld, y_ld, q_ld, s_ld); +} +template +__global__ __launch_bounds__(1024) void r4dchain_gate_quant_fp8( + const uint16_t* __restrict__ g, const uint16_t* __restrict__ x, uint16_t* __restrict__ y, + uint8_t* __restrict__ q, float* __restrict__ s, uint32_t n, uint32_t nkb, uint32_t g_ld, + uint32_t x_ld, uint32_t y_ld, uint32_t q_ld, uint32_t s_ld) { + r4d_chain_wait(); + gate_quant_fp8_kernel_body(g, x, y, q, s, n, nkb, g_ld, x_ld, y_ld, q_ld, s_ld); + r4d_chain_done(); +} + // -------------------------------------------------------- all-reduce -> rmsnorm -> quant // // The same norm with the tensor-parallel all-reduce that always precedes it folded in (o_proj, @@ -802,7 +845,7 @@ extern "C" int r4d_rmsnorm_had_quant_i8g(long x, long res, long w, long y, long // projection; `rot` alone pairs with a rotated four-bit expert, which reads E4M3. static int gated_quant_fp8_launch(long gu, long y, long q, long s, int M, int n, int mode, int gu_ld, int y_ld, int q_ld, int s_ld, RadStream stream, - bool rot, bool i8 = false) { + bool rot, bool i8 = false, bool chain = false) { int emit_rc = RAD_OK; if (!gu || !q || !s) return -1; if (M <= 0 || n <= 0) return -2; @@ -818,7 +861,8 @@ static int gated_quant_fp8_launch(long gu, long y, long q, long s, int M, int n, // there is no cross-row reduction and the rotation is wave-local (r4d_fwht.h). const int thr = std::min(nkb, r4d_act_threads(M, n) / (int)kWave) * (int)kWave; #define R4D_GQ_R(a, R, I) \ - emit_rc = R4D_EMIT(stream, (gated_quant_fp8_kernel), dim3((uint32_t)M), dim3(thr), \ + emit_rc = R4D_EMIT(stream, (chain ? &r4dchain_gated_quant_fp8 \ + : &gated_quant_fp8_kernel), dim3((uint32_t)M), dim3(thr), \ 0, (const uint16_t*)gu, (uint16_t*)y, (uint8_t*)q, \ (float*)s, (uint32_t)n, (uint32_t)nkb, (uint32_t)gu_ld, (uint32_t)y_ld, \ (uint32_t)q_ld, (uint32_t)s_ld) @@ -866,11 +910,12 @@ extern "C" int r4d_gated_had_quant_i8g(long gu, long y, long q, long s, int M, i // s [M][ceil(n/128)] f32, `s_ld` elements a row (0 = ceil(n/128)) static int gate_quant_fp8_emit(long g, long x, long y, long q, long s, int M, int n, int mode, int g_ld, int x_ld, int y_ld, int q_ld, int s_ld, - RadStream stream, bool i8 = false) { + RadStream stream, bool i8 = false, bool rot = false) { int emit_rc = RAD_OK; if (!g || !x || !q || !s) return -1; if (M <= 0 || n <= 0) return -2; if (n % 4) return -3; + if (rot && (!i8 || n % (int)kGroup)) return -3; if (mode < 0 || mode > 2) return -5; if (!g_ld) g_ld = n; if (!x_ld) x_ld = n; @@ -881,7 +926,15 @@ static int gate_quant_fp8_emit(long g, long x, long y, long q, long s, int M, in // A wave a group, capped at r4d_act_threads' width, as gated_quant_fp8 above. const int thr = std::min(nkb, r4d_act_threads(M, n) / (int)kWave) * (int)kWave; #define R4D_GTQ_I(a, I) \ - emit_rc = R4D_EMIT(stream, (gate_quant_fp8_kernel), dim3((uint32_t)M), dim3(thr), 0, \ + emit_rc = rot ? R4D_EMIT(stream, (g_r4d_chain_arg ? &r4dchain_gate_quant_fp8 \ + : &gate_quant_fp8_kernel), \ + dim3((uint32_t)M), dim3(thr), 0, (const uint16_t*)g, \ + (const uint16_t*)x, (uint16_t*)y, (uint8_t*)q, (float*)s, \ + (uint32_t)n, (uint32_t)nkb, (uint32_t)g_ld, (uint32_t)x_ld, \ + (uint32_t)y_ld, (uint32_t)q_ld, (uint32_t)s_ld) \ + : R4D_EMIT(stream, (g_r4d_chain_arg ? &r4dchain_gate_quant_fp8 \ + : &gate_quant_fp8_kernel), dim3((uint32_t)M), \ + dim3(thr), 0, \ (const uint16_t*)g, (const uint16_t*)x, \ (uint16_t*)y, (uint8_t*)q, (float*)s, (uint32_t)n, (uint32_t)nkb, \ (uint32_t)g_ld, (uint32_t)x_ld, (uint32_t)y_ld, (uint32_t)q_ld, \ @@ -1113,7 +1166,9 @@ static int rad_gated_quant_fp8(const RadArgs* a, RadStream stream, bool rot, boo if (mode < 0) return R4D_NO(RAD_E_UNSUPPORTED); const int e = gated_quant_fp8_launch(r4d_addr(gu), y ? r4d_addr(y) : 0, r4d_addr(q), r4d_addr(sc), (int)M, (int)K, mode, (int)gp, (int)yp, - (int)qp, (int)sp, stream, rot, q->dtype == RAD_I8); + (int)qp, (int)sp, stream, rot, q->dtype == RAD_I8, + /* decode heights: its rows are tokens or routed slots */ + r4d_geti_or(a, "chain", 0) != 0 && M <= 1024); return e == 0 ? RAD_OK : RAD_E_SHAPE; } @@ -1152,7 +1207,7 @@ static long long tq_pitch(const RadTensor* t, long long width) { /* Two-operand form of gated_quant_fp8 for gated attention: `x` is the attention output and the * gate a column view of the [q|gate] projection. The gate offset comes from the view, so there is * no `gate_offset` parameter. */ -extern "C" int r4d_rad_gate_quant_fp8(const RadArgs* a, RadStream stream) { +static int rad_gate_quant(const RadArgs* a, RadStream stream, bool rot) { const RadTensor* g = r4d_opt(a, TQ_G); const RadTensor* x = r4d_opt(a, TQ_X); const RadTensor* q = r4d_opt(a, TQ_Q); @@ -1160,6 +1215,7 @@ extern "C" int r4d_rad_gate_quant_fp8(const RadArgs* a, RadStream stream) { const RadTensor* y = r4d_opt(a, TQ_Y); if (!g || !x || !q || !sc) return R4D_NO(RAD_E_INVAL); if (q->dtype != RAD_F8E4M3 && q->dtype != RAD_I8) return R4D_NO(RAD_E_DTYPE); + if (rot && q->dtype != RAD_I8) return R4D_NO(RAD_E_DTYPE); /* M is numel(x) / n. The `M` parameter is the band's declared maximum, not this issue's, and * shape[0] counts tokens while a row here is a (token, head) pair. */ const long long K = r4d_geti_or(a, "n", 0); @@ -1178,10 +1234,20 @@ extern "C" int r4d_rad_gate_quant_fp8(const RadArgs* a, RadStream stream) { if (gp < 0 || xp < 0 || qp < 0 || sp < 0 || yp < 0) return R4D_NO(RAD_E_STRIDE); const int mode = act_mode(a, 1); /* sigmoid: gated attention */ if (mode < 0) return R4D_NO(RAD_E_UNSUPPORTED); + const R4dChainArg chain_arg(r4d_geti_or(a, "chain", 0) != 0 && M <= 1024); const int e = gate_quant_fp8_emit(r4d_addr(g), r4d_addr(x), y ? r4d_addr(y) : 0, r4d_addr(q), r4d_addr(sc), (int)M, (int)K, mode, (int)gp, (int)xp, (int)yp, (int)qp, (int)sp, stream, - q->dtype == RAD_I8); + q->dtype == RAD_I8, rot); return e == 0 ? RAD_OK : RAD_E_SHAPE; } +extern "C" int r4d_rad_gate_quant_fp8(const RadArgs* a, RadStream stream) { + return rad_gate_quant(a, stream, false); +} + +/* gate_quant_fp8 at had_quant_act_i8g's codes, for an out projection stored rotated (i8a8h). */ +extern "C" int r4d_rad_gate_had_quant_i8g(const RadArgs* a, RadStream stream) { + return rad_gate_quant(a, stream, true); +} + diff --git a/libr4d/r4d_gdn_recurrent_update_k128_v128_bf16_fp32state.hip b/libr4d/r4d_gdn_recurrent_update_k128_v128_bf16_fp32state.hip index dec073a0..44e5e141 100644 --- a/libr4d/r4d_gdn_recurrent_update_k128_v128_bf16_fp32state.hip +++ b/libr4d/r4d_gdn_recurrent_update_k128_v128_bf16_fp32state.hip @@ -32,7 +32,9 @@ #include "r4d_gdn_wmma.h" #include "r4d_common.h" #include "r4d_gdn_conv_tap.h" +#include "r4d_chain.h" #include "r4d_q8.h" // the 8-bit codes the folded quantiser writes: E4M3 or int8 +#include "r4d_fwht.h" // NORM 3: had_quant_act_i8g's rotation before the int8 codes #include #include #include @@ -217,8 +219,7 @@ __device__ __forceinline__ void ru_conv_rewrite(unsigned short* sp, const unsign template -__global__ __launch_bounds__(RU_V / VS * 2) -void r4d_gdn_recurrent_update_kernel(const unsigned short* __restrict__ q, +__device__ __forceinline__ void r4d_gdn_recurrent_update_kernel_body(const unsigned short* __restrict__ q, const unsigned short* __restrict__ k, const unsigned short* __restrict__ v, const void* __restrict__ av, @@ -238,13 +239,13 @@ void r4d_gdn_recurrent_update_kernel(const unsigned short* __restrict__ q, long zg_pitch, const float* __restrict__ nw, float neps, int nact, int H, int Hg, float scale, float sp_thr, - const RuConv cv) -{ + const RuConv cv) { using ST = typename ru_state::T; constexpr int NR = RU_V / VS; // v rows this workgroup owns constexpr int THR = NR * 2; static_assert(!(NORM && VS > 1), "the fused row norm needs the whole 128-wide row"); __shared__ float wsum[THR / 32]; + __shared__ float srot[NORM == 3 ? RU_V : 1]; // NORM 3: the row's bf16 output, for the rotation __shared__ float spart[STG ? RU_TMAX * 4 : 1]; // per (token, half): sum q^2, sum k^2 __shared__ float sscl [STG ? RU_TMAX * 2 : 1]; // per token: the two closed scales const int n = blockIdx.x, hv = blockIdx.y; @@ -642,7 +643,32 @@ void r4d_gdn_recurrent_update_kernel(const unsigned short* __restrict__ q, // `on`, with r4d_fused_quant_fp8.hip's quant_group arithmetic (including the clamp that keeps // the group maximum from becoming NaN). NORM == 2 writes int8 codes instead (quant_act_i8g: // scale amax / 127, round to nearest-even). - if (NORM && oq) { + // NORM == 3 writes had_quant_act_i8g's codes: the row's 128 stored bf16 values through + // r4d_fwht_wave<128> in one wave (a lane four consecutive channels, that function's mapping), + // then its amax / 127 scale and round-to-nearest-even, so the bytes are that quantiser's over + // `o`. + if (NORM == 3 && oq) { + if (half == 0) srot[row] = bf2f(ob); + __syncthreads(); + if (tid < 32) { + float rv[4]; +#pragma unroll + for (int j = 0; j < 4; ++j) rv[j] = srot[4 * tid + j]; + r4d_fwht_wave<128>(rv, tid); + float m = fmaxf(fmaxf(fabsf(rv[0]), fabsf(rv[1])), fmaxf(fabsf(rv[2]), fabsf(rv[3]))); + m = r4d_wave_max(m); + const float qs = m > 0.0f ? m * (1.0f / 127.0f) : 1.0f; + if (tid == 0) os[(size_t)tok * os_ld + hv] = qs; + const float inv = 1.0f / qs; + uint32_t pk = 0; +#pragma unroll + for (int j = 0; j < 4; ++j) + pk |= ((uint32_t)(int)rintf(fminf(fmaxf(rv[j] * inv, -127.0f), 127.0f)) & 0xFFu) << (8 * j); + *(uint32_t*)(oq + (size_t)tok * oq_pitch + (size_t)hv * RU_V + 4 * tid) = pk; + } + __syncthreads(); // srot is reused by the next token + } + if ((NORM == 1 || NORM == 2) && oq) { const float ov = bf2f(ob); float mv = (half == 0) ? fabsf(ov) : 0.0f; mv = fmaxf(mv, r4d_xor_lane<16>(mv)); mv = fmaxf(mv, r4d_xor_lane<8>(mv)); @@ -705,6 +731,62 @@ void r4d_gdn_recurrent_update_kernel(const unsigned short* __restrict__ q, } } +/* The plain and chained forms (r4d_chain.h): every block leaves through the wrapper. */ +template +__global__ __launch_bounds__(RU_V / VS * 2) +void r4d_gdn_recurrent_update_kernel(const unsigned short* __restrict__ q, + const unsigned short* __restrict__ k, + const unsigned short* __restrict__ v, + const void* __restrict__ av, + const void* __restrict__ bv, long ab_stride, + const float* __restrict__ A_log, + const float* __restrict__ dt_bias, + typename ru_state::T* __restrict__ state, + long st_slot, long st_head, + unsigned short* __restrict__ o, + unsigned char* __restrict__ oq, + float* __restrict__ os, long oq_pitch, + long os_ld, + const int* __restrict__ cu, + const int* __restrict__ sidx, long sidx_stride, + const int* __restrict__ naccept, + const unsigned short* __restrict__ zg, + long zg_pitch, + const float* __restrict__ nw, float neps, int nact, + int H, int Hg, float scale, float sp_thr, + const RuConv cv) { + r4d_gdn_recurrent_update_kernel_body(q, k, v, av, bv, ab_stride, A_log, dt_bias, state, st_slot, st_head, o, oq, os, oq_pitch, os_ld, cu, sidx, sidx_stride, naccept, zg, zg_pitch, nw, neps, nact, H, Hg, scale, sp_thr, cv); +} +template +__global__ __launch_bounds__(RU_V / VS * 2) +void r4dchain_gdn_recurrent_update(const unsigned short* __restrict__ q, + const unsigned short* __restrict__ k, + const unsigned short* __restrict__ v, + const void* __restrict__ av, + const void* __restrict__ bv, long ab_stride, + const float* __restrict__ A_log, + const float* __restrict__ dt_bias, + typename ru_state::T* __restrict__ state, + long st_slot, long st_head, + unsigned short* __restrict__ o, + unsigned char* __restrict__ oq, + float* __restrict__ os, long oq_pitch, + long os_ld, + const int* __restrict__ cu, + const int* __restrict__ sidx, long sidx_stride, + const int* __restrict__ naccept, + const unsigned short* __restrict__ zg, + long zg_pitch, + const float* __restrict__ nw, float neps, int nact, + int H, int Hg, float scale, float sp_thr, + const RuConv cv) { + r4d_chain_wait(); + r4d_gdn_recurrent_update_kernel_body(q, k, v, av, bv, ab_stride, A_log, dt_bias, state, st_slot, st_head, o, oq, os, oq_pitch, os_ld, cu, sidx, sidx_stride, naccept, zg, zg_pitch, nw, neps, nact, H, Hg, scale, sp_thr, cv); + r4d_chain_done(); +} + // Non-temporal hint on the state load and store (TH_LOAD_NT / TH_STORE_NT): no result changes; // chosen per launch because its cost and saving land in different kernels. In isolation it makes // this kernel 43.8% slower (DRAM-write bound), but no state survives the 64 MB last-level cache @@ -736,6 +818,14 @@ static bool ru_anchor() { #define RU_NT_MB 16 // `oq_i8` picks the folded quantiser's codes: E4M3 (0) or int8 (1); see the kernel's epilogue. +/* The chained form (r4d_chain.h) for this thread's launch: set by the plugin ABI entries below from + * the row's `chain`, around their launch only, so the C entry point never chains. */ +static thread_local bool g_ru_chain = false; +struct RuChainScope { + explicit RuChainScope(bool on) { g_ru_chain = on; } + ~RuChainScope() { g_ru_chain = false; } +}; + static int ru_update_launch( const void* q, const void* k, const void* v, const void* a, const void* b, long ab_stride, int ab_is_bf16, const void* A_log, const void* dt_bias, void* state, @@ -761,7 +851,8 @@ static int ru_update_launch( dim3 grid(N, H, vs), blk(RU_V / vs * 2); // Every switch is a template parameter; the nested pick macros enumerate the instantiations. #define RU_LAUNCH(AB, NM, VSC, NTC, ANCC, STGC, SDTC) \ - hipLaunchKernelGGL((r4d_gdn_recurrent_update_kernel), \ + hipLaunchKernelGGL((g_ru_chain ? &r4dchain_gdn_recurrent_update \ + : &r4d_gdn_recurrent_update_kernel), \ grid, blk, 0, (hipStream_t)stream, \ (const unsigned short*)q, (const unsigned short*)k, \ (const unsigned short*)v, a, b, ab_stride, \ @@ -879,7 +970,8 @@ static unsigned int* ru_conv_ctr(RadStream s, const void* out) { // The recurrent update with gdn_conv_update folded in, decode shape only (bf16 a/b, fused row // norm, one workgroup per (sequence, value head)). State contract, non-temporal choice and -// factor-block bounds are as in ru_update_launch. `w_f32` is the conv weight's type. +// factor-block bounds are as in ru_update_launch. `w_f32` is the conv weight's type. `oq_i8`: +// E4M3 codes (0), int8 (1), or had_quant_act_i8g's rotated int8 (2). static int ru_conv_recurrent_launch(const RuConv& cv, const void* a, const void* b, long ab_stride, const void* A_log, const void* dt_bias, void* state, long st_slot, long st_head, void* o, void* oq, void* os, @@ -896,10 +988,12 @@ static int ru_conv_recurrent_launch(const RuConv& cv, const void* a, const void* const bool nt = flood <= (long)RU_NT_MB * 1024 * 1024; const dim3 grid(N, H, 1), blk(RU_V * 2); #define RC_LAUNCH(NTC, ANCC, SDTC, CVC) \ - do { if (oq_i8) RC_LAUNCH_NM(2, NTC, ANCC, SDTC, CVC); \ - else RC_LAUNCH_NM(1, NTC, ANCC, SDTC, CVC); } while (0) + do { if (oq_i8 == 2) RC_LAUNCH_NM(3, NTC, ANCC, SDTC, CVC); \ + else if (oq_i8) RC_LAUNCH_NM(2, NTC, ANCC, SDTC, CVC); \ + else RC_LAUNCH_NM(1, NTC, ANCC, SDTC, CVC); } while (0) #define RC_LAUNCH_NM(NM, NTC, ANCC, SDTC, CVC) \ - hipLaunchKernelGGL((r4d_gdn_recurrent_update_kernel<1, NM, 1, NTC, ANCC, 0, SDTC, CVC>), \ + hipLaunchKernelGGL((g_ru_chain ? &r4dchain_gdn_recurrent_update<1, NM, 1, NTC, ANCC, 0, SDTC, CVC> \ + : &r4d_gdn_recurrent_update_kernel<1, NM, 1, NTC, ANCC, 0, SDTC, CVC>), \ grid, blk, 0, (hipStream_t)stream, nullptr, nullptr, nullptr, a, b, \ ab_stride, (const float*)A_log, (const float*)dt_bias, \ (ru_state::T*)state, st_slot, st_head, (unsigned short*)o, \ @@ -1022,6 +1116,7 @@ extern "C" int r4d_rad_gdn_recurrent_update(const RadArgs* a, RadStream s) { /* Slot and head strides come from the tensor, so a cache with padded slots is served too * (see the header); the engine's own state cache is dense ([n_states, H, V, K] per layer). */ + const RuChainScope chain_scope(r4d_geti_or(a, "chain", 0) != 0); return R4D_RAW(ru_update_launch( q->data, k->data, v->data, ta->data, tb->data, (long)ab_stride, ab_is_bf16, alog->data, dtb->data, state->data, @@ -1044,7 +1139,8 @@ enum { OPD_CR_X = 0, OPD_CR_CW, OPD_CR_CB, OPD_CR_CSTATE, OPD_CR_CIDX, OPD_CR_A, OPD_CR_ALOG, OPD_CR_DTB, OPD_CR_STATE, OPD_CR_SIDX, OPD_CR_NACC, OPD_CR_CU, OPD_CR_Z, OPD_CR_NORMW, OPD_CR_O, OPD_CR_OQ, OPD_CR_OS }; -extern "C" int r4d_rad_gdn_conv_recurrent_update(const RadArgs* a, RadStream s) { +/* `had`: gdn_conv_recurrent_update_had, whose codes are had_quant_act_i8g's over `o` (required). */ +static int gdn_conv_recurrent_entry(const RadArgs* a, RadStream s, bool had) { if (gdn_dims_ok() != RAD_OK) return R4D_NO(RAD_E_SHAPE); const RadTensor* x = r4d_opt(a, OPD_CR_X); const RadTensor* cw = r4d_opt(a, OPD_CR_CW); @@ -1070,6 +1166,7 @@ extern "C" int r4d_rad_gdn_conv_recurrent_update(const RadArgs* a, RadStream s) !z || !nw || !o) return R4D_NO(RAD_E_INVAL); if ((oq != nullptr) != (os != nullptr)) return R4D_NO(RAD_E_INVAL); + if (had && (!oq || oq->dtype != RAD_I8)) return R4D_NO(RAD_E_INVAL); if (x->rank != 2 || cst->rank != 3 || o->rank != 3 || ta->rank != 2 || tb->rank != 2) return R4D_NO(RAD_E_SHAPE); if (state->rank < 2 || sidx->rank < 1 || cidx->rank < 1) return R4D_NO(RAD_E_SHAPE); @@ -1140,6 +1237,7 @@ extern "C" int r4d_rad_gdn_conv_recurrent_update(const RadArgs* a, RadStream s) cv.ctr = ru_conv_ctr(s, o->data); if (!cv.ctr) return R4D_NO(RAD_E_NOMEM); + const RuChainScope chain_scope(r4d_geti_or(a, "chain", 0) != 0); return ru_conv_recurrent_launch( cv, ta->data, tb->data, (long)ab_stride, alog->data, dtb->data, state->data, (long)state->stride[0], (long)state->stride[1], o->data, oq ? oq->data : nullptr, @@ -1147,5 +1245,13 @@ extern "C" int r4d_rad_gdn_conv_recurrent_update(const RadArgs* a, RadStream s) os ? (long)r4d_row_pitch(os) : 0, cu->data, sidx->data, (long)sidx->stride[0], nacc ? nacc->data : nullptr, z->data, (long)z_row, nw->data, neps, nact, N, (int)H, (int)Hg, scale, thr, state->dtype == RAD_F16 ? 1 : 0, s, - oq && oq->dtype == RAD_I8 ? 1 : 0, anc != 0, cw->dtype == RAD_F32); + had ? 2 : oq && oq->dtype == RAD_I8 ? 1 : 0, anc != 0, cw->dtype == RAD_F32); +} + +extern "C" int r4d_rad_gdn_conv_recurrent_update(const RadArgs* a, RadStream s) { + return gdn_conv_recurrent_entry(a, s, false); +} + +extern "C" int r4d_rad_gdn_conv_recurrent_update_had(const RadArgs* a, RadStream s) { + return gdn_conv_recurrent_entry(a, s, true); } diff --git a/libr4d/r4d_gemm_iqr.hip b/libr4d/r4d_gemm_iqr.hip index 984a790f..a3f289f9 100644 --- a/libr4d/r4d_gemm_iqr.hip +++ b/libr4d/r4d_gemm_iqr.hip @@ -1,18 +1,20 @@ // gemm_nt_q over the IQR weights (r4d_iqr.h), decoded from their codes where they are read; VRAM // holds a B-bit weight in B bits. Two rows, as the int8 family's (r4d_gemm_fp8a8.hip): // -// gemm_iqr_nt_m64 M <= 64 (decode and speculative verify). At M <= 8 a GEMV: a wave a 16-row -// tile, its lanes across K, each lane's decoded values one sudot4 against the -// activation. Above, the i8a8 narrow tile with each 128-K block's weight decoded -// and transposed into fragment order through LDS just before its WMMA steps. +// gemm_iqr_nt_m64 M <= 64 (decode and speculative verify). At one token (a computed trellis; +// M <= 8 for the other forms) a GEMV: a block a 16-row tile, its waves across +// K, each lane's decoded values one sudot4 against the activation. To 16 tokens +// a WMMA tile of the same shape, each 128-K unit decoded and transposed into +// fragment order through the wave's LDS just before its WMMA steps. Above, the +// i8a8 narrow tile with the same per-unit decode. // gemm_iqr_tiled any M (prefill). The i8a8 prefill tile over the int8 fragment plane in the // caller's scratch, which the tile's blocks decode as they arrive, each value // once. // -// The narrow and prefill tiles compute what the int8 tiles compute over the same int8 values (their -// split, staging, accumulation order and fold), so a weight decoded here and the same weight's int8 -// values in the int8 kernels give the same output bytes. The GEMV folds per lane and then sums -// across lanes: the product within f32 rounding. +// The narrow tile above 16 tokens and the prefill tile compute what the int8 tiles compute over the +// same int8 values (their split, staging, accumulation order and fold), so a weight decoded here +// and the same weight's int8 values in the int8 kernels give the same output bytes. The GEMV and +// the 16-token tile sum per wave and then across waves: the product within f32 rounding. #include "r4d.h" #include "r4d_args.h" @@ -20,6 +22,8 @@ #include "r4d_fp8_wmma.h" #include "r4d_iqr.h" #include "r4d_iqr_dec.h" +#include "r4d_fwht.h" +#include "r4d_q8.h" #include #include @@ -48,37 +52,97 @@ constexpr uint32_t kIqrSplitWaves = 512; #include "r4d_gemm_8a8_prefill.h" +/* ---- the gated fold (gemm_nt_q_gated at i8a8h) ---------------------------------------------- + * + * gate_up's GEMM with gated_had_quant_i8g's pass in its epilogue. A block computes one 16-column + * tile of the gated output: the gate rows' tile and the up rows' tile, each with the waves and K + * order of the plain kernel at the full weight's N, so their bf16 values are the plain kernel's. + * It writes silu(gate) * up, rounded as gated_quant_fp8_kernel rounds it, into the op's scratch + * (and `out_bf16`), and the last of a 128-column group's eight blocks to arrive rotates and + * quantises the group, a wave a token, as that kernel does: so the codes and scales are the + * pair's bytes. */ +struct GatedOut { + uint16_t* H; /* [M][n] the bf16 product, scratch */ + int8_t* Q; /* [M][q_ld] int8 codes */ + float* S; /* [M][s_ld] a scale per (token, 128 columns) */ + uint16_t* Yb; /* [M][y_ld] the unrotated bf16 product, or null */ + unsigned int* cnt; /* an arrival counter per 128-column group */ + uint32_t n, q_ld, s_ld, y_ld; +}; + +/* Token m's gated value at column `col` from the gate and up rows' f32 sums (row scale applied). */ +__device__ __forceinline__ void gated_put(const GatedOut& go, uint32_t m, uint32_t col, float vg, + float vu) { + const float gv = bf16_to_f32(f32_to_bf16(vg)); + const float a = gv / (1.0f + expf(-gv)); + const uint16_t h = f32_to_bf16(a * bf16_to_f32(f32_to_bf16(vu))); + go.H[(size_t)m * go.n + col] = h; + if (go.Yb) go.Yb[(size_t)m * go.y_ld + col] = h; +} + +/* After every thread's gated_put: the group's last arriver quantises it, `nw` waves. */ +__device__ __forceinline__ void gated_tail(const GatedOut& go, uint32_t M, uint32_t nw) { + __shared__ unsigned int s_last; + const uint32_t tid = threadIdx.x, lane = tid & (kWave - 1), wave = tid / kWave; + const uint32_t g = blockIdx.x / 8u; + __threadfence(); + __syncthreads(); + if (tid == 0) + s_last = __hip_atomic_fetch_add(&go.cnt[g], 1u, __ATOMIC_ACQ_REL, __HIP_MEMORY_SCOPE_AGENT); + __syncthreads(); + if (s_last != 7u) return; + if (tid == 0) __hip_atomic_store(&go.cnt[g], 0u, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_AGENT); + __threadfence(); + for (uint32_t m = wave; m < M; m += nw) { + const uint32_t c0 = g * 128u + lane * 4u; + float v[4]; +#pragma unroll + for (uint32_t j = 0; j < 4; ++j) v[j] = bf16_to_f32(go.H[(size_t)m * go.n + c0 + j]); + r4d_fwht_wave<128>(v, (int)lane); + const float mx = r4d_wave_max(fmaxf(fmaxf(fabsf(v[0]), fabsf(v[1])), fmaxf(fabsf(v[2]), fabsf(v[3])))); + const float sc = mx > 0.0f ? mx * (1.0f / q8_top()) : 1.0f; + if (lane == 0) go.S[(size_t)m * go.s_ld + g] = sc; + *(uint32_t*)(go.Q + (size_t)m * go.q_ld + c0) = q8_pack4(v[0], v[1], v[2], v[3], 1.0f / sc); + } +} + /* ---- the GEMV: M <= 8 ---------------------------------------------------------------------- * - * A wave a 16-row tile, its lanes across K: lane l takes columns 4l .. 4l + 3 of each 128-K block, - * so its decoded values of a row are one sudot4 against the activation's four bytes there, and a - * row's sum is folded into f32 with the (row, block) and (token, block) scales a block at a time, - * in each lane, then summed across the wave once at the end. The weight stream is the codes' own + * A block a 16-row tile, its KW waves across K: wave w takes the tile's 128-K blocks w, w + KW, .., + * so at any time a block's waves read KW consecutive units of one tile. Within a wave lane l takes + * columns 4l .. 4l + 3 of each block, so its decoded values of a row are one sudot4 against the + * activation's four bytes there, and a row's sum is folded into f32 with the (row, block) and + * (token, block) scales a block at a time, in each lane. At the end each wave sums its lanes and + * the block sums its waves through LDS in ascending order. The weight stream is the codes' own * bytes, fetched a block ahead; the work a value is its decode, a quarter sudot4 a token and half - * an f32 fold. Split over K into partial planes when the tiles alone leave the card idle; the last - * z block of a column of blocks sums them in ascending z. + * an f32 fold. * - * The fold order differs from the WMMA tile's (per lane, then across lanes), so the output is the - * product within f32 rounding rather than the int8 tile's bytes. */ -constexpr uint32_t kGW = 8; /* waves a block */ -template -__global__ __launch_bounds__(kGW * kWave) R4D_WAVES(6) + * A block lives for 1 / KW of a tile's K, so the card balances over N / 16 short blocks and no + * weight needs a split across blocks. A wave a tile over all of K (the previous form) left a + * partial last round of long waves on every shape: at 102 VGPRs a SIMD holds 15 waves, and N / 16 + * tiles (gate_up 2176, down split 7 ways 2240) never divide that. + * + * The fold order differs from the WMMA tile's (per lane, then across lanes and waves), so the + * output is the product within f32 rounding rather than the int8 tile's bytes. */ +template +__global__ __launch_bounds__((GATED ? 2u : 1u) * KW * kWave) R4D_WAVES(6) void iqr_gemv_kernel(Ctx c0, const int8_t* __restrict__ X, const float* __restrict__ XS, - float* __restrict__ part, uint16_t* __restrict__ Y, - unsigned int* __restrict__ Ctr, uint32_t N, uint32_t x_ld, uint32_t xs_ld, - uint32_t kbs) { + uint16_t* __restrict__ Y, uint32_t N, uint32_t x_ld, uint32_t xs_ld, + GatedOut go) { using D = Dec; + constexpr uint32_t NW = (GATED ? 2u : 1u) * KW; __shared__ __attribute__((aligned(16))) int8_t s_tab[D::kTab]; + __shared__ float s_red[NW][16 * MT]; const uint32_t tid = threadIdx.x, lane = tid & (kWave - 1); - const uint32_t wave = __builtin_amdgcn_readfirstlane(tid / kWave); + const uint32_t wave0 = __builtin_amdgcn_readfirstlane(tid / kWave); Ctx c = c0; c.tab = s_tab; - D::stage(s_tab, c, tid, kGW * kWave); + D::stage(s_tab, c, tid, NW * kWave); __syncthreads(); - const uint32_t rt = blockIdx.x * kGW + wave; - const bool alive = rt * 16u < N; - const uint32_t kb0 = blockIdx.z * kbs, kb1 = min(c.nkb, kb0 + kbs); + /* Gated, waves KW and up take the up rows' tile, n rows below the gate rows'. */ + const uint32_t half = GATED ? wave0 / KW : 0u, wave = GATED ? wave0 % KW : wave0; + const uint32_t rt = blockIdx.x + half * (N / 32u); const uint32_t myrow = rt * 16u + (lane & 15u); float acc[16][MT]; @@ -86,10 +150,14 @@ void iqr_gemv_kernel(Ctx c0, const int8_t* __restrict__ X, const float* __restri for (uint32_t q = 0; q < 16; ++q) #pragma unroll for (uint32_t m = 0; m < MT; ++m) acc[q][m] = 0.0f; + float fsum[MT]; /* the biased path's fold factors since its last flush (wave-uniform) */ +#pragma unroll + for (uint32_t m = 0; m < MT; ++m) fsum[m] = 0.0f; + uint32_t nflush = 0; - typename D::Raw cur = D::fetch(c, rt, kb0, lane, alive && kb0 < kb1), nxt; - for (uint32_t kb = kb0; kb < kb1; ++kb) { - if (kb + 1u < kb1) nxt = D::fetch(c, rt, kb + 1u, lane, alive); + typename D::Raw cur = D::fetch(c, rt, wave, lane, wave < c.nkb), nxt; + for (uint32_t kb = wave; kb < c.nkb; kb += KW) { + if (kb + KW < c.nkb) nxt = D::fetch(c, rt, kb + KW, lane, true); uint32_t xv[MT]; float as[MT]; #pragma unroll @@ -98,8 +166,25 @@ void iqr_gemv_kernel(Ctx c0, const int8_t* __restrict__ X, const float* __restri as[m] = XS[(size_t)m * xs_ld + kb]; } /* Row (lane & 15)'s fold scale and ratio, read by every lane through readlane. */ - const float fs = alive ? fold_f32(c, myrow, kb) : 0.0f; - const float ratio = alive ? rb_ratio(c, myrow, kb) : 0.0f; + /* A bf16 scale a (row, 128): the tile's sixteen rows' scales of this block are 32 + * consecutive bytes at a wave-uniform address, read through the constant address space + * into scalar registers, so no row's scale is broadcast by readlane. */ + constexpr bool SROW = F::SC == kBf16 && F::LRB == 0; + [[maybe_unused]] uint32_t sw[8]; + if constexpr (SROW) { + typedef const __attribute__((address_space(4))) uint32_t cu32; + cu32* sp = (cu32*)((const uint16_t*)c.S + ((size_t)rt * c.nkb + kb) * 16u); +#pragma unroll + for (uint32_t i = 0; i < 8; ++i) sw[i] = sp[i]; + } + auto row_fold = [&](uint32_t q, float fs_) { + if constexpr (SROW) + return __uint_as_float(q & 1u ? sw[q / 2u] & 0xFFFF0000u : sw[q / 2u] << 16); + else + return __builtin_bit_cast(float, __builtin_amdgcn_readlane(__float_as_int(fs_), q)); + }; + const float fs = SROW ? 0.0f : fold_f32(c, myrow, kb); + const float ratio = rb_ratio(c, myrow, kb); uint32_t w[16]; /* A computed trellis off the tcq_rb grid decodes each value as its byte sum, the value * plus 126: one sudot4 of the unsigned sums less 126 times the lane's activation sum. */ @@ -108,19 +193,54 @@ void iqr_gemv_kernel(Ctx c0, const int8_t* __restrict__ X, const float* __restri if constexpr (UNS) { #pragma unroll for (uint32_t m = 0; m < MT; ++m) - xsum[m] = 126 * __builtin_amdgcn_sudot4(true, (int)xv[m], false, 0x01010101, 0, false); + xsum[m] = __builtin_amdgcn_sudot4(true, (int)xv[m], false, 0x7E7E7E7E, 0, false); } - if constexpr (UNS && MT == 1) { + if constexpr (UNS && MT <= 4 && F::SC == kRowF32) { /* One token: each value's hash dotted with its activation byte in every byte lane - * sums the value's bytes and multiplies in one instruction, nothing packed. */ + * sums the value's bytes and multiplies in one instruction, nothing packed. Under one + * f32 scale a row the block's fold is one factor for all rows, so a row's dot starts + * at 0x4B400000 less the lane's bias sum: read as an f32 it is exactly 12582912 plus + * the sum (|sum| < 2^22), one fma folds it, and 12582912 times the block's factors + * leaves each row once at the end. */ + uint32_t h[16][4]; + D::hashes(cur, c, h); +#pragma unroll + for (uint32_t m = 0; m < MT; ++m) { + uint32_t xs[4]; +#pragma unroll + for (uint32_t e = 0; e < 4; ++e) xs[e] = __builtin_amdgcn_perm(0u, xv[m], e * 0x01010101u); + const float s = fs * as[m]; + fsum[m] += s; + const int b0 = kRbBias - __builtin_amdgcn_sudot4(true, (int)xv[m], false, 0x7E7E7E7E, 0, false); +#pragma unroll + for (uint32_t q = 0; q < 16; ++q) { + int d = b0; +#pragma unroll + for (uint32_t e = 0; e < 4; ++e) + d = __builtin_amdgcn_sudot4(false, (int)h[q][e], true, (int)xs[e], d, false); + acc[q][m] = fmaf(__int_as_float(d), s, acc[q][m]); + } + } + /* the bias out every kRbFlush blocks, so a row's sum stays within a few bias terms + * of its value (the prefill tile's bound) */ + if (++nflush == kRbFlush) { +#pragma unroll + for (uint32_t m = 0; m < MT; ++m) { +#pragma unroll + for (uint32_t q = 0; q < 16; ++q) acc[q][m] = fmaf(-kRbBiasF, fsum[m], acc[q][m]); + fsum[m] = 0.0f; + } + nflush = 0; + } + } else if constexpr (UNS && MT == 1) { uint32_t h[16][4]; D::hashes(cur, c, h); uint32_t xs[4]; #pragma unroll - for (uint32_t e = 0; e < 4; ++e) xs[e] = ((xv[0] >> (8u * e)) & 0xFFu) * 0x01010101u; + for (uint32_t e = 0; e < 4; ++e) xs[e] = __builtin_amdgcn_perm(0u, xv[0], e * 0x01010101u); #pragma unroll for (uint32_t q = 0; q < 16; ++q) { - const float wsq = __builtin_bit_cast(float, __builtin_amdgcn_readlane(__float_as_int(fs), q)); + const float wsq = row_fold(q, fs); int d = -xsum[0]; #pragma unroll for (uint32_t e = 0; e < 4; ++e) @@ -132,7 +252,7 @@ void iqr_gemv_kernel(Ctx c0, const int8_t* __restrict__ X, const float* __restri D::unzero(c, rt, kb, w); #pragma unroll for (uint32_t q = 0; q < 16; ++q) { - const float wsq = __builtin_bit_cast(float, __builtin_amdgcn_readlane(__float_as_int(fs), q)); + const float wsq = row_fold(q, fs); #pragma unroll for (uint32_t m = 0; m < MT; ++m) { int d = __builtin_amdgcn_sudot4(!UNS, (int)w[q], true, (int)xv[m], 0, false); @@ -143,58 +263,192 @@ void iqr_gemv_kernel(Ctx c0, const int8_t* __restrict__ X, const float* __restri } cur = nxt; } + /* every lane's rows carry 12582912 times the factors once for each of its blocks */ #pragma unroll for (uint32_t q = 0; q < 16; ++q) #pragma unroll - for (uint32_t m = 0; m < MT; ++m) acc[q][m] = r4d_wave_sum(acc[q][m]); - if constexpr (F::SC == kRowF32) { - /* each row's own scale, after its blocks' sums (lane q's row q; a split's partials are - * linear in it) */ - const float rs = alive ? row_scale(c, rt * 16u + (lane & 15u)) : 0.0f; -#pragma unroll - for (uint32_t q = 0; q < 16; ++q) { - const float rq = __builtin_bit_cast(float, __builtin_amdgcn_readlane(__float_as_int(rs), q)); -#pragma unroll - for (uint32_t m = 0; m < MT; ++m) acc[q][m] *= rq; - } - } - if (lane < 16u && alive) { - /* lane q stores row q: the sums are wave-uniform, picked by a constant index */ + for (uint32_t m = 0; m < MT; ++m) acc[q][m] = r4d_wave_sum(fmaf(-kRbBiasF, fsum[m], acc[q][m])); + if (lane == 0) { #pragma unroll for (uint32_t q = 0; q < 16; ++q) - if (lane == q) { #pragma unroll - for (uint32_t m = 0; m < MT; ++m) { - const size_t o = (size_t)m * N + rt * 16u + q; - if (gridDim.z > 1u) part[(size_t)blockIdx.z * MT * N + o] = acc[q][m]; - else Y[o] = f32_to_bf16(acc[q][m]); - } - } + for (uint32_t m = 0; m < MT; ++m) s_red[wave0][q * MT + m] = acc[q][m]; } - if (gridDim.z > 1u) { - __threadfence(); - __syncthreads(); - __shared__ unsigned int s_arrived; - if (tid == 0) - s_arrived = __hip_atomic_fetch_add(&Ctr[blockIdx.x], 1u, __ATOMIC_ACQ_REL, - __HIP_MEMORY_SCOPE_AGENT); - __syncthreads(); - if (s_arrived + 1u == gridDim.z) { - if (tid == 0) - __hip_atomic_store(&Ctr[blockIdx.x], 0u, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_AGENT); - __threadfence(); - const uint32_t r0 = blockIdx.x * kGW * 16u, nr = min(kGW * 16u, N - r0); - for (uint32_t i = tid; i < nr * MT; i += kGW * kWave) { - const size_t o = (size_t)(i / nr) * N + r0 + i % nr; - float v = 0.0f; - for (uint32_t z = 0; z < gridDim.z; ++z) v += part[(size_t)z * MT * N + o]; - Y[o] = f32_to_bf16(v); - } + __syncthreads(); + if constexpr (GATED) { + if (tid < 16u * MT) { + const uint32_t q = tid / MT, m = tid % MT; + float vg = 0.0f, vu = 0.0f; +#pragma unroll + for (uint32_t w = 0; w < KW; ++w) vg += s_red[w][tid]; +#pragma unroll + for (uint32_t w = 0; w < KW; ++w) vu += s_red[KW + w][tid]; + vg *= row_scale(c, blockIdx.x * 16u + q); + vu *= row_scale(c, (blockIdx.x + N / 32u) * 16u + q); + gated_put(go, m, blockIdx.x * 16u + q, vg, vu); + } + gated_tail(go, MT, NW); + } else { + if (tid < 16u * MT) { + const uint32_t q = tid / MT, m = tid % MT; + float v = 0.0f; +#pragma unroll + for (uint32_t w = 0; w < KW; ++w) v += s_red[w][tid]; + /* each row's own scale, after its blocks' sums */ + v *= row_scale(c, rt * 16u + q); + Y[(size_t)m * N + rt * 16u + q] = f32_to_bf16(v); } } } -/* ---- the narrow tile: 8 < M <= 64 ----------------------------------------------------------- +/* ---- the narrow tile at M <= 16 ------------------------------------------------------------- + * + * One 16-token tile: a block a 16-row weight tile, its KW waves across K as the GEMV's (wave w + * the tile's 128-K blocks w, w + KW, ..). A wave decodes each unit and transposes it into + * fragment order through its own LDS tile (frag), then runs the unit's eight WMMA steps against + * the activation's fragments read straight from global memory, where the M x K activation sits + * in L2, so the loop has no block barrier and no shared staging. Rows of the token tile past M + * read token M - 1; their outputs are not stored. + * + * Under one f32 scale a row each unit's int32 sums start at 0x4B400000, so a slot read as an f32 + * is 12582912 plus its sum and one fma folds it (the prefill tile's RB 32 fold), flushed every + * kRbFlush units; other scale forms fold the converted sum with their (row, block) scales. The + * waves' partials are summed through LDS in ascending wave order, so the output is the product + * within f32 rounding, not the int8 tile's bytes. */ +template +__global__ __launch_bounds__((GATED ? 2u : 1u) * KW * kWave) R4D_WAVES(6) +void iqr_m16_kernel(Ctx c0, const int8_t* __restrict__ X, const float* __restrict__ XS, + uint16_t* __restrict__ Y, uint32_t N, uint32_t M, uint32_t x_ld, uint32_t xs_ld, + GatedOut go) { + using D = Dec; + constexpr bool BIAS = F::SC == kRowF32; + constexpr uint32_t NW = (GATED ? 2u : 1u) * KW; + __shared__ __attribute__((aligned(16))) int8_t s_tab[D::kTab]; + /* the waves' transpose tiles, then their partials (8 x 32 floats a wave, in its own tile) */ + __shared__ __attribute__((aligned(16))) uint8_t s_tr[NW * kTrBytes]; + static_assert(8u * kWave * 4u <= kTrBytes, "a wave's partials in its transpose tile"); + auto red = [&](uint32_t w) { return (float*)(s_tr + w * kTrBytes); }; + const uint32_t tid = threadIdx.x, lane = tid & (kWave - 1); + const uint32_t wave0 = __builtin_amdgcn_readfirstlane(tid / kWave); + Ctx c = c0; + c.tab = s_tab; + uint8_t* const tr = s_tr + wave0 * kTrBytes; + D::stage(s_tab, c, tid, NW * kWave); + __syncthreads(); + + /* Gated, waves KW and up take the up rows' tile, n rows below the gate rows'. */ + const uint32_t half = GATED ? wave0 / KW : 0u, wave = GATED ? wave0 % KW : wave0; + const uint32_t rt = blockIdx.x + half * (N / 32u), row0 = rt * 16u; + const uint32_t tok = min(frag_c(lane), M - 1u); + const int8_t* const xrow = X + (size_t)tok * x_ld + frag_k0(lane); + + f8v out = acc_zero(); + float corr = 0.0f; /* BIAS: the units' fold factors since the last flush */ + uint32_t nflush = 0; + auto bload = [&](uint32_t kb, i2v (&b)[8], bool live) { +#pragma unroll + for (uint32_t ks = 0; ks < 8; ++ks) { + const uint2 v = live ? *(const uint2*)(xrow + kb * kBlock + ks * kK) : make_uint2(0u, 0u); + b[ks][0] = (int)v.x; + b[ks][1] = (int)v.y; + } + }; + typename D::Raw cur = D::fetch(c, rt, wave, lane, wave < c.nkb), nxt; + i2v bc[8], bn[8]; + bload(wave, bc, wave < c.nkb); + for (uint32_t kb = wave; kb < c.nkb; kb += KW) { + if (kb + KW < c.nkb) { + nxt = D::fetch(c, rt, kb + KW, lane, true); + bload(kb + KW, bn, true); + } + uint32_t w[16]; + D::rows(cur, c, rb_ratio(c, row0 + (lane & 15u), kb), w); + D::unzero(c, rt, kb, w); + Stage8 a8[2]; + frag(w, tr, lane, a8); + /* two chains of four steps, so a step does not wait on the one before it */ + f8v raw = rb_first(); +#pragma unroll + for (uint32_t ks = 0; ks < kBlock / kK; ++ks) + raw = mma8(frag_of(a8[ks / 4u], ks % 4u), bc[ks], raw); + const float as = XS[(size_t)tok * xs_ld + kb]; + if constexpr (BIAS) { + const float sb = fold_f32(c, row0, kb) * as; + corr += sb; +#pragma unroll + for (uint32_t t = 0; t < 8; ++t) out[t] = __builtin_fmaf(raw[t], sb, out[t]); + if (++nflush == kRbFlush) { +#pragma unroll + for (uint32_t t = 0; t < 8; ++t) out[t] = __builtin_fmaf(-kRbBiasF, corr, out[t]); + corr = 0.0f; + nflush = 0; + } + } else { + float wsr[8]; + if constexpr (F::SC == kBf16 && F::LRB == 0) { + /* A bf16 scale a (row, 128): the lane's eight rows are consecutive in the tile's + * scale run (own_scale's order), 16 aligned bytes, one load. */ + const uint4 q4 = *(const uint4*)((const uint16_t*)c.S + ((size_t)rt * c.nkb + kb) * 16u + + acc_row(lane, 0)); + const uint32_t qd[4] = { q4.x, q4.y, q4.z, q4.w }; +#pragma unroll + for (uint32_t t = 0; t < 4; ++t) { + wsr[2 * t] = __uint_as_float(qd[t] << 16); + wsr[2 * t + 1] = __uint_as_float(qd[t] & 0xFFFF0000u); + } + } else { +#pragma unroll + for (uint32_t t = 0; t < 8; ++t) wsr[t] = fold_f32(c, row0 + acc_row(lane, t), kb); + } +#pragma unroll + for (uint32_t t = 0; t < 8; ++t) + out[t] = __builtin_fmaf(acc_val(raw[t]), wsr[t] * as, out[t]); + } + cur = nxt; +#pragma unroll + for (uint32_t ks = 0; ks < 8; ++ks) bc[ks] = bn[ks]; + } + /* each wave's partials in its own tile, behind its last transpose's reads */ + __builtin_amdgcn_fence(__ATOMIC_RELEASE, "wavefront", "local"); + __builtin_amdgcn_wave_barrier(); +#pragma unroll + for (uint32_t t = 0; t < 8; ++t) red(wave0)[t * kWave + lane] = BIAS ? __builtin_fmaf(-kRbBiasF, corr, out[t]) : out[t]; + __syncthreads(); + if constexpr (GATED) { + if (wave0 == 0) { + const uint32_t col = frag_c(lane); + const uint32_t r0 = acc_row(lane, 0); +#pragma unroll + for (uint32_t t = 0; t < 8; ++t) { + float ag = 0.0f, au = 0.0f; +#pragma unroll + for (uint32_t w = 0; w < KW; ++w) ag += red(w)[t * kWave + lane]; +#pragma unroll + for (uint32_t w = 0; w < KW; ++w) au += red(KW + w)[t * kWave + lane]; + ag *= row_scale(c, blockIdx.x * 16u + r0 + t); + au *= row_scale(c, (blockIdx.x + N / 32u) * 16u + r0 + t); + if (col < M) gated_put(go, col, blockIdx.x * 16u + r0 + t, ag, au); + } + } + gated_tail(go, M, NW); + } else if (wave == 0) { + const uint32_t col = frag_c(lane); + const uint32_t r0 = row0 + acc_row(lane, 0); + float v[8]; +#pragma unroll + for (uint32_t t = 0; t < 8; ++t) { + float a = 0.0f; +#pragma unroll + for (uint32_t w = 0; w < KW; ++w) a += red(w)[t * kWave + lane]; + v[t] = a * row_scale(c, r0 + t); + } + if (col < M) + *(uint4*)(Y + (size_t)col * N + r0) = make_uint4(bf16x2_rne(v[0], v[1]), bf16x2_rne(v[2], v[3]), + bf16x2_rne(v[4], v[5]), bf16x2_rne(v[6], v[7])); + } +} + +/* ---- the narrow tile: 16 < M <= 64 ----------------------------------------------------------- * * r4d_gemm_fp8a8.hip's gemm_fp8a8_body at I8, unfused: MW waves a block, a wave one 16-row weight * tile against NT 16-token tiles staged through LDS, split-K over the caller's scratch with the @@ -305,6 +559,20 @@ void iqr_m64_kernel(Ctx c0, const uint8_t* __restrict__ Bp, const float* __restr const float f = alive ? fold_f32(c, wrow0, kb) : 0.0f; #pragma unroll for (uint32_t t = 0; t < 8; ++t) wsr[t] = f; + } else if constexpr (F::SC == kBf16 && F::LRB == 0) { + /* A bf16 scale a (row, 128): the lane's eight rows are consecutive in the + * tile's scale run (own_scale's order), 16 aligned bytes, one load. Every row + * of a live tile is live (rows is a multiple of 16). */ + uint4 q = make_uint4(0u, 0u, 0u, 0u); + if (alive) + q = *(const uint4*)((const uint16_t*)c.S + + ((size_t)(wrow0 / 16u) * c.nkb + kb) * 16u + acc_row(lane, 0)); + const uint32_t qd[4] = { q.x, q.y, q.z, q.w }; +#pragma unroll + for (uint32_t t = 0; t < 4; ++t) { + wsr[2 * t] = __uint_as_float(qd[t] << 16); + wsr[2 * t + 1] = __uint_as_float(qd[t] & 0xFFFF0000u); + } } else { #pragma unroll for (uint32_t t = 0; t < 8; ++t) @@ -568,55 +836,82 @@ Ctx ctx_of(const Operands& g) { return c; } -/* The GEMV's K split: enough waves to keep the card's memory busy (2048 tiles' worth), each split at - * least four blocks. A function of N and K alone. */ constexpr uint32_t kGemvMaxM = 8; -uint32_t gemv_ksplit(uint32_t N, uint32_t nkb) { - const uint32_t tiles = N / 16u; - uint32_t ks = std::min((2048u + tiles - 1u) / tiles, std::max(1u, nkb / 4u)); - const uint32_t kbs = (nkb + ks - 1u) / ks; - return (nkb + kbs - 1u) / kbs; -} +/* The GEMV, plain into `g.y`, or with `go` the gated fold (a block a gated tile, twice the waves). */ template -int gemv_launch(const Operands& g, void* scratch, long long scratch_bytes, RadStream stream) { - const uint32_t N = (uint32_t)g.N, M = (uint32_t)g.M, nkb = (uint32_t)g.nkb; - uint32_t ks = gemv_ksplit(N, nkb); - const uint32_t gx = (N / 16u + kGW - 1u) / kGW; - unsigned int* ctr = nullptr; - if (ks > 1u) { - ctr = gx <= 8192u ? r4d_8a8_split_ctr(stream, g.y->data) : nullptr; - if (!ctr || !scratch || scratch_bytes < (long long)ks * kGemvMaxM * N * 4) ks = 1u; - } - const uint32_t kbs = (nkb + ks - 1u) / ks; +int gemv_launch(const Operands& g, RadStream stream, const GatedOut* go = nullptr) { + const uint32_t N = (uint32_t)g.N, M = (uint32_t)g.M; const Ctx c = ctx_of(g); - const dim3 grid(gx, 1, ks); + /* Four waves a tile where the tiles alone nearly fill the card, eight on narrow weights (M = 1, + * 4 bits: gate_up 146.6 / 147.1 us, down 76.0 / 78.4, the 5120 x 6144 outputs 31.4 / 31.9, + * attn_k 9.5 / 8.8). */ + const uint32_t kw = N >= 4096u ? 4u : 8u; + const GatedOut gz = go ? *go : GatedOut{}; + uint16_t* const y = go ? nullptr : (uint16_t*)g.y->data; int rc = RAD_E_SHAPE; -#define R4D_IQR_GV(mt_) rc = R4D_EMIT(stream, (iqr_gemv_kernel), grid, dim3(kGW * kWave), 0, c, (const int8_t*)g.a->data, (const float*)g.as->data, (float*)scratch, (uint16_t*)g.y->data, ctr, N, (uint32_t)g.a_ld, (uint32_t)g.sa_ld, kbs) +#define R4D_IQR_GV(mt_, kw_) \ + rc = go ? R4D_EMIT(stream, (iqr_gemv_kernel), dim3(N / 32u), \ + dim3(2u * kw_ * kWave), 0, c, (const int8_t*)g.a->data, \ + (const float*)g.as->data, y, N, (uint32_t)g.a_ld, (uint32_t)g.sa_ld, gz) \ + : R4D_EMIT(stream, (iqr_gemv_kernel), dim3(N / 16u), dim3(kw_ * kWave), \ + 0, c, (const int8_t*)g.a->data, (const float*)g.as->data, y, N, \ + (uint32_t)g.a_ld, (uint32_t)g.sa_ld, gz) +#define R4D_IQR_GVK(mt_) do { if (kw == 4u) R4D_IQR_GV(mt_, 4u); else R4D_IQR_GV(mt_, 8u); } while (0) switch (M) { - case 1u: R4D_IQR_GV(1u); break; - case 2u: R4D_IQR_GV(2u); break; - case 3u: R4D_IQR_GV(3u); break; - case 4u: R4D_IQR_GV(4u); break; - case 5u: R4D_IQR_GV(5u); break; - case 6u: R4D_IQR_GV(6u); break; - case 7u: R4D_IQR_GV(7u); break; - case 8u: R4D_IQR_GV(8u); break; + case 1u: R4D_IQR_GVK(1u); break; + case 2u: R4D_IQR_GVK(2u); break; + case 3u: R4D_IQR_GVK(3u); break; + case 4u: R4D_IQR_GVK(4u); break; + case 5u: R4D_IQR_GVK(5u); break; + case 6u: R4D_IQR_GVK(6u); break; + case 7u: R4D_IQR_GVK(7u); break; + case 8u: R4D_IQR_GVK(8u); break; default: return R4D_NO(RAD_E_SHAPE); } +#undef R4D_IQR_GVK #undef R4D_IQR_GV return rc == RAD_OK && hipGetLastError() == hipSuccess ? RAD_OK : R4D_NO(RAD_E_DEVICE); } +/* The 16-token tile, plain into `g.y` or gated as gemv_launch. */ +template +int m16_launch(const Operands& g, RadStream stream, const GatedOut* go = nullptr) { + const uint32_t N = (uint32_t)g.N, M = (uint32_t)g.M; + const Ctx c = ctx_of(g); + const GatedOut gz = go ? *go : GatedOut{}; + uint16_t* const y = go ? nullptr : (uint16_t*)g.y->data; + int rc; +#define R4D_IQR_M16(kw_) \ + rc = go ? R4D_EMIT(stream, (iqr_m16_kernel), dim3(N / 32u), \ + dim3(2u * kw_ * kWave), 0, c, (const int8_t*)g.a->data, \ + (const float*)g.as->data, y, N, M, (uint32_t)g.a_ld, (uint32_t)g.sa_ld, gz) \ + : R4D_EMIT(stream, (iqr_m16_kernel), dim3(N / 16u), dim3(kw_ * kWave), 0, c, \ + (const int8_t*)g.a->data, (const float*)g.as->data, y, N, M, \ + (uint32_t)g.a_ld, (uint32_t)g.sa_ld, gz) + if (N >= 4096u) R4D_IQR_M16(4u); + else R4D_IQR_M16(8u); +#undef R4D_IQR_M16 + return rc == RAD_OK && hipGetLastError() == hipSuccess ? RAD_OK : R4D_NO(RAD_E_DEVICE); +} + +/* A computed trellis's GEMV pays its decode in VALU work beside every token's dot and fold, the + * tiles decode a unit once for all tokens. Measured on gate_up (34816 x 5120): at one token the + * GEMV wins at every width (2 / 4 / 6 bits 92.6 / 145.2 / 214.6 us, the 16-token tile at 4 / 6 bits + * 150.0 / 215.7); at two only on 2- and 3-bit codes under one f32 scale a row, its values dotted + * straight from their hashes (128.4 / 132.4 against the tile's 137.7 / 138.5; 4 bits 152.8 against + * 150.1); from three tokens the tile. */ +template +constexpr uint32_t gemv_max() { + return F::KIND != kTrellisMad ? kGemvMaxM : F::B <= 3u && F::SC == kRowF32 ? 2u : 1u; +} + template int m64_launch(const Operands& g, void* scratch, long long scratch_bytes, int split_n, RadStream stream) { const uint32_t N = (uint32_t)g.N, K = (uint32_t)g.K, M = (uint32_t)g.M; - /* A computed trellis's GEMV pays its decode in VALU work beside every token's dot and fold; - * from five tokens the narrow tile, which decodes a unit once for all of them, is faster - * (gate_up at 4 bits: GEMV 120 / 136 / 186 us at 3 / 4 / 8 tokens, the tile 151 / 154 / 157). */ - constexpr uint32_t gemv_max = F::KIND == kTrellisMad ? 4u : kGemvMaxM; - if (M <= gemv_max) return gemv_launch(g, scratch, scratch_bytes, stream); + if (M <= gemv_max()) return gemv_launch(g, stream); + if (M <= 16u && ((uintptr_t)g.y->data & 15u) == 0u) return m16_launch(g, stream); /* At most eight waves a block: each has its own transpose tile in LDS. The wave count changes * no output bit (r4d_gemm_fp8a8.hip's narrow_mw). */ const uint32_t mw = std::min(r4d_8a8_narrow_mw(N, M), 8u); @@ -701,11 +996,7 @@ extern "C" int64_t r4d_rad_gemm_iqr_m64_scratch(const RadArgs* a) { uint32_t ck = 0; const uint32_t k2 = r4d_8a8_narrow_ksplit((uint32_t)(sn > 0 ? sn : N), (uint32_t)K, (uint32_t)M, &ck, kIqrSplitWaves); - /* The band's bound covers the GEMV's split at M <= 4 too. */ - const int64_t tile = k2 > 1 ? (int64_t)k2 * M * N * 4 : 0; - const uint32_t kg = gemv_ksplit((uint32_t)N, (uint32_t)(K / kBlock)); - const int64_t gemv = kg > 1 ? (int64_t)kg * kGemvMaxM * N * 4 : 0; - return std::max(tile, gemv); + return k2 > 1 ? (int64_t)k2 * M * N * 4 : 0; } extern "C" int r4d_rad_gemm_iqr_m64(const RadArgs* a, RadStream s) { @@ -723,6 +1014,89 @@ extern "C" int r4d_rad_gemm_iqr_m64(const RadArgs* a, RadStream s) { return R4D_NO(RAD_E_UNSUPPORTED); } +namespace { + +/* gemm_nt_q_gated's operands at i8a8h: [0] a [1] a_scale [2] b [3] b_scale [4] q [5] scale + * [6] out_bf16. The weight is one [N, K] IQR plane, gate rows then up rows. */ +int gated_operands(const RadArgs* a, Operands* g, GatedOut* go) { + g->a = r4d_opt(a, 0); + g->as = r4d_opt(a, 1); + g->b = r4d_opt(a, 2); + g->bs = r4d_opt(a, 3); + g->y = nullptr; + const RadTensor* q = r4d_opt(a, 4); + const RadTensor* sc = r4d_opt(a, 5); + const RadTensor* yb = r4d_opt(a, 6); + if (!g->a || !g->as || !g->b || !g->bs || !q || !sc) return R4D_NO(RAD_E_INVAL); + if (!is_weight_dtype(g->b->dtype) || !is_scale_dtype(g->bs->dtype)) return R4D_NO(RAD_E_DTYPE); + g->word = g->b->dtype & kWordMask; + if ((g->bs->dtype & kWordMask) != g->word) return R4D_NO(RAD_E_DTYPE); + if (g->a->dtype != RAD_I8 || g->as->dtype != RAD_F32 || q->dtype != RAD_I8 || + sc->dtype != RAD_F32 || (yb && yb->dtype != RAD_BF16)) + return R4D_NO(RAD_E_DTYPE); + if (g->b->rank != 2 || g->a->rank < 2 || g->as->rank != 2) return R4D_NO(RAD_E_SHAPE); + g->M = g->a->shape[0]; + g->N = g->b->shape[0]; + g->K = g->b->shape[1]; + const long long n = g->N / 2; + if (g->M < 1 || g->M > 16 || g->N % 256 || g->K % kFK) return R4D_NO(RAD_E_SHAPE); + g->nkb = g->K / kBlock; + if (r4d_numel(g->a) != g->M * g->K || g->as->shape[0] != g->M || g->as->shape[1] != g->nkb) + return R4D_NO(RAD_E_SHAPE); + if (r4d_numel(q) != g->M * n || r4d_numel(sc) != g->M * (n / kBlock) || + (yb && r4d_numel(yb) != g->M * n)) + return R4D_NO(RAD_E_SHAPE); + g->a_ld = r4d_row_pitch(g->a); + g->sa_ld = r4d_row_pitch(g->as); + const long long q_ld = r4d_row_pitch(q), s_ld = r4d_row_pitch(sc), y_ld = yb ? r4d_row_pitch(yb) : 0; + if (g->a_ld < 0 || g->sa_ld < 0 || q_ld < 0 || s_ld < 0 || y_ld < 0) return R4D_NO(RAD_E_STRIDE); + if (!r4d_aligned(g->a->data, 16) || !r4d_aligned(g->b->data, 256) || !r4d_aligned(q->data, 4) || + q_ld % 4) + return R4D_NO(RAD_E_ALIGN); + const Form f = form(g->word); + if (is_trellis(f.kind) && g->N % ((long long)1 << f.lrun)) return R4D_NO(RAD_E_SHAPE); + go->Q = (int8_t*)q->data; + go->S = (float*)sc->data; + go->Yb = yb ? (uint16_t*)yb->data : nullptr; + go->n = (uint32_t)n; + go->q_ld = (uint32_t)q_ld; + go->s_ld = (uint32_t)s_ld; + go->y_ld = (uint32_t)y_ld; + return RAD_OK; +} + +template +int gated_launch(const Operands& g, const GatedOut& go, RadStream stream) { + if (g.M <= gemv_max()) return gemv_launch(g, stream, &go); + return m16_launch(g, stream, &go); +} + +} // namespace + +extern "C" int64_t r4d_rad_gemm_iqr_gated_scratch(const RadArgs* a) { + const long long M = r4d_geti_or(a, "M", 0), N = r4d_geti_or(a, "N", 0); + if (M < 1 || N < 2) return 0; + return (int64_t)align256(M * (N / 2) * 2); +} + +extern "C" int r4d_rad_gemm_iqr_gated(const RadArgs* a, RadStream s) { + Operands g; + GatedOut go; + const int rc = gated_operands(a, &g, &go); + if (rc != RAD_OK) return rc; + if (!a->scratch || (long long)a->scratch_bytes < align256(g.M * (g.N / 2) * 2)) + return R4D_NO(RAD_E_SCRATCH); + go.H = (uint16_t*)a->scratch; + go.cnt = r4d_8a8_split_ctr(s, go.Q); + if (!go.cnt || go.n / 128u > 8192u) return R4D_NO(RAD_E_DEVICE); + const uint32_t kw = kernel_word(g.word); +#define R4D_IQR_GO(...) \ + if (kw == R4D_IQR_T(__VA_ARGS__)::word()) return gated_launch(g, go, s); + R4D_IQR_FORMS(R4D_IQR_GO) +#undef R4D_IQR_GO + return R4D_NO(RAD_E_UNSUPPORTED); +} + extern "C" int64_t r4d_rad_gemm_iqr_tiled_scratch(const RadArgs* a) { const long long N = r4d_geti_or(a, "N", 0), K = r4d_geti_or(a, "K", 0); if (N < 1 || K < 1) return 0; diff --git a/libr4d/r4d_glm.hip b/libr4d/r4d_glm.hip index f4e0440d..0fa85cd8 100644 --- a/libr4d/r4d_glm.hip +++ b/libr4d/r4d_glm.hip @@ -183,6 +183,93 @@ __device__ __forceinline__ int router_sigmoid_row(const float* logits, const flo } return e; } +// router_sigmoid_group_topk in one wave per row: router_sigmoid_row's keys, but only the experts of +// the `kg` best of `ng` equal groups are selectable. A group ranks by the sum of its two highest +// ranks; lane g holds group g's sum (ng <= 32), and the groups are taken as the experts are, the +// largest first, equal sums to the lower group, a group with no finite pair never. Then the +// selection, the weights and the stores are router_sigmoid_row's. +template +__global__ void __launch_bounds__(128) + router_group_wave_kernel(const float* logits, const float* bias, int* ids, float* weights, + long lp, long bp, long ip, long wp, int m, int ne, int k, int ng, + int kg, int norm, float factor) { + const int lane = threadIdx.x & 31, r = blockIdx.x * 4 + (threadIdx.x >> 5); + if (r >= m) return; + const int gs = ne / ng; + float p[OWN], rank[OWN]; +#pragma unroll + for (int i = 0; i < OWN; ++i) { + const int e = lane + 32 * i, s = e < ne ? e : 0; + p[i] = 1.0f / (1.0f + expf(-logits[(long)r * lp + s])); + rank[i] = e < ne ? p[i] + bias[(long)s * bp] : -INFINITY; + } + float group = -INFINITY; + for (int g = 0; g < ng; ++g) { + float t0 = -INFINITY, t1 = -INFINITY; +#pragma unroll + for (int i = 0; i < OWN; ++i) { + const int e = lane + 32 * i; + if (e < ne && e / gs == g) { + const float v = rank[i]; + if (v > t0) { + t1 = t0; + t0 = v; + } else if (v > t1) + t1 = v; + } + } +#pragma unroll + for (int mask = 16; mask; mask >>= 1) { + const float o0 = __shfl_xor(t0, mask, 32), o1 = __shfl_xor(t1, mask, 32); + const float hi = fmaxf(t0, o0), lo = fmaxf(fminf(t0, o0), fmaxf(t1, o1)); + t0 = hi; + t1 = lo; + } + if (lane == g) group = t0 + t1; + } + unsigned long long gkey = lane < ng && group > -INFINITY ? router_rank_key(group, lane) : 0ull; + unsigned kept = 0; // bit g: group g is kept + unsigned long long below = ~0ull; + for (int j = 0; j < kg; ++j) { + const unsigned long long best = router_wave_max(gkey < below ? gkey : 0ull); + if (best) kept |= 1u << (int)~(uint32_t)best; + below = best; + } + unsigned long long key[OWN]; +#pragma unroll + for (int i = 0; i < OWN; ++i) { + const int e = lane + 32 * i; + key[i] = e < ne && ((kept >> (e / gs)) & 1u) ? router_rank_key(rank[i], e) : 0ull; + } + unsigned long long mine = 0; + below = ~0ull; + for (int j = 0; j < k; ++j) { + unsigned long long best = 0; +#pragma unroll + for (int i = 0; i < OWN; ++i) { + const unsigned long long c = key[i] < below ? key[i] : 0ull; + best = c > best ? c : best; + } + best = router_wave_max(best); + if (lane == j) mine = best; + below = best; + } + const int e = mine ? (int)~(uint32_t)mine : 0; + float chosen = 0; +#pragma unroll + for (int i = 0; i < OWN; ++i) { + const float v = __shfl(p[i], e & 31, 32); + if ((e >> 5) == i) chosen = v; + } + float total = 0; + for (int j = 0; j < k; ++j) + total += __int_as_float(__builtin_amdgcn_readlane(__float_as_int(chosen), j)); + const float mult = norm ? factor / (total + 1e-20f) : factor; + if (lane < k) { + ids[(long)r * ip + lane] = e; + weights[(long)r * wp + lane] = chosen * mult; + } +} template __global__ void __launch_bounds__(128) router_sigmoid_wave_kernel(const float* logits, const float* bias, int* ids, float* weights, @@ -248,6 +335,35 @@ int router_body(const RadArgs* a, RadStream stream) { lg.stride[0], bias.stride[0], ids.stride[0], w.stride[0], (int)lg.shape[0], (int)ne, (int)k, norm, factor); } +int router_group_body(const RadArgs* a, RadStream stream) { + if (!a || a->n_t < 4) return RAD_E_INVAL; + const auto &lg = a->t[0], &bias = a->t[1], &ids = a->t[2], &w = a->t[3]; + const long ne = r4d_geti_or(a, "n_expert", 0), k = r4d_geti_or(a, "top_k", 0), + ng = r4d_geti_or(a, "n_group", 0), kg = r4d_geti_or(a, "topk_group", 0); + const float factor = (float)r4d_getf(a, "route_scale", 0); + if (lg.dtype != RAD_F32 || bias.dtype != RAD_F32 || ids.dtype != RAD_I32 || w.dtype != RAD_F32) + return RAD_E_DTYPE; + if (ne < 1 || ne > 512 || k < 1 || k > 32 || ng < 1 || ng > 32 || ne % ng || ne / ng < 2 || + kg < 1 || kg > ng || k > kg * (ne / ng) || !std::isfinite(factor) || factor <= 0 || + !lg.data || !bias.data || !ids.data || !w.data || lg.rank != 2 || lg.shape[0] < 1 || + lg.shape[0] > 65535 || lg.shape[1] != ne || bias.rank != 1 || bias.shape[0] != ne || + ids.rank != 2 || w.rank != 2 || ids.shape[0] != lg.shape[0] || w.shape[0] != lg.shape[0] || + ids.shape[1] != k || w.shape[1] != k || lg.stride[1] != 1 || ids.stride[1] != 1 || + w.stride[1] != 1 || lg.stride[0] < ne || ids.stride[0] < k || w.stride[0] < k || + bias.stride[0] < 1) + return RAD_E_SHAPE; + const int norm = (int)(r4d_geti_or(a, "norm", 0) != 0); + const dim3 grid((unsigned)((lg.shape[0] + 3) / 4)); + if (ne <= 9 * 32) + return R4D_EMIT(stream, router_group_wave_kernel<9>, grid, dim3(128), 0, + (const float*)lg.data, (const float*)bias.data, (int*)ids.data, + (float*)w.data, lg.stride[0], bias.stride[0], ids.stride[0], w.stride[0], + (int)lg.shape[0], (int)ne, (int)k, (int)ng, (int)kg, norm, factor); + return R4D_EMIT(stream, router_group_wave_kernel<16>, grid, dim3(128), 0, + (const float*)lg.data, (const float*)bias.data, (int*)ids.data, (float*)w.data, + lg.stride[0], bias.stride[0], ids.stride[0], w.stride[0], (int)lg.shape[0], + (int)ne, (int)k, (int)ng, (int)kg, norm, factor); +} /* Operands: router_sigmoid_topk's four, moe_scatter's three outputs, then the optional gate and the * optional inverse. The sort is the single-workgroup form, so M * top_k must fit it; a larger pass * is refused rather than served at another cost. */ @@ -321,7 +437,18 @@ __global__ void swiglu_clamped_kernel(const uint16_t* gu, uint16_t* y, long gp, const float u = fminf(fmaxf(bf16_to_f32(gu[r * gp + n + i]), -limit), limit); y[r * yp + i] = f32_to_bf16((g / (1.0f + expf(-g))) * u); } -int clamped_body(const RadArgs* a, RadStream stream) { +// swiglu_step: the SiLU first, its value clipped above (Ling-3.0; vLLM's SwigluStepAndMul). +__global__ void swiglu_step_kernel(const uint16_t* gu, uint16_t* y, long gp, long yp, int n, + float limit) { + const long r = blockIdx.x; + const int i = blockIdx.y * 256 + threadIdx.x; + if (i >= n) return; + const float x = bf16_to_f32(gu[r * gp + i]); + const float g = fminf(x / (1.0f + expf(-x)), limit); + const float u = fminf(fmaxf(bf16_to_f32(gu[r * gp + n + i]), -limit), limit); + y[r * yp + i] = f32_to_bf16(g * u); +} +int clamped_body(const RadArgs* a, RadStream stream, bool step = false) { if (!a || a->n_t < 2) return RAD_E_INVAL; const auto &gu = a->t[0], &y = a->t[1]; const long n = r4d_geti_or(a, "n", 0); @@ -332,6 +459,10 @@ int clamped_body(const RadArgs* a, RadStream stream) { gu.shape[0] != y.shape[0] || gu.shape[1] != 2 * n || y.shape[1] != n || gu.stride[1] != 1 || y.stride[1] != 1 || gu.stride[0] < 2 * n || y.stride[0] < n) return RAD_E_SHAPE; + if (step) + return R4D_EMIT(stream, swiglu_step_kernel, dim3(y.shape[0], (n + 255) / 256), dim3(256), 0, + (const uint16_t*)gu.data, (uint16_t*)y.data, gu.stride[0], y.stride[0], + (int)n, limit); return R4D_EMIT(stream, swiglu_clamped_kernel, dim3(y.shape[0], (n + 255) / 256), dim3(256), 0, (const uint16_t*)gu.data, (uint16_t*)y.data, gu.stride[0], y.stride[0], (int)n, limit); @@ -405,6 +536,12 @@ int clamped_quant_body(const RadArgs* a, RadStream stream) { extern "C" int r4d_rad_swiglu_clamped(const RadArgs* a, RadStream stream) { return clamped_body(a, stream); } +extern "C" int r4d_rad_swiglu_step(const RadArgs* a, RadStream stream) { + return clamped_body(a, stream, true); +} +extern "C" int r4d_rad_router_sigmoid_group_topk(const RadArgs* a, RadStream stream) { + return router_group_body(a, stream); +} extern "C" int r4d_rad_swiglu_clamped_quant_fp8(const RadArgs* a, RadStream stream) { return clamped_quant_body(a, stream); } diff --git a/libr4d/r4d_gram_accum_fp8.hip b/libr4d/r4d_gram_accum_fp8.hip index 4bac179d..d2812fde 100644 --- a/libr4d/r4d_gram_accum_fp8.hip +++ b/libr4d/r4d_gram_accum_fp8.hip @@ -1,5 +1,5 @@ -// H += X^T X, in f32, over an E4M3 activation with a per-(row, group) scale, or over a plain bf16 -// one. +// H += X^T X, in f32, over an E4M3 or int8 activation with a per-(row, group) scale, or over a plain +// bf16 one. // // Purpose: the device half of GPTQ's Gram matrix `H = sum_t x_t x_t^T` over a calibration corpus, // for the 4-bit expert format (docs/MOE-W4.md). @@ -38,6 +38,9 @@ constexpr int kThreads = 256; constexpr int kMB = 32; // M rows staged a pass; 2 * 32 * 64 * 4 = 16 KiB of LDS constexpr int kTT = 4; +// I8: the codes are int8 (an int8 trunk's activation, quant_act_i8g's), otherwise E4M3; both carry an f32 +// scale per (row, group). +template __global__ __launch_bounds__(kThreads) void gram_accum_kernel( const void* __restrict__ qv, const float* __restrict__ sc, float* __restrict__ h, uint32_t M, uint32_t K, uint32_t q_ld, uint32_t s_ld, uint32_t h_ld, uint32_t grp, @@ -79,14 +82,24 @@ __global__ __launch_bounds__(kThreads) void gram_accum_kernel( // contract), so a dword load at c1 < K stays inside the allocation. const uint32_t w = *(const uint32_t*)((const uint8_t*)qv + qrow + c1); const float s = sc[(size_t)m * s_ld + g1]; - const v2f lo = r4d_fp8::e4m3_pk(w), hi = r4d_fp8::e4m3_pk(w); - a0 = lo.x * s; a1 = lo.y * s; a2 = hi.x * s; a3 = hi.y * s; + if constexpr (I8) { + a0 = (float)(int8_t)(w & 0xffu) * s; a1 = (float)(int8_t)(w >> 8) * s; + a2 = (float)(int8_t)(w >> 16) * s; a3 = (float)(int8_t)(w >> 24) * s; + } else { + const v2f lo = r4d_fp8::e4m3_pk(w), hi = r4d_fp8::e4m3_pk(w); + a0 = lo.x * s; a1 = lo.y * s; a2 = hi.x * s; a3 = hi.y * s; + } } if (c2 < K) { const uint32_t w = *(const uint32_t*)((const uint8_t*)qv + qrow + c2); const float s = sc[(size_t)m * s_ld + g2]; - const v2f lo = r4d_fp8::e4m3_pk(w), hi = r4d_fp8::e4m3_pk(w); - b0 = lo.x * s; b1 = lo.y * s; b2 = hi.x * s; b3 = hi.y * s; + if constexpr (I8) { + b0 = (float)(int8_t)(w & 0xffu) * s; b1 = (float)(int8_t)(w >> 8) * s; + b2 = (float)(int8_t)(w >> 16) * s; b3 = (float)(int8_t)(w >> 24) * s; + } else { + const v2f lo = r4d_fp8::e4m3_pk(w), hi = r4d_fp8::e4m3_pk(w); + b0 = lo.x * s; b1 = lo.y * s; b2 = hi.x * s; b3 = hi.y * s; + } } } // Columns past K stage as zeros and contribute nothing; the store masks them anyway. @@ -216,8 +229,9 @@ extern "C" int r4d_gram_accum_fp8_tile(void) { return kTile; } // s [M][ceil(K/grp)] f32, `s_ld` elements a row (0 = ceil(K/grp)) // h [K][K] f32, `h_ld` elements a row (0 = K), read and written; with `upper` // only the 64-wide tiles on or above the diagonal are added to -extern "C" int r4d_gram_accum_fp8(long q, long s, long h, int M, int K, int grp, - int q_ld, int s_ld, int h_ld, int upper, long stream) { +namespace { +int gram_accum_codes(bool i8, long q, long s, long h, int M, int K, int grp, int q_ld, int s_ld, + int h_ld, int upper, long stream) { if (!q || !s || !h) return -1; if (M <= 0 || K <= 0) return -2; if (K % 4) return -3; // a staging slot is one dword of four codes @@ -227,12 +241,30 @@ extern "C" int r4d_gram_accum_fp8(long q, long s, long h, int M, int K, int grp, if (!s_ld) s_ld = (K + grp - 1) / grp; if (!h_ld) h_ld = K; const uint32_t nt = (uint32_t)((K + kTile - 1) / kTile); - hipLaunchKernelGGL(gram_accum_kernel, dim3(nt, nt), dim3(kThreads), 0, - (hipStream_t)stream, (const void*)q, (const float*)s, (float*)h, - (uint32_t)M, (uint32_t)K, (uint32_t)q_ld, (uint32_t)s_ld, (uint32_t)h_ld, - (uint32_t)grp, (uint32_t)(upper != 0)); + if (i8) + hipLaunchKernelGGL(gram_accum_kernel, dim3(nt, nt), dim3(kThreads), 0, + (hipStream_t)stream, (const void*)q, (const float*)s, (float*)h, + (uint32_t)M, (uint32_t)K, (uint32_t)q_ld, (uint32_t)s_ld, + (uint32_t)h_ld, (uint32_t)grp, (uint32_t)(upper != 0)); + else + hipLaunchKernelGGL(gram_accum_kernel, dim3(nt, nt), dim3(kThreads), 0, + (hipStream_t)stream, (const void*)q, (const float*)s, (float*)h, + (uint32_t)M, (uint32_t)K, (uint32_t)q_ld, (uint32_t)s_ld, + (uint32_t)h_ld, (uint32_t)grp, (uint32_t)(upper != 0)); return hipGetLastError() == hipSuccess ? 0 : -4; } +} // namespace + +extern "C" int r4d_gram_accum_fp8(long q, long s, long h, int M, int K, int grp, + int q_ld, int s_ld, int h_ld, int upper, long stream) { + return gram_accum_codes(false, q, s, h, M, K, grp, q_ld, s_ld, h_ld, upper, stream); +} + +// q [M][K] int8, otherwise as r4d_gram_accum_fp8 +extern "C" int r4d_gram_accum_i8(long q, long s, long h, int M, int K, int grp, + int q_ld, int s_ld, int h_ld, int upper, long stream) { + return gram_accum_codes(true, q, s, h, M, K, grp, q_ld, s_ld, h_ld, upper, stream); +} // a [M][K] bf16, `a_ld` elements a row (0 = K) // h [K][K] f32, `h_ld` elements a row (0 = K), read and written; `upper` as above @@ -260,7 +292,8 @@ extern "C" int r4d_rad_gram_accum(const RadArgs* a, RadStream s) { const RadTensor* sc = r4d_opt(a, GA_S); const RadTensor* h = r4d_opt(a, GA_H); if (!q || !sc || !h) return R4D_NO(RAD_E_INVAL); - if (q->dtype != RAD_F8E4M3 || sc->dtype != RAD_F32 || h->dtype != RAD_F32) + if ((q->dtype != RAD_F8E4M3 && q->dtype != RAD_I8) || sc->dtype != RAD_F32 || + h->dtype != RAD_F32) return R4D_NO(RAD_E_DTYPE); /* Rows are dim 0 and everything after is the row, as in r4d_rad_quant_act_fp8; `sc` and `h` * are rank 2 by definition. */ @@ -274,9 +307,9 @@ extern "C" int r4d_rad_gram_accum(const RadArgs* a, RadStream s) { if (h->shape[0] != K || h->shape[1] != K) return R4D_NO(RAD_E_SHAPE); const long long qp = r4d_row_pitch(q), sp = r4d_row_pitch(sc), hp = r4d_row_pitch(h); if (qp < 0 || sp < 0 || hp < 0) return R4D_NO(RAD_E_STRIDE); - const int e = r4d_gram_accum_fp8(r4d_addr(q), r4d_addr(sc), r4d_addr(h), (int)M, (int)K, - (int)grp, (int)qp, (int)sp, (int)hp, - (int)r4d_geti_or(a, "upper", 0), (long)(uintptr_t)s); + const int e = gram_accum_codes(q->dtype == RAD_I8, r4d_addr(q), r4d_addr(sc), r4d_addr(h), + (int)M, (int)K, (int)grp, (int)qp, (int)sp, (int)hp, + (int)r4d_geti_or(a, "upper", 0), (long)(uintptr_t)s); return e == 0 ? RAD_OK : RAD_E_SHAPE; } diff --git a/libr4d/r4d_hc_bf16.hip b/libr4d/r4d_hc_bf16.hip index d688e0c5..3fce8351 100644 --- a/libr4d/r4d_hc_bf16.hip +++ b/libr4d/r4d_hc_bf16.hip @@ -62,6 +62,7 @@ #include #include "r4d.h" #include "r4d_emit.h" +#include "r4d_chain.h" #include "r4d_gdn_args.h" #include "r4d_common.h" #include "r4d_gdn_wmma.h" @@ -305,6 +306,49 @@ __device__ __forceinline__ void hc8_dot_up(const float* __restrict__ sd, long lr } } +/* hc8_up_dot_rows over `d` already in floats: the same fmaf sequence on the same values. */ +template +__device__ __forceinline__ void hc8_up_dot_rows_f(const float* __restrict__ sdf, long lr, const Q* o, + int q4, float (*acc)[RG]) { + const long G = lr / 4, k0 = (long)q4 * G; + const int nq = (int)(G / 16); +#pragma unroll + for (int m = 0; m < RPT; ++m) +#pragma unroll + for (int r = 0; r < RG; ++r) acc[m][r] = 0.0f; +#pragma unroll + for (int i = 0; i < 8; ++i) { + if (i >= nq) break; + float wf[RPT][16]; +#pragma unroll + for (int m = 0; m < RPT; ++m) { + e4m3x8(o[m].c[i].x, o[m].c[i].y, wf[m]); + e4m3x8(o[m].c[i].z, o[m].c[i].w, wf[m] + 8); + } +#pragma unroll + for (int r = 0; r < RG; ++r) { + const float4* dr = (const float4*)(sdf + (long)r * lr + k0 + 16 * i); + const float4 d0 = dr[0], d1 = dr[1], d2 = dr[2], d3 = dr[3]; + const float dv[16] = { d0.x, d0.y, d0.z, d0.w, d1.x, d1.y, d1.z, d1.w, + d2.x, d2.y, d2.z, d2.w, d3.x, d3.y, d3.z, d3.w }; +#pragma unroll + for (int t = 0; t < 16; ++t) { +#pragma unroll + for (int m = 0; m < RPT; ++m) acc[m][r] = fmaf(wf[m][t], dv[t], acc[m][r]); + } + } + } +#pragma unroll + for (int m = 0; m < RPT; ++m) +#pragma unroll + for (int r = 0; r < RG; ++r) { + float a = acc[m][r] * o[m].sc; + a += __shfl_xor(a, 1); + a += __shfl_xor(a, 2); + acc[m][r] = a; + } +} + /* hc8_dot_up split at its loads, so a kernel can issue them before `d` exists: a * quarter's codes and its group scale, then the same arithmetic in the same order. */ struct Hc8UpQuarter { @@ -1224,7 +1268,9 @@ __device__ __forceinline__ void hc_rot_group(float* v, int lane, unsigned char* /* The fused form's wait (hc_read_fused_kernel, below): its B blocks hold here until every A * block has published `d` and the scales. */ -constexpr unsigned kHcSyncCtr = 3; /* tickets, A blocks done, B blocks past the wait */ +/* Tickets, A blocks done, B blocks past the wait; then decode form G's tile counters. */ +constexpr unsigned kHcGTilesMax = 192; /* tiles x row groups */ +constexpr unsigned kHcSyncCtr = 3 + kHcGTilesMax; __device__ __forceinline__ void hc_role_wait(unsigned int* __restrict__ sync, unsigned na, unsigned nb_all) { @@ -1268,7 +1314,7 @@ __device__ __forceinline__ void hc_role_wait(unsigned int* __restrict__ sync, un /* RPT > 1 (E4M3 only) gives the workgroup RPT * 64 rows of W_up, RPT a thread with one * quarter each (hc8_up_dot_rows), and 1 / RPT the grid (kUpRpt). WAIT is the fused form's * (hc_read_fused_kernel): `d` and kernel A's scales are read only after hc_role_wait. */ -template +template __device__ __forceinline__ void hc_up_mix_body(const void* __restrict__ upv, long uld, const unsigned short* __restrict__ dbuf, const unsigned short* __restrict__ h, const float* __restrict__ w, @@ -1302,7 +1348,9 @@ __device__ __forceinline__ void hc_up_mix_body(const void* __restrict__ upv, lon constexpr int kDStage = 2; const bool dpre = lr <= (long)kDStage * kThreads; unsigned short dv[RG][kDStage]; /* bf16 bits; the E4M3 dot keeps them as is */ - if (dpre && !WAIT) { + /* PREW (the chained form): the constant W_up quarters first, then the chain wait, + * then everything the predecessor wrote. */ + if (!PREW && dpre && !WAIT) { #pragma unroll for (int r = 0; r < RG; ++r) { const bool live = r0 + r < rows; @@ -1325,6 +1373,47 @@ __device__ __forceinline__ void hc_up_mix_body(const void* __restrict__ upv, lon } } const bool one = RG * ipb <= kThreads; + /* PF: the chained E4M3 form issues everything the predecessor wrote in one batch. */ + constexpr bool PF = PREW && F8; + float NpreP[kHcMax]; + uint4 dq[2]; + if constexpr (PF) { + const bool item = one && tid < RG * ipb; + const int rl = item ? tid / ipb : 0, ii = tid - rl * ipb; + const long rP = r0 + rl < rows ? r0 + rl : rows - 1; + float wvP[kHcMax]; +#pragma unroll + for (int c = 0; c < kHcMax; ++c) wvP[c] = (item && c < hc) ? w[(long)c * n + i0 + ii] : 0.0f; + r4d_chain_wait(); + const long live = rows - r0 < RG ? rows - r0 : RG; + const int nq8 = (int)(live * lr / 8); +#pragma unroll + for (int s2 = 0; s2 < 2; ++s2) { + const int i = tid + s2 * kThreads; + dq[s2] = i < nq8 ? ((const uint4*)(dbuf + r0 * lr))[i] : make_uint4(0u, 0u, 0u, 0u); + } + float hvP[kHcMax], scP[kHcMax]; +#pragma unroll + for (int c = 0; c < kHcMax; ++c) { + hvP[c] = (item && c < hc) ? bf2f(h[rP * hrow + (long)c * n + i0 + ii]) : 0.0f; + scP[c] = (item && c < hc) ? scalein[rP * kHcMax + c] : 0.0f; + } +#pragma unroll + for (int c = 0; c < kHcMax; ++c) NpreP[c] = nbf(hvP[c] * scP[c] * (wvP[c] + wadd)); + } else if constexpr (PREW) { + r4d_chain_wait(); + if (dpre) { +#pragma unroll + for (int r = 0; r < RG; ++r) { + const bool live = r0 + r < rows; +#pragma unroll + for (int s2 = 0; s2 < kDStage; ++s2) { + const long k = tid + (long)s2 * kThreads; + dv[r][s2] = (live && k < lr) ? dbuf[(r0 + r) * lr + k] : (unsigned short)0; + } + } + } + } float Npre[kHcMax]; if constexpr (WAIT) { /* The fused form (hc_read_fused_kernel): `h` and the gain here, kernel A's half after it. */ @@ -1359,6 +1448,9 @@ __device__ __forceinline__ void hc_up_mix_body(const void* __restrict__ upv, lon Npre[c] = nbf(hv[c] * scalein[r * kHcMax + c] * (wv[c] + wadd)); } } + } else if constexpr (PF) { +#pragma unroll + for (int c = 0; c < kHcMax; ++c) Npre[c] = NpreP[c]; } else if (one && tid < RG * ipb) { const int rl = tid / ipb, ii = tid - rl * ipb; const long r = r0 + rl < rows ? r0 + rl : rows - 1; @@ -1371,9 +1463,22 @@ __device__ __forceinline__ void hc_up_mix_body(const void* __restrict__ upv, lon } } - /* `d` as bf16 for the E4M3 dot (hc8_up_dot_rows), as floats for the bf16 one. */ + /* `d` as bf16 for the E4M3 dot (hc8_up_dot_rows), as floats for the bf16 one; as floats for the + * chained E4M3 form (PF). */ unsigned short* const sdh = (unsigned short*)sd; - if (dpre) { + if constexpr (PF) { +#pragma unroll + for (int s2 = 0; s2 < 2; ++s2) { + const int i = tid + s2 * kThreads; + if (i < RG * (int)lr / 8) { + float f[8]; + bf8_f(dq[s2], f); + float4* dst = (float4*)(sd + (long)i * 8); + dst[0] = make_float4(f[0], f[1], f[2], f[3]); + dst[1] = make_float4(f[4], f[5], f[6], f[7]); + } + } + } else if (dpre) { #pragma unroll for (int r = 0; r < RG; ++r) #pragma unroll @@ -1401,7 +1506,8 @@ __device__ __forceinline__ void hc_up_mix_body(const void* __restrict__ upv, lon * E4M3 form takes each row four threads at a time, as in hc_up_kernel. */ if constexpr (F8) { float acc[RPT][RG]; - hc8_up_dot_rows(sdh, lr, wq, q4, acc); + if constexpr (PF) hc8_up_dot_rows_f(sd, lr, wq, q4, acc); + else hc8_up_dot_rows(sdh, lr, wq, q4, acc); #pragma unroll for (int m = 0; m < RPT; ++m) #pragma unroll @@ -1466,9 +1572,14 @@ __device__ __forceinline__ void hc_up_mix_body(const void* __restrict__ upv, lon __HIP_MEMORY_SCOPE_AGENT); __syncthreads(); if (s_arrived + 1u != (unsigned)nb) return; - if (tid == 0) - __hip_atomic_store(&ctr[slot], 0u, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_AGENT); - __threadfence(); + /* The reset goes after this block's codes (wave 0 always quantises a row), so the + * acquire waits for no store. */ + __builtin_amdgcn_fence(__ATOMIC_ACQUIRE, "agent"); + struct ResetAtEnd { + unsigned int* c; + bool on; + __device__ ~ResetAtEnd() { if (on) __hip_atomic_store(c, 0u, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_AGENT); } + } reset_at_end{ &ctr[slot], tid == 0 }; /* One wave per row (RG <= wave count); a lane takes four of the group's 128 channels, one * packed dword of codes. */ @@ -1508,6 +1619,647 @@ void hc_up_mix_kernel(const void* __restrict__ upv, long uld, hc_up_mix_body(upv, uld, dbuf, h, w, scalein, x, q, qs, rq, rqs, ctr, rows, n, hc, lr, hrow, xrow, qrow, srow, rqrow, rsrow, wadd, blockIdx.x, blockIdx.y); } +/* Its chained form (r4d_chain.h): the body waits itself, after the W_up loads (PREW). */ +template +__global__ __launch_bounds__(kThreads) +void r4dchain_hc_up_mix(const void* __restrict__ upv, long uld, + const unsigned short* __restrict__ dbuf, + const unsigned short* __restrict__ h, const float* __restrict__ w, + const float* __restrict__ scalein, + unsigned short* __restrict__ x, unsigned char* __restrict__ q, + float* __restrict__ qs, unsigned char* __restrict__ rq, + float* __restrict__ rqs, unsigned int* __restrict__ ctr, + long rows, long n, int hc, long lr, long hrow, long xrow, + long qrow, long srow, long rqrow, long rsrow, float wadd) { + hc_up_mix_body(upv, uld, dbuf, h, w, scalein, x, q, qs, rq, rqs, ctr, rows, n, hc, lr, hrow, xrow, qrow, srow, rqrow, rsrow, wadd, blockIdx.x, blockIdx.y); + r4d_chain_done(); +} + +/* ============================================================== hc_read, decode form G (A') + * + * Kernel A for one to eight decode rows at Flash-Next's shape as + * (16-column tile, sub-stream c) blocks plus one inject tile: the grouped norm of stream c needs + * only h[r, c, :], so a block holds every row of the step and reads its W_down slice once. The + * slice and the norm gain are constant and load before the chain wait; everything after it is one + * round trip for h, the norm (hc_read_a_body's arithmetic: same scales, same N), bf16 WMMA dots + * and a deterministic finisher: the last of a tile's hc blocks sums their partials in ascending c. + * + * WMMA operand order (r4d_gdn_wmma.h): lane half hh of a 32-wide K chunk takes 16 contiguous + * elements, the first eight in one step and the last eight in the next, for N and for W alike, so + * both operands map every K slot to the same element and each chunk's 32 products are summed. A + * chunk lies in one 128-wide scale group; a wave's 320-wide slice spans at most three, and the + * accumulator is scaled and folded into P at each group change. */ +constexpr long kHcGN = 2560; /* n: the form's only width */ +constexpr int kHcGTile = 16; /* W_down columns a block owns */ +constexpr int kHcGSlice = (int)kHcGN / kWaves; /* 320: K a wave covers in its stream */ +constexpr int kHcGChunks = kHcGSlice / 32; /* 10 */ +constexpr int kHcGPer = (int)kHcGN / kThreads; /* 10 values of h a thread a row */ + +__device__ __forceinline__ v8bf hcg_e4m3_v8bf(uint32_t lo, uint32_t hi) { + float f[8]; + e4m3x8(lo, hi, f); + union { unsigned u[4]; v8bf v; } r; +#pragma unroll + for (int i = 0; i < 4; ++i) /* exact: an E4M3 value has three mantissa bits */ + r.u[i] = __builtin_amdgcn_perm(__float_as_uint(f[2 * i + 1]), __float_as_uint(f[2 * i]), + 0x07060302u); + return r.v; +} +__device__ __forceinline__ v8bf hcg_v8bf(uint32_t a, uint32_t b, uint32_t c, uint32_t d) { + union { uint4 u; v8bf v; } r; + r.u = make_uint4(a, b, c, d); + return r.v; +} + +template +__device__ __forceinline__ void hc_read_g_down_body( + const unsigned short* __restrict__ h, const float* __restrict__ w, + const unsigned char* __restrict__ downv, long dld, const unsigned short* __restrict__ injw, + unsigned short* __restrict__ dout, unsigned short* __restrict__ inj, + float* __restrict__ scaleout, float* __restrict__ part, unsigned int* __restrict__ tctr, + long lr, long hrow, long irow, float eps, float wadd, int ntd, long rows) { + extern __shared__ __attribute__((aligned(16))) unsigned short sN[]; /* [RG][kHcGN] */ + __shared__ float s_red[kWaves][16][16]; + __shared__ float s_part[kWaves][RG]; + __shared__ float s_scale[RG]; + __shared__ unsigned s_last; + constexpr int hc = 4; + constexpr long HN = hc * kHcGN; + constexpr long NG = HN / r4d_hc8::kDownGroup; + const int tid = threadIdx.x, lane = tid & (kWave - 1), wave = tid / kWave; + const int t = (int)blockIdx.x / hc, c = (int)blockIdx.x % hc; + const bool itile = t == ntd; + /* This block's row group: rows r0 .. r0 + rr - 1 of the step (RG a group, the last may be short). */ + const long r0 = (long)blockIdx.y * RG; + const int rr = (int)(rows - r0 < RG ? rows - r0 : RG); + h += r0 * hrow; + dout += r0 * lr; + if (inj) inj += r0 * irow; + if (scaleout) scaleout += r0 * kHcMax; + part += (long)blockIdx.y * (ntd + 1) * hc * RG * kHcGTile; + tctr += (long)blockIdx.y * (ntd + 1); + const int col = lane & 15, hh = lane >> 4; + const long kslice = (long)c * kHcGN + (long)wave * kHcGSlice; /* the wave's first K */ + const long kl = kslice + 16 * hh; /* the lane half's */ + + /* ---- constant operands, before the chain wait */ + uint4 wc[kHcGChunks]; + float wsc[3] = { 0.0f, 0.0f, 0.0f }; + const long g0 = kslice / r4d_hc8::kDownGroup; + if (!itile) { + long k = (long)t * kHcGTile + col; + if (k >= lr) k = lr - 1; + const unsigned char* row = downv + k * dld; +#pragma unroll + for (int j = 0; j < kHcGChunks; ++j) wc[j] = *(const uint4*)(row + kl + 32 * j); + const float* sr = (const float*)(row + HN); +#pragma unroll + for (int i = 0; i < 3; ++i) wsc[i] = sr[g0 + i < NG ? g0 + i : NG - 1]; + } else { + /* The inject rows are bf16: the slice's first half (five chunks, two loads each) now. */ + const unsigned short* row = injw + (long)(col < hc ? col : hc - 1) * HN; +#pragma unroll + for (int j = 0; j < kHcGChunks / 2; ++j) { + wc[2 * j] = *(const uint4*)(row + kl + 32 * j); + wc[2 * j + 1] = *(const uint4*)(row + kl + 32 * j + 8); + } + } + float wv[kHcGPer]; +#pragma unroll + for (int p = 0; p < kHcGPer; ++p) wv[p] = w[(long)c * kHcGN + tid + (long)p * kThreads]; + if constexpr (CH) r4d_chain_wait(); + + /* ---- the grouped norm of stream c for every row, as hc_read_a_body's preloaded form */ + uint32_t hv[RG][kHcGPer]; +#pragma unroll + for (int r = 0; r < RG; ++r) +#pragma unroll + for (int p = 0; p < kHcGPer; ++p) + hv[r][p] = bfw(h + (long)(r < rr ? r : rr - 1) * hrow + (long)c * kHcGN + tid + (long)p * kThreads); +#pragma unroll + for (int r = 0; r < RG; ++r) { + float acc = 0.0f; +#pragma unroll + for (int p = 0; p < kHcGPer; ++p) { const float v = bfw_f(hv[r][p]); acc += v * v; } + acc = wave_sum(acc); + if (lane == 0) s_part[wave][r] = acc; + } + __syncthreads(); + if (tid < RG) { + float ss = 0.0f; + for (int k = 0; k < kWaves; ++k) ss += s_part[k][tid]; + s_scale[tid] = __frsqrt_rn(ss / (float)kHcGN + eps); + if (t == 0 && scaleout && tid < rr) scaleout[(long)tid * kHcMax + c] = s_scale[tid]; + } + __syncthreads(); +#pragma unroll + for (int r = 0; r < RG; ++r) { + const float sc = s_scale[r]; +#pragma unroll + for (int p = 0; p < kHcGPer; ++p) + sN[(long)r * kHcGN + tid + (long)p * kThreads] = f2bf(bfw_f(hv[r][p]) * sc * (wv[p] + wadd)); + } + __syncthreads(); + + /* ---- the dots: rows of N as A (rows past RG repeat the last; their D rows are dropped) */ + const unsigned short* nr = sN + (long)(col < rr ? col : rr - 1) * kHcGN + (kl - (long)c * kHcGN); + float P[8]; +#pragma unroll + for (int e = 0; e < 8; ++e) P[e] = 0.0f; + v8f D = {}; + if (!itile) { + int gi = 0; +#pragma unroll + for (int j = 0; j < kHcGChunks; ++j) { + const int g = (int)((kslice + 32 * j) / r4d_hc8::kDownGroup - g0); + if (g != gi) { +#pragma unroll + for (int e = 0; e < 8; ++e) { P[e] = fmaf(D[e], wsc[gi], P[e]); D[e] = 0.0f; } + gi = g; + } + const uint4 a0 = *(const uint4*)(nr + 32 * j); + const uint4 a1 = *(const uint4*)(nr + 32 * j + 8); + D = mma(hcg_v8bf(a0.x, a0.y, a0.z, a0.w), hcg_e4m3_v8bf(wc[j].x, wc[j].y), D); + D = mma(hcg_v8bf(a1.x, a1.y, a1.z, a1.w), hcg_e4m3_v8bf(wc[j].z, wc[j].w), D); + } +#pragma unroll + for (int e = 0; e < 8; ++e) P[e] = fmaf(D[e], wsc[gi], P[e]); + } else { + const unsigned short* row = injw + (long)(col < hc ? col : hc - 1) * HN; +#pragma unroll + for (int half = 0; half < 2; ++half) { + if (half == 1) { +#pragma unroll + for (int j = 0; j < kHcGChunks / 2; ++j) { + const long o = kl + 32 * (j + kHcGChunks / 2); + wc[2 * j] = *(const uint4*)(row + o); + wc[2 * j + 1] = *(const uint4*)(row + o + 8); + } + } +#pragma unroll + for (int j = 0; j < kHcGChunks / 2; ++j) { + const int jj = j + half * (kHcGChunks / 2); + const uint4 a0 = *(const uint4*)(nr + 32 * jj); + const uint4 a1 = *(const uint4*)(nr + 32 * jj + 8); + D = mma(hcg_v8bf(a0.x, a0.y, a0.z, a0.w), + hcg_v8bf(wc[2 * j].x, wc[2 * j].y, wc[2 * j].z, wc[2 * j].w), D); + D = mma(hcg_v8bf(a1.x, a1.y, a1.z, a1.w), + hcg_v8bf(wc[2 * j + 1].x, wc[2 * j + 1].y, wc[2 * j + 1].z, wc[2 * j + 1].w), D); + } + } +#pragma unroll + for (int e = 0; e < 8; ++e) P[e] = D[e]; + } + + /* ---- the waves' partials, summed in ascending wave order; this block's into scratch */ +#pragma unroll + for (int e = 0; e < 8; ++e) s_red[wave][col][8 * hh + e] = P[e]; + __syncthreads(); + const long pstride = (long)RG * kHcGTile; /* one stream's partials of a tile */ + float* const pt = part + (long)t * hc * pstride; + if (tid < RG * kHcGTile) { + const int r = tid / kHcGTile, n = tid % kHcGTile; + float v = 0.0f; + for (int k = 0; k < kWaves; ++k) v += s_red[k][n][r]; + pt[(long)c * pstride + r * kHcGTile + n] = v; + } + + /* ---- the tile's last block finishes: c ascending, then silu or the doubled sigmoid */ + __threadfence(); + __syncthreads(); + if (tid == 0) + s_last = __hip_atomic_fetch_add(&tctr[t], 1u, __ATOMIC_ACQ_REL, __HIP_MEMORY_SCOPE_AGENT) + + 1u == (unsigned)hc; + __syncthreads(); + if (!s_last) return; + /* Every wave: a workgroup's waves may sit on both CUs of a WGP, each with its own cache. The + * reset goes after the payload, so this acquire waits for no store. */ + __builtin_amdgcn_fence(__ATOMIC_ACQUIRE, "agent"); + struct ResetAtEnd { + unsigned int* c; + bool on; + __device__ ~ResetAtEnd() { if (on) __hip_atomic_store(c, 0u, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_AGENT); } + } reset_at_end{ &tctr[t], tid == 0 }; + if (tid < RG * kHcGTile) { + const int r = tid / kHcGTile, n = tid % kHcGTile; + const float* pp = pt + r * kHcGTile + n; + float acc = pp[0]; + acc += pp[pstride]; + acc += pp[2 * pstride]; + acc += pp[3 * pstride]; + const float inv_hc = 1.0f / (float)hc; + if (r >= rr) { + } else if (!itile) { + const long k = (long)t * kHcGTile + n; + if (k < lr) dout[(long)r * lr + k] = f2bf(siluf_(acc * inv_hc)); + } else if (n < hc && inj) { + inj[(long)r * irow + n] = f2bf(2.0f * sigmoidf_(acc * inv_hc)); + } + } +} + +/* ============================================================== hc_read, decode form S (A' for 9..16 rows) + * + * As form G's kernel A', but the norm's scale is applied after the dot: + * the A operand bf16(h * (w + wadd)) is formed from h in global memory per WMMA fragment, so nothing of N sits in + * LDS and one block takes every row of the step (MT m-tiles). A lane's squares of h ride along; the block sums + * them per row in a fixed order (a whole stream a block: every tile gets the same scale). P = sum over the + * stream's groups of D_g * w_scale_g is multiplied by s[r, c] after the waves' fixed-order sum. */ +template +__device__ __forceinline__ void hc_read_s_down_body( + const unsigned short* __restrict__ h, const float* __restrict__ w, + const unsigned char* __restrict__ downv, long dld, const unsigned short* __restrict__ injw, + unsigned short* __restrict__ dout, unsigned short* __restrict__ inj, + float* __restrict__ scaleout, float* __restrict__ part, unsigned int* __restrict__ tctr, + long lr, long hrow, long irow, float eps, float wadd, int ntd, long rows) { + constexpr int RM = 16 * MT; /* rows the m-tiles hold */ + __shared__ float s_red[kWaves][16][RM]; + __shared__ __attribute__((aligned(16))) float s_w[kHcGN]; /* this stream's w + wadd */ + __shared__ float s_ss[kWaves][RM]; + __shared__ float s_sc[RM]; + __shared__ unsigned s_last; + constexpr int hc = 4; + constexpr long HN = hc * kHcGN; + constexpr long NG = HN / r4d_hc8::kDownGroup; + const int tid = threadIdx.x, lane = tid & (kWave - 1), wave = tid / kWave; + const int t = (int)blockIdx.x / hc, c = (int)blockIdx.x % hc; + const bool itile = t == ntd; + const int col = lane & 15, hh = lane >> 4; + const long kslice = (long)c * kHcGN + (long)wave * kHcGSlice; + const long kl = kslice + 16 * hh; + /* This block's row group (RM rows a group; the last may be short). */ + { + const long r0 = (long)blockIdx.y * RM; + h += r0 * hrow; + dout += r0 * lr; + if (inj) inj += r0 * irow; + if (scaleout) scaleout += r0 * kHcMax; + part += (long)blockIdx.y * (ntd + 1) * hc * RM * kHcGTile; + tctr += (long)blockIdx.y * (ntd + 1); + rows = rows - r0 < RM ? rows - r0 : RM; + } + + /* ---- constant operands, before the chain wait (form G's) */ + uint4 wc[kHcGChunks]; + float wsc[3] = { 0.0f, 0.0f, 0.0f }; + const long g0 = kslice / r4d_hc8::kDownGroup; + if (!itile) { + long k = (long)t * kHcGTile + col; + if (k >= lr) k = lr - 1; + const unsigned char* row = downv + k * dld; +#pragma unroll + for (int j = 0; j < kHcGChunks; ++j) wc[j] = *(const uint4*)(row + kl + 32 * j); + const float* sr = (const float*)(row + HN); +#pragma unroll + for (int i = 0; i < 3; ++i) wsc[i] = sr[g0 + i < NG ? g0 + i : NG - 1]; + } else { + const unsigned short* row = injw + (long)(col < hc ? col : hc - 1) * HN; +#pragma unroll + for (int j = 0; j < kHcGChunks / 2; ++j) { + wc[2 * j] = *(const uint4*)(row + kl + 32 * j); + wc[2 * j + 1] = *(const uint4*)(row + kl + 32 * j + 8); + } + } +#pragma unroll + for (int p = 0; p < kHcGPer; ++p) { + const long i = tid + (long)p * kThreads; + s_w[i] = w[(long)c * kHcGN + i] + wadd; + } + if constexpr (CH) r4d_chain_wait(); + __syncthreads(); + + /* ---- the dots, A = bf16(h * (w + wadd)) per fragment, squares alongside */ + const float* wl = s_w + (kl - (long)c * kHcGN); + const unsigned short* irow_w = injw + (long)(col < hc ? col : hc - 1) * HN; + float ss[MT]; + float P[MT][8]; +#pragma unroll 1 + for (int mt = 0; mt < MT; ++mt) { + const long r = 16 * mt + col; + const unsigned short* hrp = h + (r < rows ? r : rows - 1) * hrow + kl; + if (itile && mt > 0) { +#pragma unroll + for (int jj = 0; jj < kHcGChunks / 2; ++jj) { + wc[2 * jj] = *(const uint4*)(irow_w + kl + 32 * jj); + wc[2 * jj + 1] = *(const uint4*)(irow_w + kl + 32 * jj + 8); + } + } + float ssm = 0.0f, Pm[8]; +#pragma unroll + for (int e = 0; e < 8; ++e) Pm[e] = 0.0f; + v8f D = {}; + int gi = 0; +#pragma unroll + for (int j = 0; j < kHcGChunks; ++j) { + if (!itile) { + const int g = (int)((kslice + 32 * j) / r4d_hc8::kDownGroup - g0); + if (g != gi) { +#pragma unroll + for (int e = 0; e < 8; ++e) { Pm[e] = fmaf(D[e], wsc[gi], Pm[e]); D[e] = 0.0f; } + gi = g; + } + } else if (j == kHcGChunks / 2) { +#pragma unroll + for (int jj = 0; jj < kHcGChunks / 2; ++jj) { + const long o = kl + 32 * (jj + kHcGChunks / 2); + wc[2 * jj] = *(const uint4*)(irow_w + o); + wc[2 * jj + 1] = *(const uint4*)(irow_w + o + 8); + } + } + v8bf bA, bB; + if (!itile) { + bA = hcg_e4m3_v8bf(wc[j].x, wc[j].y); + bB = hcg_e4m3_v8bf(wc[j].z, wc[j].w); + } else { + const int q = 2 * (j % (kHcGChunks / 2)); + bA = hcg_v8bf(wc[q].x, wc[q].y, wc[q].z, wc[q].w); + bB = hcg_v8bf(wc[q + 1].x, wc[q + 1].y, wc[q + 1].z, wc[q + 1].w); + } +#pragma unroll + for (int hf = 0; hf < 2; ++hf) { + const uint4 hv4 = *(const uint4*)(hrp + 32 * j + 8 * hf); + const float4 wa = *(const float4*)(wl + 32 * j + 8 * hf), wb = *(const float4*)(wl + 32 * j + 8 * hf + 4); + const float wf[8] = { wa.x, wa.y, wa.z, wa.w, wb.x, wb.y, wb.z, wb.w }; + float v[8]; + bf8_f(hv4, v); + float av[8]; +#pragma unroll + for (int e = 0; e < 8; ++e) { ssm = fmaf(v[e], v[e], ssm); av[e] = v[e] * wf[e]; } + const uint4 pa = f2bf8(av); + D = mma(hcg_v8bf(pa.x, pa.y, pa.z, pa.w), hf ? bB : bA, D); + } + __builtin_amdgcn_sched_barrier(0); + } +#pragma unroll + for (int e = 0; e < 8; ++e) Pm[e] = itile ? D[e] : fmaf(D[e], wsc[gi], Pm[e]); + /* MT is 1 or 2: select into the per-m-tile arrays without a dynamic register index */ +#pragma unroll + for (int q = 0; q < MT; ++q) + if (q == mt) { + ss[q] = ssm; +#pragma unroll + for (int e = 0; e < 8; ++e) P[q][e] = Pm[e]; + } + } + + /* ---- the stream's scale for every row: lanes l and l + 16 hold the same row's two halves */ +#pragma unroll + for (int mt = 0; mt < MT; ++mt) { + const float v = ss[mt] + __shfl_xor(ss[mt], 16); + if (hh == 0) s_ss[wave][16 * mt + col] = v; +#pragma unroll + for (int e = 0; e < 8; ++e) s_red[wave][col][16 * mt + 8 * hh + e] = P[mt][e]; + } + __syncthreads(); + if (tid < RM) { + float q = 0.0f; + for (int k = 0; k < kWaves; ++k) q += s_ss[k][tid]; + s_sc[tid] = __frsqrt_rn(q / (float)kHcGN + eps); + if (t == 0 && scaleout && tid < rows) scaleout[(long)tid * kHcMax + c] = s_sc[tid]; + } + __syncthreads(); + const long pstride = (long)rows * kHcGTile; + float* const pt = part + (long)t * hc * pstride; + for (int i = tid; i < rows * kHcGTile; i += kThreads) { + const int r = i / kHcGTile, n = i % kHcGTile; + float v = 0.0f; + for (int k = 0; k < kWaves; ++k) v += s_red[k][n][r]; + pt[(long)c * pstride + i] = v * s_sc[r]; + } + + /* ---- the tile's last block finishes, as form G's */ + __threadfence(); + __syncthreads(); + if (tid == 0) + s_last = __hip_atomic_fetch_add(&tctr[t], 1u, __ATOMIC_ACQ_REL, __HIP_MEMORY_SCOPE_AGENT) + + 1u == (unsigned)hc; + __syncthreads(); + if (!s_last) return; + __builtin_amdgcn_fence(__ATOMIC_ACQUIRE, "agent"); + struct ResetAtEnd { + unsigned int* c; + bool on; + __device__ ~ResetAtEnd() { if (on) __hip_atomic_store(c, 0u, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_AGENT); } + } reset_at_end{ &tctr[t], tid == 0 }; + const float inv_hc = 1.0f / (float)hc; + for (int i = tid; i < rows * kHcGTile; i += kThreads) { + const int r = i / kHcGTile, n = i % kHcGTile; + const float* pp = pt + i; + float acc = pp[0]; + acc += pp[pstride]; + acc += pp[2 * pstride]; + acc += pp[3 * pstride]; + if (!itile) { + const long k = (long)t * kHcGTile + n; + if (k < lr) dout[(long)r * lr + k] = f2bf(siluf_(acc * inv_hc)); + } else if (n < hc && inj) { + inj[(long)r * irow + n] = f2bf(2.0f * sigmoidf_(acc * inv_hc)); + } + } +} + +/* ============================================================== hc_read, kernel B3 (forms G and S) + * Kernel B for forms G and S at lr 320: the up product as WMMA over d with W_up's exact quarter + * scales, then the mix in each lane. Block b: channels 32b .. 32b + 31 of all streams; wave w: + * channels 32b + 4w .. + 3 (16 W_up rows). RG: the step's rows (1..16). W_up and its scales load + * before the chain wait. */ +constexpr int kHcBCh = 32; /* channels a block */ +template +__device__ __forceinline__ void hc_up_w_body( + const unsigned char* __restrict__ upv, long uld, const unsigned short* __restrict__ dbuf, + const unsigned short* __restrict__ h, const float* __restrict__ w, const float* __restrict__ scalein, + unsigned short* __restrict__ x, unsigned char* __restrict__ q, float* __restrict__ qs, + unsigned char* __restrict__ rq, float* __restrict__ rqs, unsigned int* __restrict__ ctr, + long rows, long n, long lr, long hrow, long xrow, long qrow, long srow, long rqrow, long rsrow, + float wadd) { + constexpr int hc = 4; + constexpr int kLr = 320, kQ = kLr / 4, kStepsQ = kQ / 16; /* 80 codes, 5 steps a quarter */ + __shared__ __attribute__((aligned(16))) unsigned short sd[RG * kLr]; /* d [RG][lr] */ + __shared__ float s_usc[kWaves][16][4]; + __shared__ unsigned s_arrived; + const int tid = threadIdx.x, lane = tid & (kWave - 1), wave = tid / kWave; + const int col = lane & 15, hh = lane >> 4; + const long i0 = (long)blockIdx.x * kHcBCh; + const long iw = i0 + 4 * wave; + + /* ---- constant operands before the chain wait: this lane's W_up row (m = col), its half of every quarter */ + const unsigned char* wr = upv + ((long)(col & 3) * n + iw + (col >> 2)) * uld; + uint2 wc[4][kStepsQ]; +#pragma unroll + for (int qq = 0; qq < 4; ++qq) +#pragma unroll + for (int st = 0; st < kStepsQ; ++st) wc[qq][st] = *(const uint2*)(wr + qq * kQ + 40 * hh + 8 * st); + if (hh == 0) { +#pragma unroll + for (int qq = 0; qq < 4; ++qq) s_usc[wave][col][qq] = ((const float*)(wr + kLr))[qq]; + } + float wv[2][4]; +#pragma unroll + for (int a = 0; a < 2; ++a) +#pragma unroll + for (int c = 0; c < hc; ++c) wv[a][c] = w[(long)c * n + iw + 2 * hh + a] + wadd; + if constexpr (CH) r4d_chain_wait(); + + /* ---- one batch: d (uint4, contiguous rows), the mix items' h and scales */ + constexpr int kD8 = RG * kLr / 8; + uint4 dq[(kD8 + kThreads - 1) / kThreads]; +#pragma unroll + for (int i = 0; i < (kD8 + kThreads - 1) / kThreads; ++i) { + const int k = tid + i * kThreads; + dq[i] = k < kD8 ? ((const uint4*)dbuf)[k] : make_uint4(0u, 0u, 0u, 0u); + } + const int rr = col < RG ? col : RG - 1; + float sc[4]; + uint32_t hv2[4]; +#pragma unroll + for (int c = 0; c < hc; ++c) { + sc[c] = scalein[(long)rr * kHcMax + c]; + hv2[c] = *(const uint32_t*)(h + (long)rr * hrow + (long)c * n + iw + 2 * hh); + } +#pragma unroll + for (int i = 0; i < (kD8 + kThreads - 1) / kThreads; ++i) { + const int k = tid + i * kThreads; + if (k < kD8) ((uint4*)sd)[k] = dq[i]; + } + float Npre[2][4]; +#pragma unroll + for (int c = 0; c < hc; ++c) +#pragma unroll + for (int a = 0; a < 2; ++a) + Npre[a][c] = nbf(bfw_f(a ? (hv2[c] >> 16) : (hv2[c] & 0xffffu)) * sc[c] * wv[a][c]); + __syncthreads(); + + /* ---- the up product: per quarter five WMMA steps, folded with the quarter's scale */ + float U[8]; +#pragma unroll + for (int e = 0; e < 8; ++e) U[e] = 0.0f; + const unsigned short* dr = sd + (long)rr * kLr + 40 * hh; +#pragma unroll + for (int qq = 0; qq < 4; ++qq) { + v8f D = {}; +#pragma unroll + for (int st = 0; st < kStepsQ; ++st) { + const uint4 b = *(const uint4*)(dr + qq * kQ + 8 * st); + D = mma(hcg_e4m3_v8bf(wc[qq][st].x, wc[qq][st].y), hcg_v8bf(b.x, b.y, b.z, b.w), D); + } +#pragma unroll + for (int e = 0; e < 8; ++e) U[e] = fmaf(D[e], s_usc[wave][8 * hh + e][qq], U[e]); + } + + /* ---- sigmoid, narrowed; the mix in the lane (D row 8hh + e = channel 2hh + e/4, stream e%4) */ + const float inv_hc = 1.0f / (float)hc; + if (col < RG && col < rows) { + float acc[2]; +#pragma unroll + for (int a = 0; a < 2; ++a) { + acc[a] = 0.0f; +#pragma unroll + for (int c = 0; c < hc; ++c) acc[a] += nbf(sigmoidf_(U[4 * a + c])) * Npre[a][c]; + acc[a] *= inv_hc; + } + *(uint32_t*)(x + (long)col * xrow + iw + 2 * hh) = f2bf2(acc[0], acc[1]); + } + if (!q || !ctr) return; + + /* ---- the 128-channel group's last block quantises it */ + const int nb = kUpTB / kHcBCh; + __threadfence(); + __syncthreads(); + const unsigned slot = (unsigned)(i0 / kUpTB); + if (tid == 0) + s_arrived = __hip_atomic_fetch_add(&ctr[slot], 1u, __ATOMIC_ACQ_REL, __HIP_MEMORY_SCOPE_AGENT); + __syncthreads(); + if (s_arrived + 1u != (unsigned)nb) return; + __builtin_amdgcn_fence(__ATOMIC_ACQUIRE, "agent"); + const long base = (i0 / kUpTB) * kUpTB; + for (int r = wave; r < RG && r < rows; r += kWaves) { + const unsigned short* const xr = x + (long)r * xrow + base; + float v[4]; +#pragma unroll + for (int j = 0; j < 4; ++j) v[j] = bf2f(xr[lane * 4 + j]); + float m = fmaxf(fmaxf(fabsf(v[0]), fabsf(v[1])), fmaxf(fabsf(v[2]), fabsf(v[3]))); + m = r4d_wave_max(m); + const float scq = m > 0.0f ? m * (1.0f / q8_top()) : 1.0f; + const float inv = 1.0f / scq; + if (lane == 0) qs[(long)r * srow + base / kUpTB] = scq; + const uint32_t pk = q8_pack4(v[0], v[1], v[2], v[3], inv); + *(unsigned*)(q + (long)r * qrow + base + lane * 4) = (unsigned)pk; + if (rq) hc_rot_group(v, lane, rq + (long)r * rqrow + base, rqs + (long)r * rsrow + base / kUpTB); + } + if (tid == 0) __hip_atomic_store(&ctr[slot], 0u, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_AGENT); +} + +#define R4D_HCW_PARAMS \ + const unsigned char* __restrict__ upv, long uld, const unsigned short* __restrict__ dbuf, \ + const unsigned short* __restrict__ h, const float* __restrict__ w, \ + const float* __restrict__ scalein, unsigned short* __restrict__ x, unsigned char* __restrict__ q, \ + float* __restrict__ qs, unsigned char* __restrict__ rq, float* __restrict__ rqs, \ + unsigned int* __restrict__ ctr, long rows, long n, long lr, long hrow, long xrow, long qrow, \ + long srow, long rqrow, long rsrow, float wadd +#define R4D_HCW_ARGS upv, uld, dbuf, h, w, scalein, x, q, qs, rq, rqs, ctr, rows, n, lr, hrow, xrow, \ + qrow, srow, rqrow, rsrow, wadd +template +__global__ __launch_bounds__(kThreads) void hc_up_w_kernel(R4D_HCW_PARAMS) { + hc_up_w_body(R4D_HCW_ARGS); +} +template +__global__ __launch_bounds__(kThreads) void r4dchain_hc_up_w(R4D_HCW_PARAMS) { + hc_up_w_body(R4D_HCW_ARGS); + r4d_chain_done(); +} +template +__global__ __launch_bounds__(kThreads) +void hc_read_s_down_kernel(const unsigned short* __restrict__ h, const float* __restrict__ w, + const unsigned char* __restrict__ downv, long dld, + const unsigned short* __restrict__ injw, + unsigned short* __restrict__ dout, unsigned short* __restrict__ inj, + float* __restrict__ scaleout, float* __restrict__ part, + unsigned int* __restrict__ tctr, long lr, long hrow, long irow, + float eps, float wadd, int ntd, long rows) { + hc_read_s_down_body(h, w, downv, dld, injw, dout, inj, scaleout, part, tctr, lr, + hrow, irow, eps, wadd, ntd, rows); +} +template +__global__ __launch_bounds__(kThreads) +void r4dchain_hc_read_s_down(const unsigned short* __restrict__ h, const float* __restrict__ w, + const unsigned char* __restrict__ downv, long dld, + const unsigned short* __restrict__ injw, + unsigned short* __restrict__ dout, unsigned short* __restrict__ inj, + float* __restrict__ scaleout, float* __restrict__ part, + unsigned int* __restrict__ tctr, long lr, long hrow, long irow, + float eps, float wadd, int ntd, long rows) { + hc_read_s_down_body(h, w, downv, dld, injw, dout, inj, scaleout, part, tctr, lr, + hrow, irow, eps, wadd, ntd, rows); + r4d_chain_done(); +} + +template +__global__ __launch_bounds__(kThreads) +void hc_read_g_down_kernel(const unsigned short* __restrict__ h, const float* __restrict__ w, + const unsigned char* __restrict__ downv, long dld, + const unsigned short* __restrict__ injw, + unsigned short* __restrict__ dout, unsigned short* __restrict__ inj, + float* __restrict__ scaleout, float* __restrict__ part, + unsigned int* __restrict__ tctr, long lr, long hrow, long irow, + float eps, float wadd, int ntd, long rows) { + hc_read_g_down_body(h, w, downv, dld, injw, dout, inj, scaleout, part, tctr, lr, + hrow, irow, eps, wadd, ntd, rows); +} +/* The chained form: the body waits itself, after the constant loads. */ +template +__global__ __launch_bounds__(kThreads) +void r4dchain_hc_read_g_down(const unsigned short* __restrict__ h, const float* __restrict__ w, + const unsigned char* __restrict__ downv, long dld, + const unsigned short* __restrict__ injw, + unsigned short* __restrict__ dout, unsigned short* __restrict__ inj, + float* __restrict__ scaleout, float* __restrict__ part, + unsigned int* __restrict__ tctr, long lr, long hrow, long irow, + float eps, float wadd, int ntd, long rows) { + hc_read_g_down_body(h, w, downv, dld, injw, dout, inj, scaleout, part, tctr, lr, + hrow, irow, eps, wadd, ntd, rows); + r4d_chain_done(); +} + /* ============================================================== hc_read, A and B in one grid * * At decode, kernel A is mostly latency (its norm prologue and the L2 round trips around @@ -1525,9 +2277,7 @@ void hc_up_mix_kernel(const void* __restrict__ upv, long uld, * * Bit-identical to the two launches: the same bodies, the same per-block work. */ template -__global__ __launch_bounds__(kThreads) -__attribute__((amdgpu_waves_per_eu(9, 9))) -void hc_read_fused_kernel(const unsigned short* __restrict__ h, const float* __restrict__ w, +__device__ __forceinline__ void hc_read_fused_kernel_body(const unsigned short* __restrict__ h, const float* __restrict__ w, const void* __restrict__ downv, long dld, const unsigned short* __restrict__ injw, unsigned short* __restrict__ dbuf, unsigned short* __restrict__ inj, @@ -1560,6 +2310,46 @@ void hc_read_fused_kernel(const unsigned short* __restrict__ h, const float* __r wadd, b % gxb, b / gxb, sync, na, nb_all); } +/* The plain and chained forms (r4d_chain.h): every block leaves through the wrapper. */ +template +__global__ __launch_bounds__(kThreads) +__attribute__((amdgpu_waves_per_eu(9, 9))) +void hc_read_fused_kernel(const unsigned short* __restrict__ h, const float* __restrict__ w, + const void* __restrict__ downv, long dld, + const unsigned short* __restrict__ injw, + unsigned short* __restrict__ dbuf, unsigned short* __restrict__ inj, + float* __restrict__ scale, long ta, long irow, float eps, + const void* __restrict__ upv, long uld, + unsigned short* __restrict__ x, unsigned char* __restrict__ q, + float* __restrict__ qs, unsigned char* __restrict__ rq, + float* __restrict__ rqs, unsigned int* __restrict__ ctr, + long rows, long n, int hc, long lr, long hrow, long xrow, + long qrow, long srow, long rqrow, long rsrow, float wadd, + unsigned int* __restrict__ sync, + unsigned na, unsigned gxa, unsigned gxb, unsigned nb_all) { + hc_read_fused_kernel_body(h, w, downv, dld, injw, dbuf, inj, scale, ta, irow, eps, upv, uld, x, q, qs, rq, rqs, ctr, rows, n, hc, lr, hrow, xrow, qrow, srow, rqrow, rsrow, wadd, sync, na, gxa, gxb, nb_all); +} +template +__global__ __launch_bounds__(kThreads) +__attribute__((amdgpu_waves_per_eu(9, 9))) +void r4dchain_hc_read_fused(const unsigned short* __restrict__ h, const float* __restrict__ w, + const void* __restrict__ downv, long dld, + const unsigned short* __restrict__ injw, + unsigned short* __restrict__ dbuf, unsigned short* __restrict__ inj, + float* __restrict__ scale, long ta, long irow, float eps, + const void* __restrict__ upv, long uld, + unsigned short* __restrict__ x, unsigned char* __restrict__ q, + float* __restrict__ qs, unsigned char* __restrict__ rq, + float* __restrict__ rqs, unsigned int* __restrict__ ctr, + long rows, long n, int hc, long lr, long hrow, long xrow, + long qrow, long srow, long rqrow, long rsrow, float wadd, + unsigned int* __restrict__ sync, + unsigned na, unsigned gxa, unsigned gxb, unsigned nb_all) { + r4d_chain_wait(); + hc_read_fused_kernel_body(h, w, downv, dld, injw, dbuf, inj, scale, ta, irow, eps, upv, uld, x, q, qs, rq, rqs, ctr, rows, n, hc, lr, hrow, xrow, qrow, srow, rqrow, rsrow, wadd, sync, na, gxa, gxb, nb_all); + r4d_chain_done(); +} + /* Row group size: the row count, up to eight. RG is a template parameter so `acc[RG]` stays in * registers. Every size from 1 to 8 is instantiated, so up to eight rows read the weight once * (a five-row verify split 4 + 1 would read W_up twice). Output bytes do not depend on RG. @@ -1845,9 +2635,14 @@ void hc_up_mix_2grid_kernel(const void* __restrict__ upv, long uld, __HIP_MEMORY_SCOPE_AGENT); __syncthreads(); if (s_arrived + 1u != (unsigned)nb) return; - if (tid == 0) - __hip_atomic_store(&ctr[slot], 0u, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_AGENT); - __threadfence(); + /* The reset goes after this block's codes (wave 0 always quantises a row), so the + * acquire waits for no store. */ + __builtin_amdgcn_fence(__ATOMIC_ACQUIRE, "agent"); + struct ResetAtEnd { + unsigned int* c; + bool on; + __device__ ~ResetAtEnd() { if (on) __hip_atomic_store(c, 0u, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_AGENT); } + } reset_at_end{ &ctr[slot], tid == 0 }; /* One wave per row (RG <= wave count); a lane takes four of the group's 128 channels, one * packed dword of codes. */ @@ -1923,7 +2718,7 @@ static inline int hc_up_mix_launch(const RadTensor* up, long uld, bool f8, bool unsigned int* ctr, long long rows, long long n, int hc, long long lr, long long hrow, long long xrow, long long qrow, long long srow, long long rqrow, long long rsrow, float wadd, - RadStream stream) { + RadStream stream, bool ch = false) { if (g_hc_decode_form == 1) return hc_up_mix_2grid_launch(up, uld, f8, i8, dbuf, h, w, scale, x, q, qs, rq, rqs, ctr, rows, n, hc, lr, hrow, xrow, qrow, srow, rqrow, rsrow, wadd, @@ -1935,7 +2730,8 @@ static inline int hc_up_mix_launch(const RadTensor* up, long uld, bool f8, bool const unsigned lds = (unsigned)(rg * lr * sizeof(float)); const void* upp = up->data; #define HC_UPMIX_K(RG_, F8_, I8_, RPT_) \ - emit_rc = R4D_EMIT(stream, (hc_up_mix_kernel), grid, dim3(kThreads), lds, \ + emit_rc = R4D_EMIT(stream, (ch ? &r4dchain_hc_up_mix \ + : &hc_up_mix_kernel), grid, dim3(kThreads), lds, \ upp, uld, dbuf, h, w, scale, x, q, qs, rq, rqs, ctr, (long)rows, (long)n, \ hc, \ (long)lr, (long)hrow, (long)xrow, (long)qrow, (long)srow, (long)rqrow, \ @@ -2077,8 +2873,7 @@ constexpr long kDecMinRows = 8; // below this the per-row kernels win; the t * N. Bit-identical to the fused form: same thread stride, wave_sum and ascending sum over the wave * partials. Removing the launch itself would need `h`'s producer (hc_write, another op with its * own arena) to compute the scales. */ -__global__ __launch_bounds__(kThreads) -void hc_norm_scale_kernel(const unsigned short* __restrict__ h, float* __restrict__ scaleout, +__device__ __forceinline__ void hc_norm_scale_kernel_body(const unsigned short* __restrict__ h, float* __restrict__ scaleout, long rows, long n, long hrow, float eps) { __shared__ float s_part[kWaves]; const long r = blockIdx.y, c = blockIdx.x; @@ -2097,6 +2892,20 @@ void hc_norm_scale_kernel(const unsigned short* __restrict__ h, float* __restric } } +/* The plain and chained forms (r4d_chain.h): every block leaves through the wrapper. */ +__global__ __launch_bounds__(kThreads) +void hc_norm_scale_kernel(const unsigned short* __restrict__ h, float* __restrict__ scaleout, + long rows, long n, long hrow, float eps) { + hc_norm_scale_kernel_body(h, scaleout, rows, n, hrow, eps); +} +__global__ __launch_bounds__(kThreads) +void r4dchain_hc_norm_scale(const unsigned short* __restrict__ h, float* __restrict__ scaleout, + long rows, long n, long hrow, float eps) { + r4d_chain_wait(); + hc_norm_scale_kernel_body(h, scaleout, rows, n, hrow, eps); + r4d_chain_done(); +} + /* ==================================================== tile shape follows the row count * * RT varies with rows: 128 suits thousands of rows, but at 32 it would stage 128 rows to use 32 @@ -2128,8 +2937,7 @@ constexpr int kTKSPLIT_WANT = 128; // workgroups the down product aims to cove * at eight sequences). `ncol` is lr + hc with gains, lr without; columns at or past lr read injw * and take the sigmoid epilogue. */ template -__global__ __launch_bounds__(kThreads) -void hc_down_tiled_kernel(const unsigned short* __restrict__ h, const float* __restrict__ w, +__device__ __forceinline__ void hc_down_tiled_kernel_body(const unsigned short* __restrict__ h, const float* __restrict__ w, const void* __restrict__ downv, long dld, const float* __restrict__ scalein, const unsigned short* __restrict__ injw, @@ -2225,10 +3033,37 @@ void hc_down_tiled_kernel(const unsigned short* __restrict__ h, const float* __r } } +/* The plain and chained forms (r4d_chain.h): every block leaves through the wrapper. */ +template +__global__ __launch_bounds__(kThreads) +void hc_down_tiled_kernel(const unsigned short* __restrict__ h, const float* __restrict__ w, + const void* __restrict__ downv, long dld, + const float* __restrict__ scalein, + const unsigned short* __restrict__ injw, + unsigned short* __restrict__ dout, unsigned short* __restrict__ inj, + float* __restrict__ part, + long rows, long n, int hc, long lr, long ncol, long hrow, long irow, + long kc, float wadd) { + hc_down_tiled_kernel_body(h, w, downv, dld, scalein, injw, dout, inj, part, rows, n, hc, lr, ncol, hrow, irow, kc, wadd); +} +template +__global__ __launch_bounds__(kThreads) +void r4dchain_hc_down_tiled(const unsigned short* __restrict__ h, const float* __restrict__ w, + const void* __restrict__ downv, long dld, + const float* __restrict__ scalein, + const unsigned short* __restrict__ injw, + unsigned short* __restrict__ dout, unsigned short* __restrict__ inj, + float* __restrict__ part, + long rows, long n, int hc, long lr, long ncol, long hrow, long irow, + long kc, float wadd) { + r4d_chain_wait(); + hc_down_tiled_kernel_body(h, w, downv, dld, scalein, injw, dout, inj, part, rows, n, hc, lr, ncol, hrow, irow, kc, wadd); + r4d_chain_done(); +} + /* The split-K reduce: partials summed in ascending z (reproducible), then the epilogue: silu for a * W_down column, doubled sigmoid for an inject column. */ -__global__ __launch_bounds__(kThreads) -void hc_down_reduce_kernel(const float* __restrict__ part, unsigned short* __restrict__ dout, +__device__ __forceinline__ void hc_down_reduce_kernel_body(const float* __restrict__ part, unsigned short* __restrict__ dout, unsigned short* __restrict__ inj, long rows, long lr, long ncol, long irow, int ksplit, float inv_hc) { const long i = (long)blockIdx.x * kThreads + threadIdx.x; @@ -2251,6 +3086,22 @@ void hc_down_reduce_kernel(const float* __restrict__ part, unsigned short* __res else inj[r * irow + (col - lr)] = f2bf(2.0f * sigmoidf_(s * inv_hc)); } +/* The plain and chained forms (r4d_chain.h): every block leaves through the wrapper. */ +__global__ __launch_bounds__(kThreads) +void hc_down_reduce_kernel(const float* __restrict__ part, unsigned short* __restrict__ dout, + unsigned short* __restrict__ inj, long rows, long lr, long ncol, + long irow, int ksplit, float inv_hc) { + hc_down_reduce_kernel_body(part, dout, inj, rows, lr, ncol, irow, ksplit, inv_hc); +} +__global__ __launch_bounds__(kThreads) +void r4dchain_hc_down_reduce(const float* __restrict__ part, unsigned short* __restrict__ dout, + unsigned short* __restrict__ inj, long rows, long lr, long ncol, + long irow, int ksplit, float inv_hc) { + r4d_chain_wait(); + hc_down_reduce_kernel_body(part, dout, inj, rows, lr, ncol, irow, ksplit, inv_hc); + r4d_chain_done(); +} + /* The prefill tile: rows, down-product columns per workgroup and up-product channels per * workgroup. 112 columns is three tiles over 320 + 4, the fewest that fit the 128-row A tile and * the B tile in LDS twice per CU; faster than 64 and 128 at 129 to 4096 rows. */ @@ -2546,8 +3397,7 @@ void hc_up_tiled_kernel(const void* __restrict__ upv, long uld, * Bit-identical to the unfused pair: `u` and `N` are narrowed to bf16 where hc_mix would read them * back, both pass through LDS as bf16, and the sum over c ascends. */ template -__global__ __launch_bounds__(kThreads) -void hc_up_mix_tiled_kernel(const void* __restrict__ upv, long uld, +__device__ __forceinline__ void hc_up_mix_tiled_kernel_body(const void* __restrict__ upv, long uld, const unsigned short* __restrict__ dbuf, const unsigned short* __restrict__ h, const float* __restrict__ w, const float* __restrict__ scalein, @@ -2819,6 +3669,36 @@ void hc_up_mix_tiled_kernel(const void* __restrict__ upv, long uld, } } +/* The plain and chained forms (r4d_chain.h): every block leaves through the wrapper. */ +template +__global__ __launch_bounds__(kThreads) +void hc_up_mix_tiled_kernel(const void* __restrict__ upv, long uld, + const unsigned short* __restrict__ dbuf, + const unsigned short* __restrict__ h, const float* __restrict__ w, + const float* __restrict__ scalein, + unsigned short* __restrict__ x, unsigned char* __restrict__ q, + float* __restrict__ qs, unsigned char* __restrict__ rq, + float* __restrict__ rqs, unsigned int* __restrict__ ctr, + long rows, long n, int hc, long lr, long hrow, long xrow, + long qrow, long srow, long rqrow, long rsrow, float wadd) { + hc_up_mix_tiled_kernel_body(upv, uld, dbuf, h, w, scalein, x, q, qs, rq, rqs, ctr, rows, n, hc, lr, hrow, xrow, qrow, srow, rqrow, rsrow, wadd); +} +template +__global__ __launch_bounds__(kThreads) +void r4dchain_hc_up_mix_tiled(const void* __restrict__ upv, long uld, + const unsigned short* __restrict__ dbuf, + const unsigned short* __restrict__ h, const float* __restrict__ w, + const float* __restrict__ scalein, + unsigned short* __restrict__ x, unsigned char* __restrict__ q, + float* __restrict__ qs, unsigned char* __restrict__ rq, + float* __restrict__ rqs, unsigned int* __restrict__ ctr, + long rows, long n, int hc, long lr, long hrow, long xrow, + long qrow, long srow, long rqrow, long rsrow, float wadd) { + r4d_chain_wait(); + hc_up_mix_tiled_kernel_body(upv, uld, dbuf, h, w, scalein, x, q, qs, rq, rqs, ctr, rows, n, hc, lr, hrow, xrow, qrow, srow, rqrow, rsrow, wadd); + r4d_chain_done(); +} + /* The tiled up-mix with its K passes unpipelined, for r4d_hc_read_pin_decode(1) (see the * two-grid decode kernels above). */ template @@ -3250,7 +4130,8 @@ static inline void hc_up_mix_tiled_launch(int rt, bool f8, bool i8, const void* #define HC_UM_CASE3(RT_, F8_, I8_) \ do { \ if (g_hc_decode_form == 1) HC_UM_K((hc_up_mix_tiled_2grid_kernel)); \ - else HC_UM_K((hc_up_mix_tiled_kernel)); \ + else HC_UM_K((g_r4d_chain_arg ? &r4dchain_hc_up_mix_tiled \ + : &hc_up_mix_tiled_kernel)); \ } while (0) #define HC_UM_CASE(RT_, F8_) \ do { if (i8) HC_UM_CASE3(RT_, F8_, true); else HC_UM_CASE3(RT_, F8_, false); } while (0) @@ -4140,7 +5021,8 @@ static inline void hc_down_tiled_launch(int rt, bool f8, const unsigned short* h const dim3 gd((unsigned)((ncol + kTNT - 1) / kTNT), (unsigned)((rows + rt - 1) / rt), (unsigned)((HN + kc - 1) / kc)); #define HC_DOWN_CASE(RT_, F8_) \ - hipLaunchKernelGGL((hc_down_tiled_kernel), gd, dim3(kThreads), 0, \ + hipLaunchKernelGGL((g_r4d_chain_arg ? &r4dchain_hc_down_tiled \ + : &hc_down_tiled_kernel), gd, dim3(kThreads), 0, \ (hipStream_t)s, h, w, down, dld, scale, injw, dbuf, inj, part, rows, n, \ hc, lr, ncol, hrow, irow, kc, wadd) switch (rt) { @@ -4638,8 +5520,39 @@ extern "C" int r4d_rad_hc_read(const RadArgs* a, RadStream s) { * (prefill), else 32 or 64 with a K-split down product. Below kDecMinRows the per-row kernels * win. */ bool fused = false; - const bool tiled = can_tile && rows >= kDecMinRows; + /* Decode forms G (one to eight rows) and S (9..16) at Flash-Next's shape with the inject gains: + * kernel A' as (tile, stream) blocks, its partials after `fixed` and its tile counters behind the + * fused form's, then kernel B3. From 17 rows the tiled path (chained) measured faster (x8 +2.9 % + * against two 16-row groups of form S). */ + constexpr long hcg_max = 16; + const long hcg_nt = (lr + kHcGTile - 1) / kHcGTile; + unsigned int* hcg_ctr = nullptr; + float* hcg_part = nullptr; + /* Form S: one block a (tile, stream) holds every row. */ + const bool hcs = rows > 8 && rows <= 16 && (hrow % 8) == 0 + && (((uintptr_t)h->data & 15u) == 0u) && (((uintptr_t)w->data & 15u) == 0u); + const long hcg_rg = hcs ? 16 : rows <= 8 ? rows : 8; /* rows a group of kernel A' */ + const long hcg_gy = (rows + hcg_rg - 1) / hcg_rg; + if (f8 && hc == 4 && n == kHcGN && lr % kHcGTile == 0 && lr <= 2L * kThreads + && (hcg_nt + 1) * hcg_gy <= (long)kHcGTilesMax + && rows >= 1 && rows <= hcg_max && injw && inj && g_hc_decode_form == 0 + && a->scratch_bytes >= fixed + hcg_gy * (hcg_nt + 1) * hc * hcg_rg * kHcGTile * 4) { + unsigned int* mc = hc_mix_ctr(s); + if (mc) { + hcg_ctr = mc + kMaxMixCtr + 3; + hcg_part = (float*)((unsigned char*)a->scratch + fixed); + } + } + const bool hcg = hcg_ctr != nullptr; + const bool hcg_ch = hcg && r4d_geti_or(a, "chain", 0) != 0; + /* Kernel B3 for forms G and S at lr 320, a single row group; else the chained up-mix. */ + const bool hcw = hcg && lr == 320 && rows <= 16 && (rows <= 8 || hcs) && (n % 128) == 0 + && (hrow % 2) == 0 && (xrow % 2) == 0; + const bool tiled = can_tile && rows >= kDecMinRows && !hcg; if (tiled) { + /* The chained forms of the tiled kernels (r4d_chain.h) at decode heights, where the row + * resolved with `chain`. */ + const R4dChainArg chain_arg(r4d_geti_or(a, "chain", 0) != 0 && rows <= 64); const int rt = hc_down_rt(rows); /* The inject gains, if any, are hc more columns of the same GEMM. */ const bool fold = injw != nullptr && inj != nullptr; @@ -4678,7 +5591,7 @@ extern "C" int r4d_rad_hc_read(const RadArgs* a, RadStream s) { } /* The per-s norm scales: one workgroup per (row, s). */ - hipLaunchKernelGGL(hc_norm_scale_kernel, + hipLaunchKernelGGL((g_r4d_chain_arg ? &r4dchain_hc_norm_scale : &hc_norm_scale_kernel), dim3((unsigned)hc, (unsigned)rows), dim3(kThreads), 0, (hipStream_t)s, (const unsigned short*)h->data, scale, (long)rows, (long)n, (long)hrow, eps); @@ -4702,7 +5615,7 @@ extern "C" int r4d_rad_hc_read(const RadArgs* a, RadStream s) { if (ks > 1) { const long tot = (long)rows * ncol; - hipLaunchKernelGGL(hc_down_reduce_kernel, + hipLaunchKernelGGL((g_r4d_chain_arg ? &r4dchain_hc_down_reduce : &hc_down_reduce_kernel), dim3((unsigned)((tot + kThreads - 1) / kThreads)), dim3(kThreads), 0, (hipStream_t)s, part, dbuf, fold ? (unsigned short*)inj->data : nullptr, @@ -4761,7 +5674,7 @@ extern "C" int r4d_rad_hc_read(const RadArgs* a, RadStream s) { * there kernels A and B as one grid (hc_read_fused_kernel) when the row group is the whole * step, the up-mix fuses (q's counters or none) and the per-stream counters exist. */ const bool pre = f8 && hc == 4 && n == 10LL * kThreads && g_hc_decode_form != 1; - if (pre) { + if (pre && !hcg) { const long rgf = hc_up_rg(rows, lr); const int rpt = hc_up_rpt(true, (int)hc, n); const long ipf = (long)kUpRows * rpt / hc; @@ -4774,8 +5687,11 @@ extern "C" int r4d_rad_hc_read(const RadArgs* a, RadStream s) { const unsigned na = gxa * (unsigned)rows; const unsigned gxb = (unsigned)(n / ipf); const unsigned nbf_ = gxb; /* one row group */ + /* The chained form (r4d_chain.h) where the row resolved with `chain`. */ + const bool ch = r4d_geti_or(a, "chain", 0) != 0 && r4d_chain_rows_ok(rows); #define HC_FUSED_K(RG_, I8_, RPT_) \ - emit_rc = R4D_EMIT(s, (hc_read_fused_kernel), \ + emit_rc = R4D_EMIT(s, (ch ? &r4dchain_hc_read_fused \ + : &hc_read_fused_kernel), \ dim3(na + nbf_), dim3(kThreads), (unsigned)lds, \ (const unsigned short*)h->data, (const float*)w->data, (const void*)down->data, \ (long)dld, injw ? (const unsigned short*)injw->data : nullptr, dbuf, \ @@ -4814,7 +5730,39 @@ extern "C" int r4d_rad_hc_read(const RadArgs* a, RadStream s) { (long)dld, injw ? (const unsigned short*)injw->data : nullptr, dbuf, \ inj ? (unsigned short*)inj->data : nullptr, scale, (long)rows, (long)n, (int)hc, \ (long)lr, (long)ta, (long)hrow, (long)irow, eps, wadd) - if (g_hc_decode_form == 1) + if (hcg && hcs) { +#define HC_S_K(MT_) \ + emit_rc = R4D_EMIT(s, (hcg_ch ? &r4dchain_hc_read_s_down : &hc_read_s_down_kernel), \ + dim3((unsigned)((hcg_nt + 1) * hc), (unsigned)hcg_gy), dim3(kThreads), 0, \ + (const unsigned short*)h->data, (const float*)w->data, \ + (const unsigned char*)down->data, (long)dld, \ + (const unsigned short*)injw->data, dbuf, (unsigned short*)inj->data, \ + scale, hcg_part, hcg_ctr, (long)lr, (long)hrow, (long)irow, eps, wadd, \ + (int)hcg_nt, (long)rows) + HC_S_K(1); +#undef HC_S_K + } else if (hcg) { +#define HC_G_K(RG_) \ + emit_rc = R4D_EMIT(s, (hcg_ch ? &r4dchain_hc_read_g_down : &hc_read_g_down_kernel), \ + dim3((unsigned)((hcg_nt + 1) * hc), (unsigned)hcg_gy), dim3(kThreads), \ + (unsigned)(RG_ * kHcGN * sizeof(unsigned short)), \ + (const unsigned short*)h->data, (const float*)w->data, \ + (const unsigned char*)down->data, (long)dld, \ + (const unsigned short*)injw->data, dbuf, (unsigned short*)inj->data, \ + scale, hcg_part, hcg_ctr, (long)lr, (long)hrow, (long)irow, eps, wadd, \ + (int)hcg_nt, (long)rows) + switch (hcg_rg) { + case 8: HC_G_K(8); break; + case 7: HC_G_K(7); break; + case 6: HC_G_K(6); break; + case 5: HC_G_K(5); break; + case 4: HC_G_K(4); break; + case 3: HC_G_K(3); break; + case 2: HC_G_K(2); break; + default: HC_G_K(1); break; + } +#undef HC_G_K + } else if (g_hc_decode_form == 1) emit_rc = f8 ? HC_READ_A(hc_read_a_2grid_kernel) : HC_READ_A(hc_read_a_2grid_kernel); else if (pre) emit_rc = HC_READ_A((hc_read_a_kernel)); else emit_rc = f8 ? HC_READ_A(hc_read_a_kernel) : HC_READ_A(hc_read_a_kernel); @@ -4832,7 +5780,31 @@ extern "C" int r4d_rad_hc_read(const RadArgs* a, RadStream s) { mctr = hc_mix_ctr(s); fused = (mctr != nullptr); } - if (fused) + if (hcw) { + unsigned int* const qctr = q ? mctr : nullptr; +#define HC_UPW_K(RG_, I8_) \ + emit_rc = R4D_EMIT(s, (hcg_ch ? &r4dchain_hc_up_w : &hc_up_w_kernel), \ + dim3((unsigned)(n / kHcBCh)), dim3(kThreads), 0, \ + (const unsigned char*)up->data, (long)uld, (const unsigned short*)dbuf, \ + (const unsigned short*)h->data, (const float*)w->data, \ + (const float*)scale, (unsigned short*)x->data, \ + q ? (unsigned char*)q->data : nullptr, q ? (float*)qs->data : nullptr, \ + rq ? (unsigned char*)rq->data : nullptr, \ + rq ? (float*)rqs->data : nullptr, qctr, (long)rows, (long)n, (long)lr, \ + (long)hrow, (long)xrow, (long)qrow, (long)srow, (long)rqrow, \ + (long)rsrow, wadd) +#define HC_UPW_R(RG_) do { if (i8) HC_UPW_K(RG_, true); else HC_UPW_K(RG_, false); } while (0) + switch (rows) { + case 16: HC_UPW_R(16); break; case 15: HC_UPW_R(15); break; case 14: HC_UPW_R(14); break; + case 13: HC_UPW_R(13); break; case 12: HC_UPW_R(12); break; case 11: HC_UPW_R(11); break; + case 10: HC_UPW_R(10); break; case 9: HC_UPW_R(9); break; case 8: HC_UPW_R(8); break; + case 7: HC_UPW_R(7); break; case 6: HC_UPW_R(6); break; case 5: HC_UPW_R(5); break; + case 4: HC_UPW_R(4); break; case 3: HC_UPW_R(3); break; case 2: HC_UPW_R(2); break; + default: HC_UPW_R(1); break; + } +#undef HC_UPW_R +#undef HC_UPW_K + } else if (fused) emit_rc = hc_up_mix_launch(up, (long)uld, f8, i8, dbuf, (const unsigned short*)h->data, (const float*)w->data, scale, (unsigned short*)x->data, @@ -4840,7 +5812,7 @@ extern "C" int r4d_rad_hc_read(const RadArgs* a, RadStream s) { q ? (float*)qs->data : nullptr, rq ? (unsigned char*)rq->data : nullptr, rq ? (float*)rqs->data : nullptr, mctr, rows, n, (int)hc, lr, - hrow, xrow, qrow, srow, rqrow, rsrow, wadd, s); + hrow, xrow, qrow, srow, rqrow, rsrow, wadd, s, hcg_ch); else emit_rc = hc_up_launch(up, (long)uld, f8, dbuf, ubuf, rows, HN, lr, s); if (emit_rc != RAD_OK) return R4D_NO(RAD_E_DEVICE); diff --git a/libr4d/r4d_iqr.h b/libr4d/r4d_iqr.h index 0fc84f21..243a2c69 100644 --- a/libr4d/r4d_iqr.h +++ b/libr4d/r4d_iqr.h @@ -181,7 +181,11 @@ R4D_IQR_HD constexpr int64_t tile_major(int64_t r, int64_t kb, int64_t nkb) { X(kTrellisMad, 6, 0, 16, 5, kE4m3Tensor) X(kTrellisMad, 7, 0, 16, 5, kE4m3Tensor) \ /* the computed trellis with a scale a row (no rescale a value) */ \ X(kTrellisMad, 2, 0, 16, 0, kE4m3Tensor) X(kTrellisMad, 3, 0, 16, 0, kE4m3Tensor) \ - X(kTrellisMad, 4, 0, 16, 0, kE4m3Tensor) \ + X(kTrellisMad, 4, 0, 16, 0, kE4m3Tensor) X(kTrellisMad, 5, 0, 16, 0, kE4m3Tensor) \ + X(kTrellisMad, 6, 0, 16, 0, kE4m3Tensor) X(kTrellisMad, 7, 0, 16, 0, kE4m3Tensor) \ + /* the computed trellis under a bf16 scale a (row, 128): the fold reads it in place */ \ + X(kTrellisMad, 4, 0, 16, 0, kBf16) X(kTrellisMad, 5, 0, 16, 0, kBf16) \ + X(kTrellisMad, 6, 0, 16, 0, kBf16) X(kTrellisMad, 7, 0, 16, 0, kBf16) \ /* the computed trellis under one scale a row and a factor a 128-K block */ \ X(kTrellisMad, 2, 0, 16, 0, kRowF32) X(kTrellisMad, 3, 0, 16, 0, kRowF32) \ X(kTrellisMad, 4, 0, 16, 0, kRowF32) X(kTrellisMad, 5, 0, 16, 0, kRowF32) \ @@ -212,9 +216,11 @@ R4D_IQR_HD constexpr bool built(uint32_t w) { X(kTable, 4, 0, 0, 0, kBf16, 0) X(kTable, 5, 0, 0, 0, kBf16, 0) \ X(kTable, 2, 0, 0, 0, kBf16, 1) X(kTable, 3, 0, 0, 0, kBf16, 1) \ X(kTable, 4, 0, 0, 0, kBf16, 1) X(kTable, 5, 0, 0, 0, kBf16, 1) \ - X(kZero, 6, 0, 0, 0, kBf16, 0) \ + X(kZero, 6, 0, 0, 0, kBf16, 0) X(kZero, 7, 0, 0, 0, kBf16, 0) \ + X(kZero, 8, 0, 0, 0, kBf16, 0) \ X(kTrellis, 2, 0, 12, 0, kE4m3Tensor, 1) X(kTrellis, 3, 0, 12, 0, kE4m3Tensor, 1) \ - X(kTrellis, 4, 0, 12, 0, kE4m3Tensor, 1) X(kTrellis, 5, 0, 12, 0, kE4m3Tensor, 1) + X(kTrellis, 4, 0, 12, 0, kE4m3Tensor, 1) X(kTrellis, 5, 0, 12, 0, kE4m3Tensor, 1) \ + X(kTrellis, 6, 0, 12, 0, kE4m3Tensor, 1) X(kTrellis, 7, 0, 12, 0, kE4m3Tensor, 1) R4D_IQR_HD constexpr bool embed_built(uint32_t w) { #define R4D_IQR_EIS(k, b, lv, l, lrb, sc, r) \ diff --git a/libr4d/r4d_iqr_dec.h b/libr4d/r4d_iqr_dec.h index 746ba871..44416eb6 100644 --- a/libr4d/r4d_iqr_dec.h +++ b/libr4d/r4d_iqr_dec.h @@ -49,13 +49,26 @@ struct Ctx { * rows' 8-byte fragment reads fall on distinct banks. */ constexpr uint32_t kTrPitch = 136, kTrBytes = 16 * kTrPitch; +/* Bits [s, s + n) of the 64 bits hi:lo, n <= 32 (constants after unrolling). On byte bounds one + * v_perm, which also zeroes the bytes above; else a funnel shift and a mask. */ +__device__ __forceinline__ uint32_t window(uint32_t lo, uint32_t hi, uint32_t s, uint32_t n) { + if (s % 8u == 0u && n % 8u == 0u && n < 32u) { + uint32_t sel = 0x0C0C0C0Cu; + for (uint32_t i = 0; i < n / 8u; ++i) /* byte s / 8 + i of hi:lo: lo's 0-3, hi's 4-7 */ + sel = (sel & ~(0xFFu << (8u * i))) | ((s / 8u + i) << (8u * i)); + return __builtin_amdgcn_perm(hi, lo, sel); + } + const uint32_t m = n == 32u ? 0xFFFFFFFFu : ((1u << n) - 1u); + return __builtin_amdgcn_alignbit(hi, lo, s) & m; +} + /* `n` <= 32 bits of a little-endian dword stream from bit `o` (constant after unrolling). */ template __device__ __forceinline__ uint32_t field(const uint32_t (&d)[ND], uint32_t o, uint32_t n) { const uint32_t q = o >> 5, s = o & 31u; const uint32_t m = n == 32u ? 0xFFFFFFFFu : ((1u << n) - 1u); if (s + n <= 32u) return (d[q] >> s) & m; - return __builtin_amdgcn_alignbit(q + 1u < ND ? d[q + 1u] : 0u, d[q], s) & m; + return window(d[q], q + 1u < ND ? d[q + 1u] : 0u, s, n); } /* Low bytes of two, then of two pairs, into one dword. */ @@ -161,9 +174,50 @@ struct Dec { /* A grid lane segment may start mid-dword: read the dword-aligned window covering it. */ static constexpr bool ALIGNED = LANE_BITS % 32u == 0u; static constexpr uint32_t ND = ALIGNED ? LANE_BITS / 32u : (LANE_BITS + 24u + 31u) / 32u; - /* The dwords of the unit above a trellis column's continuation can reach: its first codes. */ - static constexpr uint32_t NP = TR ? ND : 1; + /* A trellis column's continuation: its first L - B bits in the unit above, which lie in one + * dword of that unit's lane segment for every width (column e starts at bit 16 B e), so a lane + * reads that dword alone of each of its four columns: p[e]. */ + static constexpr uint32_t CB = 16u * B; + static constexpr uint32_t NP = TR ? 4u : 1u; + static constexpr uint32_t pdw(uint32_t e) { return e * CB / 32u; } + static constexpr uint32_t pbit(uint32_t e) { return e * CB % 32u; } struct Raw { uint32_t d[ND]; uint32_t p[NP]; }; + /* A trellis column's stream: its CB code bits, then its continuation, as NW dwords, which + * its sixteen rows' states are windows of (row q's at bit q B). Built once a unit: a dword of + * a column that does not start on a dword bound is one funnel shift or v_perm, where reading + * each state from the lane's codes would join every state that crosses a bound, and every + * continued one, separately. */ + static constexpr uint32_t NW = TR ? (15u * B + F::L + 31u) / 32u : 1u; + __device__ static uint32_t colw(const Raw& r, uint32_t e, uint32_t i) { + const uint32_t a = e * CB + 32u * i, oe = e * CB + CB; + const uint32_t q = a >> 5, s = a & 31u; + if (a + 32u <= oe) return s == 0u ? r.d[q] : __builtin_amdgcn_alignbit(r.d[q + 1u], r.d[q], s); + if (a >= oe) return r.p[e] >> (pbit(e) + (a - oe)); + const uint32_t n0 = oe - a; /* the column's own last bits, then its continuation */ + if (s + n0 == 32u && pbit(e) == 0u) return __builtin_amdgcn_alignbit(r.p[e], r.d[q], s); + if (s % 8u == 0u && n0 % 8u == 0u && pbit(e) % 8u == 0u && s + n0 <= 32u) { + uint32_t sel = 0u; + for (uint32_t j = 0; j < 4u; ++j) { + const uint32_t b = j < n0 / 8u ? s / 8u + j : 4u + pbit(e) / 8u + (j - n0 / 8u); + sel |= (b < 8u ? b : 0x0Cu) << (8u * j); + } + return __builtin_amdgcn_perm(r.p[e], r.d[q], sel); + } + return field(r.d, a, n0) | (r.p[e] >> pbit(e)) << n0; + } + __device__ static void columns(const Raw& r, uint32_t (&cw)[4][NW]) { +#pragma unroll + for (uint32_t e = 0; e < 4; ++e) +#pragma unroll + for (uint32_t i = 0; i < NW; ++i) cw[e][i] = colw(r, e, i); + } + /* Row q's state of column e: L bits from bit q B of the column's stream. */ + __device__ static uint32_t state(const uint32_t (&cw)[4][NW], uint32_t q, uint32_t e) { + constexpr uint32_t L = F::L; + const uint32_t o = q * B, i = o >> 5, s = o & 31u; + if (s + L <= 32u) return (cw[e][i] >> s) & ((1u << L) - 1u); + return window(cw[e][i], cw[e][i + 1u], s, L); + } static constexpr bool HALF = H16 && TR && !MAD && F::LRB != 0; static constexpr uint32_t kTab = F::KIND == kTable ? 256u : GRID ? (1u << B) << F::LV @@ -203,9 +257,14 @@ struct Dec { r.d[i] = __builtin_amdgcn_alignbit(i + 1u < ND ? w[i + 1u] : 0u, w[i], sh); } if constexpr (TR) { + static_assert(!TR || (pbit(1) + F::L - B <= 32u && pbit(2) + F::L - B <= 32u && + pbit(3) + F::L - B <= 32u), + "a column's continuation in one dword"); const uint32_t rp = rt % c.run_tiles == 0u ? rt + c.run_tiles - 1u : rt - 1u; - const uint8_t* up = c.W + ((size_t)rp * c.nkb + kb) * ub; - load_dw(r.p, up + (size_t)lane * (LANE_BITS / 8u), live); + const uint32_t* up = (const uint32_t*)(c.W + ((size_t)rp * c.nkb + kb) * ub + + (size_t)lane * (LANE_BITS / 8u)); +#pragma unroll + for (uint32_t e = 0; e < 4; ++e) r.p[e] = live ? up[pdw(e)] : 0u; } else { r.p[0] = 0u; } @@ -219,19 +278,14 @@ struct Dec { __device__ static void rows(const Raw& r, const Ctx& c, float ratio, uint32_t (&w)[16]) { static_assert(!UNS || (MAD && F::LRB == 0), "unsigned values: a computed trellis, one scale a row"); if constexpr (TR) { - constexpr uint32_t L = F::L, CB = 16u * B; /* All 64 states, then all 64 lookups, then the values: the LDS reads go out together * instead of each waiting on the last's use. */ - uint32_t st[64]; + uint32_t st[64], cw[4][NW]; + columns(r, cw); #pragma unroll for (uint32_t q = 0; q < 16; ++q) #pragma unroll - for (uint32_t e = 0; e < 4; ++e) { - const uint32_t pos = e * CB + q * B, own = CB - q * B; - st[q * 4 + e] = L <= own ? field(r.d, pos, L) - : field(r.d, pos, own) | - field(r.p, e * CB, L - own) << own; - } + for (uint32_t e = 0; e < 4; ++e) st[q * 4 + e] = state(cw, q, e); [[maybe_unused]] int32_t t[HALF ? 1 : 64]; [[maybe_unused]] _Float16 th[HALF ? 64 : 1]; if constexpr (MAD) { @@ -315,20 +369,16 @@ struct Dec { * each byte is the value plus 126 times the activation, the sum and the product in one. */ __device__ static void hashes(const Raw& r, const Ctx& c, uint32_t (&h)[16][4]) { static_assert(MAD, "hashes: a computed trellis"); - constexpr uint32_t L = F::L, CB = 16u * B; constexpr Form f{ F::KIND, F::B, F::LV, F::L, F::LRB, F::SC, 0 }; const uint32_t* ab = (const uint32_t*)(c.W + aux_off(f, c.N, (int64_t)c.nkb * 128) + ((int64_t)1 << F::L)); const uint32_t A = ab[0], Bc = ab[1]; + uint32_t cw[4][NW]; + columns(r, cw); #pragma unroll for (uint32_t q = 0; q < 16; ++q) #pragma unroll - for (uint32_t e = 0; e < 4; ++e) { - const uint32_t pos = e * CB + q * B, own = CB - q * B; - const uint32_t st = L <= own ? field(r.d, pos, L) - : field(r.d, pos, own) | field(r.p, e * CB, L - own) << own; - h[15u - q][e] = (__umul24(st, A) + Bc) & 0x3F3F3F3Fu; - } + for (uint32_t e = 0; e < 4; ++e) h[15u - q][e] = (__umul24(state(cw, q, e), A) + Bc) & 0x3F3F3F3Fu; } /* Zero: the zero of row (rt*16 + q) for block kb is subtracted bytewise after `rows`. */ diff --git a/libr4d/r4d_iqr_layout.cpp b/libr4d/r4d_iqr_layout.cpp index 807a6740..fc46479b 100644 --- a/libr4d/r4d_iqr_layout.cpp +++ b/libr4d/r4d_iqr_layout.cpp @@ -136,7 +136,8 @@ bool classify(const RadEncoding* enc, const char* tr, Form* f, int64_t* entries) return true; } const int b = unsigned_bits(cp.dtype); - if (!b || b > 7) return false; + /* eight bits only under a zero: the embedding's u8 table (no GEMM form takes it) */ + if (!b || b > 8 || (b == 8 && !rad_enc_plane(enc, "zero"))) return false; if (const RadEncPlane* zp = rad_enc_plane(enc, "zero")) { if (!scale_form(enc, 3, &sc) || sc != kBf16 || !unsigned_bits(zp->dtype) || zp->block[0] != 1 || zp->block[1] != 128) @@ -733,3 +734,69 @@ extern "C" int r4d_rad_unrelayout_iqr_logits(const RadParam* p, int n_p, int ope std::memcpy(v.aux->data, s + lm_tab(f, rows, dim), (size_t)entries); return RAD_OK; } + +/* ==================================================================== logits_gemm_vocab's classes + * + * Each width class of the head is a gemm_nt_q weight of its own rows (operands 1 + 3i its codes, + * 2 + 3i its scales), stored as that row stores it, with the class's rows (`rows`) and n_embd + * as its geometry and the rotated forms (the classes are fwht128). A class's vocabulary ids + * (3 + 3i) are read as stored. */ +namespace { +int vocab_geom(const RadParam* p, int n_p, int operand, RadParam (&q)[4], int* il) { + if (operand < 1 || operand > 12 || (operand - 1) % 3 == 2) return RAD_E_UNSUPPORTED; + static const char* kRows[] = { "rows0", "rows1", "rows2", "rows3" }; + const int i = (operand - 1) / 3; + std::memset(q, 0, sizeof q); + q[0].key = "N"; + q[0].kind = RAD_P_INT; + q[0].ival = r4d_pgeti_or(p, n_p, kRows[i], 0); + q[1].key = "K"; + q[1].kind = RAD_P_INT; + q[1].ival = r4d_pgeti_or(p, n_p, "n_embd", 0); + q[2].key = "group"; + q[2].kind = RAD_P_INT; + q[2].ival = 128; + q[3].key = "dtype"; + q[3].kind = RAD_P_STR; + q[3].sval = "i8a8h"; + *il = (operand - 1) % 3 == 0 ? IL_B : IL_BSCALE; + return RAD_OK; +} +} /* namespace */ + +extern "C" int r4d_rad_layout_iqr_vocab(const RadParam* p, int n_p, int operand, + const RadEncoding* enc, const int* sel, const RadTensor* pl, + int n, RadLayout* out) { + RadParam q[4]; + int il = 0; + const int rc = vocab_geom(p, n_p, operand, q, &il); + if (rc != RAD_OK) return rc; + Form f; + int64_t entries = 0; + if (!classify(enc, "fwht128", &f, &entries) || f.kind != kTrellisMad || f.scale != kRowF32 || + f.lrb != 0 || f.lrun != 8) + return RAD_E_DTYPE; + return r4d_rad_layout_iqr(q, 4, il, enc, sel, pl, n, out); +} + +extern "C" int r4d_rad_relayout_iqr_vocab(const RadParam* p, int n_p, int operand, + const RadEncoding* enc, const int* sel, + const RadTensor* pl, int n, void* dst, + int64_t dst_bytes) { + RadParam q[4]; + int il = 0; + const int rc = vocab_geom(p, n_p, operand, q, &il); + if (rc != RAD_OK) return rc; + return r4d_rad_relayout_iqr(q, 4, il, enc, sel, pl, n, dst, dst_bytes); +} + +extern "C" int r4d_rad_unrelayout_iqr_vocab(const RadParam* p, int n_p, int operand, + const RadEncoding* enc, const int* sel, + const void* src, int64_t src_bytes, + const RadTensor* pl, int n) { + RadParam q[4]; + int il = 0; + const int rc = vocab_geom(p, n_p, operand, q, &il); + if (rc != RAD_OK) return rc; + return r4d_rad_unrelayout_iqr(q, 4, il, enc, sel, src, src_bytes, pl, n); +} diff --git a/libr4d/r4d_lili.hip b/libr4d/r4d_lili.hip new file mode 100644 index 00000000..d5ae822b --- /dev/null +++ b/libr4d/r4d_lili.hip @@ -0,0 +1,421 @@ +/* r4d_lili.hip -- LiLiCorr's candidate correlator (libref/ref_lili.cpp has the contracts): + * lili_cand, lili_attn, lili_factor and lili_walk, at a draft step's size (seven positions of eight + * candidates a sequence, a 1024-wide lattice). Each is a few microseconds of a draft step, so the + * kernels are plain: one workgroup a row (lili_cand, lili_factor), a (sequence, head) pair + * (lili_attn) or a sequence (lili_walk), shared memory and serial loops where a step is short, f32 + * arithmetic in libref's order and one rounding to bf16 at each store. + * + * Activations are bf16; lili_cand's statistics, LayerNorm and up projection are f32 and its slot and + * rank tables bf16; lili_attn's biases f32. Rows may have their own pitch, the last axis dense. + * Nothing here allocates or synchronises (docs/PLUGIN.md §5). + */ +#include + +#include +#include + +#include "r4d_plugin.h" +#include "r4d_launch.h" +#include "rad_plugin.h" + +namespace r4d_lili { + +constexpr int kThr = 256; +constexpr int kMaxK = 64; /* candidates a position (lili_cand, lili_walk) */ +constexpr int kMaxW = 16; /* ranks (lili_cand) */ +constexpr int kMaxL = 64; /* lattice rows a sequence (lili_attn) */ +constexpr int kMaxHd = 128; /* head width (lili_attn) */ +constexpr int kMaxWalk = 512; /* steps * k * k scores a sequence (lili_walk) */ + +__device__ __forceinline__ float bf(uint16_t v) { return __uint_as_float((uint32_t)v << 16); } +__device__ __forceinline__ uint16_t tobf(float f) { + uint32_t u = __float_as_uint(f); + if ((u & 0x7fffffffu) > 0x7f800000u) return (uint16_t)((u >> 16) | 0x40u); /* NaN stays NaN */ + u += 0x7fffu + ((u >> 16) & 1u); + return (uint16_t)(u >> 16); +} + +/* ------------------------------------------------------------------ lili_cand */ +struct CandArgs { + const float* st; long long st_rs; + const uint16_t* pas; long long pas_rs; + const float *lnw, *lnb, *upw, *upb; + const uint16_t *slot, *rank; + int* cand; long long cand_rs; + uint16_t* feat; long long feat_rs; + uint16_t* base; long long base_rs; + int k, row_k, world, steps, n; + float eps; +}; + +__global__ __launch_bounds__(kThr) void cand_kernel(CandArgs A) { + __shared__ float s_y[kMaxK][5]; + const long long m = blockIdx.x; + const int k = A.k, w = 2 + 2 * A.row_k; + if (threadIdx.x == 0) { + const float* row = A.st + m * A.st_rs; + float mx = -__builtin_inff(); + for (int r = 0; r < A.world; ++r) mx = __builtin_fmaxf(mx, row[r * w]); + float sum = 0.0f; + for (int r = 0; r < A.world; ++r) + if (row[r * w] > -__builtin_inff()) sum += row[r * w + 1] * expf(row[r * w] - mx); + const float lse = mx + logf(sum); + /* A world-way merge of lists sorted by value, ties to the lower id. */ + int at[kMaxW]; + for (int r = 0; r < A.world; ++r) at[r] = 0; + float lp[kMaxK]; + for (int j = 0; j < k; ++j) { + int br = -1, bid = 0; + float bv = 0.0f; + for (int r = 0; r < A.world; ++r) { + while (at[r] < k && (int)row[r * w + 2 + 2 * at[r]] < 0) ++at[r]; + if (at[r] >= k) continue; + const float v = row[r * w + 3 + 2 * at[r]]; + const int id = (int)row[r * w + 2 + 2 * at[r]]; + if (br < 0 || v > bv || (v == bv && id < bid)) { br = r; bv = v; bid = id; } + } + lp[j] = br < 0 ? -1e4f : bv - lse; + if (br >= 0) ++at[br]; + A.cand[m * A.cand_rs + j] = br < 0 ? 0 : bid; + } + for (int j = 0; j < k; ++j) { + const float f[5] = { lp[j], expf(lp[j]), lp[j] - lp[0], (float)j / (float)(k - 1), + j == 0 ? 1.0f : 0.0f }; + float mean = 0.0f; + for (int i = 0; i < 5; ++i) mean += f[i]; + mean /= 5.0f; + float var = 0.0f; + for (int i = 0; i < 5; ++i) var += (f[i] - mean) * (f[i] - mean); + var /= 5.0f; + const float rs = 1.0f / __builtin_sqrtf(var + A.eps); + for (int i = 0; i < 5; ++i) s_y[j][i] = (f[i] - mean) * rs * A.lnw[i] + A.lnb[i]; + } + } + __syncthreads(); + const int s = (int)(m % A.steps); + for (int c = (int)threadIdx.x; c < A.n; c += kThr) { + const float pv = bf(A.pas[m * A.pas_rs + c]) + bf(A.slot[(long long)s * A.n + c]); + float uw[5]; + for (int i = 0; i < 5; ++i) uw[i] = A.upw[(long long)c * 5 + i]; + const float ub = A.upb[c]; + for (int j = 0; j < k; ++j) { + float u = ub; + for (int i = 0; i < 5; ++i) u += uw[i] * s_y[j][i]; + const long long row = m * k + j; + A.feat[row * A.feat_rs + c] = tobf(u / (1.0f + expf(-u))); + A.base[row * A.base_rs + c] = tobf(pv + bf(A.rank[(long long)j * A.n + c])); + } + } +} + +/* ------------------------------------------------------------------ lili_attn */ +struct AttnArgs { + const uint16_t* qkv; long long q_rs; + const float *rel, *same; int rel_w; + uint16_t* out; long long o_rs; + int steps, k, nh, hd; + float scale; +}; + +__global__ __launch_bounds__(kThr) void attn_kernel(AttnArgs A) { + __shared__ uint16_t s_k[kMaxL][kMaxHd], s_v[kMaxL][kMaxHd]; + __shared__ float s_q[kMaxHd], s_sc[kMaxL], s_sum; + const int L = A.steps * A.k, hd = A.hd, n = A.nh * hd, h = (int)blockIdx.y; + const long long r0 = (long long)blockIdx.x * L; + const int tid = (int)threadIdx.x; + for (int e = tid; e < L * hd; e += kThr) { + const int j = e / hd, d = e - j * hd; + const uint16_t* row = A.qkv + (r0 + j) * A.q_rs; + s_k[j][d] = row[n + h * hd + d]; + s_v[j][d] = row[2 * n + h * hd + d]; + } + const float sm = A.same[h]; + for (int i = 0; i < L; ++i) { + __syncthreads(); + if (tid < hd) s_q[tid] = bf(A.qkv[(r0 + i) * A.q_rs + h * hd + tid]); + __syncthreads(); + const int si = i / A.k; + if (tid < L) { + float dot = 0.0f; + for (int d = 0; d < hd; ++d) dot += s_q[d] * bf(s_k[tid][d]); + const int sj = tid / A.k; + float b = A.rel[(long long)h * A.rel_w + (si - sj + A.steps)]; + if (si == sj) b += sm; + s_sc[tid] = dot * A.scale + b; + } + __syncthreads(); + if (tid == 0) { + float mx = s_sc[0]; + for (int j = 1; j < L; ++j) mx = __builtin_fmaxf(mx, s_sc[j]); + float sum = 0.0f; + for (int j = 0; j < L; ++j) { s_sc[j] = expf(s_sc[j] - mx); sum += s_sc[j]; } + s_sum = sum; + } + __syncthreads(); + if (tid < hd) { + float acc = 0.0f; + for (int j = 0; j < L; ++j) acc += s_sc[j] * bf(s_v[j][tid]); + A.out[(r0 + i) * A.o_rs + h * hd + tid] = tobf(acc / s_sum); + } + } +} + +/* ------------------------------------------------------------------ lili_factor */ +struct FactorArgs { + const uint16_t* h; long long h_rs; + const uint16_t* a; long long a_rs; + uint16_t* y; long long y_rs; + int L, n; +}; + +__global__ __launch_bounds__(kThr) void factor_kernel(FactorArgs A) { + const long long i = blockIdx.x; + const uint16_t* hr = A.h + i * A.h_rs; + const uint16_t* ar = A.a + (i / A.L) * A.a_rs; + uint16_t* yr = A.y + i * A.y_rs; + for (int c = (int)threadIdx.x; c < A.n; c += kThr) { + const float hv = bf(hr[c]), av = bf(ar[c]); + yr[c] = hr[c]; + yr[A.n + c] = ar[c]; + yr[2 * A.n + c] = tobf(hv * av); + } +} + +/* ------------------------------------------------------------------ lili_walk */ +struct WalkArgs { + const uint16_t* ed; long long e_rs; + const uint16_t* ao; long long a_rs; + const int* cand; long long c_rs; + int* tok; long long t_rs; + float* scores; /* [M, steps, k, k] dense, or null */ + int steps, k, n; + float eps, scale; +}; + +__global__ __launch_bounds__(kThr) void walk_kernel(WalkArgs A) { + /* norms: [0, R) outgoing, [R, 2R) incoming, 2R the anchor's */ + __shared__ float s_nrm[2 * kMaxK * 8 + 1]; + __shared__ float s_sc[kMaxWalk]; + const long long m = blockIdx.x; + const int k = A.k, R = A.steps * k, n = A.n, tid = (int)threadIdx.x; + const uint16_t* E = A.ed + m * R * A.e_rs; + const uint16_t* an = A.ao + m * A.a_rs; + for (int v = tid; v < 2 * R + 1; v += kThr) { + const uint16_t* p = v < 2 * R ? E + (long long)(v % R) * A.e_rs + (v < R ? 0 : n) : an; + float ss = 0.0f; + for (int c = 0; c < n; ++c) { const float x = bf(p[c]); ss += x * x; } + s_nrm[v] = __builtin_fmaxf(__builtin_sqrtf(ss), A.eps); + } + __syncthreads(); + /* start (k entries, shared by every i) and the pairs: dots of the raw vectors over their norms */ + const int npair = (A.steps - 1) * k * k; + for (int e = tid; e < k + npair; e += kThr) { + const uint16_t *x, *y; + float nx, ny; + if (e < k) { + x = an; nx = s_nrm[2 * R]; + y = E + (long long)e * A.e_rs + n; ny = s_nrm[R + e]; + } else { + const int q = e - k, s = q / (k * k) + 1, i = (q / k) % k, j = q % k; + x = E + (long long)((s - 1) * k + i) * A.e_rs; nx = s_nrm[(s - 1) * k + i]; + y = E + (long long)(s * k + j) * A.e_rs + n; ny = s_nrm[R + s * k + j]; + } + float d = 0.0f; + for (int c = 0; c < n; ++c) d += bf(x[c]) * bf(y[c]); + const float v = A.scale * (d / nx / ny); + if (e < k) { + for (int i = 0; i < k; ++i) s_sc[i * k + e] = v; + } else { + s_sc[k * k + (e - k)] = v; + } + } + __syncthreads(); + if (tid == 0) { + int prev = 0; + for (int s = 0; s < A.steps; ++s) { + const float* row = s_sc + (s * k + prev) * k; + int best = 0; + for (int j = 1; j < k; ++j) if (row[j] > row[best]) best = j; + A.tok[m * A.t_rs + s] = A.cand[(m * A.steps + s) * A.c_rs + best]; + prev = best; + } + } + if (A.scores) + for (int e = tid; e < R * k; e += kThr) A.scores[m * R * k + e] = s_sc[e]; +} + +/* A tensor read as [rows, cols] with a row pitch, last axis dense: the pitch, and the rows in *M. */ +static long long pitch_of(const RadTensor* t, long long cols, long long* M) { + if (!t || cols <= 0) return -1; + if (t->rank == 1) { + if (t->stride[0] != 1 || t->shape[0] % cols) return -1; + *M = t->shape[0] / cols; + return cols; + } + const uint32_t r = t->rank; + if (r < 2 || t->stride[r - 1] != 1) return -1; + long long rows = 1; + for (uint32_t i = 0; i + 1 < r; ++i) rows *= t->shape[i]; + if (t->shape[r - 1] == cols) { + for (uint32_t i = 0; i + 2 < r; ++i) + if (t->shape[i] > 1 && t->stride[i] != t->stride[i + 1] * t->shape[i + 1]) return -1; + *M = rows; + return t->stride[r - 2]; + } + /* A flat [rows, a * cols] read at a narrower width is not a pitch. */ + if (r == 2 && t->stride[0] == t->shape[1] && t->shape[1] % cols == 0) { + *M = rows * (t->shape[1] / cols); + return cols; + } + return -1; +} + +static bool dense(const RadTensor* t) { + int64_t s = 1; + for (int i = (int)t->rank - 1; i >= 0; --i) { + if (t->shape[i] != 1 && t->stride[i] != s) return false; + s *= t->shape[i]; + } + return true; +} + +} /* namespace r4d_lili */ + +using namespace r4d_lili; + +extern "C" { + +int r4d_rad_lili_cand(const RadArgs* a, RadStream stream) { + if (!a || a->n_t < 11) return RAD_E_INVAL; + const RadTensor* t[11]; + for (int i = 0; i < 11; ++i) if (!(t[i] = rad_arg_in(a, i))) return RAD_E_INVAL; + const long long k = rad_args_geti_or(a, "k", 0), world = rad_args_geti_or(a, "world", 1); + const long long steps = rad_args_geti_or(a, "steps", 0), n = rad_args_geti_or(a, "n", 0); + const long long rk = rad_args_geti_or(a, "row_k", k); + if (k < 2 || k > kMaxK || rk < k || world < 1 || world > kMaxW || steps < 1 || n <= 0) + return RAD_E_SHAPE; + if (t[0]->dtype != RAD_F32 || t[1]->dtype != RAD_BF16 || t[8]->dtype != RAD_I32 || + t[9]->dtype != RAD_BF16 || t[10]->dtype != RAD_BF16 || t[6]->dtype != RAD_BF16 || + t[7]->dtype != RAD_BF16) + return RAD_E_DTYPE; + for (int i = 2; i <= 5; ++i) if (t[i]->dtype != RAD_F32) return RAD_E_DTYPE; + for (int i = 2; i <= 7; ++i) if (!dense(t[i])) return RAD_E_STRIDE; + if (rad_tensor_numel(t[2]) < 5 || rad_tensor_numel(t[3]) < 5 || rad_tensor_numel(t[4]) < n * 5 || + rad_tensor_numel(t[5]) < n || rad_tensor_numel(t[6]) < steps * n || + rad_tensor_numel(t[7]) < k * n) + return RAD_E_SHAPE; + long long M = 0, Mp = 0, Mc = 0, Mf = 0, Mb = 0; + CandArgs A{}; + A.st_rs = pitch_of(t[0], world * (2 + 2 * rk), &M); + A.pas_rs = pitch_of(t[1], n, &Mp); + A.cand_rs = pitch_of(t[8], k, &Mc); + A.feat_rs = pitch_of(t[9], n, &Mf); + A.base_rs = pitch_of(t[10], n, &Mb); + if (A.st_rs < 0 || A.pas_rs < 0 || A.cand_rs < 0 || A.feat_rs < 0 || A.base_rs < 0) + return RAD_E_STRIDE; + if (M <= 0 || Mp < M || Mc < M || Mf < M * k || Mb < M * k) return RAD_E_SHAPE; + A.st = (const float*)t[0]->data; A.pas = (const uint16_t*)t[1]->data; + A.lnw = (const float*)t[2]->data; A.lnb = (const float*)t[3]->data; + A.upw = (const float*)t[4]->data; A.upb = (const float*)t[5]->data; + A.slot = (const uint16_t*)t[6]->data; A.rank = (const uint16_t*)t[7]->data; + A.cand = (int*)t[8]->data; A.feat = (uint16_t*)t[9]->data; + A.base = (uint16_t*)t[10]->data; + A.k = (int)k; A.row_k = (int)rk; A.world = (int)world; A.steps = (int)steps; A.n = (int)n; + A.eps = (float)rad_args_getf_or(a, "eps", 1e-5); + R4D_KLAUNCH(R4D_KNAME(cand_kernel), dim3((unsigned)M), dim3(kThr), (hipStream_t)stream, A); + return hipGetLastError() == hipSuccess ? RAD_OK : RAD_E_DEVICE; +} + +int r4d_rad_lili_attn(const RadArgs* a, RadStream stream) { + if (!a || a->n_t < 4) return RAD_E_INVAL; + const RadTensor* q = rad_arg_in(a, 0); + const RadTensor* rel = rad_arg_in(a, 1); + const RadTensor* same = rad_arg_in(a, 2); + const RadTensor* o = rad_arg_in(a, 3); + if (!q || !rel || !same || !o) return RAD_E_INVAL; + const long long steps = rad_args_geti_or(a, "steps", 0), k = rad_args_geti_or(a, "k", 0); + const long long nh = rad_args_geti_or(a, "n_head", 0), hd = rad_args_geti_or(a, "head_dim", 0); + if (steps < 1 || k < 1 || nh < 1 || hd < 1 || hd > kMaxHd || steps * k > kMaxL) + return RAD_E_SHAPE; + if (q->dtype != RAD_BF16 || o->dtype != RAD_BF16 || rel->dtype != RAD_F32 || + same->dtype != RAD_F32) + return RAD_E_DTYPE; + if (!dense(rel) || !dense(same)) return RAD_E_STRIDE; + const long long rw = rel->rank ? rel->shape[rel->rank - 1] : 0; + if (rw < 2 * steps - 1 || rad_tensor_numel(rel) < nh * rw || rad_tensor_numel(same) < nh) + return RAD_E_SHAPE; + const long long L = steps * k, n = nh * hd; + long long M = 0, Mo = 0; + AttnArgs A{}; + A.q_rs = pitch_of(q, 3 * n, &M); + A.o_rs = pitch_of(o, n, &Mo); + if (A.q_rs < 0 || A.o_rs < 0) return RAD_E_STRIDE; + if (M <= 0 || M % L || Mo < M) return RAD_E_SHAPE; + A.qkv = (const uint16_t*)q->data; A.out = (uint16_t*)o->data; + A.rel = (const float*)rel->data; A.same = (const float*)same->data; A.rel_w = (int)rw; + A.steps = (int)steps; A.k = (int)k; A.nh = (int)nh; A.hd = (int)hd; + A.scale = (float)rad_args_getf_or(a, "scale", 1.0 / __builtin_sqrt((double)hd)); + R4D_KLAUNCH(R4D_KNAME(attn_kernel), dim3((unsigned)(M / L), (unsigned)nh), dim3(kThr), + (hipStream_t)stream, A); + return hipGetLastError() == hipSuccess ? RAD_OK : RAD_E_DEVICE; +} + +int r4d_rad_lili_factor(const RadArgs* a, RadStream stream) { + if (!a || a->n_t < 3) return RAD_E_INVAL; + const RadTensor* h = rad_arg_in(a, 0); + const RadTensor* an = rad_arg_in(a, 1); + const RadTensor* y = rad_arg_in(a, 2); + if (!h || !an || !y) return RAD_E_INVAL; + if (h->dtype != RAD_BF16 || an->dtype != RAD_BF16 || y->dtype != RAD_BF16) return RAD_E_DTYPE; + const long long L = rad_args_geti_or(a, "L", 0), n = rad_args_geti_or(a, "n", 0); + if (L < 1 || n < 1) return RAD_E_SHAPE; + long long M = 0, Ma = 0, My = 0; + FactorArgs A{}; + A.h_rs = pitch_of(h, n, &M); + A.a_rs = pitch_of(an, n, &Ma); + A.y_rs = pitch_of(y, 3 * n, &My); + if (A.h_rs < 0 || A.a_rs < 0 || A.y_rs < 0) return RAD_E_STRIDE; + if (M <= 0 || M % L || Ma < M / L || My < M) return RAD_E_SHAPE; + A.h = (const uint16_t*)h->data; A.a = (const uint16_t*)an->data; A.y = (uint16_t*)y->data; + A.L = (int)L; A.n = (int)n; + R4D_KLAUNCH(R4D_KNAME(factor_kernel), dim3((unsigned)M), dim3(kThr), (hipStream_t)stream, A); + return hipGetLastError() == hipSuccess ? RAD_OK : RAD_E_DEVICE; +} + +int r4d_rad_lili_walk(const RadArgs* a, RadStream stream) { + if (!a || a->n_t < 4) return RAD_E_INVAL; + const RadTensor* ed = rad_arg_in(a, 0); + const RadTensor* ao = rad_arg_in(a, 1); + const RadTensor* cd = rad_arg_in(a, 2); + const RadTensor* tk = rad_arg_in(a, 3); + const RadTensor* sc = a->n_t > 4 ? rad_arg_in(a, 4) : nullptr; + if (!ed || !ao || !cd || !tk) return RAD_E_INVAL; + const long long steps = rad_args_geti_or(a, "steps", 0), k = rad_args_geti_or(a, "k", 0); + const long long n = rad_args_geti_or(a, "n", 0); + if (steps < 1 || k < 1 || k > kMaxK || n < 1 || steps * k * k > kMaxWalk || + steps * k > kMaxK * 8) + return RAD_E_SHAPE; + if (ed->dtype != RAD_BF16 || ao->dtype != RAD_BF16 || cd->dtype != RAD_I32 || + tk->dtype != RAD_I32 || (sc && sc->dtype != RAD_F32)) + return RAD_E_DTYPE; + if (sc && !dense(sc)) return RAD_E_STRIDE; + long long M = 0, Me = 0, Mc = 0, Mt = 0; + WalkArgs A{}; + A.a_rs = pitch_of(ao, n, &M); + A.e_rs = pitch_of(ed, 2 * n, &Me); + A.c_rs = pitch_of(cd, k, &Mc); + A.t_rs = pitch_of(tk, steps, &Mt); + if (A.a_rs < 0 || A.e_rs < 0 || A.c_rs < 0 || A.t_rs < 0) return RAD_E_STRIDE; + if (M <= 0 || Me < M * steps * k || Mc < M * steps || Mt < M) return RAD_E_SHAPE; + if (sc && rad_tensor_numel(sc) < M * steps * k * k) return RAD_E_SHAPE; + A.ed = (const uint16_t*)ed->data; A.ao = (const uint16_t*)ao->data; + A.cand = (const int*)cd->data; A.tok = (int*)tk->data; + A.scores = sc ? (float*)sc->data : nullptr; + A.steps = (int)steps; A.k = (int)k; A.n = (int)n; + A.eps = (float)rad_args_getf_or(a, "eps", 1e-4); + A.scale = (float)rad_args_getf_or(a, "scale", 1.0); + R4D_KLAUNCH(R4D_KNAME(walk_kernel), dim3((unsigned)M), dim3(kThr), (hipStream_t)stream, A); + return hipGetLastError() == hipSuccess ? RAD_OK : RAD_E_DEVICE; +} + +} /* extern "C" */ diff --git a/libr4d/r4d_logits_vocab.hip b/libr4d/r4d_logits_vocab.hip new file mode 100644 index 00000000..4be05cbb --- /dev/null +++ b/libr4d/r4d_logits_vocab.hip @@ -0,0 +1,536 @@ +// logits_gemm_vocab: the lm_head stored as width classes of the vocabulary's rows, each an IQR +// computed trellis (r4d_iqr.h: tcq_code=mad, one f32 scale a row under a factor a 128-K block, +// fwht128) decoded where it is read. +// +// KL weighs a head row by its token's probability, so a vocabulary-weighted head gives the likely +// tokens' rows more bits than the rare ones'. The rows are sorted into classes of one code width +// each (whole 256-row trellis runs), every class a weight of its own whose rows each carry their +// vocabulary id, and the logits come out in vocabulary order: nothing after the head knows the rows +// were permuted. Stored at its id from the tile, a logit in a random row order is a write to a line +// of its own (+120 us of 760 at 8 tokens, +970 of 2350 at 64). So within a class the rows are in +// ascending id (the converter's order; a class's rows share a width, so their order is free), and +// above 32 tokens the tile stores at the ids directly, the large narrow class's rows then nearly +// contiguous; up to 32 it writes a staging plane in row order and a gather through `vrow` (each +// id's class and row) puts it in vocabulary order, cheaper there by the narrow classes' scattered +// rows (626 / 646 us against 668 / 706 at 8 / 16 tokens; 1618 against 1559 at 64). A rank's rows of +// each class hold only ids of that rank's share (an id outside it is dropped), so the head shards by +// rows as any lm_head does. +// +// The activation is the head's bf16 input rotated by the unnormalised Hadamard per 128 of K (the +// rotation the codes were quantised under) and held at sixteen bits: one f32 scale a (token, 128) +// over integers q = 128 hi + lo, |q| <= 127 * 128, hi and lo int8. The int8 grid the trunk's GEMMs +// use costs the head 2e-5 KL on its own (half the weighted head's quantisation cost); sixteen bits +// are below bf16's rounding. Each 128-K block's dot is then two int8 WMMA passes over the same +// decoded weight fragments, hi then lo, the first scaled by 128 in the accumulator: an exact +// integer per (row, token, block), folded once into f32. +// +// One launch covers every class: a block finds its class among the classes' row ranges (the +// widest first, so the narrow classes' cheaper blocks fill the tail) and runs that width's +// decoder. A class of one width alone would leave most of the card idle (the widest is a few +// thousand rows). + +#include "r4d.h" +#include "r4d_args.h" +#include "r4d_emit.h" +#include "r4d_fp8_wmma.h" +#include "r4d_fwht.h" +#include "r4d_iqr.h" +#include "r4d_iqr_dec.h" + +#include + +namespace { + +using namespace r4d_fp8; +using namespace r4d_iqr; +using namespace r4d_iqr_dev; + +constexpr uint32_t kWave = 32, kBlock = 128, kFK = 256; +constexpr uint32_t kMaxClass = 4; +/* Tokens a pass of the tile: four 16-token tiles. More tokens are taken in passes, each reading + * the head once (a prefill wants one row's logits; the all-position logits of a KL evaluation are + * the case this serves). */ +constexpr uint32_t kPassTok = 64; +/* |q| <= 127 * 128: hi = round(q / 128) stays in int8, lo = q - 128 hi in [-64, 64]. */ +constexpr float kQMax = 16256.0f; + +/* One width class, as the launch sees it. */ +struct Cls { + const uint8_t* W; /* the IQR weight buffer (codes, then the computed code's A and B) */ + const uint8_t* S; /* its scale buffer: the rows' f32 scales, then the blocks' factors */ + uint32_t N; /* rows */ + uint32_t bits; /* code width */ + const int32_t* ids; /* the vocabulary id of each row, global, ascending */ + uint32_t blk0; /* the first grid block of this class */ + uint32_t row0; /* its first row in the classes' row order (the staging plane's) */ +}; +struct Head { + Cls c[kMaxClass]; /* widest first */ + uint32_t n; /* classes */ + uint32_t nkb; /* K / 128 */ + int32_t off; /* this rank's first vocabulary id */ + uint32_t n_vocab; /* this rank's share */ +}; + +/* ---- the activation: rotated, sixteen bits as two int8 planes ------------------------------ + * + * A wave a (token, 128-K block): each lane's four values through r4d_fwht_wave, the block's + * absolute maximum, then q = rint(x * kQMax / amax). An all-zero block stores zeros under scale 0. */ +__global__ __launch_bounds__(kWave) void vocab_quant_kernel(const uint16_t* __restrict__ X, + uint32_t x_ld, int8_t* __restrict__ XH, + int8_t* __restrict__ XL, + float* __restrict__ XS, uint32_t K) { + const uint32_t m = blockIdx.x, kb = blockIdx.y, lane = threadIdx.x; + const uint32_t nkb = K / kBlock; + const uint2 raw = *(const uint2*)(X + (size_t)m * x_ld + kb * kBlock + 4u * lane); + float v[4] = { __uint_as_float(raw.x << 16), __uint_as_float(raw.x & 0xFFFF0000u), + __uint_as_float(raw.y << 16), __uint_as_float(raw.y & 0xFFFF0000u) }; + r4d_fwht_wave<128>(v, (int)lane); + float a = 0.0f; +#pragma unroll + for (uint32_t i = 0; i < 4; ++i) a = fmaxf(a, fabsf(v[i])); + a = r4d_wave_max(a); + const float inv = a > 0.0f ? kQMax / a : 0.0f; + uint32_t hp = 0, lp = 0; +#pragma unroll + for (uint32_t i = 0; i < 4; ++i) { + const int q = (int)fminf(fmaxf(rintf(v[i] * inv), -kQMax), kQMax); + const int hi = (q + 64) >> 7, lo = q - (hi << 7); + hp |= ((uint32_t)hi & 0xFFu) << (8u * i); + lp |= ((uint32_t)lo & 0xFFu) << (8u * i); + } + const size_t o = (size_t)m * K + kb * kBlock + 4u * lane; + *(uint32_t*)(XH + o) = hp; + *(uint32_t*)(XL + o) = lp; + if (lane == 0) XS[(size_t)m * nkb + kb] = a / kQMax; +} + +/* ---- vocabulary order through the staging plane --------------------------------------- + * + * `vrow` is the head's inverse map, one word a vocabulary id: its class's code width in the top four + * bits and its row in the class's whole tensor below, of which this rank holds rows + * [rank * rows, (rank + 1) * rows). A row's tokens are one contiguous read, consecutive ids + * consecutive writes. A staging row is `mp` floats (16-byte aligned). */ +__global__ void vocab_gather_kernel(Head h, const float* __restrict__ st, + const int32_t* __restrict__ vrow, float* __restrict__ out, + uint32_t c_ld, uint32_t mp, uint32_t nb) { + const uint32_t v = blockIdx.x * blockDim.x + threadIdx.x; + if (v >= h.n_vocab) return; + const uint32_t w = (uint32_t)vrow[v], b = w >> 28, rank = (uint32_t)h.off / h.n_vocab; + uint32_t rc = 0, r0 = 0; +#pragma unroll + for (uint32_t k = 0; k < kMaxClass; ++k) + if (k < h.n && h.c[k].bits == b) { rc = h.c[k].N; r0 = h.c[k].row0; } + const uint32_t j = (w & 0x0FFFFFFFu) - rank * rc; + const bool ok = j < rc; + const float4* const src = (const float4*)(st + (size_t)(ok ? r0 + j : 0u) * mp); + for (uint32_t m4 = 0; m4 < nb; m4 += 4) { + float4 q = src[m4 / 4]; + if (!ok) q = make_float4(0.0f, 0.0f, 0.0f, 0.0f); + const float qv[4] = { q.x, q.y, q.z, q.w }; +#pragma unroll + for (uint32_t i = 0; i < 4; ++i) + if (m4 + i < nb) out[(size_t)(m4 + i) * c_ld + v] = qv[i]; + } +} + +/* ---- the decoder --------------------------------------------------------------------------- + * + * r4d_iqr_dec.h's for the computed trellis under one scale a row, with the continuation read + * compactly: a column's stream is 16 B bits, so each of a lane's four columns starts at bit 0 or + * 16 of a dword, and the at most 15 bits a row's state takes from the unit above lie in that one + * dword: four dword loads a unit, where Dec reads the unit above's whole segment again (fourteen + * dwords at seven bits). */ +template +struct HeadDec { + static constexpr uint32_t L = 16, LANE_BITS = 64u * B, ND = LANE_BITS / 32u, CB = 16u * B; + struct Raw { uint32_t d[ND]; uint32_t p[4]; }; + + __device__ static Raw fetch(const uint8_t* W, uint32_t nkb, uint32_t rt, uint32_t kb, + uint32_t lane, bool live) { + Raw r; + constexpr size_t ub = 4u * LANE_BITS; + load_dw(r.d, W + ((size_t)rt * nkb + kb) * ub + lane * (LANE_BITS / 8u), live); + /* the unit above in the run of 256 rows (16 tiles), tail-biting at the run's first */ + const uint32_t rp = rt % 16u == 0u ? rt + 15u : rt - 1u; + const uint32_t* up = (const uint32_t*)(W + ((size_t)rp * nkb + kb) * ub + lane * (LANE_BITS / 8u)); +#pragma unroll + for (uint32_t e = 0; e < 4; ++e) r.p[e] = live ? up[e * CB / 32u] : 0u; + return r; + } + + /* The lane's four values of each of the tile's 16 rows, packed: bytesum((st * A + Bc) & + * 0x3F3F3F3F) - 126 a state. */ + __device__ static void rows(const Raw& r, uint32_t A, uint32_t Bc, uint32_t (&w)[16]) { + /* a row's four values packed as soon as they are computed: the tile's NT accumulators + * leave no room for all 64 at once */ +#pragma unroll + for (uint32_t q = 0; q < 16; ++q) { + uint32_t t[4]; +#pragma unroll + for (uint32_t e = 0; e < 4; ++e) { + const uint32_t pos = e * CB + q * B, own = CB - q * B; + const uint32_t st = + L <= own ? field(r.d, pos, L) + : field(r.d, pos, own) | + ((r.p[e] >> ((e * CB) & 31u)) & ((1u << (L - own)) - 1u)) << own; + const uint32_t h = (__umul24(st, A) + Bc) & 0x3F3F3F3Fu; + t[e] = (uint32_t)__builtin_amdgcn_sudot4(false, (int)h, false, 0x01010101, -126, false); + } + w[15u - q] = pack4(pack2(t[0], t[1]), pack2(t[2], t[3])); + } + } +}; + +/* ---- the tile ------------------------------------------------------------------------------ + * + * gemm_iqr_nt_m64's narrow tile (r4d_gemm_iqr.hip) without the K split: MW waves a block, a wave + * one 16-row tile of its class against NT 16-token tiles whose hi and lo planes are staged through + * LDS a 256-K chunk at a time. Each unit's codes are fetched a chunk ahead, decoded to int8 and + * transposed into fragment order through the wave's LDS tile, then used by both planes' WMMA + * steps. */ +template +struct Lds { + static constexpr uint32_t FN = NT * 16, kB = FN * lds_pitch(); +}; + +template +__device__ __forceinline__ void vocab_tile(const Head& h, const Cls& cl, uint32_t bx, + const int8_t* __restrict__ XH, + const int8_t* __restrict__ XL, + const float* __restrict__ XS, float* __restrict__ out, + uint32_t c_ld, uint32_t nb, uint8_t* s_bh, + uint8_t* s_bl, uint8_t* s_tr) { + using D = HeadDec; + static_assert(F::KIND == kTrellisMad && F::LRB == 0 && F::SC == kRowF32 && F::L == 16, + "a computed trellis, one scale a row"); + constexpr uint32_t FK = kFK, FN = NT * 16, kU = FK / kBlock; + const uint32_t tid = threadIdx.x, lane = tid & (kWave - 1), wave = tid / kWave; + const uint32_t K = h.nkb * kBlock; + + Ctx c{}; + c.W = cl.W; + c.S = cl.S; + c.N = cl.N; + c.nkb = h.nkb; + c.run_tiles = 256u / 16u; + uint8_t* const tr = s_tr + wave * kTrBytes; + + const uint32_t m0 = bx * MW * 16u, n0 = blockIdx.y * FN; + const uint32_t wrow0 = m0 + wave * 16u; + const uint32_t arow = wrow0 / 16u; + const bool alive = wrow0 < cl.N; + + f8v raw[NT], acc[NT]; +#pragma unroll + for (uint32_t j = 0; j < NT; ++j) { raw[j] = acc_zero(); acc[j] = acc_zero(); } + + /* Staging: kTPR threads a token row of a chunk, both planes. */ + constexpr uint32_t kSeg = 32, kTPR = FK / kSeg, kRPP = (MW * kWave) / kTPR; + constexpr uint32_t kBP = (FN + kRPP - 1) / kRPP; + const uint32_t sn = tid / kTPR, sk = (tid % kTPR) * kSeg; + const uint32_t brow0 = n0 + frag_c(lane); + const uint8_t* const hsrc = (const uint8_t*)XH + (size_t)(n0 + sn) * K + sk; + const uint8_t* const lsrc = (const uint8_t*)XL + (size_t)(n0 + sn) * K + sk; + + Stage8 ph[kBP], pl[kBP]; +#pragma unroll + for (uint32_t p = 0; p < kBP; ++p) { + const uint32_t r = sn + p * kRPP; + const bool live = r < FN && n0 + r < nb; + ph[p] = stage8_load(hsrc + (size_t)p * kRPP * K, live); + pl[p] = stage8_load(lsrc + (size_t)p * kRPP * K, live); + } + typename D::Raw pf[kU], pfn[kU]; +#pragma unroll + for (uint32_t p = 0; p < kU; ++p) pf[p] = D::fetch(c.W, c.nkb, arow, p, lane, alive); + /* the computed code's A and B, after its 2^16 values (kept for the unrelayout) */ + constexpr Form fm{ F::KIND, F::B, F::LV, F::L, F::LRB, F::SC, 0 }; + const uint32_t* const ab = (const uint32_t*)(c.W + aux_off(fm, c.N, (int64_t)K) + (1 << 16)); + const uint32_t mA = ab[0], mB = ab[1]; + + for (uint32_t k0 = 0; k0 < K; k0 += FK) { +#pragma unroll + for (uint32_t p = 0; p < kBP; ++p) { + const uint32_t r = sn + p * kRPP; + if (r < FN) { + stage8_store(s_bh, r, sk, ph[p]); + stage8_store(s_bl, r, sk, pl[p]); + } + } + __syncthreads(); + const uint32_t k1 = k0 + FK; + if (k1 < K) { +#pragma unroll + for (uint32_t p = 0; p < kBP; ++p) { + const uint32_t r = sn + p * kRPP; + const bool live = r < FN && n0 + r < nb; + if (r < FN) { + ph[p] = stage8_load(hsrc + (size_t)p * kRPP * K + k1, live); + pl[p] = stage8_load(lsrc + (size_t)p * kRPP * K + k1, live); + } + } +#pragma unroll + for (uint32_t p = 0; p < kU; ++p) pfn[p] = D::fetch(c.W, c.nkb, arow, k1 / kBlock + p, lane, alive); + } + +#pragma unroll + for (uint32_t p = 0; p < kU; ++p) { + const uint32_t kb = k0 / kBlock + p; + uint32_t w[16]; + D::rows(pf[p], mA, mB, w); + Stage8 a8[2]; + frag(w, tr, lane, a8); + /* hi: 128 times its sum, exactly, in the accumulator; then lo on top */ +#pragma unroll + for (uint32_t kk = 0; kk < kBlock / kK; ++kk) { + const uint32_t ks = p * kBlock + kk * kK; + const i2v af = frag_of(a8[kk / 4u], kk % 4u); +#pragma unroll + for (uint32_t j = 0; j < NT; ++j) raw[j] = mma8(af, frag(s_bh, j * 16, ks, lane), raw[j]); + } +#pragma unroll + for (uint32_t j = 0; j < NT; ++j) +#pragma unroll + for (uint32_t t = 0; t < 8; ++t) + raw[j][t] = __int_as_float(__float_as_int(raw[j][t]) << 7); +#pragma unroll + for (uint32_t kk = 0; kk < kBlock / kK; ++kk) { + const uint32_t ks = p * kBlock + kk * kK; + const i2v af = frag_of(a8[kk / 4u], kk % 4u); +#pragma unroll + for (uint32_t j = 0; j < NT; ++j) raw[j] = mma8(af, frag(s_bl, j * 16, ks, lane), raw[j]); + } + /* the block's factor (shared by every row) times each token's activation scale */ + const float f = alive ? fold_f32(c, wrow0, kb) : 0.0f; +#pragma unroll + for (uint32_t j = 0; j < NT; ++j) { + const uint32_t tok = brow0 + j * 16; + const float ws = tok < nb ? f * XS[(size_t)tok * h.nkb + kb] : 0.0f; +#pragma unroll + for (uint32_t t = 0; t < 8; ++t) { + acc[j][t] = fmaf(acc_val(raw[j][t]), ws, acc[j][t]); + raw[j][t] = 0.0f; + } + } + } +#pragma unroll + for (uint32_t p = 0; p < kU; ++p) pf[p] = pfn[p]; + __syncthreads(); + } + + /* A lane's eight accumulator rows are consecutive rows of the wave's tile, of one token: their + * row scales and ids are two 16-byte loads each. STAGE: the logits go to the staging plane in + * the classes' row order, `c_ld` (the pass's tokens rounded up to four) a row, a wave's rows + * then a few consecutive lines; else each goes to its id. */ + if (!alive) return; + const uint32_t r0 = wrow0 + acc_row(lane, 0); + const float4 sa = *(const float4*)((const float*)cl.S + r0), sb = *(const float4*)((const float*)cl.S + r0 + 4); + const float rs[8] = { sa.x, sa.y, sa.z, sa.w, sb.x, sb.y, sb.z, sb.w }; + if constexpr (STAGE) { +#pragma unroll + for (uint32_t j = 0; j < NT; ++j) { + const uint32_t tok = brow0 + j * 16; + if (tok >= nb) continue; + float* const o = out + (size_t)(cl.row0 + r0) * c_ld + tok; +#pragma unroll + for (uint32_t t = 0; t < 8; ++t) o[(size_t)t * c_ld] = acc[j][t] * rs[t]; + } + } else { + const int4 ia = *(const int4*)(cl.ids + r0), ib = *(const int4*)(cl.ids + r0 + 4); + const int32_t id[8] = { ia.x, ia.y, ia.z, ia.w, ib.x, ib.y, ib.z, ib.w }; +#pragma unroll + for (uint32_t j = 0; j < NT; ++j) { + const uint32_t tok = brow0 + j * 16; + if (tok >= nb) continue; + float* const o = out + (size_t)tok * c_ld; +#pragma unroll + for (uint32_t t = 0; t < 8; ++t) { + const uint32_t v = (uint32_t)(id[t] - h.off); + if (v < h.n_vocab) o[v] = acc[j][t] * rs[t]; + } + } + } +} + +template +using VF = FormT; + +/* The widths the classes may have: the computed trellis's built row forms. */ +#define R4D_VOCAB_BITS(X) X(2) X(3) X(4) X(5) X(6) X(7) + +/* Six waves a SIMD: 4 and 8 measure within 2% of it at every width (M = 1 .. 64). */ +template +__global__ __launch_bounds__(MW * kWave) R4D_WAVES(6) +void vocab_tile_kernel(Head h, const int8_t* __restrict__ XH, const int8_t* __restrict__ XL, + const float* __restrict__ XS, float* __restrict__ out, uint32_t c_ld, + uint32_t nb) { + __shared__ __attribute__((aligned(16))) uint8_t s_bh[Lds::kB]; + __shared__ __attribute__((aligned(16))) uint8_t s_bl[Lds::kB]; + __shared__ __attribute__((aligned(16))) uint8_t s_tr[MW * kTrBytes]; + /* the block's class: the last whose first block is at or below this one (uniform), copied + * at constant indices so the argument block is never indexed at run time */ + Cls cl = h.c[0]; +#pragma unroll + for (uint32_t i = 1; i < kMaxClass; ++i) + if (i < h.n && blockIdx.x >= h.c[i].blk0) cl = h.c[i]; + const uint32_t bx = blockIdx.x - cl.blk0; + switch (cl.bits) { +#define R4D_VOCAB_CASE(b) \ + case b: vocab_tile, NT, MW, STAGE>(h, cl, bx, XH, XL, XS, out, c_ld, nb, s_bh, s_bl, s_tr); \ + break; + R4D_VOCAB_BITS(R4D_VOCAB_CASE) +#undef R4D_VOCAB_CASE + default: break; + } +} + +constexpr uint32_t kMW = 8; + +struct Operands { + const RadTensor* x = nullptr; + const RadTensor* y = nullptr; + const RadTensor *w[kMaxClass] = {}, *s[kMaxClass] = {}, *r[kMaxClass] = {}, *vrow = nullptr; + long long M = 0, K = 0, rows[kMaxClass] = {}; + uint32_t n = 0; +}; + +/* Operand order: x, then (w, s, ids) a class, the inverse map, the logits (r4d_rows.cpp's + * oLogitsVocab). */ +constexpr int kOpX = 0, kOpMap = 1 + 3 * (int)kMaxClass, kOpY = kOpMap + 1; + +int operands(const RadArgs* a, Operands* g) { + g->x = r4d_opt(a, kOpX); + g->y = r4d_opt(a, kOpY); + if (!g->x || !g->y) return R4D_NO(RAD_E_INVAL); + if (g->x->dtype != RAD_BF16 || g->y->dtype != RAD_F32) return R4D_NO(RAD_E_DTYPE); + if (g->x->rank < 2 || g->y->rank < 2) return R4D_NO(RAD_E_SHAPE); + g->M = g->x->shape[0]; + g->K = r4d_geti_or(a, "n_embd", 0); + if (g->M < 1 || g->K < kFK || g->K % kFK || r4d_numel(g->x) != g->M * g->K) + return R4D_NO(RAD_E_SHAPE); + if (g->y->shape[0] < g->M) return R4D_NO(RAD_E_SHAPE); + static const char* kRows[kMaxClass] = { "rows0", "rows1", "rows2", "rows3" }; + for (uint32_t i = 0; i < kMaxClass; ++i) { + const RadTensor* w = r4d_opt(a, 1 + 3 * (int)i); + const RadTensor* s = r4d_opt(a, 2 + 3 * (int)i); + const RadTensor* r = r4d_opt(a, 3 + 3 * (int)i); + const long long n = r4d_geti_or(a, kRows[i], 0); + if (!w && !s && !r && n == 0) break; + if (!w || !s || !r || n < 256 || n % 256) return R4D_NO(RAD_E_SHAPE); + if (!is_weight_dtype(w->dtype) || !is_scale_dtype(s->dtype) || r->dtype != RAD_I32) + return R4D_NO(RAD_E_DTYPE); + const uint32_t word = w->dtype & kWordMask; + const Form f = form(word); + if ((s->dtype & kWordMask) != word || f.kind != kTrellisMad || f.L != 16 || f.lrb != 0 || + f.scale != kRowF32 || f.lrun != 8 || f.bits < 2 || f.bits > 7) + return R4D_NO(RAD_E_DTYPE); + if (w->shape[0] != n || w->shape[1] != g->K || r4d_numel(r) != n) return R4D_NO(RAD_E_SHAPE); + if (!r4d_aligned(w->data, 256) || !r4d_aligned(s->data, 16) || !r4d_aligned(r->data, 16)) + return R4D_NO(RAD_E_ALIGN); + g->w[i] = w; + g->s[i] = s; + g->r[i] = r; + g->rows[i] = n; + g->n = i + 1; + } + if (g->n == 0) return R4D_NO(RAD_E_INVAL); + g->vrow = r4d_opt(a, kOpMap); + if (!g->vrow || g->vrow->dtype != RAD_I32 || r4d_numel(g->vrow) != r4d_geti_or(a, "n_vocab", -1)) + return R4D_NO(RAD_E_SHAPE); + if (r4d_row_pitch(g->x) != g->K) return R4D_NO(RAD_E_STRIDE); + return RAD_OK; +} + +/* The staging plane's tokens: a pass of up to this many stages, a larger one stores directly + * (staging 48 tokens measured 1175 us against the direct store's 1062 at 33). */ +constexpr uint32_t kStageTok = 32; + +/* Scratch: the two int8 planes and the scales for every token, then the staging plane. */ +long long scratch_bytes(long long M, long long K, long long rows) { + return 2 * align256(M * K) + align256(M * (K / kBlock) * 4) + align256(rows * kStageTok * 4); +} + +} // namespace + +extern "C" int64_t r4d_rad_logits_gemm_vocab_scratch(const RadArgs* a) { + const long long M = r4d_geti_or(a, "M", 0), K = r4d_geti_or(a, "n_embd", 0); + static const char* kRows[kMaxClass] = { "rows0", "rows1", "rows2", "rows3" }; + long long rows = 0; + for (const char* k : kRows) rows += r4d_geti_or(a, k, 0); + if (M < 1 || K < 1) return 0; + return (int64_t)scratch_bytes(M, K, rows); +} + +extern "C" int r4d_rad_logits_gemm_vocab(const RadArgs* a, RadStream s) { + Operands g; + const int rc = operands(a, &g); + if (rc != RAD_OK) return rc; + const long long M = g.M, K = g.K, nkb = K / kBlock; + long long rows = 0; + for (uint32_t i = 0; i < g.n; ++i) rows += g.rows[i]; + if (!a->scratch || (long long)a->scratch_bytes < scratch_bytes(M, K, rows)) + return R4D_NO(RAD_E_SHAPE); + int8_t* const xh = (int8_t*)a->scratch; + int8_t* const xl = xh + align256(M * K); + float* const xs = (float*)(xl + align256(M * K)); + float* const stg = (float*)((uint8_t*)xs + align256(M * (K / kBlock) * 4)); + + Head h{}; + h.n = g.n; + h.nkb = (uint32_t)nkb; + h.off = (int32_t)r4d_geti_or(a, "vocab_offset", 0); + h.n_vocab = (uint32_t)r4d_geti_or(a, "n_vocab", 0); + const long long c_ld = r4d_row_pitch(g.y); + if (h.n_vocab < 1 || c_ld < (long long)h.n_vocab) return R4D_NO(RAD_E_SHAPE); + /* the widest class first: the narrow classes' cheaper blocks then fill the tail */ + uint32_t ord[kMaxClass]; + for (uint32_t i = 0; i < g.n; ++i) ord[i] = i; + std::sort(ord, ord + g.n, [&](uint32_t x, uint32_t y) { + return form(g.w[x]->dtype & kWordMask).bits > form(g.w[y]->dtype & kWordMask).bits; + }); + uint32_t blocks = 0; + for (uint32_t i = 0; i < g.n; ++i) { + const uint32_t k = ord[i]; + Cls& c = h.c[i]; + c.W = (const uint8_t*)g.w[k]->data; + c.S = (const uint8_t*)g.s[k]->data; + c.ids = (const int32_t*)g.r[k]->data; + c.N = (uint32_t)g.rows[k]; + c.bits = form(g.w[k]->dtype & kWordMask).bits; + c.blk0 = blocks; + c.row0 = blocks * kMW * 16u; + blocks += c.N / (kMW * 16u); + } + + if (R4D_EMIT(s, vocab_quant_kernel, dim3((uint32_t)M, (uint32_t)nkb), dim3(kWave), 0, + (const uint16_t*)g.x->data, (uint32_t)K, xh, xl, xs, (uint32_t)K) != RAD_OK) + return R4D_NO(RAD_E_DEVICE); + for (long long t0 = 0; t0 < M; t0 += kPassTok) { + const uint32_t nb = (uint32_t)std::min(kPassTok, M - t0); + const uint32_t nt = nb > 48 ? 4u : nb > 32 ? 3u : nb > 16 ? 2u : 1u; + const dim3 grid(blocks, 1, 1); + const int8_t* const ph = xh + t0 * K; + const int8_t* const pl = xl + t0 * K; + const float* const ps = xs + t0 * nkb; + const bool stage = nb <= kStageTok; + const uint32_t mp = (nb + 3u) / 4u * 4u; + float* const po = stage ? stg : (float*)g.y->data + t0 * c_ld; + const uint32_t ld = stage ? mp : (uint32_t)c_ld; + int e; +#define R4D_VOCAB_GO(nt_, st_) \ + e = R4D_EMIT(s, (vocab_tile_kernel), grid, dim3(kMW * kWave), 0, h, ph, pl, \ + ps, po, ld, nb) + if (nt == 4u) R4D_VOCAB_GO(4u, false); + else if (nt == 3u) R4D_VOCAB_GO(3u, false); + else if (nt == 2u) R4D_VOCAB_GO(2u, true); + else R4D_VOCAB_GO(1u, true); +#undef R4D_VOCAB_GO + if (e != RAD_OK) return R4D_NO(RAD_E_DEVICE); + if (stage && R4D_EMIT(s, vocab_gather_kernel, dim3((h.n_vocab + 255u) / 256u), dim3(256), 0, + h, (const float*)stg, (const int32_t*)g.vrow->data, + (float*)g.y->data + t0 * c_ld, (uint32_t)c_ld, mp, nb) != RAD_OK) + return R4D_NO(RAD_E_DEVICE); + } + return hipGetLastError() == hipSuccess ? RAD_OK : R4D_NO(RAD_E_DEVICE); +} diff --git a/libr4d/r4d_mla.hip b/libr4d/r4d_mla.hip index 06f56fa0..18bee37b 100644 --- a/libr4d/r4d_mla.hip +++ b/libr4d/r4d_mla.hip @@ -5,6 +5,7 @@ #include "r4d_args.h" #include "r4d_common.h" #include "r4d_emit.h" +#include "r4d_fp8_wmma.h" #include "r4d_gdn_wmma.h" #include #include @@ -24,7 +25,7 @@ struct ProjectMeta { * sum runs over j in the same order whatever R is (expand: each lane's share in ascending j, then * r4d_xor_sum<32>), so a row's bytes do not depend on the batch it is in. A tail group past the * last row reads that row again and stores nothing for it. */ -template +template __global__ void project_absorb_rows(const uint16_t* x, const uint16_t* w, uint16_t* y, ProjectMeta m) { const int col = blockIdx.x * 128 + threadIdx.x, head = blockIdx.y, r0 = blockIdx.z * R; @@ -35,8 +36,8 @@ __global__ void project_absorb_rows(const uint16_t* x, const uint16_t* w, uint16 float sum[R]; #pragma unroll for (int r = 0; r < R; ++r) sum[r] = 0; - for (int j = 0; j < 256; ++j) { - const float wv = bf16_to_f32(w[((long)head * 512 + j) * m.wp + col]); + for (int j = 0; j < HD; ++j) { + const float wv = bf16_to_f32(w[((long)head * 2 * HD + j) * m.wp + col]); #pragma unroll for (int r = 0; r < R; ++r) sum[r] = fmaf(bf16_to_f32(xr[r][j]), wv, sum[r]); } @@ -44,7 +45,7 @@ __global__ void project_absorb_rows(const uint16_t* x, const uint16_t* w, uint16 for (int r = 0; r < R; ++r) if (r0 + r < m.rows) y[(long)(r0 + r) * m.yr + head * m.yh + col] = f32_to_bf16(sum[r]); } -template +template __global__ void project_expand_rows(const uint16_t* x, const uint16_t* w, uint16_t* y, ProjectMeta m) { const int lane = threadIdx.x & 31, col = blockIdx.x * 4 + (threadIdx.x >> 5), head = blockIdx.y, @@ -52,7 +53,7 @@ __global__ void project_expand_rows(const uint16_t* x, const uint16_t* w, uint16 const uint16_t* xr[R]; #pragma unroll for (int r = 0; r < R; ++r) xr[r] = x + (long)min(r0 + r, m.rows - 1) * m.xr + head * m.xh; - const uint16_t* const wr = w + ((long)head * 512 + 256 + col) * m.wp; + const uint16_t* const wr = w + ((long)head * 2 * HD + HD + col) * m.wp; float sum[R]; #pragma unroll for (int r = 0; r < R; ++r) sum[r] = 0; @@ -77,7 +78,7 @@ int project_body(const RadArgs* a, RadStream stream) { const char* mode = r4d_gets(a, "mode"); const bool absorb = mode && !std::strcmp(mode, "absorb"), expand = mode && !std::strcmp(mode, "expand"); - const long h = r4d_geti_or(a, "heads", 0); + const long h = r4d_geti_or(a, "heads", 0), hd = r4d_geti_or(a, "head_dim", 0); auto heads_view = [&](RadTensor& t, long width) { if (h > 0 && t.rank == 2 && t.shape[1] == h * width) { t.rank = 3; @@ -87,15 +88,15 @@ int project_body(const RadArgs* a, RadStream stream) { t.stride[1] *= width; } }; - heads_view(x, absorb ? 256 : 512); - heads_view(y, absorb ? 512 : 256); + heads_view(x, absorb ? hd : 512); + heads_view(y, absorb ? 512 : hd); if (x.dtype != RAD_BF16 || w.dtype != RAD_BF16 || y.dtype != RAD_BF16) return RAD_E_DTYPE; if (!x.data || !w.data || !y.data) return RAD_E_INVAL; - if ((!absorb && !expand) || h < 1 || h > 64 || r4d_geti_or(a, "head_dim", 0) != 256 || + if ((!absorb && !expand) || h < 1 || h > 64 || (hd != 128 && hd != 256) || r4d_geti_or(a, "latent_dim", 0) != 512 || x.rank != 3 || w.rank != 2 || y.rank != 3 || x.shape[0] < 1 || x.shape[0] > 65535 || x.shape[1] != h || - x.shape[2] != (absorb ? 256 : 512) || w.shape[0] != h * 512 || w.shape[1] != 512 || - y.shape[0] != x.shape[0] || y.shape[1] != h || y.shape[2] != (absorb ? 512 : 256) || + x.shape[2] != (absorb ? hd : 512) || w.shape[0] != h * 2 * hd || w.shape[1] != 512 || + y.shape[0] != x.shape[0] || y.shape[1] != h || y.shape[2] != (absorb ? 512 : hd) || x.stride[2] != 1 || w.stride[1] != 1 || y.stride[2] != 1 || x.stride[1] < x.shape[2] || x.stride[0] < h * x.stride[1] || w.stride[0] < 512 || y.stride[1] < y.shape[2] || y.stride[0] < h * y.stride[1]) @@ -107,20 +108,26 @@ int project_body(const RadArgs* a, RadStream stream) { auto* yp = (uint16_t*)y.data; /* The largest of 8, 4, 2 and 1 rows a group that the batch fills. */ const int R = m.rows >= 8 ? 8 : m.rows >= 4 ? 4 : m.rows >= 2 ? 2 : 1; -#define MLA_PROJECT_ROWS(RR) \ +#define MLA_PROJECT_HD(RR, HD) \ do { \ const unsigned groups = (unsigned)((m.rows + RR - 1) / RR); \ if (absorb) \ - return R4D_EMIT(stream, (project_absorb_rows), dim3(4, h, groups), dim3(128), 0, \ - xp, wp, yp, m); \ - return R4D_EMIT(stream, (project_expand_rows), dim3(64, h, groups), dim3(128), 0, xp, \ - wp, yp, m); \ + return R4D_EMIT(stream, (project_absorb_rows), dim3(4, h, groups), dim3(128), \ + 0, xp, wp, yp, m); \ + return R4D_EMIT(stream, (project_expand_rows), dim3(HD / 4, h, groups), dim3(128), \ + 0, xp, wp, yp, m); \ + } while (0) +#define MLA_PROJECT_ROWS(RR) \ + do { \ + if (hd == 128) MLA_PROJECT_HD(RR, 128); \ + MLA_PROJECT_HD(RR, 256); \ } while (0) if (R == 8) MLA_PROJECT_ROWS(8); if (R == 4) MLA_PROJECT_ROWS(4); if (R == 2) MLA_PROJECT_ROWS(2); MLA_PROJECT_ROWS(1); #undef MLA_PROJECT_ROWS +#undef MLA_PROJECT_HD } constexpr int D = 512, PART = D + 2; constexpr int64_t scratch_bytes = 512ll * PART * 4; @@ -149,7 +156,49 @@ __device__ void load_latent(const uint16_t* p, float (&v)[16]) { for (int j = 0; j < 16; ++j) v[j] = bf16_to_f32(p[j]); } } -__global__ __launch_bounds__(128) void attend(const uint16_t* q, const uint16_t* kv, const int* bt, +/* The latent cache is bf16, or E4M3 as kv_store_fp8 writes it at its default descale of 1, so a + * code is the value itself. Every E4M3 value is a bf16 (three mantissa bits against seven, an + * exponent range bf16 contains), so an fp8 key decodes exactly to the bf16 the tiles hold and every + * kernel's arithmetic past the load is its bf16 instance's. The loads below are overloaded on the + * cache's element type; at uint16_t each is the plain load the bf16 kernels always made. */ +template +__device__ __forceinline__ uint32_t e4m3x2_bf16(uint32_t w) { + const v2f f = r4d_fp8::e4m3_pk(w); + return (__float_as_uint(f.x) >> 16) | (__float_as_uint(f.y) & 0xffff0000u); +} +__device__ __forceinline__ void load_latent(const uint8_t* p, float (&v)[16]) { + if (!((uintptr_t)p & 15)) { + const uint4 a = *(const uint4*)p; + const uint32_t packed[4] = { a.x, a.y, a.z, a.w }; +#pragma unroll + for (int j = 0; j < 4; ++j) { + const v2f lo = r4d_fp8::e4m3_pk(packed[j]), + hi = r4d_fp8::e4m3_pk(packed[j]); + v[4 * j] = lo.x; + v[4 * j + 1] = lo.y; + v[4 * j + 2] = hi.x; + v[4 * j + 3] = hi.y; + } + } else { +#pragma unroll + for (int j = 0; j < 16; ++j) v[j] = r4d_fp8::e4m3(p[j]); + } +} +/* Eight consecutive cache elements as four bf16 pairs: one 16-byte load at bf16, one 8-byte load + * at E4M3. The caller keeps the 16-byte alignment the bf16 load needs, which covers the E4M3 one. */ +__device__ __forceinline__ uint4 load8(const uint16_t* p) { return *(const uint4*)p; } +__device__ __forceinline__ uint4 load8(const uint8_t* p) { + const uint2 raw = *(const uint2*)p; + return make_uint4(e4m3x2_bf16(raw.x), e4m3x2_bf16(raw.x), + e4m3x2_bf16(raw.y), e4m3x2_bf16(raw.y)); +} +/* One cache element as bf16 bits. */ +__device__ __forceinline__ uint16_t elem(const uint16_t* p) { return *p; } +__device__ __forceinline__ uint16_t elem(const uint8_t* p) { + return (uint16_t)(__float_as_uint(r4d_fp8::e4m3(*p)) >> 16); +} +template +__global__ __launch_bounds__(128) void attend(const uint16_t* q, const K* kv, const int* bt, const int* len, uint16_t* out, float* scratch, Meta m) { const int lane = threadIdx.x & 31, head = blockIdx.y * 4 + (threadIdx.x >> 5), r = blockIdx.x, @@ -219,6 +268,184 @@ __global__ __launch_bounds__(128) void merge(const float* scratch, uint16_t* out out[(long)r * m.orr + (long)head * m.oh + lane * 16 + j] = f32_to_bf16(den > 0 ? value[j] / den : 0); } +/* mla_attn_paged: dense causal latent attention over a cache row of [latent 512 | rope 64], one + * page table a sequence (Ling-3.0's MLA). A wave a (query row, head) as `attend`: lane l holds + * latent columns 16l..16l+15 and rotary columns 2l, 2l+1, so a score is one wave sum. A row's + * sequence, position and causal bound come from cu_seqlens and seqused as attn_paged reads them. + * A short batch splits its history over waves and `merge_paged` joins the f32 partials; the + * optional head gate multiplies the rounded output by the rounded sigmoid of the head's logit. */ +constexpr int RD = 64; +struct PagedMeta { + long qr, qh, rr, rh, kp, kt, bp, bc, orr, oh, gr; + int rows, heads, seqs, blocks, bs, pages, splits; + float scale; +}; +__device__ __forceinline__ int paged_seq(const int* cu, int seqs, int r) { + int s = 0; + while (s + 1 < seqs && cu[s + 1] <= r) ++s; + return s; +} +__device__ __forceinline__ void paged_store(uint16_t* out, const uint16_t* gate, const PagedMeta& m, + int r, int head, int lane, const float (&value)[16], + float den) { + float g = 1.0f; + if (gate) g = bf16_to_f32(f32_to_bf16(1.0f / (1.0f + expf(-bf16_to_f32(gate[(long)r * m.gr + head]))))); +#pragma unroll + for (int j = 0; j < 16; ++j) { + float v = den > 0 ? value[j] / den : 0; + if (gate) v = bf16_to_f32(f32_to_bf16(v)) * g; + out[(long)r * m.orr + (long)head * m.oh + lane * 16 + j] = f32_to_bf16(v); + } +} +__global__ __launch_bounds__(128) void attend_paged(const uint16_t* q, const uint16_t* qrot, + const uint16_t* kv, const int* bt, + const int* used, const int* cu, + const uint16_t* gate, uint16_t* out, + float* scratch, PagedMeta m) { + const int lane = threadIdx.x & 31, head = blockIdx.y * 4 + (threadIdx.x >> 5), r = blockIdx.x, + split = blockIdx.z; + if (head >= m.heads) return; + const int s = paged_seq(cu, m.seqs, r); + const int qlen = cu[s + 1] - cu[s], i = r - cu[s]; + const int live = min(max(used[s] - qlen + i + 1, 0), m.blocks * m.bs); + const int begin = (int)((long)live * split / m.splits), + end = (int)((long)live * (split + 1) / m.splits); + float query[16], value[16] = {}; + load_latent(q + (long)r * m.qr + (long)head * m.qh + lane * 16, query); + const uint16_t* const qp = qrot + (long)r * m.rr + (long)head * m.rh + lane * 2; + const float rq0 = bf16_to_f32(qp[0]), rq1 = bf16_to_f32(qp[1]); + float max_score = -INFINITY, den = 0; + for (int token = begin; token < end; ++token) { + const int page = bt[(long)s * m.bp + (token / m.bs) * m.bc]; + if (page < 0 || page >= m.pages) continue; + const uint16_t* const row = kv + (long)page * m.kp + (token % m.bs) * m.kt; + float key[16]; + load_latent(row + lane * 16, key); + float score = rq0 * bf16_to_f32(row[D + lane * 2]) + rq1 * bf16_to_f32(row[D + lane * 2 + 1]); +#pragma unroll + for (int j = 0; j < 16; ++j) score += query[j] * key[j]; + score = r4d_wave_sum(score) * m.scale; + const bool higher = score > max_score; + const float weight = expf(higher ? max_score - score : score - max_score); + if (higher) { +#pragma unroll + for (int j = 0; j < 16; ++j) value[j] = value[j] * weight + key[j]; + den = den * weight + 1; + max_score = score; + } else { +#pragma unroll + for (int j = 0; j < 16; ++j) value[j] += key[j] * weight; + den += weight; + } + } + if (m.splits == 1) { + paged_store(out, gate, m, r, head, lane, value, den); + } else { + float* dst = scratch + (((long)r * m.heads + head) * m.splits + split) * PART; +#pragma unroll + for (int j = 0; j < 16; ++j) dst[lane * 16 + j] = value[j]; + if (!lane) { + dst[D] = max_score; + dst[D + 1] = den; + } + } +} +__global__ __launch_bounds__(128) void merge_paged(const float* scratch, const uint16_t* gate, + uint16_t* out, PagedMeta m) { + const int lane = threadIdx.x & 31, head = blockIdx.y * 4 + (threadIdx.x >> 5), r = blockIdx.x; + if (head >= m.heads) return; + const float* src = scratch + ((long)r * m.heads + head) * m.splits * PART; + float max_score = -INFINITY; + for (int s = 0; s < m.splits; ++s) + if (src[s * PART + D + 1] > 0) max_score = fmaxf(max_score, src[s * PART + D]); + float value[16] = {}, den = 0; + for (int s = 0; s < m.splits; ++s) { + const float part_den = src[s * PART + D + 1]; + if (!(part_den > 0)) continue; + const float w = expf(src[s * PART + D] - max_score); + den += part_den * w; +#pragma unroll + for (int j = 0; j < 16; ++j) value[j] += src[s * PART + lane * 16 + j] * w; + } + paged_store(out, gate, m, r, head, lane, value, den); +} +/* Splits of a (row, head) job's history. A row's bytes must not depend on the batch it is in: a + * speculative verify scores the k + 1 rows of a sequence in one launch, and greedy output equals + * the run without speculation only if each row gives the single-row decode at its position bit for + * bit. So the count is a function of the head count alone, not of the launch's rows or its longest + * table. A history shorter than the count leaves splits empty; they exit at once and merge_paged + * skips them. */ +/* The rows the scratch serves at full split: a verify at depth 31. */ +constexpr long kPagedRows = 32; +int paged_splits(long heads) { return (int)std::min(16l, (256 + heads - 1) / heads); } +int64_t paged_scratch_bytes(long rows, long heads) { + return std::min(rows, kPagedRows) * heads * paged_splits(heads) * PART * 4; +} +/* Operands: q [M, heads, 512], q_rope [M, heads, 64], kv [pages, 1, bs, >= 576], block_table + * [seqs, blocks], seqused [seqs], cu_seqlens [seqs + 1], gate [M, >= heads] (optional), out + * [M, heads, 512]. */ +int paged_body(const RadArgs* a, RadStream stream) { + if (!a || a->n_t < 8) return RAD_E_INVAL; + RadTensor q = a->t[0], qr = a->t[1], o = a->t[7]; + const auto &kv = a->t[2], &bt = a->t[3], &su = a->t[4], &cu = a->t[5]; + const RadTensor* gate = r4d_opt(a, 6); + const long heads = r4d_geti_or(a, "heads", 0), bs = r4d_geti_or(a, "block_size", 0); + const float scale = (float)r4d_getf(a, "scale", 0); + auto heads_view = [&](RadTensor& t, long width) { + if (heads > 0 && t.rank == 2 && t.shape[1] == heads * width) { + t.rank = 3; + t.shape[1] = heads; + t.shape[2] = width; + t.stride[2] = t.stride[1]; + t.stride[1] *= width; + } + }; + heads_view(q, D); + heads_view(qr, RD); + heads_view(o, D); + if (q.dtype != RAD_BF16 || qr.dtype != RAD_BF16 || kv.dtype != RAD_BF16 || + o.dtype != RAD_BF16 || bt.dtype != RAD_I32 || su.dtype != RAD_I32 || cu.dtype != RAD_I32 || + (gate && gate->dtype != RAD_BF16)) + return RAD_E_DTYPE; + if (!q.data || !qr.data || !kv.data || !bt.data || !su.data || !cu.data || !o.data) + return RAD_E_INVAL; + if (r4d_geti_or(a, "latent_dim", 0) != D || r4d_geti_or(a, "rope_dim", 0) != RD || heads < 1 || + heads > 64 || bs < 1 || bs > 256 || !std::isfinite(scale) || scale <= 0 || q.rank != 3 || + q.shape[0] < 1 || q.shape[0] > 65535 || q.shape[1] != heads || q.shape[2] != D || + q.stride[2] != 1 || q.stride[1] < D || q.stride[0] < heads * q.stride[1] || qr.rank != 3 || + qr.shape[0] != q.shape[0] || qr.shape[1] != heads || qr.shape[2] != RD || + qr.stride[2] != 1 || qr.stride[1] < RD || qr.stride[0] < heads * qr.stride[1] || + kv.rank != 4 || kv.shape[0] < 1 || kv.shape[0] > INT_MAX || kv.shape[1] != 1 || + kv.shape[2] != bs || kv.shape[3] < D + RD || kv.stride[3] != 1 || kv.stride[2] < D + RD || + kv.stride[0] < bs * kv.stride[2] || bt.rank != 2 || bt.shape[1] < 1 || + bt.shape[1] > INT_MAX / bs || bt.stride[1] < 1 || bt.stride[0] < bt.shape[1] * bt.stride[1] || + su.rank != 1 || su.shape[0] < 1 || bt.shape[0] < su.shape[0] || !r4d_contig(&su) || + !r4d_contig(&cu) || r4d_numel(&cu) != su.shape[0] + 1 || o.rank != 3 || + o.shape[0] != q.shape[0] || o.shape[1] != heads || o.shape[2] != D || o.stride[2] != 1 || + o.stride[1] < D || o.stride[0] < heads * o.stride[1] || + (gate && (gate->rank != 2 || gate->shape[0] != q.shape[0] || gate->shape[1] < heads || + gate->stride[1] != 1))) + return RAD_E_SHAPE; + /* The split comes from the head count alone (paged_splits). Only a batch whose partials the + * scratch cannot hold takes fewer, as many as fit. */ + const long rows = q.shape[0], slots = a->scratch ? a->scratch_bytes / (PART * 4) : 0; + int splits = paged_splits(heads); + if (rows * heads * splits > slots) splits = (int)std::max(1l, slots / (rows * heads)); + const PagedMeta m{ q.stride[0], q.stride[1], qr.stride[0], qr.stride[1], + kv.stride[0], kv.stride[2], bt.stride[0], bt.stride[1], + o.stride[0], o.stride[1], gate ? (long)gate->stride[0] : 0L, + (int)q.shape[0], (int)heads, (int)su.shape[0], (int)bt.shape[1], + (int)bs, (int)kv.shape[0], splits, scale }; + const uint16_t* gp = gate ? (const uint16_t*)gate->data : nullptr; + int rc = R4D_EMIT(stream, attend_paged, dim3(m.rows, (m.heads + 3) / 4, m.splits), dim3(128), 0, + (const uint16_t*)q.data, (const uint16_t*)qr.data, (const uint16_t*)kv.data, + (const int*)bt.data, (const int*)su.data, (const int*)cu.data, gp, + (uint16_t*)o.data, (float*)a->scratch, m); + if (rc == RAD_OK && splits > 1) + rc = R4D_EMIT(stream, merge_paged, dim3(m.rows, (m.heads + 3) / 4), dim3(128), 0, + (const float*)a->scratch, gp, (uint16_t*)o.data, m); + return rc; +} /* Heads are the matrix rows, so all sixteen share each latent load even when * each query selected different pages. Splitting P into BF16 high/low parts * preserves FP32 softmax precision without a materialized per-head KV cache. @@ -240,9 +467,10 @@ constexpr int kUnionBlocks = 520, kUnionSlots = 1024; __device__ __forceinline__ unsigned union_slot(int page) { return ((unsigned)page * 2654435761u) >> 22; } -/* STATS is its own instance: counting inside the loop costs the paired tile spilled VGPRs. */ -template -__global__ __launch_bounds__(128) void attend_matrix(const uint16_t* q, const uint16_t* kv, +/* STATS is its own instance: counting inside the loop costs the paired tile spilled VGPRs. K is + * the cache's element (uint16_t bf16, uint8_t E4M3). */ +template +__global__ __launch_bounds__(128) void attend_matrix(const uint16_t* q, const K* kv, const int* bt, const int* len, uint16_t* out, float* scratch, Meta m) { static_assert(PAIR || !UNION, "the union pairs two requests"); @@ -430,7 +658,7 @@ __global__ __launch_bounds__(128) void attend_matrix(const uint16_t* q, const ui for (int j = 0; j < 8; ++j) { const int flat = tid + j * 128; const long at = source[flat >> 6]; - part[j] = *(const uint4*)(kv + (at >= 0 ? at : 0) + (flat & 63) * 8); + part[j] = load8(kv + (at >= 0 ? at : 0) + (flat & 63) * 8); if (at < 0) part[j] = make_uint4(0, 0, 0, 0); } #pragma unroll @@ -441,7 +669,8 @@ __global__ __launch_bounds__(128) void attend_matrix(const uint16_t* q, const ui } else { for (int j = tid; j < 16 * 512; j += 128) { const int token = j / 512, col = j % 512; - keys[token * 520 + col] = source[token] >= 0 ? kv[source[token] + col] : 0; + keys[token * 520 + col] = + source[token] >= 0 ? elem(kv + source[token] + col) : 0; } } __syncthreads(); @@ -550,8 +779,8 @@ __global__ __launch_bounds__(128) void attend_matrix(const uint16_t* q, const ui * The next chunk's keys are fetched into registers while the current one is multiplied, so a * chunk costs two barriers. */ constexpr int kRowsPitch = 520; -template -__global__ __launch_bounds__(HG * 128) void attend_rows(const uint16_t* q, const uint16_t* kv, +template +__global__ __launch_bounds__(HG * 128) void attend_rows(const uint16_t* q, const K* kv, const int* bt, const int* len, uint16_t* out, float* scratch, Meta m) { constexpr int NT = HG * 128, LOADS = 16 * 64 / NT; @@ -593,13 +822,15 @@ __global__ __launch_bounds__(HG * 128) void attend_rows(const uint16_t* q, const const bool ok = page >= 0 && page < m.pages; const long at = ok ? (long)page * m.kp + (token % m.bs) * m.kt + piece * 8 : 0; if constexpr (WIDE) { - staged[j] = *(const uint4*)(kv + at); + staged[j] = load8(kv + at); if (!ok) staged[j] = make_uint4(0, 0, 0, 0); } else { uint32_t w[4]; #pragma unroll for (int i = 0; i < 4; ++i) - w[i] = ok ? (uint32_t)kv[at + 2 * i] | (uint32_t)kv[at + 2 * i + 1] << 16 : 0u; + w[i] = ok ? (uint32_t)elem(kv + at + 2 * i) | + (uint32_t)elem(kv + at + 2 * i + 1) << 16 + : 0u; staged[j] = make_uint4(w[0], w[1], w[2], w[3]); } staged_ok = ok ? staged_ok | 1u << j : staged_ok & ~(1u << j); @@ -747,11 +978,13 @@ void report_stats(RadStream stream) { "%llu second passes (%.3fx)\n", device, v[0], v[2], v[1], (double)v[0] / (double)v[2]); } -template +/* K is the cache's element: uint16_t for a bf16 cache, uint8_t for an E4M3 one. */ +template int body(const RadArgs* a, RadStream stream) { + constexpr uint32_t KV = sizeof(K) == 1 ? (uint32_t)RAD_F8E4M3 : (uint32_t)RAD_BF16; if (!a || a->n_t < 5) return RAD_E_INVAL; const auto &q = a->t[0], &kv = a->t[1], &bt = a->t[2], &len = a->t[3], &o = a->t[4]; - if (q.dtype != RAD_BF16 || kv.dtype != RAD_BF16 || o.dtype != RAD_BF16 || bt.dtype != RAD_I32 || + if (q.dtype != RAD_BF16 || kv.dtype != KV || o.dtype != RAD_BF16 || bt.dtype != RAD_I32 || len.dtype != RAD_I32) return RAD_E_DTYPE; for (int i = 0; i < 5; ++i) @@ -793,8 +1026,8 @@ int body(const RadArgs* a, RadStream stream) { int rc; if constexpr (MATRIX) { #define MATRIX_EMIT(P, W, U, S, X, Y) \ - R4D_EMIT(stream, (attend_matrix), dim3(X, Y, m.splits), dim3(128), 0, \ - (const uint16_t*)q.data, (const uint16_t*)kv.data, (const int*)bt.data, \ + R4D_EMIT(stream, (attend_matrix), dim3(X, Y, m.splits), dim3(128), 0, \ + (const uint16_t*)q.data, (const K*)kv.data, (const int*)bt.data, \ (const int*)len.data, (uint16_t*)o.data, (float*)a->scratch, m) #define MATRIX_LAUNCH(P, W, U, X, Y) \ (stats ? MATRIX_EMIT(P, W, U, true, X, Y) : MATRIX_EMIT(P, W, U, false, X, Y)) @@ -810,8 +1043,8 @@ int body(const RadArgs* a, RadStream stream) { #undef MATRIX_LAUNCH #undef MATRIX_EMIT } else - rc = R4D_EMIT(stream, attend, dim3(m.rows, (m.heads + 3) / 4, m.splits), dim3(128), 0, - (const uint16_t*)q.data, (const uint16_t*)kv.data, (const int*)bt.data, + rc = R4D_EMIT(stream, attend, dim3(m.rows, (m.heads + 3) / 4, m.splits), dim3(128), 0, + (const uint16_t*)q.data, (const K*)kv.data, (const int*)bt.data, (const int*)len.data, (uint16_t*)o.data, (float*)a->scratch, m); if (rc == RAD_OK && splits > 1) rc = R4D_EMIT(stream, merge, dim3(m.rows, (m.heads + 3) / 4), dim3(128), 0, @@ -829,10 +1062,12 @@ int g_mla_rows_form = 0; * the matrix row's four tiles a row and its splits are faster (r4d_selftest --case * mla_attn_rows_bf16, M 7: 0.5x). */ constexpr long kRowsMin = 32; +template int rows_body(const RadArgs* a, RadStream stream) { + constexpr uint32_t KV = sizeof(K) == 1 ? (uint32_t)RAD_F8E4M3 : (uint32_t)RAD_BF16; if (!a || a->n_t < 5) return RAD_E_INVAL; const auto &q = a->t[0], &kv = a->t[1], &bt = a->t[2], &len = a->t[3], &o = a->t[4]; - if (q.dtype != RAD_BF16 || kv.dtype != RAD_BF16 || o.dtype != RAD_BF16 || bt.dtype != RAD_I32 || + if (q.dtype != RAD_BF16 || kv.dtype != KV || o.dtype != RAD_BF16 || bt.dtype != RAD_I32 || len.dtype != RAD_I32) return RAD_E_DTYPE; for (int i = 0; i < 5; ++i) @@ -853,7 +1088,7 @@ int rows_body(const RadArgs* a, RadStream stream) { return RAD_E_SHAPE; if (heads % 32) return RAD_E_UNSUPPORTED; const int form = g_mla_rows_form; - if (form == 4 || (!form && q.shape[0] < kRowsMin)) return body(a, stream); + if (form == 4 || (!form && q.shape[0] < kRowsMin)) return body(a, stream); const int group_heads = heads % 64 || form == 2 ? 32 : 64; const long rows = q.shape[0], groups = heads / group_heads, jobs = rows * groups; /* Short batches split the history until 64 workgroups run, two to each of the R9700's 32 @@ -869,8 +1104,8 @@ int rows_body(const RadArgs* a, RadStream stream) { o.stride[1], (int)q.shape[0], (int)heads, (int)bt.shape[1], (int)bs, (int)kv.shape[0], splits, scale }; #define ROWS_EMIT(HG, W) \ - R4D_EMIT(stream, (attend_rows), dim3(m.rows, (unsigned)groups, m.splits), \ - dim3(HG * 128), 0, (const uint16_t*)q.data, (const uint16_t*)kv.data, \ + R4D_EMIT(stream, (attend_rows), dim3(m.rows, (unsigned)groups, m.splits), \ + dim3(HG * 128), 0, (const uint16_t*)q.data, (const K*)kv.data, \ (const int*)bt.data, (const int*)len.data, (uint16_t*)o.data, (float*)a->scratch, m) int rc; if (group_heads == 64) @@ -893,10 +1128,29 @@ extern "C" int r4d_rad_mla_attn_matrix(const RadArgs* a, RadStream stream) { extern "C" int r4d_rad_mla_attn_rows(const RadArgs* a, RadStream stream) { return rows_body(a, stream); } +/* The same three rows over an E4M3 latent cache (kv_dtype fp8_e4m3). */ +extern "C" int r4d_rad_mla_attn_fp8kv(const RadArgs* a, RadStream stream) { + return body(a, stream); +} +extern "C" int r4d_rad_mla_attn_matrix_fp8kv(const RadArgs* a, RadStream stream) { + return body(a, stream); +} +extern "C" int r4d_rad_mla_attn_rows_fp8kv(const RadArgs* a, RadStream stream) { + return rows_body(a, stream); +} extern "C" int r4d_rad_mla_project(const RadArgs* a, RadStream stream) { return project_body(a, stream); } +extern "C" int r4d_rad_mla_attn_paged(const RadArgs* a, RadStream stream) { + return paged_body(a, stream); +} extern "C" int64_t r4d_rad_mla_attn_scratch(const RadArgs*) { return scratch_bytes; } +/* Sized at the band's top row count, at most kPagedRows (paged_splits). */ +extern "C" int64_t r4d_rad_mla_attn_paged_scratch(const RadArgs* a) { + const long heads = r4d_geti_or(a, "heads", 0), rows = r4d_geti_or(a, "M", kPagedRows); + if (heads < 1 || heads > 64 || rows < 1) return RAD_E_SHAPE; + return paged_scratch_bytes(rows, heads); +} extern "C" int64_t r4d_rad_mla_attn_matrix_scratch(const RadArgs*) { return matrix_scratch_bytes; } extern "C" void r4d_mla_matrix_pin_form(int form) { g_mla_matrix_form = form; } extern "C" void r4d_mla_rows_pin_form(int form) { g_mla_rows_form = form; } diff --git a/libr4d/r4d_moe.hip b/libr4d/r4d_moe.hip index 8ed82a09..db7a0661 100644 --- a/libr4d/r4d_moe.hip +++ b/libr4d/r4d_moe.hip @@ -42,6 +42,7 @@ #include "r4d_fp8_wmma.h" #include "r4d_plugin.h" #include "r4d_emit.h" +#include "r4d_chain.h" #include "r4d_gemm_args.h" #include "r4d_moe_sort.h" #include "r4d_moe_gather.h" @@ -677,8 +678,7 @@ constexpr uint32_t moe_waves(uint32_t ntl, int w4, bool es, bool al, uint32_t fk template -__global__ __launch_bounds__(WGM * WGN * kWave) R4D_WAVES(moe_waves(NTL, W4, ES, AL, FK, RS)) -void moe_gemm_q_kernel( +__device__ __forceinline__ void moe_gemm_q_kernel_body( const uint8_t* __restrict__ Aq, const float* __restrict__ As, const MoeCls c_even, const MoeCls c_odd, const MoeCls c_2, const MoeCls c_3, const int32_t* __restrict__ sorted, const int32_t* __restrict__ off, @@ -1431,6 +1431,36 @@ void moe_gemm_q_kernel( } } +/* The plain and chained forms (r4d_chain.h): every block leaves through the wrapper. */ +template +__global__ __launch_bounds__(WGM * WGN * kWave) R4D_WAVES(moe_waves(NTL, W4, ES, AL, FK, RS)) +void moe_gemm_q_kernel( + const uint8_t* __restrict__ Aq, const float* __restrict__ As, + const MoeCls c_even, const MoeCls c_odd, const MoeCls c_2, const MoeCls c_3, + const int32_t* __restrict__ sorted, const int32_t* __restrict__ off, + uint16_t* __restrict__ Y, const uint32_t* __restrict__ map, + uint32_t T, uint32_t N, uint32_t n_expert, uint32_t top_k, + uint32_t a_ld, uint32_t as_ld, uint32_t y_ld, uint32_t mode, const MoeTab tab) { + moe_gemm_q_kernel_body(Aq, As, c_even, c_odd, c_2, c_3, sorted, off, Y, map, T, N, n_expert, top_k, a_ld, as_ld, y_ld, mode, tab); +} +template +__global__ __launch_bounds__(WGM * WGN * kWave) R4D_WAVES(moe_waves(NTL, W4, ES, AL, FK, RS)) +void r4dchain_moe_gemm_q( + const uint8_t* __restrict__ Aq, const float* __restrict__ As, + const MoeCls c_even, const MoeCls c_odd, const MoeCls c_2, const MoeCls c_3, + const int32_t* __restrict__ sorted, const int32_t* __restrict__ off, + uint16_t* __restrict__ Y, const uint32_t* __restrict__ map, + uint32_t T, uint32_t N, uint32_t n_expert, uint32_t top_k, + uint32_t a_ld, uint32_t as_ld, uint32_t y_ld, uint32_t mode, const MoeTab tab) { + r4d_chain_wait(); + moe_gemm_q_kernel_body(Aq, As, c_even, c_odd, c_2, c_3, sorted, off, Y, map, T, N, n_expert, top_k, a_ld, as_ld, y_ld, mode, tab); + r4d_chain_done(); +} + /* ================================================================== moe_gemm_q, the down decode form * * The sorted-operand projection at decode: one block per run tile, G column tiles per block. @@ -1463,7 +1493,7 @@ void moe_gemm_q_kernel( * Sorted operand only: a run's activation rows are [rs, re) of `Aq` with no gather. Every row in a * run is a placed slot (the scatter fills exactly [0, off[n_expert])), so `sorted` is not read. */ template -__global__ __launch_bounds__(4 * kWave) void moe_down_dec_kernel( +__device__ __forceinline__ void moe_down_dec_kernel_body( const uint8_t* __restrict__ Aq, const float* __restrict__ As, const MoeCls c_even, const MoeCls c_odd, const MoeCls c_2, const MoeCls c_3, const int32_t* __restrict__ off, uint16_t* __restrict__ Y, @@ -1769,6 +1799,28 @@ __global__ __launch_bounds__(4 * kWave) void moe_down_dec_kernel( } } +/* The plain and chained forms (r4d_chain.h): every block leaves through the wrapper. */ +template +__global__ __launch_bounds__(4 * kWave) void moe_down_dec_kernel( + const uint8_t* __restrict__ Aq, const float* __restrict__ As, + const MoeCls c_even, const MoeCls c_odd, const MoeCls c_2, const MoeCls c_3, + const int32_t* __restrict__ off, uint16_t* __restrict__ Y, + uint32_t T, uint32_t N, uint32_t n_expert, uint32_t G, + uint32_t a_ld, uint32_t as_ld, uint32_t y_ld, uint32_t mode, const MoeTab tab) { + moe_down_dec_kernel_body(Aq, As, c_even, c_odd, c_2, c_3, off, Y, T, N, n_expert, G, a_ld, as_ld, y_ld, mode, tab); +} +template +__global__ __launch_bounds__(4 * kWave) void r4dchain_moe_down_dec( + const uint8_t* __restrict__ Aq, const float* __restrict__ As, + const MoeCls c_even, const MoeCls c_odd, const MoeCls c_2, const MoeCls c_3, + const int32_t* __restrict__ off, uint16_t* __restrict__ Y, + uint32_t T, uint32_t N, uint32_t n_expert, uint32_t G, + uint32_t a_ld, uint32_t as_ld, uint32_t y_ld, uint32_t mode, const MoeTab tab) { + r4d_chain_wait(); + moe_down_dec_kernel_body(Aq, As, c_even, c_odd, c_2, c_3, off, Y, T, N, n_expert, G, a_ld, as_ld, y_ld, mode, tab); + r4d_chain_done(); +} + /* One or a few routed rows at I4 with BF16 scales per 128 K (signed or a 16-entry codebook). * A block owns one sorted row and 64 columns; * the two halves of each wave read the same activation row and their own eight K bytes directly @@ -2848,6 +2900,9 @@ static int moe_gemm_launch(const RadArgs* a, RadStream stream, int ncls = 2) { * rows take the aligned 32-row form; r4d_moe_decode_band has the crossover. */ const uint32_t ny = (uint32_t)(N / 64); const int form = g_moe_prefill_form; + /* The chained forms (r4d_chain.h) where the row resolved with `chain`, at decode heights. */ + const bool ch = r4d_geti_or(a, "chain", 0) != 0 && + r4d_chain_rows_ok(a_sorted ? (T + top_k - 1) / top_k : M); if ((form == 0 && r4d_moe_decode_band(T, n_expert)) || form == 2) { /* The decode grid is (tile, run) wide (the kernel's ES note); decode has one tile of rows, * which alone would give only N/64 workgroups. */ @@ -2861,7 +2916,7 @@ static int moe_gemm_launch(const RadArgs* a, RadStream stream, int ncls = 2) { if (dn_dec && g2 > 0) { const unsigned slots = (unsigned)(std::min(T, n_expert) + (T + 15) / 16); const unsigned groups = (unsigned)((N + 64 * g2 - 1) / (64 * g2)); - emit_rc = R4D_EMIT(stream, (moe_down_dec_kernel), + emit_rc = R4D_EMIT(stream, (ch ? &r4dchain_moe_down_dec : &moe_down_dec_kernel), dim3(slots + 1u, groups), dim3(4 * kWave), 0, (const uint8_t*)Aq->data, (const float*)As->data, ce, co, c2, c3, (const int32_t*)off->data, (uint16_t*)Y->data, @@ -2878,6 +2933,9 @@ static int moe_gemm_launch(const RadArgs* a, RadStream stream, int ncls = 2) { const bool rs = n_expert <= (long long)kMaxExpert; auto pick = [&](auto fk) { constexpr uint32_t F = decltype(fk)::value; + if (ch) + return rs ? &r4dchain_moe_gemm_q<1, 4, 1, 4, W4, true, false, false, F, true, true> + : &r4dchain_moe_gemm_q<1, 4, 1, 4, W4, true, false, false, F, true, false>; return rs ? &moe_gemm_q_kernel<1, 4, 1, 4, W4, true, false, false, F, true, true> : &moe_gemm_q_kernel<1, 4, 1, 4, W4, true, false, false, F, true, false>; }; @@ -3404,7 +3462,7 @@ struct RgGeom { /* `lg` is neither const nor __restrict__: every block writes it and the last one reads it back. */ template -__global__ __launch_bounds__(NW * kWave) void router_gemm_topk_scatter_kernel( +__device__ __forceinline__ void router_gemm_topk_scatter_kernel_body( const uint16_t* __restrict__ A, const uint16_t* __restrict__ W, const uint16_t* __restrict__ Wg, uint16_t* lg, uint16_t* __restrict__ gate, int32_t* __restrict__ ids, uint16_t* __restrict__ w, int32_t* __restrict__ sorted, @@ -3472,6 +3530,28 @@ __global__ __launch_bounds__(NW * kWave) void router_gemm_topk_scatter_kernel( scatter_small_place(sorted, off, cnt, g.M * g.top_k, g.n_local, sl); } +/* The plain and chained forms (r4d_chain.h): every block leaves through the wrapper. */ +template +__global__ __launch_bounds__(NW * kWave) void router_gemm_topk_scatter_kernel( + const uint16_t* __restrict__ A, const uint16_t* __restrict__ W, + const uint16_t* __restrict__ Wg, uint16_t* lg, uint16_t* __restrict__ gate, + int32_t* __restrict__ ids, uint16_t* __restrict__ w, int32_t* __restrict__ sorted, + int32_t* __restrict__ off, int32_t* __restrict__ cnt, unsigned int* __restrict__ ctr, + RgGeom g, Protect prot) { + router_gemm_topk_scatter_kernel_body(A, W, Wg, lg, gate, ids, w, sorted, off, cnt, ctr, g, prot); +} +template +__global__ __launch_bounds__(NW * kWave) void r4dchain_router_gemm_topk_scatter( + const uint16_t* __restrict__ A, const uint16_t* __restrict__ W, + const uint16_t* __restrict__ Wg, uint16_t* lg, uint16_t* __restrict__ gate, + int32_t* __restrict__ ids, uint16_t* __restrict__ w, int32_t* __restrict__ sorted, + int32_t* __restrict__ off, int32_t* __restrict__ cnt, unsigned int* __restrict__ ctr, + RgGeom g, Protect prot) { + r4d_chain_wait(); + router_gemm_topk_scatter_kernel_body(A, W, Wg, lg, gate, ids, w, sorted, off, cnt, ctr, g, prot); + r4d_chain_done(); +} + /* The arrival counter belongs to the op instance and is taken at init, not on the launch path. * * It must persist between launches, zeroed (the last block resets it; a non-zero start would rank @@ -3645,9 +3725,12 @@ extern "C" int r4d_rad_router_gemm_topk_scatter(const RadArgs* a, RadStream stre g.sk = (uint32_t)cr.sk; g.tpb = (uint32_t)tpb; g.nrb = (uint32_t)nrb; g.skg = wg ? (uint32_t)cg.sk : 0u; const dim3 grid((unsigned)(nrb + (wg ? 1 : 0)), (unsigned)((M + 15) / 16)); + /* The chained form (r4d_chain.h) where the row resolved with `chain`. */ + const bool ch = r4d_geti_or(a, "chain", 0) != 0 && r4d_chain_rows_ok(M); #define R4D_RG_L(OWN, NWV) \ - emit_rc = R4D_EMIT(stream, (router_gemm_topk_scatter_kernel), grid, \ + emit_rc = R4D_EMIT(stream, (ch ? &r4dchain_router_gemm_topk_scatter \ + : &router_gemm_topk_scatter_kernel), grid, \ dim3((NWV) * kWave), lds, \ (const uint16_t*)x->data, (const uint16_t*)wr->data, \ wg ? (const uint16_t*)wg->data : (const uint16_t*)nullptr, \ diff --git a/libr4d/r4d_moe_mxfp4.hip b/libr4d/r4d_moe_mxfp4.hip index 5abb605d..9bba888f 100644 --- a/libr4d/r4d_moe_mxfp4.hip +++ b/libr4d/r4d_moe_mxfp4.hip @@ -1071,6 +1071,10 @@ int table(const RadTensor* t, uint32_t dtype, int bits, long experts, long n, lo *row = (int)(t->stride[1] * bits / 8); return RAD_OK; } +/* r4d_moe_mxfp4_pin_small: 0 the rule, 1 the small-M form at any GLM slice up to 384 routed rows + * (TP4 as well as TP8, past the rule's bounds), 2 never, 3 as 1 with the K256 x4 tiles whatever + * K. For r4d_selftest --perfmx to measure the form where the rule does not take it. */ +int g_mx_small_pin = 0; int body(const RadArgs* a, RadStream stream) { if (!a || a->n_t < 9) return RAD_E_INVAL; const auto *aq = rad_arg_in(a, 0), *as = rad_arg_in(a, 1), *sorted = rad_arg_in(a, 4), @@ -1157,12 +1161,19 @@ int body(const RadArgs* a, RadStream stream) { return bm == 64 ? MX_P64(64, 64, 256, 1, false) : MX_P64(32, 64, 256, 1, false); #undef MX_P64 } - /* The small-M form at GLM's TP8 slices, ahead of the expert-major band: gate_up up to 384 - * routed rows, down up to 32, where it stops gaining (at 5 to 8 tokens it reads 3 to 5 % - * slower than the staged form). At those slices on gfx1201 (perfmx, cold) it is 6 to 16 % - * faster than the expert-major form for gate_up from 1 to 48 tokens, and 4 to 23 % for down - * from 1 to 4. */ - if (tp8 && m.T <= (m.K <= 256 ? 32 : 384)) { + /* The small-M form at GLM's slices, ahead of the expert-major band (perfmx, cold, its output + * byte-identical to the expert-major form's). At the TP8 slices: gate_up up to 384 routed rows, + * down up to 32, where it stops gaining (at 5 to 8 tokens it reads 3 to 5 % slower than the + * staged form); on gfx1201 it is 6 to 16 % faster than the expert-major form for gate_up from + * 1 to 48 tokens, and 4 to 23 % for down from 1 to 4. At the TP4 slices (--perfmx-tp 4): + * gate_up from 2 to 48 tokens, 3 to 18 % faster (at one token it reads 5 % slower), and down + * up to 48 tokens at the K256 x4 tiles, 37 % faster at one token and 4 % at 48. */ + const bool tp8_small = tp8 && m.T <= (m.sorted_a ? 32 : 384); + const bool tp4 = glm_prefill && !tp8; + const bool tp4_small = tp4 && m.T <= 384 && (m.sorted_a || m.T > m.topk); + if (g_mx_small_pin == 1 || g_mx_small_pin == 3 + ? glm_prefill && m.T <= 384 + : g_mx_small_pin != 2 && (tp8_small || tp4_small)) { const long rows = std::min(m.experts, m.T) + 1; #define MX_SMALL(SK, CT) \ R4D_EMIT(stream, (moe_mxfp4_small_kernel), \ @@ -1170,7 +1181,9 @@ int body(const RadArgs* a, RadStream stream) { (const uint8_t*)aq->data, (const float*)as->data, w[0]->data, s[0]->data, \ w[1]->data, s[1]->data, (const int*)sorted->data, (const int*)off->data, \ (uint16_t*)y->data, m) - return m.K <= 256 ? MX_SMALL(256, 4) : MX_SMALL(512, 1); + return m.K <= 256 || g_mx_small_pin == 3 || (g_mx_small_pin == 0 && tp4 && m.sorted_a) + ? MX_SMALL(256, 4) + : MX_SMALL(512, 1); #undef MX_SMALL } /* The expert-major form up to a routed-row bound per projection (token rows: gate_up, sorted @@ -1205,3 +1218,4 @@ int body(const RadArgs* a, RadStream stream) { } } extern "C" int r4d_rad_moe_mxfp4(const RadArgs* a, RadStream stream) { return body(a, stream); } +extern "C" void r4d_moe_mxfp4_pin_small(int form) { g_mx_small_pin = form; } diff --git a/libr4d/r4d_ple_conv_bf16.hip b/libr4d/r4d_ple_conv_bf16.hip index 6ad534ea..95446575 100644 --- a/libr4d/r4d_ple_conv_bf16.hip +++ b/libr4d/r4d_ple_conv_bf16.hip @@ -60,7 +60,8 @@ __global__ __launch_bounds__(kPcThreads) void ple_conv_kernel( uint16_t* __restrict__ cs, const int32_t* __restrict__ cu, const uint16_t* __restrict__ resid, const int32_t* __restrict__ sidx, const int32_t* __restrict__ hini, const int32_t* __restrict__ nacc, - uint16_t* __restrict__ y, uint32_t n, uint32_t wid, uint32_t dil, uint32_t hist, + uint16_t* __restrict__ y, const uint16_t* __restrict__ bias, + uint32_t n, uint32_t wid, uint32_t dil, uint32_t hist, uint32_t xld, uint32_t rld, uint32_t yld, uint32_t wld, long long cs_slot, long long cs_ch, long long cs_tok, long long state_len) { @@ -92,8 +93,9 @@ __global__ __launch_bounds__(kPcThreads) void ple_conv_kernel( const uint16_t* __restrict__ hc = warm ? dst + off * cs_tok : nullptr; uint16_t* __restrict__ yc = y + (size_t)bos * yld + c; + const float b0 = bias ? bf16_to_f32(bias[c]) : 0.0f; for (int32_t t = t0; t < t1; ++t) { - float acc = 0.0f; + float acc = b0; #pragma unroll for (uint32_t j = 0; j < kPcMaxW; ++j) { if (j < wid) { @@ -150,17 +152,21 @@ __global__ __launch_bounds__(kPcThreads) void ple_conv_kernel( } enum { PC_X = 0, PC_W, PC_CS, PC_CU, PC_RESID, PC_CIDX, PC_HINIT, PC_NACC, PC_Y }; +/* ple_conv_bias: ple_conv's operands with `b`, the per-channel bias inside the silu (Mamba-2's + * conv1d), before `y`. */ +enum { PB_B = PC_Y, PB_Y }; /* causal_conv1d's operands: ple_conv's without `resid`. */ enum { CC_X = 0, CC_W, CC_CS, CC_CU, CC_CIDX, CC_HINIT, CC_NACC, CC_Y }; int conv_launch(const RadArgs* a, RadStream s, bool silu, const RadTensor* x, const RadTensor* w, const RadTensor* cs, const RadTensor* cu, const RadTensor* resid, const RadTensor* cidx, const RadTensor* hini, const RadTensor* nacc, - const RadTensor* y) { + const RadTensor* y, const RadTensor* b = nullptr) { if (!x || !w || !cu || !y) return R4D_NO(RAD_E_INVAL); if (x->dtype != RAD_BF16 || w->dtype != RAD_BF16 || y->dtype != RAD_BF16) return R4D_NO(RAD_E_DTYPE); if (resid && resid->dtype != RAD_BF16) return R4D_NO(RAD_E_DTYPE); + if (b && b->dtype != RAD_BF16) return R4D_NO(RAD_E_DTYPE); if (cs && cs->data && cs->dtype != RAD_BF16) return R4D_NO(RAD_E_DTYPE); if (cu->dtype != RAD_I32) return R4D_NO(RAD_E_DTYPE); if (cidx && cidx->dtype != RAD_I32) return R4D_NO(RAD_E_DTYPE); @@ -188,6 +194,7 @@ int conv_launch(const RadArgs* a, RadStream s, bool silu, const RadTensor* x, co * the band's upper bound and a grid sized by it would run off the arena. */ if (T <= 0 || ty != T || (resid && tr != T)) return R4D_NO(RAD_E_SHAPE); if (wrows < n) return R4D_NO(RAD_E_SHAPE); + if (b && (r4d_numel(b) != n || !r4d_contig(b))) return R4D_NO(RAD_E_SHAPE); const long long N = r4d_numel(cu) - 1; if (N <= 0) return R4D_NO(RAD_E_SHAPE); @@ -218,7 +225,8 @@ int conv_launch(const RadArgs* a, RadStream s, bool silu, const RadTensor* x, co cidx ? (const int32_t*)r4d_addr(cidx) : nullptr, hini ? (const int32_t*)r4d_addr(hini) : nullptr, nacc ? (const int32_t*)r4d_addr(nacc) : nullptr, - (uint16_t*)r4d_addr(y), (uint32_t)n, (uint32_t)wid, (uint32_t)dil, + (uint16_t*)r4d_addr(y), b ? (const uint16_t*)r4d_addr(b) : nullptr, + (uint32_t)n, (uint32_t)wid, (uint32_t)dil, (uint32_t)hist, (uint32_t)xld, (uint32_t)rld, (uint32_t)yld, (uint32_t)wld, cs_slot, cs_ch, cs_tok, state_len); return hipGetLastError() == hipSuccess ? RAD_OK : R4D_NO(RAD_E_DEVICE); @@ -232,6 +240,14 @@ extern "C" int r4d_rad_ple_conv(const RadArgs* a, RadStream s) { r4d_opt(a, PC_HINIT), r4d_opt(a, PC_NACC), r4d_opt(a, PC_Y)); } +extern "C" int r4d_rad_ple_conv_bias(const RadArgs* a, RadStream s) { + const RadTensor* b = r4d_opt(a, PB_B); + if (!b) return R4D_NO(RAD_E_INVAL); + return conv_launch(a, s, true, r4d_opt(a, PC_X), r4d_opt(a, PC_W), r4d_opt(a, PC_CS), + r4d_opt(a, PC_CU), r4d_opt(a, PC_RESID), r4d_opt(a, PC_CIDX), + r4d_opt(a, PC_HINIT), r4d_opt(a, PC_NACC), r4d_opt(a, PB_Y), b); +} + extern "C" int r4d_rad_causal_conv1d(const RadArgs* a, RadStream s) { if (r4d_geti_or(a, "dilation", 1) != 1) return R4D_NO(RAD_E_INVAL); return conv_launch(a, s, false, r4d_opt(a, CC_X), r4d_opt(a, CC_W), r4d_opt(a, CC_CS), diff --git a/libr4d/r4d_plugin.h b/libr4d/r4d_plugin.h index 1c91c1df..ca1ca60f 100644 --- a/libr4d/r4d_plugin.h +++ b/libr4d/r4d_plugin.h @@ -169,6 +169,11 @@ int64_t r4d_rad_attn_qrow_h128_gqa8_scratch(const RadArgs*); * row pitch, so they serve both attn_paged and attn_paged_qrow. */ int r4d_rad_attn_window_h128_gqa1_bf16(const RadArgs*, RadStream); int r4d_rad_attn_window_h128_gqa1_fp8 (const RadArgs*, RadStream); +/* The same kernels under attn_paged_sink (a sink logit a query head). */ +int r4d_rad_attn_window_sink_h128_gqa8_bf16 (const RadArgs*, RadStream); +int r4d_rad_attn_window_sink_h128_gqa8_fp8 (const RadArgs*, RadStream); +int r4d_rad_attn_window_sink_h128_gqa16_bf16(const RadArgs*, RadStream); +int r4d_rad_attn_window_sink_h128_gqa16_fp8 (const RadArgs*, RadStream); int r4d_rad_attn_window_h256_gqa1_bf16(const RadArgs*, RadStream); int r4d_rad_attn_window_h256_gqa1_fp8 (const RadArgs*, RadStream); int r4d_rad_attn_window_h256_gqa2_bf16(const RadArgs*, RadStream); @@ -185,9 +190,22 @@ int r4d_rad_attn_window_h512_gqa4_bf16(const RadArgs*, RadStream); int r4d_rad_attn_window_h512_gqa4_fp8 (const RadArgs*, RadStream); int r4d_rad_attn_window_h512_gqa8_bf16(const RadArgs*, RadStream); int r4d_rad_attn_window_h512_gqa8_fp8 (const RadArgs*, RadStream); +int r4d_rad_attn_window_h512_gqa16_bf16(const RadArgs*, RadStream); +int r4d_rad_attn_window_h512_gqa16_fp8 (const RadArgs*, RadStream); int64_t r4d_rad_attn_window_h128_scratch(const RadArgs*); int64_t r4d_rad_attn_window_h256_scratch(const RadArgs*); int64_t r4d_rad_attn_window_h512_scratch(const RadArgs*); +#define R4D_ATTN_ANCHOR_DECL(HD, G) \ + int r4d_rad_attn_anchor_window_h##HD##_gqa##G##_bf16kv(const RadArgs*, RadStream); \ + int r4d_rad_attn_anchor_window_h##HD##_gqa##G##_fp8kv(const RadArgs*, RadStream); +R4D_ATTN_ANCHOR_DECL(128, 1) +R4D_ATTN_ANCHOR_DECL(256, 1) R4D_ATTN_ANCHOR_DECL(256, 2) R4D_ATTN_ANCHOR_DECL(256, 4) +R4D_ATTN_ANCHOR_DECL(256, 8) +R4D_ATTN_ANCHOR_DECL(512, 1) R4D_ATTN_ANCHOR_DECL(512, 2) R4D_ATTN_ANCHOR_DECL(512, 4) +R4D_ATTN_ANCHOR_DECL(512, 8) +#undef R4D_ATTN_ANCHOR_DECL +int r4d_rad_dflash_markov_greedy(const RadArgs*, RadStream); +int r4d_rad_dflash_markov_greedy_f32(const RadArgs*, RadStream); /* attn_paged_qrow_tree (docs/OPS.md): the h256/gqa2 split-KV decode and the windowed kernels with a * tree verify's mask from operand 8, `spec_parent`. */ int r4d_rad_attn_qrow_tree_decode_h256_gqa2_fp8 (const RadArgs*, RadStream); @@ -198,11 +216,23 @@ int r4d_rad_attn_qrow_tree_decode_h256_gqa2_bf16(const RadArgs*, RadStream); R4D_WIN_TREE_DECL(256, 1) R4D_WIN_TREE_DECL(256, 2) R4D_WIN_TREE_DECL(256, 4) R4D_WIN_TREE_DECL(256, 8) R4D_WIN_TREE_DECL(512, 1) R4D_WIN_TREE_DECL(512, 2) R4D_WIN_TREE_DECL(512, 4) R4D_WIN_TREE_DECL(512, 8) #undef R4D_WIN_TREE_DECL +/* attn_paged_ahead and attn_paged_qrow_ahead (docs/OPS.md): the windowed kernels with a non-causal + * window that bounds the keys behind only. */ +#define R4D_WIN_AHEAD_DECL(HD, G) \ + int r4d_rad_attn_window_ahead_h##HD##_gqa##G##_bf16(const RadArgs*, RadStream); \ + int r4d_rad_attn_window_ahead_h##HD##_gqa##G##_fp8 (const RadArgs*, RadStream); +R4D_WIN_AHEAD_DECL(256, 1) R4D_WIN_AHEAD_DECL(256, 2) R4D_WIN_AHEAD_DECL(256, 4) R4D_WIN_AHEAD_DECL(256, 8) +#undef R4D_WIN_AHEAD_DECL /* dflash_tree (r4d_dflash_tree_bf16.hip): dflash_select's lattice grown best-first into a tree. */ int r4d_rad_dflash_tree(const RadArgs*, RadStream); /* The top-1 of a row of all-gathered (id, value) pairs, written one id a row: the vocab-sharded * draft head's merge (r4d_pair_argmax_f32.hip). */ int r4d_rad_pair_argmax_f32(const RadArgs*, RadStream); +/* LiLiCorr's correlator (r4d_lili.hip). */ +int r4d_rad_lili_cand (const RadArgs*, RadStream); +int r4d_rad_lili_attn (const RadArgs*, RadStream); +int r4d_rad_lili_factor(const RadArgs*, RadStream); +int r4d_rad_lili_walk (const RadArgs*, RadStream); /* Gemma 4's two sandwich-norm joins, each one kernel for a chain of rmsnorm / add / mul_weight * launches (r4d_norm_join_bf16.hip), and expert_scale, the embed_lookup + mul pair that scales * each routing weight by its expert's scale (r4d_expert_scale_bf16.hip). */ @@ -365,6 +395,13 @@ int r4d_rad_attn_prefill_h128_gqa2_bf16(const RadArgs*, RadStream); int r4d_rad_attn_decode_h128_gqa2_fp8 (const RadArgs*, RadStream); int r4d_rad_attn_decode_h128_gqa2_bf16 (const RadArgs*, RadStream); int64_t r4d_rad_attn_decode_h128_gqa2_scratch(const RadArgs*); +/* Sixteen queries per KV head at head_dim 128 (Nemotron-H): the gqa8 body at gqa 16 + * (r4d_attn_paged_h128_gqa16.hip). */ +int r4d_rad_attn_prefill_h128_gqa16_fp8 (const RadArgs*, RadStream); +int r4d_rad_attn_prefill_h128_gqa16_bf16(const RadArgs*, RadStream); +int r4d_rad_attn_decode_h128_gqa16_fp8 (const RadArgs*, RadStream); +int r4d_rad_attn_decode_h128_gqa16_bf16 (const RadArgs*, RadStream); +int64_t r4d_rad_attn_decode_h128_gqa16_scratch(const RadArgs*); /* Twelve queries per KV head, head_dim 256 only: Qwen3.8-Flash-Next's QSA layers. Same body, * another instantiation (r4d_attn_paged_h256_gqa12.hip). */ int r4d_rad_attn_prefill_h256_gqa12_fp8 (const RadArgs*, RadStream); @@ -421,6 +458,7 @@ int r4d_rad_gdn_recurrent_update(const RadArgs*, RadStream); /* gdn_conv_update folded into the recurrent update's prologue for the decode shape; q/k/v are * never written (r4d_gdn_recurrent_update_k128_v128_bf16_fp32state.hip). */ int r4d_rad_gdn_conv_recurrent_update(const RadArgs*, RadStream); +int r4d_rad_gdn_conv_recurrent_update_had(const RadArgs*, RadStream); int r4d_rad_gdn_gated_rmsnorm (const RadArgs*, RadStream); int r4d_rad_dflash_conv (const RadArgs*, RadStream); int r4d_rad_dflash_select (const RadArgs*, RadStream); @@ -432,6 +470,7 @@ int r4d_rad_mhc_pre(const RadArgs*, RadStream); int r4d_rad_mhc_pre_partial(const RadArgs*, RadStream); int r4d_rad_mhc_pre_finish(const RadArgs*, RadStream); int r4d_rad_kda_update(const RadArgs*, RadStream); +int r4d_rad_ssd_update(const RadArgs*, RadStream); int r4d_rad_moe_mxfp4(const RadArgs*, RadStream); int r4d_rad_layout_moe_mxfp4(const RadParam*, int, int, const RadEncoding*, const int*, const RadTensor*, int, RadLayout*); @@ -602,6 +641,9 @@ int r4d_rad_gemm_i8a8_m16 (const RadArgs*, RadStream); int64_t r4d_rad_gemm_i8a8_m16_scratch(const RadArgs*); int r4d_rad_logits_gemm_i8(const RadArgs*, RadStream); int r4d_rad_logits_gemm_iqr(const RadArgs*, RadStream); +/* `logits_gemm_vocab`: the head as width classes of the vocabulary's rows (r4d_logits_vocab.hip). */ +int r4d_rad_logits_gemm_vocab(const RadArgs*, RadStream); +int64_t r4d_rad_logits_gemm_vocab_scratch(const RadArgs*); int r4d_rad_logit_rerank_iqr(const RadArgs*, RadStream); int r4d_rad_gemm_i8a8_tiled(const RadArgs*, RadStream); int r4d_rad_gemm_i8a8_rb8_tiled(const RadArgs*, RadStream); @@ -609,6 +651,8 @@ int r4d_rad_gemm_i8a8_rb32_tiled(const RadArgs*, RadStream); /* The IQR weights, decoded from their codes where they are read (r4d_gemm_iqr.hip). */ int r4d_rad_gemm_iqr_m64(const RadArgs*, RadStream); int64_t r4d_rad_gemm_iqr_m64_scratch(const RadArgs*); +int r4d_rad_gemm_iqr_gated(const RadArgs*, RadStream); +int64_t r4d_rad_gemm_iqr_gated_scratch(const RadArgs*); int r4d_rad_gemm_iqr_tiled(const RadArgs*, RadStream); int64_t r4d_rad_gemm_iqr_tiled_scratch(const RadArgs*); int r4d_rad_quant_act_i8g(const RadArgs*, RadStream); @@ -622,6 +666,7 @@ int r4d_rad_gated_quant_fp8 (const RadArgs*, RadStream); int r4d_rad_gated_had_quant_fp8(const RadArgs*, RadStream); int r4d_rad_gated_had_quant_i8g(const RadArgs*, RadStream); int r4d_rad_gate_quant_fp8 (const RadArgs*, RadStream); +int r4d_rad_gate_had_quant_i8g(const RadArgs*, RadStream); int r4d_rad_gram_accum (const RadArgs*, RadStream); /* The same accumulator over a plain bf16 activation, no scale operand. */ int r4d_rad_gram_accum_bf16 (const RadArgs*, RadStream); @@ -655,6 +700,7 @@ R4D_HOOKS(fp8_block) R4D_HOOKS(i8_block) R4D_HOOKS(iqr) R4D_HOOKS(iqr_logits) +R4D_HOOKS(iqr_vocab) R4D_HOOKS(fp8_logits) R4D_HOOKS(i8_logits) R4D_HOOKS(hc_e4m3) @@ -773,6 +819,7 @@ int r4d_rad_embed_lookup_q (const RadArgs*, RadStream); int r4d_rad_ngram_ids (const RadArgs*, RadStream); int r4d_rad_ple_gate (const RadArgs*, RadStream); int r4d_rad_ple_conv (const RadArgs*, RadStream); +int r4d_rad_ple_conv_bias (const RadArgs*, RadStream); int r4d_rad_causal_conv1d (const RadArgs*, RadStream); int r4d_rad_cast (const RadArgs*, RadStream); int r4d_rad_gather_rows (const RadArgs*, RadStream); @@ -796,6 +843,7 @@ int r4d_rad_cast_f16 (const RadArgs*, RadStream); int r4d_rad_cast_bf16 (const RadArgs*, RadStream); int r4d_rad_pool_rows (const RadArgs*, RadStream); int r4d_rad_pool_cols (const RadArgs*, RadStream); +int r4d_rad_point_fourier (const RadArgs*, RadStream); int r4d_rad_relu (const RadArgs*, RadStream); int r4d_rad_silu (const RadArgs*, RadStream); int r4d_rad_gelu (const RadArgs*, RadStream); @@ -811,6 +859,7 @@ int r4d_rad_logit_softcap (const RadArgs*, RadStream); int r4d_rad_scale (const RadArgs*, RadStream); int r4d_rad_silu_mul (const RadArgs*, RadStream); int r4d_rad_swiglu_clamped(const RadArgs*, RadStream); +int r4d_rad_swiglu_step(const RadArgs*, RadStream); int r4d_rad_swiglu_clamped_quant_fp8(const RadArgs*, RadStream); int r4d_rad_dsa_pool(const RadArgs*, RadStream); int r4d_shape_dsa_pool(const RadParam*, int, int, RadOpdDesc*); @@ -827,12 +876,20 @@ int r4d_shape_mla_project(const RadParam*, int, int, RadOpdDesc*); int r4d_rad_dsa_score(const RadArgs*, RadStream); int r4d_shape_dsa_score(const RadParam*, int, int, RadOpdDesc*); int r4d_rad_mla_attn(const RadArgs*, RadStream); +int r4d_rad_mla_attn_paged(const RadArgs*, RadStream); +int r4d_shape_mla_attn_paged(const RadParam*, int, int, RadOpdDesc*); int64_t r4d_rad_mla_attn_scratch(const RadArgs*); +int64_t r4d_rad_mla_attn_paged_scratch(const RadArgs*); int r4d_rad_mla_attn_matrix(const RadArgs*, RadStream); int64_t r4d_rad_mla_attn_matrix_scratch(const RadArgs*); int r4d_rad_mla_attn_rows(const RadArgs*, RadStream); +int r4d_rad_mla_attn_fp8kv(const RadArgs*, RadStream); +int r4d_rad_mla_attn_matrix_fp8kv(const RadArgs*, RadStream); +int r4d_rad_mla_attn_rows_fp8kv(const RadArgs*, RadStream); int r4d_shape_mla_attn(const RadParam*, int, int, RadOpdDesc*); int r4d_rad_router_sigmoid_topk(const RadArgs*, RadStream); +int r4d_rad_router_sigmoid_group_topk(const RadArgs*, RadStream); +int r4d_shape_router_sigmoid_group_topk(const RadParam*, int, int, RadOpdDesc*); int r4d_shape_router_sigmoid_topk(const RadParam*, int, int, RadOpdDesc*); int r4d_rad_router_sigmoid_topk_scatter(const RadArgs*, RadStream); int r4d_rad_moe_scatter_inv(const RadArgs*, RadStream); @@ -848,6 +905,7 @@ int r4d_rad_rope_rows (const RadArgs*, RadStream); int r4d_rad_layernorm (const RadArgs*, RadStream); int r4d_rad_grid_embed (const RadArgs*, RadStream); int r4d_rad_grid_embed_aa (const RadArgs*, RadStream); +int r4d_rad_grid_embed_cpe (const RadArgs*, RadStream); int r4d_rad_gemm_nt_bias (const RadArgs*, RadStream); /* gemm_nt_bias at f32 (r4d_gemm_f32_nt_bias.hip). */ int r4d_rad_gemm_f32_nt_bias(const RadArgs*, RadStream); @@ -902,6 +960,7 @@ int r4d_shape_mhc_pre(const RadParam*, int, int, RadOpdDesc*); int r4d_shape_mhc_pre_partial(const RadParam*, int, int, RadOpdDesc*); int r4d_shape_mhc_pre_finish(const RadParam*, int, int, RadOpdDesc*); int r4d_shape_kda_update(const RadParam*, int, int, RadOpdDesc*); +int r4d_shape_ssd_update(const RadParam*, int, int, RadOpdDesc*); int r4d_shape_moe_mxfp4(const RadParam*, int, int, RadOpdDesc*); int r4d_shape_mhc_post(const RadParam*, int, int, RadOpdDesc*); int r4d_shape_mhc_contract(const RadParam*, int, int, RadOpdDesc*); @@ -914,6 +973,7 @@ int r4d_shape_mul_weight (const RadParam*, int, int operand, RadOpdDesc*); int r4d_shape_scatter_rows_bf16(const RadParam*, int, int operand, RadOpdDesc*); int r4d_shape_layernorm (const RadParam*, int, int operand, RadOpdDesc*); int r4d_shape_grid_embed (const RadParam*, int, int operand, RadOpdDesc*); +int r4d_shape_grid_embed_cpe (const RadParam*, int, int operand, RadOpdDesc*); int r4d_shape_gemm_nt_bias (const RadParam*, int, int operand, RadOpdDesc*); int r4d_shape_unary (const RadParam*, int, int operand, RadOpdDesc*); int r4d_shape_fill (const RadParam*, int, int operand, RadOpdDesc*); @@ -935,6 +995,7 @@ int r4d_shape_sample_pick (const RadParam*, int, int operand, RadOpdDesc*); int r4d_shape_sample_chain (const RadParam*, int, int operand, RadOpdDesc*); int r4d_shape_attn_paged (const RadParam*, int, int operand, RadOpdDesc*); +int r4d_shape_attn_paged_sink (const RadParam*, int, int operand, RadOpdDesc*); int r4d_shape_attn_paged_gate_quant(const RadParam*, int, int operand, RadOpdDesc*); int r4d_shape_qk_norm_rope_gate (const RadParam*, int, int operand, RadOpdDesc*); int r4d_shape_qk_norm_rope_gate_kv_store(const RadParam*, int, int operand, RadOpdDesc*); @@ -971,6 +1032,10 @@ int r4d_shape_scale_rows (const RadParam*, int, int operand, RadOpdDesc*); int r4d_shape_scale (const RadParam*, int, int operand, RadOpdDesc*); int r4d_shape_row_topk_merge (const RadParam*, int, int operand, RadOpdDesc*); int r4d_shape_pair_argmax (const RadParam*, int, int operand, RadOpdDesc*); +int r4d_shape_lili_cand (const RadParam*, int, int operand, RadOpdDesc*); +int r4d_shape_lili_attn (const RadParam*, int, int operand, RadOpdDesc*); +int r4d_shape_lili_factor (const RadParam*, int, int operand, RadOpdDesc*); +int r4d_shape_lili_walk (const RadParam*, int, int operand, RadOpdDesc*); int r4d_shape_quant_act_i8 (const RadParam*, int, int operand, RadOpdDesc*); int r4d_shape_had_quant_act_i8 (const RadParam*, int, int operand, RadOpdDesc*); @@ -994,6 +1059,8 @@ int r4d_shape_qsa_work (const RadParam*, int, int operand, RadOpdDesc* int r4d_shape_dflash_conv (const RadParam*, int, int operand, RadOpdDesc*); int r4d_shape_dflash_select (const RadParam*, int, int operand, RadOpdDesc*); +int r4d_shape_dflash_markov (const RadParam*, int, int operand, RadOpdDesc*); +int r4d_shape_dflash_markov_f32(const RadParam*, int, int operand, RadOpdDesc*); /* -- declared fusions (r4d_fuse.cpp, pure host) -- * @@ -1015,6 +1082,7 @@ int r4d_fuse_router_sigmoid_topk_scatter(const RadParam*, int, uint64_t, int, Ra int r4d_fuse_gate_quant_fp8 (const RadParam*, int, uint64_t, int, RadFuseStep*); int r4d_fuse_gemm_nt_q_gated (const RadParam*, int, uint64_t, int, RadFuseStep*); int r4d_fuse_gemm_nt_q_gated_mx (const RadParam*, int, uint64_t, int, RadFuseStep*); +int r4d_fuse_gemm_nt_q_gated_iqr (const RadParam*, int, uint64_t, int, RadFuseStep*); int r4d_fuse_gdn_conv_recurrent_update(const RadParam*, int, uint64_t, int, RadFuseStep*); int r4d_fuse_qk_norm_rope_gate_kv_store(const RadParam*, int, uint64_t, int, RadFuseStep*); int r4d_fuse_qkv_norm_rope_kv_store(const RadParam*, int, uint64_t, int, RadFuseStep*); diff --git a/libr4d/r4d_qk_norm_rope_gate.hip b/libr4d/r4d_qk_norm_rope_gate.hip index a2b27c3c..38ec74db 100644 --- a/libr4d/r4d_qk_norm_rope_gate.hip +++ b/libr4d/r4d_qk_norm_rope_gate.hip @@ -19,6 +19,7 @@ #include "r4d.h" #include "r4d_args.h" #include "r4d_emit.h" +#include "r4d_chain.h" #include "r4d_common.h" #include "rad_yarn.h" #include @@ -67,7 +68,7 @@ enum { QK_KV_NONE = 0, QK_KV_FP8 = 1, QK_KV_BF16 = 2, QK_KV_F8V4 = 3, QK_KV_K6V4 * writes that element and the head's v element into the cache at the token's slot, as E4M3 with * kv_store_fp8's arithmetic or as bf16 like kv_store_bf16 (see the store at the end). */ template -__global__ __launch_bounds__(256) void r4d_qk_norm_rope_gate_kernel( +__device__ __forceinline__ void r4d_qk_norm_rope_gate_kernel_body( const __hip_bfloat16* __restrict__ QG, const __hip_bfloat16* __restrict__ K, __hip_bfloat16* __restrict__ QO, __hip_bfloat16* __restrict__ KO, __hip_bfloat16* __restrict__ GO, @@ -274,6 +275,32 @@ __global__ __launch_bounds__(256) void r4d_qk_norm_rope_gate_kernel( } } +/* The plain and chained forms (r4d_chain.h): every block leaves through the wrapper. */ +template +__global__ __launch_bounds__(256) void r4d_qk_norm_rope_gate_kernel( + const __hip_bfloat16* __restrict__ QG, const __hip_bfloat16* __restrict__ K, + __hip_bfloat16* __restrict__ QO, __hip_bfloat16* __restrict__ KO, + __hip_bfloat16* __restrict__ GO, + const void* __restrict__ WQ, const void* __restrict__ WK, + const void* __restrict__ CS, const void* __restrict__ POS, long cs_rows, + int nq, int nkv, int rot, float eps, float wadd, + int qg_pitch, int k_pitch, int cs_f32, int pos_i64, int w_f32, QkKvStore kvs) { + r4d_qk_norm_rope_gate_kernel_body(QG, K, QO, KO, GO, WQ, WK, CS, POS, cs_rows, nq, nkv, rot, eps, wadd, qg_pitch, k_pitch, cs_f32, pos_i64, w_f32, kvs); +} +template +__global__ __launch_bounds__(256) void r4dchain_qk_norm_rope_gate( + const __hip_bfloat16* __restrict__ QG, const __hip_bfloat16* __restrict__ K, + __hip_bfloat16* __restrict__ QO, __hip_bfloat16* __restrict__ KO, + __hip_bfloat16* __restrict__ GO, + const void* __restrict__ WQ, const void* __restrict__ WK, + const void* __restrict__ CS, const void* __restrict__ POS, long cs_rows, + int nq, int nkv, int rot, float eps, float wadd, + int qg_pitch, int k_pitch, int cs_f32, int pos_i64, int w_f32, QkKvStore kvs) { + r4d_chain_wait(); + r4d_qk_norm_rope_gate_kernel_body(QG, K, QO, KO, GO, WQ, WK, CS, POS, cs_rows, nq, nkv, rot, eps, wadd, qg_pitch, k_pitch, cs_f32, pos_i64, w_f32, kvs); + r4d_chain_done(); +} + // ============================================================ the cos/sin table // // The fused kernel reads a precomputed table instead of theta, and this fills it: one launch per @@ -376,7 +403,10 @@ static int qk_body(const RadArgs* args, RadStream stream, const QkKvStore& kvs) const int nh = (int)(nq + nkv); // One block per (token, head), 256 threads, one element per lane. The width is fixed at 256, not // fitted to the head count, so the sum of squares matches r4d_rmsnorm_bf16 (see the kernel). -#define R4D_QKG_L(H) emit_rc = R4D_EMIT(stream, (r4d_qk_norm_rope_gate_kernel), \ + /* The chained form (r4d_chain.h) where the row resolved with `chain`. */ + const bool ch = r4d_geti_or(args, "chain", 0) != 0 && r4d_chain_rows_ok(M); +#define R4D_QKG_L(H) emit_rc = R4D_EMIT(stream, (ch ? &r4dchain_qk_norm_rope_gate \ + : &r4d_qk_norm_rope_gate_kernel), \ dim3((int)M, nh), dim3(256), 0, (const __hip_bfloat16*)r4d_p(qg), \ (const __hip_bfloat16*)r4d_p(k), (__hip_bfloat16*)r4d_wp(qo), (__hip_bfloat16*)r4d_wp(ko), \ (__hip_bfloat16*)r4d_wp(go), r4d_p(wq), r4d_p(wk), r4d_p(cs), r4d_p(po), (long)cs_rows, \ diff --git a/libr4d/r4d_qsa_block_key_bf16.hip b/libr4d/r4d_qsa_block_key_bf16.hip index b7e6743a..5f1bcd57 100644 --- a/libr4d/r4d_qsa_block_key_bf16.hip +++ b/libr4d/r4d_qsa_block_key_bf16.hip @@ -30,6 +30,7 @@ #include "r4d_args.h" #include "rad_yarn.h" #include "r4d_emit.h" +#include "r4d_chain.h" #include "r4d_common.h" // r4d_wave_sum #include @@ -54,7 +55,7 @@ __device__ __forceinline__ int qbk_comp(int mode, int i, int s0, int s1, int s2) return i < s0 ? 0 : (i < s0 + s1 ? 1 : 2); } -__global__ __launch_bounds__(kMaxN) void qsa_block_key_kernel( +__device__ __forceinline__ void qsa_block_key_kernel_body( const uint16_t* __restrict__ k, const float* __restrict__ w, const int32_t* __restrict__ page, const int32_t* __restrict__ bpos, uint16_t* __restrict__ out, @@ -124,6 +125,26 @@ __global__ __launch_bounds__(kMaxN) void qsa_block_key_kernel( ((__hip_bfloat16*)out)[(size_t)orow * o_ld + t] = __float2bfloat16(res); } +/* The plain and chained forms (r4d_chain.h): every block leaves through the wrapper. */ +__global__ __launch_bounds__(kMaxN) void qsa_block_key_kernel( + const uint16_t* __restrict__ k, const float* __restrict__ w, + const int32_t* __restrict__ page, const int32_t* __restrict__ bpos, + uint16_t* __restrict__ out, + int n, int ratio, int rot, float eps, float wadd, float theta, float rscale, + long long pos0, int k_ld, int o_ld, int mode, int s0, int s1, int s2, int bstep, int mc, RadYarn yarn) { + qsa_block_key_kernel_body(k, w, page, bpos, out, n, ratio, rot, eps, wadd, theta, rscale, pos0, k_ld, o_ld, mode, s0, s1, s2, bstep, mc, yarn); +} +__global__ __launch_bounds__(kMaxN) void r4dchain_qsa_block_key( + const uint16_t* __restrict__ k, const float* __restrict__ w, + const int32_t* __restrict__ page, const int32_t* __restrict__ bpos, + uint16_t* __restrict__ out, + int n, int ratio, int rot, float eps, float wadd, float theta, float rscale, + long long pos0, int k_ld, int o_ld, int mode, int s0, int s1, int s2, int bstep, int mc, RadYarn yarn) { + r4d_chain_wait(); + qsa_block_key_kernel_body(k, w, page, bpos, out, n, ratio, rot, eps, wadd, theta, rscale, pos0, k_ld, o_ld, mode, s0, s1, s2, bstep, mc, yarn); + r4d_chain_done(); +} + } // namespace // k [M*ratio][n] bf16, `k_ld` elements a row (0 = n) @@ -144,7 +165,7 @@ static int r4d_qsa_block_key_bf16_emit(long k, long w, long page, long bpos, lon if (!o_ld) o_ld = n; /* n threads rounded up to whole waves for the block reduction (extra threads contribute 0). */ const int thr = ((n + 31) / 32) * 32; - return R4D_EMIT(stream, qsa_block_key_kernel, dim3((unsigned)M), dim3((unsigned)thr), 0, + return R4D_EMIT(stream, g_r4d_chain_arg ? &r4dchain_qsa_block_key : &qsa_block_key_kernel, dim3((unsigned)M), dim3((unsigned)thr), 0, (const uint16_t*)k, (const float*)w, (const int32_t*)page, (const int32_t*)bpos, (uint16_t*)out, n, ratio, rot, eps, wadd, theta, rscale, pos0, k_ld, o_ld, mode, s0, s1, s2, bstep, mc, yarn); @@ -217,6 +238,7 @@ extern "C" int r4d_rad_qsa_block_key(const RadArgs* a, RadStream stream) { if (!rad_yarn_valid(yarn) || (yarn.factor != 0.0f && (rot <= 0 || r4d_getf(a, "scale", 1.0) != 1.0))) return R4D_NO(RAD_E_INVAL); + const R4dChainArg chain_arg(r4d_geti_or(a, "chain", 0) != 0); return r4d_qsa_block_key_bf16_emit( r4d_addr(k), r4d_addr(w), r4d_addr(pg), r4d_addr(bp), r4d_addr(o), (int)M, (int)n, (int)ratio, (int)rot, diff --git a/libr4d/r4d_qsa_score_bf16.hip b/libr4d/r4d_qsa_score_bf16.hip index 3c4c5c29..b13a479e 100644 --- a/libr4d/r4d_qsa_score_bf16.hip +++ b/libr4d/r4d_qsa_score_bf16.hip @@ -20,6 +20,7 @@ #include "r4d.h" #include "r4d_args.h" #include "r4d_emit.h" +#include "r4d_chain.h" #include "r4d_common.h" #include "r4d_gdn_wmma.h" @@ -242,7 +243,7 @@ constexpr long long kMxWavesTarget = 4096; constexpr long long kMxMinTiles = 4; template -__global__ __launch_bounds__(kMxWaves * kWave) void qsa_score_mx_kernel( +__device__ __forceinline__ void qsa_score_mx_kernel_body( const unsigned short* __restrict__ q, const unsigned short* __restrict__ bk, const int32_t* __restrict__ bt, const int32_t* __restrict__ cu, const int32_t* __restrict__ nc, float* __restrict__ out, @@ -334,6 +335,26 @@ __global__ __launch_bounds__(kMxWaves * kWave) void qsa_score_mx_kernel( } } +/* The plain and chained forms (r4d_chain.h): every block leaves through the wrapper. */ +template +__global__ __launch_bounds__(kMxWaves * kWave) void qsa_score_mx_kernel( + const unsigned short* __restrict__ q, const unsigned short* __restrict__ bk, + const int32_t* __restrict__ bt, const int32_t* __restrict__ cu, + const int32_t* __restrict__ nc, float* __restrict__ out, + int M, int nb, int nseq, int tpw, int q_ld, int bk_ld, int bt_ld, int out_ld, int vec) { + qsa_score_mx_kernel_body(q, bk, bt, cu, nc, out, M, nb, nseq, tpw, q_ld, bk_ld, bt_ld, out_ld, vec); +} +template +__global__ __launch_bounds__(kMxWaves * kWave) void r4dchain_qsa_score_mx( + const unsigned short* __restrict__ q, const unsigned short* __restrict__ bk, + const int32_t* __restrict__ bt, const int32_t* __restrict__ cu, + const int32_t* __restrict__ nc, float* __restrict__ out, + int M, int nb, int nseq, int tpw, int q_ld, int bk_ld, int bt_ld, int out_ld, int vec) { + r4d_chain_wait(); + qsa_score_mx_kernel_body(q, bk, bt, cu, nc, out, M, nb, nseq, tpw, q_ld, bk_ld, bt_ld, out_ld, vec); + r4d_chain_done(); +} + /* Form override for tests (r4d_selftest compares the two): 0 = automatic, 1 = scalar, * 2 = matrix. Like r4d_gemm_fp8a8_pin_mw. */ int g_qsa_form = 0; @@ -374,7 +395,7 @@ static int r4d_qsa_score_bf16_emit(long q, long bk, long bt, long cu, long nc, l const unsigned gx = (unsigned)((tiles + tpw * kMxWaves - 1) / (tpw * kMxWaves)); const int vec = (out_ld % 4 == 0) && ((out & 15) == 0); #define RAD_QSA_MX(H) \ - emit_rc = R4D_EMIT(stream, (qsa_score_mx_kernel), dim3(gx, (unsigned)qt), \ + emit_rc = R4D_EMIT(stream, (g_r4d_chain_arg ? &r4dchain_qsa_score_mx : &qsa_score_mx_kernel), dim3(gx, (unsigned)qt), \ dim3(kMxWaves * kWave), 0, (const unsigned short*)q, \ (const unsigned short*)bk, \ (const int32_t*)bt, (const int32_t*)cu, (const int32_t*)nc, \ @@ -461,6 +482,7 @@ extern "C" int r4d_rad_qsa_score(const RadArgs* a, RadStream stream) { const long long qp = r4d_row_pitch(q), kp = r4d_row_pitch(bk); const long long tp = r4d_row_pitch(bt), op = r4d_row_pitch(o); if (qp < 0 || kp < 0 || tp < 0 || op < 0) return R4D_NO(RAD_E_STRIDE); + const R4dChainArg chain_arg(r4d_geti_or(a, "chain", 0) != 0); return r4d_qsa_score_bf16_emit(r4d_addr(q), r4d_addr(bk), r4d_addr(bt), r4d_addr(cu), r4d_addr(nc), r4d_addr(o), (int)M, (int)n, (int)heads, (int)nb, (int)nseq, diff --git a/libr4d/r4d_qsa_select_bf16.hip b/libr4d/r4d_qsa_select_bf16.hip index aeb3c285..6fa3a5f7 100644 --- a/libr4d/r4d_qsa_select_bf16.hip +++ b/libr4d/r4d_qsa_select_bf16.hip @@ -20,6 +20,7 @@ #include "r4d.h" #include "r4d_args.h" #include "r4d_emit.h" +#include "r4d_chain.h" #include "r4d_launch.h" // R4D_DYN_LDS #include "r4d_common.h" // the DPP wave scans @@ -129,7 +130,7 @@ __device__ __forceinline__ void counts_before(const uint32_t* wsum, int lane, in * entirely in the query's past when b * ratio + ratio - 1 <= pos. At decode this equals the * sequence's complete count. */ template -__global__ __launch_bounds__(kThreads) void qsa_select_kernel( +__device__ __forceinline__ void qsa_select_kernel_body( const float* __restrict__ score, const int32_t* __restrict__ bt, const int32_t* __restrict__ nc, const int32_t* __restrict__ pos, const int32_t* __restrict__ cu, @@ -294,6 +295,28 @@ __global__ __launch_bounds__(kThreads) void qsa_select_kernel( } } +/* The plain and chained forms (r4d_chain.h): every block leaves through the wrapper. */ +template +__global__ __launch_bounds__(kThreads) void qsa_select_kernel( + const float* __restrict__ score, const int32_t* __restrict__ bt, + const int32_t* __restrict__ nc, const int32_t* __restrict__ pos, + const int32_t* __restrict__ cu, + int32_t* __restrict__ sel, int32_t* __restrict__ nsel, int32_t* __restrict__ seqused, + int nb, int topk, int ratio, int nseq, int s_ld, int t_ld, int o_ld, int cap) { + qsa_select_kernel_body(score, bt, nc, pos, cu, sel, nsel, seqused, nb, topk, ratio, nseq, s_ld, t_ld, o_ld, cap); +} +template +__global__ __launch_bounds__(kThreads) void r4dchain_qsa_select( + const float* __restrict__ score, const int32_t* __restrict__ bt, + const int32_t* __restrict__ nc, const int32_t* __restrict__ pos, + const int32_t* __restrict__ cu, + int32_t* __restrict__ sel, int32_t* __restrict__ nsel, int32_t* __restrict__ seqused, + int nb, int topk, int ratio, int nseq, int s_ld, int t_ld, int o_ld, int cap) { + r4d_chain_wait(); + qsa_select_kernel_body(score, bt, nc, pos, cu, sel, nsel, seqused, nb, topk, ratio, nseq, s_ld, t_ld, o_ld, cap); + r4d_chain_done(); +} + /* ===================================================== the wide-launch path, for a prefill chunk * * Without the key cache the kernel above reads every key from global memory five times, and its @@ -1148,6 +1171,14 @@ static int r4d_qsa_select_bf16_emit(long score, long bt, long nc, long pos, long /* Never more than the table width. */ int cap = (M <= kCacheMaxM) ? lds_cap_of() : 0; if (cap > nb) cap = nb; + /* Two launch sites rather than a choice of kernel inside one: each names its kernel alone, and + * the emulator test reads the plain one's name (tests/r4d_emu/test_qsa.cpp). */ + if (g_r4d_chain_arg) + return R4D_EMIT(stream, r4dchain_qsa_select, dim3((unsigned)M), dim3(kThreads), + (size_t)cap * sizeof(uint32_t), (const float*)score, (const int32_t*)bt, + (const int32_t*)nc, (const int32_t*)pos, (const int32_t*)cu, + (int32_t*)sel, (int32_t*)nsel, + (int32_t*)seqused, nb, topk, ratio, nseq, s_ld, t_ld, o_ld, cap); return R4D_EMIT(stream, qsa_select_kernel, dim3((unsigned)M), dim3(kThreads), (size_t)cap * sizeof(uint32_t), (const float*)score, (const int32_t*)bt, (const int32_t*)nc, (const int32_t*)pos, (const int32_t*)cu, @@ -1168,6 +1199,7 @@ enum { QL_SCORE = 0, QL_BT = 1, QL_NC = 2, QL_POS = 3, QL_CU = 4, QL_SEL = 5, QL QL_SEQ = 7 }; extern "C" int r4d_rad_qsa_select(const RadArgs* a, RadStream stream) { + const R4dChainArg chain_arg(r4d_geti_or(a, "chain", 0) != 0); const RadTensor* sc = r4d_opt(a, QL_SCORE); const RadTensor* bt = r4d_opt(a, QL_BT); const RadTensor* nc = r4d_opt(a, QL_NC); diff --git a/libr4d/r4d_qsa_tail_store_bf16.hip b/libr4d/r4d_qsa_tail_store_bf16.hip index 82588658..7640fe3d 100644 --- a/libr4d/r4d_qsa_tail_store_bf16.hip +++ b/libr4d/r4d_qsa_tail_store_bf16.hip @@ -22,6 +22,7 @@ #include "r4d.h" #include "r4d_args.h" #include "r4d_emit.h" +#include "r4d_chain.h" #include #include @@ -30,11 +31,11 @@ namespace { constexpr int kThreads = 256; -__global__ __launch_bounds__(kThreads) void qsa_tail_store_kernel( +__device__ __forceinline__ void qsa_tail_store_kernel_body( const uint16_t* __restrict__ k, const int32_t* __restrict__ pos, const int32_t* __restrict__ cu, const int32_t* __restrict__ sidx, uint16_t* __restrict__ state, - int T, int n, int ring, int seqs, int k_ld, int s_slot, int s_row, int sidx_ld) { + int T, int n, int ring, int seqs, int slots, int k_ld, int s_slot, int s_row, int sidx_ld) { const int t = (int)blockIdx.x; if (t >= T) return; @@ -48,9 +49,10 @@ __global__ __launch_bounds__(kThreads) void qsa_tail_store_kernel( /* Only the last `ring` tokens of this sequence's chunk -- see the header. */ if (t < cu[s + 1] - ring) return; - /* Column 0 is the committed slot; -1 marks a sequence with no state. */ + /* Column 0 is the committed slot; -1 marks a sequence with no state. A slot past the + * state plane's would write past its allocation. */ const int si = sidx[(size_t)s * sidx_ld]; - if (si < 0) return; + if (si < 0 || si >= slots) return; const int row = pos[t] % ring; const size_t src = (size_t)t * k_ld; @@ -58,6 +60,24 @@ __global__ __launch_bounds__(kThreads) void qsa_tail_store_kernel( for (int d = (int)threadIdx.x; d < n; d += kThreads) state[dst + d] = k[src + d]; } +/* The plain and chained forms (r4d_chain.h): every block leaves through the wrapper. */ +__global__ __launch_bounds__(kThreads) void qsa_tail_store_kernel( + const uint16_t* __restrict__ k, const int32_t* __restrict__ pos, + const int32_t* __restrict__ cu, const int32_t* __restrict__ sidx, + uint16_t* __restrict__ state, + int T, int n, int ring, int seqs, int slots, int k_ld, int s_slot, int s_row, int sidx_ld) { + qsa_tail_store_kernel_body(k, pos, cu, sidx, state, T, n, ring, seqs, slots, k_ld, s_slot, s_row, sidx_ld); +} +__global__ __launch_bounds__(kThreads) void r4dchain_qsa_tail_store( + const uint16_t* __restrict__ k, const int32_t* __restrict__ pos, + const int32_t* __restrict__ cu, const int32_t* __restrict__ sidx, + uint16_t* __restrict__ state, + int T, int n, int ring, int seqs, int slots, int k_ld, int s_slot, int s_row, int sidx_ld) { + r4d_chain_wait(); + qsa_tail_store_kernel_body(k, pos, cu, sidx, state, T, n, ring, seqs, slots, k_ld, s_slot, s_row, sidx_ld); + r4d_chain_done(); +} + } // namespace // k [T][n] bf16, `k_ld` elements a row (0 = n) @@ -67,17 +87,17 @@ __global__ __launch_bounds__(kThreads) void qsa_tail_store_kernel( // state [slots][ring][n] bf16, this layer's tail cache; written only, untargeted rows // keep their contents static int r4d_qsa_tail_store_bf16_emit(long k, long pos, long cu, long sidx, long state, int T, - int n, int ring, int seqs, int k_ld, int s_slot, int s_row, - int sidx_ld, RadStream stream) { + int n, int ring, int seqs, int slots, int k_ld, int s_slot, + int s_row, int sidx_ld, RadStream stream) { if (!k || !pos || !cu || !sidx || !state) return R4D_NO(RAD_E_INVAL); - if (T <= 0 || n <= 0 || ring <= 0 || seqs <= 0) return R4D_NO(RAD_E_SHAPE); + if (T <= 0 || n <= 0 || ring <= 0 || seqs <= 0 || slots <= 0) return R4D_NO(RAD_E_SHAPE); if (!k_ld) k_ld = n; if (!s_row) s_row = n; if (!sidx_ld) sidx_ld = 1; - return R4D_EMIT(stream, qsa_tail_store_kernel, dim3((unsigned)T), dim3(kThreads), 0, + return R4D_EMIT(stream, g_r4d_chain_arg ? &r4dchain_qsa_tail_store : &qsa_tail_store_kernel, dim3((unsigned)T), dim3(kThreads), 0, (const uint16_t*)k, (const int32_t*)pos, (const int32_t*)cu, - (const int32_t*)sidx, (uint16_t*)state, T, n, ring, seqs, k_ld, s_slot, s_row, - sidx_ld); + (const int32_t*)sidx, (uint16_t*)state, T, n, ring, seqs, slots, k_ld, s_slot, + s_row, sidx_ld); } // ============================================================== the plugin ABI entry point @@ -112,9 +132,10 @@ extern "C" int r4d_rad_qsa_tail_store(const RadArgs* a, RadStream stream) { const long long kp = r4d_row_pitch(k); if (kp < 0) return R4D_NO(RAD_E_STRIDE); if (k->dtype != RAD_BF16 || st->dtype != RAD_BF16) return R4D_NO(RAD_E_DTYPE); + const R4dChainArg chain_arg(r4d_geti_or(a, "chain", 0) != 0); return r4d_qsa_tail_store_bf16_emit(r4d_addr(k), r4d_addr(po), r4d_addr(cu), r4d_addr(sx), r4d_addr(st), (int)T, (int)n, (int)ring, (int)seqs, - (int)kp, (int)st->stride[0], (int)st->stride[2], - (int)sxp, stream); + (int)st->shape[0], (int)kp, (int)st->stride[0], + (int)st->stride[2], (int)sxp, stream); } diff --git a/libr4d/r4d_qsa_work_bf16.hip b/libr4d/r4d_qsa_work_bf16.hip index 5a052ff2..6cedb868 100644 --- a/libr4d/r4d_qsa_work_bf16.hip +++ b/libr4d/r4d_qsa_work_bf16.hip @@ -21,6 +21,7 @@ #include "r4d.h" #include "r4d_args.h" #include "r4d_emit.h" +#include "r4d_chain.h" #include #include @@ -32,7 +33,7 @@ constexpr int kThreads = 128; * row constraint on the declared seqs (rad-convert declares 256, which must still resolve). */ constexpr int kMaxSeq = 256; -__global__ __launch_bounds__(kThreads) void qsa_work_kernel( +__device__ __forceinline__ void qsa_work_kernel_body( const uint16_t* __restrict__ k, const int32_t* __restrict__ pos, const int32_t* __restrict__ cu, const uint16_t* __restrict__ state, const int32_t* __restrict__ sidx, const int32_t* __restrict__ bt, @@ -113,6 +114,32 @@ __global__ __launch_bounds__(kThreads) void qsa_work_kernel( } } +/* The plain and chained forms (r4d_chain.h): every block leaves through the wrapper. */ +__global__ __launch_bounds__(kThreads) void qsa_work_kernel( + const uint16_t* __restrict__ k, const int32_t* __restrict__ pos, + const int32_t* __restrict__ cu, const uint16_t* __restrict__ state, + const int32_t* __restrict__ sidx, const int32_t* __restrict__ bt, + uint16_t* __restrict__ stage, int32_t* __restrict__ page, int32_t* __restrict__ bpos, + int32_t* __restrict__ nc, + int n, int ratio, int ring, int seqs, int max_work, int k_ld, int s_slot, int s_row, + int sidx_ld, int bt_ld, int g_ld, const int32_t* __restrict__ rope, int rplane, + int bstep) { + qsa_work_kernel_body(k, pos, cu, state, sidx, bt, stage, page, bpos, nc, n, ratio, ring, seqs, max_work, k_ld, s_slot, s_row, sidx_ld, bt_ld, g_ld, rope, rplane, bstep); +} +__global__ __launch_bounds__(kThreads) void r4dchain_qsa_work( + const uint16_t* __restrict__ k, const int32_t* __restrict__ pos, + const int32_t* __restrict__ cu, const uint16_t* __restrict__ state, + const int32_t* __restrict__ sidx, const int32_t* __restrict__ bt, + uint16_t* __restrict__ stage, int32_t* __restrict__ page, int32_t* __restrict__ bpos, + int32_t* __restrict__ nc, + int n, int ratio, int ring, int seqs, int max_work, int k_ld, int s_slot, int s_row, + int sidx_ld, int bt_ld, int g_ld, const int32_t* __restrict__ rope, int rplane, + int bstep) { + r4d_chain_wait(); + qsa_work_kernel_body(k, pos, cu, state, sidx, bt, stage, page, bpos, nc, n, ratio, ring, seqs, max_work, k_ld, s_slot, s_row, sidx_ld, bt_ld, g_ld, rope, rplane, bstep); + r4d_chain_done(); +} + } // namespace // k [T][n] bf16, this step's raw index keys @@ -140,7 +167,7 @@ static int r4d_qsa_work_bf16_emit(long k, long pos, long cu, long state, long si if (!s_row) s_row = n; if (!g_ld) g_ld = n; if (!sidx_ld) sidx_ld = 1; - return R4D_EMIT(stream, qsa_work_kernel, dim3((unsigned)max_work), dim3(kThreads), 0, + return R4D_EMIT(stream, g_r4d_chain_arg ? &r4dchain_qsa_work : &qsa_work_kernel, dim3((unsigned)max_work), dim3(kThreads), 0, (const uint16_t*)k, (const int32_t*)pos, (const int32_t*)cu, (const uint16_t*)state, (const int32_t*)sidx, (const int32_t*)bt, (uint16_t*)stage, (int32_t*)page, (int32_t*)bpos, (int32_t*)nc, n, ratio, @@ -211,6 +238,7 @@ extern "C" int r4d_rad_qsa_work(const RadArgs* a, RadStream stream) { const long long bp2 = r4d_row_pitch(bt), sp = r4d_row_pitch(st); if (kp < 0 || bp2 < 0 || sp < 0) return R4D_NO(RAD_E_STRIDE); if (k->dtype != RAD_BF16 || tl->dtype != RAD_BF16) return R4D_NO(RAD_E_DTYPE); + const R4dChainArg chain_arg(r4d_geti_or(a, "chain", 0) != 0); return r4d_qsa_work_bf16_emit(r4d_addr(k), r4d_addr(po), r4d_addr(cu), r4d_addr(tl), r4d_addr(sx), r4d_addr(bt), r4d_addr(st), r4d_addr(pg), r4d_addr(bp), r4d_addr(nc), (int)n, (int)ratio, (int)ring, diff --git a/libr4d/r4d_rows.cpp b/libr4d/r4d_rows.cpp index afcf16c3..fdd53f82 100644 --- a/libr4d/r4d_rows.cpp +++ b/libr4d/r4d_rows.cpp @@ -137,6 +137,19 @@ static const RadOperandSpec oAttnPagedTree[] = { { "spec_parent", RAD_OPD_IN, 0 }, }; +/* attn_paged with a sink logit a query head, its own name so no kernel ignorant of it is chosen. */ +static const RadOperandSpec oAttnPagedSink[] = { + { "q", RAD_OPD_IN, 0 }, + { "kv_cache", RAD_OPD_IN, 0 }, + { "block_table", RAD_OPD_IN, 0 }, + { "seqused", RAD_OPD_IN, 0 }, + { "k_descale", RAD_OPD_IN, 1 }, + { "v_descale", RAD_OPD_IN, 1 }, + { "cu_seqlens", RAD_OPD_IN, 1 }, + { "sinks", RAD_OPD_WEIGHT, 0 }, /* [n_head] f32 */ + { "out", RAD_OPD_OUT, 0 }, +}; + /* attn_paged with gate_quant_fp8 folded into its merge: attn_paged's parameters plus the two of * gate_quant_fp8's that are not implied (its `n` is `head_dim`, its rows attn_paged's (token, * head) pairs), then attn_paged's operands, the gate, the codes and the scales. `out` holds the @@ -532,6 +545,29 @@ static const RadOperandSpec oGdnConvRecurrentUpdate[] = { { "o_scale", RAD_OPD_OUT, 1 }, }; +/* gdn_conv_recurrent_update with had_quant_act_i8g's codes of `o` (a rotated int8 out projection's + * input): the same operands, the codes required. libr4d's alone; no reference serves it. */ +static const RadOperandSpec oGdnConvRecurrentUpdateHad[] = { + { "x", RAD_OPD_IN, 0 }, + { "conv_w", RAD_OPD_WEIGHT, 0 }, + { "conv_b", RAD_OPD_WEIGHT, 1 }, + { "conv_state", RAD_OPD_INOUT, 0 }, + { "conv_idx", RAD_OPD_IN, 0 }, + { "a", RAD_OPD_IN, 0 }, + { "b", RAD_OPD_IN, 0 }, + { "A_log", RAD_OPD_WEIGHT, 0 }, + { "dt_bias", RAD_OPD_WEIGHT, 0 }, + { "state", RAD_OPD_INOUT, 0 }, + { "state_idx", RAD_OPD_IN, 0 }, + { "num_accepted", RAD_OPD_IN, 0 }, + { "cu", RAD_OPD_IN, 0 }, + { "z", RAD_OPD_IN, 0 }, + { "norm_w", RAD_OPD_WEIGHT, 0 }, + { "o", RAD_OPD_OUT, 0 }, + { "o_q", RAD_OPD_OUT, 0 }, + { "o_scale", RAD_OPD_OUT, 0 }, +}; + /* The control vector's projection (r4d_hc_bf16.hip, with the other gated-residual kernels): a bf16 * stream, one unit f32 direction for every stream, an int32 switch per row. */ static const RadParamSpec pHcProject[] = { P_INT("M"), P_INT("n"), P_INT("hc"), P_F64("scale"), @@ -595,6 +631,17 @@ static const RadOperandSpec oKdaUpdate[] = { {"cu", RAD_OPD_IN, 0}, {"num_accepted", RAD_OPD_IN, 1}, {"has_init", RAD_OPD_IN, 1}, {"o", RAD_OPD_OUT, 0}, }; +static const RadParamSpec pSsdUpdate[] = { + P_INT("M"), P_INT("heads"), P_INT("head_dim"), P_INT("d_state"), P_INT("groups"), + P_STR("mode"), P_STR("dtype"), P_STRO("state_form"), +}; +static const RadOperandSpec oSsdUpdate[] = { + {"x", RAD_OPD_IN, 0}, {"B", RAD_OPD_IN, 0}, {"C", RAD_OPD_IN, 0}, + {"dt", RAD_OPD_IN, 0}, {"A_log", RAD_OPD_WEIGHT, 0}, {"dt_bias", RAD_OPD_WEIGHT, 0}, + {"D", RAD_OPD_WEIGHT, 0}, {"state", RAD_OPD_INOUT, 0}, {"state_idx", RAD_OPD_IN, 0}, + {"cu", RAD_OPD_IN, 0}, {"num_accepted", RAD_OPD_IN, 1}, {"has_init", RAD_OPD_IN, 1}, + {"o", RAD_OPD_OUT, 0}, +}; static const RadOperandSpec oHcWrite[] = { { "y", RAD_OPD_IN, 0 }, { "inj", RAD_OPD_IN, 0 }, { "h", RAD_OPD_INOUT, 0 }, }; @@ -713,6 +760,20 @@ static const RadOperandSpec oDflashSelect[] = { { "succ", RAD_OPD_WEIGHT, 0 }, { "tokens", RAD_OPD_OUT, 0 }, }; +/* DSpark's exact, vocabulary-wide greedy Markov walk. Per-tile score/id planes are explicit + * outputs so the device implementation can parallelize each full-vocabulary step and reduce it + * before the next autoregressive step. */ +static const RadParamSpec pDflashMarkov[] = { + { "M", RAD_P_INT, RAD_REQUIRED }, { "steps", RAD_P_INT, RAD_REQUIRED }, + { "rank", RAD_P_INT, RAD_REQUIRED }, { "n_vocab", RAD_P_INT, RAD_REQUIRED }, + { "anchor_stride", RAD_P_INT, RAD_OPTIONAL }, { "dtype", RAD_P_STR, RAD_REQUIRED }, +}; +static const RadOperandSpec oDflashMarkov[] = { + { "logits", RAD_OPD_IN, 0 }, { "anchor", RAD_OPD_IN, 0 }, + { "pred", RAD_OPD_WEIGHT, 0 }, { "succ", RAD_OPD_WEIGHT, 0 }, + { "tile_scores", RAD_OPD_OUT, 0 }, { "tile_tokens", RAD_OPD_OUT, 0 }, + { "tokens", RAD_OPD_OUT, 0 }, +}; /* dflash_tree: dflash_select's, plus the node count, the softmax temperature and the parents. */ static const RadParamSpec pDflashTree[] = { { "M", RAD_P_INT, RAD_REQUIRED }, @@ -1236,7 +1297,8 @@ static const RadOperandSpec oGivensDense[] = { * * `h` is inout: a caller zeroes it once and each launch adds its block. The operands are named `a` * and `a_scale` as in `gemm_nt_q`, whose activation this characterises. `a_scale` is optional: - * dtype "bf16" reads a plain activation with no scale (a model served at bf16). */ + * dtype "bf16" reads a plain activation with no scale (a model served at bf16); "i8a8" reads an + * int8 trunk's codes. */ static const RadParamSpec pGramAccum[] = { { "M", RAD_P_INT, RAD_REQUIRED }, { "n", RAD_P_INT, RAD_REQUIRED }, @@ -1870,11 +1932,23 @@ static const RadParamSpec pSwigluClampedQuant[] = { P_INT("M"), P_INT("n"), P_F6 P_INT("group"), P_STR("dtype") }; static const RadParamSpec pDsaPool[] = { P_INT("M"), P_INT("n"), P_INT("ratio"), P_STR("dtype"), P_INTO("block_size") }; +/* `kv_dtype` is the latent cache's: absent or bf16, or fp8_e4m3 (kv_store_fp8 at descale 1). */ static const RadParamSpec pMlaAttn[] = { P_INT("M"), P_INT("latent_dim"), P_INT("heads"), P_INT("blocks"), P_INT("block_size"), P_F64("scale"), - P_STR("dtype") }; + P_STR("dtype"), P_STRO("kv_dtype") }; static const RadParamSpec pMlaProject[] = { P_INT("M"), P_INT("heads"), P_INT("head_dim"), P_INT("latent_dim"), P_STR("mode"), P_STR("dtype") }; +static const RadParamSpec pMlaAttnPaged[] = { P_INT("M"), P_INT("heads"), P_INT("latent_dim"), + P_INT("rope_dim"), P_INT("block_size"), P_F64("scale"), + P_STR("dtype") }; +static const RadOperandSpec oMlaAttnPaged[] = { { "q", RAD_OPD_IN, 0 }, + { "q_rope", RAD_OPD_IN, 1 }, + { "kv", RAD_OPD_IN, 0 }, + { "block_table", RAD_OPD_IN, 0 }, + { "seqused", RAD_OPD_IN, 0 }, + { "cu_seqlens", RAD_OPD_IN, 0 }, + { "gate", RAD_OPD_IN, 1 }, + { "out", RAD_OPD_OUT, 0 } }; static const RadOperandSpec oMlaAttn[] = { { "q", RAD_OPD_IN, 0 }, { "kv", RAD_OPD_IN, 0 }, { "bt", RAD_OPD_IN, 0 }, @@ -1895,6 +1969,8 @@ static const RadOperandSpec oDsaPool[] = { }; static const RadParamSpec pRouterSigmoid[] = { P_INT("M"), P_INT("n_expert"), P_INT("top_k"), P_INT("norm"), P_F64("route_scale"), P_STR("dtype") }; +static const RadParamSpec pRouterSigmoidGroup[] = { P_INT("M"), P_INT("n_expert"), P_INT("top_k"), + P_INT("n_group"), P_INT("topk_group"), P_INT("norm"), P_F64("route_scale"), P_STR("dtype") }; static const RadOperandSpec oRouterSigmoid[] = { { "logits", RAD_OPD_IN, 0 }, { "bias", RAD_OPD_WEIGHT, 0 }, { "ids", RAD_OPD_OUT, 0 }, { "weights", RAD_OPD_OUT, 0 } @@ -1960,6 +2036,10 @@ static const RadParamSpec pQkNormRope[] = { static const RadParamSpec pPoolRows[] = { P_INT("M"), P_INT("n"), P_INT("k"), P_F64O("mult"), P_STR("dtype"), }; +/* `n` is the point's values; y has n (2 freqs + 1) columns. */ +static const RadParamSpec pPointFourier[] = { + P_INT("M"), P_INT("n"), P_INT("freqs"), P_INTO("pi"), P_STR("dtype"), +}; /* `positions` may be absent at `rotary_dim` 0 (the norm alone), and an absent gain is a unit * gain. */ static const RadOperandSpec oQkNormRope[] = { @@ -2124,6 +2204,16 @@ static const RadOperandSpec oGridEmbed[] = { { "table", RAD_OPD_WEIGHT, 0 }, { "coord", RAD_OPD_IN, 0 }, }; +static const RadParamSpec pGridEmbedCpe[] = { + P_INT("M"), P_INT("n"), P_INT("side"), P_STR("dtype"), + { "n_prefix", RAD_P_INT, RAD_OPTIONAL }, +}; +static const RadOperandSpec oGridEmbedCpe[] = { + { "x", RAD_OPD_INOUT, 0 }, + { "table", RAD_OPD_WEIGHT, 0 }, + { "coord", RAD_OPD_IN, 0 }, + { "prefix", RAD_OPD_WEIGHT, 1 }, +}; static const RadParamSpec pGemmBias[] = { P_INT("M"), P_INT("N"), P_INT("K"), P_STR("dtype"), { "act", RAD_P_STR, RAD_OPTIONAL }, @@ -2254,6 +2344,19 @@ static const RadOperandSpec oPleConv[] = { { "num_accepted", RAD_OPD_IN, 1 }, { "y", RAD_OPD_OUT, 0 }, }; +/* ple_conv's operands with `b`, a per-channel bias inside the silu, before `y`. */ +static const RadOperandSpec oPleConvBias[] = { + { "x", RAD_OPD_IN, 0 }, + { "w", RAD_OPD_WEIGHT, 0 }, + { "conv_state", RAD_OPD_INOUT, 0 }, + { "cu", RAD_OPD_IN, 0 }, + { "resid", RAD_OPD_IN, 1 }, + { "cache_idx", RAD_OPD_IN, 1 }, + { "has_init", RAD_OPD_IN, 1 }, + { "num_accepted", RAD_OPD_IN, 1 }, + { "b", RAD_OPD_WEIGHT, 0 }, + { "y", RAD_OPD_OUT, 0 }, +}; /* ple_conv's operands without `resid`, its parameters without `dilation`. */ static const RadParamSpec pCausalConv[] = { { "M", RAD_P_INT, RAD_REQUIRED }, @@ -2307,6 +2410,38 @@ static const RadOperandSpec oLogits[] = { { "logits", RAD_OPD_OUT, 0 }, }; +/* The lm_head as width classes of the vocabulary's rows: up to four (codes, scales, ids) triples, + * a class's rows on this rank in `rows`, ids global (`vocab_offset` is this rank's first), and + * `vrow`, the inverse: each of the rank's ids' class width and row. */ +static const RadParamSpec pLogitsVocab[] = { + { "M", RAD_P_INT, RAD_REQUIRED }, + { "n_vocab", RAD_P_INT, RAD_REQUIRED }, + { "n_embd", RAD_P_INT, RAD_REQUIRED }, + { "dtype", RAD_P_STR, RAD_REQUIRED }, + { "vocab_offset", RAD_P_INT, RAD_REQUIRED }, + { "rows0", RAD_P_INT, RAD_REQUIRED }, + { "rows1", RAD_P_INT, RAD_OPTIONAL }, + { "rows2", RAD_P_INT, RAD_OPTIONAL }, + { "rows3", RAD_P_INT, RAD_OPTIONAL }, +}; +static const RadOperandSpec oLogitsVocab[] = { + { "x", RAD_OPD_IN, 0 }, + { "w0", RAD_OPD_WEIGHT, 0 }, + { "s0", RAD_OPD_WEIGHT, 0 }, + { "ids0", RAD_OPD_WEIGHT, 0 }, + { "w1", RAD_OPD_WEIGHT, 1 }, + { "s1", RAD_OPD_WEIGHT, 1 }, + { "ids1", RAD_OPD_WEIGHT, 1 }, + { "w2", RAD_OPD_WEIGHT, 1 }, + { "s2", RAD_OPD_WEIGHT, 1 }, + { "ids2", RAD_OPD_WEIGHT, 1 }, + { "w3", RAD_OPD_WEIGHT, 1 }, + { "s3", RAD_OPD_WEIGHT, 1 }, + { "ids3", RAD_OPD_WEIGHT, 1 }, + { "vrow", RAD_OPD_WEIGHT, 0 }, + { "logits", RAD_OPD_OUT, 0 }, +}; + /* Every sampler scalar is per row and arrives in `params`, an array of RadSampleParams * (abi/rad_sample.h). Parameters are geometry, frozen at declare, so only the two extents are * parameters. */ @@ -2390,7 +2525,7 @@ static const RadParamSpec pLogprobs[] = { }; static const RadOperandSpec oLogprobs[] = { { "logits", RAD_OPD_IN, 0 }, - { "params", RAD_OPD_IN, 0 }, + { "params", RAD_OPD_IN, 1 }, /* absent: every row */ { "stats", RAD_OPD_OUT, 0 }, }; static const RadOperandSpec oNarrow[] = { @@ -2427,6 +2562,38 @@ static const RadOperandSpec oPairArgmax[] = { { "idx", RAD_OPD_OUT, 0 }, { "val", RAD_OPD_OUT, 1 }, }; +/* LiLiCorr's correlator (r4d_lili.hip; libref/ref_lili.cpp has the contracts). */ +static const RadParamSpec pLiliCand[] = { + P_INT("M"), P_INT("k"), P_INT("world"), P_INT("steps"), P_INT("n"), P_STR("dtype"), + P_F64O("eps"), P_INTO("row_k"), +}; +static const RadOperandSpec oLiliCand[] = { + { "stats", RAD_OPD_IN, 0 }, { "pas", RAD_OPD_IN, 0 }, + { "ln_w", RAD_OPD_WEIGHT, 0 }, { "ln_b", RAD_OPD_WEIGHT, 0 }, + { "up_w", RAD_OPD_WEIGHT, 0 }, { "up_b", RAD_OPD_WEIGHT, 0 }, + { "slot", RAD_OPD_WEIGHT, 0 }, { "rank", RAD_OPD_WEIGHT, 0 }, + { "cand", RAD_OPD_OUT, 0 }, { "feat", RAD_OPD_OUT, 0 }, { "base", RAD_OPD_OUT, 0 }, +}; +static const RadParamSpec pLiliAttn[] = { + P_INT("M"), P_INT("steps"), P_INT("k"), P_INT("n_head"), P_INT("head_dim"), P_STR("dtype"), + P_F64O("scale"), +}; +static const RadOperandSpec oLiliAttn[] = { + { "qkv", RAD_OPD_IN, 0 }, { "rel", RAD_OPD_WEIGHT, 0 }, { "same", RAD_OPD_WEIGHT, 0 }, + { "out", RAD_OPD_OUT, 0 }, +}; +static const RadParamSpec pLiliFactor[] = { P_INT("M"), P_INT("L"), P_INT("n"), P_STR("dtype") }; +static const RadOperandSpec oLiliFactor[] = { + { "h", RAD_OPD_IN, 0 }, { "a", RAD_OPD_IN, 0 }, { "y", RAD_OPD_OUT, 0 }, +}; +static const RadParamSpec pLiliWalk[] = { + P_INT("M"), P_INT("steps"), P_INT("k"), P_INT("n"), P_STR("dtype"), P_F64O("eps"), + P_F64O("scale"), +}; +static const RadOperandSpec oLiliWalk[] = { + { "edges", RAD_OPD_IN, 0 }, { "aout", RAD_OPD_IN, 0 }, { "cand", RAD_OPD_IN, 0 }, + { "tokens", RAD_OPD_OUT, 0 }, { "scores", RAD_OPD_OUT, 1 }, +}; static const RadParamSpec pNormJoin[] = { P_INT("M"), P_INT("n"), @@ -2999,6 +3166,10 @@ static const RadOpSchema kSchemas[] = { "(broadcast down the rows): a learned gain on an activation. f32 product, rounded once."), SCHEMA("mla_attn", pMlaAttn, oMlaAttn, "Softmax over selected latent vectors used as both key and value; per-query page tables and visible lengths."), + SCHEMA("mla_attn_paged", pMlaAttnPaged, oMlaAttnPaged, + "Dense causal latent attention over a paged cache whose token row is the latent then the " + "rotated key part: score = scale * (q . latent + q_rope . rope), value = the latent; " + "sequences as in attn_paged. With `gate`, out = bf16(bf16(out) * bf16(sigmoid(gate[head])))."), SCHEMA("mla_project", pMlaProject, oGemmNt, "Per-head query absorption or value expansion through the shared [head,(K|V),latent] BF16 matrix."), SCHEMA("dsa_score", pDsaScore, oDsaScore, @@ -3009,6 +3180,8 @@ static const RadOpSchema kSchemas[] = { "Normalized Hadamard, BF16 boundary and power-of-two E4M3 quantization per query head."), SCHEMA("gemm_nt_f32", pGemmNt, oGemmNt, "BF16 activations times F32 weights, F32 accumulation and output; preserves routing and index gate precision."), + SCHEMA("swiglu_step", pSwigluClamped, oGateUp, + "min(silu(gate),limit)*clamp(up,-limit,limit); gate is the first half."), SCHEMA("swiglu_clamped", pSwigluClamped, oGateUp, "silu(min(gate,limit))*clamp(up,-limit,limit); gate is the first half."), SCHEMA("swiglu_clamped_quant_fp8", pSwigluClampedQuant, oGatedQuantFp8, @@ -3023,9 +3196,9 @@ static const RadOpSchema kSchemas[] = { "op, not gelu, because gated feed-forwards are trained with the tanh form and the " "unary gelu is the exact erf one."), SCHEMA("act_mul", pActMul, oBinary, - "y = act(a) * b, the activation (silu, gelu, gelu_tanh, sigmoid or quick_gelu) rounded " - "to y's dtype before " - "the product: silu_mul with its two halves in two operands."), + "y = act(a) * b, the activation (silu, gelu, gelu_tanh, sigmoid, quick_gelu or relu) " + "rounded to y's dtype before the product: silu_mul with its two halves in two " + "operands."), SCHEMA("seg_mean", pSegMean, oSegMean, "Row s of y is the mean of x's rows [cu_seqlens[s], cu_seqlens[s+1]), summed in f64 " "and rounded once; an empty segment is zeros."), @@ -3048,6 +3221,10 @@ static const RadOpSchema kSchemas[] = { "Column c of row m of y is the mean of x[m]'s columns [c*k, c*k + k), summed in f32 and " "rounded, then times `mult` and rounded again. n, the input width, is a multiple of k; " "y has n / k columns."), + SCHEMA("point_fourier", pPointFourier, oUnary, + "A point's Fourier features: row m of y is [x | sin(x_i f_j) | cos(x_i f_j)], f_j = 2^j " + "for j < freqs (times pi with `pi` 1), sines then cosines each i-major then j; y is " + "[M, n (2 freqs + 1)]."), SCHEMA("sigmoid", pMnDtype, oUnary, "y = 1 / (1 + exp(-x))."), SCHEMA("relu", pMnDtype, oUnary, "y = max(x, 0)."), SCHEMA("silu", pMnDtype, oUnary, "y = x * sigmoid(x)."), @@ -3125,6 +3302,12 @@ static const RadOpSchema kSchemas[] = { "position embedding: per axis a triangle filter on half-pixel centres, widened by the " "scale when shrinking, its in-table taps normalised. Separable, f32, rounded once " "before the add; coordinates clamp into their grid."), + SCHEMA("grid_embed_cpe", pGridEmbedCpe, oGridEmbedCpe, + "x += the side x side table resampled as torch's F.interpolate(bilinear, " + "align_corners=False) -- no antialias -- onto a square of side max(grid height, grid " + "width), of which the grid keeps the top-left part: RADIO's cropped position embedding. " + "Two taps an axis, the row blended first; f32, rounded once before the add. A row " + "whose row coordinate is negative gets the learned prefix row its column names."), SCHEMA("gemm_nt_bias", pGemmBias, oGemmBias, "y = res + act(a @ b^T + bias), rounded to bf16 after the biased product, after the " "activation and after the residual -- the unfused chain's three tensors."), @@ -3168,6 +3351,11 @@ static const RadOpSchema kSchemas[] = { "Absent, every token commits: the read is at offset zero and the last " "(width-1)*dilation inputs land at offset zero, which is the prefill chunk. " "`resid` absent drops the add and leaves the plain convolution."), + SCHEMA("ple_conv_bias", pPleConv, oPleConvBias, + "ple_conv with `b`, a per-channel bias added inside the silu: y[t] = resid[t] + " + "silu(b[c] + sum_j w[c][j] * x[t - (width-1-j)*dilation]). At dilation one with no " + "`resid` it is Mamba-2's conv1d. The window, `has_init`, `cache_idx` and " + "`num_accepted` are ple_conv's."), SCHEMA("causal_conv1d", pCausalConv, oCausalConv, "y[t] = sum_j w[c][j] * x[t - (width-1-j)], ple_conv at dilation one with no " "activation and no residual: LFM2's short convolution, whose gates the caller applies. " @@ -3182,6 +3370,15 @@ static const RadOpSchema kSchemas[] = { "present: `tok` holds its row count more tokens after the step's, continuing the LAST " "sequence, and their ids -- as the step that runs them will compute them -- go there; " "the window is the step's own."), + SCHEMA("logits_gemm_vocab", pLogitsVocab, oLogitsVocab, + "logits[M, n_vocab] = x[M, n_embd] @ lm_head^T over a head stored as width classes of " + "the vocabulary's rows: class i is a weight of rows rows on this rank (w its " + "codes, s its scales) and ids the global vocabulary id of each, whose logit it " + "writes; ids outside [vocab_offset, vocab_offset + n_vocab) are dropped. The classes " + "cover the rank's share of the vocabulary once; ascending ids within a class keep the " + "stores together. vrow[n_vocab] is the inverse, each of the rank's ids' class width in " + "the top four bits and its row in the class's whole tensor below, which must fall in " + "this rank's rows (vocab_offset / n_vocab is the rank)."), SCHEMA("logits_gemm", pLogits, oLogits, "the lm_head projection. gemm_nt's arithmetic under the vocabulary edge's parameter " "spelling; M is one row per SAMPLED position, `gather_rows` having run first."), @@ -3232,15 +3429,26 @@ static const RadOpSchema kSchemas[] = { "paged causal attention, varlen. The ranged parameter is q_len, not M: one query row " "at decode, up to 64/gqa at a speculative verify, thousands in a prefill chunk, and " "libr4d has a different kernel for each band."), + SCHEMA("attn_paged_anchor_window", pAttnPaged, oAttnPaged, + "paged attention whose query rows all use the sequence's first query as the sliding-window anchor."), /* attn_paged under its own name, for q read at its own row pitch. The windowed kernels * (r4d_attn_paged_window.hip) read q in place in a fused [q|k|v] projection; the other * attn_paged kernels read q dense and refuse a slice (RAD_E_STRIDE). Under this name the op * resolves to a kernel that takes the slice or to nothing, and in the latter case the * architecture lifts q into a dense block for attn_paged. */ + SCHEMA("attn_paged_sink", pAttnPaged, oAttnPagedSink, + "attn_paged with `sinks` [n_head] f32: one logit a query head in the scaled-score " + "domain, in the softmax's maximum and denominator, with no value."), SCHEMA("attn_paged_qrow", pAttnPaged, oAttnPaged, "attn_paged, parameter for parameter and value for value, with q read at its own row " "pitch: a column slice of a wider row -- the q part of a fused [q|k|v] projection -- read " "where it lies rather than lifted into a dense block first."), + SCHEMA("attn_paged_ahead", pAttnPaged, oAttnPaged, + "attn_paged, non-causal, with `window` (> 0) bounding the keys behind a row only: key j is " + "visible when pos - j < window, every later key of the sequence is. A sliding layer's mask " + "over a picture's rows read both ways."), + SCHEMA("attn_paged_qrow_ahead", pAttnPaged, oAttnPaged, + "attn_paged_ahead with q read at its own row pitch, as attn_paged_qrow."), SCHEMA("attn_paged_qrow_tree", pAttnPaged, oAttnPagedTree, "attn_paged_qrow over a tree verify (rad_drafter_tree): spec_parent is -2 for an " "ordinary causal row, else the row's parent's index within its sequence's rows (-1 for " @@ -3306,6 +3514,11 @@ static const RadOpSchema kSchemas[] = { "gdn_conv_update followed by gdn_recurrent_update, with the convolution computed in " "the recurrent update's prologue: q, k and v never reach memory. Byte-identical to " "the two ops it replaces."), + SCHEMA("gdn_conv_recurrent_update_had", pGdnConvRecurrentUpdate, oGdnConvRecurrentUpdateHad, + "gdn_conv_recurrent_update whose `o_q` / `o_scale` are had_quant_act_i8g's codes of " + "`o` (int8, a 128-wide Hadamard before the per-(token, head) amax), for an out " + "projection stored rotated (i8a8h). Byte-identical to gdn_conv_recurrent_update " + "followed by had_quant_act_i8g."), SCHEMA("hc_enter", pHcPlain, oHcEnter, "h[s] = x for each of the hc streams -- the wide residual stream's first value."), SCHEMA("mhc_pre", pMhcPre, oMhcPre, @@ -3324,6 +3537,11 @@ static const RadOpSchema kSchemas[] = { SCHEMA("kda_update", pKdaUpdate, oKdaUpdate, "Bounded per-channel KDA recurrence. verify stores candidate states; prefill commits final state. " "Absolute cu offsets, accepted-prefix read slot, optional cold initialization, no output norm."), + SCHEMA("ssd_update", pSsdUpdate, oSsdUpdate, + "Mamba-2 selective state update: dt' = softplus(dt + dt_bias) (no clamp), state decays by " + "exp(-exp(A_log) dt') and gains dt' x B^T; o = state C + D x. verify stores candidate " + "states; prefill commits the final state. Absolute cu offsets, accepted-prefix read slot, " + "optional cold initialization, per_candidate only."), SCHEMA("hc_read", pHcRead, oHcRead, "the read half of a gated residual: a grouped rmsnorm, a low-rank sigmoid gate, and " "the mean of the gated streams -- plus the per-branch write gains and, optionally, " @@ -3352,6 +3570,12 @@ static const RadOpSchema kSchemas[] = { "positions, and the greedy walk that turns a block of independent top-k sets into one " "path. Only the K edges leaving the previous pick are scored, because the walk is " "serial and the other K-1 rows of the score matrix are never read."), + SCHEMA("dflash_markov_greedy", pDflashMarkov, oDflashMarkov, + "DSpark's exact greedy Markov walk: add the full-vocabulary bilinear bias to each " + "draft-head logit, choose the greatest token (ties to the lower id), then use it as the " + "next position's predecessor."), + SCHEMA("dflash_markov_greedy_f32", pDflashMarkov, oDflashMarkov, + "DSpark full-vocabulary greedy walk with F32 base logits and BF16 codebooks."), SCHEMA("dflash_tree", pDflashTree, oDflashTree, "dflash_select's lattice and edge scores grown best-first into a tree of `nodes` nodes: " "a taken node's children are the valid candidates at the next position, each with log " @@ -3391,6 +3615,10 @@ static const RadOpSchema kSchemas[] = { "With `add` present the form is y = bf16(x * act(s)) + add: the product is NARROWED " "before the sum, which is what makes the fused form bit-identical to the two ops it " "stands in for rather than merely close to them."), + SCHEMA("router_sigmoid_group_topk", pRouterSigmoidGroup, oRouterSigmoid, + "Group-limited sigmoid routing: groups rank by the sum of their two best p + bias, " + "selection runs over the topk_group best groups; correction bias selects, original " + "scores weight."), SCHEMA("router_sigmoid_topk", pRouterSigmoid, oRouterSigmoid, "Single-group sigmoid routing; correction bias selects experts, original scores weight them."), SCHEMA("router_sigmoid_topk_scatter", pRouterSigmoidScatter, oRouterSigmoidScatter, @@ -3551,6 +3779,11 @@ static const RadOpSchema kSchemas[] = { "epilogue, byte-identical to the two ops it replaces."), SCHEMA("gate_quant_fp8", pGateQuantFp8, oGateQuantFp8, "the same, with the gate in its own operand rather than packed beside x."), + SCHEMA("gate_had_quant_i8g", pGateQuantFp8, oGateQuantFp8, + "gate_quant_fp8 at int8 codes with a `group`-wide Hadamard before the absmax: " + "had_quant_act_i8g's codes of the bf16 product (`out_bf16` the unrotated product), for " + "an out projection stored rotated (dtype i8a8h). Byte-identical to gate_quant_fp8's " + "product and had_quant_act_i8g over it."), SCHEMA("quant_act_fp8", pQuantActFp8, oQuantActFp8, "per-(row, `group`-column) symmetric E4M3 quantisation of a token-major activation, in " "PLAIN ROW-MAJOR order rather than quant_act_i8's fragment order. The scale is " @@ -3685,6 +3918,16 @@ static const RadOpSchema kSchemas[] = { "token order (with the shared arm folded when present) ARE the all-reduce's message, " "and the gated residual's write follows the reduction. Both wires at two ranks, the " "exact one at four."), + SCHEMA("lili_cand", pLiliCand, oLiliCand, + "LiLiCorr's candidates from the ranks' sample_logprobs rows, their rank features through " + "layernorm, the up projection and silu, and the lattice rows' additive part."), + SCHEMA("lili_attn", pLiliAttn, oLiliAttn, + "attention over each sequence's candidate lattice with a learned bias on slot distance " + "and the same slot."), + SCHEMA("lili_factor", pLiliFactor, oLiliFactor, + "[h | a | h * a] a lattice row, a its sequence's anchor."), + SCHEMA("lili_walk", pLiliWalk, oLiliWalk, + "LiLiCorr's normalised edge scores and their greedy walk."), SCHEMA("pair_argmax", pPairArgmax, oPairArgmax, "idx[m] = the id of the largest value among pairs[m, 0..n), each pair an int32 id in " "the first f32 slot and its value in the second (row_topk's `pairs`, all-gathered): ties " @@ -4155,10 +4398,10 @@ static const RadConstraint cAttnPrefillH64G4Bf16[] = { C_EQ("causal", 1), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", "bf16"), }; /* The windowed kernels (r4d_attn_paged_window.hip): head_dim 128, 256 and 512, 1/2/4/8 queries per - * KV head, any window, causal or not. Gemma 4's sliding layers are h256/gqa2 with a 1024-token - * window, its full layers h512 at gqa 8 (TP1/TP2), 4 (TP4) or 2 (TP8); h128/gqa1 is Unlimited-OCR's - * MHA decoder. One kernel serves every q_len (splitting the key range when there are too few tiles - * to fill the card), so `q_len` cuts no band. `causal` and `window` are runtime fields; block_size + * KV head (16 at 512), any window, causal or not. Gemma 4's sliding layers are h256/gqa2 with a + * 1024-token window, its full layers h512 at gqa 8 (TP1/TP2), 4 (TP4) or 2 (TP8), the 12B's at + * gqa 16 (TP1); h128/gqa1 is Unlimited-OCR's MHA decoder. One kernel serves every q_len (splitting + * the key range when there are too few tiles to fill the card), so `q_len` cuts no band. `causal` and `window` are runtime fields; block_size * is derived: 16. * * h256 at gqa 4 and 8 take a window only (C_GE 1), leaving the window-0 band to the gqa4 / gqa8 @@ -4170,6 +4413,8 @@ static const RadConstraint cAttnPrefillH64G4Bf16[] = { C_GE("window", WMIN), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", KV), \ }; R4D_WIN_C(cWinH128G1Bf16, 128, 1, "bf16", 0) R4D_WIN_C(cWinH128G1Fp8, 128, 1, "fp8_e4m3", 0) +R4D_WIN_C(cWinH128G8Bf16, 128, 8, "bf16", 0) R4D_WIN_C(cWinH128G8Fp8, 128, 8, "fp8_e4m3", 0) +R4D_WIN_C(cWinH128G16Bf16, 128, 16, "bf16", 0) R4D_WIN_C(cWinH128G16Fp8, 128, 16, "fp8_e4m3", 0) R4D_WIN_C(cWinH256G1Bf16, 256, 1, "bf16", 0) R4D_WIN_C(cWinH256G1Fp8, 256, 1, "fp8_e4m3", 0) R4D_WIN_C(cWinH256G2Bf16, 256, 2, "bf16", 0) R4D_WIN_C(cWinH256G2Fp8, 256, 2, "fp8_e4m3", 0) R4D_WIN_C(cWinH256G4Bf16, 256, 4, "bf16", 1) R4D_WIN_C(cWinH256G4Fp8, 256, 4, "fp8_e4m3", 1) @@ -4178,7 +4423,29 @@ R4D_WIN_C(cWinH512G1Bf16, 512, 1, "bf16", 0) R4D_WIN_C(cWinH512G1Fp8, 512, 1, "f R4D_WIN_C(cWinH512G2Bf16, 512, 2, "bf16", 0) R4D_WIN_C(cWinH512G2Fp8, 512, 2, "fp8_e4m3", 0) R4D_WIN_C(cWinH512G4Bf16, 512, 4, "bf16", 0) R4D_WIN_C(cWinH512G4Fp8, 512, 4, "fp8_e4m3", 0) R4D_WIN_C(cWinH512G8Bf16, 512, 8, "bf16", 0) R4D_WIN_C(cWinH512G8Fp8, 512, 8, "fp8_e4m3", 0) +/* DSpark uses the same geometry constraints, but requires a positive window. */ +R4D_WIN_C(cAnchorH128G1Bf16, 128, 1, "bf16", 1) R4D_WIN_C(cAnchorH128G1Fp8, 128, 1, "fp8_e4m3", 1) +R4D_WIN_C(cAnchorH256G1Bf16, 256, 1, "bf16", 1) R4D_WIN_C(cAnchorH256G1Fp8, 256, 1, "fp8_e4m3", 1) +R4D_WIN_C(cAnchorH256G2Bf16, 256, 2, "bf16", 1) R4D_WIN_C(cAnchorH256G2Fp8, 256, 2, "fp8_e4m3", 1) +R4D_WIN_C(cAnchorH256G4Bf16, 256, 4, "bf16", 1) R4D_WIN_C(cAnchorH256G4Fp8, 256, 4, "fp8_e4m3", 1) +R4D_WIN_C(cAnchorH256G8Bf16, 256, 8, "bf16", 1) R4D_WIN_C(cAnchorH256G8Fp8, 256, 8, "fp8_e4m3", 1) +R4D_WIN_C(cAnchorH512G1Bf16, 512, 1, "bf16", 1) R4D_WIN_C(cAnchorH512G1Fp8, 512, 1, "fp8_e4m3", 1) +R4D_WIN_C(cAnchorH512G2Bf16, 512, 2, "bf16", 1) R4D_WIN_C(cAnchorH512G2Fp8, 512, 2, "fp8_e4m3", 1) +R4D_WIN_C(cAnchorH512G4Bf16, 512, 4, "bf16", 1) R4D_WIN_C(cAnchorH512G4Fp8, 512, 4, "fp8_e4m3", 1) +R4D_WIN_C(cAnchorH512G8Bf16, 512, 8, "bf16", 1) R4D_WIN_C(cAnchorH512G8Fp8, 512, 8, "fp8_e4m3", 1) +R4D_WIN_C(cWinH512G16Bf16, 512, 16, "bf16", 0) R4D_WIN_C(cWinH512G16Fp8, 512, 16, "fp8_e4m3", 0) #undef R4D_WIN_C +/* The open-ended window (attn_paged_ahead): non-causal, a window of at least one. */ +#define R4D_WIN_AHEAD_C(NAME, HD, G, KV) \ + static const RadConstraint NAME[] = { \ + C_EQ("head_dim", HD), C_EQ("gqa", G), C_EQ("block_size", 16), C_EQ("causal", 0), \ + C_GE("window", 1), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", KV), \ + }; +R4D_WIN_AHEAD_C(cWinAheadH256G1Bf16, 256, 1, "bf16") R4D_WIN_AHEAD_C(cWinAheadH256G1Fp8, 256, 1, "fp8_e4m3") +R4D_WIN_AHEAD_C(cWinAheadH256G2Bf16, 256, 2, "bf16") R4D_WIN_AHEAD_C(cWinAheadH256G2Fp8, 256, 2, "fp8_e4m3") +R4D_WIN_AHEAD_C(cWinAheadH256G4Bf16, 256, 4, "bf16") R4D_WIN_AHEAD_C(cWinAheadH256G4Fp8, 256, 4, "fp8_e4m3") +R4D_WIN_AHEAD_C(cWinAheadH256G8Bf16, 256, 8, "bf16") R4D_WIN_AHEAD_C(cWinAheadH256G8Fp8, 256, 8, "fp8_e4m3") +#undef R4D_WIN_AHEAD_C /* Twelve queries per KV head, head_dim 256 (r4d_attn_paged_h256_gqa12.hip): Qwen3.8-Flash-Next's * QSA layers, 24 query heads over 2. `q_len <= 5` is the same `q_len * gqa <= 64` bound, tighter * than the legal speculation depths: a depth-7 verify (q_len 8) takes the prefill kernel, which @@ -4365,6 +4632,24 @@ static const RadConstraint cAttnDecodeH128G2Bf16[] = { C_EQ("window", 0), C_EQ("head_dim", 128), C_EQ("gqa", 2), C_EQ("block_size", 16), C_GE("causal", 0), C_LE("q_len", 32), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", "bf16"), }; +/* Sixteen queries per KV head at head_dim 128 (Nemotron-H's 32 over 2): q_len <= 8 at decode, eight + * waves, so a verify of LiLiCorr's 7 drafts runs the decode kernel a plain decode runs. */ +static const RadConstraint cAttnPrefillH128G16Fp8[] = { + C_EQ("window", 0), C_EQ("head_dim", 128), C_EQ("gqa", 16), C_EQ("block_size", 16), + C_EQ("causal", 1), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", "fp8_e4m3"), +}; +static const RadConstraint cAttnPrefillH128G16Bf16[] = { + C_EQ("window", 0), C_EQ("head_dim", 128), C_EQ("gqa", 16), C_EQ("block_size", 16), + C_EQ("causal", 1), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", "bf16"), +}; +static const RadConstraint cAttnDecodeH128G16Fp8[] = { + C_EQ("window", 0), C_EQ("head_dim", 128), C_EQ("gqa", 16), C_EQ("block_size", 16), + C_GE("causal", 0), C_LE("q_len", 8), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", "fp8_e4m3"), +}; +static const RadConstraint cAttnDecodeH128G16Bf16[] = { + C_EQ("window", 0), C_EQ("head_dim", 128), C_EQ("gqa", 16), C_EQ("block_size", 16), + C_GE("causal", 0), C_LE("q_len", 8), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", "bf16"), +}; /* Key rename: libr4d writes C_IN("q_dtype","bf16") and C_IN("kv_dtype","bf16"); docs/OPS.md's * `attn_dense` has one `dtype`. The predicate is unchanged. * @@ -4414,6 +4699,10 @@ static const RadConstraint cCastNarrow[] = { static const RadConstraint cAttnDenseH64[] = { C_EQ("head_dim", 64), C_EQ("gqa", 1), C_IN("dtype", "bf16"), }; +/* head_dim 80 without GQA: C-RADIO's ViT heads (Nemotron-3.5-Bolt's vision tower), bidirectional. */ +static const RadConstraint cAttnDenseH80[] = { + C_EQ("head_dim", 80), C_EQ("gqa", 1), C_IN("dtype", "bf16"), +}; /* head_dim 256 without GQA, sequences past the small kernel's. */ static const RadConstraint cAttnDenseH256G1[] = { C_EQ("head_dim", 256), C_EQ("gqa", 1), C_GE("max_seqlen", 33), C_IN("dtype", "bf16"), @@ -4591,6 +4880,10 @@ static const RadConstraint cDflashSelect[] = { C_GE("steps", 1), C_GE("top_k", 1), C_LE("top_k", 32), C_DIV("rank", 32), C_LE("rank", 512), C_IN("dtype", "bf16"), }; +static const RadConstraint cDflashMarkov[] = { + C_GE("steps", 1), C_DIV("rank", 32), C_LE("rank", 512), + C_GE("n_vocab", 1), C_IN("dtype", "bf16"), +}; /* dflash_tree's frontier (nodes x top_k children) and its node table live in LDS. */ static const RadConstraint cDflashTree[] = { C_GE("steps", 1), C_LE("steps", 63), C_GE("top_k", 1), C_LE("top_k", 32), @@ -4609,6 +4902,14 @@ static const RadConstraint cNormJoinRoute[] = { static const RadConstraint cPairArgmax[] = { C_GE("n", 1), C_IN("dtype", "f32 fp32"), }; +static const RadConstraint cLiliCand[] = { + C_GE("k", 2), C_LE("k", 64), C_GE("world", 1), C_LE("world", 16), C_IN("dtype", "bf16"), +}; +static const RadConstraint cLiliAttn[] = { + C_GE("head_dim", 1), C_LE("head_dim", 128), C_IN("dtype", "bf16"), +}; +static const RadConstraint cLiliFactor[] = { C_IN("dtype", "bf16") }; +static const RadConstraint cLiliWalk[] = { C_GE("k", 1), C_LE("k", 64), C_IN("dtype", "bf16") }; static const RadConstraint cExpertScale[] = { C_GE("top_k", 1), C_LE("top_k", 64), C_GE("n_expert", 1), C_IN("dtype", "bf16"), }; @@ -4686,6 +4987,13 @@ static const RadConstraint cKdaUpdate[] = { C_EQ("head_k", 128), C_EQ("head_v", 128), C_IN("mode", "prefill verify"), C_IN("dtype", "bf16"), }; +/* Mamba-2 at a 128-wide state (four registers a lane) and heads in rows of 16 (four waves of four + * rows): Nemotron-H's 64. */ +static const RadConstraint cSsdUpdate[] = { + C_GE("M", 1), C_GE("heads", 1), C_LE("heads", 65535), + C_EQ("d_state", 128), C_GE("head_dim", 16), C_LE("head_dim", 256), + C_DIV("head_dim", 16), C_IN("mode", "prefill verify"), C_IN("dtype", "bf16"), +}; static const RadConstraint cMhcPre[] = { C_GE("M", 1), C_LE("M", 65535), C_GE("n", 1), C_LE("n", 16384), C_GE("hc", 2), C_LE("hc", 8), @@ -4711,11 +5019,16 @@ static const RadConstraint cMlaAttn[] = { C_GE("M", 1), C_LE("M", 65535), C_EQ("latent_dim", 512), C_GE("heads", 1), C_LE("heads", 64), C_GE("blocks", 1), C_EQ("block_size", 4), C_IN("dtype", "bf16") }; +static const RadConstraint cMlaAttnPaged[] = { + C_GE("M", 1), C_LE("M", 65535), C_EQ("latent_dim", 512), C_EQ("rope_dim", 64), + C_GE("heads", 1), C_LE("heads", 64), C_GE("block_size", 1), C_LE("block_size", 256), + C_IN("dtype", "bf16") +}; static const RadConstraint cMlaProject[] = { C_GE("M", 1), C_LE("M", 65535), C_GE("heads", 1), C_LE("heads", 64), - C_EQ("head_dim", 256), + C_IN("head_dim", "128 256"), C_EQ("latent_dim", 512), C_IN("mode", "absorb expand"), C_IN("dtype", "bf16") }; @@ -4742,6 +5055,29 @@ static const RadConstraint cMlaRows[] = { C_GE("M", 1), C_LE("M", 65535) C_EQ("latent_dim", 512), C_EQ("heads", 64), C_GE("blocks", 1), C_EQ("block_size", 4), C_IN("dtype", "bf16") }; +/* The three rows over an E4M3 latent cache: each bf16 row's constraints and kv_dtype fp8_e4m3, + * ranked above all three bf16 rows (which state no kv_dtype and would otherwise also match), in + * the bf16 rows' order among themselves. The kernels are the bf16 rows' with the key load + * decoding E4M3 (r4d_mla.hip). */ +static const RadConstraint cMlaAttnFp8[] = { + C_GE("M", 1), C_LE("M", 65535), C_EQ("latent_dim", 512), C_GE("heads", 1), + C_LE("heads", 64), C_GE("blocks", 1), C_EQ("block_size", 4), C_IN("dtype", "bf16"), + C_IN("kv_dtype", "fp8_e4m3") +}; +static const RadConstraint cMlaMatrixFp8[] = { C_GE("M", 1), + C_LE("M", 65535), + C_EQ("latent_dim", 512), + C_GE("heads", 8), + C_LE("heads", 64), + C_DIV("heads", 8), + C_GE("blocks", 1), + C_EQ("block_size", 4), + C_IN("dtype", "bf16"), + C_IN("kv_dtype", "fp8_e4m3") }; +static const RadConstraint cMlaRowsFp8[] = { C_GE("M", 1), C_LE("M", 65535), + C_EQ("latent_dim", 512), C_EQ("heads", 64), + C_GE("blocks", 1), C_EQ("block_size", 4), + C_IN("dtype", "bf16"), C_IN("kv_dtype", "fp8_e4m3") }; /* `n` is bounded by LDS: nh (hc*n) and ne (n) are both bf16 and live through the second phase; * 28672 elements is that budget at hc 4. */ static const RadConstraint cMtpEnter[] = { @@ -4765,6 +5101,11 @@ static const RadConstraint cRouterSigmoid[] = { C_GE("M", 1), C_LE("M", 6 C_GE("n_expert", 1), C_LE("n_expert", 512), C_GE("top_k", 1), C_LE("top_k", 32), C_IN("dtype", "f32") }; +static const RadConstraint cRouterSigmoidGroup[] = { C_GE("M", 1), C_LE("M", 65535), + C_GE("n_expert", 1), C_LE("n_expert", 512), + C_GE("top_k", 1), C_LE("top_k", 32), + C_GE("n_group", 1), C_LE("n_group", 32), + C_IN("dtype", "f32") }; /* The sort's single-workgroup form bounds M * top_k at 1024, which the shim checks. */ static const RadConstraint cRouterSigmoidScatter[] = { C_GE("M", 1), C_LE("M", 1024), C_GE("n_expert", 1), C_LE("n_expert", 512), @@ -4935,6 +5276,12 @@ static const RadConstraint cGemmNtIqrM64[] = { C_LE("M", 64), C_DIV("K", 256), C_DIV("N", 16), C_EQ("group", R4D_FP8_BLOCK), C_IN("dtype", "i8a8 i8a8h"), }; +/* The gated fold over an IQR gate_up weight, to the 16-token tile's band: the gated width a whole + * number of 128-column groups, silu only (gated_had_quant_i8g's mode the fold compiles). */ +static const RadConstraint cGemmNtQGatedIqr[] = { + C_LE("M", 16), C_DIV("K", 256), C_DIV("N", 256), C_EQ("group", R4D_FP8_BLOCK), + C_IN("dtype", "i8a8h"), C_IN("act", "silu"), +}; static const RadConstraint cGemmNtIqrTiled[] = { C_DIV("K", 256), C_DIV("N", R4D_FP8_BLOCK), C_EQ("group", R4D_FP8_BLOCK), C_IN("dtype", "i8a8 i8a8h"), @@ -4993,7 +5340,7 @@ static const RadConstraint cQsaBlockKey[] = { * `n` a multiple of 4 is the staging slot (one dword of four codes); the 64-wide C tile masks a * ragged tile. */ static const RadConstraint cGramAccum[] = { - C_DIV("n", 4), C_EQ("group", R4D_FP8_BLOCK), C_IN("dtype", "fp8a8"), + C_DIV("n", 4), C_EQ("group", R4D_FP8_BLOCK), C_IN("dtype", "fp8a8 i8a8"), }; /* The bf16 form has no scale grid, so `group` constrains nothing; the staging slot is four * elements of a row. */ @@ -5099,6 +5446,10 @@ static const RadConstraint cGemmNtQGatedMxWide[] = { C_GE("M", 9), C_LE("M", 64), C_DIV("K", 128), C_GE("K", 2688), C_DIV("N", 256), C_EQ("group", 32), C_IN("dtype", "mxfp4a8"), C_IN("act", "silu gelu_tanh"), }; +/* The rotated form: whole 128-column groups (a rotation block cannot straddle a row's end). */ +static const RadConstraint cGateHadQuantI8g[] = { + C_DIV("n", R4D_FP8_BLOCK), C_EQ("group", R4D_FP8_BLOCK), C_IN("dtype", "bf16"), +}; static const RadConstraint cGateQuantFp8[] = { C_DIV("n", 4), C_EQ("group", R4D_FP8_BLOCK), C_IN("dtype", "bf16"), }; @@ -5601,6 +5952,7 @@ static const RadConstraint cLogitsGemmCols[] = { C_EQ("n_embd", 4096), C_IN("dty * 2560 the row would win selection and then fail at layout with no fallback. r4d_fp8_lm.h pads the * stored row to 16 bytes instead (under 0.3% at K = 2560), so every multiple of 128 is served. */ static const RadConstraint cLogitsGemmFp8[] = { C_DIV("n_embd", 128), C_IN("dtype", "bf16") }; +static const RadConstraint cLogitsVocab[] = { C_DIV("n_embd", 256), C_IN("dtype", "bf16") }; /* No tunable axes. */ #define NOTUNE nullptr, 0, nullptr @@ -5784,6 +6136,14 @@ static const RadKernelInfo kKernels[] = { ROW(cPleConv), NOTUNE, nullptr, nullptr, r4d_rad_ple_conv }, +{ "ple_conv_bias_bf16", "ple_conv_bias", "norm", + "ple_conv with a per-channel bias inside the silu (Mamba-2's conv1d); one thread a channel", + "width up to 5 and dilation up to 4 -- (width-1)*dilation is a register window", + "bf16 activations, weights, bias and conv state; i32 cu, slots, has_init and num_accepted", + RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, + ROW(cPleConv), NOTUNE, + nullptr, nullptr, r4d_rad_ple_conv_bias }, + { "causal_conv1d_bf16", "causal_conv1d", "conv", "depthwise causal conv with no activation (ple_conv's kernel); one thread a channel", "width 2 to 8, undilated", @@ -6047,6 +6407,15 @@ static const RadKernelInfo kKernels[] = { ROW(cBf16Row), NOTUNE, nullptr, nullptr, r4d_rad_pool_cols }, +{ "point_fourier_f32", "point_fourier", "elem", + "a point's Fourier features: x, then its sines and cosines at octaves (a shape decoder's query " + "embedding)", + "any n and freqs up to 30; a thread an output column", + "f32 in and out, the device's sinf and cosf", + RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, + ROW(cF32Row), NOTUNE, + nullptr, nullptr, r4d_rad_point_fourier }, + { "rmsnorm_bf16", "rmsnorm", "norm", "root-mean-square norm with a gain, two passes over the row", "any n; the sum of squares accumulates in f32 and only the store narrows", @@ -6104,6 +6473,15 @@ static const RadKernelInfo kKernels[] = { nullptr, nullptr, r4d_rad_grid_embed_aa, nullptr, nullptr, nullptr, r4d_shape_grid_embed }, +{ "grid_embed_cpe_bf16", "grid_embed_cpe", "elem", + "a learned position grid resampled half-pixel bilinear onto a square and cropped (RADIO's CPE)", + "any n and side; coord [4, M] dense; one workgroup a row", + "bf16 x, bf16 or f32 table, i32 coord, f32 taps", + RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, + ROW(cGridEmbed), NOTUNE, + nullptr, nullptr, r4d_rad_grid_embed_cpe, nullptr, nullptr, nullptr, + r4d_shape_grid_embed_cpe }, + { "gemm_bf16_nt_bias_tiled", "gemm_nt_bias", "gemm", "biased GEMM C = res + act(A @ W^T + bias) over 64-deep K tiles, the K tail staged as zeros, " "the activation and residual in the store: from 32 blocks of 128x128 the weight read straight " @@ -6244,6 +6622,27 @@ static const RadKernelInfo kKernels[] = { RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, ROW(cMlaAttn), NOTUNE, nullptr, nullptr, r4d_rad_mla_attn, r4d_rad_mla_attn_scratch, nullptr, nullptr, r4d_shape_mla_attn }, +{ "mla_attn_rows_fp8kv", "mla_attn", "attn", + "mla_attn_rows_bf16 over an E4M3 latent cache, each key decoded exactly to bf16 at the load", + "latent_dim=512, heads=64, block_size=4", + "bf16 Q/output, fp8-e4m3 cache at descale 1; FP32 probabilities via high/low BF16", + RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY + 5, ROW(cMlaRowsFp8), NOTUNE, + nullptr, nullptr, r4d_rad_mla_attn_rows_fp8kv, r4d_rad_mla_attn_matrix_scratch, nullptr, + nullptr, r4d_shape_mla_attn }, +{ "mla_attn_matrix_fp8kv", "mla_attn", "attn", + "mla_attn_matrix_bf16 over an E4M3 latent cache, each key decoded exactly to bf16 at the load", + "latent_dim=512, heads a multiple of 8 (heads%16==8 pairs two requests a tile), block_size=4", + "bf16 Q/output, fp8-e4m3 cache at descale 1; FP32 probabilities via high/low BF16", + RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY + 4, ROW(cMlaMatrixFp8), NOTUNE, + nullptr, nullptr, r4d_rad_mla_attn_matrix_fp8kv, r4d_rad_mla_attn_matrix_scratch, nullptr, + nullptr, r4d_shape_mla_attn }, +{ "mla_attn_fp8kv", "mla_attn", "attn", + "mla_attn_bf16 over an E4M3 latent cache, each key decoded exactly at the load", + "latent_dim=512, heads<=64, block_size=4", + "bf16 Q/output, fp8-e4m3 cache at descale 1, f32 softmax and partials", + RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY + 3, ROW(cMlaAttnFp8), NOTUNE, + nullptr, nullptr, r4d_rad_mla_attn_fp8kv, r4d_rad_mla_attn_scratch, nullptr, nullptr, + r4d_shape_mla_attn }, { "gemm_fp8a8_f32scale", "gemm_nt_q", "gemm", "FP8 WMMA with canonical F32 block scales", "N and K multiples of 128; pitched activations and row-major weights", "E4M3 codes, F32 scales, BF16 output", RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, ROW(cFp8F32Scale), NOTUNE, @@ -6259,8 +6658,15 @@ static const RadKernelInfo kKernels[] = { RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, ROW(cDsaScore), NOTUNE, nullptr, nullptr, r4d_rad_dsa_score, nullptr, nullptr, nullptr, r4d_shape_dsa_score }, +{ "mla_attn_paged_bf16", "mla_attn_paged", "attn", + "dense causal latent attention with a rotary part, a wave a (row, head), split history", + "latent_dim=512, rope_dim=64, heads<=64, block_size<=256; one page table a sequence", + "bf16 Q/rotary/cache/gate/output, f32 softmax and partials", + RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, ROW(cMlaAttnPaged), NOTUNE, + nullptr, nullptr, r4d_rad_mla_attn_paged, r4d_rad_mla_attn_paged_scratch, nullptr, nullptr, + r4d_shape_mla_attn_paged }, { "mla_project_bf16", "mla_project", "attn", "per-head absorbed MLA projections", - "head_dim=256, latent_dim=512; pitched tensors", "bf16 input, weights and output; fp32 arithmetic", + "head_dim 128 or 256, latent_dim=512; pitched tensors", "bf16 input, weights and output; fp32 arithmetic", RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, ROW(cMlaProject), NOTUNE, nullptr, nullptr, r4d_rad_mla_project, nullptr, nullptr, nullptr, r4d_shape_mla_project }, @@ -6279,6 +6685,12 @@ static const RadKernelInfo kKernels[] = { RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, ROW(cDsaPool), NOTUNE, nullptr, nullptr, r4d_rad_dsa_pool, nullptr, nullptr, nullptr, r4d_shape_dsa_pool }, +{ "swiglu_step_bf16", "swiglu_step", "elem", + "SwiGLU clipped after the SiLU", "positive finite limit; pitched rows", + "bf16 in and out, fp32 arithmetic", RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, + ROW(cBf16Row), NOTUNE, + nullptr, nullptr, r4d_rad_swiglu_step, nullptr, nullptr, nullptr, + r4d_shape_silu_mul }, { "swiglu_clamped_bf16", "swiglu_clamped", "elem", "asymmetrically clipped SwiGLU", "positive finite limit; pitched rows", "bf16 in and out, fp32 arithmetic", RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, @@ -6450,6 +6862,21 @@ static const RadKernelInfo kKernels[] = { r4d_rad_layout_i8_logits, r4d_rad_relayout_i8_logits, nullptr, r4d_rad_unrelayout_i8_logits }, +{ "logits_gemm_vocab_iqr", "logits_gemm_vocab", "vocab", + "the vocabulary-weighted IQR head in one launch over every class: each block decodes its " + "class's computed-trellis codes (the class's width) into int8 fragments through LDS and runs " + "two int8 WMMA passes against the rotated activation's sixteen bits (hi and lo planes); up to 32 " + "tokens into a staging plane in row order gathered through vrow, above that at each row's id", + "any M (64 tokens a pass); n_embd a multiple of 256; each class a multiple of 256 rows", + "bf16 x, rotated by fwht128 and quantised to 16 bits a (token, 128) in the call's scratch; " + "classes of tcq_code=mad codes (2 to 7 bits, runs of 256 rows) under one f32 scale a row; F32 " + "LOGITS OUT, int32 block sums folded in fp32", + RAD_DOMAIN_DEVICE, R4D_PRIO_LOGITS_FP8, + ROW(cLogitsVocab), NOTUNE, + nullptr, nullptr, r4d_rad_logits_gemm_vocab, r4d_rad_logits_gemm_vocab_scratch, + r4d_rad_layout_iqr_vocab, r4d_rad_relayout_iqr_vocab, + nullptr, r4d_rad_unrelayout_iqr_vocab }, + { "logits_gemm_iqr", "logits_gemm", "vocab", "logits_gemm_i8 over an IQR head kept at its codes' width: each lane's sixteen codes read at " "their width and looked up in the head's table by byte permutes, then the int8 head's matvec " @@ -6625,7 +7052,7 @@ static const RadKernelInfo kKernels[] = { ROW(cAttnPrefillFp8), NOTUNE, nullptr, nullptr, r4d_rad_attn_prefill_h256_fp8, r4d_rad_attn_prefill_h256_scratch, nullptr, nullptr, - r4d_shape_attn_paged }, + r4d_shape_attn_paged, nullptr, nullptr, RAD_KERNEL_CAP_DYNAMIC_PREFILL_SPLIT }, /* Lossy: they match only a caller whose `prefill_fp8` accepts their legs. */ { "attn_prefill_h256_gqa6_fp8kv_qk8", "attn_paged", "attn", @@ -6666,7 +7093,7 @@ static const RadKernelInfo kKernels[] = { ROW(cAttnPrefillFp8v4), NOTUNE, nullptr, nullptr, r4d_rad_attn_prefill_h256_fp8v4, r4d_rad_attn_prefill_h256_v4_scratch, nullptr, nullptr, - nullptr }, + nullptr, nullptr, nullptr, RAD_KERNEL_CAP_DYNAMIC_PREFILL_SPLIT }, { "attn_prefill_h256_gqa6_fp8v4_qk8", "attn_paged", "attn", "paged causal attention, query-tiled (prefill / chunked prefill), Q.K^T as e4m3 WMMA", @@ -6709,7 +7136,7 @@ static const RadKernelInfo kKernels[] = { ROW(cAttnPrefillK6v4), NOTUNE, nullptr, nullptr, r4d_rad_attn_prefill_h256_k6v4, r4d_rad_attn_prefill_h256_k6_scratch, nullptr, nullptr, - nullptr }, + nullptr, nullptr, nullptr, RAD_KERNEL_CAP_DYNAMIC_PREFILL_SPLIT }, { "attn_prefill_h256_gqa6_k6v4_qk8", "attn_paged", "attn", "paged causal attention, query-tiled (prefill / chunked prefill), Q.K^T as e4m3 WMMA", @@ -6752,7 +7179,7 @@ static const RadKernelInfo kKernels[] = { ROW(cAttnPrefillBf16), NOTUNE, nullptr, nullptr, r4d_rad_attn_prefill_h256_bf16, r4d_rad_attn_prefill_h256_scratch, nullptr, nullptr, - r4d_shape_attn_paged }, + r4d_shape_attn_paged, nullptr, nullptr, RAD_KERNEL_CAP_DYNAMIC_PREFILL_SPLIT }, { "attn_decode_h256_gqa6_fp8kv", "attn_paged", "attn", "paged causal attention, split-KV (decode / speculative verify)", @@ -6825,7 +7252,7 @@ static const RadKernelInfo kKernels[] = { ROW(cAttnPrefillH256Gqa2Fp8), NOTUNE, nullptr, nullptr, r4d_rad_attn_prefill_h256_gqa2_fp8, r4d_rad_attn_prefill_h256_gqa2_scratch, nullptr, nullptr, - r4d_shape_attn_paged }, + r4d_shape_attn_paged, nullptr, nullptr, RAD_KERNEL_CAP_DYNAMIC_PREFILL_SPLIT }, { "attn_prefill_h256_gqa2_bf16kv", "attn_paged", "attn", "paged causal attention with a sliding window, query-tiled (prefill / chunked prefill)", @@ -6836,7 +7263,7 @@ static const RadKernelInfo kKernels[] = { ROW(cAttnPrefillH256Gqa2Bf16), NOTUNE, nullptr, nullptr, r4d_rad_attn_prefill_h256_gqa2_bf16, r4d_rad_attn_prefill_h256_gqa2_scratch, nullptr, nullptr, - r4d_shape_attn_paged }, + r4d_shape_attn_paged, nullptr, nullptr, RAD_KERNEL_CAP_DYNAMIC_PREFILL_SPLIT }, { "attn_decode_h256_gqa2_fp8kv", "attn_paged", "attn", "paged causal attention with a sliding window, split-KV (decode / verify)", @@ -7014,7 +7441,7 @@ static const RadKernelInfo kKernels[] = { ROW(cAttnPrefillH256G8Fp8), NOTUNE, nullptr, nullptr, r4d_rad_attn_prefill_h256_gqa8_fp8, r4d_rad_attn_prefill_h256_gqa8_scratch, nullptr, nullptr, - r4d_shape_attn_paged }, + r4d_shape_attn_paged, nullptr, nullptr, RAD_KERNEL_CAP_DYNAMIC_PREFILL_SPLIT }, { "attn_prefill_h256_gqa8_bf16kv", "attn_paged", "attn", "paged causal attention, query-tiled (prefill / chunked prefill)", @@ -7024,7 +7451,7 @@ static const RadKernelInfo kKernels[] = { ROW(cAttnPrefillH256G8Bf16), NOTUNE, nullptr, nullptr, r4d_rad_attn_prefill_h256_gqa8_bf16, r4d_rad_attn_prefill_h256_gqa8_scratch, nullptr, nullptr, - r4d_shape_attn_paged }, + r4d_shape_attn_paged, nullptr, nullptr, RAD_KERNEL_CAP_DYNAMIC_PREFILL_SPLIT }, { "attn_decode_h256_gqa8_fp8kv", "attn_paged", "attn", "paged attention, causal or not, split-KV (decode / speculative verify / draft block)", @@ -7054,7 +7481,7 @@ static const RadKernelInfo kKernels[] = { ROW(cAttnPrefillH256G4Fp8), NOTUNE, nullptr, nullptr, r4d_rad_attn_prefill_h256_gqa4_fp8, r4d_rad_attn_prefill_h256_gqa4_scratch, nullptr, nullptr, - r4d_shape_attn_paged }, + r4d_shape_attn_paged, nullptr, nullptr, RAD_KERNEL_CAP_DYNAMIC_PREFILL_SPLIT }, { "attn_prefill_h256_gqa4_bf16kv", "attn_paged", "attn", "paged causal attention, query-tiled (prefill / chunked prefill)", @@ -7064,7 +7491,7 @@ static const RadKernelInfo kKernels[] = { ROW(cAttnPrefillH256G4Bf16), NOTUNE, nullptr, nullptr, r4d_rad_attn_prefill_h256_gqa4_bf16, r4d_rad_attn_prefill_h256_gqa4_scratch, nullptr, nullptr, - r4d_shape_attn_paged }, + r4d_shape_attn_paged, nullptr, nullptr, RAD_KERNEL_CAP_DYNAMIC_PREFILL_SPLIT }, { "attn_decode_h256_gqa4_fp8kv", "attn_paged", "attn", "paged attention, causal or not, split-KV (decode / speculative verify / draft block)", @@ -7133,8 +7560,76 @@ static const RadKernelInfo kKernels[] = { R4D_WIN_PAIR(128, 1) R4D_WIN_PAIR(256, 1) R4D_WIN_PAIR(256, 2) R4D_WIN_PAIR(256, 4) R4D_WIN_PAIR(256, 8) R4D_WIN_PAIR(512, 1) R4D_WIN_PAIR(512, 2) R4D_WIN_PAIR(512, 4) R4D_WIN_PAIR(512, 8) +R4D_WIN_PAIR(512, 16) #undef R4D_WIN_PAIR #undef R4D_WIN_ROW +/* attn_paged_sink: the windowed kernels with the sink folded in (LiLiCorr's drafter, h128 at gqa 16 + * to TP 2, gqa 8 at TP 4). */ +#define R4D_WINSINK_ROW(HD, G, KVN, KVS, C, KVDOC) \ +{ "attn_window_sink_h" #HD "_gqa" #G "_" #KVN, "attn_paged_sink", "attn", \ + "paged attention with a sink logit a head, any window, causal or not; split-KV with a merge", \ + "head_dim " #HD ", " #G " queries per kv head, paged block 16, any q_len, varlen", \ + "bf16 query, " KVDOC " kv cache, f32 sinks, bf16 out, f32 partials", \ + RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, \ + ROW(C), NOTUNE, \ + nullptr, nullptr, r4d_rad_attn_window_sink_h##HD##_gqa##G##_##KVS, \ + r4d_rad_attn_window_h##HD##_scratch, \ + nullptr, nullptr, \ + r4d_shape_attn_paged_sink }, +R4D_WINSINK_ROW(128, 8, bf16kv, bf16, cWinH128G8Bf16, "bf16") +R4D_WINSINK_ROW(128, 8, fp8kv, fp8, cWinH128G8Fp8, "fp8-e4m3 (per-(seq,head) descales)") +R4D_WINSINK_ROW(128, 16, bf16kv, bf16, cWinH128G16Bf16, "bf16") +R4D_WINSINK_ROW(128, 16, fp8kv, fp8, cWinH128G16Fp8, "fp8-e4m3 (per-(seq,head) descales)") +#undef R4D_WINSINK_ROW + +/* DSpark's shared-anchor mask is intentionally a distinct op/kernel family, not an accepted + * `window` variation of attn_paged's per-query visibility. Its base/upper key bounds are tied to + * the sequence's first query row. */ +#define R4D_ANCHOR_ROW(HD, G, KVN, KVS, C, KVDOC) \ +{ "attn_anchor_window_h" #HD "_gqa" #G "_" #KVN, "attn_paged_anchor_window", "attn", \ + "paged attention with the first query row as the shared sliding-window anchor", \ + "head_dim " #HD ", " #G " queries per kv head, paged block 16, any q_len, varlen", \ + "bf16 query, " KVDOC " kv cache, bf16 out, f32 partials", \ + RAD_DOMAIN_DEVICE, R4D_PRIO_ATTN_WINDOW, \ + ROW(C), NOTUNE, \ + nullptr, nullptr, r4d_rad_attn_anchor_window_h##HD##_gqa##G##_##KVS, \ + r4d_rad_attn_window_h##HD##_scratch, nullptr, nullptr, r4d_shape_attn_paged }, +#define R4D_ANCHOR_PAIR(HD, GQ) \ + R4D_ANCHOR_ROW(HD, GQ, bf16kv, bf16kv, cAnchorH##HD##G##GQ##Bf16, "bf16") \ + R4D_ANCHOR_ROW(HD, GQ, fp8kv, fp8kv, cAnchorH##HD##G##GQ##Fp8, "fp8-e4m3 (per-(seq,head) descales)") +R4D_ANCHOR_PAIR(128, 1) +R4D_ANCHOR_PAIR(256, 1) R4D_ANCHOR_PAIR(256, 2) R4D_ANCHOR_PAIR(256, 4) R4D_ANCHOR_PAIR(256, 8) +R4D_ANCHOR_PAIR(512, 1) R4D_ANCHOR_PAIR(512, 2) R4D_ANCHOR_PAIR(512, 4) R4D_ANCHOR_PAIR(512, 8) +#undef R4D_ANCHOR_PAIR +#undef R4D_ANCHOR_ROW +/* ...and the same kernels under attn_paged_ahead and attn_paged_qrow_ahead, where the window + * bounds the keys behind only. */ +#define R4D_WIN_AHEAD_ROW(HD, G, KVN, KVS, C, KVDOC) \ +{ "attn_ahead_h" #HD "_gqa" #G "_" #KVN, "attn_paged_ahead", "attn", \ + "paged attention, non-causal, a window over the keys behind only", \ + "head_dim " #HD ", " #G " queries per kv head, paged block 16, any q_len, varlen", \ + "bf16 query, " KVDOC " kv cache, bf16 out, f32 partials", \ + RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, \ + ROW(C), NOTUNE, \ + nullptr, nullptr, r4d_rad_attn_window_ahead_h##HD##_gqa##G##_##KVS, \ + r4d_rad_attn_window_h##HD##_scratch, \ + nullptr, nullptr, nullptr }, \ +{ "attn_qrow_ahead_h" #HD "_gqa" #G "_" #KVN, "attn_paged_qrow_ahead", "attn", \ + "paged attention reading q at its own row pitch, non-causal, a window over the keys behind only", \ + "head_dim " #HD ", " #G " queries per kv head, paged block 16, any q_len, varlen", \ + "bf16 query (any row pitch), " KVDOC " kv cache, bf16 out, f32 partials", \ + RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, \ + ROW(C), NOTUNE, \ + nullptr, nullptr, r4d_rad_attn_window_ahead_h##HD##_gqa##G##_##KVS, \ + r4d_rad_attn_window_h##HD##_scratch, \ + nullptr, nullptr, nullptr }, +#define R4D_WIN_AHEAD_PAIR(HD, GQ) \ + R4D_WIN_AHEAD_ROW(HD, GQ, bf16kv, bf16, cWinAheadH##HD##G##GQ##Bf16, "bf16") \ + R4D_WIN_AHEAD_ROW(HD, GQ, fp8kv, fp8, cWinAheadH##HD##G##GQ##Fp8, "fp8-e4m3 (per-(seq,head) descales)") +R4D_WIN_AHEAD_PAIR(256, 1) R4D_WIN_AHEAD_PAIR(256, 2) R4D_WIN_AHEAD_PAIR(256, 4) +R4D_WIN_AHEAD_PAIR(256, 8) +#undef R4D_WIN_AHEAD_PAIR +#undef R4D_WIN_AHEAD_ROW /* ...and under attn_paged_qrow_tree, the scalar kernel with a tree verify's mask (the launch * refuses a non-causal one and never takes the WMMA kernel). */ @@ -7165,7 +7660,7 @@ R4D_WIN_TREE_PAIR(512, 4) R4D_WIN_TREE_PAIR(512, 8) ROW(cAttnPrefillH256G12Fp8), NOTUNE, nullptr, nullptr, r4d_rad_attn_prefill_h256_gqa12_fp8, r4d_rad_attn_prefill_h256_gqa12_scratch, nullptr, nullptr, - r4d_shape_attn_paged }, + r4d_shape_attn_paged, nullptr, nullptr, RAD_KERNEL_CAP_DYNAMIC_PREFILL_SPLIT }, { "attn_prefill_h256_gqa12_bf16kv", "attn_paged", "attn", "paged causal attention, query-tiled (prefill / chunked prefill)", @@ -7175,7 +7670,7 @@ R4D_WIN_TREE_PAIR(512, 4) R4D_WIN_TREE_PAIR(512, 8) ROW(cAttnPrefillH256G12Bf16), NOTUNE, nullptr, nullptr, r4d_rad_attn_prefill_h256_gqa12_bf16, r4d_rad_attn_prefill_h256_gqa12_scratch, nullptr, nullptr, - r4d_shape_attn_paged }, + r4d_shape_attn_paged, nullptr, nullptr, RAD_KERNEL_CAP_DYNAMIC_PREFILL_SPLIT }, { "attn_decode_h256_gqa12_fp8kv", "attn_paged", "attn", "paged attention, causal or not, split-KV (decode / speculative verify / draft block)", @@ -7233,7 +7728,7 @@ R4D_WIN_TREE_PAIR(512, 4) R4D_WIN_TREE_PAIR(512, 8) ROW(cAttnPrefillH256G6Bs4Fp8), NOTUNE, nullptr, nullptr, r4d_rad_attn_prefill_h256_gqa6_fp8, r4d_rad_attn_prefill_h256_gqa6_scratch, nullptr, nullptr, - r4d_shape_attn_paged }, + r4d_shape_attn_paged, nullptr, nullptr, RAD_KERNEL_CAP_DYNAMIC_PREFILL_SPLIT }, { "attn_prefill_h256_gqa6_bs4_bf16kv", "attn_paged", "attn", "paged causal attention, query-tiled (prefill / chunked prefill)", @@ -7243,7 +7738,7 @@ R4D_WIN_TREE_PAIR(512, 4) R4D_WIN_TREE_PAIR(512, 8) ROW(cAttnPrefillH256G6Bs4Bf16), NOTUNE, nullptr, nullptr, r4d_rad_attn_prefill_h256_gqa6_bf16, r4d_rad_attn_prefill_h256_gqa6_scratch, nullptr, nullptr, - r4d_shape_attn_paged }, + r4d_shape_attn_paged, nullptr, nullptr, RAD_KERNEL_CAP_DYNAMIC_PREFILL_SPLIT }, { "attn_decode_h256_gqa6_bs4_fp8kv", "attn_paged", "attn", "paged attention, causal or not, split-KV (decode / speculative verify / draft block)", @@ -7299,7 +7794,7 @@ R4D_WIN_TREE_PAIR(512, 4) R4D_WIN_TREE_PAIR(512, 8) ROW(cAttnPrefillH256G12Fp8v4), NOTUNE, nullptr, nullptr, r4d_rad_attn_prefill_h256_gqa12_fp8v4, r4d_rad_attn_prefill_h256_gqa12_fp8v4_scratch, nullptr, nullptr, - nullptr }, + nullptr, nullptr, nullptr, RAD_KERNEL_CAP_DYNAMIC_PREFILL_SPLIT }, { "attn_decode_h256_gqa12_fp8v4", "attn_paged", "attn", "paged attention, causal or not, split-KV (decode / speculative verify / draft block)", @@ -7330,7 +7825,7 @@ R4D_WIN_TREE_PAIR(512, 4) R4D_WIN_TREE_PAIR(512, 8) ROW(cAttnPrefillH256G12K6v4), NOTUNE, nullptr, nullptr, r4d_rad_attn_prefill_h256_gqa12_k6v4, r4d_rad_attn_prefill_h256_gqa12_k6v4_scratch, nullptr, nullptr, - nullptr }, + nullptr, nullptr, nullptr, RAD_KERNEL_CAP_DYNAMIC_PREFILL_SPLIT }, { "attn_decode_h256_gqa12_k6v4", "attn_paged", "attn", "paged attention, causal or not, split-KV (decode / speculative verify / draft block)", @@ -7361,7 +7856,7 @@ R4D_WIN_TREE_PAIR(512, 4) R4D_WIN_TREE_PAIR(512, 8) ROW(cAttnPrefillH256G6Bs4Fp8v4), NOTUNE, nullptr, nullptr, r4d_rad_attn_prefill_h256_gqa6_fp8v4, r4d_rad_attn_prefill_h256_gqa6_fp8v4_scratch, nullptr, nullptr, - nullptr }, + nullptr, nullptr, nullptr, RAD_KERNEL_CAP_DYNAMIC_PREFILL_SPLIT }, { "attn_decode_h256_gqa6_bs4_fp8v4", "attn_paged", "attn", "paged attention, causal or not, split-KV (decode / speculative verify / draft block)", @@ -7392,7 +7887,7 @@ R4D_WIN_TREE_PAIR(512, 4) R4D_WIN_TREE_PAIR(512, 8) ROW(cAttnPrefillH256G6Bs4K6v4), NOTUNE, nullptr, nullptr, r4d_rad_attn_prefill_h256_gqa6_k6v4, r4d_rad_attn_prefill_h256_gqa6_k6v4_scratch, nullptr, nullptr, - nullptr }, + nullptr, nullptr, nullptr, RAD_KERNEL_CAP_DYNAMIC_PREFILL_SPLIT }, { "attn_decode_h256_gqa6_bs4_k6v4", "attn_paged", "attn", "paged attention, causal or not, split-KV (decode / speculative verify / draft block)", @@ -7491,6 +7986,44 @@ R4D_WIN_TREE_PAIR(512, 4) R4D_WIN_TREE_PAIR(512, 8) nullptr, nullptr, r4d_shape_attn_paged }, +{ "attn_prefill_h128_gqa16_fp8kv", "attn_paged", "attn", + "paged causal attention, query-tiled (prefill / chunked prefill)", + "head_dim 128, 16 queries per kv head, paged block 16, varlen", + "bf16 query, fp8-e4m3 kv cache with per-(seq,head) descales, bf16 out", + RAD_DOMAIN_DEVICE, R4D_PRIO_ATTN_PREFILL, + ROW(cAttnPrefillH128G16Fp8), NOTUNE, + nullptr, nullptr, r4d_rad_attn_prefill_h128_gqa16_fp8, nullptr, nullptr, nullptr, + r4d_shape_attn_paged }, + +{ "attn_prefill_h128_gqa16_bf16kv", "attn_paged", "attn", + "paged causal attention, query-tiled (prefill / chunked prefill)", + "head_dim 128, 16 queries per kv head, paged block 16, varlen", + "bf16 query, bf16 kv cache, bf16 out", + RAD_DOMAIN_DEVICE, R4D_PRIO_ATTN_PREFILL, + ROW(cAttnPrefillH128G16Bf16), NOTUNE, + nullptr, nullptr, r4d_rad_attn_prefill_h128_gqa16_bf16, nullptr, nullptr, nullptr, + r4d_shape_attn_paged }, + +{ "attn_decode_h128_gqa16_fp8kv", "attn_paged", "attn", + "paged attention, causal or not, split-KV (decode / speculative verify)", + "head_dim 128, 16 queries per kv head, paged block 16, q_len*gqa <= 128, no window", + "bf16 query, fp8-e4m3 kv cache with per-(seq,head) descales, bf16 out, f16 partials", + RAD_DOMAIN_DEVICE, R4D_PRIO_ATTN_DECODE, + ROW(cAttnDecodeH128G16Fp8), ROW(tAttnSplit), nullptr, + nullptr, nullptr, r4d_rad_attn_decode_h128_gqa16_fp8, r4d_rad_attn_decode_h128_gqa16_scratch, + nullptr, nullptr, + r4d_shape_attn_paged }, + +{ "attn_decode_h128_gqa16_bf16kv", "attn_paged", "attn", + "paged attention, causal or not, split-KV (decode / speculative verify)", + "head_dim 128, 16 queries per kv head, paged block 16, q_len*gqa <= 128, no window", + "bf16 query, bf16 kv cache, bf16 out, f16 partials", + RAD_DOMAIN_DEVICE, R4D_PRIO_ATTN_DECODE, + ROW(cAttnDecodeH128G16Bf16), ROW(tAttnSplit), nullptr, + nullptr, nullptr, r4d_rad_attn_decode_h128_gqa16_bf16, r4d_rad_attn_decode_h128_gqa16_scratch, + nullptr, nullptr, + r4d_shape_attn_paged }, + { "attn_vit_h72_bf16", "attn_dense", "attn", "dense non-causal vision-encoder attention, varlen over images / windows", "head_dim 72 native (no padding to 128), multi-head (no GQA), contiguous q/k/v/o, " @@ -7520,6 +8053,16 @@ R4D_WIN_TREE_PAIR(512, 4) R4D_WIN_TREE_PAIR(512, 8) ROW(cAttnDenseH64), NOTUNE, nullptr, nullptr, r4d_rad_attn_dense }, +{ "attn_dense_h80_bf16", "attn_dense", "attn", + "dense varlen attention over cu_seqlens: bidirectional with an optional two-sided window or " + "blocks, or causal with an optional window behind", + "head_dim 80, multi-head (no GQA), q/k/v/o at their own token pitches (column slices of a " + "fused projection allowed)", + "bf16 query / key / value / out, f16 operands, fp32 accumulate", + RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, + ROW(cAttnDenseH80), NOTUNE, + nullptr, nullptr, r4d_rad_attn_dense }, + { "attn_dense_h256_bf16", "attn_dense", "attn", "dense varlen attention over cu_seqlens: bidirectional with an optional two-sided window or " "blocks, or causal with an optional window behind", @@ -7647,11 +8190,28 @@ R4D_WIN_TREE_PAIR(512, 4) R4D_WIN_TREE_PAIR(512, 8) nullptr, nullptr, r4d_rad_gdn_conv_recurrent_update, nullptr, nullptr, nullptr, nullptr, nullptr, r4d_fuse_gdn_conv_recurrent_update }, +{ "gdn_conv_recurrent_update_had_k128_v128_bf16", "gdn_conv_recurrent_update_had", "gdn", + "gdn_conv_recurrent_update_k128_v128_bf16 with had_quant_act_i8g's pass in its epilogue: the " + "workgroup's (token, head) row of `o`, one 128-wide group, rotated in one wave and quantised to " + "int8, saving that quantiser's launch per layer", + "as gdn_conv_recurrent_update_k128_v128_bf16; int8 codes", + "as gdn_conv_recurrent_update_k128_v128_bf16, the codes had_quant_act_i8g's over `o`. " + "Byte-identical to that row followed by had_quant_act_i8g (r4d_selftest's gdn conv fold)", + RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, + ROW(cGdnConvRecurrentUpdate), NOTUNE, + nullptr, nullptr, r4d_rad_gdn_conv_recurrent_update_had }, + { "kda_update_k128_v128_bf16", "kda_update", "gdn", "per-channel KDA recurrence and candidate rollback", "heads 1..65535, K=V=128, prefill and verify", "bf16 activations, f32 gates and state", RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, ROW(cKdaUpdate), NOTUNE, nullptr, nullptr, r4d_rad_kda_update, nullptr, nullptr, nullptr, r4d_shape_kda_update }, +{ "ssd_update_n128_bf16", "ssd_update", "gdn", "Mamba-2 recurrence and candidate states", + "heads 1..65535, d_state 128, head_dim a multiple of 16 up to 256, prefill and verify", + "bf16 activations, f32 A_log, dt_bias, D and state", + RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, ROW(cSsdUpdate), NOTUNE, + nullptr, nullptr, r4d_rad_ssd_update, nullptr, nullptr, nullptr, + r4d_shape_ssd_update }, { "mhc_pre_bf16", "mhc_pre", "norm", "manifold residual gates and Sinkhorn mixing", "M 1..65535, n 1..16384, hc 2..8, iterations 1..256", "bf16 activation, f32 weights and coefficients", RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, ROW(cMhcPre), NOTUNE, @@ -8259,6 +8819,24 @@ R4D_WIN_TREE_PAIR(512, 4) R4D_WIN_TREE_PAIR(512, 8) r4d_rad_layout_iqr, r4d_rad_relayout_iqr, nullptr, r4d_rad_unrelayout_iqr }, +{ "gemm_iqr_gated", "gemm_nt_q_gated", "gemm", + "gemm_iqr_nt_m64's GEMV and 16-token tile over a gate_up weight with gated_had_quant_i8g's pass " + "in the epilogue: a block per 16-column tile of the gated output, the plain kernel's waves on the " + "gate rows' tile and as many on the up rows', the product in the op's scratch and the last of a " + "128-column group's blocks to arrive rotating and quantising it, so the [M, 2n] bf16 plane and " + "the quantiser's launch are gone", + "M <= 16; K a multiple of 256; N a multiple of 256 (the gated width of the 128-column group), " + "and of a trellis's run; act silu; an IQR weight's codes, gate rows then up rows", + "i8 A with an f32 scale per (row, 128 K), W an IQR form's codes (as gemm_iqr_nt_m64), and the " + "QUANTISER's outputs: int8 codes of the rotated product, an f32 scale per (row, 128 columns) and " + "an optional bf16 product. Byte-identical to gemm_iqr_nt_m64 followed by gated_had_quant_i8g", + RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, + ROW(cGemmNtQGatedIqr), NOTUNE, + nullptr, nullptr, r4d_rad_gemm_iqr_gated, r4d_rad_gemm_iqr_gated_scratch, + r4d_rad_layout_iqr, r4d_rad_relayout_iqr, nullptr, r4d_rad_unrelayout_iqr, + /* The byte-identity claim above, as a chain of two rows of this plugin (r4d_fuse.cpp). */ + r4d_fuse_gemm_nt_q_gated_iqr }, + { "gemm_iqr_tiled", "gemm_nt_q", "gemm", "the prefill GEMM over an IQR weight: the call decodes the weight's codes into the int8 fragment " "plane in its scratch, once, and runs gemm_i8a8_tiled (or its rb8 / rb32 fold on a tcq_rb " @@ -8495,6 +9073,12 @@ R4D_WIN_TREE_PAIR(512, 4) R4D_WIN_TREE_PAIR(512, 8) nullptr, nullptr, r4d_rad_scale_rows, nullptr, nullptr, nullptr, r4d_shape_scale_rows }, +{ "router_sigmoid_group_topk_f32", "router_sigmoid_group_topk", "moe", + "group-limited sigmoid correction-bias routing, one wave a row", "experts <=512, groups <=32, top_k<=32", + "f32 logits, bias and weights; i32 ids", RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, + ROW(cRouterSigmoidGroup), NOTUNE, + nullptr, nullptr, r4d_rad_router_sigmoid_group_topk, nullptr, nullptr, nullptr, + r4d_shape_router_sigmoid_group_topk }, { "router_sigmoid_topk_f32", "router_sigmoid_topk", "moe", "sigmoid correction-bias routing", "single group, experts <=512, top_k<=32", "f32 logits, bias and weights; i32 ids", RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, @@ -8879,10 +9463,11 @@ R4D_WIN_TREE_PAIR(512, 4) R4D_WIN_TREE_PAIR(512, 8) * accumulated Hessians at convert time, from a file. So it is unresolved by the serving graph on * purpose, not an unwired kernel. */ { "gram_accum", "gram_accum", "quant", - "h += x^T x over an E4M3 activation, in f32 -- the Gram matrix a GPTQ packer needs", + "h += x^T x over an E4M3 or int8 activation, in f32 -- the Gram matrix a GPTQ packer needs", "n a multiple of 4 and group 128, because a 64-wide output tile must lie inside one scale " "group; any M, and the accumulator is READ as well as written", - "E4M3 plus an f32 scale per (row, 128 columns) in; an f32 [n][n] accumulator in and out", + "E4M3 (dtype fp8a8) or int8 (i8a8) plus an f32 scale per (row, 128 columns) in; an f32 [n][n] " + "accumulator in and out", RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, ROW(cGramAccum), NOTUNE, nullptr, nullptr, r4d_rad_gram_accum, nullptr, nullptr, nullptr, @@ -8992,6 +9577,18 @@ R4D_WIN_TREE_PAIR(512, 4) R4D_WIN_TREE_PAIR(512, 8) /* `sigmoid` + `mul` + `quant_act_fp8`, and `mul` + `quant_act_fp8` for act none (r4d_fuse.cpp). */ r4d_fuse_gate_quant_fp8 }, +{ "gate_had_quant_i8g", "gate_had_quant_i8g", "quant", + "gate_quant_fp8 with the width-128 Hadamard between the bf16-rounded product and the absmax and " + "int8 codes: had_quant_act_i8g's pass folded in, saving that quantiser's launch before a gated " + "attention's rotated out projection", + "n a multiple of 128; otherwise as gate_quant_fp8", + "bf16 in, int8 out with an f32 scale per (row, 128 columns) and an optional bf16 out; the codes " + "are had_quant_act_i8g's over the BF16-ROUNDED product", + RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, + ROW(cGateHadQuantI8g), NOTUNE, + nullptr, nullptr, r4d_rad_gate_had_quant_i8g, nullptr, nullptr, nullptr, + r4d_shape_gate_quant_fp8, nullptr }, + /* ---------------------------------------------------------------------------------- sampling * * spec §13 requires sampling on device. This is the only implementation of sample_chain (libref @@ -9472,6 +10069,25 @@ R4D_WIN_TREE_PAIR(512, 4) R4D_WIN_TREE_PAIR(512, 8) nullptr, nullptr, r4d_rad_dflash_conv, nullptr, nullptr, nullptr, r4d_shape_dflash_conv }, +{ "dflash_markov_greedy_bf16", "dflash_markov_greedy", "dflash", + "Full-vocabulary DSpark Markov bias and serial greedy argmax; dependent positions each follow " + "a complete scan of the draft-head vocabulary", + "steps >= 1, rank a multiple of 32 and <= 512, 64 vocabulary ids per scratch tile", + "bf16 logits and codebooks, i32 anchor, f32/i32 tile winners, i32 tokens out", + RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, + ROW(cDflashMarkov), NOTUNE, + nullptr, nullptr, r4d_rad_dflash_markov_greedy, nullptr, nullptr, nullptr, + r4d_shape_dflash_markov }, + +{ "dflash_markov_greedy_f32", "dflash_markov_greedy_f32", "dflash", + "Full-vocabulary DSpark greedy walk with F32 base logits", + "steps >= 1, rank a multiple of 32 and <= 512, 64 vocabulary ids per scratch tile", + "f32 logits, bf16 codebooks, i32 anchor, f32/i32 tile winners, i32 tokens out", + RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, + ROW(cDflashMarkov), NOTUNE, + nullptr, nullptr, r4d_rad_dflash_markov_greedy_f32, nullptr, nullptr, nullptr, + r4d_shape_dflash_markov_f32 }, + { "dflash_select_bf16", "dflash_select", "dflash", "DFlash2 candidate selector: the low-rank edge scores and the greedy walk over them, one " "workgroup a sequence and no launch between steps", @@ -9496,6 +10112,41 @@ R4D_WIN_TREE_PAIR(512, 4) R4D_WIN_TREE_PAIR(512, 8) /* pair_argmax, the sandwich-norm joins and expert_scale. The joins and expert_scale have no * opd_shape: libref has no row for them, and tests/r4d_emu holds their source to the replaced chain * bit for bit on the host. pair_argmax is described as libref describes it. */ +/* LiLiCorr's correlator: a few microseconds of a draft step each (r4d_lili.hip). */ +{ "lili_cand_bf16", "lili_cand", "draft", + "LiLiCorr candidates: the ranks' logprob rows merged, five rank features through layernorm, " + "the up projection and silu, and the lattice rows' additive part", + "k <= 64, world <= 16; one workgroup a draft position", + "f32 stats, layernorm and up projection; bf16 activations, slot and rank tables; i32 cand", + RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, + ROW(cLiliCand), NOTUNE, + nullptr, nullptr, r4d_rad_lili_cand, nullptr, nullptr, nullptr, + r4d_shape_lili_cand }, +{ "lili_attn_bf16", "lili_attn", "draft", + "LiLiCorr lattice attention with learned slot biases, no mask", + "steps * k <= 64, head_dim <= 128; one workgroup a (sequence, head)", + "bf16 qkv and out, f32 biases", + RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, + ROW(cLiliAttn), NOTUNE, + nullptr, nullptr, r4d_rad_lili_attn, nullptr, nullptr, nullptr, + r4d_shape_lili_attn }, +{ "lili_factor_bf16", "lili_factor", "draft", + "LiLiCorr factor input [h | a | h * a]", + "any M and n; one workgroup a row", + "bf16", + RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, + ROW(cLiliFactor), NOTUNE, + nullptr, nullptr, r4d_rad_lili_factor, nullptr, nullptr, nullptr, + r4d_shape_lili_factor }, +{ "lili_walk_bf16", "lili_walk", "draft", + "LiLiCorr normalised edge scores and their greedy walk", + "k <= 64, steps * k * k <= 512; one workgroup a sequence", + "bf16 edges and anchor, i32 cand and tokens, f32 scores", + RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, + ROW(cLiliWalk), NOTUNE, + nullptr, nullptr, r4d_rad_lili_walk, nullptr, nullptr, nullptr, + r4d_shape_lili_walk }, + { "pair_argmax_f32", "pair_argmax", "select", "the top-1 of a row of (id, value) pairs, ties to the lower id, negative ids skipped", "any M and n; one wave a row; the outputs one element a row at their own pitch", @@ -10548,6 +11199,21 @@ extern "C" int rad_kernel_chain(int i) { "dflash_select_bf16", "dflash_tree_bf16", /* the weight read beside a collective (its blocks add before reading, r4d_prefetch.hip) */ "prefetch", + /* Flash-Next at decode heights: the MoE block */ + "router_gemm_topk_scatter_bf16", "moe_gemm_fp8a8", "moe_gemm_fp8a8_mod4", "gated_quant_fp8", + /* ...and the rest of a delta-net layer */ + "hc_read_bf16", "hc_read_e4m3", "gdn_recurrent_update_k128_v128_bf16_fp32state", + "gdn_conv_recurrent_update_k128_v128_bf16", "ar_hc_write", "ar_gather_hc_write", + /* the four-bit routed experts and their rotated quantiser */ + "moe_gemm_w4a8", "moe_gemm_w4a8_mod4", "gated_had_quant_fp8", "gated_had_quant_i8g", + /* ...and an attention layer: the indexer, the norm/rope/gate, the quantiser before o_proj + * and the gqa6 decode rows (their split-KV decode and merge already have chained forms) */ + "qk_norm_rope_gate", "qsa_work_bf16", "qsa_block_key_bf16", "qsa_tail_store_bf16", + "qsa_score_bf16", "qsa_select_i32", "gate_quant_fp8", + "attn_decode_h256_gqa6_fp8kv", "attn_decode_h256_gqa6_fp8v4", "attn_decode_h256_gqa6_k6v4", + "attn_decode_h256_gqa6_bf16kv", "attn_decode_h256_gqa6_bs4_fp8kv", + "attn_decode_h256_gqa6_bs4_bf16kv", "attn_decode_gq_h256_gqa6_bs4_fp8kv", + "attn_decode_gq_h256_gqa6_bs4_bf16kv", }; for (const char* p : kChained) if (std::strcmp(k->name, p) == 0) return 1; diff --git a/libr4d/r4d_sample_stages_f32.hip b/libr4d/r4d_sample_stages_f32.hip index a7bdd464..fe138f11 100644 --- a/libr4d/r4d_sample_stages_f32.hip +++ b/libr4d/r4d_sample_stages_f32.hip @@ -687,7 +687,7 @@ __global__ __launch_bounds__(kTopkThreads) void logprobs_kernel( __shared__ float red[kTopkWaves]; const uint32_t m = blockIdx.x; - if (!(sp[m].flags & SP_LOGPROBS)) return; + if (sp && !(sp[m].flags & SP_LOGPROBS)) return; /* no params: every row */ const float* __restrict__ row = lg + (size_t)m * lg_ld; float* __restrict__ out = st + (size_t)m * st_ld; const uint32_t kk = k < n_vocab ? k : n_vocab; @@ -1165,7 +1165,7 @@ static int r4d_sample_argmax_f32(long lg, long tok, int M, int n_vocab, int lg_l static int r4d_sample_logprobs_f32(long lg, long params, long stats, int M, int n_vocab, int k, int lg_ld, int st_ld, int vocab_off, long stream) { - if (!lg || !params || !stats) return R4D_NO(RAD_E_INVAL); + if (!lg || !stats) return R4D_NO(RAD_E_INVAL); if (M <= 0 || n_vocab <= 0 || k <= 0) return R4D_NO(RAD_E_SHAPE); if ((uint32_t)k > kMaxLogprobs) return R4D_NO(RAD_E_SHAPE); if (!lg_ld) lg_ld = n_vocab; @@ -1389,8 +1389,9 @@ extern "C" int r4d_rad_sample_logprobs(const RadArgs* a, RadStream s) { const RadTensor* lg; long long M = 0, nv = 0, ld = 0; R4D_NEED(logits_of(a, &lg, &M, &nv, &ld)); + /* Absent params: every row (a drafter's candidate logprobs). */ const RadTensor* pr = r4d_opt(a, V_PARAMS); - R4D_NEED(params_ok(pr, M)); + if (pr) R4D_NEED(params_ok(pr, M)); const RadTensor* st = r4d_opt(a, 2); if (!st) return R4D_NO(RAD_E_INVAL); R4D_NEED(dt_f32(st)); diff --git a/libr4d/r4d_selftest.cpp b/libr4d/r4d_selftest.cpp index f146144a..65f9b809 100644 --- a/libr4d/r4d_selftest.cpp +++ b/libr4d/r4d_selftest.cpp @@ -40,6 +40,7 @@ #include "r4d_hc_fp8.h" #include "r4d_fp8_frag.h" #include "r4d_fp8_lm.h" +#include "r4d_iqr.h" #include "rad_encoding.h" #include "rad_philox.h" #include "rad_sample.h" @@ -139,6 +140,7 @@ struct Plugin { void (*pin_qsa)(int) = nullptr; void (*pin_moe)(int) = nullptr; void (*pin_fk)(int) = nullptr; + void (*pin_mx_small)(int) = nullptr; /* optional: absent from an older libr4d */ void (*pin_dtile)(int) = nullptr; void (*pin_gather)(int) = nullptr; void (*pin_ddec)(int) = nullptr; @@ -211,6 +213,7 @@ static bool load(Plugin* pl, const char* path) { okall &= sym(pl->h, "r4d_qsa_score_pin_form", &pl->pin_qsa); okall &= sym(pl->h, "r4d_moe_gemm_pin_prefill", &pl->pin_moe); okall &= sym(pl->h, "r4d_moe_gemm_pin_fk", &pl->pin_fk); + pl->pin_mx_small = (void (*)(int))dlsym(pl->h, "r4d_moe_mxfp4_pin_small"); okall &= sym(pl->h, "r4d_moe_gemm_pin_down_tile", &pl->pin_dtile); okall &= sym(pl->h, "r4d_moe_gather_pin_form", &pl->pin_gather); okall &= sym(pl->h, "r4d_moe_gemm_pin_down_dec", &pl->pin_ddec); @@ -1347,6 +1350,116 @@ static void attn_numeric_case(const Plugin& pl, const char* name, int64_t head_d fmt("corrupted ref must fail: max_err=%.5g bad=%d", nmax, nbadc)); } +/* A speculative verify against the decodes it replaces: `q_len` query rows of one sequence whose + * context after the step is `ctx`, launched together, must give bit for bit the `q_len` single-row + * launches at the same positions (context ctx - q_len + 1 + j for row j), or greedy text with a + * drafter differs from the text without one. One KV head a rank, as Nemotron-H's trunk at two + * (gqa 16) and four (gqa 8) ranks, ragged as the engine issues it, with the engine's max_ctx and + * max_seqs (--max-model-len 8192, --max-num-seqs 4). Holds while every segment of the split law is + * one tile at both launches: up to 2048 keys at one sequence, where the decode targets 256 + * segments and an eight-row verify 128 (r4d_decode_splits). */ +static bool attn_verify_bits_case(const Plugin& pl, const char* name, int64_t gqa, + const char* kv_dtype, int64_t q_len, int64_t ctx, + bool quiet = false) { + if (!sel(name)) return true; + const RadKernelInfo* r = find(pl, name); + std::string tag = fmt("%s verify %lld rows = %lld decodes at %lld keys", name, + (long long)q_len, (long long)q_len, (long long)ctx); + if (!r) { ok(tag.c_str(), false, "row absent"); return false; } + const size_t mark = g_allocs.size(); /* a sweep launches thousands of these: free as we go */ + const int64_t head_dim = 128, bs = 16, q_heads = gqa, max_ctx = 8192; + const int64_t max_blocks = max_ctx / bs, blocks = (ctx + bs - 1) / bs; + const int kv_is_fp8 = std::strcmp(kv_dtype, "bf16") != 0; + const uint32_t kvdt = kv_is_fp8 ? RAD_F8E4M3 : RAD_BF16; + const int ew = kv_is_fp8 ? 1 : 2; + const int64_t nelem = blocks * bs * 2 * head_dim; + std::vector kv((size_t)nelem * ew); + for (int64_t e = 0; e < nelem; ++e) { + if (kv_is_fp8) { kv[(size_t)e] = st_rand_e4m3((uint32_t)e); continue; } + const uint16_t h = st_rand_bf16((uint32_t)e); + kv[(size_t)e * 2] = (uint8_t)h; kv[(size_t)e * 2 + 1] = (uint8_t)(h >> 8); + } + /* the pages in reverse, so a row reading a neighbour's page shows */ + std::vector bt((size_t)max_blocks, -1); + for (int64_t b = 0; b < blocks; ++b) bt[(size_t)b] = (int32_t)(blocks - 1 - b); + const int64_t row = q_heads * head_dim; + std::vector qh((size_t)(q_len * row)); + for (size_t i = 0; i < qh.size(); ++i) qh[i] = st_rand_bf16((uint32_t)(i * 7 + 3)); + void* d_kv = dalloc(kv.size()); + st_memcpy(d_kv, kv.data(), kv.size(), hipMemcpyHostToDevice); + void* d_q = dalloc(qh.size() * 2); + st_memcpy(d_q, qh.data(), qh.size() * 2, hipMemcpyHostToDevice); + void* d_out = dalloc(qh.size() * 2); + /* rows [j0, j0 + n) at context `used`; returns the launch's code */ + auto launch = [&](int64_t j0, int64_t n, int64_t used) { + std::vector ts = { + T((char*)d_q + j0 * row * 2, RAD_BF16, { n, q_heads, head_dim }), + T(d_kv, kvdt, { blocks, 1, bs, 2 * head_dim }), + TI32({ 1, max_blocks }, bt), + TI32({ 1 }, { (int32_t)used }), + TF32({ 1, 1 }, 1.0f), + TF32({ 1, 1 }, 1.0f), + TI32({ 2 }, { 0, (int32_t)n }), + T((char*)d_out + j0 * row * 2, RAD_BF16, { n, q_heads, head_dim }), + }; + if (!kv_is_fp8) { absent(ts[4]); absent(ts[5]); } + std::vector ps = { + PI("q_len", q_len), PI("head_dim", head_dim), PI("gqa", gqa), PI("block_size", bs), + PI("causal", 1), PI("window", 0), PI("n_head", q_heads), PI("max_seqs", 4), + PI("max_ctx", max_ctx), PS("q_dtype", "bf16"), PS("kv_dtype", kv_dtype), + }; + RadArgs a; + std::memset(&a, 0, sizeof(a)); + a.t = ts.data(); a.n_t = (int)ts.size(); + a.p = ps.data(); a.n_p = (int)ps.size(); + a.world_size = 1; + if (r->scratch) { + const int64_t need = r->scratch(&a); + if (need < 0) return (int)need; + if (need > 0) { a.scratch = dalloc((size_t)need); a.scratch_bytes = need; } + } + const int rc = r->launch(&a, (RadStream) nullptr); + const hipError_t he = (hipError_t)st_stream_sync(nullptr); + return he != hipSuccess ? -1000 - (int)he : rc; + }; + int rc = launch(0, q_len, ctx); + std::vector ver(qh.size()), one(qh.size()); + st_memcpy(ver.data(), d_out, ver.size() * 2, hipMemcpyDeviceToHost); + for (int64_t j = 0; j < q_len && rc == RAD_OK; ++j) rc = launch(j, 1, ctx - q_len + 1 + j); + st_memcpy(one.data(), d_out, one.size() * 2, hipMemcpyDeviceToHost); + int64_t eq = 0; + for (int64_t j = 0; j < q_len; ++j) + eq += !std::memcmp(&ver[(size_t)(j * row)], &one[(size_t)(j * row)], (size_t)row * 2); + const bool good = rc == RAD_OK && eq == q_len; + while (g_allocs.size() > mark) { hipFree(g_allocs.back()); g_allocs.pop_back(); } + if (!quiet || !good) + ok(tag.c_str(), good, fmt("rc=%d, rows bit-equal %lld/%lld", rc, (long long)eq, (long long)q_len)); + return good; +} + +/* The same check for the verify widths a drafter of 1..7 proposes, over every context from 40 to + * 300 keys, then the page edges up to 2048: one line a width, a failure line a context. 2048 keys + * is where it ends: a verify of more than 32 (query, head) rows has one split target (128 + * segments) and a plain decode another (256), so past 128 tiles the two cut the keys differently + * by design (r4d_decode_splits). */ +static void attn_verify_sweep(const Plugin& pl, const char* name, int64_t gqa, const char* kv_dtype) { + if (!sel(name)) return; + std::vector ctxs; + for (int64_t c = 40; c <= 300; ++c) ctxs.push_back(c); + for (int64_t c = 301; c <= 2048; ++c) + if (c % 16 <= 2 || c % 16 >= 14 || c >= 2040) ctxs.push_back(c); + for (int64_t q : { 2, 3, 4, 5, 8 }) { + int64_t bad = 0, n = 0; + for (int64_t c : ctxs) { + if (c < q) continue; + ++n; + bad += !attn_verify_bits_case(pl, name, gqa, kv_dtype, q, c, true); + } + ok(fmt("%s verify sweep, %lld rows, %lld contexts 40..2048", name, (long long)q, + (long long)n).c_str(), bad == 0, fmt("%lld contexts differ", (long long)bad)); + } +} + /* A head-256 prefill geometry the KV split serves: queries per KV head, KV heads (a rank's), page * size, and the unit's test hooks' prefix (`_splits`, the law; `_last_splits`, the * count the unit's last launch used). The workgroup holds 384 / gqa query positions. */ @@ -1371,7 +1484,8 @@ static const SplitGeo kSplitG6 = { 6, 2, 16, "r4d_attn_prefill_h256_gqa6" }; struct SplitSeq { int64_t q, ctx; }; static void attn_split_case(const Plugin& pl, const SplitGeo& g, const char* name, const char* kv_dtype, const std::vector& seqs, int force, - bool law_splits, int64_t lead = 0, int64_t tail = 0) { + bool law_splits, int64_t lead = 0, int64_t tail = 0, + int64_t decl_max_ctx = 0) { if (!sel(name) && !sel("attn_prefill_split")) return; const RadKernelInfo* r = find(pl, name); if (!r) { ok(name, false, "row absent"); return; } @@ -1409,6 +1523,18 @@ static void attn_split_case(const Plugin& pl, const SplitGeo& g, const char* nam const int64_t span0 = lead, span1 = cu[(size_t)ns]; /* the launch's own rows */ const int64_t total_q = span1 + tail; const bool ragged = ns > 1 || lead || tail; + /* This direct-kernel fixture supplies an exact host maximum for a full sequence operand. Its + * synthetic partial-row operands do not carry the runtime's host slice/position view, so they + * exercise the safe declared-context fallback. */ + int32_t used_max_h = -1; + if (!lead && !tail) + for (int32_t x : used) used_max_h = std::max(used_max_h, x); + int wgp_count = 32, current_device = 0; + hipDeviceProp_t current_props{}; + if (hipGetDevice(¤t_device) == hipSuccess && + hipGetDeviceProperties(¤t_props, current_device) == hipSuccess && + current_props.multiProcessorCount > 0) + wgp_count = current_props.multiProcessorCount; /* one disjoint run of mb blocks per sequence */ const std::vector bt = iota_i32(ns * mb); @@ -1473,6 +1599,7 @@ static void attn_split_case(const Plugin& pl, const SplitGeo& g, const char* nam PI("block_size", bs), PI("causal", 1), PI("window", 0), PS("q_dtype", "bf16"), PS("kv_dtype", kv_dtype), }; + if (decl_max_ctx > 0) ps.push_back(PI("max_ctx", decl_max_ctx)); if (sp > 0) ps.push_back(PI("splits", sp)); /* run_case, with the scratch poisoned: 0x7f7f7f7f is m = 3.4e38, so a segment the merge * reads but nobody wrote outweighs every real one and the row comes out wrong. Fresh @@ -1482,6 +1609,8 @@ static void attn_split_case(const Plugin& pl, const SplitGeo& g, const char* nam a.t = ts.data(); a.n_t = (int)ts.size(); a.p = ps.data(); a.n_p = (int)ps.size(); a.world_size = 1; + a.kv_used_max_h = used_max_h; + a.wgp_count = wgp_count; const int64_t need = r->scratch ? r->scratch(&a) : 0; if (need > 0) { a.scratch = dalloc((size_t)need); @@ -1498,8 +1627,10 @@ static void attn_split_case(const Plugin& pl, const SplitGeo& g, const char* nam const int s_un = run(1, d_o[0]); const int s_fo = run(force, d_o[1]); const int s_lw = run(0, d_o[2]); + int law_ctx = decl_max_ctx > 0 ? (int)decl_max_ctx : (int)(mb * bs); + if (used_max_h > 0 && used_max_h < law_ctx) law_ctx = used_max_h; const int want = law((int)(ragged ? std::min(2048, total_q) : qmax), (int)total_q, - (int)ns, (int)kv_heads, (int)(mb * bs)); + (int)ns, (int)kv_heads, law_ctx); ok((tag + ": splits 1 / forced / law").c_str(), s_un == 1 && s_fo == force && s_lw == want && (!law_splits || want > 1), fmt("launched %d / %d / %d, the law says %d%s", s_un, s_fo, s_lw, want, @@ -4413,11 +4544,15 @@ static int64_t i8_code_misses(const uint16_t* x, int64_t x_ld, const int8_t* q, * codes to quant_act_i8g over its `o`. `f32w` hands the fold the conv weight in f32, as a GGUF * stores it, and leaves the pair's in bf16: the values are bf16's, so the bytes must not change. */ static void gdn_conv_fold_run(const Plugin& pl, const char* nm, const char* form, - bool i8 = false, bool f32w = false) { - const RadKernelInfo* rf = find(pl, "gdn_conv_recurrent_update_k128_v128_bf16"); + bool i8 = false, bool f32w = false, bool had = false) { + /* `had`: the rotated row, against the pair writing `o` and had_quant_act_i8g over it. */ + if (had) i8 = true; + const RadKernelInfo* rf = find(pl, had ? "gdn_conv_recurrent_update_had_k128_v128_bf16" + : "gdn_conv_recurrent_update_k128_v128_bf16"); const RadKernelInfo* rc = find(pl, "gdn_conv_update_w4_h128_bf16"); const RadKernelInfo* rr = find(pl, "gdn_recurrent_update_k128_v128_bf16_fp32state"); - if (!rf || !rc || !rr) { ok(nm, false, "a row is absent"); return; } + const RadKernelInfo* rh = had ? find(pl, "had_quant_act_i8g") : nullptr; + if (!rf || !rc || !rr || (had && !rh)) { ok(nm, false, "a row is absent"); return; } const int64_t K = 128, V = 128, H = 4, Hg = 2, N = 4, W = 4, MQ = 4, SL = W - 2 + MQ; const int64_t conv_dim = (2 * Hg * K + H * V), in_w = conv_dim + H * V; @@ -4535,15 +4670,24 @@ static void gdn_conv_fold_run(const Plugin& pl, const char* nm, const char* form int e = run(rc, { tx, tw, none, cs(0), tci, tna, tcu, tq, tk, tv }, pc); if (e == RAD_OK) e = run(rr, { tq, tk, tv, ta, tb, tal, tdt, st(0), tsi, tna, tcu, tz, tnw, to(0), - toq(0), tos(0) }, pr); + had ? none : toq(0), had ? none : tos(0) }, pr); + if (e == RAD_OK && had) { + std::vector ph = { PI("M", Td), PI("n", H * V), PI("group", 128), PS("dtype", "bf16") }; + e = run(rh, { T(d_o[0], RAD_BF16, { Td, H * V }), toq(0), tos(0) }, ph); + } if (e != RAD_OK) { why = "pair rc=" + std::to_string(e); break; } e = run(rf, { tx, tfw, none, cs(1), tci, ta, tb, tal, tdt, st(1), tsi, tna, tcu, tz, tnw, to(1), toq(1), tos(1) }, pf); if (e != RAD_OK) { why = "fold rc=" + std::to_string(e); break; } + /* had_quant_act_i8g also quantises the padded last sequence's row, which the fold skips + * (a zero row, scale 1 against unwritten 0): the codes over the real sequences' tokens. */ + const size_t real = (size_t)cu[(size_t)N - 1]; const struct { const char* what; void* a; void* b; size_t n; } cmp[] = { - { "o", d_o[0], d_o[1], o_b }, { "o_q", d_oq[0], d_oq[1], oq_b }, - { "o_scale", d_os[0], d_os[1], os_b }, { "state", d_st[0], d_st[1], st_b }, + { "o", d_o[0], d_o[1], o_b }, + { "o_q", d_oq[0], d_oq[1], had ? real * (size_t)(H * V) : oq_b }, + { "o_scale", d_os[0], d_os[1], had ? real * (size_t)H * 4 : os_b }, + { "state", d_st[0], d_st[1], st_b }, { "conv_state", d_cs[0], d_cs[1], cs_b }, }; for (const auto& c : cmp) { @@ -4558,7 +4702,7 @@ static void gdn_conv_fold_run(const Plugin& pl, const char* nm, const char* form } /* At int8 codes, the real sequences' tokens (all but the padded last) against * quant_act_i8g over the pair's `o`. A (token, head) row is one group. */ - if (i8 && why.empty()) { + if (i8 && !had && why.empty()) { const std::vector O = fetch(d_o[0], o_b), Q = fetch(d_oq[0], oq_b), S = fetch(d_os[0], os_b); const int64_t rows = (int64_t)cu[(size_t)N - 1] * H; @@ -4593,6 +4737,12 @@ static void gdn_conv_fold(const Plugin& pl) { "per_candidate", true); } if (sel(row) || sel(nma)) gdn_conv_fold_run(pl, nma, "anchor"); + if (sel(row) || sel("gdn_conv_recurrent_update_had")) { + gdn_conv_fold_run(pl, "gdn_conv_recurrent_update_had is byte-identical to the pair then " + "had_quant_act_i8g, per_candidate", "per_candidate", true, false, true); + gdn_conv_fold_run(pl, "gdn_conv_recurrent_update_had is byte-identical to the pair then " + "had_quant_act_i8g, anchor", "anchor", true, false, true); + } if (sel(row) || sel(nmf)) gdn_conv_fold_run(pl, nmf, "per_candidate", false, true); } @@ -6798,10 +6948,11 @@ static void iqr_gemm_case(const Plugin& pl, const IqrCase& f, int64_t M, int64_t std::vector y((size_t)(M * N)), yr((size_t)(M * N)); st_memcpy(y.data(), d_y, y.size() * 2, hipMemcpyDeviceToHost); st_memcpy(yr.data(), d_yr, yr.size() * 2, hipMemcpyDeviceToHost); - /* M <= 8 is the GEMV, which folds per lane before summing across lanes: the product within - * f32 rounding, so bf16 outputs a rounding apart. Above, the int8 tiles' bytes. */ + /* M <= 16 is the GEMV or the 16-token tile, which sum per wave before summing across waves: + * the product within f32 rounding, so bf16 outputs a rounding apart. Above, the int8 tiles' + * bytes. */ /* kRowF32 scales its sums in the epilogue, not a block at a time: to a rounding too. */ - const bool exact = M > 8 && !f.rowf; + const bool exact = M > 16 && !f.rowf; /* An output's rounding is bounded by its sum's magnitude, not its own: a row that cancels to * near zero keeps the error of its terms. The bound is a bf16 step of the output plus 2^-8 of * the outputs' rms. */ @@ -10069,6 +10220,40 @@ void attn_dense_gqa_cases(const Plugin& pl) { } } +/* attn_dense_h80_bf16: C-RADIO's tower, 16 heads of 80 over a fused [q|k|v] row, two images. */ +void attn_dense_h80_cases(const Plugin& pl) { + const RadKernelInfo* r = find(pl, "attn_dense_h80_bf16"); + if (!r) { ok("attn_dense_h80_bf16", false, "row absent"); return; } + const int64_t hd = 80, nh = 16, w = nh * hd, total = 333; + const std::vector cu = { 0, 197, 333 }; + std::vector qkv = randv((size_t)(total * 3 * w), 1.0f); + for (float& x : qkv) x = bfr(x); + void* d = up_bf16(qkv); + auto col = [&](int c) { + RadTensor t = T((char*)d + c * w * 2, RAD_BF16, { total, w }); + t.stride[0] = 3 * w; + return t; + }; + void* dout = dalloc((size_t)(total * w) * 2); + const int rc = launch(r, { col(0), col(1), col(2), T(up_i32(cu), RAD_I32, { 3 }), + T(dout, RAD_BF16, { total, w }) }, + { PI("M", total), PI("head_dim", hd), PI("gqa", 1), PI("causal", 0), + PS("dtype", "bf16"), PI("max_seqlen", 197) }); + if (rc != RAD_OK) { ok("attn_dense_h80_bf16", false, "rc " + std::to_string(rc)); return; } + std::vector q((size_t)(total * w)), k((size_t)(total * w)), v((size_t)(total * w)); + for (int64_t i = 0; i < total; ++i) + for (int64_t t = 0; t < w; ++t) { + q[(size_t)(i * w + t)] = qkv[(size_t)(i * 3 * w + t)]; + k[(size_t)(i * w + t)] = qkv[(size_t)(i * 3 * w + w + t)]; + v[(size_t)(i * w + t)] = qkv[(size_t)(i * 3 * w + 2 * w + t)]; + } + std::vector want((size_t)(total * w)); + for (int e = 0; e < 2; ++e) + host_attn(q, k, v, w, w, nh, nh, hd, cu[(size_t)e], cu[(size_t)e + 1], cu[(size_t)e], + cu[(size_t)e + 1], false, &want); + check("attn_dense_h80_bf16 16 heads over two images", down_bf16(dout, want.size()), want, 2e-2); +} + /* One wide head over every pixel, 384 and 512. */ void attn_wide_cases(const Plugin& pl) { for (const int64_t hd : { 384, 512 }) { @@ -14732,6 +14917,214 @@ static void iqr_head_case(const Plugin& pl, int TB, int64_t N, int64_t K, int64_ dfree_all(); } +/* logits_gemm_vocab_iqr against the f64 product it computes: each class a computed trellis + * (tcq_code=mad, runs of 256 rows, one f32 scale a row under a factor a 128-K block, fwht128) of + * random codes, its rows' vocabulary ids a random permutation of the rank's share (`off` = the + * share for a second rank's, whose rows are the second half of each class's tensor), the activation + * random bf16, at token counts on both sides of the staging plane's 32. The reference rotates the activation in + * f32 and quantises it to sixteen bits a (token, 128) as the kernel does, then multiplies the + * host's decode of every class in f64: the kernel's f32 folds keep the logits within 2^-18 of their + * rms. Every logit must be written once: the output starts as NaN. The classes' planes also go back + * through the hooks' inverse. */ +struct VocabClass { int B; int64_t rows; }; + +static void vocab_head_case(const Plugin& pl, const std::vector& cls, int64_t M, + int64_t K, int64_t off) { + const char* row = "logits_gemm_vocab_iqr"; + if (!sel(row)) return; + int64_t V = 0; + std::string ws; + for (const auto& c : cls) { V += c.rows; ws += (ws.empty() ? "" : ",") + std::to_string(c.B) + "x" + std::to_string(c.rows); } + char nm[200]; + std::snprintf(nm, sizeof nm, "%s classes %s K=%lld M=%lld off=%lld", row, ws.c_str(), + (long long)K, (long long)M, (long long)off); + const RadKernelInfo* r = find(pl, row); + if (!r || !r->layout || !r->relayout || !r->scratch) { ok(nm, false, "row or hooks absent"); return; } + const int64_t nkb = K / 128; + uint64_t z = 0x9E3779B97F4A7C15ull * (uint64_t)(V + M * 7 + K + off); + auto rnd = [&]() { + z += 0x9E3779B97F4A7C15ull; + uint64_t x = z; + x = (x ^ (x >> 30)) * 0xBF58476D1CE4E5B9ull; + x = (x ^ (x >> 27)) * 0x94D049BB133111EBull; + return x ^ (x >> 31); + }; + static const uint32_t kU[] = { 0, RAD_U1, RAD_U2, RAD_U3, RAD_U4, RAD_U5, RAD_U6, RAD_U7 }; + std::vector perm((size_t)V); + for (int64_t i = 0; i < V; ++i) perm[(size_t)i] = (int32_t)i; + for (int64_t i = V - 1; i > 0; --i) std::swap(perm[(size_t)i], perm[(size_t)(rnd() % (uint64_t)(i + 1))]); + + std::vector gp = { PI("M", M), PI("n_vocab", V), PI("n_embd", K), PS("dtype", "bf16"), + PI("vocab_offset", off) }; + static const char* kRows[] = { "rows0", "rows1", "rows2", "rows3" }; + for (size_t i = 0; i < cls.size(); ++i) gp.push_back(PI(kRows[i], cls[i].rows)); + + /* the decoded head in vocabulary order, f64 */ + std::vector Wd((size_t)(V * K)); + std::vector ts(1 + 3 * 4 + 2); + std::vector> keep; + /* the inverse map: each id's class width and its row in the class's whole tensor, this rank + * being the second of a share `off` (the classes' tensors then twice its rows) when off > 0 */ + const int64_t rank = off > 0 ? 1 : 0; + std::vector vrow((size_t)V, -1); + int64_t base = 0; + for (size_t ci = 0; ci < cls.size(); ++ci) { + const VocabClass& vc = cls[ci]; + const int64_t N = vc.rows; + Planes p; + rad_enc_clear(&p.enc); + rad_enc_copy_str(p.enc.scheme, "trellis"); + rad_enc_add_plane(&p.enc, "codes", kU[vc.B], 1, 1); + rad_enc_add_plane(&p.enc, "scale", RAD_F32, 1, 0); + const int t = rad_enc_add_table(&p.enc, "trellis", RAD_I8, (int64_t)1 << 16, 1); + p.enc.plane[t].block[0] = 256; + p.enc.plane[t].block[1] = 0; + rad_enc_add_table(&p.enc, "trellis.mad", RAD_U32, 2, 1); + rad_enc_add_plane(&p.enc, "scale.col", RAD_F32, 0, 128); + rad_enc_copy_str(p.enc.transform, "fwht128"); + p.size(N, K); + const int ic = p.find("codes"), is = p.find("scale"), ia = p.find("trellis"); + for (int64_t n = 0; n < N; ++n) + for (int64_t c = 0; c < K; ++c) + rad_store_bits(p.data[(size_t)ic].data() + n * p.row_bytes(ic), vc.B, c, + (uint32_t)(rnd() & ((1ull << vc.B) - 1))); + const uint32_t A = (uint32_t)(rnd() & 0xFFFFFFu) | 1u, Bc = (uint32_t)rnd(); + uint32_t* ab = (uint32_t*)p.data[(size_t)p.find("trellis.mad")].data(); + ab[0] = A; + ab[1] = Bc; + for (uint32_t st = 0; st < (1u << 16); ++st) { + const uint32_t h = ((st & 0xFFFFFFu) * A + Bc) & 0x3F3F3F3Fu; + p.data[(size_t)ia][st] = (uint8_t)(int8_t)((int)((h & 0xFFu) + ((h >> 8) & 0xFFu) + + ((h >> 16) & 0xFFu) + (h >> 24)) - 126); + } + std::vector rs((size_t)N), cf((size_t)nkb); + for (int64_t n = 0; n < N; ++n) rs[(size_t)n] = std::ldexp(1.0f + (float)(rnd() % 1000) / 1000.0f, -9 - (int)(rnd() % 3)); + for (int64_t g = 0; g < nkb; ++g) cf[(size_t)g] = 0.5f + (float)(rnd() % 1000) / 1000.0f; + for (int64_t n = 0; n < N; ++n) ((float*)p.data[(size_t)is].data())[n] = rs[(size_t)n]; + for (int64_t g = 0; g < nkb; ++g) ((float*)p.data[(size_t)p.find("scale.col")].data())[g] = cf[(size_t)g]; + const int C = (16 + vc.B - 1) / vc.B; + const int8_t* aux = (const int8_t*)p.data[(size_t)ia].data(); + for (int64_t n = 0; n < N; ++n) { + const int64_t id = perm[(size_t)(base + n)]; + for (int64_t k = 0; k < K; ++k) { + uint32_t st = 0; + for (int q = C - 1; q >= 0; --q) { + const int64_t rr = n / 256 * 256 + (n % 256 - q + 256) % 256; + st = ((st << vc.B) | rad_load_bits(p.data[(size_t)ic].data() + rr * p.row_bytes(ic), vc.B, k)) & 0xFFFFu; + } + Wd[(size_t)(id * K + k)] = (double)aux[st] * rs[(size_t)n] * cf[(size_t)(k / 128)]; + } + } + const int op = 1 + 3 * (int)ci; + std::vector wq, wsc; + RadLayout lw, ls; + const int rw = stored(r, gp, op, p, { "codes", "trellis", "trellis.mad" }, &wq, &lw); + const int rsc = stored(r, gp, op + 1, p, { "scale", "scale.col" }, &wsc, &ls); + if (rw != RAD_OK || rsc != RAD_OK) { + ok(nm, false, "relayout rc " + std::to_string(rw) + "/" + std::to_string(rsc)); + return; + } + std::string why; + const bool back = restores(r, gp, op, p, { "codes", "trellis", "trellis.mad" }, wq, &why) && + restores(r, gp, op + 1, p, { "scale", "scale.col" }, wsc, &why); + ok((std::string(nm) + ": class " + std::to_string(ci) + "'s planes invert").c_str(), back, why); + ok((std::string(nm) + ": class " + std::to_string(ci) + " holds its codes' bits").c_str(), + lw.bytes <= N * K * vc.B / 8 + ((int64_t)1 << 16) + 1024, + std::to_string(lw.bytes) + " B for " + std::to_string(N * K * vc.B / 8) + " B of codes"); + std::vector ids((size_t)N); + for (int64_t n = 0; n < N; ++n) { + ids[(size_t)n] = perm[(size_t)(base + n)] + (int32_t)off; + vrow[(size_t)perm[(size_t)(base + n)]] = (int32_t)((uint32_t)vc.B << 28) | (int32_t)(n + rank * N); + } + void* d_w = dalloc(wq.size()); + void* d_s = dalloc(wsc.size()); + void* d_r = dalloc(ids.size() * 4); + if (!d_w || !d_s || !d_r) { ok(nm, false, "hipMalloc failed"); return; } + st_memcpy(d_w, wq.data(), wq.size(), hipMemcpyHostToDevice); + st_memcpy(d_s, wsc.data(), wsc.size(), hipMemcpyHostToDevice); + st_memcpy(d_r, ids.data(), ids.size() * 4, hipMemcpyHostToDevice); + ts[(size_t)op] = T(d_w, lw.dtype, { N, K }); + ts[(size_t)op + 1] = T(d_s, ls.dtype, { N, nkb }); + ts[(size_t)op + 2] = T(d_r, RAD_I32, { N }); + base += N; + } + for (size_t ci = cls.size(); ci < 4; ++ci) + for (int j = 0; j < 3; ++j) { + ts[1 + 3 * ci + (size_t)j] = T(nullptr, RAD_U8, { 1 }); + absent(ts[1 + 3 * ci + (size_t)j]); + } + void* d_m = dalloc(vrow.size() * 4); + if (!d_m) { ok(nm, false, "hipMalloc failed"); return; } + st_memcpy(d_m, vrow.data(), vrow.size() * 4, hipMemcpyHostToDevice); + ts[13] = T(d_m, RAD_I32, { V, 1 }); + + std::vector hx((size_t)(M * K)); + for (auto& v : hx) v = h_to_bf16((float)((double)(int64_t)(rnd() % 20001 - 10000) / 4000.0)); + /* The activation as the kernel holds it: rotated in f32 (h_fwht's butterflies are + * r4d_fwht_wave's, in its order), then q = rint(x * 16256 / amax) a (token, 128) under the + * scale amax / 16256. */ + std::vector xr((size_t)(M * K)); + for (int64_t m = 0; m < M; ++m) + for (int64_t g = 0; g < nkb; ++g) { + float v[128]; + for (int j = 0; j < 128; ++j) v[j] = h_bf16(hx[(size_t)(m * K + g * 128 + j)]); + h_fwht(v, 128); + float a = 0.0f; + for (int j = 0; j < 128; ++j) a = std::max(a, std::fabs(v[j])); + const float inv = a > 0.0f ? 16256.0f / a : 0.0f, sc = a / 16256.0f; + for (int j = 0; j < 128; ++j) { + const float q = std::fmin(std::fmax(rintf(v[j] * inv), -16256.0f), 16256.0f); + xr[(size_t)(m * K + g * 128 + j)] = (double)q * (double)sc; + } + } + std::vector ref((size_t)(M * V)); + double r2 = 0.0; + for (int64_t m = 0; m < M; ++m) + for (int64_t v = 0; v < V; ++v) { + double s = 0.0; + for (int64_t k = 0; k < K; ++k) s += Wd[(size_t)(v * K + k)] * xr[(size_t)(m * K + k)]; + ref[(size_t)(m * V + v)] = s; + r2 += s * s; + } + const double rms = std::sqrt(r2 / (double)(M * V)); + + void* d_x = dalloc(hx.size() * 2); + void* d_y = dalloc((size_t)(M * V) * 4); + if (!d_x || !d_y) { ok(nm, false, "hipMalloc failed"); return; } + st_memcpy(d_x, hx.data(), hx.size() * 2, hipMemcpyHostToDevice); + std::vector nan((size_t)(M * V), std::nanf("")); + st_memcpy(d_y, nan.data(), nan.size() * 4, hipMemcpyHostToDevice); + ts[0] = T(d_x, RAD_BF16, { M, K }); + ts[14] = T(d_y, RAD_F32, { M, V }); + RadArgs a; + std::memset(&a, 0, sizeof(a)); + a.t = ts.data(); a.n_t = (int)ts.size(); + a.p = gp.data(); a.n_p = (int)gp.size(); + a.world_size = 1; + const int64_t need = r->scratch(&a); + if (need > 0) { a.scratch = dalloc((size_t)need); a.scratch_bytes = need; } + const int rc = r->launch(&a, (RadStream) nullptr); + if (rc != RAD_OK || st_stream_sync(nullptr) != hipSuccess) { ok(nm, false, "rc " + std::to_string(rc)); dfree_all(); return; } + std::vector y((size_t)(M * V)); + st_memcpy(y.data(), d_y, y.size() * 4, hipMemcpyDeviceToHost); + int64_t bad = 0, first = -1, unset = 0; + double e2 = 0.0; + for (size_t i = 0; i < y.size(); ++i) { + if (std::isnan(y[i])) { ++unset; if (first < 0) first = (int64_t)i; continue; } + const double d = (double)y[i] - ref[i]; + e2 += d * d; + if (!(std::fabs(d) <= std::ldexp(rms, -18))) { if (first < 0) first = (int64_t)i; ++bad; } + } + const double rel = std::sqrt(e2 / (r2 > 0 ? r2 : 1.0)); + ok(nm, bad == 0 && unset == 0, + bad || unset ? std::to_string(bad) + " off, " + std::to_string(unset) + " unwritten of " + + std::to_string(y.size()) + ", first [" + std::to_string(first / V) + "][" + + std::to_string(first % V) + "] " + std::to_string(y[(size_t)first]) + " vs " + + std::to_string(ref[(size_t)first]) + ", rms " + std::to_string(rms) + : "rel_l2 " + std::to_string(rel)); + dfree_all(); +} + /* embed_lookup_iqr against the table its forms stood for when libr4d widened them to bf16 at * load: each value the form's int8 times its row's bf16 scale in f32, the fwht128 rotation undone * in libquant's butterfly order, rounded to bf16 to nearest even, then times `mult` with one @@ -14746,7 +15139,7 @@ static void iqr_embed_case(const Plugin& pl, const IqrEmbedCase& f, int64_t rows (double)mult); const RadKernelInfo* r = find(pl, "embed_lookup_iqr"); if (!r || !r->layout || !r->relayout) { ok(nm, false, "row or hooks absent"); return; } - static const uint32_t kU[] = { 0, RAD_U1, RAD_U2, RAD_U3, RAD_U4, RAD_U5, RAD_U6 }; + static const uint32_t kU[] = { 0, RAD_U1, RAD_U2, RAD_U3, RAD_U4, RAD_U5, RAD_U6, RAD_U7, RAD_U8 }; const int64_t nkb = dim / 128; uint64_t z = 0xABCDEFull * (uint64_t)(f.kind * 31 + f.B + f.rot); auto rnd = [&]() { @@ -14768,7 +15161,7 @@ static void iqr_embed_case(const Plugin& pl, const IqrEmbedCase& f, int64_t rows } else { p.enc = rad_enc_affine(kU[f.B], RAD_BF16, 1, 128); if (f.kind == 3) rad_enc_add_table(&p.enc, "table", RAD_I8, 1, (int64_t)1 << f.B); - else rad_enc_add_plane(&p.enc, "zero", RAD_U6, 1, 128); + else rad_enc_add_plane(&p.enc, "zero", f.B == 8 ? RAD_U8 : f.B == 7 ? RAD_U7 : RAD_U6, 1, 128); } if (f.rot) rad_enc_copy_str(p.enc.transform, "fwht128"); p.size(rows, dim); @@ -14781,7 +15174,8 @@ static void iqr_embed_case(const Plugin& pl, const IqrEmbedCase& f, int64_t rows if (f.kind == 2) for (int64_t n = 0; n < rows; ++n) for (int64_t g = 0; g < nkb; ++g) - rad_store_bits(p.data[(size_t)ia].data() + n * p.row_bytes(ia), 6, g, (uint32_t)(24 + rnd() % 17)); + rad_store_bits(p.data[(size_t)ia].data() + n * p.row_bytes(ia), std::max(f.B, 6), g, + (uint32_t)((1 << (std::max(f.B, 6) - 1)) - 8 + rnd() % 17)); else for (auto& v : p.data[(size_t)ia]) v = (uint8_t)(int8_t)((int)(rnd() % 255) - 127); for (int64_t i = 0; i < rows * nkb; ++i) { @@ -14809,7 +15203,7 @@ static void iqr_embed_case(const Plugin& pl, const IqrEmbedCase& f, int64_t rows for (int64_t k = 0; k < dim; ++k) { int q; if (f.kind == 3) q = ((const int8_t*)p.data[(size_t)ia].data())[code(n, k)]; - else if (f.kind == 2) q = (int)code(n, k) - (int)rad_load_bits(p.data[(size_t)ia].data() + n * p.row_bytes(ia), 6, k / 128); + else if (f.kind == 2) q = (int)code(n, k) - (int)rad_load_bits(p.data[(size_t)ia].data() + n * p.row_bytes(ia), std::max(f.B, 6), k / 128); else { uint32_t st = 0; for (int qq = C - 1; qq >= 0; --qq) { @@ -15909,6 +16303,14 @@ static void perf_row(const Plugin& pl, const char* name, std::vector const int64_t need = r->scratch(&a); if (need < 0) { std::printf(" %-22s scratch %lld\n", name, (long long)need); return; } if (need > 0) { a.scratch = dalloc((size_t)need); a.scratch_bytes = need; } + /* R4D_PERF_RAND_SCRATCH: random scratch bytes, so a variant that skips writing its + * scratch still multiplies operands of real entropy (WMMA power tracks the data) */ + if (need > 0 && std::getenv("R4D_PERF_RAND_SCRATCH")) { + std::vector h((size_t)need); + uint64_t z = 0x2545F4914F6CDD1Dull; + for (auto& v : h) { z ^= z << 13; z ^= z >> 7; z ^= z << 17; v = (uint8_t)z; } + st_memcpy(a.scratch, h.data(), h.size(), hipMemcpyHostToDevice); + } } /* One warm launch, which also checks the row serves this shape; a refusal is reported, not @@ -16021,6 +16423,312 @@ static void mx_perf(const Plugin& pl, int64_t N, int64_t K, int64_t M, int iters } +/* gate_had_quant_i8g against gate_quant_fp8's bf16 product and had_quant_act_i8g over it, byte for + * byte: the codes, the scales and the product. The gate is a column view of a [q|gate] row (pitch + * 2n), as a gated attention lays it out; M rows of n, each a (token, head). */ +static void gate_had_case(const Plugin& pl, int64_t M, int64_t n) { + if (!sel("gate_had_quant_i8g")) return; + char nm[120]; + std::snprintf(nm, sizeof nm, "gate_had_quant_i8g is gate_quant_fp8 then had_quant_act_i8g, M=%lld n=%lld", + (long long)M, (long long)n); + const RadKernelInfo* rh = find(pl, "gate_had_quant_i8g"); + const RadKernelInfo* rg = find(pl, "gate_quant_fp8"); + const RadKernelInfo* rq = find(pl, "had_quant_act_i8g"); + if (!rh || !rg || !rq) { ok(nm, false, "rows absent"); return; } + uint32_t z = 0x1234567u + (uint32_t)(M * 7 + n); + auto rnd = [&](float span) { + z = z * 1664525u + 1013904223u; + return ((float)(z >> 8) / 16777216.0f * 2.0f - 1.0f) * span; + }; + std::vector hg((size_t)(M * 2 * n)), hx((size_t)(M * n)); + for (auto& v : hg) v = h_to_bf16(rnd(6.0f)); + for (auto& v : hx) v = h_to_bf16(rnd(3.0f)); + void* d_g = dalloc(hg.size() * 2); + void* d_x = dalloc(hx.size() * 2); + void* d_q = dalloc((size_t)(M * n)); + void* d_s = dalloc((size_t)(M * (n / 128)) * 4); + void* d_y = dalloc((size_t)(M * n) * 2); + void* d_q2 = dalloc((size_t)(M * n)); + void* d_s2 = dalloc((size_t)(M * (n / 128)) * 4); + void* d_y2 = dalloc((size_t)(M * n) * 2); + void* d_f8 = dalloc((size_t)(M * n)); + void* d_f8s = dalloc((size_t)(M * (n / 128)) * 4); + if (!d_g || !d_x || !d_q || !d_s || !d_y || !d_q2 || !d_s2 || !d_y2 || !d_f8 || !d_f8s) { + ok(nm, false, "hipMalloc failed"); + return; + } + st_memcpy(d_g, hg.data(), hg.size() * 2, hipMemcpyHostToDevice); + st_memcpy(d_x, hx.data(), hx.size() * 2, hipMemcpyHostToDevice); + RadTensor gate = T((uint8_t*)d_g + n * 2, RAD_BF16, { M, n }); + gate.stride[0] = 2 * n; + auto run = [&](const RadKernelInfo* r, std::vector ts, std::vector ps) { + RadArgs a; + std::memset(&a, 0, sizeof(a)); + a.t = ts.data(); a.n_t = (int)ts.size(); a.p = ps.data(); a.n_p = (int)ps.size(); + a.world_size = 1; + const int rc = r->launch(&a, (RadStream) nullptr); + return rc != RAD_OK ? rc : (st_stream_sync(nullptr) != hipSuccess ? -1000 : RAD_OK); + }; + const std::vector pg = { PI("M", M), PI("n", n), PI("group", 128), PS("dtype", "bf16"), + PS("act", "sigmoid") }; + int e = run(rh, { gate, T(d_x, RAD_BF16, { M, n }), T(d_q, RAD_I8, { M, n }), + T(d_s, RAD_F32, { M, n / 128 }), T(d_y, RAD_BF16, { M, n }) }, pg); + if (e == RAD_OK) + e = run(rg, { gate, T(d_x, RAD_BF16, { M, n }), T(d_f8, RAD_F8E4M3, { M, n }), + T(d_f8s, RAD_F32, { M, n / 128 }), T(d_y2, RAD_BF16, { M, n }) }, pg); + if (e == RAD_OK) + e = run(rq, { T(d_y2, RAD_BF16, { M, n }), T(d_q2, RAD_I8, { M, n }), T(d_s2, RAD_F32, { M, n / 128 }) }, + { PI("M", M), PI("n", n), PI("group", 128), PS("dtype", "bf16") }); + if (e != RAD_OK) { ok(nm, false, "rc " + std::to_string(e)); return; } + auto fetch = [](void* d, size_t b) { + std::vector h(b); + st_memcpy(h.data(), d, b, hipMemcpyDeviceToHost); + return h; + }; + const bool same = fetch(d_q, (size_t)(M * n)) == fetch(d_q2, (size_t)(M * n)) && + fetch(d_s, (size_t)(M * (n / 128)) * 4) == fetch(d_s2, (size_t)(M * (n / 128)) * 4) && + fetch(d_y, (size_t)(M * n) * 2) == fetch(d_y2, (size_t)(M * n) * 2); + ok(nm, same, same ? "" : "codes, scales or product differ"); +} + +/* The V4 trunk's IQR planes for an [N, K] weight: a 2^16-state computed trellis of B-bit codes in + * 256-row runs, one f32 scale a row (each its own, 7 significant bits), a power of two a 128-K block, + * fwht128; random codes from `z`. */ +static Planes iqr_v4_planes(int64_t N, int64_t K, int B, uint64_t z, bool bf16s = false) { + auto rnd = [&]() { + z += 0x9E3779B97F4A7C15ull; + uint64_t x = z; + x = (x ^ (x >> 30)) * 0xBF58476D1CE4E5B9ull; + x = (x ^ (x >> 27)) * 0x94D049BB133111EBull; + return x ^ (x >> 31); + }; + static const uint32_t kU[] = { 0, RAD_U1, RAD_U2, RAD_U3, RAD_U4, RAD_U5, RAD_U6, RAD_U7, RAD_U8 }; + constexpr int L = 16; + Planes p; + rad_enc_clear(&p.enc); + rad_enc_copy_str(p.enc.scheme, "trellis"); + rad_enc_add_plane(&p.enc, "codes", kU[B], 1, 1); + if (bf16s) rad_enc_add_plane(&p.enc, "scale", RAD_BF16, 1, 128); + else rad_enc_add_plane(&p.enc, "scale", RAD_F32, 1, 0); + const int t = rad_enc_add_table(&p.enc, "trellis", RAD_I8, (int64_t)1 << L, 1); + p.enc.plane[t].block[0] = 256; + p.enc.plane[t].block[1] = 0; + rad_enc_add_table(&p.enc, "trellis.mad", RAD_U32, 2, 1); + if (!bf16s) rad_enc_add_plane(&p.enc, "scale.col", RAD_F32, 0, 128); + rad_enc_copy_str(p.enc.transform, "fwht128"); + p.size(N, K); + for (auto& v : p.data[(size_t)p.find("codes")]) v = (uint8_t)rnd(); + const uint32_t A = (uint32_t)(rnd() & 0xFFFFFFu) | 1u, Bc = (uint32_t)rnd(); + uint32_t* ab = (uint32_t*)p.data[(size_t)p.find("trellis.mad")].data(); + ab[0] = A; + ab[1] = Bc; + uint8_t* tab = p.data[(size_t)t].data(); + for (uint32_t st = 0; st < (1u << L); ++st) { + const uint32_t h = ((st & 0xFFFFFFu) * A + Bc) & 0x3F3F3F3Fu; + tab[st] = (uint8_t)(int8_t)((int)((h & 0xFFu) + ((h >> 8) & 0xFFu) + ((h >> 16) & 0xFFu) + (h >> 24)) - 126); + } + if (bf16s) { + for (int64_t i = 0; i < N * (K / 128); ++i) + rad_store_f32(p.data[(size_t)p.find("scale")].data(), RAD_BF16, i, + std::ldexp(1.0f + (float)(rnd() % 64) / 64.0f, -9 - (int)(rnd() % 4))); + } else { + for (int64_t n = 0; n < N; ++n) + ((float*)p.data[(size_t)p.find("scale")].data())[n] = + std::ldexp(1.0f + (float)(rnd() % 64) / 64.0f, -9 - (int)(rnd() % 4)); + for (int64_t g = 0; g < K / 128; ++g) + ((float*)p.data[(size_t)p.find("scale.col")].data())[g] = std::ldexp(1.0f, (int)(rnd() % 4) - 1); + } + return p; +} + +/* gemm_iqr_gated against its chain, gemm_iqr_nt_m64 then gated_had_quant_i8g, byte for byte: the + * codes, the scales and the bf16 product, on the V4 trunk's form; and the gated row stores the + * weight as the GEMM row does, so the two read one copy. */ +static void iqr_gated_case(const Plugin& pl, int B, int64_t M, int64_t n, int64_t K) { + if (!sel("gemm_iqr_gated") && !sel("gemm_iqr")) return; + const int64_t N = 2 * n, nkb = K / 128; + char nm[160]; + std::snprintf(nm, sizeof nm, "gemm_iqr_gated trellis-mad B=%d row-f32 M=%lld n=%lld K=%lld", B, + (long long)M, (long long)n, (long long)K); + const RadKernelInfo* rg = find(pl, "gemm_iqr_gated"); + const RadKernelInfo* rm = find(pl, "gemm_iqr_nt_m64"); + const RadKernelInfo* rq = find(pl, "gated_had_quant_i8g"); + if (!rg || !rm || !rq) { ok(nm, false, "rows absent"); return; } + Planes p = iqr_v4_planes(N, K, B, 0x6A7ED00Du + (uint64_t)(B * 97 + M)); + std::vector lp = { PI("N", N), PI("K", K), PI("group", 128), PS("dtype", "i8a8h") }; + std::vector wq, wsc, wq2, wsc2; + RadLayout lw, ls; + if (stored(rg, lp, 2, p, { "codes", "trellis", "trellis.mad" }, &wq, &lw) != RAD_OK || + stored(rg, lp, 3, p, { "scale", "scale.col" }, &wsc, &ls) != RAD_OK || + stored(rm, lp, 2, p, { "codes", "trellis", "trellis.mad" }, &wq2) != RAD_OK || + stored(rm, lp, 3, p, { "scale", "scale.col" }, &wsc2) != RAD_OK) { + ok(nm, false, "relayout refused"); + return; + } + ok((std::string(nm) + ": the weight stored as gemm_iqr_nt_m64 stores it").c_str(), wq == wq2 && wsc == wsc2); + uint64_t z = 0xA5A5F00Du + (uint64_t)M; + auto rnd = [&]() { z ^= z << 13; z ^= z >> 7; z ^= z << 17; return z; }; + std::vector ha((size_t)(M * K)); + std::vector has((size_t)(M * nkb)); + for (auto& v : ha) v = (int8_t)((int)(rnd() % 255) - 127); + for (auto& v : has) v = std::ldexp(1.0f + (float)(rnd() % 256) / 256.0f, -5); + void* d_a = dalloc(ha.size()); + void* d_as = dalloc(has.size() * 4); + void* d_w = dalloc(wq.size()); + void* d_s = dalloc(wsc.size()); + void* d_q = dalloc((size_t)(M * n)); + void* d_sc = dalloc((size_t)(M * (n / 128)) * 4); + void* d_yb = dalloc((size_t)(M * n) * 2); + void* d_y = dalloc((size_t)(M * N) * 2); + void* d_q2 = dalloc((size_t)(M * n)); + void* d_sc2 = dalloc((size_t)(M * (n / 128)) * 4); + void* d_yb2 = dalloc((size_t)(M * n) * 2); + if (!d_a || !d_as || !d_w || !d_s || !d_q || !d_sc || !d_yb || !d_y || !d_q2 || !d_sc2 || !d_yb2) { + ok(nm, false, "hipMalloc failed"); + return; + } + st_memcpy(d_a, ha.data(), ha.size(), hipMemcpyHostToDevice); + st_memcpy(d_as, has.data(), has.size() * 4, hipMemcpyHostToDevice); + st_memcpy(d_w, wq.data(), wq.size(), hipMemcpyHostToDevice); + st_memcpy(d_s, wsc.data(), wsc.size(), hipMemcpyHostToDevice); + auto launch = [&](const RadKernelInfo* k, std::vector ts, std::vector ps) { + RadArgs a; + std::memset(&a, 0, sizeof(a)); + a.t = ts.data(); a.n_t = (int)ts.size(); + a.p = ps.data(); a.n_p = (int)ps.size(); + a.world_size = 1; + if (k->scratch) { + const int64_t need = k->scratch(&a); + if (need > 0) { a.scratch = dalloc((size_t)need); a.scratch_bytes = need; } + } + const int rc = k->launch(&a, (RadStream) nullptr); + return rc == RAD_OK && st_stream_sync(nullptr) == hipSuccess ? RAD_OK : (rc ? rc : -1); + }; + const RadTensor tw = T(d_w, lw.dtype, { N, K }), ts = T(d_s, ls.dtype, { N, nkb }); + int r1 = RAD_OK; + /* Twice: the second call finds the group counters the first left at zero. */ + for (int rep = 0; rep < 2 && r1 == RAD_OK; ++rep) + r1 = launch(rg, { T(d_a, RAD_I8, { M, K }), T(d_as, RAD_F32, { M, nkb }), tw, ts, + T(d_q, RAD_I8, { M, n }), T(d_sc, RAD_F32, { M, n / 128 }), + T(d_yb, RAD_BF16, { M, n }) }, + { PI("M", M), PI("N", N), PI("K", K), PI("group", 128), PS("dtype", "i8a8h"), + PS("act", "silu") }); + std::vector tm = { T(d_a, RAD_I8, { M, K }), T(d_as, RAD_F32, { M, nkb }), tw, ts, + T(d_y, RAD_BF16, { M, N }), T(nullptr, RAD_F32, { 1 }), + T(nullptr, RAD_U8, { 1 }) }; + absent(tm[5]); absent(tm[6]); + const int r2 = launch(rm, tm, { PI("M", M), PI("N", N), PI("K", K), PI("group", 128), PS("dtype", "i8a8h") }); + const int r3 = r2 == RAD_OK + ? launch(rq, { T(d_y, RAD_BF16, { M, N }), T(d_q2, RAD_I8, { M, n }), + T(d_sc2, RAD_F32, { M, n / 128 }), T(d_yb2, RAD_BF16, { M, n }) }, + { PI("M", M), PI("n", n), PI("group", 128), PS("dtype", "bf16"), PS("act", "silu") }) + : r2; + if (r1 != RAD_OK || r3 != RAD_OK) { + ok(nm, false, "rc " + std::to_string(r1) + " (chain " + std::to_string(r3) + ")"); + return; + } + std::vector q((size_t)(M * n)), q2(q.size()), sc((size_t)(M * (n / 128)) * 4), sc2(sc.size()), + yb((size_t)(M * n) * 2), yb2(yb.size()); + st_memcpy(q.data(), d_q, q.size(), hipMemcpyDeviceToHost); + st_memcpy(q2.data(), d_q2, q2.size(), hipMemcpyDeviceToHost); + st_memcpy(sc.data(), d_sc, sc.size(), hipMemcpyDeviceToHost); + st_memcpy(sc2.data(), d_sc2, sc2.size(), hipMemcpyDeviceToHost); + st_memcpy(yb.data(), d_yb, yb.size(), hipMemcpyDeviceToHost); + st_memcpy(yb2.data(), d_yb2, yb2.size(), hipMemcpyDeviceToHost); + size_t dq = 0, ds = 0, dy = 0; + for (size_t i = 0; i < q.size(); ++i) dq += q[i] != q2[i]; + for (size_t i = 0; i < sc.size(); i += 4) ds += std::memcmp(&sc[i], &sc2[i], 4) != 0; + for (size_t i = 0; i < yb.size(); i += 2) dy += std::memcmp(&yb[i], &yb2[i], 2) != 0; + char d[160]; + std::snprintf(d, sizeof d, "%zu codes, %zu scales, %zu products differ", dq, ds, dy); + ok(nm, dq == 0 && ds == 0 && dy == 0, d); +} + +/* --perfiqr: the IQR row at one shape over the V4 trunk's form (a 2^16-state computed trellis of + * B-bit codes in 256-row runs, one f32 scale a row, fwht128) with random codes, the weight streamed + * from DRAM (rotated copies), then the MXFP4 rows at the same shape (--perfmxd). Timing only. */ +static void iqr_perf(const Plugin& pl, int64_t N, int64_t K, int64_t M, int B, int iters) { + /* B >= 10: the head-fed form (V4's v4h grids), B - 10 bits under a bf16 scale a (row, 128). */ + const bool bf16s = B >= 10; + if (bf16s) B -= 10; + if (N % 256 || K % 256 || M < 1 || B < 2 || B > 8) { + std::printf("--perfiqr: N and K multiples of 256, M >= 1, 2 <= B <= 8 (+10: bf16 scales)\n"); + return; + } + const char* row = M <= 64 ? "gemm_iqr_nt_m64" : "gemm_iqr_tiled"; + const RadKernelInfo* r = find(pl, row); + if (!r || !r->layout || !r->relayout) { std::printf(" %-22s row or hooks absent\n", row); return; } + const int64_t nkb = K / 128; + uint64_t z = 0x51ED2701u + (uint64_t)B; + auto rnd = [&]() { + z += 0x9E3779B97F4A7C15ull; + uint64_t x = z; + x = (x ^ (x >> 30)) * 0xBF58476D1CE4E5B9ull; + x = (x ^ (x >> 27)) * 0x94D049BB133111EBull; + return x ^ (x >> 31); + }; + Planes p = iqr_v4_planes(N, K, B, z, bf16s); + std::vector lp = { PI("N", N), PI("K", K), PI("group", 128), PS("dtype", "i8a8h") }; + std::vector wq, wsc; + RadLayout lw, ls; + if (stored(r, lp, 2, p, { "codes", "trellis", "trellis.mad" }, &wq, &lw) != RAD_OK || + (bf16s ? stored(r, lp, 3, p, { "scale" }, &wsc, &ls) + : stored(r, lp, 3, p, { "scale", "scale.col" }, &wsc, &ls)) != RAD_OK) { + std::printf(" %-22s relayout refused\n", row); + return; + } + std::vector ha((size_t)(M * K)); + std::vector has((size_t)(M * nkb)); + for (auto& v : ha) v = (int8_t)((int)(rnd() % 255) - 127); + for (auto& v : has) v = std::ldexp(1.0f + (float)(rnd() % 256) / 256.0f, -7); + const int copies = (int)std::max(2, (256ll << 20) / (int64_t)wq.size() + 1); + void* d_a = dalloc(ha.size()); + void* d_as = dalloc(has.size() * 4); + void* d_w = dalloc(wq.size() * (size_t)copies); + void* d_s = dalloc(wsc.size()); + void* d_y = dalloc((size_t)(M * N) * 2); + if (!d_a || !d_as || !d_w || !d_s || !d_y) { std::printf(" %-22s hipMalloc failed\n", row); return; } + st_memcpy(d_a, ha.data(), ha.size(), hipMemcpyHostToDevice); + st_memcpy(d_as, has.data(), has.size() * 4, hipMemcpyHostToDevice); + for (int c = 0; c < copies; ++c) + st_memcpy((uint8_t*)d_w + (size_t)c * wq.size(), wq.data(), wq.size(), hipMemcpyHostToDevice); + st_memcpy(d_s, wsc.data(), wsc.size(), hipMemcpyHostToDevice); + std::vector tq = { + T(d_a, RAD_I8, { M, K }), T(d_as, RAD_F32, { M, nkb }), T(d_w, lw.dtype, { N, K }), + T(d_s, ls.dtype, { N, nkb }), T(d_y, RAD_BF16, { M, N }), T(nullptr, RAD_F32, { 1 }), + T(nullptr, RAD_U8, { 1 }), + }; + absent(tq[5]); absent(tq[6]); + std::vector gp = { PI("M", M), PI("N", N), PI("K", K), PI("group", 128), PS("dtype", "i8a8h") }; + char nm[64]; + std::snprintf(nm, sizeof nm, "iqr k%d%s %s", B, bf16s ? "h" : "", M <= 64 ? "m64" : "tiled"); + std::printf("\nN=%lld K=%lld M=%lld\n", (long long)N, (long long)K, (long long)M); + perf_row(pl, row, tq, gp, d_w, wq.size(), copies, (double)(wq.size() + wsc.size()), iters, 2, nm); + /* At a gate_up shape to 16 tokens: the gated fold, and the quantiser it replaces. */ + if (N % 256 == 0 && M <= 16) { + const int64_t n = N / 2; + void* d_q = dalloc((size_t)(M * n)); + void* d_sc = dalloc((size_t)(M * (n / 128)) * 4); + if (d_q && d_sc) { + perf_row(pl, "gemm_iqr_gated", + { T(d_a, RAD_I8, { M, K }), T(d_as, RAD_F32, { M, nkb }), T(d_w, lw.dtype, { N, K }), + T(d_s, ls.dtype, { N, nkb }), T(d_q, RAD_I8, { M, n }), T(d_sc, RAD_F32, { M, n / 128 }), + T(nullptr, RAD_BF16, {}) }, + { PI("M", M), PI("N", N), PI("K", K), PI("group", 128), PS("dtype", "i8a8h"), + PS("act", "silu") }, + d_w, wq.size(), copies, (double)(wq.size() + wsc.size()), iters, 2); + RadTensor nob = T(nullptr, RAD_BF16, { M, n }); + absent(nob); + perf_row(pl, "gated_had_quant_i8g", + { T(d_y, RAD_BF16, { M, N }), T(d_q, RAD_I8, { M, n }), T(d_sc, RAD_F32, { M, n / 128 }), nob }, + { PI("M", M), PI("n", n), PI("group", 128), PS("dtype", "bf16"), PS("act", "silu") }, + d_y, (size_t)(M * N * 2), 1, (double)(M * N * 2), iters, 0); + } + } + dfree_all(); + mx_perf(pl, N, K, M, iters); +} + /* ------------------------------------------------------------------ the small ops, timed * * Most of a decode step's kernels are small ops moving a few tens of kilobytes, so their cost is @@ -16810,8 +17518,10 @@ static void mhc_check(const Plugin& pl, const char* name, int64_t rows, int64_t dlclose(ref); return; } - const bool clipped = !std::strcmp(row->op, "swiglu_clamped"); - const bool routed = !std::strcmp(row->op, "router_sigmoid_topk"); + const bool clipped = + !std::strcmp(row->op, "swiglu_clamped") || !std::strcmp(row->op, "swiglu_step"); + const bool grouped = !std::strcmp(row->op, "router_sigmoid_group_topk"); + const bool routed = grouped || !std::strcmp(row->op, "router_sigmoid_topk"); const bool pooled = !std::strcmp(row->op, "dsa_pool"); const bool query = !std::strcmp(row->op, "dsa_query"); const bool projection = !std::strcmp(row->op, "gemm_nt_f32"); @@ -16821,6 +17531,10 @@ static void mhc_check(const Plugin& pl, const char* name, int64_t rows, int64_t ps.push_back(PI("top_k", 8)); ps.push_back(PI("norm", hc)); ps.push_back(PF("route_scale", 2.5)); + if (grouped) { /* Ling's grouping: 8 groups, the best 4 by their top-2 sums */ + ps.push_back(PI("n_group", 8)); + ps.push_back(PI("topk_group", 4)); + } } else if (projection) { ps.push_back(PI("N", n)); ps.push_back(PI("K", hc)); @@ -17410,7 +18124,7 @@ static void dsa_score_check(const Plugin& pl, int64_t rows, int64_t blocks, bool } static void mla_project_check(const Plugin& pl, int64_t rows, int64_t heads, const char* mode, - bool flat = false) { + bool flat = false, int64_t head_dim = 256) { const auto* row = find(pl, "mla_project_bf16"); if (!row || !g_plugin) { ok("MLA projection", false, "kernel missing"); @@ -17434,7 +18148,7 @@ static void mla_project_check(const Plugin& pl, int64_t rows, int64_t heads, con dlclose(ref); return; } - std::vector ps = { PI("M", rows + 7), PI("heads", heads), PI("head_dim", 256), + std::vector ps = { PI("M", rows + 7), PI("heads", heads), PI("head_dim", head_dim), PI("latent_dim", 512), PS("mode", mode), PS("dtype", "bf16") }; std::vector host, device; std::vector> bytes(3); @@ -17518,8 +18232,8 @@ static void mla_project_check(const Plugin& pl, int64_t rows, int64_t heads, con } for (size_t j = 0; j < got.size(); ++j) if (!written[j]) guards = guards && got[j] == 0xa5; - ok(fmt("MLA %s M=%lld H=%lld max error %.8g", mode, (long long)rows, (long long)heads, - max_error) + ok(fmt("MLA %s M=%lld H=%lld D=%lld max error %.8g", mode, (long long)rows, + (long long)heads, (long long)head_dim, max_error) .c_str(), matches); ok("MLA projection pitched tensors and guards", guards); @@ -17529,6 +18243,158 @@ static void mla_project_check(const Plugin& pl, int64_t rows, int64_t heads, con dlclose(ref); } +/* mla_attn_paged against libref: several sequences with deeper contexts than their queries, an + * unmapped page, the rotary query as a column view of a wider projection, an optional head gate, + * pitched rows and poisoned margins. */ +static void mla_paged_check(const Plugin& pl, std::vector qlen, std::vector ctx, + int64_t heads, bool gated) { + const char* what = "mla_attn_paged_bf16"; + const auto* row = find(pl, what); + if (!row || !g_plugin) { + ok(what, false, "kernel missing"); + return; + } + std::string path(g_plugin); + path = path.substr(0, path.find_last_of('/') + 1) + "libref.so"; + void* ref = dlopen(path.c_str(), RTLD_NOW | RTLD_LOCAL); + if (!ref) { + ok(what, false, "oracle missing"); + return; + } + auto count = (int (*)())dlsym(ref, "rad_kernel_count"); + auto at = (const RadKernelInfo* (*)(int))dlsym(ref, "rad_kernel_at"); + const RadKernelInfo* oracle = nullptr; + if (count && at) + for (int i = 0; i < count(); ++i) + if (!std::strcmp(at(i)->op, "mla_attn_paged")) oracle = at(i); + if (!oracle) { + ok(what, false, "oracle row missing"); + dlclose(ref); + return; + } + const int64_t L = 512, R = 64, bs = 16, S = (int64_t)qlen.size(); + int64_t M = 0, bmax = 0, pages = 0; + for (int64_t s = 0; s < S; ++s) { + M += qlen[(size_t)s]; + bmax = std::max(bmax, (ctx[(size_t)s] + bs - 1) / bs); + pages += (ctx[(size_t)s] + bs - 1) / bs; + } + std::vector ps = { PI("M", M + 5), PI("heads", heads), + PI("latent_dim", L), PI("rope_dim", R), + PI("block_size", bs), PF("scale", 1 / std::sqrt(192.0)), + PS("dtype", "bf16") }; + /* Operands: q, q_rope (a column view at 192 a head), kv, block_table, seqused, cu_seqlens, + * gate, out. */ + std::vector host(8); + host[0] = T(nullptr, RAD_BF16, { M, heads, L }); + host[0].stride[1] = L + 3; + host[0].stride[0] = heads * (L + 3) + 11; + host[1] = T(nullptr, RAD_BF16, { M, heads, R }); + host[1].stride[1] = 192; + host[1].stride[0] = heads * 192 + 4; + host[2] = T(nullptr, RAD_BF16, { pages, 1, bs, L + R }); + host[3] = T(nullptr, RAD_I32, { S, bmax }); + host[3].stride[0] = bmax + 2; + host[4] = T(nullptr, RAD_I32, { S }); + host[5] = T(nullptr, RAD_I32, { S + 1 }); + if (gated) { + host[6] = T(nullptr, RAD_BF16, { M, heads + 3 }); + host[6].stride[0] = heads + 9; + } + host[7] = T(nullptr, RAD_BF16, { M, heads, L }); + host[7].stride[1] = L + 5; + host[7].stride[0] = heads * (L + 5) + 7; + std::vector> bytes(8); + std::vector allocations(8, nullptr); + std::vector device(8); + bool allocated = true; + for (int i = 0; i < 8 && allocated; ++i) { + RadTensor& t = host[(size_t)i]; + if (!t.rank) continue; + int64_t elements = t.shape[0] * t.stride[0]; + bytes[(size_t)i].assign((size_t)elements * esz(t.dtype) + 256, 0xa5); + t.data = bytes[(size_t)i].data() + 128; + const bool bf = t.dtype == RAD_BF16 && i != 7; + if (bf) + for (int64_t e = 0; e < elements; ++e) { + const float v = + (float)((int)(st_mix32((uint32_t)(e * 7 + i * 7919)) % 2001) - 1000) / + (i == 2 ? 1000.0f : i == 6 ? 300.0f : 250.0f); + ((uint16_t*)t.data)[e] = h_to_bf16(v); + } + if (i == 3) { + /* Pages in a scrambled order; the second page of the deepest sequence unmapped. */ + int next = 0; + for (int64_t s = 0; s < S; ++s) + for (int64_t b = 0; b < bmax; ++b) { + int v = -1; + if (b < (ctx[(size_t)s] + bs - 1) / bs) v = (int)((next++ * 5 + 3) % pages); + if (s == S - 1 && b == 1 && ctx[(size_t)s] > 2 * bs) v = -1; + ((int*)t.data)[s * t.stride[0] + b] = v; + } + } + if (i == 4) + for (int64_t s = 0; s < S; ++s) ((int*)t.data)[s] = (int)ctx[(size_t)s]; + if (i == 5) { + int c = 0; + for (int64_t s = 0; s <= S; ++s) { + ((int*)t.data)[s] = c; + if (s < S) c += (int)qlen[(size_t)s]; + } + } + allocations[(size_t)i] = dalloc(bytes[(size_t)i].size()); + if (!allocations[(size_t)i]) { + allocated = false; + break; + } + st_memcpy(allocations[(size_t)i], bytes[(size_t)i].data(), bytes[(size_t)i].size(), + hipMemcpyHostToDevice); + device[(size_t)i] = t; + device[(size_t)i].data = (char*)allocations[(size_t)i] + 128; + } + std::string label = fmt("mla_attn_paged S=%lld M=%lld H=%lld%s", (long long)S, (long long)M, + (long long)heads, gated ? " gated" : ""); + if (!allocated) { + ok(label.c_str(), false, "allocation failed"); + dlclose(ref); + return; + } + RadArgs args{}; + args.t = host.data(); + args.n_t = 8; + args.p = ps.data(); + args.n_p = (int)ps.size(); + args.world_size = 1; + const int rc = oracle->launch(&args, nullptr); + ok(fmt("%s host oracle", label.c_str()).c_str(), rc == RAD_OK); + if (rc == RAD_OK) { + run_case(row, device, ps); + std::vector got(bytes[7].size()); + st_memcpy(got.data(), allocations[7], got.size(), hipMemcpyDeviceToHost); + std::vector written(got.size(), false); + bool matches = true, guards = true; + float max_error = 0; + const auto& t = host[7]; + for (int64_t r = 0; r < M; ++r) + for (int64_t h = 0; h < heads; ++h) + for (int64_t d = 0; d < L; ++d) { + const long off = r * t.stride[0] + h * t.stride[1] + d; + const float want = h_bf16(((uint16_t*)t.data)[off]), + actual = h_bf16(((uint16_t*)(got.data() + 128))[off]); + const float error = std::fabs(actual - want); + max_error = std::max(max_error, error); + matches = matches && std::isfinite(actual) && + error <= 0.002f + 0.008f * std::fabs(want); + written[128 + off * 2] = written[129 + off * 2] = true; + } + for (size_t j = 0; j < got.size(); ++j) + if (!written[j]) guards = guards && got[j] == 0xa5; + ok(fmt("%s max error %.6g", label.c_str(), max_error).c_str(), matches); + ok(fmt("%s pitched rows and guards", label.c_str()).c_str(), guards); + } + dlclose(ref); +} + /* An environment variable set (or, with a null value, cleared) for one scope and restored after * it: the MLA launcher reads its counting switch at every call. */ struct ScopedEnv { @@ -17656,6 +18522,10 @@ static void mla_check(const Plugin& pl, int64_t rows, int64_t heads, int64_t blo std::vector ps = { PI("M", rows), PI("latent_dim", 512), PI("heads", heads), PI("blocks", blocks), PI("block_size", 4), PF("scale", 0.0625), PS("dtype", "bf16") }; + /* An *_fp8kv row reads an E4M3 cache: the oracle shapes it from `kv_dtype` and reads the same + * codes, so the comparison is of the attention alone, at the bf16 rows' tolerance. */ + const bool fp8kv = std::strstr(name, "fp8kv") != nullptr; + if (fp8kv) ps.push_back(PS("kv_dtype", "fp8_e4m3")); std::vector host, device; std::vector> bytes(5); std::vector allocations; @@ -17705,6 +18575,9 @@ static void mla_check(const Plugin& pl, int64_t rows, int64_t heads, int64_t blo 1000; if (t.dtype == RAD_BF16) ((uint16_t*)t.data)[off] = h_to_bf16(i == 0 ? v * 0.25f : v); + else if (t.dtype == RAD_F8E4M3) + /* Codes over most of E4M3's exponents, subnormals included. */ + ((uint8_t*)t.data)[off] = rad_f32_to_fp8e4m3(v * v * v * 8.0f); else if (fill == MlaFill::full) ((int32_t*)t.data)[off] = i == 2 ? (int)(r * blocks + a1) : (int)(blocks * 4); @@ -18229,6 +19102,172 @@ static void kda_check(const Plugin& pl, const char* mode, bool cold, int accepte dlclose(ref); } +/* ssd_update against libref, as kda_check: two sequences over pitched planes, in prefill or verify, + * warm or cold, read at an accepted prefix; output, every written state slot and the red zones. */ +static void ssd_check(const Plugin& pl, const char* mode, bool cold, int accepted_count, + bool anchor = false) { + const char* name = "ssd_update_n128_bf16"; + const auto* row = find(pl, name); + if (!row || !g_plugin) { + ok(name, false, "row or plugin path absent"); + return; + } + std::string path(g_plugin); + path = path.substr(0, path.find_last_of('/') + 1) + "libref.so"; + void* ref = dlopen(path.c_str(), RTLD_NOW | RTLD_LOCAL); + if (!ref) { + ok(name, false, "reference plugin unavailable"); + return; + } + auto count = (int (*)(void))dlsym(ref, "rad_kernel_count"); + auto at = (const RadKernelInfo* (*)(int))dlsym(ref, "rad_kernel_at"); + const RadKernelInfo* oracle = nullptr; + if (count && at) + for (int i = 0; i < count(); ++i) + if (!std::strcmp(at(i)->op, "ssd_update")) { + oracle = at(i); + break; + } + if (!oracle) { + ok(name, false, "reference operation unavailable"); + dlclose(ref); + return; + } + /* Two heads a group, so B and C are shared and the group index is exercised. */ + const int H = 4, G = 2, T0 = 6, P = 64, N = 128; + const std::vector> shapes = { + { T0, H, P }, { T0, G, N }, { T0, G, N }, { T0, H }, { H }, + { H }, { H }, { 8, H, P, N }, { 2, anchor ? 6 : 3 }, { 3 }, + { 2 }, { 2 }, { T0, H, P }, + }; + std::vector> bytes(13), visible(13); + std::vector host, device; + std::vector allocations; + auto offset = [](const RadTensor& t, int64_t logical) { + int64_t physical = 0; + for (int d = (int)t.rank - 1; d >= 0; --d) { + physical += (logical % t.shape[d]) * t.stride[d]; + logical /= t.shape[d]; + } + return physical; + }; + for (int i = 0; i < 13; ++i) { + /* A_log, dt_bias and D (4..6) are f32, as the plugin declares them, and so is the state. */ + const uint32_t dt = i >= 8 && i <= 11 ? (uint32_t)RAD_I32 + : i >= 4 && i <= 7 ? (uint32_t)RAD_F32 + : (uint32_t)RAD_BF16; + auto ht = T(nullptr, dt, shapes[(size_t)i]); + if (ht.rank >= 2) { + int64_t pitch = ht.shape[ht.rank - 1] + 4; + for (int d = (int)ht.rank - 2; d >= 0; --d) { + ht.stride[d] = pitch; + pitch = ht.shape[d] * pitch + 8; + } + } + const size_t size = (size_t)(ht.shape[0] * ht.stride[0]) * esz(dt) + 256; + bytes[(size_t)i].assign(size, 0xa5); + visible[(size_t)i].assign(size, 0); + ht.data = bytes[(size_t)i].data() + 128; + int64_t count0 = 1; + for (uint32_t d = 0; d < ht.rank; ++d) count0 *= ht.shape[d]; + for (int64_t j = 0; j < count0; ++j) { + const int64_t off0 = offset(ht, j); + const float value = + (float)((int)(st_mix32((uint32_t)(i * 173 + j)) % 2001) - 1000) / 2000; + if (dt == RAD_F32) + ((float*)ht.data)[off0] = value; + else if (dt == RAD_BF16) + ((uint16_t*)ht.data)[off0] = h_to_bf16(value); + else + ((int*)ht.data)[off0] = 0; + for (size_t b0 = 0; b0 < esz(dt); ++b0) + visible[(size_t)i][128 + (size_t)off0 * esz(dt) + b0] = 1; + } + host.push_back(ht); + } + auto integers = [&](int i, std::initializer_list values) { + int64_t j = 0; + for (int v : values) ((int*)host[(size_t)i].data)[offset(host[(size_t)i], j++)] = v; + }; + if (anchor) { + /* Committed 2 and 5, scratch 0 and 6, each scratch's counts zero: nothing to replay. */ + integers(8, { 2, 2, 2, 0, 0, 0, 5, 5, 5, 6, 6, 6 }); + integers(9, { 0, 3, 6 }); + for (int slot : { 0, 6 }) + for (int h = 0; h < H; ++h) + ((float*)host[7].data)[slot * host[7].stride[0] + h * host[7].stride[1]] = 0; + } else { + integers(8, { 2, 0, 3, 5, 6, 7 }); + integers(9, { 1, 3, 6 }); + } + integers(10, { accepted_count, 1 }); + integers(11, { cold ? 0 : 1, 1 }); + for (int i = 0; i < 13; ++i) { + void* d = dalloc(bytes[(size_t)i].size()); + if (!d) { + ok(name, false, "allocation failed"); + dlclose(ref); + return; + } + allocations.push_back(d); + st_memcpy(d, bytes[(size_t)i].data(), bytes[(size_t)i].size(), hipMemcpyHostToDevice); + auto dt = host[(size_t)i]; + dt.data = (char*)d + 128; + device.push_back(dt); + } + std::vector ps = { + PI("M", T0 + 7), PI("heads", H), PI("head_dim", P), PI("d_state", N), + PI("groups", G), PS("mode", mode), PS("dtype", "bf16"), + PS("state_form", anchor ? "anchor" : "per_candidate") + }; + RadArgs args{}; + args.t = host.data(); + args.n_t = 13; + args.p = ps.data(); + args.n_p = (int)ps.size(); + args.world_size = 1; + const int rc = oracle->launch(&args, nullptr); + ok("SSD host oracle", rc == RAD_OK); + if (rc == RAD_OK) run_case(row, device, ps); + if (rc == RAD_OK && anchor && !std::strcmp(mode, "verify")) { + // A second window must replay only the accepted prefix of the first window. + integers(11, { 1, 1 }); + st_memcpy(allocations[11], bytes[11].data(), bytes[11].size(), hipMemcpyHostToDevice); + args.t = host.data(); + ok("SSD anchor second-window host replay", oracle->launch(&args, nullptr) == RAD_OK); + run_case(row, device, ps); + } + bool matches = rc == RAD_OK, guards = true; + for (int i : { 7, 12 }) + if (rc == RAD_OK) { + std::vector got(bytes[(size_t)i].size()); + st_memcpy(got.data(), allocations[(size_t)i], got.size(), hipMemcpyDeviceToHost); + for (size_t j = 0; j < got.size(); ++j) + if (!visible[(size_t)i][j]) guards = guards && got[j] == 0xa5; + const auto& ht = host[(size_t)i]; + int64_t count0 = 1; + for (uint32_t d = 0; d < ht.rank; ++d) count0 *= ht.shape[d]; + for (int64_t j = 0; j < count0; ++j) { + const auto off0 = offset(ht, j); + const float expected = ht.dtype == RAD_F32 + ? ((const float*)ht.data)[off0] + : h_bf16(((const uint16_t*)ht.data)[off0]); + const float actual = ht.dtype == RAD_F32 + ? ((const float*)(got.data() + 128))[off0] + : h_bf16(((const uint16_t*)(got.data() + 128))[off0]); + const float tol = + ht.dtype == RAD_F32 ? 2e-5f : 0.008f + 0.008f * std::fabs(expected); + matches = matches && std::isfinite(actual) && std::fabs(actual - expected) <= tol; + } + } + ok(fmt("SSD %s %s cold=%d accepted=%d: output, state, untouched slots", + anchor ? "anchor" : "candidate", mode, cold, accepted_count) + .c_str(), + matches); + ok("SSD pitched rows and state red zones", guards); + dlclose(ref); +} + /* One launch, then a 200 ms warm-up and `iters` timed launches (st_time_us: --cold gives the * median of flushed launches). -1 when the row refuses the arguments. */ static double form_us(const RadKernelInfo* r, RadArgs* a, int iters) { @@ -18832,6 +19871,9 @@ static void logits_cols_check(const Plugin& pl, int64_t M, int64_t N, int iters /* The MXFP4 expert GEMM at GLM's TP8 slices (mx_experts_check's model shapes 3 and 4): gate_up * 512 x 4096 over token rows (parts 2), down 4096 x 256 over sorted rows, over an M-token chunk. + * With tp 4 the TP4 slices instead, gate_up 1024 x 4096 and down 4096 x 512, where the rule's + * form is timed beside the small-M form pinned at both tilings (r4d_moe_mxfp4_pin_small) and the + * outputs compared byte for byte; the layer total counts the rule's form only. * * Routing is uniform with top_k distinct experts a token, as a trained router spreads load at * decode, or skewed (`skew`): a Gamma load per expert with the given coefficient of variation @@ -18846,7 +19888,7 @@ static void logits_cols_check(const Plugin& pl, int64_t M, int64_t N, int iters * re-read an expert once per group its run spans, the expert-major and small-M forms once per 16 * of its rows, and the P64 and GLM prefill forms once per job. */ static void mx_perf(const Plugin& pl, int64_t Mtok, int iters, int64_t E, int64_t top_k, - bool f8 = false, const char* skew = nullptr) { + bool f8 = false, const char* skew = nullptr, int tp = 8) { if (iters <= 0) iters = 100; if (Mtok < 1 || E < 2 || E > 512 || top_k < 1 || top_k > E) { std::printf("--perfmx: M >= 1, 2 <= experts <= 512 and 1 <= top_k <= experts\n"); @@ -18944,27 +19986,31 @@ static void mx_perf(const Plugin& pl, int64_t Mtok, int iters, int64_t E, int64_ ? std::string("uniform") : fmt("%s %.2f", kind == 'g' ? "Gamma CV" : "Zipf s", sk); std::printf( - "%s at GLM's TP8 slices, a %lld-token chunk: Tr=%lld routed rows, " + "%s at GLM's TP%d slices, a %lld-token chunk: Tr=%lld routed rows, " "top %lld of %lld experts (%s), %lld touched, a run 1..%lld rows, %.1f mean, CV %.2f, " "%lld under 16; %s, %d launches\n", - rname, (long long)Mtok, (long long)Tr, (long long)top_k, (long long)E, routing.c_str(), + rname, tp, (long long)Mtok, (long long)Tr, (long long)top_k, (long long)E, routing.c_str(), (long long)touched, (long long)rmax, mean, cv, (long long)under16, g_cold > 0 ? fmt("cold (%lld MiB read before each, median)", (long long)(g_cold >> 20)).c_str() : "warm (back to back, mean)", iters); - /* body()'s glm_prefill: the measured GLM slices, at which the prefill forms serve. */ - const bool glm = !f8 && E == 288 && top_k == 8; + /* body()'s glm_prefill: the measured GLM slices, at which the prefill forms serve; t8 its + * tp8, the slices the P64 and small-M forms were measured at. */ + const bool glm = !f8 && E == 288 && top_k == 8, t8 = glm && tp == 8; struct Proj { const char* name; int64_t N, K, parts; bool srt; }; - const Proj projs[2] = { { "gate_up", 512, 4096, 2, false }, { "down", 4096, 256, 1, true } }; + const Proj tp8_projs[2] = { { "gate_up", 512, 4096, 2, false }, { "down", 4096, 256, 1, true } }; + const Proj tp4_projs[2] = { { "gate_up", 1024, 4096, 2, false }, { "down", 4096, 512, 1, true } }; + const Proj* projs = tp == 4 ? tp4_projs : tp8_projs; double rule_us = 0.0, rule_bytes = 0.0; - for (const Proj& P : projs) { + for (int pi = 0; pi < 2; ++pi) { + const Proj& P = projs[pi]; const int64_t N = P.N, K = P.K, Ma = P.srt ? Tr : Mtok; /* Per expert: E2M1 codes and an E8M0 byte per 32, or E4M3 codes and an f32 per 128 x 128. */ const int64_t cb = f8 ? N * K : N * K / 2, sb = f8 ? N / 128 * (K / 128) * 4 : N * K / 32; @@ -19066,14 +20112,25 @@ static void mx_perf(const Plugin& pl, int64_t Mtok, int iters, int64_t E, int64_ a.world_size = 1; const double flop = 2.0 * (double)Tr * (double)N * (double)K; const size_t ybytes = (size_t)(Tr * N) * 2; - { + /* Off the TP8 slices, with the pin exported, the rule's form and the small-M form where + * its row bound admits it, timed in turn: their outputs must agree byte for byte. */ + const bool small_fits = glm && Tr <= (P.srt ? 32 : 384); + std::vector forms = { 0 }; + if (glm && !t8 && Tr <= 384 && pl.pin_mx_small) forms = { 0, 2, 1 }; + if (forms.size() > 1 && K > 256) forms.push_back(3); + std::vector first; + for (const int form : forms) { + if (pl.pin_mx_small) pl.pin_mx_small(form); const bool pwide = Tr >= 24576; const int64_t pbm = pwide || (K > 256 && Tr >= 12288) ? 64 : 32; const bool p64 = - glm && Tr >= (P.srt ? 5760 : 769) && (Tr + pbm - 1) / pbm + E <= 65535; - const bool small = (glm && Tr <= (P.srt ? 32 : 384)) || - (f8 && E == 288 && top_k == 8 && !P.srt && Tr <= 384); - const bool expert = !p64 && !small && (f8 || Tr <= (glm ? (P.srt ? 6143 : 768) : 511)); + t8 && Tr >= (P.srt ? 5760 : 769) && (Tr + pbm - 1) / pbm + E <= 65535; + const bool t4_small = glm && !t8 && Tr <= 384 && (P.srt || Tr > top_k); + const bool small = + (form == 1 || form == 3 ? Tr <= 384 + : form != 2 && ((t8 && small_fits) || t4_small)) || + (f8 && E == 288 && top_k == 8 && !P.srt && Tr <= 384); + const bool expert = !p64 && !small && (f8 || Tr <= (t8 ? (P.srt ? 6143 : 768) : 511)); const bool pipe = !p64 && !small && !expert && glm; const int64_t jr = p64 ? pbm : pipe ? 32 : 16; int64_t streams = 0; @@ -19083,21 +20140,22 @@ static void mx_perf(const Plugin& pl, int64_t Mtok, int iters, int64_t E, int64_ else for (int64_t i = 0; i < Tr; ++i) streams += i % 16 == 0 || owner[(size_t)i] != owner[(size_t)(i - 1)]; + const bool tile4 = K <= 256 || form == 3 || (form == 0 && !t8 && P.srt); const std::string label = p64 ? fmt("P64 BM%lld BN%d K%d", (long long)pbm, pwide ? 128 : 64, K > 256 && !pwide ? 256 : 128) + (K <= 256 ? " x4, A resident" : "") + (pwide ? ", LDS out" : "") - : small ? fmt("small-M K%d x%d tiles", K <= 256 ? 256 : 512, K <= 256 ? 4 : 1) + : small ? fmt("small-M K%d x%d tiles", tile4 ? 256 : 512, tile4 ? 4 : 1) : expert ? fmt("expert-major K%d x%d tiles", K <= 256 ? 128 : 256, K <= 256 || (f8 && Tr < 128) ? 4 : 1) : pipe ? std::string("GLM prefill form, jobs of 32 rows") : std::string("row groups of 16"); + const std::string shown = form ? label + " (pinned)" : label + " (rule)"; st_memset(d_y, 0xff, ybytes); const int rc = r->launch(&a, nullptr); if (rc != RAD_OK || st_stream_sync(nullptr) != hipSuccess) { - std::printf(" %-46s rc=%d (not served)\n", label.c_str(), rc); - dfree_all(); - continue; + std::printf(" %-46s rc=%d (not served)\n", shown.c_str(), rc); + break; /* the buffers are freed after the forms */ } { hipEvent_t w0, w1; @@ -19115,12 +20173,22 @@ static void mx_perf(const Plugin& pl, int64_t Mtok, int iters, int64_t E, int64_ st_ev_destroy(w1); } const double us = st_time_us([&](int) { r->launch(&a, nullptr); }, iters, nullptr); - rule_us += us; - rule_bytes += touched * slice; - std::printf(" %-46s %9.1f us %7.1f GB/s touched %5.2fx streamed %6.1f TFLOP/s\n", - label.c_str(), us, touched * slice / (us * 1e3), - touched ? (double)streams / (double)touched : 0.0, flop / (us * 1e6)); + if (form == forms.front()) { /* the rule's form, or at TP4 the expert-major one */ + rule_us += us; + rule_bytes += touched * slice; + } + std::vector got((size_t)(Tr * N)); + st_memcpy(got.data(), d_y, ybytes, hipMemcpyDeviceToHost); + const bool same = first.empty() || got == first; + if (first.empty()) first = std::move(got); + std::printf(" %-46s %9.1f us %7.1f GB/s touched %5.2fx streamed %6.1f TFLOP/s%s\n", + shown.c_str(), us, touched * slice / (us * 1e3), + touched ? (double)streams / (double)touched : 0.0, flop / (us * 1e6), + forms.size() < 2 || form == forms[0] ? "" + : same ? " (bytes match)" : " OUTPUT DIFFERS"); + if (!same) ++g_fail; } + if (pl.pin_mx_small) pl.pin_mx_small(0); dfree_all(); } if (rule_us > 0) @@ -19246,15 +20314,21 @@ static void hc_read_i8(const Plugin& pl, int64_t M, bool real_stream, int form) : "the int8 run changed" + bad); } -/* The gated residual's read at its decode kernels, byte for byte: the launcher's rule (kernels A and - * B as one grid at one to seven rows, the tiled up-mix pipelined from eight) against the two-grid - * form, pinned through r4d_hc_read_pin_decode(1). E4M3 or int8 codes, on a real stream (the - * one-grid form keys its counters on it). The two forms must dispatch different kernels, so a pin - * that is ignored cannot pass by comparing a form with itself. */ +/* The gated residual's read at its decode kernels: the launcher's rule against the two-grid form, + * pinned through r4d_hc_read_pin_decode(1). E4M3 or int8 codes, on a real stream (the one-grid + * form keys its counters on it). The two forms must dispatch different kernels, so a pin that is + * ignored cannot pass by comparing a form with itself. + * + * Up to sixteen rows at this shape the rule serves decode forms G (1..8) and S (9..16) with kernel + * B3: bf16 WMMA dots, S scaling after the dot. Byte for byte they match neither the per-row kernels + * nor the tiled ones, so there d is held to an fp64 host reference - no further from it than the + * two-grid form's d - the inject gains must match byte for byte, and x must stay within rounding of + * the two-grid form's. Above sixteen rows both forms are the tiled path's and match byte for byte. */ static void hc_decode_forms(const Plugin& pl, int64_t M, bool i8) { - const std::string nm = fmt("hc_read_e4m3 decode kernels at M=%lld, %s codes: the rule " - "byte-identical to the two-grid form", (long long)M, - i8 ? "int8" : "E4M3"); + const bool level = M <= 16; + const std::string nm = fmt("hc_read_e4m3 decode kernels at M=%lld, %s codes: the rule %s the " + "two-grid form", (long long)M, i8 ? "int8" : "E4M3", + level ? "as exact as" : "byte-identical to"); const RadKernelInfo* r = find(pl, "hc_read_e4m3"); if (!r) { skip(nm.c_str(), "row absent"); return; } if (!pl.pin_hc_dec || !pl.record) { skip(nm.c_str(), "no r4d_hc_read_pin_decode"); return; } @@ -19329,6 +20403,7 @@ static void hc_decode_forms(const Plugin& pl, int64_t M, bool i8) { } struct Out { std::vector x, inj, q, qs, rq, rs; std::vector fns; }; Out out[2]; + std::vector dsv[2]; /* d: the scratch's first M x lr bf16 values */ for (int form = 0; form < 2; ++form) { pl.pin_hc_dec(form); st_memset(d_x, 0, xb); st_memset(d_q, 0, qb); st_memset(d_qs, 0, sb); @@ -19349,19 +20424,87 @@ static void hc_decode_forms(const Plugin& pl, int64_t M, bool i8) { }; get(out[form].x, d_x, xb); get(out[form].inj, d_inj, ib); get(out[form].q, d_q, qb); get(out[form].qs, d_qs, sb); get(out[form].rq, d_rq, qb); get(out[form].rs, d_rs, sb); + if (a.scratch) { + dsv[form].resize((size_t)(M * lr * 2)); + st_memcpy(dsv[form].data(), a.scratch, dsv[form].size(), hipMemcpyDeviceToHost); + } } pl.pin_hc_dec(0); (void)hipStreamDestroy(hs); - std::string bad; - if (out[0].x != out[1].x) bad += " x"; - if (out[0].inj != out[1].inj) bad += " inj"; - if (out[0].q != out[1].q) bad += " q"; - if (out[0].qs != out[1].qs) bad += " qs"; - if (out[0].rq != out[1].rq) bad += " rq"; - if (out[0].rs != out[1].rs) bad += " rs"; int64_t nz = 0; for (uint8_t v : out[0].q) nz += v != 0; const bool distinct = out[0].fns != out[1].fns; + std::string bad; + if (!level) { + if (out[0].x != out[1].x) bad += " x"; + if (out[0].inj != out[1].inj) bad += " inj"; + if (out[0].q != out[1].q) bad += " q"; + if (out[0].qs != out[1].qs) bad += " qs"; + if (out[0].rq != out[1].rq) bad += " rq"; + if (out[0].rs != out[1].rs) bad += " rs"; + } else { + if (out[0].inj != out[1].inj) bad += " inj"; + if (dsv[0].empty()) bad += " (no scratch for d)"; + /* d against fp64: N unrounded, the dot over the decoded codes and their group scales. The + * error of each form as a fraction of the row's RMS of d, max and mean over every row. */ + const int64_t G = r4d_hc8::down_group(HN); + double emax[2] = { 0, 0 }, esum[2] = { 0, 0 }; + for (int64_t r0 = 0; r0 < M && !dsv[0].empty(); ++r0) { + std::vector N((size_t)HN); + for (int64_t c = 0; c < hc; ++c) { + double ss = 0; + for (int64_t j = 0; j < n; ++j) { + const double v = h_bf16(hh[(size_t)(r0 * HN + c * n + j)]); + ss += v * v; + } + const double sc = 1.0 / std::sqrt(ss / (double)n + 1e-6); + for (int64_t j = 0; j < n; ++j) + N[(size_t)(c * n + j)] = h_bf16(hh[(size_t)(r0 * HN + c * n + j)]) * sc + * ((double)wg[(size_t)(c * n + j)] + 1.0); + } + std::vector dref((size_t)lr); + double ssd = 0; + for (int64_t j = 0; j < lr; ++j) { + const uint8_t* row = down.data() + j * dld; + const float* gsc = (const float*)(row + HN); + double dot = 0; + for (int64_t kk = 0; kk < HN; ++kk) + dot += (double)h_e4m3(row[kk]) * (double)gsc[kk / G] * N[(size_t)kk]; + const double z = dot / (double)hc; + dref[(size_t)j] = z / (1.0 + std::exp(-z)); + ssd += dref[(size_t)j] * dref[(size_t)j]; + } + const double rms = std::sqrt(ssd / (double)lr) + 1e-30; + for (int f = 0; f < 2; ++f) { + const uint16_t* df = (const uint16_t*)dsv[f].data(); + for (int64_t j = 0; j < lr; ++j) { + const double e = std::fabs(h_bf16(df[r0 * lr + j]) - dref[(size_t)j]) / rms; + emax[f] = std::max(emax[f], e); + esum[f] += e; + } + } + } + const double cnt = (double)(M * lr); + if (esum[0] > esum[1] * 1.05 + 1e-6 * cnt || emax[0] > emax[1] * 1.10 + 1e-4) + bad += fmt(" d (rule %.5f / %.4f, two-grid %.5f / %.4f of RMS, mean / max)", + esum[0] / cnt, emax[0], esum[1] / cnt, emax[1]); + /* x: within rounding of the two-grid form's, as a fraction of the row's RMS. */ + const uint16_t* x0 = (const uint16_t*)out[0].x.data(); + const uint16_t* x1 = (const uint16_t*)out[1].x.data(); + double xmax = 0, xsum = 0; + for (int64_t r0 = 0; r0 < M; ++r0) { + double ss = 0; + for (int64_t j = 0; j < n; ++j) { const double v = h_bf16(x1[r0 * n + j]); ss += v * v; } + const double rms = std::sqrt(ss / (double)n) + 1e-30; + for (int64_t j = 0; j < n; ++j) { + const double e = std::fabs(h_bf16(x0[r0 * n + j]) - h_bf16(x1[r0 * n + j])) / rms; + xmax = std::max(xmax, e); + xsum += e; + } + } + if (xsum / (double)(M * n) > 0.005 || xmax > 0.15) + bad += fmt(" x (%.5f mean, %.4f max of RMS)", xsum / (double)(M * n), xmax); + } ok(nm.c_str(), bad.empty() && nz > (int64_t)qb / 2 && distinct, !bad.empty() ? "differs in" + bad : !distinct ? std::string("both forms dispatched the same kernels") @@ -20460,6 +21603,118 @@ static void fp8f32_forms(const Plugin& pl, int64_t M, int64_t N, int64_t K, int } } +/* The vocabulary-weighted head at one shape against the int8 head (logits_gemm_i8) and the 6-bit + * table head (logits_gemm_iqr) over the same rows: `spec` its classes as B:rows,B:rows (a rank's + * share), K n_embd, M tokens. Codes and scales are random bytes (the time does not depend on + * them), the vocabulary ids a random permutation, ascending within each class as the converter + * stores them. GB/s is on each head's stored bytes. */ +static void vocab_perf(const Plugin& pl, const char* spec, int64_t K, int64_t M, int iters) { + using namespace r4d_iqr; + std::vector> cls; + for (const char* p = spec; *p;) { + const int B = (int)std::strtol(p, (char**)&p, 10); + if (*p != ':') break; + const int64_t n = std::strtoll(p + 1, (char**)&p, 10); + cls.emplace_back(B, n); + if (*p == ',') ++p; + } + int64_t N = 0; + for (auto& c : cls) N += c.second; + if (cls.empty() || cls.size() > 4 || K % 256 || M < 1 || N % 16) { + std::printf("--perfvocab: B:rows[,B:rows..] (1-4 classes, rows a multiple of 256) K M\n"); + return; + } + const RadKernelInfo* rv = find(pl, "logits_gemm_vocab_iqr"); + const RadKernelInfo* ri = find(pl, "logits_gemm_i8"); + const RadKernelInfo* rq = find(pl, "logits_gemm_iqr"); + if (!rv || !ri || !rq) { std::printf("--perfvocab: rows absent\n"); return; } + uint64_t z = 12345; + auto fill = [&](void* d, size_t n) { + std::vector h(n); + for (auto& b : h) { z = z * 6364136223846793005ull + 1442695040888963407ull; b = (uint8_t)(z >> 56) & 0x3Fu; } + st_memcpy(d, h.data(), n, hipMemcpyHostToDevice); + }; + void* d_x = dalloc((size_t)(M * K) * 2); + void* d_y = dalloc((size_t)(M * N) * 4); + fill(d_x, (size_t)(M * K) * 2); + std::vector ts(15); + std::vector gp = { PI("M", M), PI("n_vocab", N), PI("n_embd", K), PS("dtype", "bf16"), + PI("vocab_offset", 0) }; + std::vector vrow((size_t)N); + static const char* kRows[] = { "rows0", "rows1", "rows2", "rows3" }; + std::vector perm((size_t)N); + for (int64_t i = 0; i < N; ++i) perm[(size_t)i] = (int32_t)i; + for (int64_t i = N - 1; i > 0; --i) { + z = z * 6364136223846793005ull + 1442695040888963407ull; + std::swap(perm[(size_t)i], perm[(size_t)((z >> 33) % (uint64_t)(i + 1))]); + } + double vbytes = 0; + int64_t base = 0; + for (size_t i = 0; i < cls.size(); ++i) { + const Form f{ kTrellisMad, (uint32_t)cls[i].first, 0, 16, 0, kRowF32, 8, 0 }; + const int64_t n = cls[i].second, wb = weight_bytes(f, n, K), sb = scale_bytes(f, n, K); + void* d_w = dalloc((size_t)wb); + void* d_s = dalloc((size_t)sb); + fill(d_w, (size_t)wb); + std::vector sc((size_t)(sb / 4), 1e-3f); + st_memcpy(d_s, sc.data(), (size_t)sb, hipMemcpyHostToDevice); + /* a class's ids ascending, as the converter writes them */ + std::sort(perm.begin() + base, perm.begin() + base + n); + for (int64_t j = 0; j < n; ++j) + vrow[(size_t)perm[(size_t)(base + j)]] = (int32_t)((uint32_t)cls[i].first << 28) | (int32_t)j; + void* d_r = dalloc((size_t)n * 4); + st_memcpy(d_r, perm.data() + base, (size_t)n * 4, hipMemcpyHostToDevice); + ts[1 + 3 * i] = T(d_w, R4D_DT_IQR_W | word(f), { n, K }); + ts[2 + 3 * i] = T(d_s, R4D_DT_IQR_S | word(f), { n, K / 128 }); + ts[3 + 3 * i] = T(d_r, RAD_I32, { n }); + gp.push_back(PI(kRows[i], n)); + vbytes += (double)(wb + sb + n * 4); + base += n; + } + for (size_t i = cls.size(); i < 4; ++i) + for (int j = 0; j < 3; ++j) { ts[1 + 3 * i + (size_t)j] = T(nullptr, RAD_U8, { 1 }); absent(ts[1 + 3 * i + (size_t)j]); } + void* d_m = dalloc((size_t)N * 4); + st_memcpy(d_m, vrow.data(), (size_t)N * 4, hipMemcpyHostToDevice); + vbytes += (double)N * 4; + ts[0] = T(d_x, RAD_BF16, { M, K }); + ts[13] = T(d_m, RAD_I32, { N, 1 }); + ts[14] = T(d_y, RAD_F32, { M, N }); + RadArgs a; + std::memset(&a, 0, sizeof(a)); + a.t = ts.data(); a.n_t = (int)ts.size(); a.p = gp.data(); a.n_p = (int)gp.size(); a.world_size = 1; + const int64_t need = rv->scratch(&a); + a.scratch = dalloc((size_t)need); a.scratch_bytes = need; + if (rv->launch(&a, nullptr) != RAD_OK || st_stream_sync(nullptr) != hipSuccess) { std::printf("--perfvocab: launch failed\n"); return; } + const double tv = st_time_us([&](int) { rv->launch(&a, nullptr); }, iters, nullptr); + + /* the int8 head and the 6-bit table head over N rows */ + const int64_t ib = N * r4d_fp8::lm_row_bytes(K); + const Form ft{ kTable, 6, 0, 0, 0, kBf16, 0, 0 }; + const int64_t qb = lm_bytes(ft, N, K); + void* d_i = dalloc((size_t)ib); + void* d_q = dalloc((size_t)qb); + fill(d_i, (size_t)ib); + fill(d_q, (size_t)qb); + std::vector lp = { PI("M", M), PI("n_vocab", N), PI("n_embd", K), PS("dtype", "bf16") }; + std::vector ti = { T(d_x, RAD_BF16, { M, K }), T(d_i, RAD_I8, { N, K }), T(d_y, RAD_F32, { M, N }) }; + std::vector tq = { T(d_x, RAD_BF16, { M, K }), T(d_q, R4D_DT_IQR_W | word(ft), { N, K }), T(d_y, RAD_F32, { M, N }) }; + auto timed = [&](const RadKernelInfo* r, std::vector& t) { + RadArgs b; + std::memset(&b, 0, sizeof(b)); + b.t = t.data(); b.n_t = (int)t.size(); b.p = lp.data(); b.n_p = (int)lp.size(); b.world_size = 1; + if (r->scratch) { const int64_t s = r->scratch(&b); if (s > 0) { b.scratch = dalloc((size_t)s); b.scratch_bytes = s; } } + if (r->launch(&b, nullptr) != RAD_OK || st_stream_sync(nullptr) != hipSuccess) return -1.0; + return st_time_us([&](int) { r->launch(&b, nullptr); }, iters, nullptr); + }; + const double t8 = timed(ri, ti), t6 = timed(rq, tq); + std::printf("\nlm_head N=%lld K=%lld M=%lld, %d iters\n", (long long)N, (long long)K, (long long)M, iters); + std::printf(" %-26s %9.1f us %7.1f MiB %6.1f GB/s %.3f b a weight\n", ("vocab " + std::string(spec)).c_str(), tv, + vbytes / (1 << 20), vbytes / (tv * 1e3), vbytes * 8 / (double)(N * K)); + std::printf(" %-26s %9.1f us %7.1f MiB %6.1f GB/s\n", "int8 (logits_gemm_i8)", t8, ib / 1048576.0, ib / (t8 * 1e3)); + std::printf(" %-26s %9.1f us %7.1f MiB %6.1f GB/s\n", "6-bit table (logits_gemm_iqr)", t6, qb / 1048576.0, qb / (t6 * 1e3)); + dfree_all(); +} + /* The block-quantised trunk GEMMs GLM's checkpoints resolve to, at one shape: E4M3 with F32 * 128x128 block scales (gemm_fp8a8_f32scale, the MLA and dense-MLP projections) and OCP-MXFP4 * (the shared experts' rows: skinny, decode split and tiled). GB/s is on the weight and its scale @@ -29876,6 +31131,17 @@ static void device_phase(const Plugin& pl) { attn_numeric_case(pl, "attn_window_h512_gqa8_bf16kv", 512, 8, 32, "bf16", 0); attn_numeric_case(pl, "attn_window_h512_gqa8_fp8kv", 512, 8, 1, "fp8_e4m3", 0); attn_numeric_case(pl, "attn_window_h512_gqa8_bf16kv", 512, 8, 1, "bf16", 0); + /* Gemma 4 12B global at one rank: 16 query heads over its one kv head, in the trunk and in the + * assistant (one row a sequence, a verify of sixteen). Launches, then numeric checks. */ + attn_case(pl, "attn_window_h512_gqa16_fp8kv", 512, 16, 32, "fp8_e4m3", 1); + attn_case(pl, "attn_window_h512_gqa16_bf16kv", 512, 16, 32, "bf16", 1); + attn_case(pl, "attn_window_h512_gqa16_fp8kv", 512, 16, 1, "fp8_e4m3", 0); + attn_case(pl, "attn_window_h512_gqa16_bf16kv", 512, 16, 1, "bf16", 0); + attn_numeric_case(pl, "attn_window_h512_gqa16_fp8kv", 512, 16, 32, "fp8_e4m3", 0); + attn_numeric_case(pl, "attn_window_h512_gqa16_bf16kv", 512, 16, 32, "bf16", 0); + attn_numeric_case(pl, "attn_window_h512_gqa16_fp8kv", 512, 16, 1, "fp8_e4m3", 0, 700); + attn_numeric_case(pl, "attn_window_h512_gqa16_bf16kv", 512, 16, 1, "bf16", 0, 700); + attn_numeric_case(pl, "attn_window_h512_gqa16_bf16kv", 512, 16, 16, "bf16", 0, 300); /* The h256/gqa2 prefill numeric check with ctx 2048 > window 1024, so the window applies: for * query row 0, pos = 2048-64 = 1984 and the visible keys are [961..1984], so wlo0 = 961 and * tstart = 961/48 = 20. This exercises the window mask and the below-window tile skip (tiles @@ -29941,6 +31207,8 @@ static void device_phase(const Plugin& pl) { attn_split_case(pl, g, n, kv, { { 345, 345 } }, 16, false); attn_split_case(pl, g, n, kv, { { 345, 1000 } }, 16, true); attn_split_case(pl, g, n, kv, { { 640, 2000 } }, 5, true); + /* Model max_ctx 2048 with a 128-token KV: occupancy would split, live seqused must not. */ + attn_split_case(pl, g, n, kv, { { 128, 128 } }, 4, false, 0, 0, 2048); attn_split_case(pl, g, n, kv, { { 53, 12000 }, { 1, 20000 } }, 16, true); attn_split_case(pl, g, n, kv, { { 11, 8192 }, { 64, 9000 }, { 1, 12000 } }, 6, true); attn_split_case(pl, g, n, kv, { { 300, 600 }, { 1, 10000 } }, 16, true); @@ -30015,6 +31283,28 @@ static void device_phase(const Plugin& pl) { attn_numeric_case(pl, "attn_decode_h128_gqa2_fp8kv", 128, 2, 1, "fp8_e4m3", 0, 256); attn_numeric_case(pl, "attn_decode_h128_gqa2_bf16kv", 128, 2, 1, "bf16", 0, 256); attn_numeric_case(pl, "attn_decode_h128_gqa2_bf16kv", 128, 2, 24, "bf16", 0, 256); + /* Nemotron-H's 32 query heads over 2 at one rank. */ + attn_case(pl, "attn_prefill_h128_gqa16_fp8kv", 128, 16, 32, "fp8_e4m3", 1); + attn_case(pl, "attn_prefill_h128_gqa16_bf16kv", 128, 16, 32, "bf16", 1); + attn_case(pl, "attn_decode_h128_gqa16_fp8kv", 128, 16, 1, "fp8_e4m3", 0); + attn_case(pl, "attn_decode_h128_gqa16_bf16kv", 128, 16, 1, "bf16", 0); + attn_numeric_case(pl, "attn_prefill_h128_gqa16_fp8kv", 128, 16, 64, "fp8_e4m3", 0, 256); + attn_numeric_case(pl, "attn_prefill_h128_gqa16_bf16kv", 128, 16, 64, "bf16", 0, 256); + attn_numeric_case(pl, "attn_decode_h128_gqa16_fp8kv", 128, 16, 1, "fp8_e4m3", 0, 256); + attn_numeric_case(pl, "attn_decode_h128_gqa16_bf16kv", 128, 16, 1, "bf16", 0, 256); + attn_numeric_case(pl, "attn_decode_h128_gqa16_bf16kv", 128, 16, 4, "bf16", 0, 256); + /* LiLiCorr's verify: 7 drafts and the anchor, eight waves. */ + attn_numeric_case(pl, "attn_decode_h128_gqa16_fp8kv", 128, 16, 8, "fp8_e4m3", 0, 256); + attn_numeric_case(pl, "attn_decode_h128_gqa16_bf16kv", 128, 16, 8, "bf16", 0, 256); + /* ... and gives, row for row, the decodes it replaces; gqa 8 is the trunk at four ranks */ + for (int64_t keys : { 120, 700, 2048 }) { + attn_verify_bits_case(pl, "attn_decode_h128_gqa16_bf16kv", 16, "bf16", 8, keys); + attn_verify_bits_case(pl, "attn_decode_h128_gqa16_fp8kv", 16, "fp8_e4m3", 8, keys); + attn_verify_bits_case(pl, "attn_decode_h128_gqa8_bf16kv", 8, "bf16", 8, keys); + } + attn_verify_sweep(pl, "attn_decode_h128_gqa16_bf16kv", 16, "bf16"); + attn_verify_sweep(pl, "attn_decode_h128_gqa16_fp8kv", 16, "fp8_e4m3"); + attn_verify_sweep(pl, "attn_decode_h128_gqa8_bf16kv", 8, "bf16"); attn_gq_fold_case(pl, 3, false); attn_gq_fold_case(pl, 24, false); /* And over the fp8_v4 and k6_v4 caches (Flash-Next's --kv-cache-dtype fp8_v4 / k6_v4). */ @@ -30086,7 +31376,7 @@ static void device_phase(const Plugin& pl) { const RadKernelInfo* r = find(pl, "act_mul_bf16"); if (!r) ok("act_mul_bf16", false, "row absent"); else - for (const char* act : { "silu", "gelu", "gelu_tanh", "sigmoid", "quick_gelu" }) { + for (const char* act : { "silu", "gelu", "gelu_tanh", "sigmoid", "quick_gelu", "relu" }) { std::vector ts = { T(nullptr, RAD_BF16, { 5, 645 }), T(nullptr, RAD_BF16, { 5, 645 }), T(nullptr, RAD_BF16, { 5, 645 }) }; @@ -30236,6 +31526,40 @@ static void device_phase(const Plugin& pl) { return v; }; + /* point_fourier: a shape decoder's query points (three values, eight octaves, f32), past + * the 65535 rows one grid row a matrix row would reach, against libm's sinf and cosf. */ + if (sel("point_fourier_f32")) { + if (const RadKernelInfo* r = find(pl, "point_fourier_f32")) { + const int64_t M = 70001, n = 3, F = 8, W = n * (2 * F + 1); + std::vector x = randv((size_t)(M * n), 1.01f); + void* dx = dalloc(x.size() * 4); + void* dy = dalloc((size_t)(M * W) * 4); + if (dx) st_memcpy(dx, x.data(), x.size() * 4, hipMemcpyHostToDevice); + std::vector ts = { T(dx, RAD_F32, { M, n }), T(dy, RAD_F32, { M, W }) }; + std::vector ps = { PI("M", M), PI("n", n), PI("freqs", F), + PS("dtype", "f32") }; + run_case(r, ts, ps); + std::vector got((size_t)(M * W)); + st_memcpy(got.data(), dy, got.size() * 4, hipMemcpyDeviceToHost); + double worst = 0.0; + for (int64_t m = 0; m < M; ++m) + for (int64_t i = 0; i < n; ++i) { + const float v = x[(size_t)(m * n + i)]; + worst = std::max(worst, (double)std::fabs(got[(size_t)(m * W + i)] - v)); + for (int64_t j = 0; j < F; ++j) { + const float t = v * std::ldexp(1.0f, (int)j); + const float* g = &got[(size_t)(m * W)]; + const float es = g[n + i * F + j] - std::sin(t); + const float ec = g[n + n * F + i * F + j] - std::cos(t); + worst = std::max(worst, (double)std::max(std::fabs(es), std::fabs(ec))); + } + } + char d[96]; + std::snprintf(d, sizeof d, "max abs err %.3g", worst); + ok("point_fourier_f32 numerics", worst <= 1e-5, d); + } else ok("point_fourier_f32", false, "row absent"); + } + if (sel("relu_bf16") || sel("silu_bf16") || sel("clamp_bf16")) { const int64_t M = 5, n = 300; std::vector x = randv((size_t)(M * n), 2.0f); @@ -31300,9 +32624,10 @@ static void device_phase(const Plugin& pl) { i8a8_numeric(pl, "gemm_i8a8_rb32_tiled", 200, 256, 640, 32); i8a8_numeric(pl, "gemm_i8a8_rb32_tiled", 300, 256, 5120, 32); /* The IQR forms, decoded where they are read, against the int8 rows on their values: V1's - * tables, grids and zero; V2's 4096-state trellis; V3's 16384-state one on tcq_rb=32. M 1, - * 4 and 8 reach the GEMV (split over K at N 512), 9 and 64 the narrow tile (64 a split at N - * 512), 300 the prefill decode. */ + * tables, grids and zero; V2's 4096-state trellis; V3's 16384-state one on tcq_rb=32. M 1 + * reaches the GEMV, 2 the GEMV on 2- and 3-bit computed codes under one f32 scale a row, 4 + * and 8 the GEMV off the computed trellis; else to 16 the 16-token tile; 17 and 64 the + * narrow tile (64 a split at N 512), 300 the prefill decode. */ { const IqrCase fs[] = { { 3, 2, 0, 0, 1, false, false }, { 3, 3, 0, 0, 1, false, true }, { 3, 4, 0, 0, 1, false, true }, @@ -31315,16 +32640,27 @@ static void device_phase(const Plugin& pl) { { 6, 2, 0, 16, 32, true, true }, { 6, 3, 0, 16, 32, true, true }, { 6, 4, 0, 16, 32, true, true }, { 6, 5, 0, 16, 32, true, true }, { 6, 6, 0, 16, 32, true, true }, { 6, 7, 0, 16, 32, true, true }, { 6, 2, 0, 16, 1, true, true }, { 6, 4, 0, 16, 1, true, true }, + { 6, 5, 0, 16, 1, true, true }, { 6, 6, 0, 16, 1, true, true }, { 6, 7, 0, 16, 1, true, true }, + { 6, 4, 0, 16, 1, false, true }, { 6, 5, 0, 16, 1, false, true }, + { 6, 6, 0, 16, 1, false, true }, { 6, 7, 0, 16, 1, false, true }, { 6, 2, 0, 16, 1, false, true, true }, { 6, 3, 0, 16, 1, false, true, true }, { 6, 4, 0, 16, 1, false, true, true }, { 6, 5, 0, 16, 1, false, true, true }, { 6, 6, 0, 16, 1, false, true, true }, { 6, 7, 0, 16, 1, false, true, true }, { 6, 2, 0, 15, 1, false, true, true }, }; + for (const int b : { 2, 3, 4, 6 }) + for (const int64_t m : { (int64_t)1, (int64_t)2, (int64_t)5, (int64_t)16 }) + iqr_gated_case(pl, b, m, 1024, 1280); + iqr_gated_case(pl, 4, 1, 17408, 5120); + iqr_gated_case(pl, 4, 9, 17408, 5120); for (const IqrCase& f : fs) { iqr_gemm_case(pl, f, 1, 512, 1024); + iqr_gemm_case(pl, f, 2, 4096, 1024); iqr_gemm_case(pl, f, 4, 2048, 2560); iqr_gemm_case(pl, f, 8, 512, 1024); iqr_gemm_case(pl, f, 9, 512, 1024); + iqr_gemm_case(pl, f, 16, 4096, 2560); + iqr_gemm_case(pl, f, 17, 512, 1024); iqr_gemm_case(pl, f, 64, 512, 2560); iqr_gemm_case(pl, f, 300, 512, 1024); } @@ -31914,6 +33250,7 @@ static void device_phase(const Plugin& pl) { if (sel("attn_cross_h128_bf16")) g3::attn_cross_cases(pl, 128); if (sel("attn_cross_h64_bf16")) g3::attn_cross_cases(pl, 64); if (sel("attn_dense_gqa")) g3::attn_dense_gqa_cases(pl); + if (sel("attn_dense_h80_bf16")) g3::attn_dense_h80_cases(pl); if (sel("attn_dense_h384_bf16") || sel("attn_dense_h512_bf16")) g3::attn_wide_cases(pl); if (sel("rms_mod_bf16") || sel("rms_mod_quant_fp8_bf16")) g3::rms_mod_forms(pl); if (sel("timestep_embed_bf16")) g3::timestep_round_cases(pl); @@ -32119,6 +33456,16 @@ static void device_phase(const Plugin& pl) { for (int64_t rows : { 1, 7, 33 }) for (int64_t n : { 31, 259, 4096 }) mhc_check(pl, "swiglu_clamped_bf16", rows, n, 0); } + if (sel("swiglu_step_bf16")) { + for (int64_t rows : { 1, 7, 33 }) + for (int64_t n : { 31, 259, 768 }) mhc_check(pl, "swiglu_step_bf16", rows, n, 0); + } + if (sel("router_sigmoid_group_topk_f32")) { + for (int64_t rows : { 1, 7, 33, 300 }) + for (int64_t ne : { 64, 512 }) + for (int norm : { 0, 1 }) + mhc_check(pl, "router_sigmoid_group_topk_f32", rows, ne, norm); + } if (sel("router_sigmoid_topk_f32")) { for (int64_t rows : { 1, 7, 33 }) for (int64_t ne : { 32, 288, 512 }) @@ -32192,6 +33539,51 @@ static void device_phase(const Plugin& pl) { mla_check(pl, requests, heads, 513, "mla_attn_bf16", MlaFill::full); mla_check(pl, 7, 8, 65, "mla_attn_bf16", MlaFill::topk, nullptr, 0, 16); } + /* The E4M3-cache twins: each kernel form of its bf16 row, on the same operands with the cache + * as E4M3 codes. The comparison partner is the twin of the row the bf16 case compares with. */ + if (sel("mla_attn_fp8kv")) { + mla_check(pl, 1, 1, 3, "mla_attn_fp8kv"); + mla_check(pl, 7, 16, 17, "mla_attn_fp8kv"); + mla_check(pl, 4, 16, 513, "mla_attn_fp8kv"); + mla_check(pl, 1, 64, 17, "mla_attn_fp8kv"); + mla_check(pl, 33, 8, 17, "mla_attn_fp8kv"); + mla_check(pl, 4, 8, 513, "mla_attn_fp8kv", MlaFill::full); + mla_check(pl, 7, 8, 65, "mla_attn_fp8kv", MlaFill::topk, nullptr, 0, 16); + } + if (sel("mla_attn_matrix_fp8kv")) { + mla_check(pl, 7, 16, 17, "mla_attn_matrix_fp8kv"); + mla_check(pl, 4, 16, 513, "mla_attn_matrix_fp8kv"); + mla_check(pl, 1, 64, 17, "mla_attn_matrix_fp8kv"); + mla_check(pl, 4, 12, 17, "mla_attn_matrix_fp8kv"); + for (int requests : { 1, 4, 7, 33 }) + mla_check(pl, requests, 8, 513, "mla_attn_matrix_fp8kv", MlaFill::ragged, + "mla_attn_fp8kv"); + mla_check(pl, 7, 8, 513, "mla_attn_matrix_fp8kv", MlaFill::full, "mla_attn_fp8kv"); + mla_check(pl, 33, 8, 513, "mla_attn_matrix_fp8kv", MlaFill::prefill, "mla_attn_fp8kv"); + mla_check(pl, 128, 8, 513, "mla_attn_matrix_fp8kv", MlaFill::prefill, "mla_attn_fp8kv"); + mla_check(pl, 7, 8, 65, "mla_attn_matrix_fp8kv", MlaFill::topk, "mla_attn_fp8kv", 0, 16); + mla_check(pl, 33, 8, 513, "mla_attn_matrix_fp8kv", MlaFill::topk, "mla_attn_fp8kv", 0, + 16); + /* Past the union's lists, the positional pairing. */ + mla_check(pl, 7, 8, 521, "mla_attn_matrix_fp8kv", MlaFill::prefill, nullptr); + /* The element-wise key load. */ + mla_check(pl, 33, 16, 17, "mla_attn_matrix_fp8kv", MlaFill::ragged, nullptr, 1); + mla_check(pl, 7, 8, 513, "mla_attn_matrix_fp8kv", MlaFill::prefill, nullptr, 1); + } + if (sel("mla_attn_rows_fp8kv")) { + for (int requests : { 1, 7, 33 }) + for (int64_t blocks : { 17, 513 }) + mla_check(pl, requests, 64, blocks, "mla_attn_rows_fp8kv", MlaFill::ragged, + "mla_attn_matrix_fp8kv", requests < 32 ? 3 : 0); + mla_check(pl, 33, 64, 513, "mla_attn_rows_fp8kv", MlaFill::prefill, + "mla_attn_matrix_fp8kv"); + mla_check(pl, 33, 64, 65, "mla_attn_rows_fp8kv", MlaFill::topk, "mla_attn_matrix_fp8kv", + 0, 16); + /* Under 32 rows the rule's matrix kernel; the element-wise load; 32 heads a workgroup. */ + mla_check(pl, 7, 64, 513, "mla_attn_rows_fp8kv", MlaFill::full); + mla_check(pl, 7, 64, 513, "mla_attn_rows_fp8kv", MlaFill::prefill, nullptr, 1); + mla_check(pl, 33, 64, 65, "mla_attn_rows_fp8kv", MlaFill::topk, nullptr, 2, 16); + } if (sel("mla_project_bf16")) { for (const char* mode : { "absorb", "expand" }) { /* Every rows-a-group form (1, 2, 4, 8) and tails past the last full group. */ @@ -32201,8 +33593,22 @@ static void device_phase(const Plugin& pl) { mla_project_check(pl, 1, 64, mode); for (int64_t rows : { 1, 4, 33 }) for (int64_t heads : { 8, 16 }) mla_project_check(pl, rows, heads, mode, true); + /* Ling-3.0's 128-wide heads, 8 a rank under TP4 and 32 unsplit. */ + for (int64_t rows : { 1, 3, 33, 130 }) + for (int64_t heads : { 8, 32 }) + mla_project_check(pl, rows, heads, mode, false, 128); } } + if (sel("mla_attn_paged_bf16")) { + for (int64_t heads : { 8, 32 }) + for (bool gated : { false, true }) { + mla_paged_check(pl, { 1 }, { 1 }, heads, gated); + mla_paged_check(pl, { 7 }, { 7 }, heads, gated); + mla_paged_check(pl, { 1, 1, 1 }, { 40, 300, 1025 }, heads, gated); + mla_paged_check(pl, { 33, 5 }, { 33, 900 }, heads, gated); + mla_paged_check(pl, { 130 }, { 130 }, heads, gated); + } + } if (sel("mla_attn_rows_bf16")) { /* A rank's run of rows with all 64 heads (GLM's prefill split by rows), against the matrix * row on the same operands. Under 32 rows the rule runs the matrix kernel, so the rows @@ -32269,6 +33675,14 @@ static void device_phase(const Plugin& pl) { mla_check(pl, 33, 8, 17, "mla_attn_matrix_bf16", MlaFill::ragged, nullptr, 1); mla_check(pl, 7, 8, 513, "mla_attn_matrix_bf16", MlaFill::prefill, nullptr, 1); } + if (sel("ssd_update_n128_bf16")) + for (const char* mode : { "prefill", "verify" }) + for (int accepted : { 1, 2, 3 }) { + ssd_check(pl, mode, false, accepted); + ssd_check(pl, mode, true, accepted); + ssd_check(pl, mode, false, accepted, true); + ssd_check(pl, mode, true, accepted, true); + } if (sel("kda_update_k128_v128_bf16")) { for (const char* mode : { "prefill", "verify" }) for (int accepted : { 1, 2, 3 }) { @@ -32346,9 +33760,9 @@ static void device_phase(const Plugin& pl) { for (int form : { 1, 2 }) hc_read_i8(pl, m, true, form); for (int64_t m : { 700, 2048 }) hc_read_i8(pl, m, true, 3); } - /* The served decode kernels against the two-grid form: each one-grid instantiation (1 to - * 7 rows) and the tiled up-mix at both of its row tiles. */ - for (int64_t m : { 1, 2, 3, 4, 5, 6, 7, 8, 16, 32, 33, 64 }) + /* The served decode kernels against the two-grid form: each row count of form G (1 to 8), + * form S at 12 and 16 rows, and the tiled up-mix at both of its row tiles. */ + for (int64_t m : { 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 32, 33, 64 }) for (bool i8 : { false, true }) hc_decode_forms(pl, m, i8); } if (sel("hc_read_bf16")) { @@ -32558,11 +33972,21 @@ static void device_phase(const Plugin& pl) { iqr_head_case(pl, 5, 4096, 5120, 1); iqr_head_case(pl, 4, 4096, 5120, 8); } + if (sel("logits_gemm_vocab_iqr")) { + const std::vector four = { { 4, 768 }, { 5, 512 }, { 6, 256 }, { 7, 256 } }; + for (const int64_t M : { (int64_t)1, (int64_t)8, (int64_t)16, (int64_t)37, (int64_t)64, (int64_t)100 }) + vocab_head_case(pl, four, M, 512, 0); + vocab_head_case(pl, { { 3, 512 }, { 2, 256 } }, 9, 1024, 768); + vocab_head_case(pl, { { 3, 512 }, { 2, 256 } }, 40, 1024, 768); + vocab_head_case(pl, { { 5, 1024 } }, 8, 5120, 0); + } if (sel("embed_lookup_iqr")) { const IqrEmbedCase es[] = { { 3, 2, 0, false, false }, { 3, 3, 0, false, false }, { 3, 4, 0, false, true }, - { 3, 5, 0, false, false }, { 2, 6, 0, false, false }, { 5, 2, 12, true, true }, + { 3, 5, 0, false, false }, { 2, 6, 0, false, false }, { 2, 7, 0, false, false }, + { 2, 8, 0, false, false }, { 5, 2, 12, true, true }, { 5, 3, 12, true, true }, { 5, 4, 12, true, true }, { 5, 5, 12, true, true }, + { 5, 6, 12, true, true }, { 5, 7, 12, true, true }, }; for (const IqrEmbedCase& f : es) { iqr_embed_case(pl, f, 512, 640, 1.0f); @@ -32577,6 +34001,8 @@ static void device_phase(const Plugin& pl) { fp8_logits_numeric(pl, 2560, 2560, M, true); } + gate_had_case(pl, 37, 256); + gate_had_case(pl, 4, 128); /* The fused quantisers are checked against the kernels they replace, gated on their own * rows. */ if (sel("rmsnorm_quant_fp8") || sel("gated_quant_fp8") || sel("gate_quant_fp8") || @@ -32832,11 +34258,15 @@ static void usage(void) { " N a gate_up's width) and print the weight bandwidth each reaches.\n" " --perfwpa N K M [iters] [pb1]: the int5 and int4 x int8 tiled GEMMs (gemm_w5a8i8_tiled,\n" " gemm_w4a8i8_tiled), warmed, min / median time and a hash of the output.\n" + " --perfiqr N K M B [iters]: the IQR row over a B-bit V4 trunk form (B + 10: the head-fed\n" + " form, a bf16 scale a (row, 128)), then --perfmxd\n" " --perfmxd N K M [iters]: the dense MXFP4 GEMM rows (gemv, decode, skinny, tiled) at\n" " one shape, with the weight bandwidth each reaches.\n" " --perfbf16 N K M [iters]: the bf16 skinny GEMM at every variant it has.\n" " --perff32 N K M [iters]: gemm_nt_f32 at the tile form its rule picks, compared\n" " byte for byte with the host arithmetic, with GB/s and TFLOP/s.\n" + " --perfvocab B:rows,.. K M [iters]: the vocabulary-weighted head against the int8\n" + " and 6-bit table heads over the same rows\n" " --perfq N K M [iters]: the block-quantised trunk rows GLM resolves to: E4M3 with\n" " F32 block scales and the three OCP-MXFP4 rows, GB/s on weight + scales.\n" " --perfw4 N K M [iters]: a tuning sweep of the asymmetric W4 x F16 GEMM;\n" @@ -32908,6 +34338,9 @@ static void usage(void) { " one card, here and in the eight-rank exact all-reduces' cases.\n" " --perfmxf8 M [iters] [experts] [top_k] [skew]: the same at the FP8 experts with f32\n" " block scales (moe_gemm_fp8a8_f32scale, GLM's MTP layer).\n" + " --perfmx-tp 4: --perfmx at GLM's TP4 slices (gate_up 1024 x 4096, down 4096 x 512),\n" + " the rule's form and, where its row bound admits it, the small-M form\n" + " pinned (r4d_moe_mxfp4_pin_small), their outputs compared byte for byte.\n" " --perfmhcpre M [iters]: mhc_pre (whole, partials alone, finish alone) and\n" " mhc_post at GLM's shape, 16-byte rows against pitched ones.\n" " --perfrouter M [iters]: router_sigmoid_topk at GLM's shape (288 experts, top 8),\n" @@ -32957,7 +34390,8 @@ int main(int argc, char** argv) { long long real_woff = 0, real_soff = 0, real_n = 0, real_k = 0; long long perf_n = 0, perf_k = 0, perf_m = 0; int perf_it = 50, perf_w2 = 0, perf_w4 = 0, perf_bf = 0, perf_w8 = 0, perf_f32 = 0, - perf_q = 0, perf_mx = 0, perf_wpa = 0; + perf_q = 0, perf_mx = 0, perf_wpa = 0, perf_vocab = 0, perf_iqr = 0; + const char* vocab_spec = nullptr; long long perf_pb1 = 0; long long sop_m = 0, sop_k = 0; int sop_it = 2000; @@ -32998,6 +34432,7 @@ int main(int argc, char** argv) { const char* ar8_w = nullptr; long long mx_m = 0, mx_e = 288, mx_k = 8; const char* mx_skew = nullptr; + int mx_tp = 8; bool mx_f8 = false; int mx_it = 100; long long mhc_m = 0; @@ -33030,6 +34465,13 @@ int main(int argc, char** argv) { perf_m = std::strtoll(argv[++i], nullptr, 0); if (i + 1 < argc && argv[i + 1][0] != '-') perf_it = (int)std::strtol(argv[++i], nullptr, 0); if (i + 1 < argc && argv[i + 1][0] != '-') perf_pb1 = std::strtoll(argv[++i], nullptr, 0); + } else if (!std::strcmp(argv[i], "--perfiqr")) { + if (i + 4 >= argc) { usage(); return 2; } + perf_n = std::strtoll(argv[++i], nullptr, 0); + perf_k = std::strtoll(argv[++i], nullptr, 0); + perf_m = std::strtoll(argv[++i], nullptr, 0); + perf_iqr = (int)std::strtol(argv[++i], nullptr, 0); + if (i + 1 < argc && argv[i + 1][0] != '-') perf_it = (int)std::strtol(argv[++i], nullptr, 0); } else if (!std::strcmp(argv[i], "--perfmxd")) { if (i + 3 >= argc) { usage(); return 2; } perf_mx = 1; @@ -33053,6 +34495,15 @@ int main(int argc, char** argv) { perf_k = std::strtoll(argv[++i], nullptr, 0); perf_m = std::strtoll(argv[++i], nullptr, 0); if (i + 1 < argc && argv[i + 1][0] != '-') perf_it = (int)std::strtol(argv[++i], nullptr, 0); + } else if (!std::strcmp(argv[i], "--perfvocab")) { + /* the vocabulary-weighted head against the int8 and table heads (see vocab_perf) */ + if (i + 3 >= argc) { usage(); return 2; } + perf_vocab = 1; + perf_n = 1; + vocab_spec = argv[++i]; + perf_k = std::strtoll(argv[++i], nullptr, 0); + perf_m = std::strtoll(argv[++i], nullptr, 0); + if (i + 1 < argc && argv[i + 1][0] != '-') perf_it = (int)std::strtol(argv[++i], nullptr, 0); } else if (!std::strcmp(argv[i], "--perfq")) { /* GLM's block-quantised trunk rows (see q_perf). */ if (i + 3 >= argc) { usage(); return 2; } @@ -33210,6 +34661,11 @@ int main(int argc, char** argv) { if (i + 1 < argc && argv[i + 1][0] != 0x2d) mx_e = std::strtoll(argv[++i], nullptr, 0); if (i + 1 < argc && argv[i + 1][0] != 0x2d) mx_k = std::strtoll(argv[++i], nullptr, 0); if (i + 1 < argc && argv[i + 1][0] != 0x2d) mx_skew = argv[++i]; + } else if (!std::strcmp(argv[i], "--perfmx-tp")) { + /* --perfmx at GLM's TP4 slices (gate_up 1024 x 4096, down 4096 x 512) instead. */ + if (i + 1 >= argc) { usage(); return 2; } + mx_tp = (int)std::strtol(argv[++i], nullptr, 0); + if (mx_tp != 4 && mx_tp != 8) { usage(); return 2; } } else if (!std::strcmp(argv[i], "--perflogits")) { /* Both bf16 head rows at GLM-5.3's TP8 slice over M rows. */ if (i + 1 >= argc) { usage(); return 2; } @@ -33428,7 +34884,7 @@ int main(int argc, char** argv) { if (mx_m) { if (!load(&pl, path)) return 1; #ifdef RAD_HAVE_HIP - mx_perf(pl, mx_m, mx_it, mx_e, mx_k, mx_f8, mx_skew); + mx_perf(pl, mx_m, mx_it, mx_e, mx_k, mx_f8, mx_skew, mx_tp); dfree_all(); #else skip("MXFP4 expert GEMM timing", "built without HIP"); @@ -33481,7 +34937,9 @@ int main(int argc, char** argv) { #ifdef RAD_HAVE_HIP if (perf_f32) f32_forms(pl, perf_m, perf_n, perf_k, perf_it, true); else if (perf_q) q_perf(pl, perf_n, perf_k, perf_m, perf_it); + else if (perf_vocab) vocab_perf(pl, vocab_spec, perf_k, perf_m, perf_it); else if (perf_wpa) wpa_perf(pl, perf_n, perf_k, perf_m, perf_it, perf_pb1); + else if (perf_iqr) iqr_perf(pl, perf_n, perf_k, perf_m, perf_iqr, perf_it); else if (perf_mx) mx_perf(pl, perf_n, perf_k, perf_m, perf_it); else if (perf_bf) bf16_perf(pl, perf_n, perf_k, perf_m, perf_it); else if (perf_w4) w5a16_perf(pl, 4, perf_m, perf_n, perf_k, perf_it, diff --git a/libr4d/r4d_shapes.cpp b/libr4d/r4d_shapes.cpp index a66a28fb..318cf311 100644 --- a/libr4d/r4d_shapes.cpp +++ b/libr4d/r4d_shapes.cpp @@ -372,6 +372,16 @@ extern "C" int r4d_shape_grid_embed(const RadParam* p, int n_p, int operand, Rad R4D_PICK(l); } +/* grid_embed's operands plus the prefix rows (RADIO's class and register tokens). */ +extern "C" int r4d_shape_grid_embed_cpe(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { + const int64_t M = pi(p, n_p, "M"), n = pi(p, n_p, "n"), side = pi(p, n_p, "side"); + const int64_t npre = rad_param_geti(p, n_p, "n_prefix", 1); + const uint32_t D = dt_act(p, n_p, "dtype"); + const RadOpdDesc l[] = { opd(D, M, n), opd(D, side * side, n), opd_idx(4, M, side), + opd(D, npre > 0 ? npre : 1, n) }; + R4D_PICK(l); +} + extern "C" int r4d_shape_gemm_nt_bias(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { const int64_t M = pi(p, n_p, "M"), N = pi(p, n_p, "N"), K = pi(p, n_p, "K"); const uint32_t D = dt_act(p, n_p, "dtype"); @@ -421,6 +431,26 @@ extern "C" int r4d_shape_kda_update(const RadParam* p, int n_p, int operand, Rad R4D_PICK(l); } +extern "C" int r4d_shape_ssd_update(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { + const char* form = rad_param_gets(p, n_p, "state_form", ""); + if (!std::strcmp(form, "anchor")) return RAD_E_UNSUPPORTED; + const int64_t M = pi(p, n_p, "M"), H = pi(p, n_p, "heads"), P = pi(p, n_p, "head_dim"); + const int64_t N = pi(p, n_p, "d_state"), G = pi(p, n_p, "groups"); + if (G < 1 || H % G) return RAD_E_UNSUPPORTED; + const uint32_t D = dt_act(p, n_p, "dtype"); + const char* mode = rad_param_gets(p, n_p, "mode", ""); + const int64_t history = !std::strcmp(mode, "verify") ? M : 1; + const RadOpdDesc l[] = { + opd(D, M, H, P), opd(D, M, G, N), opd(D, M, G, N), opd(D, M, H), + opd((uint32_t)RAD_F32, H), opd((uint32_t)RAD_F32, H), opd((uint32_t)RAD_F32, H), + opd((uint32_t)RAD_F32, history + 1, H, P, N), + opd_idx(1, history, history + 1, -1, RAD_OPD_F_IDX_UNIQUE), + opd_idx(2, 0, M, -1, RAD_OPD_F_IDX_CU), + opd_idx(1, 0, 0, 1), opd_idx(1, 0, 0, 1), opd(D, M, H, P), + }; + R4D_PICK(l); +} + extern "C" int r4d_shape_mhc_pre(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { const int64_t M = pi(p, n_p, "M"), n = pi(p, n_p, "n"), hc = pi(p, n_p, "hc"); const uint32_t D = dt_act(p, n_p, "dtype"); @@ -617,6 +647,18 @@ extern "C" int r4d_shape_router_sigmoid_topk(const RadParam* p, int n_p, int ope opd(D, M, k) }; R4D_PICK(l); } +extern "C" int r4d_shape_router_sigmoid_group_topk(const RadParam* p, int n_p, int operand, + RadOpdDesc* out) { + const int64_t M = pi(p, n_p, "M"), ne = pi(p, n_p, "n_expert"), k = pi(p, n_p, "top_k"); + const int64_t ng = pi(p, n_p, "n_group"), kg = pi(p, n_p, "topk_group"); + if (ne <= 0 || ne > 512 || k <= 0 || ng <= 0 || ng > 32 || ne % ng || ne / ng < 2 || kg <= 0 || + kg > ng || k > kg * (ne / ng)) + return RAD_E_UNSUPPORTED; + const uint32_t D = dt_act(p, n_p, "dtype"); + const RadOpdDesc l[] = { opd(D, M, ne), opd((uint32_t)RAD_F32, ne), opd_idx(M, k, ne), + opd(D, M, k) }; + R4D_PICK(l); +} extern "C" int r4d_shape_router_sigmoid_topk_scatter(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { const int64_t M = pi(p, n_p, "M"), ne = pi(p, n_p, "n_expert"), k = pi(p, n_p, "top_k"); @@ -663,6 +705,24 @@ extern "C" int r4d_shape_mla_project(const RadParam* p, int n_p, int operand, Ra opd((uint32_t)RAD_BF16, M, h, absorb ? l : d) }; R4D_PICK(list); } +/* One sequence whose context is its query, as libref describes the op; a harness passes `ctx`. */ +extern "C" int r4d_shape_mla_attn_paged(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { + const int64_t M = pi(p, n_p, "M"), h = pi(p, n_p, "heads"), L = pi(p, n_p, "latent_dim"), + R = pi(p, n_p, "rope_dim"), bs = pi(p, n_p, "block_size"); + if (M <= 0 || h <= 0 || L <= 0 || R <= 0 || bs <= 0) return RAD_E_UNSUPPORTED; + int64_t ctx = pi(p, n_p, "ctx", 0); + if (ctx < M) ctx = M; + const int64_t blocks = (ctx + bs - 1) / bs; + const RadOpdDesc list[] = { opd((uint32_t)RAD_BF16, M, h, L), + opd((uint32_t)RAD_BF16, M, h, R), + opd((uint32_t)RAD_BF16, blocks, 1, bs, L + R), + opd_idx(1, blocks, blocks), + opd_idx(1, 0, 0, ctx), + opd_idx(2, 0, M + 1, -1, (uint32_t)RAD_OPD_F_IDX_CU), + opd_none(), + opd((uint32_t)RAD_BF16, M, h, L) }; + R4D_PICK(list); +} extern "C" int r4d_shape_dsa_score(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { const int64_t M = pi(p, n_p, "M"), n = pi(p, n_p, "n"), H = pi(p, n_p, "heads"); const int64_t B = pi(p, n_p, "blocks"), S = pi(p, n_p, "seqs"), pages = S * B; @@ -683,7 +743,9 @@ extern "C" int r4d_shape_mla_attn(const RadParam* p, int n_p, int operand, RadOp const int64_t B = pi(p, n_p, "blocks"), bs = pi(p, n_p, "block_size"), pages = std::max((int64_t)2, B * M); const uint32_t dt = dt_act(p, n_p, "dtype"); - const RadOpdDesc l[] = { opd(dt, M, H, D), opd(dt, pages, 1, bs, D), opd_idx(M, B, pages), + /* The cache is the query's dtype unless `kv_dtype` names another (fp8_e4m3). */ + const uint32_t kv = r4d_pgets(p, n_p, "kv_dtype") ? dt_act(p, n_p, "kv_dtype") : dt; + const RadOpdDesc l[] = { opd(dt, M, H, D), opd(kv, pages, 1, bs, D), opd_idx(M, B, pages), opd_idx(M, 0, 0, B * bs), opd(dt, M, H, D) }; R4D_PICK(l); } @@ -1032,6 +1094,20 @@ extern "C" int r4d_shape_attn_paged(const RadParam* p, int n_p, int operand, R4D_PICK(l); } +/* attn_paged_sink -- attn_paged's operands with `sinks` [n_head] f32 before `out`. */ +extern "C" int r4d_shape_attn_paged_sink(const RadParam* p, int n_p, int operand, + RadOpdDesc* out) { + if (operand < 7) return r4d_shape_attn_paged(p, n_p, operand, out); + if (operand == 8) return r4d_shape_attn_paged(p, n_p, 7, out); + const int64_t nh = pi(p, n_p, "n_head"); + if (nh <= 0) return RAD_E_UNSUPPORTED; + const RadOpdDesc l[] = { + opd_none(), opd_none(), opd_none(), opd_none(), opd_none(), opd_none(), opd_none(), + opd((uint32_t)RAD_F32, nh), + }; + R4D_PICK(l); +} + /* attn_paged_gate_quant -- attn_paged's operands, then gate_quant_fp8's gate, codes and scales, * flat as gate_quant_fp8 describes them: one row per (token, head) pair, `head_dim` columns. */ extern "C" int r4d_shape_attn_paged_gate_quant(const RadParam* p, int n_p, int operand, @@ -1727,6 +1803,49 @@ extern "C" int r4d_shape_pair_argmax(const RadParam* p, int n_p, int operand, Ra R4D_PICK(l); } +/* LiLiCorr's ops, described as libref describes them; lili_cand declines (its stats rows are no + * draw; avx_check_hand.cpp and tests/r4d_emu build them). */ +extern "C" int r4d_shape_lili_cand(const RadParam*, int, int, RadOpdDesc*) { + return RAD_E_UNSUPPORTED; +} +extern "C" int r4d_shape_lili_attn(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { + const int64_t M = pi(p, n_p, "M"), S = pi(p, n_p, "steps"), k = pi(p, n_p, "k"); + const int64_t nh = pi(p, n_p, "n_head"), hd = pi(p, n_p, "head_dim"); + if (M <= 0 || S <= 0 || k <= 0 || nh <= 0 || hd <= 0) return RAD_E_UNSUPPORTED; + const int64_t rows = (M + S * k - 1) / (S * k) * (S * k); + const RadOpdDesc l[] = { + opd((uint32_t)RAD_BF16, rows, 3 * nh * hd), + opd((uint32_t)RAD_F32, nh, 2 * S + 1), + opd((uint32_t)RAD_F32, nh), + opd((uint32_t)RAD_BF16, rows, nh * hd), + }; + R4D_PICK(l); +} +extern "C" int r4d_shape_lili_factor(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { + const int64_t M = pi(p, n_p, "M"), L = pi(p, n_p, "L"), n = pi(p, n_p, "n"); + if (M <= 0 || L <= 0 || n <= 0) return RAD_E_UNSUPPORTED; + const int64_t rows = (M + L - 1) / L * L; + const RadOpdDesc l[] = { + opd((uint32_t)RAD_BF16, rows, n), + opd((uint32_t)RAD_BF16, rows / L, n), + opd((uint32_t)RAD_BF16, rows, 3 * n), + }; + R4D_PICK(l); +} +extern "C" int r4d_shape_lili_walk(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { + const int64_t M = pi(p, n_p, "M"), S = pi(p, n_p, "steps"), k = pi(p, n_p, "k"); + const int64_t n = pi(p, n_p, "n"); + if (M <= 0 || S <= 0 || k <= 0 || n <= 0) return RAD_E_UNSUPPORTED; + const RadOpdDesc l[] = { + opd((uint32_t)RAD_BF16, M * S * k, 2 * n), + opd((uint32_t)RAD_BF16, M, n), + opd_idx(M * S, k, 1000), + opd((uint32_t)RAD_I32, M, S), + opd((uint32_t)RAD_F32, M, S, k, k), + }; + R4D_PICK(l); +} + /* ========================================================================================== * Quantisation, the norms and the fusions (shims beside their kernels). * @@ -1994,7 +2113,7 @@ extern "C" int r4d_shape_gram_accum(const RadParam* p, int n_p, int operand, Rad const int64_t n = pi(p, n_p, "n"); const int64_t g = pi(p, n_p, "group", R4D_FP8_BLOCK); /* dtype bf16 is a plain activation with no scale operand; fp8a8 is E4M3 codes and a dequant - * scale per (row, group). */ + * scale per (row, group), i8a8 the same with int8 codes. */ const char* dt = rad_param_gets(p, n_p, "dtype", nullptr); if (dt && !std::strcmp(dt, "bf16")) { const RadOpdDesc l[] = { @@ -2005,8 +2124,10 @@ extern "C" int r4d_shape_gram_accum(const RadParam* p, int n_p, int operand, Rad R4D_PICK(l); } if (g != R4D_FP8_BLOCK) return RAD_E_UNSUPPORTED; + /* i8a8: an int8 trunk's codes, with the same scale grid. */ + const uint32_t q = dt && !std::strcmp(dt, "i8a8") ? (uint32_t)RAD_I8 : (uint32_t)RAD_F8E4M3; const RadOpdDesc l[] = { - opd((uint32_t)RAD_F8E4M3, M, n), + opd(q, M, n), opd((uint32_t)RAD_F32, M, (n + g - 1) / g), opd((uint32_t)RAD_F32, n, n), }; @@ -2171,3 +2292,34 @@ extern "C" int r4d_shape_dflash_select(const RadParam* p, int n_p, int operand, }; R4D_PICK(l); } + +extern "C" int r4d_shape_dflash_markov(const RadParam* p, int n_p, int operand, + RadOpdDesc* out) { + const int64_t M = pi(p, n_p, "M"); + const int64_t steps = pi(p, n_p, "steps"); + const int64_t R = pi(p, n_p, "rank"); + const int64_t V = pi(p, n_p, "n_vocab"); + const int64_t astr = pi(p, n_p, "anchor_stride", 1); + const uint32_t D = dt_act(p, n_p, "dtype"); + if (M <= 0 || steps <= 0 || R <= 0 || V <= 0 || astr < 1) + return RAD_E_UNSUPPORTED; + const int64_t tiles = (V + 63) / 64; + const int64_t rows = M * steps; + const RadOpdDesc l[] = { + opd(D, rows, V), + opd_idx((M - 1) * astr + 1, 0, V), + opd(D, V, R), + opd(D, V, R), + opd((uint32_t)RAD_F32, M, tiles), + opd_idx(M, tiles, V), + opd_idx(M, steps, V), + }; + R4D_PICK(l); +} + +extern "C" int r4d_shape_dflash_markov_f32(const RadParam* p, int n_p, int operand, + RadOpdDesc* out) { + const int rc = r4d_shape_dflash_markov(p, n_p, operand, out); + if (rc == RAD_OK && operand == 0) out->dtype = RAD_F32; + return rc; +} diff --git a/libr4d/r4d_ssd.hip b/libr4d/r4d_ssd.hip new file mode 100644 index 00000000..e156c3dd --- /dev/null +++ b/libr4d/r4d_ssd.hip @@ -0,0 +1,282 @@ +/* Mamba-2's selective state update (ssd_update): libref/ref_ssd.cpp's recurrence, a token at a time. + * One wave owns four rows of a head's [head_dim, d_state] state and keeps each row's 128-wide state + * in four registers a lane, as r4d_kda.hip does; the rows' output reductions interleave and the + * next token's operands load while this one is reduced. Prefill runs the same recurrence and + * commits only its final state; verify writes every candidate's (per_candidate), or each token's + * record into the scratch slot (anchor, docs/OPS.md): the decay, u = dt' x and B, replayed onto the + * committed state by a separate dispatch before the next window, as r4d_kda.hip's replay is, so no + * wave overwrites a record another is still reading. The replay applies a record with the window's + * own fmaf, so the committed state is the per-candidate one bit for bit. */ +#include +#include "r4d_args.h" +#include "r4d_common.h" +#include "r4d_emit.h" +#include +#include +#include +#include + +namespace { +struct SsdMeta { + long xr, xh, br, bh, cr, ch, dr, dh, os0, os1; + long ss0, ss1, ss2, is0, is1, cs0, as0, hs0; + int tokens, slots, width, verify, per_group; + /* The anchor form: the record length 1 + head_dim + d_state and the most records a head's + * block holds (at most 32). */ + int anchor, head_dim, rec, deepest; +}; + +__device__ __forceinline__ float softplus(float v) { return v > 20.0f ? v : log1pf(expf(v)); } + +/* Element i of a head's scratch block, rows of 128 at the state's row pitch. */ +__device__ __forceinline__ long factor_offset(long base, int i, long pitch) { + return base + (long)(i / 128) * pitch + (i % 128); +} + +/* The previous window's accepted prefix onto the committed state (column 0), published; a cold + * sequence's committed rows are zeroed instead. One wave a state row. */ +__global__ void ssd_replay_kernel(float* state, const int* idx, const int* cu, const int* accepted, + const int* init, SsdMeta m) { + const int lane = threadIdx.x & 31, e = blockIdx.x * 4 + (threadIdx.x >> 5), head = blockIdx.y, + seq = blockIdx.z; + if (cu[(long)seq * m.cs0] == cu[(long)(seq + 1) * m.cs0]) return; + const int anchor = idx[(long)seq * m.is0], + scratch = idx[(long)seq * m.is0 + (m.width / 2) * m.is1]; + if (anchor < 0 || anchor >= m.slots || scratch < 0 || scratch >= m.slots || anchor == scratch) + return; + const long fb = (long)scratch * m.ss0 + (long)head * m.ss1; + const long sb = (long)anchor * m.ss0 + (long)head * m.ss1 + (long)e * m.ss2; + if (init && !init[(long)seq * m.hs0]) { +#pragma unroll + for (int d = 0; d < 4; ++d) state[sb + lane + d * 32] = 0; + return; + } + const float count = state[fb]; + const int na = accepted ? accepted[(long)seq * m.as0] : 1; + if (!(count >= 0 && count <= (float)m.deepest) || count != floorf(count) || na < 1 || + na > m.deepest || (count > 0 && na > count)) + return; + float s[4]; +#pragma unroll + for (int d = 0; d < 4; ++d) s[d] = state[sb + lane + d * 32]; + for (int t = 0; t < (count > 0 ? na : 0); ++t) { + const int f = 1 + t * m.rec; + const float decay = state[factor_offset(fb, f, m.ss2)]; + const float u = state[factor_offset(fb, f + 1 + e, m.ss2)]; +#pragma unroll + for (int d = 0; d < 4; ++d) + s[d] = fmaf(s[d], decay, + u * state[factor_offset(fb, f + 1 + m.head_dim + lane + 32 * d, m.ss2)]); + } +#pragma unroll + for (int d = 0; d < 4; ++d) state[sb + lane + d * 32] = s[d]; +} + +template +__global__ void ssd_rows_kernel(const uint16_t* x, const uint16_t* B, const uint16_t* C, + const uint16_t* dt, const float* alog, const float* dtb, + const float* dskip, float* state, uint16_t* out, const int* idx, + const int* cu, const int* accepted_ptr, const int* init, + SsdMeta m) { + const int lane = threadIdx.x & 31, e0 = (blockIdx.x * 4 + (threadIdx.x >> 5)) * R; + const int head = blockIdx.y, seq = blockIdx.z, grp = head / m.per_group; + const int begin = cu[(long)seq * m.cs0], end = cu[(long)(seq + 1) * m.cs0]; + const int accepted = accepted_ptr ? accepted_ptr[(long)seq * m.as0] : 1; + const int most = m.anchor ? m.deepest : m.width; + if (begin < 0 || end <= begin || end > m.tokens || accepted < 1 || accepted > most || + (m.verify && end - begin > most)) + return; + const int read = idx[(long)seq * m.is0 + (m.verify && !m.anchor ? accepted - 1 : 0) * m.is1]; + if (read >= m.slots) return; + uint16_t* const out_row = out + (long)head * m.os1 + e0; + if (read < 0) { + if (lane < R) + for (int t = begin; t < end; ++t) out_row[(long)t * m.os0 + lane] = 0; + return; + } + /* Under anchor the replay dispatch has already published the accepted prefix (or zeroed a cold + * sequence) at column 0. */ + const bool initialized = (m.anchor && m.verify) || !init || init[(long)seq * m.hs0] != 0; + const int scratch = m.anchor ? idx[(long)seq * m.is0 + (m.width / 2) * m.is1] : 0; + if (m.anchor && (scratch < 0 || scratch >= m.slots || scratch == read)) return; + const long fb = (long)scratch * m.ss0 + (long)head * m.ss1; + const long initial = (long)read * m.ss0 + (long)head * m.ss1 + (long)e0 * m.ss2; + float s[R][4]; +#pragma unroll + for (int r = 0; r < R; ++r) +#pragma unroll + for (int d = 0; d < 4; ++d) + s[r][d] = initialized ? state[initial + r * m.ss2 + lane + 32 * d] : 0; + const float A = -expf(alog[head]), bias = dtb[head], skip = dskip[head]; + const uint16_t* const xb = x + (long)head * m.xh + e0; + const uint16_t* const bb = B + (long)grp * m.bh + lane; + const uint16_t* const cb = C + (long)grp * m.ch + lane; + const uint16_t* const db = dt + (long)head * m.dh; + struct Token { + uint32_t b[4], c[4], x[R], dt; + }; + auto fetch = [&](int t, Token& o) { +#pragma unroll + for (int d = 0; d < 4; ++d) { + o.b[d] = ldg_u16(bb + (long)t * m.br + 32 * d); + o.c[d] = ldg_u16(cb + (long)t * m.cr + 32 * d); + } +#pragma unroll + for (int r = 0; r < R; ++r) o.x[r] = ldg_u16(xb + (long)t * m.xr + r); + o.dt = ldg_u16(db + (long)t * m.dr); + }; + Token cur; + fetch(begin, cur); + for (int t = begin; t < end; ++t) { + Token next; + /* The last token loads itself again rather than a row past `end`. */ + fetch(t + 1 < end ? t + 1 : t, next); + const float step = softplus(bf16w_lo(cur.dt) + bias); + const float decay = expf(step * A); + float bv[4], cv[4], xv[R], acc[R]; +#pragma unroll + for (int d = 0; d < 4; ++d) { + bv[d] = bf16w_lo(cur.b[d]); + cv[d] = bf16w_lo(cur.c[d]); + } + const bool record = m.anchor && m.verify; + const int f = 1 + (t - begin) * m.rec; + if (record && e0 == 0) { + if (!lane) state[factor_offset(fb, f, m.ss2)] = decay; +#pragma unroll + for (int d = 0; d < 4; ++d) + state[factor_offset(fb, f + 1 + m.head_dim + lane + 32 * d, m.ss2)] = bv[d]; + } +#pragma unroll + for (int r = 0; r < R; ++r) { + xv[r] = bf16w_lo(cur.x[r]); + const float u = step * xv[r]; + if (record && lane == r) state[factor_offset(fb, f + 1 + e0 + r, m.ss2)] = u; + acc[r] = 0; +#pragma unroll + for (int d = 0; d < 4; ++d) { + s[r][d] = fmaf(s[r][d], decay, u * bv[d]); + acc[r] += s[r][d] * cv[d]; + } + } + float mine = 0; +#pragma unroll + for (int r = 0; r < R; ++r) { + const float y = r4d_wave_sum(acc[r]) + skip * xv[r]; + if (lane == r) mine = y; + } + if (lane < R) out_row[(long)t * m.os0 + lane] = f32_to_bf16(mine); + if ((m.verify && !m.anchor) || (!m.verify && t + 1 == end)) { + const int write = idx[(long)seq * m.is0 + (m.verify ? t - begin : 0) * m.is1]; + if (write >= 0 && write < m.slots) { + const long target = (long)write * m.ss0 + (long)head * m.ss1 + (long)e0 * m.ss2; +#pragma unroll + for (int r = 0; r < R; ++r) +#pragma unroll + for (int d = 0; d < 4; ++d) state[target + r * m.ss2 + lane + 32 * d] = s[r][d]; + } + } + cur = next; + } + if (m.anchor && e0 == 0 && !lane) state[fb] = m.verify ? (float)(end - begin) : 0.0f; +} + +/* A [tokens, heads, width] bf16 plane as rank 3, or rank 2 [tokens, heads * width]: its row and + * head pitches. */ +bool headed(const RadTensor& t, long tokens, long heads, long width, long* row, long* head) { + if (!t.data || t.dtype != RAD_BF16 || t.shape[0] != tokens || t.stride[0] > INT_MAX) + return false; + if (t.rank == 3 && t.shape[1] == heads && t.shape[2] == width && t.stride[2] == 1 && + t.stride[1] >= width && t.stride[1] <= INT_MAX) { + *row = t.stride[0]; + *head = t.stride[1]; + return true; + } + if (t.rank == 2 && t.shape[1] == heads * width && t.stride[1] == 1 && + t.stride[0] >= heads * width) { + *row = t.stride[0]; + *head = width; + return true; + } + return false; +} +bool vector(const RadTensor& t, uint32_t dt, long n) { + return t.data && t.dtype == dt && t.rank == 1 && t.shape[0] >= n && t.stride[0] == 1; +} + +constexpr int kRows = 4, kState = 128; + +int body(const RadArgs* a, RadStream stream) { + if (!a || a->n_t < 13) return RAD_E_INVAL; + const long H = r4d_geti_or(a, "heads", 0), P = r4d_geti_or(a, "head_dim", 0); + const long N = r4d_geti_or(a, "d_state", 0), G = r4d_geti_or(a, "groups", 0); + if (H < 1 || H > 65535 || N != kState || P < 4 * kRows || P % (4 * kRows) || G < 1 || H % G) + return RAD_E_SHAPE; + const char* form = r4d_gets(a, "state_form"); + const bool anchor = form && !std::strcmp(form, "anchor"); + if (form && !anchor && std::strcmp(form, "per_candidate")) return RAD_E_INVAL; + const char* mode = r4d_gets(a, "mode"); + if (!mode || (std::strcmp(mode, "verify") && std::strcmp(mode, "prefill"))) return RAD_E_INVAL; + SsdMeta m{}; + m.verify = !std::strcmp(mode, "verify"); + m.anchor = anchor ? 1 : 0; + m.head_dim = (int)P; + m.rec = (int)(1 + P + N); + m.deepest = (int)std::min(32, (P * N - 1) / m.rec); + const auto &state = a->t[7], &idx = a->t[8], &cu = a->t[9]; + const long tokens = a->t[0].shape[0]; + if (tokens < 1 || tokens > INT_MAX || state.rank != 4 || state.dtype != RAD_F32 || + !state.data || state.shape[0] < 1 || state.shape[0] > INT_MAX || state.shape[1] != H || + state.shape[2] != P || state.shape[3] != N || state.stride[3] != 1 || + state.stride[2] < N || state.stride[1] < P * state.stride[2] || + state.stride[0] < H * state.stride[1] || cu.rank != 1 || cu.dtype != RAD_I32 || + !cu.data || cu.shape[0] < 2 || cu.shape[0] > 65536 || cu.stride[0] < 1 || + idx.rank != 2 || idx.dtype != RAD_I32 || !idx.data || idx.shape[0] < cu.shape[0] - 1 || + idx.shape[1] < 1 || idx.shape[1] > INT_MAX || idx.stride[1] < 1 || + idx.stride[0] < idx.shape[1] * idx.stride[1] || (anchor && idx.shape[1] < 2)) + return RAD_E_SHAPE; + if (!headed(a->t[0], tokens, H, P, &m.xr, &m.xh) || + !headed(a->t[1], tokens, G, N, &m.br, &m.bh) || + !headed(a->t[2], tokens, G, N, &m.cr, &m.ch) || + !headed(a->t[3], tokens, H, 1, &m.dr, &m.dh) || + !headed(a->t[12], tokens, H, P, &m.os0, &m.os1) || !vector(a->t[4], RAD_F32, H) || + !vector(a->t[5], RAD_F32, H) || !vector(a->t[6], RAD_F32, H)) + return RAD_E_SHAPE; + const RadTensor *accepted = rad_arg_in(a, 10), *init = rad_arg_in(a, 11); + if ((accepted && !vector(*accepted, RAD_I32, cu.shape[0] - 1)) || + (init && !vector(*init, RAD_I32, cu.shape[0] - 1))) + return RAD_E_SHAPE; + m.tokens = (int)tokens; + m.slots = (int)state.shape[0]; + m.width = (int)idx.shape[1]; + m.per_group = (int)(H / G); + m.ss0 = state.stride[0]; + m.ss1 = state.stride[1]; + m.ss2 = state.stride[2]; + m.is0 = idx.stride[0]; + m.is1 = idx.stride[1]; + m.cs0 = cu.stride[0]; + if (accepted) m.as0 = accepted->stride[0]; + if (init) m.hs0 = init->stride[0]; + const unsigned seqs = (unsigned)(cu.shape[0] - 1); + if (anchor && m.verify) { + const dim3 rgrid((unsigned)(P / 4), (unsigned)H, seqs); + const int rc = R4D_EMIT(stream, ssd_replay_kernel, rgrid, dim3(128), 0, + (float*)state.data, (const int*)idx.data, + (const int*)cu.data, + accepted ? (const int*)accepted->data : nullptr, + init ? (const int*)init->data : nullptr, m); + if (rc != RAD_OK) return rc; + } + const dim3 grid((unsigned)(P / (4 * kRows)), (unsigned)H, seqs); + return R4D_EMIT(stream, (ssd_rows_kernel), grid, dim3(128), 0, + (const uint16_t*)a->t[0].data, (const uint16_t*)a->t[1].data, + (const uint16_t*)a->t[2].data, (const uint16_t*)a->t[3].data, + (const float*)a->t[4].data, (const float*)a->t[5].data, + (const float*)a->t[6].data, (float*)state.data, (uint16_t*)a->t[12].data, + (const int*)idx.data, (const int*)cu.data, + accepted ? (const int*)accepted->data : nullptr, + init ? (const int*)init->data : nullptr, m); +} +} +extern "C" int r4d_rad_ssd_update(const RadArgs* a, RadStream stream) { return body(a, stream); } diff --git a/libr4d/r4d_vit_bf16.hip b/libr4d/r4d_vit_bf16.hip index 4bbe5a8d..7d5efdc8 100644 --- a/libr4d/r4d_vit_bf16.hip +++ b/libr4d/r4d_vit_bf16.hip @@ -170,6 +170,54 @@ __global__ __launch_bounds__(kThr) void grid_embed_aa_kernel( } } +// ---------------------------------------------------------------------------- grid_embed_cpe +// ref_grid_embed_cpe: RADIO's cropped position embedding, torch's half-pixel bilinear without +// antialias onto a square of the grid's larger side, cropped to the grid. Two taps an axis, the +// row blended first as libref does; rounded once before the add. +__device__ __forceinline__ void cpe_taps(int at, int d, int side, int* t, float* w) { + d = d < 1 ? 1 : d; + at = at < 0 ? 0 : (at >= d ? d - 1 : at); + float src = (float)side / (float)d * ((float)at + 0.5f) - 0.5f; + src = src < 0.0f ? 0.0f : src; + int i0 = (int)src; + i0 = i0 > side - 1 ? side - 1 : i0; + t[0] = i0; + t[1] = i0 < side - 1 ? i0 + 1 : i0; + w[1] = src - (float)i0; + w[0] = 1.0f - w[1]; +} + +template +__global__ __launch_bounds__(kThr) void grid_embed_cpe_kernel( + unsigned short* __restrict__ x, const void* __restrict__ tab, const int32_t* __restrict__ crd, + uint32_t n, int side, uint32_t x_ld, uint32_t plane, const unsigned short* __restrict__ pre, + int npre) { + const uint32_t m = blockIdx.x; + const int g[4] = { crd[m], crd[plane + m], crd[2 * plane + m], crd[3 * plane + m] }; + unsigned short* __restrict__ xr = x + (size_t)m * x_ld; + if (g[0] < 0) { + // A row ahead of its segment's patches: the learned bf16 row its column names. + if (!pre || npre <= 0) return; + const int k = g[1] < 0 ? 0 : (g[1] >= npre ? npre - 1 : g[1]); + for (uint32_t i = threadIdx.x; i < n; i += kThr) + xr[i] = f32_to_bf16(bf2f(xr[i]) + bf2f(pre[(size_t)k * n + i])); + return; + } + const int d = g[2] > g[3] ? g[2] : g[3]; + int th[2], tw[2]; + float wh[2], ww[2]; + cpe_taps(g[0], d, side, th, wh); + cpe_taps(g[1], d, side, tw, ww); + for (uint32_t i = threadIdx.x; i < n; i += kThr) { + const float r0 = ww[0] * ldw(tab, (uint32_t)(th[0] * side + tw[0]) * n + i) + + ww[1] * ldw(tab, (uint32_t)(th[0] * side + tw[1]) * n + i); + const float r1 = ww[0] * ldw(tab, (uint32_t)(th[1] * side + tw[0]) * n + i) + + ww[1] * ldw(tab, (uint32_t)(th[1] * side + tw[1]) * n + i); + const float pe = bf2f(f32_to_bf16(wh[0] * r0 + wh[1] * r1)); + xr[i] = f32_to_bf16(bf2f(xr[i]) + pe); + } +} + // ---------------------------------------------------------------------------- gemm_nt_bias #define VB_BK 64 #define VB_PITCH (VB_BK + 8) // 144-byte LDS rows, as in gemm_bf16_nt_tiled (bank spread) @@ -621,6 +669,41 @@ extern "C" int r4d_rad_grid_embed_aa(const RadArgs* a, RadStream stream) { (uint32_t)n, (int)side, (uint32_t)x_ld, plane); } +/* grid_embed_cpe: grid_embed's operands and checks, RADIO's cropped resample. */ +extern "C" int r4d_rad_grid_embed_cpe(const RadArgs* a, RadStream stream) { + const RadTensor* x = r4d_opt(a, GE_X); + const RadTensor* tab = r4d_opt(a, GE_TAB); + const RadTensor* crd = r4d_opt(a, GE_CRD); + if (!x || !tab || !crd) return R4D_NO(RAD_E_INVAL); + if (x->dtype != RAD_BF16 || crd->dtype != RAD_I32) return R4D_NO(RAD_E_DTYPE); + if (tab->dtype != RAD_BF16 && tab->dtype != RAD_F32) return R4D_NO(RAD_E_DTYPE); + if (!r4d_contig(tab)) return R4D_NO(RAD_E_STRIDE); + const long long n = r4d_geti_or(a, "n", r4d_dim(tab, (int)tab->rank - 1)); + const long long side = r4d_geti_or(a, "side", 0); + if (n <= 0 || side <= 0 || r4d_numel(tab) < side * side * n) return R4D_NO(RAD_E_SHAPE); + long long M = 0; + const long long x_ld = r4d_rows_pitch(x, n, &M); + if (x_ld < 0) return R4D_NO(RAD_E_STRIDE); + if (crd->rank != 2 || crd->shape[0] < 4 || crd->shape[1] < M || !r4d_contig(crd)) + return R4D_NO(RAD_E_SHAPE); + if (M <= 0) return R4D_NO(RAD_E_SHAPE); + const uint32_t plane = (uint32_t)crd->shape[1]; + /* The prefix rows: bf16, contiguous, n_prefix rows of n. */ + const long long npre = r4d_geti_or(a, "n_prefix", 0); + const RadTensor* pre = npre > 0 ? r4d_opt(a, 3) : nullptr; + if (npre > 0 && (!pre || pre->dtype != RAD_BF16 || !r4d_contig(pre) || + r4d_numel(pre) < npre * n)) + return R4D_NO(pre && pre->dtype != RAD_BF16 ? RAD_E_DTYPE : RAD_E_SHAPE); + const unsigned short* pp = pre ? (const unsigned short*)r4d_p(pre) : nullptr; + if (tab->dtype == RAD_F32) + return R4D_EMIT(stream, grid_embed_cpe_kernel, dim3((uint32_t)M), dim3(kThr), 0, + (unsigned short*)r4d_wp(x), r4d_p(tab), (const int32_t*)r4d_p(crd), + (uint32_t)n, (int)side, (uint32_t)x_ld, plane, pp, (int)npre); + return R4D_EMIT(stream, grid_embed_cpe_kernel, dim3((uint32_t)M), dim3(kThr), 0, + (unsigned short*)r4d_wp(x), r4d_p(tab), (const int32_t*)r4d_p(crd), + (uint32_t)n, (int)side, (uint32_t)x_ld, plane, pp, (int)npre); +} + /* ------------------------------------------------------------------ gemm_nt_bias */ enum { GB_A = 0, GB_W, GB_BIAS, GB_RES, GB_Y }; diff --git a/libref/ref_attn.cpp b/libref/ref_attn.cpp index d5b47a2a..c7658bba 100644 --- a/libref/ref_attn.cpp +++ b/libref/ref_attn.cpp @@ -75,20 +75,24 @@ struct KvDyn { } /* namespace */ /* ------------------------------------------------------------------ attn_paged */ +/* attn_paged, and attn_paged_sink with `sinks` (one logit a query head, beside the keys in the + * softmax's denominator and nowhere else): out at operand `oi`. */ /* attn_paged_tree's ninth operand, `spec_parent` (RadBatch::spec_parent, rad_drafter_tree), is * read here too: a row whose entry is -2 is an ordinary causal row; any other row is a node of its * sequence's verify block, whose entry is its parent's row within the sequence's rows (-1 for the * root, the block's first row). Inside the block such a row sees itself and its ancestors only, * and its window is measured from the block's first position plus its depth -- the position its * token has if its path is committed -- rather than from its row. */ -int ref_attn_paged(const RadArgs* a, RadStream) { - if (a->n_t < 8) return RAD_E_INVAL; - const RadTensor *q = &a->t[0], *kv = &a->t[1], *bt = &a->t[2], *su = &a->t[3], *o = &a->t[7]; +static int attn_paged_impl(const RadArgs* a, const RadTensor* sinks, int oi, bool shared_anchor_window) { + if (a->n_t < oi + 1) return RAD_E_INVAL; + const RadTensor *q = &a->t[0], *kv = &a->t[1], *bt = &a->t[2], *su = &a->t[3], *o = &a->t[oi]; const RadTensor* kdes = t_in(a, 4); const RadTensor* vdes = t_in(a, 5); const RadTensor* cus = t_in(a, 6); - const RadTensor* tpar = a->n_t > 8 ? t_in(a, 8) : nullptr; + /* The tree operand sits where attn_paged_sink keeps its output; a sinked call has none. */ + const RadTensor* tpar = !sinks && a->n_t > 8 ? t_in(a, 8) : nullptr; if (!q->data || !kv->data || !bt->data || !su->data || !o->data) return RAD_E_INVAL; + if (sinks && !sinks->data) return RAD_E_INVAL; const int64_t head_dim = p_int(a, "head_dim", q->rank >= 3 ? q->shape[q->rank - 1] : 0); const int64_t gqa = p_int(a, "gqa", 1); @@ -97,7 +101,8 @@ int ref_attn_paged(const RadArgs* a, RadStream) { const int64_t block_size = p_int(a, "block_size", kv->rank == 4 ? kv->shape[2] : 0); const int causal = (int)p_int(a, "causal", 1); const int64_t window = p_int(a, "window", 0); - if (head_dim <= 0 || gqa <= 0 || block_size <= 0) return RAD_E_SHAPE; + if (head_dim <= 0 || gqa <= 0 || block_size <= 0 || + (shared_anchor_window && window <= 0)) return RAD_E_SHAPE; if (head_dim > REF_HD_MAX) return RAD_E_UNSUPPORTED; const int64_t kv_heads = kv->rank == 4 ? kv->shape[1] : 0; @@ -106,6 +111,7 @@ int ref_attn_paged(const RadArgs* a, RadStream) { /* gqa and the cache's head count fix the query head count; a rank-3 query that disagrees would * stride through the wrong rows. */ if (q->rank >= 3 && q->shape[q->rank - 2] != q_heads) return RAD_E_SHAPE; + if (sinks && numel(sinks) != q_heads) return RAD_E_SHAPE; const int64_t n_seq = numel(su); const int64_t rows = numel(q) / (q_heads * head_dim); if (n_seq <= 0 || rows <= 0) return RAD_E_SHAPE; @@ -198,11 +204,16 @@ int ref_attn_paged(const RadArgs* a, RadStream) { /* Key j's slot in the cache, or -1 when the mask hides it or its block is * unmapped. */ auto key_at = [&](int64_t j) -> int64_t { - if (causal && j > pos) return -1; + const int64_t mask_pos = shared_anchor_window ? base : pos; + if (causal && j > mask_pos) return -1; if (tree && j >= base && !((tmask >> (j - base)) & 1)) return -1; if (window > 0) { - const int64_t d = wpos - j; - if (causal ? (d >= window) : (d >= window || d <= -window)) return -1; + const int64_t d = (shared_anchor_window ? base : wpos) - j; + if (shared_anchor_window) { + if (d >= window) return -1; + } else if (causal ? (d >= window) : (d >= window || d <= -window)) { + return -1; + } } const int64_t blk = ld_int(bt->dtype, bt->data, s * bt_rs + (j / block_size) * bt_cs); @@ -249,6 +260,11 @@ int ref_attn_paged(const RadArgs* a, RadStream) { return; } + /* A sink is one more logit in the softmax with no value: the maximum takes it, + * the sum adds it last, and the output stays the keys' weighted values. */ + const float sk = sinks ? ldt(sinks, h) : -INFINITY; + if (sinks && sk > mx) mx = sk; + /* Pass two: exponentiate and accumulate in ascending key order. */ float acc[REF_HD_MAX]; for (int64_t d = 0; d < head_dim; ++d) acc[d] = 0.0f; @@ -262,6 +278,7 @@ int ref_attn_paged(const RadArgs* a, RadStream) { for (int64_t d = 0; d < head_dim; ++d) acc[d] += w * (kl(kv->data, vb + d * kvv.sd) * vds); } + if (sinks) sum += ref_exp(sk - mx); const float inv = sum > 0.0f ? 1.0f / sum : 0.0f; for (int64_t d = 0; d < head_dim; ++d) stt(o, ob + d * o_ds, acc[d] * inv); }; @@ -276,6 +293,19 @@ int ref_attn_paged(const RadArgs* a, RadStream) { return RAD_OK; } +int ref_attn_paged(const RadArgs* a, RadStream) { return attn_paged_impl(a, nullptr, 7, false); } + +int ref_attn_paged_anchor_window(const RadArgs* a, RadStream) { + if (!a || a->n_t < 8) return RAD_E_INVAL; + if (a->n_t > 8 && t_in(a, 8)) return RAD_E_UNSUPPORTED; + return attn_paged_impl(a, nullptr, 7, true); +} + +int ref_attn_paged_sink(const RadArgs* a, RadStream) { + if (a->n_t < 9 || !a->t[7].data) return RAD_E_INVAL; + return attn_paged_impl(a, &a->t[7], 8, false); +} + /* attn_paged with its tree operand present: ref_attn_paged reads it (see there). Refused without * one, and for a non-causal layer, whose two-sided window has no tree reading here. */ int ref_attn_paged_tree(const RadArgs* a, RadStream s) { diff --git a/libref/ref_elementwise.cpp b/libref/ref_elementwise.cpp index abc369ef..0f383143 100644 --- a/libref/ref_elementwise.cpp +++ b/libref/ref_elementwise.cpp @@ -8,6 +8,7 @@ #include "ref_ops.h" #include +#include #include using namespace ref; @@ -248,6 +249,73 @@ int ref_grid_embed_aa(const RadArgs* a, RadStream) { return RAD_OK; } +/* grid_embed_cpe: RADIO's cropped position embedding (CPE). The table resampled as torch's + * F.interpolate(mode="bilinear", align_corners=False) -- without antialias -- onto a square of side + * d = max(grid height, grid width), of which the grid keeps the top-left h x w. Per axis two taps at + * src = (i + 0.5) * side / d - 0.5, clamped at 0, the upper tap clamped into the table, and blended + * along the row first as torch's bilinear kernel does. f32, rounded once before the add. */ +static void cpe_taps(int64_t at, int64_t d, int64_t side, int64_t t[2], float w[2]) { + if (d < 1) d = 1; + at = at < 0 ? 0 : (at >= d ? d - 1 : at); + float src = (float)side / (float)d * ((float)at + 0.5f) - 0.5f; + if (src < 0.0f) src = 0.0f; + int64_t i0 = (int64_t)src; + if (i0 > side - 1) i0 = side - 1; + t[0] = i0; + t[1] = i0 < side - 1 ? i0 + 1 : i0; + w[1] = src - (float)i0; + w[0] = 1.0f - w[1]; +} + +int ref_grid_embed_cpe(const RadArgs* a, RadStream) { + if (!have(a, 3)) return RAD_E_INVAL; + const RadTensor *x = &a->t[0], *tab = &a->t[1], *crd = &a->t[2]; + const int64_t n = p_int(a, "n", tab->rank ? tab->shape[tab->rank - 1] : 0); + const int64_t side = p_int(a, "side", 0); + if (n <= 0 || side <= 0 || numel(tab) < side * side * n) return RAD_E_SHAPE; + const int64_t rows = rows_of(x, n); + if (rows <= 0 || crd->rank != 2 || crd->shape[0] < 4 || crd->shape[1] < rows) + return RAD_E_SHAPE; + const int64_t cs = crd->stride[0], ms = crd->stride[1]; + const int64_t ts = laststride(tab); + /* The prefix rows, when n_prefix names some; without it the operand is not read. */ + const int64_t npre = p_int(a, "n_prefix", 0); + const RadTensor* pre = npre > 0 && a->n_t > 3 && a->t[3].data ? &a->t[3] : nullptr; + if (npre > 0 && (!pre || numel(pre) < npre * n)) return RAD_E_SHAPE; + + REF_PAR_FOR(rows * n * 4) + for (int64_t r = 0; r < rows; ++r) { + int64_t g[4]; + for (int c = 0; c < 4; ++c) g[c] = ld_int(crd->dtype, crd->data, c * cs + r * ms); + const int64_t xb0 = rowoff(x, r, n), xs0 = laststride(x); + if (g[0] < 0) { + /* A row ahead of its segment's patches: the learned row its column names. */ + const int64_t k = g[1] < 0 ? 0 : (g[1] >= npre ? npre - 1 : g[1]); + for (int64_t i = 0; npre > 0 && i < n; ++i) { + const float pe = round_dt(x->dtype, ldt(pre, rowoff(pre, k, n) + i * laststride(pre))); + stt(x, xb0 + i * xs0, ldt(x, xb0 + i * xs0) + pe); + } + continue; + } + const int64_t d = g[2] > g[3] ? g[2] : g[3]; + int64_t th[2], tw[2]; + float wh[2], ww[2]; + cpe_taps(g[0], d, side, th, wh); + cpe_taps(g[1], d, side, tw, ww); + const int64_t xb = rowoff(x, r, n), xs = laststride(x); + auto at = [&](int64_t y, int64_t c, int64_t i) { + return ldt(tab, rowoff(tab, y * side + c, n) + i * ts); + }; + for (int64_t i = 0; i < n; ++i) { + const float r0 = ww[0] * at(th[0], tw[0], i) + ww[1] * at(th[0], tw[1], i); + const float r1 = ww[0] * at(th[1], tw[0], i) + ww[1] * at(th[1], tw[1], i); + const float pe = round_dt(x->dtype, wh[0] * r0 + wh[1] * r1); + stt(x, xb + i * xs, ldt(x, xb + i * xs) + pe); + } + } + return RAD_OK; +} + /* ------------------------------------------------------------------ add / mul */ /* Elementwise over the output's extent. `b` may be a single row of exactly `n` elements, which * broadcasts along rows (a bias add); nothing else broadcasts, so a shape bug cannot pass as a @@ -376,7 +444,8 @@ int ref_silu_mul(const RadArgs* a, RadStream) { /* ------------------------------------------------------------------ act_mul */ /* y = act(a) * b, the gated product with its halves in two operands: two column slices of a fused * gate_up, or a gate whose multiplier is another tensor (Gemma's per-layer-input block multiplies - * gelu(gate(x)) by a per-layer embedding). + * gelu(gate(x)) by a per-layer embedding). With `relu` and the same tensor in both operands it is + * relu(x)^2, Nemotron-H's ungated expert activation. * * The activation is rounded to y's dtype before the product, as the unfused pair stores it. */ int ref_act_mul(const RadArgs* a, RadStream) { @@ -386,8 +455,8 @@ int ref_act_mul(const RadArgs* a, RadStream) { if (n <= 0) return RAD_E_SHAPE; const int64_t rows = rows_of(Y, n); if (rows <= 0 || numel(A) < rows * n || numel(B) < rows * n) return RAD_E_SHAPE; - static const char* kActs[] = { "silu", "gelu", "gelu_tanh", "sigmoid", "quick_gelu" }; - const int act = p_enum(a, "act", kActs, 5, -1); + static const char* kActs[] = { "silu", "gelu", "gelu_tanh", "sigmoid", "quick_gelu", "relu" }; + const int act = p_enum(a, "act", kActs, 6, -1); if (act < 0) return RAD_E_INVAL; REF_PAR_FOR(rows * n) @@ -401,6 +470,7 @@ int ref_act_mul(const RadArgs* a, RadStream) { const float v = act == 0 ? act_silu(g) : act == 1 ? act_gelu(g) : act == 2 ? act_gelu_tanh(g) : act == 3 ? act_sigmoid(g) + : act == 5 ? (g > 0.0f ? g : 0.0f) : act_sigmoid(round_dt(Y->dtype, g * round_dt(RAD_BF16, 1.702f))); stt(Y, yb + i * ys, round_dt(Y->dtype, v) * ldt(B, bb + i * bs)); @@ -525,6 +595,42 @@ int ref_pool_cols(const RadArgs* a, RadStream) { return RAD_OK; } +/* ------------------------------------------------------------------ point_fourier */ +/* A point's Fourier features: row m of y is [x | sin(x_i f_j) | cos(x_i f_j)] over x's n values, + * the sines and the cosines each i-major then j, f_j = 2^j for j < freqs (times pi with `pi` 1), + * so y has n (2 freqs + 1) columns. The products are f32 (exact without pi: a power of two), the + * sine and cosine f32 and rounded once to y's dtype, as Hunyuan3D-2's shape VAE embeds a query + * point. */ +int ref_point_fourier(const RadArgs* a, RadStream) { + if (!have(a, 2)) return RAD_E_INVAL; + const RadTensor *X = &a->t[0], *Y = &a->t[1]; + const int64_t n = p_int(a, "n", 0), F = p_int(a, "freqs", 0); + const bool pi = p_int(a, "pi", 0) != 0; + if (n <= 0 || F <= 0 || F > 30) return RAD_E_SHAPE; + const int64_t w = n * (2 * F + 1); + const int64_t M = rows_of(X, n); + if (M <= 0 || numel(Y) < M * w) return RAD_E_SHAPE; + float f[30]; + for (int64_t j = 0; j < F; ++j) + f[j] = pi ? (float)std::ldexp(3.14159265358979323846, (int)j) : std::ldexp(1.0f, (int)j); + + REF_PAR_FOR(M * w) + for (int64_t r = 0; r < M; ++r) { + const int64_t xb = rowoff(X, r, n), yb = rowoff(Y, r, w); + const int64_t xs = laststride(X), ys = laststride(Y); + for (int64_t i = 0; i < n; ++i) { + const float v = ldt(X, xb + i * xs); + stt(Y, yb + i * ys, v); + for (int64_t j = 0; j < F; ++j) { + const float t = v * f[j]; + stt(Y, yb + (n + i * F + j) * ys, std::sin(t)); + stt(Y, yb + (n + n * F + i * F + j) * ys, std::cos(t)); + } + } + } + return RAD_OK; +} + /* ------------------------------------------------------------------ relu */ /* y = max(x, 0) over [M, n], each operand at its own row pitch. */ int ref_relu(const RadArgs* a, RadStream) { diff --git a/libref/ref_glm.cpp b/libref/ref_glm.cpp index 1c1c7c8c..ae2423f3 100644 --- a/libref/ref_glm.cpp +++ b/libref/ref_glm.cpp @@ -68,6 +68,91 @@ int ref_router_sigmoid_topk(const RadArgs* a, RadStream) { return RAD_OK; } +/* Group-limited noaux_tc routing (DeepSeek-V3's, Ling-3.0's): the experts fall into `n_group` + * equal groups, a group ranks by the sum of its two highest `p + bias`, and selection runs over + * the experts of the `topk_group` best groups only. Weights as in router_sigmoid_topk. */ +int ref_router_sigmoid_group_topk(const RadArgs* a, RadStream) { + if (!have(a, 4)) return RAD_E_INVAL; + const auto &lg = a->t[0], &bias = a->t[1], &ids = a->t[2], &weights = a->t[3]; + const int64_t ne = p_int(a, "n_expert", 0), k = p_int(a, "top_k", 0), + ng = p_int(a, "n_group", 0), kg = p_int(a, "topk_group", 0); + const float scale = p_f32(a, "route_scale", 0); + const bool norm = p_int(a, "norm", 0) != 0; + if (ne < 1 || ne > 512 || k < 1 || ng < 1 || ne % ng || ne / ng < 2 || kg < 1 || kg > ng || + k > kg * (ne / ng) || !std::isfinite(scale) || scale <= 0 || lg.rank != 2 || + lg.shape[0] < 1 || lg.shape[1] != ne || bias.rank != 1 || bias.shape[0] != ne || + bias.dtype != RAD_F32 || ids.dtype != RAD_I32 || ids.rank != 2 || weights.rank != 2 || + ids.shape[0] != lg.shape[0] || weights.shape[0] != lg.shape[0] || ids.shape[1] != k || + weights.shape[1] != k || !lg.data || !bias.data || !ids.data || !weights.data) + return RAD_E_SHAPE; + const int64_t gsz = ne / ng; + for (int64_t r = 0; r < lg.shape[0]; ++r) { + float scores[512], select[512], chosen[512], gscore[512]; + int index[512]; + bool keep[512] = {}; + for (int64_t e = 0; e < ne; ++e) { + scores[e] = act_sigmoid(ldt(&lg, rowoff(&lg, r, ne) + e * laststride(&lg))); + select[e] = scores[e] + ldt(&bias, e * laststride(&bias)); + } + for (int64_t gi = 0; gi < ng; ++gi) { + float t0 = -INFINITY, t1 = -INFINITY; + for (int64_t e = gi * gsz; e < (gi + 1) * gsz; ++e) { + if (select[e] > t0) { t1 = t0; t0 = select[e]; } + else if (select[e] > t1) t1 = select[e]; + } + gscore[gi] = t0 + t1; + } + for (int64_t j = 0; j < kg; ++j) { + int best = -1; + for (int64_t gi = 0; gi < ng; ++gi) + if (gscore[gi] > -INFINITY && (best < 0 || gscore[gi] > gscore[best])) best = (int)gi; + if (best < 0) return RAD_E_SHAPE; + for (int64_t e = best * gsz; e < (best + 1) * gsz; ++e) keep[e] = true; + gscore[best] = -INFINITY; + } + float sum = 0; + for (int64_t j = 0; j < k; ++j) { + int best = -1; + for (int64_t e = 0; e < ne; ++e) + if (keep[e] && select[e] > -INFINITY && (best < 0 || select[e] > select[best])) + best = (int)e; + if (best < 0) return RAD_E_SHAPE; + index[j] = best; + chosen[j] = scores[best]; + sum += chosen[j]; + select[best] = -INFINITY; + } + for (int64_t j = 0; j < k; ++j) { + st_int(ids.dtype, ids.data, rowoff(&ids, r, k) + j * laststride(&ids), index[j]); + stt(&weights, rowoff(&weights, r, k) + j * laststride(&weights), + chosen[j] * (norm ? scale / (sum + 1e-20f) : scale)); + } + } + return RAD_OK; +} + +/* Ling-3.0's clamp: the SiLU is taken first and its value clipped above, the up branch on both + * sides (vLLM's SwigluStepAndMul). swiglu_clamped clips the gate before the SiLU instead. */ +int ref_swiglu_step(const RadArgs* a, RadStream) { + if (!have(a, 2)) return RAD_E_INVAL; + const auto &gu = a->t[0], &y = a->t[1]; + const int64_t n = p_int(a, "n", 0); + const float limit = p_f32(a, "limit", 0); + if (n < 1 || !std::isfinite(limit) || limit <= 0 || gu.rank != 2 || y.rank != 2 || !gu.data || + !y.data || y.shape[0] < 1 || gu.shape[0] != y.shape[0] || gu.shape[1] != 2 * n || + y.shape[1] != n) + return RAD_E_SHAPE; +#pragma omp parallel for schedule(static) + for (int64_t r = 0; r < y.shape[0]; ++r) + for (int64_t i = 0; i < n; ++i) { + const int64_t b = rowoff(&gu, r, 2 * n), s = laststride(&gu); + const float g = std::min(act_silu(ldt(&gu, b + i * s)), limit); + const float u = std::clamp(ldt(&gu, b + (n + i) * s), -limit, limit); + stt(&y, rowoff(&y, r, n) + i * laststride(&y), g * u); + } + return RAD_OK; +} + /* GLM clamps the gate only above, but clamps the up branch on both sides. */ int ref_swiglu_clamped(const RadArgs* a, RadStream) { if (!have(a, 2)) return RAD_E_INVAL; diff --git a/libref/ref_lili.cpp b/libref/ref_lili.cpp new file mode 100644 index 00000000..a57996d7 --- /dev/null +++ b/libref/ref_lili.cpp @@ -0,0 +1,260 @@ +/* ref_lili.cpp -- LiLiCorr's candidate correlator (NVIDIA's Nemotron-3.5-Bolt drafter; vLLM's + * model_executor/models/lilicorr.py), the four ops a block drafter's query pass ends in: + * + * lili_cand the candidates of every draft position from the target head's top-k, their five + * rank features through LayerNorm, the up projection and SiLU, and the lattice row's + * additive part: the position's own state plus a slot and a rank embedding + * lili_attn attention over each sequence's lattice of steps x k rows, with a learned bias per + * head on the slot distance and on the same slot + * lili_factor [h | a | h * a] a row, a = its sequence's anchor + * lili_walk the factored edge scores and the greedy walk over them + * + * A sequence's lattice is `steps` draft positions of `k` candidates, row s * k + j for position s's + * j-th candidate, the sequences one after another. Everything runs in f32 and rounds once to the + * output's dtype. + */ +#include "ref_common.h" +#include "ref_ops.h" + +#include +#include +#include + +using namespace ref; + +/* ------------------------------------------------------------------ lili_cand */ +/* stats [M, world * (2 + 2 row_k)] f32: each rank's sample_logprobs row (max, sum of exp(l - max), + * row_k >= k (id, logit) pairs descending), all-gathered row-interleaved; row_k defaults to k (a + * caller widens it so a row is whole 16-byte words for the all-gather). The ranks merge as one row would: + * the maximum and the rescaled sum give the log-normaliser, the pairs the k largest by value, ties + * to the lower id. For candidate j of row m, with lp_j = logit_j - lse: + * + * feat = [lp_j, exp(lp_j), lp_j - lp_0, j / (k - 1), j == 0] + * f = silu(up_w . layernorm(feat; ln_w, ln_b, eps) + up_b) -> feat out, row m*k+j + * base = pas[m] + slot[m % steps] + rank[j] -> base out, row m*k+j + * cand = id_j -> cand [M, k] i32 + */ +int ref_lili_cand(const RadArgs* a, RadStream) { + if (a->n_t < 11) return RAD_E_INVAL; + for (int i = 0; i < 11; ++i) if (!a->t[i].data) return RAD_E_INVAL; + const RadTensor *st = &a->t[0], *pas = &a->t[1], *lnw = &a->t[2], *lnb = &a->t[3]; + const RadTensor *upw = &a->t[4], *upb = &a->t[5], *slot = &a->t[6], *rank = &a->t[7]; + const RadTensor *cand = &a->t[8], *fo = &a->t[9], *bo = &a->t[10]; + const int64_t k = p_int(a, "k", 0), world = p_int(a, "world", 1), steps = p_int(a, "steps", 0); + const int64_t n = p_int(a, "n", 0); + const float eps = p_f32(a, "eps", 1e-5f); + const int64_t rk = p_int(a, "row_k", k); + if (k < 2 || k > 64 || rk < k || world < 1 || steps < 1 || n <= 0) return RAD_E_SHAPE; + const int64_t w = 2 + 2 * rk; + const int64_t M = rows_of(st, world * w); + if (M <= 0 || rows_of(pas, n) < M || numel(cand) < M * k || rows_of(fo, n) < M * k || + rows_of(bo, n) < M * k) + return RAD_E_SHAPE; + if (numel(lnw) < 5 || numel(lnb) < 5 || numel(upw) < n * 5 || numel(upb) < n || + rows_of(slot, n) < steps || rows_of(rank, n) < k) + return RAD_E_SHAPE; + if (cand->dtype != RAD_I32) return RAD_E_DTYPE; + + REF_PAR_FOR(M * k * n * 8) + for (int64_t m = 0; m < M; ++m) { + const int64_t sb = rowoff(st, m, world * w), ss = laststride(st); + auto S = [&](int64_t r, int64_t i) { return ldt(st, sb + (r * w + i) * ss); }; + /* The log-normaliser over every rank's shard. */ + float mx = -INFINITY; + for (int64_t r = 0; r < world; ++r) mx = std::max(mx, S(r, 0)); + double sum = 0.0; + for (int64_t r = 0; r < world; ++r) + if (S(r, 0) > -INFINITY) sum += (double)S(r, 1) * std::exp((double)S(r, 0) - mx); + const double lse = (double)mx + std::log(sum); + /* The k largest pairs of the world * k, by value, ties to the lower id. */ + std::vector> all; + all.reserve((size_t)(world * k)); + for (int64_t r = 0; r < world; ++r) + for (int64_t j = 0; j < k; ++j) { + const int64_t id = (int64_t)S(r, 2 + 2 * j); + if (id >= 0) all.push_back({ S(r, 3 + 2 * j), id }); + } + std::sort(all.begin(), all.end(), [](const auto& x, const auto& y) { + return x.first > y.first || (x.first == y.first && x.second < y.second); + }); + float lp[64]; + int64_t ids[64]; + for (int64_t j = 0; j < k; ++j) { + const bool have_j = j < (int64_t)all.size(); + ids[j] = have_j ? all[(size_t)j].second : 0; + lp[j] = have_j ? (float)((double)all[(size_t)j].first - lse) : -1e4f; + ((int32_t*)cand->data)[rowoff(cand, m, k) + j * laststride(cand)] = (int32_t)ids[j]; + } + const int64_t s = m % steps; + for (int64_t j = 0; j < k; ++j) { + const float f[5] = { lp[j], std::exp(lp[j]), lp[j] - lp[0], + (float)j / (float)(k - 1), j == 0 ? 1.0f : 0.0f }; + float mean = 0.0f; + for (int i = 0; i < 5; ++i) mean += f[i]; + mean /= 5.0f; + float var = 0.0f; + for (int i = 0; i < 5; ++i) var += (f[i] - mean) * (f[i] - mean); + var /= 5.0f; + const float rs = 1.0f / std::sqrt(var + eps); + float y[5]; + for (int i = 0; i < 5; ++i) y[i] = (f[i] - mean) * rs * ldt(lnw, i) + ldt(lnb, i); + const int64_t row = m * k + j; + const int64_t fb = rowoff(fo, row, n), fs = laststride(fo); + const int64_t bb = rowoff(bo, row, n), bs = laststride(bo); + for (int64_t c = 0; c < n; ++c) { + float u = ldt(upb, c); + for (int i = 0; i < 5; ++i) u += ldt(upw, c * 5 + i) * y[i]; + stt(fo, fb + c * fs, u / (1.0f + std::exp(-u))); + const float b = ldt(pas, rowoff(pas, m, n) + c * laststride(pas)) + + ldt(slot, rowoff(slot, s, n) + c * laststride(slot)) + + ldt(rank, rowoff(rank, j, n) + c * laststride(rank)); + stt(bo, bb + c * bs, b); + } + } + } + return RAD_OK; +} + +/* ------------------------------------------------------------------ lili_attn */ +/* qkv [M, 3 * n_head * head_dim] (q | k | v, heads contiguous within each), M = sequences * L with + * L = steps * k. Row i of a lattice sits at slot s_i = i / k. Per sequence and head: + * + * score(i, j) = q_i . k_j * scale + rel[h][s_i - s_j + steps] + (s_i == s_j ? same[h] : 0) + * out_i = softmax_j(score(i, .)) . v + * + * Every row sees every row of its lattice: the bias is a preference, not a mask. */ +int ref_lili_attn(const RadArgs* a, RadStream) { + if (!have(a, 4)) return RAD_E_INVAL; + const RadTensor *qkv = &a->t[0], *rel = &a->t[1], *same = &a->t[2], *o = &a->t[3]; + const int64_t steps = p_int(a, "steps", 0), k = p_int(a, "k", 0); + const int64_t nh = p_int(a, "n_head", 0), hd = p_int(a, "head_dim", 0); + if (steps < 1 || k < 1 || nh < 1 || hd < 1) return RAD_E_SHAPE; + const int64_t L = steps * k, n = nh * hd; + const int64_t M = rows_of(qkv, 3 * n); + if (M <= 0 || M % L || rows_of(o, n) < M) return RAD_E_SHAPE; + const int64_t rw = rel->rank ? rel->shape[rel->rank - 1] : 0; + if (rw < 2 * steps - 1 || rows_of(rel, rw) < nh || numel(same) < nh) return RAD_E_SHAPE; + const float scale = p_f32(a, "scale", 1.0f / std::sqrt((float)hd)); + const int64_t qs = laststride(qkv), os = laststride(o); + + REF_PAR_FOR(M * nh * L * hd * 2) + for (int64_t u = 0; u < M * nh; ++u) { + const int64_t i = u / nh, h = u % nh; + const int64_t q0 = i / L * L, si = (i - q0) / k; + const int64_t qb = rowoff(qkv, i, 3 * n) + h * hd * qs; + std::vector sc((size_t)L); + float mx = -INFINITY; + for (int64_t j = 0; j < L; ++j) { + const int64_t kb = rowoff(qkv, q0 + j, 3 * n) + (n + h * hd) * qs; + float dot = 0.0f; + for (int64_t d = 0; d < hd; ++d) dot += ldt(qkv, qb + d * qs) * ldt(qkv, kb + d * qs); + const int64_t sj = j / k; + float b = ldt(rel, rowoff(rel, h, rw) + (si - sj + steps) * laststride(rel)); + if (si == sj) b += ldt(same, h); + sc[(size_t)j] = dot * scale + b; + mx = std::max(mx, sc[(size_t)j]); + } + float sum = 0.0f; + for (int64_t j = 0; j < L; ++j) { sc[(size_t)j] = std::exp(sc[(size_t)j] - mx); sum += sc[(size_t)j]; } + const int64_t ob = rowoff(o, i, n) + h * hd * os; + for (int64_t d = 0; d < hd; ++d) { + float acc = 0.0f; + for (int64_t j = 0; j < L; ++j) + acc += sc[(size_t)j] * ldt(qkv, rowoff(qkv, q0 + j, 3 * n) + (2 * n + h * hd + d) * qs); + stt(o, ob + d * os, acc / sum); + } + } + return RAD_OK; +} + +/* ------------------------------------------------------------------ lili_factor */ +/* y[i] = [h_i | a_s | h_i * a_s] with s = i / L, the factor projection's input. */ +int ref_lili_factor(const RadArgs* a, RadStream) { + if (!have(a, 3)) return RAD_E_INVAL; + const RadTensor *h = &a->t[0], *an = &a->t[1], *y = &a->t[2]; + const int64_t L = p_int(a, "L", 0), n = p_int(a, "n", 0); + if (L < 1 || n < 1) return RAD_E_SHAPE; + const int64_t M = rows_of(h, n); + if (M <= 0 || M % L || rows_of(an, n) < M / L || rows_of(y, 3 * n) < M) return RAD_E_SHAPE; + REF_PAR_FOR(M * n * 3) + for (int64_t i = 0; i < M; ++i) { + const int64_t hb = rowoff(h, i, n), ab = rowoff(an, i / L, n), yb = rowoff(y, i, 3 * n); + const int64_t hs = laststride(h), as = laststride(an), ys = laststride(y); + for (int64_t c = 0; c < n; ++c) { + const float hv = ldt(h, hb + c * hs), av = ldt(an, ab + c * as); + stt(y, yb + c * ys, hv); + stt(y, yb + (n + c) * ys, av); + stt(y, yb + (2 * n + c) * ys, hv * av); + } + } + return RAD_OK; +} + +/* ------------------------------------------------------------------ lili_walk */ +/* edges [M * steps * k, 2n]: each candidate's outgoing | incoming vector, aout [M, n] the anchor's + * outgoing one, cand [M * steps, k] i32. Vectors are normalised as F.normalize (v / max(|v|, eps)). + * + * start[j] = scale * aout . in[0][j] + * pair[s][i][j] = scale * out[s][i] . in[s + 1][j] + * walk p_0 = argmax start, p_s = argmax pair[s - 1][p_{s-1}] (first index on ties) + * tokens[m][s] = cand[m * steps + s][p_s] + * + * `scores` [M, steps, k, k], when present, is vLLM's tensor: row 0 is start for every i. */ +int ref_lili_walk(const RadArgs* a, RadStream) { + if (!have(a, 4)) return RAD_E_INVAL; + const RadTensor *ed = &a->t[0], *ao = &a->t[1], *cd = &a->t[2], *tk = &a->t[3]; + const RadTensor* sco = a->n_t > 4 && a->t[4].data ? &a->t[4] : nullptr; + const int64_t steps = p_int(a, "steps", 0), k = p_int(a, "k", 0), n = p_int(a, "n", 0); + const float eps = p_f32(a, "eps", 1e-4f), scale = p_f32(a, "scale", 1.0f); + if (steps < 1 || k < 1 || n < 1) return RAD_E_SHAPE; + const int64_t M = rows_of(ao, n); + if (M <= 0 || rows_of(ed, 2 * n) < M * steps * k || numel(cd) < M * steps * k || + numel(tk) < M * steps) + return RAD_E_SHAPE; + if (cd->dtype != RAD_I32 || tk->dtype != RAD_I32) return RAD_E_DTYPE; + if (sco && numel(sco) < M * steps * k * k) return RAD_E_SHAPE; + + REF_PAR_FOR(M * steps * k * k * n) + for (int64_t m = 0; m < M; ++m) { + auto vec = [&](const RadTensor* t, int64_t row, int64_t pitch, int64_t col0, float* v) { + const int64_t b = rowoff(t, row, pitch) + col0 * laststride(t); + double ss = 0.0; + for (int64_t c = 0; c < n; ++c) { v[c] = ldt(t, b + c * laststride(t)); ss += (double)v[c] * v[c]; } + const float inv = 1.0f / std::max((float)std::sqrt(ss), eps); + for (int64_t c = 0; c < n; ++c) v[c] *= inv; + }; + std::vector va((size_t)n), vo((size_t)(steps * k * n)), vi((size_t)(steps * k * n)); + vec(ao, m, n, 0, va.data()); + for (int64_t r = 0; r < steps * k; ++r) { + vec(ed, m * steps * k + r, 2 * n, 0, &vo[(size_t)(r * n)]); + vec(ed, m * steps * k + r, 2 * n, n, &vi[(size_t)(r * n)]); + } + auto dot = [&](const float* x, const float* y) { + float s = 0.0f; + for (int64_t c = 0; c < n; ++c) s += x[c] * y[c]; + return s * scale; + }; + std::vector sc((size_t)(steps * k * k)); + for (int64_t j = 0; j < k; ++j) { + const float v = dot(va.data(), &vi[(size_t)(j * n)]); + for (int64_t i = 0; i < k; ++i) sc[(size_t)(i * k + j)] = v; + } + for (int64_t s = 1; s < steps; ++s) + for (int64_t i = 0; i < k; ++i) + for (int64_t j = 0; j < k; ++j) + sc[(size_t)((s * k + i) * k + j)] = + dot(&vo[(size_t)(((s - 1) * k + i) * n)], &vi[(size_t)((s * k + j) * n)]); + int64_t prev = 0; + for (int64_t s = 0; s < steps; ++s) { + int64_t best = 0; + for (int64_t j = 1; j < k; ++j) + if (sc[(size_t)((s * k + prev) * k + j)] > sc[(size_t)((s * k + prev) * k + best)]) best = j; + const int64_t id = ld_int(cd->dtype, cd->data, rowoff(cd, m * steps + s, k) + best * laststride(cd)); + ((int32_t*)tk->data)[rowoff(tk, m, steps) + s * laststride(tk)] = (int32_t)id; + prev = best; + } + if (sco) + for (int64_t e = 0; e < steps * k * k; ++e) stt(sco, m * steps * k * k + e, sc[(size_t)e]); + } + return RAD_OK; +} diff --git a/libref/ref_mla.cpp b/libref/ref_mla.cpp index 85515da0..361fdf62 100644 --- a/libref/ref_mla.cpp +++ b/libref/ref_mla.cpp @@ -50,6 +50,97 @@ int ref_mla_project(const RadArgs* a, RadStream) { return RAD_OK; } +/* Dense causal latent attention over a paged cache whose token row is the normed latent followed + * by the rotated key part (Ling-3.0's MLA). A score is scale * (q . latent + q_rope . rope); the + * value is the latent. Sequences, positions and the causal bound follow attn_paged: sequence s + * owns query rows [cu[s], cu[s+1]), its context after this step is seqused[s], and row i of it + * sits at position seqused[s] - qlen + i and sees keys 0..position. With `gate` the rounded output + * is multiplied by the rounded sigmoid of the head's gate logit and rounded again. */ +int ref_mla_attn_paged(const RadArgs* a, RadStream) { + /* q_rope (1) is required when rope_dim is nonzero, gate (6) is optional. */ + if (a->n_t < 8 || !t_in(a, 0) || !t_in(a, 2) || !t_in(a, 3) || !t_in(a, 4) || !t_in(a, 5) || + !t_in(a, 7)) + return RAD_E_INVAL; + RadTensor q = a->t[0], qr = a->t[1], o = a->t[7]; + const auto &kv = a->t[2], &bt = a->t[3], &su = a->t[4], &cu = a->t[5]; + const RadTensor* gate = t_in(a, 6); + const int64_t h = p_int(a, "heads", 0), L = p_int(a, "latent_dim", 0), + R = p_int(a, "rope_dim", 0), bs = p_int(a, "block_size", 0); + const float scale = p_f32(a, "scale", 0); + auto heads_view = [&](RadTensor& t, int64_t width) { + if (h > 0 && width > 0 && t.rank == 2 && t.shape[1] == h * width) { + t.rank = 3; + t.shape[1] = h; + t.shape[2] = width; + t.stride[2] = t.stride[1]; + t.stride[1] *= width; + } + }; + heads_view(q, L); + heads_view(qr, R); + heads_view(o, L); + if (h < 1 || L < 1 || L > 2048 || R < 0 || bs < 1 || !std::isfinite(scale) || scale <= 0 || + q.rank != 3 || q.shape[0] < 1 || q.shape[1] != h || q.shape[2] != L || (R && (qr.rank != 3 || + qr.shape[0] != q.shape[0] || qr.shape[1] != h || qr.shape[2] != R)) || kv.rank != 4 || + kv.shape[1] != 1 || kv.shape[2] != bs || kv.shape[3] < L + R || bt.rank != 2 || + su.rank != 1 || cu.rank != 1 || numel(&cu) != numel(&su) + 1 || o.rank != 3 || + o.shape[0] != q.shape[0] || o.shape[1] != h || o.shape[2] != L || + (gate && (gate->rank != 2 || gate->shape[0] != q.shape[0] || gate->shape[1] < h))) + return RAD_E_SHAPE; + if (!q.data || (R && !qr.data) || !kv.data || !bt.data || !su.data || !cu.data || !o.data) + return RAD_E_INVAL; + const int64_t n_seq = numel(&su), rows = q.shape[0]; + if (cu_at(&cu, 0) != 0 || cu_at(&cu, n_seq) != rows) return RAD_E_SHAPE; +#pragma omp parallel for schedule(dynamic) + for (int64_t job = 0; job < rows * h; ++job) { + const int64_t r = job / h, head = job % h; + const int64_t s = seq_of(&cu, n_seq, r); + const int64_t qlen = cu_at(&cu, s + 1) - cu_at(&cu, s), i = r - cu_at(&cu, s); + const int64_t ctx = ld_int(su.dtype, su.data, s * su.stride[0]); + const int64_t pos = ctx - qlen + i; + const int64_t live = std::min(pos + 1, bt.shape[1] * bs); + auto key_offset = [&](int64_t token) -> int64_t { + const int64_t page = + ld_int(bt.dtype, bt.data, s * bt.stride[0] + (token / bs) * bt.stride[1]); + return page < 0 || page >= kv.shape[0] + ? -1 + : page * kv.stride[0] + (token % bs) * kv.stride[2]; + }; + auto score = [&](int64_t base) -> float { + float v = 0; + for (int64_t c = 0; c < L; ++c) + v += ldt(&q, r * q.stride[0] + head * q.stride[1] + c * q.stride[2]) * + ldt(&kv, base + c * kv.stride[3]); + for (int64_t c = 0; c < R; ++c) + v += ldt(&qr, r * qr.stride[0] + head * qr.stride[1] + c * qr.stride[2]) * + ldt(&kv, base + (L + c) * kv.stride[3]); + return v * scale; + }; + float max = -INFINITY; + for (int64_t j = 0; j < live; ++j) { + const auto base = key_offset(j); + if (base >= 0) max = std::max(max, score(base)); + } + float val[2048] = {}, den = 0; + for (int64_t j = 0; j < live; ++j) { + const auto base = key_offset(j); + if (base < 0) continue; + const float w = std::exp(score(base) - max); + den += w; + for (int64_t c = 0; c < L; ++c) val[c] += w * ldt(&kv, base + c * kv.stride[3]); + } + const float g = gate ? round_dt(RAD_BF16, act_sigmoid(ldt(gate, r * gate->stride[0] + + head * gate->stride[1]))) + : 1.0f; + for (int64_t c = 0; c < L; ++c) { + float v = den > 0 ? val[c] / den : 0; + if (gate) v = round_dt(RAD_BF16, v) * g; + stt(&o, r * o.stride[0] + head * o.stride[1] + c * o.stride[2], v); + } + } + return RAD_OK; +} + int ref_mla_attn(const RadArgs* a, RadStream) { if (!have(a, 5)) return RAD_E_INVAL; const auto &q = a->t[0], &kv = a->t[1], &bt = a->t[2], &len = a->t[3], &out = a->t[4]; diff --git a/libref/ref_moe.cpp b/libref/ref_moe.cpp index d1b593ce..742d0064 100644 --- a/libref/ref_moe.cpp +++ b/libref/ref_moe.cpp @@ -17,6 +17,8 @@ #include "ref_gemm.h" #include "ref_ops.h" #include "ref_planes.h" +#include +#include #include #include @@ -707,9 +709,229 @@ static int moe_gemm_impl(const RadArgs* a, bool quant, int ncls = 2) { } int ref_moe_gemm(const RadArgs* a, RadStream) { return moe_gemm_impl(a, false); } -int ref_moe_gemm_q(const RadArgs* a, RadStream) { return moe_gemm_impl(a, true); } +int ref_moe_gemm_q(const RadArgs* a, RadStream s) { + const char* dt = p_str(a, "dtype", ""); + if (dt && std::strcmp(dt, "w4a8") == 0) return ref_moe_gemm_w4a8(a, s); + if (dt && std::strcmp(dt, "w4a4") == 0) return ref_moe_gemm_w4a4(a, s); + return moe_gemm_impl(a, true); +} int ref_moe_gemm_q_mod4(const RadArgs* a, RadStream) { return moe_gemm_impl(a, true, 4); } +/* ------------------------------------------------------------------ moe_gemm_w4a8 */ +/* moe_gemm_q dtype w4a8: y[i, :] = a[sorted_tok[i] / top_k, :] @ w[e(i)]^T. The two's-complement + * int4 experts (nibbles, -8..7) carry one bf16 scale per (row, 128 of K); the output is bf16 in + * sorted order. The experts are two tables by parity (the even in `w` / `w_scale`, the odd in + * `w_odd` / `w_odd_scale`, expert e at entry e/2 of class e%2). Two activation arms: + * * int8 a: each 128-block accumulates its raw product sum in i32 (exact), then folds + * (sub * a_scale) * w_scale in f32 in ascending block order -- the exact arithmetic and order + * the libr3d kernel runs, so the two agree bit for bit. + * * E4M3 a: the a and w codes decode exactly to f32 and the 128-block dot is summed in f32, the + * scales folded the same way; the kernel's f16 wave-matrix arm matches this to the f16 store + * ulp. + * A row no expert owns (a dropped slot) is left as the caller set it. */ +int ref_moe_gemm_w4a8(const RadArgs* a, RadStream) { + if (!have(a, 9)) return RAD_E_INVAL; + const RadTensor* A = &a->t[0]; + const RadTensor* AS = &a->t[1]; + const RadTensor* W = &a->t[2]; + const RadTensor* WS = &a->t[3]; + const RadTensor* ST = &a->t[4]; + const RadTensor* OF = &a->t[5]; + const RadTensor* WO = &a->t[6]; + const RadTensor* WOS = &a->t[7]; + const RadTensor* Y = &a->t[8]; + const bool e4m3 = (A->dtype == RAD_F8E4M3); + if (A->dtype != RAD_I8 && !e4m3) return RAD_E_DTYPE; + if (AS->dtype != RAD_F32 || W->dtype != RAD_I4 || WS->dtype != RAD_BF16 || Y->dtype != RAD_BF16) + return RAD_E_DTYPE; + if (e4m3 && (WO->dtype != RAD_I4 || WOS->dtype != RAD_BF16)) return RAD_E_DTYPE; + + const char* ord = p_str(a, "a_order", "token"); + const bool sorted_a = ord && std::strcmp(ord, "sorted") == 0; + if (ord && !sorted_a && std::strcmp(ord, "token") != 0) return RAD_E_UNSUPPORTED; + + const int64_t n_expert = p_int(a, "n_expert", W->rank >= 3 ? W->shape[0] * 2 : 0); + const int64_t top_k = p_int(a, "top_k", 1); + if (n_expert <= 0 || top_k <= 0) return RAD_E_SHAPE; + const int64_t N = W->rank >= 3 ? W->shape[1] : 0; + const int64_t K = W->rank >= 3 ? W->shape[2] : 0; + const int64_t T = Y->rank >= 2 ? Y->shape[0] : 0; + if (N <= 0 || K <= 0 || T <= 0 || K % 128) return RAD_E_SHAPE; + if (p_int(a, "N", N) != N || p_int(a, "K", K) != K) return RAD_E_SHAPE; + + const int64_t n_even = (n_expert + 1) / 2, n_odd = n_expert / 2; + if (W->rank < 3 || W->shape[0] < n_even || W->shape[1] < N || W->shape[2] < K) return RAD_E_SHAPE; + if (WS->rank < 3 || WS->shape[0] < n_even || WS->shape[1] < N || WS->shape[2] < K / 128) + return RAD_E_SHAPE; + if (n_odd > 0) { + if (WO->rank < 3 || WO->shape[0] < n_odd || WO->shape[1] < N || WO->shape[2] < K) + return RAD_E_SHAPE; + if (WOS->rank < 3 || WOS->shape[0] < n_odd || WOS->shape[1] < N || WOS->shape[2] < K / 128) + return RAD_E_SHAPE; + } + const int64_t M = A->rank >= 2 ? A->shape[0] : 0; + const int64_t ar = sorted_a ? T : M; + if (M <= 0 || numel(AS) < ar * (K / 128) || numel(ST) < T || numel(OF) < n_expert + 1) + return RAD_E_SHAPE; + + const int64_t a_ld = A->rank >= 2 ? A->stride[0] : K; + const int64_t y_ld = Y->rank >= 2 ? Y->stride[0] : N; + const int64_t w_ld = W->stride[1]; // nibbles per weight row + const int64_t ws_ld = WS->stride[1]; // scales per weight row + const int8_t* ap = (const int8_t*)A->data; + const uint8_t* ap8 = (const uint8_t*)A->data; + const float* asp = (const float*)AS->data; + const int32_t* st = (const int32_t*)ST->data; + const int32_t* of = (const int32_t*)OF->data; + const uint8_t* wp = (const uint8_t*)W->data; + const uint16_t* wsp = (const uint16_t*)WS->data; + const uint8_t* wop = (const uint8_t*)WO->data; + const uint16_t* wosp = (const uint16_t*)WOS->data; + uint16_t* yp = (uint16_t*)Y->data; + + for (int64_t i = 0; i < T; ++i) { + const int32_t f = st[i]; + const int64_t src = sorted_a ? i : (f >= 0 ? (int64_t)f / top_k : -1); + if (src < 0 || (!sorted_a && (int64_t)f / top_k >= M)) continue; // a dropped slot + int64_t e = 0; + while (e + 1 < n_expert && of[e + 1] <= i) ++e; + if (i < of[e] || i >= of[e + 1]) continue; // no expert owns this row + const int64_t cls = e & 1, e2 = e >> 1; + const uint8_t* wt = cls ? wop : wp; + const uint16_t* wst = cls ? wosp : wsp; + const int64_t wrow0 = (size_t)e2 * (size_t)N * w_ld / 2; + const int64_t wsrow0 = (size_t)e2 * (size_t)N * ws_ld; + for (int64_t n = 0; n < N; ++n) { + const uint8_t* wrow = wt + wrow0 + (size_t)n * w_ld / 2; + const uint16_t* wsrow = wst + wsrow0 + (size_t)n * ws_ld; + const float* asr = asp + src * (K / 128); + float acc = 0.f; + for (int64_t b = 0; b < K / 128; ++b) { + const int64_t k0 = b * 128; + float term; + float wscale; + const uint32_t ws_bits = (uint32_t)wsrow[b] << 16; /* bf16 -> f32: align to high 16 bits */ + std::memcpy(&wscale, &ws_bits, 4); + if (e4m3) { + float dot = 0.f; + for (int64_t k = 0; k < 128; ++k) + dot += fp8e4m3_to_f32(ap8[(size_t)src * a_ld + k0 + k]) * w4_code(wrow, k0 + k); + term = dot * asr[b] * wscale; + } else { + int32_t sub = 0; + for (int64_t k = 0; k < 128; ++k) + sub += (int32_t)ap[(size_t)src * a_ld + k0 + k] * (int32_t)w4_code(wrow, k0 + k); + term = (float)sub * asr[b] * wscale; + } + acc += term; + } + yp[i * y_ld + n] = f32_to_bf16(acc); + } + } + return RAD_OK; +} + +/* ------------------------------------------------------------------ moe_gemm_w4a4 */ +/* moe_gemm_q dtype w4a4: y[i, :] = a[sorted_tok[i] / top_k, :] @ w[e(i)]^T. Both the activation and + * the experts are two's-complement int4 (nibbles, -8..7) packed two per byte; the activation carries + * one f32 scale per (row, 128 of K), each expert one bf16 scale per (row, 128 of K); the output is + * bf16 in sorted order. The experts are two tables by parity (the even in `w` / `w_scale`, the odd in + * `w_odd` / `w_odd_scale`, expert e at entry e/2 of class e%2). Each 128-block accumulates its raw + * product sum in i32 (exact: both codes widen to int8), then folds (sub * a_scale) * w_scale in f32 + * in ascending block order -- the exact arithmetic and order the libr3d kernel runs, so the two agree + * bit for bit. A row no expert owns (a dropped slot) is left as the caller set it. */ +int ref_moe_gemm_w4a4(const RadArgs* a, RadStream) { + if (!have(a, 9)) return RAD_E_INVAL; + const RadTensor* A = &a->t[0]; + const RadTensor* AS = &a->t[1]; + const RadTensor* W = &a->t[2]; + const RadTensor* WS = &a->t[3]; + const RadTensor* ST = &a->t[4]; + const RadTensor* OF = &a->t[5]; + const RadTensor* WO = &a->t[6]; + const RadTensor* WOS = &a->t[7]; + const RadTensor* Y = &a->t[8]; + if (A->dtype != RAD_I4) return RAD_E_DTYPE; + if (AS->dtype != RAD_F32 || W->dtype != RAD_I4 || WS->dtype != RAD_BF16 || Y->dtype != RAD_BF16) + return RAD_E_DTYPE; + if (WO->dtype != RAD_I4 || WOS->dtype != RAD_BF16) return RAD_E_DTYPE; + + const char* ord = p_str(a, "a_order", "token"); + const bool sorted_a = ord && std::strcmp(ord, "sorted") == 0; + if (ord && !sorted_a && std::strcmp(ord, "token") != 0) return RAD_E_UNSUPPORTED; + + const int64_t n_expert = p_int(a, "n_expert", W->rank >= 3 ? W->shape[0] * 2 : 0); + const int64_t top_k = p_int(a, "top_k", 1); + if (n_expert <= 0 || top_k <= 0) return RAD_E_SHAPE; + const int64_t N = W->rank >= 3 ? W->shape[1] : 0; + const int64_t K = W->rank >= 3 ? W->shape[2] : 0; + const int64_t T = Y->rank >= 2 ? Y->shape[0] : 0; + if (N <= 0 || K <= 0 || T <= 0 || K % 128) return RAD_E_SHAPE; + if (p_int(a, "N", N) != N || p_int(a, "K", K) != K) return RAD_E_SHAPE; + + const int64_t n_even = (n_expert + 1) / 2, n_odd = n_expert / 2; + if (W->rank < 3 || W->shape[0] < n_even || W->shape[1] < N || W->shape[2] < K) return RAD_E_SHAPE; + if (WS->rank < 3 || WS->shape[0] < n_even || WS->shape[1] < N || WS->shape[2] < K / 128) + return RAD_E_SHAPE; + if (n_odd > 0) { + if (WO->rank < 3 || WO->shape[0] < n_odd || WO->shape[1] < N || WO->shape[2] < K) + return RAD_E_SHAPE; + if (WOS->rank < 3 || WOS->shape[0] < n_odd || WOS->shape[1] < N || WOS->shape[2] < K / 128) + return RAD_E_SHAPE; + } + const int64_t M = A->rank >= 2 ? A->shape[0] : 0; + const int64_t ar = sorted_a ? T : M; + if (M <= 0 || numel(AS) < ar * (K / 128) || numel(ST) < T || numel(OF) < n_expert + 1) + return RAD_E_SHAPE; + + const int64_t a_ld = A->rank >= 2 ? A->stride[0] / 2 : K / 2; // BYTES per activation row (K int4 = K/2 bytes) + const int64_t y_ld = Y->rank >= 2 ? Y->stride[0] : N; + const int64_t w_ld = W->stride[1]; // nibbles per weight row + const int64_t ws_ld = WS->stride[1]; // scales per weight row + const uint8_t* ap = (const uint8_t*)A->data; + const float* asp = (const float*)AS->data; + const int32_t* st = (const int32_t*)ST->data; + const int32_t* of = (const int32_t*)OF->data; + const uint8_t* wp = (const uint8_t*)W->data; + const uint16_t* wsp = (const uint16_t*)WS->data; + const uint8_t* wop = (const uint8_t*)WO->data; + const uint16_t* wosp = (const uint16_t*)WOS->data; + uint16_t* yp = (uint16_t*)Y->data; + + for (int64_t i = 0; i < T; ++i) { + const int32_t f = st[i]; + const int64_t src = sorted_a ? i : (f >= 0 ? (int64_t)f / top_k : -1); + if (src < 0 || (!sorted_a && (int64_t)f / top_k >= M)) continue; // a dropped slot + int64_t e = 0; + while (e + 1 < n_expert && of[e + 1] <= i) ++e; + if (i < of[e] || i >= of[e + 1]) continue; // no expert owns this row + const int64_t cls = e & 1, e2 = e >> 1; + const uint8_t* wt = cls ? wop : wp; + const uint16_t* wst = cls ? wosp : wsp; + const int64_t wrow0 = (size_t)e2 * (size_t)N * w_ld / 2; + const int64_t wsrow0 = (size_t)e2 * (size_t)N * ws_ld; + for (int64_t n = 0; n < N; ++n) { + const uint8_t* wrow = wt + wrow0 + (size_t)n * w_ld / 2; + const uint16_t* wsrow = wst + wsrow0 + (size_t)n * ws_ld; + const float* asr = asp + src * (K / 128); + float acc = 0.f; + for (int64_t b = 0; b < K / 128; ++b) { + const int64_t k0 = b * 128; + float wscale; + const uint32_t ws_bits = (uint32_t)wsrow[b] << 16; /* bf16 -> f32: high 16 bits */ + std::memcpy(&wscale, &ws_bits, 4); + int32_t sub = 0; + for (int64_t k = 0; k < 128; ++k) + sub += (int32_t)w4_code(ap + (size_t)src * a_ld, k0 + k) + * (int32_t)w4_code(wrow, k0 + k); + acc += (float)sub * asr[b] * wscale; + } + yp[i * y_ld + n] = f32_to_bf16(acc); + } + } + return RAD_OK; +} + /* ------------------------------------------------------------------ moe_gather */ /* y[t] = sum over the token's slots of expert_w[t, j] * y_expert[position of (t, j)]. * diff --git a/libref/ref_ops.h b/libref/ref_ops.h index fcdb6679..5c76d9d6 100644 --- a/libref/ref_ops.h +++ b/libref/ref_ops.h @@ -65,6 +65,7 @@ int ref_mhc_pre_finish (const RadArgs*, RadStream); int ref_mhc_post (const RadArgs*, RadStream); int ref_mhc_contract (const RadArgs*, RadStream); int ref_kda_update (const RadArgs*, RadStream); +int ref_ssd_update (const RadArgs*, RadStream); int ref_hc_read (const RadArgs*, RadStream); int ref_hc_write (const RadArgs*, RadStream); int ref_hc_project (const RadArgs*, RadStream); @@ -72,17 +73,25 @@ int ref_mtp_enter (const RadArgs*, RadStream); int ref_layernorm (const RadArgs*, RadStream); int ref_grid_embed (const RadArgs*, RadStream); int ref_grid_embed_aa (const RadArgs*, RadStream); +int ref_grid_embed_cpe (const RadArgs*, RadStream); +int ref_lili_cand (const RadArgs*, RadStream); +int ref_lili_attn (const RadArgs*, RadStream); +int ref_lili_factor (const RadArgs*, RadStream); +int ref_lili_walk (const RadArgs*, RadStream); int ref_add (const RadArgs*, RadStream); int ref_mul (const RadArgs*, RadStream); int ref_silu_mul (const RadArgs*, RadStream); int ref_swiglu_clamped (const RadArgs*, RadStream); int ref_router_sigmoid_topk(const RadArgs*, RadStream); +int ref_router_sigmoid_group_topk(const RadArgs*, RadStream); +int ref_swiglu_step (const RadArgs*, RadStream); int ref_dsa_pool(const RadArgs*, RadStream); int ref_dsa_query(const RadArgs*, RadStream); int ref_gemm_nt_f32(const RadArgs*, RadStream); int ref_mla_project(const RadArgs*, RadStream); int ref_dsa_score(const RadArgs*, RadStream); int ref_mla_attn(const RadArgs*, RadStream); +int ref_mla_attn_paged(const RadArgs*, RadStream); int ref_gelu_mul (const RadArgs*, RadStream); int ref_act_mul (const RadArgs*, RadStream); int ref_mul_weight (const RadArgs*, RadStream); @@ -91,6 +100,7 @@ int ref_seg_mean (const RadArgs*, RadStream); int ref_seg_softmax_pool (const RadArgs*, RadStream); int ref_pool_rows (const RadArgs*, RadStream); int ref_pool_cols (const RadArgs*, RadStream); +int ref_point_fourier (const RadArgs*, RadStream); int ref_relu (const RadArgs*, RadStream); int ref_clamp (const RadArgs*, RadStream); int ref_conv2d (const RadArgs*, RadStream); @@ -110,6 +120,7 @@ int ref_scatter_rows (const RadArgs*, RadStream); int ref_ngram_ids (const RadArgs*, RadStream); int ref_ple_gate (const RadArgs*, RadStream); int ref_ple_conv (const RadArgs*, RadStream); +int ref_ple_conv_bias (const RadArgs*, RadStream); int ref_causal_conv1d (const RadArgs*, RadStream); int ref_cast (const RadArgs*, RadStream); int ref_softmax (const RadArgs*, RadStream); @@ -128,11 +139,14 @@ int ref_rmsnorm_quant_fp8 (const RadArgs*, RadStream); int ref_gated_quant_fp8 (const RadArgs*, RadStream); int ref_gemm_nt_q_gated (const RadArgs*, RadStream); int ref_dflash_select (const RadArgs*, RadStream); +int ref_dflash_markov_greedy(const RadArgs*, RadStream); +int ref_dflash_markov_greedy_f32(const RadArgs*, RadStream); int ref_dflash_tree (const RadArgs*, RadStream); int ref_gram_accum (const RadArgs*, RadStream); int ref_rmsnorm_had_quant_i8(const RadArgs*, RadStream); int ref_gated_had_quant_i8 (const RadArgs*, RadStream); int ref_dequant (const RadArgs*, RadStream); +int ref_dequant_w4 (const RadArgs*, RadStream); /* ---- gemm and the vocabulary edges */ int ref_gemm_nt (const RadArgs*, RadStream); @@ -149,7 +163,9 @@ int ref_logits_gemm (const RadArgs*, RadStream); /* ---- attention */ int ref_attn_paged (const RadArgs*, RadStream); +int ref_attn_paged_anchor_window(const RadArgs*, RadStream); int ref_attn_paged_tree (const RadArgs*, RadStream); +int ref_attn_paged_sink (const RadArgs*, RadStream); int ref_attn_dense (const RadArgs*, RadStream); int ref_attn_cross (const RadArgs*, RadStream); int ref_table_add (const RadArgs*, RadStream); @@ -271,6 +287,8 @@ int ref_router_gemm_topk_scatter(const RadArgs*, RadStream); int ref_moe_gemm (const RadArgs*, RadStream); int ref_moe_gemm_q (const RadArgs*, RadStream); int ref_moe_gemm_q_mod4 (const RadArgs*, RadStream); +int ref_moe_gemm_w4a8 (const RadArgs*, RadStream); +int ref_moe_gemm_w4a4 (const RadArgs*, RadStream); /* The layout hooks of moe_gemm_q and moe_gemm_q_mod4: a codebook expert's views of several planes * in the joined form of abi/rad_planes.h, checked against `dtype` (ref_moe.cpp). */ int ref_moe_cb_layout (const RadParam*, int, int, const RadEncoding*, const int*, @@ -342,6 +360,7 @@ REF_SHAPE_FN(ref_mhc_pre_finish); REF_SHAPE_FN(ref_mhc_post); REF_SHAPE_FN(ref_mhc_contract); REF_SHAPE_FN(ref_kda_update); +REF_SHAPE_FN(ref_ssd_update); REF_SHAPE_FN(ref_hc_read); REF_SHAPE_FN(ref_hc_write); REF_SHAPE_FN(ref_hc_project); @@ -349,17 +368,25 @@ REF_SHAPE_FN(ref_mtp_enter); REF_SHAPE_FN(ref_layernorm); REF_SHAPE_FN(ref_grid_embed); REF_SHAPE_FN(ref_grid_embed_aa); +REF_SHAPE_FN(ref_grid_embed_cpe); +REF_SHAPE_FN(ref_lili_cand); +REF_SHAPE_FN(ref_lili_attn); +REF_SHAPE_FN(ref_lili_factor); +REF_SHAPE_FN(ref_lili_walk); REF_SHAPE_FN(ref_add); REF_SHAPE_FN(ref_mul); REF_SHAPE_FN(ref_silu_mul); REF_SHAPE_FN(ref_swiglu_clamped); REF_SHAPE_FN(ref_router_sigmoid_topk); +REF_SHAPE_FN(ref_router_sigmoid_group_topk); +REF_SHAPE_FN(ref_swiglu_step); REF_SHAPE_FN(ref_dsa_pool); REF_SHAPE_FN(ref_dsa_query); REF_SHAPE_FN(ref_gemm_nt_f32); REF_SHAPE_FN(ref_mla_project); REF_SHAPE_FN(ref_dsa_score); REF_SHAPE_FN(ref_mla_attn); +REF_SHAPE_FN(ref_mla_attn_paged); REF_SHAPE_FN(ref_gelu_mul); REF_SHAPE_FN(ref_act_mul); REF_SHAPE_FN(ref_mul_weight); @@ -368,6 +395,7 @@ REF_SHAPE_FN(ref_seg_softmax_pool); REF_SHAPE_FN(ref_seg_mean_bf16_sum); REF_SHAPE_FN(ref_pool_rows); REF_SHAPE_FN(ref_pool_cols); +REF_SHAPE_FN(ref_point_fourier); REF_SHAPE_FN(ref_relu); REF_SHAPE_FN(ref_clamp); REF_SHAPE_FN(ref_conv2d); @@ -387,6 +415,7 @@ REF_SHAPE_FN(ref_scatter_rows); REF_SHAPE_FN(ref_ngram_ids); REF_SHAPE_FN(ref_ple_gate); REF_SHAPE_FN(ref_ple_conv); +REF_SHAPE_FN(ref_ple_conv_bias); REF_SHAPE_FN(ref_causal_conv1d); REF_SHAPE_FN(ref_cast); REF_SHAPE_FN(ref_softmax); @@ -404,11 +433,14 @@ REF_SHAPE_FN(ref_rmsnorm_quant_fp8); REF_SHAPE_FN(ref_gated_quant_fp8); REF_SHAPE_FN(ref_gemm_nt_q_gated); REF_SHAPE_FN(ref_dflash_select); +REF_SHAPE_FN(ref_dflash_markov_greedy); +REF_SHAPE_FN(ref_dflash_markov_greedy_f32); REF_SHAPE_FN(ref_dflash_tree); REF_SHAPE_FN(ref_gram_accum); REF_SHAPE_FN(ref_rmsnorm_had_quant_i8); REF_SHAPE_FN(ref_gated_had_quant_i8); REF_SHAPE_FN(ref_dequant); +REF_SHAPE_FN(ref_dequant_w4); REF_SHAPE_FN(ref_gemm_nt); REF_SHAPE_FN(ref_gemm_nt_bias); @@ -422,7 +454,9 @@ REF_SHAPE_FN(ref_embed_lookup_q); REF_SHAPE_FN(ref_logits_gemm); REF_SHAPE_FN(ref_attn_paged); +REF_SHAPE_FN(ref_attn_paged_anchor_window); REF_SHAPE_FN(ref_attn_paged_tree); +REF_SHAPE_FN(ref_attn_paged_sink); REF_SHAPE_FN(ref_attn_dense); REF_SHAPE_FN(ref_attn_cross); REF_SHAPE_FN(ref_table_add); @@ -532,6 +566,8 @@ REF_SHAPE_FN(ref_router_gemm_topk_scatter); REF_SHAPE_FN(ref_moe_gemm); REF_SHAPE_FN(ref_moe_gemm_q); REF_SHAPE_FN(ref_moe_gemm_q_mod4); +REF_SHAPE_FN(ref_moe_gemm_w4a8); +REF_SHAPE_FN(ref_moe_gemm_w4a4); REF_SHAPE_FN(ref_scale_rows); REF_SHAPE_FN(ref_moe_gather); REF_SHAPE_FN(ref_row_topk); diff --git a/libref/ref_ple.cpp b/libref/ref_ple.cpp index 01a1ffea..d3b2adb5 100644 --- a/libref/ref_ple.cpp +++ b/libref/ref_ple.cpp @@ -195,11 +195,12 @@ int ref_ple_gate(const RadArgs* a, RadStream) { struct ConvArgs { const RadTensor *x, *w, *cs, *cu, *resid, *sidx, *hini, *nacc, *y; bool silu; + const RadTensor* b; /* per-channel bias inside the activation (Mamba-2's conv1d), or null */ }; static int depthwise_causal_conv(const RadArgs* a, const ConvArgs& o) { const RadTensor *x = o.x, *w = o.w, *cs = o.cs, *cu = o.cu, *resid = o.resid; - const RadTensor *sidx = o.sidx, *hini = o.hini, *nacc = o.nacc, *y = o.y; + const RadTensor *sidx = o.sidx, *hini = o.hini, *nacc = o.nacc, *y = o.y, *b = o.b; if (!x || !w || !cs || !cu || !y) return RAD_E_INVAL; const int64_t n = p_int(a, "n", 0); @@ -217,6 +218,7 @@ static int depthwise_causal_conv(const RadArgs* a, const ConvArgs& o) { if (N <= 0) return RAD_E_SHAPE; if (numel(x) < M * n || numel(y) < M * n || numel(w) < n * wid) return RAD_E_SHAPE; if (resid && numel(resid) < M * n) return RAD_E_SHAPE; + if (b && numel(b) != n) return RAD_E_SHAPE; const int64_t state_len = cs->rank >= 3 ? cs->shape[cs->rank - 1] : hist_len; if (cs->data && state_len < hist_len) return RAD_E_SHAPE; @@ -263,8 +265,9 @@ static int depthwise_causal_conv(const RadArgs* a, const ConvArgs& o) { for (int64_t i = 0; i < hist_len; ++i) hist[i] = (warm && cs->data) ? ldt(cs, base + (off + i) * cs_t) : 0.0f; + const float bias = b ? ldt(b, c * laststride(b)) : 0.0f; for (int64_t t = 0; t < slen; ++t) { - float acc = 0.0f; + float acc = bias; for (int64_t j = 0; j < wid; ++j) { const int64_t src = t - hist_len + j * dil; const float v = src >= 0 ? ldt(x, (bos + src) * xrow + c * xcol) @@ -300,6 +303,15 @@ int ref_ple_conv(const RadArgs* a, RadStream) { t_in(a, 5), t_in(a, 6), t_in(a, 7), t_in(a, 8), true }); } +/* ple_conv's operands with `b`, a per-channel bias inside the silu, before `y`: Mamba-2's + * conv1d at dilation one. */ +int ref_ple_conv_bias(const RadArgs* a, RadStream) { + if (a->n_t < 10 || !t_in(a, 8)) return RAD_E_INVAL; + return depthwise_causal_conv(a, { t_in(a, 0), t_in(a, 1), t_in(a, 2), t_in(a, 3), t_in(a, 4), + t_in(a, 5), t_in(a, 6), t_in(a, 7), t_in(a, 9), true, + t_in(a, 8) }); +} + /* ple_conv's operands without `resid`, at dilation one and with no activation. */ int ref_causal_conv1d(const RadArgs* a, RadStream) { if (a->n_t < 8) return RAD_E_INVAL; diff --git a/libref/ref_quant.cpp b/libref/ref_quant.cpp index 5b0838bb..f1a061c3 100644 --- a/libref/ref_quant.cpp +++ b/libref/ref_quant.cpp @@ -273,6 +273,66 @@ int ref_dequant(const RadArgs* a, RadStream) { return RAD_OK; } +/* ------------------------------------------------------------------ dequant_w4 + * The packed 4-bit weight back to a plain row-major bf16 [N, K]. The fragment order is + * [t][kb][lh][r][s] with eight nibbles along i, where t = n/16, r = n%16, kb = k/64, + * s = (k%64)/16, and the k inside the step is 4*lh + _KOFF[i] with _KOFF = {0,8,1,9,2,10,3,11}. + * The scale dword at [t][g][r] holds the f16 scale low and -(1024+zero) high. */ +static const int kKOFF[8] = {0, 8, 1, 9, 2, 10, 3, 11}; +static float f16_bits_to_f32(uint16_t h) { + uint32_t sign = (uint32_t)(h >> 15) << 31; + uint32_t exp = (uint32_t)(h >> 10) & 0x1fu; + uint32_t mant = (uint32_t)(h & 0x3ffu); + uint32_t f32; + if (exp == 0) { + if (mant == 0) f32 = sign; + else { while (!(mant & 0x400u)) { mant <<= 1; --exp; } f32 = sign | ((exp + 126u) << 23) | ((mant & 0x3ffu) << 13); } + } else if (exp == 31) { + f32 = sign | 0x7f800000u | (mant << 13); + } else { + f32 = sign | ((exp + 112u) << 23) | (mant << 13); + } + float f; std::memcpy(&f, &f32, 4); return f; +} + +int ref_dequant_w4(const RadArgs* a, RadStream) { + if (!have(a, 3)) return RAD_E_INVAL; + const RadTensor *wq = &a->t[0], *ws = &a->t[1], *y = &a->t[2]; + const int64_t N = y->shape[0], K = y->shape[1]; + const int64_t group = p_int(a, "group", 128); + const int64_t twos = p_int(a, "twos", 1); + if (N <= 0 || K <= 0 || N % 16 || K % 64 || group < 1 || K % group) return RAD_E_SHAPE; + + const uint32_t* Wq = (const uint32_t*)wq->data; + const uint32_t* Ws = (const uint32_t*)ws->data; + const int64_t nkb = K / 64, ng = K / group; + const int64_t ys = y->stride[1]; + + for (int64_t idx = 0; idx < N * K / 8; ++idx) { + const int s = (int)(idx & 3); + const int r = (int)((idx >> 2) & 15); + const int lh = (int)((idx >> 6) & 1); + const int kb = (int)((idx >> 7) % nkb); + const int t = (int)((idx >> 7) / nkb); + const int row_n = t * 16 + r; + const uint32_t w = Wq[idx]; + + const int kbase = kb * 64 + s * 16 + 4 * lh; + const uint32_t sz = Ws[(size_t)(t * ng + kbase / group) * 16 + r]; + const float sc = f16_bits_to_f32((uint16_t)(sz & 0xFFFFu)); + const float nz = f16_bits_to_f32((uint16_t)(sz >> 16)); + const float zero = -nz - 1024.f; + + for (int i = 0; i < 8; i++) { + const int n = (int)((w >> (4 * i)) & 0xF); + const float q = twos ? (float)((n ^ 8) - 8) : (float)n; + const int k = kbase + kKOFF[i]; + stt(y, (size_t)row_n * K + k, (q - (twos ? 0.f : zero)) * sc); + } + } + return RAD_OK; +} + /* ------------------------------------------------------------------ quant_act_fp8 * * The oracle for the block-scaled FP8 family, the activation format the production checkpoints @@ -824,6 +884,97 @@ int ref_dflash_select(const RadArgs* a, RadStream) { return RAD_OK; } +/* ------------------------------------------------------ dflash_markov_greedy */ +/* `logits`, `anchor`, `pred`w, `succ`w -> tile-local winners and `tokens`. + * + * The pinned DSpark reference adds the full-vocabulary bilinear bigram bias to each draft-head + * score, then takes a vocabulary-wide greedy argmax at every position. This is deliberately not + * `dflash_select`: no top-K candidate restriction is applied, and the result at one position is + * the predecessor for the next. Scratch is a 64-token tile decomposition used by the device row; + * the reference writes the same tile winners before selecting the global winner. */ +static int ref_markov_greedy(const RadArgs* a, uint32_t logits_dtype) { + if (a->n_t < 7) return RAD_E_INVAL; + const RadTensor *logits = &a->t[0], *anchor = &a->t[1], *pred = &a->t[2]; + const RadTensor *succ = &a->t[3], *tile_scores = &a->t[4], *tile_tokens = &a->t[5]; + const RadTensor *out = &a->t[6]; + if (!logits->data || !anchor->data || !pred->data || !succ->data || + !tile_scores->data || !tile_tokens->data || !out->data) return RAD_E_INVAL; + if (logits->dtype != logits_dtype || pred->dtype != RAD_BF16 || succ->dtype != RAD_BF16 || + tile_scores->dtype != RAD_F32 || tile_tokens->dtype != RAD_I32 || out->dtype != RAD_I32) + return RAD_E_DTYPE; + /* The device requires I32 anchors and reports invalid anchor tensors as shape errors. */ + if (anchor->dtype != RAD_I32) return RAD_E_SHAPE; + + const int64_t steps = p_int(a, "steps", 0); + const int64_t R = p_int(a, "rank", 0); + const int64_t V = p_int(a, "n_vocab", 0); + const int64_t astr = p_int(a, "anchor_stride", 1); + const int64_t M = steps > 0 && V > 0 + ? band_rows(numel(logits) / (steps * V), p_int(a, "M", 0)) : 0; + if (M <= 0 || steps <= 0 || R <= 0 || V <= 0 || astr <= 0) return RAD_E_SHAPE; + if (numel(logits) < M * steps * V || numel(anchor) < (M - 1) * astr + 1 || + numel(pred) < V * R || numel(succ) < V * R || numel(out) < M * steps) + return RAD_E_SHAPE; + const int64_t n_tiles = (V + 63) / 64; + if (numel(tile_scores) < M * n_tiles || numel(tile_tokens) < M * n_tiles) + return RAD_E_SHAPE; + + const int64_t ls = laststride(logits), ps = laststride(pred), ss = laststride(succ); + const int64_t os = laststride(out), tss = laststride(tile_scores), tis = laststride(tile_tokens); + REF_PAR_FOR(M * steps * V * R) + for (int64_t m = 0; m < M; ++m) { + std::vector previous((size_t)R); + int64_t pid = ld_int(anchor->dtype, anchor->data, offlin(anchor, m * astr)); + for (int64_t l = 0; l < steps; ++l) { + const int64_t row = m * steps + l; + const bool pid_ok = pid >= 0 && pid < V; + const int64_t pb = pid_ok ? rowoff(pred, pid, R) : 0; + for (int64_t r = 0; r < R; ++r) + previous[(size_t)r] = pid_ok ? ldt(pred, pb + r * ps) : 0.0f; + + float global_best = -INFINITY; + int64_t global_token = 0; + for (int64_t tile = 0; tile < n_tiles; ++tile) { + const int64_t first = tile * 64; + const int64_t end = std::min(first + 64, V); + float best = -INFINITY; + int64_t best_token = first; + const int64_t lb = rowoff(logits, row, V); + for (int64_t token = first; token < end; ++token) { + const float base = ldt(logits, lb + token * ls); + float score = logits_dtype == RAD_F32 ? 0.0f : base; + const int64_t sb = rowoff(succ, token, R); + for (int64_t r = 0; r < R; ++r) + score += previous[(size_t)r] * ldt(succ, sb + r * ss); + if (logits_dtype == RAD_F32) score += base; + if (score > best || (score == best && token < best_token)) { + best = score; + best_token = token; + } + } + stt(tile_scores, rowoff(tile_scores, m, n_tiles) + tile * tss, best); + st_int(tile_tokens->dtype, tile_tokens->data, + rowoff(tile_tokens, m, n_tiles) + tile * tis, best_token); + if (best > global_best || (best == global_best && best_token < global_token)) { + global_best = best; + global_token = best_token; + } + } + st_int(out->dtype, out->data, rowoff(out, m, steps) + l * os, global_token); + pid = global_token; + } + } + return RAD_OK; +} + +int ref_dflash_markov_greedy(const RadArgs* a, RadStream) { + return ref_markov_greedy(a, RAD_BF16); +} + +int ref_dflash_markov_greedy_f32(const RadArgs* a, RadStream) { + return ref_markov_greedy(a, RAD_F32); +} + /* ------------------------------------------------------------- dflash_tree */ /* `cand`, `unary`, `hp`?, `anchor`, `pred`w, `succ`w -> `tokens`, `parents` * diff --git a/libref/ref_registry.cpp b/libref/ref_registry.cpp index eb771ba0..e7a05c23 100644 --- a/libref/ref_registry.cpp +++ b/libref/ref_registry.cpp @@ -112,6 +112,10 @@ static const RadParamSpec pPleConv[] = { P_INT("M"), P_INT("n"), P_INT("width"), static const RadOperandSpec oPleConv[] = { OPD("x"), WGT("w"), INOUT("conv_state"), OPD("cu"), OPD_O("resid"), OPD_O("cache_idx"), OPD_O("has_init"), OPD_O("num_accepted"), OUT("y") }; +/* ple_conv's operands with `b`, a per-channel bias inside the silu, before `y`. */ +static const RadOperandSpec oPleConvBias[] = { OPD("x"), WGT("w"), INOUT("conv_state"), OPD("cu"), + OPD_O("resid"), OPD_O("cache_idx"), OPD_O("has_init"), + OPD_O("num_accepted"), WGT("b"), OUT("y") }; static const RadParamSpec pCausalConv[] = { P_INT("M"), P_INT("n"), P_INT("width"), P_STR("dtype") }; static const RadOperandSpec oCausalConv[] = { OPD("x"), WGT("w"), INOUT("conv_state"), OPD("cu"), @@ -146,6 +150,12 @@ static const RadParamSpec pKdaUpdate[] = { P_INT("M"), P_INT("heads"), P_INT("he static const RadOperandSpec oKdaUpdate[] = { OPD("q"), OPD("k"), OPD("v"), OPD("a"), OPD("b"), WGT("A_log"), WGT("dt_bias"), INOUT("state"), OPD("state_idx"), OPD("cu"), OPD_O("num_accepted"), OPD_O("has_init"), OUT("o") }; +/* Mamba-2's selective state update: kda_update's rollback contract with a scalar decay per head. */ +static const RadParamSpec pSsdUpdate[] = { P_INT("M"), P_INT("heads"), P_INT("head_dim"), + P_INT("d_state"), P_INT("groups"), P_STR("mode"), P_STR("dtype"), P_STRO("state_form") }; +static const RadOperandSpec oSsdUpdate[] = { OPD("x"), OPD("B"), OPD("C"), OPD("dt"), + WGT("A_log"), WGT("dt_bias"), WGT("D"), INOUT("state"), OPD("state_idx"), OPD("cu"), + OPD_O("num_accepted"), OPD_O("has_init"), OUT("o") }; /* The MTP head's entry for a wide residual stream. `ngroup` is hc for a grouped norm over the * sub-streams, 1 for a flat one over the whole row (see ref_hc.cpp). */ static const RadParamSpec pMtpEnter[] = { P_INT("M"), P_INT("n"), P_INT("hc"), @@ -162,14 +172,41 @@ static const RadOperandSpec oLayernorm[] = { OPD("x"), WGT("w"), WGT_O("b"), OUT /* A learned position table resampled to each row's grid and added in (a vision tower's). */ static const RadParamSpec pGridEmbed[] = { P_INT("M"), P_INT("n"), P_INT("side"), P_STR("dtype") }; static const RadOperandSpec oGridEmbed[] = { INOUT("x"), WGT("table"), OPD("coord") }; +/* grid_embed_cpe adds the rows a segment carries ahead of its patches (n_prefix, `prefix`). */ +static const RadParamSpec pGridEmbedCpe[] = { P_INT("M"), P_INT("n"), P_INT("side"), P_STR("dtype"), + P_INTO("n_prefix") }; +static const RadOperandSpec oGridEmbedCpe[] = { INOUT("x"), WGT("table"), OPD("coord"), + WGT_O("prefix") }; + +/* LiLiCorr's correlator (ref_lili.cpp). */ +static const RadParamSpec pLiliCand[] = { P_INT("M"), P_INT("k"), P_INT("world"), P_INT("steps"), + P_INT("n"), P_STR("dtype"), P_F64O("eps"), + P_INTO("row_k") }; +static const RadOperandSpec oLiliCand[] = { OPD("stats"), OPD("pas"), WGT("ln_w"), WGT("ln_b"), + WGT("up_w"), WGT("up_b"), WGT("slot"), WGT("rank"), + OUT("cand"), OUT("feat"), OUT("base") }; +static const RadParamSpec pLiliAttn[] = { P_INT("M"), P_INT("steps"), P_INT("k"), P_INT("n_head"), + P_INT("head_dim"), P_STR("dtype"), P_F64O("scale") }; +static const RadOperandSpec oLiliAttn[] = { OPD("qkv"), WGT("rel"), WGT("same"), OUT("out") }; +static const RadParamSpec pLiliFactor[] = { P_INT("M"), P_INT("L"), P_INT("n"), P_STR("dtype") }; +static const RadOperandSpec oLiliFactor[] = { OPD("h"), OPD("a"), OUT("y") }; +static const RadParamSpec pLiliWalk[] = { P_INT("M"), P_INT("steps"), P_INT("k"), P_INT("n"), + P_STR("dtype"), P_F64O("eps"), P_F64O("scale") }; +static const RadOperandSpec oLiliWalk[] = { OPD("edges"), OPD("aout"), OPD("cand"), OUT("tokens"), + OUT_O("scores") }; static const RadParamSpec pSwigluClamped[] = { P_INT("M"), P_INT("n"), P_F64("limit"), P_STR("dtype") }; static const RadParamSpec pDsaPool[] = { P_INT("M"), P_INT("n"), P_INT("ratio"), P_STR("dtype"), P_INTO("block_size") }; +/* `kv_dtype`: the latent cache's dtype when it is not the query's (fp8_e4m3, at descale 1). */ static const RadParamSpec pMlaAttn[] = { P_INT("M"), P_INT("latent_dim"), P_INT("heads"), - P_INT("blocks"), P_INT("block_size"), P_F64("scale"), P_STR("dtype") }; + P_INT("blocks"), P_INT("block_size"), P_F64("scale"), P_STR("dtype"), P_STRO("kv_dtype") }; static const RadParamSpec pMlaProject[] = { P_INT("M"), P_INT("heads"), P_INT("head_dim"), P_INT("latent_dim"), P_STR("mode"), P_STR("dtype") }; static const RadOperandSpec oMlaAttn[] = { OPD("q"), OPD("kv"), OPD("bt"), OPD("length"), OUT("out") }; +static const RadParamSpec pMlaAttnPaged[] = { P_INT("M"), P_INT("heads"), P_INT("latent_dim"), + P_INT("rope_dim"), P_INT("block_size"), P_F64("scale"), P_STR("dtype") }; +static const RadOperandSpec oMlaAttnPaged[] = { OPD("q"), OPD_O("q_rope"), OPD("kv"), + OPD("block_table"), OPD("seqused"), OPD("cu_seqlens"), OPD_O("gate"), OUT("out") }; static const RadParamSpec pDsaScore[] = { P_INT("M"), P_INT("n"), P_INT("heads"), P_INT("blocks"), P_INT("seqs"), P_STR("dtype"), P_INTO("row_part") }; static const RadOperandSpec oDsaScore[] = { OPD("q"), OPD("q_scale"), OPD("gate"), OPD("k"), @@ -179,6 +216,8 @@ static const RadOperandSpec oDsaPool[] = { OPD("kg"), WGT("ape"), OUT("q"), OUT( static const RadParamSpec pRouterSigmoid[] = { P_INT("M"), P_INT("n_expert"), P_INT("top_k"), P_INT("norm"), P_F64("route_scale"), P_STR("dtype") }; static const RadOperandSpec oRouterSigmoid[] = { OPD("logits"), WGT("bias"), OUT("ids"), OUT("weights") }; +static const RadParamSpec pRouterSigmoidGroup[] = { P_INT("M"), P_INT("n_expert"), P_INT("top_k"), + P_INT("n_group"), P_INT("topk_group"), P_INT("norm"), P_F64("route_scale"), P_STR("dtype") }; static const RadParamSpec pMnD[] = { P_INT("M"), P_INT("n"), P_STR("dtype") }; /* `div` divides the rounded sum, rounded again (default 1, the plain sum): a mean of branches * summed pairwise, as a vocoder averages its residual blocks. */ @@ -197,6 +236,9 @@ static const RadParamSpec pSegMean[] = { P_INT("M"), P_INT("n"), P_STR("dtype") static const RadOperandSpec oSegMean[] = { OPD("x"), OPD("cu_seqlens"), OUT("y") }; static const RadParamSpec pSegPool[] = { P_INT("M"), P_INT("n"), P_STR("dtype") }; static const RadOperandSpec oSegPool[] = { OPD("score"), OPD("v"), OPD("cu_seqlens"), OUT("y") }; +/* `n` is the point's values; y has n (2 freqs + 1) columns. */ +static const RadParamSpec pPointFourier[] = { P_INT("M"), P_INT("n"), P_INT("freqs"), P_INTO("pi"), + P_STR("dtype") }; /* `M` is the input row count, a multiple of `k`; y has M / k rows. */ static const RadParamSpec pPoolRows[] = { P_INT("M"), P_INT("n"), P_INT("k"), P_F64O("mult"), P_STR("dtype") }; @@ -289,9 +331,15 @@ static const RadOperandSpec oGemmQGated[] = { OPD("a"), OPD("a_scale"), WGT("b") static const RadParamSpec pDflashSelect[] = { P_INT("M"), P_INT("steps"), P_INT("top_k"), P_INT("rank"), P_INT("n_vocab"), P_INTO("anchor_stride"), P_STR("dtype") }; +static const RadParamSpec pDflashMarkov[] = { P_INT("M"), P_INT("steps"), P_INT("rank"), + P_INT("n_vocab"), P_INTO("anchor_stride"), + P_STR("dtype") }; static const RadOperandSpec oDflashSelect[] = { OPD("cand"), OPD("unary"), OPD_O("hp"), OPD("anchor"), WGT("pred"), WGT("succ"), OUT("tokens") }; +static const RadOperandSpec oDflashMarkov[] = { OPD("logits"), OPD("anchor"), WGT("pred"), + WGT("succ"), OUT("tile_scores"), + OUT("tile_tokens"), OUT("tokens") }; static const RadParamSpec pDflashTree[] = { P_INT("M"), P_INT("steps"), P_INT("top_k"), P_INT("rank"), P_INT("n_vocab"), P_INTO("anchor_stride"), P_INT("nodes"), @@ -384,6 +432,13 @@ static const RadOperandSpec oAttnPagedTree[] = { OPD("q"), OPD("kv_cache"), OPD("block_table"), OPD("seqused"), OPD_O("k_descale"), OPD_O("v_descale"), OPD_O("cu_seqlens"), OUT("out"), OPD("spec_parent") }; + +/* attn_paged with a learned sink logit a query head (gpt-oss, LiLiCorr's drafter). A name of its + * own, so no attn_paged kernel that does not know the operand can be chosen for it. */ +static const RadOperandSpec oAttnPagedSink[] = { + OPD("q"), OPD("kv_cache"), OPD("block_table"), OPD("seqused"), + OPD_O("k_descale"), OPD_O("v_descale"), OPD_O("cu_seqlens"), WGT("sinks"), OUT("out") +}; /* Effective on kv_store, where `block_size` is RAD_REQUIRED: admits every value and refuses only a * query that omits it. On attn_paged the key is RAD_DERIVED and the constraint is skipped * (core/plugin/select.cpp). See the file header for the spec §7.2 consequence. */ @@ -596,7 +651,7 @@ static const RadParamSpec pMoeGemmQ[] = { P_INT("M"), P_INT("N"), P_INT("K"), P_ static const RadOperandSpec oMoeGemmQ[] = { OPD("a"), OPD_O("a_scale"), WTAB("w"), WTAB("w_scale"), OPD("sorted_tok"), OPD("expert_offset"), WTAB("w_odd"), WTAB("w_odd_scale"), OUT("y") }; -/* The same op over four classes by expert number mod 4: `w`/`w_scale` class 0 at [N, K], + /* The same op over four classes by expert number mod 4: `w`/`w_scale` class 0 at [N, K], * `w_q`/`w_q_scale` class q at [N_q, K_q], expert e at entry e / 4 of class e % 4; how four ranks * share the extra block of a five-block expert (as in libr4d's schema). */ static const RadParamSpec pMoeGemmQMod4[] = { P_INT("M"), P_INT("N"), P_INT("K"), P_INT("n_expert"), @@ -627,6 +682,9 @@ static const RadOperandSpec oRowTopk[] = { OPD("x"), OUT("idx"), OUT("val"), OUT static const RadParamSpec pRowTopkMerge[] = { P_INT("M"), P_INT("R"), P_INT("world_size"), P_STR("dtype") }; static const RadOperandSpec oRowTopkMerge[] = { OPD("gathered"), OUT("idx"), OUT("val") }; +static const RadParamSpec pDequantW4[] = { P_INT("N"), P_INT("K"), P_INT("group"), P_STR("dtype"), + P_INT("twos") }; +static const RadOperandSpec oDequantW4[] = { WGT("wq"), WGT("ws"), OUT("y") }; static const RadParamSpec pPairArgmax[] = { P_INT("M"), P_INT("n"), P_STR("dtype") }; static const RadOperandSpec oPairArgmax[] = { OPD("pairs"), OUT("idx"), OUT_O("val") }; @@ -788,7 +846,7 @@ static const RadOperandSpec oArgmax[] = { OPD("logits"), OPD("params"), OUT(" * sample_topk. */ static const RadParamSpec pLogprobs[] = { P_INT("M"), P_INT("n_vocab"), P_INT("k"), P_INTO("vocab_off") }; -static const RadOperandSpec oLogprobs[] = { OPD("logits"), OPD("params"), OUT("stats") }; +static const RadOperandSpec oLogprobs[] = { OPD("logits"), OPD_O("params"), OUT("stats") }; static const RadOperandSpec oNarrow[] = { INOUT("cand_idx"), INOUT("cand_val"), OPD("params") }; static const RadOperandSpec oPick[] = { OPD("cand_idx"), OPD("cand_val"), OPD("params"), OUT("token") }; @@ -1126,6 +1184,15 @@ static const RadOpSchema kSchemas[] = { "verify reads state_idx[seq,num_accepted-1] and writes each candidate state_idx[seq,t]; " "prefill reads/writes column zero, committing only the final state. cu offsets are absolute; " "has_init=0 starts from zero and a negative initial slot emits zero output. No output norm." }, +{ "ssd_update", ARR(pSsdUpdate), ARR(oSsdUpdate), + "Mamba-2 selective state update: dt'=softplus(dt+dt_bias) (identity above 20, no clamp), " + "S*=exp(-exp(A_log)*dt'); S+=dt'*x*B^T; o=S*C+D*x, B and C shared by heads/groups heads. " + "State is f32 [slot,heads,head_dim,d_state]. verify reads state_idx[seq,num_accepted-1] and " + "writes each candidate state_idx[seq,t]; prefill reads/writes column zero, committing only the " + "final state. cu offsets are absolute; has_init=0 starts from zero and a negative initial slot " + "emits zero output. state_form anchor: one committed state (column 0) and a scratch slot " + "(column width/2) of per-token records (decay, dt' x, B) replayed up to num_accepted. No output " + "norm." }, { "hc_read", ARR(pHcRead), ARR(oHcRead), "The read half of a gated residual. N = grouped_rmsnorm(h) -- one rsqrt per `n`-wide stream, " "one gain of hc*n over all of them, `w + wadd`; g = sigmoid(mix_up @ silu(mix_down @ N / hc)); " @@ -1163,6 +1230,32 @@ static const RadOpSchema kSchemas[] = { "antialias=True) resamples it to the row's grid -- SigLIP2's position embedding: per axis a " "triangle filter on half-pixel centres, widened by the scale when shrinking, its in-table taps " "normalised. Separable, f32, rounded once before the add; coordinates clamp into their grid." }, +{ "grid_embed_cpe", ARR(pGridEmbedCpe), ARR(oGridEmbedCpe), + "x += the side x side table resampled as torch's F.interpolate(bilinear, align_corners=False) -- " + "no antialias -- onto a square of side max(grid height, grid width), of which the grid keeps the " + "top-left part: RADIO's cropped position embedding (CPE). Per axis two taps at (i + 0.5) * side / " + "d - 0.5, clamped at 0 and into the table, blended along the row first; f32, rounded once before " + "the add. A row whose coordinate row is negative is the k-th of `n_prefix` learned rows ahead of its segment (RADIO's class and register tokens), k its column: it gets `prefix[k]` instead, rounded the same way." }, +{ "lili_cand", ARR(pLiliCand), ARR(oLiliCand), + "LiLiCorr's candidates. `stats` [M, world * (2 + 2k)] f32 is each rank's sample_logprobs row, " + "row-interleaved; the ranks merge to the log-normaliser and the k largest pairs by value, ties to " + "the lower id. cand [M, k] i32 = those ids. For candidate j, lp_j = logit_j - lse: feat row m*k+j " + "= silu(up_w . layernorm([lp_j, exp lp_j, lp_j - lp_0, j/(k-1), j == 0]; ln_w, ln_b, eps) + " + "up_b); base row m*k+j = pas[m] + slot[m % steps] + rank[j]. f32, rounded once to the outputs." }, +{ "lili_attn", ARR(pLiliAttn), ARR(oLiliAttn), + "Attention over each sequence's lattice of L = steps * k rows (row i at slot i / k): qkv [M, 3 * " + "n_head * head_dim] as q | k | v; score(i, j) = q_i . k_j * scale + rel[h][s_i - s_j + steps] + " + "(s_i == s_j ? same[h] : 0), softmax over the lattice's rows, out [M, n_head * head_dim]. No " + "mask." }, +{ "lili_factor", ARR(pLiliFactor), ARR(oLiliFactor), + "y [M, 3n] = [h_i | a_s | h_i * a_s] with s = i / L: each lattice row beside its sequence's anchor " + "and their product, the factor projection's input." }, +{ "lili_walk", ARR(pLiliWalk), ARR(oLiliWalk), + "LiLiCorr's walk. edges [M * steps * k, 2n] each candidate's outgoing | incoming vector, aout " + "[M, n] the anchor's; each normalised as v / max(|v|, eps). start[j] = scale * aout . in[0][j], " + "pair[s][i][j] = scale * out[s][i] . in[s+1][j]; greedy p_0 = argmax start, p_s = argmax " + "pair[s-1][p_{s-1}], first index on ties; tokens [M, steps] i32 = cand[m * steps + s][p_s]. " + "`scores` [M, steps, k, k], when passed: row 0 start for every i, row s pair[s - 1]." }, { "add", ARR(pAdd), ARR(oBinary), "y = a + b. An operand carrying exactly n elements against a taller output broadcasts along " "rows; nothing else broadcasts. With `div`, y = rd(rd(a + b) / div), rd y's dtype: the last " @@ -1182,9 +1275,10 @@ static const RadOpSchema kSchemas[] = { "y = x * w, `w` a WEIGHT of one element (a scalar for the whole output) or of one row " "(broadcast down the rows): a learned gain on an activation. f32 product, rounded once." }, { "act_mul", ARR(pActMul), ARR(oBinary), - "y = act(a) * b, `act` \"silu\", \"gelu\" (exact erf), \"gelu_tanh\" or \"sigmoid\". The activation is " - "rounded to y's dtype before the product, which is the unfused pair. `a` and `b` may be column " - "slices of one fused row." }, + "y = act(a) * b, `act` \"silu\", \"gelu\" (exact erf), \"gelu_tanh\", \"sigmoid\", \"quick_gelu\" or " + "\"relu\" (relu(x)^2 with one tensor in both operands). The activation is rounded to y's dtype " + "before the product, which is the unfused pair. `a` and `b` may be column slices of one fused " + "row." }, { "seg_mean_bf16_sum", ARR(pSegMean), ARR(oSegMean), "BF16 masked mean: f32 segment sum rounded to BF16 before division, then BF16 output." }, { "seg_mean", ARR(pSegMean), ARR(oSegMean), @@ -1201,6 +1295,10 @@ static const RadOpSchema kSchemas[] = { "Column c of row m of y is the mean of x[m]'s columns [c*k, c*k + k), summed in f32 and rounded " "to y's dtype, then times `mult` (default 1) and rounded again. n, the input width, is a " "multiple of k." }, +{ "point_fourier", ARR(pPointFourier), ARR(oUnary), + "A point's Fourier features: row m of y is [x | sin(x_i f_j) | cos(x_i f_j)] over x's n values, " + "sines then cosines each i-major then j, f_j = 2^j for j < freqs (times pi with `pi` 1); the " + "products f32, the sine and cosine f32 rounded once to y's dtype. y is [M, n (2 freqs + 1)]." }, { "relu", ARR(pMnD), ARR(oUnary), "y = max(x, 0), each operand at its own row pitch." }, { "clamp", ARR(pMnD), ARR(oClamp), "y = min(max(x, lo), hi), `lo` and `hi` WEIGHTS of one element each: a clipped linear's range." }, @@ -1233,6 +1331,10 @@ static const RadOpSchema kSchemas[] = { "rounding." }, { "mla_attn", ARR(pMlaAttn), ARR(oMlaAttn), "Softmax over selected latent vectors used as both key and value; per-query page tables and visible lengths." }, +{ "mla_attn_paged", ARR(pMlaAttnPaged), ARR(oMlaAttnPaged), + "Dense causal latent attention over a paged cache whose token row is the latent then the rotated " + "key part: score = scale * (q . latent + q_rope . rope), value = the latent; sequences as in " + "attn_paged. With `gate`, out = bf16(bf16(out) * bf16(sigmoid(gate[head])))." }, { "mla_project", ARR(pMlaProject), ARR(oGemm), "Per-head query absorption or value expansion through the shared [head,(K|V),latent] BF16 matrix." }, { "dsa_score", ARR(pDsaScore), ARR(oDsaScore), @@ -1241,6 +1343,8 @@ static const RadOpSchema kSchemas[] = { "Normalized Hadamard, BF16 boundary and power-of-two E4M3 quantization per query head." }, { "dsa_pool", ARR(pDsaPool), ARR(oDsaPool), "Channel-wise softmax pooling with learned position bias, BF16, normalized Hadamard, BF16, power-of-two FP8." }, +{ "swiglu_step", ARR(pSwigluClamped), ARR(oGateUp), + "min(silu(gate),limit)*clamp(up,-limit,limit); gate is the first half." }, { "swiglu_clamped", ARR(pSwigluClamped), ARR(oGateUp), "silu(min(gate,limit))*clamp(up,-limit,limit); gate is the first half." }, { "silu_mul", ARR(pMnD), ARR(oGateUp), @@ -1283,6 +1387,10 @@ static const RadOpSchema kSchemas[] = { "(width-1)*dilation - 1 slots plus one a token. Absent, every token commits: the read is at " "offset zero and the last (width-1)*dilation inputs land at offset zero, which is the prefill " "chunk. `resid` absent drops the add and leaves the plain convolution." }, +{ "ple_conv_bias", ARR(pPleConv), ARR(oPleConvBias), + "ple_conv with `b`, a per-channel bias added inside the silu: y[t] = resid[t] + silu(b[c] + " + "sum_j w[c][j] * x[t - (width-1-j)*dilation]). At dilation one with no `resid` it is Mamba-2's " + "conv1d. The window, `has_init`, `cache_idx` and `num_accepted` are ple_conv's." }, { "causal_conv1d", ARR(pCausalConv), ARR(oCausalConv), "y[t] = sum_j w[c][j] * x[t - (width-1-j)], a DEPTHWISE CAUSAL convolution with no activation " "and no residual (LFM2's short convolution, whose gates the caller applies). The state, " @@ -1357,6 +1465,12 @@ static const RadOpSchema kSchemas[] = { "previous pick. `hp` absent is a plane of ones, which drops the form to a plain low-rank " "bigram. Serial in l by construction -- the predecessor is not known until the previous step " "has been decided." }, +{ "dflash_markov_greedy", ARR(pDflashMarkov), ARR(oDflashMarkov), + "The DSpark reference walk: score all vocabulary ids at each position as draft_logit[token] + " + "sum_r pred[previous_token][r] * succ[token][r], select the greatest score (lower id breaks " + "ties), then use that token as the next predecessor." }, +{ "dflash_markov_greedy_f32", ARR(pDflashMarkov), ARR(oDflashMarkov), + "Full-vocabulary greedy Markov walk with F32 base logits and BF16 codebooks." }, { "dflash_tree", ARR(pDflashTree), ARR(oDflashTree), "dflash_select's lattice and edge scores grown best-first into a tree of `nodes` nodes: node 0 " "is the anchor, each selected node's children are the valid candidates at the next position " @@ -1448,11 +1562,20 @@ static const RadOpSchema kSchemas[] = { "one kernel serves decode, speculative verify and prefill. seqused is the TOTAL key count " "including this step's query rows. k_descale / v_descale are optional and apply to an fp8 " "cache. `scale` is not in docs/OPS.md and defaults to 1/sqrt(head_dim)." }, +{ "attn_paged_anchor_window", ARR(pAttnPaged), ARR(oAttnPaged), + "Paged attention with one shared window anchor at the first query position in each sequence. " + "Every row uses anchor - key < window as its lower-bound predicate; causal attention also masks " + "keys after the anchor. This operation has a distinct name because ordinary attn_paged measures " + "visibility from each query row." }, { "attn_paged_tree", ARR(pAttnPaged), ARR(oAttnPagedTree), "attn_paged over a tree verify (rad_drafter_tree): spec_parent[row] is -2 for an ordinary " "causal row, else the row's parent's index within its sequence's rows (-1 for the block's " "first row). Inside the block such a row sees itself and its ancestors only, and its window is " "measured from the block's first position plus its depth." }, +{ "attn_paged_sink", ARR(pAttnPaged), ARR(oAttnPagedSink), + "attn_paged with `sinks` [n_head] f32, one logit a query head in the scaled-score domain: it " + "joins the softmax's maximum and denominator, contributes no value, and so only shrinks the " + "keys' weights (out = sum_j p_j v_j with p_j = exp(s_j) / (sum_k exp(s_k) + exp(sink)))." }, { "attn_dense", ARR(pAttnDense), ARR(oAttnDense), "Dense varlen attention over cu_seqlens segments (rows cu/cu_div). Nothing paged. `window` is " "attn_paged's rule over a segment's positions: causal, i - j < window; non-causal, |i - j| < " @@ -1556,6 +1679,9 @@ static const RadOpSchema kSchemas[] = { "when rows == n. `act` is \"sigmoid\" or \"none\", and it applies to the SCALAR. With `add` " "present the form is y = bf16(x * act(s)) + add -- the product NARROWED before the sum, which " "is what makes the fused form bit-identical to the pair it replaces." }, +{ "router_sigmoid_group_topk", ARR(pRouterSigmoidGroup), ARR(oRouterSigmoid), + "Group-limited sigmoid routing: groups rank by the sum of their two best p + bias, selection " + "runs over the topk_group best groups; correction bias selects, original scores weight." }, { "router_sigmoid_topk", ARR(pRouterSigmoid), ARR(oRouterSigmoid), "Single-group sigmoid routing; correction bias selects experts, original scores weight them." }, { "router_topk", ARR(pRouter), ARR(oRouter), @@ -1611,6 +1737,9 @@ static const RadOpSchema kSchemas[] = { "(idx, val) form the single-rank top-R produces. `gathered` is [M, world_size * R, 2] pairs, " "rank r's at [r*R, (r+1)*R); id -1 is a pad and is dropped. Ties break on the LOWER id, which is " "what makes the merged answer agree with a top-R over the unsharded plane." }, +{ "dequant_w4", ARR(pDequantW4), ARR(oDequantW4), + "Packed int4 weight to row-major bf16. Each 32-bit word holds 8 codes; the scale is " + "f16 in the low 16 bits, the zero point -(1024+zero) as f16 in the high 16 bits." }, { "pair_argmax", ARR(pPairArgmax), ARR(oPairArgmax), "idx[m] = the id of the largest value among pairs[m, 0..n), each pair an int32 id in the first " "f32 slot and its value in the second (row_topk's `pairs`, all-gathered): ties to the lower " @@ -2231,6 +2360,8 @@ SIMPLE("ref_mhc_contract", "mhc_contract", "norm", "mean of manifold residual st ref_mhc_contract), SIMPLE("ref_kda_update", "kda_update", "gdn", "bounded per-channel delta recurrence and candidate rollback", DT_FLOAT, ref_kda_update), +SIMPLE("ref_ssd_update", "ssd_update", "gdn", "Mamba-2 scalar-decay recurrence and candidate rollback", DT_FLOAT, + ref_ssd_update), ROWL("ref_hc_read", "hc_read", "norm", "gated residual read: grouped norm, low-rank gate, stream mix", DT_FLOAT ", or mixing matrices of E4M3 / int8 codes with a scale plane, joined", @@ -2251,6 +2382,17 @@ SIMPLE("ref_grid_embed", "grid_embed", "elem", SIMPLE("ref_grid_embed_aa", "grid_embed_aa", "elem", "antialiased half-pixel bilinear resample of a position grid, added in", DT_FLOAT, ref_grid_embed_aa), +SIMPLE("ref_grid_embed_cpe", "grid_embed_cpe", "elem", + "half-pixel bilinear resample of a position grid onto a square, cropped, added in", DT_FLOAT, + ref_grid_embed_cpe), +SIMPLE("ref_lili_cand", "lili_cand", "draft", "LiLiCorr candidates and their features", + DT_FLOAT, ref_lili_cand), +SIMPLE("ref_lili_attn", "lili_attn", "draft", "LiLiCorr lattice attention with slot biases", + DT_FLOAT, ref_lili_attn), +SIMPLE("ref_lili_factor", "lili_factor", "draft", "LiLiCorr factor input [h | a | h * a]", + DT_FLOAT, ref_lili_factor), +SIMPLE("ref_lili_walk", "lili_walk", "draft", "LiLiCorr edge scores and greedy walk", DT_FLOAT, + ref_lili_walk), SIMPLE("ref_add", "add", "elem", "elementwise sum", DT_FLOAT, ref_add), SIMPLE("ref_mul", "mul", "elem", "elementwise product", DT_FLOAT, ref_mul), SIMPLE("ref_mla_attn", "mla_attn", "attn", "absorbed latent MQA attention", DT_FLOAT, @@ -2263,6 +2405,10 @@ SIMPLE("ref_dsa_query", "dsa_query", "attn", "normalized FP8 index queries", DT_ ref_dsa_query), SIMPLE("ref_gemm_nt_f32", "gemm_nt_f32", "gemm", "F32 routing projection", DT_FLOAT, ref_gemm_nt_f32), +SIMPLE("ref_mla_attn_paged", "mla_attn_paged", "attn", "dense paged latent attention with a rotary part", + DT_FLOAT, ref_mla_attn_paged), +SIMPLE("ref_swiglu_step", "swiglu_step", "elem", "SwiGLU clipped after the SiLU", DT_FLOAT, + ref_swiglu_step), SIMPLE("ref_mla_project", "mla_project", "attn", "absorbed MLA projections", DT_FLOAT, ref_mla_project), SIMPLE("ref_swiglu_clamped", "swiglu_clamped", "elem", "asymmetrically clipped SwiGLU", DT_FLOAT, @@ -2289,6 +2435,8 @@ SIMPLE("ref_pool_rows", "pool_rows", "elem", "mean of every k consecutive rows, DT_FLOAT, ref_pool_rows), SIMPLE("ref_pool_cols", "pool_cols", "elem", "mean of every k consecutive columns, then a " "multiplier", DT_FLOAT, ref_pool_cols), +SIMPLE("ref_point_fourier", "point_fourier", "elem", "a point's sines and cosines at octaves", + DT_FLOAT, ref_point_fourier), SIMPLE("ref_relu", "relu", "elem", "max(x, 0)", DT_FLOAT, ref_relu), SIMPLE("ref_clamp", "clamp", "elem", "x clamped to two weight scalars", DT_FLOAT, ref_clamp), SIMPLE("ref_conv2d", "conv2d", "elem", "segment-wise 2-D convolution, channels innermost", @@ -2323,6 +2471,9 @@ SIMPLE("ref_ple_gate", "ple_gate", "norm", "PLE gate: three grouped norms, a dot DT_FLOAT, ref_ple_gate), SIMPLE("ref_ple_conv", "ple_conv", "norm", "PLE's dilated depthwise conv, silu and residual add", DT_FLOAT, ref_ple_conv), +SIMPLE("ref_ple_conv_bias", "ple_conv_bias", "norm", + "ple_conv with a per-channel bias inside the silu (Mamba-2's conv1d)", DT_FLOAT, + ref_ple_conv_bias), SIMPLE("ref_causal_conv1d", "causal_conv1d", "conv", "depthwise causal conv, no activation", DT_FLOAT, ref_causal_conv1d), SIMPLE("ref_gather_rows", "gather_rows", "elem", "y[i,:] = x[idx[i],:]", DT_ANY, ref_gather_rows), @@ -2353,6 +2504,14 @@ SIMPLE("ref_gemm_nt_q_gated", "gemm_nt_q_gated", "gemm", SIMPLE("ref_dflash_select", "dflash_select", "draft", "DFlash2's greedy walk over the candidate lattice", "i32 candidates, bf16 codebooks, i32 tokens out", ref_dflash_select), +SIMPLE("ref_dflash_markov_greedy", "dflash_markov_greedy", "draft", + "DSpark's full-vocabulary greedy Markov walk", + "bf16 logits and codebooks, f32/i32 tile winners, i32 tokens out", + ref_dflash_markov_greedy), +SIMPLE("ref_dflash_markov_greedy_f32", "dflash_markov_greedy_f32", "draft", + "Full-vocabulary greedy Markov walk with F32 base logits", + "f32 logits, bf16 codebooks, f32/i32 tile winners, i32 tokens out", + ref_dflash_markov_greedy_f32), SIMPLE("ref_dflash_tree", "dflash_tree", "draft", "DFlash2's candidate lattice grown best-first into a tree", "i32 candidates, bf16 codebooks, i32 tokens and parents out", ref_dflash_tree), @@ -2387,6 +2546,7 @@ SIMPLE("ref_gated_had_quant_i8", "gated_had_quant_i8", "quant", "gated product, rotation and int8 in one pass", "float in, i8 out, f32 scale", ref_gated_had_quant_i8), SIMPLE("ref_dequant", "dequant", "quant", "group-scaled dequantisation", DT_ANY, ref_dequant), +SIMPLE("ref_dequant_w4", "dequant_w4", "quant", "packed int4 weight to row-major bf16", DT_ANY, ref_dequant_w4), SIMPLE("ref_gemm_nt", "gemm_nt", "gemm", "C = A B^T, f32 accumulate", DT_FLOAT, ref_gemm_nt), SIMPLE("ref_gemm_nt_bias", "gemm_nt_bias", "gemm", "C = A B^T + bias", DT_FLOAT, @@ -2413,11 +2573,21 @@ ROW("ref_attn_paged", "attn_paged", "attn", "any q and out dtype; bf16 or fp8 kv cache with optional per-(seq,head) descales", cPagedBlock, (int)(sizeof(cPagedBlock) / sizeof(cPagedBlock[0])), nullptr, nullptr, ref_attn_paged, nullptr), +ROW("ref_attn_paged_anchor_window", "attn_paged_anchor_window", "attn", + "paged attention with an exact shared anchor-aligned sliding window", + "any q and out dtype; bf16 or fp8 kv cache with optional per-(seq,head) descales", + cPagedBlock, (int)(sizeof(cPagedBlock) / sizeof(cPagedBlock[0])), + nullptr, nullptr, ref_attn_paged_anchor_window, nullptr), ROW("ref_attn_paged_tree", "attn_paged_tree", "attn", "paged causal / sliding-window attention with a tree verify block (spec_parent)", "any q and out dtype; bf16 or fp8 kv cache with optional per-(seq,head) descales; i32 parents", cPagedBlock, (int)(sizeof(cPagedBlock) / sizeof(cPagedBlock[0])), nullptr, nullptr, ref_attn_paged_tree, nullptr), +ROW("ref_attn_paged_sink", "attn_paged_sink", "attn", + "paged causal / sliding-window attention with a sink logit a head, any query length", + "any q and out dtype; bf16 or fp8 kv cache with optional per-(seq,head) descales; f32 sinks", + cPagedBlock, (int)(sizeof(cPagedBlock) / sizeof(cPagedBlock[0])), + nullptr, nullptr, ref_attn_paged_sink, nullptr), SIMPLE("ref_attn_dense", "attn_dense", "attn", "dense varlen attention over cu_seqlens", DT_FLOAT, ref_attn_dense), SIMPLE("ref_attn_cross", "attn_cross", "attn", @@ -2445,6 +2615,8 @@ SIMPLE("ref_qk_norm_rope", "qk_norm_rope", "attn", "per-head QK norm then rotary SIMPLE("ref_scale_rows", "scale_rows", "elem", "one scalar per row, broadcast across the row", DT_FLOAT, ref_scale_rows), +SIMPLE("ref_router_sigmoid_group_topk", "router_sigmoid_group_topk", "moe", + "group-limited sigmoid correction-bias routing", DT_FLOAT, ref_router_sigmoid_group_topk), SIMPLE("ref_router_sigmoid_topk", "router_sigmoid_topk", "moe", "sigmoid correction-bias routing", DT_FLOAT, ref_router_sigmoid_topk), SIMPLE("ref_router_topk", "router_topk", "moe", "softmax then exact top-k routing", DT_FLOAT, diff --git a/libref/ref_sample.cpp b/libref/ref_sample.cpp index 697e4573..8d0c43ba 100644 --- a/libref/ref_sample.cpp +++ b/libref/ref_sample.cpp @@ -674,9 +674,9 @@ int ref_sample_argmax(const RadArgs* a, RadStream) { * floats (exact below 2^24). Read before any sampling stage, as OpenAI's and llama-server's * logprobs report. Rows without the flag are not written. Under a split vocabulary ids are global * (+ `vocab_off`) and the host merges ranks; an unfilled slot is id -1, logit -infinity. The sum is - * in double. */ + * in double. Without `params` every row is written (a drafter's candidate logprobs). */ int ref_sample_logprobs(const RadArgs* a, RadStream) { - if (!have(a, 3)) return RAD_E_INVAL; + if (a->n_t < 3 || !a->t[0].data || !a->t[2].data) return RAD_E_INVAL; const RadTensor *lg = &a->t[0], *pr = &a->t[1], *st = &a->t[2]; const int64_t n_vocab = p_int(a, "n_vocab", lg->rank >= 2 ? lg->shape[lg->rank - 1] : 0); const int64_t k = p_int(a, "k", 0); @@ -686,11 +686,11 @@ int ref_sample_logprobs(const RadArgs* a, RadStream) { const int64_t w = 2 + 2 * k; if (M <= 0 || numel(st) < M * w) return RAD_E_SHAPE; Rows R; - RAD_REF_TRY(param_rows(pr, M, &R)); + if (pr->data) RAD_REF_TRY(param_rows(pr, M, &R)); REF_PAR_FOR(M * n_vocab * (k + 2)) for (int64_t m = 0; m < M; ++m) { - if (!(R.p[m].flags & RAD_SP_LOGPROBS)) continue; + if (pr->data && !(R.p[m].flags & RAD_SP_LOGPROBS)) continue; const int64_t lb = rowoff(lg, m, n_vocab), ls = laststride(lg); const int64_t sb = rowoff(st, m, w), ss = laststride(st); float mx = -INFINITY; diff --git a/libref/ref_shapes.cpp b/libref/ref_shapes.cpp index 1fd0903f..3a40e974 100644 --- a/libref/ref_shapes.cpp +++ b/libref/ref_shapes.cpp @@ -358,6 +358,27 @@ int ref_kda_update_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* ou return o.finish("kda_update", operand, out); } +int ref_ssd_update_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { + const char* form = gs(p, n_p, "state_form"); + if (form && !std::strcmp(form, "anchor")) return RAD_E_UNSUPPORTED; + const uint32_t D = act_dt(p, n_p); + const int64_t M = gi(p, n_p, "M", 0), H = gi(p, n_p, "heads", 0); + const int64_t P = gi(p, n_p, "head_dim", 0), N = gi(p, n_p, "d_state", 0); + const int64_t G = gi(p, n_p, "groups", 0); + if (M < 1 || H < 1 || P < 1 || N < 1 || G < 1 || H % G) return RAD_E_UNSUPPORTED; + const char* mode = gs(p, n_p, "mode"); + const int64_t history = mode && !std::strcmp(mode, "verify") ? M : 1; + Opd o; + o.t(D, {M, H, P}); o.t(D, {M, G, N}); o.t(D, {M, G, N}); o.t(D, {M, H}); + o.t((uint32_t)RAD_F32, {H}); o.t((uint32_t)RAD_F32, {H}); o.t((uint32_t)RAD_F32, {H}); + o.t((uint32_t)RAD_F32, {history + 1, H, P, N}); + o.t_idx({1, history}, history + 1, -1, (uint32_t)RAD_OPD_F_IDX_UNIQUE); + o.t_idx({2}, M, -1, (uint32_t)RAD_OPD_F_IDX_CU); + o.t_idx({1}, 0, 1, 0); o.t_idx({1}, 0, 1, 0); + o.t(D, {M, H, P}); + return o.finish("ssd_update", operand, out); +} + int ref_mhc_pre_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { const uint32_t D = act_dt(p, n_p); const int64_t M = gi(p, n_p, "M", 0), n = gi(p, n_p, "n", 0), hc = gi(p, n_p, "hc", 0); @@ -488,6 +509,64 @@ int ref_grid_embed_aa_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* return o.finish("grid_embed_aa", operand, out); } +/* grid_embed's operands plus the prefix rows; coordinates drawn over the table's side. */ +int ref_grid_embed_cpe_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { + const uint32_t D = act_dt(p, n_p); + const int64_t M = gi(p, n_p, "M", 0), n = gi(p, n_p, "n", 0), side = gi(p, n_p, "side", 0); + const int64_t npre = gi(p, n_p, "n_prefix", 0); + if (M <= 0 || n <= 0 || side <= 0) return RAD_E_UNSUPPORTED; + Opd o; + o.t(D, { M, n }); /* x, INOUT */ + o.t(D, { side * side, n }); /* table */ + o.t_idx({ 4, M }, side, -1, 0); + o.t(D, { npre > 0 ? npre : 1, n }); /* prefix */ + return o.finish("grid_embed_cpe", operand, out); +} + +/* LiLiCorr's ops. lili_cand declines: its stats rows (sample_logprobs' sorted pairs and positive + * sums) are no draw; avx_check_hand.cpp builds them. The others draw freely. */ +int ref_lili_cand_shape(const RadParam*, int, int, RadOpdDesc*) { return RAD_E_UNSUPPORTED; } + +int ref_lili_attn_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { + const uint32_t D = act_dt(p, n_p); + const int64_t M = gi(p, n_p, "M", 0), S = gi(p, n_p, "steps", 0), k = gi(p, n_p, "k", 0); + const int64_t nh = gi(p, n_p, "n_head", 0), hd = gi(p, n_p, "head_dim", 0); + if (M <= 0 || S <= 0 || k <= 0 || nh <= 0 || hd <= 0) return RAD_E_UNSUPPORTED; + const int64_t rows = (M + S * k - 1) / (S * k) * (S * k); /* whole lattices */ + Opd o; + o.t(D, { rows, 3 * nh * hd }); /* qkv */ + o.t((uint32_t)RAD_F32, { nh, 2 * S + 1 }); /* rel */ + o.t((uint32_t)RAD_F32, { nh }); /* same */ + o.t(D, { rows, nh * hd }); /* out */ + return o.finish("lili_attn", operand, out); +} + +int ref_lili_factor_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { + const uint32_t D = act_dt(p, n_p); + const int64_t M = gi(p, n_p, "M", 0), L = gi(p, n_p, "L", 0), n = gi(p, n_p, "n", 0); + if (M <= 0 || L <= 0 || n <= 0) return RAD_E_UNSUPPORTED; + const int64_t rows = (M + L - 1) / L * L; + Opd o; + o.t(D, { rows, n }); /* h */ + o.t(D, { rows / L, n }); /* a */ + o.t(D, { rows, 3 * n }); /* y */ + return o.finish("lili_factor", operand, out); +} + +int ref_lili_walk_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { + const uint32_t D = act_dt(p, n_p); + const int64_t M = gi(p, n_p, "M", 0), S = gi(p, n_p, "steps", 0), k = gi(p, n_p, "k", 0); + const int64_t n = gi(p, n_p, "n", 0); + if (M <= 0 || S <= 0 || k <= 0 || n <= 0) return RAD_E_UNSUPPORTED; + Opd o; + o.t(D, { M * S * k, 2 * n }); /* edges */ + o.t(D, { M, n }); /* aout */ + o.t_idx({ M * S, k }, 1000, -1, 0); /* cand: ids, copied */ + o.t((uint32_t)RAD_I32, { M, S }); /* tokens */ + o.t((uint32_t)RAD_F32, { M, S, k, k }); /* scores */ + return o.finish("lili_walk", operand, out); +} + int ref_layernorm_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { const uint32_t D = act_dt(p, n_p); const int64_t M = gi(p, n_p, "M", 0), n = gi(p, n_p, "n", 0); @@ -634,6 +713,16 @@ int ref_pool_cols_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out return o.finish("pool_cols", operand, out); } +int ref_point_fourier_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { + const uint32_t D = act_dt(p, n_p); + const int64_t M = gi(p, n_p, "M", 0), n = gi(p, n_p, "n", 0), F = gi(p, n_p, "freqs", 0); + if (M <= 0 || n <= 0 || F <= 0 || F > 30) return RAD_E_UNSUPPORTED; + Opd o; + o.t(RAD_F32, { M, n }); /* x */ + o.t(D, { M, n * (2 * F + 1) }); /* y */ + return o.finish("point_fourier", operand, out); +} + int ref_relu_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { const uint32_t D = act_dt(p, n_p); const int64_t M = gi(p, n_p, "M", 0), n = gi(p, n_p, "n", 0); @@ -763,6 +852,24 @@ int ref_router_sigmoid_topk_shape(const RadParam* p, int n_p, int operand, RadOp o.t(D, { M, k }); return o.finish("router_sigmoid_topk", operand, out); } +int ref_swiglu_step_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { + return ref_silu_mul_shape(p, n_p, operand, out); +} +int ref_router_sigmoid_group_topk_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { + const int64_t M = gi(p, n_p, "M", 0), ne = gi(p, n_p, "n_expert", 0), + k = gi(p, n_p, "top_k", 0), ng = gi(p, n_p, "n_group", 0), + kg = gi(p, n_p, "topk_group", 0); + if (M < 1 || ne < 1 || ne > 512 || k < 1 || ng < 1 || ne % ng || ne / ng < 2 || kg < 1 || + kg > ng || k > kg * (ne / ng)) + return RAD_E_UNSUPPORTED; + const uint32_t D = act_dt(p, n_p); + Opd o; + o.t(D, { M, ne }); + o.t(RAD_F32, { ne }); + o.t_idx({ M, k }, ne, -1, 0); + o.t(D, { M, k }); + return o.finish("router_sigmoid_group_topk", operand, out); +} int ref_mla_project_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { const int64_t M = gi(p, n_p, "M", 0), h = gi(p, n_p, "heads", 0), d = gi(p, n_p, "head_dim", 0), l = gi(p, n_p, "latent_dim", 0); @@ -822,14 +929,39 @@ int ref_mla_attn_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) pages = std::max((int64_t)2, B * M); if (M < 1 || D < 1 || D > 2048 || H < 1 || B < 1 || bs < 1) return RAD_E_UNSUPPORTED; const uint32_t dtype = act_dt(p, n_p); + /* The cache is the query's dtype unless `kv_dtype` names another (fp8_e4m3). */ + const char* kvs = gs(p, n_p, "kv_dtype"); + const uint32_t kv = kvs && dt_parse(kvs) != (uint32_t)RAD_DT_INVALID ? dt_parse(kvs) : dtype; Opd o; o.t(dtype, { M, H, D }); - o.t(dtype, { pages, 1, bs, D }); + o.t(kv, { pages, 1, bs, D }); o.t_idx({ M, B }, pages, -1, 0); o.t_idx({ M }, 0, B * bs, 0); o.t(dtype, { M, H, D }); return o.finish("mla_attn", operand, out); } +/* One sequence whose context is its query (a prefill chunk), as attn_paged describes itself; a + * harness passes `ctx` for a deeper history. */ +int ref_mla_attn_paged_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { + const int64_t M = gi(p, n_p, "M", 0), L = gi(p, n_p, "latent_dim", 0), + R = gi(p, n_p, "rope_dim", 0), H = gi(p, n_p, "heads", 0), + bs = gi(p, n_p, "block_size", 0); + if (M < 1 || L < 1 || L > 2048 || R < 1 || H < 1 || bs < 1) return RAD_E_UNSUPPORTED; + int64_t ctx = gi(p, n_p, "ctx", 0); + if (ctx < M) ctx = M; + const int64_t blocks = (ctx + bs - 1) / bs; + const uint32_t dtype = act_dt(p, n_p); + Opd o; + o.t(dtype, { M, H, L }); /* q */ + o.t(dtype, { M, H, R }); /* q_rope */ + o.t(dtype, { blocks, 1, bs, L + R }); /* kv */ + o.t_idx({ 1, blocks }, blocks, -1, 0); /* block_table */ + o.t_idx({ 1 }, 0, ctx, 0); /* seqused */ + o.t_idx({ 2 }, M, -1, (uint32_t)RAD_OPD_F_IDX_CU); /* cu_seqlens: [0, M], one sequence */ + o.skip(); /* gate */ + o.t(dtype, { M, H, L }); /* out */ + return o.finish("mla_attn_paged", operand, out); +} int ref_silu_mul_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { const uint32_t D = act_dt(p, n_p); const int64_t M = gi(p, n_p, "M", 0), n = gi(p, n_p, "n", 0); @@ -961,6 +1093,27 @@ int ref_ple_conv_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) return o.finish("ple_conv", operand, out); } +/* ple_conv's description with `b` before `y`. */ +int ref_ple_conv_bias_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { + const uint32_t D = act_dt(p, n_p); + const int64_t M = gi(p, n_p, "M", 0), n = gi(p, n_p, "n", 0); + const int64_t wid = gi(p, n_p, "width", 0), dil = gi(p, n_p, "dilation", 1); + if (M <= 0 || n <= 0 || wid <= 0 || dil <= 0) return RAD_E_UNSUPPORTED; + const int64_t S = 1, hist = (wid - 1) * dil, depth = hist - 1 + M; + Opd o; + o.t(D, { M, n }); /* x */ + o.t(D, { n, wid }); /* w */ + o.t(D, { S, n, depth }); /* conv_state, INOUT */ + o.t_idx({ S + 1 }, 0, -1, (uint32_t)RAD_OPD_F_IDX_CU); /* cu */ + o.t(D, { M, n }); /* resid */ + o.t_idx({ S }, S, -1, (uint32_t)RAD_OPD_F_IDX_UNIQUE); /* cache_idx */ + o.t_idx({ S }, 0, 1, 0); /* has_init: warm */ + o.t_idx({ S }, 0, M, 0); /* num_accepted: read at M - 1 */ + o.t(D, { n }); /* b */ + o.t(D, { M, n }); /* y */ + return o.finish("ple_conv_bias", operand, out); +} + /* ple_conv's description without `resid` and at dilation one. */ int ref_causal_conv1d_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { const uint32_t D = act_dt(p, n_p); @@ -1186,6 +1339,17 @@ int ref_dequant_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) return o.finish("dequant", operand, out); } +int ref_dequant_w4_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { + const int64_t N = gi(p, n_p, "N", 0), K = gi(p, n_p, "K", 0); + const int64_t group = gi(p, n_p, "group", 128); + if (N < 1 || K < 1 || N % 16 || K % 64 || group < 1 || K % group) return RAD_E_UNSUPPORTED; + Opd o; + o.t(RAD_I4, { N * K }); /* wq -- packed int4: N*K nibbles = N*K/2 bytes = N*K/8 dwords */ + o.t(RAD_F32, { N * K / group }); /* ws -- scale (f16 in a dword, but declared f32) */ + o.t(RAD_BF16, { N, K }); /* y */ + return o.finish("dequant_w4", operand, out); +} + /* ================================================================== gemm */ int ref_gemm_nt_f32_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { @@ -1369,7 +1533,8 @@ int ref_lora_expand_mm_shape(const RadParam* p, int n_p, int operand, RadOpdDesc * The block count and context length are this description's choice; any cache large enough for * the indices will do. */ -int ref_attn_paged_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { +static int ref_attn_paged_shape_impl(const RadParam* p, int n_p, int operand, RadOpdDesc* out, + const char* op_name) { /* `q_len` is the ranged parameter, a query length (one row at decode, thousands in a prefill * chunk; different kernels, docs/OPS.md). */ const int64_t M = gi(p, n_p, "q_len", 0); @@ -1408,7 +1573,15 @@ int ref_attn_paged_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* ou * would have to agree with a tool's `M` rather than this description's. */ o.skip(); /* cu_seqlens */ o.t(Q, { S * M, nh, hd }); /* out */ - return o.finish("attn_paged", operand, out); + return o.finish(op_name, operand, out); +} + +int ref_attn_paged_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { + return ref_attn_paged_shape_impl(p, n_p, operand, out, "attn_paged"); +} + +int ref_attn_paged_anchor_window_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { + return ref_attn_paged_shape_impl(p, n_p, operand, out, "attn_paged_anchor_window"); } /* attn_paged's operands and its tree's parents, each row an ordinary causal one (-2): a drawn @@ -1423,6 +1596,24 @@ int ref_attn_paged_tree_shape(const RadParam* p, int n_p, int operand, RadOpdDes return o.finish("attn_paged_tree", operand, out); } +/* attn_paged's operands with the sinks before `out`: a learned logit a query head. */ +int ref_attn_paged_sink_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { + const int nbase = 8; + if (operand < 7) return ref_attn_paged_shape(p, n_p, operand, out); + if (operand == 8) return ref_attn_paged_shape(p, n_p, nbase - 1, out); + if (operand != 7 || !out) return RAD_E_SHAPE; + const int64_t gqa = gi(p, n_p, "gqa", 1); + const int64_t nh = gi(p, n_p, "n_head", gqa); + if (nh <= 0) return RAD_E_UNSUPPORTED; + std::memset(out, 0, sizeof *out); + out->fill = (uint32_t)RAD_FILL_NORMAL; + out->idx_const = -1; + out->dtype = (uint32_t)RAD_F32; + out->rank = 1; + out->shape[0] = nh; + return RAD_OK; +} + int ref_attn_dense_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { const int64_t M = gi(p, n_p, "M", 0); const int64_t hd = gi(p, n_p, "head_dim", 0); @@ -1953,6 +2144,10 @@ static MoeScaleGrid moe_scale_grid(const RadParam* p, int n_p, int64_t g) { * `w` is described stacked [ne, N, K], since a fixture cannot hold a pointer table; expert_entry() * reads both forms. */ int ref_moe_gemm_q_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { + if (const char* dk = gs(p, n_p, "dtype")) { + if (!std::strcmp(dk, "w4a8")) return ref_moe_gemm_w4a8_shape(p, n_p, operand, out); + if (!std::strcmp(dk, "w4a4")) return ref_moe_gemm_w4a4_shape(p, n_p, operand, out); + } const int64_t M = gi(p, n_p, "M", 0); const int64_t N0 = gi(p, n_p, "N", 0), K0 = gi(p, n_p, "K", 0); const int64_t N1 = gi(p, n_p, "N_odd", N0), K1 = gi(p, n_p, "K_odd", K0); @@ -2033,6 +2228,61 @@ int ref_moe_gemm_q_mod4_shape(const RadParam* p, int n_p, int operand, RadOpdDes return o.finish("moe_gemm_q_mod4", operand, out); } +/* The grouped int4 GEMM: an int8 activation with an f32 scale per (row, 128 of K), two's- + * complement int4 experts (nibbles, -8..7) with an f32 scale per (row, 128 of K); one weight + * table, token-order a only. */ +int ref_moe_gemm_w4a8_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { + const int64_t M = gi(p, n_p, "M", 0); + const int64_t N0 = gi(p, n_p, "N", 0), K0 = gi(p, n_p, "K", 0); + const int64_t N1 = gi(p, n_p, "N_odd", N0), K1 = gi(p, n_p, "K_odd", K0); + const int64_t ne = gi(p, n_p, "n_expert", 0); + const int64_t k = gi(p, n_p, "top_k", 0); + if (M <= 0 || N0 <= 0 || K0 <= 0 || N1 <= 0 || K1 <= 0 || K0 % 128 || K1 % 128 || + ne <= 0 || k <= 0) + return RAD_E_UNSUPPORTED; + const int64_t N = N0 > N1 ? N0 : N1, K = K0 > K1 ? K0 : K1; + const int64_t ne0 = (ne + 1) / 2, ne1 = ne / 2; + const int64_t AR = sorted_a_order(p, n_p) ? M * k : M; + Opd o; + o.t((uint32_t)RAD_I8, { AR, K }); /* a -- int8 (the E4M3 arm is 8-bit too) */ + o.t((uint32_t)RAD_F32, { AR, K / 128 }); /* a_scale */ + o.t((uint32_t)RAD_I4, { ne0, N0, K0 }); /* w -- even experts, nibbles */ + o.t((uint32_t)RAD_BF16, { ne0, N0, K0 / 128 }); /* w_scale */ + o.t_idx({ M * k }, M * k, -1, (uint32_t)RAD_OPD_F_IDX_UNIQUE); /* sorted_tok */ + o.t_idx({ ne + 1 }, M * k + 1, -1, (uint32_t)RAD_OPD_F_IDX_PREFIX); /* expert_offset */ + o.t((uint32_t)RAD_I4, { ne1, N1, K1 }); /* w_odd -- odd experts */ + o.t((uint32_t)RAD_BF16, { ne1, N1, K1 / 128 }); /* w_odd_scale */ + o.t((uint32_t)RAD_BF16, { M * k, N }); /* y -- in sorted order */ + return o.finish("moe_gemm_q", operand, out); +} + +/* The same over a two's-complement int4 activation (two nibbles per byte): the w4a8 grid with an + * I4 a, so the activation row is K/2 bytes. */ +int ref_moe_gemm_w4a4_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { + const int64_t M = gi(p, n_p, "M", 0); + const int64_t N0 = gi(p, n_p, "N", 0), K0 = gi(p, n_p, "K", 0); + const int64_t N1 = gi(p, n_p, "N_odd", N0), K1 = gi(p, n_p, "K_odd", K0); + const int64_t ne = gi(p, n_p, "n_expert", 0); + const int64_t k = gi(p, n_p, "top_k", 0); + if (M <= 0 || N0 <= 0 || K0 <= 0 || N1 <= 0 || K1 <= 0 || K0 % 128 || K1 % 128 || + ne <= 0 || k <= 0) + return RAD_E_UNSUPPORTED; + const int64_t N = N0 > N1 ? N0 : N1, K = K0 > K1 ? K0 : K1; + const int64_t ne0 = (ne + 1) / 2, ne1 = ne / 2; + const int64_t AR = sorted_a_order(p, n_p) ? M * k : M; + Opd o; + o.t((uint32_t)RAD_I4, { AR, K }); /* a -- int4, two nibbles per byte */ + o.t((uint32_t)RAD_F32, { AR, K / 128 }); /* a_scale */ + o.t((uint32_t)RAD_I4, { ne0, N0, K0 }); /* w -- even experts, nibbles */ + o.t((uint32_t)RAD_BF16, { ne0, N0, K0 / 128 }); /* w_scale */ + o.t_idx({ M * k }, M * k, -1, (uint32_t)RAD_OPD_F_IDX_UNIQUE); /* sorted_tok */ + o.t_idx({ ne + 1 }, M * k + 1, -1, (uint32_t)RAD_OPD_F_IDX_PREFIX); /* expert_offset */ + o.t((uint32_t)RAD_I4, { ne1, N1, K1 }); /* w_odd -- odd experts */ + o.t((uint32_t)RAD_BF16, { ne1, N1, K1 / 128 }); /* w_odd_scale */ + o.t((uint32_t)RAD_BF16, { M * k, N }); /* y -- in sorted order */ + return o.finish("moe_gemm_q", operand, out); +} + int ref_moe_gather_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { const int64_t M = gi(p, n_p, "M", 0), n = gi(p, n_p, "n", 0); const int64_t k = gi(p, n_p, "top_k", 0); @@ -2195,6 +2445,36 @@ int ref_dflash_select_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* return o.finish("dflash_select", operand, out); } +/* The full-vocabulary DSpark Markov walk. Its tile planes hold one exact local max per 64 ids. */ +static int ref_markov_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out, + uint32_t logits_dtype, const char* op) { + const int64_t M = gi(p, n_p, "M", 0); + const int64_t steps = gi(p, n_p, "steps", 0); + const int64_t R = gi(p, n_p, "rank", 0); + const int64_t nv = gi(p, n_p, "n_vocab", 0); + const int64_t astr = gi(p, n_p, "anchor_stride", 1); + if (M <= 0 || steps <= 0 || R <= 0 || nv <= 0 || astr <= 0) + return RAD_E_UNSUPPORTED; + const int64_t rows = M * steps; + const int64_t tiles = (nv + 63) / 64; + Opd o; + o.t(logits_dtype, { rows, nv }); /* logits */ + o.t_idx_dt((uint32_t)RAD_I32, { M * astr }, nv, -1, 0); /* anchor */ + o.t((uint32_t)RAD_BF16, { nv, R }); /* pred */ + o.t((uint32_t)RAD_BF16, { nv, R }); /* succ */ + o.t((uint32_t)RAD_F32, { M, tiles }); /* tile_scores */ + o.t_idx_dt((uint32_t)RAD_I32, { M, tiles }, nv, -1, 0); /* tile_tokens */ + o.t_idx_dt((uint32_t)RAD_I32, { M, steps }, nv, -1, 0); /* tokens */ + return o.finish(op, operand, out); +} + +int ref_dflash_markov_greedy_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { + return ref_markov_shape(p, n_p, operand, out, RAD_BF16, "dflash_markov_greedy"); +} +int ref_dflash_markov_greedy_f32_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { + return ref_markov_shape(p, n_p, operand, out, RAD_F32, "dflash_markov_greedy_f32"); +} + /* dflash_select's operands, then `nodes` tokens and parents a sequence. */ int ref_dflash_tree_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) { const int64_t M = gi(p, n_p, "M", 0); diff --git a/libref/ref_ssd.cpp b/libref/ref_ssd.cpp new file mode 100644 index 00000000..ce446fca --- /dev/null +++ b/libref/ref_ssd.cpp @@ -0,0 +1,233 @@ +/* ref_ssd.cpp -- the Mamba-2 selective state update (SSD), token by token. + * + * ============================== The algorithm ============================== + * + * Per token, per head h of `heads`, with the state S shaped [head_dim, d_state] and g = h / (heads / + * groups) the head's B/C group: + * + * dt' = softplus(dt[h] + dt_bias[h]) A = -exp(A_log[h]) + * S *= e^{dt' A} + * S += dt' . x[h] B[g]^T o[h] = S C[g] + D[h] . x[h] + * + * A Mamba-2 head is a gated delta net head without the delta: one scalar decay per head and token, + * no beta, no l2 norm on B or C, and the skip term D. The gdn ops cannot run it (their rank-1 update + * subtracts S k and their keys are normalised), so it is an op of its own. + * + * dt is not clamped. The checkpoint's `time_step_limit` is (0, inf), which is what mamba_ssm's + * kernels and vLLM pass; transformers' CPU fallback clamps dt at `time_step_min` and is not what + * the model was trained or is served with. softplus keeps torch's and mamba_ssm's threshold: above + * 20 it is the identity. + * + * The output excludes the model's gated norm. + * + * ============================== The layouts ============================== + * + * x, o [T, heads, head_dim] or [T, heads*head_dim] + * B, C [T, groups, d_state] or [T, groups*d_state] + * dt [T, heads] A_log, dt_bias, D [heads], f32 + * state [n_slots, heads, head_dim, d_state], f32 state_idx [N, W] cu [N+1] + * + * The rollback contract is kda_update's, in both forms. `per_candidate`: `mode=verify` reads column + * `num_accepted - 1` of the sequence's `state_idx` row and writes the state after token t of the + * window to column t; `mode=prefill` reads column zero and writes only the final state there. + * `has_init` 0 starts from zero, a negative read slot gives zero output and a negative write slot + * is skipped. + * + * `anchor`: column zero is the committed state and column `width/2` a scratch slot of the same + * shape. Per head the scratch holds a replay count and then one record per window token: the + * decay e^{dt' A}, u = dt' x (head_dim) and B (d_state), 1 + head_dim + d_state floats, as many as + * the [head_dim, d_state] block holds, at most 32 (a 64 x 128 head holds 42). `mode=verify` first + * replays the previous window's accepted prefix (`num_accepted` records, at most the stored count) + * onto the committed state, publishes it, then runs the window from it writing each token's record + * and the window length as the new count. The rank-1 update is replayed with the same arithmetic, + * so the committed state is the per-candidate form's bit for bit. `mode=prefill` commits its final + * state and sets the count to zero; a zeroed scratch replays nothing. + */ +#include "ref_common.h" +#include "ref_ops.h" + +#include +#include +#include + +using namespace ref; + +namespace { + +/* Rows of `width` columns per (token, head), whether the tensor is 3-D or flattened to 2-D. */ +bool headed(const RadTensor& t, int64_t tokens, int64_t heads, int64_t width) { + return t.data && t.shape[0] == tokens && + ((t.rank == 3 && t.shape[1] == heads && t.shape[2] == width) || + (t.rank == 2 && t.shape[1] == heads * width)); +} +int64_t off(const RadTensor& t, int64_t token, int64_t head, int64_t d, int64_t width) { + return token * t.stride[0] + head * (t.rank == 3 ? t.stride[1] : width * t.stride[1]) + + d * laststride(&t); +} +float softplus(float v) { return v > 20.0f ? v : std::log1p(std::exp(v)); } + +/* The anchor scratch's records: per window token 1 + head_dim + d_state floats behind the count. */ +int64_t anchor_tokens(int64_t P, int64_t Nst) { + const int64_t fit = (P * Nst - 1) / (1 + P + Nst); + return fit < 32 ? fit : 32; +} + +} // namespace + +int ref_ssd_update(const RadArgs* a, RadStream) { + if (!a || a->n_t < 13) return RAD_E_INVAL; + for (int i = 0; i < 10; ++i) + if (!rad_arg_in(a, i)) return RAD_E_INVAL; + if (!rad_arg_in(a, 12)) return RAD_E_INVAL; + const int64_t H = p_int(a, "heads", 0), P = p_int(a, "head_dim", 0); + const int64_t Nst = p_int(a, "d_state", 0), G = p_int(a, "groups", 0); + const char* mode = p_str(a, "mode", ""); + const bool verify = !std::strcmp(mode, "verify"); + if (!verify && std::strcmp(mode, "prefill")) return RAD_E_INVAL; + const char* form = p_str(a, "state_form", "per_candidate"); + const bool anchor = !std::strcmp(form, "anchor"); + if (!anchor && std::strcmp(form, "per_candidate")) return RAD_E_INVAL; + if (H <= 0 || P <= 0 || Nst <= 0 || G <= 0 || H % G) return RAD_E_SHAPE; + const int64_t rec = 1 + P + Nst, deepest = anchor_tokens(P, Nst); + if (anchor && deepest < 1) return RAD_E_SHAPE; + const auto &x = a->t[0], &B = a->t[1], &C = a->t[2], &dt = a->t[3]; + const auto &alog = a->t[4], &dtb = a->t[5], &dskip = a->t[6], &state = a->t[7]; + const auto &idx = a->t[8], &cu = a->t[9]; + const RadTensor *accepted = rad_arg_in(a, 10), *init = rad_arg_in(a, 11); + const auto& out = a->t[12]; + if (x.rank < 2 || cu.rank != 1 || cu.dtype != RAD_I32 || cu.shape[0] < 2) return RAD_E_SHAPE; + const int64_t T = x.shape[0], N = cu.shape[0] - 1; + if (T < 1) return RAD_E_SHAPE; + if (!headed(x, T, H, P) || !headed(B, T, G, Nst) || !headed(C, T, G, Nst) || + !headed(dt, T, H, 1) || !headed(out, T, H, P) || numel(&alog) != H || numel(&dtb) != H || + numel(&dskip) != H || state.rank != 4 || state.dtype != RAD_F32 || state.shape[1] != H || + state.shape[2] != P || state.shape[3] != Nst || idx.dtype != RAD_I32 || idx.rank != 2 || + idx.shape[0] < N || idx.shape[1] < 1 || + (accepted && (accepted->dtype != RAD_I32 || numel(accepted) < N)) || + (init && (init->dtype != RAD_I32 || numel(init) < N))) + return RAD_E_SHAPE; + const int64_t width = idx.shape[1], slots = state.shape[0]; + /* Every address is checked before any state is written, so a malformed batch cannot leave a + * partly committed prefix behind an error. */ + for (int64_t seq = 0; seq < N; ++seq) { + const int64_t begin = ld_int(cu.dtype, cu.data, seq * cu.stride[0]); + const int64_t end = ld_int(cu.dtype, cu.data, (seq + 1) * cu.stride[0]); + const int64_t na = + accepted ? ld_int(accepted->dtype, accepted->data, offlin(accepted, seq)) : 1; + const int64_t most = anchor ? deepest : width; + if (begin < 0 || end < begin || end > T || na < 1 || na > most || + (verify && end - begin > most) || (anchor && width < 2)) + return RAD_E_SHAPE; + for (int64_t j = 0; j < width; ++j) + if (ld_int(idx.dtype, idx.data, seq * idx.stride[0] + j * idx.stride[1]) >= slots) + return RAD_E_SHAPE; + if (anchor) { + const int64_t read = ld_int(idx.dtype, idx.data, seq * idx.stride[0]); + const int64_t scratch = + ld_int(idx.dtype, idx.data, seq * idx.stride[0] + (width / 2) * idx.stride[1]); + if (read >= 0 && (scratch < 0 || scratch == read)) return RAD_E_SHAPE; + if (verify && read >= 0 && + (!init || ld_int(init->dtype, init->data, offlin(init, seq)))) + for (int64_t h = 0; h < H; ++h) { + const float count = + ldt(&state, scratch * state.stride[0] + h * state.stride[1]); + if (!std::isfinite(count) || count < 0 || count > (float)deepest || + count != std::floor(count) || (count > 0 && na > count)) + return RAD_E_SHAPE; + } + } + } + const int64_t per_group = H / G; +#pragma omp parallel for schedule(static) + for (int64_t sh = 0; sh < N * H; ++sh) { + const int64_t seq = sh / H, head = sh % H, grp = head / per_group; + const int64_t begin = ld_int(cu.dtype, cu.data, seq * cu.stride[0]); + const int64_t end = ld_int(cu.dtype, cu.data, (seq + 1) * cu.stride[0]); + if (begin == end) continue; + const int64_t na = + accepted ? ld_int(accepted->dtype, accepted->data, offlin(accepted, seq)) : 1; + const int64_t read = + ld_int(idx.dtype, idx.data, + seq * idx.stride[0] + (verify && !anchor ? na - 1 : 0) * idx.stride[1]); + if (read < 0) { + for (int64_t t = begin; t < end; ++t) + for (int64_t e = 0; e < P; ++e) stt(&out, off(out, t, head, e, P), 0); + continue; + } + const bool initialized = !init || ld_int(init->dtype, init->data, offlin(init, seq)) != 0; + std::vector S((size_t)(P * Nst)), b((size_t)Nst), c((size_t)Nst); + const int64_t sb = read * state.stride[0] + head * state.stride[1]; + for (int64_t e = 0; e < P; ++e) + for (int64_t d = 0; d < Nst; ++d) + S[e * Nst + d] = + initialized ? ldt(&state, sb + e * state.stride[2] + d * state.stride[3]) : 0; + const int64_t scratch = + anchor ? ld_int(idx.dtype, idx.data, seq * idx.stride[0] + (width / 2) * idx.stride[1]) + : 0; + auto factor_at = [&](int64_t i) { + return scratch * state.stride[0] + head * state.stride[1] + + (i / Nst) * state.stride[2] + (i % Nst) * state.stride[3]; + }; + if (anchor && verify) { + /* The accepted prefix of the previous window, onto the committed state, published. */ + const int64_t replay = initialized ? (int64_t)ldt(&state, factor_at(0)) : 0; + for (int64_t t = 0; t < (replay ? na : 0); ++t) { + const int64_t f = 1 + t * rec; + const float decay = ldt(&state, factor_at(f)); + for (int64_t d = 0; d < Nst; ++d) b[(size_t)d] = ldt(&state, factor_at(f + 1 + P + d)); + for (int64_t e = 0; e < P; ++e) { + const float u = ldt(&state, factor_at(f + 1 + e)); + for (int64_t d = 0; d < Nst; ++d) { + float& s = S[e * Nst + d]; + s = s * decay + u * b[d]; + } + } + } + for (int64_t e = 0; e < P; ++e) + for (int64_t d = 0; d < Nst; ++d) + stt(&state, sb + e * state.stride[2] + d * state.stride[3], S[e * Nst + d]); + } + const float A = -std::exp(ldt(&alog, head * laststride(&alog))); + const float bias = ldt(&dtb, head * laststride(&dtb)); + const float skip = ldt(&dskip, head * laststride(&dskip)); + for (int64_t t = begin; t < end; ++t) { + const float step = softplus(ldt(&dt, off(dt, t, head, 0, 1)) + bias); + const float decay = std::exp(step * A); + for (int64_t d = 0; d < Nst; ++d) { + b[d] = ldt(&B, off(B, t, grp, d, Nst)); + c[d] = ldt(&C, off(C, t, grp, d, Nst)); + } + const int64_t f = 1 + (t - begin) * rec; + if (anchor && verify) { + stt(&state, factor_at(f), decay); + for (int64_t d = 0; d < Nst; ++d) stt(&state, factor_at(f + 1 + P + d), b[d]); + } + for (int64_t e = 0; e < P; ++e) { + const float xe = ldt(&x, off(x, t, head, e, P)); + const float u = step * xe; + if (anchor && verify) stt(&state, factor_at(f + 1 + e), u); + float result = 0; + for (int64_t d = 0; d < Nst; ++d) { + float& s = S[e * Nst + d]; + s = s * decay + u * b[d]; + result += s * c[d]; + } + stt(&out, off(out, t, head, e, P), result + skip * xe); + } + if ((verify && !anchor) || (!verify && t + 1 == end)) { + const int64_t write = + ld_int(idx.dtype, idx.data, + seq * idx.stride[0] + (verify ? t - begin : 0) * idx.stride[1]); + if (write >= 0) + for (int64_t e = 0; e < P; ++e) + for (int64_t d = 0; d < Nst; ++d) + stt(&state, + write * state.stride[0] + head * state.stride[1] + + e * state.stride[2] + d * state.stride[3], + S[e * Nst + d]); + } + } + if (anchor) stt(&state, factor_at(0), verify ? (float)(end - begin) : 0.0f); + } + return RAD_OK; +} diff --git a/scripts/dspark_kv_rollback_device.py b/scripts/dspark_kv_rollback_device.py new file mode 100644 index 00000000..94000539 --- /dev/null +++ b/scripts/dspark_kv_rollback_device.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python3 +"""Exercise the compile-time-only direct KV rollback observer against a live Spark server. + +Build the server with -DRAD_ENABLE_KV_ROLLBACK_TEST_HOOK=ON and set +RADIANCE_TEST_KV_ROLLBACK_REPORT in that server's environment to the same report path supplied +here. This script sends a real greedy completion; it does not synthesize KV data. +""" +import argparse +import json +from pathlib import Path +import sys +import time +import urllib.error +import urllib.request + + +def main() -> int: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--url", required=True, help="server base URL, e.g. http://127.0.0.1:8080") + parser.add_argument("--model", required=True) + parser.add_argument("--report", required=True, type=Path, + help="same path configured in server's RADIANCE_TEST_KV_ROLLBACK_REPORT") + parser.add_argument("--prompt", default=("Write a detailed, varied explanation of why " + "forest ecosystems change over time. " * 20)) + parser.add_argument("--max-tokens", type=int, default=128) + parser.add_argument("--timeout", type=float, default=180.0) + args = parser.parse_args() + + if args.report.exists(): + parser.error(f"report path already exists; choose a fresh path: {args.report}") + args.report.parent.mkdir(parents=True, exist_ok=True) + evidence = None + endpoint = args.url.rstrip("/") + "/v1/chat/completions" + for attempt in range(8): + prompt = args.prompt + f"\nVariation {attempt + 1}: use a distinct example." + body = json.dumps({"model": args.model, "messages": [{"role": "user", "content": prompt}], + "temperature": 0, "max_tokens": args.max_tokens, + "reasoning_effort": "none", "stream": False}).encode() + request = urllib.request.Request(endpoint, body, {"Content-Type": "application/json"}) + try: + with urllib.request.urlopen(request, timeout=args.timeout) as response: + result = json.loads(response.read()) + if not result.get("choices"): + raise RuntimeError("server returned no completion choices") + except (urllib.error.URLError, TimeoutError, RuntimeError, json.JSONDecodeError) as exc: + print(f"request {attempt + 1} failed: {exc}", file=sys.stderr) + return 1 + deadline = time.monotonic() + 5 + while time.monotonic() < deadline: + if args.report.exists(): + try: + candidate = json.loads(args.report.read_text()) + except (OSError, json.JSONDecodeError): + time.sleep(0.05) + continue + if candidate.get("next_greedy_decode_observed"): + evidence = candidate + break + time.sleep(0.05) + if evidence is not None: + break + if evidence is None: + print("no completed direct KV observer report; a partial depth-7 rollback followed by " + "the next greedy decode was not observed", file=sys.stderr) + return 1 + required = { + "partial_rejection_observed": evidence.get("partial_rejection_observed") is True, + "depth_7": evidence.get("proposals") == 7 and 0 < evidence.get("accepted", 0) < 7, + "rollback_length": evidence.get("prefix_tokens_after") == evidence.get("rollback_to_tokens"), + "bytes_equal": evidence.get("bytes_equal") is True, + "mapping_equal": evidence.get("mapping_equal") is True, + "physical_slot_mapping": len(evidence.get("logical_blocks", [])) > 0 and + len(evidence.get("logical_blocks", [])) == + len(evidence.get("physical_slots", [])) and + evidence.get("logical_blocks") == + sorted(set(evidence.get("logical_blocks", []))) and + len(evidence.get("physical_slots", [])) == + len(set(evidence.get("physical_slots", []))), + "all_complete_prefix_blocks": evidence.get("block_size", 0) > 0 and + evidence.get("prefix_tokens_before_verify", 0) >= + evidence.get("first_block_pos", 0) and + len(evidence.get("logical_blocks", [])) == + (evidence.get("prefix_tokens_before_verify", 0) - + evidence.get("first_block_pos", 0)) // + evidence.get("block_size", 1), + "snapshot_geometry": evidence.get("layers", 0) > 0 and + evidence.get("bytes_per_layer", 0) * evidence.get("layers", 0) * + len(evidence.get("logical_blocks", [])) == + evidence.get("committed_prefix_bytes", 0), + "negative_control": evidence.get("negative_control_detected") is True, + "next_greedy_decode": evidence.get("next_greedy_decode_observed") is True and + isinstance(evidence.get("next_greedy_token"), int) and + evidence.get("next_greedy_token") >= 0, + } + print(json.dumps({"checks": required, "evidence": evidence}, indent=2)) + return 0 if all(required.values()) else 1 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/scripts/dspark_qos_regression.py b/scripts/dspark_qos_regression.py new file mode 100644 index 00000000..9e4955b0 --- /dev/null +++ b/scripts/dspark_qos_regression.py @@ -0,0 +1,552 @@ +#!/usr/bin/env python3 +"""Repeatable DSpark serving/QoS smoke test against two already-running Radiance servers. + +Start the same model/checkpoint and build on both endpoints with empty caches, changing only the +prefix-cache setting: + + python3 scripts/dspark_qos_regression.py \ + --cache-off-url http://127.0.0.1:8000 --cache-on-url http://127.0.0.1:8001 \ + --model spark --output dspark-qos.json + +The off server must use --no-prefix-cache; the on server must have a usable cache. Restart both +with empty caches before each run (the prompt also carries a fresh run nonce). This script +reports first streamed text-chunk/end-to-end latency and token rates alongside Prometheus counter +deltas. A text chunk can contain multiple model tokens, so it is not necessarily true token TTFT. It +also checks a >512-token prefill, a generated crossing of the 512-token boundary, drafting with +unaccepted draft proposals, streaming disconnect accounting, EOS/stop/tool protocol behavior, +and repeated seeded sampling. Aggregate counters cannot identify a partially accepted verify or +prove rollback correctness. Pass --allow-unobserved-rejection only for a deliberately weaker +diagnostic run; the JSON retains every failed assertion. + +This is a runtime release harness, not a numerical-equivalence test. Record model, server build, +GPU/kernel revision, launch arguments and the JSON artifact when comparing runs. No latency claim +is inferred from a single sample; the output contains repeated samples and p50/p95 summaries. +""" +from __future__ import annotations + +import argparse +import concurrent.futures +import json +import math +import platform +import re +import sys +import time +import urllib.error +import urllib.request +from datetime import datetime, timezone +from pathlib import Path +from typing import Any + +METRICS = ( + "radiance:attn_cached_tokens_total", + "radiance:linear_cached_tokens_total", + "radiance:prefix_cache_evictions_total", + "radiance:draft_tokens_total", + "radiance:draft_accepted_total", + "radiance:draft_refills_total", + "radiance:draft_acceptance_ratio", + "radiance:linear_prefix_cache_hit_rate", + "radiance:prefill_tokens_per_second", + "radiance:decode_tokens_per_second", + "radiance:client_disconnect_total", + "vllm:gpu_prefix_cache_hit_rate", +) +METRIC_LINE = re.compile( + r"^([a-zA-Z_:][a-zA-Z0-9_:]*)(?:\{[^}]*\})?\s+" + r"([-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?|NaN|[+-]?Inf)(?:\s+\d+)?$" +) + + +class HarnessError(RuntimeError): + pass + + +def endpoint(base: str, path: str) -> str: + return base.rstrip("/") + path + + +def fetch(url: str, *, data: bytes | None = None, headers: dict[str, str] | None = None, + timeout: float = 120.0): + req = urllib.request.Request(url, data=data, headers=headers or {}, method="GET" if data is None else "POST") + try: + return urllib.request.urlopen(req, timeout=timeout) + except urllib.error.HTTPError as e: + detail = e.read(4096).decode("utf-8", "replace") + raise HarnessError(f"HTTP {e.code} from {url}: {detail}") from e + except urllib.error.URLError as e: + raise HarnessError(f"request to {url} failed: {e}") from e + + +def scrape(base: str, api_key: str | None) -> dict[str, float]: + headers = {"Authorization": f"Bearer {api_key}"} if api_key else {} + with fetch(endpoint(base, "/metrics"), headers=headers) as r: + raw = r.read().decode("utf-8", "replace") + values: dict[str, float] = {} + for line in raw.splitlines(): + m = METRIC_LINE.match(line.strip()) + if not m: + continue + name, value = m.groups() + try: + n = float(value) + except ValueError: + continue + if math.isfinite(n): + values[name] = values.get(name, 0.0) + n + return values + + +def metric_delta(before: dict[str, float], after: dict[str, float], name: str) -> float: + if name not in before or name not in after: + raise HarnessError(f"required metric {name} missing from one or both scrapes") + delta = after[name] - before[name] + if delta < 0: + raise HarnessError(f"counter {name} decreased; server restarted or metric labels changed") + return delta + + +def selected_metrics(values: dict[str, float]) -> dict[str, float | None]: + return {name: values.get(name) for name in METRICS} + + +def chat_request(base: str, model: str, messages: list[dict[str, Any]], *, api_key: str | None, + timeout: float, **options: Any) -> dict[str, Any]: + body = {"model": model, "messages": messages, **options} + headers = {"Content-Type": "application/json"} + if api_key: + headers["Authorization"] = f"Bearer {api_key}" + start = time.monotonic() + with fetch(endpoint(base, "/v1/chat/completions"), data=json.dumps(body).encode(), + headers=headers, timeout=timeout) as r: + payload = json.loads(r.read()) + elapsed = time.monotonic() - start + choices = payload.get("choices") or [] + if not choices: + raise HarnessError("chat completion returned no choices") + choice = choices[0] + message = choice.get("message") or {} + usage = payload.get("usage") or {} + return { + "elapsed_s": elapsed, + "finish_reason": choice.get("finish_reason"), + "content": message.get("content") or "", + "tool_calls": message.get("tool_calls") or [], + "prompt_tokens": usage.get("prompt_tokens"), + "completion_tokens": usage.get("completion_tokens"), + "id": payload.get("id"), + } + + +def stream_request(base: str, model: str, prompt: str, *, api_key: str | None, + timeout: float, cancel_after_first_event: bool = False, + **options: Any) -> dict[str, Any]: + body = {"model": model, "messages": [{"role": "user", "content": prompt}], + "stream": True, **options} + headers = {"Content-Type": "application/json"} + if api_key: + headers["Authorization"] = f"Bearer {api_key}" + start = time.monotonic() + response = fetch(endpoint(base, "/v1/chat/completions"), data=json.dumps(body).encode(), + headers=headers, timeout=timeout) + content: list[str] = [] + finish = None + first_event_s = None + first_text_s = None + events = 0 + try: + while True: + line = response.readline() + if not line: + break + if not line.startswith(b"data:"): + continue + data = line[5:].strip() + if data == b"[DONE]": + break + try: + chunk = json.loads(data) + except json.JSONDecodeError: + continue + events += 1 + if first_event_s is None: + first_event_s = time.monotonic() - start + for choice in chunk.get("choices", []): + delta = choice.get("delta") or {} + piece = delta.get("content") + reasoning = delta.get("reasoning_content") + if first_text_s is None and ((isinstance(piece, str) and piece) or + (isinstance(reasoning, str) and reasoning)): + first_text_s = time.monotonic() - start + if isinstance(piece, str): + content.append(piece) + if choice.get("finish_reason") is not None: + finish = choice["finish_reason"] + if cancel_after_first_event and first_event_s is not None: + break + finally: + response.close() + return { + "elapsed_s": time.monotonic() - start, + "first_event_s": first_event_s, + "first_text_s": first_text_s, + "finish_reason": finish, + "content": "".join(content), + "events": events, + "cancelled": cancel_after_first_event, + } + + +def percentile(xs: list[float], p: float) -> float | None: + if not xs: + return None + ys = sorted(xs) + return ys[min(len(ys) - 1, max(0, math.ceil(p * len(ys)) - 1))] + + +def summarize(samples: list[dict[str, Any]]) -> dict[str, Any]: + elapsed = [float(s["elapsed_s"]) for s in samples if s.get("elapsed_s") is not None] + first_text = [float(s["first_text_s"]) for s in samples if s.get("first_text_s") is not None] + rates = [] + for s in samples: + n, t = s.get("completion_tokens"), s.get("elapsed_s") + if isinstance(n, (int, float)) and n > 0 and t and t > 0: + rates.append(float(n) / float(t)) + return { + "n": len(samples), + "end_to_end_s": {"p50": percentile(elapsed, .50), "p95": percentile(elapsed, .95)}, + "first_text_s": {"p50": percentile(first_text, .50), "p95": percentile(first_text, .95)}, + "completion_tokens_per_second": {"p50": percentile(rates, .50), "p95": percentile(rates, .95)}, + } + + +def cache_probe(base: str, name: str, model: str, api_key: str | None, + timeout: float, prompt: str, repeats: int) -> dict[str, Any]: + before = scrape(base, api_key) + first = chat_request(base, model, [{"role": "user", "content": prompt}], api_key=api_key, + timeout=timeout, temperature=0, seed=17, max_tokens=4) + middle = scrape(base, api_key) + warm = [chat_request(base, model, [{"role": "user", "content": prompt}], api_key=api_key, + timeout=timeout, temperature=0, seed=17, max_tokens=4) + for _ in range(repeats)] + after = scrape(base, api_key) + return { + "name": name, "first": first, "warm_samples": warm, + "latency": summarize([first, *warm]), + "first_attn_cache_tokens": metric_delta(before, middle, "radiance:attn_cached_tokens_total"), + "warm_attn_cache_tokens": metric_delta(middle, after, "radiance:attn_cached_tokens_total"), + "first_linear_cache_tokens": metric_delta(before, middle, "radiance:linear_cached_tokens_total"), + "warm_linear_cache_tokens": metric_delta(middle, after, "radiance:linear_cached_tokens_total"), + "evictions": metric_delta(before, after, "radiance:prefix_cache_evictions_total"), + } + + +def require(result: dict[str, Any], name: str, passed: bool, detail: str) -> None: + result.setdefault("assertions", []).append({"name": name, "passed": bool(passed), "detail": detail}) + if not passed: + result.setdefault("failures", []).append(f"{name}: {detail}") + + +def stop_sequence_observed(unstopped: dict[str, Any], stopped: dict[str, Any], marker: str) -> bool: + before_marker, found, _ = unstopped["content"].partition(marker) + return bool(found) and stopped["finish_reason"] == "stop" and stopped["content"] == before_marker + + +def observed_draft_token_total(trials: list[dict[str, Any]]) -> int: + return sum(int(trial["draft_tokens"]) for trial in trials) + + +def seeded_sample_reproduced(first: dict[str, Any], repeat: dict[str, Any]) -> bool: + """Equal empty responses do not establish seeded sampling reproducibility.""" + content = first.get("content") + count = first.get("completion_tokens") + repeat_count = repeat.get("completion_tokens") + finish = first.get("finish_reason") + return (isinstance(content, str) and bool(content.strip()) and + content == repeat.get("content") and + finish in ("stop", "length") and finish == repeat.get("finish_reason") and + type(count) is int and count > 0 and + type(repeat_count) is int and count == repeat_count) + + +def calibrated_rollover_prompt(base: str, model: str, api_key: str | None, + timeout: float, target: int = 480) -> tuple[str, int]: + """Find a repeated prompt below the 512 boundary using response usage (no tokenizer guess).""" + phrase = "rollover-boundary marker " + lo, hi, best = 1, 1, None + # Bracket from small inputs; starting at 1024 repetitions can exceed the server's + # max-model-len before calibration has found a safe prompt. + while True: + r = chat_request(base, model, [{"role": "user", "content": phrase * hi}], api_key=api_key, + timeout=timeout, temperature=0, seed=23, max_tokens=1) + n = r.get("prompt_tokens") + if not isinstance(n, int): + raise HarnessError("usage.prompt_tokens is required to calibrate the rollover boundary") + if n > target: + break + best = (phrase * hi, n) + lo = hi + 1 + hi *= 2 + if hi > 2048: + raise HarnessError("could not bracket the rollover boundary in 2048 repetitions") + while lo <= hi: + count = (lo + hi) // 2 + prompt = phrase * count + r = chat_request(base, model, [{"role": "user", "content": prompt}], api_key=api_key, + timeout=timeout, temperature=0, seed=23, max_tokens=1) + n = r.get("prompt_tokens") + if not isinstance(n, int): + raise HarnessError("usage.prompt_tokens is required to calibrate the rollover boundary") + if n <= target: + best = (prompt, n) + lo = count + 1 + else: + hi = count - 1 + if best is None: + raise HarnessError("could not construct a prompt below the 512-token rollover boundary") + return best + + +def run(args: argparse.Namespace) -> dict[str, Any]: + result: dict[str, Any] = { + "created_utc": datetime.now(timezone.utc).isoformat(), + "python": platform.python_version(), "platform": platform.platform(), + "model": args.model, "cache_off_url": args.cache_off_url, "cache_on_url": args.cache_on_url, + "configuration": {"short_repeats": args.short_repeats, "long_repeats": args.long_repeats, + "long_output_tokens": args.long_output_tokens, + "rollover_output_tokens": args.rollover_output_tokens, + "rejection_trials": args.rejection_trials}, + "failures": [], "assertions": [], "scenarios": {}, + } + off_url, on_url = args.cache_off_url, args.cache_on_url + off_initial = scrape(off_url, args.api_key) + on_initial = scrape(on_url, args.api_key) + nonce = datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%S%fZ") + long_cache_prompt = f"DSpark-{nonce} cache reuse marker. " + "cache prefix item. " * 180 + off = cache_probe(off_url, "prefix_cache_off", args.model, args.api_key, args.timeout, + long_cache_prompt, args.short_repeats) + on = cache_probe(on_url, "prefix_cache_on", args.model, args.api_key, args.timeout, + long_cache_prompt, args.short_repeats) + result["scenarios"]["prefix_cache"] = {"off": off, "on": on} + require(result, "cache_off_has_no_reuse", + off["warm_attn_cache_tokens"] == 0 and off["warm_linear_cache_tokens"] == 0, + f"warm attention/linear hits={off['warm_attn_cache_tokens']}/{off['warm_linear_cache_tokens']}") + require(result, "cache_on_reuses_prefix", + on["warm_attn_cache_tokens"] > 0 or on["warm_linear_cache_tokens"] > 0, + f"warm attention/linear hits={on['warm_attn_cache_tokens']}/{on['warm_linear_cache_tokens']}") + + # Long prompt and decode that begins well beyond the 512-token DSpark history. + long_prompt = "DSpark long-context oracle marker 37. " * args.long_repeats + long_samples = [] + long_before = scrape(on_url, args.api_key) + for i in range(args.short_repeats): + s = chat_request(on_url, args.model, [{"role": "user", "content": long_prompt}], + api_key=args.api_key, timeout=args.timeout, temperature=0, seed=31, + max_tokens=args.long_output_tokens) + long_samples.append(s) + long_after = scrape(on_url, args.api_key) + long_tokens = long_samples[-1].get("prompt_tokens") if long_samples else None + result["scenarios"]["long_context"] = { + "prompt_tokens": long_tokens, "samples": long_samples, "latency": summarize(long_samples), + "draft_tokens": metric_delta(long_before, long_after, "radiance:draft_tokens_total"), + "draft_accepted": metric_delta(long_before, long_after, "radiance:draft_accepted_total"), + "draft_refills": metric_delta(long_before, long_after, "radiance:draft_refills_total"), + } + require(result, "long_context_exceeds_512", + isinstance(long_tokens, int) and long_tokens > 512, + f"reported prompt_tokens={long_tokens}") + + # Precisely place the input below 512 from usage and generate across the boundary. + rollover_prompt, calibrated_tokens = calibrated_rollover_prompt( + on_url, args.model, args.api_key, args.timeout) + roll_before = scrape(on_url, args.api_key) + rollover = chat_request(on_url, args.model, [{"role": "user", "content": rollover_prompt}], + api_key=args.api_key, timeout=args.timeout, temperature=0, seed=43, + max_tokens=args.rollover_output_tokens) + roll_after = scrape(on_url, args.api_key) + completion = rollover.get("completion_tokens") + actual_prompt_tokens = rollover.get("prompt_tokens") + crossed = (isinstance(actual_prompt_tokens, int) and isinstance(completion, int) and + actual_prompt_tokens < 512 and actual_prompt_tokens + completion >= 512) + result["scenarios"]["window_rollover"] = { + "calibrated_prompt_tokens": calibrated_tokens, + "prompt_tokens": actual_prompt_tokens, "completion_tokens": completion, + "crossed_absolute_512_boundary": crossed, "sample": rollover, + "draft_tokens": metric_delta(roll_before, roll_after, "radiance:draft_tokens_total"), + "draft_accepted": metric_delta(roll_before, roll_after, "radiance:draft_accepted_total"), + "draft_refills": metric_delta(roll_before, roll_after, "radiance:draft_refills_total"), + } + require(result, "generation_crosses_512_boundary", crossed, + f"calibrated={calibrated_tokens}, actual prompt={actual_prompt_tokens}, completion={completion}") + + # A true stream and a client-side cancellation; the latter is checked against the disconnect counter. + stream = stream_request(on_url, args.model, "Give a concise description of a star.", + api_key=args.api_key, timeout=args.timeout, temperature=0, seed=53, + max_tokens=48) + result["scenarios"]["streaming"] = stream + require(result, "stream_emits_text", stream["events"] > 0 and stream["first_text_s"] is not None, + f"events={stream['events']}, first_text={stream['first_text_s']}") + disconnect_before = scrape(on_url, args.api_key) + cancelled = stream_request(on_url, args.model, + "Continue an unbounded story about a long voyage through space.", + api_key=args.api_key, timeout=args.timeout, + cancel_after_first_event=True, temperature=0.8, seed=59, + max_tokens=2048) + disconnect_after = scrape(on_url, args.api_key) + deadline = time.monotonic() + 5.0 + while metric_delta(disconnect_before, disconnect_after, "radiance:client_disconnect_total") <= 0 and \ + time.monotonic() < deadline: + time.sleep(0.1) + disconnect_after = scrape(on_url, args.api_key) + disconnect_delta = metric_delta(disconnect_before, disconnect_after, + "radiance:client_disconnect_total") + result["scenarios"]["cancellation"] = {**cancelled, "disconnect_counter_delta": disconnect_delta} + require(result, "client_disconnect_is_counted", disconnect_delta > 0, + f"radiance:client_disconnect_total delta={disconnect_delta}") + + # A stop finish alone does not prove the explicit marker fired. Compare a matching untruncated + # no-stop control and require that it actually emits the marker. + eos = chat_request(on_url, args.model, + [{"role": "user", "content": "Reply with exactly OK and then end the turn."}], + api_key=args.api_key, timeout=args.timeout, temperature=0, seed=61, + max_tokens=24, reasoning_effort="none") + stop_prompt = [{"role": "user", "content": "Write exactly DS_STOP_6f41 and nothing after it."}] + unstopped = chat_request(on_url, args.model, stop_prompt, + api_key=args.api_key, timeout=args.timeout, temperature=0, seed=67, + max_tokens=24, reasoning_effort="none") + stopped = chat_request(on_url, args.model, stop_prompt, + api_key=args.api_key, timeout=args.timeout, temperature=0, seed=67, + max_tokens=24, stop=["DS_STOP_6f41"], reasoning_effort="none") + result["scenarios"]["eos_and_stop"] = {"eos": eos, "without_stop": unstopped, "stop": stopped} + require(result, "natural_end_of_turn", eos["finish_reason"] == "stop", + f"finish_reason={eos['finish_reason']}") + marker = "DS_STOP_6f41" + stop_proven = stop_sequence_observed(unstopped, stopped, marker) + require(result, "explicit_stop_sequence", stop_proven, + f"control_contains_marker={marker in unstopped['content']}, finish_reason={stopped['finish_reason']}, " + f"control={unstopped['content']!r}, stopped={stopped['content']!r}") + + tool = chat_request( + on_url, args.model, + [{"role": "user", "content": "Call emit_probe with value dspark_qos now; do not answer in text."}], + api_key=args.api_key, timeout=args.timeout, temperature=0, seed=71, max_tokens=48, + tools=[{"type": "function", "function": { + "name": "emit_probe", "description": "Record the DSpark QoS tool-call probe.", + "parameters": {"type": "object", "properties": {"value": {"type": "string"}}, + "required": ["value"], "additionalProperties": False}}}], + tool_choice={"type": "function", "function": {"name": "emit_probe"}}, + ) + result["scenarios"]["tool_call"] = tool + require(result, "tool_call_is_emitted", bool(tool["tool_calls"]), + f"finish_reason={tool['finish_reason']}, tool_calls={len(tool['tool_calls'])}") + + seeded_body = [{"role": "user", "content": "Write a short, varied sentence about a comet."}] + seeded_a = chat_request(on_url, args.model, seeded_body, api_key=args.api_key, timeout=args.timeout, + temperature=0.75, seed=99173, max_tokens=32, reasoning_effort="none") + seeded_b = chat_request(on_url, args.model, seeded_body, api_key=args.api_key, timeout=args.timeout, + temperature=0.75, seed=99173, max_tokens=32, reasoning_effort="none") + same = seeded_a["content"] == seeded_b["content"] + reproduced = seeded_sample_reproduced(seeded_a, seeded_b) + result["scenarios"]["seeded_sampling"] = {"first": seeded_a, "repeat": seeded_b, + "identical": same, "valid_reproduction": reproduced} + require(result, "seed_reproduces_sample", reproduced, + f"first={seeded_a['content']!r}, repeat={seeded_b['content']!r}, " + f"finish={seeded_a['finish_reason']!r}/{seeded_b['finish_reason']!r}, " + f"completion_tokens={seeded_a['completion_tokens']!r}/{seeded_b['completion_tokens']!r}") + + # Exercise concurrent batching, then look for unaccepted proposals. Aggregate per-request + # counters cannot establish whether any single verify was partially accepted. + def concurrent_call(idx: int) -> dict[str, Any]: + return chat_request(on_url, args.model, + [{"role": "user", "content": f"In two sentences, describe a different planet. Case {idx}."}], + api_key=args.api_key, timeout=args.timeout, temperature=0.6, + seed=101 + idx, max_tokens=40) + concurrent_before = scrape(on_url, args.api_key) + with concurrent.futures.ThreadPoolExecutor(max_workers=2) as pool: + concurrent_samples = list(pool.map(concurrent_call, (0, 1))) + concurrent_after = scrape(on_url, args.api_key) + result["scenarios"]["concurrent"] = { + "samples": concurrent_samples, "latency": summarize(concurrent_samples), + "draft_tokens": metric_delta(concurrent_before, concurrent_after, "radiance:draft_tokens_total"), + "draft_accepted": metric_delta(concurrent_before, concurrent_after, "radiance:draft_accepted_total"), + } + + rejection_trials = [] + any_rejection = False + for i in range(args.rejection_trials): + before = scrape(on_url, args.api_key) + sample = chat_request(on_url, args.model, + [{"role": "user", "content": f"Continue this changing story with new details: trial {i}, a river crosses a city."}], + api_key=args.api_key, timeout=args.timeout, temperature=0.85, + seed=1201 + i, max_tokens=80) + after = scrape(on_url, args.api_key) + proposed = metric_delta(before, after, "radiance:draft_tokens_total") + accepted = metric_delta(before, after, "radiance:draft_accepted_total") + rejected = proposed > accepted + any_rejection = any_rejection or rejected + rejection_trials.append({"sample": sample, "draft_tokens": proposed, + "draft_accepted": accepted, "unaccepted_proposals": rejected}) + result["scenarios"]["unaccepted_proposals"] = {"trials": rejection_trials, + "observed": any_rejection} + draft_tokens_observed = observed_draft_token_total(rejection_trials) + require(result, "draft_proposals_are_observed", draft_tokens_observed > 0, + f"draft_tokens_total delta={draft_tokens_observed}") + if not args.allow_unobserved_rejection: + require(result, "unaccepted_proposals_are_observed", any_rejection, + f"trials={len(rejection_trials)}; per-trial deltas are recorded") + + # QoS summary is deliberately descriptive. Compare these artifacts under matched launch args; + # this harness does not invent universal latency or acceptance thresholds. + result["summaries"] = { + "prefix_cache_off": off["latency"], "prefix_cache_on": on["latency"], + "long_context": result["scenarios"]["long_context"]["latency"], + "concurrent": result["scenarios"]["concurrent"]["latency"], + "unaccepted_proposal_trials": summarize([t["sample"] for t in rejection_trials]), + } + result["server_metrics"] = { + "cache_off_initial": selected_metrics(off_initial), + "cache_off_final": selected_metrics(scrape(off_url, args.api_key)), + "cache_on_initial": selected_metrics(on_initial), + "cache_on_final": selected_metrics(scrape(on_url, args.api_key)), + } + return result + + +def main() -> int: + p = argparse.ArgumentParser(description=__doc__) + p.add_argument("--cache-off-url", required=True, help="root URL of --prefix-cache-mib 0 server") + p.add_argument("--cache-on-url", required=True, help="root URL of server with prefix cache enabled") + p.add_argument("--model", required=True, help="OpenAI-compatible model id") + p.add_argument("--api-key", default=None, help="optional bearer token (never written to output)") + p.add_argument("--output", type=Path, default=Path("dspark-qos.json")) + p.add_argument("--timeout", type=float, default=180.0) + p.add_argument("--short-repeats", type=int, default=3) + p.add_argument("--long-repeats", type=int, default=160, + help="repetitions of a marker phrase; response usage must confirm >512 tokens") + p.add_argument("--long-output-tokens", type=int, default=48) + p.add_argument("--rollover-output-tokens", type=int, default=96) + p.add_argument("--rejection-trials", "--partial-rejection-trials", dest="rejection_trials", + type=int, default=8, + help="trials to look for unaccepted proposals; aggregate counts cannot prove partial rejection") + p.add_argument("--allow-unobserved-rejection", action="store_true", + help="record but do not fail when sampled trials find no unaccepted proposals") + args = p.parse_args() + if args.short_repeats < 1 or args.long_repeats < 1 or args.rejection_trials < 1: + p.error("repeat counts must be positive") + try: + result = run(args) + except Exception as e: + print(f"dspark_qos_regression: {e}", file=sys.stderr) + return 2 + args.output.write_text(json.dumps(result, indent=2, sort_keys=True) + "\n", encoding="utf-8") + print(f"wrote {args.output}") + print(f"failures={len(result['failures'])}; long_context={result['scenarios']['long_context']['prompt_tokens']} prompt tokens; " + f"rollover={result['scenarios']['window_rollover']['crossed_absolute_512_boundary']}; " + f"unaccepted_proposals={result['scenarios']['unaccepted_proposals']['observed']}") + for failure in result["failures"]: + print(f"FAIL {failure}") + return 1 if result["failures"] else 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/spec.md b/spec.md index 4f32dccf..8e700b36 100644 --- a/spec.md +++ b/spec.md @@ -935,12 +935,15 @@ utilisation fraction: | flag | | |---|---| | `--gpu-headroom-mib` | VRAM left unclaimed on every card (default 96) | +| `--gpu-memory-mib` | VRAM claimed on every card; inverse of `--gpu-headroom-mib` (headroom is the card less N). The two cannot be combined | | `--host-pool-mib` | the pinned host tier | | `--host-headroom-mib` | host RAM left free for the system at startup (default 4096); a snapshot store's floor takes back the shortfall from it, down to 1 GiB | | `--weights-disk-tier` | the file tier for weights, read from the container; needs `O_DIRECT` | | `--max-model-len`, `--max-num-seqs` | the KV cache's bound | | `--kv-resident` | stream the sparse attention group's KV from pinned host memory, keeping a ring of N tokens on the card; off by default. Raised to 32 768 and to one decode step's selection; a ring that covers the context streams nothing; ignored with a warning on an architecture that cannot stream (docs/KV-STREAMING.md) | +`--gpu-memory-mib N` is the same input as `--gpu-headroom-mib` written as a claim. Give one. + Nothing is inferred from the free VRAM at startup, which would size pools differently depending on what else is open. Each term is a fixed property, a computed quantity, or a measurement printed on its own line (`core/mem/vram_budget.h`). The startup report lists them in the order spent (sizes diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b1720048..253c50f7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -10,12 +10,12 @@ # fast every test with none of slow, gpu, oot and perf, set at the end of this file: the # inner loop (`ctest --preset fast`, or `ctest -L fast`) # -# arch_test and glm5next_test do not link rad_core: they supply their own recording fake of the -# declare-phase C ABI (arch_fakes.h), so plugins are tested without depending on core/build/'s -# builder. With the archive linked, a new ABI call missing from the fake would pull in -# rad_builder.cpp.o and collide on every rad_decl_* symbol; without it the error is a single -# undefined reference. -set(RAD_TESTS_NO_CORE arch_test glm5next_test nemotron35_test) +# arch_test, glm5next_test, nemotron35_test, spark25_arch_test and nemotronh_test do not link rad_core: they supply +# their own recording fake of the declare-phase C ABI (arch_fakes.h), so plugins are tested without +# depending on core/build/'s builder. With the archive linked, a new ABI call missing from the fake +# would pull in rad_builder.cpp.o and collide on every rad_decl_* symbol; without it the error is a +# single undefined reference. +set(RAD_TESTS_NO_CORE arch_test glm5next_test nemotron35_test spark25_arch_test nemotronh_test) # fixture_test tests tools/kfixture.cpp and tools/opshapes.cpp (the seeded draw, the reduction and # the on-disk recording) directly, kbench_test tools/kbench_core.cpp (rad-kbench's rules), and @@ -166,6 +166,9 @@ string(APPEND RAD_PERF_SCRIPT "include([==[${CMAKE_CURRENT_SOURCE_DIR}/perf_entr set(RAD_TESTS_WHOLE_CORE shipped_plugins_test) file(GLOB RAD_TESTS CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*_test.cpp) +if(NOT RAD_HIP_FOUND) + list(FILTER RAD_TESTS EXCLUDE REGEX "/dspark_device_test\\.cpp$") +endif() foreach(t ${RAD_TESTS}) get_filename_component(n ${t} NAME_WE) if(n IN_LIST RAD_TESTS_NO_CORE) @@ -263,16 +266,28 @@ foreach(t ${RAD_TESTS}) if(n STREQUAL "mem_test") set_target_properties(${n} PROPERTIES ENABLE_EXPORTS ON) endif() - if(DEFINED RAD_TEST_SHARDS_${n}) - math(EXPR last "${RAD_TEST_SHARDS_${n}} - 1") - foreach(k RANGE ${last}) - rad_unit_test(${n}_shard${k} ${n} --shard ${k}/${RAD_TEST_SHARDS_${n}}) - endforeach() + if(n STREQUAL "dspark_device_test") + if(RAD_HIP_FOUND AND TARGET libr4d) + add_dependencies(${n} libr4d) + add_test(NAME ${n} COMMAND ${n} ${RAD_PLUGIN_OUT}/kernels/libr4d.so) + set_tests_properties(${n} PROPERTIES + LABELS gpu + SKIP_RETURN_CODE 77 + TIMEOUT ${RAD_TEST_TIMEOUT} + ENVIRONMENT "${RAD_TEST_CARD_ENV}") + endif() else() - rad_unit_test(${n} ${n}) + if(DEFINED RAD_TEST_SHARDS_${n}) + math(EXPR last "${RAD_TEST_SHARDS_${n}} - 1") + foreach(k RANGE ${last}) + rad_unit_test(${n}_shard${k} ${n} --shard ${k}/${RAD_TEST_SHARDS_${n}}) + endforeach() + else() + rad_unit_test(${n} ${n}) + endif() + string(APPEND RAD_PERF_SCRIPT + "rad_perf_entry(${n} [==[${t}]==] [==[${CMAKE_BINARY_DIR}/tests/${n}]==])\n") endif() - string(APPEND RAD_PERF_SCRIPT - "rad_perf_entry(${n} [==[${t}]==] [==[${CMAKE_BINARY_DIR}/tests/${n}]==])\n") endforeach() # ================================================================== perf_ cases @@ -333,6 +348,11 @@ if(TARGET spechub) add_dependencies(sample_test spechub) endif() +if(TARGET spark25_recipe_test) + target_compile_definitions(spark25_recipe_test PRIVATE + RAD_SPARK25_RECIPE_DIR="${CMAKE_SOURCE_DIR}/data/recipes") +endif() + # ================================================================== whole models on the CPU # # engine_e2e_test runs the radiance binary on tiny synthetic checkpoints (tests/tiny_model.h) on @@ -344,12 +364,14 @@ set(RAD_E2E_DEPS radiance rad-convert libref libquant nemotron35_embed qwen35_bf if(TARGET libavx) list(APPEND RAD_E2E_DEPS libavx) endif() -foreach(t engine_e2e_test convert_test clef_decision_test laya_decision_test) +foreach(t engine_e2e_test convert_test clef_decision_test laya_decision_test spark25_convert_test) if(TARGET ${t}) target_compile_definitions(${t} PRIVATE RAD_E2E_SERVER="$" RAD_E2E_CONVERT="$" RAD_E2E_HOME="${RAD_PLUGIN_OUT}" RAD_E2E_RECIPES="${CMAKE_SOURCE_DIR}/data/recipes") - if(t STREQUAL "clef_decision_test") + if(t STREQUAL "spark25_convert_test") + add_dependencies(${t} rad-convert libref spark25_bf16) + elseif(t STREQUAL "clef_decision_test") # The tiny clef's golden (tests/mkclefgolden.py) and the one plugin a clef container selects. target_compile_definitions(${t} PRIVATE RAD_CLEF_GOLDEN="${CMAKE_CURRENT_SOURCE_DIR}/data/golden/clef_tiny.json") @@ -384,10 +406,10 @@ if(TARGET abi_layout_test) COMPILE_OPTIONS "-std=c11;-pedantic-errors;-Wall;-Wextra") endif() -# arch_test reads libref's vocabulary from $RADIANCE_HOME/kernels to check that each architecture -# declares on it, and glm5next_test the loaded libraries' op schemas, so libref is built before -# them. -foreach(t arch_test glm5next_test) +# arch_test and nemotronh_test read libref's vocabulary from $RADIANCE_HOME/kernels to check that +# each architecture declares on it, and glm5next_test the loaded libraries' op schemas, so libref is +# built before them. +foreach(t arch_test glm5next_test nemotronh_test) if(TARGET libref AND TARGET ${t}) add_dependencies(${t} libref) endif() @@ -430,11 +452,13 @@ endif() # # libhalo serves gfx1151 behind libr4d's exact interface (libhalo/halo_parity.cpp): the same op # schemas and rows, so every model plugin runs on either. Host-only (the tables, no device calls); -# present when one build produces both plugins. +# present when one build produces both plugins. Labelled `parity`: it fails while libr4d has ops +# libhalo has not ported yet (every one printed as "only in libr4d"), which the image's test stage +# leaves out; a schema both declare must still agree, or the loader refuses the second library. if(TARGET halo_parity) add_test(NAME halo_parity COMMAND halo_parity ${RAD_PLUGIN_OUT}/kernels/libr4d.so ${RAD_PLUGIN_OUT}/kernels/libhalo.so) - set_tests_properties(halo_parity PROPERTIES LABELS "fast" TIMEOUT 60) + set_tests_properties(halo_parity PROPERTIES LABELS "fast;parity" TIMEOUT 60) endif() # ================================================================== the device layer without SVM @@ -535,11 +559,12 @@ set(R4D_EMU_HIP ${R4D_DIR}/r4d_attn_paged_window.hip ${R4D_DIR}/r4d_pair_argmax_ ${R4D_DIR}/r4d_mhc.hip ${R4D_DIR}/r4d_fp8_f32scale.hip ${R4D_DIR}/r4d_kda.hip ${R4D_DIR}/r4d_moe_mxfp4.hip ${R4D_DIR}/r4d_mla.hip ${R4D_DIR}/r4d_quant_act_fp8.hip ${R4D_DIR}/r4d_kv_resolve.hip ${R4D_DIR}/r4d_dsa.hip - ${R4D_DIR}/r4d_gemm_m2xfp4a8_decode.hip ${R4D_DIR}/r4d_gemm_m2xfp4a8_tiled.hip) + ${R4D_DIR}/r4d_gemm_m2xfp4a8_decode.hip ${R4D_DIR}/r4d_gemm_m2xfp4a8_tiled.hip + ${R4D_DIR}/r4d_lili.hip) # The M2XFP4 units' plugin entries call two cfg readers that r4d_rows.cpp defines, which is not in # this build: cfg_stub.cpp defines them at their axis defaults, in both arms below. set(R4D_EMU_TESTS attn pick norm escale qsa lora f32 mhc fp8f32 kda moemx mla moefuse kvres - dsa m2xfp4) + dsa m2xfp4 lili) set(R4D_EMU_BUILT OFF) if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64)$") # No fiber switch for this ISA. @@ -580,7 +605,8 @@ else() ${R4D_EMU}/test_f32.cpp ${R4D_EMU}/test_mhc.cpp ${R4D_EMU}/test_fp8f32.cpp ${R4D_EMU}/test_kda.cpp ${R4D_EMU}/test_moemx.cpp ${R4D_EMU}/test_mla.cpp ${R4D_EMU}/test_moefuse.cpp ${R4D_EMU}/test_kvres.cpp - ${R4D_EMU}/test_dsa.cpp ${R4D_EMU}/test_m2xfp4.cpp ${R4D_EMU}/cfg_stub.cpp) + ${R4D_EMU}/test_dsa.cpp ${R4D_EMU}/test_m2xfp4.cpp ${R4D_EMU}/test_lili.cpp + ${R4D_EMU}/cfg_stub.cpp) get_filename_component(stem ${src} NAME_WE) set(lang "") if(src MATCHES "\\.hip$") @@ -617,7 +643,7 @@ else() endif() endif() if(R4D_EMU_BUILT) - foreach(t pick norm escale qsa lora f32 mhc fp8f32 kda moemx mla moefuse kvres dsa m2xfp4) + foreach(t pick norm escale qsa lora f32 mhc fp8f32 kda moemx mla moefuse kvres dsa m2xfp4 lili) add_test(NAME r4d_emu_${t} COMMAND ${CMAKE_BINARY_DIR}/tests/r4d_emu_${t}) endforeach() # The attention cases take about 11 s, 7 of them in the two long prefills on the WMMA kernel, @@ -628,7 +654,7 @@ if(R4D_EMU_BUILT) endforeach() set_tests_properties(r4d_emu_attn_shard0 r4d_emu_attn_shard1 r4d_emu_attn_shard2 r4d_emu_pick r4d_emu_norm r4d_emu_escale r4d_emu_qsa r4d_emu_lora r4d_emu_mla r4d_emu_moefuse - r4d_emu_dsa r4d_emu_m2xfp4 + r4d_emu_dsa r4d_emu_m2xfp4 r4d_emu_lili PROPERTIES LABELS "r4d_emu" TIMEOUT ${RAD_TEST_TIMEOUT}) # The LoRA pair has a libref oracle, and the test holds the emulated kernels to it when it can # load one -- expand bit for bit, shrink to its bound. kda_update is held to libref's within @@ -810,6 +836,12 @@ find_program(RAD_PYTHON3 NAMES python3) if(RAD_PYTHON3) add_test(NAME rad_export_test COMMAND ${RAD_PYTHON3} ${CMAKE_CURRENT_SOURCE_DIR}/rad_export_test.py) set_tests_properties(rad_export_test PROPERTIES LABELS "unit;fast" TIMEOUT ${RAD_TEST_TIMEOUT}) + add_test(NAME spark25_validation_test + COMMAND ${RAD_PYTHON3} ${CMAKE_CURRENT_SOURCE_DIR}/spark25_validation_test.py) + set_tests_properties(spark25_validation_test PROPERTIES LABELS "unit;fast" TIMEOUT ${RAD_TEST_TIMEOUT}) + add_test(NAME dspark_qos_regression_test + COMMAND ${RAD_PYTHON3} ${CMAKE_CURRENT_SOURCE_DIR}/dspark_qos_regression_test.py) + set_tests_properties(dspark_qos_regression_test PROPERTIES LABELS "unit;fast" TIMEOUT ${RAD_TEST_TIMEOUT}) endif() # ================================================================== the shipped plugins, out of tree diff --git a/tests/abi_layout_table.h b/tests/abi_layout_table.h index 7ddfcaaa..5e9b586d 100644 --- a/tests/abi_layout_table.h +++ b/tests/abi_layout_table.h @@ -1,8 +1,8 @@ -/* abi_layout_table.h -- every abi/ struct's size and field offsets at RAD_ABI_VERSION 32 and +/* abi_layout_table.h -- every abi/ struct's size and field offsets at RAD_ABI_VERSION 37 and * RAD_FORMAT_VER 2, as { type, field, offset, size } rows ("" is the struct itself). A snapshot * of the headers on x86-64 Linux, which abi_layout_test.cpp holds the layout to; regenerate it * from the test's printout only together with a version bump. */ -{ "RadArchProbe", "", 0, 120 }, +{ "RadArchProbe", "", 0, 128 }, { "RadArchProbe", "draft_depth", 0, 4 }, { "RadArchProbe", "draft_depth_fixed", 4, 4 }, { "RadArchProbe", "shape_probe_ok", 8, 4 }, @@ -22,7 +22,8 @@ { "RadArchProbe", "tree_pays", 96, 8 }, { "RadArchProbe", "gen_max_pixels", 104, 8 }, { "RadArchProbe", "gen_max_refs", 112, 8 }, -{ "RadArgs", "", 0, 64 }, +{ "RadArchProbe", "gen_shape", 120, 4 }, +{ "RadArgs", "", 0, 72 }, { "RadArgs", "t", 0, 8 }, { "RadArgs", "n_t", 8, 4 }, { "RadArgs", "p", 16, 8 }, @@ -32,7 +33,9 @@ { "RadArgs", "instance", 48, 8 }, { "RadArgs", "rank", 56, 4 }, { "RadArgs", "world_size", 60, 4 }, -{ "RadBatch", "", 0, 408 }, +{ "RadArgs", "kv_used_max_h", 64, 4 }, +{ "RadArgs", "wgp_count", 68, 4 }, +{ "RadBatch", "", 0, 480 }, { "RadBatch", "phase", 0, 4 }, { "RadBatch", "step", 4, 4 }, { "RadBatch", "n_tok", 8, 8 }, @@ -89,6 +92,15 @@ { "RadBatch", "plugin_cu", 384, 8 }, { "RadBatch", "plugin_words_h", 392, 8 }, { "RadBatch", "plugin_cu_h", 400, 8 }, +{ "RadBatch", "sgen_b", 408, 8 }, +{ "RadBatch", "kv_used_max_h", 416, 8 }, +{ "RadBatch", "positions_h", 424, 8 }, +{ "RadBatch", "n_bidi", 432, 8 }, +{ "RadBatch", "bidi_row", 440, 8 }, +{ "RadBatch", "bidi_n", 448, 8 }, +{ "RadBatch", "bidi_seq", 456, 8 }, +{ "RadBatch", "bidi_used", 464, 8 }, +{ "RadBatch", "anchor_rows", 472, 8 }, { "RadBufDecl", "", 0, 80 }, { "RadBufDecl", "dtype", 0, 4 }, { "RadBufDecl", "rank", 4, 4 }, @@ -97,7 +109,7 @@ { "RadBufDecl", "domain", 60, 4 }, { "RadBufDecl", "derive", 64, 8 }, { "RadBufDecl", "kv", 72, 4 }, -{ "RadBuildCtx", "", 0, 200 }, +{ "RadBuildCtx", "", 0, 208 }, { "RadBuildCtx", "rank", 0, 4 }, { "RadBuildCtx", "world_size", 4, 4 }, { "RadBuildCtx", "max_tok", 8, 8 }, @@ -130,6 +142,7 @@ { "RadBuildCtx", "calib_tokens", 176, 8 }, { "RadBuildCtx", "gen_max_pixels", 184, 8 }, { "RadBuildCtx", "gen_max_refs", 192, 8 }, +{ "RadBuildCtx", "expert_file_tier", 200, 4 }, { "RadAudioGenBatch", "", 0, 344 }, { "RadAudioGenBatch", "n_lane", 0, 8 }, { "RadAudioGenBatch", "lane", 8, 8 }, @@ -485,7 +498,7 @@ { "RadGeneratorDecl", "chunk_bos", 364, 4 }, { "RadGeneratorDecl", "chunk_eos", 368, 4 }, { "RadGeneratorDecl", "cond_opts", 372, 4 }, -{ "RadKVGroupBatch", "", 0, 80 }, +{ "RadKVGroupBatch", "", 0, 88 }, { "RadKVGroupBatch", "group", 0, 4 }, { "RadKVGroupBatch", "slot_mapping", 8, 8 }, { "RadKVGroupBatch", "block_table", 16, 8 }, @@ -496,6 +509,7 @@ { "RadKVGroupBatch", "block_size", 56, 8 }, { "RadKVGroupBatch", "max_blocks", 64, 8 }, { "RadKVGroupBatch", "stream", 72, 8 }, +{ "RadKVGroupBatch", "seqused_h", 80, 8 }, { "RadKVGroupDecl", "", 0, 56 }, { "RadKVGroupDecl", "kind", 0, 4 }, { "RadKVGroupDecl", "dtype", 4, 4 }, @@ -514,7 +528,7 @@ { "RadKVStream", "host_layer_stride", 48, 8 }, { "RadKVStream", "slots", 56, 8 }, { "RadKVStream", "host_bytes", 64, 8 }, -{ "RadKernelInfo", "", 0, 168 }, +{ "RadKernelInfo", "", 0, 176 }, { "RadKernelInfo", "name", 0, 8 }, { "RadKernelInfo", "op", 8, 8 }, { "RadKernelInfo", "family", 16, 8 }, @@ -537,6 +551,7 @@ { "RadKernelInfo", "opd_shape", 144, 8 }, { "RadKernelInfo", "unrelayout", 152, 8 }, { "RadKernelInfo", "replaces", 160, 8 }, +{ "RadKernelInfo", "capabilities", 168, 8 }, { "RadLayout", "", 0, 80 }, { "RadLayout", "tag", 0, 8 }, { "RadLayout", "dtype", 8, 4 }, @@ -695,6 +710,44 @@ { "RadSampleParams", "mask_row", 84, 4 }, { "RadSampleParams", "flags", 88, 4 }, { "RadSampleParams", "dry_rep_limit", 92, 4 }, +{ "RadShapeGenBatch", "", 0, 112 }, +{ "RadShapeGenBatch", "lane", 0, 4 }, +{ "RadShapeGenBatch", "patches", 8, 8 }, +{ "RadShapeGenBatch", "step", 16, 4 }, +{ "RadShapeGenBatch", "n_steps", 20, 4 }, +{ "RadShapeGenBatch", "sigma", 24, 8 }, +{ "RadShapeGenBatch", "sigma_next", 32, 8 }, +{ "RadShapeGenBatch", "cfg", 40, 8 }, +{ "RadShapeGenBatch", "pair", 48, 8 }, +{ "RadShapeGenBatch", "lanes", 56, 8 }, +{ "RadShapeGenBatch", "flags", 64, 8 }, +{ "RadShapeGenBatch", "seed", 72, 8 }, +{ "RadShapeGenBatch", "lat_cu", 80, 8 }, +{ "RadShapeGenBatch", "n_query", 88, 8 }, +{ "RadShapeGenBatch", "query", 96, 8 }, +{ "RadShapeGenBatch", "query_cu", 104, 8 }, +{ "RadShapeGenDecl", "", 0, 200 }, +{ "RadShapeGenDecl", "name", 0, 8 }, +{ "RadShapeGenDecl", "canvas", 8, 8 }, +{ "RadShapeGenDecl", "border_ratio", 16, 8 }, +{ "RadShapeGenDecl", "enc_size", 24, 8 }, +{ "RadShapeGenDecl", "enc_patch", 32, 8 }, +{ "RadShapeGenDecl", "pix_mean", 40, 24 }, +{ "RadShapeGenDecl", "pix_std", 64, 24 }, +{ "RadShapeGenDecl", "latent_rows", 88, 8 }, +{ "RadShapeGenDecl", "latent_channels", 96, 8 }, +{ "RadShapeGenDecl", "step_rows", 104, 8 }, +{ "RadShapeGenDecl", "default_steps", 112, 8 }, +{ "RadShapeGenDecl", "max_steps", 120, 8 }, +{ "RadShapeGenDecl", "default_guidance", 128, 8 }, +{ "RadShapeGenDecl", "bounds", 136, 8 }, +{ "RadShapeGenDecl", "level", 144, 8 }, +{ "RadShapeGenDecl", "default_resolution", 152, 8 }, +{ "RadShapeGenDecl", "min_resolution", 160, 8 }, +{ "RadShapeGenDecl", "max_resolution", 168, 8 }, +{ "RadShapeGenDecl", "max_lanes", 176, 8 }, +{ "RadShapeGenDecl", "max_query", 184, 8 }, +{ "RadShapeGenDecl", "field_out", 192, 4 }, { "RadTensor", "", 0, 112 }, { "RadTensor", "data", 0, 8 }, { "RadTensor", "dtype", 8, 4 }, diff --git a/tests/abi_layout_test.cpp b/tests/abi_layout_test.cpp index 09a02672..ccb98c3c 100644 --- a/tests/abi_layout_test.cpp +++ b/tests/abi_layout_test.cpp @@ -8,7 +8,7 @@ * * Checked: a C translation unit (abi_c_test.c, strict C11) lays every struct out as C++ does; every * struct's listed fields account for its size, so the list in rad_abi_layout_rows.h is complete; and - * the layout agrees with the table below, taken at RAD_ABI_VERSION 32 and RAD_FORMAT_VER 2. Under + * the layout agrees with the table below, taken at RAD_ABI_VERSION 37 and RAD_FORMAT_VER 2. Under * those versions a listed field may not move or change size, an ABI struct may only grow by fields * past its old end, and an on-disk struct may not change at all. The table is a snapshot of the * headers: nothing else states the layout. When it disagrees the test prints the live table. @@ -59,8 +59,8 @@ std::vector cpp_rows() { }; } -/* The layout at RAD_ABI_VERSION 32 / RAD_FORMAT_VER 2 (see the file header). */ -constexpr uint32_t kTableAbi = 32, kTableFormat = 2; +/* The layout at RAD_ABI_VERSION 37 / RAD_FORMAT_VER 2 (see the file header). */ +constexpr uint32_t kTableAbi = 37, kTableFormat = 2; const AbiRow kTable[] = { #include "abi_layout_table.h" }; diff --git a/tests/advance_test.cpp b/tests/advance_test.cpp index 1093e947..24361d06 100644 --- a/tests/advance_test.cpp +++ b/tests/advance_test.cpp @@ -158,7 +158,7 @@ TEST(the_cards_acceptance_is_accept_greedy_and_the_end_of_generation_cut) { int32_t cards[Slab::kSeq]; for (int i = 0; i < Slab::kSeq; ++i) cards[i] = i; for (int i = Slab::kSeq - 1; i > 0; --i) std::swap(cards[i], cards[lcg(rng) % (i + 1)]); - struct Want { int card, rout, acc, tok, head; } want[4]; + struct Want { int card, rout, acc, tok, head, hrow; } want[4]; for (int i = 0; i < n_rows; ++i) { const int kind = (int)(lcg(rng) % 4); /* 0: mid-prefill, 1: last chunk, else decode */ const int n_spec = kind >= 2 ? (int)(lcg(rng) % 9) : 0; @@ -178,7 +178,7 @@ TEST(the_cards_acceptance_is_accept_greedy_and_the_end_of_generation_cut) { : 1 + (int32_t)(lcg(rng) % 3); if (rout >= 0) s.src[rout + j] = target[j]; } - want[i] = { cards[i], rout, -1, 0, 0 }; + want[i] = { cards[i], rout, -1, 0, 0, 0 }; if (rout >= 0) { int32_t out[9] = {}, acc = -1; CHECK_OK(accept_greedy(draft, n_spec, target, out, &acc)); @@ -188,6 +188,7 @@ TEST(the_cards_acceptance_is_accept_greedy_and_the_end_of_generation_cut) { want[i].acc = cut; want[i].tok = out[cut]; want[i].head = ctx + (rtok - k) + cut; + want[i].hrow = rtok + cut; /* the row of the last accepted position */ out_row += 1 + n_spec; } k += n_tok; @@ -202,7 +203,8 @@ TEST(the_cards_acceptance_is_accept_greedy_and_the_end_of_generation_cut) { ok = std::memcmp(&S, &untouched, sizeof S) == 0; } else { ok = S.acc == want[i].acc && S.tok[0] == want[i].tok && S.n_acc == want[i].acc + 1 && - S.head == want[i].head && S.ctx == want[i].head + 1; + S.head == want[i].head && S.ctx == want[i].head + 1 && + S.hrow == want[i].hrow; } if (!ok) { bad = 1; @@ -244,7 +246,7 @@ TEST(the_cards_tree_acceptance_is_accept_tree_and_the_end_of_generation_cut) { const int n_rows = 1 + (int)(lcg(rng) % 4); int k = 0, out_row = 0; - struct Want { int card, acc, tok, head; int32_t path[8]; } want[4]; + struct Want { int card, acc, tok, head, hrow; int32_t path[8]; } want[4]; for (int i = 0; i < n_rows; ++i) { const int n_spec = (int)(lcg(rng) % 9); const int n_tok = 1 + n_spec; @@ -270,7 +272,8 @@ TEST(the_cards_tree_acceptance_is_accept_tree_and_the_end_of_generation_cut) { const int32_t cut = accept_cut_at_eog(out, acc, is_eog); deep += cut >= 2; cut_cases += cut < acc; - want[i] = { i, cut, out[cut], ctx + cut, {} }; + /* the row of the last node on the accepted path: rows are nodes, in order */ + want[i] = { i, cut, out[cut], ctx + cut, rtok + (cut == 0 ? 0 : path[cut - 1]), {} }; std::memcpy(want[i].path, path, sizeof path); out_row += 1 + n_spec; k += n_tok; @@ -279,7 +282,8 @@ TEST(the_cards_tree_acceptance_is_accept_tree_and_the_end_of_generation_cut) { for (int i = 0; i < n_rows && !bad; ++i) { const StepSlot& S = s.st[want[i].card]; bool ok = S.acc == want[i].acc && S.tok[0] == want[i].tok && S.n_acc == want[i].acc + 1 && - S.head == want[i].head && S.ctx == want[i].head + 1 && S.npath == want[i].acc; + S.head == want[i].head && S.ctx == want[i].head + 1 && S.npath == want[i].acc && + S.hrow == want[i].hrow; for (int t = 0; ok && t < want[i].acc; ++t) ok = S.path[t] == want[i].path[t]; if (!ok) { bad = 1; diff --git a/tests/arch_fakes.h b/tests/arch_fakes.h index c30d3419..db4587cb 100644 --- a/tests/arch_fakes.h +++ b/tests/arch_fakes.h @@ -70,6 +70,7 @@ struct RecMap { int mode = 0; std::vector src; int concat_dim = 0; + std::vector src_index; /* RadNameMap::src_index, one per source */ }; struct RecKV { std::string name; RadKVGroupDecl d{}; bool zero = false; bool replicated = false; bool dense = false; }; @@ -99,6 +100,7 @@ struct RadBuilder { /* Ops the fake kernel hierarchy refuses, to drive the fused-op fallback; and ops no loaded * library declares (rad_op_declared), as without an optional library. */ std::set refuse; + std::set> refuse_dtype; /* (op, dtype) forms */ std::set undeclared; /* When set, the only ops any loaded library declares (a CPU-only engine's: libref's * vocabulary); every other op is undeclared. */ @@ -217,7 +219,10 @@ extern "C" rad_op rad_decl_op(RadBuilder* b, const char* op, const RadParam* par r.p.push_back(p); } for (int i = 0; i < n_weights; ++i) r.w.push_back(weights[i]); - r.resolved = b->refuse.count(r.op) == 0; + bool dtype_refused = false; + for (const auto& p : r.p) + if (p.key == "dtype" && b->refuse_dtype.count({r.op, p.sval})) dtype_refused = true; + r.resolved = b->refuse.count(r.op) == 0 && !dtype_refused; b->ops.push_back(r); /* Declare always completes. An unresolved op is RAD_NULL_HANDLE, an error only if the plugin * issues it (rad_builder.h). */ @@ -274,7 +279,10 @@ extern "C" int rad_decl_name_map(RadBuilder* b, const RadNameMap* m) { r.declared = m->declared; r.mode = m->mode; r.concat_dim = m->concat_dim; - for (int i = 0; i < m->n_src; ++i) r.src.push_back(m->src[i]); + for (int i = 0; i < m->n_src; ++i) { + r.src.push_back(m->src[i]); + r.src_index.push_back(m->src_index[i]); + } b->maps.push_back(r); return RAD_OK; } @@ -524,6 +532,7 @@ extern "C" int rad_step_fail(RadCtx* c, const char* what) { extern "C" const RadBatch* rad_batch(RadCtx* c) { return c->batch; } extern "C" int rad_rank(RadCtx* c) { return c->rank; } extern "C" int rad_world_size(RadCtx* c) { return c->world; } +extern "C" int rad_ctx_wgp_count(RadCtx*) { return 32; } /* The context itself, so a copy issued on the step's stream is recorded in it (rad_memcpy_async). */ extern "C" RadStream rad_stream(RadCtx* c) { return (RadStream)c; } extern "C" int rad_stream_sync(RadStream s) { (void)s; return RAD_OK; } diff --git a/tests/arch_test.cpp b/tests/arch_test.cpp index 96fcc005..f4e7c2db 100644 --- a/tests/arch_test.cpp +++ b/tests/arch_test.cpp @@ -1882,6 +1882,109 @@ RadModelMeta qwen4exp_meta() { } } /* namespace */ +TEST(qwen4exp_pass_key_reuses_only_proven_uniform_prefill_grids) { + RadModelMeta meta = qwen4exp_meta(); + RadBuildCtx build = build_ctx(0, 1); + build.max_tok = 64; build.max_seqs = 2; build.max_spec = 0; build.max_ctx = 65536; + RadBuilder graph; + REQUIRE_EQ(qwen4exp_fp8::declare(&graph, &meta, &build), RAD_OK); + rad_kvgroup kv_full = 0; + for (size_t i = 0; i < graph.kv_groups.size(); ++i) + if (graph.kv_groups[i].name.find("kv_attn") != std::string::npos) { + kv_full = (rad_kvgroup)(i + 1); + break; + } + REQUIRE(kv_full != 0); + + RadCtx ctx{}; + RadKVGroupBatch group{}; + group.group = kv_full; + RadBatch batch{}; + batch.phase = RAD_PHASE_PREFILL; + batch.n_tok = 64; batch.n_seq = 1; batch.max_q_len = 64; + /* The split law uses the declared launch context, not this rounded live-batch bound. */ + batch.max_ctx_len = 1024; batch.n_kv_groups = 1; batch.kv = &group; + int32_t used[1] = {2304}; + const uint64_t key6 = qwen4exp_fp8::pass_key(&ctx, &batch, used); + CHECK(key6 != 0); + used[0] = 2305; + CHECK_EQ(qwen4exp_fp8::pass_key(&ctx, &batch, used), key6); + used[0] = 3072; + CHECK(qwen4exp_fp8::pass_key(&ctx, &batch, used) != key6); + + /* Same rounded live bound, different exact grids under the launcher's model context. */ + used[0] = 896; + const uint64_t key_896 = qwen4exp_fp8::pass_key(&ctx, &batch, used); + used[0] = 1152; + CHECK(qwen4exp_fp8::pass_key(&ctx, &batch, used) != key_896); + + /* A shorter one-sequence chunk still proves q_len = n_tok; do not require the model max_tok. */ + used[0] = 2304; + batch.n_tok = 32; batch.max_q_len = 32; + const uint64_t key_chunk = qwen4exp_fp8::pass_key(&ctx, &batch, used); + CHECK(key_chunk != 0); + CHECK(key_chunk != key6); + batch.n_tok = 64; batch.max_q_len = 64; + + batch.phase = RAD_PHASE_MIXED; + CHECK_EQ(qwen4exp_fp8::pass_key(&ctx, &batch, used), (uint64_t)0); + batch.phase = RAD_PHASE_PREFILL; batch.draft_pass = 0; batch.n_seq = 2; + CHECK_EQ(qwen4exp_fp8::pass_key(&ctx, &batch, used), (uint64_t)0); + batch.n_seq = 1; used[0] = 0; + CHECK_EQ(qwen4exp_fp8::pass_key(&ctx, &batch, used), (uint64_t)0); +} + +/* Decode, verify and draft passes are recorded, keyed by the cap their live KV length puts on a + * split launcher (eight 48-key tiles a split, binding below 64 splits): one key within a level, another + * across it, the same past the last level, and none without a host summary or in a mixed pass. A pass + * left unkeyed (0) is issued op by op on every step (issue #402). */ +TEST(qwen4exp_pass_key_keys_decode_verify_and_draft_by_the_split_cap) { + RadModelMeta meta = qwen4exp_meta(); + RadBuildCtx build = build_ctx(0, 1); + build.max_tok = 64; build.max_seqs = 2; build.max_spec = 5; build.max_ctx = 65536; + RadBuilder graph; + REQUIRE_EQ(qwen4exp_fp8::declare(&graph, &meta, &build), RAD_OK); + rad_kvgroup kv_full = 0; + for (size_t i = 0; i < graph.kv_groups.size(); ++i) + if (graph.kv_groups[i].name.find("kv_attn") != std::string::npos) { + kv_full = (rad_kvgroup)(i + 1); + break; + } + REQUIRE(kv_full != 0); + + RadCtx ctx{}; + RadKVGroupBatch group{}; + group.group = kv_full; + RadBatch batch{}; + batch.phase = RAD_PHASE_DECODE; batch.n_spec = 5; + batch.n_tok = 6; batch.n_seq = 1; batch.max_q_len = 6; + batch.max_ctx_len = 1024; batch.n_kv_groups = 1; batch.kv = &group; + int32_t used[1] = {400}; /* 9 tiles: level 1 (337-720 keys) */ + const uint64_t verify1 = qwen4exp_fp8::pass_key(&ctx, &batch, used); + CHECK(verify1 != 0); + used[0] = 720; + CHECK_EQ(qwen4exp_fp8::pass_key(&ctx, &batch, used), verify1); + used[0] = 721; /* 16 tiles: level 2 */ + CHECK(qwen4exp_fp8::pass_key(&ctx, &batch, used) != verify1); + used[0] = 300; /* 7 tiles: level 0 */ + CHECK(qwen4exp_fp8::pass_key(&ctx, &batch, used) != verify1); + used[0] = 30000; /* past 64 splits' 24,576 keys: one key */ + const uint64_t verify_long = qwen4exp_fp8::pass_key(&ctx, &batch, used); + used[0] = 60000; + CHECK_EQ(qwen4exp_fp8::pass_key(&ctx, &batch, used), verify_long); + + used[0] = 400; + batch.n_spec = 0; batch.n_tok = 1; batch.max_q_len = 1; + CHECK(qwen4exp_fp8::pass_key(&ctx, &batch, used) != 0); /* plain decode */ + batch.draft_pass = -1; + CHECK(qwen4exp_fp8::pass_key(&ctx, &batch, used) != 0); /* the MTP head's draft pass */ + + used[0] = 0; + CHECK_EQ(qwen4exp_fp8::pass_key(&ctx, &batch, used), (uint64_t)0); + used[0] = 400; batch.draft_pass = 0; batch.phase = RAD_PHASE_MIXED; + CHECK_EQ(qwen4exp_fp8::pass_key(&ctx, &batch, used), (uint64_t)0); +} + TEST(qwen4exp_yarn_reaches_attention_indexer_and_compressed_keys) { RadModelMeta meta = qwen4exp_meta(); std::vector keys(meta.kv_key, meta.kv_key + meta.n_kv); @@ -4950,6 +5053,130 @@ TEST(the_gemma4_31b_form_reads_asymmetric_int4_and_int5_linears) { } } +/* Gemma 4 12B (`gemma4_unified`, served here through the arch id's alias) on the same twelve + * layers: width 3840, 16 query heads over 8 sliding KV heads and ONE global KV head, its layer + * schedule from layer_types. */ +const char* k_gem12_keys[] = { + "model_type", "sliding_window", "global_head_dim", "num_global_key_value_heads", + "rope_parameters.sliding_attention.rope_theta", "rope_parameters.full_attention.rope_theta", + "rope_parameters.full_attention.partial_rotary_factor", "num_kv_shared_layers", + "final_logit_softcapping", "attention_k_eq_v", "hidden_size_per_layer_input", "layer_types", +}; +const char* k_gem12_vals[] = { + "gemma4_unified", "1024", "512", "1", "10000", "1000000", "0.25", "0", "30", "1", "0", + "sliding_attention sliding_attention sliding_attention sliding_attention sliding_attention " + "full_attention sliding_attention sliding_attention sliding_attention sliding_attention " + "sliding_attention full_attention", +}; + +RadModelMeta gemma4_12b_meta() { + RadModelMeta m = gemma4_meta(); + m.name = "test-gemma4-12b-form"; + m.n_embd = 3840; + m.n_head = 16; + m.n_head_kv = 8; + m.n_ff = 15360; + m.n_kv = (int)(sizeof(k_gem12_keys) / sizeof(k_gem12_keys[0])); + m.kv_key = k_gem12_keys; + m.kv_val = k_gem12_vals; + return m; +} + +/* At one rank the global class is 16 q heads over one KV head (gqa 16). At two and four the + * sliding heads split (4 and 2 a rank, gqa 2) and the global head is replicated: each rank keeps + * a share of the q heads (gqa 8 and 4) and the whole k row (rows 0..511), as one span or as the k + * part of a fused q|k. Each layer's attention reads its own cache in its class's group, and a + * step reduces the lookup and two a layer. */ +TEST(the_gemma4_12b_form_declares_and_steps_at_one_two_and_four_ranks) { + const int64_t L = 12, hs = 256, hg = 512; + for (bool fused : { false, true }) { + for (int world : { 1, 2, 4 }) { + for (int rank = 0; rank < world; ++rank) { + RadBuilder b; + if (fused) { + const RadEncoding e = rad_enc_affine(RAD_I4, RAD_F16, 1, 128); + b.encs = { { "attn_qkv.", e }, { "attn_o.", e }, { "ffn_gate_up.", e }, + { "ffn_down.", e } }; + } + RadModelMeta meta = gemma4_12b_meta(); + RadBuildCtx ctx = build_ctx(rank, world); + CHECK_OK(gemma4_bf16::declare(&b, &meta, &ctx)); + CHECK_EQ(gemma4_bf16::g_model[rank].fuse, fused); + REQUIRE_EQ((int)b.kv_groups.size(), 2); + CHECK_EQ(b.kv_groups[0].d.n_head_kv, 8 / world); + CHECK_EQ(b.kv_groups[0].d.head_dim, hs); + CHECK_EQ(b.kv_groups[1].d.n_head_kv, 1); + CHECK_EQ(b.kv_groups[1].d.head_dim, hg); + const int64_t nq = 16 / world; + if (!fused) { + const RecOp* as = find_op(b, "attn_paged", 0); + const RecOp* ag = find_op(b, "attn_paged", 5); + REQUIRE(as != nullptr && ag != nullptr); + CHECK_EQ(pint(as, "head_dim"), hs); + CHECK_EQ(pint(as, "n_head"), nq); + CHECK_EQ(pint(as, "gqa"), 2); + CHECK_EQ(pint(as, "window"), 1024); + CHECK_EQ(pint(ag, "head_dim"), hg); + CHECK_EQ(pint(ag, "n_head"), nq); + CHECK_EQ(pint(ag, "gqa"), 16 / world); + CHECK_EQ(pint(ag, "window"), 0); + const RecWeight* q0 = find_w(b, "blk.0.attn_q.weight"); + const RecWeight* k0 = find_w(b, "blk.0.attn_k.weight"); + const RecWeight* q5 = find_w(b, "blk.5.attn_q.weight"); + const RecWeight* k5 = find_w(b, "blk.5.attn_k.weight"); + REQUIRE(q0 && k0 && q5 && k5); + CHECK_EQ(q0->d.shape[0], nq * hs); CHECK_EQ(q0->d.shape[1], 3840); + CHECK_EQ(k0->d.shape[0], (8 / world) * hs); + CHECK_EQ(q5->d.shape[0], nq * hg); + CHECK_EQ(k5->d.shape[0], hg); + CHECK(find_w(b, "blk.5.attn_v.weight") == nullptr); /* k == v */ + CHECK(!k0->span_set); /* an even share */ + CHECK_EQ(k5->span_set, world > 1); + if (world > 1) { CHECK_EQ(k5->span_lo, 0); CHECK_EQ(k5->span_hi, hg); } + } else { + const RecWeight* s0 = find_w(b, "blk.0.attn_qkv.weight"); + REQUIRE(s0 != nullptr); + CHECK_EQ(s0->n_part_spans, 0); /* even shares */ + for (const char* v : { "weight", "scale" }) { + const RecWeight* w = find_w(b, std::string("blk.5.attn_qkv.") + v); + REQUIRE(w != nullptr); + if (world == 1) { CHECK_EQ(w->n_part_spans, 0); continue; } + REQUIRE_EQ(w->n_part_spans, 2); /* q and k, no v */ + CHECK_EQ(w->part_lo[0], rank * nq * hg); + CHECK_EQ(w->part_hi[0], (rank + 1) * nq * hg); + CHECK_EQ(w->part_total[0], 16 * hg); + CHECK_EQ(w->part_lo[1], 0); + CHECK_EQ(w->part_hi[1], hg); + CHECK_EQ(w->part_total[1], hg); + } + } + + RadBatch batch = decode_batch(); + RadCtx c; c.b = &b; c.rank = rank; c.world = world; c.batch = &batch; + gemma4_bf16::step(&c, &batch); + CHECK_LINT(b, &c); + CHECK(c.step_fail.empty()); + std::vector> kv; + for (const auto& i : c.issues) { + const RecOp* o = b.op_of(i.op); + if (!o || (o->op != "attn_paged" && o->op != "attn_paged_qrow")) continue; + REQUIRE(i.opd.size() > 1); + CHECK_EQ((int)i.opd[1].kind, (int)RAD_OPK_KV); + kv.push_back({ (int)i.opd[1].handle, (int64_t)i.opd[1].offset }); + } + REQUIRE_EQ((int)kv.size(), (int)L); + for (int l = 0; l < (int)L; ++l) { + CHECK_EQ(kv[(size_t)l].first, (l % 6 == 5) ? 2 : 1); + CHECK_EQ(kv[(size_t)l].second, (int64_t)l); + } + const std::vector ops = issued_ops(b, c); + CHECK_EQ(count_issued(ops, "all_reduce") + count_issued(ops, "ar_rmsnorm_quant_i8"), + world > 1 ? (int)(1 + 2 * L) : 0); + } + } + } +} + TEST(gemma4_attention_shapes_for_both_classes) { RadBuilder b; RadModelMeta meta = gemma4_meta(); @@ -5486,6 +5713,104 @@ TEST(gemma4_probe_names_the_heads_operating_depth) { CHECK_EQ(q.draft_depth, 0); } +/* The 12B's assistant: the same head under the name Gemma4UnifiedAssistantForCausalLM, width + * 1024 over a 3840 trunk, 16 q heads over the trunk's 8 sliding and one global KV head. */ +const char* k_gem12d_keys[] = { + "model_type", "sliding_window", "global_head_dim", "num_global_key_value_heads", + "rope_parameters.sliding_attention.rope_theta", "rope_parameters.full_attention.rope_theta", + "rope_parameters.full_attention.partial_rotary_factor", "num_kv_shared_layers", + "final_logit_softcapping", "attention_k_eq_v", "hidden_size_per_layer_input", "layer_types", + "draft.architectures", "draft.backbone_hidden_size", "draft.use_ordered_embeddings", + "draft.text_config.hidden_size", "draft.text_config.num_hidden_layers", + "draft.text_config.layer_types", "draft.text_config.num_attention_heads", + "draft.text_config.num_key_value_heads", "draft.text_config.num_global_key_value_heads", + "draft.text_config.head_dim", "draft.text_config.global_head_dim", + "draft.text_config.intermediate_size", "draft.text_config.sliding_window", + "draft.text_config.vocab_size", "draft.text_config.rms_norm_eps", + "draft.text_config.rope_parameters.sliding_attention.rope_theta", + "draft.text_config.rope_parameters.full_attention.rope_theta", + "draft.text_config.rope_parameters.full_attention.partial_rotary_factor", +}; +std::vector gem12d_vals() { + std::vector v(std::begin(k_gem12_vals), std::end(k_gem12_vals)); + for (const char* s : { "Gemma4UnifiedAssistantForCausalLM", "3840", "0", "1024", "4", + "sliding_attention sliding_attention sliding_attention full_attention", + "16", "8", "1", "256", "512", "8192", "1024", "262144", "1e-06", "10000", + "1000000", "0.25" }) + v.push_back(s); + return v; +} + +/* Declared at one, two and four ranks: the head's full layer is gqa 16, 8 and 4 over the trunk's + * one (replicated) global KV head, its sliding layers gqa 2. A pass reads layers 10 and 11. A head + * stating another global KV count than the trunk's is still refused. */ +TEST(the_gemma4_12b_assistant_is_declared_at_one_two_and_four_ranks) { + const std::vector vals = gem12d_vals(); + REQUIRE_EQ(vals.size(), sizeof(k_gem12d_keys) / sizeof(k_gem12d_keys[0])); + for (int world : { 1, 2, 4 }) { + for (int rank : { 0, world - 1 }) { + RadBuilder b; + RadModelMeta meta = gemma4_12b_meta(); + meta.n_kv = (int)vals.size(); meta.kv_key = k_gem12d_keys; meta.kv_val = vals.data(); + RadBuildCtx ctx = build_ctx(rank, world); + ctx.max_spec = 3; + CHECK_OK(gemma4_bf16::declare(&b, &meta, &ctx)); + CHECK_EQ((int)b.drafter.kind, (int)RAD_DRAFT_SERIAL); + CHECK_EQ(b.drafter.depth, 3); + CHECK_EQ(count_op(b, "attn_paged"), 16); + const int64_t nq = 16 / world; + for (int l = 0; l < 4; ++l) { + const RecOp* at = find_op(b, "attn_paged", 12 + l); + REQUIRE(at != nullptr); + CHECK_EQ(pint(at, "n_head"), nq); + CHECK_EQ(pint(at, "head_dim"), l == 3 ? 512 : 256); + CHECK_EQ(pint(at, "gqa"), l == 3 ? nq : 2); + } + const RecWeight* wq3 = find_w(b, "mtp.blk.3.attn_q.weight"); + const RecWeight* pre = find_w(b, "mtp.pre_proj.weight"); + const RecWeight* post = find_w(b, "mtp.post_proj.weight"); + REQUIRE(wq3 && pre && post); + CHECK_EQ(wq3->d.shape[0], nq * 512); CHECK_EQ(wq3->d.shape[1], 1024); + CHECK_EQ(pre->d.shape[0], 1024); CHECK_EQ(pre->d.shape[1], 2 * 3840); + CHECK_EQ(post->d.shape[0], 3840); CHECK_EQ(post->d.shape[1], 1024); + const RecMap* mpre = find_map(b, "mtp.pre_proj.weight"); + REQUIRE(mpre != nullptr); + CHECK_EQ(mpre->src[0], std::string("draft.pre_projection.weight")); + + RadBatch batch = head_batch(-1); + RadCtx c; c.b = &b; c.rank = rank; c.world = world; c.batch = &batch; + gemma4_bf16::step(&c, &batch); + CHECK(c.step_fail.empty()); + int seen = 0; + for (const auto& i : c.issues) { + const RecOp* o = b.op_of(i.op); + if (!o || o->op != "attn_paged") continue; + REQUIRE(i.opd.size() > 1); + CHECK_EQ((int)i.opd[1].handle, seen < 3 ? 1 : 2); + CHECK_EQ((long long)i.opd[1].offset, seen < 3 ? 10LL : 11LL); + ++seen; + } + CHECK_EQ(seen, 4); + } + } + std::vector two = gem12d_vals(); + two[20] = "2"; /* draft.text_config.num_global_key_value_heads */ + for (int world : { 1, 2 }) { + RadBuilder b; + RadModelMeta meta = gemma4_12b_meta(); + meta.n_kv = (int)two.size(); meta.kv_key = k_gem12d_keys; meta.kv_val = two.data(); + RadBuildCtx ctx = build_ctx(0, world); + ctx.max_spec = 3; + CHECK_EQ(stderr_of_rc([&] { return gemma4_bf16::declare(&b, &meta, &ctx); }), + (int)RAD_E_INVAL); + } + RadArchProbe p{}; + RadModelMeta with = gemma4_12b_meta(); + with.n_kv = (int)vals.size(); with.kv_key = k_gem12d_keys; with.kv_val = vals.data(); + CHECK_OK(gemma4_bf16::probe(&with, &p)); + CHECK_EQ(p.draft_depth, gemma4_bf16::kHeadDepth); +} + /* ===================== gemma4: the 26B-A4B, a dense and a routed arm side by side ===================== */ namespace { @@ -7734,7 +8059,11 @@ TEST(gemma4_31b_dflash2_fc_splits_by_rows_without_changing_a_bit) { } if (o.op == "all_gather" && pint(&o, "row") == cs.share) { ++fc_gathers; - CHECK_EQ(pint(&o, "numel"), (long long)(2048 * E)); /* the trunk's instance */ + /* The trunk's instance, and a range: a sizing declare may not change it. */ + const RecParam* ne = param(&o, "numel"); + REQUIRE(ne != nullptr); + CHECK_EQ(ne->kind, (int)RAD_P_RANGE); + CHECK_EQ(ne->ihi, (long long)(2048 * E)); CHECK_EQ(pint(&o, "world_size"), (long long)cs.world); } } @@ -9421,9 +9750,11 @@ int w8a8_declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* ctx } /* namespace */ -/* The `_had_quant_i8g` producers, which libr4d serves and libref does not. */ +/* The `_had_quant_i8g` producers and the ops that write those codes in their epilogue (the + * attention gate's, the delta net's decode conv fold's), which libr4d serves and libref does not. */ const char* const kW8a8Fused[] = { "rmsnorm_had_quant_i8g", "ar_rmsnorm_had_quant_i8g", - "gated_had_quant_i8g" }; + "gated_had_quant_i8g", "gate_had_quant_i8g", + "gdn_conv_recurrent_update_had" }; /* Where the `_had_quant_i8g` producers are not served, every trunk linear of a rotated int8 * container is an i8a8h GEMM right behind its own had_quant_act_i8g, at one rank and two: 2 @@ -9458,11 +9789,13 @@ TEST(qwen35_w8a8_serves_every_trunk_linear_rotated_int8) { } } -/* Where they are served, the norms and the gated product write had_quant_act_i8g's codes into the - * int8 pair, and the projections reading them declare no quantiser: had_quant_act_i8g is left only - * before the attention and delta-net output projections (2 + 6), every norm is the rotated twin (at - * two ranks with its fused all-reduce form beside it), and every feed-forward's product is - * gated_had_quant_i8g. No E4M3 norm or gated quantiser is left, and the 36 GEMMs are unchanged. */ +/* Where they are served, the norms, the gated product, the attention gate and the delta net's + * decode conv fold write had_quant_act_i8g's codes into the int8 pair, and the projections reading + * them declare no quantiser: had_quant_act_i8g is left only as the delta net's quantiser of the + * rows its decode fold does not serve (6), every norm is the rotated twin (at two ranks with its + * fused all-reduce form beside it), every feed-forward's product is gated_had_quant_i8g and every + * attention gate gate_had_quant_i8g. No E4M3 norm or gated quantiser is left, and the 36 GEMMs are + * unchanged. */ TEST(qwen35_w8a8_feeds_its_rotated_codes_from_the_producers_where_libr4d_serves_them) { MetaKV mk = q35w8a8_meta(); for (int world : { 1, 2 }) { @@ -9473,9 +9806,11 @@ TEST(qwen35_w8a8_feeds_its_rotated_codes_from_the_producers_where_libr4d_serves_ int rot = 0; for (const RecOp& o : b.ops) rot += o.op == "gemm_nt_q" && pstr(&o, "dtype") == "i8a8h"; CHECK_EQ(rot, 2 * 4 + 6 * 2 + 8 * 2); - CHECK_EQ(count_op(b, "had_quant_act_i8g"), 2 + 6); + CHECK_EQ(count_op(b, "had_quant_act_i8g"), 6); CHECK_EQ(count_op(b, "rmsnorm_had_quant_i8g"), 8 + 8); CHECK_EQ(count_op(b, "gated_had_quant_i8g"), 8); + CHECK_EQ(count_op(b, "gate_had_quant_i8g"), 2); + CHECK_EQ(count_op(b, "gdn_conv_recurrent_update_had"), 6); for (const char* op : { "rmsnorm_quant_fp8", "ar_rmsnorm_quant_fp8", "gated_quant_fp8", "quant_act_i8g" }) CHECK_EQ(count_op(b, op), 0); @@ -10358,6 +10693,232 @@ TEST(nomicbert_probe_reads_the_model_type) { RAD_E_UNSUPPORTED); } +/* Gemma 4 12B's media embedders (rad_block_gemma4_unified.h) in place of the tower and the + * conformer: a picture patch is a 48 x 48 window and an audio frame 640 samples, each one row. The + * position table [npos, 2, width] is read as its taps 0 (column) and 1 (row) of dimension 1; a + * vision pass is LayerNorm, the dense with its bias, LayerNorm, the two position rows (the column + * from coordinate plane 1, the row from plane 0) added in, LayerNorm (eps 1e-5, no config states it), + * the weightless RMS norm and the projection; an audio pass the norm and its projection. Every rank + * runs both whole and both lint clean; the probe says one patch a row and 750 frames. */ +TEST(the_gemma4_12b_embeds_images_and_audio_without_an_encoder) { + std::vector keys(std::begin(k_gem12_keys), std::end(k_gem12_keys)); + std::vector vals(std::begin(k_gem12_vals), std::end(k_gem12_vals)); + const char* mk[] = { "vision_config.model_type", "vision_config.mm_embed_dim", + "vision_config.mm_posemb_size", "vision_config.model_patch_size", + "vision_config.output_proj_dims", "vision_config.rms_norm_eps", + "vision_config.patch_size", "vision_config.pooling_kernel_size", + "audio_config.model_type", "audio_config.audio_embed_dim", + "audio_config.rms_norm_eps", "processor.feature_extractor.sampling_rate", + "processor.feature_extractor.audio_samples_per_token", + "processor.audio_seq_length" }; + const char* mv[] = { "gemma4_unified_vision", "3840", "1120", "48", "3840", "1e-06", "16", "3", + "gemma4_unified_audio", "640", "1e-06", "16000", "640", "750" }; + keys.insert(keys.end(), std::begin(mk), std::end(mk)); + vals.insert(vals.end(), std::begin(mv), std::end(mv)); + RadModelMeta meta = gemma4_12b_meta(); + meta.n_kv = (int)keys.size(); meta.kv_key = keys.data(); meta.kv_val = vals.data(); + + RadArchProbe pr{}; + REQUIRE_EQ(gemma4_bf16::probe(&meta, &pr), RAD_OK); + CHECK_EQ(pr.enc_merge, 1); + CHECK_EQ(pr.audio_frames, 750); + + for (int world : { 1, 2, 4 }) { + for (int rank = 0; rank < world; ++rank) { + RadBuilder b; + RadBuildCtx ctx = build_ctx(rank, world); + ctx.max_enc_patches = 1120; + ctx.max_audio_frames = 750; + REQUIRE_EQ(gemma4_bf16::declare(&b, &meta, &ctx), RAD_OK); + CHECK_EQ(b.encoder_name, std::string("vision")); + CHECK_EQ(b.encoder.patch_dim, 6912); + CHECK_EQ(b.encoder.merge, 1); + CHECK_EQ(b.encoder.max_patches, 1120); + CHECK_EQ(b.encoder.n_embd, 3840); + CHECK_EQ(b.audio_encoder_name, std::string("audio")); + CHECK_EQ(b.audio_encoder.patch_dim, 640); + CHECK_EQ(b.audio_encoder.merge, 1); + CHECK_EQ(b.audio_encoder.max_patches, 750); + CHECK_EQ(count_op(b, "scatter_rows"), 1); + for (int t = 0; t < 2; ++t) { + const RecMap* pos = find_map(b, t ? "v.pos_y.weight" : "v.pos_x.weight"); + REQUIRE(pos != nullptr); + CHECK_EQ(pos->mode, (int)RAD_MAP_TAP); + CHECK_EQ(pos->concat_dim, 1); + CHECK(pos->src == std::vector{ "model.vision_embedder.pos_embedding" }); + REQUIRE_EQ(pos->src_index.size(), (size_t)1); + CHECK_EQ(pos->src_index[0], t); + const RecWeight* w = find_w(b, t ? "v.pos_y.weight" : "v.pos_x.weight"); + REQUIRE(w != nullptr); + CHECK_EQ(w->d.shape[0], 1120); + CHECK_EQ(w->d.shape[1], 3840); + } + const struct { const char* d; const char* s; } src[] = { + { "v.ln1.weight", "model.vision_embedder.patch_ln1.weight" }, + { "v.ln1.bias", "model.vision_embedder.patch_ln1.bias" }, + { "v.in.weight", "model.vision_embedder.patch_dense.weight" }, + { "v.in.bias", "model.vision_embedder.patch_dense.bias" }, + { "v.ln2.weight", "model.vision_embedder.patch_ln2.weight" }, + { "v.ln2.bias", "model.vision_embedder.patch_ln2.bias" }, + { "v.pn.weight", "model.vision_embedder.pos_norm.weight" }, + { "v.pn.bias", "model.vision_embedder.pos_norm.bias" }, + { "v.embed.weight", "model.embed_vision.embedding_projection.weight" }, + { "a.embed.weight", "model.embed_audio.embedding_projection.weight" } }; + for (const auto& e : src) { + const RecMap* mp = find_map(b, e.d); + REQUIRE(mp != nullptr); + CHECK(mp->src == std::vector{ e.s }); + CHECK(find_w(b, e.d) != nullptr); + } + const RecWeight* dense = find_w(b, "v.in.weight"); + REQUIRE(dense != nullptr); + CHECK_EQ(dense->d.shape[0], 3840); + CHECK_EQ(dense->d.shape[1], 6912); + CHECK_EQ(dense->d.shard, (int)RAD_SHARD_NONE); + CHECK(find_w(b, "v.blk.0.qkv") == nullptr); /* no tower */ + for (const auto& o : b.ops) + if (o.op == "layernorm") CHECK_NEAR(pflt(&o, "eps"), 1e-5, 0.0); + + const auto vis = enc_pass(RAD_MM_IMAGE, 280, 6912); + RadCtx cv{ .b = &b, .batch = &vis->b }; + cv.rank = rank; cv.world = world; + gemma4_bf16::step(&cv, &vis->b); + CHECK(cv.step_fail.empty()); + CHECK_LINT(b, &cv); + const std::vector want = { "layernorm", "gemm_nt_bias", "layernorm", + "embed_lookup", "embed_lookup", "add", "add", + "layernorm", "rmsnorm", "gemm_nt" }; + CHECK_EQ(join(issued_ops(b, cv)), join(want)); + REQUIRE_EQ(cv.issues.size(), want.size()); + CHECK(cv.issues[0].opd[0].raw == vis->pix.data()); + CHECK(cv.issues[3].opd[0].raw == vis->coord.data() + 280); /* the column */ + CHECK(cv.issues[4].opd[0].raw == vis->coord.data()); /* the row */ + CHECK_EQ(cv.issues[3].opd[1].handle, (uint32_t)gemma4_bf16::g_model[rank].uvis.w_px); + CHECK_EQ(cv.issues[4].opd[1].handle, (uint32_t)gemma4_bf16::g_model[rank].uvis.w_py); + CHECK_EQ(cv.issues.back().n, 280); + CHECK_EQ(cv.issues.back().opd.back().handle, b.encoder.out); + + const auto aud = enc_pass(RAD_MM_AUDIO, 125, 640); + RadCtx ca{ .b = &b, .batch = &aud->b }; + ca.rank = rank; ca.world = world; + gemma4_bf16::step(&ca, &aud->b); + CHECK(ca.step_fail.empty()); + CHECK_LINT(b, &ca); + CHECK_EQ(join(issued_ops(b, ca)), join({ "rmsnorm", "gemm_nt" })); + CHECK_EQ(ca.issues.back().n, 125); + CHECK_EQ(ca.issues.back().opd.back().handle, b.audio_encoder.out); + + /* More patches than declared is refused, issuing nothing. */ + const auto big = enc_pass(RAD_MM_IMAGE, 1121, 6912); + RadCtx cb{ .b = &b, .batch = &big->b }; + gemma4_bf16::step(&cb, &big->b); + CHECK(!cb.step_fail.empty()); + CHECK(cb.issues.empty()); + } + } +} + +/* The 12B (and the 31B) read a picture's placeholders both ways (use_bidirectional_attention + * "vision") on the sliding layers; the global layers stay causal, as transformers' Gemma 4 masks + * and KerasHub's have it. Every sliding layer declares a second attention without the causal + * bound (its window two-sided), the encoder says so to the core (RadEncoderDecl::bidirectional), + * and on a pass with a run (RadBatch::n_bidi) each sliding layer attends the run's rows again over + * their sequence's cache up to the run's end, written over the causal result in the same rows. + * Without the config key, nothing of it. */ +TEST(the_gemma4_12b_reads_a_pictures_rows_both_ways) { + std::vector keys(std::begin(k_gem12_keys), std::end(k_gem12_keys)); + std::vector vals(std::begin(k_gem12_vals), std::end(k_gem12_vals)); + const char* mk[] = { "vision_config.model_type", "vision_config.mm_embed_dim", + "vision_config.mm_posemb_size", "vision_config.model_patch_size", + "use_bidirectional_attention" }; + const char* mv[] = { "gemma4_unified_vision", "3840", "1120", "48", "vision" }; + keys.insert(keys.end(), std::begin(mk), std::end(mk)); + vals.insert(vals.end(), std::begin(mv), std::end(mv)); + static const int32_t row[] = { 40 }, seq[] = { 1 }, used[] = { 30 }; + const int64_t L_sliding = 10; /* layers 5 and 11 are global */ + /* A run of 10 rows within the window, and one longer than a window of 8, whose rows read the + * keys behind them only through the window (attn_paged_ahead). */ + const int32_t run = 10; + static const int32_t rows[] = { run }; + for (const int win : { 1024, 8 }) + for (int mode = 0; mode < 2; ++mode) { /* 0 on, 1 no key */ + std::vector wvals = vals; + for (size_t k = 0; k < keys.size(); ++k) + if (!std::strcmp(keys[k], "sliding_window")) wvals[k] = win == 8 ? "8" : "1024"; + for (bool fused : { false, true }) { + for (int world : { 1, 2 }) { + for (int rank = 0; rank < world; ++rank) { + RadBuilder b; + if (fused) { + const RadEncoding e = rad_enc_affine(RAD_I4, RAD_F16, 1, 128); + b.encs = { { "attn_qkv.", e }, { "attn_o.", e }, { "ffn_gate_up.", e }, + { "ffn_down.", e } }; + } + RadModelMeta meta = gemma4_12b_meta(); + meta.n_kv = (int)keys.size() - (mode == 1 ? 1 : 0); + meta.kv_key = keys.data(); meta.kv_val = wvals.data(); + RadBuildCtx ctx = build_ctx(rank, world); + ctx.max_enc_patches = 1120; + const int rc = gemma4_bf16::declare(&b, &meta, &ctx); + REQUIRE_EQ(rc, RAD_OK); + const bool on = mode == 0; + CHECK_EQ(b.encoder.bidirectional, on ? 1 : 0); + int nc = 0; + for (const auto& o : b.ops) + if ((o.op == "attn_paged" || o.op == "attn_paged_qrow") && pint(&o, "causal") == 0) { + ++nc; + CHECK_EQ(pint(&o, "window"), win); + CHECK_EQ(pint(&o, "head_dim"), 256); + } + CHECK_EQ(nc, on ? (int)L_sliding : 0); + int na = 0; + for (const auto& o : b.ops) + if (o.op == "attn_paged_ahead" || o.op == "attn_paged_qrow_ahead") { + ++na; + CHECK_EQ(pint(&o, "causal"), 0); + CHECK_EQ(pint(&o, "window"), win); + } + CHECK_EQ(na, on ? (int)L_sliding : 0); + + RadBatch batch = prefill_batch(); + batch.n_bidi = 1; + batch.bidi_row = row; batch.bidi_n = rows; batch.bidi_seq = seq; + batch.bidi_used = used; + RadCtx c; c.b = &b; c.rank = rank; c.world = world; c.batch = &batch; + gemma4_bf16::step(&c, &batch); + CHECK_LINT(b, &c); + CHECK(c.step_fail.empty()); + int again = 0; + rad_op last_attn = 0; + for (const auto& i : c.issues) { + const RecOp* o = b.op_of(i.op); + if (!o || (o->op != "attn_paged" && o->op != "attn_paged_qrow" && + o->op != "attn_paged_ahead" && o->op != "attn_paged_qrow_ahead")) + continue; + if (pint(o, "causal") == 1) { last_attn = i.op; continue; } + ++again; + CHECK(last_attn != 0); /* behind the causal pass */ + const bool ahead = o->op.size() > 6 && o->op.compare(o->op.size() - 6, 6, "_ahead") == 0; + CHECK_EQ(ahead, run > win); + CHECK_EQ(i.n, run); + REQUIRE(i.opd.size() == 8); + CHECK_EQ((int)i.opd[1].kind, (int)RAD_OPK_KV); + CHECK(i.opd[3].raw == used); + CHECK_EQ(i.opd[3].rows, 1); + CHECK_EQ(i.opd[2].rows, 1); /* the run's sequence's table */ + CHECK(i.opd[6].kind == RAD_OPK_NONE); + const int64_t qd = (16 / world) * (pint(o, "head_dim")); + CHECK_EQ(i.opd[7].offset, 40 * qd); /* its rows of the output */ + CHECK_EQ(i.opd[7].rows, run); + last_attn = 0; + } + CHECK_EQ(again, on ? (int)L_sliding : 0); + } + } + } + } +} + /* ==================================================================== qwenimage21 */ namespace { @@ -11012,22 +11573,22 @@ struct ArchCases { qwen35_bf16::step, 0, {}, 0xf82117051023e608ull); add("qwen35_fp8 + MTP", [this, sc](RadBuilder* b) { auto c = sc(1, 3); return qwen35_fp8::declare(b, q35.meta(), &c); }, - qwen35_fp8::step, 3, {}, 0x20ab9ed24e409329ull); + qwen35_fp8::step, 3, {}, 0x958b83102809266bull); add("qwen35_fp8 + MTP, two ranks", [this, sc](RadBuilder* b) { auto c = sc(2, 3); return qwen35_fp8::declare(b, q35.meta(), &c); }, - nullptr, 3, { "ar_rmsnorm_quant_fp8" }, 0x5b52afb1706a954eull); + nullptr, 3, { "ar_rmsnorm_quant_fp8" }, 0x91408682a38a1754ull); add("qwen35_fp8 + DFlash2", [this, sc](RadBuilder* b) { auto c = sc(1, 7); return qwen35_fp8::declare(b, q35df.meta(), &c); }, - qwen35_fp8::step, 7, {}, 0x365e4cbb415ac284ull); + qwen35_fp8::step, 7, {}, 0x60d33ded99aa451eull); add("qwen35_w8a8 + DFlash2", [this, sc](RadBuilder* b) { auto c = sc(1, 7); return w8a8_declare(b, q35w8df.meta(), &c); }, - qwen35_w8a8::step, 7, {}, 0x742a596708bbda1dull); + qwen35_w8a8::step, 7, {}, 0x570d3bc8fc15f701ull); add("qwen35_w8a8 + DFlash2, two ranks", [this, sc](RadBuilder* b) { auto c = sc(2, 7); return w8a8_declare(b, q35w8df.meta(), &c); }, - nullptr, 7, { "ar_rmsnorm_quant_fp8" }, 0x93b6390d30e59953ull); + nullptr, 7, { "ar_rmsnorm_quant_fp8" }, 0x6c5267846652829full); add("qwen35moe_fp8 + MTP", [this, sc](RadBuilder* b) { auto c = sc(1, 3); return qwen35moe_fp8::declare(b, q35moe.meta(), &c); }, - qwen35moe_fp8::step, 3, {}, 0x4c7e42e71f167042ull); + qwen35moe_fp8::step, 3, {}, 0x325d0299495a0dd8ull); add("qwen4exp_fp8", [this](RadBuilder* b) { auto c = q4_ctx(0, 1); return qwen4exp_fp8::declare(b, &q4, &c); }, qwen4exp_fp8::step, 3, {}, 0x9454e9dff6db286bull); @@ -11770,10 +12331,10 @@ TEST(a_4096_budget_without_a_span_is_the_pinned_graph_and_steps) { { "qwen4exp_fp8", 2, 1, 0x4bc19e44d0743e49ull, 0x959ef6b7c6f57d8bull }, { "qwen4exp_fp8", 4, 0, 0xea29df78a9297c5cull, 0xfbe74f2b9d7020bfull }, { "qwen4exp_fp8", 4, 3, 0x1e4ba87a0d9619f4ull, 0x36df57cac613c6cfull }, - { "qwen35_fp8", 1, 0, 0xc56a518087e3f4b4ull, 0xa7ec3cf6252cd441ull }, - { "qwen35_fp8", 2, 1, 0x6e644b3d13bac619ull, 0xdd5d65ef158c4136ull }, - { "qwen35moe_fp8", 1, 0, 0x7a9330e0da08f97cull, 0x2b5989b2a6dbc7dfull }, - { "qwen35moe_fp8", 2, 0, 0x3a2761e9546797f1ull, 0x4a597c66b5868eeeull }, + { "qwen35_fp8", 1, 0, 0x0f08ba5027cba71aull, 0xa7ec3cf6252cd441ull }, + { "qwen35_fp8", 2, 1, 0xe7780f241685a18bull, 0xdd5d65ef158c4136ull }, + { "qwen35moe_fp8", 1, 0, 0xb1e6173bd121dc2aull, 0x2b5989b2a6dbc7dfull }, + { "qwen35moe_fp8", 2, 0, 0x46d061a0de9a8933ull, 0x4a597c66b5868eeeull }, }; for (const Case& cs : cases) { RadBuilder b; diff --git a/tests/checkpoint_test.cpp b/tests/checkpoint_test.cpp index 227d1a40..29b1cb27 100644 --- a/tests/checkpoint_test.cpp +++ b/tests/checkpoint_test.cpp @@ -1925,6 +1925,21 @@ TEST(config_json_fills_the_model_meta_as_each_family_spells_it) { "lfm2", 0, 1024, 16, 8, 64, 0, 0, 0, 0, 0, 0, 1e-5, 1e4, { { "layer_types", "conv full_attention conv" }, { "hidden_size", "7" }, { "vision_config.hidden_size", "768" } } }, + { "Gemma 4 12B: the unified wrapper maps to gemma4, its model_type stays, null experts", + R"({"model_type":"gemma4_unified","eos_token_id":[1,106], + "text_config":{"model_type":"gemma4_unified_text","hidden_size":3840, + "num_attention_heads":16,"num_key_value_heads":8,"num_global_key_value_heads":1, + "head_dim":256,"global_head_dim":512,"num_hidden_layers":48, + "intermediate_size":15360,"moe_intermediate_size":null,"num_experts":null, + "rms_norm_eps":1e-06,"vocab_size":262144,"max_position_embeddings":262144, + "rope_parameters":{"full_attention":{"rope_theta":1000000.0}, + "sliding_attention":{"rope_theta":10000.0}}}, + "vision_config":{"model_type":"gemma4_unified_vision"}})", + "gemma4", 48, 3840, 16, 8, 256, 15360, 262144, 262144, 0, 0, 0, 1e-6, 1e4, + { { "model_type", "gemma4_unified" }, { "global_head_dim", "512" }, + { "num_global_key_value_heads", "1" }, + { "rope_parameters.full_attention.rope_theta", "1000000" }, + { "vision_config.model_type", "gemma4_unified_vision" } } }, { "rope_parameters wins over rope_theta", R"({"model_type":"llama","rope_theta":10000,"rope_parameters":{"rope_theta":5000000}})", "llama", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1e-6, 5e6, {} }, diff --git a/tests/config_test.cpp b/tests/config_test.cpp index 4875f010..05132a04 100644 --- a/tests/config_test.cpp +++ b/tests/config_test.cpp @@ -455,11 +455,27 @@ TEST(prefill_interleave_takes_a_step_count_up_to_64) { Config d; REQUIRE_EQ(parse({}, &d), RAD_OK); CHECK_EQ(d.prefill_interleave, 0); + CHECK(!d.prefill_interleave_set); /* not given: bring-up serves auto:1 */ Config c; CHECK_EQ(parse({ "--prefill-interleave", "4" }, &c), RAD_OK); CHECK_EQ(c.prefill_interleave, 4); + CHECK(c.prefill_interleave_set); CHECK_EQ(parse({ "--prefill-interleave", "65" }, &c), RAD_E_INVAL); CHECK_EQ(parse({ "--prefill-interleave", "-1" }, &c), RAD_E_INVAL); + /* auto sizes the hold from measured step costs (Scheduler::interleave_steps) */ + Config a; + CHECK_EQ(parse({ "--prefill-interleave", "auto" }, &a), RAD_OK); + CHECK_EQ(a.prefill_interleave, -1); + CHECK_EQ(parse({ "--prefill-interleave", "automatic" }, &c), RAD_E_INVAL); + /* auto:SHARE gives decode-only steps SHARE of a chunk step's time, in (0, 4] */ + Config h; + CHECK_EQ(parse({ "--prefill-interleave", "auto:1" }, &h), RAD_OK); + CHECK_EQ(h.prefill_interleave, -1); + CHECK(h.prefill_interleave_share == 1.0); + CHECK(a.prefill_interleave_share == 0.25); + CHECK_EQ(parse({ "--prefill-interleave", "auto:0" }, &c), RAD_E_INVAL); + CHECK_EQ(parse({ "--prefill-interleave", "auto:5" }, &c), RAD_E_INVAL); + CHECK_EQ(parse({ "--prefill-interleave", "auto:x" }, &c), RAD_E_INVAL); } /* ================================================================== the table, the parser and the help agree @@ -507,7 +523,8 @@ const std::map>& legal_values() { { "--preempt-wait-ms", { "5000" } }, { "--max-num-seqs", { "4" } }, { "--max-model-len", { "4096" } }, { "--rope-scaling", { "yarn:4" } }, - { "--gpu-headroom-mib", { "128" } }, { "--kv-cache-dtype", { "fp8" } }, + { "--gpu-memory-mib", { "16384" } }, { "--gpu-headroom-mib", { "128" } }, + { "--kv-cache-dtype", { "fp8" } }, { "--state-cache-dtype", { "f16" } }, { "--attn-prefill-fp8", { "both" } }, { "--kv-resident", { "65536" } }, { "--host-pool-mib", { "1024" } }, { "--host-headroom-mib", { "2048" } }, @@ -901,9 +918,28 @@ TEST(the_ngram_table_takes_a_directory_for_a_shared_ram_copy) { CHECK(s.ngram_placement == TablePlacement::Ram); CHECK(s.ngram_share_dir.empty()); Config c; - for (const char* bad : { "ram=", "vram=/tmp/x", "disk=/tmp/x", "auto=/tmp/x" }) + for (const char* bad : { "ram=", "disk=", "vram=/tmp/x", "auto=/tmp/x" }) CHECK_EQ(parse({ "--ngram-placement", bad }, &c), RAD_E_INVAL); CHECK_EQ(parse({ "--embedding-placement", "ram=/tmp/x" }, &c), RAD_E_INVAL); + CHECK_EQ(parse({ "--embedding-placement", "disk=/tmp/x" }, &c), RAD_E_INVAL); +} + +/* disk=DIR is disk read from the table's own file in DIR (#130); it and ram=DIR replace each + * other, and a plain placement drops both directories. */ +TEST(the_ngram_table_takes_a_directory_for_its_own_file_on_disk) { + Config s; + CHECK_EQ(parse({ "--ngram-placement", "disk=/mnt/optane" }, &s), RAD_OK); + CHECK(s.ngram_placement == TablePlacement::Disk); + CHECK_EQ(s.ngram_disk_dir, std::string("/mnt/optane")); + CHECK(s.ngram_share_dir.empty()); + CHECK_EQ(parse({ "--ngram-placement", "disk=/mnt/optane", "--ngram-placement", "ram=/dev/shm" }, + &s), RAD_OK); + CHECK(s.ngram_placement == TablePlacement::Ram); + CHECK(s.ngram_disk_dir.empty()); + CHECK_EQ(s.ngram_share_dir, std::string("/dev/shm")); + CHECK_EQ(parse({ "--ngram-placement", "disk=/mnt/optane", "--ngram-placement", "disk" }, &s), + RAD_OK); + CHECK(s.ngram_disk_dir.empty()); } /* --draft-window takes exactly two names; the default is kDraftWindowDefault, which the help text @@ -1387,6 +1423,26 @@ TEST(gpu_headroom_parses_under_both_spellings) { CHECK_EQ(d.gpu_headroom_mib, 96ll); } +/* --gpu-memory-mib is the inverse of --gpu-headroom-mib; they cannot be combined. The default + * headroom is not "given", so memory alone is legal and leaves the default until the resolver. */ +TEST(gpu_memory_mib_parses_and_excludes_headroom) { + Config a; + CHECK_EQ(parse({ "--gpu-memory-mib", "28000" }, &a), RAD_OK); + CHECK_EQ(a.gpu_memory_mib, 28000ll); + CHECK_EQ(a.gpu_headroom_mib, 96ll); + CHECK(a.given.count("--gpu-memory-mib")); + CHECK(!a.given.count("--gpu-headroom-mib")); + + Config z; + CHECK_EQ(parse({ "--gpu-memory-mib", "0" }, &z), RAD_E_INVAL); + CHECK_EQ(parse({ "--gpu-memory-mib", "-1" }, &z), RAD_E_INVAL); + CHECK_EQ(parse({ "--gpu-memory-mib", "8x" }, &z), RAD_E_INVAL); + + Config b, c; + CHECK_EQ(parse({ "--gpu-memory-mib", "28000", "--gpu-headroom-mib", "96" }, &b), RAD_E_INVAL); + CHECK_EQ(parse({ "--gpu-memory-mib", "28000", "--gpu-headroom", "96" }, &c), RAD_E_INVAL); +} + TEST(the_kernel_hierarchy_is_separated_by_commas_or_colons_and_ordered) { Config c; CHECK_EQ(parse({ "--kernels", "libr4d.so,libref.so" }, &c), RAD_OK); diff --git a/tests/convert_test.cpp b/tests/convert_test.cpp index 8e2de6a8..0af15b8c 100644 --- a/tests/convert_test.cpp +++ b/tests/convert_test.cpp @@ -615,6 +615,34 @@ TEST(lora_map_refusals_name_the_target_the_sums_or_the_flag) { CHECK(!exists(d / "c.rad")); } +/* A checkpoint tensor no declared weight reads is not written (a tower or head the plugin does not + * know), and the run names it; a tensor beside one that is read (its scale) is not named, nor is + * anything when every tensor is read. */ +TEST(a_checkpoint_tensor_no_weight_reads_is_named) { + World& w = world(); + REQUIRE(w.ok); + CHECK(w.log.find("read by no declared weight") == std::string::npos); + tiny::TempDir d("convert_u"); + const std::string ck = d / "llama"; + REQUIRE(mkdir(ck.c_str(), 0755) == 0); + for (const char* f : { "config.json", "tokenizer.json" }) + REQUIRE(copy_file(w.ckpt + "/" + f, ck + "/" + f)); + std::vector ts = tiny::read_safetensors(w.ckpt + "/model.safetensors"); + const size_t n = ts.size(); + ts.push_back({ "model.vision_embedder.patch_dense.weight", "BF16", { 4, 4 }, + std::vector(32, 0) }); + ts.push_back({ "model.layers.0.mlp.down_proj.weight_scale", "BF16", { 1 }, + std::vector(2, 0) }); + REQUIRE(tiny::write_safetensors(ck + "/model.safetensors", ts)); + std::string log; + REQUIRE_EQ(convert(ck, { "-o", d / "u.rad", "--recipe", w.recipe }, &log), 0); + const std::string want = "1 of " + std::to_string(n + 2) + " checkpoint tensors are read by no " + "declared weight and are not written: model.vision_embedder.patch_dense.weight"; + if (log.find(want) == std::string::npos) fprintf(stderr, " log:\n%s\n", log.c_str()); + CHECK(log.find(want) != std::string::npos); + CHECK(log.find("down_proj.weight_scale") == std::string::npos); +} + /* ================================================================== --in-place */ /* Extending a container with nothing new keeps every weight at its offset, and the .pre-append diff --git a/tests/dashboard_test.cpp b/tests/dashboard_test.cpp index 606a9bf7..d13a98e4 100644 --- a/tests/dashboard_test.cpp +++ b/tests/dashboard_test.cpp @@ -32,6 +32,7 @@ struct StatsScheduler : FakeScheduler { r.slot = 2; r.age_s = 4.5; r.ttft_s = 0.25; + r.prefill_s = 0.20; r.decode_tps = 61.0; out->assign(1, r); return 1; @@ -221,6 +222,7 @@ TEST(stats_carries_the_engine_the_requests_and_the_snapshot) { CHECK_EQ(r.value("state", ""), std::string("decode")); CHECK_EQ(r.value("kv_tokens", (int64_t)0), (int64_t)960); CHECK_NEAR(r.value("ttft_s", -1.0), 0.25, 1e-12); + CHECK_NEAR(r.value("prefill_s", -1.0), 0.20, 1e-12); REQUIRE(s["cards"].size() == 1); CHECK_EQ(s["cards"][0].value("name", ""), std::string("R9700")); REQUIRE(s["experts"]["tiers"].size() == (size_t)kTierCount); diff --git a/tests/dspark_device_test.cpp b/tests/dspark_device_test.cpp new file mode 100644 index 00000000..65914d96 --- /dev/null +++ b/tests/dspark_device_test.cpp @@ -0,0 +1,239 @@ +/* Focused device/CPU DSpark differential. Build with hipcc, then pass libr4d.so. + * This intentionally calls the real exported launchers, not the host SIMT emulator. + * See docs/DSPARK-VALIDATION-WIP.md for a scoped invocation and its limitations. */ +#include "rad_abi.h" +#include "rad_plugin.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using Fn = int (*)(const RadArgs*, RadStream); +static void check(bool b, const char* s) { if (!b) { std::fprintf(stderr, "FAIL %s\n", s); std::exit(1); } } +static void hipcheck(hipError_t e) { if (e != hipSuccess) { std::fprintf(stderr, "HIP: %s\n", hipGetErrorString(e)); std::exit(1); } } +static uint16_t bf(float f) { uint32_t x; std::memcpy(&x, &f, 4); x += 0x7fff + ((x >> 16) & 1); return x >> 16; } +static float fb(uint16_t b) { uint32_t x = (uint32_t)b << 16; float f; std::memcpy(&f, &x, 4); return f; } +template struct Device { + T* p = nullptr; size_t n; + explicit Device(const std::vector& v): n(v.size()) { hipcheck(hipMalloc(&p, n*sizeof(T))); hipcheck(hipMemcpy(p, v.data(), n*sizeof(T), hipMemcpyHostToDevice)); } + ~Device() { (void)hipFree(p); } + std::vector get() { std::vector v(n); hipcheck(hipMemcpy(v.data(), p, n*sizeof(T), hipMemcpyDeviceToHost)); return v; } +}; +static RadTensor t(void* p, int dt, std::initializer_list sh) { + RadTensor x{}; x.data=p; x.dtype=dt; x.rank=sh.size(); int i=0; for (auto d:sh) x.shape[i++]=d; rad_tensor_pack(&x); return x; +} +static RadParam pi(const char* k, long long v) { RadParam p{}; p.key=k; p.kind=RAD_P_INT; p.ival=v; return p; } +static RadParam ps(const char* k, const char* v) { RadParam p{}; p.key=k; p.kind=RAD_P_STR; p.sval=v; return p; } +static Fn symbol(void* h, const char* name) { auto f = reinterpret_cast(dlsym(h,name)); check(f != nullptr, name); return f; } + +static void markov(Fn fn, int R, bool f32) { + constexpr int M=2, S=2, V=130, T=3, LP=137, SP=5, TP=7, OP=4; + std::vector l(M*S*LP,bf(0)), p(V*R,bf(0)), u(V*R,bf(0)); + for (int m=0;m anchor{1,-1,2,-1}, ti(M*TP,-777), out(M*OP,-777); + std::vector ts(M*SP,-777.f); + std::vector lf(l.size()); for(size_t i=0;i dl(l), dp(p), du(u); Device da(anchor), di(ti), dout(out); + Device ds(ts), dlf(lf); + RadTensor a[]={t(f32 ? (void*)dlf.p : (void*)dl.p,f32 ? RAD_F32 : RAD_BF16,{M*S,V}),t(da.p,RAD_I32,{M,2}),t(dp.p,RAD_BF16,{V,R}),t(du.p,RAD_BF16,{V,R}),t(ds.p,RAD_F32,{M,T}),t(di.p,RAD_I32,{M,T}),t(dout.p,RAD_I32,{M,S})}; + a[0].stride[0]=LP; a[4].stride[0]=SP; a[5].stride[0]=TP; a[6].stride[0]=OP; + RadParam par[]={pi("M",M),pi("steps",S),pi("rank",R),pi("n_vocab",V),pi("anchor_stride",2),ps("dtype","bf16")}; + RadArgs args{}; args.t=a; args.n_t=7; args.p=par; args.n_p=6; + check(fn(&args,nullptr)==RAD_OK,"markov launch"); hipcheck(hipDeviceSynchronize()); + auto go=dout.get(); auto gs=ds.get(); auto gi=di.get(); + // Independent scalar oracle. Values are deliberately exactly representable so reduction order + // cannot explain a discrepancy. Sequential conditioning and tile winners are both checked. + for(int m=0;mbest) { best=score; winner=v; } + } + check(go[m*OP+s]==winner,"markov CPU winner"); prev=winner; + } + for(int tile=0;tilebest) {best=score; win=v;} + } + check(gs[m*SP+tile]==best && gi[m*TP+tile]==win,"markov pitched tile oracle"); + } + for(int i=T;i l{bf(1.001f),bf(1.002f)}, w(V*R,bf(0)); + std::vector anchor{0}, token{-1}, tile{-1}; std::vector score{-1}; + check(l[0]==l[1],"near tie quantizes identically"); + Device dl(l), dw(w); Device da(anchor), dt(tile), dout(token); Device ds(score); + RadTensor a[]={t(dl.p,RAD_BF16,{1,V}),t(da.p,RAD_I32,{1}),t(dw.p,RAD_BF16,{V,R}),t(dw.p,RAD_BF16,{V,R}),t(ds.p,RAD_F32,{1,1}),t(dt.p,RAD_I32,{1,1}),t(dout.p,RAD_I32,{1,1})}; + RadParam par[]={pi("steps",1),pi("rank",R),pi("n_vocab",V),pi("anchor_stride",1)}; + RadArgs args{}; args.t=a; args.n_t=7; args.p=par; args.n_p=4; + check(fn(&args,nullptr)==RAD_OK,"near tie launch"); hipcheck(hipDeviceSynchronize()); + check(dout.get()[0]==0 && 1.002f>1.001f,"BF16/F32 near tie divergence"); + std::vector full{1.001f,1.002f}; Device df(full); + a[0]=t(df.p,RAD_F32,{1,V}); + check(fn(&args,nullptr)!=RAD_OK,"BF16 op refuses F32 logits"); + check(fn_f32(&args,nullptr)==RAD_OK,"F32 near tie launch"); hipcheck(hipDeviceSynchronize()); + check(dout.get()[0]==1,"F32 near tie retains winner"); + a[0]=t(dl.p,RAD_BF16,{1,V}); + check(fn_f32(&args,nullptr)!=RAD_OK,"F32 op refuses BF16 logits"); + std::puts("near tie: F32 argmax=1, BF16 input argmax=0: PASS (synthetic)"); +} + +// Real device head -> F32 Markov chain, with an exactly representable BF16-input near tie. +static void head_chain(Fn head, Fn walk) { + constexpr int K=8, V=2, R=32; + std::vector x(K,bf(0)), w(V*K,bf(0)), cb(V*R,bf(0)); + x[0]=bf(1); x[1]=bf(0.001953125f); w[0]=bf(1); w[K]=bf(1); w[K+1]=bf(1); + std::vector logits(V,-1), scores(1,-1); + std::vector anchor{0}, tile{-1}, out{-1}; + Device dx(x), dw(w), dc(cb); Device dl(logits), ds(scores); + Device da(anchor), dt(tile), dout(out); + RadTensor h[]={t(dx.p,RAD_BF16,{1,K}),t(dw.p,RAD_BF16,{V,K}),t(dl.p,RAD_F32,{1,V})}; + RadParam hp[]={pi("M",1),pi("n_vocab",V),pi("n_embd",K),ps("dtype","bf16")}; + RadArgs ha{}; ha.t=h; ha.n_t=3; ha.p=hp; ha.n_p=4; + check(head(&ha,nullptr)==RAD_OK,"F32 logits head launch"); hipcheck(hipDeviceSynchronize()); + auto got=dl.get(); check(got[0]==1.f && got[1]==1.001953125f,"F32 logits head CPU dot oracle"); + check(bf(got[0])==bf(got[1]),"head-chain BF16 negative control"); + RadTensor a[]={t(dl.p,RAD_F32,{1,V}),t(da.p,RAD_I32,{1}),t(dc.p,RAD_BF16,{V,R}),t(dc.p,RAD_BF16,{V,R}),t(ds.p,RAD_F32,{1,1}),t(dt.p,RAD_I32,{1,1}),t(dout.p,RAD_I32,{1,1})}; + RadParam par[]={pi("M",1),pi("steps",1),pi("rank",R),pi("n_vocab",V),ps("dtype","bf16")}; + RadArgs args{}; args.t=a; args.n_t=7; args.p=par; args.n_p=5; + check(walk(&args,nullptr)==RAD_OK,"head-chain walk launch"); hipcheck(hipDeviceSynchronize()); + check(dout.get()[0]==1,"F32 head-chain winner"); + std::puts("F32 head -> Markov near tie and BF16 negative control: PASS"); +} + +static void attention(Fn shared, Fn ordinary, int G, int ctx0, int ctx1, int causal) { + constexpr int M=2, Q=7, H=256, BS=16, W=513; + const int ctx[M]={ctx0,ctx1}, blocks=(std::max(ctx0,ctx1)+15)/16, nblocks=M*blocks; + std::vector q(M*Q*G*H,bf(0)), kv((size_t)nblocks*BS*2*H,bf(0)), out(M*Q*G*H,bf(0)); + std::vector bt(M*blocks), su{ctx0,ctx1}, cu{0,Q,2*Q}; + // Reverse physical pages: the oracle must consult block_table rather than logical positions. + for(int s=0;s dq(q), dk(kv), dout(out); Device db(bt), ds(su), dc(cu); + RadTensor a[]={t(dq.p,RAD_BF16,{M*Q,G,H}),t(dk.p,RAD_BF16,{nblocks,1,BS,2*H}), + t(db.p,RAD_I32,{M,blocks}),t(ds.p,RAD_I32,{M}),RadTensor{},RadTensor{}, + t(dc.p,RAD_I32,{M+1}),t(dout.p,RAD_BF16,{M*Q,G,H})}; + RadParam par[]={pi("q_len",Q),pi("head_dim",H),pi("gqa",G),pi("block_size",BS), + pi("causal",causal),pi("window",W),pi("n_head",G),pi("max_seqs",M), + ps("q_dtype","bf16"),ps("kv_dtype","bf16")}; + RadArgs args{}; args.t=a; args.n_t=8; args.p=par; args.n_p=10; + check(shared(&args,nullptr)==RAD_OK,"shared anchor attention launch"); hipcheck(hipDeviceSynchronize()); + auto got=dout.get(); std::vector expected(M*Q*G); + for(int s=0;s0.03) distinguished=true; + check(distinguished,"attention per-row window negative control"); + std::printf("attention gqa=%d ctx=%d,%d causal=%d shared oracle and negative control: PASS\n",G,ctx0,ctx1,causal); +} + +// Real checkpoint head slice, but synthetic BF16 activations and zero Markov weights. This tests +// head arithmetic, not full-graph/reference equivalence or real hidden-state acceptance. +static void checkpoint_head(Fn head, Fn walk, const char* weights_path) { + constexpr int M=16, V=1025, K=2560, R=32, T=(V+63)/64; + std::vector w((size_t)V*K), x((size_t)M*K), cb((size_t)V*R,bf(0)); + std::ifstream f(weights_path,std::ios::binary); check((bool)f,"open checkpoint head slice"); + f.read(reinterpret_cast(w.data()),w.size()*sizeof(uint16_t)); + check((size_t)f.gcount()==w.size()*sizeof(uint16_t) && f.peek()==EOF,"exact head slice size"); + uint32_t rng=123456789; for(auto& v:x) { rng=rng*1664525u+1013904223u; v=bf(((int)(rng>>24)-128)/128.f); } + std::vector logits((size_t)M*V,0), scores((size_t)M*T,0); + std::vector anchor(M,0), tile((size_t)M*T,-1), out(M,-1); + Device dx(x), dw(w), dc(cb); Device dl(logits), ds(scores); + Device da(anchor), dt(tile), dout(out); + RadTensor h[]={t(dx.p,RAD_BF16,{M,K}),t(dw.p,RAD_BF16,{V,K}),t(dl.p,RAD_F32,{M,V})}; + RadParam hp[]={pi("M",M),pi("n_vocab",V),pi("n_embd",K),ps("dtype","bf16")}; + RadArgs ha{}; ha.t=h; ha.n_t=3; ha.p=hp; ha.n_p=4; + check(head(&ha,nullptr)==RAD_OK,"checkpoint head launch"); hipcheck(hipDeviceSynchronize()); + auto got=dl.get(); double maxerr=0, se=0, sr=0, minmargin=INFINITY; int changed=0,ties=0; + std::vector refwin(M); + for(int m=0;mbest) {second=best;best=ref;winner=v;} else if(ref>second) second=ref; + } + refwin[m]=winner; minmargin=std::min(minmargin,best-second); + int gw=0,bw=0,nmax=0; float gmax=-INFINITY, bmax=-INFINITY; + for(int v=0;vgmax) {gmax=y;gw=v;} if(by>bmax) {bmax=by;bw=v;nmax=1;} else if(by==bmax) ++nmax; + } + if(gw!=bw) ++changed; if(nmax>1) ++ties; + check(gw==winner,"checkpoint head F32 top1 versus FP64 oracle"); + } + RadTensor a[]={t(dl.p,RAD_F32,{M,V}),t(da.p,RAD_I32,{M}),t(dc.p,RAD_BF16,{V,R}),t(dc.p,RAD_BF16,{V,R}),t(ds.p,RAD_F32,{M,T}),t(dt.p,RAD_I32,{M,T}),t(dout.p,RAD_I32,{M,1})}; + RadParam p[]={pi("M",M),pi("steps",1),pi("rank",R),pi("n_vocab",V),ps("dtype","bf16")}; + RadArgs args{};args.t=a;args.n_t=7;args.p=p;args.n_p=5; + check(walk(&args,nullptr)==RAD_OK,"checkpoint head walk"); hipcheck(hipDeviceSynchronize()); + auto picks=dout.get(); for(int m=0;m 100_000_000: + raise ValueError("unreasonably large safetensors header") + header = json.loads(f.read(n)) + t = header["model.embedding.weight"] + if t["dtype"] != "BF16" or t["shape"] != [131072, 2560]: + raise ValueError("expected Spark BF16 embedding [131072, 2560]") + start, end = t["data_offsets"] + size = 1025 * 2560 * 2 + if end - start < size: + raise ValueError("short tensor") + f.seek(8 + n + start) + data = f.read(size) + if len(data) != size: + raise ValueError("short read") +with args.output.open("xb") as f: + f.write(data) +print(f"{args.safetensors}: model.embedding.weight rows 0..1024; " + f"bytes={len(data)} sha256={hashlib.sha256(data).hexdigest()} -> {args.output}") diff --git a/tests/dspark_qos_regression_test.py b/tests/dspark_qos_regression_test.py new file mode 100644 index 00000000..f2618fe1 --- /dev/null +++ b/tests/dspark_qos_regression_test.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python3 +"""Host unit tests for the DSpark QoS harness's evidence checks (no server/GPU).""" +import importlib.util +import io +import json +from pathlib import Path +import unittest +from unittest.mock import patch + +path = Path(__file__).resolve().parents[1] / "scripts" / "dspark_qos_regression.py" +spec = importlib.util.spec_from_file_location("dspark_qos", path) +qos = importlib.util.module_from_spec(spec) +spec.loader.exec_module(qos) + + +class HarnessChecks(unittest.TestCase): + def test_counter_delta_requires_both_samples_and_rejects_reset(self): + self.assertEqual(qos.metric_delta({"x": 4}, {"x": 7}, "x"), 3) + for before, after in (({}, {"x": 7}), ({"x": 4}, {}), ({"x": 7}, {"x": 4})): + with self.assertRaises(qos.HarnessError): + qos.metric_delta(before, after, "x") + + def test_calibration_brackets_safely_then_finds_largest_prompt(self): + seen = [] + phrase = "rollover-boundary marker " + def fake(_base, _model, messages, **_options): + count = len(messages[0]["content"]) // len(phrase) + seen.append(count) + if count > 64: + raise AssertionError("calibration overflowed a short server context") + return {"prompt_tokens": 10 + count * 3} + with patch.object(qos, "chat_request", side_effect=fake): + prompt, tokens = qos.calibrated_rollover_prompt("", "", None, 1, target=100) + self.assertEqual(len(prompt) // len(phrase), 30) + self.assertEqual(tokens, 100) + self.assertEqual(seen[:5], [1, 2, 4, 8, 16]) + self.assertLessEqual(max(seen), 32) + + def test_missing_usage_refuses_calibration(self): + with patch.object(qos, "chat_request", return_value={}): + with self.assertRaises(qos.HarnessError): + qos.calibrated_rollover_prompt("", "", None, 1) + + def test_stream_first_event_is_not_first_text(self): + event_only = b'data: {"choices":[{"delta":{"role":"assistant"}}]}\n\ndata: [DONE]\n\n' + with patch.object(qos, "fetch", return_value=io.BytesIO(event_only)): + r = qos.stream_request("", "", "test", api_key=None, timeout=1) + self.assertEqual(r["events"], 1) + self.assertIsNotNone(r["first_event_s"]) + self.assertIsNone(r["first_text_s"]) + reasoning = b'data: {"choices":[{"delta":{"reasoning_content":"think"}}]}\n\ndata: [DONE]\n\n' + with patch.object(qos, "fetch", return_value=io.BytesIO(reasoning)): + r = qos.stream_request("", "", "test", api_key=None, timeout=1) + self.assertIsNotNone(r["first_text_s"]) + + def test_draft_token_total_reports_observed_trials(self): + self.assertEqual(qos.observed_draft_token_total([{"draft_tokens": 168}, {"draft_tokens": 189}]), 357) + self.assertEqual(qos.observed_draft_token_total([]), 0) + + def test_seeded_repeat_requires_nonempty_matching_content_and_usage(self): + sample = {"content": "A bright comet crosses the sky.", "finish_reason": "stop", + "completion_tokens": 7} + self.assertTrue(qos.seeded_sample_reproduced(sample, dict(sample))) + for first, repeat in ( + ({**sample, "content": ""}, {**sample, "content": ""}), + ({**sample, "content": " "}, {**sample, "content": " "}), + (sample, {**sample, "content": "A different comet."}), + (sample, {**sample, "finish_reason": "length"}), + (sample, {**sample, "completion_tokens": 8}), + (sample, {**sample, "completion_tokens": 7.0}), + (sample, {**sample, "completion_tokens": None}), + ({**sample, "completion_tokens": 1}, {**sample, "completion_tokens": True}), + ({**sample, "finish_reason": None}, {**sample, "finish_reason": None}), + ): + with self.subTest(first=first, repeat=repeat): + self.assertFalse(qos.seeded_sample_reproduced(first, repeat)) + + def test_chat_request_forwards_reasoning_effort(self): + payload = {"choices": [{"finish_reason": "stop", "message": {"content": "OK"}}], + "usage": {"completion_tokens": 1}} + with patch.object(qos, "fetch", return_value=io.BytesIO(json.dumps(payload).encode())) as fetch: + result = qos.chat_request("http://localhost", "spark", [{"role": "user", "content": "test"}], + api_key=None, timeout=1, reasoning_effort="none") + self.assertEqual(result["content"], "OK") + sent = json.loads(fetch.call_args.kwargs["data"]) + self.assertEqual(sent["reasoning_effort"], "none") + + def test_stop_requires_control_and_exact_prefix(self): + marker = "STOP" + stopped = {"finish_reason": "stop", "content": "prefix "} + self.assertTrue(qos.stop_sequence_observed({"content": "prefix STOP after"}, stopped, marker)) + self.assertFalse(qos.stop_sequence_observed({"content": "prefix "}, stopped, marker)) + self.assertFalse(qos.stop_sequence_observed({"content": "prefix STOP"}, + {"finish_reason": "length", "content": "prefix "}, marker)) + self.assertFalse(qos.stop_sequence_observed({"content": "prefix STOP"}, + {"finish_reason": "stop", "content": "other"}, marker)) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/engine_e2e_test.cpp b/tests/engine_e2e_test.cpp index 08ef2870..287e32b0 100644 --- a/tests/engine_e2e_test.cpp +++ b/tests/engine_e2e_test.cpp @@ -85,9 +85,12 @@ std::vector serving_argv(const std::string& model, } /* The shape the preemption cases run in: four sequences of at most 512 tokens, 256 a step. Their - * small KV pool comes from a small device, whose size small_device() finds. */ + * small KV pool comes from a small device, whose size small_device() finds. --prefill-interleave 0 + * pins the schedule these cases are sized for: the bring-up default auto:1 follows measured step + * times, so on a loaded host the four sequences may never overlap enough to preempt. */ std::vector small_pool_args() { - return { "--max-num-seqs", "4", "--max-num-batched-tokens", "256", "--max-model-len", "512" }; + return { "--max-num-seqs", "4", "--max-num-batched-tokens", "256", "--max-model-len", "512", + "--prefill-interleave", "0" }; } std::vector device_env(int device_mib) { return { "RADIANCE_HOST_VRAM_MIB=" + std::to_string(device_mib) }; diff --git a/tests/fixture_test.cpp b/tests/fixture_test.cpp index 8d63d0f0..58735305 100644 --- a/tests/fixture_test.cpp +++ b/tests/fixture_test.cpp @@ -1240,6 +1240,52 @@ TEST(a_weight_tables_experts_are_drawn_from_its_encoding) { CHECK(via_draw == cb); } +/* A kernel that lays out its experts (libr4d's 4-bit tables) is handed each expert's arrangement of + * the planes kf_draw_table decodes, stacked one laid expert apart; a kernel with no layout reads the + * decoded table, and a layout that changes an expert's size cannot be stacked. */ +TEST(a_weight_tables_experts_are_each_laid_out_by_the_kernel) { + KfOperand codes = fp8_weight(128, 256, { "codes" }); + codes.role = RAD_OPD_WTAB; + codes.shape.insert(codes.shape.begin(), 3); + const KfEntryPlanes drawn = [&](int64_t e, std::vector>* pl) { + kf_draw_entry_planes(codes, 2, e, pl); + return (int)RAD_OK; + }; + RadKernelInfo ki{}; + RadLayout lay{}; + std::vector out; + CHECK_EQ(kf_lay_table(&ki, nullptr, 0, 2, codes, drawn, &lay, &out), RAD_E_UNSUPPORTED); + ki.layout = lay_identity; + CHECK_EQ(kf_lay_table(&ki, nullptr, 0, 2, codes, drawn, &lay, &out), RAD_E_UNSUPPORTED); + ki.layout = lay_reverse; + ki.relayout = relay_reverse; + REQUIRE_EQ(kf_lay_table(&ki, nullptr, 0, 2, codes, drawn, &lay, &out), RAD_OK); + const size_t per = (size_t)128 * 256; + REQUIRE_EQ(out.size(), 3 * per); + CHECK_EQ(lay.bytes, (int64_t)per); + std::vector> pl; + for (int64_t e = 0; e < 3; ++e) { + kf_draw_entry_planes(codes, 2, e, &pl); + CHECK(std::equal(out.begin() + (long)(per * e), out.begin() + (long)(per * (e + 1)), + pl[0].rbegin())); + } + /* The entries the kernel reads are the ones the oracle decodes. */ + std::vector logical; + std::string why; + REQUIRE_EQ(kf_draw_table(codes, 2, &logical, &why), RAD_OK); + kf_draw_entry_planes(codes, 2, 1, &pl); + CHECK(std::equal(logical.begin() + (long)per, logical.begin() + (long)(2 * per), + pl[0].begin())); + /* Laid out to a size the declared expert does not stride by. */ + ki.layout = [](const RadParam*, int, int, const RadEncoding*, const int*, + const RadTensor* t, int, RadLayout* o) { + o->dtype = t[0].dtype; + o->bytes = rad_dtype_bytes(t[0].dtype, t[0].shape[0] * t[0].shape[1]) + 256; + return (int)RAD_OK; + }; + CHECK_EQ(kf_lay_table(&ki, nullptr, 0, 2, codes, drawn, &lay, &out), RAD_E_SHAPE); +} + /* ================================================================== routing */ /* moe_scatter's offsets are a prefix array: non-decreasing from 0 to the row count. A uniform draw diff --git a/tests/format_test.cpp b/tests/format_test.cpp index 962b86b9..e6c4ac57 100644 --- a/tests/format_test.cpp +++ b/tests/format_test.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -26,6 +27,7 @@ #include #include #include +#include #include #include @@ -453,6 +455,70 @@ TEST(a_table_copied_into_locked_memory_is_the_mapping_byte_for_byte) { f.close(); } +/* --ngram-placement disk=DIR (#130): the first open fills the table's own file from the container, + * renamed into place whole; the mapping holds the container's bytes and is that file's (the disk + * gather finds the file behind its mapping); a second open reuses it unfilled; a file that is not + * this table is refused rather than served. */ +TEST(a_table_file_on_another_disk_is_filled_once_and_mapped_in_place_of_the_container) { + const std::string p = radtest::tmp_path("tfile"); + RadWriter w; + REQUIRE(w.begin(p.c_str()) >= 0); + w.set_arch("radtest"); + const RadWriter::Weight x = mkw("ngram.weight", plain_bf16(), 1500, 999, -1, -1, 0); + const Planes want = planes_of(x, 7); + REQUIRE(w.add_weight(x, want.ptr.data()) >= 0); + REQUIRE(w.finish() >= 0); + RadFile f; + REQUIRE(f.open(p.c_str()) >= 0); + const RadFilePlane& pl = f.plane(*f.find("ngram.weight"), 0); + const uint8_t* src = f.data(pl); + const int64_t n = (int64_t)pl.bytes; + const std::string tab = radtest::tmp_path("tfile-table"); + ::unlink(tab.c_str()); + + TableCopy a; + bool filled = false; + std::string why; + REQUIRE_EQ(table_file_open(f, src, n, (int64_t)pl.offset, tab, &a, &filled, &why), (int)RAD_OK); + CHECK(filled); + CHECK_EQ(a.bytes, (size_t)n); + CHECK(std::memcmp(a.base, src, (size_t)n) == 0); + CHECK(::access((tab + ".part").c_str(), F_OK) != 0); + /* The mapping is the file's, as /proc/self/maps names it. */ + { + std::ifstream maps("/proc/self/maps"); + bool backed = false; + for (std::string line; std::getline(maps, line);) { + unsigned long long lo = 0, hi = 0; + if (std::sscanf(line.c_str(), "%llx-%llx", &lo, &hi) != 2) continue; + if ((uintptr_t)a.base >= lo && (uintptr_t)a.base < hi) + backed = line.size() >= tab.size() && line.compare(line.size() - tab.size(), tab.size(), tab) == 0; + } + CHECK(backed); + } + ::munmap(a.base, a.bytes); + + TableCopy b; + REQUIRE_EQ(table_file_open(f, src, n, (int64_t)pl.offset, tab, &b, &filled, &why), (int)RAD_OK); + CHECK(!filled); + CHECK(std::memcmp(b.base, src, (size_t)n) == 0); + ::munmap(b.base, b.bytes); + + /* Same size, other bytes: refused, and left for the operator to remove. */ + { + std::fstream t(tab, std::ios::in | std::ios::out | std::ios::binary); + t.seekp(0); + const char junk[16] = "not the table.."; + t.write(junk, sizeof junk); + } + TableCopy c; + CHECK_EQ(table_file_open(f, src, n, (int64_t)pl.offset, tab, &c, &filled, &why), (int)RAD_E_IO); + CHECK(c.base == nullptr); + CHECK(why.find("does not match") != std::string::npos); + ::unlink(tab.c_str()); + f.close(); +} + /* --ngram-placement ram=DIR: the first holder to open the file fills it, a later one finds it * ready (a second descriptor in one process is a second holder, since flock locks belong to the * open file description), and the file goes when the last holder leaves. A file whose header is diff --git a/tests/gemma4u_golden.h b/tests/gemma4u_golden.h new file mode 100644 index 00000000..29602f94 --- /dev/null +++ b/tests/gemma4u_golden.h @@ -0,0 +1,14 @@ +/* gemma4u_golden.h -- GENERATED by mkgemma4ugolden.py from transformers 5.15.0; do not edit. */ +#pragma once +#include + +struct GoldGemma4uPic { int32_t f, h, w, budget, grid_h, grid_w, soft; uint64_t fnv; uint16_t head[8]; }; +static const GoldGemma4uPic kGoldGemma4uPics[] = { + { 2, 336, 480, 70, 7, 10, 70, 0x24f3317a5fdef4e5ull, { 16238, 16186, 16218, 16199, 16083, 15857, 16213, 16219 } }, + { 6, 432, 672, 140, 9, 14, 126, 0x1f2f65633d037b7dull, { 15929, 16244, 16077, 16212, 15665, 16130, 15985, 15993 } }, +}; +static const int32_t kGoldGemma4uClipFrames[] = { 4, 5, 6 }; +static const int32_t kGoldGemma4uClipH = 336, kGoldGemma4uClipW = 432, kGoldGemma4uClipGridH = 7, kGoldGemma4uClipGridW = 9, kGoldGemma4uClipSoft = 63; +static const uint64_t kGoldGemma4uClipFnv = 0xfee282f9d3bab92bull; +static const int32_t kGoldGemma4uAudioN = 16037, kGoldGemma4uAudioFrames = 26; +static const uint64_t kGoldGemma4uAudioFnv = 0x27a5cc012ee3ad6dull; diff --git a/tests/gen_config_test.cpp b/tests/gen_config_test.cpp index 7e3a452a..ef35c0df 100644 --- a/tests/gen_config_test.cpp +++ b/tests/gen_config_test.cpp @@ -258,4 +258,31 @@ TEST(gen_config_reads_the_ngram_ban) { CHECK_EQ(greedy.onto(SamplingParams{}).ngram_ban_n, 0); } +TEST(gen_config_reads_suppress_tokens) { + /* Gemma 4's generation_config.json: the end-of-image and end-of-audio markers. */ + GenSampling g; + CHECK(gen_sampling_parse(R"({"temperature": 1.0, "suppress_tokens": [258883, 258882]})", + "test", &g)); + CHECK_EQ((int)g.suppress.size(), 2); + CHECK_EQ(g.suppress[0], 258883); + CHECK_EQ(g.suppress[1], 258882); + const SamplingParams sp = g.onto(SamplingParams{}); + CHECK_EQ((int)sp.suppress_tokens.size(), 2); + CHECK(SamplingParams{}.suppress_tokens.empty()); + + /* The container's flattened copy: the array as a space-separated string. */ + GenSampling kv; + CHECK(gen_sampling_from_kv(kv_of({ { "suppress_tokens", "258883 258882" } }), &kv)); + CHECK_EQ((int)kv.suppress.size(), 2); + CHECK_EQ(kv.suppress[1], 258882); + + /* An entry that is no id is dropped on its own, and a non-array is dropped whole. */ + GenSampling bad; + CHECK(gen_sampling_parse(R"({"top_k": 64, "suppress_tokens": [7, -1, "x", 9]})", "test", &bad)); + CHECK_EQ((int)bad.suppress.size(), 2); + GenSampling flat; + CHECK(gen_sampling_parse(R"({"top_k": 64, "suppress_tokens": 7})", "test", &flat)); + CHECK(flat.suppress.empty()); +} + RAD_TEST_MAIN() diff --git a/tests/glm5next_test.cpp b/tests/glm5next_test.cpp index bd645b67..33d0cb0d 100644 --- a/tests/glm5next_test.cpp +++ b/tests/glm5next_test.cpp @@ -611,8 +611,12 @@ TEST( CHECK_EQ(std::count(ops.begin(), ops.end(), "mhc_pre"), 90); CHECK_EQ(std::count(ops.begin(), ops.end(), "kda_update"), 34); CHECK_EQ(std::count(ops.begin(), ops.end(), "mla_attn"), 11); - // Two rows stay under the split threshold: 42 routers and 11 index heads, replicated. - CHECK_EQ(std::count(ops.begin(), ops.end(), "gemm_nt_f32"), 53); + // Two rows stay under the split threshold, and their history fits the selection + // (DsaCache::takes_all): the 42 routers run, the 11 index heads and scorers do not. + CHECK_EQ(std::count(ops.begin(), ops.end(), "gemm_nt_f32"), 42); + CHECK_EQ(std::count(ops.begin(), ops.end(), "dsa_query"), 0); + CHECK_EQ(std::count(ops.begin(), ops.end(), "dsa_score"), 0); + CHECK_EQ(std::count(ops.begin(), ops.end(), "qsa_select"), 11); CHECK_EQ(std::count(ops.begin(), ops.end(), "all_gather"), 0); // The split is declared on every rank whatever its step size; only rank 0 issues it here. const bool split = world > 1; @@ -661,6 +665,21 @@ TEST( batch.out_ids = &last; batch.draft_pass = 0; batch.max_q_len = 512; + { + // 512 rows whose history fits the selection: the indexer takes every + // block and does not split, so no index head runs and nothing of its is + // gathered, while the routers, mHC reads and MLA still split. + ctx.issues.clear(); + glm5next::step(&ctx, &batch); + CHECK(ctx.step_fail.empty()); + const auto fit_ops = issued_ops(b, ctx); + CHECK_EQ(std::count(fit_ops.begin(), fit_ops.end(), "gemm_nt_f32"), 42); + CHECK_EQ(std::count(fit_ops.begin(), fit_ops.end(), "dsa_score"), 0); + CHECK_EQ(std::count(fit_ops.begin(), fit_ops.end(), "qsa_select"), 11); + CHECK_EQ(std::count(fit_ops.begin(), fit_ops.end(), "all_gather"), + world > 1 ? 42 + 90 + 11 : 0); + } + batch.max_ctx_len = 3000; // live blocks past the top-k: the indexer scores ctx.issues.clear(); glm5next::step(&ctx, &batch); CHECK(ctx.step_fail.empty()); @@ -668,7 +687,7 @@ TEST( // 512 rows reach the split: each router runs on its column slice, each mHC // read on its chunks, each indexer, its head gates included, on its run // of query rows, and each MLA on its run of rows, all gathered but the - // gates; at TP1 nothing changes. + // gates. At TP1 the step does not split, and the indexer scores whole. const auto long_ops = issued_ops(b, ctx); CHECK_EQ(std::count(long_ops.begin(), long_ops.end(), "gemm_nt_f32"), 53); CHECK_EQ(std::count(long_ops.begin(), long_ops.end(), "all_gather"), @@ -801,8 +820,39 @@ TEST(glm53_indexer_scores_and_selects_one_run_of_query_rows_per_rank) { CHECK_EQ(b.bufs[w.selected - 1].d.shape[0], world * most); CHECK_EQ(b.bufs[w.codes - 1].d.shape[0], world * most * 32); CHECK_EQ(b.bufs[w.sel_part - 1].d.shape[0], most); - // Two decode rows beside a 498-row chunk: 500 rows, runs of R. - auto k = kit(b, { 1, 1 }, { 498 }, 100); + // Wide page tables, so that live blocks follow the history past the selection. + auto widen = [](Kit& kt) { + const int64_t pitch = 1024; + kt.table.resize((size_t)(kt.b.n_seq * pitch)); + for (int64_t i = 0; i < kt.b.n_seq * pitch; ++i) kt.table[(size_t)i] = (int32_t)i; + for (auto& g : kt.kv) { + g.block_table = kt.table.data(); + g.block_table_pitch = g.max_blocks = pitch; + } + }; + { + // 500 rows whose history fits the selection take every block without splitting: + // each rank selects the whole step from the unscored plane, and nothing gathers. + auto fit = kit(b, { 1, 1 }, { 498 }, 100); + widen(*fit); + auto fits = run_passes(b, glm5next::step, { fit.get() }, rank, world); + CHECK_PASSES(b, fits); + int all = 0; + for (const auto& issue : fits[0]->issues) { + CHECK(issue.op != cache.op_score_part && issue.op != cache.op_gather_sel && + issue.op != cache.op_score); + if (issue.op == cache.op_select_all) { + ++all; + CHECK_EQ(issue.n, 500); + CHECK_EQ(issue.opd[0].handle, w.unscored); + } + } + CHECK_EQ(all, 1); + } + // Two decode rows beside a 498-row chunk of 3000 tokens of history: 500 rows that + // score, in runs of R. + auto k = kit(b, { 1, 1 }, { 498 }, 3000); + widen(*k); const int64_t T = 500, R = DsaCache::part_rows(T, world), r0 = rank * R, have = std::min(R, T - r0); auto passes = run_passes(b, glm5next::step, { k.get() }, rank, world); @@ -859,8 +909,19 @@ TEST(glm53_indexer_scores_and_selects_one_run_of_query_rows_per_rank) { CHECK_EQ(gathered, 1); CHECK_EQ(replicated, 0); CHECK_EQ(fronts, 4); - // Under the threshold every rank scores and selects the whole step. - auto small = kit(b, {}, { 255 }); + // Under the threshold every rank scores and selects the whole step. 3000 tokens of + // history reach 815 blocks, past the selection, and 255 rows of them stay under + // kSplitWork. + auto small = kit(b, {}, { 255 }, 3000); + { + const int64_t pitch = 1024; + small->table.resize((size_t)pitch); + for (int64_t i = 0; i < pitch; ++i) small->table[(size_t)i] = (int32_t)i; + for (auto& g : small->kv) { + g.block_table = small->table.data(); + g.block_table_pitch = g.max_blocks = pitch; + } + } auto under = run_passes(b, glm5next::step, { small.get() }, rank, world); CHECK_PASSES(b, under); int whole = 0; @@ -874,6 +935,27 @@ TEST(glm53_indexer_scores_and_selects_one_run_of_query_rows_per_rank) { if (issue.op == index.op_head) CHECK_EQ(issue.n, 255); } CHECK_EQ(whole, 1); + // Without that history every row selects all its blocks: no rank runs the query side + // or scores, and the selection reads zeros over the selection's width. + auto fits = kit(b, {}, { 255 }); + auto all = run_passes(b, glm5next::step, { fits.get() }, rank, world); + CHECK_PASSES(b, all); + int unscored = 0, picks = 0; + for (const auto& issue : all[0]->issues) { + CHECK(issue.op != cache.op_score && issue.op != cache.op_score_part && + issue.op != cache.op_query && issue.op != index.op_query_copy && + issue.op != index.op_head && issue.op != index.query.op); + if (issue.op == cache.op_unscored) { + ++unscored; + CHECK_EQ(issue.n, 255); + CHECK_EQ(issue.opd[0].handle, w.unscored); + CHECK_EQ(b.bufs[w.unscored - 1].d.shape[1], cache.unscored_cols()); + } + CHECK(issue.op != cache.op_select); + picks += issue.op == cache.op_select_all; + } + CHECK_EQ(unscored, 1); + CHECK_EQ(picks, 1); // A verify of eight sequences at 32k of context (48 rows x 8014 blocks) splits too, a // single sequence's six rows do not; a rank whose run lies past the step still writes // the runs it gathers. @@ -1024,8 +1106,8 @@ TEST(glm53_refusals_name_what_was_refused) { return err; }; RadBuildCtx c = ok; - c.kv_dtype = RAD_F8E4M3; - CHECK(has(refusal(meta, c), "--kv-cache-dtype fp8")); + c.kv_dtype = RAD_F16; + CHECK(has(refusal(meta, c), "--kv-cache-dtype f16")); c = ok; c.max_spec = 32; CHECK(has(refusal(meta, c), "--num-speculative-tokens 32")); @@ -1055,6 +1137,70 @@ TEST(glm53_refusals_name_what_was_refused) { } } +/* --kv-cache-dtype fp8 narrows the latent attention cache alone to E4M3: its group, every latent + * store (plain and streamed) and every latent attention (head form, row form, the MTP layer's) + * name fp8_e4m3, and the index tail, DSA index and KDA groups keep their dtypes. Under bf16 the + * attention states no kv_dtype, the op it always declared. */ +TEST(glm53_fp8_kv_cache_narrows_the_latent_group_only) { + const char* keys[] = { "num_nextn_predict_layers", "hc_mult", "n_routed_experts", + "index_topk" }; + const char* vals[] = { "1", "4", "288", "2048" }; + RadModelMeta meta{}; + meta.n_layers = 45; + meta.n_embd = 4096; + meta.n_vocab = 154880; + meta.rms_eps = 1e-5f; + meta.n_kv = 4; + meta.kv_key = keys; + meta.kv_val = vals; + const auto mx = rad_enc_affine(RAD_FP4E2M1, RAD_E8M0, 1, 32); + const auto fp8 = rad_enc_affine(RAD_F8E4M3, RAD_F32, 128, 128); + for (int kv_dtype : { (int)RAD_DT_INVALID, (int)RAD_BF16, (int)RAD_F8E4M3 }) { + const bool narrow = kv_dtype == RAD_F8E4M3; + RadBuilder b; + b.kv_block = 4; + b.encs = { { "mtp.blk.45.ffn_gate_up_exps", fp8 }, + { "mtp.blk.45.ffn_down_exps", fp8 }, + { "ffn_gate_up_exps", mx }, + { "ffn_down_exps", mx }, + { "ffn_gate_up_shexp", mx }, + { "ffn_down_shexp", mx }, + { "ffn_gate_up.weight", fp8 }, + { "ffn_down.weight", fp8 } }; + RadBuildCtx build{}; + build.rank = 0; + build.world_size = 4; + build.max_tok = 512; + build.max_seqs = 4; + build.max_ctx = 4096; + build.max_spec = 3; + build.tp_attn_rows = 1; + build.kv_dtype = kv_dtype; + REQUIRE_EQ(glm5next::declare(&b, &meta, &build), RAD_OK); + std::map dtypes; + for (const auto& g : b.kv_groups) dtypes[g.name] = g.d.dtype; + CHECK_EQ(dtypes["kv_latent"], narrow ? (uint32_t)RAD_F8E4M3 : (uint32_t)RAD_BF16); + CHECK_EQ(dtypes["kv_index_tail"], (uint32_t)RAD_BF16); + CHECK_EQ(dtypes["kv_dsa_index"], (uint32_t)RAD_U8); + CHECK_EQ(dtypes["kv_kda"], (uint32_t)RAD_F32); + CHECK_EQ(dtypes["kv_kda_conv"], (uint32_t)RAD_BF16); + int stores = 0, attns = 0; + for (const auto& o : b.ops) { + if (o.op == "kv_store" || o.op == "kv_store_streamed") { + ++stores; + CHECK_EQ(pstr(&o, "kv_dtype"), narrow ? "fp8_e4m3" : "bf16"); + } + if (o.op == "mla_attn") { + ++attns; + CHECK_EQ(pstr(&o, "kv_dtype"), narrow ? "fp8_e4m3" : ""); + } + } + // 11 MLA layers and the MTP layer, each a store and a head-form attention; 11 row forms. + CHECK(stores >= 12); + CHECK_EQ(attns, 12 + 11); + } +} + /* The MoE block's decode fusions: over a two-row trunk step, its draft pass and a 512-row prefill * (past the router fusion's one-workgroup sort), each fused launch stands where it fits and the * launches it replaces are gone, with the step lint clean throughout. The sort writes each slot's @@ -1230,6 +1376,7 @@ TEST(dsa_cache_uses_distinct_index_and_attention_pages_and_a_speculative_tail_ri w.pooled = decl_b(&b, "pooled", RAD_F8E4M3, { 12, 128 }); w.pool_scale = decl_b(&b, "pool_scale", RAD_F32, { 12, 1 }); w.score = decl_b(&b, "score", RAD_F32, { 32, 1024 }); + w.unscored = decl_b(&b, "unscored", RAD_F32, { 32, 513 }); w.selected = decl_b(&b, "sel", RAD_I32, { 32, 513 }); w.nsel = decl_b(&b, "nsel", RAD_I32, { 32 }); w.length = decl_b(&b, "len", RAD_I32, { 32 }); @@ -1258,54 +1405,85 @@ TEST(dsa_cache_uses_distinct_index_and_attention_pages_and_a_speculative_tail_ri RAD_OK); CHECK_EQ(b.kv_groups[index - 1].d.dtype, RAD_U8); CHECK_EQ(b.kv_groups[index - 1].d.head_dim, 17); - int32_t ibt[16]{}, abt[16]{}, sidx[12]{}, cu[] = { 0, 3, 8 }, pos[8]{}; - RadKVGroupBatch kv[3]{}; - kv[0].group = index; - kv[0].block_table = ibt; - kv[0].block_table_pitch = 8; - kv[1].group = tail; - kv[1].state_index = sidx; - kv[1].state_index_pitch = 6; - kv[2].group = attn; - kv[2].block_table = abt; - kv[2].block_table_pitch = 8; - RadBatch batch{}; - batch.n_tok = 8; - batch.n_seq = 2; - batch.n_spec = 2; - batch.kv = kv; - batch.n_kv_groups = 3; - batch.positions = pos; - batch.cu_seqlens = cu; - batch.max_ctx_len = 64; // Mixed-row bound exceeds the eight physical table columns. - RadCtx ctx; - ctx.b = &b; - ctx.batch = &batch; - if (front) { - indexer.step(&ctx, &batch); - REQUIRE_EQ(ctx.issues.size(), (size_t)12); - CHECK_EQ(ctx.issues[1].op, indexer.op_query_copy); - CHECK_EQ(ctx.issues[1].opd[1].rows, 256); - CHECK_EQ(ctx.issues[3].op, indexer.op_norm); - CHECK_EQ(ctx.issues[4].opd[0].offset, 128); - CHECK_EQ(ctx.issues[5].op, indexer.op_head); - ctx.issues.erase(ctx.issues.begin(), ctx.issues.begin() + 6); - } else - block.step(&ctx, &batch); - REQUIRE_EQ(ctx.issues.size(), (size_t)6); - CHECK_EQ(ctx.issues[0].n, 256); - CHECK(ctx.issues[1].opd[5].raw == ibt); - CHECK_EQ(ctx.issues[1].opd[4].cols, 6); - CHECK_EQ(ctx.issues[2].op, block.op_pool); - CHECK_EQ(ctx.issues[2].opd[5].handle, index); - CHECK_EQ(ctx.issues[3].op, block.op_tail); - CHECK_EQ(ctx.issues[4].opd[0].rows, 256); - CHECK_EQ(ctx.issues[4].opd[3].handle, index); - CHECK_EQ(ctx.issues[4].opd[4].kind, RAD_OPK_NONE); - CHECK(ctx.issues[4].opd[5].raw == ibt); - CHECK_EQ(ctx.issues[4].opd[8].cols, 8); - CHECK_EQ(ctx.issues[5].opd[0].cols, 8); - CHECK(ctx.issues[5].opd[1].raw == abt); + /* Eight table columns cap the live reach below the selection, so every row takes all its + * blocks (DsaCache::takes_all); 4000 tokens of history over 1024 columns reach 1004 blocks, + * past it, and score. */ + for (const int64_t pitch : { 8, 1024 }) { + const bool scores = pitch > 8; + std::vector ibt((size_t)(2 * pitch)), abt((size_t)(2 * pitch)); + int32_t sidx[12]{}, cu[] = { 0, 3, 8 }, pos[8]{}; + RadKVGroupBatch kv[3]{}; + kv[0].group = index; + kv[0].block_table = ibt.data(); + kv[0].block_table_pitch = pitch; + kv[1].group = tail; + kv[1].state_index = sidx; + kv[1].state_index_pitch = 6; + kv[2].group = attn; + kv[2].block_table = abt.data(); + kv[2].block_table_pitch = pitch; + RadBatch batch{}; + batch.n_tok = 8; + batch.n_seq = 2; + batch.n_spec = 2; + batch.kv = kv; + batch.n_kv_groups = 3; + batch.positions = pos; + batch.cu_seqlens = cu; + // At eight columns the mixed-row bound exceeds the physical table. + batch.max_ctx_len = scores ? 4000 : 64; + const int64_t live = scores ? 1004 : 8; + CHECK_EQ(block.live_blocks(&batch), live); + CHECK_EQ(block.takes_all(&batch), !scores); + RadCtx ctx; + ctx.b = &b; + ctx.batch = &batch; + if (front) { + indexer.step(&ctx, &batch); + if (scores) { + REQUIRE_EQ(ctx.issues.size(), (size_t)12); + CHECK_EQ(ctx.issues[1].op, indexer.op_query_copy); + CHECK_EQ(ctx.issues[1].opd[1].rows, 256); + CHECK_EQ(ctx.issues[3].op, indexer.op_norm); + CHECK_EQ(ctx.issues[4].opd[0].offset, 128); + CHECK_EQ(ctx.issues[5].op, indexer.op_head); + ctx.issues.erase(ctx.issues.begin(), ctx.issues.begin() + 6); + } else { + // The key side alone: key and gate projection, norm, gate copy. + REQUIRE_EQ(ctx.issues.size(), (size_t)8); + CHECK_EQ(ctx.issues[1].op, indexer.op_norm); + CHECK_EQ(ctx.issues[2].op, indexer.op_gate_copy); + ctx.issues.erase(ctx.issues.begin(), ctx.issues.begin() + 3); + } + } else + block.step(&ctx, &batch); + const size_t q = scores ? 1 : 0; // the query quantiser leads a scored step + REQUIRE_EQ(ctx.issues.size(), 5 + q); + if (scores) CHECK_EQ(ctx.issues[0].n, 256); + CHECK(ctx.issues[q].opd[5].raw == ibt.data()); + CHECK_EQ(ctx.issues[q].opd[4].cols, 6); + CHECK_EQ(ctx.issues[q + 1].op, block.op_pool); + CHECK_EQ(ctx.issues[q + 1].opd[5].handle, index); + CHECK_EQ(ctx.issues[q + 2].op, block.op_tail); + const auto& fill = ctx.issues[q + 3]; + if (scores) { + CHECK_EQ(fill.op, block.op_score); + CHECK_EQ(fill.opd[0].rows, 256); + CHECK_EQ(fill.opd[3].handle, index); + CHECK_EQ(fill.opd[4].kind, RAD_OPK_NONE); + CHECK(fill.opd[5].raw == ibt.data()); + CHECK_EQ(fill.opd[8].cols, live); + } else { + CHECK_EQ(fill.op, block.op_unscored); + CHECK_EQ(fill.n, 8); + CHECK_EQ(fill.opd[0].handle, w.unscored); + CHECK_EQ(fill.opd[0].rows, 8); + } + CHECK_EQ(ctx.issues[q + 4].op, scores ? block.op_select : block.op_select_all); + CHECK_EQ(ctx.issues[q + 4].opd[0].handle, scores ? w.score : w.unscored); + CHECK_EQ(ctx.issues[q + 4].opd[0].cols, live); + CHECK(ctx.issues[q + 4].opd[1].raw == abt.data()); + } } } @@ -1610,16 +1788,23 @@ TEST(glm53_is_the_pinned_graph_and_steps) { int world; uint64_t graph, steps; bool heads_only = false; /* the default: the graph before the row form */ + bool file_tier = false; /* --weights-disk-tier: whole experts at four ranks and up */ }; /* Pins from this test's own `pin:` printout: the head form (heads_only, which declares the * streamed ops) and the row form, at one and eight ranks. Re-recorded after every graph * change -- the merge re-recorded them for main's builder plus this branch's file-direct - * expert ops. */ - const Case cases[] = { { 1, 0x8e12725b3ed3548dull, 0x68ffc03d2b640d51ull }, - /* World 8 is this branch's expert-parallel graph (288/world whole - * experts, file-direct), so its pins differ from main's. */ - { 8, 0x6232b56d6f971d61ull, 0x1b80576ba8f1ecc7ull }, - { 8, 0x3e4b89352f01b57bull, 0xed8cc595e8eeb593ull, true } }; + * expert ops, and the graphs again when the routing counts became RAD_BUF_PERSIST (the + * steps did not change). */ + const Case cases[] = { { 1, 0xce4368c09bfdbbeeull, 0x19679d4fcc0321ebull }, + /* Two ranks keep whole experts; four and eight split them by width. */ + { 2, 0xab04b95724840abeull, 0x76865603b1390635ull }, + { 4, 0xfdee91cd1c985b0aull, 0xde7ebe5b604c3cd2ull }, + { 8, 0x59112e7ad7d77fdeull, 0xb9c29d30003a6df7ull }, + { 8, 0xf1bb904ab21d8813ull, 0xfb28d3dcd8ec5ae1ull, true }, + /* The file tier's whole experts, file-direct, at four and eight. */ + { 4, 0x1918906f91fad4e7ull, 0x07d518b9a0f32986ull, false, true }, + { 8, 0x553f81a93cec76bfull, 0x17f0a90d3bed9713ull, false, true }, + { 8, 0x9685be82c8d55813ull, 0x75e775f0568636b5ull, true, true } }; for (const Case& cs : cases) { RadBuilder b; b.kv_block = 4; @@ -1636,17 +1821,78 @@ TEST(glm53_is_the_pinned_graph_and_steps) { ctx.max_seqs = 8; ctx.max_ctx = 200000; ctx.tp_attn_rows = cs.heads_only ? 0 : 1; + ctx.expert_file_tier = cs.file_tier; REQUIRE_EQ(glm5next::declare(&b, &meta, &ctx), RAD_OK); const uint64_t g = graph_hash(b); const uint64_t s = pinned_steps(b, glm5next::step, 0, cs.world); - fprintf(stderr, " pin: glm5next world %d%s: graph 0x%016llxull, steps 0x%016llxull\n", - cs.world, cs.heads_only ? " heads only" : "", + fprintf(stderr, " pin: glm5next world %d%s%s: graph 0x%016llxull, steps 0x%016llxull\n", + cs.world, cs.heads_only ? " heads only" : "", cs.file_tier ? " file tier" : "", (unsigned long long)g, (unsigned long long)s); CHECK_EQ(g, cs.graph); CHECK_EQ(s, cs.steps); } } +/* The width split is for all-MXFP4 experts alone: anything else keeps whole experts at four ranks + * and up, because a plain bf16 expert, even one protected among MXFP4 ones, cannot be sliced. */ +TEST(glm53_lays_out_its_experts_by_their_format) { + const char* keys[] = { "num_nextn_predict_layers", "hc_mult", "n_routed_experts", + "index_topk" }; + const char* vals[] = { "1", "4", "288", "2048" }; + RadModelMeta meta{}; + meta.n_layers = 45; + meta.n_embd = 4096; + meta.n_vocab = 154880; + meta.rms_eps = 1e-5f; + meta.n_kv = 4; + meta.kv_key = keys; + meta.kv_val = vals; + const auto mx = rad_enc_affine(RAD_FP4E2M1, RAD_E8M0, 1, 32); + const auto fp8 = rad_enc_affine(RAD_F8E4M3, RAD_F32, 128, 128); + const auto bf = rad_enc_plain(RAD_BF16); + const auto declare = [&](const RadEncoding& first, const RadEncoding& rest, bool tier, + int world, uint64_t* graph) { + RadBuilder b; + b.kv_block = 4; + b.encs = { { "mtp.blk.45.ffn_gate_up_exps", fp8 }, + { "mtp.blk.45.ffn_down_exps", fp8 }, + { "blk.3.ffn_gate_up_exps.0.", first }, + { "blk.3.ffn_down_exps.0.", first }, + { "blk.3.ffn_gate_up_exps.1.", first }, + { "blk.3.ffn_down_exps.1.", first }, + { "ffn_gate_up_exps", rest }, + { "ffn_down_exps", rest }, + { "ffn_gate_up_shexp", rest }, + { "ffn_down_shexp", rest }, + { "ffn_gate_up.weight", fp8 }, + { "ffn_down.weight", fp8 } }; + RadBuildCtx ctx = spec_ctx(0, world, 3); + ctx.max_tok = 4096; + ctx.max_seqs = 8; + ctx.max_ctx = 200000; + ctx.expert_file_tier = tier; + const int rc = glm5next::declare(&b, &meta, &ctx); + if (rc == RAD_OK) *graph = graph_hash(b); + return rc; + }; + for (const int world : { 4, 8 }) { + uint64_t whole = 0, g = 0; + REQUIRE_EQ(declare(bf, bf, true, world, &whole), RAD_OK); + REQUIRE_EQ(declare(bf, bf, false, world, &g), RAD_OK); /* was refused: slices every expert */ + CHECK_EQ(g, whole); + REQUIRE_EQ(declare(fp8, fp8, true, world, &whole), RAD_OK); + REQUIRE_EQ(declare(fp8, fp8, false, world, &g), RAD_OK); + CHECK_EQ(g, whole); + REQUIRE_EQ(declare(mx, mx, true, world, &whole), RAD_OK); + uint64_t width = 0; + REQUIRE_EQ(declare(mx, mx, false, world, &width), RAD_OK); + CHECK(width != whole); + REQUIRE_EQ(declare(bf, mx, true, world, &whole), RAD_OK); + REQUIRE_EQ(declare(bf, mx, false, world, &g), RAD_OK); /* a protected pair */ + CHECK_EQ(g, whole); + } +} + /* ==================================================================== GLM-5.3's vision tower */ namespace { @@ -2166,7 +2412,9 @@ TEST(glm53_streamed_decode_resolves_after_select_and_before_attention_with_the_e }; auto check_layer_order = [&](const glm5next::Layer& l) { const size_t store = find_issue(l.mla.op_store_stream); - const size_t sel = find_issue(l.index.cache.op_select); + // A short history takes every block (DsaCache::takes_all), a long one scores. + const size_t sel = std::min(find_issue(l.index.cache.op_select), + find_issue(l.index.cache.op_select_all)); const size_t res_i = find_issue(l.mla.op_resolve); const size_t attn = find_issue(l.mla.core.op_attn); REQUIRE(store != SIZE_MAX); diff --git a/tests/js/README.md b/tests/js/README.md new file mode 100644 index 00000000..fb7d1e2d --- /dev/null +++ b/tests/js/README.md @@ -0,0 +1,51 @@ +# Dashboard page tests + +The dashboard is one C++ string: `core/server/dashboard.cpp` embeds the whole page, +so its JavaScript has no file of its own to test. These harnesses extract the page +from the translation unit (`page.js`) and **execute the shipped functions**, sliced +by line range, against mocked DOM. A retyped copy would test the copy, not the bytes +that ship, and each harness calls the functions it slices: one that is only defined proves +nothing. + + node tests/js/poll_spark.test.js + node tests/js/extremes.test.js + node tests/js/history.test.js + node tests/js/download.test.js + +## What each one covers + +| file | the shipped code it drives | +| --- | --- | +| `poll_spark.test.js` | the cadence fields, the sparkline | +| `extremes.test.js` | `noteSample`, `triple`, `acceptTriple`, `resetWindows`, `newEngineRun` | +| `history.test.js` | the history summary line: how it groups, and how it wraps | +| `download.test.js` | the Requests-header JSON export: its markup and its handler | + +Each asserts structure, not just text. `history.test.js` inspects the DOM the page builds and the +CSS it ships, because the rules it guards -- a category wraps whole, the category break is a dot +and the break within one is a pipe -- are not properties of any string the code builds. +`download.test.js` invokes the click handler against stubs and checks it really builds a file, +names it, clicks it and releases the blob URL: a button that looks clickable and does nothing is +the failure it exists to catch. + +## The render check (manual, needs Chrome) + +`render_align.js` is not a unit test and cannot be: it answers whether the download glyph is +level with the caption by loading the page in headless Chrome, screenshotting the header at 4x, +and comparing the lowest inked pixel row of each. It needs puppeteer and a Chrome binary, which +are deliberately not repo dependencies: + + npm i puppeteer && npx puppeteer browsers install chrome + node tests/js/render_align.js http://127.0.0.1:8800/ + +Exits nonzero when the two bottoms land on different device rows. Run it after touching glyph or +header geometry: alignment cannot be read off the CSS and the SVG viewBox (collapsed whitespace can +make a separator zero pixels wide, and an SVG flush with the baseline still floats, because the +baseline sits above the box bottom), so measure the rendered page. + +## Why these are not in ctest + +They need node, which is not a build dependency of this project and will not be +present on a contributor's box or in the ROCm build image. Wiring them into ctest +would turn a missing optional tool into a red build, so they stay opt-in and are run +by hand when the page changes. `dashboard_test` covers the C++ side only. diff --git a/tests/js/download.test.js b/tests/js/download.test.js new file mode 100644 index 00000000..7596339b --- /dev/null +++ b/tests/js/download.test.js @@ -0,0 +1,128 @@ +/* The Requests-header JSON export. It used to be a "json" text button in the history row that + * copied to the clipboard; it is now a download icon that saves a file. A button that looks + * clickable and silently does nothing is the failure this guards: so drive the SHIPPED handler + * against stubs and assert it actually builds a file, names it, clicks it, and cleans up. */ +const fs = require("fs"); +const path = require("path"); +const src = require("./page.js"); // the