Skip to content

Add type-aware extrema and integer ceil-division APIs [wip] - #995

Open
Phil-amd wants to merge 3 commits into
mainfrom
feature/typed-arithmetic-modernization
Open

Add type-aware extrema and integer ceil-division APIs [wip]#995
Phil-amd wants to merge 3 commits into
mainfrom
feature/typed-arithmetic-modernization

Conversation

@Phil-amd

@Phil-amd Phil-amd commented Aug 10, 2026

Copy link
Copy Markdown
Member

Summary

  • Add stable fx.max(), fx.min(), and fx.ceildiv() exports with per-type lowering (float → maximumf/minimumf, signed int → maxsi/minsi/ceildivsi, unsigned int → maxui/minui/ceildivui) and compile-time folding where host semantics match.
  • Migrate audited kernel call sites (softmax, top-k gating, RMSNorm, LayerNorm, pa_metadata, shared cdiv helper) to the new typed APIs; mechanical extrema migrations produce byte-identical normalized IR and final ISA.
  • Add unit tests, an AST-based CI guard (scripts/check_typed_arithmetic_usage.py), and update authoring docs/skills to steer away from deprecated method-form extrema and raw MLIR builders.

Closes #994. Child of #934.

Test plan

  • pytest tests/unit/test_typed_arith_ops.py tests/unit/test_typed_arithmetic_guard.py
  • Focused kernel tests: softmax, topk gating, rmsnorm, layernorm (gfx942 + gfx950)
  • Full CI on gfx942 (308): 1,755 passed (excluding known-flaky test_kernel_known_block_size.py and multi-GPU tests)
  • Full CI on gfx950 (355): passed with same exclusions
  • MoE sorting kernel: 61/61 passed in isolated run
  • IR/ISA equivalence verified for migrated reduction kernels

Provide direct signed, unsigned, and floating-point lowering so kernels can avoid raw arithmetic without changing edge-case semantics.
Route tested extrema and runtime ceiling division through the public typed APIs while preserving generated code for reduction kernels.
Align authoring guidance with the new semantics and reject newly introduced raw extrema or ceil-division spellings in kernel diffs.
@Phil-amd Phil-amd changed the title Add type-aware extrema and integer ceil-division APIs Add type-aware extrema and integer ceil-division APIs [wip] Aug 10, 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.

Add type-aware extrema and integer ceil-division APIs

1 participant