Skip to content

bvh_gpu_smoke: raise default --heap-bytes from 1 MiB to 16 MiB - #6633

Merged
shayderrr merged 1 commit into
ItsNotRexed:mainfrom
Wasler:fix/bvh-smoke-default-heap
Nov 23, 2026
Merged

shayderrr merged 1 commit into
ItsNotRexed:mainfrom
Wasler:fix/bvh-smoke-default-heap

Conversation

@Wasler

@Wasler Wasler commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: comment

What and why

tools/bvh_gpu_smoke.py defaulted --heap-bytes to 1 << 20 (1 MiB). With the default --table-qword 0x2000, BuildKDOP accesses ~2 MiB (passes only at >= 3 MiB on RTX 5060 Ti) and RadixCount accesses ~8 MiB (passes only at >= 8 MiB on RTX 5060 Ti).

On GPUs with strict GPU MMU page-fault reporting (measured on NVIDIA GeForce RTX 5060 Ti, Windows 11, driver 621.01, with and without Vulkan validation), both programs exited 1 with VK_ERROR_DEVICE_LOST (-4) under the 1 MiB default even though their translated SPIR-V executes cleanly when given a large enough heap buffer.

  • Raises the default --heap-bytes in tools/bvh_gpu_smoke.py from 1 << 20 (1 MiB) to 16 << 20 (16 MiB), leaving explicit --heap-bytes overrides unchanged.
  • Adds test_default_heap_bytes_is_16_mib in tests/test_bvh_gpu_smoke.py running smoke.main(["--spirv", ..., "--no-validation"]) without --heap-bytes against a mocked subprocess.run and find_vk_compute_test to check VKC_OUT_WORDS, the 16 MiB heap image length, and the seeded 0x2000 table qword.

No overlap or conflict with #5085, #5130, #6291, or #6472.

Tested

  • Negative control (upstream/main tools/bvh_gpu_smoke.py): python -I tests/test_bvh_gpu_smoke.py -k test_default_heap_bytes_is_16_mib fails with [(262144, 1048576, 8192), ...] != [(4194304, 16777216, 8192), ...].
  • Unit & lint checks (Windows 11, CPython 3.14.4, CPU only):
    • python -I tests/test_bvh_gpu_smoke.py: 13 tests OK
    • python -I tests/test_check_no_game_data.py: 8 tests OK
    • python -I tests/test_docs_cli_flags.py: 3 tests OK
    • python -m py_compile & git diff --check: clean, LF line endings preserved.
  • GPU check (Windows 11, NVIDIA GeForce RTX 5060 Ti, driver 621.01, Vulkan validation enabled, own 1.0.2.1 copy, counts only):
    • Default before (1 MiB): 45 of 49 pass; 7 changed heap words beyond running; exit 1 4 (BuildKDOP, DecompressHeader, RadixAlloc, RadixCount fail with -4).
    • Default after (16 MiB, --heap-bytes omitted): 47 of 49 pass; 8 changed heap words beyond running; exit 1 2 (BuildKDOP passes with 0 changed words, RadixCount passes with 2 changed words, checked: 6 of 6 write exactly what they should; only DecompressHeader and RadixAlloc remain).

AI-assisted: yes (Antigravity)

Checklist

  • 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. (no translator change)

With the default --table-qword 0x2000, BuildKDOP reads ~2 MiB and RadixCount writes ~8 MiB, so the old 1 MiB heap triggered VK_ERROR_DEVICE_LOST (-4) on strict MMU drivers such as NVIDIA RTX 5060 Ti.
@AsgerCode

Copy link
Copy Markdown

Tested b5b6504 on Windows 11 (NTFS), Python 3.12.10 (CPU only, no GPU, no game files): pass

I could not check the GPU results in the description (RTX 5060 Ti, -4 at 1 MiB), because I have no GPU. Everything below uses the CPU-only test and fake runners.

What I ran:

