Skip to content

SWF(bug): reject invalid mmproj patch frame indices - #91

Merged
maplepaladin73 merged 2 commits into
mainfrom
devin/1795406532-mmproj-patch-frame-bound
Nov 23, 2026
Merged

maplepaladin73 merged 2 commits into
mainfrom
devin/1795406532-mmproj-patch-frame-bound

Conversation

@maplepaladin73

@maplepaladin73 maplepaladin73 commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

CLIP mmproj GGUF patch-embed frame suffixes are now bounded by the number of patch-frame tensors in the file, so v.patch_embd.weight.18446744073709551615 returns a loader error instead of panicking or forcing a huge patch_frames allocation.

Root cause: vision_patch_frame() accepts any usize suffix, and load_pass() used that value directly as a Vec index/length. usize::MAX overflowed frame + 1 in debug builds and indexed past the empty vector in release; smaller hostile indices could still allocate frame + 1 entries before the contiguity check.

Test plan

Try it (CPU):

ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo test -p spark-runtime --lib clip_patch_frame_index_is_bounded -- --nocapture
  • Before: the new regression test panicked on main at crates/spark-runtime/src/weights/gguf/sidecar.rs:141 (attempt to add with overflow) with a synthetic clip GGUF containing v.patch_embd.weight.18446744073709551615.
  • After: targeted test → 1 passed; full cargo test -p spark-runtime --lib → 590 passed; 0 failed; 11 ignored (re-run after merging main).
  • cargo fmt --all -- --check
  • ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo clippy --workspace --tests
  • bash scripts/check-license-headers.sh (4283 files checked, 0 invalid)
  • typos
  • Added regression test through sidecar::load_pass with a synthetic clip GGUF.
  • Untested: real mmproj GGUF / GPU vision load (CPU parser/loader-path change only).

Notes for reviewers

Valid contiguous frame sets are unchanged: frame indices must still be 0..T-1, and the new check only rejects an index that cannot belong to that set because it reaches the file's patch-frame tensor count. The GGUF tensor-directory arithmetic overflow is intentionally untouched here (landed separately in #90).

Branch updated with main after #90 merged; the only conflict was in crates/spark-runtime/src/weights/gguf/tests.rs, resolved by keeping both the malformed-directory tests and this regression test.

CLA


Software Factory opened this PR for Robert
Implemented in session Bound mmproj patch-frame index from GGUF tensor names
Review with Devin · Open in Devin Desktop


Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

…oj-patch-frame-bound

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

# Conflicts:
#	crates/spark-runtime/src/weights/gguf/tests.rs
@maplepaladin73
maplepaladin73 merged commit 002b072 into main Nov 23, 2026
1 check passed
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