Ë
    ßGìjK  ã                   óª   — d dl mZmZ d dlmZ d dlmZ d dlmZm	Z	 d dlm
Z eZeZej                  d e«       fdedee	z  d	ed
ededee   fd„«       Z
y)é    )ÚCallableÚHashable)ÚAny)Útraceback_util)ÚMeshÚAbstractMesh)Ú	shard_mapTÚfÚmeshÚin_specsÚ	out_specsÚ	check_repÚautoc           	      ój   — t        |j                  «      |z
  }t        j                  | |||||d¬«      S )aˆ  Map a function over shards of data.

  Note:
    ``shard_map`` is an experimental API, and still subject to change. For an
    introduction to sharded data, refer to :ref:`sharded-computation`. For a more
    in-depth look at using ``shard_map``, refer to `SPMD multi-device parallelism with shard_map`_.

  Args:
    f: callable to be mapped. Each application of ``f``, or "instance" of ``f``,
      takes as input a shard of the mapped-over arguments and produces a shard
      of the output.
    mesh: a ``jax.sharding.Mesh`` representing the array of devices over which
      to shard the data and on which to execute instances of ``f``. The names of
      the ``Mesh`` can be used in collective communication operations in ``f``.
      This is typically created by a utility function like
      :func:`jax.experimental.mesh_utils.create_device_mesh`.
    in_specs: a pytree with :class:`~jax.sharding.PartitionSpec` instances as leaves,
      with a tree structure that is a tree prefix of the args tuple to be mapped
      over. Similar to :class:`~jax.sharding.NamedSharding`, each ``PartitionSpec``
      represents how the corresponding argument (or subtree of arguments) should
      be sharded along the named axes of ``mesh``. In each ``PartitionSpec``,
      mentioning a ``mesh`` axis name at a position expresses sharding the
      corresponding argument array axis along that positional axis; not
      mentioning an axis name expresses replication. If an argument, or argument
      subtree, has a corresponding spec of None, that argument is not sharded.
    out_specs: a pytree with :class:`~jax.sharding.PartitionSpec` instances as leaves,
      with a tree structure that is a tree prefix of the output of ``f``. Each
      ``PartitionSpec`` represents how the corresponding output shards should be
      concatenated. In each ``PartitionSpec``, mentioning a ``mesh`` axis name at
      a position expresses concatenation of that mesh axis's shards along the
      corresponding positional axis. Not mentioning a ``mesh`` axis name
      expresses a promise that the output values are equal along that mesh axis,
      and that rather than concatenating only a single value should be produced.
    check_rep: If True (default) enable additional validity checks and automatic
      differentiation optimizations. The validity checks concern whether any mesh
      axis names not mentioned in ``out_specs`` are consistent with how the outputs
      of ``f`` are replicated. Must be set False if using a Pallas kernel in ``f``.
    auto: (experimental) an optional set of axis names from ``mesh`` over which we
      do not shard the data or map the function, but rather we allow the
      compiler to control sharding. These names cannot be used in ``in_specs``,
      ``out_specs``, or in communication collectives in ``f``.

  Returns:
    A callable that applies the input function ``f`` across data sharded according to
    the ``mesh`` and ``in_specs``.

  Examples:
    For examples, refer to :ref:`sharded-computation` or `SPMD multi-device parallelism with shard_map`_.

  .. _SPMD multi-device parallelism with shard_map: https://docs.jax.dev/en/latest/notebooks/shard_map.html
  T)r   r   r   Ú	check_vmaÚ
axis_namesÚ_skip_mesh_check)Ú	frozensetr   ÚjshmapÚ
_shard_map)r
   r   r   r   r   r   r   s          ú^C:\Users\Stabi\Downloads\virtual-tryon(1)\venv\Lib\site-packages\jax/experimental/shard_map.pyr	   r	      s=   € ôn ˜Ÿ™Ó)¨DÑ0€*Ü	×	Ñ	Øˆd˜X°Ø jÀ4ô
Ið Ió    N)Úcollections.abcr   r   Útypingr   Újax._srcr   Újax.shardingr   r   r	   r   ÚSpecsÚAxisNameÚapi_boundaryr   Úbool© r   r   Ú<module>r"      sƒ   ð÷ /Ý Ý #ß +Ý (à€Ø€à×Ñð ¹	»ñ9IØð9IØ˜lÑ*ð9IØ6;ð9IØHMð9Iàð9Ià"+¨HÑ"5ò9Ió ñ9Ir   