Skip to main content

Arithmetic circuits on the GPU

Project description

KLay

Python 3.10 License PyPI Downloads

KLay is a Python library for evaluating sparse circuits on the GPU.

To get started, install KLay using pip and check out the documentation. You can also refer to this video or the paper for more information.

pip install klaycircuits

KLay features:

  • GPU acceleration of circuits using Jax or PyTorch.
  • Loading SDD and d-DNNF circuits compiled by PySDD or D4.
  • Evaluation in various semirings (e.g. real, log, tropical).
  • Propagating constants and merging duplicate nodes.

🧪 Tests

Run the test suite from the project root:

pytest tests/

Tests are split by backend. They are automatically skipped if the required backend is not installed:

  • tests/test_manual.py, tests/fuzzer_torch.py, tests/fuzzer_torch_multi.py, tests/fuzzer_creation.py — require PyTorch
  • tests/fuzzer_jax.py — requires JAX
  • tests/test_compression.py — no backend required

📊 Benchmarks

Benchmarks live in the benchmark/ directory. Run from the project root with:

python -m benchmark.benchmark_wmc --benchmark sdd --target torch -v 100 200 500
python -m benchmark.benchmark_wmc --benchmark sdd --target jax   -v 100 200 500
python -m benchmark.benchmark_wmc --benchmark sdd --target pysdd -v 100 200 500

Key options:

Flag Description
-b / --benchmark Circuit type: sdd or d4
-t / --target Backend: torch, jax, or pysdd
-v / --nb_vars Number of variables (one or more)
-d / --device Device: cpu, cuda, cuda:0, etc.
-s / --semiring Semiring: log (default) or real
-r / --nb_repeats Number of seeds to average over (default: 1)

Results are saved as JSON files under results/.

📃 Paper

If you use KLay in your research, consider citing our paper.

To replicate the exact results and figures of the paper, use this code.

