From eab81f2f2c9297026ae66fdbdb0492df21624443 Mon Sep 17 00:00:00 2001 From: seongwoo Date: Mon, 10 Aug 2026 15:56:31 +0900 Subject: [PATCH 1/3] Refactor CI and torch version policy This commit refacotrs the CI and torh version policy. TICO-DCO-1.0-Signed-off-by: seongwoo --- .github/actions/setup-tico-test/action.yml | 73 ++++ .github/workflows/check-pr.yaml | 170 ++++---- .../check-pytorch-compatibility.yaml | 118 ++++++ .github/workflows/check-workflows.yaml | 1 + .../workflows/publish-official-package.yaml | 104 +++-- README.md | 6 +- docs/README.md | 3 + docs/development.md | 61 ++- docs/getting_started.md | 17 +- docs/requirements.md | 37 +- docs/system_test.md | 62 +-- docs/torch_version_policy.md | 102 +++++ infra/scripts/install.sh | 67 ++- infra/scripts/pytorch_package_utils.sh | 115 ++++-- infra/scripts/test_configure.sh | 131 ++++-- .../utils/test_torch_version_policy.py | 168 ++++++++ tico/__init__.py | 41 +- tico/utils/compat/torch_version_policy.py | 380 ++++++++++++++++++ 18 files changed, 1407 insertions(+), 249 deletions(-) create mode 100644 .github/actions/setup-tico-test/action.yml create mode 100644 .github/workflows/check-pytorch-compatibility.yaml create mode 100644 docs/torch_version_policy.md create mode 100644 test/unit_test/utils/test_torch_version_policy.py create mode 100644 tico/utils/compat/torch_version_policy.py diff --git a/.github/actions/setup-tico-test/action.yml b/.github/actions/setup-tico-test/action.yml new file mode 100644 index 000000000..1443b3f78 --- /dev/null +++ b/.github/actions/setup-tico-test/action.yml @@ -0,0 +1,73 @@ +name: Setup TICO test environment +description: Install ONE, a selected PyTorch channel, TICO, and test dependencies + +inputs: + torch-version: + description: PyTorch family, nightly, or nightly-latest + required: true + one-version: + description: ONE compiler release used by tests + required: false + default: 1.30.1 + +runs: + using: composite + steps: + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Resolve ONE package name + id: one + shell: bash + env: + ONE_VERSION: ${{ inputs.one-version }} + run: | + CODENAME="$(lsb_release -cs)" + echo "filename=one-compiler-${CODENAME}_${ONE_VERSION}_amd64.deb" >> "$GITHUB_OUTPUT" + + - name: Download ONE compiler + shell: bash + working-directory: ./.github/actions/download-release-asset + env: + ONE_VERSION: ${{ inputs.one-version }} + ONE_PACKAGE: ${{ steps.one.outputs.filename }} + run: | + chmod +x entrypoint.sh + ./entrypoint.sh Samsung ONE "$ONE_VERSION" "$ONE_PACKAGE" + + - name: Install ONE compiler + shell: bash + working-directory: ./.github/actions/download-release-asset + env: + ONE_PACKAGE: ${{ steps.one.outputs.filename }} + run: | + sudo dpkg -i "$ONE_PACKAGE" || sudo apt-get install -f -y + onecc --version + + - name: Trust the checkout for versioningit + shell: bash + run: git config --global --add safe.directory '*' + + - name: Install TICO and configure tests + shell: bash + env: + TORCH_VERSION: ${{ inputs.torch-version }} + run: | + ./ccex install --dist --torch_ver "$TORCH_VERSION" --cpu_only + pt2-to-circle -h + ./ccex configure test --torch_ver "$TORCH_VERSION" --cpu_only + + - name: Show installed package versions + shell: bash + run: | + python3 - <<'PY' + import torch + import torchvision + import tico + + print(f"torch={torch.__version__}") + print(f"torchvision={torchvision.__version__}") + print(f"tico={tico.__version__}") + PY diff --git a/.github/workflows/check-pr.yaml b/.github/workflows/check-pr.yaml index a58f30667..e1941cf64 100644 --- a/.github/workflows/check-pr.yaml +++ b/.github/workflows/check-pr.yaml @@ -6,6 +6,13 @@ on: - main - rel/* +permissions: + contents: read + +concurrency: + group: check-pr-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: check-commit-message: name: Check commit message @@ -16,18 +23,15 @@ jobs: steps: - uses: actions/checkout@v4 with: - # Checkout PR head commit - # Checkout Action use merge commit as default + # Checkout PR head commit. The default is the synthetic merge commit. ref: ${{ github.event.pull_request.head.sha }} - # Fetch all history and branch (default: 1) fetch-depth: 0 - - name: "Check signed-off" + + - name: Check signed-off run: | - # Get commit body git log origin/"$GITHUB_BASE_REF"..HEAD --format=%b > commit_msg.txt sed "/^$/d" commit_msg.txt > commit_body.txt - # Check string starting from "TICO-DCO-1.0-Signed-off-by:" count="$(grep -c "TICO-DCO-1.0-Signed-off-by:" commit_body.txt)" if [[ ! "$count" -ge "1" ]]; then echo "Your commit message does not contain the expected signoff information." @@ -38,97 +42,119 @@ jobs: echo "TICO-DCO-1.0-Signed-off-by is OK" - check-style: + name: Check style runs-on: ubuntu-24.04 + steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: '3.12' - - name: "Run configure" - run: | - ./ccex configure format + - name: Run configure + run: ./ccex configure format + + - name: Run linters + run: ./ccex format --no-apply-patches + + resolve_torch_policy: + name: Resolve PyTorch policy + runs-on: ubuntu-24.04 + outputs: + default_family: ${{ steps.policy.outputs.default_family }} + pr_smoke_matrix: ${{ steps.policy.outputs.pr_smoke_matrix }} + + steps: + - uses: actions/checkout@v4 - - name: "Run linters" + - name: Read central policy + id: policy run: | - ./ccex format --no-apply-patches + POLICY=tico/utils/compat/torch_version_policy.py + python3 "$POLICY" validate + echo "default_family=$(python3 "$POLICY" default-family)" >> "$GITHUB_OUTPUT" + echo "pr_smoke_matrix=$(python3 "$POLICY" ci-matrix pr-smoke)" >> "$GITHUB_OUTPUT" - build-and-test: + build_package: + name: Build package once runs-on: ubuntu-24.04 - strategy: - matrix: - torch-version: ["2.5", "2.6", "2.7", "2.8", "nightly"] + steps: - uses: actions/checkout@v4 with: - fetch-depth: 0 # Import all commit history and tag + fetch-depth: 0 - - name: Get Ubuntu codename - id: os - run: | - CODENAME=$(lsb_release -cs) - echo "codename=$CODENAME" >> "$GITHUB_OUTPUT" + - uses: actions/setup-python@v5 + with: + python-version: '3.12' - - name: Specify ONE version and binary - id: one - run: | - VERSION=1.30.1 - echo "version=$VERSION" >> "$GITHUB_OUTPUT" - echo "filename=one-compiler-${{ steps.os.outputs.codename }}_${VERSION}_amd64.deb" >> "$GITHUB_OUTPUT" + - name: Build wheel + run: ./ccex build - - name: Download one-compiler package - id: download - uses: ./.github/actions/download-release-asset + - name: Upload wheel + uses: actions/upload-artifact@v4 with: - owner: Samsung - repo: ONE - tag: ${{ steps.one.outputs.version }} - filename: ${{ steps.one.outputs.filename }} + name: tico-wheel + path: ./dist/ + retention-days: 1 + + test_default: + name: Full test (default torch ${{ needs.resolve_torch_policy.outputs.default_family }}) + needs: + - resolve_torch_policy + - build_package + runs-on: ubuntu-24.04 - - name: "Install one-compiler" - working-directory: ./.github/actions/download-release-asset - run: | - sudo dpkg -i ${{ steps.one.outputs.filename }} - sudo apt-get install -f -y - onecc --version || echo "Installation failed." + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 - - name: Trust all directories for Git - run: | - # Enable access to git from 'versioningit' - git config --global --add safe.directory "*" + - name: Download wheel + uses: actions/download-artifact@v4 + with: + name: tico-wheel + path: ./dist/ - - name: "Build package" - run: | - pip install build - ./ccex build + - name: Set up test environment + uses: ./.github/actions/setup-tico-test + with: + torch-version: ${{ needs.resolve_torch_policy.outputs.default_family }} - - name: "Run install" - shell: bash - run: | - TORCH_VERSION=${{ matrix.torch-version }} - ./ccex install --dist --torch_ver $TORCH_VERSION - pt2-to-circle -h + - name: Run all tests + run: ./ccex test - - name: "Configure test" - shell: bash - run: | - TORCH_VERSION=${{ matrix.torch-version }} - ./ccex configure test --torch_ver $TORCH_VERSION + test_compatibility: + name: Smoke (${{ matrix.tier }}, torch ${{ matrix.torch-version }}) + needs: + - resolve_torch_policy + - build_package + runs-on: ubuntu-24.04 + continue-on-error: ${{ matrix.experimental }} + strategy: + fail-fast: false + matrix: ${{ fromJSON(needs.resolve_torch_policy.outputs.pr_smoke_matrix) }} - - name: "Show torch package versions" - shell: bash - run: | - pip list | grep torch + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 - - name: "Run test" - shell: bash - run: | - ./ccex test + - name: Download wheel + uses: actions/download-artifact@v4 + with: + name: tico-wheel + path: ./dist/ - - name: "Upload artifact" - uses: actions/upload-artifact@v4 + - name: Set up test environment + uses: ./.github/actions/setup-tico-test with: - name: "wheel-${{ matrix.torch-version }}" - path: "./dist/" + torch-version: ${{ matrix.torch-version }} + + - name: Run export and quantization smoke tests + run: | + ./ccex test -k SimpleAdd + python3 -m unittest \ + test.quantization.wrapq.test_cnn_quantized_export.CNNQuantizedExportTest.test_uint8_circle_export \ + -v diff --git a/.github/workflows/check-pytorch-compatibility.yaml b/.github/workflows/check-pytorch-compatibility.yaml new file mode 100644 index 000000000..3aca07a77 --- /dev/null +++ b/.github/workflows/check-pytorch-compatibility.yaml @@ -0,0 +1,118 @@ +name: Check PyTorch Compatibility + +on: + schedule: + # Daily latest-nightly smoke at 03:17 KST. + - cron: '17 18 * * *' + # Weekly full matrix on Monday at 03:41 KST. + - cron: '41 18 * * 0' + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: pytorch-compatibility-${{ github.event.schedule || github.ref }} + cancel-in-progress: true + +jobs: + resolve_torch_policy: + name: Resolve PyTorch policy + runs-on: ubuntu-24.04 + outputs: + scheduled_full_matrix: ${{ steps.policy.outputs.scheduled_full_matrix }} + + steps: + - uses: actions/checkout@v4 + + - name: Read central policy + id: policy + run: | + POLICY=tico/utils/compat/torch_version_policy.py + python3 "$POLICY" validate + echo "scheduled_full_matrix=$(python3 "$POLICY" ci-matrix scheduled-full)" >> "$GITHUB_OUTPUT" + + build_package: + name: Build package once + runs-on: ubuntu-24.04 + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Build wheel + run: ./ccex build + + - name: Upload wheel + uses: actions/upload-artifact@v4 + with: + name: tico-wheel + path: ./dist/ + retention-days: 1 + + nightly_smoke: + name: Daily latest-nightly smoke + if: github.event_name == 'schedule' && github.event.schedule == '17 18 * * *' + needs: + - resolve_torch_policy + - build_package + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Download wheel + uses: actions/download-artifact@v4 + with: + name: tico-wheel + path: ./dist/ + + - name: Set up latest-nightly test environment + uses: ./.github/actions/setup-tico-test + with: + torch-version: nightly-latest + + - name: Run export and quantization smoke tests + run: | + ./ccex test -k SimpleAdd + python3 -m unittest \ + test.quantization.wrapq.test_cnn_quantized_export.CNNQuantizedExportTest.test_uint8_circle_export \ + -v + + full_matrix: + name: Full test (${{ matrix.tier }}, torch ${{ matrix.torch-version }}) + if: >- + github.event_name == 'workflow_dispatch' || + (github.event_name == 'schedule' && github.event.schedule == '41 18 * * 0') + needs: + - resolve_torch_policy + - build_package + runs-on: ubuntu-24.04 + strategy: + fail-fast: false + matrix: ${{ fromJSON(needs.resolve_torch_policy.outputs.scheduled_full_matrix) }} + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Download wheel + uses: actions/download-artifact@v4 + with: + name: tico-wheel + path: ./dist/ + + - name: Set up test environment + uses: ./.github/actions/setup-tico-test + with: + torch-version: ${{ matrix.torch-version }} + + - name: Run all tests + run: ./ccex test diff --git a/.github/workflows/check-workflows.yaml b/.github/workflows/check-workflows.yaml index 46ff99b1e..fc35b8708 100644 --- a/.github/workflows/check-workflows.yaml +++ b/.github/workflows/check-workflows.yaml @@ -5,6 +5,7 @@ on: paths: # WARNING: PRs from forked repo are not allowed. - '.github/workflows/**' + - '.github/actions/**' jobs: actionlint: diff --git a/.github/workflows/publish-official-package.yaml b/.github/workflows/publish-official-package.yaml index 2901d5a45..cbfcbc95d 100644 --- a/.github/workflows/publish-official-package.yaml +++ b/.github/workflows/publish-official-package.yaml @@ -4,53 +4,107 @@ on: workflow_dispatch: inputs: ref_name: - description: 'Git reference (branch or tag) to build and publish' + description: Git reference (branch or tag) to build and publish required: true type: string +permissions: + contents: read + jobs: - build-and-upload: + resolve_torch_policy: + name: Resolve PyTorch release matrix runs-on: ubuntu-24.04 + outputs: + release_matrix: ${{ steps.policy.outputs.release_matrix }} steps: - - name: "Checkout the specified ref" - uses: actions/checkout@v4 + - uses: actions/checkout@v4 with: ref: ${{ inputs.ref_name }} - fetch-depth: 0 # Import all commit history and tag - - name: "Build package" + - name: Read central policy + id: policy run: | - ./ccex build + POLICY=tico/utils/compat/torch_version_policy.py + python3 "$POLICY" validate + echo "release_matrix=$(python3 "$POLICY" ci-matrix release)" >> "$GITHUB_OUTPUT" - - name: "Check requested version (ref_name)" - run: | - INPUT_REF="${{ inputs.ref_name }}" - TAG_VERSION="${INPUT_REF#v}" # Strip leading 'v' from ref_name + build_and_upload: + name: Build official package + runs-on: ubuntu-24.04 + steps: + - name: Checkout the specified ref + uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref_name }} + fetch-depth: 0 + + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Build package + run: ./ccex build + + - name: Check requested version + env: + INPUT_REF: ${{ inputs.ref_name }} + run: | + TAG_VERSION="${INPUT_REF#v}" VERSION="$(versioningit)" CLEAN_VERSION="$(echo "$VERSION" | cut -d'.' -f1-3)" - echo "$CLEAN_VERSION" - echo "VERSION from prepared package: $CLEAN_VERSION" echo "VERSION from ref_name: $TAG_VERSION" - if [ "$CLEAN_VERSION" != "$TAG_VERSION" ]; then - echo "::error::VERSION($CLEAN_VERSION) of current package does not match your requested ref_name ($INPUT_REF)" + if [[ "$CLEAN_VERSION" != "$TAG_VERSION" ]]; then + echo "::error::VERSION($CLEAN_VERSION) does not match requested ref ($INPUT_REF)" exit 1 fi - - name: "Upload artifact" + - name: Upload wheel uses: actions/upload-artifact@v4 with: - name: "wheel" - path: "./dist/" + name: official-wheel + path: ./dist/ + retention-days: 1 + + test_supported_torch: + name: Release test (torch ${{ matrix.torch-version }}) + needs: + - resolve_torch_policy + - build_and_upload + runs-on: ubuntu-24.04 + strategy: + fail-fast: false + matrix: ${{ fromJSON(needs.resolve_torch_policy.outputs.release_matrix) }} + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref_name }} + fetch-depth: 0 + + - name: Download wheel + uses: actions/download-artifact@v4 + with: + name: official-wheel + path: ./dist/ + + - name: Set up test environment + uses: ./.github/actions/setup-tico-test + with: + torch-version: ${{ matrix.torch-version }} - publish-to-pypi: + - name: Run all tests + run: ./ccex test + publish_to_pypi: + name: Publish to PyPI needs: - - build-and-upload + - test_supported_torch runs-on: ubuntu-24.04 environment: @@ -58,14 +112,14 @@ jobs: url: https://pypi.org/p/TICO permissions: - id-token: write # IMPORTANT: mandatory for trusted publishing + id-token: write steps: - - name: "Download all the dists" + - name: Download distribution uses: actions/download-artifact@v4 with: - name: "wheel" - path: "./dist/" + name: official-wheel + path: ./dist/ - - name: "Publish distribution to PyPI" + - name: Publish distribution to PyPI uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/README.md b/README.md index 0a0980c6a..fa704dc64 100644 --- a/README.md +++ b/README.md @@ -48,10 +48,14 @@ cd TICO | Option | Description | |---|---| | `--dist` | Install from the built wheel (default is editable mode) | -| `--torch_ver ` | Torch version to install: a family (`2.5` ~ `2.10`), an exact version (e.g. `2.7.0+cu118`), or `nightly`. Default: `2.7` | +| `--torch_ver ` | Torch version to install: a configured family (`2.10` ~ `2.13`; `2.13` is a candidate), an exact version (e.g. `2.13.0+cu132`), `nightly` (repository-pinned), or `nightly-latest` (moving Torch/TorchVision pair). Default: `2.12` | | `--cuda_ver ` | Override the detected CUDA version (e.g. `12.1`) | | `--cpu_only` | Force a CPU-only Torch installation | +`./ccex install` pins the newest qualified stable family for a reproducible source +setup. See the [PyTorch version policy](./docs/torch_version_policy.md) for the +support window and CI tiers. + ## Quick start ```python diff --git a/docs/README.md b/docs/README.md index a198e236e..c0bdd5f09 100644 --- a/docs/README.md +++ b/docs/README.md @@ -11,6 +11,7 @@ workflows, supported behavior, and the test strategy. | [Getting Started](./getting_started.md) | TICO users | Install TICO, convert PyTorch modules or `.pt2` files, configure conversion, run Circle models, and inspect artifacts. | | [System Design](./design.md) | Contributors | Understand the actual `main`-branch conversion pipeline, package boundaries, pass execution, serialization, runtime behavior, and extension points. | | [Development Guide](./development.md) | Contributors | Set up a source checkout, select a Torch build, run tests and model tests, format code, collect coverage, and understand PR CI. | +| [PyTorch Version Policy](./torch_version_policy.md) | Users and contributors | Understand the qualified stable window, default and candidate families, CI tiers, promotion rules, and release-branch policy. | | [Requirements](./requirements.md) | Users and contributors | Define the currently supported contract, constraints, quality expectations, benchmark targets, and non-goals. | | [System Test Guide](./system_test.md) | Contributors | Explain test layers, end-to-end validation, test commands, CI coverage, performance tests, and maintenance rules. | @@ -41,7 +42,9 @@ source of truth for version-sensitive details: - Conversion pass order: `tico/utils/convert.py` - Circle serialization: `tico/serialize/` - Source-install and test tooling: `infra/command/` and `infra/scripts/` +- PyTorch compatibility metadata: `tico/utils/compat/torch_version_policy.py` - PR CI: `.github/workflows/check-pr.yaml` +- Scheduled PyTorch compatibility CI: `.github/workflows/check-pytorch-compatibility.yaml` When a change modifies a public API, command, configuration field, package boundary, pass order, supported version, or test workflow, update the corresponding document in diff --git a/docs/development.md b/docs/development.md index b4e472c59..5f3c87a0e 100644 --- a/docs/development.md +++ b/docs/development.md @@ -60,18 +60,24 @@ Set up only one part of the environment when needed: ## Torch selection -The source installer accepts a stable family, an exact version, or a pinned nightly: +The source installer accepts a stable family, an exact version, a qualification +candidate, a repository-pinned nightly, or the latest published nightly pair: ```bash -./ccex install --torch_ver 2.7 -./ccex install --torch_ver 2.10.0 -./ccex install --torch_ver 2.7.1+cu128 -./ccex install --torch_ver nightly +./ccex install --torch_ver 2.12 +./ccex install --torch_ver 2.10 +./ccex install --torch_ver 2.12.1+cu132 +./ccex install --torch_ver 2.13 +./ccex install --torch_ver nightly # repository-pinned Torch/TorchVision +./ccex install --torch_ver nightly-latest # latest published nightly pair ``` -Current stable families supported by the install tooling are 2.5 through 2.10. The -default family is 2.7. Family requests resolve to a project-pinned latest supported -patch rather than allowing pip to select any patch release. +TICO qualifies the latest three stable Torch families: 2.10, 2.11, and 2.12. The +default family is 2.12. Torch 2.13 is installable as a qualification candidate but is +not part of the release-support window. Family requests resolve to a project-pinned +patch rather than allowing pip to select an arbitrary patch release. `nightly` uses the +versions pinned under `infra/dependency/`; `nightly-latest` resolves Torch and +TorchVision together from one moving nightly index. Compute-platform options: @@ -85,10 +91,17 @@ Compute-platform options: `--cpu_only` and `--cuda_ver` are mutually exclusive. -When no Torch version is explicitly requested and a supported stable Torch package is +When no Torch version is explicitly requested and a qualified stable Torch package is already installed, `./ccex install` preserves that installation if its compute platform is compatible. `./ccex configure test` then installs the matching TorchVision package -and verifies the final package pair with `pip check`. +and verifies the final package pair with `pip check`. Nightly selectors are deliberately +re-resolved: `nightly` restores the repository pin, while `nightly-latest` upgrades the +Torch/TorchVision pair together before test configuration validates it. + +The source of truth for families, exact patches, CUDA wheel variants, and CI matrices is +[`tico/utils/compat/torch_version_policy.py`](../tico/utils/compat/torch_version_policy.py). +See the [PyTorch Version Policy](./torch_version_policy.md) for qualification, +promotion, and release-branch rules. ## Build and install a wheel @@ -108,8 +121,8 @@ A clean wheel workflow similar to CI is: ```bash ./ccex build -./ccex install --dist --torch_ver 2.7 -./ccex configure test --torch_ver 2.7 +./ccex install --dist --torch_ver 2.12 +./ccex configure test --torch_ver 2.12 pt2-to-circle -h ``` @@ -325,8 +338,8 @@ If `coverage` is not installed, the current helper requests version 7.6.1. ## Pull-request CI -The PR workflow currently performs three major checks for pull requests targeting -`main` or `rel/*`: +The PR workflow targets `main` and `rel/*`. PyTorch versions are resolved from the +central policy module rather than duplicated in workflow YAML. 1. **Commit-message check** - Runs when the pull request is ready for review. @@ -341,11 +354,21 @@ The PR workflow currently performs three major checks for pull requests targetin - Executes `./ccex configure format` and `./ccex format --no-apply-patches`. -3. **Build and test matrix** - - Current matrix: Torch 2.5, 2.6, 2.7, 2.8, and the pinned nightly. - - Installs the CI-pinned ONE compiler package. - - Builds a wheel, installs it, configures test dependencies, and runs - `./ccex test`. +3. **Package build** + - Builds the TICO wheel once. + - Uploads one short-lived artifact reused by all versioned test jobs. + +4. **Versioned tests** + - Runs the complete suite on the default qualified family, currently 2.12. + - Runs blocking export and quantization smoke tests on the oldest supported family, + currently 2.10. + - Runs the same smoke tests non-blockingly on the qualification candidate, currently + 2.13. + +A separate compatibility workflow runs `nightly-latest` smoke tests daily and the +complete supported/candidate/`nightly-latest` matrix weekly. Official package +publication runs the full suite on every qualified stable family before publishing. See the +[PyTorch Version Policy](./torch_version_policy.md) for the exact tiers. Performance tests are available through `./ccex test -p`, but are not part of the current PR matrix. diff --git a/docs/getting_started.md b/docs/getting_started.md index f0c6c2eac..fc3230c49 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -25,10 +25,11 @@ workflow; a Circle runtime is needed only when the generated model is executed. - A supported PyTorch installation - An inference-mode, `torch.export`-compatible module -TICO's source tooling supports stable Torch families 2.5 through 2.10 and a pinned -nightly build. The default source-install family is 2.7. TICO warns below 2.5 and -recommends Torch 2.6 or newer when possible because older releases may contain known -security vulnerabilities. See the +TICO's qualified stable support window is Torch 2.10 through 2.12, and the +default source-install family is 2.12. Torch 2.13 is available as a qualification +candidate. `nightly` is repository-pinned for reproducibility, while +`nightly-latest` is used as a moving early-compatibility signal rather than release +support. See the [PyTorch Version Policy](./torch_version_policy.md) and [Development Guide](./development.md) for exact installation and CI details. > [!IMPORTANT] @@ -61,9 +62,11 @@ Useful source-install options include: ```bash ./ccex install --cpu_only -./ccex install --torch_ver 2.7 -./ccex install --torch_ver 2.10.0 +./ccex install --torch_ver 2.12 +./ccex install --torch_ver 2.10 +./ccex install --torch_ver 2.13 ./ccex install --torch_ver nightly +./ccex install --torch_ver nightly-latest ./ccex install --cuda_ver 12.8 ``` @@ -406,6 +409,8 @@ The conversion pipeline writes images such as `1_after_decompose.png`, - [System Design](./design.md): conversion stages, invariants, serialization, and extension points +- [PyTorch Version Policy](./torch_version_policy.md): supported families, default and + candidate versions, CI tiers, and promotion rules - [Development Guide](./development.md): source setup, tests, formatting, and CI - [Quantization](../tico/quantization/README.md): quantize a model before Circle export - [Quantization examples](../tico/quantization/examples/README.md): config-driven LLM diff --git a/docs/requirements.md b/docs/requirements.md index baca699fe..6f578c610 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -226,16 +226,22 @@ The package metadata requires Python 3.10 or newer. ### PyTorch -- The package warns when Torch is older than 2.5. -- It also recommends Torch 2.6 or newer for security when an older supported release - is detected. -- Source installation tooling currently supports stable Torch families 2.5 through - 2.10 and a pinned nightly build. -- The default source-install family is 2.7. -- The current PR CI matrix tests Torch 2.5, 2.6, 2.7, 2.8, and the pinned nightly. - -“Install-tool support” and “PR CI coverage” are intentionally separate claims. A -stable family accepted by `./ccex install` is not necessarily run in every pull request. +- Package metadata accepts `torch>=2.10,<2.14`. +- The qualified stable support window is Torch 2.10, 2.11, and 2.12. +- The default source-install family is 2.12. +- Torch 2.13 is explicitly installable as a qualification candidate and is not part of + release support until it is promoted. +- `nightly` installs the repository-pinned Torch/TorchVision builds for reproducible + local debugging. +- `nightly-latest` resolves Torch and TorchVision together from the moving nightly index; + scheduled compatibility CI uses this selector as its early-warning signal. +- Pull requests run the full suite on the default family, blocking compatibility smoke + on the oldest supported family, and non-blocking candidate smoke. Scheduled CI runs + daily `nightly-latest` smoke and a weekly full matrix. + +Package compatibility, source-installer acceptance, qualified release support, and CI +coverage are intentionally separate claims. The exact policy is defined in +[`tico/utils/compat/torch_version_policy.py`](../tico/utils/compat/torch_version_policy.py). ### Operating system @@ -327,7 +333,7 @@ TICO does not currently promise: | Circle artifact verification/extraction/passes | `test/unit_test/circle/` | | CLI and configuration | `test/pt2_to_circle_test/`, config tests, quantization example/config tests | | Performance thresholds | `test/performance/benchmark_perf.py`, invoked by `./ccex test -p` | -| Torch compatibility and package build | `.github/workflows/check-pr.yaml` matrix | +| Torch compatibility and package build | `tico/utils/compat/torch_version_policy.py`, `.github/workflows/check-pr.yaml`, `.github/workflows/check-pytorch-compatibility.yaml` | | Style and type checks | `.lintrunner.toml` through `./ccex format --no-apply-patches` | See [System Test Guide](./system_test.md) for test flow and commands. @@ -348,10 +354,11 @@ Version-sensitive sources of truth: | Fact | Source | |---|---| -| Python requirement and entry points | `pyproject.toml` | -| Torch warning and public exports | `tico/__init__.py` | -| Supported source-install Torch families | `infra/scripts/pytorch_package_utils.sh` | -| PR CI matrix | `.github/workflows/check-pr.yaml` | +| Python and Torch package requirements and entry points | `pyproject.toml` | +| Runtime Torch warnings and public exports | `tico/__init__.py` | +| Torch families, exact patches, wheel variants, and CI matrices | `tico/utils/compat/torch_version_policy.py` | +| PR compatibility tiers | `.github/workflows/check-pr.yaml` | +| Scheduled compatibility matrix | `.github/workflows/check-pytorch-compatibility.yaml` | | Compile configuration | `tico/config/v1.py` and its use sites | | Pass order | `tico/utils/convert.py` | | Performance thresholds | `test/performance/benchmark_perf.py` | diff --git a/docs/system_test.md b/docs/system_test.md index f79e98a62..71db52a2f 100644 --- a/docs/system_test.md +++ b/docs/system_test.md @@ -40,7 +40,7 @@ The test suite is designed to answer distinct questions: 4. **Negative-path behavior** - Does TICO reject unsupported or invalid patterns with the expected diagnostic? 5. **Version compatibility** - - Does the package build and test across the current PR Torch matrix? + - Does the package satisfy the tiered PR and scheduled PyTorch compatibility policy? 6. **Performance regression detection** - Do the opt-in synthetic Llama conversion and size benchmarks remain within their repository thresholds? @@ -62,7 +62,7 @@ runtime parity, and target-NPU compilation are different checks. | Quantization tests | `test/quantization/` | Cover algorithms, WrapQ, qparam passes, configs, recipes, evaluation, analysis, and export behavior. | | Performance tests | `test/performance/` | Measure the current synthetic Llama decoder-layer conversion time and serialized-size thresholds. | | Shared test support | `test/support/` | Provide test builders, runtime adapters, tags, and helpers. | -| PR compatibility checks | `.github/workflows/check-pr.yaml` | Build/install/test selected Torch versions and enforce style and DCO checks. | +| PyTorch compatibility checks | `.github/workflows/check-pr.yaml`, `.github/workflows/check-pytorch-compatibility.yaml` | Enforce style/DCO checks and validate the default, oldest supported, candidate, and `nightly-latest` tiers. | ## 3. Test directory layout @@ -441,9 +441,15 @@ source of structural assertions. ## 11. Continuous integration -The current pull-request workflow targets `main` and `rel/*` and contains: +PyTorch version selection is generated from +`tico/utils/compat/torch_version_policy.py`; workflow YAML does not maintain a separate +hard-coded family list. -### Commit-message check +### Pull-request workflow + +The pull-request workflow targets `main` and `rel/*`. + +#### Commit-message check For non-draft pull requests, at least one commit body must contain: @@ -451,7 +457,7 @@ For non-draft pull requests, at least one commit body must contain: TICO-DCO-1.0-Signed-off-by: <> ``` -### Style job +#### Style job - Ubuntu 24.04 - Python 3.12 @@ -460,28 +466,38 @@ TICO-DCO-1.0-Signed-off-by: <> The lintrunner configuration currently includes Pylint, ufmt, and mypy for Python files. -### Build-and-test matrix +#### Build package once -Current Torch matrix: +The workflow builds one TICO wheel and uploads one short-lived artifact. All versioned +test jobs download and reuse that wheel instead of rebuilding it for each Torch family. -```text -2.5, 2.6, 2.7, 2.8, nightly -``` +#### Versioned tests + +- The complete suite runs on the default qualified family, currently 2.12. +- Blocking export and quantization smoke tests run on the oldest supported family, + currently 2.10. +- The same smoke tests run non-blockingly on the qualification candidate, currently + 2.13. + +The smoke path includes a small `torch.export`/PT2/Circle conversion and a quantized CNN +Circle export. It is intended to detect version-contract breakage without multiplying +the complete suite across every pull request. + +### Scheduled compatibility workflow + +A separate workflow provides broader early warning without participating in PR branch +protection: -Each matrix job: +- daily: `nightly-latest` export and quantization smoke +- weekly: complete suite on all qualified stable families, qualification candidates, + and `nightly-latest` +- manual dispatch: complete matrix on demand -1. Checks out full Git history. -2. Installs the CI-pinned ONE compiler package. -3. Builds the TICO wheel. -4. Installs the wheel with the selected Torch family. -5. Runs `pt2-to-circle -h` as an entry-point smoke check. -6. Configures test dependencies for that Torch installation. -7. Prints installed Torch package versions. -8. Runs `./ccex test`. -9. Uploads the wheel artifact. +### Official release workflow -The source installer supports additional stable families, but the PR matrix is the -explicit list above. +Official package publication builds the wheel once and runs the complete suite on every +qualified stable family before publishing. Candidate and nightly selectors are not +part of the release-support gate. ## 12. Test-result reporting policy @@ -559,7 +575,7 @@ and make the assertion distinguish the bug from unrelated failures. | Quantized graph legalization | `test/quantization/passes/`, quantization unit tests | | Quantization API and workflows | registry/config/WrapQ/algorithm/recipe tests | | Circle artifact structural contracts | `test/unit_test/circle/` | -| Package/Torch compatibility | `.github/workflows/check-pr.yaml` | +| Package/Torch compatibility | `tico/utils/compat/torch_version_policy.py`, `.github/workflows/check-pr.yaml`, `.github/workflows/check-pytorch-compatibility.yaml` | | Performance thresholds | `test/performance/benchmark_perf.py` through `./ccex test -p` | | Formatting/type quality | `.lintrunner.toml` through `./ccex format --no-apply-patches` | diff --git a/docs/torch_version_policy.md b/docs/torch_version_policy.md new file mode 100644 index 000000000..114e255c0 --- /dev/null +++ b/docs/torch_version_policy.md @@ -0,0 +1,102 @@ +# PyTorch Version Policy + +TICO depends directly on `torch.export`, FX graphs, ATen operators, fake-tensor +behavior, and quantization internals. PyTorch compatibility therefore needs a +stricter policy than an ordinary leaf dependency. + +The source of truth is +[`tico/utils/compat/torch_version_policy.py`](../tico/utils/compat/torch_version_policy.py). +The installer and GitHub Actions read this module instead of maintaining separate +hard-coded version lists. + +## Support window + +TICO keeps these tiers: + +| Tier | Meaning | Current value | +|---|---|---| +| Default | Newest qualified stable family used by `./ccex install` | `2.12` | +| Supported stable | Latest three qualified stable families | `2.10`, `2.11`, `2.12` | +| Candidate | Newly released stable family under qualification | `2.13` | +| Pinned nightly | Reproducible nightly channel for local debugging | `nightly` | +| Moving nightly | Latest compatible Torch/TorchVision nightly pair | `nightly-latest` | + +The package metadata allows the qualified families and the current candidate +(`torch>=2.10,<2.14`) while excluding the next unknown stable family. Exact default +pinning is left to `./ccex install`, because an exact `Requires-Dist` pin would +prevent users and CI from selecting another configured family. + +## Nightly selectors + +The two nightly selectors have deliberately different contracts: + +```bash +# Install the exact Torch build from infra/dependency/torch_dev.txt. During +# test configuration, install the matching pinned TorchVision requirement. +./ccex install --torch_ver nightly +./ccex configure test --torch_ver nightly + +# Resolve Torch and TorchVision together from the latest published nightly +# index, then preserve and validate that pair during test configuration. +./ccex install --torch_ver nightly-latest +./ccex configure test --torch_ver nightly-latest +``` + +`nightly-latest` installs `torch` and `torchvision` in the same pip resolver call. +This avoids selecting a moving Torch build and an independently resolved TorchVision +build. The composite GitHub Action delegates both selectors to `ccex`; it does not +maintain a separate nightly installation implementation. + +Both selectors are re-resolved when explicitly requested. `nightly` restores the +repository pin, while `nightly-latest` checks the moving index for a newer compatible +pair. `configure test` validates that a pinned request matches the repository pin and +that a latest request already contains an importable nightly TorchVision build with a +matching CPU/CUDA wheel tag. + +## CI tiers + +| Trigger | PyTorch coverage | Test scope | Merge blocking | +|---|---|---|---| +| Every PR | Default family | Full unit-test suite | Yes | +| Every PR | Oldest supported family | Export and quantization smoke tests | Yes | +| Every PR | Candidate families, when configured | Export and quantization smoke tests | No | +| Daily schedule | `nightly-latest` | Export and quantization smoke tests | Separate workflow | +| Weekly schedule | All supported families | Full unit-test suite | Separate workflow | +| Weekly schedule | Candidate families and `nightly-latest` | Full unit-test suite | Separate workflow | +| Official release | All supported stable families | Full unit-test suite | Yes | + +The wheel is built once per workflow run and reused by all test jobs. PR jobs do not +upload one wheel per PyTorch family. Scheduled failures remain red so that maintainers +receive a useful upstream signal, but they do not participate in PR branch protection. + +Nightly builds are intentionally outside the stable package bound. Test setup ignores +only TICO's expected Torch metadata mismatch for a development build and still fails on +every other `pip check` conflict. + +## Promoting a new stable family + +When PyTorch `2.N` is released: + +1. Add `2.N` to `QUALIFICATION_CANDIDATE_FAMILIES`. +2. Add its exact patch and published CUDA wheel variants to + `LATEST_STABLE_VERSION` and `STABLE_CUDA_WHEELS`. +3. Keep it as an experimental candidate for 28 days after the candidate CI is + merged while daily and weekly jobs collect compatibility results. +4. After qualification, append it to `SUPPORTED_STABLE_FAMILIES`, set it as + `DEFAULT_FAMILY`, remove the oldest supported family, and clear it from the + candidate tuple. +5. Update the bounded Torch requirement in `pyproject.toml` when either edge of + the configured family window changes. + +The policy unit test rejects a non-contiguous window, a default that is not the +newest supported family, missing version metadata, a stale package minimum, duplicated +nightly selectors, and a scheduled matrix that uses the reproducible pin instead of the +moving nightly channel. + +## Release branches + +A `rel/*` branch should keep the default family it had when the branch was cut. +Patch releases of that family may be adopted, but the branch should not shift its +three-family window unless a security or compatibility issue requires it. A release +branch may keep its own pinned `nightly` requirements for reproduction; moving +`nightly-latest` results are advisory only. diff --git a/infra/scripts/install.sh b/infra/scripts/install.sh index 1c307faee..aa292ff68 100644 --- a/infra/scripts/install.sh +++ b/infra/scripts/install.sh @@ -32,9 +32,13 @@ Usage: ./ccex install [OPTIONS] --dist Install from wheel in ./dist instead of editable mode --torch_ver VER Torch version or family to install. Accepts: - • 2.5 ~ 2.10 (family, installs latest supported patch) - • 2.6.0, 2.7.1+cu126 ... (exact) - • nightly + • ${PYTORCH_INSTALLABLE_FAMILY_MIN} ~ ${PYTORCH_INSTALLABLE_FAMILY_MAX} + (family, installs latest configured patch) + • 2.10.0, 2.13.0+cu132 ... (exact) + • ${PYTORCH_PINNED_NIGHTLY_SELECTOR} + (repository-pinned nightly Torch) + • ${PYTORCH_LATEST_NIGHTLY_SELECTOR} + (latest published Torch/TorchVision nightly pair) Default: ${PYTORCH_DEFAULT_FAMILY} --cuda_ver MAJ.MIN Override detected host CUDA capability (e.g. 12.1) --cpu_only Force CPU-only Torch installation @@ -123,17 +127,21 @@ fi # Normalize the requested Torch version ############################################################################### REQUEST_IS_NIGHTLY=0 +REQUEST_IS_LATEST_NIGHTLY=0 REQUEST_IS_EXACT=0 REQUESTED_FAMILY="" REQUESTED_EXACT_VERSION="" REQUESTED_BUILD_TAG="" RESOLVED_TORCH_VERSION="" -if [[ "${_TORCH_VER}" == "nightly" ]]; then +if [[ "${_TORCH_VER}" == "${PYTORCH_PINNED_NIGHTLY_SELECTOR}" ]]; then REQUEST_IS_NIGHTLY=1 +elif [[ "${_TORCH_VER}" == "${PYTORCH_LATEST_NIGHTLY_SELECTOR}" ]]; then + REQUEST_IS_NIGHTLY=1 + REQUEST_IS_LATEST_NIGHTLY=1 elif [[ "${_TORCH_VER}" =~ ^[0-9]+\.[0-9]+$ ]]; then REQUESTED_FAMILY="${_TORCH_VER}" - if ! pytorch_is_supported_family "${REQUESTED_FAMILY}"; then + if ! pytorch_is_installable_family "${REQUESTED_FAMILY}"; then echo "[ERROR] Unsupported --torch_ver family '${_TORCH_VER}'" >&2 exit 1 fi @@ -143,7 +151,7 @@ elif [[ "${_TORCH_VER}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(\+[A-Za-z0-9._-]+)?$ ]]; then REQUESTED_EXACT_VERSION="${_TORCH_VER}" REQUESTED_FAMILY="$(pytorch_version_family "${_TORCH_VER}")" || exit 1 REQUESTED_BUILD_TAG="$(pytorch_local_build_tag "${_TORCH_VER}")" - if ! pytorch_is_supported_family "${REQUESTED_FAMILY}"; then + if ! pytorch_is_installable_family "${REQUESTED_FAMILY}"; then echo "[ERROR] Unsupported --torch_ver value '${_TORCH_VER}'" >&2 exit 1 fi @@ -196,9 +204,8 @@ if [[ -n "${INSTALLED_TORCH_FULL}" ]]; then SKIP_TORCH_INSTALL=1 RESOLVED_TORCH_VERSION="${INSTALLED_TORCH_BASE}" fi - elif [[ "${REQUEST_IS_NIGHTLY}" == "1" && "${INSTALLED_TORCH_IS_NIGHTLY}" == "1" ]]; then - echo "[INFO] Requested nightly torch ${INSTALLED_TORCH_FULL} already present — keeping it" - SKIP_TORCH_INSTALL=1 + elif [[ "${REQUEST_IS_NIGHTLY}" == "1" ]]; then + echo "[INFO] Re-resolving ${_TORCH_VER}; nightly selectors are never cached" elif [[ "${REQUEST_IS_EXACT}" == "1" ]]; then REQUESTED_BASE="$(pytorch_strip_local_version "${REQUESTED_EXACT_VERSION}")" if [[ "${INSTALLED_TORCH_BASE}" == "${REQUESTED_BASE}" ]]; then @@ -227,7 +234,8 @@ if [[ "${SKIP_TORCH_INSTALL}" == "0" ]]; then HOST_CUDA="" PINNED_BUILD_TAG="" - if [[ "${REQUEST_IS_NIGHTLY}" == "1" ]]; then + if [[ "${REQUEST_IS_NIGHTLY}" == "1" && \ + "${REQUEST_IS_LATEST_NIGHTLY}" == "0" ]]; then TORCH_DEV_FILE="${SCRIPTS_DIR}/../dependency/torch_dev.txt" PINNED_TORCH_VERSION="$(pytorch_get_pinned_requirement_version "${TORCH_DEV_FILE}" torch)" if [[ -z "${PINNED_TORCH_VERSION}" ]]; then @@ -263,7 +271,12 @@ if [[ "${SKIP_TORCH_INSTALL}" == "0" ]]; then echo "[INFO] CUDA was not detected; using a CPU Torch wheel" fi - if [[ "${REQUEST_IS_NIGHTLY}" == "1" ]]; then + if [[ "${REQUEST_IS_LATEST_NIGHTLY}" == "1" ]]; then + pytorch_build_index_urls "" "${HOST_CUDA}" 1 "${REQUESTED_BUILD_TAG}" || exit 1 + # Resolve Torch and TorchVision together so pip selects one compatible + # nightly pair from the same moving index. + install_torch --pre --upgrade torch torchvision || exit 1 + elif [[ "${REQUEST_IS_NIGHTLY}" == "1" ]]; then pytorch_build_index_urls "" "${HOST_CUDA}" 1 "${REQUESTED_BUILD_TAG}" || exit 1 install_torch -r "${TORCH_DEV_FILE}" || exit 1 else @@ -291,6 +304,36 @@ IFS=$'\t' read -r \ echo "[INFO] Installed torch: ${INSTALLED_TORCH_FULL}" echo "[INFO] Torch wheel build: ${INSTALLED_TORCH_WHEEL_TAG}" +if [[ "${REQUEST_IS_NIGHTLY}" == "1" && \ + "${INSTALLED_TORCH_IS_NIGHTLY}" != "1" ]]; then + echo "[ERROR] ${_TORCH_VER} resolved non-nightly torch ${INSTALLED_TORCH_FULL}." >&2 + exit 1 +fi + +if [[ "${REQUEST_IS_LATEST_NIGHTLY}" == "1" ]]; then + VISION_INFO="$(pytorch_get_installed_torchvision_info)" || { + echo "[ERROR] TorchVision is not importable after nightly-latest installation." >&2 + exit 1 + } + IFS=$'\t' read -r \ + INSTALLED_VISION_FULL \ + INSTALLED_VISION_BASE \ + INSTALLED_VISION_WHEEL_TAG \ + INSTALLED_VISION_IS_NIGHTLY <<< "${VISION_INFO}" + + if [[ "${INSTALLED_VISION_IS_NIGHTLY}" != "1" ]]; then + echo "[ERROR] nightly-latest resolved stable torchvision ${INSTALLED_VISION_FULL}." >&2 + exit 1 + fi + if [[ "${INSTALLED_VISION_WHEEL_TAG}" != "none" && \ + "${INSTALLED_VISION_WHEEL_TAG}" != "${INSTALLED_TORCH_WHEEL_TAG}" ]]; then + echo "[ERROR] Nightly wheel mismatch: torch uses ${INSTALLED_TORCH_WHEEL_TAG}, " \ + "but torchvision is ${INSTALLED_VISION_FULL}." >&2 + exit 1 + fi + echo "[INFO] Installed torchvision: ${INSTALLED_VISION_FULL}" +fi + ############################################################################### # Install the auxiliary Python requirements ############################################################################### @@ -307,7 +350,7 @@ if [[ "${_DIST}" -eq 1 ]]; then "${CCEX_PROJECT_PATH}"/dist/tico*.whl || exit 1 else echo "[INFO] Installing TICO in editable mode" - python3 -m pip install --editable "${CCEX_PROJECT_PATH}" || exit 1 + python3 -m pip install --no-deps --editable "${CCEX_PROJECT_PATH}" || exit 1 fi # TorchVision is installed by `./ccex configure test`, so a global `pip check` diff --git a/infra/scripts/pytorch_package_utils.sh b/infra/scripts/pytorch_package_utils.sh index 6643cb839..adaf324ef 100644 --- a/infra/scripts/pytorch_package_utils.sh +++ b/infra/scripts/pytorch_package_utils.sh @@ -21,36 +21,15 @@ if [[ -n "${TICO_PYTORCH_PACKAGE_UTILS_SOURCED:-}" ]]; then fi TICO_PYTORCH_PACKAGE_UTILS_SOURCED=1 -PYTORCH_DEFAULT_FAMILY="2.7" -PYTORCH_SUPPORTED_FAMILIES=("2.5" "2.6" "2.7" "2.8" "2.9" "2.10") - -# Keep family requests deterministic. A family such as 2.7 resolves to the -# latest stable patch explicitly supported by TICO instead of asking pip to -# backtrack over every 2.7.x release. -declare -A PYTORCH_LATEST_STABLE_VERSION=( - ["2.5"]="2.5.1" - ["2.6"]="2.6.0" - ["2.7"]="2.7.1" - ["2.8"]="2.8.0" - ["2.9"]="2.9.1" - ["2.10"]="2.10.0" -) - -# Official CUDA wheel variants for each supported stable Torch family. Values -# are ordered from newest to oldest so that the best compatible wheel is tried -# first. The CPU index is appended separately as the final fallback. -declare -A PYTORCH_STABLE_CUDA_WHEELS=( - ["2.5"]="12.4 12.1 11.8" - ["2.6"]="12.6 12.4 11.8" - ["2.7"]="12.8 12.6 11.8" - ["2.8"]="12.9 12.8 12.6" - ["2.9"]="13.0 12.8 12.6" - ["2.10"]="13.0 12.8 12.6" -) - -# Used only when a nightly requirement does not contain an explicit local -# build tag such as +cpu or +cu130. -PYTORCH_NIGHTLY_CUDA_FALLBACKS=("13.0" "12.8" "12.6") +PYTORCH_PACKAGE_UTILS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PYTORCH_POLICY_FILE="${PYTORCH_PACKAGE_UTILS_DIR}/../../tico/utils/compat/torch_version_policy.py" + +if ! PYTORCH_POLICY_SHELL="$(python3 "${PYTORCH_POLICY_FILE}" shell)"; then + echo "[ERROR] Failed to load PyTorch policy from ${PYTORCH_POLICY_FILE}" >&2 + return 1 +fi +eval "${PYTORCH_POLICY_SHELL}" +unset PYTORCH_POLICY_SHELL pytorch_is_supported_family() { local family="$1" @@ -62,6 +41,26 @@ pytorch_is_supported_family() { return 1 } +pytorch_is_installable_family() { + local family="$1" + local installable + + for installable in "${PYTORCH_INSTALLABLE_FAMILIES[@]}"; do + [[ "${installable}" == "${family}" ]] && return 0 + done + return 1 +} + +pytorch_is_nightly_selector() { + local selector="$1" + local nightly_selector + + for nightly_selector in "${PYTORCH_NIGHTLY_SELECTORS[@]}"; do + [[ "${nightly_selector}" == "${selector}" ]] && return 0 + done + return 1 +} + pytorch_version_le() { local lhs="$1" local rhs="$2" @@ -103,7 +102,7 @@ pytorch_local_build_tag() { pytorch_resolve_latest_stable_version() { local family="$1" - if ! pytorch_is_supported_family "${family}"; then + if ! pytorch_is_installable_family "${family}"; then return 1 fi @@ -128,12 +127,12 @@ pytorch_resolve_torchvision_version() { patch="${BASH_REMATCH[3]}" family="${major}.${minor}" - if [[ "${major}" != "2" ]] || ! pytorch_is_supported_family "${family}"; then + if [[ "${major}" != "2" ]] || ! pytorch_is_installable_family "${family}"; then return 1 fi - # Torch 2.N.P is paired with TorchVision 0.(N+15).P for the supported - # release families (2.5 through 2.10). + # Torch 2.N.P is paired with TorchVision 0.(N+15).P for the stable + # release families configured by the central policy. vision_minor=$((10#${minor} + 15)) echo "0.${vision_minor}.${patch}" } @@ -245,7 +244,7 @@ pytorch_build_index_urls() { pytorch_add_unique_index_url "$(pytorch_index_url "${cuda_tag}" 1)" cuda_candidates=("${PYTORCH_NIGHTLY_CUDA_FALLBACKS[@]}") else - if ! pytorch_is_supported_family "${family}"; then + if ! pytorch_is_installable_family "${family}"; then echo "[ERROR] Unsupported Torch family '${family}'" >&2 return 1 fi @@ -313,3 +312,49 @@ else: print("\t".join((full_version, base_version, family, wheel_tag, is_nightly))) PY } + +pytorch_get_installed_torchvision_info() { + python3 - <<'PY' +import importlib.util +import sys + +if importlib.util.find_spec("torchvision") is None: + sys.exit(1) + +try: + import torchvision +except Exception as exc: + print(f"Failed to import torchvision: {exc}", file=sys.stderr) + sys.exit(2) + +full_version = str(torchvision.__version__) +base_version = full_version.split("+", 1)[0] +wheel_tag = full_version.split("+", 1)[1] if "+" in full_version else "none" +is_nightly = "1" if ".dev" in base_version else "0" +print("\t".join((full_version, base_version, wheel_tag, is_nightly))) +PY +} + +pytorch_pip_check() { + local allow_nightly_mismatch="${1:-0}" + local output + local status + + if output="$(python3 -m pip check 2>&1)"; then + [[ -n "${output}" ]] && printf '%s\n' "${output}" + return 0 + else + status=$? + fi + + if [[ "${allow_nightly_mismatch}" == "1" ]]; then + if printf '%s\n' "${output}" | \ + python3 "${PYTORCH_POLICY_FILE}" filter-nightly-pip-check; then + return 0 + fi + return "${status}" + fi + + printf '%s\n' "${output}" >&2 + return "${status}" +} diff --git a/infra/scripts/test_configure.sh b/infra/scripts/test_configure.sh index 0feda55e9..0a27642bc 100755 --- a/infra/scripts/test_configure.sh +++ b/infra/scripts/test_configure.sh @@ -32,9 +32,10 @@ Usage: ./ccex configure test [OPTIONS] --torch_ver VER Validate the installed Torch version before installing its matching TorchVision package. Accepts: - • 2.5 ~ 2.10 - • 2.6.0, 2.7.1+cu126 ... - • nightly + • ${PYTORCH_INSTALLABLE_FAMILY_MIN} ~ ${PYTORCH_INSTALLABLE_FAMILY_MAX} + • 2.10.0, 2.13.0+cu132 ... + • ${PYTORCH_PINNED_NIGHTLY_SELECTOR} + • ${PYTORCH_LATEST_NIGHTLY_SELECTOR} If omitted, the installed Torch version is used. --cuda_ver MAJ.MIN Validate that this CUDA capability can run the installed Torch wheel. TorchVision still follows the Torch wheel. @@ -103,22 +104,71 @@ if [[ "${INSTALLED_TORCH_WHEEL_TAG}" != "cpu" && \ fi if [[ "${INSTALLED_TORCH_IS_NIGHTLY}" == "0" ]] && \ - ! pytorch_is_supported_family "${INSTALLED_TORCH_FAMILY}"; then - echo "[ERROR] Installed torch ${INSTALLED_TORCH_FULL} is not supported." >&2 + ! pytorch_is_installable_family "${INSTALLED_TORCH_FAMILY}"; then + echo "[ERROR] Installed torch ${INSTALLED_TORCH_FULL} is not configured." >&2 exit 1 fi +NIGHTLY_MODE="" +PINNED_TORCH_VERSION="" +PINNED_TORCH_BASE="" +PINNED_TORCH_BUILD_TAG="" +INSTALLED_MATCHES_PINNED=0 + +if [[ "${INSTALLED_TORCH_IS_NIGHTLY}" == "1" ]]; then + TORCH_DEV_FILE="${SCRIPTS_DIR}/../dependency/torch_dev.txt" + PINNED_TORCH_VERSION="$(pytorch_get_pinned_requirement_version \ + "${TORCH_DEV_FILE}" torch)" + if [[ -z "${PINNED_TORCH_VERSION}" ]]; then + echo "[ERROR] ${TORCH_DEV_FILE} must pin torch with 'torch==VERSION'." >&2 + exit 1 + fi + PINNED_TORCH_BASE="$(pytorch_strip_local_version "${PINNED_TORCH_VERSION}")" + PINNED_TORCH_BUILD_TAG="$(pytorch_local_build_tag "${PINNED_TORCH_VERSION}")" + + if [[ "${INSTALLED_TORCH_BASE}" == "${PINNED_TORCH_BASE}" && \ + ( -z "${PINNED_TORCH_BUILD_TAG}" || \ + "${INSTALLED_TORCH_WHEEL_TAG}" == "${PINNED_TORCH_BUILD_TAG}" ) ]]; then + INSTALLED_MATCHES_PINNED=1 + fi + + if [[ "${_TORCH_VER_WAS_SET}" == "1" && \ + "${_TORCH_VER}" == "${PYTORCH_LATEST_NIGHTLY_SELECTOR}" ]]; then + NIGHTLY_MODE="latest" + elif [[ "${_TORCH_VER_WAS_SET}" == "1" && \ + "${_TORCH_VER}" == "${PYTORCH_PINNED_NIGHTLY_SELECTOR}" ]]; then + NIGHTLY_MODE="pinned" + elif [[ "${INSTALLED_MATCHES_PINNED}" == "1" ]]; then + NIGHTLY_MODE="pinned" + else + NIGHTLY_MODE="latest" + fi +fi + ############################################################################### # Validate optional version and compute-platform requests ############################################################################### if [[ "${_TORCH_VER_WAS_SET}" == "1" ]]; then - if [[ "${_TORCH_VER}" == "nightly" ]]; then + if [[ "${_TORCH_VER}" == "${PYTORCH_PINNED_NIGHTLY_SELECTOR}" ]]; then + if [[ "${INSTALLED_TORCH_IS_NIGHTLY}" != "1" ]]; then + echo "[ERROR] --torch_ver ${PYTORCH_PINNED_NIGHTLY_SELECTOR} was requested, " \ + "but ${INSTALLED_TORCH_FULL} is installed." >&2 + exit 1 + fi + if [[ "${INSTALLED_MATCHES_PINNED}" != "1" ]]; then + echo "[ERROR] Requested pinned nightly ${PINNED_TORCH_VERSION}, " \ + "but ${INSTALLED_TORCH_FULL} is installed." >&2 + echo "[ERROR] Re-run './ccex install --torch_ver ${PYTORCH_PINNED_NIGHTLY_SELECTOR}' first." >&2 + exit 1 + fi + elif [[ "${_TORCH_VER}" == "${PYTORCH_LATEST_NIGHTLY_SELECTOR}" ]]; then if [[ "${INSTALLED_TORCH_IS_NIGHTLY}" != "1" ]]; then - echo "[ERROR] --torch_ver nightly was requested, but ${INSTALLED_TORCH_FULL} is installed." >&2 + echo "[ERROR] --torch_ver ${PYTORCH_LATEST_NIGHTLY_SELECTOR} was requested, " \ + "but ${INSTALLED_TORCH_FULL} is installed." >&2 exit 1 fi elif [[ "${_TORCH_VER}" =~ ^[0-9]+\.[0-9]+$ ]]; then - if ! pytorch_is_supported_family "${_TORCH_VER}"; then + if ! pytorch_is_installable_family "${_TORCH_VER}"; then echo "[ERROR] Unsupported --torch_ver family '${_TORCH_VER}'" >&2 exit 1 fi @@ -133,7 +183,7 @@ if [[ "${_TORCH_VER_WAS_SET}" == "1" ]]; then REQUESTED_BUILD_TAG="$(pytorch_local_build_tag "${_TORCH_VER}")" REQUESTED_FAMILY="$(pytorch_version_family "${_TORCH_VER}")" || exit 1 - if ! pytorch_is_supported_family "${REQUESTED_FAMILY}"; then + if ! pytorch_is_installable_family "${REQUESTED_FAMILY}"; then echo "[ERROR] Unsupported --torch_ver value '${_TORCH_VER}'" >&2 exit 1 fi @@ -179,25 +229,52 @@ INDEX_URL="$(pytorch_index_url \ EXPECTED_VISION_VERSION="" if [[ "${INSTALLED_TORCH_IS_NIGHTLY}" == "1" ]]; then - TORCHVISION_DEV_FILE="${SCRIPTS_DIR}/../dependency/torchvision_dev.txt" - EXPECTED_VISION_FULL="$(pytorch_get_pinned_requirement_version \ - "${TORCHVISION_DEV_FILE}" torchvision)" - if [[ -z "${EXPECTED_VISION_FULL}" ]]; then - echo "[ERROR] ${TORCHVISION_DEV_FILE} must pin torchvision with 'torchvision==VERSION'." >&2 - exit 1 - fi + if [[ "${NIGHTLY_MODE}" == "latest" ]]; then + VISION_INFO="$(pytorch_get_installed_torchvision_info)" || { + echo "[ERROR] ${PYTORCH_LATEST_NIGHTLY_SELECTOR} requires an installed " \ + "TorchVision nightly from './ccex install'." >&2 + exit 1 + } + IFS=$'\t' read -r \ + INSTALLED_VISION_FULL \ + INSTALLED_VISION_BASE \ + INSTALLED_VISION_WHEEL_TAG \ + INSTALLED_VISION_IS_NIGHTLY <<< "${VISION_INFO}" + + if [[ "${INSTALLED_VISION_IS_NIGHTLY}" != "1" ]]; then + echo "[ERROR] Expected a TorchVision nightly, but found ${INSTALLED_VISION_FULL}." >&2 + exit 1 + fi + if [[ "${INSTALLED_VISION_WHEEL_TAG}" != "none" && \ + "${INSTALLED_VISION_WHEEL_TAG}" != "${INSTALLED_TORCH_WHEEL_TAG}" ]]; then + echo "[ERROR] Nightly wheel mismatch: torch uses ${INSTALLED_TORCH_WHEEL_TAG}, " \ + "but torchvision is ${INSTALLED_VISION_FULL}." >&2 + exit 1 + fi - PINNED_VISION_BUILD_TAG="$(pytorch_local_build_tag "${EXPECTED_VISION_FULL}")" - if [[ -n "${PINNED_VISION_BUILD_TAG}" && \ - "${PINNED_VISION_BUILD_TAG}" != "${INSTALLED_TORCH_WHEEL_TAG}" ]]; then - echo "[ERROR] torchvision_dev.txt pins +${PINNED_VISION_BUILD_TAG}, but Torch uses ${INSTALLED_TORCH_WHEEL_TAG}." >&2 - exit 1 - fi + EXPECTED_VISION_VERSION="${INSTALLED_VISION_BASE}" + echo "[INFO] Keeping installed latest nightly torchvision ${INSTALLED_VISION_FULL}" + else + TORCHVISION_DEV_FILE="${SCRIPTS_DIR}/../dependency/torchvision_dev.txt" + EXPECTED_VISION_FULL="$(pytorch_get_pinned_requirement_version \ + "${TORCHVISION_DEV_FILE}" torchvision)" + if [[ -z "${EXPECTED_VISION_FULL}" ]]; then + echo "[ERROR] ${TORCHVISION_DEV_FILE} must pin torchvision with 'torchvision==VERSION'." >&2 + exit 1 + fi - EXPECTED_VISION_VERSION="$(pytorch_strip_local_version "${EXPECTED_VISION_FULL}")" - echo "[INFO] Installing torchvision ${EXPECTED_VISION_FULL} from ${INDEX_URL}" - python3 -m pip install -r "${TORCHVISION_DEV_FILE}" \ - --index-url "${INDEX_URL}" || exit 1 + PINNED_VISION_BUILD_TAG="$(pytorch_local_build_tag "${EXPECTED_VISION_FULL}")" + if [[ -n "${PINNED_VISION_BUILD_TAG}" && \ + "${PINNED_VISION_BUILD_TAG}" != "${INSTALLED_TORCH_WHEEL_TAG}" ]]; then + echo "[ERROR] torchvision_dev.txt pins +${PINNED_VISION_BUILD_TAG}, but Torch uses ${INSTALLED_TORCH_WHEEL_TAG}." >&2 + exit 1 + fi + + EXPECTED_VISION_VERSION="$(pytorch_strip_local_version "${EXPECTED_VISION_FULL}")" + echo "[INFO] Installing torchvision ${EXPECTED_VISION_FULL} from ${INDEX_URL}" + python3 -m pip install -r "${TORCHVISION_DEV_FILE}" \ + --index-url "${INDEX_URL}" || exit 1 + fi else EXPECTED_VISION_VERSION="$(pytorch_resolve_torchvision_version \ "${INSTALLED_TORCH_BASE}")" || { @@ -278,7 +355,7 @@ if actual_tag != expected_tag: print(f"[INFO] Verified torch {torch_full} with torchvision {vision_full}") PY -python3 -m pip check || { +pytorch_pip_check "${INSTALLED_TORCH_IS_NIGHTLY}" || { echo "[ERROR] Installed Python packages have incompatible dependencies." >&2 exit 1 } diff --git a/test/unit_test/utils/test_torch_version_policy.py b/test/unit_test/utils/test_torch_version_policy.py new file mode 100644 index 000000000..f447608dd --- /dev/null +++ b/test/unit_test/utils/test_torch_version_policy.py @@ -0,0 +1,168 @@ +# Copyright (c) 2026 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the central PyTorch compatibility policy.""" + +from __future__ import annotations + +import json +import subprocess +import unittest +from pathlib import Path + +from tico.utils.compat import torch_version_policy as policy + + +class TorchVersionPolicyTest(unittest.TestCase): + """Keep installer and CI metadata internally consistent.""" + + def test_policy_is_valid(self) -> None: + """Validate all static policy invariants.""" + policy.validate_policy() + + def test_default_is_latest_supported_family(self) -> None: + """Use the newest qualified stable family as the source default.""" + self.assertEqual( + policy.DEFAULT_FAMILY, + policy.SUPPORTED_STABLE_FAMILIES[-1], + ) + + def test_pr_smoke_matrix_does_not_repeat_default(self) -> None: + """Keep PR compatibility jobs smaller than the scheduled matrix.""" + entries = policy.github_matrix("pr-smoke")["include"] + versions = [entry["torch-version"] for entry in entries] + + self.assertNotIn(policy.DEFAULT_FAMILY, versions) + self.assertIn(policy.SUPPORTED_STABLE_FAMILIES[0], versions) + for candidate in policy.QUALIFICATION_CANDIDATE_FAMILIES: + self.assertIn(candidate, versions) + + def test_scheduled_matrix_covers_all_tiers(self) -> None: + """Run every supported family and nightly in scheduled CI.""" + entries = policy.github_matrix("scheduled-full")["include"] + by_version = {entry["torch-version"]: entry for entry in entries} + + for family in policy.SUPPORTED_STABLE_FAMILIES: + self.assertIn(family, by_version) + self.assertFalse(by_version[family]["experimental"]) + for family in policy.QUALIFICATION_CANDIDATE_FAMILIES: + self.assertIn(family, by_version) + self.assertTrue(by_version[family]["experimental"]) + self.assertNotIn(policy.PINNED_NIGHTLY_SELECTOR, by_version) + self.assertTrue(by_version[policy.LATEST_NIGHTLY_SELECTOR]["experimental"]) + + def test_project_dependency_matches_policy(self) -> None: + """Keep package metadata aligned with the central family window.""" + project_root = Path(__file__).resolve().parents[3] + pyproject = (project_root / "pyproject.toml").read_text(encoding="utf-8") + self.assertIn(f'"{policy.PACKAGE_TORCH_REQUIREMENT}"', pyproject) + + def test_nightly_selectors_have_distinct_semantics(self) -> None: + """Keep reproducible and moving nightly channels explicitly separate.""" + self.assertTrue(policy.is_nightly_selector(policy.PINNED_NIGHTLY_SELECTOR)) + self.assertTrue(policy.is_nightly_selector(policy.LATEST_NIGHTLY_SELECTOR)) + self.assertNotEqual( + policy.PINNED_NIGHTLY_SELECTOR, + policy.LATEST_NIGHTLY_SELECTOR, + ) + + def test_latest_nightly_installation_is_owned_by_ccex(self) -> None: + """Keep the moving nightly resolver in ccex, not the composite action.""" + project_root = Path(__file__).resolve().parents[3] + action = ( + project_root / ".github/actions/setup-tico-test/action.yml" + ).read_text(encoding="utf-8") + install = (project_root / "infra/scripts/install.sh").read_text( + encoding="utf-8" + ) + configure = (project_root / "infra/scripts/test_configure.sh").read_text( + encoding="utf-8" + ) + + self.assertIn('./ccex install --dist --torch_ver "$TORCH_VERSION"', action) + self.assertIn('./ccex configure test --torch_ver "$TORCH_VERSION"', action) + self.assertNotIn("python3 -m pip", action) + self.assertIn( + "install_torch --pre --upgrade torch torchvision", + install, + ) + self.assertIn('NIGHTLY_MODE="latest"', configure) + self.assertIn( + "Keeping installed latest nightly torchvision", + configure, + ) + + def test_nightly_pip_check_filter_ignores_only_expected_conflict(self) -> None: + """Allow the bounded metadata mismatch only for a development Torch.""" + expected = ( + "tico 0.2.0 has requirement torch<2.14,>=2.10, " + "but you have torch 2.14.0.dev20260806." + ) + ignored, remaining = policy.filter_expected_nightly_pip_check(expected) + self.assertEqual(ignored, [expected]) + self.assertEqual(remaining, []) + + stable_conflict = expected.replace("2.14.0.dev20260806", "2.14.0") + ignored, remaining = policy.filter_expected_nightly_pip_check( + expected + "\n" + stable_conflict + ) + self.assertEqual(ignored, [expected]) + self.assertEqual(remaining, [stable_conflict]) + + def test_cli_matrix_is_compact_json(self) -> None: + """Keep matrix output safe for one-line GitHub Actions outputs.""" + completed = subprocess.run( + [ + "python3", + policy.__file__, + "ci-matrix", + "scheduled-full", + ], + check=True, + capture_output=True, + text=True, + ) + self.assertNotIn("\n", completed.stdout.rstrip("\n")) + self.assertEqual( + json.loads(completed.stdout), + policy.github_matrix("scheduled-full"), + ) + + def test_shell_assignments_can_be_sourced(self) -> None: + """Ensure Bash can consume the generated installer metadata.""" + script = ( + "set -euo pipefail\n" + + policy.shell_assignments() + + "\n" + + 'test "$PYTORCH_DEFAULT_FAMILY" = "' + + policy.DEFAULT_FAMILY + + '"\n' + + 'test "${#PYTORCH_SUPPORTED_FAMILIES[@]}" -eq 3\n' + + 'test "$PYTORCH_PINNED_NIGHTLY_SELECTOR" = "' + + policy.PINNED_NIGHTLY_SELECTOR + + '"\n' + + 'test "$PYTORCH_LATEST_NIGHTLY_SELECTOR" = "' + + policy.LATEST_NIGHTLY_SELECTOR + + '"\n' + + 'test "${PYTORCH_LATEST_STABLE_VERSION[' + + policy.DEFAULT_FAMILY + + ']}" = "' + + policy.LATEST_STABLE_VERSION[policy.DEFAULT_FAMILY] + + '"\n' + ) + subprocess.run(["bash"], input=script, check=True, text=True) + + +if __name__ == "__main__": + unittest.main() diff --git a/tico/__init__.py b/tico/__init__.py index 36a759bd2..5dd4cc793 100644 --- a/tico/__init__.py +++ b/tico/__init__.py @@ -18,6 +18,12 @@ from packaging.version import Version from tico.config import CompileConfigV1, get_default_config +from tico.utils.compat.torch_version_policy import ( + MINIMUM_SUPPORTED_VERSION, + QUALIFICATION_CANDIDATE_FAMILIES, + SUPPORTED_STABLE_FAMILIES, + version_family, +) from tico.utils.convert import convert, convert_from_exported_program, convert_from_pt2 __all__ = [ @@ -31,20 +37,27 @@ # THIS LINE IS AUTOMATICALLY GENERATED __version__ = "0.2.0" -MINIMUM_SUPPORTED_VERSION = "2.5.0" -SECURE_TORCH_VERSION = "2.6.0" +_torch_version = Version(torch.__version__) +_torch_family = version_family(str(_torch_version)) +_supported_range = f"{SUPPORTED_STABLE_FAMILIES[0]} ~ {SUPPORTED_STABLE_FAMILIES[-1]}" -if Version(torch.__version__) < Version(MINIMUM_SUPPORTED_VERSION): +if _torch_version < Version(MINIMUM_SUPPORTED_VERSION): warnings.warn( - f"TICO officially supports torch>={MINIMUM_SUPPORTED_VERSION}. " - f"You are using a lower version of torch ({torch.__version__}). " - f"We highly recommend to upgrade torch>={MINIMUM_SUPPORTED_VERSION} to avoid unexpected behaviors." - ) - -if Version(torch.__version__) < Version(SECURE_TORCH_VERSION): - warnings.warn( - f"Detected PyTorch version {torch.__version__}, which may include known security vulnerabilities. " - f"We recommend upgrading to {SECURE_TORCH_VERSION} or later for better security.\n" - "Upgrade command: pip install --upgrade torch\n" - "For more details, see: https://pytorch.org/security" + f"TICO supports PyTorch families {_supported_range}; " + f"detected torch {torch.__version__}. Upgrade to " + f"torch>={MINIMUM_SUPPORTED_VERSION}.", + stacklevel=2, ) +elif not _torch_version.is_devrelease: + if _torch_family in QUALIFICATION_CANDIDATE_FAMILIES: + warnings.warn( + f"PyTorch {_torch_family} is still a TICO qualification candidate. " + "Use it for compatibility testing, not release builds.", + stacklevel=2, + ) + elif _torch_family not in SUPPORTED_STABLE_FAMILIES: + warnings.warn( + f"TICO supports PyTorch families {_supported_range}; " + f"detected torch {torch.__version__}.", + stacklevel=2, + ) diff --git a/tico/utils/compat/torch_version_policy.py b/tico/utils/compat/torch_version_policy.py new file mode 100644 index 000000000..615fd0b4b --- /dev/null +++ b/tico/utils/compat/torch_version_policy.py @@ -0,0 +1,380 @@ +# Copyright (c) 2026 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Central PyTorch version and CI policy for TICO. + +Keep the policy in this module so that the installer, runtime warnings, tests, +and GitHub Actions all consume the same version window. + +A newly released stable family should first be added to +``QUALIFICATION_CANDIDATE_FAMILIES``. After the scheduled compatibility job has +remained green for the qualification window, move it into +``SUPPORTED_STABLE_FAMILIES``, promote it to ``DEFAULT_FAMILY``, and remove the +oldest supported family. +""" + +from __future__ import annotations + +import argparse +import json +import re +import shlex +import sys +from collections.abc import Iterable, Mapping, Sequence +from typing import Final + +DEFAULT_FAMILY: Final = "2.12" +SUPPORTED_STABLE_FAMILIES: Final = ("2.10", "2.11", "2.12") +QUALIFICATION_CANDIDATE_FAMILIES: Final = ("2.13",) +QUALIFICATION_WINDOW_DAYS: Final = 28 +PACKAGE_TORCH_REQUIREMENT: Final = "torch>=2.10,<2.14" +PINNED_NIGHTLY_SELECTOR: Final = "nightly" +LATEST_NIGHTLY_SELECTOR: Final = "nightly-latest" +NIGHTLY_SELECTORS: Final = ( + PINNED_NIGHTLY_SELECTOR, + LATEST_NIGHTLY_SELECTOR, +) + +LATEST_STABLE_VERSION: Final[dict[str, str]] = { + "2.10": "2.10.0", + "2.11": "2.11.0", + "2.12": "2.12.1", + "2.13": "2.13.0", +} + +# Values are ordered from newest to oldest. The installer selects the newest +# published wheel that does not exceed the detected host CUDA capability. +STABLE_CUDA_WHEELS: Final[dict[str, tuple[str, ...]]] = { + "2.10": ("13.0", "12.8", "12.6"), + "2.11": ("13.0", "12.8", "12.6"), + "2.12": ("13.2", "13.0", "12.6"), + "2.13": ("13.2", "13.0", "12.6"), +} + +NIGHTLY_CUDA_FALLBACKS: Final = ("13.2", "13.0", "12.6") + +INSTALLABLE_FAMILIES: Final = ( + *SUPPORTED_STABLE_FAMILIES, + *QUALIFICATION_CANDIDATE_FAMILIES, +) +MINIMUM_SUPPORTED_VERSION: Final = LATEST_STABLE_VERSION[SUPPORTED_STABLE_FAMILIES[0]] + +_FAMILY_PATTERN = re.compile(r"^(\d+\.\d+)") + + +def version_family(version: str) -> str: + """Return the ``major.minor`` family from a PyTorch version string.""" + match = _FAMILY_PATTERN.match(version) + if match is None: + raise ValueError(f"Unrecognized PyTorch version: {version}") + return match.group(1) + + +def is_supported_family(family: str) -> bool: + """Return whether a stable family is in TICO's qualified support window.""" + return family in SUPPORTED_STABLE_FAMILIES + + +def is_candidate_family(family: str) -> bool: + """Return whether a stable family is being qualified for future support.""" + return family in QUALIFICATION_CANDIDATE_FAMILIES + + +def is_installable_family(family: str) -> bool: + """Return whether the source installer may explicitly install a family.""" + return family in INSTALLABLE_FAMILIES + + +def is_nightly_selector(selector: str) -> bool: + """Return whether a CLI selector requests a PyTorch nightly channel.""" + return selector in NIGHTLY_SELECTORS + + +def filter_expected_nightly_pip_check(output: str) -> tuple[list[str], list[str]]: + """Split the intentional TICO/nightly metadata mismatch from real conflicts. + + PyPI metadata is bounded to configured stable families, while nightly CI + deliberately installs the next development family with ``--no-deps``. + ``pip check`` therefore reports exactly one expected TICO-to-Torch conflict. + All other lines remain errors. + """ + ignored: list[str] = [] + remaining: list[str] = [] + actual_marker = ", but you have torch " + + for line in output.splitlines(): + normalized = line.strip().lower() + if ( + normalized.startswith("tico ") + and " has requirement torch" in normalized + and actual_marker in normalized + ): + actual_version = normalized.split(actual_marker, maxsplit=1)[1].rstrip(".") + if ".dev" in actual_version: + ignored.append(line) + continue + if line.strip(): + remaining.append(line) + + return ignored, remaining + + +def _family_key(family: str) -> tuple[int, int]: + major, minor = family.split(".", maxsplit=1) + return int(major), int(minor) + + +def _validate_contiguous(families: Sequence[str], label: str) -> None: + keys = [_family_key(family) for family in families] + if keys != sorted(keys): + raise ValueError(f"{label} must be sorted from oldest to newest: {families}") + + for previous, current in zip(keys, keys[1:]): + if current[0] != previous[0] or current[1] != previous[1] + 1: + raise ValueError(f"{label} must be contiguous: {families}") + + +def validate_policy() -> None: + """Raise ``ValueError`` when policy metadata is internally inconsistent.""" + if len(set(NIGHTLY_SELECTORS)) != len(NIGHTLY_SELECTORS): + raise ValueError("Nightly selectors must be unique") + if any(selector in INSTALLABLE_FAMILIES for selector in NIGHTLY_SELECTORS): + raise ValueError("Nightly selectors must not overlap stable family names") + + if len(SUPPORTED_STABLE_FAMILIES) != 3: + raise ValueError("TICO must keep exactly three qualified stable families") + if DEFAULT_FAMILY not in SUPPORTED_STABLE_FAMILIES: + raise ValueError("DEFAULT_FAMILY must be a qualified stable family") + if DEFAULT_FAMILY != SUPPORTED_STABLE_FAMILIES[-1]: + raise ValueError("DEFAULT_FAMILY must be the newest qualified stable family") + + _validate_contiguous(SUPPORTED_STABLE_FAMILIES, "SUPPORTED_STABLE_FAMILIES") + + overlap = set(SUPPORTED_STABLE_FAMILIES).intersection( + QUALIFICATION_CANDIDATE_FAMILIES + ) + if overlap: + raise ValueError(f"Stable and candidate families overlap: {sorted(overlap)}") + + if QUALIFICATION_CANDIDATE_FAMILIES: + _validate_contiguous( + QUALIFICATION_CANDIDATE_FAMILIES, + "QUALIFICATION_CANDIDATE_FAMILIES", + ) + expected_first_candidate = ( + _family_key(SUPPORTED_STABLE_FAMILIES[-1])[0], + _family_key(SUPPORTED_STABLE_FAMILIES[-1])[1] + 1, + ) + if _family_key(QUALIFICATION_CANDIDATE_FAMILIES[0]) != expected_first_candidate: + raise ValueError( + "The first candidate must immediately follow the newest " + "supported family" + ) + + newest_installable_major, newest_installable_minor = _family_key( + INSTALLABLE_FAMILIES[-1] + ) + expected_package_requirement = ( + f"torch>={SUPPORTED_STABLE_FAMILIES[0]}," + f"<{newest_installable_major}.{newest_installable_minor + 1}" + ) + if PACKAGE_TORCH_REQUIREMENT != expected_package_requirement: + raise ValueError( + "PACKAGE_TORCH_REQUIREMENT must cover the supported and candidate " + "families, but exclude the next unknown stable family" + ) + + expected = set(INSTALLABLE_FAMILIES) + if set(LATEST_STABLE_VERSION) != expected: + raise ValueError( + "LATEST_STABLE_VERSION keys must match all supported and candidate families" + ) + if set(STABLE_CUDA_WHEELS) != expected: + raise ValueError( + "STABLE_CUDA_WHEELS keys must match all supported and candidate families" + ) + + for family, version in LATEST_STABLE_VERSION.items(): + if version_family(version) != family: + raise ValueError(f"Version {version} does not belong to family {family}") + for family, cuda_versions in STABLE_CUDA_WHEELS.items(): + if not cuda_versions: + raise ValueError(f"No CUDA wheel candidates configured for torch {family}") + + +def _matrix_entry( + torch_version: str, + *, + tier: str, + experimental: bool, +) -> dict[str, object]: + return { + "torch-version": torch_version, + "tier": tier, + "experimental": experimental, + } + + +def github_matrix(kind: str) -> dict[str, list[dict[str, object]]]: + """Return a GitHub Actions matrix for one compatibility test tier.""" + include: list[dict[str, object]] = [] + + if kind == "pr-smoke": + oldest = SUPPORTED_STABLE_FAMILIES[0] + if oldest != DEFAULT_FAMILY: + include.append( + _matrix_entry(oldest, tier="oldest-supported", experimental=False) + ) + include.extend( + _matrix_entry(family, tier="candidate", experimental=True) + for family in QUALIFICATION_CANDIDATE_FAMILIES + ) + elif kind == "scheduled-full": + include.extend( + _matrix_entry(family, tier="supported", experimental=False) + for family in SUPPORTED_STABLE_FAMILIES + ) + include.extend( + _matrix_entry(family, tier="candidate", experimental=True) + for family in QUALIFICATION_CANDIDATE_FAMILIES + ) + include.append( + _matrix_entry( + LATEST_NIGHTLY_SELECTOR, + tier="nightly-latest", + experimental=True, + ) + ) + elif kind == "release": + include.extend( + _matrix_entry(family, tier="supported", experimental=False) + for family in SUPPORTED_STABLE_FAMILIES + ) + else: + raise ValueError(f"Unknown matrix kind: {kind}") + + return {"include": include} + + +def _shell_array(values: Iterable[str]) -> str: + return "(" + " ".join(shlex.quote(value) for value in values) + ")" + + +def _shell_map(name: str, values: Mapping[str, str | Sequence[str]]) -> list[str]: + lines = [f"declare -A {name}=("] + for key, value in values.items(): + rendered = " ".join(value) if not isinstance(value, str) else value + lines.append(f" [{shlex.quote(key)}]={shlex.quote(rendered)}") + lines.append(")") + return lines + + +def shell_assignments() -> str: + """Render policy metadata as Bash declarations for installer scripts.""" + lines = [ + f"PYTORCH_DEFAULT_FAMILY={shlex.quote(DEFAULT_FAMILY)}", + "PYTORCH_SUPPORTED_FAMILIES=" + _shell_array(SUPPORTED_STABLE_FAMILIES), + "PYTORCH_CANDIDATE_FAMILIES=" + _shell_array(QUALIFICATION_CANDIDATE_FAMILIES), + "PYTORCH_INSTALLABLE_FAMILIES=" + _shell_array(INSTALLABLE_FAMILIES), + "PYTORCH_SUPPORTED_FAMILY_MIN=" + shlex.quote(SUPPORTED_STABLE_FAMILIES[0]), + "PYTORCH_SUPPORTED_FAMILY_MAX=" + shlex.quote(SUPPORTED_STABLE_FAMILIES[-1]), + "PYTORCH_INSTALLABLE_FAMILY_MIN=" + shlex.quote(INSTALLABLE_FAMILIES[0]), + "PYTORCH_INSTALLABLE_FAMILY_MAX=" + shlex.quote(INSTALLABLE_FAMILIES[-1]), + "PYTORCH_QUALIFICATION_WINDOW_DAYS=" + + shlex.quote(str(QUALIFICATION_WINDOW_DAYS)), + "PYTORCH_PINNED_NIGHTLY_SELECTOR=" + shlex.quote(PINNED_NIGHTLY_SELECTOR), + "PYTORCH_LATEST_NIGHTLY_SELECTOR=" + shlex.quote(LATEST_NIGHTLY_SELECTOR), + "PYTORCH_NIGHTLY_SELECTORS=" + _shell_array(NIGHTLY_SELECTORS), + ] + lines.extend(_shell_map("PYTORCH_LATEST_STABLE_VERSION", LATEST_STABLE_VERSION)) + lines.extend(_shell_map("PYTORCH_STABLE_CUDA_WHEELS", STABLE_CUDA_WHEELS)) + lines.append( + "PYTORCH_NIGHTLY_CUDA_FALLBACKS=" + _shell_array(NIGHTLY_CUDA_FALLBACKS) + ) + return "\n".join(lines) + + +def _range_text(families: Sequence[str]) -> str: + if len(families) == 1: + return families[0] + return f"{families[0]} ~ {families[-1]}" + + +def _build_parser() -> argparse.ArgumentParser: + parser = argparse.ArgumentParser(description=__doc__) + subparsers = parser.add_subparsers(dest="command", required=True) + subparsers.add_parser("validate", help="Validate policy invariants") + subparsers.add_parser("shell", help="Print Bash policy declarations") + subparsers.add_parser("default-family", help="Print the default Torch family") + subparsers.add_parser("supported-range", help="Print the qualified range") + subparsers.add_parser("installable-range", help="Print the installer range") + subparsers.add_parser( + "package-requirement", help="Print the package Torch requirement" + ) + subparsers.add_parser( + "filter-nightly-pip-check", + help="Ignore only the expected TICO-to-nightly Torch metadata conflict", + ) + + matrix_parser = subparsers.add_parser( + "ci-matrix", help="Print a compact GitHub Actions matrix" + ) + matrix_parser.add_argument( + "kind", + choices=("pr-smoke", "scheduled-full", "release"), + ) + return parser + + +def main(argv: Sequence[str] | None = None) -> int: + """Run the small CLI consumed by shell scripts and GitHub Actions.""" + args = _build_parser().parse_args(argv) + validate_policy() + + if args.command == "validate": + return 0 + if args.command == "shell": + print(shell_assignments()) + elif args.command == "default-family": + print(DEFAULT_FAMILY) + elif args.command == "supported-range": + print(_range_text(SUPPORTED_STABLE_FAMILIES)) + elif args.command == "installable-range": + print(_range_text(INSTALLABLE_FAMILIES)) + elif args.command == "package-requirement": + print(PACKAGE_TORCH_REQUIREMENT) + elif args.command == "filter-nightly-pip-check": + ignored, remaining = filter_expected_nightly_pip_check(sys.stdin.read()) + for line in ignored: + print(f"[WARN] Ignoring expected nightly metadata mismatch: {line}") + if remaining or not ignored: + for line in remaining: + print(line, file=sys.stderr) + if not ignored: + print( + "No expected TICO-to-nightly Torch mismatch was found.", + file=sys.stderr, + ) + return 1 + elif args.command == "ci-matrix": + print(json.dumps(github_matrix(args.kind), separators=(",", ":"))) + else: # pragma: no cover - argparse rejects unknown commands. + raise AssertionError(f"Unhandled command: {args.command}") + return 0 + + +validate_policy() + +if __name__ == "__main__": + raise SystemExit(main()) From d655c802a0bfd83f242ded12cdf0f033d87151d0 Mon Sep 17 00:00:00 2001 From: seongwoo Date: Mon, 10 Aug 2026 21:37:09 +0900 Subject: [PATCH 2/3] change cron. --- .../workflows/check-pytorch-compatibility.yaml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/check-pytorch-compatibility.yaml b/.github/workflows/check-pytorch-compatibility.yaml index 3aca07a77..630d957c0 100644 --- a/.github/workflows/check-pytorch-compatibility.yaml +++ b/.github/workflows/check-pytorch-compatibility.yaml @@ -2,10 +2,16 @@ name: Check PyTorch Compatibility on: schedule: - # Daily latest-nightly smoke at 03:17 KST. - - cron: '17 18 * * *' - # Weekly full matrix on Monday at 03:41 KST. - - cron: '41 18 * * 0' + # Tuesday-Sunday, 03:30 KST: + # Run the nightly smoke test. + # + # Monday is excluded because the weekly full matrix below + # already tests PyTorch nightly. + - cron: "30 18 * * 1-6" + + # Monday, 04:30 KST: + # Run the full supported/candidate/nightly matrix. + - cron: "30 19 * * 0" workflow_dispatch: permissions: @@ -57,7 +63,7 @@ jobs: nightly_smoke: name: Daily latest-nightly smoke - if: github.event_name == 'schedule' && github.event.schedule == '17 18 * * *' + if: github.event_name == 'schedule' && github.event.schedule == '30 18 * * 1-6' needs: - resolve_torch_policy - build_package @@ -89,7 +95,7 @@ jobs: name: Full test (${{ matrix.tier }}, torch ${{ matrix.torch-version }}) if: >- github.event_name == 'workflow_dispatch' || - (github.event_name == 'schedule' && github.event.schedule == '41 18 * * 0') + (github.event_name == 'schedule' && github.event.schedule == '30 19 * * 0') needs: - resolve_torch_policy - build_package From 86299403d3d9b9c13ac1953f3d9fb882ca9c396e Mon Sep 17 00:00:00 2001 From: seongwoo Date: Mon, 10 Aug 2026 23:11:29 +0900 Subject: [PATCH 3/3] allow legacy versions. --- README.md | 8 +- docs/README.md | 2 +- docs/development.md | 18 ++- docs/getting_started.md | 17 ++- docs/requirements.md | 9 +- docs/torch_version_policy.md | 53 ++++--- infra/scripts/install.sh | 12 +- infra/scripts/pytorch_package_utils.sh | 24 --- infra/scripts/test_configure.sh | 2 +- .../utils/test_torch_version_policy.py | 45 +++--- tico/__init__.py | 22 +-- tico/utils/compat/torch_version_policy.py | 139 ++++++++---------- 12 files changed, 172 insertions(+), 179 deletions(-) diff --git a/README.md b/README.md index fa704dc64..0e33234b7 100644 --- a/README.md +++ b/README.md @@ -48,13 +48,15 @@ cd TICO | Option | Description | |---|---| | `--dist` | Install from the built wheel (default is editable mode) | -| `--torch_ver ` | Torch version to install: a configured family (`2.10` ~ `2.13`; `2.13` is a candidate), an exact version (e.g. `2.13.0+cu132`), `nightly` (repository-pinned), or `nightly-latest` (moving Torch/TorchVision pair). Default: `2.12` | +| `--torch_ver ` | Torch version to install: a configured family (`2.5` ~ `2.13`; `2.5` ~ `2.9` are legacy best-effort and `2.13` is a candidate), an exact version (e.g. `2.13.0+cu132`), `nightly` (repository-pinned), or `nightly-latest` (moving Torch/TorchVision pair). Default: `2.12` | | `--cuda_ver ` | Override the detected CUDA version (e.g. `12.1`) | | `--cpu_only` | Force a CPU-only Torch installation | `./ccex install` pins the newest qualified stable family for a reproducible source -setup. See the [PyTorch version policy](./docs/torch_version_policy.md) for the -support window and CI tiers. +setup. Older configured families remain explicitly installable, while `pyproject.toml` +keeps an unbounded `torch` dependency so `pip install` does not reject a user-managed +Torch version. See the [PyTorch version policy](./docs/torch_version_policy.md) for the +installer, support, and CI tiers. ## Quick start diff --git a/docs/README.md b/docs/README.md index c0bdd5f09..0ccc72955 100644 --- a/docs/README.md +++ b/docs/README.md @@ -11,7 +11,7 @@ workflows, supported behavior, and the test strategy. | [Getting Started](./getting_started.md) | TICO users | Install TICO, convert PyTorch modules or `.pt2` files, configure conversion, run Circle models, and inspect artifacts. | | [System Design](./design.md) | Contributors | Understand the actual `main`-branch conversion pipeline, package boundaries, pass execution, serialization, runtime behavior, and extension points. | | [Development Guide](./development.md) | Contributors | Set up a source checkout, select a Torch build, run tests and model tests, format code, collect coverage, and understand PR CI. | -| [PyTorch Version Policy](./torch_version_policy.md) | Users and contributors | Understand the qualified stable window, default and candidate families, CI tiers, promotion rules, and release-branch policy. | +| [PyTorch Version Policy](./torch_version_policy.md) | Users and contributors | Understand package installation, legacy installable families, the qualified stable window, candidates, CI tiers, and promotion rules. | | [Requirements](./requirements.md) | Users and contributors | Define the currently supported contract, constraints, quality expectations, benchmark targets, and non-goals. | | [System Test Guide](./system_test.md) | Contributors | Explain test layers, end-to-end validation, test commands, CI coverage, performance tests, and maintenance rules. | diff --git a/docs/development.md b/docs/development.md index 5f3c87a0e..f0666a188 100644 --- a/docs/development.md +++ b/docs/development.md @@ -65,6 +65,7 @@ candidate, a repository-pinned nightly, or the latest published nightly pair: ```bash ./ccex install --torch_ver 2.12 +./ccex install --torch_ver 2.7 # legacy best-effort ./ccex install --torch_ver 2.10 ./ccex install --torch_ver 2.12.1+cu132 ./ccex install --torch_ver 2.13 @@ -72,11 +73,13 @@ candidate, a repository-pinned nightly, or the latest published nightly pair: ./ccex install --torch_ver nightly-latest # latest published nightly pair ``` -TICO qualifies the latest three stable Torch families: 2.10, 2.11, and 2.12. The -default family is 2.12. Torch 2.13 is installable as a qualification candidate but is -not part of the release-support window. Family requests resolve to a project-pinned -patch rather than allowing pip to select an arbitrary patch release. `nightly` uses the -versions pinned under `infra/dependency/`; `nightly-latest` resolves Torch and +TICO keeps Torch 2.5 through 2.9 as legacy best-effort source-install choices, +qualifies 2.10, 2.11, and 2.12, and uses 2.12 as the default. Torch 2.13 is installable +as a qualification candidate but is not part of the release-support window. Family +requests resolve to a project-pinned patch rather than allowing pip to select an +arbitrary patch release. The package metadata itself keeps a bare `torch` dependency, +so a normal `pip install` does not reject a user-managed older version. `nightly` uses +the versions pinned under `infra/dependency/`; `nightly-latest` resolves Torch and TorchVision together from one moving nightly index. Compute-platform options: @@ -91,9 +94,10 @@ Compute-platform options: `--cpu_only` and `--cuda_ver` are mutually exclusive. -When no Torch version is explicitly requested and a qualified stable Torch package is +When no Torch version is explicitly requested and a configured stable Torch package is already installed, `./ccex install` preserves that installation if its compute platform -is compatible. `./ccex configure test` then installs the matching TorchVision package +is compatible. This includes legacy best-effort families. `./ccex configure test` then +installs the matching TorchVision package and verifies the final package pair with `pip check`. Nightly selectors are deliberately re-resolved: `nightly` restores the repository pin, while `nightly-latest` upgrades the Torch/TorchVision pair together before test configuration validates it. diff --git a/docs/getting_started.md b/docs/getting_started.md index fc3230c49..f85156045 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -25,11 +25,13 @@ workflow; a Circle runtime is needed only when the generated model is executed. - A supported PyTorch installation - An inference-mode, `torch.export`-compatible module -TICO's qualified stable support window is Torch 2.10 through 2.12, and the -default source-install family is 2.12. Torch 2.13 is available as a qualification -candidate. `nightly` is repository-pinned for reproducibility, while -`nightly-latest` is used as a moving early-compatibility signal rather than release -support. See the [PyTorch Version Policy](./torch_version_policy.md) and +TICO's source installer keeps Torch 2.5 through 2.9 as legacy best-effort choices, +while the qualified stable support window is 2.10 through 2.12 and the default is 2.12. +Torch 2.13 is available as a qualification candidate. The package metadata keeps a +bare `torch` dependency so a normal `pip install` can coexist with a user-managed old +version. `nightly` is repository-pinned for reproducibility, while `nightly-latest` is +used as a moving early-compatibility signal rather than release support. See the +[PyTorch Version Policy](./torch_version_policy.md) and [Development Guide](./development.md) for exact installation and CI details. > [!IMPORTANT] @@ -63,6 +65,7 @@ Useful source-install options include: ```bash ./ccex install --cpu_only ./ccex install --torch_ver 2.12 +./ccex install --torch_ver 2.7 # legacy best-effort ./ccex install --torch_ver 2.10 ./ccex install --torch_ver 2.13 ./ccex install --torch_ver nightly @@ -409,8 +412,8 @@ The conversion pipeline writes images such as `1_after_decompose.png`, - [System Design](./design.md): conversion stages, invariants, serialization, and extension points -- [PyTorch Version Policy](./torch_version_policy.md): supported families, default and - candidate versions, CI tiers, and promotion rules +- [PyTorch Version Policy](./torch_version_policy.md): package installation, legacy and + supported families, candidate versions, CI tiers, and promotion rules - [Development Guide](./development.md): source setup, tests, formatting, and CI - [Quantization](../tico/quantization/README.md): quantize a model before Circle export - [Quantization examples](../tico/quantization/examples/README.md): config-driven LLM diff --git a/docs/requirements.md b/docs/requirements.md index 6f578c610..782d0c948 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -226,7 +226,9 @@ The package metadata requires Python 3.10 or newer. ### PyTorch -- Package metadata accepts `torch>=2.10,<2.14`. +- Package metadata intentionally declares the unbounded dependency `torch`, so + installation does not reject a user-managed older or newer Torch version. +- Source tooling keeps Torch 2.5 through 2.9 as legacy best-effort install choices. - The qualified stable support window is Torch 2.10, 2.11, and 2.12. - The default source-install family is 2.12. - Torch 2.13 is explicitly installable as a qualification candidate and is not part of @@ -239,8 +241,9 @@ The package metadata requires Python 3.10 or newer. on the oldest supported family, and non-blocking candidate smoke. Scheduled CI runs daily `nightly-latest` smoke and a weekly full matrix. -Package compatibility, source-installer acceptance, qualified release support, and CI -coverage are intentionally separate claims. The exact policy is defined in +Package installation, source-installer acceptance, qualified release support, and CI +coverage are intentionally separate claims. An installable legacy version is not a +promise of regression fixes or CI coverage. The exact policy is defined in [`tico/utils/compat/torch_version_policy.py`](../tico/utils/compat/torch_version_policy.py). ### Operating system diff --git a/docs/torch_version_policy.md b/docs/torch_version_policy.md index 114e255c0..ba5394090 100644 --- a/docs/torch_version_policy.md +++ b/docs/torch_version_policy.md @@ -9,22 +9,29 @@ The source of truth is The installer and GitHub Actions read this module instead of maintaining separate hard-coded version lists. -## Support window +## Package metadata and policy tiers -TICO keeps these tiers: +TICO deliberately separates package installation from qualified compatibility: | Tier | Meaning | Current value | |---|---|---| +| Package dependency | Allows installation into an existing Torch environment | Unbounded `torch` | +| Legacy installable | Accepted by `./ccex install`, but maintained on a best-effort basis | `2.5` through `2.9` | +| Supported stable | Qualified stable families used for release support | `2.10`, `2.11`, `2.12` | | Default | Newest qualified stable family used by `./ccex install` | `2.12` | -| Supported stable | Latest three qualified stable families | `2.10`, `2.11`, `2.12` | | Candidate | Newly released stable family under qualification | `2.13` | | Pinned nightly | Reproducible nightly channel for local debugging | `nightly` | | Moving nightly | Latest compatible Torch/TorchVision nightly pair | `nightly-latest` | -The package metadata allows the qualified families and the current candidate -(`torch>=2.10,<2.14`) while excluding the next unknown stable family. Exact default -pinning is left to `./ccex install`, because an exact `Requires-Dist` pin would -prevent users and CI from selecting another configured family. +`pyproject.toml` declares `"torch"` without a version specifier. Therefore an +already-installed older Torch release can satisfy `pip install tico`; package metadata +does not force an upgrade or reject it. This is an installation contract, not a claim +that every Torch release is qualified. + +The source installer has explicit metadata for families 2.5 through 2.13. Families +2.5 through 2.9 are retained for existing users and reproducibility, but are not run in +the regular CI matrix. Their usability also depends on PyTorch publishing a wheel for +the requested Python, operating-system, and compute-platform combination. ## Nightly selectors @@ -51,7 +58,9 @@ Both selectors are re-resolved when explicitly requested. `nightly` restores the repository pin, while `nightly-latest` checks the moving index for a newer compatible pair. `configure test` validates that a pinned request matches the repository pin and that a latest request already contains an importable nightly TorchVision build with a -matching CPU/CUDA wheel tag. +matching CPU/CUDA wheel tag. Because the package dependency is unbounded, nightly +setup uses the normal `pip check` result and does not suppress a TICO/Torch metadata +conflict. ## CI tiers @@ -65,14 +74,14 @@ matching CPU/CUDA wheel tag. | Weekly schedule | Candidate families and `nightly-latest` | Full unit-test suite | Separate workflow | | Official release | All supported stable families | Full unit-test suite | Yes | +Legacy installable families are intentionally omitted from routine CI. A project that +still depends on one of those families should pin it explicitly and run its own +application-level verification. + The wheel is built once per workflow run and reused by all test jobs. PR jobs do not upload one wheel per PyTorch family. Scheduled failures remain red so that maintainers receive a useful upstream signal, but they do not participate in PR branch protection. -Nightly builds are intentionally outside the stable package bound. Test setup ignores -only TICO's expected Torch metadata mismatch for a development build and still fails on -every other `pip check` conflict. - ## Promoting a new stable family When PyTorch `2.N` is released: @@ -83,20 +92,20 @@ When PyTorch `2.N` is released: 3. Keep it as an experimental candidate for 28 days after the candidate CI is merged while daily and weekly jobs collect compatibility results. 4. After qualification, append it to `SUPPORTED_STABLE_FAMILIES`, set it as - `DEFAULT_FAMILY`, remove the oldest supported family, and clear it from the - candidate tuple. -5. Update the bounded Torch requirement in `pyproject.toml` when either edge of - the configured family window changes. + `DEFAULT_FAMILY`, move the oldest supported family to + `LEGACY_INSTALLABLE_FAMILIES`, and clear it from the candidate tuple. +5. Keep the package dependency unbounded unless TICO becomes fundamentally + un-installable with a known range of Torch releases. -The policy unit test rejects a non-contiguous window, a default that is not the -newest supported family, missing version metadata, a stale package minimum, duplicated -nightly selectors, and a scheduled matrix that uses the reproducible pin instead of the -moving nightly channel. +The policy unit test rejects overlapping or non-contiguous tiers, a default that is not +the newest supported family, incomplete installer metadata, a bounded package Torch +dependency, duplicated nightly selectors, and a scheduled matrix that uses the +reproducible pin instead of the moving nightly channel. ## Release branches A `rel/*` branch should keep the default family it had when the branch was cut. Patch releases of that family may be adopted, but the branch should not shift its -three-family window unless a security or compatibility issue requires it. A release -branch may keep its own pinned `nightly` requirements for reproduction; moving +qualified three-family window unless a security or compatibility issue requires it. A +release branch may keep its own pinned `nightly` requirements for reproduction; moving `nightly-latest` results are advisory only. diff --git a/infra/scripts/install.sh b/infra/scripts/install.sh index aa292ff68..44c6897e9 100644 --- a/infra/scripts/install.sh +++ b/infra/scripts/install.sh @@ -185,12 +185,12 @@ fi SKIP_TORCH_INSTALL=0 if [[ -n "${INSTALLED_TORCH_FULL}" ]]; then - # With no explicit Torch version, preserve any supported stable family. If a + # With no explicit Torch version, preserve any configured stable family. If a # compute-platform option requires reinstalling the wheel, reinstall the same - # family at its latest supported patch rather than falling back to the default. + # family at its project-pinned patch rather than falling back to the default. if [[ "${_TORCH_VER_WAS_SET}" == "0" && \ "${INSTALLED_TORCH_IS_NIGHTLY}" == "0" ]] && \ - pytorch_is_supported_family "${INSTALLED_TORCH_FAMILY}"; then + pytorch_is_installable_family "${INSTALLED_TORCH_FAMILY}"; then REQUESTED_FAMILY="${INSTALLED_TORCH_FAMILY}" RESOLVED_TORCH_VERSION="$(pytorch_resolve_latest_stable_version \ "${REQUESTED_FAMILY}")" || exit 1 @@ -199,8 +199,8 @@ if [[ -n "${INSTALLED_TORCH_FULL}" ]]; then if installed_compute_matches_request "${INSTALLED_TORCH_WHEEL_TAG}"; then if [[ "${_TORCH_VER_WAS_SET}" == "0" ]]; then if [[ "${INSTALLED_TORCH_IS_NIGHTLY}" == "0" ]] && \ - pytorch_is_supported_family "${INSTALLED_TORCH_FAMILY}"; then - echo "[INFO] Supported torch ${INSTALLED_TORCH_FULL} already present — keeping it" + pytorch_is_installable_family "${INSTALLED_TORCH_FAMILY}"; then + echo "[INFO] Configured torch ${INSTALLED_TORCH_FULL} already present — keeping it" SKIP_TORCH_INSTALL=1 RESOLVED_TORCH_VERSION="${INSTALLED_TORCH_BASE}" fi @@ -350,7 +350,7 @@ if [[ "${_DIST}" -eq 1 ]]; then "${CCEX_PROJECT_PATH}"/dist/tico*.whl || exit 1 else echo "[INFO] Installing TICO in editable mode" - python3 -m pip install --no-deps --editable "${CCEX_PROJECT_PATH}" || exit 1 + python3 -m pip install --editable "${CCEX_PROJECT_PATH}" || exit 1 fi # TorchVision is installed by `./ccex configure test`, so a global `pip check` diff --git a/infra/scripts/pytorch_package_utils.sh b/infra/scripts/pytorch_package_utils.sh index adaf324ef..7dc0efae0 100644 --- a/infra/scripts/pytorch_package_utils.sh +++ b/infra/scripts/pytorch_package_utils.sh @@ -334,27 +334,3 @@ is_nightly = "1" if ".dev" in base_version else "0" print("\t".join((full_version, base_version, wheel_tag, is_nightly))) PY } - -pytorch_pip_check() { - local allow_nightly_mismatch="${1:-0}" - local output - local status - - if output="$(python3 -m pip check 2>&1)"; then - [[ -n "${output}" ]] && printf '%s\n' "${output}" - return 0 - else - status=$? - fi - - if [[ "${allow_nightly_mismatch}" == "1" ]]; then - if printf '%s\n' "${output}" | \ - python3 "${PYTORCH_POLICY_FILE}" filter-nightly-pip-check; then - return 0 - fi - return "${status}" - fi - - printf '%s\n' "${output}" >&2 - return "${status}" -} diff --git a/infra/scripts/test_configure.sh b/infra/scripts/test_configure.sh index 0a27642bc..97a05e3bd 100755 --- a/infra/scripts/test_configure.sh +++ b/infra/scripts/test_configure.sh @@ -355,7 +355,7 @@ if actual_tag != expected_tag: print(f"[INFO] Verified torch {torch_full} with torchvision {vision_full}") PY -pytorch_pip_check "${INSTALLED_TORCH_IS_NIGHTLY}" || { +python3 -m pip check || { echo "[ERROR] Installed Python packages have incompatible dependencies." >&2 exit 1 } diff --git a/test/unit_test/utils/test_torch_version_policy.py b/test/unit_test/utils/test_torch_version_policy.py index f447608dd..006bf8297 100644 --- a/test/unit_test/utils/test_torch_version_policy.py +++ b/test/unit_test/utils/test_torch_version_policy.py @@ -17,6 +17,7 @@ from __future__ import annotations import json +import re import subprocess import unittest from pathlib import Path @@ -62,11 +63,25 @@ def test_scheduled_matrix_covers_all_tiers(self) -> None: self.assertNotIn(policy.PINNED_NIGHTLY_SELECTOR, by_version) self.assertTrue(by_version[policy.LATEST_NIGHTLY_SELECTOR]["experimental"]) - def test_project_dependency_matches_policy(self) -> None: - """Keep package metadata aligned with the central family window.""" + def test_legacy_families_remain_installable_but_not_qualified(self) -> None: + """Keep older source-install selections available on a best-effort basis.""" + for family in policy.LEGACY_INSTALLABLE_FAMILIES: + self.assertTrue(policy.is_legacy_installable_family(family)) + self.assertTrue(policy.is_installable_family(family)) + self.assertFalse(policy.is_supported_family(family)) + self.assertIn(family, policy.LATEST_STABLE_VERSION) + self.assertIn(family, policy.STABLE_CUDA_WHEELS) + + def test_project_declares_unbounded_torch_dependency(self) -> None: + """Do not let package metadata reject unqualified PyTorch versions.""" project_root = Path(__file__).resolve().parents[3] pyproject = (project_root / "pyproject.toml").read_text(encoding="utf-8") - self.assertIn(f'"{policy.PACKAGE_TORCH_REQUIREMENT}"', pyproject) + torch_dependencies = re.findall( + r'^\s*"(torch(?:[<>=!~][^"]*)?)",\s*$', + pyproject, + flags=re.MULTILINE, + ) + self.assertEqual(torch_dependencies, [policy.PACKAGE_TORCH_DEPENDENCY]) def test_nightly_selectors_have_distinct_semantics(self) -> None: """Keep reproducible and moving nightly channels explicitly separate.""" @@ -89,6 +104,9 @@ def test_latest_nightly_installation_is_owned_by_ccex(self) -> None: configure = (project_root / "infra/scripts/test_configure.sh").read_text( encoding="utf-8" ) + package_utils = ( + project_root / "infra/scripts/pytorch_package_utils.sh" + ).read_text(encoding="utf-8") self.assertIn('./ccex install --dist --torch_ver "$TORCH_VERSION"', action) self.assertIn('./ccex configure test --torch_ver "$TORCH_VERSION"', action) @@ -102,23 +120,9 @@ def test_latest_nightly_installation_is_owned_by_ccex(self) -> None: "Keeping installed latest nightly torchvision", configure, ) - - def test_nightly_pip_check_filter_ignores_only_expected_conflict(self) -> None: - """Allow the bounded metadata mismatch only for a development Torch.""" - expected = ( - "tico 0.2.0 has requirement torch<2.14,>=2.10, " - "but you have torch 2.14.0.dev20260806." - ) - ignored, remaining = policy.filter_expected_nightly_pip_check(expected) - self.assertEqual(ignored, [expected]) - self.assertEqual(remaining, []) - - stable_conflict = expected.replace("2.14.0.dev20260806", "2.14.0") - ignored, remaining = policy.filter_expected_nightly_pip_check( - expected + "\n" + stable_conflict - ) - self.assertEqual(ignored, [expected]) - self.assertEqual(remaining, [stable_conflict]) + self.assertIn("python3 -m pip check", configure) + self.assertNotIn("pytorch_pip_check", package_utils) + self.assertNotIn("filter-nightly-pip-check", package_utils) def test_cli_matrix_is_compact_json(self) -> None: """Keep matrix output safe for one-line GitHub Actions outputs.""" @@ -148,6 +152,7 @@ def test_shell_assignments_can_be_sourced(self) -> None: + 'test "$PYTORCH_DEFAULT_FAMILY" = "' + policy.DEFAULT_FAMILY + '"\n' + + 'test "${#PYTORCH_LEGACY_INSTALLABLE_FAMILIES[@]}" -eq 5\n' + 'test "${#PYTORCH_SUPPORTED_FAMILIES[@]}" -eq 3\n' + 'test "$PYTORCH_PINNED_NIGHTLY_SELECTOR" = "' + policy.PINNED_NIGHTLY_SELECTOR diff --git a/tico/__init__.py b/tico/__init__.py index 5dd4cc793..e432c716d 100644 --- a/tico/__init__.py +++ b/tico/__init__.py @@ -19,7 +19,7 @@ from tico.config import CompileConfigV1, get_default_config from tico.utils.compat.torch_version_policy import ( - MINIMUM_SUPPORTED_VERSION, + LEGACY_INSTALLABLE_FAMILIES, QUALIFICATION_CANDIDATE_FAMILIES, SUPPORTED_STABLE_FAMILIES, version_family, @@ -41,15 +41,15 @@ _torch_family = version_family(str(_torch_version)) _supported_range = f"{SUPPORTED_STABLE_FAMILIES[0]} ~ {SUPPORTED_STABLE_FAMILIES[-1]}" -if _torch_version < Version(MINIMUM_SUPPORTED_VERSION): - warnings.warn( - f"TICO supports PyTorch families {_supported_range}; " - f"detected torch {torch.__version__}. Upgrade to " - f"torch>={MINIMUM_SUPPORTED_VERSION}.", - stacklevel=2, - ) -elif not _torch_version.is_devrelease: - if _torch_family in QUALIFICATION_CANDIDATE_FAMILIES: +if not _torch_version.is_devrelease: + if _torch_family in LEGACY_INSTALLABLE_FAMILIES: + warnings.warn( + f"PyTorch {_torch_family} is a legacy TICO install target. " + "It remains available on a best-effort basis but is not covered " + f"by the qualified CI window {_supported_range}.", + stacklevel=2, + ) + elif _torch_family in QUALIFICATION_CANDIDATE_FAMILIES: warnings.warn( f"PyTorch {_torch_family} is still a TICO qualification candidate. " "Use it for compatibility testing, not release builds.", @@ -57,7 +57,7 @@ ) elif _torch_family not in SUPPORTED_STABLE_FAMILIES: warnings.warn( - f"TICO supports PyTorch families {_supported_range}; " + f"TICO officially supports PyTorch families {_supported_range}; " f"detected torch {torch.__version__}.", stacklevel=2, ) diff --git a/tico/utils/compat/torch_version_policy.py b/tico/utils/compat/torch_version_policy.py index 615fd0b4b..0e6c1f1c6 100644 --- a/tico/utils/compat/torch_version_policy.py +++ b/tico/utils/compat/torch_version_policy.py @@ -17,11 +17,15 @@ Keep the policy in this module so that the installer, runtime warnings, tests, and GitHub Actions all consume the same version window. +The package dependency intentionally remains unbounded so users can install TICO +into environments that already use older PyTorch releases. Installer acceptance, +qualified support, and CI coverage are separate policy tiers. + A newly released stable family should first be added to ``QUALIFICATION_CANDIDATE_FAMILIES``. After the scheduled compatibility job has remained green for the qualification window, move it into -``SUPPORTED_STABLE_FAMILIES``, promote it to ``DEFAULT_FAMILY``, and remove the -oldest supported family. +``SUPPORTED_STABLE_FAMILIES``, promote it to ``DEFAULT_FAMILY``, and move the +oldest supported family into ``LEGACY_INSTALLABLE_FAMILIES``. """ from __future__ import annotations @@ -30,15 +34,15 @@ import json import re import shlex -import sys from collections.abc import Iterable, Mapping, Sequence from typing import Final DEFAULT_FAMILY: Final = "2.12" +LEGACY_INSTALLABLE_FAMILIES: Final = ("2.5", "2.6", "2.7", "2.8", "2.9") SUPPORTED_STABLE_FAMILIES: Final = ("2.10", "2.11", "2.12") QUALIFICATION_CANDIDATE_FAMILIES: Final = ("2.13",) QUALIFICATION_WINDOW_DAYS: Final = 28 -PACKAGE_TORCH_REQUIREMENT: Final = "torch>=2.10,<2.14" +PACKAGE_TORCH_DEPENDENCY: Final = "torch" PINNED_NIGHTLY_SELECTOR: Final = "nightly" LATEST_NIGHTLY_SELECTOR: Final = "nightly-latest" NIGHTLY_SELECTORS: Final = ( @@ -47,6 +51,11 @@ ) LATEST_STABLE_VERSION: Final[dict[str, str]] = { + "2.5": "2.5.1", + "2.6": "2.6.0", + "2.7": "2.7.1", + "2.8": "2.8.0", + "2.9": "2.9.1", "2.10": "2.10.0", "2.11": "2.11.0", "2.12": "2.12.1", @@ -56,6 +65,11 @@ # Values are ordered from newest to oldest. The installer selects the newest # published wheel that does not exceed the detected host CUDA capability. STABLE_CUDA_WHEELS: Final[dict[str, tuple[str, ...]]] = { + "2.5": ("12.4", "12.1", "11.8"), + "2.6": ("12.6", "12.4", "11.8"), + "2.7": ("12.8", "12.6", "11.8"), + "2.8": ("12.9", "12.8", "12.6"), + "2.9": ("13.0", "12.8", "12.6"), "2.10": ("13.0", "12.8", "12.6"), "2.11": ("13.0", "12.8", "12.6"), "2.12": ("13.2", "13.0", "12.6"), @@ -65,6 +79,7 @@ NIGHTLY_CUDA_FALLBACKS: Final = ("13.2", "13.0", "12.6") INSTALLABLE_FAMILIES: Final = ( + *LEGACY_INSTALLABLE_FAMILIES, *SUPPORTED_STABLE_FAMILIES, *QUALIFICATION_CANDIDATE_FAMILIES, ) @@ -81,6 +96,11 @@ def version_family(version: str) -> str: return match.group(1) +def is_legacy_installable_family(family: str) -> bool: + """Return whether a stable family is accepted on a best-effort basis.""" + return family in LEGACY_INSTALLABLE_FAMILIES + + def is_supported_family(family: str) -> bool: """Return whether a stable family is in TICO's qualified support window.""" return family in SUPPORTED_STABLE_FAMILIES @@ -101,35 +121,6 @@ def is_nightly_selector(selector: str) -> bool: return selector in NIGHTLY_SELECTORS -def filter_expected_nightly_pip_check(output: str) -> tuple[list[str], list[str]]: - """Split the intentional TICO/nightly metadata mismatch from real conflicts. - - PyPI metadata is bounded to configured stable families, while nightly CI - deliberately installs the next development family with ``--no-deps``. - ``pip check`` therefore reports exactly one expected TICO-to-Torch conflict. - All other lines remain errors. - """ - ignored: list[str] = [] - remaining: list[str] = [] - actual_marker = ", but you have torch " - - for line in output.splitlines(): - normalized = line.strip().lower() - if ( - normalized.startswith("tico ") - and " has requirement torch" in normalized - and actual_marker in normalized - ): - actual_version = normalized.split(actual_marker, maxsplit=1)[1].rstrip(".") - if ".dev" in actual_version: - ignored.append(line) - continue - if line.strip(): - remaining.append(line) - - return ignored, remaining - - def _family_key(family: str) -> tuple[int, int]: major, minor = family.split(".", maxsplit=1) return int(major), int(minor) @@ -159,50 +150,65 @@ def validate_policy() -> None: if DEFAULT_FAMILY != SUPPORTED_STABLE_FAMILIES[-1]: raise ValueError("DEFAULT_FAMILY must be the newest qualified stable family") + _validate_contiguous( + LEGACY_INSTALLABLE_FAMILIES, + "LEGACY_INSTALLABLE_FAMILIES", + ) _validate_contiguous(SUPPORTED_STABLE_FAMILIES, "SUPPORTED_STABLE_FAMILIES") + _validate_contiguous(INSTALLABLE_FAMILIES, "INSTALLABLE_FAMILIES") - overlap = set(SUPPORTED_STABLE_FAMILIES).intersection( - QUALIFICATION_CANDIDATE_FAMILIES + tier_sets = ( + set(LEGACY_INSTALLABLE_FAMILIES), + set(SUPPORTED_STABLE_FAMILIES), + set(QUALIFICATION_CANDIDATE_FAMILIES), + ) + overlaps = any( + left.intersection(right) + for index, left in enumerate(tier_sets) + for right in tier_sets[index + 1 :] ) - if overlap: - raise ValueError(f"Stable and candidate families overlap: {sorted(overlap)}") + if overlaps: + raise ValueError("Legacy, supported, and candidate families must not overlap") + + if LEGACY_INSTALLABLE_FAMILIES: + legacy_major, legacy_minor = _family_key(LEGACY_INSTALLABLE_FAMILIES[-1]) + if _family_key(SUPPORTED_STABLE_FAMILIES[0]) != ( + legacy_major, + legacy_minor + 1, + ): + raise ValueError( + "The supported window must immediately follow the legacy window" + ) if QUALIFICATION_CANDIDATE_FAMILIES: _validate_contiguous( QUALIFICATION_CANDIDATE_FAMILIES, "QUALIFICATION_CANDIDATE_FAMILIES", ) - expected_first_candidate = ( - _family_key(SUPPORTED_STABLE_FAMILIES[-1])[0], - _family_key(SUPPORTED_STABLE_FAMILIES[-1])[1] + 1, - ) - if _family_key(QUALIFICATION_CANDIDATE_FAMILIES[0]) != expected_first_candidate: + supported_major, supported_minor = _family_key(SUPPORTED_STABLE_FAMILIES[-1]) + if _family_key(QUALIFICATION_CANDIDATE_FAMILIES[0]) != ( + supported_major, + supported_minor + 1, + ): raise ValueError( "The first candidate must immediately follow the newest " "supported family" ) - newest_installable_major, newest_installable_minor = _family_key( - INSTALLABLE_FAMILIES[-1] - ) - expected_package_requirement = ( - f"torch>={SUPPORTED_STABLE_FAMILIES[0]}," - f"<{newest_installable_major}.{newest_installable_minor + 1}" - ) - if PACKAGE_TORCH_REQUIREMENT != expected_package_requirement: + if PACKAGE_TORCH_DEPENDENCY != "torch": raise ValueError( - "PACKAGE_TORCH_REQUIREMENT must cover the supported and candidate " - "families, but exclude the next unknown stable family" + "The package dependency must remain unbounded; support is enforced " + "by policy and CI, not by pip resolution" ) expected = set(INSTALLABLE_FAMILIES) if set(LATEST_STABLE_VERSION) != expected: raise ValueError( - "LATEST_STABLE_VERSION keys must match all supported and candidate families" + "LATEST_STABLE_VERSION keys must match all installable stable families" ) if set(STABLE_CUDA_WHEELS) != expected: raise ValueError( - "STABLE_CUDA_WHEELS keys must match all supported and candidate families" + "STABLE_CUDA_WHEELS keys must match all installable stable families" ) for family, version in LATEST_STABLE_VERSION.items(): @@ -286,6 +292,8 @@ def shell_assignments() -> str: f"PYTORCH_DEFAULT_FAMILY={shlex.quote(DEFAULT_FAMILY)}", "PYTORCH_SUPPORTED_FAMILIES=" + _shell_array(SUPPORTED_STABLE_FAMILIES), "PYTORCH_CANDIDATE_FAMILIES=" + _shell_array(QUALIFICATION_CANDIDATE_FAMILIES), + "PYTORCH_LEGACY_INSTALLABLE_FAMILIES=" + + _shell_array(LEGACY_INSTALLABLE_FAMILIES), "PYTORCH_INSTALLABLE_FAMILIES=" + _shell_array(INSTALLABLE_FAMILIES), "PYTORCH_SUPPORTED_FAMILY_MIN=" + shlex.quote(SUPPORTED_STABLE_FAMILIES[0]), "PYTORCH_SUPPORTED_FAMILY_MAX=" + shlex.quote(SUPPORTED_STABLE_FAMILIES[-1]), @@ -320,11 +328,7 @@ def _build_parser() -> argparse.ArgumentParser: subparsers.add_parser("supported-range", help="Print the qualified range") subparsers.add_parser("installable-range", help="Print the installer range") subparsers.add_parser( - "package-requirement", help="Print the package Torch requirement" - ) - subparsers.add_parser( - "filter-nightly-pip-check", - help="Ignore only the expected TICO-to-nightly Torch metadata conflict", + "package-dependency", help="Print the unbounded package dependency" ) matrix_parser = subparsers.add_parser( @@ -352,21 +356,8 @@ def main(argv: Sequence[str] | None = None) -> int: print(_range_text(SUPPORTED_STABLE_FAMILIES)) elif args.command == "installable-range": print(_range_text(INSTALLABLE_FAMILIES)) - elif args.command == "package-requirement": - print(PACKAGE_TORCH_REQUIREMENT) - elif args.command == "filter-nightly-pip-check": - ignored, remaining = filter_expected_nightly_pip_check(sys.stdin.read()) - for line in ignored: - print(f"[WARN] Ignoring expected nightly metadata mismatch: {line}") - if remaining or not ignored: - for line in remaining: - print(line, file=sys.stderr) - if not ignored: - print( - "No expected TICO-to-nightly Torch mismatch was found.", - file=sys.stderr, - ) - return 1 + elif args.command == "package-dependency": + print(PACKAGE_TORCH_DEPENDENCY) elif args.command == "ci-matrix": print(json.dumps(github_matrix(args.kind), separators=(",", ":"))) else: # pragma: no cover - argparse rejects unknown commands.