This file provides guidance to AI coding agents (e.g., GitHub Copilot, Cursor, OpenAI Codex) working within the Skala repository. Follow these conventions to produce consistent, high-quality contributions.
Skala is a neural network-based exchange-correlation (XC) functional for density functional theory (DFT). The codebase includes:
| Path | Description |
|---|---|
skala/ |
Published ASE, PySCF, and GPU4PySCF runtime plus tests |
model/ |
Trainable model definition, tests, and LibTorch/FTorch examples |
gauxc/ |
GauXC exporter, native examples, tests, and documentation |
benchmark/ |
Benchmark runner, reference data, report tooling, and tests |
website/ |
Main Sphinx site |
.github/workflows/ |
CI workflows (test, docs) |
- Python version: 3.11–3.13 (target 3.11 for compatibility tooling).
- Environment setup (Pixi 0.82.1):
pixi install --locked -e dev
3. **Pre-commit hooks** (required before committing):
```bash
pixi run -e dev pre-commit install
pixi run -e dev pre-commit run --all-files
- Formatter/linter: Ruff (
ruff format,ruff check --fix --select I). - Type checking: Pyrefly in strict mode. Ignore missing type information only for explicitly
named untyped dependencies in
pyrefly.toml; do not use global missing-import suppression. - Line length: 100 characters (Black-compatible).
- Imports sorted via Ruff's isort rules.
- Generated build, coverage, and documentation output is excluded from static analysis.
When editing code:
- Run
pre-commit run ruff-format --files <file>andpre-commit run ruff --files <file>before committing. - Add type hints to new public functions and classes.
- Use Google-style docstrings with
Args:,Returns:,Raises:sections.
- Framework: pytest with pytest-cov.
- Run tests:
OMP_NUM_THREADS=4 pixi run -e dev pytest -v --doctest-modules \ --cov=skala --cov-report=xml --cov-report=term-missing --cov-report=html \ --durations=50 --durations-min=1.0 skala/src/skala/ skala/tests/
- Keep tests beside their owning component with a
test_prefix. - Use fixtures for expensive setup (molecule construction, model loading).
- Prefer fast unit tests; integration tests that run DFT should be marked or placed separately.
- Engine: Sphinx with myst-nb (executes notebooks during build).
- Build locally (main site plus GauXC guide into
website/_build/html):pixi run docs
- Check external links with
pixi run docs-linkcheck. - Notebooks in
website/should be executable with a 5-minute timeout. - Use reStructuredText for standalone pages; Jupyter notebooks for tutorials.
- Create a feature branch from
main. - Ensure pre-commit hooks pass.
- Add or update tests for new functionality.
- Update documentation if public API changes.
- Keep commits atomic; write clear commit messages.
- CI must pass (tests, linting, docs build).
- Runtime functional API (
skala/src/skala/functional/): Loads traced checkpoints and defines traditional functionals and the runtime interface. - Model definition (
model/src/skala_model/): Defines trainable layers and the enhancement-factor network; it is not part of release artifacts. - PySCF integration (
skala/src/skala/pyscf/): Customnumintmodule andSkalaKSclass hook the model into PySCF's DFT machinery. - ASE calculator (
skala/src/skala/ase/): Provides an ASE-compatible calculator for energy/force evaluations and geometry optimizations. - GauXC integration (
gauxc/): Exporter and C/C++/Fortran examples for external GauXC builds.
| Task | Command |
|---|---|
| Format code | pixi run -e dev pre-commit run ruff-format --all-files |
| Lint code | pixi run -e dev pre-commit run --all-files |
| Run runtime tests | OMP_NUM_THREADS=4 pixi run -e dev pytest -v --doctest-modules --cov=skala --cov-report=xml --cov-report=term-missing --cov-report=html --durations=50 --durations-min=1.0 skala/src/skala/ skala/tests/ |
| Run component tests | OMP_NUM_THREADS=4 pixi run -e dev pytest -v model/tests/test_model.py model/tests/test_utils.py gauxc/tests/ benchmark/tests/ |
| Build docs | pixi run docs |
| Type check | pixi run -e dev pyrefly check |
- Issues: https://github.com/microsoft/skala/issues
- Security: See
SECURITY.md - Code of Conduct: Microsoft Open Source CoC (see
CONTRIBUTING.md)