Skip to content

buffer_format_fuzz: an unknown --formats is a usage error before the GPU oracle (EGEN-BUFFMT-EXPLICIT-FIRST) - #6310

Open
evilclanker9000 wants to merge 2 commits into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/10-buffmt-formats-first
Open

evilclanker9000 wants to merge 2 commits into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/10-buffmt-formats-first

Conversation

@evilclanker9000

Copy link
Copy Markdown
Contributor

What and why

tools/buffer_format_fuzz.py parsed an explicit --formats only after runner.open_oracle(). A typo therefore never reached the user as a usage error:

  • on a machine without the hardware oracle the tool answered hardware oracle unavailable: ... and exited 77, never naming the bad token;
  • with an oracle it raised SystemExit from select_formats, exit 1.

An explicit --formats needs no GPU to be parsed (select_formats only uses family for the default list), so this parses it up front: select_formats raises ValueError and main reports it through ap.error — exit 2, before any oracle work. A valid list still reaches the oracle unchanged, and the module docstring's exit-code line now says usage error as well.

Task: EGEN-BUFFMT-EXPLICIT-FIRST.

Tested

New test tests/test_buffer_format_fuzz_cli.py (CPU only, no GPU):

python -I tests/test_buffer_format_fuzz_cli.py -v
  • Before (561b65a8, tool file taken from upstream/main, same test file):
FAIL: test_unknown_format_is_a_usage_error_before_the_oracle
AssertionError: 77 != 2 : hardware oracle unavailable: no AMD clang ...
FAIL: test_a_code_outside_the_table_is_refused_too
AssertionError: 77 != 2
ERROR: test_known_names_and_codes_map_to_the_table  (select_formats raised SystemExit, not ValueError)
Ran 3 tests - FAILED (failures=2, errors=1)
  • After (this branch):
test_a_code_outside_the_table_is_refused_too ... ok
test_known_names_and_codes_map_to_the_table ... ok
test_unknown_format_is_a_usage_error_before_the_oracle ... ok
Ran 3 tests in 0.338s - OK

CLI, this branch:

$ python -I tools/buffer_format_fuzz.py --oracle hw --formats 8_8_8_8_UNORM_typo
buffer_format_fuzz.py: error: unknown format '8_8_8_8_UNORM_typo'; give a GFX10 code (1..77) or name such as 8_8_8_8_UNORM   (exit 2)
$ python -I tools/buffer_format_fuzz.py --oracle hw --formats 8_8_8_8_UNORM
hardware oracle unavailable: no AMD clang ...   (exit 77, unchanged)
$ python -I tools/buffer_format_fuzz.py --self-test
self-test: ok   (exit 0)

python -m compileall -q tools/buffer_format_fuzz.py tests/test_buffer_format_fuzz_cli.py passes.

No GPU was used for this change and none is needed: the fix moves a check that never needed hardware. (The oracle on this machine reports no AMD clang; I did not run the fuzz itself.)

Notes

  • Two commits: the tool, then the test. The select_formats exception type changed with the tool commit, so the helper test belongs with it.
  • The parsed list is kept in a local (explicit) and reused after the oracle opens, so a valid --formats is parsed once and the default list is still built from the family the oracle reports.
  • Checked against the open pull requests and the claim registry before claiming: no other PR touches tools/buffer_format_fuzz.py.

AI-assisted.

… opens

A typo in --formats was found only after runner.open_oracle(): without the oracle the tool answered 'hardware oracle unavailable' (77) and never named the bad token, and with one select_formats raised SystemExit (1). It is now a usage error (2) before the oracle: select_formats raises ValueError and main reports it through ap.error.
Fails on 561b65a (77 != 2: the typo is masked by 'hardware oracle unavailable', and select_formats raises SystemExit instead of ValueError) and passes with the fix; no GPU.
@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested fa88474 on Windows with CPython 3.14.7, CPU only: pass.

All three tests passed with py -3.14 -I tests/test_buffer_format_fuzz_cli.py. The CLI returned usage status 2 for an unknown name and for code 0 in a mixed list. The same three tests failed against merge base 561b65a. The tool's --self-test also passed on the head.

I checked each of the 77 table entries as an explicit numeric code and as a name. Both forms selected the same entry for each family argument (gfx10 and gfx11). This checks format selection only. I did not submit GPU work.

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.

2 participants