JIT-compiling the extension results in non-functional Python module.
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 领域
- build-system
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Python
- 星标
- 1.2k
- 派生
- 250
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pytorch/extension-cpp 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 68/100
pytorch/extension-cpp#100 · 5 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 78/100
pytorch/extension-cpp#82 ·
-
难度 4/5 3-5 天 新手友好度 45/100
pytorch/extension-cpp#124 ·
-
难度 3/5 1-2 天 新手友好度 35/100
pytorch/extension-cpp#123 ·
-
难度 4/5 1-2 天 新手友好度 12/100
pytorch/extension-cpp#121 · 3 条评论 ·
查看 pytorch/extension-cpp 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
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"可能已有人在做 @cestercian 今天认领。 未关闭comp/cli P2 type/bug
难度 2/5 1-3 小时 新手友好度 75/100
NousResearch/hermes-agent#162259 · 1 条评论 ·
维护者通常 1 天内回复
-
upstream update
难度 2/5 1-3 小时 新手友好度 72/100
conan-io/conan-center-index#31597 ·
维护者通常 1 天内回复
-
bug enhancement
难度 1/5 1 小时以内 新手友好度 90/100
AOSSIE-Org/PictoPy#1802 · 2 条评论 ·
维护者通常 3 天内回复
-
community-request
难度 2/5 1-3 小时 新手友好度 78/100
NVIDIA-NeMo/Run#727 ·
维护者通常 1 天内回复