Skip to content

ci: split CUDA tests into separate jobs - #5896

Merged
njzjz merged 1 commit into
deepmodeling:masterfrom
njzjz:ci/split-cuda-test-jobs
Jul 22, 2026
Merged

ci: split CUDA tests into separate jobs#5896
njzjz merged 1 commit into
deepmodeling:masterfrom
njzjz:ci/split-cuda-test-jobs

Conversation

@njzjz-bot

@njzjz-bot njzjz-bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • split the CUDA Python and C++ suites into independent jobs
  • install the complete CUDA and Python backend dependency stack in both jobs
  • require both jobs in the final CUDA pass check while allowing both to skip when CUDA testing is not requested

Validation

  • parsed the workflow with PyYAML and asserted both jobs have identical setup steps
  • ruff check .
  • ruff format . (1673 files unchanged)
  • git diff --check

AI attribution

Coding agent: Codex
Codex version: codex-cli 0.144.6
Model: gpt-5.6-sol
Reasoning effort: xhigh

Summary by CodeRabbit

  • Tests
    • Split CUDA validation into separate Python and C++/CUDA test jobs.
    • Improved independent setup and execution of GPU-based test suites.
    • Updated final test status aggregation to reflect the new job structure.

Run the Python and C++ CUDA suites in independent jobs, with each runner installing the complete CUDA and Python dependency stack.

Coding-Agent: Codex
Codex-Version: codex-cli 0.144.6
Model: gpt-5.6-sol
Reasoning-Effort: xhigh
@dosubot dosubot Bot added the build label Jul 22, 2026
@njzjz
njzjz enabled auto-merge July 22, 2026 16:48
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

CUDA CI testing is split from one combined job into independent Python and C++/CUDA GPU jobs. The aggregation job now depends on both jobs and permits either job to be skipped.

Changes

CUDA CI workflow

Layer / File(s) Summary
Split CUDA test jobs and aggregation
.github/workflows/test_cuda.yml
The combined CUDA job is replaced with test_python and test_cc, each with independent setup and execution steps. The pass job now depends on both jobs and updates its allowed skips.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: Python

Suggested reviewers: njzjz

🚥 Pre-merge checks | ✅ 5
✅ 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 accurately summarizes the main change: splitting CUDA tests into separate CI jobs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
.github/workflows/test_cuda.yml

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'


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.

@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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
.github/workflows/test_cuda.yml (1)

88-88: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Pin lukka/get-cmake to an immutable revision.

The new C++ job tracks @latest, allowing unreviewed action changes to alter the build environment. Pin this action to a reviewed commit SHA or immutable release.

🤖 Prompt for 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.

In @.github/workflows/test_cuda.yml at line 88, Update the lukka/get-cmake
action reference in the CUDA workflow to use a reviewed immutable commit SHA or
immutable release instead of `@latest`. Keep the action’s existing behavior and
configuration unchanged.
🤖 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/test_cuda.yml:
- Around line 17-20: Declare explicit least-privilege workflow permissions at
the top level of the CUDA workflow, using contents: read and no write
permissions. Keep the existing test_python job configuration unchanged.
- Line 109: Remove the --trusted-host options from the paddlepaddle-gpu
installation command in the CUDA workflow, while preserving the HTTPS find-links
URL, PyPI index, and pinned package version.

---

Nitpick comments:
In @.github/workflows/test_cuda.yml:
- Line 88: Update the lukka/get-cmake action reference in the CUDA workflow to
use a reviewed immutable commit SHA or immutable release instead of `@latest`.
Keep the action’s existing behavior and configuration unchanged.
🪄 Autofix (Beta)

❌ Autofix failed (check again to retry)

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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 009343c5-58eb-430e-8e41-c1ea81001a14

📥 Commits

Reviewing files that changed from the base of the PR and between 126d64e and 6cc27ef.

📒 Files selected for processing (1)
  • .github/workflows/test_cuda.yml

Comment thread .github/workflows/test_cuda.yml
Comment thread .github/workflows/test_cuda.yml
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

The agent generated fixes only for .github/workflows/ files, which cannot be committed due to permission restrictions. Please apply these changes manually.


