pyghl
Python bindings and neural-network tooling for GRHayL.
pyghl packages a pinned GRHayL build together with a CPython extension and
Python utilities for tabulated equations of state, conservative-to-primitive
experiments, and neural-network initial guesses.
Warning
While revised by humans, the majority of the code in this repository has leveraged AI assistance. Users should review results carefully and use this package at their own risk.
At a high level:
pyghlexposes selected GRHayL C structs and routines to Python.pyghl.eosprovides tabulated-EOS loading and interpolation helpers.pyghl.nnprovides neural-network con2prim data, training, export, and EOS embedding helpers.pyghl traintrains a neural-network model for an EOS table.pyghl appendembeds a trained model into an EOS HDF5 file.
Installation
For end users installing from PyPI:
python -m pip install pyghl
Check the installed package:
pyghl --version
For contributors working from a clone of this repository:
git clone https://github.com/GRHayL/pyghl.git
cd pyghl
git submodule update --init --recursive
python -m pip install -e .
The local build compiles the pinned GRHayL submodule in extern/GRHayL and then
builds the Python extension against the resulting libghl.
If you need to build against a different local GRHayL checkout:
GRHAYL_DIR=/path/to/GRHayL python -m pip install -e .
Prerequisites by Workflow
python -m pip install pyghl should install a prebuilt wheel on supported
platforms. Source builds need additional system tools:
- Local extension builds: a C compiler,
make, HDF5, and Python build tooling. - Editable contributor installs: initialized
extern/GRHayLsubmodule. - Neural-network training:
torch,numpy, andh5pyfrom package dependencies. - EOS workflows: a GRHayL-compatible tabulated EOS HDF5 file.
Current CI builds wheels for Linux x86_64 and macOS arm64.
EOS format support
Currently,
pyghlsupports only tables in the StellarCollapse HDF5 format. Support for tables in the CompOSE format is planned for a future release.
Downloading an EOS Table
stellarcollapse.org provides
GRHayL-compatible tabulated EOS files. For example, the
APR EOS page provides an APR table
with NSE (3335 nuclides). Download and extract it before passing the HDF5 file
to pyghl:
curl -fL \
'https://stockholmuniversity.box.com/s/xatxe62v9ywxr5sl2vf94e180uf1zkik?download=1' \
-o APR_3335_rho393_temp133_ye66_gitM180edd5_20190225.h5.tar.bz2
tar -xjf APR_3335_rho393_temp133_ye66_gitM180edd5_20190225.h5.tar.bz2
This APR table does not currently have an installed pyghl model, so train
one and embed it in the extracted EOS file:
pyghl train APR_3335_rho393_temp133_ye66_gitM180edd5_20190225.h5
pyghl check-eos APR_3335_rho393_temp133_ye66_gitM180edd5_20190225.h5
pyghl train generates a training dataset, trains and saves the model, and
embeds the resulting neural-network data into the EOS file.
Basic EOS Neural-Network Workflow
The quickest useful workflow is to make sure the EOS file itself contains the
neural-network data that GRHayL loads when enable_neural_net_c2p=True.
1. Try the installed model cache first
pyghl append path/to/eos_table.h5
This looks for an installed neural-network model whose recorded EOS hash matches
the EOS file, then embeds it into the EOS under the grhayl_nn_c2p group. This
is the preferred first command because it is fast and avoids retraining known
EOS tables.
2. Train if the EOS is unknown
Run training without an EOS path to choose from the tables published through the StellarCollapse microphysics index:
pyghl train
The command discovers EOS-family catalog pages from that index (including nested EOS catalog links). It first presents the category/paper names used by the StellarCollapse microphysics page, then opens a searchable list of the specific tables in the selected category. Table search supports arrow-key navigation, paging, and type-to-filter matching across family, variant, and filename.
APR tables remain advertised by StellarCollapse, but their Stockholm University Box downloads currently return HTTP 404. The category and table screens mark these entries unavailable before selection. Other selected bzip2 or tar+bzip2 HDF5 tables are downloaded, decompressed into the current directory, and reused on later runs. Downloads display transferred size and speed; servers that report the file size also get a percentage bar and ETA. Standard tables are hundreds of MB compressed; some high-resolution SRO tables are 4.3-4.5 GB.
To use an EOS table already on disk instead:
pyghl train path/to/eos_table.h5
If no installed model matches, pyghl train creates training data when no
dataset is supplied, trains a small neural network, writes model artifacts such
as tiny_mlp_model.h5, registers the model by the EOS canonical MD5 hash, and
embeds the result into the EOS file by default.
To train from an existing dataset:
pyghl train path/to/eos_table.h5 path/to/nn_training_dataset.bin
3. Retrain a known EOS deliberately
pyghl train path/to/eos_table.h5 --force_retrain
Use this when the EOS is already known but you want to replace the installed
model artifacts with a fresh training run. If the EOS already contains embedded
neural-network data and you want to replace it too, add --overwrite_eos.
Other Useful Commands
Inspect whether an EOS file already contains embedded neural-network data:
pyghl check-eos path/to/eos_table.h5
List installed models that can be matched by EOS hash:
pyghl list-models
Append a specific model file instead of using the installed model cache:
pyghl append path/to/eos_table.h5 path/to/tiny_mlp_model.h5
Remove embedded neural-network data from an EOS file:
pyghl remove-eos-nn path/to/eos_table.h5
Python API Example
import pyghl as ghl
params = ghl.initialize_params()
eos = ghl.eos.initialize_tabulated_eos_functions_and_params(
params,
"path/to/eos_table.h5",
)
rho = 1.0e-12
Y_e = 0.05
T = 1.0e2
rho, Y_e, T = eos.tabulated_enforce_bounds_rho_Ye_T(rho, Y_e, T)
pressure = eos.tabulated_compute_P_from_T(rho, Y_e, T)
print(pressure)
Command-Line Tools
Primary commands:
pyghl train [<eos-file>] [dataset]
pyghl append <eos-file> [nn-hdf5]
pyghl check-eos <eos-file>
pyghl list-models
pyghl remove-eos-nn <eos-file>
pyghl --version
What Is Exposed?
Selected top-level bindings include:
initialize_paramsinitialize_metriccompute_ADM_auxiliariesinitialize_primitivesinitialize_diagnosticscompute_conservsundensitize_conservativescompute_SU_Bsq_Ssq_BdotSlimit_v_and_compute_u0limit_utilde_and_compute_vguess_primitivestabulated_Palenzuela1D_energytabulated_con2prim_multi_methodnn_c2p_guessnn_c2p_guess_x
Struct wrappers include:
PrimitiveConservativeMetricADMAuxDiagnosticsParamsTabulatedEOS
Repository Map
csrc/: CPython extension source.src/pyghl/: Python package.src/pyghl/nn_c2p/: command-line neural-network workflows.examples/: direct example scripts.extern/GRHayL/: pinned GRHayL submodule used for builds..github/workflows/: wheel and PyPI publishing automation.PUBLISHING.md: release and PyPI publishing checklist.
Contributor Setup
Recommended local workflow:
git submodule update --init --recursive
python -m pip install -e .
python -m compileall -q src setup.py
Build a local wheel:
python -m pip wheel . -w /tmp/pyghl-wheel --no-deps --no-build-isolation
Metadata
Release files for pyghl 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| pyghl-0.4.0-cp313-cp313-manylinux_2_28_x86_64.whl | CPython 3.13 | CPython 3.13 | Linux glibc 2.28+ x86-64 | Details |
| pyghl-0.4.0-cp313-cp313-macosx_14_0_arm64.whl | CPython 3.13 | CPython 3.13 | macOS 14.0+ ARM64 | Details |
| pyghl-0.4.0-cp312-cp312-manylinux_2_28_x86_64.whl | CPython 3.12 | CPython 3.12 | Linux glibc 2.28+ x86-64 | Details |
| pyghl-0.4.0-cp312-cp312-macosx_14_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 14.0+ ARM64 | Details |
| pyghl-0.4.0-cp311-cp311-manylinux_2_28_x86_64.whl | CPython 3.11 | CPython 3.11 | Linux glibc 2.28+ x86-64 | Details |
| pyghl-0.4.0-cp311-cp311-macosx_14_0_arm64.whl | CPython 3.11 | CPython 3.11 | macOS 14.0+ ARM64 | Details |
| pyghl-0.4.0-cp310-cp310-manylinux_2_28_x86_64.whl | CPython 3.10 | CPython 3.10 | Linux glibc 2.28+ x86-64 | Details |
| pyghl-0.4.0-cp310-cp310-macosx_14_0_arm64.whl | CPython 3.10 | CPython 3.10 | macOS 14.0+ ARM64 | Details |
Total release size: 15.9 MB
Release files / pyghl-0.4.0-cp313-cp313-manylinux_2_28_x86_64.whl
| Download URL | pyghl-0.4.0-cp313-cp313-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.13 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
d9fd4ed8054ba6f8b7d608e22a0e960c6623c8bfaf6655d27d77b9961d20c7b1
|
|
BLAKE2b-256 checksum How to use checksums |
2d16445e5c277a479a94686b93b2d9675085c45965891dfa08633bf71547b1d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 14, 2026.
Transparency logRelease files / pyghl-0.4.0-cp313-cp313-macosx_14_0_arm64.whl
| Download URL | pyghl-0.4.0-cp313-cp313-macosx_14_0_arm64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.13 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
cd09a6f09c3e4ea14ca6c74cc8e8e32b7be6b4aa8f2e15cf4821bdefbc64c659
|
|
BLAKE2b-256 checksum How to use checksums |
60a3b25b461ca27ed541f4803332e863ef44ac012926cf5af99261e464b6e267
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 14, 2026.
Transparency logRelease files / pyghl-0.4.0-cp312-cp312-manylinux_2_28_x86_64.whl
| Download URL | pyghl-0.4.0-cp312-cp312-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.12 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
5ef2cf49e32fa06cdc8e57bd98501aad411a8084bff451e36e6278d5792c463f
|
|
BLAKE2b-256 checksum How to use checksums |
2f03d6a2d6d3323f4305721f913aa379915b2ee15c2e20ac18187c998e8fbfd8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 14, 2026.
Transparency logRelease files / pyghl-0.4.0-cp312-cp312-macosx_14_0_arm64.whl
| Download URL | pyghl-0.4.0-cp312-cp312-macosx_14_0_arm64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.12 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ad319d4dc2f778c50e7bafa67fb13f10289fbd98f28e34c0d41489e8362bc5b7
|
|
BLAKE2b-256 checksum How to use checksums |
6a602cc6c6cec9c43b0d04586a0de88196782681fadee414b6e8605dc87abc15
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 14, 2026.
Transparency logRelease files / pyghl-0.4.0-cp311-cp311-manylinux_2_28_x86_64.whl
| Download URL | pyghl-0.4.0-cp311-cp311-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.11 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
53a1b218aa1bf42224ffbf92d572a93831cde1653eb589763b883fddca120c1e
|
|
BLAKE2b-256 checksum How to use checksums |
e34923ed4d81b8aa31abf7e26470c19431d8a32bc6f94fef6d3ad97373d346bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 14, 2026.
Transparency logRelease files / pyghl-0.4.0-cp311-cp311-macosx_14_0_arm64.whl
| Download URL | pyghl-0.4.0-cp311-cp311-macosx_14_0_arm64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.11 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
7f02f0db95802f99f536c92b1fd38f734cf9fb4e8f5edc54cfad77462ffec67c
|
|
BLAKE2b-256 checksum How to use checksums |
f9b5d8b7ab6f13be41b07e88468907733340e48bbc86a05764b654ea7275dccf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 14, 2026.
Transparency logRelease files / pyghl-0.4.0-cp310-cp310-manylinux_2_28_x86_64.whl
| Download URL | pyghl-0.4.0-cp310-cp310-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
a84abfcc5df81be2f38fff4c08f070ab4877a1abfd896be0ea67303841becdf9
|
|
BLAKE2b-256 checksum How to use checksums |
8c8209c85d3292f7fe4ec732aee2ee39e415645a2522f1b89ddd196b6227831f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 14, 2026.
Transparency logRelease files / pyghl-0.4.0-cp310-cp310-macosx_14_0_arm64.whl
| Download URL | pyghl-0.4.0-cp310-cp310-macosx_14_0_arm64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.10 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
cdf19ae06d57645c8f780b872101b42b4873c8b31fa8ca61e7f3db493bc614e9
|
|
BLAKE2b-256 checksum How to use checksums |
69843e3295423bbca92ce28a8acdee62563ff2c7ad2c12782584224634e49751
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 14, 2026.
Transparency logSecurity for pyghl 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 8 files in this release have been uploaded with provenance metadata.
Attestation for pyghl-0.4.0-cp313-cp313-manylinux_2_28_x86_64.whl
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 14, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.