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 append-eosembeds 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.
First Successful Run
The quickest useful workflow is to train a small model for an EOS table and append the result back into that EOS file.
1. Train a model
pyghl train path/to/eos_table.h5
This creates training data if no dataset is supplied, trains a small neural
network, writes model artifacts such as tiny_mlp_model.h5, and registers the
installed model by the EOS canonical MD5 hash.
To train from an existing dataset:
pyghl train path/to/eos_table.h5 path/to/nn_training_dataset.bin
2. Append a model to an EOS file
Append an explicit model:
pyghl append-eos path/to/eos_table.h5 tiny_mlp_model.h5
Or append the installed model matching the EOS canonical MD5 hash:
pyghl append-eos path/to/eos_table.h5
3. Inspect installed models
python -m pyghl.nn_c2p.list_installed_models
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 <eos-file> [nn-hdf5]
pyghl --version
Additional module entry points:
python -m pyghl.nn_c2p.nn_c2p_generate_dataset ...
python -m pyghl.nn_c2p.nn_c2p_train ...
python -m pyghl.nn_c2p.nn_c2p_test ...
python -m pyghl.nn_c2p.append_eos_file ...
python -m pyghl.nn_c2p.check_eos ...
python -m pyghl.nn_c2p.list_installed_models
python -m pyghl.nn_c2p.remove_eos_nn ...
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
If editable installs are not available in your environment, many Python-only checks can be run from the repository root with:
PYTHONPATH=src python -m pyghl.nn_c2p.list_installed_models
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.2.1-cp313-cp313-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pyghl-0.2.1-cp313-cp313-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.8 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 |
cd0a7728d7cca6a8238ca55b7d2c1f0bf5436857f1dddd3c6ce60af07e9f93f8
|
|
| MD5 |
f2c007dcedb43fbf3c69026bb29fa25b
|
|
| BLAKE2b-256 |
42aa3182ca6283f04ec5e396fff47af09a2e29eec518a091d57dffea1a79bdfb
|
Provenance
The following attestation bundles were made for pyghl-0.2.1-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.2.1-cp313-cp313-manylinux_2_28_x86_64.whl -
Subject digest:
cd0a7728d7cca6a8238ca55b7d2c1f0bf5436857f1dddd3c6ce60af07e9f93f8 - Sigstore transparency entry: 2014972103
- Sigstore integration time:
-
Permalink:
GRHayL/pyghl@96a6a6541a22417ac40a8c3df2483c47462cd0d7 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/GRHayL
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@96a6a6541a22417ac40a8c3df2483c47462cd0d7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyghl-0.2.1-cp313-cp313-macosx_14_0_arm64.whl.
File metadata
- Download URL: pyghl-0.2.1-cp313-cp313-macosx_14_0_arm64.whl
- Upload date:
- Size: 1.7 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 |
78b9fff33bbf198c55f5e2e68c3e7273723cceedc60dc0f1b1fc57c40ef3c474
|
|
| MD5 |
08fc946584caafdfac40e89a060ce32d
|
|
| BLAKE2b-256 |
636fff64973b8c5a5062a9d0d8efa887676546104e07d5417ab7559c2386e958
|
Provenance
The following attestation bundles were made for pyghl-0.2.1-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.2.1-cp313-cp313-macosx_14_0_arm64.whl -
Subject digest:
78b9fff33bbf198c55f5e2e68c3e7273723cceedc60dc0f1b1fc57c40ef3c474 - Sigstore transparency entry: 2014972773
- Sigstore integration time:
-
Permalink:
GRHayL/pyghl@96a6a6541a22417ac40a8c3df2483c47462cd0d7 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/GRHayL
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@96a6a6541a22417ac40a8c3df2483c47462cd0d7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyghl-0.2.1-cp312-cp312-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pyghl-0.2.1-cp312-cp312-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.8 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 |
7d984e155864280830a213ed044018f2ae0740fb624fed6c40f7376cf250f027
|
|
| MD5 |
4d9b1ac6ac8d11e334b6ba1b27f189c0
|
|
| BLAKE2b-256 |
b014bbab1aa1d28543898e11fd0cf908bf21b1027f9618cdc450c3805179d79d
|
Provenance
The following attestation bundles were made for pyghl-0.2.1-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.2.1-cp312-cp312-manylinux_2_28_x86_64.whl -
Subject digest:
7d984e155864280830a213ed044018f2ae0740fb624fed6c40f7376cf250f027 - Sigstore transparency entry: 2014971688
- Sigstore integration time:
-
Permalink:
GRHayL/pyghl@96a6a6541a22417ac40a8c3df2483c47462cd0d7 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/GRHayL
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@96a6a6541a22417ac40a8c3df2483c47462cd0d7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyghl-0.2.1-cp312-cp312-macosx_14_0_arm64.whl.
File metadata
- Download URL: pyghl-0.2.1-cp312-cp312-macosx_14_0_arm64.whl
- Upload date:
- Size: 1.7 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 |
2658d1528718b446d015df7e1ec38d98666ccb92c40e79f5ac6b0e7f64832af6
|
|
| MD5 |
9e9fe9bcc4aabe529e05bcece6ea7fee
|
|
| BLAKE2b-256 |
aa6a6708767f5704adb8dc80198c3e951d6598a075f1200ec98330e497841b7c
|
Provenance
The following attestation bundles were made for pyghl-0.2.1-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.2.1-cp312-cp312-macosx_14_0_arm64.whl -
Subject digest:
2658d1528718b446d015df7e1ec38d98666ccb92c40e79f5ac6b0e7f64832af6 - Sigstore transparency entry: 2014972642
- Sigstore integration time:
-
Permalink:
GRHayL/pyghl@96a6a6541a22417ac40a8c3df2483c47462cd0d7 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/GRHayL
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@96a6a6541a22417ac40a8c3df2483c47462cd0d7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyghl-0.2.1-cp311-cp311-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pyghl-0.2.1-cp311-cp311-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.8 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 |
c5a868505247ab6140ee0ea7c5953bd1b07fe4048eebd547633ba4b59f5f5747
|
|
| MD5 |
45bb69374dc92bb14417b29d396f8cd2
|
|
| BLAKE2b-256 |
6b93d8eaebbad59470766c4763cfd797010f1b907e16675d5a926ba43f2f54a3
|
Provenance
The following attestation bundles were made for pyghl-0.2.1-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.2.1-cp311-cp311-manylinux_2_28_x86_64.whl -
Subject digest:
c5a868505247ab6140ee0ea7c5953bd1b07fe4048eebd547633ba4b59f5f5747 - Sigstore transparency entry: 2014972296
- Sigstore integration time:
-
Permalink:
GRHayL/pyghl@96a6a6541a22417ac40a8c3df2483c47462cd0d7 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/GRHayL
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@96a6a6541a22417ac40a8c3df2483c47462cd0d7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyghl-0.2.1-cp311-cp311-macosx_14_0_arm64.whl.
File metadata
- Download URL: pyghl-0.2.1-cp311-cp311-macosx_14_0_arm64.whl
- Upload date:
- Size: 1.7 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 |
9696f8b33e611917737dc04d3d4ffce2aab4d884f076f6aeaafac074528edf0e
|
|
| MD5 |
856ff849ee8fa76a44002a1ca04302b1
|
|
| BLAKE2b-256 |
6d37bff4c79bfbe7c1f2ff5987213497ea79a6cecabdacff5e6bb26023fc6dda
|
Provenance
The following attestation bundles were made for pyghl-0.2.1-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.2.1-cp311-cp311-macosx_14_0_arm64.whl -
Subject digest:
9696f8b33e611917737dc04d3d4ffce2aab4d884f076f6aeaafac074528edf0e - Sigstore transparency entry: 2014971968
- Sigstore integration time:
-
Permalink:
GRHayL/pyghl@96a6a6541a22417ac40a8c3df2483c47462cd0d7 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/GRHayL
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@96a6a6541a22417ac40a8c3df2483c47462cd0d7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyghl-0.2.1-cp310-cp310-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pyghl-0.2.1-cp310-cp310-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.8 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 |
2648960e7f9d89ae549202c349fab0fee708bb0a69bc2d67a32d9453b825720f
|
|
| MD5 |
76d49be3030438d905c71797b420d56c
|
|
| BLAKE2b-256 |
f4573408abd089371c078a6b5d0369412a34fd8846afe1f302b42bc5c66d8d66
|
Provenance
The following attestation bundles were made for pyghl-0.2.1-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.2.1-cp310-cp310-manylinux_2_28_x86_64.whl -
Subject digest:
2648960e7f9d89ae549202c349fab0fee708bb0a69bc2d67a32d9453b825720f - Sigstore transparency entry: 2014972414
- Sigstore integration time:
-
Permalink:
GRHayL/pyghl@96a6a6541a22417ac40a8c3df2483c47462cd0d7 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/GRHayL
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@96a6a6541a22417ac40a8c3df2483c47462cd0d7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyghl-0.2.1-cp310-cp310-macosx_14_0_arm64.whl.
File metadata
- Download URL: pyghl-0.2.1-cp310-cp310-macosx_14_0_arm64.whl
- Upload date:
- Size: 1.7 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 |
9fa027aefc6f21eb1d53a94a24c1b1ffda61f1234985113fc6011d25691485d0
|
|
| MD5 |
653d8a385b9cb84a66d77996201da421
|
|
| BLAKE2b-256 |
50fe1df0197eb80e26829ce9c584e81236d06934155c548cdbff2d99c181b9ca
|
Provenance
The following attestation bundles were made for pyghl-0.2.1-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.2.1-cp310-cp310-macosx_14_0_arm64.whl -
Subject digest:
9fa027aefc6f21eb1d53a94a24c1b1ffda61f1234985113fc6011d25691485d0 - Sigstore transparency entry: 2014971837
- Sigstore integration time:
-
Permalink:
GRHayL/pyghl@96a6a6541a22417ac40a8c3df2483c47462cd0d7 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/GRHayL
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@96a6a6541a22417ac40a8c3df2483c47462cd0d7 -
Trigger Event:
release
-
Statement type: