Skip to content

Automate Puzzletron GPU lifecycle tests - #2167

Open
j-rausch wants to merge 4 commits into
jrausch/puzzletron-gpu-quality-baseline-v4from
jrausch/puzzletron-gpu-ci-image-workflow
Open

Automate Puzzletron GPU lifecycle tests#2167
j-rausch wants to merge 4 commits into
jrausch/puzzletron-gpu-quality-baseline-v4from
jrausch/puzzletron-gpu-ci-image-workflow

Conversation

@j-rausch

@j-rausch j-rausch commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Type of change: New tests.

The existing gpu_puzzletron session proves the current Puzzletron lifecycle but is only run manually. This change adds a digest-pinned repository-owned CUDA image recipe and a dedicated copied-PR, nightly, and manual workflow that runs that focused session against the reusable tiny-Qwen lifecycle test.

The workflow accepts only immutable nvcr.io image references, verifies the checked-out image contract before allocating a GPU, and installs the checked-out ModelOpt source without resolving dependencies at runtime. The image build preinstalls the declared ModelOpt runtime and test dependencies and verifies the pinned CUDA, Torch, Transformers, LMMS-Eval, AutoModel, AIPerf, and Nox environment.

Testing

Adds CPU contract coverage for the recorded base-image digest, image-reference validation, Docker setup contract, workflow permissions and routing, and dependency-isolated runtime installation. The dedicated GPU workflow runs the existing one-GPU Puzzletron lifecycle test through nox -s gpu_puzzletron.

Additional Information

This PR is stacked on #2166. The registry image must be built and published separately, then PUZZLETRON_GPU_CI_IMAGE must be configured with its immutable digest before the workflow can run.

Summary by CodeRabbit

  • New Features

    • Added automated Puzzletron GPU testing for pull requests, scheduled runs, and manual execution.
    • Added a pinned CUDA-based CI environment with automated setup and validation.
    • Added immutable container image resolution and verification for reliable GPU test execution.
  • Bug Fixes

    • Improved environment checks to validate configured dependency and CUDA versions dynamically.
  • Documentation

    • Added instructions for building, publishing, validating, and running the GPU CI image locally.
  • Tests

    • Added coverage for image immutability, workflow configuration, dependency isolation, and GPU environment validation.

@copy-pr-bot

copy-pr-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (3)
  • main
  • release/.*
  • feature/.*

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 1b1021ce-d353-476d-b533-40574a89ba05

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: d8f84405-3279-4d00-902c-087e1eaf55c3

📥 Commits

Reviewing files that changed from the base of the PR and between 79eb6cd and 278e060.

📒 Files selected for processing (9)
  • .github/workflows/puzzletron_gpu_tests.yml
  • .github/workflows/unit_tests.yml
  • examples/puzzletron/ci/Dockerfile
  • examples/puzzletron/ci/README.md
  • examples/puzzletron/ci/resolve_ci_image.py
  • examples/puzzletron/ci/setup_env.sh
  • examples/puzzletron/ci_environment.json
  • noxfile.py
  • tests/unit/torch/puzzletron/test_ci_image_contract.py

📝 Walkthrough

Walkthrough

The PR adds a pinned CUDA-based Puzzletron CI image, validates its image and environment contracts, updates Nox GPU verification, and adds a gated GitHub Actions workflow for GPU lifecycle tests.

Changes

Puzzletron GPU CI

Layer / File(s) Summary
Pinned image and contract validation
examples/puzzletron/ci_environment.json, examples/puzzletron/ci/Dockerfile, examples/puzzletron/ci/resolve_ci_image.py, examples/puzzletron/ci/README.md, tests/unit/torch/puzzletron/test_ci_image_contract.py
Defines the immutable CUDA image and dependencies. The resolver validates image references and repository contracts. Documentation covers image build, execution, and publication. Tests cover resolver and image contracts.
GPU environment provisioning and verification
examples/puzzletron/ci/setup_env.sh, noxfile.py, tests/unit/torch/puzzletron/test_ci_image_contract.py
Adds pinned dependency installation, ModelOpt installation, environment checks, GPU-image-specific Nox validation, and runtime installation checks.
Gated GPU workflow execution
.github/workflows/puzzletron_gpu_tests.yml, .github/workflows/unit_tests.yml, tests/unit/torch/puzzletron/test_ci_image_contract.py
Adds pull-request, nightly, and manual workflow execution. The workflow gates file scope, resolves the immutable image, runs the GPU Nox session, and reports required-check status.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Mergeability Score: 🔵 Low · up to 278e0

