feat(array): a bare vmap gives its new axis a positional dim, pa.tag names it, and "batch" stops being special

オープン
#409 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
38/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
api, backend

調査の方向性

Start with pipekit_array/named/_carrier.py, focusing on vmapped_dims, core_dims, and _batch_names; then inspect the dim functions and to_xarray named in the implementation steps. Run the referenced q4b_batch_clash.py prototype and relevant tests. Done means vmap preserves item dims, leaves its added axis positional until pa.tag, and lint, type checks, and tests pass; the issue also calls for checking listed downstream consumers.

索引モデルが issue の本文から書いたものです。

説明

area:code type:feature

Problem / Request

After a bare jax.vmap, give the new axis a positional dim (None) instead of "batch". Dim functions refuse a positional dim with an error naming pa.tag. Add pa.tag(x, *names) and pa.untag(x, *dims). vmapped_dims and core_dims stop treating names starting with "batch" as added axes.

Motivation

The prototype built a ("batch", "x") carrier of shape (3, 4) for each of 2 items under vmap. The result's sizes were {batch: 2, batch_1: 3, x: 4}: the item's own dim was renamed batch_1 and its name went to the mapped axis, with no error. With ("member", "x") the result was {batch: 2, member: 3, x: 4}. coordax leaves such axes positional until tag names them (CP-D5).

Proposed API

# Shapes: (patch, y, x) = (2, 3, 4)

# today (pipekit-array)
# ("batch", x) per item → (batch, batch_1, x)
out = jax.vmap(build)(patches)

# proposed (CP-D5)
# ("batch", x) per item → (None, batch, x)
out = jax.vmap(build)(patches)

# proposed (CP-D5)
# (None, batch, x) → (patch, batch, x)
out = pa.tag(out, "patch")

Reuse

  • pipekit_array/named/_carrier.py: vmapped_dims, core_dims, _batch_names.

References & Existing Code

  • Design: docs/design/coordax_carriers.md in jejjohnson/geostack (merged in jejjohnson/geostack#368), pattern 4 and question CP-O2.
  • Prototype: q4b_batch_clash.py.

Implementation Steps

  • vmapped_dims prepends None; core_dims drops leading Nones only.
  • Every dim function and to_xarray refuses a None dim, naming pa.tag.
  • pa.tag, pa.untag.
  • Grep every consumer (geotoolz, gridax, sesmax, plumax, radtrax, diagnostix, vardax) for code that relies on a dim called "batch" appearing after vmap, and list them in the PR.

Definition of Done

  • Q4b: a ("batch", "x") item under vmap keeps its name; the mapped axis is None.
  • pa.tag after vmap gives the same carrier as building it with the name.
  • Lint, type check and tests green.

Relationships

  • Parent: jejjohnson/geostack#369
  • Blocked by: jejjohnson/gridax#627, jejjohnson/geotoolz#849, #407
  • Blocks: jejjohnson/geotoolz#851, jejjohnson/gridax#629
主要言語
Python
スター
0
フォーク
0
平均マージ
3時間 50分
マージ済み PR(30日)
143

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

jejjohnson/pipekit のほかの issue

jejjohnson/pipekit の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。