Scripts: reject non-RDNA2 decoder table inputs #2602

Open
JiyouProt wants to merge 1 commit from upstream-pr/2612 into main
JiyouProt commented 2026-11-26 01:55:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JiyouProt on 2026-11-26T01:55:37Z.


gen_rdna2.py accepts AMD's public RDNA1 XML and replaces the requested RDNA2 decoder table successfully: 1,149 instructions instead of 1,153. Check ISA/Architecture/ArchitectureName before parsing tables or opening the output. Wrong or missing architecture exits with a diagnostic and preserves the destination; valid RDNA2 generation is unchanged.

What is in it

  • scripts/gen_rdna2.py: architecture guard resolved from the root, including an absent <ISA> element. This addresses review 6069236763: <Spec><Document/></Spec> now reports the missing architecture instead of an AttributeError traceback.
  • scripts/test_gen_rdna2_architecture.py: synthetic CLI regressions for wrong/missing metadata, absent ISA with existing/absent destination, and valid table generation. No vendor XML or generated source committed.
  • #1504 covers broader CLI/output and structural validation; this remains a small architecture guard.

Tested

  • Windows 11 Pro 10.0.26300, Ryzen 7 5800X, 64 GB, RTX 3080 Ti 12 GB / NVIDIA 616.92; Python 3.11.9, DXC 1.9.2609.5, portable Rust 1.100.0 Windows GNU / LLVM-MinGW 23.1.6. Session-local LLD/self-contained support libraries and -C target-feature=+fma on this FMA-capable CPU, as in the prior validation.
  • python -B -m unittest discover -s scripts -p 'test_*.py' -v: 30 passed, 0 failed. Before the review fix, both new absent-ISA subcases fail with the reported traceback; afterward both reject cleanly and preserve the destination state.
  • Public MIT AMD ISA files, release 2026-02-20: RDNA1 rejected without changing the sentinel; RDNA2 still generates 42 encodings / 21 primary / 1,153 instructions, byte-identical to the checked-in 751,032-byte table. Re-executed after the review fix.
  • Exact revised head 5efcf08de944, clean tree: cargo build --locked --workspace -j 4 and cargo test --locked --workspace --no-fail-fast -j 4 -- --test-threads=4 --show-output, both Debug and Release (--release), pass. Each test run: 1,435 passed / 0 failed / 47 ignored. Session-local XCL_DXIL_CACHE points to a writable workspace directory; caching remains enabled.
  • Each full run has 29 explicit SKIPPED lines: 21 native-wave64 cases, three unsupported per-lane f16 cases, three unavailable D3D12-debug-layer cases, one disabled opt-in heap-window case and one unavailable cold-driver-cache-control case. Harness passes include these skips and sample-dependent early returns; no XCL_SAMPLE_* files supplied.
  • Initial Debug rerun with the sandbox's default LOCALAPPDATA cache: 1,434 passed / 1 failed / 47 ignored (console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk, cached-only miss). It also failed alone; setting the documented cache path to a writable workspace directory made the isolated test and both full suites pass. No source/assertion changes to that test; initial failure retained in the report.
  • Changed-file git diff --check and PR-description checks pass.

Regression run

  • Generator/tests only; no runtime/build-input change or generated table change.

Not tested

  • No retail shader sweeps/titles, MSVC, AMD/WARP parity, native wave64, D3D12 debug layer or controlled cold driver-cache run. No game data, system/driver setting change or GPU performance claim.
  • The guard checks architecture metadata, not the complete XML schema. Upstream CI approval is still required; local results are not an upstream CI pass.

AI use

  • OpenAI Codex (GPT-6; exact model variant unavailable) investigated, implemented and reviewed the fix and review follow-up, ran the reported tests, and prepared this description. Publication authorized by the user.
