Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
89c20c5
add dev environment
JensWehner Sep 29, 2026
7ef7442
Add strict Pyrefly type checking
JensWehner Oct 4, 2026
59f8e74
Add types to test callbacks
JensWehner Oct 4, 2026
79b5fbf
Guard optional PySCF state
JensWehner Oct 4, 2026
e442c5f
Type benchmark run configuration JSON
JensWehner Oct 4, 2026
ecc3eb5
Reconcile model Irreps types
JensWehner Oct 4, 2026
341e101
Narrow symmetric contraction Irreps
JensWehner Oct 4, 2026
c75b9f0
Correct dynamic return types
JensWehner Oct 4, 2026
73be0e3
Make SkalaNumInt a PySCF NumInt
JensWehner Oct 4, 2026
7421fbe
Fix custom autograd context types
JensWehner Oct 4, 2026
7efd289
Explain custom autograd override suppression
JensWehner Oct 4, 2026
3bc8a0e
Type ASE calculator factory calls
JensWehner Oct 4, 2026
5de49d1
Type Skala ASE parameters
JensWehner Oct 4, 2026
45c547c
Validate Skala ASE parameters
JensWehner Oct 4, 2026
608b08c
Guard UKS gradient grids
JensWehner Oct 4, 2026
29bae29
Align PySCF grids setattr signature
JensWehner Oct 4, 2026
9b0649b
Fix XC integrator tensor cleanup
JensWehner Oct 4, 2026
949f13b
Type benchmark prose notes
JensWehner Oct 4, 2026
42583da
Type AO screening test coordinates
JensWehner Oct 4, 2026
8bd4032
Resolve benchmark fit coefficients
JensWehner Oct 4, 2026
86ff9ab
Simplify benchmark fitting iterations
JensWehner Oct 4, 2026
b075b49
Type benchmark timing marks
JensWehner Oct 4, 2026
d9ac559
Validate benchmark iteration counts
JensWehner Oct 4, 2026
2a6a1f0
Guard private Torch profiling API
JensWehner Oct 4, 2026
91dc763
Document private Torch API boundary
JensWehner Oct 4, 2026
b225235
Document platform DFTD3 import
JensWehner Oct 4, 2026
40e38de
Harden Pyrefly ignore handling
JensWehner Oct 4, 2026
8fe8e27
Clear Pyrefly warning baseline
JensWehner Oct 4, 2026
c7e1479
Keep PySCF auxiliary count conversion
JensWehner Oct 4, 2026
8b978c7
Remove mypy type checking
JensWehner Oct 4, 2026
8ce326e
remove duplication
JensWehner Oct 4, 2026
c683841
Constrain e3nn compatibility
JensWehner Oct 4, 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
2 changes: 1 addition & 1 deletion .github/actions/setup-pixi/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ runs:
- name: Setup Pixi
uses: prefix-dev/setup-pixi@f00437f565399d418b0acc85936d12c1fb668347 # v0.10.1
with:
pixi-version: v0.78.0
pixi-version: v0.81.0
working-directory: ${{ inputs.working-directory }}
pixi-bin-path: ${{ inputs.pixi-bin-path }}
environments: ${{ inputs.environment }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Setup Pixi
uses: ./.github/actions/setup-pixi
with:
environment: lint
environment: default

- name: Run pre-commit hooks
run: pre-commit run --all-files
17 changes: 5 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,12 @@ repos:

- repo: local
hooks:
- id: mypy
name: mypy
entry: mypy
- id: pyrefly
name: pyrefly
entry: pyrefly check
language: system
args:
- --config-file
- pyproject.toml
- --num-workers
- "4"
- skala
- model
- gauxc
- benchmark
- website
- --config
- pyrefly.toml
pass_filenames: false
always_run: true
24 changes: 12 additions & 12 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ Skala is a neural network-based exchange-correlation (XC) functional for density
## Development environment

1. **Python version**: 3.11–3.13 (target 3.11 for compatibility tooling).
2. **Environment setup** (Pixi 0.75):
2. **Environment setup** (Pixi 0.81):
```bash
pixi install --locked -e default
pixi install --locked -e dev
```
3. **Pre-commit hooks** (required before committing):
```bash
pixi run -e default pre-commit install
pixi run -e default pre-commit run --all-files
pixi run -e dev pre-commit install
pixi run -e dev pre-commit run --all-files
```

## Code style & linting

- **Formatter/linter**: Ruff (`ruff format`, `ruff check --fix --select I`).
- **Type checking**: mypy in strict mode. Ignore missing type information only for explicitly
named untyped dependencies in `pyproject.toml`; do not use global `--ignore-missing-imports`.
- **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.
Expand All @@ -51,7 +51,7 @@ When editing code:
- Framework: pytest with pytest-cov.
- Run tests:
```bash
OMP_NUM_THREADS=4 pixi run -e default pytest -v --doctest-modules \
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/
```
Expand Down Expand Up @@ -96,12 +96,12 @@ When editing code:

| Task | Command |
|------|---------|
| Format code | `pixi run -e default pre-commit run ruff-format --all-files` |
| Lint code | `pixi run -e default pre-commit run --all-files` |
| Run runtime tests | `OMP_NUM_THREADS=4 pixi run -e default 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 default pytest -v model/tests/test_model.py model/tests/test_utils.py gauxc/tests/ benchmark/tests/` |
| 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 -e docs sphinx-build -b html website website/_build/html && pixi run -e docs sphinx-build -b html gauxc/docs website/_build/html/gauxc && touch website/_build/html/.nojekyll` |
| Type check | `pixi run -e default mypy skala/src model/src gauxc/src benchmark/src` |
| Type check | `pixi run -e dev pyrefly check` |

## Contact

Expand Down
21 changes: 13 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,34 @@ or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any addi

## Development setup

Install Pixi 0.78, then create the default locked development environment from the repository root:
Install Pixi 0.81, then create the locked CPU development environment from the repository root:

```bash
pixi install --locked -e default
pixi run -e default pre-commit install
pixi install --locked -e dev
pixi run -e dev pre-commit install
```

Run the standard checks in their Pixi environments:

```bash
OMP_NUM_THREADS=4 pixi run -e default pytest -v --doctest-modules \
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/
OMP_NUM_THREADS=4 pixi run -e default pytest -v model/tests/test_model.py \
OMP_NUM_THREADS=4 pixi run -e dev pytest -v model/tests/test_model.py \
model/tests/test_utils.py gauxc/tests/ benchmark/tests/
pixi run -e default pre-commit run --all-files
pixi run -e docs sphinx-build -b html website website/_build/html
pixi run -e docs sphinx-build -b html gauxc/docs website/_build/html/gauxc
pixi run -e dev pre-commit run --all-files
pixi run -e dev sphinx-build -b html website website/_build/html
pixi run -e dev sphinx-build -b html gauxc/docs website/_build/html/gauxc
touch website/_build/html/.nojekyll
```

Set `OMP_NUM_THREADS=4` when running tests locally to match CI.

The `dev` environment includes all CPU development, documentation, profiling, packaging,
and native integration dependencies. Use `dev-gpu` for the equivalent CUDA 12 toolchain.
Both environments provide unconstrained `pip` and `py-spy` installations so those tools
do not impose version requirements on the rest of the environment.

Named compatibility environments cover Python 3.11 through 3.13, PySCF 2.14,
PyTorch 2.12 and 2.13, GPU4PySCF 1.8.1, and CUDA 12 and 13. Keep `pixi.lock`
synchronized with changes to `pixi.toml` or any component `pyproject.toml`.
Expand Down
61 changes: 33 additions & 28 deletions benchmark/src/skala_benchmark/fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ def _candidate_knots(
return []

candidates: set[float] = set()
for index in range(1, unique_x.size - 1):
candidates.add(float(unique_x[index]))
for candidate in unique_x[1:-1]:
candidates.add(float(candidate))

for left, right in pairwise(unique_x[1:-1]):
candidates.add(float((left + right) / 2.0))
Expand Down Expand Up @@ -211,10 +211,10 @@ def _fit_continuous(x: FloatArray, y: FloatArray, knots: list[float]) -> _Model:
slopes, intercepts = _continuous_convex_lines(x, y, knots)
boundaries = [float(np.min(x)), *knots, float(np.max(x))]
segments = [
_LogSegment(
boundaries[index], boundaries[index + 1], slopes[index], intercepts[index]
_LogSegment(left, right, slope, intercept)
for (left, right), slope, intercept in zip(
pairwise(boundaries), slopes, intercepts, strict=True
)
for index in range(len(slopes))
]
return _Model(segments=segments, knots=knots, continuous=True)

Expand Down Expand Up @@ -261,7 +261,7 @@ def _continuous_convex_lines(


def _forbid_downward_jumps(
coefficients: list[tuple[float, float] | None],
coefficients: list[tuple[float, float]],
boundaries: list[float],
) -> None:
"""Raise segment intercepts so the fit never steps down at a breakpoint.
Expand All @@ -270,19 +270,20 @@ def _forbid_downward_jumps(
would start below its predecessor's end value makes the whole piecewise
curve non-decreasing from left to right. Slopes are left untouched.
"""
for index in range(len(coefficients) - 1):
left = coefficients[index]
right = coefficients[index + 1]
assert left is not None and right is not None
boundary = boundaries[index + 1]
for right_index, ((left, right), boundary) in enumerate(
zip(pairwise(coefficients), boundaries[1:-1], strict=True), start=1
):
end_left = left[0] * boundary + left[1]
start_right = right[0] * boundary + right[1]
if start_right < end_left:
coefficients[index + 1] = (right[0], right[1] + (end_left - start_right))
coefficients[right_index] = (
right[0],
right[1] + (end_left - start_right),
)


def _enforce_increasing_slopes(
coefficients: list[tuple[float, float] | None],
coefficients: list[tuple[float, float]],
x: FloatArray,
y: FloatArray,
indices: NDArray[np.int64],
Expand All @@ -297,9 +298,7 @@ def _enforce_increasing_slopes(
non-decreasing.
"""
running_slope = 0.0
for index in range(len(coefficients)):
coefficient = coefficients[index]
assert coefficient is not None
for index, coefficient in enumerate(coefficients):
slope = coefficient[0]
if slope < running_slope:
slope = running_slope
Expand All @@ -326,7 +325,9 @@ def _fit_discontinuous(x: FloatArray, y: FloatArray, knots: list[float]) -> _Mod
coefficients.append(None)

valid_indices = [
index for index, coefficient in enumerate(coefficients) if coefficient
index
for index, coefficient in enumerate(coefficients)
if coefficient is not None
]
for index, coefficient in enumerate(coefficients):
if coefficient is not None:
Expand All @@ -338,22 +339,26 @@ def _fit_discontinuous(x: FloatArray, y: FloatArray, knots: list[float]) -> _Mod
neighbor = min(
valid_indices, key=lambda valid_index: abs(valid_index - index)
)
slope = max(coefficients[neighbor][0], 0.0) # type: ignore[index]
neighbor_coefficient = coefficients[neighbor]
assert neighbor_coefficient is not None
slope = max(neighbor_coefficient[0], 0.0)
else:
slope = 0.0
coefficients[index] = (slope, mean_y - slope * mean_x)

resolved_coefficients: list[tuple[float, float]] = []
for coefficient in coefficients:
assert coefficient is not None
resolved_coefficients.append(coefficient)

boundaries = [float(np.min(x)), *knots, float(np.max(x))]
_enforce_increasing_slopes(coefficients, x, y, indices)
_forbid_downward_jumps(coefficients, boundaries)
_enforce_increasing_slopes(resolved_coefficients, x, y, indices)
_forbid_downward_jumps(resolved_coefficients, boundaries)
segments = [
_LogSegment(
boundaries[index],
boundaries[index + 1],
coefficients[index][0], # type: ignore[index]
coefficients[index][1], # type: ignore[index]
_LogSegment(left, right, slope, intercept)
for (left, right), (slope, intercept) in zip(
pairwise(boundaries), resolved_coefficients, strict=True
)
for index in range(len(coefficients))
]
return _Model(segments=segments, knots=knots, continuous=False)

Expand Down Expand Up @@ -677,8 +682,8 @@ def smooth_stacked_fractions(

dense_log = np.linspace(log_x[0], log_x[-1], grid_points)
smoothed = np.empty((dense_log.size, num_bands - 1), dtype=np.float64)
for band in range(num_bands - 1):
spline = make_smoothing_spline(log_x, cumulative_data[:, band])
for band, cumulative_band in enumerate(cumulative_data.T):
spline = make_smoothing_spline(log_x, cumulative_band)
smoothed[:, band] = spline(dense_log)
smoothed = np.clip(smoothed, 0.0, 1.0)
smoothed = np.maximum.accumulate(smoothed, axis=1)
Expand Down
5 changes: 4 additions & 1 deletion benchmark/src/skala_benchmark/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,11 @@ def metric_value(row: Row, metric: str) -> float | None:
return None

if metric == "iterations":
raw_count = row.get("num_scf_iterations")
if raw_count is None:
return None
try:
count = int(row.get("num_scf_iterations")) # type: ignore[arg-type]
count = int(raw_count)
except (TypeError, ValueError):
return None
return float(count) if count > 0 else None
Expand Down
3 changes: 2 additions & 1 deletion benchmark/src/skala_benchmark/report/prose.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def load_prose(path: str | Path | None) -> dict[str, Any]:
result["comparison"].get("environments")
)
notes = result["comparison"].get("notes")
result["comparison"]["notes"] = list(notes) if isinstance(notes, list) else []
normalized_notes: list[Any] = list(notes) if isinstance(notes, list) else []
result["comparison"]["notes"] = normalized_notes
result["plots"] = as_mapping(result.get("plots"))
return result

Expand Down
Loading
Loading