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 include:

  • 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}
}

🚀 Impact

Examples of papers that use KLay include:

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.1.0.tar.gz (84.7 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.1.0-cp314-cp314t-win_amd64.whl (186.8 kB view details)

Uploaded CPython 3.14tWindows x86-64

klaycircuits-0.1.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (158.6 kB view details)

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

klaycircuits-0.1.0-cp314-cp314t-macosx_11_0_arm64.whl (129.1 kB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

klaycircuits-0.1.0-cp312-abi3-win_amd64.whl (179.9 kB view details)

Uploaded CPython 3.12+Windows x86-64

klaycircuits-0.1.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (152.3 kB view details)

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

klaycircuits-0.1.0-cp312-abi3-macosx_11_0_arm64.whl (126.0 kB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

klaycircuits-0.1.0-cp311-cp311-win_amd64.whl (181.9 kB view details)

Uploaded CPython 3.11Windows x86-64

klaycircuits-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (156.6 kB view details)

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

klaycircuits-0.1.0-cp311-cp311-macosx_11_0_arm64.whl (128.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

klaycircuits-0.1.0-cp310-cp310-win_amd64.whl (182.1 kB view details)

Uploaded CPython 3.10Windows x86-64

klaycircuits-0.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (156.9 kB view details)

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

klaycircuits-0.1.0-cp310-cp310-macosx_11_0_arm64.whl (128.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for klaycircuits-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c444c28b106745e0bf61ac82bbd95d5e70f57342581e005fb86b4b60bc087276
MD5 208d7739bdebc3b7cbe71c74de5ee3d5
BLAKE2b-256 62f94d5edc6d53b19ca0f166970523932ac2f62ceccf43f9d8b9848325359da5

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.1.0.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.1.0-cp314-cp314t-win_amd64.whl.

File metadata

File hashes

Hashes for klaycircuits-0.1.0-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 0f238066294cdc3d6963a8247d2483b88e910401cc1a4d8fe95ce1b54bd05928
MD5 054220cf6dff5b5e0f00a939635da6d2
BLAKE2b-256 d3dfcc113719fe8ab6769684e69232fcd18226de0ecd34f1fcdcf1578c76f50c

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.1.0-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.1.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for klaycircuits-0.1.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 87e254b5e6c46931e246db06d5ce81f1988f36b1f9cdda04fd3f92a986207a19
MD5 ed20cd3e4b5c2ec40c3ae0467b886254
BLAKE2b-256 56fd9ed3f09d7b4001bc058ac866e5189d84d722c1347960463d6c4d96bff2db

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.1.0-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.1.0-cp314-cp314t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for klaycircuits-0.1.0-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7fffd6e9cd0619dae7cc849aa44bc9fbff84dfd0b72219f5296174dbad4b3828
MD5 2fff646496d35a18fdb3db15e3c8b3b2
BLAKE2b-256 cd3481db653f8678a162ee4c65b809f2443cae9f7e40395da98b9d1bba27c807

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.1.0-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.1.0-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: klaycircuits-0.1.0-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 179.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.1.0-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9d92e624d358f029d35b9a044f48a2310f243ac94bfdfe8f44fac91627af40dc
MD5 25457238f8ff5191325a1f4164a7559b
BLAKE2b-256 8684514a8df964c624ce844fdb2aa5a132cc96004d2d569914d81da7f8640da1

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.1.0-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.1.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for klaycircuits-0.1.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 79f357d23c7792d70a5727caa311d308478f19de544ec28fa0d580487c63e0c6
MD5 6a1290eda4217e107988afd297bf820d
BLAKE2b-256 40233eac82db474d8d978a092ac4886b98fc4e11c76bf8c999e41efdda9addc3

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.1.0-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.1.0-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for klaycircuits-0.1.0-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e00c4f51c80e4f3b0f6f8b667556c96af439adb9c133c108107c9da2e31171c0
MD5 f3a52935611e94aacc62c2a1d9f2a4ec
BLAKE2b-256 7c4858c276ba802cee0b5f336b440ffca787bff78b449180472f74caa6e7fcb9

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.1.0-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.1.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for klaycircuits-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a36a7dd98f0ea73c8d2ae3f3a12cf8f47c644c1a50210aae838a04a44f2db884
MD5 c67ebdf34a9ab8b8ea194aa4d287f292
BLAKE2b-256 19f63f65169f0452fa9dd33e6f7b8dc02840e915a44868e3c525dec94667cfc9

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.1.0-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.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for klaycircuits-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ed29237d3445effc7a8c6cbcb2e4745a108f76e89500d36dae561b2c23ad0666
MD5 1544210d64b494f43f101a3885242e1b
BLAKE2b-256 93ba8ed27adcbed46b180a297c1cd8732871d1f4dd7dc1971e907d8e70b49a5f

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.1.0-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.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for klaycircuits-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4f132085faabc60a38e51dbe78ca624ca1922b399db5bb5f667a44b225e5a110
MD5 0b71749a741e77fed5eb35d2ac30b47c
BLAKE2b-256 244b58cf41082788f17e56c8fc2680465585e1d0ca47bd114c01452c31766965

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.1.0-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.1.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for klaycircuits-0.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 168f22da5a44d81498f4404dce9e5dbcd284723ba922afbc99f9a07d318206b6
MD5 e8e53cead355e2eb88369dc2450cfb50
BLAKE2b-256 62e04fadace91b5bfbda7af5f738e20257b406be39b3a3c4c459fa63d6ecc181

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.1.0-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.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for klaycircuits-0.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b894c1d535bba7b61bb58fa14321376a8b67165b68c3dc83cf5001db7b49c1c0
MD5 4f14c1c2f5d93679828a28895da54950
BLAKE2b-256 75143a60cca8e110ee8d587223711c69a892ea1b411bcf1abf1235f4e128ac26

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.1.0-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.1.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for klaycircuits-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 18b1336320c9d19139024bbd845b7459826578fa1ac8c928c978d71c53ec21ec
MD5 9e0b84999c9b6b56f738106c229d2833
BLAKE2b-256 5b7e29dc3e0af8cea746dadbf879244ea4ccfa47f16b4389b3f2e2cb607cee45

See more details on using hashes here.

Provenance

The following attestation bundles were made for klaycircuits-0.1.0-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