Skip to content

test_make_game_argparse: the shaders stage probes two GPUs the test does not mock - #2818

Merged
MoonEyes merged 1 commit into
ProjectLeonida:mainfrom
imShangLi:fix/argparse-gpu-probe-list
Dec 1, 2026
Merged

MoonEyes merged 1 commit into
ProjectLeonida:mainfrom
imShangLi:fix/argparse-gpu-probe-list

Conversation

@imShangLi

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: TEST-ARGPARSE-GPU-PROBE-LIST

Depends on: #1885

What and why

JobsHandlingTest.test_custom_jobs_forwarded_to_shaders asserts fallbacks=(), but it mocks only four of the six runtime_gpu_* probes the shaders stage consults. The two it leaves out are precisely the two that answer False on hardware tools/vk_subgroup_info.py:50-55 documents:

  • denorm_flush_to_zero_f32 — "where it is false (e.g. NVIDIA Vulkan drivers, which report VK_FALSE)"
  • integer_dot_product — "false only on a Vulkan 1.2 device such as MoltenVK's"

When a probe answers False, make_game.py sets the fallback flag unconditionally rather than going through keep_recorded_fallback() (that path is only taken for None), so the assertion sees a fallback the test never asked for:

Expected: preflight(['shaders'], '<work>', False, None, emulate=True, keep_emulated=True, fallbacks=(), jobs=6, overlap=True)
Actual:   preflight(['shaders'], '<work>', False, None, emulate=True, keep_emulated=True, fallbacks=('--no-ftz32',), jobs=6, overlap=True)

tests/test_make_game_translator_flags.py:212-217 already mocks all six probes, so this is an incomplete copy of the same list rather than a deliberate difference. This change adds the two missing patches; nothing outside the with block changes.

Depends on: #1885 — that pull request inserts runtime_gpu_mesh_shader into the same with header, so the two conflict on one line. Whichever lands second rebases trivially; I did not reorder the existing probes to dodge it.

Tested

No game files or particular hardware needed.

python -I tests/test_make_game_argparse.py     # before: 1 failure of 38 (skipped=1)  ->  after: OK (skipped=1)
python -I tests/test_make_game_translator_flags.py   # OK, 42 tests
python -m compileall -q make_game.py tests     # OK

Before/after were measured on the same commit by stashing the change, so the single failure is attributable to the missing mocks.

runtime_gpu_* answers on the machine used (Mesa llvmpipe, LLVM 23.1.0, CPU Vulkan): per_vertex_inputs=False, barycentric_fallback=False, max_push_constants_size=256, mesh_draws_crash=False, integer_dot_product=True, denorm_flush_to_zero_f32=False. Only the last one produced the failure here; integer_dot_product is mocked too because the documented Vulkan 1.2 case would fail the same way.

GPUs tested: n/a — no GPU tests. The reproduction runs against a CPU Vulkan device (Mesa llvmpipe) on Fedora Linux under a VM; no hardware GPU, vendor driver or OS driver was involved.

AI-assisted: yes — MiMo-V2.6-Flash (OpenCode), which located the failure, read make_game.py and tools/vk_subgroup_info.py to establish the trigger conditions, and wrote the patch. The claim and this description were drafted by it as well.

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. — n/a, no translator rule in this change.

… than the test mocks

test_custom_jobs_forwarded_to_shaders asserts fallbacks=() but neutralises only four of the six
runtime_gpu_* probes the shaders stage consults. The two it misses answer False on hardware
tools/vk_subgroup_info.py documents: denorm_flush_to_zero_f32 on NVIDIA Vulkan drivers (VK_FALSE)
and integer_dot_product on a Vulkan 1.2 device such as MoltenVK's. Where a probe answers False,
make_game.py sets the fallback flag unconditionally instead of going through
keep_recorded_fallback(), so the assertion fails with fallbacks=('--no-ftz32',).

Add the two missing patches, the same six-probe list tests/test_make_game_translator_flags.py
already uses.
@OreoFR

OreoFR commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Verified by OreoFR on macOS 27.2.1, Apple M5 (MoltenVK), Python 3.12, head 872d2e753, main d920d850d. CPU only, no game.

This is the failure I'd been seeing on this Mac all night (noted on #2792 as pre-existing on main).

MEASURED

  • main as is: tests/test_make_game_argparse.py gives 1 failure, JobsHandlingTest::test_custom_jobs_forwarded_to_shaders. Expected: … fallbacks=() vs Actual: … fallbacks=('--no-ftz32',), the same diff you quote.
  • On this machine, the two unmocked probes answer make_game.runtime_gpu_denorm_ftz_f32() → False and make_game.runtime_gpu_integer_dot_product() → True. So it's the FTZ probe that adds --no-ftz32 here, the "where it is false" case tools/vk_subgroup_info.py documents.
  • main + this PR (merge-tree): 37 passed, 1 skipped, 13 subtests passed. The red/green split doesn't apply, since the PR only touches the test file; the before/after is main's test file vs this one.

