Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
venv
*venv
venv_pp
/data/
__pycache__/
Expand All @@ -10,3 +10,8 @@ gridfm_graphkit.egg-info
mlruns
*.pt
.DS_Store
integrationtests/data_out*
.julia
*logs*
*data_out*
site*
4 changes: 2 additions & 2 deletions docs/datasets/data_modules.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# LitGridDataModule
# LitGridHeteroDataModule

::: gridfm_graphkit.datasets.powergrid_datamodule.LitGridDataModule
::: gridfm_graphkit.datasets.hetero_powergrid_datamodule.LitGridHeteroDataModule
47 changes: 19 additions & 28 deletions docs/datasets/data_normalization.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@


Normalization improves neural network training by ensuring features are well-scaled, preventing issues like exploding gradients and slow convergence. In power grids, where variables like voltage and power span wide ranges, normalization is essential.
The `gridfm-graphkit` package offers four methods:
The `gridfm-graphkit` package offers normalization methods based on the per-unit (p.u.) system:

- [`Min-Max Normalization`](#minmaxnormalizer)
- [`Standardization (Z-score)`](#standardizer)
- [`Identity (no normalization)`](#identitynormalizer)
- [`BaseMVA Normalization`](#basemvanormalizer)
- [`BaseMVA Normalization`](#heterodatamvanormalizer)
- [`Per-Sample BaseMVA Normalization`](#heterodatapersamplemvanormalizer)

Each of these strategies implements a unified interface and can be used interchangeably depending on the learning task and data characteristics.

Expand All @@ -25,27 +23,15 @@ Each of these strategies implements a unified interface and can be used intercha

---

### `MinMaxNormalizer`
### `HeteroDataMVANormalizer`

::: gridfm_graphkit.datasets.normalizers.MinMaxNormalizer
::: gridfm_graphkit.datasets.normalizers.HeteroDataMVANormalizer

---

### `Standardizer`
### `HeteroDataPerSampleMVANormalizer`

::: gridfm_graphkit.datasets.normalizers.Standardizer

---

### `BaseMVANormalizer`

::: gridfm_graphkit.datasets.normalizers.BaseMVANormalizer

---

### `IdentityNormalizer`

::: gridfm_graphkit.datasets.normalizers.IdentityNormalizer
::: gridfm_graphkit.datasets.normalizers.HeteroDataPerSampleMVANormalizer

---

Expand All @@ -54,13 +40,18 @@ Each of these strategies implements a unified interface and can be used intercha
Example:

```python
from gridfm_graphkit.datasets.normalizers import MinMaxNormalizer
import torch
from gridfm_graphkit.datasets.normalizers import HeteroDataMVANormalizer
from torch_geometric.data import HeteroData

# Create normalizer
normalizer = HeteroDataMVANormalizer(args)

# Fit on training data
params = normalizer.fit(data_path, scenario_ids)

data = torch.randn(100, 5) # Example tensor
# Transform data
normalizer.transform(hetero_data)

normalizer = MinMaxNormalizer(node_data=True,args=None)
params = normalizer.fit(data)
normalized = normalizer.transform(data)
restored = normalizer.inverse_transform(normalized)
# Inverse transform to restore original scale
normalizer.inverse_transform(hetero_data)
```
4 changes: 2 additions & 2 deletions docs/datasets/powergrid.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## `GridDatasetDisk`
## `HeteroGridDatasetDisk`

::: gridfm_graphkit.datasets.powergrid_dataset.GridDatasetDisk
::: gridfm_graphkit.datasets.powergrid_hetero_dataset.HeteroGridDatasetDisk
24 changes: 8 additions & 16 deletions docs/datasets/transforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,18 @@

> Each transformation class inherits from [`BaseTransform`](https://pytorch-geometric.readthedocs.io/en/latest/modules/transforms.html#torch_geometric.transforms.BaseTransform) provided by [PyTorch Geometric](https://pytorch-geometric.readthedocs.io/).

### `AddNormalizedRandomWalkPE`
### `RemoveInactiveGenerators`

::: gridfm_graphkit.datasets.transforms.AddNormalizedRandomWalkPE
::: gridfm_graphkit.datasets.transforms.RemoveInactiveGenerators

### `AddEdgeWeights`
### `RemoveInactiveBranches`

::: gridfm_graphkit.datasets.transforms.AddEdgeWeights
::: gridfm_graphkit.datasets.transforms.RemoveInactiveBranches

### `AddIdentityMask`
### `ApplyMasking`

::: gridfm_graphkit.datasets.transforms.AddIdentityMask
::: gridfm_graphkit.datasets.transforms.ApplyMasking

### `AddRandomMask`
### `LoadGridParamsFromPath`

::: gridfm_graphkit.datasets.transforms.AddRandomMask

### `AddPFMask`

::: gridfm_graphkit.datasets.transforms.AddPFMask

### `AddOPFMask`

::: gridfm_graphkit.datasets.transforms.AddOPFMask
::: gridfm_graphkit.datasets.transforms.LoadGridParamsFromPath
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ This library is brought to you by the GridFM team to train, finetune and interac



## Citation: TBD
## Citation: TBD
26 changes: 25 additions & 1 deletion docs/install/installation.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
# Installation

You can install `gridfm-graphkit` directly from PyPI:

```bash
pip install gridfm-graphkit
```

For GPU support and compatibility with PyTorch Geometric's scatter operations, install PyTorch (and optionally CUDA) first, then install the matching `torch-scatter` wheel. See [PyTorch and torch-scatter](#pytorch-and-torch-scatter-optional) below.

---

## Development Setup

To contribute or develop locally, clone the repository and install in editable mode:
To contribute or develop locally, clone the repository and install in editable mode. Use Python 3.10, 3.11, or 3.12 (3.12 is recommended).

```bash
git clone git@github.com:gridfm/gridfm-graphkit.git
Expand All @@ -18,6 +22,26 @@ source venv/bin/activate
pip install -e .
```

### PyTorch and torch-scatter (optional)

If you need GPU acceleration or PyTorch Geometric scatter ops (used by the library), install PyTorch and the matching `torch-scatter` wheel:

1. Install PyTorch (see [pytorch.org](https://pytorch.org/) for your platform and CUDA version).

2. Get your Torch + CUDA version string:
```bash
TORCH_CUDA_VERSION=$(python -c "import torch; print(torch.__version__ + ('+cpu' if torch.version.cuda is None else ''))")
```

3. Install the correct `torch-scatter` wheel:
```bash
pip install torch-scatter -f https://data.pyg.org/whl/torch-${TORCH_CUDA_VERSION}.html
```

---

## Optional extras

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

```bash
Expand Down
35 changes: 31 additions & 4 deletions docs/models/models.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,37 @@
# Models

### `GPSTransformer`
### `GNS_heterogeneous`

::: gridfm_graphkit.models.gps_transformer.GPSTransformer
::: gridfm_graphkit.models.gnn_heterogeneous_gns.GNS_heterogeneous

---

### `GNN_TransformerConv`
## Physics Decoders

::: gridfm_graphkit.models.gnn_transformer.GNN_TransformerConv
### `PhysicsDecoderOPF`

::: gridfm_graphkit.models.utils.PhysicsDecoderOPF

### `PhysicsDecoderPF`

::: gridfm_graphkit.models.utils.PhysicsDecoderPF

### `PhysicsDecoderSE`

::: gridfm_graphkit.models.utils.PhysicsDecoderSE

---

## Utility Modules

### `ComputeBranchFlow`

::: gridfm_graphkit.models.utils.ComputeBranchFlow

### `ComputeNodeInjection`

::: gridfm_graphkit.models.utils.ComputeNodeInjection

### `ComputeNodeResiduals`

::: gridfm_graphkit.models.utils.ComputeNodeResiduals
Loading
Loading