Repository navigation
core: typed config field readers and named EOS policies; Qwen 3.5 CUDA, HIP and qwen27 Metal read through them (#2460 item 4) - #3716
Merged
Conversation
|
tested on a 3090, looks good |
Owner
|
Thanks @jschmied. We read this head (
One note for landing: #3777 edits the Whether this shape is the one to extend to Gemma 4 and Spark 2.5 is our call on #2460. We'll answer it there.
|
config_fields.zig reads one config.json value one way: required or optional, int, float or bool, and every refusal names its source and field in a Problem. eos.zig takes a Policy (order, nested arrays, most ids, none refused); resolve is the served policy unchanged, and qwen35_hip and qwen27_metal name the two Qwen family rules. Both are std-only shared modules so std-only family files can import them.
CUDA (cuda_geometry.zig) and qwen27 Metal read their counts, numbers and flags through config_fields; the refusals keep their names (BadQwenConfig, BadConfig) and the field now reaches the log. The HIP loader's and qwen27's EOS ids come from eos.zig's qwen35_hip and qwen27_metal policies. Geometry, pins, top_k caps, tied heads and RoPE stay in the families.
…keeps its name why
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft for #2460 item 4, steps 2 and 3 of the survey (issuecomment-6938315721), kept as small as the survey's proposal so you can judge the shape before more families move. Head
5c2f24af78, on main038e4a2787. Nothing a user sees changes except one log line on a refused config (below).What it adds (commit 1,
bf343980b8)core/config_fields.zig: one value read one way.requiredInt,requiredFloat,optionalInt,optionalFloat,optionalFlagon aReader(object, source name,*Problem), and the value-levelint,float,flagthey use. Ints are integer-tagged only and range-checked before any narrowing, floats take an int or a float, bools are JSON bools. Optional keys say what a presentnullmeans (.refusedor.absent). Every refusal iserror.BadConfigFieldplus aProblemtext naming source, field and reason, e.g.config.json text_config: num_key_value_heads is a string, not an integer. No defaults, pins or geometry: those stay in the families.core/tokenizer/eos.zig:collect(out, policy, root, text, generation, vocab)with aPolicy(order, nested arrays, most ids, none refused) and three named policies:served: today'sresolve(root; text_config only when the root gave none; then generation; flat arrays; no limit; none allowed).resolveandmergenow run on it with the same refusal names (BadEos).qwen35_hip: the Qwen 3.5 HIP loader's rule (config_checks.zig:92on main): root, text tower and generation all; nested arrays read; at most 8; none refused (MissingEos).qwen27_metal: qwen27 Metal's rule (qwen27/config.zig:340on main): the root's key whenever it exists (a rootnullor[]hides the tower), else the tower; then generation; nested arrays read; at most 8; none refused.BadEosValue(not an id, an id array or null) is separate fromBadEos(an id past the vocabulary), so each family keeps its own name for it: HIP saysBadEos, qwen27 saysBadConfig, as on main.zig/build/qwen35_layers.zigtable, besideqwen35_rulesandrope_config), becauseqwen3_5/config.zigandqwen27/config.zigalso build in modules withoutcore.tokenizer.zigimports eos through the shared module so the file lives in one module per compilation.What moves (commit 2,
9500529074)qwen3_5/cuda_geometry.zig:integerandnumberread throughconfig_fields; the refusal staysBadQwenConfig.Geometry.readlogs the Problem on a refusal.qwen27/config.zig:required,optional,integer,norm_topk_probthroughconfig_fields(refusal staysBadConfig); EOS throughqwen27_metal.model.zig:95logs the Problem on a refusal.qwen3_5/config_checks.zig:eoscallsqwen35_hip; its signature andweights/config.zigare unchanged (so no overlap with hip: ModelOpt NVFP4 and FP8 checkpoints keep their codes and decode in flight #2490, the only open PR touching these files).> 31(CUDA) and> 15(qwen27) refusals; tied heads throughqwen35_rules(TiedEmbeddingHeadon qwen27, admitted on CUDA);rope_scaling/YaRN handling throughrope_config/cuda_rope; head-dim derivation, pins and products. None of those lines changed.server/hf_text.zig:220→resolve(now theservedpolicy). CUDA qwen3_5 reads no EOS itself.Evidence (all on
84cd8edb10;9500529074differs from it only byconfig_fields.zig's header comment, shortened to one line for lean.5c2f24af78fixes a macOS compile error mac-agent found inqwen27/model.zig: the newvar why: cfg.Problemredeclared a later localwhy; it is nowproblem. That file builds only on macOS, so the Linux runs never compiled it;zig ast-checkon every changed file is clean now)cuda_geometry.parse, HIPweights/config.Config.parse, qwen27 Metalconfig.parse, Metal 2Bconfig.parse) over 24 real Qwen 3.5/3.6/3.8 configs (20 HF repo configs incl. 0.8B to 397B, 2.4T, FP8 and GPTQ, and 4 local checkpoints: Qwen3.8-27B MLX 4-bit, our Qwen3.8-27B NVFP4, Qwen3.6-35B-A3B MLX and NVIDIA NVFP4), each with its generation_config.json and six generation variants, plus 16,066 mutations (24 keys at root and in text_config: absent,null,"5",5.0,128.9,-1,0,1,2^32,1e20,true,[], nested and null-holding arrays,{}). 16,932 variants: the 54 MB snapshot is byte-identical (sha256550e535d…), both every parsed struct ({any}) and every refusal name. One gap:0is left out for the four head counts, because it panics on main and here alike (HIPconfig_checks.productsdivides bykv_heads/key_heads; qwen27 divideshidden / headswhenhead_dimis absent). That is a follow-up, not part of a move.test-config-fields(fixture admitted values; 19 named refusals by exact Problem text; truncation at the buffer end),test-checkpoint-eos(19 fixtures × 3 policies, including every row of the survey's EOS matrix;resolveagainst theservedcolumn; a non-object source). qwen27config_test.zig21/21 and qwen3_5config.zig/config_checks.zig14/14 run by hand on Linux (they are macOS-only steps in the build).test-cuda-host,test-checkpoint-io-host,compile-config-server,test-qwen35-rules-host,-layers-host,-metal-scope-host,-formats-host: 436/436 steps green on the GB10.config_fields_test.zigandeos_policy_test.zig): int range check dropped; int truncating a float; float taking a string; anullalways absent; Problem without the field; flag taking 0/1;root_key_else_textfalling through on a null root;every_sourceskipping the tower; nested arrays refused; most-ids not enforced; none allowed underrequired; dedup dropped;servednaming a malformed value something other thanBadEos;servedreading the tower after the root gave ids. Family controls against the snapshot: qwen27 onserved(155 lines differ), HIP onqwen27_metal(272), CUDA counts admitting 0 (78), qwen27 refusing a nullrms_norm_eps(51).stopon EOS, 2 to 75 tokens, so the served stop set fromresolveis exercised). Binaries: mainfb78306…, head0572cf1…(md5, built from038e4a2787and84cd8edb10)./v1/models, page cache dropped before each start) and one c=1 decode row: load main 12.7 / 12.2 s, head 12.7 / 11.7 s (the server's ownloaded inline: 12.3 / 11.8 vs 12.4 / 11.7 s); c=1 decode (256 tokens, 3 runs each) main 11.58 / 11.43 tok/s, head 11.59 / 11.57 tok/s, TTFT 0.126-0.132 s on all four. No served cell slower than main beyond run-to-run noise.zig build -Dfixed-cpu teston the GB10: green. x86 (8 cores,84cd8edb10):test-golden test-kernel-contract test-server-security test-pull-security fuzz-cortheon55/55 steps and 230/230 tests,check-release-paths, x86check-native-cuda-host compile-cuda-tests,zig fmt --checkgreen;test10146/10225 with 1 failure andtest-hostwith 2:cli_config_test"serve --config: expand reads the file…" (it fails the same way on this x86 box's main-only runs, head == basecf4555373and4ddc28cfc) andtest-dsv41-device-host(in this box's runs of 9 other branches too); neither touches these files.pr_check.py0 errors on9500529074, lean 221 vs 221 on main, 0 new.Metal (mac-agent, M3 Pro 36 GB, head
5c2f24af78vs main038e4a2787; no sudo there, so no page-cache purge, A-B-B-A order instead). All four pass:zig build test-qwen-dense-geometry-host test-qwen35-metal-scope-host: head 10/10 steps, 112/112 tests; main 10/10, 115/115. (9500529074failed to compile here, see the evidence note.)--parallel 1), greedy and seeded (t 0.8, seed 7), plain and drafted: 16/16 equal to main on token sha256, length and finish reason; allstop; drafted == plain.--no-drafts, ctx 2048,--parallel 4: greedy and seeded 8/8 equal to main, and 4 streams == 1 stream plain.run()without a stop override: every drafted reply stops at the same token count and hash as main and as plain (lengths 61/43/18/11 greedy, 57/43/18/11 seeded).text_config.num_key_value_heads: "4": both refuse withBadConfig; head logsconfig.json text_config: num_key_value_heads is a string, not an integer, main logs no reason.What this does not do (kept for separate, reviewable one-line policy diffs or issues): changing any family's EOS rule (the qwen27-vs-served set, HIP's union), qwen27 tied heads, qwen27 YaRN, the top_k caps, the Metal 2B reader, the HIP loader's Python-
int()field reads, and the zero-divisor panics above. Gemma 4 and Spark 2.5 are the next migrations if this shape is right.Proposed CHANGELOG line (yours to place):
core: config_fields.zig (typed field reads naming source and field) and named EOS policies in eos.zig; Qwen 3.5 CUDA, HIP and qwen27 Metal read through them with unchanged refusals (#2460).