cp: fix(diffusion): reuse warm HF cache instead of re-downloading models (2747) into r0.5.0 - #2754
Merged
Merged
Conversation
…2747) * fix(diffusion): reuse warm HF cache instead of re-downloading models The diffusers bridge and preprocessing processors passed bare repo ids to diffusers' from_pretrained, which resolves in online mode by default and re-validates (and can re-download) a warm HF_HOME over the network on every run. The transformers bridge avoids this by pre-resolving the repo to a local snapshot dir; port the same discipline to the diffusion path. - Add resolve_diffusion_model_dir() helper: returns local paths unchanged, downloads once only on a cold cache when online, then resolves the local snapshot with local_files_only=True so from_pretrained does no network I/O. - Use it in NeMoAutoDiffusionPipeline.from_pretrained and from_config. - Use it in the flux, flux2, hunyuan, qwen_image, and wan processors. - Add unit tests for the helper. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Pranav Prashant Thombre <pthombre@nvidia.com> * fix(diffusion): make HF cache resolver patchable and keep diffuser tests offline The cache-resolution helper imported snapshot_download inside the function body, so test_hf_cache.py's patch of the module-level name failed at setup. Bind it at module scope (guarded by the optional-dep check) so it is patchable, with identical runtime behavior. The auto_diffusion_pipeline from_pretrained/from_config tests mock DiffusionPipeline but not the newly added resolve_diffusion_model_dir call, so they reached the Hub for fake repo ids (401). Add an autouse fixture that resolves repo ids to a passthrough, keeping the unit tests offline. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Pranav Prashant Thombre <pthombre@nvidia.com> --------- Signed-off-by: Pranav Prashant Thombre <pthombre@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: NeMo Bot <nemo-bot@nvidia.com>
Contributor
Author
|
/ok to test a0fedc8 |
akoumpa
approved these changes
Jun 24, 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.
beep boop [🤖]: Hi @pthombre 👋,