Skip to content

tests: stop the installer constraint test counting occurrences - #7503

Merged
danielhanchen merged 1 commit into
mainfrom
fix/torch-constraint-test-counts
Jul 27, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix/torch-constraint-test-counts

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

tests/sh/test_torch_constraint.sh asserts how many times each pin literal appears in install.sh. Every hardware branch assigns its own torch / torchvision / torchaudio triple, so #7354 adding the gfx906 branch pushed three of those counts up by one, and the Backend CI "Shell installer tests" step has been failing on main since:

FAIL: default TORCH_CONSTRAINT assignment exists (expected '1', got '2')
FAIL: hardcoded torch>=2.4 appears exactly once (expected '1', got '2')
FAIL: torchvision bounded (<0.26) at default + custom-leaf (expected '2', got '3')
FAIL: torchaudio bounded (<2.11) at default + custom-leaf (expected '2', got '3')

Every expectation is off by exactly one, which is the three lines #7354 added:

+            TORCH_CONSTRAINT="torch>=2.4,<2.11.0"
+            TORCHVISION_CONSTRAINT="torchvision>=0.19,<0.26.0"
+            TORCHAUDIO_CONSTRAINT="torchaudio>=2.4,<2.11.0"

install.sh is right; the numbers were the stale part. Rather than bump them to 2 and 3 and have the next hardware branch break the file again, this asserts the invariants the counts were standing in for.

What changed

  • Default assignment. The default is the one assigned at top level, and a branch's is always indented, so the grep is anchored at column 0 instead of counting occurrences. This is stronger than before: with the old count, deleting the top-level default while a branch kept the same literal still passed.
  • "Hardcoded torch>=2.4 appears exactly once". What that was guarding is that no uv pip install line spells a pin out instead of using "$TORCH_CONSTRAINT", since a literal there ignores whatever the branch above it chose. Checked directly now, because the premise that the literal can only appear once is no longer true.
  • Companion bounds. Compares bounded assignments against total assignments rather than pinning a count of 2. torchaudio 2.11 dropped its exact torch pin, so a bare companion next to a <2.11-capped torch resolves a mismatched 2.11 build, and that has to hold for every assignment. It now covers all 7 rather than the 2 the old numbers happened to name.

Testing

bash tests/sh/test_torch_constraint.sh goes from 41 pass / 4 fail to 45 pass / 0 fail.

Each new assertion was checked by breaking the property it guards and confirming it reddens:

mutation assertion that fails
make one torchvision companion bare every torchvision constraint is upper-bounded
drop the upper bound from one torchaudio companion every torchaudio constraint is upper-bounded
put a literal "torch>=2.4,<2.11.0" on a pip install line no pip install hardcodes a torch pin
remove the top-level default assignment default TORCH_CONSTRAINT assignment exists

The whole tests/sh suite was run against this branch and against main: the only difference is test_torch_constraint.sh going green. test_install_host_defaults.sh fails on both, and the Backend CI workflow skips it deliberately.

test_torch_constraint.sh asserted how many times each pin appears in install.sh.
Every hardware branch assigns its own torch/torchvision/torchaudio triple, so
#7354 adding gfx906 pushed three of those counts up by one and Backend CI has
been red on main since:

  FAIL: default TORCH_CONSTRAINT assignment exists (expected '1', got '2')
  FAIL: hardcoded torch>=2.4 appears exactly once (expected '1', got '2')
  FAIL: torchvision bounded (<0.26) at default + custom-leaf (expected '2', got '3')
  FAIL: torchaudio bounded (<2.11) at default + custom-leaf (expected '2', got '3')

install.sh is correct; the numbers were the stale part. Assert the invariants
instead, so the next hardware branch is not a test edit:

- the default assignment is the top-level one, so anchor the grep at column 0
  rather than counting every occurrence. An indented branch pin no longer
  satisfies it, which the old count did not distinguish either.
- what "appears exactly once" really guarded is that no pip install line spells
  a pin out instead of using "$TORCH_CONSTRAINT", so check that directly.
- companions must be bounded everywhere, so compare bounded assignments against
  total assignments rather than pinning a count of 2. That is strictly stronger:
  it now covers all 7, not the 2 the old numbers happened to name.

45 pass, 0 fail. Each new assertion fails when its property is broken: a bare or
unbounded companion, a hardcoded pin on an install line, or a missing top-level
default.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@danielhanchen
danielhanchen merged commit 4b3809a into main Jul 27, 2026
15 checks passed
@danielhanchen
danielhanchen deleted the fix/torch-constraint-test-counts branch July 27, 2026 13:42
danielhanchen added a commit that referenced this pull request Jul 27, 2026
Picks up #7503, which unbreaks the Backend CI shell installer tests. No conflicts.
danielhanchen added a commit that referenced this pull request Jul 27, 2026
Resolve tests/sh/test_torch_constraint.sh by keeping main's invariant
based structure from #7503 and restating it against this branch's
composed ceiling variables.

Both sides rewrote the same assertions in the same spirit. #7503
replaced brittle occurrence counts with invariants after #7354's gfx906
branch pushed three counts up by one and left Backend CI red. This
branch had independently rewritten them because the default torch range
is no longer a literal, it is composed from _TORCH_CEILING="2.12.0".

The resolution keeps both:

- The column 0 anchor for the default assignment now reads the composed
  form TORCH_CONSTRAINT="torch>=2.4,<${_TORCH_CEILING}", so an indented
  per branch pin still cannot satisfy it. _TORCH_CEILING="2.12.0" is
  asserted separately so the anchor keeps its teeth.
- The tightened macOS py3.13 assignment is an existence check rather
  than a count, per #7503.
- Both stray literal checks are kept. They are complementary: #7503's
  sees through shell escaped quotes on an install or echoed command
  line, this branch's catches the two default ranges copied onto any
  assignment that is not TORCH_CONSTRAINT=.
- The gfx906 sub 2.11 cap assertion is kept, converted from a count to
  an indented existence check so a second hardware branch adding its own
  sub 2.11 cap is not a test edit.
- #7503's every assignment upper bound checks for torchvision and
  torchaudio are kept, widened to accept the composed ceiling alongside
  a literal bound.

install.sh, install.ps1, studio/setup.ps1 and studio/install_python_stack.py
are untouched by this merge. The gfx906 literal cap and the three ROCm
2.11 floors stay literal, and the test permits them without forcing them
to track the ceiling.

tests/sh/test_torch_constraint.sh: 49 pass, 0 fail.
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.

1 participant