Skip to content

[XLA] Reorganize dynamic-size support into feature-based commits - #53

Open
stevenvar wants to merge 20 commits into
steven.for-serving-2.20-clean-history-basefrom
steven.for-serving-2.20-clean-history
Open

[XLA] Reorganize dynamic-size support into feature-based commits#53
stevenvar wants to merge 20 commits into
steven.for-serving-2.20-clean-history-basefrom
steven.for-serving-2.20-clean-history

Conversation

@stevenvar

@stevenvar stevenvar commented Aug 17, 2026

Copy link
Copy Markdown
Owner

Summary

This PR reconstructs the current for-serving-2.20 source tree from commit 92148e0b108c3547ca73c2b08b2149b6bf349e75 using a dependency-ordered, feature-based history.

The new history separates:

  • shared dynamic expression representation
  • TensorFlow and HLO shape inference
  • tf2xla propagation and broadcasting
  • symbolic constant folding
  • clustering and cluster runtime boundaries
  • MLIR guards
  • CPU runtime plumbing, LLVM loop bounds, and operation emitters
  • integration tests

The final source tree is byte-for-byte identical to the current for-serving-2.20 branch. This PR is intended for reviewing the proposed history rather than introducing new source changes.

Verification

  • Confirmed that the reconstructed branch and for-serving-2.20 have the same Git tree hash: e92c08b099aa105e9e75fb7b26b862a071856983.
  • Confirmed that the worktree is clean.

@stevenvar
stevenvar force-pushed the steven.for-serving-2.20-clean-history branch 4 times, most recently from d53f0c2 to d2858fa Compare August 17, 2026 09:25
@stevenvar stevenvar changed the title Reorganize dynamic-size support into feature-based commits [XLA] Reorganize dynamic-size support into feature-based commits Aug 17, 2026
@stevenvar stevenvar added the enhancement New feature or request label Aug 17, 2026
@stevenvar
stevenvar force-pushed the steven.for-serving-2.20-clean-history branch 14 times, most recently from 1edf990 to 54a0c74 Compare August 18, 2026 12:49
Use the same owned expression representation for TensorFlow TensorShape dimensions and XLA Shape dimensions. Add serialization, simplification, substitution, solving, and focused expression tests.
Extend TensorFlow shape inference to preserve symbolic dimension identities and shape-derived tensor values. Keep unknown physical sizes separate from their symbolic expressions.
Carry dynamic expressions through XLA shape construction, HLO instructions, and shape inference. This keeps symbolic dimensions available while HLO graphs are built and transformed.
@stevenvar
stevenvar force-pushed the steven.for-serving-2.20-clean-history branch from 54a0c74 to c3d2540 Compare August 18, 2026 14:37
Add the flags, shape conversion helpers, argument metadata, and XlaExpression APIs needed to carry symbolic dimensions and shape-derived contents through tf2xla. Keep concrete kernel propagation separate so this commit defines the common contract first.
Update individual tf2xla kernel lowerings to derive and preserve symbolic shape and value expressions. Cover shape-producing, reshaping, slicing, sequence, partitioning, and related kernels using the shared expression plumbing.
Derive binary-op output expressions from the operand XLA shapes during broadcasting. Preserve the non-singleton expression when an operand expands from a singleton dimension.
@stevenvar
stevenvar force-pushed the steven.for-serving-2.20-clean-history branch from c3d2540 to edd2ef7 Compare August 19, 2026 15:07
Retain symbolic contents when shape-derived operations are rewritten or folded to constants. Add a dedicated rewrite path so optimization does not erase runtime shape dependencies.
Normalize compatible dynamic expressions around their smallest shared variable-covering subexpression before clustering. Reject cluster merges whose dynamic inputs and outputs cannot use one consistent symbolic core.
Map compiled XLA parameters back to their runtime TensorFlow inputs and solve the shared dynamic value from concrete dimensions. Filter broadcast-singleton evidence, pass the solved value through execution, and substitute it into dynamic output shapes after execution.
Normalize symbolic input metadata, pad solved dynamic values to configured compilation buckets, and include the resulting constants in executable cache signatures. Retry inconsistent dynamic requests with concrete static arguments instead of reusing an incompatible executable.
Prevent MLIR XLA kernels from silently consuming dynamic expressions they cannot preserve. Keep the existing MLIR path for operations without dynamic expression metadata.
Store the solved dynamic batch value in executable run options and expose it to CPU execution paths. Keep thunk and non-thunk execution consistent at the cluster boundary.
Generate LLVM loop bounds from the runtime batch dimension when an HLO dimension carries a dynamic expression. Add focused coverage for runtime-dependent bounds.
Teach CPU emitters to use runtime dynamic dimensions for affected operations instead of fixed padded extents. Preserve the padded allocation while limiting computation to the real shape.
Make CPU HLO profiling tolerate dynamic execution metadata and missing profile counters. Avoid invalid accesses while retaining profiling for supported instructions.
Add end-to-end coverage for symbolic shape propagation, clustering, compilation, and CPU execution. Exercise representative dynamic models across the complete TensorFlow-to-XLA path.
@stevenvar
stevenvar force-pushed the steven.for-serving-2.20-clean-history branch from edd2ef7 to e8b6182 Compare August 20, 2026 09:26
fenxcc and others added 4 commits August 20, 2026 10:48
Previously, we used a padding policy of powers of 2, which would
result in the loss of the multiple relationship. This commit changes
the padding policy to a multiple padding with k value.

All padding shapes are recorded for each function, if there exists a
upper_bound for k*dim, select the upper_bound shape as padding shape
TF_XLA_BATCH_SMALL_FACTOR is padding multiplier for size less
than 10; TF_XLA_BATCH_LARGE_FACTOR is padding multiplier for
size not less than 10.
Avoid representing ceil-aligned reshape padding with ordinary integer division, which can simplify to an incorrect symbolic bound.
Solve the dynamic branch when the observed result is strictly greater than the constant bound, while keeping equality ambiguous.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants