Skip to content

fix(profiler): request Hub checkpoint file sizes - #16141

Closed
git-jxj wants to merge 3 commits into
ai-dynamo:mainfrom
git-jxj:fix/16140-profiler-hub-weight-sizes
Closed

git-jxj wants to merge 3 commits into
ai-dynamo:mainfrom
git-jxj:fix/16140-profiler-hub-weight-sizes

Conversation

@git-jxj

@git-jxj git-jxj commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The profiler's Hub query leaves checkpoint sizes unset by default, making packed quantized weights fall back to an inaccurate parameter-count estimate. Request file metadata and select checkpoint files through index references or checkpoint filenames so training and optimizer artifacts do not inflate automatic GPU sizing. Select one checkpoint format and use file bytes only when all selected checkpoints have size metadata, preserving the safetensors estimate when metadata is incomplete or the index is unavailable.

For TheBloke/TinyLlama-1.1B-Chat-v1.0-GPTQ, the helper reports the actual checkpoint size of 732.56 MiB instead of 2098.93 MiB. Custom quantized safetensors and indexed custom binary shards are supported.

Validation

  • Model-info/model-cache tests: 55 passed, 2 existing optional-module skips. Training-artifact, partial-size and missing-indexed-shard regressions fail before their corresponding fixes. Connection/timeout exception regressions preserve the metadata fallback.
  • Real Hub queries: exact checkpoint totals for a tiny BERT repository with training_args.bin, TinyLlama GPTQ, and Qwen2.5-3B's sharded index. Only metadata and a JSON index were fetched; no weights or inference engine were loaded.
  • Changed-file pre-commit and git diff --check passed.

Where should the reviewer start?

_get_hub_checkpoint_filenames(), get_model_weight_size_from_hub() and their regressions in test_model_info.py.

Related Issues

Closes #16140.

Use available checkpoint file metadata before the safetensors parameter-count fallback, preventing packed quantized weights from being overestimated.

Fixes ai-dynamo#16140

Signed-off-by: xinjun.jiang <[email protected]>
@git-jxj
git-jxj requested a review from a team as a code owner October 12, 2026 03:08
@copy-pr-bot

copy-pr-bot Bot commented Oct 12, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@git-jxj
git-jxj temporarily deployed to external_collaborator October 12, 2026 03:08 — with GitHub Actions Inactive
@git-jxj
git-jxj temporarily deployed to external_collaborator October 12, 2026 03:08 — with GitHub Actions Inactive
@github-actions github-actions Bot added the fix label Oct 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👋 Hi git-jxj! Thank you for contributing to ai-dynamo/dynamo.

Just a reminder: The NVIDIA Test Github Validation CI runs an essential subset of the testing framework to quickly catch errors.Your PR reviewers may elect to test the changes comprehensively before approving your changes.

🚀

@github-actions github-actions Bot added external-contribution Pull request is from an external contributor planner labels Oct 12, 2026
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: ai-dynamo/dynamo/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 80ef4ff5-e555-46ee-9cb0-01442f579109
📥 Commits

Reviewing files that changed from the base of the PR and between bea55a5 and 2d39b7b.

📒 Files selected for processing (2)
  • components/src/dynamo/profiler/tests/unit/test_model_info.py
  • components/src/dynamo/profiler/utils/model_info.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 9 remain after this review.

Walkthrough

The profiler now requests file metadata when it retrieves model information from Hugging Face Hub. Unit tests cover checkpoint-size summation, tokenizer exclusion, MiB conversion, and fallback results.

Changes

Hub checkpoint size calculation

Layer / File(s) Summary
Request file metadata and verify size calculation
components/src/dynamo/profiler/utils/model_info.py, components/src/dynamo/profiler/tests/unit/test_model_info.py
The Hub model-info request now sets files_metadata=True. Tests cover safetensors sizes, sharded files, tokenizer exclusion, MiB conversion, and fallback results when metadata is unavailable.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 2d39b

The checkpoint-size change is ready to merge after normal checks; no outstanding issue is established.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed The PR satisfies the coding requirements in #16140. get_model_weight_size_from_hub() now calls model_info(..., files_metadata=True), so available checkpoint sizes can be summed. The existing safet…
Out of Scope Changes check Passed The changes stay within #16140. The source change requests checkpoint file metadata, and the tests verify checkpoint-size selection and fallback behavior. No unrelated production behavior or unrelated…
Title check Passed The title clearly and concisely describes the main change: requesting checkpoint file sizes from the Hub for the profiler.
Description check Passed The description is mostly complete. It explains the change, validation, reviewer starting points, and includes the required issue link. It uses "Summary" instead of the template's "Overview" and does …
  • Fix all pre-merge checks with AI
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

"""Return model size in MB by querying Hugging Face Hub API."""
try:
info = model_info(model_name, token=token)
info = model_info(model_name, token=token, files_metadata=True)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting Hub file metadata makes the existing broad extension filter authoritative for remote models, so any non-checkpoint artifact ending in .bin, .pt, or .pth is now included in model_size. A Hub repo that contains Trainer artifacts such as training_args.bin or optimizer.pt will inflate the profiler's GPU search bound even though those files are not inference weights. Filter the metadata total to checkpoint filenames/index entries rather than every file with a weight-like extension, and keep the safetensors fallback when no checkpoint sizes are available.

🤖 AI Fix

Restrict Hub metadata summation to actual checkpoint files, excluding trainer and optimizer artifacts before adding sibling sizes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the follow-up commit: Hub sizes now use checkpoint index weight_map entries (deduplicated and pinned to the metadata revision), or checkpoint filenames when no index is present. Trainer/optimizer/scheduler/scaler/RNG and unrelated binary artifacts no longer contribute; custom quantized safetensors and indexed custom binary shards remain supported. Checkpoint bytes are used only when every selected file is present and has a size; incomplete size metadata or unreadable indexes use the safetensors estimate when available.

Validation: 55 model-info/model-cache tests passed (2 existing optional-module skips), including regressions for partial sizes, missing indexed shards and the installed Hub transport's connection/timeout errors. Changed-file pre-commit passed. A real Hub query for philschmid/tiny-bert-sst2-distilled previously included 2,927 bytes of training_args.bin; it now returns exactly the checkpoint size. TinyLlama GPTQ and Qwen's sharded index also returned their exact checkpoint totals. Only metadata and the JSON index were fetched; no weights or inference engine were loaded.

@pull-request-size pull-request-size Bot added size/L and removed size/M labels Oct 13, 2026
@git-jxj
git-jxj temporarily deployed to external_collaborator October 13, 2026 02:08 — with GitHub Actions Inactive
@git-jxj

git-jxj commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Current head 79c48d378b is still missing the full CI status checks. Could a code owner authorize this revision with /ok to test 79c48d378b when appropriate?

This branch was previously deployed

1 inactive deployment
external_collaborator — 79c48d37 Deployed Oct 13, 2026 by git-jxj via ok-to-test #31168
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contribution Pull request is from an external contributor fix planner size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Profiler ignores available Hub checkpoint sizes for quantized models

1 participant