Skip to content

vision: one gate for --vision at open on CUDA and HIP; LFM2 loads its tower only with --vision, Qwen3.5 HIP and Flash Next refuse a missing tower by name - #3456

Merged
ashhart merged 9 commits into
ashhart:mainfrom
jschmied:vision-gate-unify
Nov 24, 2026
Merged

ashhart merged 9 commits into
ashhart:mainfrom
jschmied:vision-gate-unify

Conversation

@jschmied

@jschmied jschmied commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Head: a52de41bd5 (branch vision-gate-unify, on ashhart's refresh 6ea71c058e; the last commit removes LFM2's old
--vision refusal on CUDA, review 7105791776).

Each CUDA and HIP family decided --vision its own way. LFM2 (d1) on CUDA loaded its tower whenever config.json had a
vision_config. Qwen3.5 on HIP served text when --vision named a checkpoint without a tower. Flash Next on CUDA
called a missing tower an "unsupported Flash Next Qwen-VL tower configuration". This PR gives them one gate in core,
with one message format, and changes nothing else they do.

What changes

Core (shared by every family):

  • zig/src/core/engine_vision.zig: gate(requested, tower), declared(a, config) and words(model, err), re-exported
    from engine_api as visionGate, visionDeclared and visionWords.
    • --vision on a checkpoint without a tower returns error.VisionWithoutTower, worded
      "--vision given but this checkpoint has no vision tower".
    • A tower without --vision stays unread, and the server starts text-only. Vision stays opt-in.
    • error.VisionNotLoaded is worded " has a vision tower; pass --vision to load it", for a family that has to
      refuse images itself. No family uses it yet: the server refuses images before family code runs.
    • declared is the HIP Qwen check (vision_config absent or null means no tower), moved to core unchanged. Its test
      moved with it.
  • zig/src/core/checkpoint_weights.zig: the header-only text count used to skip only RADIO's prefixes. It now also
    skips model.visual., visual., vision_tower., model.vision_tower., vision., model.vision_model.,
    vision_embedder., embed_vision., model.vision_encoder. and model.vision_projection..
    • The list's only consumer is Nemotron's tensorWeightBytes (CUDA admission). Nemotron's three local checkpoints
      (Bolt-74B, Bolt-E4B, Lightning) hold no tensor under any of the new prefixes: their counts are unchanged.
    • A test pins tower names as vision and text names as text, among them model.multi_modal_projector.. I left that
      prefix out on purpose, because audio models use the same name for their audio projector.
  • zig/src/cluster/config.zig: a model's "vision" that is not a bool is refused as "models..vision: true or false".
    Before, it silently meant false.
  • zig/src/server/systemone.zig: the System One picture refusal no longer claims the checkpoint has no tower. It now
    reads "this server reads no pictures: start it with --vision on a checkpoint with a vision tower", because a d1
    started without --vision has a tower.

Families (CUDA/HIP only, no Metal file touched):

  • LFM2 / d1 CUDA (native/lfm2.zig, families/lfm2/weights.zig): calls the gate after reading the config and before
    opening the driver. native/cuda_refusal.zig's lfm2 no longer refuses --vision ahead of that open (it did, so
    the gate and the tower were unreachable); it still refuses --tp and --rank. plan and Weights.load take
    tower, and without --vision the plan holds the language
    model's pieces alone. d1's pictures now need --vision.
  • Qwen3.5 HIP (hip/engine/engine.zig, native.zig, vision.zig): --vision on a checkpoint without a tower is
    refused through the gate, before the HIP runtime opens. It no longer serves text.
  • Flash Next CUDA (cuda_lanes_load.zig, _explain.zig, _bytes.zig, cuda_images.zig): the gate runs first in open,
    before a stream, glue, module or weight. visionBytes counts 0 without a tower, so the open is what refuses, by name.
  • docs/vision.md: one paragraph on the gate.

No kernel or .cu file changes (git diff origin/main -- zig/kernels is empty), so the five SASS SMs are unchanged.

Evidence

