mirror of
https://github.com/openai/CLIP.git
synced 2026-11-05 01:37:26 +00:00
[PR #550] fix: rewind file pointer and handle AttributeError on JIT load fallback #532
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openai/CLIP#532
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/openai/CLIP/pull/550
Author: @reginaldalfret
Created: 10/14/2026
Status: 🔄 Open
Base:
main← Head:fix/issue-494-load-fallback📝 Commits (1)
4b5b3b4fix: rewind file pointer and handle AttributeError on JIT load fallback📊 Changes
2 files changed (+36 additions, -1 deletions)
View changed files
📝
clip/clip.py(+2 -1)➕
tests/test_model_fallback.py(+34 -0)📄 Description
Summary
In
clip.load(), when attempting to load a checkpoint file, the function first triestorch.jit.load():If
torch.jit.load()encounters an incompatibility (such as anAttributeErrorfrom missing script attributes in certain environments) or fails after reading initial bytes from the stream:AttributeErrorwas uncaught, causing an unhandled crash rather than falling back to loading a plain PyTorchstate_dict.opened_file.seek(0)), causingtorch.load()to read from an offset position and fail during unpickling.Fix
(RuntimeError, AttributeError)in the fallback handler.opened_file.seek(0)before callingtorch.load(opened_file).Validation
tests/test_model_fallback.pyverifying that whentorch.jit.loadraisesAttributeError,clip.loadcatches it, rewinds the file stream, and loads the model viatorch.load.Closes #494
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.