Skip to content

BUILD-1758: scan float opcodes before adding NoContraction - #5481

Open
TG0000 wants to merge 1 commit into
ItsNotRexed:mainfrom
TG0000:codex/nocontraction-prefix
Open

TG0000 wants to merge 1 commit into
ItsNotRexed:mainfrom
TG0000:codex/nocontraction-prefix

Conversation

@TG0000

@TG0000 TG0000 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Claimed as BUILD-1758 in coordination.

What and why

Find the literal float opcode prefix first, then apply the existing whitespace and result-ID constraint to each candidate line. The pass still decorates the same instructions in the same order. The regression test covers arithmetic opcodes, indentation, lookalike opcodes, comments and debug names.

Tested

  • Windows 11, Ryzen 9 5900X, CPython 3.12.10. Four warmed alternating process pairs on the same 221 synthetic listings (16.9 million emitted assembly characters). Median CPU translation time fell from 1.899 s to 1.593 s (16.1%); the isolated NoContraction pass fell from 205.35 ms to 24.89 ms.

  • On 3faac557, the standalone patch, and the patch combined with BUILD-1709: skip the dispatch-switch scan on unaffected shaders #5344, all 221/221 fixtures translated and passed SPIRV-Tools 2026.4. Both the SPIR-V assembly and binary output matched byte for byte. Forced dispatch also emitted identical assembly.

  • Passed seven focused tests on the standalone integration and four switch tests on the combined integration with BUILD-1709: skip the dispatch-switch scan on unaffected shaders #5344. A synthetic parity probe additionally checked 40,000 candidate-line variants against the baseline matcher.

  • Follow-up GPU run on Radeon RX 6800, AMD 26.11.2 / Windows driver 32.0.21045.29003, with wave64 emulation and the optional Vulkan validation layer off. On both main and this standalone integration, all 221 shaders translated and passed spirv-val. All 235 generated SPIR-V binaries, including auxiliary modules, were byte-identical. The integration passed 201 Vulkan checks with 16 skips and no failures. Hardware report.

AI-assisted (OpenAI Codex). Repository synthetic inputs only.

@neoisg8

neoisg8 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Independent verification on Windows 11 (Python 3.14.7, head 2889275d, base main 3faac557):

  • git diff --check main...HEAD — clean.
  • python -I tests/test_f64_output_modifiers.py -v — 3/3 OK (including the new test_no_contraction_selects_only_float_arithmetic_lines).
  • Verified exact output parity against main on synthetic SPIR-V modules (testing comments, lookalike opcodes, string literals, and multi-stage modules).
  • Benchmarked on 1,000-line synthetic assembly: scanning literal opcodes before validating result-IDs achieved ~3.6x speedup over the previous multiline full-text regex scan while producing identical OpDecorate sequences.
  • Early exit when %void = OpTypeVoid is missing avoids unnecessary scans on malformed or empty listings.
  • Standard library only, no GPU or game data needed.

Looks good to merge.

AI-assisted.

@cynbun

cynbun commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Reviewed 2889275 (code read + CPU tests on Linux, Python 3.14): pass.

  • python -I tests/test_f64_output_modifiers.py passes 3/3. The new test also passes against the merge base's tools/rdna2spirv.py, as a parity test should.
  • Differential check: I compared main's _FLOAT_ARITH + findall version of no_contraction with this head's version (tools/rdna2spirv.py:12843-12867) on 200,000 random listings. They were built from opcode tokens, %ids, =, ;, quotes, \t, \r, \v, \f, \x1c, \x85, 
 and %void = OpTypeVoid markers. The output was identical for every listing. The fullmatch from the last \n reproduces ^\s* under re.M, including leading blank lines.
  • On a synthetic 200,000-line module with 50,094 float ops, the pass took 150 ms before and 56 ms after on a heavily loaded machine. The decorations were the same.
  • python -m unittest discover -s tests/semantic ran 7456 tests with 7 failures and 2 errors. They are in test_cmp_class_f64, test_loop_ballot_barrier and test_mutations. The same three files fail the same way on the merge base 03b09a08, so this change does not cause them.

AI-assisted (Claude Code).

@sovljanskii

Copy link
Copy Markdown
Contributor

