Support model initialization without loading pretrained weights - #9821
Open
LiXinYuECNU wants to merge 1 commit into
Open
Support model initialization without loading pretrained weights#9821LiXinYuECNU wants to merge 1 commit into
LiXinYuECNU wants to merge 1 commit into
Conversation
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
LiXinYuECNU
requested a deployment
to
qoder-review
July 30, 2026 09:24 — with
GitHub Actions
Waiting
LiXinYuECNU
marked this pull request as ready for review
July 31, 2026 08:09
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
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
load_modelandreturn_dummy_modelmodel arguments to control model instantiation and pretrained-weight loadingconfig.json, including support fordevice_map=metaswift export --to_model_summaryto inspect model architecture, parameter statistics, tokenizer, and template information without loading pretrained weightsMotivation
Some workflows need the model architecture and processor but do not need pretrained weights. Examples include training a model from random initialization, debugging tokenization/templates, and inspecting large model architectures without allocating real parameter memory or downloading weight files.
With this change:
--load_model falseprepares only the config and processor--return_dummy_model truebuilds the complete model from its config with randomly initialized parameters--device_map metakeeps the dummy model on the meta device for architecture inspection without real memory allocationUser impact
Users can initialize models for training without loading pretrained checkpoints, or inspect model/tokenizer metadata through the export pipeline. Existing behavior remains unchanged because
load_model=trueandreturn_dummy_model=falseare still the defaults.Validation
git diff --checkpassed