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

Filter by extension

Filter by extension

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

## Unreleased

- HIP: `serve` with `--drafter` runs Qwen3.8-27B's DFlash2 drafter on the HIP engine through the lane core, where it was refused, and the drafter's weights and per-stream contexts count in the memory plan (#3665, refs #1563). Thanks to @AbrahamCete.

- HIP: an EXL3 input rotation and trellis linear kernel group (`exl3/exl3.hip`) at 2 to 8 bits, the HIP side of the projection DeepSeek-V4.1's CUDA path calls for its head, Engram's `wkv` and the indexer's `wk`, with sums in a fixed order so a row's bits do not depend on the rows beside it; nothing serves through it yet (#3314, refs #2065). Thanks to @Shoestring-dev.

- 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
2 changes: 1 addition & 1 deletion docs/community-benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tensorfold benchmark TensorFold/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-MLX-4bit

The examples call the command `tensorfold`. A source build's binary is `zig-out/native/bin/tensorfold-native`, and it takes the same arguments.

The command starts its own single-request `serve` on a loopback port, disables prompt reuse, warms each workload, and measures five repeats at sampled and greedy settings. It stops only the server it started, and a Ctrl-C or a closed terminal stops that server too; a second Ctrl-C exits at once and kills it. The default output limit is 256 tokens. The checkpoint must already be in the cache: `tensorfold benchmark` never downloads, so run `tensorfold pull` first. `--drafter DIR_OR_REPO` passes a drafter to engines that take one. Drafts stay on by default, and only `--serial` disables them. The default `--drafter auto` passes the target's own drafter when it is already cached (`z-lab/Qwen3.8-27B-DFlash2` for Qwen3.8-27B) and names it in the run output and the receipt; when it is not cached, the run passes none and says why. `--drafter none` passes none. When `--serial` overrides a given `--drafter`, the run prints a line saying so. The HIP engine runs no DFlash2 drafter yet, so a ROCm run passes none: a named `--drafter` is refused before the run starts, and `--drafter auto` on a checkpoint with its own drafter, such as Qwen3.8-27B, says the run passes no drafter, so the receipt's `drafter_repo_id` is null. `serve --drafter` on the HIP engine is refused before it loads. Without a drafter the HIP engine still drafts on its own, with the model's MTP head where the checkpoint has one and with copies from the stream's own context, so a ROCm run without a drafter is not a plain run; `--serial` gives one.
The command starts its own single-request `serve` on a loopback port, disables prompt reuse, warms each workload, and measures five repeats at sampled and greedy settings. It stops only the server it started, and a Ctrl-C or a closed terminal stops that server too; a second Ctrl-C exits at once and kills it. The default output limit is 256 tokens. The checkpoint must already be in the cache: `tensorfold benchmark` never downloads, so run `tensorfold pull` first. `--drafter DIR_OR_REPO` passes a drafter to engines that take one. Drafts stay on by default, and only `--serial` disables them. The default `--drafter auto` passes the target's own drafter when it is already cached (`z-lab/Qwen3.8-27B-DFlash2` for Qwen3.8-27B) and names it in the run output and the receipt; when it is not cached, the run passes none and says why. `--drafter none` passes none. When `--serial` overrides a given `--drafter`, the run prints a line saying so. On ROCm the HIP engine runs DFlash2 over the dense `qwen3_5` checkpoints, so a named `--drafter` passes it to them; for any other family a ROCm run refuses a named `--drafter` before the run starts. `--drafter auto` passes none on ROCm: a ROCm run drafts with a drafter only when one is named, and on a checkpoint with its own drafter, such as Qwen3.8-27B, `auto` says the run passes no drafter, so the receipt's `drafter_repo_id` is null. Without a drafter the HIP engine still drafts on its own, with the model's MTP head where the checkpoint has one and with copies from the stream's own context, so a ROCm run without a drafter is not a plain run; `--serial` gives one.

A managed run sizes its served context as `serve` does, unless `--context N` (1 through 10,000,000) names the
prompt plus reply capacity, and serves a bf16 attention cache unless `--kv-cache fp8` says otherwise. An attached
Expand Down
7 changes: 7 additions & 0 deletions docs/kernel-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,13 @@ HIP also checks Flash Next's indexer block score kernel (`tf_fn_idx_scores`, `co
`hip_records_sparse.zig`): staging each tile's rows of `q` in LDS when `heads * dims <= 512`, checked against the
fp64 relu-summed head dots with one control leaving out each row's last head (`shapes`).

HIP also checks EXL3's projections for decode rows (`exl3/exl3.hip`, CUDA's `exl3_block/linear.cu`): `tf_exl3_rot_in`
(bf16 rows times suh, rotated by 128 and rounded to fp16) and `tf_exl3_linear` at 2, 3, 4, 5, 6 and 8 bits (mul1) on 4
and 8 waves, each against float64 at deepseek_v41's indexer wk and Engram wkv (and its head at 8 bits) and the plan's
8-wave edge. The linear's gate 4 is exact: all-ones trellis states give one weight (-0.651 at every width), so 6144
terms of 4096 times it stay integers under 2^24 where fp16 overflows. Two controls: rot_in reading the next block's suh,
and the linear reading its input rows one row late.

