Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[BUG]: f32::to_int_unchecked fails with "invalid input program" in a kernel

Open
#1,595 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
backend, compilers

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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NVIDIA/cuda-rust

All issues in NVIDIA/cuda-rust

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.