hunyuan_vl / gemma3n: drop dead assignments in cache-offset extraction#1056
Merged
Conversation
hunyuan_vl was setting ``offset = cache.offset`` in both branches even though only ``offset_scalar`` is read downstream — that variable is never used again. Hoist ``offset_scalar = 0`` above the ``if cache`` branch and drop the unused ``offset`` assignment. gemma3n was eagerly computing ``raw_offset`` via a generator expression before the ``_idx`` fast path even ran. Move that lookup into the fallback branch so the fast path does zero extra work. No functional change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
afanty2021
added a commit
to afanty2021/mlx-vlm
that referenced
this pull request
Apr 24, 2026
Merge changes from upstream: - Blaizzy#1056: hunyuan_vl/gemma3n cache-offset optimization - Blaizzy#1053: Fix DFlash speculative decoding (GPU hang, performance) - Blaizzy#1050: Thread-local generation stream (port mlx-lm#1090) - Blaizzy#1055: Close batch_generate/server decode gap + VLM fixes Conflict resolution: - requirements.txt: Mixed approach - mlx>=0.31.2 with transformers<5.4.0 to maintain omlx compatibility while accepting mlx update Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Small follow-up to #1055 — two post-merge clean-ups spotted while re-reading the changes:
hunyuan_vl/language.py: both branches of the_idxcheck assignedoffset = cache.offset, but onlyoffset_scalaris read downstream (for thexdrope_sectionprefill-vs-decode branch). Dropped the dead assignment, and hoisted theoffset_scalar = 0default above theif cache is not Noneso the no-cacheelsedisappears.gemma3n/language.py:raw_offsetwas computed via a generator expression before the_idxfast path ran, even though the fast path doesn't use it. Moved the lookup into the fallback branch so the fast path does zero extra work.No functional change; same outputs on the same inputs.
Test plan
from mlx_vlm.models.hunyuan_vl import language/from mlx_vlm.models.gemma3n import language— imports clean.mlx-community/gemma-3n-E2B-it-8bit+tencent/HunyuanOCR(CLI + server single + server concurrent).🤖 Generated with Claude Code