Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Python bindings: Module path gives device-tagged unplanned outputs host memory

未关闭
#23,553 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
cpp, python, pytorch

调研方向

Read extension/pybindings/pybindings.cpp, especially PyModule::allocate_output_tensors, and compare its behavior with the Method path fixed in #23547. Investigate how output tensors can own device buffers while preserving the ownership behavior described in the issue. Done means unplanned device-tagged outputs through the Module path use appropriate device memory and repeated calls remain safe while callers retain prior results.

由索引模型根据 Issue 内容生成。

描述

🐛 Describe the bug

PyModule::allocate_output_tensors in extension/pybindings/pybindings.cpp (the _load_for_executorch / Module path) backs every unplanned tensor output with std::vector<uint8_t>(nbytes) through make_tensor_ptr, whatever device the program tagged the output with.

So a program exported device resident (skip_d2h_for_method_outputs=True with alloc_graph_output=False) fails through this path the same way the Method path did before #23547:

  • The CUDA backend rejects the host buffer with InvalidArgument (0x12), because its cudaPointerGetAttributes check finds no CUDA allocation.
  • A delegate without that check writes into the host buffer. The CUDA tensor returned over it then fails to clone on a GPU that cannot read pageable host memory, with CUDA error: invalid argument and "Allocation not found" from cuMemcpyDtoDAsync_v2.

#23547 fixes the Method path (PyMethod::allocate_output_storages). This path needs the same choice, with one more requirement: make_tensor_ptr takes ownership of the host bytes, so a device buffer has to be owned by the tensor the same way, or the next call writes through a result the caller still holds.

Reported by @Gasoonjia in review of #23547. Part of #23101.

Versions

ExecuTorch main at 1802bcf030.

主要语言
Python
星标
5.1k
派生
1.2k
平均合并
2 天 9 小时
30 天内合并 PR
632

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

pytorch/executorch 的其他 Issue

查看 pytorch/executorch 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。