Skip to content

d3d12: run leonida-gpu's tests on one thread - #2923

Open
fiestorra wants to merge 2 commits into
ProjectLeonida:mainfrom
fiestorra:ci-serial-leonida-gpu
Open

fiestorra wants to merge 2 commits into
ProjectLeonida:mainfrom
fiestorra:ci-serial-leonida-gpu

Conversation

@fiestorra

Copy link
Copy Markdown
Contributor

The Tests (no GPU, no game data) job fails on the runner's WARP adapter about one run in eight, on a different test each time, and this makes the crate that owns the device tests run them one at a time.

What was seen, three runs of two branches, same job:

#2887  8f5c23f  success
#2887  9dfe9b7  crash::tests::memory_at_names_what_an_access_hit   (leonida-loader)
#2823  b60a729  descriptor::tests::re...  631 passed, 1 failed      (leonida-gpu)

Different crates, different tests, and the branch passed an hour before. What they share is the device: the runner has no hardware GPU, so host() returns WARP and these tests take it.

Why one thread is the fix and not a guess: this crate's flake was measured and cured that way already.

16 parallel runs of leonida-gpu/lib      2 failures, in two different tests
--test-threads=1                         8 of 8 clean, 37 s against 13 s
each test alone                          15 of 15 clean

The workflow ran them the default way, so every device test in the crate shared one WARP device on every core at once. descriptor::tests allocates from the host heap and checks what it made; crash::tests maps a page and looks at what follows it - both exactly the shape that goes wrong when two tests drive one device together.

The change: the workspace runs without leonida-gpu, and the crate runs by itself with --test-threads=1, keeping the --skip depth_bounds_pipeline_loads_and_filters_draws that the software adapter needs.

run: cargo test --workspace --exclude xtask --exclude leonida-gpu --locked
...
run: cargo test -p leonida-gpu --locked -- --test-threads=1 --skip depth_bounds_pipeline_loads_and_filters_draws

Measured here (this machine has a card, so it says what the step costs, not that WARP is fixed):

cargo test -p leonida-gpu --locked -- --test-threads=1 --skip depth_bounds_pipeline_loads_and_filters_draws
  exit 0, 55.4 s, 632 passed, 0 failed, 59 ignored, 1 filtered out

So the job grows by seconds, not minutes, and its 30-minute timeout stays.

What I cannot show: that WARP then passes three times in a row. gh run rerun is refused for this account and this machine has no WARP. If it still fails, the culprit is elsewhere and the job is no worse off - the change is ordering only, and no test is skipped that was not skipped before.

AI-assisted: yes - DeepSeek v4.1 (flash), which matched two failures in two crates to a measurement already in this repository.

Written with an AI assistant.

places.rs models one card and one driver - RTX 4060 Ti, 616.64, as its own first
lines say - and the section above records that model. On an RTX 4090 with 621.24
four of its five tests fail, and the reason is a single behaviour the model gets
the other way round.

On 616.64 a loaded pipeline gives its static-sampler places back: the root
signature goes, the place with it, the next samplers made take the lowest free
ones and a stored pipeline reads through whatever is now at its old places.
That is the fault the numbering at the start exists to survive.

On 621.24 the sixteen stay where the first run left them:

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

KelboLive measured the same on an RTX 4070 Ti SUPER with 621.01.

At run time this changes nothing harmful: Places::check loads a stored pipeline,
compares it with one made now, finds no difference, reports "same", and the
library is used - correctly, because the places are the ones the pipeline was
stored with. The numbering still happens and is now unnecessary on this driver
rather than wrong.

The four tests are left as they are, deliberately: with one driver measured and
the other machine missing, a test accepting both would stop reporting the change
it exists to report. What would settle it is the command in the section above,
run on a 40-series card with 616.64.

Written with an AI assistant.
The Tests (no GPU, no game data) job fails on the runner's WARP adapter about
one run in eight, a different test each time: crash::tests in leonida-loader on
one run, descriptor::tests in leonida-gpu on another, and the same branch passed
the job an hour before the second failure.

This crate's flake was measured and cured that way already: 16 parallel runs of
leonida-gpu/lib gave 2 failures in two different tests, --test-threads=1 gave 8
of 8 clean at 37 s against 13 s, and every test alone was 15 of 15 clean. The
workflow runs them the default way, so every device test in the crate shares one
WARP device on every core at once.

