feat(tools): add HF model normalization utility - #2073
Open
caixianzhang wants to merge 4 commits into
Open
Conversation
jayhenry
approved these changes
Sep 7, 2026
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
xtuner.tools.model_normalizeCLI for HF repack and FP8 conversionScope
This PR intentionally provides conversion/repacking only. It does not run full-model validation, SHA256 scans, inference services, or Hub uploads.
Validation
ruff check xtuner/tools/model_normalize tests/tools/test_model_normalize_cli.pyPYTHONPATH=. pytest -q --confcutdir=tests/tools tests/tools/test_model_normalize_cli.py(2 passed, 1 skipped whensafetensorsis unavailable)bash xtuner/tools/model_normalize/run_model_normalize.sh --helprun_glm52.shusageThe GLM-5.2 example accepts one positional argument:
It does not define other positional arguments; extra arguments are ignored.
Environment variables:
SOURCE_DIROUTPUT_ROOTSHARD_SIZE_GB4REFERENCE_DIRMAX_SAVE_WORKERS4BF16 example:
FP8 example:
The output directories are fixed relative to
OUTPUT_ROOT:Real-model smoke test
The wrapper was also run against the GLM-5.2-derived HF checkpoint in the
glm5-2-8gpu-99022910-cfcd2Job. Because the Job has no external networkaccess, the PR code was staged through the shared storage into a temporary
directory; the existing repository checkout was not modified.
Input:
Commands used:
Results:
model.safetensors.index.jsonandconfig.json; bothconversion sessions exited normally.
it does not replace full-model loading, semantic weight validation, or
inference testing.
generation_config.jsonwas absent because it was notpresent in the input checkpoint.