Repository navigation
feat(fuzzer): fold an aggregate into the trace by its leaves - #792
Merged
nihalpasham merged 1 commit intoAug 11, 2026
Merged
Conversation
The trace API hashed 16 scalar types and nothing else, so a generated program whose dump site or return position held a tuple or an array was refused at the adapter. That was 18 of the 60 seeds in the window the README quotes, and 320 of the 1000 seeds in the sweep that produced NVIDIA#765 and NVIDIA#767. TraceValue now covers arrays and tuples of anything it already covered, to any nesting depth, folding each leaf through the existing scalar writers. The byte sequence an aggregate produces is the one a scalar-by-scalar dump of the same leaves produces, so nothing that hashed before hashes differently. The fold reads leaves and never the aggregate's bytes. Padding is uninitialized, so folding raw bytes would be undefined behavior in the CPU oracle and would report a MISMATCH on any layout the two backends pad differently. Padding is also where the miscompile behind NVIDIA#393 lived.
Collaborator
|
Reproduced on RTX 5090 (sm_120):
The leaf-walk impls and the recursive Python gate accept and refuse identical types on every edge case we threw at them (1-tuples, nested units, zero-length arrays, arity-6 tuples, slices, pointers). Merging, closes #791. |
nihalpasham
approved these changes
Aug 11, 2026
nihalpasham
added a commit
that referenced
this pull request
Aug 20, 2026
…t accepts (#1069) * docs(book): the fuzzing chapter says the adapter rejects five types it accepts `fuzzing-and-differential-testing.md` documents the trace API's type support as nine scalars and then rules out five more: Today the trace supports: bool, i8, i16, i32, i64, u8, u16, u32, u64 It does not yet support `u128`, `i128`, `usize`, `isize`, or `char`. `SCALAR_TRACE_TYPES` in `crates/fuzzer/tools/mir_generator.py` holds sixteen, including all five of those plus `f32` and `f64`, and `supported_trace_type` gates the adapter on exactly that set. Executing the real predicate: u128 True i128 True usize True isize True char True f32 True f64 True [u128; 4] True (u32, char) True *const i8 False &i32 False (i8,i8,i8,i8,i8,i8) False So the paragraph is wrong about every type it names, and understates the rest: support is not set membership but a recursive question, because an array or tuple folds by its leaves up to arity 5 ([#792](#792)) -- and `f32`/`f64` have been in since [#484](#484). `crates/fuzzer/README.md` already states all of this correctly, listing the same sixteen scalars and the folding rule. The book page is the one outlier, so this brings it in line with the README and the code rather than inventing a third description. Two consequences follow: - The sample `UNSUPPORTED [adapter]` line used `u128` as its rejected type, which the adapter now accepts, so the example cannot be produced. It becomes `*const i8`, which the predicate does reject (measured above) and which the fuzzer README already uses as its own example of an adapter refusal. - The widening plan listed "Add trace support for more scalar types (`u128`, `i128`, `usize`, `isize`)" and "Add arrays, tuples, and eventually structs/enums" as future work. The first is done and the second is half done, so the plan now records what landed and keeps structs and enums as what remains. Left alone deliberately: the `RigidTy(Char)` backend classification in the same sample output. `char` behaviour is in flux -- translation maps it to `u32`, and whether `#[device]` extern signatures accept it is an open question ([#875](#875)) -- and I did not reproduce that line end to end, so it is not mine to rewrite here. Verified: the predicate results above come from importing `mir_generator.py` and calling `supported_trace_type`, not from reading it. Book builds clean under `sphinx-build -W`; `check-book-api-names.sh` passes. Signed-off-by: Vyncint Ng <[email protected]> * docs(book): fix the pointer refusal example and plain-language pass on the folding text --------- Signed-off-by: Vyncint Ng <[email protected]> Co-authored-by: nihalpasham <[email protected]>
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 #791.
The trace API hashed 16 scalar types and nothing else, so a generated program whose dump site or return position held a tuple or an array was refused at the adapter with
unsupported dumped type. That was 18 of the 60 seeds in the window the README quotes, and 320 of the 1000 seeds in the sweep that found #765 and #767.Summary
Folds an aggregate into the trace as its leaves, in declaration order, so
TraceValuecovers arrays and tuples of anything it already covered, to any nesting depth.Changes
crates/fuzzer/src/trace.rs:TraceValuefor[T; N]over a const generic, for tuples up to arity 5, and for(). Each walks its leaves through the existing scalar writers.crates/fuzzer/src/lib.rs:#![cfg_attr(not(test), no_std)], so a test build links std on the host while every real build, the device build included, staysno_std.crates/fuzzer/tools/mir_generator.py:supported_trace_typebecomes a recursive question over[T; N]and tuples rather than a set membership test. It governs both existing call sites, the dumped locals and the return type.crates/fuzzer/README.md: refreshes the status transcripts and the supported-type list, which this change makes stale.Rationale
The byte sequence an aggregate produces is exactly the one a scalar-by-scalar dump of the same leaves produces, so this widens what the trace accepts without introducing a second trace model. Nothing that hashed before hashes differently.
The fold reads leaves and never the aggregate's bytes. Padding is uninitialised, so folding raw bytes would be undefined behaviour in the CPU oracle, and any layout the two backends pad differently would report a MISMATCH on every seed that touched it. Padding is also where the silent miscompile behind #393 lived, so a byte fold would bury the signal this fuzzer exists to find.
(u8, u32)is the discriminating case in the test: it holds only for an implementation that reads the two fields.The array walk is an indexed
whilerather than aforover the array'sIntoIterator. This crate is compiled for the device as well as the host, and #399 records that small local arrays consumed through iterator adapters stay in local memory. An index loop states the same thing without depending on how that resolves.The tuple arity stops at 5 because
TraceDumpstops at 5, and the adapter refuses a wider one rather than emitting a program that fails to compile. Every assertion lives in one test function, because the trace is a singlestatic mutand cargo runs test functions on parallel threads, so two folds at once would race on it.Validation
RTX 5060 Laptop GPU, compute capability 12.0, CUDA 13.3, driver 610.43.03.
Seeds 300-359, the window the README quotes, changing only the trace API and the adapter:
Every refused seed became an executing differential run, and none of them mismatched. Seeds 0-99 are also 100 PASS with nothing refused.
Seeds 1000-1999, the window that produced #765 and #767:
The recorded figure for that window on 2026-08-09 was
PASS=673 UNSUPPORTED=320 COMPILE_FAIL=7. The seven compile failures are gone because #769 landed, and that run predates this branch, so it is a recorded baseline rather than a paired arm.No mismatch, so this widening surfaced no new silent miscompile in that window. What it did was put 319 more programs through the device where the harness previously refused to look at them.
The one remaining refusal is seed 1436, which returns a
*const i8:That one is permanent rather than a gap to widen next. The CPU oracle and the device hold different addresses for the same object by construction, so folding a pointer into the trace would report a MISMATCH on every seed that dumped one.
The unit test discriminates. Reversing the array walk, so that it folds
[1, 2, 3, 4]as4, 3, 2, 1, fails the first assertion and leaves the rest of the file passing.