Repository navigation
fix: register unmapped leaf parameters so module conversions reach them - #1940
Merged
Merged
Conversation
Collaborator
|
Looks good, merging now! |
1 task done
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
Fixes #1935.
_register_unowned_container_stateregistered unmapped buffers of every module, but unmapped parameters only of modules with children. The per-layer embedding modules on Gemma 4 E2B/E4B and Gemma 3n and the AltUp projections on Gemma 3n are unmapped leaves, so.half()and the othernn.Module._applyconversions, conversions of a parent module, andparent.parameters()missed their weights.The children check is gone, so unmapped parameters get the same owner views as unmapped buffers. This also reaches the unmapped multimodal modules: the audio tower on Gemma 4 E2B/E4B, the audio and vision towers on Gemma 3n, the vision tower on T5Gemma2 and the VQ tokenizer on Emu3.
bridge.state_dict()keys and hooks are unchanged;parent.state_dict()gains_container_state_owners.*keys for the newly reachable parameters. As noted in #1935,test_parent_and_direct_traversal_have_identical_stateno longer flags an adapter that leaves a leaf module unmapped.test_parent_module_traversal.pygains two Gemma 4 cases (per-layer embeddings, and the audio and vision towers) andtest_dtype_conversion_updates_unmapped_leaf_parametersforbridge.half()andparent.to(torch.float16);test_gemma3n_bridge.pygainstest_half_converts_unmapped_parameters. All five fail ondevand pass with the fix.Type of change
Checklist: