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

Aperta
#409 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
38/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
api, backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
Python
Stelle
0
Fork
0
Merge medio
3h 50m
PR unite (30g)
143

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di jejjohnson/pipekit

Tutte le issue di jejjohnson/pipekit

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.