jax icon indicating copy to clipboard operation
jax copied to clipboard

`splat_is_compatible_with_tiled` left-aligns the shapes

Open samanklesaria opened this issue 3 months ago • 3 comments

Description

The docstring for WGSplatFragLayout.can_broadcast_to says that "All source dimensions must match the target's trailing dimensions". That is to say, broadcasting is right aligned, just like in numpy. But splat_is_compatible_with_tiled doesn't following this: it left aligns. Its code is:

def splat_is_compatible_with_tiled(
    l1: fa.WGSplatFragLayout, l2: fa.TiledLayout
) -> bool:
  s1, s2 = l1.shape, l2.base_tile_shape
  return all(d1 % d2 == 0 for d1, d2 in zip(s1, s2))

Here's a minimal example of what goes wrong:

from jax.experimental.mosaic.gpu import fragmented_array as fa
from jax.experimental.mosaic.gpu import layouts

# `(32,)` base tile: the minor axis is what it constrains.
reduced = fa.WGMMA_LAYOUT.reduce([0])
splat = fa.WGSplatFragLayout(shape=(4, 8))
print(reduced.base_tile_shape)                                   # (8,)
print(layouts.splat_is_compatible_with_tiled(splat, reduced))    # False; want True

System info (python version, jaxlib version, accelerator, etc.)

jax:    0.11.1.dev20260814+ce6cfc5c2b
jaxlib: 0.11.0
numpy:  2.5.1
python: 3.13.5 (main, Jun 12 2025, 12:22:43) [Clang 20.1.4 ]
device info: cpu-1, 1 local devices"
process_count: 1
platform: uname_result(system='Darwin', release='23.5.0', version='Darwin Kernel Version 23.5.0: Wed May  1 20:14:59 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8122', machine='arm64')

samanklesaria avatar Aug 14 '26 18:08 samanklesaria

Hi! I’ve reproduced this on macOS/CPU and worked on a fix #40021 . The issue is the left-aligned zip(s1, s2); I've updated the compatibility check to align the base tile with the trailing dimensions and adding regression coverage for both the false-negative and false-positive cases.

edluyuan avatar Aug 15 '26 18:08 edluyuan

Hi! Could a maintainer please add the review label when convenient? Thanks!

edluyuan avatar Aug 27 '26 10:08 edluyuan

Thanks for the report @samanklesaria, and for the contribution @edluyuan!

Apologies for the delay in replying, I missed this :)

bchetioui avatar Aug 28 '26 13:08 bchetioui