Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
fb298c2
Examples/contingency ipynb (#46)
celiacintas Aug 29, 2025
22f2cce
GNS-inspired model (#47)
MatteoMazzonelli Oct 7, 2025
5f41414
heteroGNS
MatteoMazzonelli Oct 31, 2025
7b11437
Bounded opf
MatteoMazzonelli Nov 10, 2025
933cf89
heterogeneous changes
MatteoMazzonelli Nov 20, 2025
adca359
Cleaned up version
MatteoMazzonelli Nov 20, 2025
cc630f8
Working GNS heterogeneous
MatteoMazzonelli Dec 1, 2025
0817268
Fixed inactive elements
MatteoMazzonelli Dec 4, 2025
a851d79
Working PF and OPF
MatteoMazzonelli Dec 5, 2025
5fc2f3e
Fix task handler
MatteoMazzonelli Dec 5, 2025
9453743
First physics decoder version
MatteoMazzonelli Dec 9, 2025
ab18be7
pre-commit check
MatteoMazzonelli Dec 9, 2025
9c0a810
train models for SE (#51)
Dec 11, 2025
c158c7a
pre-commit checks (#52)
MatteoMazzonelli Dec 11, 2025
bc49666
load grid data for unknown perturbations
Dec 11, 2025
ce730c5
split train val test by load scenario
Dec 12, 2025
dd9989c
test edge flows calculations against branch_data
Dec 12, 2025
6f1fcff
pr-commit stuff
Dec 13, 2025
ae00474
fix in loss
Dec 15, 2025
4859bfe
plots for state estimation task test
Dec 16, 2025
cc87de2
Merge pull request #53 from PowerGrid-FM/dev-hector
Dec 22, 2025
5220fd1
Fix pf masking and configs (#55)
MatteoMazzonelli Jan 6, 2026
c25a745
weights_only True (#56)
MatteoMazzonelli Jan 8, 2026
604bd45
Updated configs
MatteoMazzonelli Jan 13, 2026
98de7cd
Removed backward compatibility and added tests
MatteoMazzonelli Jan 13, 2026
35efc82
pre-commit checks
MatteoMazzonelli Jan 13, 2026
3cd0cab
added ccc specifics
albanpuech Jan 23, 2026
f7816f1
implemented norm on train only
albanpuech Feb 12, 2026
454362d
fixed eval on multiple gpus
albanpuech Feb 16, 2026
89be3e4
reuse data loader stat for other gpus and for eval
albanpuech Feb 16, 2026
920c9b7
save split idx in dataloader
albanpuech Feb 16, 2026
07ebc1a
fix main
albanpuech Feb 16, 2026
435da49
updated readme
albanpuech Feb 16, 2026
b2022c9
fixed main
albanpuech Feb 16, 2026
98304c0
fixed config
albanpuech Feb 17, 2026
617c616
fixed config
albanpuech Feb 17, 2026
9a86709
evaluation with predict
albanpuech Feb 23, 2026
f759ced
renamed columns dc residuals
albanpuech Feb 25, 2026
85de80f
Remove Infiniband configuration functions
albanpuech Mar 1, 2026
f870180
Update pyproject.toml
albanpuech Mar 2, 2026
0b13a97
Revise installation instructions in README.md
albanpuech Mar 2, 2026
bc0ff28
Revise installation steps in README.md
albanpuech Mar 2, 2026
b9c1616
merge with main
albanpuech Mar 3, 2026
3b498ab
finalized merge
albanpuech Mar 3, 2026
771a122
fixed datakit requirement in pyproject
albanpuech Mar 3, 2026
b93843f
ruff fix
albanpuech Mar 3, 2026
a710af3
fix formatting
albanpuech Mar 3, 2026
56af109
Correct TORCH_CUDA_VERSION assignment in README
albanpuech Mar 4, 2026
de14305
Add urllib3 as a required dependency to fix security issue
romeokienzler Mar 6, 2026
1c45c79
Merge branch 'normalization_fixed_eval_predict_merge_main' into patch-3
romeokienzler Mar 6, 2026
cd2ad50
Merge pull request #37 from romeokienzler/patch-3
albanpuech Mar 6, 2026
a31cb81
Enhance detect-secrets scan configuration
romeokienzler Mar 6, 2026
8cf048f
Merge pull request #38 from romeokienzler/patch-3
albanpuech Mar 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/workflows/ci-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,19 @@ jobs:
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade "git+https://github.com/ibm/detect-secrets.git@master#egg=detect-secrets"
python3 -m pip install boxsdk

- name: Scan repository & write snapshot
run: |
mkdir -p security-outputs
# Run the scan; send stderr to a log; stdout to JSON

# Run detect-secrets while skipping binary files
detect-secrets scan \
--exclude-files '.*\.ipynb$' \
--exclude-files '.*\.ipynb$|.*\.(png|jpg|jpeg|gif|pdf|onnx|pt|pth|bin|zip)$' \
--exclude-lines '"(outputs|image/\w+|id|hash)":.*' \
> security-outputs/ds-results.json 2> security-outputs/.secrets.new

--force-use-all-plugins \
. \
> security-outputs/ds-results.json \
2> security-outputs/.secrets.new || true


- name: Upload scan artifacts (for triage)
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ If you just need help or have a question, refer to [SUPPORT.md](SUPPORT.md).

## How to Contribute a Bug Fix or Change

To contribute code to the project, first read over the [governance policies] page to understand the roles involved.
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..

Expand Down
103 changes: 67 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,28 @@ This library is brought to you by the GridFM team to train, finetune and interac

# Installation

You can install `gridfm-graphkit` directly from PyPI:
Create and activate a virtual environment (make sure you use the right python version = 3.10, 3.11 or 3.12. I highly recommend 3.12)
```bash
python -m venv venv
source venv/bin/activate
```

Install gridfm-graphkit in editable mode
```bash
pip install gridfm-graphkit
pip install -e .
```

To contribute or develop locally, clone the repository and install in editable mode:
Get PyTorch + CUDA version for torch-scatter
```bash
TORCH_CUDA_VERSION=$(python -c "import torch; print(torch.__version__ + ('+cpu' if torch.version.cuda is None else ''))")
```

Install the correct torch-scatter wheel
```bash
git clone git@github.com:gridfm/gridfm-graphkit.git
cd gridfm-graphkit
python -m venv venv
source venv/bin/activate
pip install -e .
pip install torch-scatter -f https://data.pyg.org/whl/torch-${TORCH_CUDA_VERSION}.html
```


For documentation generation and unit testing, install with the optional `dev` and `test` extras:

```bash
Expand All @@ -45,15 +51,15 @@ pip install -e .[dev,test]

# CLI commands

An interface to train, fine-tune, and evaluate GridFM models using configurable YAML files and MLflow tracking.
Interface to train, fine-tune, evaluate, and run inference on GridFM models using YAML configs and MLflow tracking.

```bash
gridfm_graphkit <command> [OPTIONS]
```

Available commands:

* `train` Train a new model from scrathc
* `train` - Train a new model from scratch
* `finetune` – Fine-tune an existing pre-trained model
* `evaluate` – Evaluate model performance on a dataset
* `predict` – Run inference and save predictions
Expand All @@ -70,11 +76,11 @@ gridfm_graphkit train --config path/to/config.yaml

| Argument | Type | Description | Default |
| ---------------- | ------ | ---------------------------------------------------------------- | ------- |
| `--config` | `str` | **Required**. Path to the training configuration YAML file. | `None` |
| `--exp_name` | `str` | **Optional**. MLflow experiment name. | `timestamp` |
| `--run_name` | `str` | **Optional**. MLflow run name. | `run` |
| `--log_dir ` | `str` | **Optional**. MLflow logging directory. | `mlruns` |
| `--data_path` | `str` | **Optional**. Root dataset directory. | `data` |
| `--config` | `str` | **Required**. Path to the training configuration YAML file. | `None` |
| `--exp_name` | `str` | MLflow experiment name. | `timestamp` |
| `--run_name` | `str` | MLflow run name. | `run` |
| `--log_dir` | `str` | MLflow tracking/logging directory. | `mlruns` |
| `--data_path` | `str` | Root dataset directory. | `data` |

### Examples

Expand All @@ -89,15 +95,15 @@ gridfm_graphkit train --config examples/config/case30_ieee_base.yaml --data_path
## Fine-Tuning Models

```bash
gridfm_graphkit finetune --config path/to/config.yaml --model_path path/to/model.pth
gridfm_graphkit finetune --config path/to/config.yaml --model_path path/to/model.pt
```

### Arguments

| Argument | Type | Description | Default |
| -------------- | ----- | ----------------------------------------------- | --------- |
| `--config` | `str` | **Required**. Fine-tuning configuration file. | `None` |
| `--model_path` | `str` | **Required**. Path to a pre-trained model file. | `None` |
| `--model_path` | `str` | **Required**. Path to a pre-trained model state dict. | `None` |
| `--exp_name` | `str` | MLflow experiment name. | timestamp |
| `--run_name` | `str` | MLflow run name. | `run` |
| `--log_dir` | `str` | MLflow logging directory. | `mlruns` |
Expand All @@ -109,38 +115,63 @@ gridfm_graphkit finetune --config path/to/config.yaml --model_path path/to/model
## Evaluating Models

```bash
gridfm_graphkit evaluate --config path/to/eval.yaml --model_path path/to/model.pth
gridfm_graphkit evaluate --config path/to/eval.yaml --model_path path/to/model.pt
```

### Arguments

| Argument | Type | Description | Default |
| -------------- | ----- | ---------------------------------------- | --------- |
| `--config` | `str` | **Required**. Path to evaluation config. | `None` |
| `--model_path` | `str` | Path to the trained model file. | `None` |
| `--exp_name` | `str` | MLflow experiment name. | timestamp |
| `--run_name` | `str` | MLflow run name. | `run` |
| `--log_dir` | `str` | MLflow logging directory. | `mlruns` |
| `--data_path` | `str` | Dataset directory. | `data` |
| Argument | Type | Description | Default |
| --------------------- | ----- | ------------------------------------------------------------------------------------------------------------- | --------- |
| `--config` | `str` | **Required**. Path to evaluation config. | `None` |
| `--model_path` | `str` | Path to the trained model state dict. | `None` |
| `--normalizer_stats` | `str` | Path to `normalizer_stats.pt` from a training run. Restores `fit_on_train` normalizers from saved statistics instead of re-fitting on the current data split. | `None` |
| `--exp_name` | `str` | MLflow experiment name. | timestamp |
| `--run_name` | `str` | MLflow run name. | `run` |
| `--log_dir` | `str` | MLflow logging directory. | `mlruns` |
| `--data_path` | `str` | Dataset directory. | `data` |
| `--compute_dc_ac_metrics` | `flag` | Compute ground-truth AC/DC power balance metrics on the test split. | `False` |
| `--save_output` | `flag` | Save predictions as `<grid_name>_predictions.parquet` under MLflow artifacts (`.../artifacts/test`). | `False` |

### Example with saved normalizer stats

When evaluating a model on a dataset, you can pass the normalizer statistics from the original training run to ensure the same normalization parameters are used:

```bash
gridfm_graphkit evaluate \
--config examples/config/HGNS_PF_datakit_case118.yaml \
--model_path mlruns/<experiment_id>/<run_id>/artifacts/model/best_model_state_dict.pt \
--normalizer_stats mlruns/<experiment_id>/<run_id>/artifacts/stats/normalizer_stats.pt \
--data_path data
```

> **Note:** The `--normalizer_stats` flag only affects normalizers with `fit_strategy = "fit_on_train"` (e.g. `HeteroDataMVANormalizer`). Per-sample normalizers (`HeteroDataPerSampleMVANormalizer`) always recompute their statistics from the current dataset regardless of this flag.

---

## Running Predictions

```bash
gridfm_graphkit predict --config path/to/config.yaml --model_path path/to/model.pth
gridfm_graphkit predict --config path/to/config.yaml --model_path path/to/model.pt
```

### Arguments

| Argument | Type | Description | Default |
| --------------- | ----- | --------------------------------------------- | --------- |
| `--config` | `str` | **Required**. Path to prediction config file. | `None` |
| `--model_path` | `str` | Path to the trained model file. | `None` |
| `--exp_name` | `str` | MLflow experiment name. | timestamp |
| `--run_name` | `str` | MLflow run name. | `run` |
| `--log_dir` | `str` | MLflow logging directory. | `mlruns` |
| `--data_path` | `str` | Dataset directory. | `data` |
| `--output_path` | `str` | Directory where predictions are saved. | `data` |
| Argument | Type | Description | Default |
| --------------------- | ----- | ------------------------------------------------------------------------------------------------------------- | --------- |
| `--config` | `str` | **Required**. Path to prediction config file. | `None` |
| `--model_path` | `str` | Path to the trained model state dict. | `None` |
| `--normalizer_stats` | `str` | Path to `normalizer_stats.pt` from a training run. Restores `fit_on_train` normalizers from saved statistics. | `None` |
| `--exp_name` | `str` | MLflow experiment name. | timestamp |
| `--run_name` | `str` | MLflow run name. | `run` |
| `--log_dir` | `str` | MLflow logging directory. | `mlruns` |
| `--data_path` | `str` | Dataset directory. | `data` |
| `--output_path` | `str` | Directory where predictions are saved as `<grid_name>_predictions.parquet`. | `data` |

Use built-in help for full command details:

```bash
gridfm_graphkit --help
gridfm_graphkit <command> --help
```

---
1 change: 0 additions & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

Loading
Loading