gridfm / gridfm/gridfm-graphkit

[Bug] PF task: masked limit columns are not restored

Open
#104 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
105
Forks
36
Avg merge
1d 8h
Merged PRs (30d)
9

Description

Description
AddPFHeteroMask intentionally masks static limit columns in the PF task so they are not visible to the model. However, these values are not restored after inverse_transform / inverse_output, meaning post-inference constraint calculations and exported predictions operate on zeroed limits rather than the original values.

Affected columns
Bus: MIN_VM, MAX_VM, MIN_QG, MAX_QG, VN_KV (indices 8, 9, 10, 11, 14)
Branch: ANG_MIN, ANG_MAX, RATE_A (indices 7, 8, 9)

Impact
The limit columns (Vm_min, Vm_max, Qg_min, Qg_max, ANG_MIN, ANG_MAX, RATE_A) saved in the predict_step and test_step output are all zero instead of their true physical values.

Root cause
ApplyMasking replaces the limit columns with 0.0 after normalisation. During inverse transformation these zeros are preserved, and the original limit values are never restored before constraint evaluation.

Proposed fix
Store the original limit values separately (e.g. in a .static attribute) before masking.
Add a transform to restore these values after inverse_output.
Invoke the restore step in test_step and predict_step before constraint calculations.

IMPORTANT: The restored values are only used for post-inference evaluation and export, not as model inputs, so this should not introduce data leakage.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing AddPFHeteroMask and ApplyMasking through inverse_transform and inverse_output, focusing on the listed Bus and Branch limit columns. Then inspect test_step and predict_step to see where constraint calculations and exported outputs are produced. Done means the original limits are restored only after inference, while model inputs remain masked, and the affected outputs retain their physical values.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.