From e614a286395b01d058725bd41c7009ada590da79 Mon Sep 17 00:00:00 2001 From: mrL <1417558386@qq.com> Date: Sat, 1 Aug 2026 23:35:44 +0800 Subject: [PATCH 1/3] ci(cuda): build only for CI runner GPU arch and raise parallelism The CUDA CI built every .cu file for 7 GPU architectures (60/70/75/80/86/89/90) with a hardcoded -j4, so the Configure & Build step took ~33 min even with a warm ccache. - Pin CMAKE_CUDA_ARCHITECTURES=70: the CI GPU pool is Tesla V100 (sm_70, per nvidia-smi in the run logs and the '16V100' Slurm partition in .ci/slurm/config.ini). This cuts nvcc work by ~7x. - Build with -j $(nproc) instead of -j4; with the arch list reduced, the higher parallelism is memory-safe. Expected: Configure & Build ~33 min -> ~10 min on a cache-cold run. --- .github/workflows/cuda.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cuda.yml b/.github/workflows/cuda.yml index 2216ab9873..f03d6f1af5 100644 --- a/.github/workflows/cuda.yml +++ b/.github/workflows/cuda.yml @@ -46,8 +46,14 @@ jobs: nvidia-smi source toolchain/install/setup rm -rf build - cmake -B build -G Ninja -DUSE_CUDA=ON -DBUILD_TESTING=ON -DENABLE_FLOAT_FFTW=ON - cmake --build build -j4 + # Build only for the GPU architecture of the CI runner instead of the + # default 7 architectures (60/70/75/80/86/89/90). The CI GPU pool is + # Tesla V100 (sm_70, see the nvidia-smi output above); update this if + # the runner GPU model changes (V100=70, A100=80, H100=90, T4=75). + # This cuts nvcc work by ~7x and allows safe -j. + cmake -B build -G Ninja -DUSE_CUDA=ON -DBUILD_TESTING=ON -DENABLE_FLOAT_FFTW=ON \ + -DCMAKE_CUDA_ARCHITECTURES=70 + cmake --build build -j "$(nproc)" cmake --install build - name: Module_LCAO CUDA Unittests From bb4157be0ddf8d995fb1516ac59151ad9f03de37 Mon Sep 17 00:00:00 2001 From: mrL <1417558386@qq.com> Date: Sun, 2 Aug 2026 11:43:05 +0800 Subject: [PATCH 2/3] ci(cuda): split GPU tests into matrix jobs and add 01_PW smoke list The single-job CUDA workflow ran the build and all GPU test suites serially. After #7690 added 73 01_PW cases executed with -n 1, the GPU test portion grew to ~9 min serial on top of the build. - Split into a build job (publishes the installed binary as an artifact) and a matrix of 6 gpu-test jobs that download the binary and run their suites in parallel. - 01_PW runs with -n 2 like the other suites, and pull requests now run a new 23-case smoke subset (CASES_GPU_SMOKE.txt, covering solvers, spin variants, smearing/mixing, relax, symmetry, vdW, MD, DFT+half and output options). The full CASES_GPU.txt list runs nightly via the new schedule trigger and on workflow_dispatch. - Add ccache sizing/statistics steps for observability. Expected: end-to-end CUDA CI wall time roughly halves; the 01_PW step drops from ~4.8 min serial to ~2 min within its own parallel job. --- .github/workflows/cuda.yml | 127 ++++++++++++++++++++++---------- tests/01_PW/CASES_GPU_SMOKE.txt | 29 ++++++++ 2 files changed, 117 insertions(+), 39 deletions(-) create mode 100644 tests/01_PW/CASES_GPU_SMOKE.txt diff --git a/.github/workflows/cuda.yml b/.github/workflows/cuda.yml index f03d6f1af5..f129e1698d 100644 --- a/.github/workflows/cuda.yml +++ b/.github/workflows/cuda.yml @@ -3,18 +3,23 @@ name: CUDA Test on: workflow_dispatch: pull_request: + schedule: + # Nightly at 18:00 UTC: run the full 01_PW GPU case list. Pull requests + # run the smaller CASES_GPU_SMOKE.txt subset instead. + - cron: '0 18 * * *' defaults: run: shell: bash concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.suite || 'build' }} cancel-in-progress: true jobs: - test: - name: Test on CUDA Build + # ── Job 1: build once, publish the binary as an artifact ───────────── + build: + name: Build CUDA runs-on: gpu if: github.repository_owner == 'deepmodeling' container: @@ -22,7 +27,7 @@ jobs: volumes: - /tmp/ccache:/github/home/.ccache options: --gpus all - + steps: - name: Checkout uses: actions/checkout@v7 @@ -34,6 +39,12 @@ jobs: sudo apt-get update sudo apt-get install -y ccache xz-utils ninja-build pkg-config + - name: Setup ccache + run: | + ccache --max-size=30G + ccache --zero-stats + ccache -s + - name: Install external tools from toolchain run: | cd toolchain @@ -46,16 +57,21 @@ jobs: nvidia-smi source toolchain/install/setup rm -rf build - # Build only for the GPU architecture of the CI runner instead of the - # default 7 architectures (60/70/75/80/86/89/90). The CI GPU pool is - # Tesla V100 (sm_70, see the nvidia-smi output above); update this if - # the runner GPU model changes (V100=70, A100=80, H100=90, T4=75). - # This cuts nvcc work by ~7x and allows safe -j. + # Build only for the GPU architecture of the CI runner instead of + # the default 7 architectures (60/70/75/80/86/89/90). The CI GPU + # pool is Tesla V100 (sm_70, see the nvidia-smi output above); + # update this if the runner GPU model changes (V100=70, A100=80, + # H100=90, T4=75). This cuts nvcc work by ~7x and allows safe -j. cmake -B build -G Ninja -DUSE_CUDA=ON -DBUILD_TESTING=ON -DENABLE_FLOAT_FFTW=ON \ - -DCMAKE_CUDA_ARCHITECTURES=70 + -DCMAKE_CUDA_ARCHITECTURES=70 \ + -DCMAKE_INSTALL_PREFIX="${GITHUB_WORKSPACE}/install" cmake --build build -j "$(nproc)" cmake --install build + - name: ccache statistics + if: always() + run: ccache -s + - name: Module_LCAO CUDA Unittests env: GTEST_COLOR: 'yes' @@ -63,39 +79,72 @@ jobs: run: | ctest --test-dir build -V --timeout 1700 -R '^(MODULE_LCAO_tddft_radial_interpolation_cuda_test|MODULE_LCAO_tddft_snap_psibeta_half_test)$' - - name: Test 11_PW_GPU - run: | - cd tests/11_PW_GPU - bash ../integrate/Autotest.sh -n 2 -f CASES_GPU.txt + - name: Upload binary artifact + uses: actions/upload-artifact@v4 + with: + name: abacus-cuda-bin + path: install/ + retention-days: 1 - - name: Test 12_NAO_Gamma_GPU - run: | - cd tests/12_NAO_Gamma_GPU - bash ../integrate/Autotest.sh -n 2 -f CASES_GPU.txt + # ── Job 2: matrix instances run their test suites in parallel ──────── + gpu-test: + name: Test ${{ matrix.suite }} + needs: build + runs-on: gpu + if: github.repository_owner == 'deepmodeling' + container: + image: ghcr.io/deepmodeling/abacus-cuda + options: --gpus all + strategy: + fail-fast: false + matrix: + suite: + - 11_PW_GPU + - 12_NAO_Gamma_GPU + - 13_NAO_multik_GPU + - 15_rtTDDFT_GPU + - 16_SDFT_GPU + - 01_PW - - name: Test 13_NAO_multik_GPU - run: | - cd tests/13_NAO_multik_GPU - bash ../integrate/Autotest.sh -n 2 -f CASES_GPU.txt + steps: + - name: Checkout test scripts + uses: actions/checkout@v7 - - name: Test 15_rtTDDFT_GPU - run: | - cd tests/15_rtTDDFT_GPU - bash ../integrate/Autotest.sh -n 2 -f CASES_GPU.txt + - name: Download binary artifact + uses: actions/download-artifact@v4 + with: + name: abacus-cuda-bin + path: install/ + + - name: Make binary executable + run: find install/bin -type f -exec chmod +x {} \; - - name: Test 16_SDFT_GPU + - name: Select 01_PW case list + if: matrix.suite == '01_PW' run: | - cd tests/16_SDFT_GPU - bash ../integrate/Autotest.sh -n 2 -f CASES_GPU.txt + # PRs run the smoke subset; schedule/dispatch runs the full list. + if [ "${{ github.event_name }}" = "pull_request" ]; then + echo "CASE_FILE=CASES_GPU_SMOKE.txt" >> "$GITHUB_ENV" + else + echo "CASE_FILE=CASES_GPU.txt" >> "$GITHUB_ENV" + fi - - name: Test 01_PW on GPU + - name: Test ${{ matrix.suite }} + env: + GTEST_COLOR: 'yes' + OMP_NUM_THREADS: '2' run: | - cd tests/01_PW - find . -name INPUT | while read f; do - if grep -q "^device" "$f"; then - sed -i 's/^device.*/device gpu/' "$f" - else - echo "device gpu" >> "$f" - fi - done - bash ../integrate/Autotest.sh -n 1 -a abacus -f CASES_GPU.txt + export PATH="${GITHUB_WORKSPACE}/install/bin:${PATH}" + cd "tests/${{ matrix.suite }}" + if [ "${{ matrix.suite }}" = "01_PW" ]; then + find . -name INPUT | while read f; do + if grep -q "^device" "$f"; then + sed -i 's/^device.*/device gpu/' "$f" + else + echo "device gpu" >> "$f" + fi + done + bash ../integrate/Autotest.sh -n 2 -f "$CASE_FILE" + else + bash ../integrate/Autotest.sh -n 2 -f CASES_GPU.txt + fi diff --git a/tests/01_PW/CASES_GPU_SMOKE.txt b/tests/01_PW/CASES_GPU_SMOKE.txt new file mode 100644 index 0000000000..6b4fc1a35c --- /dev/null +++ b/tests/01_PW/CASES_GPU_SMOKE.txt @@ -0,0 +1,29 @@ +# Smoke subset of CASES_GPU.txt for pull_request runs (~1/3 of the cases, +# chosen to cover: basic SCF with different pseudopotentials, diagonalization +# solvers CG/David/DS_sca, spin variants nspin=1/2/4, smearing, charge +# mixing, force/stress, relax/cell-relax, symmetry, vdW, MD, DFT+half and +# output options). The full CASES_GPU.txt list still runs on schedule +# (nightly) and workflow_dispatch triggers. +nscf_out_pot +scf_out_elf +001_PW_UPF100_Al +004_PW_UPF201_Si +006_PW_UPF201_Eu +020_PW_kspace +022_PW_CG +023_PW_DA +025_PW_DS_sca +029_PW_15_CF_CS_S1_smallg +035_PW_15_SO +036_PW_AF +037_PW_FM +041_PW_GA_smear +045_PW_BD_chgmix +051_PW_OBOD_MemSaver +058_PW_RE_MB +066_PW_CR_fix_abc +073_PW_SY +083_PW_sol_H2 +090_PW_VWR +101_PW_MD_1O +209_PW_DFTHALF From a9297ce238e22c0fdc14a9ce659da2c577a59758 Mon Sep 17 00:00:00 2001 From: MrLi000001 <77618365+MrLi000001@users.noreply.github.com> Date: Mon, 3 Aug 2026 19:02:32 +0800 Subject: [PATCH 3/3] ci(cuda): fix workflow-level concurrency and keep 01_PW at -n 1 --- .github/workflows/cuda.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cuda.yml b/.github/workflows/cuda.yml index f129e1698d..08ffc5fd9d 100644 --- a/.github/workflows/cuda.yml +++ b/.github/workflows/cuda.yml @@ -13,11 +13,14 @@ defaults: shell: bash concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.suite || 'build' }} + # The matrix context is not available at workflow scope; referencing + # matrix.suite here made the workflow fail to run entirely. Keep the + # same per-ref cancellation semantics as before. + group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: - # ── Job 1: build once, publish the binary as an artifact ───────────── + # 鈹€鈹€ Job 1: build once, publish the binary as an artifact 鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€ build: name: Build CUDA runs-on: gpu @@ -86,7 +89,7 @@ jobs: path: install/ retention-days: 1 - # ── Job 2: matrix instances run their test suites in parallel ──────── + # 鈹€鈹€ Job 2: matrix instances run their test suites in parallel 鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€ gpu-test: name: Test ${{ matrix.suite }} needs: build @@ -144,7 +147,9 @@ jobs: echo "device gpu" >> "$f" fi done - bash ../integrate/Autotest.sh -n 2 -f "$CASE_FILE" + # CI pods are single-GPU: keep the intentional -n 1 from #7690. + # The speed win comes from the smoke subset, not MPI processes. + bash ../integrate/Autotest.sh -n 1 -f "$CASE_FILE" else bash ../integrate/Autotest.sh -n 2 -f CASES_GPU.txt fi