So the workspace runs without leonida-gpu, and the crate runs by itself with
--test-threads=1, keeping the --skip for the depth bounds test that the software
adapter does not do. The cost measured here: the whole crate serial is 55.4 s
and 632 tests pass; the job grows by seconds, not minutes, and its timeout stays
30.

Written with an AI assistant.
@merzleckeier

Copy link
Copy Markdown
Contributor

Independent check of the split test inventory at d2fefa98 on main 60f7dcd9. I built the original selection, both replacement selections and the diagnostics replay target for Win64 with the locked dependencies. The original 20 artifacts partition into 17 non-GPU and three leonida-gpu artifacts with identical selected test-target features. The three GPU libtest lists match byte-for-byte, with 703 unit entries before filtering and two feature-gated integration binaries with zero tests in the default build. The separate diagnostics replay build still has one test. The depth-bounds exclusion stays on the leonida-gpu command. The loader retains its parallel invocation.

On Wine 11.22 / VKD3D-Proton 3.1.0, I also ran three focused repetitions per mode on each of RTX 4070 SUPER (620.73.4) and Radeon (RADV 26.3.1). All 12 runs (old selection with eight threads and split selection with one) returned 74 passes and the same failure, watch::tests::what_is_left_alone_is_no_known_hole. It also failed alone in each RTX binary. That is a stable result on this setup. The no-ICD full GPU runs and the separate diagnostics replay did not complete under Wine. Native Windows WARP flake incidence remains unmeasured here.

MEASURED with synthetic or unit test inputs. AI-assisted (Codex).

@Neutron-0

Copy link
Copy Markdown

Verified on Windows 11, Rust 1.98.1, no GPU and no game files.

The claim holds, on the pull request's own base. The whole leonida-gpu test binary was run ten times in parallel and six times with --test-threads=1, on the same commit (60f7dcd90, which is on main):

runs
parallel, as the workflow ran it 8 passed, 2 failed
--test-threads=1, as this pull request runs it 6 passed, 0 failed

Both parallel failures were the same test:

texture::alias_cast_tests::committed_and_placed_r32_uint_textures_cast_to_r9g9b9e5_under_legacy_barriers
panicked at crates\leonida-gpu\src\texture.rs:5664:17
assertion `left == right` failed: left: true, right: false

which is the pool race #2854 fixes. Running the crate's tests one at a time removes it here, so the mechanism the pull request relies on - the device tests of one crate sharing one device - is the right one, and the cost of the extra step (the pull request measures 55 s for the whole crate serial) is what it says.

Two details of the diff that are right and worth stating. The workspace step drops --skip depth_bounds_pipeline_loads_and_filters_draws, and that is safe: the test with that name exists only in d3d12/crates/leonida-gpu/src/pipeline/host.rs, and the step now excludes leonida-gpu, so nothing that needed the skip is left in it - and the new step keeps the skip for the crate that has the test. The separate Replay test (diagnostics) step still runs in parallel, and that is fine: d3d12/crates/leonida-gpu/tests/replay.rs has exactly one #[test], so there is nothing in it to run in parallel. The workflow file parses, and the job list is unchanged (d3d12). actionlint is not on this machine, so the repository's own jactionlint workflow is what would check the file's style.

One thing to be clear about, because it decides what happens to #2854 and #2884. This pull request makes the job green by changing the schedule of the tests, and at least two of the races it hides are in product code, not in the tests:

Serializing the tests does not repair any of those; it only stops the tests from seeing them. So this pull request and #2854 and #2884 are complementary rather than alternatives: this one makes the job green now, and those two remove the defect that a program with two threads would still meet. It would be a mistake to read this pull request as "the races are only in the tests" and close the other two on that basis.

What cannot be shown here either. The pull request says it cannot show that the runner's WARP then passes three times in a row, and neither can this box: the runs above are on this machine's own card, with WARP not involved, so they show that the schedule removes the parallel failures here and not that the runner's software adapter is fixed. The serial runs take about a minute each on this machine, well inside the 30-minute timeout of the new step.

Not checked: the D3D12 runtime job's own steps (a GPU runner); the workflow's behaviour when leonida-gpu fails to build (the new step would report it separately from the workspace step).

