Skip to content

[Pallas] Fix block size constraint assuming spec order matches tensor dim order#1987

Closed
norx1991 wants to merge 1 commit intomainfrom
yifeixu/fix-block-size-constraint-ordering
Closed

[Pallas] Fix block size constraint assuming spec order matches tensor dim order#1987
norx1991 wants to merge 1 commit intomainfrom
yifeixu/fix-block-size-constraint-ordering

Conversation

@norx1991
Copy link
Copy Markdown
Contributor

@norx1991 norx1991 commented Apr 8, 2026

Summary

  • Fix adjust_block_size_constraints fallback that assumed BlockSizeSpec ordering matches tensor dimension ordering
  • The old fallback ndim - 1 - i computed wrong dim_from_end when tile order differs from tensor dim order (e.g., hl.tile([M, N, B]) on tensor [B, M, N])
  • This incorrectly applied last-dim 128-alignment to the batch block size, potentially rejecting valid configs when B is small
  • Skip alignment constraints when no tensor dim mapping is found instead of guessing from spec index
  • Add regression test with mismatched tile/tensor dim ordering

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 8, 2026
… dim order

The fallback `ndim - 1 - i` in `adjust_block_size_constraints` assumed
BlockSizeSpec ordering matches tensor dimension ordering.  For
`hl.tile([M, N, B])` on a tensor with shape `[B, M, N]`, B is the last
spec (i=2) but maps to the first tensor dim (dfe=2).  The fallback
computed dfe=0, incorrectly applying 128-alignment to a small batch dim.

Skip alignment constraints when no tensor dim mapping is found instead
of guessing from the spec index.
@norx1991 norx1991 force-pushed the yifeixu/fix-block-size-constraint-ordering branch from a87f98b to 5a5b54b Compare April 8, 2026 22:10
@norx1991
Copy link
Copy Markdown
Contributor Author

norx1991 commented Apr 8, 2026

Closing — the fallback code being fixed is effectively dead code. Every block_id maps to at least one tensor dimension through dim_matches(), so min_dim_from_end.get(bid) never returns None in practice. Will fold this cleanup into PR #1972 instead.

@norx1991 norx1991 closed this Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant