Skip to content

test: restore bounded GPU correctness tests - #1026

Draft
Stardust0831 wants to merge 1 commit into
cp2k:developfrom
Stardust0831:restore-gpu-correctness-tests
Draft

Stardust0831 wants to merge 1 commit into
cp2k:developfrom
Stardust0831:restore-gpu-correctness-tests

Conversation

@Stardust0831

@Stardust0831 Stardust0831 commented Jul 19, 2026 •

Copy link
Copy Markdown
Member

Motivation

The libsmm_acc_unittest_multiply and libsmm_acc_unittest_transpose executables are built for CUDA and HIP, but their CTest registrations have been disabled because the original tests were not parallelized and were too slow (see #427). As a result, accelerator builds currently compile the tests without running their correctness checks.

Fixes #427.

Changes

  • Register the two libsmm_acc correctness tests for CUDA and HIP builds while leaving the timer/performance tests disabled.
  • Bound the default smoke coverage to 64 autotuned multiplication kernels, 64 predicted kernels, and 64 transpose pairs.
  • Make sampling deterministic and expose zero-valued limits as an explicit full-coverage mode.
  • Initialize MPI and the accelerator in the correctness executables, select a device using the node-local MPI rank, and shard cases cyclically across global ranks.
  • Aggregate correctness failures across ranks and normalize the process exit status to avoid truncating large error counts.
  • Label the tests gpu;libsmm_acc, run them serially to avoid GPU contention, and provide configurable rank and timeout settings.

Non-MPI builds continue to execute the same tests directly with one process.
No production DBCSR kernel or accelerator code is changed.

GitHub Actions red/green validation

I ran the same temporary self-hosted workflow against the code before and after this patch. The workflow itself is kept only on validation branches in my fork and is not part of this PR.

  • Before: run 29677536620
    • source: upstream develop plus only the temporary workflow
    • configure: passed
    • build: passed
    • CTest: failed as expected with Total Tests: 0 and test_rc=8
    • Slurm logs were uploaded as the dbcsr-v100-gha-gpu-before-29677536620
      artifact
  • After: run 29677660083
    • source files are byte-identical to this PR patch
    • 4 NVIDIA V100 GPUs, CUDA 12.4.1, GCC 14.3, OpenMPI 5.0.10
    • configure: passed
    • build: passed
    • libsmm_acc_unittest_multiply: passed in 50.27 s
    • libsmm_acc_unittest_transpose: passed in 3.47 s
    • 2/2 tests passed; logs were uploaded as the dbcsr-v100-gha-gpu-after-29677660083 artifact

Additional validation

  • Full V100 parameter coverage on 32 GPUs across two nodes:
    • 1,235 autotuned and 72,857 predicted multiplication kernels
    • 1,769 transpose pairs
    • zero correctness errors
  • Round-robin multi-node placement on 8 GPUs across two nodes verified that node-local ranks select devices 0-3 independently on each node; both tests passed with zero errors.
  • Non-MPI CUDA smoke tests passed on one V100.
  • The relevant pre-commit hooks pass, including ruff, Black, Python AST, cmake-format, header checks, and clang-format-fypp.

As a separate validation of the MPI/device-sharding approach, I also ran libsmm_acc_timer_multiply with a benchmark-only patch on 1, 2, 4, 8, and 16 V100 GPUs. A fixed 1,024-kernel workload reached 1.98x, 3.44x, 4.82x, and 7.59x speedup, respectively, and all CPU checksum validations passed. The timer changes are not included in this PR.

CUDA runtime behavior was validated on V100 GPUs. HIP/ROCm remains covered by the existing compile CI, but I did not have an AMD GPU runner for a HIP runtime test. These are DBCSR backend correctness tests rather than CP2K application
regression inputs. The upstream GitHub Actions accelerator jobs currently compile these executables without access to a physical GPU; this PR makes the tests runnable by GPU-enabled CTest environments but does not add a permanent GPU runner.

@Stardust0831

Copy link
Copy Markdown
Member Author

The two Fedora Rawhide Packit failures appear unrelated to this PR. Both fail while linking the existing dbcsr_test and dbcsr_tensor_test executables with unresolved c_dbcsr_* symbols. PR #1025 shows the same failures on both Rawhide architectures. The CUDA and ROCm MPI/non-MPI build checks for this PR all pass.

@Growl1234

Growl1234 commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

The two Fedora Rawhide Packit failures appear unrelated to this PR. Both fail while linking the existing dbcsr_test and dbcsr_tensor_test executables with unresolved c_dbcsr_* symbols. PR #1025 shows the same failures on both Rawhide architectures. The CUDA and ROCm MPI/non-MPI build checks for this PR all pass.

I can take care of this. Similar issue also happened with CP2K.

Edit: Done with #1027.

@Stardust0831
Stardust0831 force-pushed the restore-gpu-correctness-tests branch from b843ad1 to 4513996 Compare July 20, 2026 09:42
@alazzaro

Copy link
Copy Markdown
Member

@Stardust0831 thanks for your PR. I must admit, the checks of the GPU kernels are less and less important nowadays since we now provide a generic kernel. The other limitation is that CI doesn't check GPU execution at all, so there is no way to verify it (I will do it manually in the next days).
The only scenario where I can see those tests being useful is when people want to apply kernels for GPU X on a different GPU Y (still, this doesn't prevent side effects if the requested kernel is not present).
Please, allow me some time to check your PR.

@Stardust0831

Copy link
Copy Markdown
Member Author

Thanks @Growl1234 for quickly tracking this down and fixing the Fedora Rawhide/GCC 16 C API linking issue in #1027! After rebasing onto the latest develop and rerunning CI, all checks on this PR are now passing. Much appreciated!

@Growl1234

Copy link
Copy Markdown
Contributor

Hi, is there any progress?

@alazzaro

alazzaro commented Oct 8, 2026

Copy link
Copy Markdown
Member

Hi, is there any progress?

No, this is a no-go since that code will be removed at some point (and restoring old stuff with AI is not a good idea). Why are you asking?

@Growl1234

Copy link
Copy Markdown
Contributor

I'm simply asking because there hasn't been further response for the past two months. Now that the direction is clear, I have no problem with it.

@alazzaro

alazzaro commented Oct 8, 2026

Copy link
Copy Markdown
Member

Yes, that's reasonable (no issues), but I care more about functionality... Note that the PR reintroduces tests on GPUs that are not executed in the DBCSR CI (we only compile HIP/CUDA, no tests are executed).
I should have an updated version of the DBCSR in about 2 months (for the next CP2K release). So, please stand by.

@Stardust0831

Copy link
Copy Markdown
Member Author

Understood — closing this PR. With the generic-kernel fallback in place, these checks are indeed largely obsolete, and the V100 validation results above stay here for reference.

One more thing: regarding the point that CI cannot verify GPU execution — this is actually solvable. I recently landed a solution of the same pattern upstream in ABACUS (deepmodeling/abacus-develop#7665): GitHub Actions acts only as the control plane, driving a Slurm cluster over SSH to do real builds and GPU tests (including multi-node cases), with results reported back to the PR as summaries and logs. If this approach would help GPU-acceleration-related development in DBCSR, I'm happy to provide the test environment and compute resources free of charge to run real tests.

@alazzaro

alazzaro commented Oct 8, 2026

Copy link
Copy Markdown
Member

Please, do not close it. I keep it as a placeholder for things to do.
In the past we had a way to run on the CSCS daint (Cray system), we still have budget there...

@alazzaro alazzaro reopened this Oct 8, 2026
@alazzaro
alazzaro marked this pull request as draft October 22, 2026 08:42

This branch has not been deployed

No deployments
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.

tests: make libsmm_acc tests run with MPI

3 participants