Repository navigation
fix(fuzzer): run seeds whose device code calls libdevice - #395
Merged
nihalpasham merged 3 commits intoJul 22, 2026
Merged
Conversation
A generated seed whose device code calls libdevice never reached the comparison.
The harness loaded the kernel with `load_module_from_file("rustlantis_smoke.ptx")`,
and once libdevice is involved the backend does not emit a bare PTX file, so the
run died with `DriverError(301, "file not found")` and the seed was scored
COMPILE_FAIL. The compiler was right and the harness could not keep up with it.
Load through `kernels::load(&ctx)` instead. `cuda-host`'s `load_embedded_module`
dispatches over cubin, PTX, NVVM IR and LTOIR payloads and links whichever the
backend produced, which is the same entry point `examples/libdevice_math` already
uses for kernels that call libdevice math.
Seed 162 is such a case (`fmaf64`) and is now the checked in `generated_case.rs`,
so the fix is captured in the tree rather than only in this message. On an
RTX 5060, driver 610.43.03:
- against the harness on main: `COMPILE_FAIL`, with
`Failed to load PTX module: DriverError(301, "file not found")`
- against this change: `PASS [run] CPU/GPU traces matched`
The trace comparison is exact `u64` hash equality, which assumes the CPU and the
GPU agree bit for bit. That assumption is safe for `fma`, which IEEE-754 specifies
as a single correctly-rounded operation. It does not hold across libdevice as a
whole: the transcendentals are not required to match the host's libm, and this
repository already compares them within 2 ULP in `examples/math_atan` and through
`ulp_distance` in `examples/libdevice_math`. Floats never enter the hash directly,
since the trace API has no `f32` or `f64` arm and the adapter refuses a bare float
dump, but a float still reaches it through an `as` cast, through a comparison
yielding a `bool`, or through rustlantis' `transmute_place`.
Unlocking these seeds therefore admits mismatches that are precision artefacts
rather than backend bugs. `crates/fuzzer/README.md` gains a section saying so and
asking that a float-influenced `MISMATCH` be compared in ULPs before it is filed.
Making the comparison itself tolerant is a change to the trace model and is left
alone here.
The same README had drifted elsewhere: it listed the trace API as hashing nine
types when `trace.rs` has hashed fifteen since May, including the `u128` its
worked example still cites as unsupported.
Signed-off-by: Alejandro Soto Franco <[email protected]>
alejandro-soto-franco
force-pushed
the
fix/fuzzer-libdevice-seeds
branch
from
July 20, 2026 17:11
6163814 to
45c8798
Compare
The worked example still showed seed 0 classified UNSUPPORTED for a u128 dump, two lines above the corrected type list that names u128 as hashed, and the terminal-summary example still showed seed 1 failing on RigidTy(Char), which the type translator has handled for a while. Both examples predate the adapter/trace-API widening and contradict the rest of the document. Re-ran both seeds on this branch (RTX 5090, driver-backed run through run_seed.py): seed 0 and seed 1 both report PASS [run] CPU/GPU traces matched. The examples now quote that observed output, and the UNSUPPORTED explanation stands on its own instead of leaning on a classification that no longer occurs. Signed-off-by: nihalp <[email protected]>
Checked-in seeds now sit inside the example's per-directory 'cargo clippy --all-targets -- -D warnings' CI gate, and machine generated MIR-shaped code is lint-hostile by design (seed 162's '394723964_u32 as f64' trips unnecessary_cast). The generator already emits rustc lint allows for the same reason; extend the emitted header with clippy::all and regenerate seed 162, keeping the checked-in case byte-identical to generator output. Signed-off-by: nihalp <[email protected]>
Collaborator
|
Thanks for the PR. LGTM.
For example: Reviewer note: Seeds 0, 1, and 162 all PASS on an RTX 5090; This closes #414. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #414
Summary
A generated seed whose device code calls libdevice never reached the comparison. The harness loaded the kernel with
load_module_from_file("rustlantis_smoke.ptx"), and once libdevice is involved the backend does not emit a bare PTX file, so the run died withDriverError(301, "file not found")and the seed was scoredCOMPILE_FAIL. The compiler was right and the harness could not keep up with it.Changes
kernels::load(&ctx), socuda-host'sload_embedded_moduledispatches over cubin, PTX, NVVM IR and LTOIR and links whichever the backend produced. This is the entry pointexamples/libdevice_mathalready uses for kernels calling libdevice math.generated_case.rs, replacing the integer-only seed 19.crates/fuzzer/README.md.Rationale
Seed 162 calls
fmaf64and is now the checked-in case, so the fix is captured in the tree rather than asserted in prose. Measured on an RTX 5060, driver 610.43.03:mainCOMPILE_FAIL,Failed to load PTX module: DriverError(301, "file not found")PASS [run] CPU/GPU traces matchedThe trace comparison is exact
u64hash equality, which assumes the CPU and the GPU agree bit for bit. That is safe forfma, which IEEE-754 specifies as a single correctly-rounded operation. It does not hold across libdevice as a whole: the transcendentals are not required to match the host's libm, and this repository already compares them within 2 ULP inexamples/math_atanand throughulp_distanceinexamples/libdevice_math.Floats never enter the hash directly, since the trace API has no
f32orf64arm and the adapter refuses a bare float dump, but a float still reaches it through anascast, through a comparison yielding abool, or through rustlantis'transmute_place. Unlocking these seeds therefore admits mismatches that are precision artefacts rather than backend bugs. The README now says so and asks that a float-influencedMISMATCHbe compared in ULPs before it is filed. Making the comparison itself tolerant is a change to the trace model and is left alone here.The same README had drifted elsewhere: it listed the trace API as hashing nine types when
trace.rshas hashed fifteen since May, including theu128its worked example still cites as unsupported.Validation
cargo check --workspace --all-targetscargo clippy --workspace -- -D warningscargo fmt --all -- --check(cd crates/rustc-codegen-cuda && cargo fmt --all -- --check)(cd crates/rustc-codegen-cuda/examples/rustlantis-smoke && cargo fmt --all -- --check)python3 crates/fuzzer/tools/run_seed.py --seed 162againstmain, givingCOMPILE_FAILpython3 crates/fuzzer/tools/run_seed.py --seed 162against this branch, givingPASScrates/fuzzerhas no unit tests and no CI job runs it, so both fuzzer results above are manual, on the hardware named.