Fix dynamic module symlinked cache on trust_remote_code models - #46618
Conversation
Rocketknight1
left a comment
There was a problem hiding this comment.
Yes, this looks like it makes sense for symlinked remote code dirs!
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
@Rocketknight1 Hi, could you help me merge the PR. I see auto merge is enable but look like the check |
|
Working on it! |
b77a326 to
9320453
Compare
|
The check is failing because the test: |
|
This is just our CI, I'll try rebasing/retrying. |
9320453 to
50b9e41
Compare
|
CI Dashboard: View test results in Grafana |
|
View the CircleCI Test Summary for this PR: https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=46618&sha=50b9e4 |
27d8151
Tysm for your work. |
…ngface#46618) fix trust_remote_code model cache
What this fixes
#46617
Loading a
trust_remote_codemodel from a local, symlinked cache crashes with:A standard
huggingface_hubcache stores each file twice:read: https://huggingface.co/docs/huggingface_hub/en/guides/manage-cache
_compute_local_source_files_hashdidPath(resolved_module_file).resolve()before callingget_relative_import_files. That follows the snapshot symlink intoblobs/, andget_relative_import_filesthen derives sibling import paths fromPath(module_file).parent(now
blobs/). The named.pysiblings only exist insnapshots/<rev>/, not inblobs/, so thelookup raises
FileNotFoundError.Fix
snapshots/<rev>/where the named*.pysymlinks live.path components such as macOS
/var→/private/var) and keep the file's logical name.read_bytes()still follows the symlink, so content is hashed correctly. For plainnon-symlinked local dirs the produced hash is unchanged (no cache churn).
Tests
Added a regression test in
tests/utils/test_dynamic_module_utils.pythat build the realblobs/+snapshots/symlink layout:test_get_cached_module_file_local_handles_symlinked_hub_cache— loads a module with a transitiverelative-import chain (A→B→C) from a symlinked cache; fails on
mainwith the exactFileNotFoundError, passes with the fix, and asserts the transitive deps are copied with correctcontent.