Repository navigation
Sync upstream ml-explore/mlx-swift-lm efcedcd (Gemma 4 VLM hidden states #730) - #90
Merged
Merged
Conversation
Add hiddenStates(_:) at @_spi(GemmaEncoder) on Gemma4 and Gemma4Unified. It returns the text decoder's final-norm hidden states for an LMInput, built through the same helper prepare now uses: soft tokens on their placeholder rows, per-layer inputs, and the token types that drive bidirectional vision attention. Clients can read the LM head's input from the loaded VLM without a second, text-only model.
Pulls in Gemma 4 VLM hidden states (ml-explore#730). Conflicts resolved in Libraries/MLXVLM/Models/Gemma4.swift: - keep the fork's streamExperts (StreamableMoE) property; - take upstream's hiddenStates(_:) and multimodalInputs(_:), with the audio input threaded through (fork-only audio source, Gemma4 audio tower); - keep the fork's PLE output masking in getInputEmbeddings (fork commit 353c33a). Co-Authored-By: Claude Haiku 5.5 <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
efcedcd(Gemma 4 VLM: expose hidden states for a prepared input (@_spi(GemmaEncoder)) ml-explore/mlx-swift-lm#730: Gemma 4 VLM exposeshiddenStates(_:)for a prepared input) into forkmain, as a merge commit so downstream pins stay valid.e2d15c7; upstream main wasefcedcd, 1 commit ahead.Conflict resolution (
Libraries/MLXVLM/Models/Gemma4.swift)streamExperts(StreamableMoE) kept from the fork.hiddenStates(_:)andmultimodalInputs(_:)taken, withinput.audiothreaded through. The fork's audio source and audio tower stay ingetInputEmbeddings, andpreparetakes the audio branch.getInputEmbeddingskept. It came from fork commit353c33aand is not in upstream or the merge base.Gemma4Unifiedmerged without conflict; itshiddenStatesalready passes audio.Verification
Tests/MLXLMTests/Gemma4VLMHiddenStatesTests.swift(added from upstream).🤖 Generated with Claude Code