Instruction file imported from santanikolaus/pino-lightning (
.github/instructions/*.instructions.md). Copyright stays with the author.
PyTorch Lightning + Hydra project for neural operators (FNO) solving PDEs.
Conventions
- Flag deviations from these conventions when generating code
- Two blank lines after import block, one blank line between import groups (stdlib → third-party → local)
- 4 spaces indentation, no tabs
- Type hints on all function signatures including return types
- No
elseafter areturn— flatten control flow - Max 20 lines per function body, excluding docstring; split otherwise
- f-strings only — no
.format()or%s snake_casefunctions/variables,PascalCaseclasses,UPPER_CASEmodule-level constants; no abbreviations except domain-standard ones (lr,cfg,n_train)- Comments explain why, never what — if the code needs a "what" comment, rewrite it
- No commented-out code in commits
Technicals
- Normalizers and DataProcessor are stateful only during
.fit()/.partial_fit(); runtime transforms must only read buffers, never write them - New functionality requires a corresponding test; check coverage for
src/datasets/andsrc/models/
Tensor Conventions
TensorDataset.__getitem__returns{"x": ..., "y": ...}; Lightning steps must keep dict form, never unpack positionally- Every sample follows
(B, C, H, W): PT datasets unsqueeze a channel dim and keep spatial dims after it; synthetic dataset tests assert those shapes explicitly DarcyLitModulepreprocesses every batch throughDataProcessorbefore the model and postprocesses predictions before loss/logging — never bypass this path
Hydra Setup
- All configs are Hydra dataclasses registered via
ConfigStore; no hardcoded values in__init__signatures AppConfignests{data, model, opt, patching, trainer, loss}; physical parameters (resolution, domain size) belong inDataConfigonly