Refusals by name, with nothing loaded before them (host tests, x86, 8eca677010):

  • Flash Next: cuda_lanes_vision_test.zig calls the real open with every driver entry point undefined. A text
    config gives error.VisionWithoutTower, so the refusal fired before the first driver call: no stream, module or
    buffer. It also checks the words and visionBytes == 0.
  • Qwen3.5 HIP: vision.zig's new test calls Engine.load on a text config with --vision, and gets
    error.VisionWithoutTower before hip.Runtime.open. The x86 runner has no HIP runtime, so any later refusal would
    have been a runtime error instead.
  • LFM2: the plan test shows that without --vision a VL header plans exactly the 21 language pieces, at the same
    offsets as with it, and its byte count ends at the last language piece. A header that lacks the tower still plans.
  • LFM2 admission (cuda_refusal.zig, test "--vision is each family's to take"): --vision alone passes to the open,
    and --vision with --tp 2 or --rank 1 is still refused as no_ranks. Planted control: the same test with the old
    refusal put back fails by name (14 pass, 1 fail); on a52de41bd5 the filtered engines-module run passes 15/15.
  • Core: gate truth table, both messages, and declared on absent, null, [], "x", object and non-JSON. The cluster
    test covers "vision":"yes".
  • Planted control (vision-gate-unify-control, f481588185, never pushed): the same suites with the three
    family gates removed. With them removed, the three new tests fail by name and nothing else changes:
    the HIP test gets DriverUnavailable, Flash Next gets UnsupportedCheckpoint (a later step of its open), and the
    LFM2 plan test fails its piece count. Receipt: vis-x86-hipctl.log.

Suites (x86 lane, -Dfixed-cpu): the lines below are from 8eca677010; on a52de41bd5: 23585/23745 tests, 1 failed: environment_flashnext_test "the table holds all 36 settings" (25 switches, not 24). It fails the same way on your refresh 6ea71c058e without my commit, and main has since updated that test, so it is not from this change. check-native-cuda-host compile-cuda-tests 17/17, pr_check.py 0 errors, zig fmt --check clean, lean 165 vs 165 with 0 new.

Earlier runs:

  • zig build -Dfixed-cpu test test-golden test-kernel-contract test-server-security test-pull-security fuzz-cortheon check-release-paths on 4b2932ed77 (code identical to the head; the head only rewraps docs): 757/760 steps,
    10048/10128 tests, 1 failed. The failure is cli_config_test ... serve --config: expand, which fails the same way on
    main 41a72fd257 (the x86 run on main from 10:18).
  • -Dhip=true test-host-ci-linux-hip test-lfm2-load-host test-cuda-host test-cluster-membership-host on the head:
    3630/3658 tests, with only the same cli_config_test failing.
  • check-native-cuda-host compile-cuda-tests: 16/16. zig fmt --check: clean. tools/pr_check.py: 0 errors, lean
    341 vs 341, 0 new.

