Exercise the CUDA comparability warning - #17
Merged
Merged
Conversation
README and CONTRIBUTING both promise that a CUDA run prints a warning that its numbers are not bit-comparable with CPU runs. The line existed in `train` and no test had ever executed it. A promise nothing exercises is a promise nobody has checked. No GPU is needed and none is wanted. torch.cuda.is_available is pinned True so resolve_device and describe_environment run for real and produce a genuine cuda stamp, and train_baseline is replaced so nothing reaches for a CUDA context this machine does not have -- mocking availability is not the same as having a device, and manual_seed_all and Adam would find that out. What is under test is the CLI branch that reads result.environment["device"], which is what decides whether a CUDA user is told anything at all. Both halves of the branch are covered. A warning printed unconditionally would satisfy the positive test while telling every CPU user their numbers are not comparable, so the CPU case asserts the warning is absent. Mutations run, each red on the test that should catch it: deleting the warning fails the CUDA test; printing it unconditionally fails the CPU test; ignoring --device and always passing cpu fails the CUDA test. The assertions compare with all whitespace removed. rich wraps at a console width this test cannot set, and it strips the space it wrapped on, which turns "Do not mix" into "Do notmix" -- measured while writing this, not assumed. `_flat` alone was not enough.
emrefbulut
added a commit
that referenced
this pull request
Sep 14, 2026
The stacked PRs #18, #19 and #20 were merged at the same moment, so only #18 reached main -- #19 merged into fix/gate-semantics-and-provenance and #20 into docs/refresh, their own bases. Everything from those two is therefore sitting on this branch and main is still on 0.4.0. That was my mistake in stacking three deep instead of retargeting; this merge is the fix. One conflict, in CHANGELOG.md. main carried the entry describing docs/release-notes/v0.5.0.md as an unpublished draft, which commit 6491f27 on this branch had already rewritten into "the four places that carry a version agree again" -- the draft label was the state this release ends. Kept this branch's side, which also carries three entries main does not have. Checked rather than assumed, because a merge across branches that both edited the test files could silently drop one side: #17's CUDA comparability tests and #16's forced-measurement width test are both present afterwards, and the suite goes from 385 to 388 passing, which is main's three additions arriving rather than anything being lost. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Two tests covering the CUDA comparability warning in
iqforge train, which no test had ever executed.Why
README.mdandCONTRIBUTING.mdboth promise it:The line exists (
src/iqforge/cli.py:1055) and nothing ran it. It is the only thing that tells a CUDA user their numbers cannot be placed next to a CPU table, and a promise nothing exercises is a promise nobody has checked.How it was verified
No GPU needed, and none wanted.
torch.cuda.is_availableis pinnedTruesoresolve_device("cuda")anddescribe_environmentrun for real and produce a genuinecudastamp;train_baselineis replaced so nothing reaches for a CUDA context this machine does not have. Mocking availability is not the same as having a device —manual_seed_alland Adam would find that out, which is why the existingtest_models.pytests stop at placement too.What is under test is the CLI branch reading
result.environment["device"]— the line that decides whether a CUDA user is told anything.Both halves of the branch are covered. A warning printed unconditionally would satisfy the positive test while telling every CPU user their numbers are not comparable, so the CPU case asserts its absence.
Mutations, each red on the right test:
if False:)test_a_cuda_run_warns_that_its_numbers_are_not_comparableif True:)test_a_cpu_run_prints_no_comparability_warning--device, always passcputest_a_cuda_run_warns_that_its_numbers_are_not_comparableOne measurement worth recording. The assertions compare with all whitespace removed.
richwraps at a console width this test cannot set, and it strips the space it wrapped on — which turns"Do not mix"into"Do notmix". The existing_flathelper drops newlines but does not restore that space. Found by the assertion failing, not predicted.Noticed, not fixed here
Two gaps in the same feature, both out of scope for a test-only PR:
measure-leakage --device cudaprints no such warning. Onlytrainhas it. A CUDA leakage measurement emitsenvironment: device cuda | ...and nothing else — and that command is the one whose output gets pasted into a table.if result.test_accuracy is None: return), so a CUDA run with an empty test split trains on the GPU and exits without warning.Conventions it touches