Skip to content

Add Python 3.12 support#107

Open
mihow wants to merge 4 commits intomainfrom
feature/python-3.12-support
Open

Add Python 3.12 support#107
mihow wants to merge 4 commits intomainfrom
feature/python-3.12-support

Conversation

@mihow
Copy link
Collaborator

@mihow mihow commented Jan 30, 2026

Summary

  • Upgrade Python support from 3.10-3.11 to 3.10-3.12
  • Upgrade torch from 2.1.x to 2.5.x (required for Python 3.12 compatibility)
  • Upgrade torchvision from 0.16.x to 0.20.x
  • CI now tests both Python 3.10 and 3.12

Why this change

The triton package bundled with torch 2.1.x only had Linux wheels for Python 3.10/3.11. Torch 2.5.x includes triton 3.x which properly supports Python 3.12.

Test plan

  • CI passes for Python 3.10
  • CI passes for Python 3.12
  • Local testing with existing py11 environment
  • Verify ML pipeline still works end-to-end

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Added support for Python 3.12
    • Updated dependencies: PyTorch (2.5.0), TorchVision (0.20.0), and Pillow (10.0.0)

- Update Python version constraint from <3.12 to <3.13
- Upgrade torch from ^2.1.0 to ^2.5.0 (required for py3.12 + triton)
- Upgrade torchvision from ^0.16.0 to ^0.20.0
- Update CI workflows to test both Python 3.10 and 3.12

The triton package bundled with torch 2.1.x only had wheels for
Python 3.10/3.11. Torch 2.5.x includes triton 3.x which supports
Python 3.12.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@coderabbitai
Copy link

coderabbitai bot commented Jan 30, 2026

Warning

Rate limit exceeded

@mihow has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 20 minutes and 10 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

The changes expand CI/CD testing to multiple Python versions (3.10 and 3.12) using matrix strategies in workflows, while broadening the Python version constraint to support 3.12 and upgrading key dependencies (Pillow, PyTorch, torchvision).

Changes

Cohort / File(s) Summary
CI/CD Matrix Configuration
.github/workflows/test-ml.yml, .github/workflows/test.yml
Introduce matrix strategies to run jobs across Python 3.10 and 3.12. Replace static Python version setup with dynamic matrix-driven configuration. Expand cache dependencies to include pyproject.toml.
Dependency Updates
pyproject.toml
Broaden Python constraint to ^3.10 (removing upper bound 3.12). Upgrade Pillow to ^10.0.0, PyTorch to ^2.5.0, and torchvision to ^0.20.0.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hops with glee through versions new,
Python ten and twelve too!
Dependencies dance and rise,
Torch and vision, modernize!
Workflows bloom in matrix bright, 🌟

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title directly and accurately summarizes the main objective of the changeset: adding Python 3.12 support to the project.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/python-3.12-support

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

mihow and others added 2 commits January 29, 2026 19:50
Pillow 9.5.0 doesn't provide pre-built wheels for Python 3.12,
causing CI to fail when trying to compile from source.
Pillow 10.0.0+ includes Python 3.12 wheels.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Allow any Python 3.10+ instead of capping at 3.13.
The caret constraint ^3.10 already limits to <4.0.0.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/test.yml (1)

40-45: ⚠️ Potential issue | 🟠 Major

Poetry virtualenv cache key should include Python version.

The cache key venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} doesn't differentiate between Python versions. This can cause cache collisions where a 3.10 venv is restored for a 3.12 build (or vice versa), leading to incompatible binaries and potential test failures.

🔧 Proposed fix to include Python version in cache key
       - name: Load cached Poetry virtualenv
         id: cached-poetry-dependencies
         uses: actions/cache@v3
         with:
           path: .venv
-          key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
+          key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
🤖 Fix all issues with AI agents
In @.github/workflows/test-ml.yml:
- Line 24: Replace the outdated checkout action reference "uses:
actions/checkout@v3" with "uses: actions/checkout@v4" in the workflow so it
matches the other workflows using v4; search for any other occurrences of
"actions/checkout@v3" in the repo and update them as well, then commit the
change and re-run the workflow to verify compatibility.
🧹 Nitpick comments (1)
.github/workflows/test-ml.yml (1)

26-26: Avoid using @main branch ref for actions.

Using actions/setup-python@main is risky as it tracks the latest development code, which could introduce breaking changes unexpectedly. The test.yml workflow uses @v5. Pin to a specific version for stability.

🔧 Proposed fix
       - name: Set up Python ${{ matrix.python-version }}