⚠️ 1 file(s) could not be committed — the agent does not have permission to push to .github/workflows/. Please apply these changes manually:

.github/workflows/test_cuda.yml — 3 changes:

Lines 13–18
   group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
   cancel-in-progress: true
 name: Test CUDA
+permissions:
+  contents: read
 jobs:
   test_python:
     name: Test Python on CUDA
Lines 53–59
       - run: |
           export PYTORCH_ROOT=$(python -c 'import torch;print(torch.__path__[0])')
           export TENSORFLOW_ROOT=$(python -c 'import importlib.util,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)')
-          pip install --find-links "https://www.paddlepaddle.org.cn/packages/nightly/cu126/paddlepaddle-gpu/" --index-url https://pypi.org/simple --trusted-host www.paddlepaddle.org.cn --trusted-host paddlepaddle.org.cn "paddlepaddle-gpu==3.4.0.dev20260310"
+          pip install --find-links "https://www.paddlepaddle.org.cn/packages/nightly/cu126/paddlepaddle-gpu/" --index-url https://pypi.org/simple "paddlepaddle-gpu==3.4.0.dev20260310"
           source/install/uv_with_retry.sh pip install --system -v -e .[gpu,test,lmp,cu12,torch,jax] mpi4py --reinstall-package deepmd-kit
           # See https://github.com/jax-ml/jax/issues/29042
           source/install/uv_with_retry.sh pip install --system -U 'nvidia-cublas-cu12>=12.9.0.13'
Lines 106–112
       - run: |
           export PYTORCH_ROOT=$(python -c 'import torch;print(torch.__path__[0])')
           export TENSORFLOW_ROOT=$(python -c 'import importlib.util,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)')
-          pip install --find-links "https://www.paddlepaddle.org.cn/packages/nightly/cu126/paddlepaddle-gpu/" --index-url https://pypi.org/simple --trusted-host www.paddlepaddle.org.cn --trusted-host paddlepaddle.org.cn "paddlepaddle-gpu==3.4.0.dev20260310"
+          pip install --find-links "https://www.paddlepaddle.org.cn/packages/nightly/cu126/paddlepaddle-gpu/" --index-url https://pypi.org/simple "paddlepaddle-gpu==3.4.0.dev20260310"
           source/install/uv_with_retry.sh pip install --system -v -e .[gpu,test,lmp,cu12,torch,jax] mpi4py --reinstall-package deepmd-kit
           # See https://github.com/jax-ml/jax/issues/29042
           source/install/uv_with_retry.sh pip install --system -U 'nvidia-cublas-cu12>=12.9.0.13'

@njzjz
njzjz added this pull request to the merge queue Jul 22, 2026
@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.61%. Comparing base (126d64e) to head (6cc27ef).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5896      +/-   ##
==========================================
- Coverage   78.87%   78.61%   -0.27%     
==========================================
  Files        1054     1054              
  Lines      121770   121770              
  Branches     4409     4411       +2     
==========================================
- Hits        96046    95729     -317     
- Misses      24158    24468     +310     
- Partials     1566     1573       +7     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Merged via the queue into deepmodeling:master with commit 5f7b747 Jul 22, 2026
62 of 67 checks passed
@njzjz
njzjz deleted the ci/split-cuda-test-jobs branch July 22, 2026 22:56
wanghan-iapcm pushed a commit to wanghan-iapcm/deepmd-kit that referenced this pull request Jul 22, 2026
Master's deepmodeling#5896 split the CUDA workflow into separate test_python and
test_cc jobs on separate runners, superseding this PR's lane-1 cc-prep
tail. Resolution keeps deepmodeling#5896's two-job structure and re-applies this
PR's remaining pieces: the aoti_compile/gpu two-lane pytest overlap
inside test_python (hides the CPU-bound .pt2 compile tests behind the
GPU lane), the per-lane JUnit reports, and the persistent AOTInductor
compile cache -- now restored in BOTH jobs, since the test_cc fixture
builds (gen_*.py) drive the same inductor backend and reuse the cached
kernels.
pull Bot pushed a commit to ishandutta2007/deepmd-kit that referenced this pull request Jul 23, 2026
…g#5882)

