JIT-compiling the extension results in non-functional Python module.
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Lĩnh vực
- build-system
Hướng nghiên cứu
The problem is the empty PYBIND11_MODULE block in extension_cpp/csrc/muladd.cpp, which the reporter loads with torch.utils.cpp_extension.load. Start by reading how load treats is_python_module and whether the module's def calls are what expose functions on the returned Python module. Done means extension_cpp.mymuladd resolves after load, and torch.ops.extension_cpp.mymuladd still works.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
When submitting a bug report, please include the following information (where relevant):
- OS: Arch Linux
- PyTorch version: 2.3.0
- How you installed PyTorch (conda, pip, source): conda
- Python version: 3.12
- CUDA/cuDNN version: 12.1 (runtime) / 8.9.2
- GPU models and configuration: 1070 Ti
- GCC version (if compiling from source): /
When using torch.utils.cpp_extension.load to JIT compile the extension, the returned module does not provide access to the exported functions.
Code to reproduce (in interactive Python session with working directory extension-cpp):
>>> import torch
>>> from torch.utils.cpp_extension import load
>>> extension_cpp = load(name="extension_cpp", sources=["extension_cpp/csrc/muladd.cpp"])
>>> extension_cpp.mymuladd
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'extension_cpp' has no attribute 'mymuladd'
Note that after the loading, the following does work:
>>> torch.ops.extension_cpp.mymuladd
<OpOverloadPacket(op='extension_cpp.mymuladd')>
I.e., load does seem to have the side-effect of loading the PyTorch op (similar to setting is_python_module=False), but does not provide the functions in the Python module.
I would expect to be able to use extension_cpp in the same way as torch.ops.extension_cpp.
I suspect that this issue is due to the empty PYBIND11_MODULE block.
This seems to be confirmed by the fact that the following modification in muladd.cpp makes extension_cpp.mymuladd available:
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
m.def("mymuladd", &mymuladd_cpu, "custom pytorch operation 'muladd'");
m.def("mymul", &mymuladd_cpu, "custom pytorch operation 'mul'");
m.def("myadd_out", &mymuladd_cpu, "custom pytorch operation 'add_out'");
}
However, I am not sure if this is just a workaround or the actual bug-fix.
- Ngôn ngữ chính
- Python
- Star
- 1.2k
- Fork
- 250
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của pytorch/extension-cpp
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
pytorch/extension-cpp#100 · 5 bình luận ·
-
Deprecation warningĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
pytorch/extension-cpp#82 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
pytorch/extension-cpp#124 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
pytorch/extension-cpp#123 ·
-
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 12/100
pytorch/extension-cpp#121 · 3 bình luận ·
Tất cả issue của pytorch/extension-cpp
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
hermes hooks doctor smoke test never checks the hook exit code — a crashing hook (exit=1) renders ✓ "ran clean" and "All shell hooks look healthy"Có thể đã có người làm @cestercian đã nhận hôm nay. Đang mởcomp/cli P2 type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
NousResearch/hermes-agent#162259 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[request] gRpc/1.86.0Đang mởupstream update
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
conan-io/conan-center-index#31597 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug enhancement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
AOSSIE-Org/PictoPy#1802 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
community-request
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
NVIDIA-NeMo/Run#727 ·
Maintainer thường phản hồi trong vòng 1 ngày