Skip to content

compat 906: carry upstream's revert of prop.integrated on HIP — fixes the gfx1151 vision regression - #317

Merged
glennneuber merged 2 commits into
mainfrom
fix/hip-integrated-flag-906
Sep 18, 2026
Merged

glennneuber merged 2 commits into
mainfrom
fix/hip-integrated-flag-906

Conversation

@glennneuber

Copy link
Copy Markdown

Fixes the vision regression that made ollama 0.34.x unusable on gfx1151, by carrying an upstream revert that landed 78 minutes after our payload was cut.

The defect

Upstream c7d8722922a (llama.cpp#24233) set info.devices[id].integrated = prop.integrated on HIP builds. On an integrated/UMA device that changes which buffer types the backend claims, and llama.cpp#28211 root-causes the consequence as an MMQ tile-barrier race on gfx115x producing wrong output with no crash and no warning, once a decode exceeds n_ubatch.

Upstream reverted it in #28604, merged 2026-09-08T14:19:53Z. Our payload b10864 is 5d806aa25, 2026-09-08T13:01:03Z. We are on the wrong side of it by 78 minutes.

Two independent upstream reports describe our exact symptom on our exact silicon: #27419 ("upper image content is lost while Vulkan/CPU are correct" — Ryzen AI Max+ 395 / Radeon 8060S / gfx1151 / Qwen3.8-27B) and #28211.

Before and after

Five-model campaign against the 2026-09-17 baseline (#303), same runner, same digests, same environment, one power envelope. Scene bbox IoU:

model 0.32.1 (b9888) 0.34.1 (b10864) 0.34.1 + 906
qwen3.8:27b-q4_K_M 0.991 0.065 1.000
gemma4:31b-it-q4_K_M 0.961 0.922 (3/6 objects) 0.960
nemotron3:33b-q4_K_M 0.857 0.161 0.862
qwen3.6:35b-a3b-q4_k_m 0.953 0.273 0.972
gemma4:26b-a4b-it-q4_K_M 0.973 0.966 0.975

All five return to 6/6 · 6/6 · 6/6 boxes/labels/colours and 5/5 · 5/5 · ✅ invoice extraction. Unpatched 0.34.1 scored 0/5 on invoice for three of them.

This satisfies gate clause 4 — qwen35moe (qwen3.6:35b-a3b) shows 0 degenerate and scores above the baseline.

Why it tracked the image-token budget

gemma4:31b, budget pinned per cell with run_budget_sweep.sh, name_bbox_mean_iou:

budget 0.32.1 0.34.1
280 0.612 0.691
560 0.713 0.714
1120 0.728 0.000

1120 image tokens push the decode past n_ubatch; 280 and 560 do not. Since the fork pins --image-max-tokens 1120 on every gemma4 launch (#309), every gemma4 vision request on an unpatched 0.34.x build was hitting the broken path.

Refuted along the way, each by experiment

Recorded so nobody re-runs them:

  • fp16 accumulation in the vision tower — GGML_CUDA_CUBLAS_COMPUTE_TYPE f32 / f16 / unset all equally broken, env var verified to reach the llama-server process
  • multi-sub-batch image decode — at num_batch 2048 the image decodes in a single decoding image batch 1/1, n_tokens_batch = 2040, still broken
  • the b10864 resize-algo flip (#27594) — reverted as a compat patch, verified present in-binary by output-hash diff at identical prompt_eval/eval, fixed nothing. That patch (905) is dropped in this branch rather than left as dead weight.
  • the gemma4 budget bump (#28335) — creates the rung that exposes the bug, is not the bug
  • GGML_CUDA_NO_PINNED=1 — not a workaround; the runner aborts on load (signal: aborted, core dumped)
  • direct I/O, GPU layer placement, host drift, and our own compat series — stock ollama/ollama:0.34.1-rocm reproduces the regression identically

prompt_eval_count is identical between builds at every budget rung, so preprocessing and token counts never moved — the corruption is downstream of the image path entirely.

Verification

Full series 001/002/004/005/801/903/906 applies to a clean b10864 with plain git apply, and the outcome is checked rather than just the exit code: after applying, grep 'integrated = prop.integrated' returns nothing. Build is 2m38s on the ccache mount.

Caveats

  • gemma4:31b name_bbox returns to 0.663–0.72 against the baseline's 0.728 — restored, but repeats would be good, especially given the known run-to-run spread on 0.34.x (docs(vision): SOLVED — the 0.34.0 gemma4 vision shift is upstream MLX #3912 #310).
  • qwen3.8 multi-image loses q4_bbox_hit where the baseline had it; the anchored variant passes. One cell, unrepeated.
  • Drop this patch once the payload advances past d4389a4dd92.

Cross-platform verification requested in #313 — in particular whether this defect class reaches CUDA unified-memory devices, which bears on gate issue ollama#17475.

🤖 Generated with Claude Code


Recreated from #314, which GitHub closed when the head branch was renamed from fix/restore-bilinear-resize (a leftover from a refuted hypothesis) to fix/hip-integrated-flag-906. Same commits, same content; #314 carries the earlier discussion.

Local Dev and others added 2 commits September 18, 2026 17:56
b10864 switched these projectors from bilinear to bicubic in the same hunk that
raised gemma4's ceiling from (40,280) to (70,1120), and separately deleted the
naive resamplers so every algo now routes through the Pillow-parity path.

Measured on gfx1151, gemma4:31b-it-q4_K_M, budget pinned with run_budget_sweep.sh,
name_bbox_mean_iou: at 280 and 560 the two builds agree (0.612/0.691, 0.713/0.714),
at 1120 it goes 0.728 -> 0.000. prompt_eval_count is identical between builds on
every test, so the grid and token count are unchanged and only the pixels differ.
1120 is the only rung that enlarges a 1920x1080 source.

Changes the resampler ONLY, leaving (70,1120) alone, so a re-run at 1120 isolates
it. Verified: the full series 001/002/004/005/801/903/905 applies to a clean
b10864 with plain git apply.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Upstream PR #28604 (d4389a4dd92) reverts c7d8722922a (#24233). Our payload
b10864 is 5d806aa25 at 2026-09-08T13:01:03Z; the revert landed at 14:19:53Z the
same day, so v0.34.1 carries the defect and not the fix -- we missed it by 78
minutes.

Upstream #28211 root-causes it on gfx115x as an MMQ tile-barrier race that
produces wrong output with no crash once a decode exceeds n_ubatch, and #27419
reports our exact symptom on our exact silicon: upper image content lost on HIP
while Vulkan and CPU are correct.

Measured here on gemma4:31b with the budget pinned, name_bbox_mean_iou is
0.728 -> 0.000 at the 1120 rung only; 280 and 560 are equivalent between builds.
prompt_eval_count is identical, so the pixels reaching the model are unchanged.

Replaces 905, which reverted the b10864 resize-algo flip and is dropped: it was
built, verified present in-binary by output-hash diff, and did not fix anything.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@glennneuber
glennneuber merged commit 1114b85 into main Sep 18, 2026
27 of 28 checks passed
@glennneuber
glennneuber deleted the fix/hip-integrated-flag-906 branch September 18, 2026 11:15
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.

1 participant