Served, against main (main vs fix) (GB10, page cache dropped before every start; binaries' md5 in the receipts):
Main 41a72fd257 (md5 12a7c027) against fix 8eca677010 (md5 86aa6b99), on CUDA sm_121. Every cell is
byte-identical, 18 of 18:

model without --vision: greedy 2K, seeded 2K, greedy chat with --vision: greedy 2K text, image greedy, image seeded resident MiB, text / vision, main = fix
Qwen3.6-35B-A3B NVFP4 equal, equal, equal equal, equal, equal 21,695 / 29,063
Qwen3.8-27B NVFP4 equal, equal, equal equal, equal, equal 23,913 / 40,873
Gemma 4 31B 4-bit equal, equal, equal equal, equal, equal 22,277 / 50,105

So off == main, and one image reply (greedy and seeded) == main on three checkpoints that have towers. Resident memory
per server is the same on both arms (nvidia-smi once idle after load). Receipts: runs/{q35,q27,g31}.jsonl and the
server logs.

Concurrency and resume are not covered. Neither the decode nor the cache path changes: the gate runs once, at open.
Flash Next is not served here (96 GB checkpoint); its refusal is covered by the host test above.

LFM2 served with --vision (and its resident bytes) is not checked here, because there is no local LFM2-VL (lfm2_vl)
checkpoint. The admission test and the plan test above cover the path from the flag to the tower's pieces.

Questions for @ashhart (not changed here)

  1. DeepSeek V4.1 turns images on with TF_DSV41_IMAGES, not --vision. Should it move to the flag and the gate?
  2. The OCR families' --vision policy differs. Nemotron Parse requires it; dots, GLM-OCR and LightOn start text-only
    without it; uocr ignores it. Which policy do you want?
  3. The families that already refuse by name keep their own errors and words for now: Gemma 4 NoGemmaVision, Nemotron
    VisionRefused, GLM NoVisionTower, MiniMax NoMiniMaxVisionShard, Qwen3.5 CUDA NoQwenVision. Moving them to the
    gate's words would change only wording. Do you want that here, or in a follow-up?

Proposed CHANGELOG line (for you to place):

  • CUDA and HIP: one --vision gate in core. --vision on a checkpoint without a tower is refused at startup as
    "--vision given but this checkpoint has no vision tower", on Qwen3.5 HIP too, which used to serve text.
    d1-3B (LFM2-VL) loads its tower only with --vision. Flash Next names the missing tower. A cluster model's non-bool
    "vision" is refused, and the header-only text count skips Qwen-VL, Gemma 4, LFM2-VL, LightOn, DeepSeek and GLM
    towers. Text-only replies are unchanged.

@ashhart

ashhart commented Nov 16, 2026

Copy link
Copy Markdown
Owner

@jschmied, thank you. The gate is one shared path with one message, and text-only starts are unchanged. The one default change, a checkpoint that declares a tower no longer loading it without --vision, is the point of the change and we accept it.

CI's zig job fails at this head: test-gradient-serving reports a serving source that changed without its pin (zig/src/families/flashnext/cuda_images.zig). Please re-pin it in zig/tests/fixtures/gradient-serving.tsv. Once CI is green we will run the device checks on our side: the GB10 A/B from your description, and the HIP refusal on a Strix Halo iGPU.

  • Synthena (Ash's Agent)

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

Copy link
Copy Markdown
Contributor Author

@ashhart Thanks. de13716331 re-pins the three Flash Next sources this PR changes: cuda_images.zig, cuda_lanes.zig and cuda_lanes_load.zig. CI named only the first, but all three were stale. Each row gets a note naming #3456. A merge with current main shows no other pin difference, and zig build -Dfixed-cpu test-gradient-serving passes locally.

#3467 also changes cuda_lanes_load.zig. Whichever lands second will need that one row re-pinned, and I'll do it then.

@ashhart

ashhart commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

@jschmied, thank you for the re-pins; CI is green at de13716. The HIP checks we promised are done on a Strix Halo at that head. The served Qwen 3.8 27B cells are exact (0 of 8 prompt rows differ) and prompt speed is level with main (-1.1% to +0.2% at 2,048 tokens, every range overlapping). With --vision on a copy of the checkpoint whose config has no vision_config, the HIP server now stops at startup with "--vision given but this Qwen3.5 checkpoint has no vision tower". Main's build given the same start makes no vision decision there: it goes on to load and then stops on this box failing to allocate its scratch and pages, so the new message is the clearer outcome.

It's queued now; the GB10 A/B runs with its landing.

  • Synthena (Ash's Agent)

@ashhart

ashhart commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Thanks @jschmied. To get this moving, we rebased it onto current main ourselves, keeping every one of your commits as it was (author and message) and fitting it to the code main has gained since; no behaviour changes. It is in the landing queue now, and if anything else is needed from you we will say so here.

  • Synthena

@AIFlowML

Copy link
Copy Markdown
Contributor

I checked 2ec6bee2 on M5 Max with Zig 0.17.0. zig build test-qwen-vision-hip-host test-qwen-vision-weights-host test-lfm2-load-host test-flashnext-vision-contracts-host test-gradient-serving -Dhip=true -Dcpu=apple_m1 -j5 --summary all passed 45 tests with two skips. The same checks and both check-native-cuda-host and check-native-hip-host passed on a scratch merge into 124052c97.

The only conflict is the Flash Next block in gradient-serving.tsv. Rehashing the combined tree matters for cuda_lanes.zig and cuda_lanes_load.zig: both merged hashes differ from either branch's pin. I also ran the named LFM2 fixture that leaves tower bytes unread without --vision and the Qwen HIP fixture that refuses a missing vision_config before the runtime opens. Both passed on the scratch merge. These were host fixtures and compile checks.

Igor Lessio - AIFLOW LABS

ashhart pushed a commit to jschmied/TensorFold that referenced this pull request Nov 21, 2026
ashhart pushed a commit to jschmied/TensorFold that referenced this pull request Nov 21, 2026
@AIFlowML

Copy link
Copy Markdown
Contributor

The current head ade4ffa96 applies cleanly to main 2ce240cf0, including the serving fixture that conflicted on the previous revision. I ran the following on M5 Max with Zig 0.17.0:

zig build test-qwen-vision-hip-host test-qwen-vision-weights-host test-lfm2-load-host \
  test-flashnext-vision-contracts-host test-gradient-serving check-native-cuda-host \
  check-native-hip-host -Dhip=true -Dcpu=apple_m1 -j4 --summary all

All 33 build steps passed. The run recorded 49 passing tests and two skips in the LFM2 load suite. Both native build checks and the serving pins passed on the merged tree. This is host and cross-build coverage alongside the separately reported HIP device receipt.

Igor Lessio - AIFLOW LABS

ashhart pushed a commit to jschmied/TensorFold that referenced this pull request Nov 22, 2026
@AIFlowML

Copy link
Copy Markdown
Contributor

The revised 6ea71c05 head trial-merges cleanly into 25586070b, including the serving pins. On M5 Max with Zig 0.17.0, the vision, LFM2 and serving checks passed 49 tests with two skips and both native build checks passed. Separately, the shared vision gate passed both tests, the cluster target passed 47 tests with one skip, and a filtered System One server run passed 27 tests including the pre-scoring picture refusal.

zig build test-qwen-vision-hip-host test-qwen-vision-weights-host \
  test-lfm2-load-host test-flashnext-vision-contracts-host test-gradient-serving \
  check-native-cuda-host check-native-hip-host -Dhip=true -Dcpu=apple_m1 --summary all
zig test zig/src/core/engine_vision.zig
zig build test-cluster-membership-host tf-config-validate -Dcpu=apple_m1 --summary all

Using tf-config-validate config validate FIXTURE on the same cluster fixture, the trial rejected vision: "yes" with models.k.vision: true or false and exit 1. Main accepted that string. Both accepted Boolean true and false. These are host and build results. The real Strix Halo device receipt remains tied to its earlier head.

Igor Lessio - AIFLOW LABS

@ashhart

ashhart commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Thanks @jschmied for working on a consistent vision gate.

I found one blocker on the current head. CUDA's earlier LFM2 validation still rejects every --vision request before the new gate runs. Starting an LFM2-VL server with that flag therefore returns the legacy refusal, and the new tower-enabled path is unreachable. Without the flag the tower now stays unloaded, so LFM2-VL on CUDA can no longer read images. Please remove the old vision refusal while preserving rank validation, and update its test.

  • Synthena

@jschmied

Copy link
Copy Markdown
Contributor Author

Thanks, you're right. refusals.lfm2 refused every --vision before lfm2.open ran the gate, so an LFM2-VL server could not load its tower at all.

Fixed in a52de41bd5, on top of your refresh 6ea71c058e:

  • cuda_refusal.zig: lfm2() now checks only --tp and --rank (unranked). The old --vision refusal and its message are gone, so --vision reaches core's gate in lfm2.open.
  • Its test, "--vision is each family's to take": --vision alone passes, and --vision with --tp 2 or with --rank 1 is still refused as no_ranks.

Verified:

  • That test with the old refusal put back fails by name (14 pass, 1 fail). On a52de41bd5 the same filtered engines-module run passes 15/15.
  • Full x86 CI set on a52de41bd5: 23585/23745 tests, 1 failed: environment_flashnext_test "the table holds all 36 settings" (25 switches, not 24). It fails the same way on your refresh 6ea71c058e without my commit, and main has since updated that test, so it is not from this change. check-native-cuda-host compile-cuda-tests 17/17, pr_check.py 0 errors, zig fmt --check clean, lean 165 vs 165 with 0 new.
  • Not served: there is no LFM2-VL (lfm2_vl) checkpoint on this box, so starting a server with --vision and sending an image is not checked here.

ashhart and others added 6 commits November 24, 2026 12:08
core/engine_vision.zig gains gate(), declared() and words(): --vision without a
tower is refused as "--vision given but <model> has no vision tower", and a
tower without --vision stays unread. LFM2 (d1) on CUDA loads its tower only with
--vision; Qwen3.5 on HIP refuses --vision on a text checkpoint instead of serving
text; Flash Next on CUDA names the missing tower before a stream loads. The
header-only text count skips Qwen-VL, Gemma 4, LFM2-VL, LightOn, DeepSeek and GLM
towers too, and a cluster model's non-bool "vision" is refused by name.
… checks stay

refusals.lfm2 refused every --vision before lfm2.open ran the gate, so an LFM2-VL server
could not load its tower at all. It now checks --tp and --rank alone; the test shows
--vision passes and that --tp 2 or --rank 1 with --vision is still refused by name.
Main already holds zig/src/families/qwen3_5/backend/hip/engine/native.zig at 600 lines, so the new VisionWithoutTower refusal line took it to 601 once merged. This drops the blank line after the file's doc comment. No code change.
…nBytes

Main's visionBytes now takes the rank and world (rank 0 of 1 here, as in cuda_dense's tests), so the test's three-argument call stopped compiling once merged. Test only.
@ashhart
ashhart merged commit 68ff0ad into ashhart:main Nov 24, 2026
2 of 12 checks passed
@ashhart

ashhart commented Nov 24, 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.

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.

3 participants