@inproceedings{
    maene2025klay,
    title={{KL}ay: Accelerating Arithmetic Circuits for Neurosymbolic {AI}},
    author = {Maene, Jaron and Derkinderen, Vincent and Zuidberg Dos Martires, Pedro},
    booktitle={The Thirteenth International Conference on Learning Representations},
    year={2025},
    url={https://openreview.net/forum?id=Zes7Wyif8G}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

klaycircuits-0.0.5.tar.gz (80.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

klaycircuits-0.0.5-cp314-cp314t-win_amd64.whl (152.1 kB view details)

Uploaded CPython 3.14tWindows x86-64

klaycircuits-0.0.5-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (152.6 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

klaycircuits-0.0.5-cp314-cp314t-macosx_11_0_arm64.whl (124.7 kB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

klaycircuits-0.0.5-cp312-abi3-win_amd64.whl (143.9 kB view details)

Uploaded CPython 3.12+Windows x86-64

klaycircuits-0.0.5-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (146.3 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

klaycircuits-0.0.5-cp312-abi3-macosx_11_0_arm64.whl (121.5 kB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

klaycircuits-0.0.5-cp311-cp311-win_amd64.whl (146.0 kB view details)

Uploaded CPython 3.11Windows x86-64

klaycircuits-0.0.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (150.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

klaycircuits-0.0.5-cp311-cp311-macosx_11_0_arm64.whl (123.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

klaycircuits-0.0.5-cp310-cp310-win_amd64.whl (146.2 kB view details)

Uploaded CPython 3.10Windows x86-64

klaycircuits-0.0.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (150.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

klaycircuits-0.0.5-cp310-cp310-macosx_11_0_arm64.whl (123.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file klaycircuits-0.0.5.tar.gz.

File metadata

  • Download URL: klaycircuits-0.0.5.tar.gz
  • Upload date:
  • Size: 80.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for klaycircuits-0.0.5.tar.gz
Algorithm Hash digest
SHA256 2380ed83423e08fa6d6de02d6e4d93a1348aa8ba38396f7dc06ae517cc6abe3b
MD5 67a073dfe895927cea1a9fe780eaff5b
BLAKE2b-256 510d347530d29de437a67adaa16a5f3fba7481ffcad1fd4372fb194268c7ef4a

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.0.5.tar.gz:

Publisher: release.yml on ML-KULeuven/klay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file klaycircuits-0.0.5-cp314-cp314t-win_amd64.whl.

File metadata

File hashes

Hashes for klaycircuits-0.0.5-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 28209bf939f26d8dd40cfa3e2adecbcf474c239d6887367deb75ac9c15cba752
MD5 de1585b0fac5b0e0348e9b9d1eeaafa2
BLAKE2b-256 bdb780fcfc34eaffe9a34079bc683e66dfad0ce50aaa03764114726607c1b3e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.0.5-cp314-cp314t-win_amd64.whl:

Publisher: release.yml on ML-KULeuven/klay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file klaycircuits-0.0.5-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for klaycircuits-0.0.5-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5fbd0d0740a31c9e37cf9c0bf1d0d95fc64231e30ae27bc34aba9e7d038c3d7f
MD5 58acff9f1bcb20fc3592045e05b666b6
BLAKE2b-256 887b25a4826fda2dee152c952414ba0f010d83fd5553ab9e560f6f283f814dc2

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.0.5-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on ML-KULeuven/klay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file klaycircuits-0.0.5-cp314-cp314t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for klaycircuits-0.0.5-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4cd4bc61f1a809a20ffdb14e7ebd70e752973e4edf9a81518789a81a2e07b11a
MD5 c014f9c88de3142ec97b7bb0d9a1b2a2
BLAKE2b-256 9806b58a41088cd4017bf7eed5d58d303c79ce7835f550ddb5ca325c94a99585

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.0.5-cp314-cp314t-macosx_11_0_arm64.whl:

Publisher: release.yml on ML-KULeuven/klay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file klaycircuits-0.0.5-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: klaycircuits-0.0.5-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 143.9 kB
  • Tags: CPython 3.12+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for klaycircuits-0.0.5-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0d5cad123fe18ac8c5689ddb154b97cf73c12b2e8743c0ded57884f38cbe3cbd
MD5 c2f69ab0250d7b0a33c5e0bf564a5830
BLAKE2b-256 8f67a4c3d37e3f2e8671d31039d9020e413ea04c4550181097ef79674565d93a

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.0.5-cp312-abi3-win_amd64.whl:

Publisher: release.yml on ML-KULeuven/klay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file klaycircuits-0.0.5-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for klaycircuits-0.0.5-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 aad908a660b3a30a7b0c47cdd5b36dfddcd1124bd6f59ec62d78ada4d25f5a8f
MD5 6d4f3208d5cd3c2ada36aad1715eced1
BLAKE2b-256 5e8670559bc194f23c3c472926c0212c10f5bf0f25e5ec830bf687b2a34928e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.0.5-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on ML-KULeuven/klay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file klaycircuits-0.0.5-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for klaycircuits-0.0.5-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f7c4604a91397554eb50e6689e838099269200d08ba47efe9836b42b1c52c996
MD5 e026a9fda2219eb36f5ba48a0b828a44
BLAKE2b-256 2c67d685841d007ac3c8a5a78343cd7d38f7cee97779e924978223e6d5c25aa0

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.0.5-cp312-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on ML-KULeuven/klay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file klaycircuits-0.0.5-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for klaycircuits-0.0.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 861ff7b2b3afc607d29bb4054469985811d598859cba6e9a1d71e86d603b1bac
MD5 b3f37ba7a242602f226990211fc4e308
BLAKE2b-256 d2e339b050247d75e246a4e8cc94e8cb983df156ef1b098f46bf86f38cae3925

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.0.5-cp311-cp311-win_amd64.whl:

Publisher: release.yml on ML-KULeuven/klay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file klaycircuits-0.0.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for klaycircuits-0.0.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f89a289b0d563ba9a9ac844a14457b3a13bf708adcef809377ffb137b863f89c
MD5 47fff1c387b251076108fe6fdeb9897c
BLAKE2b-256 eb510af3da93502c645907a52c440e3bddbbeac795680822ef856f2ebef0b04f

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.0.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on ML-KULeuven/klay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file klaycircuits-0.0.5-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for klaycircuits-0.0.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d81dc28b02cde44497588db5b99003d5d731d06b902c7e1dbc2e0a506fd45aa4
MD5 a7b4189397a94697fb2907b1cfa8fc74
BLAKE2b-256 f2a65eca23ff124a8e83e2435cdedc5c9f80978d3aed414725f7e26274b1e985

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.0.5-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yml on ML-KULeuven/klay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file klaycircuits-0.0.5-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for klaycircuits-0.0.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 09102271fc12a237c395452a93f2265f726bf75ad58ab6ce67621e5c981eb49e
MD5 850203994c9d88269eb6a499e720065a
BLAKE2b-256 9442f8534eda106435d40bb06c41b3511f53037cc75e60486931be9c26ea46e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.0.5-cp310-cp310-win_amd64.whl:

Publisher: release.yml on ML-KULeuven/klay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file klaycircuits-0.0.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for klaycircuits-0.0.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e3472ea8940b1416892ce3f554a4d593b24160c00c36561bb1e4a916729147cb
MD5 e84b7672651678daab9fd8a913600c59
BLAKE2b-256 0bf871bcc9a3d0e98c2a21693f5bb1ed3f74c890782a44f874502a19fa9be6a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.0.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on ML-KULeuven/klay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file klaycircuits-0.0.5-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for klaycircuits-0.0.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8a3e9daf2341bd8d75f86fce44741051879edbd629c95d2ee014d1ec4c652a28
MD5 11925e263ce95578d577197e21c51635
BLAKE2b-256 b4f39122c01c6b2ee1c1b1877d900900777df6543f024956813e7d2e8412dc7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.0.5-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: release.yml on ML-KULeuven/klay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page