Skip to content

fix(cuda-oxide-mlir-export): saturate float to int casts - #1655

Open
Rachit2323 wants to merge 1 commit into
NVIDIA:mainfrom
Rachit2323:fix/mlir-export-saturating-float-to-int
Open

Rachit2323 wants to merge 1 commit into
NVIDIA:mainfrom
Rachit2323:fix/mlir-export-saturating-float-to-int

Conversation

@Rachit2323

Copy link
Copy Markdown

Fixes #1642.

Summary

On the cutlass-mlir backend, 300.0 as u8 wasn't clamped to 255 like it is in Rust. The exporter was emitting plain arith.fptosi/arith.fptoui, and those are undefined when the value is out of range. Now it uses the .sat intrinsics, the same as mir-lower does.

Changes

Testing

No GPU on my machine, so I couldn't run a kernel.

  • The new tests fail on main and pass with this.

  • cargo test -p cuda-oxide-mlir-export, fmt and clippy are clean.

  • I also pushed the MLIR through mlir-translate and llc by hand. The PTX has the clamp now, and it didn't before.

  • just check (can't run it, no CUDA

  • cargo oxide run (no GPU)

  • New example (not needed)

Checklist

  • All commits signed off (git commit -s)
  • SPDX headers on new source files (no new files)

Fixes NVIDIA#1642.

Signed-off-by: Rachit2323 <atreyrachit23@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Oct 26, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

This branch has not been deployed

No deployments
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.

[BUG]: cutlass-mlir backend doesn't clamp float -> int as casts

1 participant