On gfx12, HIP also checks the WMMA dense tile (`dense_wmma12_gemm`, both block geometries, fp32 and BF16 out). The
small block meets its depth-k bound. The big block (64-deep K steps over swizzled LDS rows) replaces the 32-deep block
it was before #2245's second lever, byte for byte: gate 3 runs a frozen copy of that block (`tf_ref_wmma12_k32`, in the
Expand Down
17 changes: 13 additions & 4 deletions docs/recipes/qwen3.8-27b.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,21 @@ tensorfold serve TensorFold/Qwen3.8-27B-MLX-4bit --name bench

DFlash2 is used automatically once pulled. On MLX, `--drafter none` disables that draft model;
`--no-drafts` disables all drafts on either backend. CUDA requires DFlash2 unless `--no-drafts` is set.
The HIP engine runs no DFlash2 drafter yet: `serve --drafter` is refused before the engine opens the GPU or
loads any weights. Refusing DFlash2 does not turn off the engine's own drafts: the model's MTP head where the
On HIP, `serve --drafter DIR` runs the DFlash2 drafter over the dense checkpoints: the target taps the
drafter's layers into a ring beside each stream's caches, budgeted before the streams are sized, and the
drafter's chains reach the round loop through the lane core's drafter wrapper. It runs on one rank at 4 bits:
`--drafter` with `--tp` above 1 and `--drafter-bits 0` are refused before any load, and the other HIP families
(the sparse `qwen3_5_moe` among them) refuse `--drafter` by name, as BF16 checkpoints do: the engine times no
BF16 windows to price the drafter's rounds. Prompts reach the drafter whole, as their prompt pass ends.
Without `--drafter` the engine still drafts on its own: the model's MTP head where the
checkpoint has one, and copies from the stream's own context. `TensorFold/Qwen3.8-27B-MLX-4bit` has no MTP
head, so on HIP it drafts copies only. `--mtp-drafts 0` stops the MTP head's drafts alone; `--no-drafts` turns
both off and decodes plain.
head, so on HIP it then drafts copies only. `--mtp-drafts 0` stops the MTP head's drafts alone; `--no-drafts`
turns every draft off (the drafter is not loaded) and decodes plain.
The target verifies every proposed token against its own serial sample.
`tf-qwen35-test check <model dir> --drafter DIR` (`zig build tf-qwen35-test -Dhip=true`) runs the HIP model checks
with the drafter in front of the target, opened as the server opens it, so the lane checks compare drafted
replies with serial ones (greedy and seeded), solo with together and graph with eager under the drafter; without
`--drafter` the 27B has no draft head and skips the drafted == serial checks.

## CUDA

Expand Down
28 changes: 5 additions & 23 deletions zig/build/hip.zig
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,14 @@ pub fn steps(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.buil
.imports = &.{ .{ .name = "hip", .module = gpu.hip }, .{ .name = "core", .module = gpu.hip.import_table.get("core").? }, .{ .name = "lighton_ocr", .module = gpu.lighton } },
}) });
b.step("tf-lighton-hip-capture", "Capture native HIP LightOnOCR stages against a local reference fixture").dependOn(&b.addInstallArtifact(lighton_capture, .{}).step);
const qwen_capture_host = captureQwen(b, b.graph.host, host);
const qwen_capture_host = @import("lighton_hip.zig").captureQwen(b, b.graph.host, host);
b.step("check-qwen-hip-capture-host", "Compile the Qwen HIP fixture capture without device execution").dependOn(&qwen_capture_host.step);
const qwen_capture_gpu = captureQwen(b, target, gpu);
const qwen_capture_gpu = @import("lighton_hip.zig").captureQwen(b, target, gpu);
b.step("tf-qwen-hip-capture", "Capture native Qwen HIP stages against local reference fixtures").dependOn(&b.addInstallArtifact(qwen_capture_gpu, .{}).step);
for ([_][]const u8{ "lighton", "qwen" }) |family_name| {
const exact_host = exactTool(b, b.graph.host, host, family_name);
const exact_host = @import("lighton_hip.zig").exactTool(b, b.graph.host, host, family_name);
b.step(b.fmt("check-{s}-hip-exact-host", .{family_name}), "Compile native HIP image consistency checks without execution").dependOn(&exact_host.step);
const exact_gpu = exactTool(b, target, gpu, family_name);
const exact_gpu = @import("lighton_hip.zig").exactTool(b, target, gpu, family_name);
b.step(b.fmt("tf-{s}-hip-exact", .{family_name}), "Build native HIP image consistency checks").dependOn(&b.addInstallArtifact(exact_gpu, .{}).step);
}
const native = server(b, target, gpu, build_options);
Expand Down Expand Up @@ -478,25 +478,6 @@ pub fn server(b: *std.Build, target: std.Build.ResolvedTarget, e: Engine, build_
_ = @import("server.zig").addTo(b, exe.root_module, target, .ReleaseSafe);
return exe;
}
fn captureQwen(b: *std.Build, target: std.Build.ResolvedTarget, e: Engine) *std.Build.Step.Compile {
return b.addExecutable(.{ .name = "tf-qwen-hip-capture", .root_module = b.createModule(.{
.root_source_file = b.path("zig/tests/lighton_hip/qwen_capture.zig"),
.target = target,
.optimize = .ReleaseSafe,
.link_libc = true,
.imports = &.{ .{ .name = "hip", .module = e.hip }, .{ .name = "core", .module = e.hip.import_table.get("core").? }, .{ .name = "qwen3_5", .module = e.family }, .{ .name = "lanes", .module = e.lanes }, .{ .name = "qwen_hip_vision", .module = e.family.import_table.get("qwen_hip_vision").? } },
}) });
}
fn exactTool(b: *std.Build, target: std.Build.ResolvedTarget, e: Engine, family_name: []const u8) *std.Build.Step.Compile {
const file = if (std.mem.eql(u8, family_name, "lighton")) "exact.zig" else "qwen_exact.zig";
return b.addExecutable(.{ .name = b.fmt("tf-{s}-hip-exact", .{family_name}), .root_module = b.createModule(.{
.root_source_file = b.path(b.fmt("zig/tests/lighton_hip/{s}", .{file})),
.target = target,
.optimize = .ReleaseSafe,
.link_libc = true,
.imports = &.{ .{ .name = "hip", .module = e.hip }, .{ .name = "core", .module = e.hip.import_table.get("core").? }, .{ .name = "lighton_ocr", .module = e.lighton }, .{ .name = "qwen3_5", .module = e.family }, .{ .name = "lanes", .module = e.lanes }, .{ .name = "qwen_hip_vision", .module = e.family.import_table.get("qwen_hip_vision").? } },
}) });
}
/// A group's source and whether it compiles with IEEE arithmetic (`strict`: -O2 -fno-fast-math, IEEE denormals).
const Source = struct { path: []const u8, strict: bool = false };
/// The model-free kernels' source groups, in zig/src/hip/kernels.zig's Group order.
Expand All @@ -517,6 +498,7 @@ const groups = [_]Source{
.{ .path = "lighton_ocr.hip", .strict = true },
.{ .path = "qwen_vision.hip", .strict = true },
.{ .path = "draft/draft.hip" },
.{ .path = "exl3/exl3.hip" },
};
/// What the group sources include, so an edit to one rebuilds them.
const headers = [_][]const u8{
Expand Down
24 changes: 23 additions & 1 deletion zig/build/lighton_hip.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! HIP LightOnOCR module construction and host checks, using the native server's shared engine types.
//! HIP LightOnOCR modules, host checks and the zig/tests/lighton_hip tools, on the server's shared engine types.
const std = @import("std");
const Engine = @import("hip.zig").Engine;

pub fn module(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, hip: *std.Build.Module, core: *std.Build.Module, lanes: *std.Build.Module, api: *std.Build.Module, serve: *std.Build.Module) *std.Build.Module {
return b.createModule(.{ .root_source_file = b.path("zig/src/families/lighton_ocr/hip.zig"), .target = target, .optimize = optimize, .link_libc = true, .imports = &.{ .{ .name = "hip", .module = hip }, .{ .name = "core", .module = core }, .{ .name = "lanes", .module = lanes }, .{ .name = "engine_api", .module = api }, .{ .name = "hip_serve", .module = serve } } });
Expand All @@ -14,3 +15,24 @@ pub fn host(b: *std.Build, m: *std.Build.Module, step: *std.Build.Step) void {
b.step("test-lighton-hip-host", "LightOnOCR HIP image, state and admission tests without devices").dependOn(&run.step);
step.dependOn(&run.step);
}

pub fn captureQwen(b: *std.Build, target: std.Build.ResolvedTarget, e: Engine) *std.Build.Step.Compile {
return b.addExecutable(.{ .name = "tf-qwen-hip-capture", .root_module = b.createModule(.{
.root_source_file = b.path("zig/tests/lighton_hip/qwen_capture.zig"),
.target = target,
.optimize = .ReleaseSafe,
.link_libc = true,
.imports = &.{ .{ .name = "hip", .module = e.hip }, .{ .name = "core", .module = e.hip.import_table.get("core").? }, .{ .name = "qwen3_5", .module = e.family }, .{ .name = "lanes", .module = e.lanes }, .{ .name = "qwen_hip_vision", .module = e.family.import_table.get("qwen_hip_vision").? } },
}) });
}

pub fn exactTool(b: *std.Build, target: std.Build.ResolvedTarget, e: Engine, family_name: []const u8) *std.Build.Step.Compile {
const file = if (std.mem.eql(u8, family_name, "lighton")) "exact.zig" else "qwen_exact.zig";
return b.addExecutable(.{ .name = b.fmt("tf-{s}-hip-exact", .{family_name}), .root_module = b.createModule(.{
.root_source_file = b.path(b.fmt("zig/tests/lighton_hip/{s}", .{file})),
.target = target,
.optimize = .ReleaseSafe,
.link_libc = true,
.imports = &.{ .{ .name = "hip", .module = e.hip }, .{ .name = "core", .module = e.hip.import_table.get("core").? }, .{ .name = "lighton_ocr", .module = e.lighton }, .{ .name = "qwen3_5", .module = e.family }, .{ .name = "lanes", .module = e.lanes }, .{ .name = "qwen_hip_vision", .module = e.family.import_table.get("qwen_hip_vision").? } },
}) });
}
Loading
Loading