Repository navigation
Add a torch grader image with sensible baked-in defaults - #65
Merged
Merged
Conversation
Add Dockerfile.torch (a glibc base, since PyTorch has no musl wheels) with a CPU build of torch, torchvision and torchinfo on top of the full scientific stack, and publish it as the :torch tag. The image bakes in a 10s default sandbox timeout (via PL_GRADER_SANDBOX_TIMEOUT) and single-threaded numeric defaults, all overridable per question. Documents the image, the tensor assertion helpers, and the dataset/determinism gotchas in torch.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Give the torch image its own fully pinned requirements file instead of layering on requirements-full.txt. The torch image runs on a different Python and libc than the full image and pins torch tightly to specific numpy/Pillow versions, so it should pin its scientific stack on its own terms rather than silently inheriting the full image's bumps. Also fixes a latent bug: Dockerfile.torch copied requirements-torch.txt but installed torch/torchvision/torchinfo by bare name, so the file was never actually used. The whole set now installs from that one file, with the PyTorch CPU index as the primary index so only CPU wheels are pulled. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
On the Alpine (musl) base, scikit-learn has no prebuilt wheel, so it compiled from source on every build — pulling in the build-base toolchain and pushing the image build to close to an hour. Every compiled dependency (numpy, scipy, scikit-learn, pandas, matplotlib, Pillow) ships a manylinux wheel for Python 3.14, so switching to the Debian slim base the torch image already uses lets the whole stack install from wheels. No compiler is needed, the build drops to a few minutes, and the image no longer carries build-base. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The publish workflow only builds the images on a release tag, so a broken dependency combination wouldn't surface until release. This builds all three images on PRs and pushes that touch docker/**, amd64-only and without pushing, with per-variant layer caching so unchanged images stay fast. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The publish and build-only workflows each carry their own copy of the image matrix. Add a comment in each pointing at the other so a new image isn't added to one and forgotten in the other. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Move the standalone torch.md into a PyTorch grading section of quick_start.md, add the :torch row to the image table (which still listed only two variants), and point the README there. A later PR will reorganize these docs further. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the
prairielearn/grader-python-pytest:torchimage (closes #62, re-scoped to torch per discussion), plus two related build improvements.Torch image
docker/Dockerfile.torchon a glibc (Debian) base — PyTorch publishes only manylinux wheels, so the Alpine base of the lite/full images can't install it. Pinned to Python 3.13 (newest with stable CPU torch wheels).requirements-torch.txt: the image carries its own pinned copy of the scientific stack plus the torch stack rather than layering onrequirements-full.txt. It runs on a different Python/libc than the full image and pins torch tightly to specific numpy/Pillow versions, so it pins on its own terms; the cost is that new full-image packages are mirrored here by hand, which keeps changes to this heavy image explicit. (Also fixes a latent bug: the Dockerfile copiedrequirements-torch.txtbut installed torch by bare name, so the file was never used.)PL_GRADER_SANDBOX_TIMEOUT=10(torch work blows past the 1s default) and single-threadedOMP/MKL_NUM_THREADSfor reproducible grading. Questions override viaConfigObject/ their own code.:torchtag via a newpublish.yamlmatrix entry.PyTorch gradingsection inquick_start.mddocuments the image, the override table, the tensor helpers, and the dataset/determinism gotchas (and the image table now lists:torch); README points there.Full image build time
bookworm-slim) base, keeping Python 3.14. On Alpine,scikit-learnhas no musl wheel and compiled from source every build (dragging inbuild-baseand pushing the build to ~an hour); every compiled dependency ships a manylinux 3.14 wheel, so on glibc the whole stack installs from wheels — build drops to a few minutes and the image no longer carries the compiler toolchain.Build-only CI
docker-build.yamlbuilds all three images on PRs / pushes that touchdocker/**(amd64,push: false, per-variant layer cache). The publish workflow only builds on a release tag, so without this a broken dependency combination wouldn't surface until release.Testing
2.8.0/0.23.0/1.8.0) are provisional: confirm the CPU wheels resolve against the pinnednumpy==2.5.4/Pillow==13.0.0via that CI build, and bump if newer is wanted.Stacked on #64 (which is stacked on #63).
🤖 Generated with Claude Code