Skip to content

qwen35 rules: one table for the computed-part refusals, a column per backend (#2460 item 4) - #2563

Merged
ashhart merged 4 commits into
ashhart:mainfrom
jschmied:core-config-1
Nov 9, 2026
Merged

ashhart merged 4 commits into
ashhart:mainfrom
jschmied:core-config-1

Conversation

@jschmied

@jschmied jschmied commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

The first config block of #2460 item 4, for the case #2118 names: Qwen 3.5/3.8, read by four config entry points. Each
checks the parts the kernels compute (activation, attention gate, attention bias, recurrent state dtype) with its own
rules and its own words. On main:

keys checked absent words
CUDA (cuda_geometry.zig:274-276) hidden_act, attn_output_gate, attention_bias refused UnsupportedQwenConfig
Metal 27B (qwen27/config.zig:292-295) hidden_act, output_gate_type, attn_output_gate, linear_attn_state_dtype passes UnsupportedAttentionGate; the rest UnsupportedActivation (also a wrong state dtype)
Metal 2B (qwen3_5/config.zig:104-107) hidden_act, attn_output_gate, attention_bias, mamba_ssm_dtype refused BadQwenConfig absent, UnsupportedQwenConfig wrong
HIP (config_checks.zig:55-64) all six, 0/1 taken as flags passes UnsupportedActivation, UnsupportedAttentionGate, UnsupportedStateType

After: core/qwen35_rules.zig holds one row per key: the value the kernels compute, its refusal word (HIP's three,
which already named the part), and a column per backend: skip, optional or required. Each entry point calls
rules.check(tower, .<backend>) where its lines were. The columns are main's rules, so every backend admits exactly
what it admitted on main; only the word of an already-refused config changes, to the row's. The module is std-only and
wired into every module the same way as qwen35_layers (#1863): build/qwen35_layers.zig now wires both.

What a refusal now says, for the same config, on every backend that checks the row:

config CUDA was Metal 27B was Metal 2B was now, everywhere
hidden_act not silu, or absent where required UnsupportedQwenConfig UnsupportedActivation UnsupportedQwenConfig / BadQwenConfig UnsupportedActivation
output_gate_type not swish not checked UnsupportedActivation not checked UnsupportedAttentionGate
attn_output_gate not true, attention_bias not false UnsupportedQwenConfig gate: UnsupportedAttentionGate; bias not checked UnsupportedQwenConfig / BadQwenConfig UnsupportedAttentionGate
linear_attn_state_dtype / mamba_ssm_dtype not float32 not checked UnsupportedActivation / not checked 2B mamba: UnsupportedQwenConfig / BadQwenConfig UnsupportedStateType

A config with several wrong keys now reports the first in table order, which is HIP's order.

Kept as on main, for you to decide (each would change what a backend admits)

Checks on this head

  • Head commit: ac1efde (the CHANGELOG line on 6695ccb; 6695ccb is d636d74 plus one test commit: qwen27/config_test.zig now expects the row's words, UnsupportedAttentionGate for output_gate_type and a new UnsupportedStateType case for linear_attn_state_dtype)
  • Lean checker, python3 tools/zig/lean_check.py, on the base and on this head: 116 on the base (5874551), 116 on this
    head, identical problem lists, 0 new.
  • Tests run, with the command and pass, fail and skip counts: zig build test test-golden -Dnvcc=/usr/local/cuda/bin/nvcc (aarch64 host): green. zig build test-cuda-host: green (includes the new test-qwen35-rules-host). zig build check-native-cuda-host compile-cuda-tests -Dtarget=x86_64-linux-gnu: green. zig build check-native-hip-host -Dhip=true: green. zig build test-kernel-contract test-server-security test-pull-security fuzz-cortheon: green. python3 tools/pr_check.py: 0 errors (1 advisory warning: the CHANGELOG line needs --pr). zig fmt --check build.zig zig and git diff --check: clean. Merge-tree against the 21 open PRs that touch these files: no new conflict.
    New tests:
    • core/qwen35_rules.zig (zig build test-qwen35-rules): every backend admits the wanted values. Each row it reads
      refuses a wrong value with the row's word. Each row it requires refuses an absent key, and each row it skips passes.
      0 and 1 count as flags on HIP only.
    • zig/qwen35_rules_host.zig (zig build test-qwen35-rules-host, in test-cuda-host): main's four rules, ported
      verbatim as in Host fp32→bf16 copies: 59 panic on negative NaNs in Debug; Qwen3.5's layer pattern is read four ways across backends #1863's host test, against the new entry points. On every real Qwen 3.5 config in the repo (the ones
      qwen35_layers_host.zig scans), the table admits exactly what main's rule admitted: 44 (config, backend) pairs. On
      the 2B and 27B bases, through each backend's actual entry point (cuda_geometry.parse, qwen27/config.parse, the
      2B parse, HIP's Config.parse), every row is tried with ten values (each wanted value, another string, true,
      false, 0, 1, null, absent). That is 360 cases, and each admits as main did, and each refusal is the row's word.
    • Each fails against a fault planted in a scratch copy: a backend column flipped (Metal 27B reads attention_bias): the host row test fails. Every refusal given one word: both core tests and the host row test fail. 0/1 taken as flags beyond HIP: the core flag test and the host row test fail. CUDA treating required rows as optional: all four tests fail.
  • CI on 6695ccb: all seven jobs pass (zig, zig-windows, zig-macos-dev-tools, fmt, release-paths, benchmark-clients on Ubuntu and Windows; the host-nightly jobs skip on PRs). ac1efde adds only the CHANGELOG line.
  • Metal (M3 Pro 36 GB, macOS, against main 5874551): zig build test 765/765 steps on this head (all 11,752 tests ran on
    d636d74, where the one stale qwen27 test above failed; the head only changes that test), test-qwen27 46/46,
    test-golden 5/5, lean 0 new.
  • Not run, and why: HIP and XPU: no device. XPU's reader (xpu/qwen27_config.zig) reads
    none of these keys and is untouched.

Receipt

  • Main against branch, Metal (M3 Pro), served greedy, 64 tokens, --parallel 1 --context 4096 --prompt-cache-gib 0,
    token sha256 (first 12 hex digits), drafts off and on:

    model prompt (tokens) main off / on branch off / on
    Qwen3.8-27B MLX 4-bit + DFlash2 poem (20) 5515f210e483 ×2 5515f210e483 ×2
    primes (23) ca45330e98d2 ×2 ca45330e98d2 ×2
    list summary (2,734) 390865d39853 ×2 390865d39853 ×2
    Qwen3.5-2B MLX 4-bit poem (20) c4939a9c2377 ×2 c4939a9c2377 ×2
    primes (23) f1329786ce3c ×2 f1329786ce3c ×2
    list summary (2,734) 97669da82ab5 ×2 97669da82ab5 ×2

    A 27B config with rope_scaling YaRN ×4, and one with tie_word_embeddings: true, are refused on main and on the
    branch with the same text.

  • CUDA: no served A/B. On an admitted config, check returns void and sets nothing. Above, admission is
    shown equal to main's for every row, every value and every backend, so tokens can't change. The real checkpoints
    here (Qwen3.8-27B NVFP4 Unsloth head, Qwen3.8-27B MLX 4-bit, Qwen3.6-35B-A3B MLX 4-bit MTP) declare hidden_act
    silu, attn_output_gate true, attention_bias false and mamba_ssm_dtype float32. The 27B also declares
    output_gate_type swish. All three pass every column.

  • Boxes it reaches: Qwen 3.5/3.8 config admission on CUDA, Metal (27B and 2B) and HIP; the build's shared-module walk.

  • New switch? None.

  • Environment: TensorFold 6695ccb on main 5874551; Zig 0.17.0; aarch64 host (GB10) for host tests, x86_64 cross
    compile for compile-cuda-tests.

  • Paths and platforms the change reaches, which I ran and which I could not: host tests for all four readers (ran);
    CUDA build and x86 compile (ran); Metal build, tests and served hashes (ran, on the Mac); HIP: check-native-hip-host compiles; no HIP device run.

  • Exactness: admission equality above; no kernel or served path changes.

  • Decode speed before and after: n/a (load-time check, six map lookups).

  • Prompt speed before and after: n/a.

  • Licence of any new weights or drafter: n/a.

@ashhart

ashhart commented Nov 8, 2026

Copy link
Copy Markdown
Owner

Thanks, @jschmied. I checked the table against main entry by entry, and each backend's column matches what main read: which keys, whether a missing key refuses, and 0/1 on HIP only. No config is admitted or refused differently. The host test that runs main's four rules beside the new entry points is the right proof.

Two things:

  1. Refusal words. The table changes what three backends say for configs they already refused: CUDA's UnsupportedQwenConfig, the 2B's BadQwenConfig/UnsupportedQwenConfig, and the 27B's UnsupportedActivation for output_gate_type and linear_attn_state_dtype. With several wrong keys, the first refusal now follows table order. One word per part across backends is fine with us: it changes only what an already-refused config says, so we'll note it under what can change in the release notes.
  2. CHANGELOG: one line, e.g. "Qwen 3.5/3.8: the four config readers check activation, attention gate, bias and recurrent state type from one table with a column per backend; each admits what it did, and a refused config names the part (qwen35 rules: one table for the computed-part refusals, a column per backend (#2460 item 4) #2563, part of RFC: families compose core blocks: a conformance kit first, then sampler, config, drafter and format loaders #2460). Thanks to @jschmied."

Please also refresh the body's CI line.

jschmied added a commit to jschmied/TensorFold that referenced this pull request Nov 8, 2026
@jschmied

jschmied commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, @ashhart. The CHANGELOG line is in ac1efde, a plain commit on 6695ccb: your wording, under Unreleased. The body's CI line now names the run on 6695ccb, where all seven jobs passed; the new head adds only that line. Agreed on the refusal words: one word per part, and with several wrong keys the first in table order.

@ashhart

ashhart commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Thanks @jschmied. The line and the CI refresh are what we asked for. This is on the landing queue now.

jschmied and others added 4 commits November 9, 2026 17:08
…backend

CUDA, Metal's 27B and 2B readers and HIP each checked hidden_act, the
attention gate and bias and the recurrent state dtype with their own rules
and words. core/qwen35_rules.zig holds one row per key with its refusal
word and each backend's column (skip, optional, required), wired like
qwen35_layers. Columns are main's rules: every backend admits what it
admitted; only the words of refused configs change to the row's.

Refs ashhart#2460 (item 4), ashhart#2118.
@ashhart
ashhart merged commit 6186afe into ashhart:main Nov 9, 2026
5 of 10 checks passed
ashhart pushed a commit that referenced this pull request Nov 9, 2026
@ashhart

ashhart commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Thank you @jschmied. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

@ashhart

ashhart commented Nov 10, 2026

Copy link
Copy Markdown
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants