Skip to content

Commit 36d3592

Browse files
committed
README and docs alignment + fresh installation check
1 parent c8bc921 commit 36d3592

8 files changed

Lines changed: 45 additions & 51 deletions

File tree

‎.readthedocs.yml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ build:
1313
jobs:
1414
pre_install:
1515
- pip install --upgrade pip setuptools wheel
16-
- pip install torch --index-url https://download.pytorch.org/whl/cpu
17-
- pip install torch-scatter torch-sparse torch-cluster -f https://data.pyg.org/whl/torch-2.5.0+cpu.html
16+
- pip install "torch==2.5.1" --index-url https://download.pytorch.org/whl/cpu
17+
- pip install torch-scatter torch-sparse torch-cluster -f https://data.pyg.org/whl/torch-2.5.1+cpu.html
1818

1919
# Build documentation in the docs/ directory with Sphinx
2020
sphinx:
@@ -27,3 +27,4 @@ python:
2727
path: .
2828
extra_requirements:
2929
- docs
30+
- lightning

‎README.md‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,9 @@ Deep learning for theoretical X-ray spectroscopy.
1010

1111
</div>
1212

13-
<div align="center">
14-
<strong>This README is a work in progress.</strong>
15-
</div>
16-
1713
## Overview
1814

19-
We present XANESNET, a PyTorch-based, open-source software framework for machine learning in spectroscopy. The framework integrates training, inference, and automated analysis within a plugin-based architecture. Its modular design allows users to compare, combine, and extend different methods without modifying the core codebase, providing a flexible and reusable framework rather than a single-purpose implementation. XANESNET supports forward prediction from structure to spectrum and inverse inference from spectra to structures or properties. A unified data pipeline uniformly handles molecular and periodic systems, while the framework remains agnostic to the spectroscopic technique. We demonstrate its use for learning structure-spectrum relationships in X-ray absorption spectroscopy. By prioritizing extensibility and reproducibility, XANESNET aims to accelerate and make more accessible machine-learning research in spectroscopy.
15+
We present XANESNET, an open-source, PyTorch-based software package for machine learning in spectroscopy. Specifically, the framework integrates training, inference, and automated analysis for structure--spectrum learning within a plugin-based architecture. Its modular design enables users to compare, combine, and extend workflow and analysis components without modifying the core codebase, providing a flexible and reusable alternative to single-purpose implementations. XANESNET supports both forward prediction from atomic structures to spectra and inverse inference from spectra to structures, properties, or descriptors. Through PyTorch Lightning, we enable multi-device training using Distributed Data Parallel (DDP) across multiple GPUs. A shared data pipeline uniformly handles both molecular and periodic systems. Although the framework is agnostic to spectroscopic techniques, current modules primarily implement atom-centred spectra. We demonstrate its use for learning structure--spectrum relationships in X-ray absorption spectroscopy. To our knowledge, \textsc{XANESNET} is the first general-purpose machine-learning framework for spectroscopy with a central focus on extensibility and reproducibility. This facilitates systematic comparisons and evaluations of machine-learning approaches, lowering the barrier for researchers to develop and benchmark novel methods.
2016

2117
## Highlights
2218

@@ -37,15 +33,17 @@ We present XANESNET, a PyTorch-based, open-source software framework for machine
3733

3834
Install from a local checkout with the project metadata in [pyproject.toml](pyproject.toml):
3935

40-
From the XANESNET directory:
36+
From the XANESNET directory, create an environment and install a matching CPU PyTorch/PyG wheel set before XANESNET. This Python 3.12 sequence was tested with PyTorch 2.5.1:
4137
```bash
4238
python3.12 -m venv .venv
4339
source .venv/bin/activate
4440
python -m pip install --upgrade pip setuptools wheel
41+
python -m pip install "torch==2.5.1" --index-url https://download.pytorch.org/whl/cpu
42+
python -m pip install torch-scatter torch-sparse torch-cluster -f https://data.pyg.org/whl/torch-2.5.1+cpu.html
4543
python -m pip install -e .
4644
```
4745

48-
For a non-editable install, use:
46+
For a non-editable install, use `python -m pip install .` instead of `-e .`, after installing the matching PyTorch/PyG wheels.
4947

5048
```bash
5149
python -m pip install .
@@ -59,19 +57,21 @@ xanesnet --help
5957

6058
### PyTorch and PyTorch Geometric
6159

62-
XANESNET depends on PyTorch and PyTorch Geometric native extensions. CPU-only Linux installs may work with plain pip resolution. For CUDA installs, or if `torch-scatter`, `torch-sparse`, or `torch-cluster` cannot find wheels automatically, install wheels matching your Python, PyTorch, and CUDA versions first.
60+
XANESNET depends on PyTorch and PyTorch Geometric native extensions. The PyTorch version and CPU/CUDA build must match the extension wheels. If no matching wheel is installed first, pip may try to compile an extension from source and fail.
6361

64-
Example for PyTorch 2.5 with CUDA 12.4:
62+
For CUDA 12.4 with PyTorch 2.5.1, install the matching wheels before XANESNET:
6563

6664
```bash
67-
python -m pip install torch --index-url https://download.pytorch.org/whl/cu124
65+
python -m pip install "torch==2.5.1" --index-url https://download.pytorch.org/whl/cu124
6866
python -m pip install torch-scatter torch-sparse torch-cluster -f https://data.pyg.org/whl/torch-2.5.1+cu124.html
6967
python -m pip install -e .
7068
```
7169

72-
Adjust the wheel URLs for your target platform. The PyTorch and PyTorch Geometric installation guides are the source of truth for the current compatibility matrix.
70+
For other Python, PyTorch, or CUDA versions, choose the corresponding wheel URLs from the PyTorch and PyTorch Geometric installation guides. Keep the PyTorch and extension versions aligned.
7371

7472
### Lightning, Developer and Docs Extras
73+
After installing the matching PyTorch/PyG wheels and the base package, install optional tooling as needed:
74+
7575

7676
```bash
7777
python -m pip install -e ".[lightning]" # Lightning training backend
@@ -83,7 +83,7 @@ python -m pip install -e ".[docs,lightning]" # docs tooling and Lightning API im
8383

8484
## Config UI
8585

86-
The config UI in [tools/config-ui/](tools/config-ui/) is an interactive React editor for XANESNET `train`, `infer`, and `analyze` YAML files. It is useful both as a guided config builder and as a browsable reference for valid options in the current forward workflow.
86+
The config UI in [tools/config-ui/](tools/config-ui/) is an interactive React editor for XANESNET `train`, `infer`, and `analyze` YAML files. It is useful both as a guided config builder and as a browsable reference for valid options in the forward and inverse workflows.
8787

8888
It provides:
8989

@@ -118,7 +118,7 @@ More details are in [tools/config-ui/README.md](tools/config-ui/README.md).
118118

119119
## Usage
120120

121-
XANESNET runs are driven by YAML configuration files. The supported workflow today is forward spectrum prediction: prepare structure/spectrum data, train a model, infer spectra with a saved checkpoint, and analyze inference-run outputs. Examples live in [configs/](configs/), including [configs/mlp.yaml](configs/mlp.yaml), [configs/mlp_infer.yaml](configs/mlp_infer.yaml), and [configs/analyze_example.yaml](configs/analyze_example.yaml).
121+
XANESNET runs are driven by YAML configuration files. The main example workflow is forward structure-to-spectrum prediction: prepare structure/spectrum data, train a model, infer spectra with a saved checkpoint, and analyze inference-run outputs. The framework also supports inverse inference with registered descriptor and multi-head model pairings. Examples live in [configs/](configs/), including [configs/mlp.yaml](configs/mlp.yaml), [configs/mlp_infer.yaml](configs/mlp_infer.yaml), and [configs/analyze_example.yaml](configs/analyze_example.yaml).
122122

123123
### Train
124124