## What

The CUDA python job runs `source/tests` as one serial pytest process.
The tests that freeze a `.pt2` (torch.export + AOTInductor) are
CPU-bound: inductor / g++ / ptxas generate code for minutes while the
GPU sits idle. On the CI GPU the device measured ~98% idle (peak <250
MiB) for the entire duration of that test group, so those minutes are
pure serialization in front of the GPU-bound tests.

Since deepmodeling#5896 moved the C++ build + ctest + LAMMPS to a separate `test_cc`
job, this PR's scope is the python side plus caching:

- **Two pytest lanes in `test_python`, concurrently on the one GPU:**
lane 1 = the CPU-bound `.pt2`-freezing tests (`-m aoti_compile`),
`nice`d and capped to half the cores so the GPU lane keeps CPU priority;
lane 2 = the GPU-bound remainder (`-m "not aoti_compile"`). Wall-clock
becomes `max(lane 1, lane 2)` instead of their sum.
- **Persistent AOTInductor compile cache** (`actions/cache`) restored in
BOTH jobs: the `test_cc` fixture builds (`gen_*.py`) drive the same
inductor backend on the same architectures, so they reuse kernels the
python lanes (or previous runs) already compiled, and unchanged models
never recompile across runs.
- **Per-lane JUnit reports** uploaded as artifacts for lane-balance
monitoring.

## How the partition stays correct

The `aoti_compile` marker is auto-applied in `source/tests/conftest.py`
to any test whose module references a `.pt2` freeze entry point
(`deserialize_to_file` / `_trace_and_export` /
`aoti_compile_and_package`). No hand-maintained file list — new
compiling tests are partitioned automatically. The two selections are
complementary and exhaustive (verified locally: A + B = total,
disjoint). A fail-fast guard aborts if an AOT compile happens in an
untagged test.

The custom-op `.so` install in `test_cc_local.sh` is **atomic** (`copy`
to a temp file + `os.replace`) rather than in place: overwriting the
destination inode while another process has it `mmap`'d corrupts its
live code pages and SIGSEGVs it. `os.replace` swaps the directory entry
to a new inode, so live mappings stay intact.

## Measured on CUDA CI

Lane wall-clocks from the green run at sha `86128ef7` (measured under
the pre-deepmodeling#5896 single-job layout; the pytest lanes are unchanged by the
rebase):

- Lane 1 (`aoti_compile`): **4063 s (~68 min)**
- Lane 2 (`-m "not aoti_compile"`): **8158 s (~2h16m)**

Serial python pytest is by construction the sum, 12221 s (~3h24m); the
overlap runs them in `max(4063, 8158) =` **8158 s (~2h16m)** — the
`test_python` job's pytest step drops by **~68 min (~33%)**, with the
entire compile stream hidden behind the GPU lane. The inductor cache
additionally removes recompilation of unchanged models from both jobs on
subsequent runs.

## Notes / limitations

- Overlap quality scales with the runner's core count (`nice` is a no-op
unless the CPU saturates); the numbers above are for the CI runner.
- Whole-file granularity: a compiling module's few non-compiling tests
also run in the compile lane (harmless).
- The compile lane tolerates pytest exit 5 ("no tests collected") so the
split is safe on branches without `.pt2`-freezing tests.
- The two jobs share one cache key per sha; if both try to save it, the
second save is skipped with a warning (caches are immutable), which is
harmless.
- Generic CI orchestration, independent of any feature branch.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Tests / CI**
* Improved CUDA CI by running AOT-related and non-AOT GPU test groups
concurrently, with separate JUnit reports and “no tests collected”
treated as success.
* Persisted the compilation cache across workflow runs to speed up
repeated runs.
* Added formal AOT compilation test tagging via a new pytest marker and
a fail-fast guard if AOT compilation occurs without the expected tag.
* **Build & Test Scripts**
* Updated local C++ test runner to support skipping build vs ctest
phases, improve runtime library setup, handle leak-sanitizer generator
behavior, and generate fixtures more reliably (clean stale outputs and
run generation in parallel).
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Han Wang <wang_han@iapcm.ac.cn>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants