Repository navigation
[StableHLO] Support StableHLO programs with dynamic dimensions, empty tensors, and general indexing operations. - #25236
Draft
jschuhmacher wants to merge 70 commits into
Draft
jschuhmacher wants to merge 70 commits into
jschuhmacher wants to merge 70 commits into
Conversation
jschuhmacher
force-pushed
the
users/jschuhmacher/stablehlo_stage01_dynamic_shapes
branch
from
November 10, 2026 12:21
9bded43 to
734fbff
Compare
Base automatically changed from
users/jschuhmacher/stablehlo_target_registry
to
main
November 10, 2026 14:31
jschuhmacher
force-pushed
the
users/jschuhmacher/stablehlo_stage01_dynamic_shapes
branch
2 times, most recently
from
November 16, 2026 14:38
4566f15 to
2c4bc0d
Compare
Contributor
Author
|
Needs #25285 |
Contributor
Author
|
Needs: #25291 |
1 of 7 tasks
jschuhmacher
force-pushed
the
users/jschuhmacher/stablehlo_stage01_dynamic_shapes
branch
from
November 23, 2026 22:09
ca75db9 to
3bc758b
Compare
Contributor
Author
|
Needs #25329 |
Contributor
Author
|
Needs #25330 |
jschuhmacher
added a commit
that referenced
this pull request
Nov 25, 2026
…vers (#25329) Programs with dynamic shapes can produce tensors with a zero-sized dimension at runtime. The compiler cannot fold these away, because the extent is only known at execution time, so the HAL drivers receive empty buffers, empty binding ranges and partially empty workgroup grids. Several drivers rejected these or stalled on them. This change makes them work in the HAL core, CUDA, HIP, AMDGPU and Vulkan. ## Changes - **Empty buffer views on devices that stage uploads.** Generating an empty buffer view failed on devices whose memory cannot be mapped, because the host staging step required a non-zero allocation. The generator callback is now also invoked for empty views, as it already was on devices with mappable memory. - **Dispatches with a partially empty workgroup grid.** A grid with any zero dimension (for example 4x0x1) launches no workgroups, but only a fully zero grid was treated as a no-op. Grids like that reached device launch APIs that reject them. The HAL command buffer and the AMDGPU host queue now skip them. - **Empty queue allocations on HIP and CUDA.** A 0-byte `queue_alloca` asked the pool for 0 bytes and got a null pointer back, so the buffer never looked ready. Its first use waited forever and stalled the queue. These allocations are now backed by a small allocation while keeping a byte length of 0. - **Empty binding ranges on Vulkan.** Vulkan descriptors cannot have a zero range, and a buffer-device-address (BDA) binding table entry needs a valid address. Each device now owns a small empty-binding buffer that is bound in place of an empty range, in both the descriptor and the BDA dispatch paths. Shaders never read from it, because the binding has no elements. These failures came up in the StableHLO dynamic-shape work (#25236), which depends on this change. Assisted-by: Claude Code
jschuhmacher
force-pushed
the
users/jschuhmacher/stablehlo_stage01_dynamic_shapes
branch
from
November 27, 2026 16:01
675092d to
74d9d51
Compare
…cution Keep runtime extents, shape constraints, general scatter semantics, and observable dispatch failures across lowering and execution. Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
…sions Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Assisted-by: Codex Signed-off-by: Jelle Schuhmacher <[email protected]>
Assisted-by: Codex Signed-off-by: Jelle Schuhmacher <[email protected]>
The clone-cost lookup captured a structured binding in a lambda, which C++17 does not allow. Clang accepts it only as an extension, so builds that treat warnings as errors rejected the StableHLO plugin. Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
The upstream StableHLO convolution verifier reads constant padding as signed and asserts on the negative bound an unsigned value with its high bit set produces, so assertion-enabled builds could not parse these tests. The normalisation of such constants stays covered without parse-time verification; end-to-end coverage keeps the runtime unsigned padding case. Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
MSVC cannot choose between the const and non-const SPIRV-Cross constant lookups from inside the lambda, which broke the Windows build. Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
These tests now run correctly on Vulkan devices without native 16-bit float support, so listing them as expected failures fails the suite. Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
The CMake build does not provide split-file to lit tests, so these tests failed wherever no system copy happened to be installed. Each case that a second pipeline checks now lives in its own test file. Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Wide shape-computation constants and the signed minimum must yield a valid divisor instead of aborting or overflowing. Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
The byte offset of an interface binding is optional; a binding without one starts at the beginning of its buffer. Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Dynamic-shape support does not depend on normalising deprecated operations, so keep that compatibility work out of this change for separate review. Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Codex
Padding amounts given as index elements were not accepted as signed values, and a padding edge of INT64_MIN wrapped to a negative crop once negated. Both produced wrong pad results for trusted inputs that the StableHLO specification allows. Assisted-by: Claude Code
The static extreme-padding pad case overflowed inside StableHLO's own shape inference before reaching IREE, so it tested upstream behaviour rather than IREE's lowering, which the dynamic and unit tests already cover. The ONNX uint8 division test now compiles on Vulkan RDNA3 at O0 and is no longer an expected failure. Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Claude Code
jschuhmacher
force-pushed
the
users/jschuhmacher/stablehlo_stage01_dynamic_shapes
branch
from
December 2, 2026 14:01
74d9d51 to
47d0ee3
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lower StableHLO programs whose dimensions are only known at run time, including
empty tensors and general gather/scatter.
The input is trusted. Facts available from dynamic shapes, shape assertions and
the surrounding IR become
util.assume.intfacts or, where provable, staticshapes. Shape assertions are not checked at run time; invalid inputs are outside
the supported contract, and no runtime checks, assertions or status results are
emitted for them. Constant invalid inputs are diagnosed at compile time.
StableHLO input conversion
symbolic size proofs (a constant times a product of symbols with powers, plus
an offset) to emit
expand_shape/collapse_shape, including reshapes thatcollapse some dimensions and expand others.
tensor.pad; padding with interior padding computes its full-range phase onthe host, so device code needs only index arithmetic.
crops.
width of at least 32 bits, including unsigned and narrow index types.
are inlined first.
Supporting compiler changes
with dynamic shapes.
emulation on targets without native support, signed-zero preservation, and
binding offsets kept through flattened memref subspans.
scf.if.through optimization barriers.
extents; zero-trip reductions fold to their initial value.
Assisted-by: Codex
Assisted-by: Claude Code