Skip to content
Merged
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
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

- Update Inkling 2 Small test fixtures to revision 885d78bf with log_scaling_n_floor 8192 (#6215).

- `--vision` with no video library: `--vision-video-tokens` defaults to 64 rather than 16,384, so no stream sets aside rows for videos the server refuses (128 MiB a stream for GLM-5.3-Flash); a given value is kept (#6217, fixes #6194).
- Fixed a compile break in the qwen27 retained-taps host test step by exporting phase_trace from the Metal stand-in module (#6244).

Expand Down
2 changes: 1 addition & 1 deletion THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ and ZWJ/ZWNJ conjuncts after it are TensorFold's own.
## Inkling 2 Small test fixtures

`zig/src/families/inkling2/fixtures/` holds files and values taken from Thinking Machines' Inkling 2 Small release at
revision `2ad1157016e1aac77b6ff1b770e7c05229403134`, under the Apache License 2.0 stated on its model card (see
revision `885d78bfca61a7e9a498e33cfa7ad35850533b8c`, under the Apache License 2.0 stated on its model card (see
[the license text](LICENSES/Apache-2.0.txt)): `config.json`, `chat_template.jinja`, `mini_tokenizer.json` (its
`tokenizer.json` cut to the added tokens, the byte alphabet and the first 1,500 merges) and the prompts and ids in
`prompt_cases.json` and `mini_cases.json`, which the Hugging Face transformers and tokenizers libraries produced from
Expand Down
2 changes: 1 addition & 1 deletion tools/zig/inkling2_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

ROOT = Path(__file__).resolve().parents[2]
FIXTURES = ROOT / "zig/src/families/inkling2/fixtures"
RELEASE = "thinkingmachines/Inkling-2-Small@2ad1157016e1aac77b6ff1b770e7c05229403134"
RELEASE = "thinkingmachines/Inkling-2-Small@885d78bfca61a7e9a498e33cfa7ad35850533b8c"
TINY = "tiny-random/inkling-2@0a57c72e4e5b68aafe1d983dbb62980344a5fcd7"
TINY_MINI = "hf-internal-testing/tiny-inkling2-mini@ee242a48af34ff0729518f4ac28cfcb847e470ab"
MINI_RELEASE = "thinkingmachines/Inkling-2-Mini"
Expand Down
10 changes: 5 additions & 5 deletions zig/src/core/contract/inkling2_attn_ref.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub const extent = 1024; // a call's default rel_extent, and the longest one: th
pub const d_rel = 16;
pub const qk_clip: f64 = 22.627416997969522; // config.json qk_l2_clip_threshold
pub const rel_clip: f64 = 8.0;
pub const floor_pos: f64 = 128000; // Small's log_scaling_n_floor (Mini's is 8,192: tauAt)
pub const floor_pos: f64 = 8192; // Small's and Mini's log_scaling_n_floor (tiny-random's is 128,000: tauAt)
pub const alpha: f64 = 0.1; // log_scaling_alpha
pub const eps: f64 = 1e-6; // rms_norm_eps
pub const scale: f64 = 0.08838834764831845; // 128^-1/2; the device's fp32 constant is within 2^-24 of it
Expand Down Expand Up @@ -245,12 +245,12 @@ test "rn rounds once to nearest even and keeps bf16 values" {
try std.testing.expectEqual(@as(u16, 0x3f80), bits(1.001));
try std.testing.expect(std.math.isNan(minNum(std.math.nan(f64), std.math.nan(f64))));
try std.testing.expectEqual(@as(f64, 1), minNum(std.math.nan(f64), 1));
try std.testing.expectEqual(@as(f64, 1), tau(127998));
try std.testing.expectEqual(@as(f64, 1), tau(8190));
}

test "a call carries its rank's heads, key heads and chains; tau takes the model's floor" {
try std.testing.expectEqual(@as(f64, 1), tauAt(8191, 8192));
try std.testing.expectApproxEqAbs(1 + 0.1 * @log(2.0), tauAt(16383, 8192), 1e-15);
try std.testing.expectEqual(@as(f64, 1), tauAt(127999, 128000));
try std.testing.expectApproxEqAbs(1 + 0.1 * @log(2.0), tauAt(255999, 128000), 1e-15);
try std.testing.expectEqual(tau(300000), tauAt(300000, floor_pos));
const call: Call = .{ .q = &.{}, .k = &.{}, .v = &.{}, .tab = &.{}, .sink = &.{}, .gate = &.{}, .pos = &.{}, .stream = &.{}, .ring = 4096, .window = 0 };
try std.testing.expectEqual(@as(usize, heads), call.heads);
Expand Down Expand Up @@ -399,7 +399,7 @@ test "CUDA's defaults keep the base bits past the extent, on a full window, the
try std.testing.expectEqualSlices(u64, &.{ 0x3fd4c00000000000, 0xbfc2200000000000 }, &.{ @bitCast(o[0]), @bitCast(o[77]) });
simulate(&call, 0, 12, .bf16, .pairwise, p, col, &o);
try std.testing.expectEqualSlices(u64, &.{ 0x3fd4e00000000000, 0xbfc2000000000000 }, &.{ @bitCast(o[0]), @bitCast(o[77]) });
for ([_]usize{ 127999, 128000, 300000, 1048575 }, [_]u64{ 0x3ff0000000000000, 0x3ff00000d1b6e1a9, 0x3ff15ce10ac9824d, 0x3ff35d741b82a5cf }) |pos, b|
for ([_]usize{ 8191, 8192, 300000, 1048575 }, [_]u64{ 0x3ff0000000000000, 0x3ff0000ccc999aab, 0x3ff5c2d12eeb3d92, 0x3ff7c3643fa46114 }) |pos, b|
try std.testing.expectEqual(b, @as(u64, @bitCast(tau(pos))));
}

Expand Down
1 change: 1 addition & 0 deletions zig/src/families/inkling2/config_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ test "Inkling 2 Small's config.json parses: 48 layers, 8 global, 384 experts, 8
try t.expectEqual(config.Heads{ .q = 48, .kv = 8, .dim = 128 }, c.text.local);
try t.expectEqual(@as(u32, 1024), c.text.window);
try t.expectEqual(@as(u32, 16), c.text.d_rel);
try t.expectEqual(@as(u32, 8192), c.text.log_floor);
try t.expectEqual(@as(u32, 6), c.text.block);
try t.expectEqual(@as(u32, 384), c.text.experts);
try t.expectEqual(@as(u32, 8), c.text.topk);
Expand Down
6 changes: 3 additions & 3 deletions zig/src/families/inkling2/exl3_pack_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,9 @@ test "admitSmallConfig admits Inkling 2 Small EXL3 and refuses ModelOpt, Mini or
small.quant = .exl3_kortexa_v1;
try pack.admitSmallConfig(&small, &why);

var small_floor8k = small;
small_floor8k.text.log_floor = 8192;
try pack.admitSmallConfig(&small_floor8k, &why);
var small_floor128k = small;
small_floor128k.text.log_floor = 128000;
try pack.admitSmallConfig(&small_floor128k, &why);

var mini = try config.parse(t.allocator, config_test.mini, &why);
mini.quant = .exl3_kortexa_v1;
Expand Down
7 changes: 7 additions & 0 deletions zig/src/families/inkling2/fixtures/chat_template.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
{%- set header.text = header.text ~ message.name -%}
{%- endif -%}
{%- set rtok = header.text -%}
{%- set rendered -%}

{%- if message.role == "assistant" and message.reasoning_content is defined and message.reasoning_content -%}
{{- rtok ~ "<|content_thinking|>" ~ message.reasoning_content ~ "<|end_message|>" -}}
Expand Down Expand Up @@ -123,6 +124,12 @@
{%- if message.role == "assistant" -%}
{{- "<|content_model_end_sampling|>" -}}
{%- endif -%}
{%- endset -%}
{%- if message.role == "assistant" -%}
{%- generation -%}{{- rendered -}}{%- endgeneration -%}
{%- else -%}
{{- rendered -}}
{%- endif -%}
{%- endfor -%}

{%- if not state.effort_emitted -%}
Expand Down
2 changes: 1 addition & 1 deletion zig/src/families/inkling2/fixtures/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"rel_extent": 1024,
"q_bias": false,
"o_bias": false,
"log_scaling_n_floor": 128000,
"log_scaling_n_floor": 8192,
"log_scaling_alpha": 0.1,
"rms_norm_eps": 1e-06,
"pre_norm_pre_affine": false,
Expand Down
2 changes: 1 addition & 1 deletion zig/src/families/inkling2/fixtures/prompt_cases.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"transformers": "5.20.0",
"tokenizers": "0.23.3",
"jinja2": "3.1.6",
"files": "thinkingmachines/Inkling-2-Small@2ad1157016e1aac77b6ff1b770e7c05229403134: tokenizer.json, tokenizer_config.json, chat_template.jinja",
"files": "thinkingmachines/Inkling-2-Small@885d78bfca61a7e9a498e33cfa7ad35850533b8c: tokenizer.json, tokenizer_config.json, chat_template.jinja",
"call": "apply_chat_template(messages, tokenize=False, add_generation_prompt=True[, reasoning_effort=E]); tok(prompt, add_special_tokens=False)"
},
"chat": [
Expand Down
Loading