Independent test on Apple M4 at head 2889275d, merged onto main 3faac557. Setup: macOS 27.2.1, MoltenVK 1.4.2, Python 3.15.2 (the new test also on 3.12.16), SPIRV-Tools v2026.4. The PR has no C++, so the runtime is main's build (AppleClang 21.0.0).

  • tests/test_f64_output_modifiers.py passes on both Python versions, and compileall is clean.
  • Corpus shard 0/64 (415 shaders), main → PR: 415/415 translated and spirv-val valid before and after. All 415 .spv and 415 .spvasm files are byte-identical by SHA-256.
  • Differential of no_contraction() alone, main vs PR:
    • Input: those 415 modules with their NoContraction lines stripped, 852 M characters in total; main decorates 388 of them.
    • Different outputs: 0.
    • Different outputs on 200,000 fuzzed modules (opcode lookalikes, tabs, \r, comments, OpName strings, missing trailing space): 0.
    • Time for the pass alone, best of 3: 6.41 s → 0.87 s. Other jobs were running, so read it as a ratio.
  • GPU suite (run_gpu_tests.py, main's runtime build): 152/217 passed, 58 skipped. Every test has the same result as main. The 7 failures are the ones main already has on MoltenVK (cs_fma_fused, ps_ssharp, ps_vcmp*_f16*, ps_vcmp_f32_nan).
  • Semantic suite: 6,245 tests, the same 32 failures and 2 errors as main on arm64 (the NaN rows spirv_mini_interp: pin the sign of a NaN made from non-NaN operands (semantic suite on arm64) #5208 fixes, plus test_loop_ballot_barrier); no new failure.

Verdict: works on Apple M4. No output change on the shard and the pass is about 7× faster.

AI-assisted.

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

Head 2889275d4683 · Verdict: LGTM

python -I -m pytest tests/test_f64_output_modifiers.py -q → 3 passed, 7 subtests. git diff --check clean.

The literal-prefix scan plus per-line fullmatch picks the same result IDs as the old anchored regex while skipping OpName strings and comments; the new test covers both. No blockers.

@gertify

gertify commented Nov 23, 2026

Copy link
Copy Markdown

Tested 2889275 on Intel UHD Graphics 630 (CFL GT2): test_f64_output_modifiers.py runs 3 tests OK, tests/test_translate.py gives 581 passed, 4 skipped, and run_gpu_tests.py --filter fma passes 3/3 ("PASS cs_fma_fused 8/8 fused exact (GLSL Fma)", ps_fma_literal and ps_fmac_f16_mods 4096/4096 pixels exact). With LEONIDA_VK_DEVICE=NoSuchDevice the same filter fails 0/3 with "no Vulkan physical device matches". The full GPU suite gives 148/210 passed, 60 skipped, with FAIL cs_fmt_int_narrow and FAIL cs_signed_zero_nan, and the same counts and the same two FAILs on the base commit 03b09a0. The Windows claims in the description were not reproduced.

AI-assisted.

@caltr98

caltr98 commented Nov 23, 2026

Copy link
Copy Markdown

Tested 2889275 on Windows 11, Python 3.11 (CPU only): pass after a merge with main. python -I tests/test_f64_output_modifiers.py: 3 tests OK. On the PR head as is, tests/semantic shows 4 failures that main does not have (test_mutations "v_mul_legacy_f32 drops zero-times-anything guard" x2, test_cmp_class_f64.test_rejected_forms x2), but the branch is 611 commits behind main: merged onto main at 3faac55, test_mutations and test_cmp_class_f64 both pass. A rebase would make that visible to CI. AI-assisted.

@TG0000
TG0000 force-pushed the codex/nocontraction-prefix branch from 2889275 to e982d41 Compare November 23, 2026 13:10
@TG0000

TG0000 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto \origin/main\ \561b65a83\ (head $sha) per @caltr98's suggestion so CI runs on current \main. \python -I tests/test_f64_output_modifiers.py\ passes (3/3 OK). AI-assisted.

@itsonlysimbo

Copy link
Copy Markdown
Contributor

Tested e982d412 on RTX 4070, NVIDIA 621.14, Windows 11 (10.0.26300), Vulkan SDK 1.4.363, llvm-mc 23.1.6, test programs from main 561b65a8: pass.

AI-assisted (Claude Code).

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.

8 participants