Differentiable PyTorch peak-fitting for FF-HEDM Zarr archives (drop-in replacement for PeaksFittingOMPZarrRefactor)
Project description
midas-peakfit
Differentiable PyTorch peak-fitting for FF-HEDM Zarr archives. A drop-in
replacement for PeaksFittingOMPZarrRefactor (C/OpenMP/NLopt) with the
following changes:
- Optimizer: Nelder-Mead → batched Levenberg-Marquardt on CPU/CUDA
- Backend: OpenMP → PyTorch (autograd, batched linear algebra)
- Precision: fp64 default;
--dtype float32available for speed - Output: identical binary format (
AllPeaks_PS.bin,AllPeaks_PX.bin) - CLI: drop-in compatible
The C tool is kept as the validation oracle. Output is scientifically equivalent to the C tool, not bit-exact (LM and Nelder-Mead converge to slightly different minima within the same basin).
Installation
pip install -e packages/midas_peakfit[dev]
or once published:
pip install midas-peakfit
PyTorch with CUDA support must be installed separately if GPU acceleration is desired. Follow the PyTorch install guide for the right wheel for your CUDA version.
Usage
peakfit_torch DataFile.MIDAS.zip 0 1 8 # CPU/CUDA auto
peakfit_torch DataFile.MIDAS.zip 0 1 8 --device cuda --dtype float32
peakfit_torch DataFile.MIDAS.zip 0 1 8 OutputFolder 1 # explicit ResultFolder + fitPeaks
peakfit_torch DataFile.MIDAS.zip 0 1 8 \
--validate-against /path/to/c_AllPeaks_PS.bin # parity check
Positional args mirror the C tool exactly: DataFile blockNr nBlocks numProcs [ResultFolder] [fitPeaks].
New flags:
| Flag | Default | Meaning |
|---|---|---|
--device {cpu,cuda} |
cuda if available else cpu |
Compute device |
--dtype {float32,float64} |
float64 |
Numeric precision |
--batch-size N |
4096 |
Cross-frame region batch threshold |
--validate-against PATH |
— | Compare to C-produced AllPeaks_PS.bin and emit parity report |
--deterministic |
off | Force deterministic algorithms (fp64 only) |
Parity tolerances
| Field | Tolerance |
|---|---|
nPeaks per frame, pixel sets, maxY/maxZ, returnCode, maskTouched |
exact |
YCen, ZCen, Radius, diffY, diffZ |
≤ 0.05 px |
Eta |
≤ 0.02° |
IMax, IntegratedIntensity, RawSumIntensity |
≤ 1% relative |
BG, SigmaR, SigmaEta, σGR, σLR, σGEta, σLEta, MU, FitRMSE |
≤ 5% relative |
Downstream gate: indexer (IndexerOMP) on both outputs must produce identical
grain orientations within 0.05° misorientation.
Output
Two binary files in {ResultFolder}/Temp/:
AllPeaks_PS.bin— peak summary (29 columns × nPeaks per frame; seeFF_HEDM/src/PeaksFittingConsolidatedIO.hfor layout).AllPeaks_PX.bin— pixel coordinates for each peak.
These files are byte-compatible with the C tool's output and readable by
ConsolidatedPeakReader/ConsolidatedPixelReader in that header.
Tests
cd packages/midas_peakfit
pytest tests/ -v # unit tests (fast)
pytest tests/ -v -m slow # full pipeline parity (~3 min)
pytest tests/ -v -m gpu # CUDA-only tests (skip on CPU)
License
BSD-3-Clause.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file midas_peakfit-0.2.0.tar.gz.
File metadata
- Download URL: midas_peakfit-0.2.0.tar.gz
- Upload date:
- Size: 72.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dacea37f9b398666d9da8283b1efac0580c41852bee40d097329b84b852fecee
|
|
| MD5 |
a5ec336c17dfb7567ff65004a9fb7f6e
|
|
| BLAKE2b-256 |
7f96a1b25ae6b7b374eab3c67565ffc8d8f588b77fc4889a08ab0e0b6b82e120
|
Provenance
The following attestation bundles were made for midas_peakfit-0.2.0.tar.gz:
Publisher:
python-packages.yml on marinerhemant/MIDAS
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
midas_peakfit-0.2.0.tar.gz -
Subject digest:
dacea37f9b398666d9da8283b1efac0580c41852bee40d097329b84b852fecee - Sigstore transparency entry: 1397474159
- Sigstore integration time:
-
Permalink:
marinerhemant/MIDAS@c6828f52154681a30609088c27370d7ddddc19e3 -
Branch / Tag:
refs/tags/midas-peakfit-v0.2.0 - Owner: https://github.com/marinerhemant
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-packages.yml@c6828f52154681a30609088c27370d7ddddc19e3 -
Trigger Event:
release
-
Statement type:
File details
Details for the file midas_peakfit-0.2.0-py3-none-any.whl.
File metadata
- Download URL: midas_peakfit-0.2.0-py3-none-any.whl
- Upload date:
- Size: 75.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
696b5f40e7815027727b8ee4f776870e437968b3fc1219c8b6f0e970337d5176
|
|
| MD5 |
390151dbcbb8a4620d35461386a22b58
|
|
| BLAKE2b-256 |
a2bbb366c19ed5ca7b6fc73ee60d05c85589de82f110eb003376c8593146c977
|
Provenance
The following attestation bundles were made for midas_peakfit-0.2.0-py3-none-any.whl:
Publisher:
python-packages.yml on marinerhemant/MIDAS
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
midas_peakfit-0.2.0-py3-none-any.whl -
Subject digest:
696b5f40e7815027727b8ee4f776870e437968b3fc1219c8b6f0e970337d5176 - Sigstore transparency entry: 1397474166
- Sigstore integration time:
-
Permalink:
marinerhemant/MIDAS@c6828f52154681a30609088c27370d7ddddc19e3 -
Branch / Tag:
refs/tags/midas-peakfit-v0.2.0 - Owner: https://github.com/marinerhemant
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-packages.yml@c6828f52154681a30609088c27370d7ddddc19e3 -
Trigger Event:
release
-
Statement type: