[baseten] fix(model): tolerate missing remote-code siblings in check_imports hook - #21
Merged
ShreyaRavi merged 6 commits intoJul 17, 2026
Conversation
…imports hook The recursive check_imports hook walks transitive relative imports by opening files on disk, but on the hub path transformers calls check_imports before downloading the module's relative imports — on a cold HF cache the walk dies with FileNotFoundError (Kimi-K2.6: modeling_deepseek.py). Guard the walk on file existence and return missing siblings by name: get_cached_module_file downloads each named module and re-enters the hook on it, so deeper imports are covered on that pass. Local-dir loads (all files present) still return the full transitive closure. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…hed_module_file Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
| @@ -0,0 +1,13 @@ | |||
| # Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved. | |||
Author
There was a problem hiding this comment.
it's standard for everything in models/, keeping it to match convention.
generally __init__.py is what you use to tell Python this is a package (so its contents can be imported)
iankorovinsky
approved these changes
Jul 17, 2026
iankorovinsky
left a comment
There was a problem hiding this comment.
left one comment (non-blocking)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This reverts commit 357c464.
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.
Problem
The
check_importshook from #? (b4072116, carried viaf9c16ee2) walks transitive relative imports of remote-code modules by opening files on disk (get_relative_import_files). On the hub path, transformers callscheck_importsbefore downloading the module's relative imports, so on a cold/partial HF cache the walk opens a file that isn't there yet:Every trainer rank dies at model build. Deterministic on cold caches for any
trust_remote_codemodel with relative imports (Kimi K2.x, etc.); masked on warm caches and pre-staged local dirs, which is why it wasn't seen when the hook landed. Root-caused from baseten/trainers benchmarking runs ofmoonshotai/Kimi-K2.6(jobsqex2o23fail /31yljg3pass with files materialized).Fix
Existence-guarded BFS instead of the blind walk. Missing siblings are returned by name:
get_cached_module_filedownloads each named module and re-enters this hook on it, so deeper imports are covered on that pass (verified against transformers 5.xdynamic_module_utilssource).Testing
modeling_deepseek.pywithout materialized siblings and passes model build with them (equivalent prefetch).🤖 Generated with Claude Code