Python bindings for GRHayL (EOS-first preview)
Project description
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.
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
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
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 pyghl-0.3.2-cp313-cp313-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pyghl-0.3.2-cp313-cp313-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.4 MB
- Tags: CPython 3.13, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa386bb31685230a5a8adae75e88d26ee1f973239b737531761dd1cc486fd8e5
|
|
| MD5 |
dc6f2558483897cfe34feab373b483f7
|
|
| BLAKE2b-256 |
d903402ee586abdc3df1f7fcf5301493ab298ee90a23591e0e31eb7e8f69b8bd
|
Provenance
The following attestation bundles were made for pyghl-0.3.2-cp313-cp313-manylinux_2_28_x86_64.whl:
Publisher:
publish.yml on GRHayL/pyghl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyghl-0.3.2-cp313-cp313-manylinux_2_28_x86_64.whl -
Subject digest:
fa386bb31685230a5a8adae75e88d26ee1f973239b737531761dd1cc486fd8e5 - Sigstore transparency entry: 2164903435
- Sigstore integration time:
-
Permalink:
GRHayL/pyghl@44d50c2298d69afcb75d325c7e288b8b49509dc6 -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/GRHayL
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@44d50c2298d69afcb75d325c7e288b8b49509dc6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyghl-0.3.2-cp313-cp313-macosx_14_0_arm64.whl.
File metadata
- Download URL: pyghl-0.3.2-cp313-cp313-macosx_14_0_arm64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.13, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ba2bf4730810aef30ef9239e34e123d02bd4e59d6e901c258d8863a0b00ecb7
|
|
| MD5 |
f98561c72677d662f91923ad9318c7ac
|
|
| BLAKE2b-256 |
70ae8cfa3e39aa57e8a6c0c354dca6fcfe1e6e1c22e1cefc79f8c5f13aff6420
|
Provenance
The following attestation bundles were made for pyghl-0.3.2-cp313-cp313-macosx_14_0_arm64.whl:
Publisher:
publish.yml on GRHayL/pyghl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyghl-0.3.2-cp313-cp313-macosx_14_0_arm64.whl -
Subject digest:
5ba2bf4730810aef30ef9239e34e123d02bd4e59d6e901c258d8863a0b00ecb7 - Sigstore transparency entry: 2164903487
- Sigstore integration time:
-
Permalink:
GRHayL/pyghl@44d50c2298d69afcb75d325c7e288b8b49509dc6 -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/GRHayL
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@44d50c2298d69afcb75d325c7e288b8b49509dc6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyghl-0.3.2-cp312-cp312-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pyghl-0.3.2-cp312-cp312-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.4 MB
- Tags: CPython 3.12, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f17e80a6737b1c4e684088c3828df3bfae2e000837b3654aec90c5d44e394e7
|
|
| MD5 |
14dfdb4fa2089656f114ad03a6ba6fca
|
|
| BLAKE2b-256 |
204f9f6de228fc1562dfab7ff0b865666402329bec5004b3053173fc57efe6e0
|
Provenance
The following attestation bundles were made for pyghl-0.3.2-cp312-cp312-manylinux_2_28_x86_64.whl:
Publisher:
publish.yml on GRHayL/pyghl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyghl-0.3.2-cp312-cp312-manylinux_2_28_x86_64.whl -
Subject digest:
2f17e80a6737b1c4e684088c3828df3bfae2e000837b3654aec90c5d44e394e7 - Sigstore transparency entry: 2164903419
- Sigstore integration time:
-
Permalink:
GRHayL/pyghl@44d50c2298d69afcb75d325c7e288b8b49509dc6 -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/GRHayL
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@44d50c2298d69afcb75d325c7e288b8b49509dc6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyghl-0.3.2-cp312-cp312-macosx_14_0_arm64.whl.
File metadata
- Download URL: pyghl-0.3.2-cp312-cp312-macosx_14_0_arm64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.12, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf4e5d63e42e974f3e7ddce4c80d3e400e5aa51ac86e22ec90e6cc4f1a500544
|
|
| MD5 |
5167cb31db7151dff7a2ab671a441f4a
|
|
| BLAKE2b-256 |
84e96814184d82fb1be3bd01bbf9aa1889e701a52493422e7fd23c452d1a5c94
|
Provenance
The following attestation bundles were made for pyghl-0.3.2-cp312-cp312-macosx_14_0_arm64.whl:
Publisher:
publish.yml on GRHayL/pyghl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyghl-0.3.2-cp312-cp312-macosx_14_0_arm64.whl -
Subject digest:
bf4e5d63e42e974f3e7ddce4c80d3e400e5aa51ac86e22ec90e6cc4f1a500544 - Sigstore transparency entry: 2164903399
- Sigstore integration time:
-
Permalink:
GRHayL/pyghl@44d50c2298d69afcb75d325c7e288b8b49509dc6 -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/GRHayL
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@44d50c2298d69afcb75d325c7e288b8b49509dc6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyghl-0.3.2-cp311-cp311-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pyghl-0.3.2-cp311-cp311-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.4 MB
- Tags: CPython 3.11, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fba7fe93c2ee7c45c96254b7e39b033dedfa939f183d38050646dca256193540
|
|
| MD5 |
c73a2ba3b379f92a5d71b5ba8879d220
|
|
| BLAKE2b-256 |
8440b93ef2689906d8f8db86f2279fa73c4a922e29dfe4d409584be759646938
|
Provenance
The following attestation bundles were made for pyghl-0.3.2-cp311-cp311-manylinux_2_28_x86_64.whl:
Publisher:
publish.yml on GRHayL/pyghl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyghl-0.3.2-cp311-cp311-manylinux_2_28_x86_64.whl -
Subject digest:
fba7fe93c2ee7c45c96254b7e39b033dedfa939f183d38050646dca256193540 - Sigstore transparency entry: 2164903457
- Sigstore integration time:
-
Permalink:
GRHayL/pyghl@44d50c2298d69afcb75d325c7e288b8b49509dc6 -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/GRHayL
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@44d50c2298d69afcb75d325c7e288b8b49509dc6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyghl-0.3.2-cp311-cp311-macosx_14_0_arm64.whl.
File metadata
- Download URL: pyghl-0.3.2-cp311-cp311-macosx_14_0_arm64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.11, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
daf37a0a5d5f502577fea8270574a22e2d6baa73a384b88b5f1eb688cba0cc2e
|
|
| MD5 |
5c0b849e5eaa3577134c94d1820b8188
|
|
| BLAKE2b-256 |
43820fd6a38402e5274236b0880e5db11555d7ad277915fc878df1316f5f192c
|
Provenance
The following attestation bundles were made for pyghl-0.3.2-cp311-cp311-macosx_14_0_arm64.whl:
Publisher:
publish.yml on GRHayL/pyghl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyghl-0.3.2-cp311-cp311-macosx_14_0_arm64.whl -
Subject digest:
daf37a0a5d5f502577fea8270574a22e2d6baa73a384b88b5f1eb688cba0cc2e - Sigstore transparency entry: 2164903348
- Sigstore integration time:
-
Permalink:
GRHayL/pyghl@44d50c2298d69afcb75d325c7e288b8b49509dc6 -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/GRHayL
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@44d50c2298d69afcb75d325c7e288b8b49509dc6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyghl-0.3.2-cp310-cp310-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pyghl-0.3.2-cp310-cp310-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.4 MB
- Tags: CPython 3.10, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a16f3e460e1cc6349993505d39f743d72c3fc7c50df937d4bc8d110c72e50d8
|
|
| MD5 |
e26e5c465f4266972b768eab9b0a37bc
|
|
| BLAKE2b-256 |
967281c2baa539edfdea8900087d14f1085ec4bfee45ecf7dd285fc93a57dc22
|
Provenance
The following attestation bundles were made for pyghl-0.3.2-cp310-cp310-manylinux_2_28_x86_64.whl:
Publisher:
publish.yml on GRHayL/pyghl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyghl-0.3.2-cp310-cp310-manylinux_2_28_x86_64.whl -
Subject digest:
3a16f3e460e1cc6349993505d39f743d72c3fc7c50df937d4bc8d110c72e50d8 - Sigstore transparency entry: 2164903324
- Sigstore integration time:
-
Permalink:
GRHayL/pyghl@44d50c2298d69afcb75d325c7e288b8b49509dc6 -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/GRHayL
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@44d50c2298d69afcb75d325c7e288b8b49509dc6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyghl-0.3.2-cp310-cp310-macosx_14_0_arm64.whl.
File metadata
- Download URL: pyghl-0.3.2-cp310-cp310-macosx_14_0_arm64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.10, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b98502c37f4d49df1425c79f4f289341bc1912cc179dd20c600cc388599ed6cf
|
|
| MD5 |
ba9dc5ef61b39ae9bba7e92532651fa1
|
|
| BLAKE2b-256 |
75fce3a39f724dff5db14710bd136d4a00770e2fa14b21216fcf7eb8f87ca6f6
|
Provenance
The following attestation bundles were made for pyghl-0.3.2-cp310-cp310-macosx_14_0_arm64.whl:
Publisher:
publish.yml on GRHayL/pyghl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyghl-0.3.2-cp310-cp310-macosx_14_0_arm64.whl -
Subject digest:
b98502c37f4d49df1425c79f4f289341bc1912cc179dd20c600cc388599ed6cf - Sigstore transparency entry: 2164903375
- Sigstore integration time:
-
Permalink:
GRHayL/pyghl@44d50c2298d69afcb75d325c7e288b8b49509dc6 -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/GRHayL
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@44d50c2298d69afcb75d325c7e288b8b49509dc6 -
Trigger Event:
release
-
Statement type: