JIT-compiling the extension results in non-functional Python module.
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Bereich
- build-system
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- Python
- Sterne
- 1.2k
- Forks
- 250
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus pytorch/extension-cpp
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 68/100
pytorch/extension-cpp#100 · 5 Kommentare ·
-
Deprecation warningOffen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 78/100
pytorch/extension-cpp#82 ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
pytorch/extension-cpp#124 ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
pytorch/extension-cpp#123 ·
-
Schwierigkeit 4/5 1-2 Tage Anfängerfreundlichkeit 12/100
pytorch/extension-cpp#121 · 3 Kommentare ·
Alle Issues in pytorch/extension-cpp
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag
-
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"Evtl. vergeben @cestercian hat das heute übernommen. Offencomp/cli P2 type/bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
NousResearch/hermes-agent#162259 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
[request] gRpc/1.86.0Offenupstream update
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
conan-io/conan-center-index#31597 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug enhancement
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
AOSSIE-Org/PictoPy#1802 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 3 Tagen
-
community-request
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
NVIDIA-NeMo/Run#727 ·
Maintainer antworten meist innerhalb von 1 Tag