Skip to content

Compare validated FSPX translation runs by code identity - #6062

Open
kacper-serewis wants to merge 4 commits into
ItsNotRexed:mainfrom
kacper-serewis:feat/compare-shader-inventories
Open

kacper-serewis wants to merge 4 commits into
ItsNotRexed:mainfrom
kacper-serewis:feat/compare-shader-inventories

Conversation

@kacper-serewis

Copy link
Copy Markdown
Contributor

FSPX-COMPARE, claim on #5934.

Depends on: #5688

Extends the existing count-only coverage CLI with an optional two-run comparison. Matches complete kind-6 code bytes by SHA-256, handles renames and shuffled inventories, flags duplicate identities, and distinguishes absent evidence from explicit refusals. Indexed modules pass through spirv-val again before being counted as validated. The original single-run invocation and output are preserved. Only aggregate counts are printed.

On Windows, compared all 29 cached programs using both input paths of #2323 at 6dcbcbd with --wave64-emulate --no-asm. Added only local recording of names in the existing Unsupported handler for this measurement. Listing to direct binary: 18 remained validated, 11 explicit refusals became validated, 0 regressions, 0 unchanged refusals, 0 missing identities. CPU and SPIRV-Tools only. No raw package, GPU or driver used. #2323 was used for testing only.

Passed tests/test_fspx_coverage.py (legacy output, renamed/shuffled synthetic programs, duplicate identities, forward/reverse changes, absent evidence and validator failure), tests/test_text_write_line_endings.py, compileall on both changed Python files, and git diff --check.

AI-assisted implementation and testing.

@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

The comparison keeps the previous program's bytes alive while it reads the next program. On Windows 11 with CPython 3.14.7 at 43228ef0, one 4 MiB program used 4,196,496 bytes of peak traced allocations in by_identity. Two distinct 4 MiB programs used 8,391,123 bytes. Streaming the same files with hashlib.file_digest gave identical SHA-256 identities and outcomes with a peak of 395,871 bytes for the pair.

Run the following from the checkout root with py -3.14 -I:

import json, sys, tempfile, tracemalloc
from pathlib import Path
sys.path.insert(0, str(Path("tools").resolve()))
from fspx_coverage import by_identity

with tempfile.TemporaryDirectory() as temp:
    root = Path(temp)
    (root / "fspx").mkdir()
    for names in (["a"], ["a", "b"]):
        for name in names:
            (root / "fspx" / (name + ".code")).write_bytes(name.encode() * (4 << 20))
        (root / "index.json").write_text(json.dumps([{"file": n + ".dxbc"} for n in names]))
        tracemalloc.start()
        groups, missing = by_identity(root, root / "out", "code")
        print(len(groups), missing, tracemalloc.get_traced_memory()[1])
        tracemalloc.stop()

Please hash each open file as a stream. Keep the existing missing-identity handling for empty and absent files. The direct parent 606d99b0 has no comparison mode.

I ran the coverage, FSPX stage, translator CLI, and text line-ending test files. Across the four suites, 50 tests passed and one skipped.

AI-assisted.

Windows CPU: 29 cached listings, 18 pass spirv-val, 11 explicit refusals. Older output has 11 missing results. All 50 focused tests passed. The repository newline scan flags the unchanged upstream f64_omod_probe.py:268. AI-assisted.
Depends on: ItsNotRexed#5688 at 31ba693. Windows CPU: both focused tests and compileall passed. Re-ran both ItsNotRexed#2323 input paths at 6dcbcbd with local refusal recording on all 29 cached programs. spirv-val confirmed 18 retained and 11 newly validated identities, with no missing identities or regressions. The legacy run had 11 missing results, all explicit refusals in the updated listing run. No raw package or GPU. AI-assisted.
@morodirule

Copy link
Copy Markdown

Tested d1321a9 on Arch Linux, Python 3.14.10, CPU only (llvm-mc 23.1.5 / SPIRV-Tools present): pass.

  • python3 -I tests/test_fspx_coverage.py — 2 tests OK (legacy/partial outputs, renamed+shuffled runs with duplicate identities, absent code evidence, validator failure via mocked validated)
  • python3 -I tests/test_fspx_shaders_stage.py — 14 tests OK
  • python3 -I tests/test_rdna2spirv_cli.py — 35 tests OK, 1 skipped
  • python -m compileall on both changed Python files OK; git diff --check clean
  • Negative control: compare is new in this stack (tools/fspx_coverage.py itself arrives via Report FSPX translation coverage against the unpacked inventory #5688, absent on origin/main), so the coverage-compare tests have nothing to run against on main.

One note, pre-existing and not from this PR: tests/test_text_write_line_endings.py fails 1/3 on this head at tools/f64_omod_probe.py:268 (write without newline=). That file is untouched by #6062 and the same line on origin/main already lacks newline=.

No game files, no GPU. AI-assisted.

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.

3 participants