Skip to content

Consolidate VLM sequential engine: shared iterator helpers, tidy (B3+B4) - #251

Draft
stikves wants to merge 1 commit into
apple:mainfrom
stikves:sukru/vlm-consolidation-b3b4
Draft

stikves wants to merge 1 commit into
apple:mainfrom
stikves:sukru/vlm-consolidation-b3b4

Conversation

@stikves

@stikves stikves commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Follows #249 (B1+B2). Third step of the VLM/text sequential-engine consolidation.

Changes

  • B3: move the max-token clamp and next-token selection (identical in CoreAISequentialEngine and CoreAISequentialVLMEngine) into a SequentialIterator namespace both call. Each engine keeps its own next() loop: the text engine's batched forced-continuation PPL path and prefix cache, the VLM engine's image prefill.
  • B4: drop the addressed re-use TODO in the VLM engine, fold the repeated reset/warmup state-clear into clearGenerationState(), update the class doc.

No behavior change.

Tests

New SequentialIteratorTests (clamp, next-token). Existing suites pass under swift test --disable-sandbox.

Validation

Bit-exact vs the pre-refactor baseline: text greedy 128/128, forced-continuation PPL exact; VLM greedy 115/115 and 400/400.

Notes

Not a full generic iterator: the text batched-PPL path stays in place rather than being merged. C1+C2 (factory-based VLM construction, CLI-fork removal) follow in a stacked PR.

Extract the identical scalar iterator logic (max-token clamp, next-token
selection) shared by CoreAISequentialEngine and CoreAISequentialVLMEngine into
a SequentialIterator namespace both call, and tidy the VLM engine: drop the
addressed re-use TODO, dedup the post-warmup/reset state-clear into
clearGenerationState(), and refresh the class docs to describe the now-shared
decode machinery.

Behavior-preserving; each engine keeps its own generation control flow.
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