@@ -130,7 +130,7 @@ xanesnet train \
130130
-y
131131
```
132132

133-
Training outputs are written under `runs/<timestamp>_train_<name>/`. Typical outputs include the copied raw config, validated and resolved configs, split indices, the signature (`models/signature.yaml`), final checkpoints (`models/final.pth` for inference and `models/final_full.pth` with the full training state), periodic checkpoints in `checkpoints/`, logs, and optional TensorBoard files. When TensorBoard is enabled, model weight and gradient histograms are omitted by default; pass `--log-weights` to include them.
133+
Training outputs are written under `runs/train_<name>_NNN/` (or `runs/train_000/` without a name). Typical outputs include the copied raw config, validated and resolved configs, split indices, the signature (`models/signature.yaml`), final checkpoints (`models/final.pth` for inference and `models/final_full.pth` with the full training state), periodic checkpoints in `checkpoints/`, logs, and optional TensorBoard files. When TensorBoard is enabled, model weight and gradient histograms are omitted by default; pass `--log-weights` to include them.
134134

135135
Use `--dry-run` with `xanesnet train` to construct the normal training pipeline, run one real epoch, and write `model_profile.json` with the model architecture, parameter counts, model size, and peak CUDA memory for that epoch when CUDA is available.
136136

@@ -188,7 +188,7 @@ At a high level, a config contains:
188188

189189
- `seed` and `device`
190190
- `datasource`: input structure and spectrum source
191-
- `dataset`: preprocessing, storage, split, and descriptor or graph settings; set `dataset_type` to `descriptor` (forward) or `descriptor_inverse` (inverse) for descriptor workflows
191+
- `dataset`: preprocessing, storage, split, and descriptor or graph settings;
192192
- `model`: model family and hyperparameters
193193
- exactly one runner section: `trainer`, `inferencer`, or analysis settings depending on workflow
194194
- `strategy`: single-model, deep-ensemble, bootstrap, or k-fold training and inference behavior
@@ -218,7 +218,7 @@ This project is licensed under the GPL-3.0 License. See [LICENSE](LICENSE) for d
218218
## Publications
219219

220220
### Main Reference
221-
*[XANESNET: A Modular, Extensible, and Flexible Machine Learning Framework for Spectroscopy](https://placeholdmon.vercel.app/)* - H. Junkawitsch, B. Li, T. Pope, A. Bande, and T. Penfold, 2026.
221+
*XANESNET: A Modular, Extensible, and Flexible Machine Learning Framework for Spectroscopy* - H. Junkawitsch, B. Li, T. Pope, A. Bande, and T. Penfold, 2026.
222222

223223
### XANESNET
224224
*[A Deep Neural Network for the Rapid Prediction of X-ray Absorption Spectra](https://doi.org/10.1021/acs.jpca.0c03723)* - C. D. Rankine, M. M. M. Madkhali, and T. J. Penfold, *J. Phys. Chem. A*, 2020, **124**, 4263-4270.

‎configs/README.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ A config drives one XANESNET run.
1212

1313
1. **Train** — `xanesnet train -i <file>` builds the datasource, dataset,
1414
encodings, model, trainer, and training strategy described by the config.
15-
Outputs are written under `runs/<timestamp>_train_<name>/`.
15+
Outputs are written under `runs/train_<name>_NNN/`, or `runs/train_000/`
16+
when no run name is provided.
1617
2. **Infer** — `xanesnet infer -i <file> -m <checkpoint>` merges the user
1718
config with the checkpoint signature before validation. Predictions land in
18-
`runs/<timestamp>_infer_<name>/predictions/`.
19+
`runs/infer_<name>_NNN/predictions/`, or `runs/infer_000/predictions/`
20+
when no run name is provided.
1921
3. **Analyze** — `xanesnet analyze -i <file> -r <inference-run>` computes and
2022
reports metrics on saved predictions.

‎docs/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ This directory contains the [Sphinx](https://www.sphinx-doc.org/) sources for th
44

55
## Building
66

7-
Install the documentation extras into the active environment (one-off):
7+
In a fresh environment, first install a matching PyTorch/PyG wheel set as described in the [installation guide](source/user-guide/install.rst). Then install the documentation extras (Lightning is included because its trainer is part of the API reference):
88

99
```bash
10-
pip install -e ".[docs,lightning]"
10+
python -m pip install -e ".[docs,lightning]"
1111
```
1212

1313
Then build the HTML site from this directory:

‎docs/source/user-guide/input.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The schemas define allowed fields, types, and default values.
99

1010
The required top-level sections are:
1111
* training: ``datasource``, ``dataset``, ``model``, ``trainer``, ``strategy``, and ``encodings``
12-
* inference: ``datasource``, ``dataset``, and ``inferencer``
12+
* inference: ``datasource``, ``dataset``, ``strategy``, and ``inferencer``
1313
* analysis: ``selectors``, ``collectors``, ``aggregators``, ``reporters``, and ``plotters``
1414

1515
Many nested fields have defaults, so they do not need to be written when the default is suitable.

‎docs/source/user-guide/install.rst‎

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
..
2-
TODO: Do we keep both GitHub and GitLab links?
3-
TODO: We should align the README.md "Install" section with this page.
4-
TODO: We should test a fresh install!
5-
61
Installing XANESNET
72
===================
83

@@ -34,7 +29,8 @@ Requirements
3429

3530
* Linux (tested on Ubuntu)
3631
* Python 3.12 and above
37-
* A C/C++ build toolchain if pip needs to compile native PyTorch Geometric extensions.
32+
* Matching PyTorch and PyTorch Geometric wheels for the chosen Python, PyTorch, and CPU/CUDA versions.
33+
* A C/C++ build toolchain only if pip must compile native PyTorch Geometric extensions from source.
3834
* Optional: NVIDIA GPU and CUDA-compatible PyTorch wheels for ``device: cuda``.
3935

4036
The Lightning trainer is an optional extra. Install it with ``python -m pip install -e ".[lightning]"`` when using ``trainer_type: lightning``.
@@ -45,27 +41,34 @@ CPU-only training does not require CUDA. MPS devices are currently unsupported a
4541
Installation
4642
------------
4743

48-
Install the package from the XANESNET repository root:
44+
The following Python 3.12 CPU-only sequence was tested from the XANESNET repository root. Install PyTorch and its matching PyTorch Geometric extension wheels before the package so pip does not attempt an incompatible source build:
4945

5046
.. code-block:: bash
5147
5248
python3.12 -m venv .venv
5349
source .venv/bin/activate
5450
python -m pip install --upgrade pip setuptools wheel
51+
python -m pip install "torch==2.5.1" --index-url https://download.pytorch.org/whl/cpu
52+
python -m pip install torch-scatter torch-sparse torch-cluster -f https://data.pyg.org/whl/torch-2.5.1+cpu.html
5553
python -m pip install -e .
5654
57-
For a non-editable install:
55+
For a non-editable install, replace ``-e .`` with ``.`` after installing the matching PyTorch/PyG wheels:
5856

5957
.. code-block:: bash
6058
6159
python -m pip install .
6260
6361
To use the optional Lightning trainer, include its extra:
64-
6562
.. code-block:: bash
6663
6764
python -m pip install -e ".[lightning]"
6865
66+
To build the API documentation, install the documentation and Lightning extras:
67+
68+
.. code-block:: bash
69+
70+
python -m pip install -e ".[docs,lightning]"
71+
6972
Verify the installation:
7073

7174
.. code-block:: bash
@@ -79,19 +82,15 @@ For the work-in-progress browser-based config editor, see :doc:`config-editor`.
7982
PyTorch and PyTorch Geometric
8083
-----------------------------
8184

82-
XANESNET depends on PyTorch and PyTorch Geometric.
83-
On Linux with CPU-only PyTorch, a normal ``pip install`` is often enough.
85+
XANESNET depends on PyTorch and PyTorch Geometric native extensions. The PyTorch version and CPU/CUDA build must match the extension wheels. The CPU-only sequence above uses PyTorch 2.5.1 and its matching ``pt25cpu`` wheels.
8486

85-
For CUDA, or if packages such as ``torch-scatter``, ``torch-sparse``, or ``torch-cluster`` fail to install,
86-
install matching wheels for your Python, PyTorch, and CUDA versions first, then install XANESNET.
87+
For CUDA, install matching wheels first, then install XANESNET. Example for PyTorch 2.5.1 with CUDA 12.4:
8788

88-
Example for PyTorch 2.5 with CUDA 12.4:
8989

9090
.. code-block:: bash
9191
92-
python -m pip install torch --index-url https://download.pytorch.org/whl/cu124
92+
python -m pip install "torch==2.5.1" --index-url https://download.pytorch.org/whl/cu124
9393
python -m pip install torch-scatter torch-sparse torch-cluster -f https://data.pyg.org/whl/torch-2.5.1+cu124.html
9494
python -m pip install -e .
9595
96-
Adjust the wheel URLs for your target platform.
97-
The PyTorch and PyTorch Geometric installation guides are the source of truth for the current compatibility matrix.
96+
For other combinations, choose wheel URLs from the PyTorch and PyTorch Geometric installation guides and keep the PyTorch and extension versions aligned.

‎docs/source/user-guide/intro.rst‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,7 @@ Introduction
44
XANESNET overview
55
-----------------
66

7-
We present XANESNET, a PyTorch-based, open-source software framework for machine learning in spectroscopy.
8-
The framework integrates training, inference, and automated analysis within a plugin-based architecture.
9-
Its modular design enables users to compare, combine, and extend different machine-learning workflow and analysis components
10-
without modifying the core codebase, providing a flexible and reusable framework rather than a single-purpose implementation.
11-
XANESNET supports both forward prediction from structure to spectrum and inverse inference from spectra to structures or properties.
12-
A common data pipeline uniformly handles both molecular and periodic systems. Moreover, the framework remains entirely agnostic to the spectroscopic technique.
13-
We demonstrate its use for learning structure-spectrum relationships in X-ray absorption spectroscopy.
14-
By prioritizing extensibility and reproducibility, XANESNET facilitates systematic comparison and evaluation of machine-learning approaches,
15-
lowering the barrier to research and accelerating the development and reuse of methods in spectroscopy.
7+
We present XANESNET, an open-source, PyTorch-based software package for machine learning in spectroscopy. Specifically, the framework integrates training, inference, and automated analysis for structure--spectrum learning within a plugin-based architecture. Its modular design enables users to compare, combine, and extend workflow and analysis components without modifying the core codebase, providing a flexible and reusable alternative to single-purpose implementations. XANESNET supports both forward prediction from atomic structures to spectra and inverse inference from spectra to structures, properties, or descriptors. Through PyTorch Lightning, we enable multi-device training using Distributed Data Parallel (DDP) across multiple GPUs. A shared data pipeline uniformly handles both molecular and periodic systems. Although the framework is agnostic to spectroscopic techniques, current modules primarily implement atom-centred spectra. We demonstrate its use for learning structure--spectrum relationships in X-ray absorption spectroscopy. To our knowledge, \textsc{XANESNET} is the first general-purpose machine-learning framework for spectroscopy with a central focus on extensibility and reproducibility. This facilitates systematic comparisons and evaluations of machine-learning approaches, lowering the barrier for researchers to develop and benchmark novel methods.
168

179
XANESNET software paper
1810
-----------------------
@@ -31,7 +23,7 @@ XANESNET features
3123
* Modular components that can be added or replaced without changing the core workflow.
3224
* Support for molecular and periodic structures, with feature-vector and graph representations.
3325
* Neural-network models ranging from feed-forward to geometry-aware graph models.
34-
* Forward and inverse workflows for spectra, structures, and properties.
26+
* Forward prediction and inverse inference.
3527
* Single-model and ensemble training for comparison and uncertainty estimates.
3628
* Automated analysis with metrics, comparisons, reports, and figures.
3729
* Browser-based :doc:`configuration tool <config-editor>`.

‎docs/source/user-guide/losses.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Losses
22
======
33

4-
The :class:`~xanesnet.losses.base.Loss` implementations measure the difference between model predictions and target spectra.
4+
The :class:`~xanesnet.losses.base.Loss` implementations compare model predictions with the targets produced by the selected dataset.
55
Encodings are applied before loss calculation; see :doc:`encodings`.
66
They are configured as a non-empty list under ``trainer.loss``.
77
XANESNET builds a combined loss from the selected terms before each training update.

0 commit comments

Comments
 (0)