RFC: In-memory sparse array interchange
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
- issue の種類
- 機能追加
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- python, pytorch, scikit-learn, tensorflow
調査の方向性
issue #840 の RFC 提案を読み、その後、参照されている sparse PR #764 と SciPy PR #22553 を確認して、並列実装を理解してください。descriptor、constituent arrays、from_binsparse interface について合意があるかを議論で確認してください。完了とは、合意された仕様と、参加するライブラリのための明確な進め方がある状態を指します。
索引モデルが issue の本文から書いたものです。
説明
Motivation
The sparse (also called PyData/Sparse) development team have been working on integration efforts with the ecosystem, most notably with SciPy, scikit-learn and others, with CuPy, PyTorch, JAX and TensorFlow also on the radar. One of the challenges we were facing was the lack of (possibly zero-copy) interchange between the different sparse array implementations. We believe this may be a pain point for many sparse array implementations moving forward.
This mirrors an issue seen for dense arrays previously, where the DLPack protocol was the one of the first things to be standardised. We're hoping to achieve community consensus for a similar problem.
Luckily, all sparse array formats (with the possible exception of DOK) are usually collections of dense arrays underneath. In addition, this problem has been solved for on-disk arrays before by the binsparse specification. @willow-ahrens is a co-author of that spec, and is also a collaborator for the sparse work.
Proposal
We propose introducing two new methods to the array-API compliant sparse array objects (such as those in sparse), which are described below.
__binsparse_descriptor__
The returned item is a dict equivalent to a parsed JSON binsparse descriptor of an array.
__binsparse__
The second item is a dict[str, Array] of __dlpack__ compatible arrays, which are the constituent arrays of the sparse array. The key represents the equivalent key in the descriptor.
Introduction of from_binsparse function.
If a library supports sparse arrays, its from_binsparse method should support accepting (when possible, zero-copy) versions of objects that follow this __binsparse__ protocol, and have an equivalent sparse format within the library.
Psuedocode implementation
Here's a psuedocode example using two libraries, xp1 and xp2, both supporting sparse arrays:
# In library code:
xp2_sparray = xp2.from_binsparse(xp1_sparray, ...)
# This psuedocode impl is common between `xp1` and `xp2`
def from_binsparse(x: object, /, *, device: device | None = None, copy: bool | None = None) -> array:
binsparse_descr = getattr(x, "__binsparse_descriptor__", None)
binsparse_impl = getattr(x, "__binsparse__", None)
if binsparse_impl is None or binsparse_descr is None:
raise TypeError(...)
binsparse_descriptor = binsparse_descr()
# Will raise an error if the format/descriptor is unsupported.
sparse_type = _type_from_binsparse_descriptor(binsparse_descriptor)
constituent_arrays = binsparse_impl()
my_constituent_arrays = {
k: from_dlpack(arr, device=device, copy=copy) for k, arr in constituent_arrays.items()
}
return sparse_type.from_strided_arrays(my_constituent_arrays, shape=...)
Parallel implementation in sparse: https://github.com/pydata/sparse/pull/764
Parallel implementation in SciPy: https://github.com/scipy/scipy/pull/22553
Alternative solutions
There are formats for on-disk sparse-array interchange [1] [2]; but none for in-memory interchange. binsparse is the one that comes closest to offering in-memory interchange.
Pinging possibly interested parties:
- @mtsokol @ivirshup (for
scipy.sparse) - @willow-ahrens @mtsokol (from
binsparseandfinch-tensor/sparse) - @leofang (for
cupyx.sparse) - @pearu (for
torch.sparse) - @jakevdp (for JAX/TensorFlow)
Updated on 2024.10.09 as agreed in https://github.com/data-apis/array-api/issues/840#issuecomment-2337333242.
- 主要言語
- Python
- スター
- 281
- フォーク
- 52
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
data-apis/array-api のほかの issue
-
bug Maintenance Narrative Content
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
-
Maintenance
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
data-apis/array-api の issue をすべて見る
似ている issue
-
bug status/needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
prowler-cloud/prowler#12887 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area: desktop platform: macos priority: p3 status: ready type: enhancement
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
use-agent-os/agent-os#3484 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
open-telemetry/opentelemetry-python-contrib#5113 · コメント 2 件 · リアクション 2 件 ·
メンテナーはふだん 1 日以内に返信
-
external
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
langchain-ai/docs#6255 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信