feat(array): map_over maps over a tuple of dims, with mapper= choosing jax.vmap, a loop or any vmap-like callable
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 75/100
Research direction
Start with pipekit_array/named/_map.py:map_over and inspect its current dimension mapping and loop fallback. Add tuple-of-dim support and the mapper option described in the issue, then compare results with nested map_over for DimArray and CField, including the NumPy loop case. Done means those checks pass and lint and type checks are green.
Written by the indexing model from the issue text.
Description
Problem / Request
Let pa.map_over(x, fn, dims, mapper=jax.vmap) take a tuple of dims and a mapper: jax.vmap (default on JAX data, as today), "loop", or any vmap-like callable such as a sharded map.
Motivation
Mapping over members and times today is two nested map_over calls. coordax's cmap takes the vmap as an argument (CP-D4). The prototype on a (member, time, y, x) = (4, 5, 32, 32) ensemble: one call over ("member", "time") equalled nesting to 0.0 with jax.vmap, and a loop equalled it to 2.2e-8; eagerly the vmap took 3.0 ms and the loop 10.3 ms, so the choice belongs to the caller.
Proposed API
# Shapes: (member, time, y, x) = (4, 5, 32, 32)
# today (pipekit-array)
# (member, time, y, x) → (member, time)
eta_bar = pa.map_over(eta, lambda m: pa.map_over(m, spatial_mean, "time"), "member")
# proposed (CP-D4)
# (member, time, y, x) → (member, time), mapped dims first in the order given
eta_bar = pa.map_over(eta, spatial_mean, ("member", "time"), mapper=jax.vmap)
A single dim as a string keeps working. Today's fallback to a loop for a fn that cannot be traced stays when mapper is not given.
Reuse
pipekit_array/named/_map.py:map_over.
References & Existing Code
- Design:
docs/design/coordax_carriers.mdin jejjohnson/geostack (merged in jejjohnson/geostack#368), "Mapping over named dims" and pattern 3. - Prototype:
q3_q7_rest.py, section Q3.
Implementation Steps
- Accept
dims: str | tuple[str, ...]andmapper; nest one level per dim. - Docstring with the nested equivalent.
Definition of Done
- Equal to nested
map_overwithjax.vmap, to the bit, onDimArrayandCField. - Equal to round-off with
mapper="loop"; NumPy data with"loop"stays NumPy. - Lint, type check and tests green.
Relationships
- Parent: jejjohnson/geostack#369
- Dominant language
- Python
- Stars
- 0
- Forks
- 0
- Avg merge
- 3h 50m
- Merged PRs (30d)
- 143
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from jejjohnson/pipekit
-
area:code layer:0-primitives priority:p2 type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
jejjohnson/pipekit#296 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 3/5 1-2 days Newbie friendliness 57/100
jejjohnson/pipekit#411 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 4/5 3-5 days Newbie friendliness 48/100
jejjohnson/pipekit#410 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 5/5 Over a week Newbie friendliness 38/100
jejjohnson/pipekit#409 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 4/5 3-5 days Newbie friendliness 48/100
jejjohnson/pipekit#407 ·
Maintainers usually reply within 1 day
All issues in jejjohnson/pipekit
Similar issues
-
bug(operator): VolterraOperator built inside jax.jit with a concrete decay raises TracerBoolConversionErrorPossibly taken @jejjohnson claimed this today. Opentype:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
jejjohnson/integrix#144 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
finos/ai-governance-framework#459 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
autowarefoundation/autoware_carla_scenario#2963 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
freelawproject/litigant-portal#1307 ·
Maintainers usually reply within 2 days
-
type/bug
Difficulty 1/5 Under an hour Newbie friendliness 86/100
h2oai/h2o-llmstudio#1163 ·
Maintainers usually reply within 1 day