Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
45ffb64
glm exl3: decode windows on the 16-pair item plan
BadAd84 Nov 3, 2026
7e1881e
glm exl3 items: the GPU check runs at GLM-5.3-Flash served size
BadAd84 Nov 3, 2026
52f8448
changelog: #2044 under Unreleased
BadAd84 Nov 13, 2026
3538687
glm: retain whole-prompt ownership while integrating decode item plans
ashhart Nov 14, 2026
220d611
glm cuda tests: one dispatch line for the glm-exl3 commands
BadAd84 Nov 16, 2026
204334c
glm exl3 items test: pass null for block32, as main's Kernels.load ta…
ashhart Nov 17, 2026
ce1b0bf
ling: Ling-3.1-flash as a native CUDA family (EXL3, one GPU or two ra…
ajensenwaud Nov 7, 2026
435fe03
kernel contract: Ling-3.1-flash's own launches
ajensenwaud Nov 7, 2026
f5bef62
ling: unload the EXL3 experts module when the prompt tiles' load fail…
ajensenwaud Nov 8, 2026
90b9f27
ling fake driver: reset forgets main's once-per-driver device reading…
ajensenwaud Nov 8, 2026
b83cfcc
ling engine: free the window graphs' cache when the open's last drain…
ajensenwaud Nov 8, 2026
2d12323
kernel contract: tf_ling_swiglu_64 holds 8 static shared bytes (nvcc …
ajensenwaud Nov 8, 2026
206fd66
ling: settings through platform/environment.zig (main's lean rule); T…
ajensenwaud Nov 8, 2026
1839843
ling: named in TENSORFOLD_PROMPT_CACHE_KEEP_OTHERS's CUDA families, a…
ajensenwaud Nov 8, 2026
c002c68
ling: the loader runs each MoE layer's expert_bias through route.chec…
ajensenwaud Nov 9, 2026
fa79b9b
ling: KDA's head_dim and taps refused once, by cuda.kda.geometry when…
ajensenwaud Nov 9, 2026
30b3c87
ling tp: the NCCL environment setters through sys.env, as GLM's (Wind…
ajensenwaud Nov 9, 2026
553da96
ling: review: the device checks' scripts in the repo (oracle/ling_lay…
ajensenwaud Nov 10, 2026
8a13b7e
ling: review: the KDA width test goes through weights.open on a tempo…
ajensenwaud Nov 10, 2026
cb763f1
docs: the Ling recipe names its EXL3 pack (repository, revision, bit …
ajensenwaud Nov 10, 2026
79ff6ef
ling: grouped experts take the pair count and tile, as main's #2843 asks
ashhart Nov 12, 2026
6273797
tests: re-pin kernels.zig for #2340
ashhart Nov 12, 2026
e8f9845
tests: remove a blank line to keep the CUDA runner at 600 lines
ashhart Nov 19, 2026
5b359f1
docs: credit the Ling contributor by GitHub handle
ashhart Nov 19, 2026
e4bf17f
changelog: #2340 under Unreleased
ashhart Nov 19, 2026
File filter

Filter by extension

Filter by extension

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

## Unreleased

- Ling-3.1-flash on CUDA: `bailing_moe_v3` EXL3 packs serve on one GB10 or across two at TP=2, within the model's native 262,144-token window, with copy drafts from the prompt and kept prompt states; setups not tested, including longer contexts, are refused by name (#2340, refs #850). Thanks to @ajensenwaud.

- CLI: `tensorfold models` lists the chat checkpoints from the supported-models guide that fit this machine, largest first, with the memory each needs, a quality score from TensorFold Web's quality suite (receipts in `docs/receipts/quality-suite`) and a rough one-stream speed (measured on this chip, or estimated from another chip by memory bandwidth); `--all` adds the rest, `--json` adds `machine` and `catalog` to schema 1, and the cached checkpoints follow as before (#3483).

- gpt-oss: a first host-only slice reads `openai/gpt-oss-20b`'s config and refuses unknown or unsupported fields by name, checks all 459 tensor names of the published checkpoint, and adds an MXFP4 reader for 32-value E2M1 blocks with UE8M0 scales that never rewrites checkpoint bytes; nothing is registered with the server yet (#3513).
Expand Down
1 change: 1 addition & 0 deletions docs/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Diagnostics quote and escape the supplied text so it cannot create another termi
| `TENSORFOLD_UNIFIED_HOST_COUNTS` | Exactly `0` or `1`, checked when the CUDA backend starts. An integrated GPU on Linux admits against `/proc/meminfo` with `1` and against the CUDA pool with `0`; unset, it reads the pool under WSL2 (`WSL_DISTRO_NAME` set) and `/proc/meminfo` otherwise ([Windows](WINDOWS.md)) |
| `TF_HEAD_GEOMETRY` | Whole native-size nonnegative geometry count in the head benchmark |
| `TF_ROCE_GID_INDEX` | Whole index 0 through 2147483647; unset searches for a RoCE v2 IPv4 GID |
| `TF_LING_RANK`, `TF_LING_WORLD` | Ling on CUDA: rank `0` or `1` of world `1` or `2`; set both or neither (one GPU) |
| `TF_GEMMA4_CHUNK_SOLO` | Gemma 4 on CUDA: a multiple of 512 from 512 through 4096; unset, empty or 512 is off. Checked when the model loads, with the family's own message |
| `TF_DRAMA_PREFILL_ROWS` | Drama 3 on CUDA: whole prompt rows a chunk, 1 through 1024; default 1. Checked when the checkpoint opens, with its own message |
| `TF_DRAMA_REFERENCE_CACHE` | Drama 3 on CUDA: kept reference states, 0 (off) through 16; default 0. Checked when the checkpoint opens, with its own message |
Expand Down
5 changes: 5 additions & 0 deletions docs/kernel-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,11 @@ CUDA checks the same head (`joint_schema.cu`, `zig/tests/cuda/contract_js_*.zig`
lexical sums read from the engine's packed BF16 lm_head (`tf_js_lex_sums`) and the head's residual add and broadcast.
Every kernel has a planted control (`contract_js_controls.cuh`), each naming the gate that catches it.

CUDA also checks Ling-3.1-flash's own kernels (`tf-cuda-test ling-contract`): ling_glue's residual add, MoE combine (by
slot and by expert), row copy and expanded prompt MLA rows (`tf_ling_pattn`), and ling_act's SwiGLU in Ling's order at
both blocks with its 64-sums. The shared kernels the family calls (the mla image, the EXL3 finish-after, the
group-limited top-k) are checked with their own images.

HIP also checks the router over the rows a checkpoint already holds in bf16 (`tf_router_bf16`, and its fp16-activation
form), bit-equal to the fp32-rows router it replaces at 1 to 16 rows, with both kinds' non-finite plants through gate 1
and the exact sums of gate 4.
Expand Down
2 changes: 1 addition & 1 deletion docs/profiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Coverage includes:
with `TENSORFOLD_DORY_KV_PAGES=0` it refuses to load, by both names. With the switch unset, the startup line
shows `TENSORFOLD_DORY_KV_PAGES=1 (arithmetic, TF_KV_SHARE)` and kept states carry the same identity as `=1`.
- Every CUDA family whose host prompt cache the CUDA host builds (Nemotron, Nemotron Omni, GLM, MiniMax M3, Qwen3.5
dense/MoE, Flash Next, Kolibri-1, Gemma 4, Spark2.5, Dory, LFM2.5-24B-A2B): `TENSORFOLD_PROMPT_CACHE_KEEP_OTHERS`,
dense/MoE, Flash Next, Kolibri-1, Gemma 4, Spark2.5, Dory, LFM2.5-24B-A2B, Ling): `TENSORFOLD_PROMPT_CACHE_KEEP_OTHERS`,
exact `1` only.
- Flash Next on CUDA: `TF_FLASHNEXT_KV_PAGES`, `TF_FLASHNEXT_KV_PAGES_ALL`.
- Dory on CUDA: `TENSORFOLD_DORY_KV_PAGES`, full-attention caches in pool pages unless it is exactly `0`; unset,
Expand Down
1 change: 1 addition & 0 deletions docs/recipes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ For agent-assisted contributions, read the [TensorFold contributor skill](SKILL.
| Qwen4 dense | [Native preparation, device qualification pending](qwen4-dense.md) |
| Ternary Bonsai 2 27B | [MLX](ternary-bonsai-2.md) |
| GLM-5.3-Flash | [MLX on a 256 GB Mac, two-rank CUDA](glm-5.3-flash.md), [native CUDA](glm-5.3-flash-cuda.md) |
| Ling-3.1-flash | [Native CUDA, EXL3 on one or two GB10s, the native 262,144 window](ling-3.1-flash-cuda.md) |
| Gemma 4 26B-A4B | [MLX, fused one-row decode](gemma-4.md) |
| Gemma 4 31B | [Native Metal, affine 4-bit](gemma-4-native.md) |
| Gemma 4 12B | [Native Metal, affine 4-bit, MTP assistant](gemma-4-12b-native.md) |
Expand Down
74 changes: 74 additions & 0 deletions docs/recipes/ling-3.1-flash-cuda.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Ling-3.1-flash on CUDA

The native CUDA build serves inclusionAI's Ling-3.1-flash (`bailing_moe_v3`: 63 KDA and 9 MLA layers, 512 routed
experts) from EXL3 packs on one GPU or on two ranks over hosts, within the checkpoint's native window of 262,144
positions. Rank 0 serves HTTP and rank 1 follows its steps, as [GLM-5.3-Flash on CUDA](glm-5.3-flash-cuda.md) does.
The family started from @jschmied's TP=1 port (#874) and keeps his loader, references and checks.

## What it serves

- EXL3 packs (exllamav3's trellises, on main's shared EXL3 kernels). bf16 checkpoints load too, for the synthetic
checks; FP8 and NVFP4 checkpoints are refused by name.
- `--context` up to 262,144 (`max_position_embeddings`, rope theta 6,000,000, the plain rope). A longer context is
refused by name, and so is a config with `rope_scaling`.
- Drafts from the prompt's own text (copies). The checkpoint's MTP layer is not loaded.
- Prompt states for the server's prompt cache, in memory: the conv windows, each KDA layer's committed state and the
MLA rows below the state's position.

## The pack

The receipts below use
[`ajensenwaud/Ling-3.1-flash-1019-exl3-2.71bpw`](https://huggingface.co/ajensenwaud/Ling-3.1-flash-1019-exl3-2.71bpw) at
revision `ddb290bc9999f720849daaaed2a5bcaa7a033609` (MIT, converted from inclusionAI's FP8 release with exllamav3
v1.6.6): EXL3 at 2.71 bits per weight on average, 197 GB in 29 shards, about half on each rank at TP=2. Routed experts
take 3 bits in the first and last 17 MoE layers and 2 in the middle 34 (down projections 3 throughout); KDA attention
takes 4; MLA attention, the shared experts and the head take 6.

```bash
hf download ajensenwaud/Ling-3.1-flash-1019-exl3-2.71bpw --revision ddb290bc9999f720849daaaed2a5bcaa7a033609 \
--local-dir /models/Ling-3.1-flash-1019-exl3-2.71bpw
```

## Two ranks

`TF_LING_RANK` of `TF_LING_WORLD` (1 or 2) places each rank and `NCCL_COMM_ID` names rank 0's address and port; each
rank keeps a TCP line to rank 0 on the next port, and a rank that fails stops the other. Each rank loads half the KDA
and MLA heads, half of every MLP and expert width (EXL3's 128-wide blocks) and half the vocabulary of the head; the
latent cache is whole on both ranks. Give both ranks the same arguments:

```bash
# on rank 1
TF_LING_RANK=1 TF_LING_WORLD=2 NCCL_COMM_ID=192.0.2.1:29651 NCCL_SOCKET_IFNAME=enp1s0f0np0 NCCL_IB_HCA=rocep1s0f0 \
tensorfold-native serve /models/Ling-3.1-flash-1019-exl3-2.71bpw --context 262144
# on rank 0 (192.0.2.1)
TF_LING_RANK=0 TF_LING_WORLD=2 NCCL_COMM_ID=192.0.2.1:29651 NCCL_SOCKET_IFNAME=enp1s0f0np0 NCCL_IB_HCA=rocep1s0f0 \
tensorfold-native serve /models/Ling-3.1-flash-1019-exl3-2.71bpw --context 262144
```

Other formats and worlds other than 1 and 2 are refused at TP.

## Checks

`tf-cuda-test ling-contract` runs the family's own kernels through kernel-contract gates 1-4. `ling-route`, `ling-mla`
and `ling-clamp` check routing, MLA and the SwiGLU order against float64; `ling-synth` writes small checkpoints with the
real schema for `ling-forward-synth`, `ling-weights`, `ling-lanes` (chunked == whole, drafted == plain, resumed ==
fresh, concurrent == solo) and `ling-init-faults`. `ling-tp` runs a prompt and greedy rows at TP=1 or TP=2 and writes
every row's logits.

## Closeness and GSM8K

At TP=2 on that pack, against exllamav3 v1.6.6 on the same pack: four public texts of 512 tokens
(`zig/tests/cuda/oracle/ling_texts.json`), the first half as the prompt and the rest as forced decode rows. The
reference comes from `oracle/ling_ref_stream.py`, our rows from `tf-cuda-test ling-tp PACK OUT --ids <text>.ids`, and
the scores from `oracle/ling_check.py` (`--misses` lists every row where the top token differs, with both margins).
The floor is exllamav3 against itself: its run over all but the last 17 tokens against its full run, on the shared rows.

| Text | KL from exllamav3 | exllamav3's floor | Ratio | Top-1 agreement | True-token NLL vs exllamav3 |
|---|---:|---:|---:|---:|---:|
| Agent trace | 0.180 | 0.149 | 1.21x | 89.5% | +2.27% |
| Code | 0.00079 | 0.00141 | 0.56x | 99.6% | -0.95% |
| English prose | 0.00927 | 0.00657 | 1.41x | 93.0% | +1.20% |
| Chinese prose | 0.00555 | 0.00406 | 1.37x | 97.3% | +0.45% |

GSM8K, 500 fixed items, served at TP=2 with two streams (thinking on, temperature 1.0, top_p 0.95, top_k 20, seed
1234, a 32,768-token budget and a 65,536-token window): 488 of 500 (97.6%).
3 changes: 2 additions & 1 deletion zig/build/cuda.zig
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub fn targets(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bu
for (exlr8_build.denseModules(b, target, optimize, exlr8, exlr8_tests[0])) |m| runner.addImport(m.name, m.module);
runner.addImport("glm_cuda", glmCuda(b, target, optimize, cuda, mods.core, mods.lanes, mods.heat, mods.api));
@import("minimax_cuda.zig").targets(b, target, optimize, strip, cuda, mods.core, mods.lanes, runner);
for ([_]struct { []const u8, *std.Build.Module }{ .{ "kolibri1", kolibri1Module(b, target, optimize, cuda, mods.core, mods.lanes) }, .{ "dory", @import("dory.zig").module(b, target, optimize, cuda, mods.core, mods.lanes) }, .{ "idol_cuda", @import("idol_cuda.zig").targets(b, target, optimize, strip, cuda, mods.core) } }) |m| runner.addImport(m[0], m[1]);
for ([_]struct { []const u8, *std.Build.Module }{ .{ "kolibri1", kolibri1Module(b, target, optimize, cuda, mods.core, mods.lanes) }, .{ "dory", @import("dory.zig").module(b, target, optimize, cuda, mods.core, mods.lanes) }, .{ "idol_cuda", @import("idol_cuda.zig").targets(b, target, optimize, strip, cuda, mods.core) }, .{ "ling_cuda", engines_build.lingCuda(b, target, optimize, cuda, mods.core, mods.lanes, runner.import_table.get("glm_cuda").?) } }) |m| runner.addImport(m[0], m[1]);
runner.addImport("gemma4_cuda", @import("gemma4_cuda.zig").module(b, target, optimize, cuda, mods.core, mods.lanes));
runner.addImport("spark25", @import("spark25.zig").module(b, target, optimize, cuda, mods.core, mods.lanes));
// the served family and its engine, for the dots runner
Expand Down Expand Up @@ -373,6 +373,7 @@ pub fn hostTests(b: *std.Build, draft_ids: *std.Build.Module, build_options: *st
b.step("test-glm-grants-host", "GLM CUDA head-cost policy without a GPU").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = glm, .filters = &.{"shared head costs:"} })).step);
skip_drafts.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = glm, .filters = &.{"zero grant:"} })).step);
@import("glm_family_host.zig").steps(b, cuda, glm, mods, step);
engines_build.lingHost(b, host, cuda, mods.core, mods.lanes, glm, step);
@import("kolibri.zig").host(b, kolibri1Module(b, host, .debug, cuda, mods.core, mods.lanes), native_modules.api, step);
const gemma = @import("gemma4_cuda.zig").module(b, host, .debug, cuda, mods.core, mods.lanes);
b.step("test-gemma-grants-host", "Gemma assistant and DFlash head-cost grants without a GPU").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = gemma, .filters = &.{"shared head costs:"} })).step);
Expand Down
19 changes: 18 additions & 1 deletion zig/build/cuda_engines.zig
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ pub fn qwen3HostTest(b: *std.Build, m: *std.Build.Module, all: *std.Build.Step)
all.dependOn(&run.step);
}

