Contributing¶
This page is the single source for the contribution workflow of GPRidge: how to set up a checkout, build and test, write a commit and a news fragment, add a command-line flag or a configuration key, change the documentation, and what the continuous integration (CI) checks. The published documentation shows the same page under Development at https://gpridge.rgoswami.me/development/contributing.html, next to the guides on the documentation build, versions and releases, correctness checks and performance.
By taking part in this project you agree to follow the code of conduct.
The development quick reference lists build commands, source paths and compatibility checks.
Set up a checkout¶
Open pull requests against develop, the integration branch. The main
branch holds released source.
git clone https://github.com/TheochemUI/gpridge.git
cd gpridge
Dependencies come from pixi (version 0.81.0 or newer; the manifest solves for linux-64 only). Three tools are not in the default environment:
A C++20 compiler. The default environment has meson, CMake and ninja but no compiler. The
pythonenvironment brings GCC 14.Rust 1.88 or newer with
cargoon thePATH. TheannealandrgminRust subprojects are enabled by default (use_annealanduse_rgmininmeson_options.txt), and both declarerust-version = "1.88". Only thescalapackenvironment installs Rust; elsewhere install it yourself.cbindgen0.29.4, which generates the C headers of those subprojects.scripts/install_cbindgen_pixi.shinstalls it into the active pixi environment withcargo install. Theinstall-cbindgenpixi task of thepythonandscalapackenvironments runs the script, andpixi run -e python buildruns that task first. For a meson build in the default environment, runbash scripts/install_cbindgen_pixi.shonce from insidepixi shell.
The Prerequisites section of docs/orgmode/getting-started/installation.org
lists the full requirements of the library and the Python package.
Pixi environments¶
Each environment adds one concern to the default one. Run a task with
pixi run -e NAME TASK and open a shell with pixi shell -e NAME.
Environment |
Purpose |
|---|---|
|
C++ build and tests with meson: library dependencies, meson, CMake, ninja, gtest, Catch2, gcovr. |
|
Python bindings (nanobind, meson-python), pytest, GCC 14, Nim. Tasks |
|
Documentation: Emacs, Doxygen, doxyrest, Sphinx, lychee, towncrier, Cog. |
|
Python 3.11 with ASE, h5py and matplotlib, for plotting and analysing run output. |
|
MPI and ScaLAPACK builds, Rust and libclang, GCC 14, the HPC benchmark and profiling tasks. |
|
CUDA compiler and CUTLASS headers, for the optional CUTLASS GEMM path. |
|
|
|
|
|
asv benchmark tasks on top of |
|
SymPy derivations (tasks |
|
Coq and Lean proofs under |
|
Fetches the PET-MAD model and configuration (tasks |
|
Builds the figures of the JCIM manuscript ( |
Run pixi task list -e NAME for the tasks of an environment.
Build and test¶
C++ library and drivers¶
pixi shell
meson setup builddir -Dwith_tests=true
meson compile -C builddir
meson test -C builddir
-Dwith_tests=true builds the test targets and the gprd and gprn drivers
they need. The build type defaults to release. The default build compiles the
Rust subprojects, so install cbindgen first (see above).
Meson groups the tests into suites. meson test -C builddir --list prints
every test with its suite, and --suite NAME selects one.
Suite |
Content |
|---|---|
|
The default suite: unit and integration tests of the library. |
|
The quantum-path tests. |
|
Five checks of pair-local directional curvature and GP iteration limits. |
|
The documentation examples and their lint, see below. |
|
Checks of an installed library. |
|
Tests of the vendored subprojects. |
Run a single test by name, for example
meson test -C builddir test_kernel_properties --print-errorlogs.
Python bindings¶
pixi run -e python build
pixi run -e python test
build runs pip install --no-build-isolation -e . and depends on
install-cbindgen. test runs pytest python/tests/ tests/integration/.
test-coverage runs the same tests with pytest-cov and fails below 100
percent line coverage of python/gpridge.
Optional features¶
Optional dependencies are meson options, listed in meson_options.txt: for
example -Duse_capnp=true for Cap’n Proto configuration files,
-Duse_hdf5=false to drop HDF5, and -Dlinalg_backend=scalapack for the
distributed backend. The CUTLASS path has its own pixi tasks,
test-cutlass-gemm and test-cutlass-rff, in the cutlass environment.
Commit messages¶
Commit subjects follow Conventional Commits:
type(scope): summary, with the scope optional, in the imperative mood and
without a trailing period. The types in the history are fix, docs,
test, chore, feat, style, perf, build and tools. Examples from
the history:
fix(env): declare the locked Linux virtual packages
perf(gp): use pair tiles for open-boundary directional curvature
docs(contributing): bring CONTRIBUTING.org in line with the markdown
Keep one logical change per commit. Close an issue with Fixes #NUMBER in
the pull request description.
News fragments¶
The release notes in CHANGELOG.md are assembled by
towncrier from files in
docs/newsfragments/. A change that a user or developer would notice adds
one fragment. The file name is TOPIC.TYPE.md, with a leading + when no
issue number applies, as in +irc-vibrational-minimum.changed.md; with an
issue number, the name is NUMBER.TYPE.md. TYPE is one of the directories
declared in towncrier.toml:
Type |
Section in the release notes |
|---|---|
|
Security |
|
Removed |
|
Deprecated |
|
Added |
|
Developer |
|
Changed |
|
Fixed |
The file holds a short paragraph in plain Markdown. Preview the notes without writing any file:
pixi run -e docs towncrier build --draft
Towncrier drops a file whose name does not end in .TYPE.md for a declared
type, without a warning. The pre-commit hook newsfragments runs
scripts/check_newsfragments.py, which rejects such files and fragments
outside docs/newsfragments/.
Formatting and pre-commit¶
Run the hooks before opening a pull request. The configuration is
.pre-commit-config.yaml:
uvx prek -a
uvx prek install
The first command checks every file. The second installs the git hook. The
standard pre-commit run --all-files reads the same configuration. The hooks
are:
Trailing whitespace and end-of-file fixes, a YAML check and a check for large files.
clang-formatv16.0.6 with the style in.clang-format, on C and C++ files outsidesubprojects/andthirdparty/.ruffv0.9.7 with its default rules, andruff-format, on Python files.meson format -ionmeson.buildfiles outsidesubprojects/.scripts/check_newsfragments.py, described above.
CI also runs tools/check_copyright.py. Every file that is not vendored
carries the notice Copyright (c) gpridge developers, and the check fails on
any other copyright line.
Conventions for the code:
C++20. Public declarations carry a Doxygen comment (
///or/** */) that starts with@brief, because the C++ API reference is generated from these comments.A new option is a command-line flag backed by a field of the Cap’n Proto schema, as described below, and not a new environment variable.
Python follows the ruff defaults.
Add a command-line flag¶
gprn and gprd are separate drivers with separate parsers.
A gprn flag¶
All of the steps are in main_neb.cpp:
Add a member with its default to the
CliArgsstruct.Add a row to the
kFlagDocstable:{"Group", "--flag <ARG>", "Meaning. Default X."}.gprn --helpprints this table, and the CLI reference page is generated from it. State the default in the text; the generator checks it against theCliArgsinitializer.Register the flag in
parseCli:boolOpt,intOpt,longOpt,doubleOpt,strOptorcstrOptfor a plain value, orparser.add(Option("--flag").argName("ARG").handler(...))when the value needs parsing.Copy the value into the configuration object where
main_neb.cppbuildsGPNEBConfig, for exampleconfig.rff_features = cli.rff_features;.Add a
add("name", ...)line tocliArgLines. It feedsgprn --dump-cli-argsand the parameters logged to MLflow. The CLI tests intests/gpr/GprnCliTest.cppuse the dump.If the option also has a TOML key, copy it from the configuration message in
applyConfigFileToCliArgs, see the next section.
Then regenerate the reference and run the check:
python scripts/gen_cli_reference.py --write
python scripts/gen_cli_reference.py --check
The generator reads kFlagDocs, the registrations and the CliArgs
initializers. It fails when a flag has no row, when a row has no flag, or when
a default in the text differs from the initializer. Hand-written text for a
flag goes in docs/cli_overrides.toml, never in the generated pages.
A gprd flag¶
Register the flag with parser.add(Option("--flag")...) in main.cpp, with
.argName(...), a .help(...) text that says more than the flag name, and a
.handler(...) that writes a member of the CliArgs struct of main.cpp.
Options shared by both drivers, such as --potential, live in
gpr/cli/PotentialOptions.h. Run the same generator and check.
Add a TOML configuration key¶
gprn --config run.toml reads TOML and also accepts a binary Cap’n Proto
message. Both end in the schema schema/params.capnp, and the code that
reads them is built only with -Duse_capnp=true. A new key touches these
files:
schema/params.capnp: add a field to the sub-struct that owns it. Give it the next free ordinal of that struct and a default that reproduces the behaviour without the field. Never renumber, retype or remove a field. RaisecurrentSchemaVersionby one. Name the matching flag in the field’s comment.schema/params.capnp.ordinals: record the field. Runpython scripts/check_capnp_evolution.py --write schema/params.capnp schema/params.capnp.ordinalsand review the added line. The meson testtest_capnp_evolution_paramscompares the two files.managers/io/TomlConfigLoader.cpp: add the key to the allowed-key list of its table (rejectUnknownKeys, which makes an unknown key an error) and read it withsetIfPresent<T>(table, "key", setter).managers/io/CapnProtoNebLoader.cpp: copy the field intoGPNEBConfig.main_neb.cpp: copy the value inapplyConfigFileToCliArgs. The file fills theCliArgsbaseline and the parser overwrites only the fields whose flags are on the command line, so a flag wins over the file.
Then regenerate the reference page and run the check:
python scripts/gen_config_reference.py
python scripts/gen_config_reference.py --check
The generator takes the key list from the setIfPresent calls, resolves each
field in the schema and the flag it mirrors, and takes the default and the
meaning from the CLI reference. A key without a flag needs an entry in the
NO_FLAG table of the script. The design page
docs/orgmode/development/design/params_capnp.org explains the schema.
Documentation¶
The sources are org files under docs/orgmode/. The page
docs/orgmode/development/docs.org describes the build in full. The steps for
a new or changed page:
Pick the page type, one of tutorial, how-to, explanation or reference, and put the file in
tutorials/,howto/,explanation/orreference/. Theory and design pages that are not user guides live inexplanation/theory/anddevelopment/design/.Start the file with
#+TITLE:and#+OPTIONS: toc:nil todo:nil num:nil author:nil. Write math in\( \)and link other pages with[[file:../howto/gpneb.org][text]].Add the page to the toctree in
docs/orgmode/index.org.Mark every code block. A
python,bash,sh,c,cpporfortranblock runs in CI against the build. Use#+begin_src bash :eval no :why REASONfor a block that must not run, and put output in a#+begin_exampleblock. Put#+DOC_OUTPUT:directly before that block to have the runner check it against the output of the block, and write a value that varies between machines as<s>,<n>or another placeholder. The docstring ofscripts/run_doc_examples.pylists the header arguments and the placeholders.Run the example runner, the lint and the export:
python3 scripts/run_doc_examples.py --lint docs/orgmode/howto/PAGE.org
pixi run -e python python scripts/run_doc_examples.py docs/orgmode/howto/PAGE.org -v --build-dir builddir
pixi run -e docs mkrst
After a change to a flag, a key or a Fortran symbol, regenerate the reference
instead of editing it by hand: scripts/gen_cli_reference.py,
scripts/gen_config_reference.py or scripts/gen_fortran_reference.py.
pixi run -e docs check-docs-reference runs the reference checks and verifies that every flag in a documented gprn or gprd command exists.
Files that exist both as org and markdown, such as this one, have the org file
as the source. Regenerate the markdown with
scripts/org_to_md.sh CONTRIBUTING.org and never edit it by hand.
What CI checks¶
The workflows are in .github/workflows/. Each runs on pushes and pull
requests unless the table says otherwise.
Workflow |
Checks |
|---|---|
|
Release build and |
|
The pre-commit hooks, |
|
The reference pages against the sources, the flags of every documented |
|
That every copy of the version matches |
|
The kernel and parser tests under AddressSanitizer and UndefinedBehaviorSanitizer, and a short fuzzing run of the TOML and binary parsers. |
|
The source distribution and the wheels, an install of each in a clean environment, and the PyPI upload for stable tags. |
|
The pkg-config and CMake package, the Fortran fpm package, the Rust |
|
The Lean and Rocq developments, and that no proof is admitted or left unfinished. |
|
The LAMMPS pair style through |
|
Pull requests into |
To reproduce a CI failure, run the command that the failing step prints from the repository root, in the pixi environment the workflow selects.
Benchmarks and performance changes¶
A change that is meant to make code faster needs a measurement before and
after. The pixi task pixi run -e python bench runs
scripts/bench_compare.nim. It builds the base branch (main by default)
and the current HEAD in separate worktrees, runs the asv benchmarks of
benchmarks/ on both, and compares them with asv-spyglass. Pass another
base branch after nim r scripts/bench_compare.nim. Add a benchmark as a
class in benchmarks/ that follows the asv conventions. The page
docs/orgmode/development/developer/performance.org lists the hot paths and
the coding patterns that matter in them.
Submit the change¶
Push the branch to your fork and open a pull request. A maintainer reviews it and may ask for changes. Before opening it:
The hooks pass (
uvx prek -a).meson test -C builddirpasses, andpixi run -e python testpasses when the change touches the Python package.A news fragment is present when the change is user-visible.
Generated reference pages are regenerated, and every new documentation page is in the toctree.