The new GPU test image currently runs its test process as root, leaving a bounded container-isolation risk that should remain explicitly owned and followed up; this is mergeable without blocking the PR.

Sequence Diagram(s)

sequenceDiagram
  participant PullRequest
  participant PRGate
  participant ImageResolver
  participant GPUContainer
  participant RequiredCheck
  PullRequest->>PRGate: evaluate changed-file scope
  PRGate->>ImageResolver: resolve pinned CI image
  ImageResolver->>GPUContainer: provide image and digest cache key
  GPUContainer->>RequiredCheck: report GPU test result
  PRGate->>RequiredCheck: report gate result
  ImageResolver->>RequiredCheck: report image result
Loading

Possibly related PRs

Suggested reviewers: kevalmorabia97, danielkorzekwa, grzegorz-k-karch

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: automating Puzzletron GPU lifecycle tests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Security Anti-Patterns ✅ Passed The PR-range diff adds no prohibited load, remote-code, eval/exec, or # nosec patterns, and adds no pyproject.toml or requirements.txt dependencies.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jrausch/puzzletron-gpu-ci-image-workflow

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

@j-rausch
j-rausch marked this pull request as ready for review August 12, 2026 12:11
@j-rausch
j-rausch requested review from a team as code owners August 12, 2026 12:11
@j-rausch
j-rausch requested review from danielkorzekwa, grzegorz-k-karch and kevalmorabia97 and removed request for a team August 12, 2026 12:11
@j-rausch

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@j-rausch

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

CodeRabbit couldn't request changes on this pull request because it doesn't have sufficient GitHub permissions.

Please grant CodeRabbit Pull requests: Read and write permission and re-run the review.

👉 Steps to fix this

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/puzzletron_gpu_tests.yml:
- Around line 19-23: Remove secrets: inherit from the pr-gate reusable workflow
invocation in puzzletron_gpu_tests.yml. Preserve the existing permissions and
uses configuration; if pr-gate requires a secret, pass only the specific named
secret through an explicit secrets mapping.

In `@examples/puzzletron/ci/Dockerfile`:
- Around line 20-31: Create a non-root runtime user in the Dockerfile, assign
ownership of /venv and /workspace/modelopt to that user, and add the
corresponding USER instruction before WORKDIR so GPU jobs execute checked-out
code without root privileges.

In `@examples/puzzletron/ci/resolve_ci_image.py`:
- Around line 18-22: Add the module-level __all__ declaration immediately after
the imports in resolve_ci_image.py, listing resolve_image_reference and
validate_repository_contract so both functions are explicitly exposed as the
resolver module’s public API.

In `@tests/unit/torch/puzzletron/test_ci_image_contract.py`:
- Line 87: Replace yaml.load with yaml.safe_load in the workflow parsing setup,
then update the related scalar assertions to expect PyYAML’s native values,
including True for “on” and integer 50 for “timeout-minutes.”
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ab0acb2b-83ac-4994-9a09-dc95f1ef40f2

📥 Commits

Reviewing files that changed from the base of the PR and between be08d47 and 2413b50.

📒 Files selected for processing (8)
  • .github/workflows/puzzletron_gpu_tests.yml
  • examples/puzzletron/ci/Dockerfile
  • examples/puzzletron/ci/README.md
  • examples/puzzletron/ci/resolve_ci_image.py
  • examples/puzzletron/ci/setup_env.sh
  • examples/puzzletron/ci_environment.json
  • noxfile.py
  • tests/unit/torch/puzzletron/test_ci_image_contract.py

Comment thread .github/workflows/puzzletron_gpu_tests.yml Outdated
Comment thread examples/puzzletron/ci/Dockerfile
Comment thread examples/puzzletron/ci/resolve_ci_image.py
Comment thread tests/unit/torch/puzzletron/test_ci_image_contract.py Outdated
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.04%. Comparing base (4e965c7) to head (9abfd3f).

Additional details and impacted files
@@                             Coverage Diff                             @@
##           jrausch/puzzletron-gpu-quality-baseline-v4    #2167   +/-   ##
===========================================================================
  Coverage                                       63.03%   63.04%           
===========================================================================
  Files                                             709      709           
  Lines                                           91929    91929           
===========================================================================
+ Hits                                            57948    57954    +6     
+ Misses                                          33981    33975    -6     
Flag Coverage Δ
examples 30.03% <ø> (ø)
gpu 23.75% <ø> (ø)
puzzletron 31.75% <ø> (ø)
regression 8.94% <ø> (ø)
unit 29.42% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@j-rausch
j-rausch force-pushed the jrausch/puzzletron-gpu-quality-baseline-v4 branch from 55478b8 to de15733 Compare August 12, 2026 15:32
@j-rausch
j-rausch force-pushed the jrausch/puzzletron-gpu-ci-image-workflow branch from c2b81f3 to 1b5940f Compare August 12, 2026 15:32
@j-rausch

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

CodeRabbit couldn't request changes on this pull request because it doesn't have sufficient GitHub permissions.

Please grant CodeRabbit Pull requests: Read and write permission and re-run the review.

👉 Steps to fix this

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/puzzletron_gpu_tests.yml:
- Around line 69-71: Remove the privileged NGC_API_KEY use from the
push-triggered GPU workflow around the credentials block. Move the GPU job and
secret access into a maintainer-controlled workflow revision, and require an
explicit trusted workflow_dispatch or maintainer approval before executing
copied PR content.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 402d3d89-0192-4214-a74a-3b6b28b3c9a9

📥 Commits

Reviewing files that changed from the base of the PR and between de15733 and 1b5940f.

📒 Files selected for processing (8)
  • .github/workflows/puzzletron_gpu_tests.yml
  • examples/puzzletron/ci/Dockerfile
  • examples/puzzletron/ci/README.md
  • examples/puzzletron/ci/resolve_ci_image.py
  • examples/puzzletron/ci/setup_env.sh
  • examples/puzzletron/ci_environment.json
  • noxfile.py
  • tests/unit/torch/puzzletron/test_ci_image_contract.py

Comment thread .github/workflows/puzzletron_gpu_tests.yml Outdated
@j-rausch
j-rausch force-pushed the jrausch/puzzletron-gpu-quality-baseline-v4 branch from e013fe8 to e3f78c2 Compare August 12, 2026 16:32
@j-rausch
j-rausch force-pushed the jrausch/puzzletron-gpu-ci-image-workflow branch from 1b5940f to 3274cb6 Compare August 12, 2026 16:32
@j-rausch
j-rausch force-pushed the jrausch/puzzletron-gpu-quality-baseline-v4 branch from 6a6b3d0 to 79eb6cd Compare August 12, 2026 21:51
@j-rausch
j-rausch force-pushed the jrausch/puzzletron-gpu-ci-image-workflow branch from 3274cb6 to 278e060 Compare August 12, 2026 21:51
@j-rausch

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@j-rausch
j-rausch force-pushed the jrausch/puzzletron-gpu-quality-baseline-v4 branch from 79eb6cd to a34b939 Compare August 12, 2026 23:03
@j-rausch
j-rausch force-pushed the jrausch/puzzletron-gpu-ci-image-workflow branch from 278e060 to 20988e6 Compare August 12, 2026 23:03
@j-rausch
j-rausch force-pushed the jrausch/puzzletron-gpu-quality-baseline-v4 branch from a34b939 to 57c87e1 Compare August 13, 2026 01:00
@j-rausch
j-rausch force-pushed the jrausch/puzzletron-gpu-ci-image-workflow branch from 20988e6 to 5fdeeb2 Compare August 13, 2026 01:00
@j-rausch
j-rausch force-pushed the jrausch/puzzletron-gpu-ci-image-workflow branch from 5fdeeb2 to f022768 Compare August 13, 2026 01:15
@j-rausch

Copy link
Copy Markdown
Contributor Author

/claude review

Comment thread .github/workflows/puzzletron_gpu_tests.yml
Comment thread .github/workflows/unit_tests.yml
Comment thread .github/workflows/puzzletron_gpu_tests.yml
Comment thread examples/puzzletron/ci/setup_env.sh

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude review — Puzzletron GPU CI image + workflow

Findings: CRITICAL: 0 · IMPORTANT: 2 · SUGGESTION: 2

Scope: all 9 changed files reviewed (547 additions). This PR touches no modelopt/ runtime code — it is CI infrastructure (workflow, Dockerfile, provisioning script, resolver, noxfile session, contract test), so the review focused on CI correctness, gate coverage, and the pinning contract rather than algorithm/mode/export concerns. I traced setup_env.sh end-to-end against noxfile.py::gpu_puzzletron, _pr_gate.yml's run_tests output, _wait_for_checks.yml's secret usage, pyproject.toml's setuptools_scm config, and the targeted GPU test's fixture (build_tiny_qwen_campaign).

Most impactful findings

