Repository navigation
Re-land the torch grader image and sandbox-timeout defaults - #66
Merged
Merged
Conversation
Serialize torch.Tensor values across the sandbox (detached, on CPU) in json_utils, and add assert_tensor_allclose / assert_tensor_equal with student-friendly failure messages. torch is a lazy, optional import so the lite and full images are unaffected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ConfigObject.sandbox_timeout now defaults to None, meaning 'use the image/global default'. The plugin resolves an unset timeout from the PL_GRADER_SANDBOX_TIMEOUT environment variable (falling back to 1.0s), so an image can bake in a more sensible default while questions keep full control by setting an explicit value. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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>
Gate the torch dev dependency below Python 3.14 (no wheels yet) so the lock resolves and the 3.14 job skips the torch tests, and guard the test's torch typing behind TYPE_CHECKING so mypy resolves torch.Tensor. 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>
#64 and #65 were merged into their stacked base branches rather than main, so their changes never reached main. This brings them in: the overridable sandbox-timeout default (#64), the torch grader image, the glibc base for the full image, the build-only CI workflow, and the docs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
eliotwrobson
marked this pull request as ready for review
November 26, 2026 05:03
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
Re-lands the work from #64 and #65, which were stacked PRs that merged into their intermediate base branches instead of
main— so although both show as merged, their changes never reachedmain(only #63 did). This brings them in as a single PR against the currentmain; the merge is conflict-free and the diff is exactly that stranded work (no #63 changes, which are already onmain).What lands here:
sandbox_timeoutdefaults toNoneand resolves from thePL_GRADER_SANDBOX_TIMEOUTenvironment variable (falling back to 1s), so a grader image can set a sensible default that a question'sConfigObject/marker still overrides.docker/Dockerfile.torchon a glibc base, a self-contained fully-pinnedrequirements-torch.txt, a CPU-only torch/torchvision/torchinfo install, and baked-in overridable defaults (PL_GRADER_SANDBOX_TIMEOUT=10, single-threadedOMP/MKL). Published as:torchvia a newpublish.yamlmatrix entry.build-base.docker-build.yaml). Builds all three images on PRs/pushes touchingdocker/**(amd64, no push, per-variant cache), so a broken dependency combination surfaces before release rather than at tag time.PyTorch gradingsection ofquick_start.md(the image table now lists:torch); README points there.After this merges, a new release tag will build and push the
:torchimage (and rebuildfull/litefrom the glibc switch) — the currentv1.4.2release predates this work and only publishedfull/lite.Testing
uv lock --checkpass locally on Python 3.13; torch tests skip when torch isn't installed.docker-buildCI job on this PR (they aren't built locally).2.8.0/0.23.0/1.8.0) are provisional pending that build's confirmation against the pinnednumpy==2.5.4/Pillow==13.0.0.🤖 Generated with Claude Code