@Kal0s-design

Copy link
Copy Markdown
Contributor

Measured on Windows with the WARP adapter, since the description says this machine has none. I forced WARP with LEONIDA_D3D12_WARP=1, which only takes effect in a diagnostics build.

Setup: main d2a564b66, leonida-gpu lib tests built with --features diagnostics, --skip depth_bounds_pipeline_loads_and_filters_draws as in the workflow. Every run is a fresh process.

how runs failed time per run
default threads (all cores here) 20 0 10-12 s
--test-threads=4 (a windows-latest runner's core count) 20 1 15-16 s
--test-threads=1 (this PR) 10 0 32-33 s
the failing test alone, --exact 20 0 -

The one failure was texture::alias_cast_tests::committed_and_placed_r32_uint_textures_cast_to_r9g9b9e5_under_legacy_barriers. That is the same test MoonEyes saw failing in 2 of 5 parallel runs of plain main (on #2852, on a card). So the shape the description gives holds here too: parallel runs on one device fail now and then, on a test that passes alone, and serial runs are clean. Two caveats:

  • With all cores I saw no failure in 20 runs; it only showed with 4 threads. Fewer threads per core may simply be closer to the runner's timing. This is 1 in 20, so it does not measure a rate.
  • My runs are a diagnostics build, the only way to force WARP on a machine with a card. The workflow step builds without it.

On cost: serial is about 2x the 4-thread time here (32 s against 16 s for the lib tests). That is consistent with the 37 s against 13 s in the description, and well inside the 30-minute timeout.

GPUs tested: WARP (forced); the same build on the card is not part of these numbers.

AI-assisted: yes (Claude Code).

@fiestorra

Copy link
Copy Markdown
Contributor Author

The job this changes is the job that ran it, and it passed. d3d12 (windows-latest) is green on this branch, and that run took the new path: the workspace without leonida-gpu, then the crate alone with --test-threads=1. jactionlint is green as well, so the YAML is what it looks like.

That is one clean run, not the three I said would settle it, and I would still like the three. But it is the first time the job has passed without a device test failing on WARP in four attempts, and the four before it are listed in the description.

What to watch when it lands: the step time. The run here is the same shape as the ones that failed, so the durations are comparable - if the Tests (leonida-gpu, one thread) step shows about a minute more than the workspace step it replaced, the cost is what the description measured.

Written with an AI assistant.

@KelboLive KelboLive left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Measured on this box (32 threads, RTX 4070 Ti SUPER, 621.01, native Windows): cargo test -p leonida-gpu --lib -- --skip depth_bounds… failed 6 of 10 parallel runs — 5× texture::alias_cast_tests::…under_legacy_barriers at texture.rs:5664 (stale pool::fresh, the production bug #2854 fixes) and 1× watch::tests::what_the_kernel_writes_through_is_not_guarded_for_another_view at watch.rs:6010. Serial is 632/632 at 34–36 s against 11–13 s parallel, so the split is cheap (+35–40 s on a 9-minute job) and it does stabilise this job.

But it is ordering, not a cure, and two claims do not hold:

  1. The races remain in the tree — local cargo test is still parallel, and #2854's descriptor TEST_SYNC_LOCK is still needed because the 4 ms leonida-heap-sync producer thread is independent of test threads. So #2854/#2896 are complementary, not redundant; #2884 is orthogonal (CI never runs the diagnostics lib suite here).
  2. The cited loader crash::tests failure has no GPU dependency (crates/leonida-loader does not depend on leonida-gpu; crash.rs:890-921 is VirtualAlloc/memory_at), and it stays parallel in the first step (d3d12.yml:76). The "shared WARP device" cause does not cover it, so one of the two motivating failures is untouched by this change.

Also: this branch contains #2921's findings commit (a012d951 is #2921's head), so merging #2923 would land that unrelated section — and that section has a blocking problem in its own review (the graphics pipeline still slides on 621.x). Please rebase off it.

Minor: the comment at d3d12.yml:72-73 is now stale (the --skip moved to the next step and leonida-gpu is no longer in that command), and the title reads like a fix rather than a mitigation — "run … on one thread" could say "to stop the parallel flakes".

Merge is mechanically clean and all checks pass.

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.

5 participants