Skip to content

tooling: add a translator corpus hash check and an IR dump option - #3791

Merged
R0Y00 merged 3 commits into
R0Y00:mainfrom
Leyukaka:quality/translator-corpus-hash
Dec 2, 2026
Merged

R0Y00 merged 3 commits into
R0Y00:mainfrom
Leyukaka:quality/translator-corpus-hash

Conversation

@Leyukaka

@Leyukaka Leyukaka commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Problem

There is no single check that says whether a change to the native translator alters its output. Refactors, build-flag changes and cache changes each have to argue "no output change" from individual fixtures.

Change

  • tests/translator_corpus_hash.py runs compile_dxil over a source-built corpus (graphics pairs, RTV variants, compute requests, raw mesh shaders) and writes a sorted TSV: one row per request with its status and either a SHA-256 fingerprint of the published DXIL or the refusal reason. Running the same script and DXC directory against two builds and diffing the TSVs compares their output.
  • compile_dxil --dump-ir writes the exact text handed to the compiler beside each stage as OUTPUT.cso.ir. The corpus script accepts --ir to fingerprint that text instead.
  • Two CTests, native_translator_corpus_dxil and native_translator_corpus_ir, check known compilations and refusals and compare two cold snapshots byte for byte. The IR test also compares DXIL from runs with and without the dump option.
  • The corpus reuses the existing synthetic fixtures; the refusal, watch and mesh checks only expose their request builders as helpers. No lowering code changes.
  • docs/experiments/translator-corpus.md has the base-to-head procedure.

Possible follow-up: a translator-corpus job in windows.yml that builds compile_dxil for the PR head and its merge base and requires identical TSVs.

Validation

Windows, MSVC, dev preset, at 2568a0d59: 8/8 tests passed.

cmake --build --preset dev --target compile_dxil
ctest --preset dev --no-tests=error -R '^(native_translator_corpus_(dxil|ir)|native_compile_dxil_(refusals|rekey|watch)|native_direct_mesh|native_rtv_variant_controls|startup_compute_translate_requests)$' --output-on-failure

Comparing two builds:

$sdk = (Get-Content out/build/dev/x2w-dxc-dir.txt -Raw).Trim()
python -B tests/translator_corpus_hash.py $baseCompiler $sdk --out out/translator-base.tsv
python -B tests/translator_corpus_hash.py $headCompiler $sdk --out out/translator-head.tsv
git diff --no-index --exit-code -- out/translator-base.tsv out/translator-head.tsv

Fixtures are generated from the synthetic instruction words already in the repository's tests.

R0Y00 commented Dec 2, 2026

Copy link
Copy Markdown
Owner

The reviewed head passed Windows and Linux CI, but GitHub reports a merge conflict against current main. Please rebase compile_dxil.cpp while preserving #3794's MSVC warning handling, and rerun the batch, refusal and IR-dump tests on the rebased head.

@Leyukaka
Leyukaka force-pushed the quality/translator-corpus-hash branch from 2568a0d to 13625d2 Compare December 2, 2026 04:12
@Leyukaka

Leyukaka commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased onto main (0dd65da) after #3794 merged. The only conflict was in tools/startup/compile_dxil.cpp, where the IR dump option now sits after the #pragma warning(suppress: 4996) that #3794 added. The CTest selection from the description passes again with MSVC on the new head.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for the rebase. I confirmed the MSVC warning suppression still surrounds the legacy environment lookup and the explicit dump path is reserved alongside the output paths. On Windows Debug at 13625d24, the eight tests selected by ctest --preset dev --no-tests=error -j 2 -R '^(native_translator_corpus_(dxil|ir)|native_compile_dxil_(refusals|rekey|watch)|native_direct_mesh|native_rtv_variant_controls|startup_compute_translate_requests)$' --output-on-failure passed.

@R0Y00
R0Y00 merged commit 20def93 into R0Y00:main Dec 2, 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.

2 participants