Nits, none blocking:

  1. A default run now needs about 1.5 GiB of temp disk. smoke() keeps both dumps of every program (<name>.1.bin, <name>.2.bin) in its TemporaryDirectory until the last program finishes. I called smoke() on 49 empty .spv files with a fake runner that writes the init image as the dump. The temp folder peaked at 99 MiB with the old 1 MiB heap and 1584 MiB with the new 16 MiB heap (0.7 s vs 5.4 s). run_checked adds 6 x 2 x 16 MiB more. If you delete first and second after changed_words, the peak stays at a few heap images.
  2. docs/embedded_shaders.md section 5 gives the RX 9070 result ("only seven change any heap word"). Section 6 says the command "reproduces the GPU run above". Commit 6d458e4b added that result together with the 1 MiB default, and the doc does not name the heap size. With the new default, your own NVIDIA run shows 8 programs that change heap words (RadixCount now writes 2). A short note in the doc on the heap size of that run (or --heap-bytes 1048576 to repeat it) keeps the doc correct.

AI-assisted (Claude Code).

@kapitche

Copy link
Copy Markdown
Contributor

Tested b5b6504 merged with main 8575d36 on Linux/Python 3.12.16: pass

Merge was clean (tools/bvh_gpu_smoke.py, tests/test_bvh_gpu_smoke.py).

  • python -I tests/test_bvh_gpu_smoke.py: Ran 13 tests, OK.
  • Negative control (tools/bvh_gpu_smoke.py restored from upstream/main, tests from the PR): Ran 13 tests, FAILED (failures=1): test_default_heap_bytes_is_16_mib. PR version restored afterwards.

Diff read: only the --heap-bytes default changes, from 1 MiB to 16 MiB (and its help text); the test runs main with subprocess.run and the vk_compute_test lookup mocked, and checks that both dispatches get a 16 MiB heap image, VKC_OUT_WORDS of 4 Mi words and the default table qword 0x2000.

Not run: no GPU or vk_compute_test was involved, so the claim in the comment that a 1 MiB heap faults on NVIDIA and that BuildKDOP/RadixCount touch about 2 MiB and 8 MiB is the author's and is not something these tests exercise.

@shayderrr shayderrr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Summary

tools/bvh_gpu_smoke.py:main() raises the default --heap-bytes from 1 MiB to 16 MiB, with a comment noting BuildKDOP uses about 2 MiB and RadixCount about 8 MiB at the default --table-qword 0x2000. tests/test_bvh_gpu_smoke.py:test_default_heap_bytes_is_16_mib stubs out the subprocess, inspects VKC_HEAP_INIT, VKC_OUT_WORDS and VKC_DUMP, and asserts both dispatches get 4M words / 16 MiB / 0x2000.

Why merge

The old 1 MiB default faulted on NVIDIA at stock settings. Test pins the exact environment both dispatches receive.

Verdict: Approve

@shayderrr

Copy link
Copy Markdown
Collaborator

Summary

tools/bvh_gpu_smoke.py:main() raises the default --heap-bytes from 1 MiB to 16 MiB, with a comment noting BuildKDOP uses about 2 MiB and RadixCount about 8 MiB at the default --table-qword 0x2000. tests/test_bvh_gpu_smoke.py:test_default_heap_bytes_is_16_mib stubs out the subprocess, inspects VKC_HEAP_INIT, VKC_OUT_WORDS and VKC_DUMP, and asserts both dispatches get 4M words / 16 MiB / 0x2000.

Why merge

The old 1 MiB default faulted on NVIDIA at stock settings. Test pins the exact environment both dispatches receive.

Verdict: Approve

@shayderrr
shayderrr merged commit 7c08216 into ItsNotRexed:main Nov 23, 2026
0 of 2 checks passed

@Senya01 Senya01 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.

Tested merged 7c0821659 on NVIDIA RTX 5070 Ti, driver 617.14, Windows 11 build 26300. Using the 52 BVH modules built by translator 07f81e760 with wave64 emulation and a 32 KiB shared-memory cap, the default 16 MiB Vulkan smoke run with validation enabled reproduced 47/49 pass and 6/6 byte-exact checks pass. The two failures were DecompressHeader and RadixAlloc, both vkQueueWaitIdle returning VK_ERROR_DEVICE_LOST (-4). All 52 compute pipelines could be created separately on this GPU.

I rebuilt vk_compute_test from aa5cd8120 and repeated the two failing dispatches individually with the same inputs. Both failed at 16 MiB, with no validation error or VUID captured before the driver error. At 1 MiB, DecompressHeader also failed. RadixAlloc exited successfully on one isolated dispatch, then failed in the follow-up smoke check, so the smaller heap did not give a stable pass here.

AI-assisted: yes. Runs and report by OpenAI Codex (gpt-6.2-sol).

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