Thank you for your interest in contributing to GridFM. This document explains our contribution process and procedures:
- Scope: What Belongs in This Repository
- How to Contribute a Bug Fix or Change
- Running the Integration Tests
- Development Workflow
- Coding Style
For a description of the roles and responsibilities of the various members of the GridFM community, see the governance policies, and for further details, see the project's Technical Charter. Briefly, Contributors are anyone who submits content to the project, Committers review and approve such submissions, and the Technical Steering Committee provides general project oversight.
If you just need help or have a question, refer to SUPPORT.md.
gridfm-graphkit is a library for training, finetuning, and interacting with a
foundation model for the electric power grid. Contributions that extend or improve
this core belong here — for example:
- Model architectures, layers, and loss functions.
- Training, finetuning, and evaluation logic.
- Data loading, transforms, and shared utilities.
- Bug fixes, performance improvements, tests, and documentation for the above.
Application-specific contributions belong in a companion GridFM applications repository, not here. If your contribution is an end-to-end application, a deployment, or a pipeline/notebook/experiment tied to one specific use case or study, please contribute it to the relevant GridFM applications repository instead of adding it to the core library. Keeping application-specific code out of the core keeps this library focused, broadly reusable, and free of use-case-specific dependencies.
If you are unsure whether a contribution is "core" or "application-specific", open an issue to discuss it before starting work.
To contribute code to the project, first read over the governance policies page to understand the roles involved.
Each contribution must meet the PEP 8 and include..
- Tests and documentation to explain the functionality.
- Any new files have copyright and license headers
- A Developer Certificate of Origin signoff.
- Submitted to the project as a pull request.
GridFM is licensed under the Apache 2.0 license. Contributions should abide by that standard license.
Project committers will review the contribution in a timely manner, and advise of any changes needed to merge the request.
The integration tests in integrationtests/ assert that training metrics fall
within calibrated bounds. These bounds are machine-specific (they depend on
your CPU/GPU, CUDA, and library versions), so the baseline
(integrationtests/calibration_baseline.json) is not committed — it is
git-ignored and you calibrate your own on your machine first.
Prerequisite. The tests train through MLflow; if you don't have an MLflow tracking server, opt into the local file store first:
export MLFLOW_ALLOW_FILE_STORE=trueCalibrate before you change any code. Run the calibration on a clean checkout so the recorded bounds reflect the current behaviour, then make your changes and run the tests to detect any drift they introduce:
-
On an unchanged checkout, calibrate a baseline on this machine:
pytest integrationtests --calibrate -s
This runs training 5 times and writes per-metric bounds (plus a per-test environment fingerprint) to
integrationtests/calibration_baseline.json. -
Make your code changes.
-
Run the integration tests (no
--calibrate) to assert against the baseline you calibrated in step 1:pytest integrationtests -s
If you calibrate after changing the code, the baseline will simply encode your changed behaviour and the tests can no longer catch regressions — always calibrate on the unchanged code first.
Passed to pytest:
| Flag | When omitted | Meaning |
|---|---|---|
--calibrate [N] |
assert mode (train once, check bounds) | --calibrate alone → 5 calibration runs; --calibrate N → N runs. Both write bounds and skip assertions. |
--ci C |
0.995 |
Confidence level for the Student-t interval (calibration mode only). |
--pad P |
0.01 |
Relative floor on each bound's half-width (`P * |
Calibrated bounds depend on your hardware (CPU/GPU), CUDA/cuDNN, and library
versions (notably the PyTorch version), so each test's bounds are stamped with
their own environment fingerprint under fingerprints in the baseline. When
you run the assertion tests, a fingerprint that differs from the one recorded
for that test emits a loud warning but does not fail the run — it lists
every differing field.
A mismatch means the recorded bounds may not hold in your current environment (for example, after a PyTorch upgrade the metrics can shift). When you see this warning, recalibrate on the unchanged code in your current environment before trusting the assertions:
export MLFLOW_ALLOW_FILE_STORE=true
pytest integrationtests --calibrate -sBefore opening a PR, make sure you complete all steps:
-
Install dev, test, and torch-scatter dependencies.
torch-scatteris not on PyPI — it needs a prebuilt wheel fromdata.pyg.orgthat matches both your PyTorch version and your compute backend. Pick the rightCUDA_TAGfrom the table below:Hardware CUDA_TAGCPU only cpuCUDA 11.8 cu118CUDA 12.1 cu121CUDA 12.6 cu126Not sure which tag to use? If you don't have an NVIDIA GPU (including Apple Silicon and CPU-only machines), use
cpu. For NVIDIA GPUs, check your CUDA version withnvidia-smi(top-right corner) ornvcc --version.Replace
<CUDA_TAG>in the command below:pip does not read
[tool.uv] find-linksinpyproject.toml. Pass the index yourself, and pintorch==2.12.*in the same command. That matches the package pintorch>=2.10,<2.13and the wheel index below.pip install -e ".[dev,test]" "torch==2.12.*" \ --find-links https://data.pyg.org/whl/torch-2.12.0+<CUDA_TAG>.html
For example, CPU-only:
pip install -e ".[dev,test]" "torch==2.12.*" \ --find-links https://data.pyg.org/whl/torch-2.12.0+cpu.html
Or CUDA 12.6:
pip install -e ".[dev,test]" "torch==2.12.*" \ --find-links https://data.pyg.org/whl/torch-2.12.0+cu126.html
Note: The PyTorch version (
2.12.0) in the URL must match what is installed. If you change thetorchpin inpyproject.toml, update this URL and regenerate the lock file withuv lock.No prebuilt wheel for your combination? If
data.pyg.orghas no prebuilt wheel for your combination, build from source instead. This compiles against the installed torch. Stay inside the package pintorch>=2.10,<2.13, and install torch first:pip install torch==2.12.0 pip install torch-scatter torch-sparse --no-build-isolation
Building from source requires a C++ compiler (and a matching CUDA toolkit with
nvccfor GPU builds).
-
Install the git hooks (this repo runs pre-commit hooks at the pre-push stage):
pre-commit install -
Create a new branch for your feature from
main.
- Write clear, readable code with self-explanatory variable names.
- Comment code where needed.
- Prefer the clearest implementation if multiple options have similar complexity.
- Add Google-style Python docstrings for all functions/classes.
- Double-check that no debug prints or temporary files are left in the code.
- Update documentation and
README.mdwhenever relevant.
-
Add any new dependencies to
pyproject.toml. -
If introducing new parameters, update all relevant YAML files:
examples/configtests/config
-
Ask your favorite code assistant to identify bugs and edge cases.
-
Add unit tests covering:
- Core functionality of your changes.
- Potential edge cases.
-
Run all tests:
MLFLOW_ALLOW_FILE_STORE=true pytest tests/
-
Run integration tests, see Running the Integration Tests.
The hooks run automatically on git push. To run them manually before pushing:
-
Run the hooks on all files:
pre-commit run --all-files
-
Fix any issues.
-
Re-run the hooks after any code changes.
-
Build docs and check rendering:
mkdocs build mkdocs serve
- Rebase your branch onto the latest
mainbefore opening a PR. - Sign off all commits with the Developer Certificate of Origin (
git commit -s). See Developer Certificate of Origin signoff. - Open a PR with a short description of your changes.
- Ensure code, tests, and documentation are clear and complete.