Skip to content

[Codegen] Cap hoisted statically-bound allocations at the stack budget. - #24527

Closed
bjacob wants to merge 1 commit into
users/bjacob/cpu-mma-widen-before-broadcastfrom
users/bjacob/cpu-hoist-alloc-cap
Closed

bjacob wants to merge 1 commit into
users/bjacob/cpu-mma-widen-before-broadcastfrom
users/bjacob/cpu-hoist-alloc-cap

Conversation

@bjacob

@bjacob bjacob commented May 21, 2026

Copy link
Copy Markdown
Collaborator

hoistOneStaticallyBoundAllocation pads a dynamic allocation to its computed upper bound. An unconstrained dynamic dimension carries only the index type maximum as its bound, so padding yields a bogus multi- petabyte allocation (#24483). Decline to hoist past the target's max_stack_allocation_size; declining to hoist is always valid -- it simply leaves the IR's existing dynamic allocation in place.

Extent of the #24483 fix: this is partial. It implements the first of the three fixes proposed in that issue -- the hoist itself no longer turns an index-umax-derived bound into a bogus static alloca (which fed poison strides into codegen and silently dropped data). It does not on its own make the originally-affected pipeline -- dynamic-shape inner_tiled data-tiling -- compile: as #24483 notes, capping leaves a dynamic CPU stack allocation, which is itself rejected downstream. What this commit guarantees is only that the failure mode is no longer a silent miscompile. The dynamic-shape inner_tiled pipeline is fully unblocked by a later commit in this series ("Fold reshape-containing encoding relayouts to map_store"), which removes the whole-tensor pack so the unbounded allocation never arises. #24483 is therefore not fully resolved by this commit alone.

Progress towards #24515.

`hoistOneStaticallyBoundAllocation` pads a dynamic allocation to its
computed upper bound. An unconstrained dynamic dimension carries only the
`index` type maximum as its bound, so padding yields a bogus multi-
petabyte allocation (#24483). Decline to hoist past the
target's `max_stack_allocation_size`; declining to hoist is always valid
-- it simply leaves the IR's existing dynamic allocation in place.

Extent of the #24483 fix: this is partial. It implements the first of the
three fixes proposed in that issue -- the hoist itself no longer turns an
`index`-umax-derived bound into a bogus static `alloca` (which fed poison
strides into codegen and silently dropped data). It does not on its own
make the originally-affected pipeline -- dynamic-shape `inner_tiled`
data-tiling -- compile: as #24483 notes, capping leaves a dynamic CPU
stack allocation, which is itself rejected downstream. What this commit
guarantees is only that the failure mode is no longer a *silent
miscompile*. The dynamic-shape `inner_tiled` pipeline is fully unblocked
by a later commit in this series ("Fold reshape-containing encoding
relayouts to map_store"), which removes the whole-tensor `pack` so the
unbounded allocation never arises. #24483 is therefore not fully resolved
by this commit alone.

Progress towards #24515.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
Signed-off-by: Benoit Jacob <[email protected]>
@bjacob
bjacob deleted the branch users/bjacob/cpu-mma-widen-before-broadcast May 22, 2026 16:13
@bjacob bjacob closed this May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant