Repository navigation
amd_swizzle: validate arguments before needing numpy, and gate the tests the way the tool runs - #2671
Conversation
|
Verified by OreoFR on macOS 27.2.1, Apple M5, Python 3.12.16, main 40e7fe6, PR head b713c15. MEASURED, both with numpy (venv, pytest) and without it (Homebrew
So there is no red with numpy, and without numpy this PR turns an OK run into errors. The errors are Those two cases get past every argument/file check and reach the computation, so with numpy absent they hit Merges cleanly with main and with #2566. AI-assisted: Claude Code |
|
I confirmed the stdlib failure from OreoFR’s macOS run on CachyOS with Python 3.14.10. I also tested with NumPy and Pillow installed in the user site. The test process can import both, while its
Base |
|
Rebased onto current
Verified after the rebase, on this branch: The six skips are the numpy-dependent cases this machine cannot run ( Written with an AI assistant. |
|
You are right, and it is a regression I introduced: making the import late also made "the import succeeded" stop meaning "numpy is here". Applied as For the record, the mechanism in my own words so it stays visible: try:
import amd_swizzle as A
HAVE_NUMPY = True
except ModuleNotFoundError as e:
...and after the lazy import that Your follow-up ( That is this machine's user-site configuration, which is the case the PR is about; your matrix (both visible, both user-site-only, Pillow user-site-only, both absent) is the evidence I do not have and could not produce here, and the four direct guard checks passing with the follow-up is the part that matters most. Two things I will fix in the body rather than pretend were covered:
Thank you for reproducing OreoFR's macOS report instead of taking my word for it - a reviewer who runs the matrix is worth more than one who reads the diff. Written with an AI assistant. |
|
Re-check by OreoFR on the new head b0013cd, same Mac (macOS 27.2.1, Apple M5, Python 3.12.16), main 1d22590. MEASURED:
AI-assisted: Claude Code |
|
Re-check by OreoFR on head c7133a8 ("exercise amd_swizzle guards with isolated dependencies"), same Mac, main 1d22590. MEASURED:
AI-assisted: Claude Code |
|
Thank you - and the conflict you found is not what I would have guessed. I diffed the two sides: #2566 carries a different implementation of the same interp fix, not the same edit.
So "resolve by taking either side" is wrong here: it is a choice between two oracles, and only one of them can be the one that ends up describing SHADER-468 in What the commit in this branch is, precisely: On the rest of your re-check: thank you for the no-numpy case. Written with an AI assistant. |
|
Correction to what I wrote above: I diffed the wrong thing. It is one change, not two. I compared the two files at their own branch heads and read "504 of 566 lines differ" as two implementations. Those files come from different bases, so most of that was drift. Compared properly - the added lines of each patch, and the file So your report was right and my escalation of it was wrong: the conflict is the same edit on both sides, and taking either resolves it. The duplicate is still real - whichever of #2633 / #2566 lands first, the other's copy is dropped - and the copy in this branch is exactly Thank you for finding the conflict; the part I got wrong after that was mine, not yours. Written with an AI assistant. |
|
Update by OreoFR: the conflict with #2566 I reported here is gone. AI-assisted: Claude Code |
…tion Two things kept this test file red on a machine where numpy came from pip install --user: - the tool imported numpy at module level, so a bad --width reported "needs numpy" instead of "must be at least 1". numpy is imported late now and only the computation requires it; - the skip gate asked whether numpy imports *here*, while the tests run the tool with -I, which hides the user site. It now probes the way the tool runs. Measured on main b8bd371, Windows, Python 3.13: 9 failed, 8 passed, 3 skipped before; 14 passed, 6 skipped after. On a machine where -I sees numpy, the probe returns true and the three gated cases run exactly as before. Written with an AI assistant.
AI-assisted with OpenAI Codex.
c7133a8 to
aec457e
Compare
|
Re-verified after the rebase onto What I did not test: the rest of the change, and anything the rebase did not touch. This confirms the rebase kept the change working, not that the change is correct - that is what the review and the CI are for. Written with an AI assistant. |
|
VERIFY-2671 — PASS
|
|
Independent check on Windows (not the author), at
Environment: Windows 11 Pro 10.0.26200.9711, Python 3.12.10. AI-assisted: yes (opencode). |
aslan2142
left a comment
There was a problem hiding this comment.
Reviewed head diff against main: tools/amd_swizzle.py cleanly defers the missing-numpy exit via _require_numpy() until after CLI argument and header validation, and tests/test_amd_swizzle.py properly gates subprocess tests on python -I visibility of numpy/Pillow. Clean-room verified and all CI checks green.
(AI-assisted review.)
Two independent reasons
tests/test_amd_swizzle.pyis red on a machine where numpy came frompip install --user, and both are the test asking the wrong question.1. The tool imported numpy before it validated anything
tools/amd_swizzle.pyhadimport numpy as npat module level, so with numpy invisible to the process every run died before argument checking:numpy is now imported late and
_require_numpy()is called after the argument, file and header checks - the checks that never needed it. The computation still demands it and still says so, with the same message.2. The skip gate asked the wrong process
but the tests it gates run the tool as
sys.executable -I …, and-Iimplies-s, which hides the user site. So the gate opens and the child dies. It now asks the tool's question:and the five cases that need a real run (the detile, the no-pattern report, the successful run and the two previews) are gated on it. The in-process
needs_numpygate stays for the module-level tests - two questions, two probes.Measured
mainb8bd37111, Windows 11, Python 3.13.14, where numpy is in the user site:and on a machine where
-Ican see numpy - CI -_numpy_visible_to_the_tool()returns true, so the gated cases run as before.A correction, because an earlier version of this description overstated it and the thread caught it: making the import late also made
import amd_swizzlesucceed withA.np is None, so the test file'stry: import amd_swizzle; HAVE_NUMPY = Trueno longer established that numpy was present - two module-level cases that compute with numpy then ran and failed. merzleckeier found it (READ IN CODE) and sent a test-only follow-up, applied here as its own commit (aec457e1d, theirs) on top of mine (34046550a) so the history says whose fix it is. The gated CLI cases were unaffected; the ungated ones were the regression.What this does not do
It does not make the tool work without numpy, and it should not: the computation is numpy. It makes the errors reachable and the skip honest.
tests/test_tile_probe.pyhas the same symptom (5 failures, "needs numpy" from the child) and no gate at all; it needs the same treatment and I did not touch it here.The extra commit at the tip (no longer carried)
The branch used to carry
a3b5ebea1(test(semantic): align computed-I/J f16 interp oracle…), added only becausesemantic-testswas red onmainfor that oracle and every branch cut frommaininherited it.mainnow has the same edit asc717967d0, so a rebase drops the commit and this pull request no longer touchestests/semantic/test_interp_computed_ij_fallback.py- the diff is only what this change actually needs.AI-assisted: yes - DeepSeek v4.1 (flash) as the coding agent, with a separate reviewer agent reading the change before submission. Where and on what: the measurements above were taken on Windows 11 with MSVC 19.44.35226 on an RTX 4090 (NVIDIA driver 621.24) where a C++ or GPU path is involved; Python and docs cases need none of it.
Written with an AI assistant.