[BUG]: f32::to_int_unchecked fails with "invalid input program" in a kernel
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
Research direction
Start with the to_int_unchecked implementation in Rust's core/src/convert/num.rs at the reported line 28 and trace how the CUDA device codegen translates that intrinsic. Compare the generated path with the working x as i32 cast, using the linked minimal reproduction and cargo oxide build --arch sm_89 --features unchecked. Done means the intrinsic compiles or reports a clear unsupported-operation error.
Written by the indexing model from the issue text.
Description
Description
f32::to_int_unchecked::<i32>() inside a #[kernel] fails to build. The saturating cast x as i32 builds. Seen on cuda-rust e027ac3 (tip of main, 2026-10-20).
Error / actual behavior
cargo oxide build --arch sm_89 --features unchecked:
error: [rustc_codegen_cuda] Device codegen failed: PTX generation failed: Translation failed: cell_index: ["~/.rustup/toolchains/nightly-2026-10-11-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/convert/num.rs": line: 28, column: 30] Compilation error: invalid input program.
Expected behavior
It should compile (a plain float-to-int conversion), or fail with a message saying the intrinsic is unsupported. It matters for performance: Rust's f32 as i32 saturates and maps NaN to 0, which adds instructions to every conversion, and a spatial hash does several per candidate. to_int_unchecked is the usual way to avoid that.
Minimal reproduction example
#[kernel]
pub fn cell_index(x: &[f32], mut out: DisjointSlice<i32>) {
let idx = thread::index_1d();
let i = idx.get();
if let Some(o) = out.get_mut(idx) {
// SAFETY: the test inputs are finite and far inside the i32 range.
*o = unsafe { x[i].to_int_unchecked::<i32>() }; // fails; `x[i] as i32` builds
}
}
Complete crate (one cargo feature switches between the two forms): https://github.com/ImanolGo/murmuration-kernels/tree/05749e6610a053280fc21993fddc0363c00d572a/upstream-repros/oxide-to-int-unchecked
Operating System
CachyOS (Arch Linux, rolling), kernel 7.2.11
GPU and GPU Architecture
NVIDIA GeForce GTX 1650 with Max-Q Design (sm_75). The PTX in this report is generated for sm_89 and needs no GPU.
CUDA driver version
615.78.08 (CUDA toolkit 13.3 and 13.4)
rustc version
rustc 1.101.0-nightly (6f5da406b 2026-10-10), toolchain nightly-2026-10-11
llc version
LLVM version 23.1.3-rust-1.101.0-nightly
AI contribution: drafted and tested with Claude Code (Anthropic); posted by me.
- Dominant language
- Rust
- Stars
- 3.7k
- Forks
- 312
- Avg merge
- 6d 5h
- Merged PRs (30d)
- 68
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NVIDIA/cuda-rust
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
NVIDIA/cuda-rust#1568 · 1 comment ·
Maintainers usually reply within 2 days
-
[BUG]: The doc of trait `LoadTileLike` is incorrectPossibly taken @akhil9tiet claimed this 6 days ago. Openbug
Difficulty 1/5 Under an hour Newbie friendliness 72/100
NVIDIA/cuda-rust#1523 · 2 comments ·
Maintainers usually reply within 2 days
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 2 days
-
Target feature scan splits LLVM IR on ';', so conjunctive predicates match across the whole module (integer redux + any f32 reads as ReduxF32)Possibly taken @vyncint claimed this 33 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
NVIDIA/cuda-rust#1303 · 1 comment ·
Maintainers usually reply within 2 days
All issues in NVIDIA/cuda-rust
Similar issues
-
documentation priority:p2 type:chore
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Maintainers usually reply within 1 day
-
dispatch:sol-high documentation
Difficulty 1/5 1-3 hours Newbie friendliness 85/100
carrick-sh/carrick#768 · 1 comment ·
Maintainers usually reply within 1 day
-
correctness postgres tursopg
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
tursodatabase/turso#10442 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
ankitects/anki#5864 · 1 reaction ·
Maintainers usually reply within 2 days
-
area: config effort: S good first issue P3 type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
ferenyl/azuredevopstui#63 ·