READ IN CODE

  • The diff adds exactly the two missing patch(...) calls, with the same return_value=None as the other four. The test now no longer depends on the machine's GPU. Nothing outside the test changes.

AI-assisted: Claude Code

@fiestorra

Copy link
Copy Markdown
Contributor

Verified on Windows, and the control bites: the suite fails with main's copy of the file.

main d920d850d, cherry-picked (the branch is already at main, merge-base = d920d850d), Python 3.13.14:

python -m pytest tests/test_make_game_argparse.py -q
  with this pull request:      38 passed, 13 subtests passed   (43.55 s)
  with main's test file:        1 failed, 37 passed, 13 subtests passed   (40.73 s)

So the two patch(...) calls this adds are what the failing case needs, and nothing else in the file changed.

What it fixes, in its own words: the shaders stage probes runtime_gpu_integer_dot_product and runtime_gpu_denorm_ftz_f32, and those are answered per machine. Pinning both to None makes the stage's list of what it asks about independent of the card - which is the reason a test of an argument parser should not depend on a GPU probe. On this machine the failure is real and reproduces from main's file, so the flake is not hypothetical.

What I did not check: that those two functions are the only probes the stage can raise on. I ran the file, not the stage against several cards, and a third probe added later would put the dependence back.

AI-assisted: yes - DeepSeek v4.1 (flash), both arms run on the machine above.

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.

Verified independently on Windows with an NVIDIA card (RTX 4070 Ti SUPER: denorm_flush_to_zero_f32=False, integer_dot_product=True, per_vertex_inputs=True), so this is the documented NVIDIA case and not an llvmpipe-only one.

                                             origin/main        PR head 872d2e753
python -I tests/test_make_game_argparse.py   FAILED (1 of 38)   ok (38/38)
tests/test_make_game_translator_flags.py     ok (42/42)         ok (42/42)
tests/test_make_game_preflight.py            ok (110/110, 1 skip) ok
python -m compileall -q make_game.py tests   exit 0             exit 0

The main failure is the quoted one: fallbacks=() expected, ('--no-ftz32',) seen (test_custom_jobs_forwarded_to_shaders, line 372). Reproduced on the d920d850d base and again on current origin/main 86c30fcea (the three commits since do not touch the relevant files); git merge-tree against current main is clean.

The claim holds and no coverage is dropped: the six patches match the probe list test_make_game_translator_flags.py already uses (212-217), and the test still pins the exact preflight and shaders kwargs, fallbacks=() included. Both fallback paths stay covered in that file (run_main(integer_dot=False), and test_failed_ftz32_probe_keeps_the_recorded_choice). It is also the only test that asserted a literal fallbacks=(...) for a real main() run — the neighbouring one uses ANY — so nothing else has the same latent failure.

Two nits, both non-blocking:

  1. A one-line comment above the six patches saying why they are pinned (an NVIDIA driver answers False for denorm FTZ and main() then adds --no-ftz32) would match the TEST-461 note above the neighbouring test.
  2. Patching make_game.runtime_gpu_info once, the way test_make_game_wave64.py does, would keep a future probe from reopening the same gap the way the mesh_shader probe did here.

@aegish-zagi

Copy link
Copy Markdown
Contributor

Verification — VERIFY-2818

Verdict: PASS (with stated limit)

  • PR: test_make_game_argparse: the shaders stage probes two GPUs the test does not mock #2818 | head sha: 872d2e75344930b796b10c33e5b75e884addba81 | merge state vs main: clean merge with current main 5dd6d444f in a scratch worktree (merge commit 01eba8f93), no conflicts. Diff is 1 file, +3/−1: tests/test_make_game_argparse.py only.
  • Tests run: python -I tests/test_make_game_argparse.py
    • On PR (merged with main): 38 tests, OK (skipped=1)
    • On plain main: 38 tests, OK (skipped=1)
  • Red-on-main vs green-on-PR: not reproducible on this host — stated limit. On this no-GPU Linux host both probes return None, so main passes too. The failure the PR fixes is hardware-dependent (a probe answering False, e.g. NVIDIA Vulkan / MoltenVK), which I cannot reproduce here — MEASURED locally, READ IN CODE for the failure path.
  • Audit (READ IN CODE): make_game.py consults exactly six runtime_gpu_* probes in the shaders stage (per_vertex, barycentric_fallback, max_push_constants, mesh_draws_crash, integer_dot_product, denorm_ftz_f32 — lines ~3754–3809). The test on main mocked only the first four; this PR adds the missing runtime_gpu_integer_dot_product and runtime_gpu_denorm_ftz_f32 patches, matching the six-probe list already used in tests/test_make_game_translator_flags.py:212-217. Where a probe is False, make_game.py:3801-3809 sets the fallback unconditionally, which is exactly the fallbacks=('--no-ftz32',) failure described. No game data, no other files touched.
  • Platform: Linux, Python 3.12.3, no GPU.

AI-assisted: yes (Muse Wonder, Muse by Meta)

@imShangLi

Copy link
Copy Markdown
Contributor Author

Measurement: with this pull request merged, every standalone test file in the repository passes