<!-- greyfinch-sync:ivall/xcl:issue:5502551960 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2612). Originally posted by [JiyouProt](https://github.com/JiyouProt) on 2026-11-26T01:55:37Z. --- `gen_rdna2.py` accepts AMD's public RDNA1 XML and replaces the requested RDNA2 decoder table successfully: 1,149 instructions instead of 1,153. Check `ISA/Architecture/ArchitectureName` before parsing tables or opening the output. Wrong or missing architecture exits with a diagnostic and preserves the destination; valid RDNA2 generation is unchanged. **What is in it** - `scripts/gen_rdna2.py`: architecture guard resolved from the root, including an absent `<ISA>` element. This addresses [review 6069236763](https://github.com/xcl-dev/xcl/pull/2612#pullrequestreview-6069236763): `<Spec><Document/></Spec>` now reports the missing architecture instead of an AttributeError traceback. - `scripts/test_gen_rdna2_architecture.py`: synthetic CLI regressions for wrong/missing metadata, absent ISA with existing/absent destination, and valid table generation. No vendor XML or generated source committed. - #1504 covers broader CLI/output and structural validation; this remains a small architecture guard. **Tested** - Windows 11 Pro 10.0.26300, Ryzen 7 5800X, 64 GB, RTX 3080 Ti 12 GB / NVIDIA 616.92; Python 3.11.9, DXC 1.9.2609.5, portable Rust 1.100.0 Windows GNU / LLVM-MinGW 23.1.6. Session-local LLD/self-contained support libraries and `-C target-feature=+fma` on this FMA-capable CPU, as in the prior validation. - `python -B -m unittest discover -s scripts -p 'test_*.py' -v`: **30 passed, 0 failed**. Before the review fix, both new absent-ISA subcases fail with the reported traceback; afterward both reject cleanly and preserve the destination state. - [Public MIT AMD ISA files](https://gpuopen.com/machine-readable-isa/), release 2026-02-20: RDNA1 rejected without changing the sentinel; RDNA2 still generates **42 encodings / 21 primary / 1,153 instructions**, byte-identical to the checked-in **751,032-byte** table. Re-executed after the review fix. - Exact revised head `5efcf08de944`, clean tree: `cargo build --locked --workspace -j 4` and `cargo test --locked --workspace --no-fail-fast -j 4 -- --test-threads=4 --show-output`, both Debug and Release (`--release`), pass. Each test run: **1,435 passed / 0 failed / 47 ignored**. Session-local `XCL_DXIL_CACHE` points to a writable workspace directory; caching remains enabled. - Each full run has **29 explicit SKIPPED lines**: 21 native-wave64 cases, three unsupported per-lane f16 cases, three unavailable D3D12-debug-layer cases, one disabled opt-in heap-window case and one unavailable cold-driver-cache-control case. Harness passes include these skips and sample-dependent early returns; no `XCL_SAMPLE_*` files supplied. - Initial Debug rerun with the sandbox's default LOCALAPPDATA cache: 1,434 passed / 1 failed / 47 ignored (`console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk`, cached-only miss). It also failed alone; setting the documented cache path to a writable workspace directory made the isolated test and both full suites pass. No source/assertion changes to that test; initial failure retained in the report. - Changed-file `git diff --check` and PR-description checks pass. **Regression run** - Generator/tests only; no runtime/build-input change or generated table change. **Not tested** - No retail shader sweeps/titles, MSVC, AMD/WARP parity, native wave64, D3D12 debug layer or controlled cold driver-cache run. No game data, system/driver setting change or GPU performance claim. - The guard checks architecture metadata, not the complete XML schema. Upstream CI approval is still required; local results are not an upstream CI pass. **AI use** - OpenAI Codex (GPT-6; exact model variant unavailable) investigated, implemented and reviewed the fix and review follow-up, ran the reported tests, and prepared this description. Publication authorized by the user.
RavenCurseBurg commented 2026-11-26 02:08:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by RavenCurseBurg on 2026-11-26T02:06:18Z.


Tested exact head 3399fd80d1ae07334c15252dea557bddc66286cf and parent b49be1836844 with an independent synthetic XML. The opcode has two disjoint ranges, listed in reverse XML order, and two identifiers that differ only in opcode bits. I saved it as UTF-8, UTF-8 with BOM, UTF-16LE and UTF-16BE.

  • RDNA2 produced byte-identical 691-byte Rust tables for all four inputs on both revisions. I checked the emitted range order [(4, 2), (10, 2)], fixed mask/value 0xf3c0/0x8140, opcode 6 and the instruction flag. SHA-256: cc174b56e226c8b1251518f701a0fa080bcd2799b1be00db95ed106b2ba21eca.
  • With the same fixture marked RDNA1, the parent replaced the output in all four runs. This head exited 1, named both architectures and preserved the previous output bytes in all four.
  • #1504 at 3608a7aa744b produced the same RDNA2 table from UTF-8 but rejected both valid UTF-16 variants. For a future combination, the guard ported onto the encoding-aware #1504 branch passes all eight cases and retains this PR's architecture tests.

Commands: python -I scripts/gen_rdna2.py <fixture.xml> <table.rs> and python -B -m unittest discover -s scripts -p "test_*.py". The complete Python suite passed 29 tests on this PR and 31 on the combined candidate, with zero failures or skips. Windows build 26100, i7-13700, Python 3.14.3. OpenAI Codex (GPT-6) prepared the fixture, ran the checks and ported the guard. No full AMD XML, Rust build, GPU or title run in this test.

Recheck after the update

I rechecked the revised head 5efcf08de944402eafb2ca1ffaa3998fa2e2de09. For <Spec><Document/></Spec>, the CLI exited 1 without a traceback both with and without an existing destination. It preserved the existing sentinel and did not create a missing file. The previous head printed a traceback in both cases. The earlier combined fork 98f2b0b also rejected these inputs cleanly via its existing structural check.

On all three revisions, the same small valid RDNA2 fixture encoded as UTF-8 and UTF-16 generated identical Rust bytes. I ran python -B -m unittest discover -s scripts -p "test_*.py" on the revised head: all 30 tests passed. These checks used synthetic XML only.

OpenAI Codex (GPT-6) ran the checks and prepared this update. No game or GPU workload.

<!-- greyfinch-sync:ivall/xcl:comment:7180463168 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2612#issuecomment-7180463168). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-26T02:06:18Z. --- Tested exact head `3399fd80d1ae07334c15252dea557bddc66286cf` and parent `b49be1836844` with an independent synthetic XML. The opcode has two disjoint ranges, listed in reverse XML order, and two identifiers that differ only in opcode bits. I saved it as UTF-8, UTF-8 with BOM, UTF-16LE and UTF-16BE. - RDNA2 produced byte-identical 691-byte Rust tables for all four inputs on both revisions. I checked the emitted range order `[(4, 2), (10, 2)]`, fixed mask/value `0xf3c0/0x8140`, opcode 6 and the instruction flag. SHA-256: `cc174b56e226c8b1251518f701a0fa080bcd2799b1be00db95ed106b2ba21eca`. - With the same fixture marked RDNA1, the parent replaced the output in all four runs. This head exited 1, named both architectures and preserved the previous output bytes in all four. - #1504 at `3608a7aa744b` produced the same RDNA2 table from UTF-8 but rejected both valid UTF-16 variants. For a future combination, [the guard ported onto the encoding-aware #1504 branch](https://github.com/RavenCurseBurg/xcl/commit/98f2b0b27c13f2b639a9628fe2954a897f6b059a) passes all eight cases and retains this PR's architecture tests. Commands: `python -I scripts/gen_rdna2.py <fixture.xml> <table.rs>` and `python -B -m unittest discover -s scripts -p "test_*.py"`. The complete Python suite passed 29 tests on this PR and 31 on the combined candidate, with zero failures or skips. Windows build 26100, i7-13700, Python 3.14.3. OpenAI Codex (GPT-6) prepared the fixture, ran the checks and ported the guard. No full AMD XML, Rust build, GPU or title run in this test. **Recheck after the update** I rechecked the revised head `5efcf08de944402eafb2ca1ffaa3998fa2e2de09`. For `<Spec><Document/></Spec>`, the CLI exited 1 without a traceback both with and without an existing destination. It preserved the existing sentinel and did not create a missing file. The previous head printed a traceback in both cases. The earlier combined fork `98f2b0b` also rejected these inputs cleanly via its existing structural check. On all three revisions, the same small valid RDNA2 fixture encoded as UTF-8 and UTF-16 generated identical Rust bytes. I ran `python -B -m unittest discover -s scripts -p "test_*.py"` on the revised head: all 30 tests passed. These checks used synthetic XML only. OpenAI Codex (GPT-6) ran the checks and prepared this update. No game or GPU workload.
DavidM1911 commented 2026-11-26 03:06:33 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T02:31:59Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 26 ignored.

Thanks!

— Devin

<!-- greyfinch-sync:ivall/xcl:comment:7180890454 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2612#issuecomment-7180890454). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T02:31:59Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 26 ignored. Thanks! — Devin
luckyteagirl commented 2026-11-26 05:59:49 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T05:59:49Z.

Review: COMMENTED


Could the missing-architecture diagnostic also cover an absent <ISA> element? With a well-formed <Spec><Document/></Spec>, root.find("ISA") returns None and isa.findtext(...) raises an AttributeError traceback before the new SystemExit diagnostic. I confirmed the script exits 1 and preserves a pre-existing output on this exact head, but the user gets the traceback rather than the promised clean rejection. Resolving ISA/Architecture/ArchitectureName from root, plus an absent-ISA fixture, would cover it. Exact head 3399fd80d1ae07334c15252dea557bddc66286cf; synthetic XML only, no vendor regeneration. AI-assisted review with Codex.

<!-- greyfinch-sync:ivall/xcl:review:6069236763 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2612#pullrequestreview-6069236763). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-26T05:59:49Z. **Review:** COMMENTED --- Could the missing-architecture diagnostic also cover an absent `<ISA>` element? With a well-formed `<Spec><Document/></Spec>`, `root.find("ISA")` returns `None` and `isa.findtext(...)` raises an `AttributeError` traceback before the new `SystemExit` diagnostic. I confirmed the script exits 1 and preserves a pre-existing output on this exact head, but the user gets the traceback rather than the promised clean rejection. Resolving `ISA/Architecture/ArchitectureName` from `root`, plus an absent-ISA fixture, would cover it. Exact head `3399fd80d1ae07334c15252dea557bddc66286cf`; synthetic XML only, no vendor regeneration. AI-assisted review with Codex.
DavidM1911 commented 2026-11-26 09:07:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T08:29:15Z.


Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

<!-- greyfinch-sync:ivall/xcl:comment:7186652877 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2612#issuecomment-7186652877). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T08:29:15Z. --- Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
Foniass commented 2026-12-01 08:28:12 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:28:12Z.


Triage (#1607) – head 5efcf08

No open or merged PR makes gen_rdna2.py reject a non-RDNA2 spec. #1504 rewrites the same main() into generate()/CLI handling but does not check ArchitectureName. #2674 changes how instruction flags are parsed. Whichever merges second will need a small rebase.
The check runs before the output is opened, and the tests cover wrong, missing and empty architectures.
No problems found in the diff.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7305359260 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2612#issuecomment-7305359260). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T08:28:12Z. --- **Triage (#1607)** – head 5efcf08 No open or merged PR makes `gen_rdna2.py` reject a non-RDNA2 spec. #1504 rewrites the same `main()` into `generate()`/CLI handling but does not check `ArchitectureName`. #2674 changes how instruction flags are parsed. Whichever merges second will need a small rebase. The check runs before the output is opened, and the tests cover wrong, missing and empty architectures. No problems found in the diff. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2612:upstream-pr/2612'
git switch 'upstream-pr/2612'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2612'
git switch 'upstream-pr/2612'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2612'
git switch 'upstream-pr/2612'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2612'
git switch 'main'
git merge --squash 'upstream-pr/2612'
git switch 'main'
git merge --ff-only 'upstream-pr/2612'
git switch 'main'
git merge 'upstream-pr/2612'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!2602
No description provided.