Skip to content

Update references of jax_layout.Layout to jax_layout.Format. #124

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 19, 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
6 changes: 3 additions & 3 deletions keras_rs/src/layers/embedding/jax/distributed_embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
def _get_partition_spec(
layout: (
keras.distribution.TensorLayout
| jax_layout.Layout
| jax_layout.Format
| jax.sharding.NamedSharding
| jax.sharding.PartitionSpec
),
Expand All @@ -45,7 +45,7 @@ def _get_partition_spec(
if isinstance(layout, keras.distribution.TensorLayout):
layout = layout.backend_layout

if isinstance(layout, jax_layout.Layout):
if isinstance(layout, jax_layout.Format):
layout = layout.sharding

if isinstance(layout, jax.sharding.NamedSharding):
Expand Down Expand Up @@ -217,7 +217,7 @@ def _create_sparsecore_distribution(
sparsecore_layout = keras.distribution.TensorLayout(axes, device_mesh)
# Custom sparsecore layout with tiling.
# pylint: disable-next=protected-access
sparsecore_layout._backend_layout = jax_layout.Layout(
sparsecore_layout._backend_layout = jax_layout.Format(
jax_layout.DeviceLocalLayout(
major_to_minor=(0, 1),
_tiling=((8,),),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _create_sparsecore_layout(
)
sparsecore_layout = keras.distribution.TensorLayout(axes, device_mesh)
# Custom sparsecore layout with tiling.
sparsecore_layout._backend_layout = jax_layout.Layout( # pylint: disable=protected-access
sparsecore_layout._backend_layout = jax_layout.Format( # pylint: disable=protected-access
jax_layout.DeviceLocalLayout(
major_to_minor=(0, 1),
_tiling=((8,),),
Expand Down
4 changes: 2 additions & 2 deletions keras_rs/src/layers/embedding/jax/embedding_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import jax
import numpy as np
from jax.experimental import layout
from jax.experimental import layout as jax_layout
from jax_tpu_embedding.sparsecore.lib.nn import embedding
from jax_tpu_embedding.sparsecore.lib.nn import embedding_spec
from jax_tpu_embedding.sparsecore.utils import utils as jte_utils
Expand All @@ -20,7 +20,7 @@
shard_map = jax.experimental.shard_map.shard_map # type: ignore[attr-defined]

ArrayLike: TypeAlias = jax.Array | np.ndarray[Any, Any]
JaxLayout: TypeAlias = jax.sharding.NamedSharding | layout.Layout
JaxLayout: TypeAlias = jax.sharding.NamedSharding | jax_layout.Format


class EmbeddingLookupConfiguration:
Expand Down
2 changes: 1 addition & 1 deletion requirements-jax-cuda.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ torch>=2.1.0
# Jax with cuda support.
# Keep same version as Keras repo.
--find-links https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
jax[cuda12_pip]==0.6.0
jax[cuda12_pip]==0.6.2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Maybe it's not working? I didn't actually try this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's never been used I believe, so we wouldn't know if it's broken.


# Support for large embeddings.
jax-tpu-embedding;sys_platform == 'linux' and platform_machine == 'x86_64'
Expand Down