Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
b731206
feat(hip): the model-free kernels on #463's runtime: attention, Delta…
BlivionIaG Oct 10, 2026
67d9479
feat(core): weight formats behind one interface, MLX affine 2- to 8-b…
BlivionIaG Oct 10, 2026
48abd99
feat(core): a kernel registry that picks a product's tile by tuned co…
BlivionIaG Oct 10, 2026
6254228
feat(hip): the MLX affine products: dot2 tiles, the gfx11 matrix-core…
BlivionIaG Oct 10, 2026
9b6b260
docs(hip): the device bitcode of Ubuntu's packaged HIP, and no rocWMM…
BlivionIaG Oct 11, 2026
1152c67
Merge branch 'hip-kernels-ops' into hip-kernels-affine
BlivionIaG Oct 11, 2026
df83c6f
Merge branch 'hip-kernels-ops' into hip-kernels-affine
BlivionIaG Oct 11, 2026
5d05894
chore(hip): gdn_prefill.hip drops the vLLM SPDX lines it kept from th…
BlivionIaG Oct 11, 2026
a579284
Merge branch 'hip-kernels-affine' into fam-new
BlivionIaG Oct 11, 2026
e6c11fb
feat(qwen3_5): the GPU backends' checkpoint loader, on the host
BlivionIaG Oct 10, 2026
eb9bd0f
fix(qwen3_5): un-center an MTP head shipped zero-centered
BlivionIaG Oct 11, 2026
4c231bf
feat(qwen3_5): the HIP config refuses what the kernels do not compute…
BlivionIaG Oct 11, 2026
02c1dd6
Merge remote-tracking branch 'upstream/main' into fam-r2
BlivionIaG Oct 12, 2026
57fadd1
feat(hip): the runtime pieces an engine uses beyond #463's model-free…
BlivionIaG Oct 10, 2026
211ea81
feat(hip): the kernels a tensor-parallel rank and the MTP head add
BlivionIaG Oct 10, 2026
42664f9
feat(qwen3_5): the Qwen3.5 / Qwen3.6 engine on HIP, its native server…
BlivionIaG Oct 10, 2026
3d9bd2e
feat(hip): one rank source: --speed-up is refused, the HIP engine's r…
BlivionIaG Oct 10, 2026
a25c8e2
feat(qwen3_5): the HIP prompt cache serves serial requests too
BlivionIaG Oct 10, 2026
3092774
test(qwen3_5): chat with the prompt cache equals chat without it thro…
BlivionIaG Oct 10, 2026
9a4e10f
feat(qwen3_5): a prompt runs 512-row chunks while other streams decode
BlivionIaG Oct 11, 2026
3f396fc
feat(hip): RDNA4 runs on the dot2 tiles; matrix=on is refused where n…
BlivionIaG Oct 11, 2026
fc795cb
test(qwen3_5): serve_rewind.py's docstring on one line, as the lean c…
BlivionIaG Oct 11, 2026
10f67d9
refactor(qwen3_5): the engine reaches the other ranks through hip/col…
BlivionIaG Oct 11, 2026
7f5fd5b
build(hip): the HIP server's CLI module takes EXLR8's import, as main…
BlivionIaG Oct 12, 2026
13961db
feat(hip): tensor parallelism over RCCL, behind hip/collective.zig
BlivionIaG Oct 11, 2026
ba0bc3c
feat(hip): the graph cache by shape in the hip module, for every HIP …
BlivionIaG Oct 12, 2026
905d9e9
feat(hip): a step recorded as graphs cut at its collectives, the coll…
BlivionIaG Oct 12, 2026
5480055
feat(hip): the graph cache over any replayable step, a caller's own k…
BlivionIaG Oct 12, 2026
ebe69eb
feat(qwen3_5): HIP rounds record split graphs: the collectives run be…
BlivionIaG Oct 12, 2026
10926cf
feat(qwen3_5): HIP rounds replay split graphs at any world size, RCCL…
BlivionIaG Oct 12, 2026
66d8a19
fix(qwen3_5): every rank sizes its streams for rank 0's window, so a …
BlivionIaG Oct 12, 2026
d47b0f8
perf(qwen3_5): the HIP loader drops each part's mapped pages once it …
BlivionIaG Oct 13, 2026
1ae1078
style(hip): the ops headers end without a blank line, as git diff --c…
BlivionIaG Oct 14, 2026
47612d0
Merge branch 'hip-kernels-ops' into qwen35-family (ops headers end wi…
BlivionIaG Oct 14, 2026
3850523
Merge branch 'qwen35-family' into qwen35-rccl (ops headers end withou…
BlivionIaG Oct 14, 2026
5537d6a
fix(hip): the paged prefill tile calls expf, as the flat tile does
BlivionIaG Oct 14, 2026
9178585
Merge branch 'hip-kernels-ops' into qwen35-family (the paged prefill …
BlivionIaG Oct 14, 2026
f5281d5
Merge branch 'qwen35-family' into qwen35-rccl (the paged prefill tile…
BlivionIaG Oct 14, 2026
d91b074
fix(hip): one fp32 DeltaNet recurrence at every length; the chunked p…
BlivionIaG Oct 14, 2026
1da7042
Merge branch 'hip-kernels-ops' into qwen35-family (one fp32 DeltaNet …
BlivionIaG Oct 14, 2026
205b800
Merge branch 'qwen35-family' into qwen35-rccl (one fp32 DeltaNet recu…
BlivionIaG Oct 14, 2026
1bdd859
refactor(hip): the policy's gdn switch goes with the chunked recurren…
BlivionIaG Oct 14, 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
Prev Previous commit
Next Next commit
feat(qwen3_5): the HIP config refuses what the kernels do not compute…
…, and reads layers, mrope and end ids

config_checks.zig takes qwen27/config.zig's rules to the HIP geometry: the
activation (silu), the attention gate (the swish gate, att * sigmoid(gate), and
no bias), the recurrent state type (fp32, under either key), the sizes the
kernels index with 32-bit counts, each layer's kind from layer_types in any
order, the mrope sections (three, filling half the rotary width,
interleaved), max_position_embeddings, and the end ids of config.json and
generation_config.json. The Qwen3.8-27B names <|im_end|> only in
generation_config.json. 0 and 1 count as false and true, as the 0.8B 2-bit
conversion writes them.

Co-authored-by: ashhart <71890694+ashhart@users.noreply.github.com>
  • Loading branch information
BlivionIaG and ashhart committed Oct 11, 2026
commit 4c231bfc7dbaffef3c5647363e32944fcb92ae00
51 changes: 38 additions & 13 deletions zig/src/families/qwen3_5/config.zig
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ pub const Error = error{
InvalidMoe,
InvalidRotary,
InvalidLayerTypes,
} || std.mem.Allocator.Error || std.json.ParseError(std.json.Scanner);
} || checks.Error || std.mem.Allocator.Error || std.json.ParseError(std.json.Scanner);

pub const checks = @import("config_checks.zig");

/// The Python `Spec`, plus the shared expert's width and the MTP layer count the config declares.
pub const Spec = struct {
Expand All @@ -295,10 +297,14 @@ pub const Spec = struct {
moe_width: usize,
shared_width: usize,
mtp_layers: usize,
/// Each layer's kind, true for full attention (the others are gated delta-net).
full_layers: [checks.max_layers]bool = @splat(false),
mrope: checks.Mrope = .{},
max_position: usize = 262144,

/// Whether layer `index` is full attention (the others are gated delta-net).
pub fn full(s: Spec, index: usize) bool {
return (index + 1) % s.full_every == 0;
return s.full_layers[index];
}

pub fn keyWidth(s: Spec) usize {
Expand Down Expand Up @@ -352,7 +358,7 @@ pub fn geometry(tower: std.json.ObjectMap, bits: u8, group_size: u16) Error!Spec
if (!(product >= 0 and product <= @as(f64, @floatFromInt(per_head)))) return error.InvalidRotary;
const rotary: usize = @intFromFloat(product);
const base = try numberOf(rope.get("rope_theta") orelse if (truthy(tower.get("rope_theta"))) tower.get("rope_theta").? else .{ .integer = 10_000_000 });
const spec: Spec = .{
var spec: Spec = .{
.hidden = model_width,
.intermediate = try optionalInt(tower, "intermediate_size", 0),
.n_layers = try requiredInt(tower, "num_hidden_layers"),
Expand All @@ -379,13 +385,11 @@ pub fn geometry(tower: std.json.ObjectMap, bits: u8, group_size: u16) Error!Spec
};
if (rotary % 2 != 0 or rotary == 0 or rotary > per_head) return error.InvalidRotary;
if (spec.full_every == 0 or attn_heads == 0) return error.InvalidConfig;
if (tower.get("layer_types")) |kinds| if (kinds != .null) {
if (kinds != .array) return error.InvalidLayerTypes;
for (kinds.array.items, 0..) |item, i| {
const want = if (spec.full(i)) "full_attention" else "linear_attention";
if (item != .string or !eql(item.string, want)) return error.InvalidLayerTypes;
}
};
try checks.computes(tower);
try checks.products(.{ .hidden = spec.hidden, .intermediate = spec.intermediate, .vocab = spec.vocab, .heads = spec.heads, .kv_heads = spec.kv_heads, .head_dim = spec.head_dim, .key_heads = spec.key_heads, .value_heads = spec.value_heads, .key_dim = spec.key_dim, .value_dim = spec.value_dim, .conv = spec.conv, .experts = spec.experts, .moe_width = spec.moe_width, .shared_width = spec.shared_width });
try checks.layers(&spec.full_layers, tower, spec.n_layers, spec.full_every);
spec.mrope = try checks.mrope(rope, rotary);
spec.max_position = try checks.maxPosition(tower);
return spec;
}

Expand Down Expand Up @@ -502,17 +506,38 @@ test "a top-level config, the partial rotary default and the MoE fields" {
try std.testing.expectEqual(@as(usize, 4), s.full_every);
}

test "the geometry refuses what the kernels do not compute and sizes past 32 bits" {
const a = std.testing.allocator;
var arena: std.heap.ArenaAllocator = .init(a);
defer arena.deinit();
const cases = [_]struct { []const u8, []const u8, Error }{
.{ "\"rms_norm_eps\"", "\"hidden_act\": \"gelu\", \"rms_norm_eps\"", error.UnsupportedActivation },
.{ "\"rms_norm_eps\"", "\"output_gate_type\": \"sigmoid\", \"rms_norm_eps\"", error.UnsupportedAttentionGate },
.{ "\"rms_norm_eps\"", "\"mamba_ssm_dtype\": \"bfloat16\", \"rms_norm_eps\"", error.UnsupportedStateType },
.{ "\"vocab_size\": 248320", "\"vocab_size\": 1048576", error.InvalidConfig },
};
for (cases) |c| {
const text = try std.mem.replaceOwned(u8, a, sample_text, c[0], c[1]);
defer a.free(text);
try std.testing.expectError(c[2], geometry(try textTower(try declared(arena.allocator(), text)), 4, 64));
}
}

test "the Python loader's refusals" {
const a = std.testing.allocator;
var arena: std.heap.ArenaAllocator = .init(a);
defer arena.deinit();
const wrong = try std.mem.replaceOwned(u8, a, sample_text, "\"qwen3_5\"", "\"llama\"");
defer a.free(wrong);
try std.testing.expectError(error.UnsupportedModel, declared(arena.allocator(), wrong));
const types = try std.mem.replaceOwned(u8, a, sample_text, "\"full_attention\"],", "\"linear_attention\"],");
// any mix of the two kinds is read as written; another kind is refused
const mixed = try std.mem.replaceOwned(u8, a, sample_text, "\"full_attention\"],", "\"linear_attention\"],");
defer a.free(mixed);
const s = try geometry(try textTower(try declared(arena.allocator(), mixed)), 4, 64);
try std.testing.expect(s.full(3) and !s.full(7));
const types = try std.mem.replaceOwned(u8, a, sample_text, "\"full_attention\"],", "\"sliding_attention\"],");
defer a.free(types);
const tower = try textTower(try declared(arena.allocator(), types));
try std.testing.expectError(error.InvalidLayerTypes, geometry(tower, 4, 64));
try std.testing.expectError(error.InvalidLayerTypes, geometry(try textTower(try declared(arena.allocator(), types)), 4, 64));
const moe = try std.mem.replaceOwned(u8, a, sample_text, "\"vocab_size\"", "\"num_experts\": 8, \"num_experts_per_tok\": 9, \"vocab_size\"");
defer a.free(moe);
try std.testing.expectError(error.InvalidMoe, geometry(try textTower(try declared(arena.allocator(), moe)), 4, 64));
Expand Down
221 changes: 221 additions & 0 deletions zig/src/families/qwen3_5/config_checks.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
//! What a Qwen3.5 config must declare for the HIP engine: activation, gate, state, layers, rope, end ids, sizes.

const std = @import("std");

pub const Error = error{ UnsupportedActivation, UnsupportedAttentionGate, UnsupportedStateType, BadEos, TooManyEos, MissingEos, InvalidConfig, InvalidLayerTypes, InvalidRotary };

/// The most end ids a checkpoint may declare across config.json and generation_config.json.
pub const max_eos = 8;

/// The most decoder layers a config may declare.
pub const max_layers = 128;

/// Each layer's kind (true: full attention), from `layer_types` in any order, else every `interval`-th layer.
pub fn layers(out: *[max_layers]bool, tower: std.json.ObjectMap, count: usize, interval: usize) Error!void {
if (count == 0 or count > max_layers or interval == 0) return error.InvalidConfig;
out.* = @splat(false);
const list = tower.get("layer_types") orelse .null;
if (list == .null) {
for (out[0..count], 0..) |*full, i| full.* = (i + 1) % interval == 0;
return;
}
if (list != .array or list.array.items.len != count) return error.InvalidLayerTypes;
for (list.array.items, out[0..count]) |item, *full| {
if (isString(item, "full_attention")) full.* = true else if (!isString(item, "linear_attention")) return error.InvalidLayerTypes;
}
}

/// The multimodal rope's three sections and their interleaving: the text and image positions a vision tower feeds.
pub const Mrope = struct { section: [3]usize = .{ 11, 11, 10 }, interleaved: bool = true };

/// `rope_parameters`' mrope fields: three sections filling half the rotary width, interleaved (the kernels' layout).
pub fn mrope(rope: std.json.ObjectMap, rotary: usize) Error!Mrope {
var m: Mrope = .{};
if (rope.get("mrope_interleaved")) |v| if (!isFlag(v, true)) return error.InvalidRotary;
const list = rope.get("mrope_section") orelse return m;
if (list == .null) return m;
if (list != .array or list.array.items.len != 3) return error.InvalidRotary;
var sum: usize = 0;
for (list.array.items, &m.section) |item, *x| {
if (item != .integer or item.integer < 0) return error.InvalidRotary;
x.* = @intCast(item.integer);
sum += x.*;
}
if (sum * 2 != rotary) return error.InvalidRotary;
return m;
}

/// `max_position_embeddings`: a positive token count, else the family's 262,144.
pub fn maxPosition(tower: std.json.ObjectMap) Error!usize {
const v = tower.get("max_position_embeddings") orelse return 262144;
if (v != .integer or v.integer <= 0 or v.integer > std.math.maxInt(u32)) return error.InvalidConfig;
return @intCast(v.integer);
}

/// Refuses a tower whose activation, attention gate, attention bias or recurrent state type the kernels do not compute.
pub fn computes(tower: std.json.ObjectMap) Error!void {
if (tower.get("hidden_act")) |v| if (!isString(v, "silu")) return error.UnsupportedActivation;
// "swish" is the gate the kernels apply, att * sigmoid(gate), as the qwen27 family reads it
if (tower.get("output_gate_type")) |v| if (!isString(v, "swish")) return error.UnsupportedAttentionGate;
if (tower.get("attn_output_gate")) |v| if (!isFlag(v, true)) return error.UnsupportedAttentionGate;
if (tower.get("attention_bias")) |v| if (!isFlag(v, false)) return error.UnsupportedAttentionGate;
inline for (.{ "linear_attn_state_dtype", "mamba_ssm_dtype" }) |key| {
if (tower.get(key)) |v| if (!isString(v, "float32")) return error.UnsupportedStateType;
}
}

/// The sizes the kernels index with 32-bit counts and the host multiplies: every product must fit.
pub const Sizes = struct {
hidden: usize,
intermediate: usize,
vocab: usize,
heads: usize,
kv_heads: usize,
head_dim: usize,
key_heads: usize,
value_heads: usize,
key_dim: usize,
value_dim: usize,
conv: usize,
experts: usize,
moe_width: usize,
shared_width: usize,
};

pub fn products(s: Sizes) Error!void {
if (s.heads % s.kv_heads != 0 or s.value_heads % s.key_heads != 0) return error.InvalidConfig;
const limit: usize = std.math.maxInt(u32);
const q = try mul(try mul(s.heads, s.head_dim), 2);
const kv = try mul(s.kv_heads, s.head_dim);
const k = try mul(s.key_heads, s.key_dim);
const v = try mul(s.value_heads, s.value_dim);
const conv = try mul(try add(try mul(k, 2), v), s.conv);
const state = try mul(try mul(v, s.key_dim), 4);
const widths = [_]usize{ q, kv, conv, state, try mul(s.hidden, s.intermediate), try mul(s.hidden, s.vocab), try mul(s.hidden, try mul(s.experts, s.moe_width)), try mul(s.hidden, s.shared_width) };
for (widths) |w| if (w > limit) return error.InvalidConfig;
}

/// The end ids, config.json's (root, then text tower) and generation_config.json's, each once and below `vocab`.
pub fn eos(out: *[max_eos]u32, root: std.json.ObjectMap, tower: std.json.ObjectMap, generation: ?std.json.ObjectMap, vocab: usize) Error![]const u32 {
var n: usize = 0;
const holders = [_]?std.json.Value{ root.get("eos_token_id"), tower.get("eos_token_id"), if (generation) |g| g.get("eos_token_id") else null };
for (holders) |h| if (h) |v| try collect(out, &n, v, vocab);
if (n == 0) return error.MissingEos;
return out[0..n];
}

fn collect(out: *[max_eos]u32, n: *usize, v: std.json.Value, vocab: usize) Error!void {
switch (v) {
.null => {},
.array => |list| for (list.items) |item| try collect(out, n, item, vocab),
.integer => |i| {
if (i < 0 or i >= vocab) return error.BadEos;
const id: u32 = @intCast(i);
if (std.mem.indexOfScalar(u32, out[0..n.*], id) != null) return;
if (n.* == max_eos) return error.TooManyEos;
out[n.*] = id;
n.* += 1;
},
else => return error.BadEos,
}
}

fn mul(a: usize, b: usize) Error!usize {
return std.math.mul(usize, a, b) catch error.InvalidConfig;
}

fn add(a: usize, b: usize) Error!usize {
return std.math.add(usize, a, b) catch error.InvalidConfig;
}

fn isString(v: std.json.Value, want: []const u8) bool {
return v == .string and std.mem.eql(u8, v.string, want);
}

/// A JSON boolean, or the 0 / 1 some conversions write in its place.
fn isFlag(v: std.json.Value, want: bool) bool {
return switch (v) {
.bool => |b| b == want,
.integer => |i| i == @intFromBool(want),
else => false,
};
}

fn parsed(a: std.mem.Allocator, text: []const u8) !std.json.ObjectMap {
return (try std.json.parseFromSliceLeaky(std.json.Value, a, text, .{})).object;
}

test "the computed parts: silu, the swish gate, no bias, fp32 state; 0 and 1 stand for false and true" {
var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
defer arena.deinit();
const a = arena.allocator();
try computes(try parsed(a, "{}"));
try computes(try parsed(a, "{\"hidden_act\":\"silu\",\"output_gate_type\":\"swish\",\"attn_output_gate\":1,\"attention_bias\":0,\"mamba_ssm_dtype\":\"float32\"}"));
try std.testing.expectError(error.UnsupportedActivation, computes(try parsed(a, "{\"hidden_act\":\"gelu\"}")));
try std.testing.expectError(error.UnsupportedAttentionGate, computes(try parsed(a, "{\"output_gate_type\":\"sigmoid\"}")));
try std.testing.expectError(error.UnsupportedAttentionGate, computes(try parsed(a, "{\"attn_output_gate\":false}")));
try std.testing.expectError(error.UnsupportedAttentionGate, computes(try parsed(a, "{\"attention_bias\":true}")));
try std.testing.expectError(error.UnsupportedStateType, computes(try parsed(a, "{\"mamba_ssm_dtype\":\"bfloat16\"}")));
try std.testing.expectError(error.UnsupportedStateType, computes(try parsed(a, "{\"linear_attn_state_dtype\":\"float16\"}")));
}

test "end ids from config.json and generation_config.json, once each, refused past the vocabulary" {
var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
defer arena.deinit();
const a = arena.allocator();
var out: [max_eos]u32 = undefined;
// the 27B: config.json names 248044, generation_config.json adds 248046
const ids = try eos(&out, try parsed(a, "{}"), try parsed(a, "{\"eos_token_id\":248044}"), try parsed(a, "{\"eos_token_id\":[248046,248044]}"), 248320);
try std.testing.expectEqualSlices(u32, &.{ 248044, 248046 }, ids);
try std.testing.expectError(error.MissingEos, eos(&out, try parsed(a, "{}"), try parsed(a, "{}"), null, 10));
try std.testing.expectError(error.BadEos, eos(&out, try parsed(a, "{\"eos_token_id\":10}"), try parsed(a, "{}"), null, 10));
try std.testing.expectError(error.BadEos, eos(&out, try parsed(a, "{\"eos_token_id\":\"2\"}"), try parsed(a, "{}"), null, 10));
try std.testing.expectError(error.TooManyEos, eos(&out, try parsed(a, "{\"eos_token_id\":[0,1,2,3,4,5,6,7,8]}"), try parsed(a, "{}"), null, 10));
}

test "sizes: products past 32 bits and uneven head groups are refused" {
const ok: Sizes = .{ .hidden = 5120, .intermediate = 17408, .vocab = 248320, .heads = 24, .kv_heads = 4, .head_dim = 256, .key_heads = 16, .value_heads = 48, .key_dim = 128, .value_dim = 128, .conv = 4, .experts = 0, .moe_width = 0, .shared_width = 0 };
try products(ok);
var moe = ok;
moe.experts = 256;
moe.moe_width = 512;
try products(moe);
var wide = ok;
wide.vocab = 1 << 20;
try std.testing.expectError(error.InvalidConfig, products(wide));
var uneven = ok;
uneven.kv_heads = 5;
try std.testing.expectError(error.InvalidConfig, products(uneven));
var huge = ok;
huge.hidden = std.math.maxInt(usize) / 2;
try std.testing.expectError(error.InvalidConfig, products(huge));
}

test "layer kinds: any order from layer_types, the interval otherwise; wrong length or names refused" {
var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
defer arena.deinit();
const a = arena.allocator();
var kinds: [max_layers]bool = undefined;
try layers(&kinds, try parsed(a, "{}"), 8, 4);
try std.testing.expectEqualSlices(bool, &.{ false, false, false, true, false, false, false, true }, kinds[0..8]);
try layers(&kinds, try parsed(a, "{\"layer_types\":[\"full_attention\",\"linear_attention\",\"full_attention\"]}"), 3, 4);
try std.testing.expectEqualSlices(bool, &.{ true, false, true }, kinds[0..3]);
try std.testing.expectError(error.InvalidLayerTypes, layers(&kinds, try parsed(a, "{\"layer_types\":[\"full_attention\"]}"), 3, 4));
try std.testing.expectError(error.InvalidLayerTypes, layers(&kinds, try parsed(a, "{\"layer_types\":[\"sliding_attention\"]}"), 1, 4));
try std.testing.expectError(error.InvalidConfig, layers(&kinds, try parsed(a, "{}"), max_layers + 1, 4));
}

test "mrope: three sections filling half the rotary width, interleaved; max_position positive" {
var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
defer arena.deinit();
const a = arena.allocator();
const m = try mrope(try parsed(a, "{\"mrope_section\":[11,11,10],\"mrope_interleaved\":true}"), 64);
try std.testing.expectEqual([3]usize{ 11, 11, 10 }, m.section);
try std.testing.expectEqual(Mrope{}, try mrope(try parsed(a, "{}"), 64));
try std.testing.expectError(error.InvalidRotary, mrope(try parsed(a, "{\"mrope_section\":[11,11,11]}"), 64));
try std.testing.expectError(error.InvalidRotary, mrope(try parsed(a, "{\"mrope_section\":[32,32]}"), 64));
try std.testing.expectError(error.InvalidRotary, mrope(try parsed(a, "{\"mrope_interleaved\":false}"), 64));
try std.testing.expectEqual(@as(usize, 262144), try maxPosition(try parsed(a, "{}")));
try std.testing.expectEqual(@as(usize, 32768), try maxPosition(try parsed(a, "{\"max_position_embeddings\":32768}")));
try std.testing.expectError(error.InvalidConfig, maxPosition(try parsed(a, "{\"max_position_embeddings\":0}")));
}
4 changes: 2 additions & 2 deletions zig/src/families/qwen3_5/weights/checkpoint_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const dense_config =
\\ "num_attention_heads": 2, "num_key_value_heads": 1, "head_dim": 32, "linear_num_key_heads": 1,
\\ "linear_num_value_heads": 2, "linear_key_head_dim": 32, "linear_value_head_dim": 16,
\\ "linear_conv_kernel_dim": 4, "vocab_size": 16, "full_attention_interval": 2,
\\ "layer_types": ["linear_attention", "full_attention"]}}
\\ "layer_types": ["linear_attention", "full_attention"], "eos_token_id": 1}}
;

const moe_config =
Expand All @@ -103,7 +103,7 @@ const moe_config =
\\ "num_key_value_heads": 1, "head_dim": 32, "linear_num_key_heads": 1, "linear_num_value_heads": 2,
\\ "linear_key_head_dim": 32, "linear_value_head_dim": 16, "linear_conv_kernel_dim": 4, "vocab_size": 16,
\\ "full_attention_interval": 1, "num_experts": 2, "num_experts_per_tok": 1, "moe_intermediate_size": 32,
\\ "shared_expert_intermediate_size": 32}}
\\ "shared_expert_intermediate_size": 32, "eos_token_id": 1}}
;

const L = "language_model.model.";
Expand Down
Loading
Loading