1. [IMPORTANT] Unconfigured PUZZLETRON_GPU_CI_IMAGE becomes a red required check on many PRs (puzzletron_gpu_tests.yml:57-61). With the variable unset — the state this PR merges in, per its own description — resolve-image fails, gpu-puzzletron is skipped, and gpu-puzzletron-required-check exits 1. The gate list includes pyproject.toml, noxfile.py, and tests/conftest.py, so this lands on a large share of PRs plus every nightly, and the error text (must be an immutable nvcr.io digest) reads as malformed value rather than variable never set. Suggested: distinguish unset from invalid in resolve_ci_image.py::main, and either land after publishing or make the unset case an explained skip while keeping invalid values a hard failure.

2. [IMPORTANT] The new CPU contract test can't be triggered by the file it guards (unit_tests.yml:87). The puzzletron_changed gate matches Puzzletron paths by extension only (**/*.py, **/*.sh, **/*.json, …), and examples/puzzletron/ci/Dockerfile has none — so a Dockerfile-only change (bumped FROM digest, dropped --verify hook, changed extras) skips the puzzletron_v2 job and test_gpu_image_uses_the_recorded_immutable_base never runs. The workflow-level paths: filter does include examples/puzzletron/**, which makes the inner skip easy to miss. Adding examples/puzzletron/ci/** (as puzzletron_gpu_tests.yml:31 already does) closes it. Note the compensating validate_repository_contract check only runs once the image variable is configured, so right now nothing catches this drift.

Suggestions

  • puzzletron_gpu_tests.yml:34 — gate uses modelopt/torch/puzzletron/**, narrower than the CPU Puzzletron gate (modelopt/torch/**) and gpu_tests.yml (modelopt/**), while the lifecycle test exercises nas/prune/opt. Defensible as a runner-cost tradeoff (nightly covers it), but worth widening or annotating.
  • setup_env.sh:23 — the Dockerfile's ENV PUZZLETRON_CI_ENVIRONMENT=/opt/puzzletron/... means the runtime --verify compares the image against its own baked pins, not the checked-out ones the README describes. Drift is still caught, but by _verify_puzzletron_v2_environment one step later, as a raw version-mismatch dict rather than "rebuild the image."

Things I checked that are correct

  • pr-gate without secrets: inherit is safe: _pr_gate.yml references no secrets, and the nested _wait_for_checks.yml uses only the automatic secrets.GITHUB_TOKEN. permissions: {checks: read} matches gpu_tests.yml/example_tests.yml.
  • run_tests is populated for PR pushes even without skip_puzzletron_onlyscope-pr runs unconditionally on pull-request/* and defaults run_tests="$ANY_CHANGED", so the gate is not accidentally always-false.
  • --no-deps at runtime does not silently hide new base dependencies: the pip check immediately after the editable install reports them (extras-only additions still escape).
  • The Dockerfile places setup_env.sh --verify in the same RUN as the dependency install, so a [hf]-extra resolution that moves transformers off 5.8.1 fails the build rather than shipping a mispinned image.
  • venv_backend="none" keeps VIRTUAL_ENV=/venv intact, so install_modelopt's sys.prefix guard passes in-image and fails loudly outside it; the missing-.git/shallow-checkout case is covered by fallback_version = "0.0.0".
  • "on": is quoted, so yaml.safe_load yields the string key the test indexes; the targeted GPU test builds its model and dataset locally, so the deliberate absence of HF_TOKEN is fine.

Risk assessment

Low-to-moderate, and confined to CI. No runtime, mode-registration, state, or export surface is touched, and the pinning design (digest-pinned base, recorded contract, build-time and pre-flight verification, no registry credentials on copied-PR branches) is sound. Both IMPORTANT findings are about when checks run rather than what they assert: one makes a new check fail broadly before the image exists, the other leaves the guarded Dockerfile ungated. Both are small, localized fixes.

Pin the execution image and dependency contract so the focused lifecycle workflow runs against a reproducible one-GPU environment.

Signed-off-by: Johannes Rausch <jrausch@nvidia.com>
Signed-off-by: Johannes Rausch <jrausch@nvidia.com>
Require the immutable execution image to support anonymous pulls so copied pull-request branches never receive registry credentials.

Signed-off-by: Johannes Rausch <jrausch@nvidia.com>
Signed-off-by: Johannes Rausch <jrausch@nvidia.com>
@j-rausch
j-rausch force-pushed the jrausch/puzzletron-gpu-ci-image-workflow branch from f022768 to 9abfd3f Compare August 13, 2026 08:37
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