Skip to content

Vision: patch preparation written from documented behaviour, with the same bytes - #2271

Merged
ashhart merged 2 commits into
mainfrom
lead/patches-rewrite
Nov 6, 2026
Merged

ashhart merged 2 commits into
mainfrom
lead/patches-rewrite

Conversation

@ashhart

@ashhart ashhart commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Rewrites zig/src/core/picture/patches.zig without working from the Transformers source, so that file no longer follows a library. The output doesn't change.

Where each rule comes from:

  • Budgets, geometry and aspect-preserving resize: the published Qwen2-VL, Qwen2.5-VL and LFM2-VL model cards.
  • Discrete sizing the cards don't state (half ties to even, grow and shrink rounding, the final factor clamp), patch ordering, normalization order and cache identities: our own tests and black-box output from the previous build.

The writer didn't open the old body or any library implementation, and the new body was frozen before the comparison. THIRD_PARTY_NOTICES.md now describes this. patches_test.zig keeps its credit for the recorded reference data.

Checks:

  • The new and old builds give byte-equal output in 55,503 host cases, 422,615,895 bytes: sizing grids, half-grid ties, pixel budgets, both variants and both resizers, both normalization modes, ramps, impulses, seeded RGB and encoded-PNG identities. A one-bit control fails at byte zero.
  • Focused host tests: 25 passed, 4 optional-codec corpus checks skipped.
  • Lean shows no new findings, and the file is 157 lines.

Not run: any device or model. Bytes out of this file are what the vision paths read, so equal bytes mean they get the same input.

Rebuild image-grid sizing and patch layout from published model cards and
the project's behavior tests, preserving normalized pixels and cache IDs.

Raw output matches main in 55,503 host cases across both resize paths and
normalization modes. Keep the recorded processor-reference data credit.
@ashhart
ashhart force-pushed the lead/patches-rewrite branch from f28446b to 46f8f05 Compare November 6, 2026 00:20
@ashhart

ashhart commented Nov 6, 2026

Copy link
Copy Markdown
Owner Author

Our M5 Ultra run on Qwen3.8-27B, main against this branch: tokens are equal in all 20 rows, and every cell is within 1%.

  • 32K prompts: prefill 1,670 tok/s on both.
  • Decode: 43.5 to 44.3 tok/s on both.
  • 1 to 8 streams, chat and code, greedy and sampled: all within -0.6% to +1.0%.

It stays in the landing queue.

@ashhart
ashhart merged commit 54695a8 into main Nov 6, 2026
7 checks passed
@ashhart
ashhart deleted the lead/patches-rewrite branch November 10, 2026 16:34
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