/// The Ling-3.1-flash CUDA family over the runtime, the core, the lane core and the GLM kernels it reuses.
pub fn lingCuda(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, cuda: *std.Build.Module, core: *std.Build.Module, lanes: *std.Build.Module, glm: *std.Build.Module) *std.Build.Module {
const m = b.createModule(.{ .root_source_file = b.path("zig/src/families/ling/cuda.zig"), .target = target, .optimize = optimize, .link_libc = true });
for ([_]struct { []const u8, *std.Build.Module }{ .{ "glm_cuda", glm }, .{ "cuda", cuda }, .{ "core", core }, .{ "lanes", lanes } }) |x| m.addImport(x[0], x[1]);
m.addImport("engine_api", glm.import_table.get("engine_api").?); // its disk image names the rows store's types: GLM's, the server's
return m;
}

/// test-ling: Ling-3.1-flash's CUDA family on the host (loader, graph, engine, lanes and routing; no GPU work).
pub fn lingHost(b: *std.Build, host: std.Build.ResolvedTarget, cuda: *std.Build.Module, core: *std.Build.Module, lanes: *std.Build.Module, glm: *std.Build.Module, step: *std.Build.Step) void {
const run = b.addRunArtifact(b.addTest(.{ .root_module = lingCuda(b, host, .debug, cuda, core, lanes, glm) }));
step.dependOn(&run.step);
b.step("test-ling", "Ling-3.1-flash's CUDA family on the host: loader, graph, engine and lanes compile, no GPU work").dependOn(&run.step);
}

