Skip to content

NVIDIA places: a test for the one bit the model takes from the driver - #2887

Open
fiestorra wants to merge 1 commit into
ProjectLeonida:mainfrom
fiestorra:places-driver-bit
Open

fiestorra wants to merge 1 commit into
ProjectLeonida:mainfrom
fiestorra:places-driver-bit

Conversation

@fiestorra

Copy link
Copy Markdown
Contributor

The four tests in pipeline/places/tests.rs are a model of one card and one driver — places.rs says which in its first lines, RTX 4060 Ti, 616.64 — and on an RTX 4090 with 621.24 all four fail, right after the first two assertions that do pass.

What they assert there and what the card says:

the_table_of_static_samplers
  left:  [0, 1, 2, ..., 15]
  right: [22, 20, 21, 0, 1, ..., 12]

And the printout from that same test, one step at a time:

host               : places 0 to 15 hold [0, 1, ..., 15]
host;make=22,20,21 : places 0 to 15 hold [0, 1, ..., 15]

So the sixteen do not slide. The model says they do, because a loaded pipeline gives its root signature back and its places with it, and the next three samplers take the lowest free ones. On 621.24 the loaded pipeline keeps them.

That one fact decides whether Places has to number the samplers at the start at all, and nothing in the code asks the driver for it — the model assumes one answer.

What this adds: a test that asks and reports the answer instead of asserting one.

It makes sixteen samplers, stores them, loads them back, makes three more after, and checks that places 0 to 15 hold either the sixteen they held (kept) or those three places on (given back), printing which. Both are answers a driver may give; on 621.24 it prints keeps its places and passes.

No existing assertion changes. The four that model 616.64 stay as they are, because with one driver measured, a test that accepted both would hide the change it should be reporting. When someone runs this on a card with 616.64, the new test prints gives back and the four keep failing — which is exactly the pair of facts needed to fix them, and it is now one command.

Measured:

cargo test -p leonida-gpu --lib                          631 passed  (37.5 s), 60 ignored
cargo test -p leonida-gpu --features diagnostics --lib places::tests::a_loaded_pipeline_keeps -- --ignored
  ok, prints "a loaded pipeline keeps its places: 0 to 15 hold [0, ..., 15]"
cargo clippy -p leonida-gpu --all-targets --features diagnostics   no warning in the file

The --ignored tests need a card and no game data: they make their own pipelines and read back what they wrote.

AI-assisted: yes — DeepSeek v4.1 (flash), on the card and the driver the model does not describe.

Written with an AI assistant.

@merzleckeier

Copy link
Copy Markdown
Contributor

I checked the new probe at a51b89e + 0ff8a53 under Wine 11.22 / VKD3D-Proton 3.1.0, with the physical RTX 4070 SUPER (620.73.04) exposed to DXGI as vendor 0x10de. The VKD3D pipeline-library prerequisite is not met here. The stock probe fails at table.loaded with the driver’s disk cache disabled and again with a fresh enabled cache. On RADV the first readback succeeds and the test takes the expected non-NVIDIA exit.

A local log of the existing subprocess records shows plain made for both the save and the attempted reload on NVIDIA. The same outcome repeats when using the harness’s explicit plain PSO name and when enabling VKD3D’s pipeline_library_app_cache option. The readback is 0 through 15 in both processes, but the second pipeline was freshly made, so those values cannot classify the loaded pipeline on this host. This is diagnostic coverage of that prerequisite, without a native NVIDIA driver result. MEASURED with offscreen synthetic shaders. AI-assisted (Codex).

@KelboLive KelboLive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Measured here on the same shape of machine (RTX 4070 Ti SUPER, 621.01): the new test passes 3/3 and prints keeps its places: 0 to 15 hold [0..15], and the four existing places tests fail exactly as the body describes (5 passed / 4 failed with --ignored) — that is genuinely useful evidence for the report.

But two claims do not hold:

  1. gave = 3..19 is not the 616.64 answer. The test's steps are byte-identical to the_table_of_static_samplers, whose 616.64 expectation is [22,20,21,0..12] (tests.rs:915, quoted in the body itself). On that driver this test will read that vector, print "gives back", and panic at tests.rs:969 rather than pass. Fix the branch to accept the observed 616.64 vector (or derive it from the same fixture).
  2. It does not test the model's bit. Running with LEONIDA_LIBRARY_STATIC_SAMPLERS=1 makes places::start return None (places.rs:1124-1131) and library_use take Use::Plain before consulting Places (:1168-1169), so short-circuiting Places::same to true leaves the test green — I verified it. And "nothing in the code asks the driver" is wrong: Places::check (places.rs:548-651) loads stored pipelines and compares them to made-now ones precisely to ask; what is not modelled is this perturbation (three samplers made before the load — the body says "after").

Also note the test only asserts its own two literals: changing kept from 0..16 to 3..19 does fail it, so the assertion is live, but nothing ties either literal to the model.

Either drive library_use/same and fix gave, or retitle it as a driver probe and drop the "nothing asks the driver" line. As an additive #[ignore]d diagnostic it is safe to merge; it just is not the test the title promises.

Merge is clean against current main (159 behind); the red check/linux-python-and-viewer jobs are the same inherited Python failures, unrelated to a Rust-only diff.

@fiestorra

Copy link
Copy Markdown
Contributor Author

Both hold, and thank you for measuring instead of reading - the second one especially, because I wrote "nothing in the code asks the driver" in a file whose check does exactly that, and I would have merged it.

The gave vector. You are right: 3..19 was never the 616.64 answer. The steps here are byte-identical to the_table_of_static_samplers's host;make=22,20,21, whose recorded answer is [22, 20, 21, 0..12], and on a card with 616.64 this probe would have printed "gives back" and then panicked on its own assertion. It now accepts that vector:

let gave: Vec<i32> = [22, 20, 21].into_iter().chain(0..13).collect();

The scope. Also right, and now said in the doc comment rather than denied: Places::check is what asks the driver at run time, and LEONIDA_LIBRARY_STATIC_SAMPLERS=1 takes Use::Plain before Places is consulted, so short-circuiting same leaves this green - as you verified. It measures the driver; the name is now a_loaded_pipeline_keeps_its_places_or_loses_them, and the "nothing asks the driver" line is gone.

"Before", not "after". The steps are host;make=22,20,21;pipe=c:0-15: the three are made before the sixteen are loaded back. The print line said "after it" and now says "before it". Same for the perturbation being what is not modelled.

What it still is: an additive #[ignore]d probe with no existing assertion touched, printing which of the two answers this card gives. What it is not: a test of the model, and the title no longer says it is.

Measured on the 4090 with 621.24 after the change:

cargo test -p leonida-gpu --features diagnostics --lib places::tests::a_loaded_pipeline
    -- --ignored --nocapture --test-threads=1
  ok, prints "a loaded pipeline keeps its places: 0 to 15 hold [0, ..., 15] ... before it"

Written with an AI assistant.

@Christopher-Sundeby

Christopher-Sundeby commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Verified on native Windows NVIDIA: RTX 5090 (Blackwell), driver 621.40, Windows 11, head 9dfe9b7af.

cargo test -p leonida-gpu --features diagnostics --lib pipeline::places -- --ignored --nocapture --test-threads=1: 5 passed, 4 failed (the same four as on the 4090 / 621.24).

  • The new probe passes and prints a loaded pipeline keeps its places: 0 to 15 hold [0, 1, ..., 15], the same answer as 621.24.
  • the_table_of_static_samplers prints host;make=22,20,21: places 0 to 15 hold [0, ..., 15], the same as 621.24.

One caveat on what "keeps" covers: the probe uses only compute pipelines (pipe=c:0-15). On this driver graphics pipelines still read through the stored places. This happened in every run (3 of 3, and 2 of 2):

a_stored_pipeline_reads_through_the_places_of_the_run_that_stored_it, "loaded after ten other samplers" (LEONIDA_LIBRARY_STATIC_SAMPLERS=1):
  s (LoadPipeline, compute)  read [6, 7]    wrong 0
  g (LoadGraphicsPipeline)   read [43, 44]  wrong 2
  c (LoadComputePipeline)    read [1, 2, 3] wrong 0

So on 621.40 (and likely 621.24, given the same failures) a loaded compute pipeline keeps its places and a loaded graphics pipeline does not. The probe's line is true for compute only. Suggestion: name it for compute, or add a pipe=g: twin.

This also has a runtime consequence, which I'm taking separately on #2570. Places::check probes with compute pipelines only, so on this driver it answers same when the places did shift, and a graphics pipeline is then loaded through the wrong samplers. In pipelines_with_static_samplers_come_from_the_library, at the step make=50,51;host;..., it reproduces 3 of 3: places: "same", and the g pipeline is loaded with read [2, 3] and wrong 2.

AI-assisted: yes (Claude Opus 5.5, via Claude Code).

@fiestorra

Copy link
Copy Markdown
Contributor Author

The d3d12 (windows-latest) job is red on crash::tests::memory_at_names_what_an_access_hit, and it is not this branch:

thread 'crash::tests::memory_at_names_what_an_access_hit' panicked
  assertion `left == right` failed
    left:  "read-write"
    right: "nothing mapped there"

That test is d3d12/crates/leonida-loader/src/crash.rs:890, and the assertion that failed is crash.rs:915, assert_eq!(memory_at(base + 8), "nothing mapped there") - it maps a page and expects the eight bytes past it to be unmapped, which depends on where the runner's allocator put things. This pull request touches pipeline/places/tests.rs and nothing else, and its test is #[ignore]d, so that job does not run it at all.

Two things I could not do: gh run rerun --failed is refused for this account (Must have admin rights to Repository), so I cannot show it passing on a second attempt. That is the one piece of evidence missing, and it is a click someone else has.

The rest of the job's output is green, including pipeline::places itself in its non-ignored form.

Written with an AI assistant.

@Christopher-Sundeby

Christopher-Sundeby commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

A correction to my comment above. On 621.40, compute pipelines are not always safe either. In a later run of pipelines_with_static_samplers_come_from_the_library, at its no-care step (=1, make=50,51 first), the stream-made compute pipeline also read through other samplers:

c read [1, 2, 3] wrong 0 | g read [2, 3] wrong 2 | s read [4, 5] wrong 2

In the earlier runs, s read [6, 7], which was right. So, measured on this card: a loaded graphics pipeline read wrong in every run, and loaded compute pipelines read right most of the time but not every time. "Keeps its places" holds for compute only, and only most of the time.

AI-assisted: yes (Claude Opus 5.5, via Claude Code).

@fiestorra

Copy link
Copy Markdown
Contributor Author

One more piece of evidence for the comment above, and it settles it: the same workflow passed on this branch's previous head and failed on this one, with the only difference being the two corrections in the places test.

46703727105  D3D12 runtime  success  8f5c23f   (my first rebase)
46709274287  D3D12 runtime  failure  9dfe9b7   (after the corrections KelboLive asked for)

What changed between them is pipeline/places/tests.rs only: the gave vector, the test's name, and its doc comment. What failed is leonida-loader/src/crash.rs::memory_at_names_what_an_access_hit, at its memory_at(base + 8) assertion. A test in another crate, checking where the allocator put a page, cannot be reached by a change to an #[ignore]d test in pipeline.

So it is the runner's address layout, not this branch - and the run on 8f5c23f is the control that says so, which is the thing I could not produce by rerunning because this account cannot.

What would make it good to land anyway: the job's other 83 tests pass, pipeline::places is not among them (it is #[ignore]d), and the change is a probe that only prints.

Written with an AI assistant.

@NetZlash

NetZlash commented Dec 1, 2026

Copy link
Copy Markdown

Native hardware validation of 9dfe9b7af6ab67aa300a26f150120e82b99878fd.

Hardware. NVIDIA RTX 4070 SUPER (Ada, 12 GiB), NVIDIA driver 621.40, native Windows 11 Pro x64 build 26200, Ryzen 7 9700X and 32 GB RAM. This was an isolated checkout with Rust/Cargo 1.98.1 and the diagnostic build. All fixtures use synthetic shaders and readbacks.

Revised probe. The stock simple-compute test passed three times. Three additional save/reload pairs each used a fresh application pipeline library. The first process created the PSO and wrote the library. A second process succeeded through LoadComputePipeline in forced plain mode. All three readbacks were [0, 1, ..., 15], matching the fresh controls. This tests the revised recipe, which puts the perturbation before reload and corrects the displaced vector described in the RTX 4070 Ti SUPER / 621.01 review. I did not run driver 616.64.

Additional forced-plain checks. I ran three fresh-library pairs for each of two recipes, with ten extra samplers after the host setup or two extra samplers before it. Every second process succeeded at the specified library entry points. The fresh controls were equivalent pipelines created in that same process.

Route Ten after host Two before host Fresh control
Simple compute, LoadComputePipeline [1, 2, 3] [1, 2, 3] [1, 2, 3]
Graphics, LoadGraphicsPipeline [43, 44] [2, 3] [4, 5]
Stream compute, LoadPipeline [6, 7] [6, 7] [6, 7]

Ada and Blackwell. On Ada, both graphics samples read the wrong sampler in all six loads. This reproduces the reported graphics mismatch on RTX 5090 (Blackwell) with 621.40. The stream-compute samples matched their controls in all six Ada loads. The 5090 follow-up observed intermittent stream-compute mismatches. My early recipe isolates the forced-plain portion of the combined test and starts with a fresh application library. Run order and cache history differ, so the stream-compute result is limited to these recipes. The tests cover the selected library routes with forced plain mode. Automatic Places::check, other drivers and in-game behavior remain outside their scope.

AI-assisted validation: Codex / GPT-6.2 Sol (gpt-6.2-sol).

@fiestorra

Copy link
Copy Markdown
Contributor Author

Red on d3d12 (windows-latest), and not this branch. Two measurements, so it does not get read as a flake:

  1. This branch's own previous head passed the same job (8f5c23f, an hour before), with only the two corrections in the places test between them.
  2. The test that failed here is in another crate — leonida-loader's crash::tests::memory_at_names_what_an_access_hit, at its memory_at(base + 8) assertion — and a change to an #[ignore]d test in pipeline cannot reach it.

The runner's WARP adapter is the common factor, and #2923 is the fix being proposed for it: the workspace tests run one per core against one WARP device, and this crate flakes about one run in eight that way (measured: 16 parallel runs, 2 failures in two different tests; --test-threads=1, 8 of 8 clean).

A third data point from tonight, on hardware: descriptor::host::tests::views_are_made_beside_the_heap_and_copied_in fails on main on an RTX 4090 with the same kind of message ("copied as it was made"). Also not this branch — but it is a real failure of the tree, reported in #2570.

Written with an AI assistant.

…s places

places/tests.rs is a model of one card and one driver - places.rs says so in its
first lines, RTX 4060 Ti, 616.64 - and on an RTX 4090 with 621.24 four of its
tests fail after the first two assertions pass. What they get wrong is that a
loaded pipeline gives its static-sampler places back, so the next samplers made
take the lowest ones and the sixteen slide on. On 621.24 they stay:

  host               : places 0 to 15 hold [0, 1, ..., 15]
  host;make=22,20,21 : places 0 to 15 hold [0, 1, ..., 15]

This adds a probe that reports which of the two a driver does. It makes sixteen
samplers, stores them, makes three more and loads the sixteen back, then checks
that places 0 to 15 hold either the sixteen they held, or the 616.64 answer -
[22, 20, 21, 0..12], which is what the_table_of_static_samplers records at its
own `host;make=22,20,21` step - and prints which. On 621.24 it prints "keeps".

It measures the driver, not the model: Places::check is what asks the driver at
run time, and LEONIDA_LIBRARY_STATIC_SAMPLERS=1 takes the plain path before
Places is consulted, so this says nothing about either. Named and worded to say
so, after KelboLive's review of the first version, which had the wrong 616.64
vector (3..19) and a title that promised more than it checks.

No existing assertion changes: the four that model 616.64 are left as they are,
because with one driver measured a test that accepted both would hide the very
change it should be reporting.

Measured:
  cargo test -p leonida-gpu --lib                        631 passed  (37.5 s)
  the probe, --ignored                                    ok, prints "keeps its places"
  cargo clippy -p leonida-gpu --all-targets --features diagnostics   no warning in the file

Written with an AI assistant.
@fiestorra

Copy link
Copy Markdown
Contributor Author

The red d3d12 (windows-latest) was not this change: it was crash::tests::memory_at_names_what, in crates/leonida-loader, which this branch does not touch.

---- crash::tests::memory_at_names_what assertion left == right failed left: "read-write" right: "nothing mapped there"

I could not make it fail here: six runs of cargo test -p leonida-loader --lib crash::tests on this machine, in parallel like CI, 19 passed, 0 failed, six times out of six. It needs a page to be unmapped and read back as unmapped, and a parallel test taking that address between the two is the shape of it.

The branch is rebased onto main 913b88b (which also re-runs the jobs - gh run rerun needs admin rights I do not have), so this PR is current and its CI is fresh.

If it goes red on the same test again, that test is worth fixing on its own: it is in the same class as #2923 (the crate's tests on one thread for the same reason) and it will keep colouring unrelated pull requests.

AI-assisted: yes - DeepSeek v4.1 (flash).

Written with an AI assistant.

@andrew-ai

Copy link
Copy Markdown

Ran a_loaded_pipeline_keeps_its_places_or_loses_them at 3be77fd on Windows, RTX 5070 / NVIDIA 616.92, with the diagnostics build and --ignored --nocapture. One test passed. It reported “gives back” and read [22, 20, 21, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]. This exercises the other accepted result from the RTX 4090 / 621.24 report and matches the earlier sampler-table readback on this machine (#2996). Codex-assisted.

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.

6 participants