Skip to content

fix-forward for pallas tpu memory spaces test #29450

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 13, 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
2 changes: 2 additions & 0 deletions jax/_src/pallas/mosaic/pallas_call_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def _get_memory_space_from_aval(
return None
case tpu_core.MemorySpace.ANY:
return None
case tpu_core.MemorySpace.HBM:
return tpu_custom_call.MemorySpace.HBM
case tpu_core.MemorySpace.VMEM:
return tpu_custom_call.MemorySpace.VMEM
case tpu_core.MemorySpace.SMEM:
Expand Down
2 changes: 2 additions & 0 deletions jax/_src/pallas/mosaic/primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,8 @@ def with_memory_space_constraint(
Returns:
The array `x` with the memory space constraint.
"""
if memory_space in {tpu_core.MemorySpace.ANY, pl_core.MemorySpace.ANY}:
return x
if memory_space not in {tpu_core.MemorySpace.HBM, tpu_core.MemorySpace.VMEM}:
raise NotImplementedError(
"with_memory_space_constraint only supports HBM and VMEM."
Expand Down
5 changes: 4 additions & 1 deletion tests/pallas/tpu_pallas_memory_space_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ def g(x):
@jax.jit
def f(x):
x = pltpu.with_memory_space_constraint(x, memory_space=memory_space)
self.assertEqual(pltpu.get_memory_space(x), memory_space)
if color is None:
self.assertIsNone(pltpu.get_memory_space(x))
else:
self.assertEqual(pltpu.get_memory_space(x), memory_space)
x = g(x)
return x

Expand Down
Loading