Add multi-directory checkpoint loader for multimodal alignment poc#4452
Closed
subawocit wants to merge 1 commit into
Closed
Add multi-directory checkpoint loader for multimodal alignment poc#4452subawocit wants to merge 1 commit into
subawocit wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
e525fac to
a248b97
Compare
Add omni_checkpoint_stitcher and omni-gemma3-qwen3 configuration pylint add test file POC Phase 1: Implement checkpoint stitching and preparation pipeline reorg files better file description pyink pyink pyink improve print statement
c3b7f52 to
e5d43ed
Compare
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.
Description
This PR implements the multi-directory checkpoint loader. It loads pretrained parameter subtrees from two distinct checkpoints (e.g., a Gemma 3 vision tower and a Qwen 3 decoder as the initial setup) and merging them into a unified multimodal checkpoint.
Step 1 of a 5-step Proof-of-Concept for any-to-any multimodal alignment in MaxText. Overall goal is to align a pretrained vision encoders with another text-only LLM, and connecting the two with a dynamically configured adaptation layer (MLP connector), special tokenizer mapping for visual placeholder tokens, and train only the MLP using supervised fine tuning.
Files
prepare_checkpoint.pyMain script: download original vision and language models' checkpoints from Hugging Face, convert to MaxText format, and stitch two checkpoints into a single multimodal checkpoint.
omni-gemma3-qwen3.ymlConfiguration file combining the Qwen 3 4B language backbone with the Gemma 3 4B vision tower.
checkpoint_stitcher/stitch.pyCheckpoint stitcher utility that loads pretrained parameter subtrees from two separate checkpoints and merges them into a unified checkpoint.
checkpoint_stitcher/unittest_stitch.pyUnit tests.
Usage
Define
hf_tokenandbase_output_directoryinprepare_checkpoint.py, then:The checkpoints from the stitched model will then be saved in output directory.
Tests
Unit tests:
Unit Test Results
Step-by-Step Objectives
√Multi-Directory Checkpoint Restoration: Implemented selective sub-tree parameter loading using Orbax such that we can initiaze a multimodal model with parameters from multiple checkpoints.nextDynamic MLP Connector: Add omni modal adapter layer (MLP) to connect vision tower output to the LLM decoderChecklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.