/// LFM2 (d1's decision model) on CUDA: config, weights, kernels and the forward that scores labels.
pub fn lfm2Module(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, cuda: *std.Build.Module, core: *std.Build.Module) *std.Build.Module {
return b.createModule(.{ .root_source_file = b.path("zig/src/families/lfm2/lfm2.zig"), .target = target, .optimize = optimize, .link_libc = true, .imports = &.{ .{ .name = "cuda", .module = cuda }, .{ .name = "core", .module = core } } });
Expand All @@ -66,6 +81,7 @@ pub fn engines(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bu
const api = qwen35.import_table.get("engine_api").?; // family()'s, so the server and qwen3_5 share one
const canon = canonModule(b, target, optimize);
const verbs = @import("tp.zig").verbsModule(b, target, optimize);
const glm = glmCudaShared(b, target, optimize, cuda, core, lanes, heat, api, canon, verbs);
const mod = b.createModule(.{
.root_source_file = b.path("zig/src/native/cuda.zig"),
.target = target,
Expand All @@ -80,9 +96,10 @@ pub fn engines(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bu
.{ .name = "lfm2", .module = lfm2Module(b, target, optimize, cuda, core) },
.{ .name = "core", .module = core },
.{ .name = "flashnext", .module = flashnextModule(b, target, optimize, cuda, core, lanes, qwen_vision, api) },
.{ .name = "glm_cuda", .module = glmCudaShared(b, target, optimize, cuda, core, lanes, heat, api, canon, verbs) },
.{ .name = "glm_cuda", .module = glm },
.{ .name = "qwen3_cuda", .module = qwen3Module(b, target, optimize, cuda, core, lanes, api) },
.{ .name = "minimax_m3_cuda", .module = @import("minimax_cuda.zig").module(b, target, optimize, cuda, core, lanes) },
.{ .name = "ling_cuda", .module = lingCuda(b, target, optimize, cuda, core, lanes, glm) },
.{ .name = "qwen35", .module = qwen35 },
.{ .name = "kolibri1", .module = @import("kolibri.zig").module(b, target, optimize, cuda, core, lanes) },
.{ .name = "gemma4_cuda", .module = @import("gemma4_cuda.zig").module(b, target, optimize, cuda, core, lanes) },
Expand Down
2 changes: 2 additions & 0 deletions zig/build/cuda_kernels.zig
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ pub const kernels = [_]Kernel{
.{ .name = "modelopt_pack", .flags = &.{"-O3"} }, // ours: ModelOpt tensors into the lane, prompt and expert layouts
.{ .name = "glm_kda", .flags = &.{ "-O3", "--fmad=false" } }, // GLM: the Python family's glm5_next/cuda/kda.cu
.{ .name = "glm_glue", .flags = &.{"-O3"} }, // ours: the Python family's Triton glue by hand, its PTX op for op
.{ .name = "ling_glue", .flags = glue }, // ours: Ling-3.1's bf16 glue at the HF model's rounding points
.{ .name = "ling_act", .flags = &.{"-O3"} }, // ours: Ling-3.1's dense SwiGLU in its clamp order (glm_swiglu.cuh)
.{ .name = "glm_ops", .flags = &.{"-O3"} }, // ours: GLM's integer work the Python family did in torch (the DSA token lists)
.{ .name = "glm_index", .flags = &.{"-O3"} }, // a prompt chunk's DSA scores and top-512 pools
.{ .name = "minimax_m3", .flags = glue }, // ours: MiniMax-M3.1-Flash's glue (norms, RoPE prep, routing, DSpark, tower RoPE)
Expand Down
Loading
Loading