-        uses: actions/setup-python@main # Need latest version to use pyproject.toml instead of requirements.txt
+        uses: actions/setup-python@v5
         with:
           python-version: ${{ matrix.python-version }}

@mihow mihow marked this pull request as ready for review February 10, 2026 00:23
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
.github/workflows/test.yml (1)

40-45: ⚠️ Potential issue | 🔴 Critical

Bug: Virtualenv cache key doesn't include python-version, so matrix jobs will corrupt each other's cache.

The cache key venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} is identical for both Python 3.10 and 3.12 matrix entries. Whichever job runs first will populate the cache with its Python-version-specific .venv, and the second job will restore an incompatible virtualenv, likely causing import errors or silent ABI mismatches.

Include the Python version in the key:

🔧 Proposed fix
       - name: Load cached Poetry virtualenv
         id: cached-poetry-dependencies
         uses: actions/cache@v3
         with:
           path: .venv
-          key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
+          key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
pyproject.toml (1)

22-22: ⚠️ Potential issue | 🔴 Critical

pandas = "^1.5.3" caps at <2.0.0 — pandas 1.x has no Python 3.12 support.

Poetry's ^1.5.3 resolves to >=1.5.3, <2.0.0. There are no pandas 1.x releases with Python 3.12 wheels. However, bumping to ^2.0.0 is insufficient—pandas 2.0.x also lacks Python 3.12 support (only up to 3.11). The minimum version for Python 3.12 support is pandas 2.1.1. Update to ^2.1.1 or higher.

🤖 Fix all issues with AI agents
In `@pyproject.toml`:
- Line 31: The pyproject specifies timm = "^0.6.13" which predates support for
torch 2.5.x; update the dependency in pyproject.toml from the pinned "timm =
\"^0.6.13\"" to a newer timm release that explicitly supports torch 2.5 (e.g.,
the latest stable timm compatible with your torch version), then regenerate your
lockfile / run your dependency install (poetry lock && poetry install or pip
freeze/update) and run your model tests to verify compatibility; ensure the
change is made where "timm = \"^0.6.13\"" appears and include the new version
string in the same dependency entry.

torchvision = "^0.16.0"
torch = "^2.5.0"
torchvision = "^0.20.0"
timm = "^0.6.13"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

timm 0.6 torch 2.5 compatibility

💡 Result:

timm==0.6.x is very old (e.g., 0.6.5 was released Jul 10, 2022) and doesn’t claim/testing coverage for modern PyTorch releases like torch 2.5. [1] In practice it may work for some models, but if you hit import/API issues, the realistic fix is to upgrade timm.

What is clearly defined is the torch/torchvision pairing for torch 2.5:

  • torch 2.5.0 ⇔ torchvision 0.20.0 (and torchaudio 2.5.0) [3] (also shown in PyTorch’s domain-library compatibility matrix) [2]

Recommended (most compatible) setup for torch 2.5:

pip install --upgrade timm
pip install --upgrade torch==2.5.0 torchvision==0.20.0 torchaudio==2.5.0

If you must stay on timm==0.6.*, at least ensure you’re on the correct torchvision for torch 2.5 (0.20.0), since mismatched torch/torchvision commonly causes binary-ops errors. [3] Also note current timm releases explicitly test newer PyTorch (e.g. “PyTorch 2.6 … tested and working”); 0.6.* predates that. [4]

Sources: PyPI timm==0.6.5 release info [1]; PyTorch versions compatibility matrix [2]; PyTorch “previous versions” install table for v2.5.0 [3]; PyPI timm changelog note about tested PyTorch versions [4].


Upgrade timm to a version with torch 2.5.x support.

The pinned version timm 0.6.13 (released July 2022) does not claim or test coverage for torch 2.5.x. While it may work for some models, compatibility issues are not unlikely. Current timm releases explicitly support torch 2.5.x and newer versions. Upgrade timm to the latest version compatible with your torch 2.5 setup.

🤖 Prompt for AI Agents
In `@pyproject.toml` at line 31, The pyproject specifies timm = "^0.6.13" which
predates support for torch 2.5.x; update the dependency in pyproject.toml from
the pinned "timm = \"^0.6.13\"" to a newer timm release that explicitly supports
torch 2.5 (e.g., the latest stable timm compatible with your torch version),
then regenerate your lockfile / run your dependency install (poetry lock &&
poetry install or pip freeze/update) and run your model tests to verify
compatibility; ensure the change is made where "timm = \"^0.6.13\"" appears and
include the new version string in the same dependency entry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments