-
Notifications
You must be signed in to change notification settings - Fork 369
Open
Labels
Description
Hi @cpuhrsch,
I noticed that the code uses torch.export.export_for_inference which is not available in the current stable version of PyTorch (2.5.1). This might cause compatibility issues for users who haven't switched to nightly builds yet.
reproduce step
python server.py ../../../ large --port 6006 --furious --fast --save-fast "./"
Saving compiled models under directory ./
Saving at path=PosixPath('sam2_image_encoder.pt2')
Traceback (most recent call last):
File "/root/ao/examples/sam2_amg_server/server.py", line 578, in <module>
fire.Fire(main)
File "/root/miniconda3/envs/sam2/lib/python3.10/site-packages/fire/core.py", line 135, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "/root/miniconda3/envs/sam2/lib/python3.10/site-packages/fire/core.py", line 468, in _Fire
component, remaining_args = _CallAndUpdateTrace(
File "/root/miniconda3/envs/sam2/lib/python3.10/site-packages/fire/core.py", line 684, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "/root/autodl-tmp/ao/examples/sam2_amg_server/server.py", line 437, in main
export_model(mask_generator,
File "/root/autodl-tmp/ao/examples/sam2_amg_server/compile_export_utils.py", line 153, in export_model
aot_compile(model_directory,
File "/root/ao/examples/sam2_amg_server/compile_export_utils.py", line 109, in aot_compile
from torch.export import export_for_inference
ImportError: cannot import name 'export_for_inference' from 'torch.export' (/root/miniconda3/envs/sam2/lib/python3.10/site-packages/torch/export/__init__.py)
Current behavior:
- The code assumes availability of
torch.export.export_for_inference - This feature is only available in PyTorch nightly builds
Suggested solutions:
- Add version check and fallback behavior
- Document PyTorch version requirement
- Consider supporting both stable and nightly versions
Would appreciate your thoughts on how to best handle this compatibility issue.
Related PR: #1468