Skip to content

vulkan_tf: refuse a model_type the engine does not know (fixes #6298) - #6325

Open
devopsfortunato wants to merge 4 commits into
ashhart:mainfrom
devopsfortunato:vulkan-config-model-type-6298
Open

devopsfortunato wants to merge 4 commits into
ashhart:mainfrom
devopsfortunato:vulkan-config-model-type-6298

Conversation

@devopsfortunato

Copy link
Copy Markdown
Contributor

What this changes

Before: engines/vulkan_tf/src/config_json.zig derived the architecture from a chain of model_type comparisons whose last arm was .qwen35_hybrid, so any unrecognised type parsed without error and was then mapped against the Qwen3.5 hybrid layout — qwen4_moe (public since 2026-12-03) does today. The failure surfaced later as a missing tensor, a wrong dimension or garbage output.

After: .qwen35_hybrid is taken only by qwen3_5 and the qwen3.5 MoE family (qwen3_5_moe[_text], qwen3_next, qwen3_6_moe[_text]); every other type falls through to error.UnsupportedModelType. The absent-key default stays qwen3_5, and every type the file recognised before still maps to the same architecture.

Checks on this head

  • Head commit: to be filled after the changelog commit.
  • Lean checker: 0 new.
  • Tests run:
    • zig build test in engines/vulkan_tf (host tests, no Vulkan device): passes, including the new check (known llama config → .qwen2_dense; the same config with model_type: "qwen4_moe" → error.UnsupportedModelType).
    • zig fmt --check on both changed files: clean.
    • The repo-level zig build test test-golden does not build this engine; CI covers the rest.
  • CI: pending on this push.
  • Not run, and why: no Vulkan device here, so no model loads with the engine; this is a parse-time refusal and needs none.

Receipt

  • Main against branch: n/a. Parse-time only: an unknown type is refused before any tensor is read; recognised types parse to the same architecture as before.
  • Boxes it reaches: any host loading a checkpoint through the vulkan_tf engine.
  • New switch? None.
  • Environment: Zig 0.17.0; Linux x86_64 (WSL2); no GPU.
  • Paths and platforms the change reaches, which I ran and which I could not: the engine's host test suite ran here; a model load on Vulkan did not.
  • Exactness: n/a, no token path changes for recognised models.
  • Main against this branch, same machine and checkpoint: n/a.
  • Decode speed before and after: n/a.
  • Prompt speed before and after: n/a.
  • Licence of any new weights or drafter, or "n/a": n/a.

devopsfortunato added a commit to devopsfortunato/TensorFold that referenced this pull request Dec 4, 2026
@ashhart ashhart added kind:bug Classified by Synthena as bug fix synthena:needs-device Initial diff review passed; waiting for device and slowdown check before READY labels Dec 4, 2026
@ashhart

ashhart commented Dec 4, 2026

Copy link
Copy Markdown
Owner

Synthena Initial Review — Initial diff check passed (awaiting device run) (kind:bug)

Refuses unrecognised model_type values in the vulkan_tf config parser with UnsupportedModelType instead of silently mapping them to the Qwen3.5 hybrid architecture, while preserving the absent-key default and all previously recognised mappings.

  • Touches runtime, kernel, or serving paths; awaiting device and performance verification before landing.
  • Synthena

@joshuaswarren

Copy link
Copy Markdown
Contributor

Review at 8650c779e — two findings:

1. qwen3_5_text is refused now; it parsed before. is_qwen35 covers "qwen3_5" and the is_qwen35_moe aliases but not "qwen3_5_text", which is a real root-level model_type: zig/src/families/qwen27/config.zig:343 lists it in kinds_of, and a standalone dense checkpoint declares it at root (zig/src/families/qwen27/cuda_drafter_open.zig:255 writes {"model_type":"qwen3_5_text"}). Before this change it fell through to .qwen35_hybrid; now it's error.UnsupportedModelType — exactly the "recognized aliases and normal dense inputs" coverage the issue asks to preserve. The same question applies to any other previously-served alias that isn't in the lists (e.g. a qwen3_6/qwen3_6_text dense variant, if published).

A table-driven test over the full recognized set — every string that parsed yesterday still parses today, one line each — would catch this class directly; the new test only covers llama + qwen4_moe.

2. The refusal doesn't name the type. error.UnsupportedModelType carries no payload, and parse() has no logger — the user sees the error name, not "qwen4_moe". #6298 and the maintainer's comment ask for a refusal "with its name" (a qwen4_moe checkpoint nested under text_config would be especially opaque). A std.log/stderr line naming mtype before returning, or naming it at the ModelConfig.load call site, closes that; the bare error value alone doesn't.

@joshuaswarren

Copy link
Copy Markdown
Contributor

Head 8650c779e still refuses model_types this engine serves today. The is_qwen35 set covers qwen3_5 plus is_qwen35_moe, but a config.json carrying qwen3_5_text, qwen3_5_vl, qwen3_5_vl_text, qwen3_vl, qwen3_vl_text, qwen3_vl_moe or qwen3_vl_moe_text now hits UnsupportedModelType where it previously loaded as qwen35_hybrid. The vision path is wired (VisionConfig.load in vision.zig, and vision_config_test writes model_type: "qwen3_vl"), so a served VL checkpoint becomes a load refusal. The sibling fix in #6503 admits that same alias set for mlx_tf — worth matching here.

@ashhart

ashhart commented Dec 5, 2026

Copy link
Copy Markdown
Owner

Thanks @devopsfortunato. The core refusal is right: an unrecognised model_type now stops at parse time with UnsupportedModelType instead of being served as a Qwen3.5 hybrid, the absent-key default and the recognised mappings are kept, and the new test pins both a known config and the refusal.

Two small things are left, and we will do them ourselves on top of your commit:

  1. qwen3_5_text is a real root-level model_type (a standalone dense checkpoint declares it, and the dense alias list in zig/src/families/qwen27/config.zig:343 names it). The is_qwen35 arm does not list it, so it would now be refused where it parsed before. We will add it and a table-driven test over every recognised string, one line each.
  2. The refusal will name the offending model_type in its log line, as the issue asks.

No change is needed from you.

  • Synthena

@joshuaswarren

Copy link
Copy Markdown
Contributor

One gap worth closing before this lands: is_qwen35 covers qwen3_5 and is_qwen35_moe only, but parse() reads text_config.model_type (or root) — and the VL text towers this engine serves carry other strings. A real Qwen3-VL checkpoint has root model_type: "qwen3_vl" and text_config.model_type: "qwen3_vl_text"; vision_config.zig:56 admits the family via indexOf on qwen3_5/qwen3_vl. As written, this change refuses those served configs. Suggest contains-matching qwen3_5/qwen3_vl (and qwen3_5_vl) the way vision_config does, with qwen3_vl_text/qwen3_5_vl_text cases in the test — same treatment the mlx_tf slice got in #6505.

devopsfortunato and others added 2 commits December 5, 2026 16:13
The architecture came from a chain of model_type comparisons whose last arm
was `.qwen35_hybrid`, so any unrecognised type (qwen4_moe today, qwen4_exp or
qwen3_8 tomorrow) parsed without error and was mapped against the Qwen3.5
hybrid layout. The failure then surfaced downstream as a missing tensor, a wrong
dimension or garbage output instead of "this model type is not supported".

`.qwen35_hybrid` is now taken only by `qwen3_5` and the qwen3.5 MoE family; every
other type falls through to `error.UnsupportedModelType`. The absent-key default
is unchanged (`qwen3_5`), and every type the file already recognised still
parses to the same architecture.

The test parses the known llama config as `.qwen2_dense` and the same config
with `model_type: "qwen4_moe"` expecting `error.UnsupportedModelType`.

Fixes ashhart#6298.
qwen3_5_text is a real root-level model_type for the Qwen3.5 dense text
model, and the parser served it as a Qwen3.5 hybrid before unknown types
were refused. It now sits in the recognised Qwen3.5 arm, so it still parses.

A refused config logs the model_type it carried, and whether it came from
text_config, before returning UnsupportedModelType.

A table test parses every model_type string the parser compares against,
at the root and under text_config, and checks the architecture each one
parsed to before; the published Ergo sample and a config with no
model_type keep theirs. An unknown type under text_config is refused as
at the root.
@ashhart
ashhart force-pushed the vulkan-config-model-type-6298 branch from 8650c77 to e7e5633 Compare December 5, 2026 16:17
`is_qwen35` matched `qwen3_5` and `qwen3_5_text` exactly, so a real
Qwen3-VL checkpoint, whose text tower names `qwen3_vl_text` or
`qwen3_5_vl_text`, was refused by the new model_type gate. The check now
contains-matches `qwen3_5` and `qwen3_vl`, as `vision_config.zig` already
does, with a test for both tower spellings.
@ashhart

ashhart commented Dec 5, 2026

Copy link
Copy Markdown
Owner

Thanks @devopsfortunato. The supplied head includes the dense and VL aliases, the recognized-type table, and a refusal log naming the offending type. The earlier asks are met.

We will tighten the remaining type guard and add its regression ourselves before landing. No further revision is needed from you. These parser checks do not require a Vulkan device run.

  • Synthena

An unknown model_type that only contains a familiar family name
(unknown_qwen3_5, qwen3_5_future) is refused instead of served as a
Qwen3.5 hybrid. Every published type stays accepted: qwen3_5 and _text,
the VL and VL-MoE names and their _text forms, and the MoE names.
@ashhart

ashhart commented Dec 5, 2026

Copy link
Copy Markdown
Owner

READY to land on this head. Reviewed with our follow-up commit: unknown model types now stop at load with a clear message, and every published config the engine serves is still admitted; host tests and the checks finished on this head pass. The landing train runs the device cells.

  • Synthena

This branch has not been deployed

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

Labels

kind:bug Classified by Synthena as bug fix synthena:needs-device Initial diff review passed; waiting for device and slowdown check before READY

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vulkan_tf: an unrecognised model_type loads silently as Qwen3.5 hybrid (qwen4_moe does today)

3 participants