Skip to content

Validate shader shard indices numerically during merge - #3946

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
BBareth:codex/rdna2spirv-validate-numeric-shard-indices
Nov 23, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
BBareth:codex/rdna2spirv-validate-numeric-shard-indices

Conversation

@BBareth

@BBareth BBareth commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

BUILD-1124 · Claim in the coordination thread

What and why

With no marker or plan, a complete set containing part 10 could be refused because file names sort lexically. Validate numeric indices without changing merge order. For incomplete sets, show a bounded preview of missing indices rather than enumerating an arbitrarily large gap.

Tested

python -I tests/test_rdna2spirv_merge.py (27 tests), including 12 legacy parts and both planned and unplanned sparse sets. This changes index validation only. Synthetic inputs on macOS arm64 with Python 3.12. CPU only, so no GPU or driver was used.

AI-assisted with Codex.

@shdann

shdann commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 912bd23 on Windows, CPython 3.14.7, CPU only (no GPU, no game files): pass.

python -m pytest -q tests/test_rdna2spirv_merge.py gives 27 tests passed and 2 subtests passed. I used a virtual environment with tests/requirements.txt.
With the translator from the merge base (aa2988c), the head tests give 3 failures and 26 passes.

I also put {} in three files with the names index.part0.json, index.part2.json and index.part1000000.json.
merge_shard_parts rejects this set. The message lists the first 16 missing indices and reports 999982 more.

I found no defect. AI-assisted.

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

I ran the public rdna2spirv.py --merge CLI on Windows at 912bd23a and compared its published index with the merge base aa2988cc.

  • I created 101 synthetic parts in reverse order, numbered 0 through 100, with a unique entry in each. Parts 9 and 100 also contained the same key with different values. Without a plan or markers, the base refused the complete set. The head merged all 102 keys. Its output was byte-identical to the planned merge on both revisions, including the value from part 9 for the shared key. This checks that numeric completeness validation preserves the existing filename order when merging records.
  • I removed every fourth part from 1 through 97, leaving 25 separate gaps. With and without a plan, the head reported the first 16 missing ordinals in order and exactly nine more. All four failed merges across the two revisions preserved the previously published index byte for byte.

The existing merge suite passed all 27 tests and both subtests on the head. CPU-only on an Intel Core Ultra 7 265K, Windows 11 Home 25H2 build 26200.9974, CPython 3.12.10. Installed GPUs were an NVIDIA GeForce RTX 5070 (621.01) and Intel Graphics (32.0.101.9150). This checked index publication with synthetic records.

AI-assisted by Codex.

@kapitche

Copy link
Copy Markdown
Contributor

Tested 912bd23 merged with main aa2988c (already its base, so a fast-forward) on Windows 11 (CPython 3.13.1, native, no pytest): python -I tests/test_rdna2spirv_merge.py ran 27 tests, OK.

GPU: not run. The change is index validation in merge_shard_parts and touches no GPU path, so neither the RTX 4080 SUPER nor the Intel UHD 770 would exercise it.

Negative control: with tools/rdna2spirv.py put back to main, the same file gives 2 failures (test_large_gaps_have_a_bounded_diagnostic, both subtests) and 1 error (test_legacy_set_with_double_digit_indices_merges). No concerns.

@sovljanskii

Copy link
Copy Markdown
Contributor

End-to-end check on real shard runs (Apple M4, Python 3.15, my own 1.0.2.1 copy): pass. The bug also shows on real output, not only on synthetic parts.

Setup. With this head (912bd23a), I translated a 240-shader slice (--limit 240) as 12 parallel --shard i/12 runs, so the parts include index.part10.json and index.part11.json. The shards report 240 translated in total. I also ran the same slice unsharded (240 shaders: 240 translated, 240 pass spirv-val).

I then merged copies of that set with main aa2988cc and with this head:

set main this PR
12 parts + shard<i>.json markers merged 240 merged 240
12 parts, markers deleted (legacy) exit 2: incomplete shard set: parts [0, 1, …, 11] are not contiguous from 0 merged 240
legacy, index.part5.json removed — exit 2, … missing [5], no index.json
markers, part 10 and its marker removed — exit 2, 11 of 12 parts (0..11), missing [10], no index.json

Each merged index.json has exactly the same 240 entries and metadata as the unsharded run's.

So on main, a complete legacy set of more than 10 parts is refused. The message names all 12 parts, so it is confusing as well as wrong. This PR merges it, and still refuses a real gap with or without markers.

python -I tests/test_rdna2spirv_merge.py on this head: OK.

No game data (counts only). AI-assisted.

@requiemsnkrp

Copy link
Copy Markdown

Tested 912bd23a (merged onto main aa2988cc) on NVIDIA GeForce RTX 3060, driver 32.0.16.1714, Windows 11, MSVC 19.51, Vulkan SDK 1.4.363.0: pass.

  • python -I tests/test_rdna2spirv_merge.py: Ran 27 tests ... OK (Windows, Python 3.14).
  • Full ctest (-E "present|swapchain|frame_pacer", LEONIDA_VK_VALIDATION=1, llvm-mc build, so the ctest shader fixtures go through this rdna2spirv.py): 100% tests passed, 0 tests failed out of 148 (9 skipped/disabled, same set as main: shader_library_corpus, bink_decode, bink_play_headless, fsr_dispatch, bvh_builder, bink_audio, gameinput, d3d12_rgb9e5_rtv, d3d12_first_light).

AI-assisted (Claude). No game files.

@AirKyzzZ

Copy link
Copy Markdown
Contributor

Tested 912bd23a on Windows 10 22H2 (19045), Python 3.14 (CPU only, nothing GPU-specific in it): pass.

python -I tests/test_rdna2spirv_merge.py: 27 tests OK. Negative control: the same test file against main's tools/rdna2spirv.py fails 3 (an error in test_legacy_set_with_double_digit_indices_merges, both subtests of test_large_gaps_have_a_bounded_diagnostic), so the lexical-order bug is real on main, not only in theory. Same result on macOS with Python 3.14.0. Small thing, not blocking: parts {indices} and unexpected {extra} in the same messages are still unbounded for a big set, if bounded output is the goal. AI-assisted.

@PingasMech

Copy link
Copy Markdown

I’d land #3306 alongside this PR. On main 98fa503f, both merge orders for #3946 (912bd23a) and #3306 (b943a296, which includes #3196) gave the same tree without conflicts.

I ran the real translator with 12 shards on Windows. The first run had 12 hand-written synthetic shaders. Inserting one shader at the start of the sorted input gave the second run 13. To model a stale part, I replaced part 1 of the second run with part 1 from the first. Parts 1 and 2 then contained the same shader, and one current shader was missing.

Direct --merge, with legacy part files only Complete second run Second run with stale part 1
Main Exited 2 on the contiguous 12-part set Exited 2 on the same index-order check
#3946 Published all 13 Exited 0 and published only 12
#3946 + #3306 Published all 13 Exited 2, named both parts and removed the stale index.json

The combined version also caught that duplicate with current shard markers present. Rerunning all 12 shards restored an index byte-for-byte identical to unsharded translation. All 13 shader binaries matched their unsharded counterparts and passed spirv-val. CPU-only, AI-assisted.

@ItsNotRexed
ItsNotRexed merged commit 808acdd into ItsNotRexed:main Nov 23, 2026
3 of 10 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.

9 participants