main is at 86c30fce (which already includes #2825 and #2827, the two reds from this morning). I built two trees and ran the same runner over both:

tree result
main 86c30fce 637 passed, 1 failed, 33 skipped
main + this pull request (99e91882) 638 passed, 0 failed, 33 skipped

The pass lists differ by exactly one line:

$ diff <(sort passed-main) <(sort passed-with-2818)
321a322
> tests/test_make_game_argparse.py

and the skip lists are identical, so nothing was traded away to make room for it. The merge itself is the one file, +3/−1, on top of 86c30fce.

The one failure on main, verbatim:

FAIL: test_custom_jobs_forwarded_to_shaders (__main__.JobsHandlingTest.test_custom_jobs_forwarded_to_shaders)
  File ".../tests/test_make_game_argparse.py", line 372, in test_custom_jobs_forwarded_to_shaders
    mock_preflight.assert_called_once_with(..., fallbacks=(), jobs=6, overlap=True)
AssertionError: expected call not found.
Expected: preflight(['shaders'], '/tmp/tmpxa7a2y4w/work', False, None, emulate=True, keep_emulated=True, fallbacks=(), jobs=6, overlap=True)
  Actual: preflight(['shaders'], '/tmp/tmpxa7a2y4w/work', False, None, emulate=True, keep_emulated=True, fallbacks=('--no-ftz32',), jobs=6, overlap=True)

fallbacks=('--no-ftz32',) — the probe this pull request mocks was answering from the machine.

Scope of that claim

The runner executes every tests/test_*.py that imports no pytest and exposes a __main__ block, as python3 -I <file>, with a 300 s timeout each:

638 run + 33 skipped = 671 files

So this is "every standalone test file", not the whole test suite: the 33 skipped are the pytest-based files and the ones with no __main__, and it says nothing about ctest, the Rust workspace, tests/semantic/, or the CI jobs themselves. I am not claiming main is otherwise green — only that within this set, this pull request is the last thing standing between it and 638/638, and it closes that gap.

Environment: Linux, Python 3.15, llvmpipe — the CI-shaped blind spot this pull request is about.

AI-assisted: yes — MiMo-V2.6-Flash (OpenCode). It built both trees, ran the two passes, diffed the lists and drafted this report.

@Neutron-0

Copy link
Copy Markdown

Verified on Windows. The control here is how often the test reaches the real GPU, not whether it passes.

main 640b0d0df, cherry-picked (one commit, 872d2e753), Python 3.13.5:

python -m pytest tests/test_make_game_argparse.py -q
  with this pull request:   38 passed, 13 subtests passed
  with main's copy of the test file:  38 passed (the file passes in both trees)

So this is not a fix of a failing test - it is a fix of a test that depends on the machine it runs on. Here is the measurement, with make_game.runtime_gpu_info wrapped in a counter and JobsHandlingTest.test_custom_jobs_forwarded_to_shaders run alone:

main's copy of the test file    ->  real GPU probe reached: 2 time(s)   (0.855 s)
this pull request's copy        ->  real GPU probe reached: 0 time(s)   (0.019 s)

Why the two calls matter: runtime_gpu_integer_dot_product() and runtime_gpu_denorm_ftz_f32() (make_game.py:2184,2191) both ask runtime_gpu_info(), which runs tools/vk_subgroup_info.py against the GPU the runtime would use. The answer is not a constant: when it says False the shaders stage turns integer_dot_fallback / no_ftz32 on, and when it cannot tell, keep_recorded_fallback (make_game.py:2039) reads the flags recorded in the work folder - its own docstring says the probe answers differently from run to run (a GPU asleep or hidden, a missing Vulkan loader, its 60 s timeout). With the two probes mocked, the test asks the same question on every machine, which is what the other four runtime_gpu_* mocks in the same with block already do.

What I could not test: nothing else - the change is in the test file only. I did not translate a corpus or run the shaders stage for real; I ran the test file and measured which functions it reaches.

AI-assisted: yes - DeepSeek v4.1 (flash), both arms on the machine above.

Written with an AI assistant.

@MoonEyes

MoonEyes commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Verified by MoonEyes (another person than the author) on head 872d2e753 merged with main 9372a4d4f: Windows 11, RTX 4060, Python 3.14. tests/test_make_game_argparse.py 38 OK (1 of 38 fails on main here, test_custom_jobs_forwarded_to_shaders, the failure this fixes). Neighbours OK.

AI-assisted (Claude Code).

@MoonEyes

MoonEyes commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Merging. Head 872d2e753 merges cleanly with main 501b3e6c5 and does not force a rebase of #2566. CI green on this head and on main. KelboLive checked it on Windows (NVIDIA) on this head: test_make_game_argparse fails on main and passes here, no coverage dropped; I ran it on main + PR (Windows, Python 3.14): 38 tests OK. MoonEyes asked for this merge. A test only. Merged by MoonEyes.

AI-assisted (Claude Code).

@MoonEyes
MoonEyes merged commit 1d73465 into ProjectLeonida:main Dec 1, 2026
5 checks passed
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.

7 participants