pmap_like¶
- jaxrens.sampling.mesh.pmap_like(fn, axis_name, mesh, *, check_vma=False)[source]¶
Wrap fn so
jax.shard_mapreproducesjax.pmap’s calling convention for it.fn should be written as if for
jax.pmap(fn, axis_name=axis_name): it receives each input leaf with the mapped axis already removed, and returns output leaves without that axis (pmap re-adds it by stacking).The returned callable is a plain
jax.shard_map-wrapped function within_specs = out_specs = PartitionSpec(axis_name)applied uniformly across every leaf of the (possibly pytree-valued) arguments/outputs — matchingjax.pmap’s defaultin_axes=0/out_axes=0behavior. Unlikejax.pmap, the result composes withjax.jit.check_vmacontrols whethershard_map’s “varying manual axis” type checker (new relative topmap, see https://docs.jax.dev/en/latest/notebooks/shard_map.html#scan-vma) is enabled. It rejects somelax.while_loop/lax.scancarries that mix a Python-literal initial value with a per-device-varying value produced inside the loop body — a pattern that was always legal underpmap, which never tracked this distinction. Defaults toFalse(pmap’s old “trust the caller” model) sopmap_likeis a faithful, unmodified port by default; callers whose wrapped function has been updated to type-check under it (e.g. viajax.lax.pcaston the affected carry entries — seejaxrens.sampling.adaptation.stepsize_handler.adjust_step_size) can passcheck_vma=Trueto get the checker’s safety net back.