Skip to content

[lammps] GPU(KOKKOS/CUDA)ビルドモード追加・arch 可変(kugui A100 検証済み) - #202

Open
k-yoshimi wants to merge 2 commits into
developfrom
feat/lammps-gpu
Open

[lammps] GPU(KOKKOS/CUDA)ビルドモード追加・arch 可変(kugui A100 検証済み)#202
k-yoshimi wants to merge 2 commits into
developfrom
feat/lammps-gpu

Conversation

@k-yoshimi

Copy link
Copy Markdown
Collaborator

概要

apps/lammps(stable_29Aug2024_update1, CMake)に GPU ビルドモード config/gpu を追加します。KOKKOS パッケージ + CUDA バックエンドで GPU 版 lmp をビルドします。default と同じパッケージ集合(all_on + nolib)を GPU 加速する構成です。

GPU arch を可変に(重要)

GPU の compute capability はマシンごとに異なるため(kugui=A100, clavius=別 arch 等)、KOKKOS_ARCH を config.txt のチューナブル変数にしました:

  • config/gpu/preprocess.sh-DKokkos_ARCH_${KOKKOS_ARCH}=ON を使用。
  • 既定値は無し(誤った arch のバイナリは GPU で動かないため、暗黙のデフォルトは危険)。未設定時は ${VAR:?...} で即座に分かりやすく失敗し、代表値(AMPERE80=A100, VOLTA70=V100, HOPPER90=H100, TURING75, ADA89, PASCAL60)を案内。
  • 別 GPU マシンでも KOKKOS_ARCH を変えるだけで対応可能。

nvcc(CUDA toolkit)と CUDA-aware MPI が PATH 上に必要。LAMMPS 同梱の nvcc_wrapper を C++ コンパイラに使用。stand-alone の GPU パッケージは無効化し KOKKOS を単一の GPU バックエンドに。

検証(物性研 kugui, NVIDIA A100 cc80, PBS GPU ノード)

  • KOKKOS_ARCH=AMPERE80 で configure 成功(Kokkos 4.3.1, Architecture AMPERE80, Backends OPENMP;CUDA, CUDA 12.4)。
  • KOKKOS-CUDA ビルド成功、lmplibcudart にリンク。
  • A100 で GPU 実行lmp -k on g 1 -sf kk -in bench/in.lj): KOKKOS mode ... will use up to 1 GPU(s) per node, attributes: ... kokkos_device, 5133 timesteps/s(exit 0)。

留意点

  • 本モードは NVIDIA GPU + CUDA が必要なため GitHub CI では検証不可(既存 CPU モードの CI はそのまま)。
  • kugui の計算ノードは外部ネット不可のため、all_on の MESONT パッケージが configure 時に行うポテンシャル DL は計算ノードで失敗する(configure はネットのあるノードで実施)。これは default ビルドと共通の既存挙動で GPU 固有ではない。

🤖 Generated with Claude Code

New config/gpu mode builds LAMMPS with the KOKKOS package and the CUDA
backend, using the same package set as the default build. The target GPU
architecture is a tunable: set KOKKOS_ARCH (e.g. AMPERE80 for A100, VOLTA70
for V100, HOPPER90 for H100, TURING75, ADA89, PASCAL60) so the same mode
works across machines (kugui A100, clavius, ...). There is no default arch
on purpose - a wrong arch yields binaries that will not run on the GPU - so
the preprocess fails fast with a clear message when KOKKOS_ARCH is unset.

Requires nvcc (a CUDA toolkit) and a CUDA-aware MPI on PATH; uses the
nvcc_wrapper shipped with LAMMPS as the C++ compiler.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QaWKJsSQqCakkMEKZpJcvP
- install.sh: fail fast (before download/extract) when mode=gpu and
  KOKKOS_ARCH is unset, instead of only hitting the guard in preprocess
  after setup (Antigravity workflow risk)
- config/gpu/preprocess.sh: reject a KOKKOS_ARCH with characters outside
  [A-Za-z0-9_] before it is spliced into the -DKokkos_ARCH_<NAME> option
  (Codex), and quote the nvcc_wrapper path; point the comment at the Kokkos
  configuration guide
- document the gpu mode + the required KOKKOS_ARCH (and the wrong-arch
  runtime-failure caveat) in the en/ja README and the Sphinx appendix, for
  consistency with the espresso gpu mode

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QaWKJsSQqCakkMEKZpJcvP
@k-yoshimi

Copy link
Copy Markdown
Collaborator Author

AI レビューサイクル結果(Codex + Antigravity)

Phase 1 — Codex(コード correctness)

  • must_fix: なし
  • should_fix(対応済み): -DKokkos_ARCH_${KOKKOS_ARCH}=ONKOKKOS_ARCH を素で展開している点 → [A-Za-z0-9_] 以外を弾く case バリデーションを追加(不正値は cmake 到達前に明確に失敗)。
  • optional(対応済み): nvcc_wrapper パスをクォート(空白パス対策)。

Phase 2 — Antigravity(ドキュメント / ワークフロー)

  • must_fix_docs(対応済み): GPU モードと必須 KOKKOS_ARCH が未ドキュメント → en/ja README + Sphinx appendix(README_lammps.rst)に GPU セクションを追記(espresso と整合。誤 arch は実行時失敗する旨も明記)。
  • workflow_risk(対応済み): KOKKOS_ARCH 未設定時、download/extract 後に preprocess で失敗=無駄 → install.sh 冒頭で mode=gpu かつ未設定なら即失敗(ダウンロード前)に。
  • should_fix(対応済み): コメントの Kokkos リンクを設定ガイドへ変更。
  • optional(省略): runtest の GPU 実行検証は runtest がモード非依存のため見送り。

検証

物性研 kugui(A100 cc80)で KOKKOS_ARCH=AMPERE80 にて configure(Kokkos 4.3.1, Backends OPENMP;CUDA)→ ビルド → GPU 実行lmp -k on g 1 -sf kk, will use up to 1 GPU(s) per node)を実機確認済み。GPU arch は KOKKOS_ARCH で可変(clavius 等別 GPU も変数変更のみ)。GPU/CUDA 必須のため CI 非対象。

must_fix 系は無し/指摘は対応済み。収束と判断します。

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.

2 participants