Repository navigation
Gpu assignment - #231
Open
The9Cat wants to merge 13 commits into
Open
Gpu assignment#231The9Cat wants to merge 13 commits into
The9Cat wants to merge 13 commits into
Conversation
added 4 commits
December 1, 2026 13:13
- freeze0: none (default; false also works), n0 (or true) or all. The k=0 field is captured at the first complete coefficient evaluation, after the MPI reduce and after multistep assembly. That's the same point the existing self_consistent: false freeze uses. - n0 sets value0 to the measured k=0, n=0 coefficient and turns on fixed0, so after capture it is your existing fixed0 path. all keeps every measured k=0 coefficient fixed. - Measured coefficients are unchanged, so outcoef still records the particles' live k=0 field as a diagnostic. - State file: SlabSL.freeze0.<component>.<runtag>.yml in outdir; you can override the name with freeze0file. Root writes it at capture. On a restart, root reads and checks it, then broadcasts it over MPI. If the file is missing, or its mode or nmaxz differ from the config, the run warns and re-measures. - Logging: stdout logs every decision: pending, captured (with T, value0 and all k=0 coefficients), restored, overridden (when fixed0/value0 are also given) and ignored (self_consistent: false). - GPU: no kernel change. For n0, initialize_constants() already copies slabFixed0 and slabValue0 to the device on every force call. For all, HtoD_coefs() swaps in the frozen k=0 entries before the copy. - Tests on 2 MPI ranks using a 20k-particle slab - GPU test TBD
- ExternalForce gains two methods: wantStepEnd(t), which by default
never asks, and stepEnd(), which by default does nothing. The header
comment spells out what a module may and may not do there.
- ExternalCollection::stepEnd() calls the hook for each force that
asks. For a force that isn't CUDA-aware, it first copies particles
to the host.
- The hook runs at every synchronized point:
- once in begin.cc, at the initial state;
- after the closing kick of every full step in step.cc, in both the
multistep and non-multistep branches, just before output.
- the actual commit on every build is recorded, with no cmake re-run needed; - for uncommitted changes, <hash>-dirty-<8 hex>, a fingerprint of git diff HEAD, so each distinct uncommitted state is identifiable. - Untracked files and changes inside submodules don't count as changes. Run199k's header would have read 8c74787…-dirty-… under this scheme. - Rebuild cost: the generated file is rewritten only when the git state changes - An unchanged rebuild compiles nothing. A change recompiles only parse.cc and OutHDF5.cc, plus ModulesVersion.cc - COMPILE_TIME ("Built:" in the config header) now means the time of the first build of that exact source state, not the time of the last cmake run.
Mode and behavior are as follows: - Mode 'auto' selects ordinal 0 when one GPU is visible. Otherwise uses the existing node-local rank and ngpus mapping. - Mode 'task' uses the rank’s visible GPU list. gpu_ordinal defaults to 0. Ranks sharing a GPU UUID on the same node trigger a warning. - Mode 'node' requires ranks on a node to see the same ordered GPU list and assigns by node-local rank. - Set gpu_allow_sharing: true to allow round-robin sharing. Existing configurations default to 'auto' and keep the current device-selection behavior. The changed sources compiled, and eight four-rank MPI checks passed with simulated CUDA devices, including duplicate UUID warnings and rejection of mismatched node lists.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Active issues leave hook velocities unsynchronized, risk MPI deadlock on filesystem errors, and make point-evaluated fields inconsistent with the frozen field used for particle forces.
3 open issues
What changed in this PR
Adds flexible GPU assignment for EXP runs with scheduler-controlled device visibility, including one-GPU-per-task configurations.
Changes:
- Adds
auto,task, andnodeGPU assignment modes with validation and diagnostics. - Introduces synchronized external-force hooks and persistent SlabSL frozen-field options.
- Generates Git provenance at build time.
| File | Description |
|---|---|
| src/step.cc | Calls step-end hooks before output. |
| src/SlabSL.H | Declares and documents frozen-field options. |
| src/SlabSL.cc | Captures, restores, and applies frozen coefficients. |
| src/parse.cc | Parses GPU settings and includes provenance. |
| src/OutHDF5.cc | Includes build-time provenance. |
| src/global.H | Declares GPU assignment settings. |
| src/global.cc | Defines GPU assignment defaults. |
| src/global_key_set.H | Registers GPU configuration keys. |
| src/ExternalForce.H | Defines optional synchronized hooks. |
| src/ExternalCollection.H | Declares hook dispatch. |
| src/ExternalCollection.cc | Dispatches hooks with GPU-to-host synchronization. |
| src/cudaSlabSL.cu | Uploads frozen coefficients for CUDA evaluation. |
| src/CMakeLists.txt | Adds provenance-generation dependency. |
| src/begin.cc | Implements GPU assignment and initialization hooks. |
| pyEXP/UtilWrappers.cc | Includes build-time provenance. |
| pyEXP/PyWrappers.cc | Includes build-time provenance. |
| pyEXP/CMakeLists.txt | Adds Python provenance dependency. |
| exp_git_version.h_in | Defines the generated provenance header. |
| config_cmake.h_in | Removes configure-time provenance definitions. |
| CMakeLists.txt | Schedules build-time provenance generation. |
| cmake/GitVersion.cmake | Generates provenance with dirty-tree fingerprints. |
Review effort: Balanced
Updated file existence check to include error handling. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…ient Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
added 5 commits
December 2, 2026 22:12
- Add a manifest list to make sure that crufty module libraries are removed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
The current GPU assignment assumes that EXP has exclusive access to each
GPU device on the cluster. This is not always possible on large clusters. For
example, a flexible resource assignment using Slurm could result in
EXP leaving ranks without a CUDA device when Slurm binds one GPU
per task. Each rank sees only CUDA ordinal
0, but EXP compared therank's node-local index against that process's visible GPU count.
This PR attempts to provide more more flexibility as follows:
0.Global.gpu_assignmentwith three modes:auto(default) preserves the existing multi-GPU mapping andhonors
ngpus.taskselectsgpu_ordinalfrom each rank's visible list(default
0) and warns when ranks on a node select the same GPU UUID.noderequires identical ordered GPU lists across ranks on a nodeand assigns by node-local rank. Set
gpu_allow_sharing: truetoallow round-robin sharing.
CUDA_VISIBLE_DEVICES, selectedordinal, and GPU UUID.
EXP continues to use one GPU per MPI rank.
Verification
with simulated CUDA devices, covering assignment, sharing, and invalid
configurations.
Documentation
The
develbranch for the Sphinx documentation describes this newfunctionality with examples.