Skip to content

Change for DeviceLocalLayout in JAX 0.6.3. #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions keras_rs/src/layers/embedding/jax/distributed_embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,14 @@ def _create_sparsecore_distribution(
)
sparsecore_layout = keras.distribution.TensorLayout(axes, device_mesh)
# Custom sparsecore layout with tiling.
LayoutClass = (
jax_layout.Layout
if jax.__version_info__ >= (0, 6, 3)
else jax_layout.DeviceLocalLayout
)
# pylint: disable-next=protected-access
sparsecore_layout._backend_layout = jax_layout.Format(
jax_layout.DeviceLocalLayout(
major_to_minor=(0, 1),
_tiling=((8,),),
),
LayoutClass(major_to_minor=(0, 1), _tiling=((8,),)), # type: ignore
jax.sharding.NamedSharding(
device_mesh.backend_mesh,
jax.sharding.PartitionSpec(
Expand Down
13 changes: 8 additions & 5 deletions keras_rs/src/layers/embedding/jax/distributed_embedding_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ def _create_sparsecore_layout(
)
sparsecore_layout = keras.distribution.TensorLayout(axes, device_mesh)
# Custom sparsecore layout with tiling.
sparsecore_layout._backend_layout = jax_layout.Format( # pylint: disable=protected-access
jax_layout.DeviceLocalLayout(
major_to_minor=(0, 1),
_tiling=((8,),),
),
LayoutClass = (
jax_layout.Layout
if jax.__version_info__ >= (0, 6, 3)
else jax_layout.DeviceLocalLayout
)
# pylint: disable-next=protected-access
sparsecore_layout._backend_layout = jax_layout.Format(
LayoutClass(major_to_minor=(0, 1), _tiling=((8,),)), # type: ignore
jax.sharding.NamedSharding(
device_mesh.backend_mesh, jax.sharding.PartitionSpec(axes)
),
Expand Down