Repository navigation
Give the ROCm bf16 chain test every name _gpu_init imports from device_type - #11688
Conversation
…e_type #11615 added the RDNA1 buffer-op workaround inside the _gpu_init.py block this test execs, and it calls arch_lacks_buffer_ops, which the test's hand-built namespace did not have: every hip case failed with a NameError on main. The namespace is now read from _gpu_init's own `from .device_type import (...)`, so the next name arrives by itself. apply_gfx101x_triton_workaround is recorded rather than run, since the real one writes Triton and Inductor settings into os.environ, and a new test covers #11615's gate: gfx101x only, RDNA2 excluded, off hip nothing.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0663135001
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| def _namespace(fake_torch, device_type, workarounds): | ||
| import unsloth.device_type as dt | ||
|
|
||
| namespace = {name: getattr(dt, name) for name in _device_type_imports()} |
There was a problem hiding this comment.
Support the fallback device-type stub
When tests/conftest.py cannot preload the real unsloth.device_type, its documented fallback installs a stub exposing arch_lacks_bf16 and hip_visible_archs, but not arch_lacks_buffer_ops or apply_gfx101x_triton_workaround. This comprehension calls getattr for both missing names before the workaround can be replaced, so every _run_chain case raises AttributeError in that supported CPU-test path. Extend the fallback stub or provide these overrides before performing the lookup.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 97ba83b, at both ends. The conftest stub now carries arch_lacks_buffer_ops (gfx101x only), apply_gfx101x_triton_workaround and gfx101x_triton_workaround_applied, and the namespace applies its overrides first, so it only looks up the names it does not replace. A new test reads _install_device_type_stub with ast and fails if it lacks any name _gpu_init.py imports from .device_type; dropping arch_lacks_buffer_ops from the stub fails it. (Separately, import unsloth under that stub already stops earlier, on get_device_stats, which predates this PR.)
…_init's imports
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…e_type (unslothai#11688) * Give the ROCm bf16 chain test every name _gpu_init imports from device_type unslothai#11615 added the RDNA1 buffer-op workaround inside the _gpu_init.py block this test execs, and it calls arch_lacks_buffer_ops, which the test's hand-built namespace did not have: every hip case failed with a NameError on main. The namespace is now read from _gpu_init's own `from .device_type import (...)`, so the next name arrives by itself. apply_gfx101x_triton_workaround is recorded rather than run, since the real one writes Triton and Inductor settings into os.environ, and a new test covers unslothai#11615's gate: gfx101x only, RDNA2 excluded, off hip nothing. * Give the conftest device_type stub unslothai#11615's names, and pin it to _gpu_init's imports
tests/python/test_rocm_bf16_capability.pyfails on main (e776f1c80) inRepo tests (CPU, studio). For example, #11679's staging run:Locally on main this gives 18 failed and 26 passed, all 18 with that NameError.
Cause
The test execs the block of
unsloth/_gpu_init.pyfromif DEVICE_TYPE == "cuda" and not torch.cuda.is_available():up to# For Gradio HF Spaces?, in a namespace it builds by hand. #11615 added its RDNA1 workaround inside that block:The hand-built namespace had
arch_lacks_bf16andhip_visible_archsbut not the two names #11615 imports. The product is right and the test's namespace was out of date.Change
_gpu_init.py's ownfrom .device_type import (...), read withast. A name the block starts using reaches the test without a hand edit.apply_gfx101x_triton_workaroundis recorded, not run. The real one writesAMDGCN_USE_BUFFER_OPS,TRITON_CACHE_DIRandTORCHINDUCTOR_CACHE_DIRintoos.environ, which would leak into the rest of the worker.test_the_chain_turns_triton_buffer_ops_off_only_for_a_visible_gfx101x. It applies the workaround ongfx1010, and on a mixed host withgfx1012:xnack-. It does not apply it ongfx1030(RDNA2), ongfx1100, or off hip.Verification
unsloth. On main, the same run gives the 18 NameErrors above.arch_lacks_buffer_opstogfx10, which would catch RDNA2, fails thegfx1030case._gpu_init.pyfails both gfx101x cases.