Multi-device support meta-thread

未关闭
#918 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
numpy, python, pytorch

调研方向

这是一个涵盖 Array API、array-api-strict、array-api-tests、array-api-compat、array-api-extra、NumPy、CuPy、PyTorch、JAX、Dask 和 SciPy 的跨项目 tracker。首先选择一个具体的后端或测试缺口,并阅读关联的 issue 和 pull request;该 tracker 没有定义单一的变更或完成条件。

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

描述

This is a tracker of the current state of support for more than one device at once in the Array API, its helper libraries, and the libraries that implement it.

Supporting multiple devices at the same time is typically substantially more fragile than pinning one of the available devices at interpreter level and then using that one exclusively, which typically works as intended.

Array API
array-api-strict
  • Supports three hardcoded devices, "cpu", "device1", "device2". This is fit for purpose for testing downstream bugs re. device propagation.
array-api-tests
array-api-compat
  • Adds device param to numpy 1, cupy, torch, and dask (read below).
  • Implements helper functions device() and to_device() to work around non-compliance of wrapped libraries
array-api-extra
  • Full support and testing for non-default devices, using array-api-strict only. Actual support from real backends entirely depends on the below.
NumPy
  • It supports a single dummy device, "cpu".
  • array-api-compat backports it to NumPy 1.x.
CuPy
  • Non-compliant support for multiple devices.
  • array-api-compat adds a dummy device= parameter to functions.
  • A compatibility layer is being added at the moment of writing by https://github.com/data-apis/array-api-compat/pull/293. [EDIT] it can't work, as array-api-compat can't patch methods.
  • As it doesn't have a "cpu" device, it's impossible to test multi-device ops without access to a dual-GPU host.
PyTorch
JAX
Dask
  • Dask doesn't have a concept of device
  • array-api-compat adds stub support, that returns "cpu" when wrapping around numpy and a dummy DASK_DEVICE otherwise. Notably, this is stored nowhere and does not survive a round-trip (device(to_device(x, d) == d can fail).
  • This is a non-issue when wrapping around numpy, or when wrapping around cupy with both client and workers mounting a single GPU.
  • Multi-GPU Dask+CuPy support could be achieved by starting separate worker processes on the same host and pinning the GPU at interpreter level. This is extremely inefficient as it incurs in IPC and possibly memory duplication. If a user does so, the client and array-api-compat will never know.
  • dask-cuda may improve the situation (did not investigate).
SciPy
主要语言
Python
星标
281
派生
52
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

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

data-apis/array-api 的其他 Issue

查看 data-apis/array-api 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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