Symbolic operator DSL for NetKet discrete JAX operators
Project description
nkDSL
nkdsl is a standalone extraction of the symbolic operator DSL from neuraLQX.
It provides a compact, declarative way to define discrete operators in NetKet and compile them into executable JAX-backed operator kernels.
[!WARNING]
nkDSLis currently experimental (alpha) and not a production release. We are still testing and refining core behavior, interfaces, and performance. Expect API changes between releases while the package matures.
What it does
With nkdsl, you describe an operator in terms of
- where to iterate, such as sites, pairs, or user-defined index sets,
- when a branch is active, through symbolic predicates,
- how to rewrite a configuration, through update programs,
- what matrix element to assign to each emitted branch.
The result is a symbolic operator that can be compiled into a NetKet-compatible executable operator.
Example: 1D transverse-field Ising model
The example below builds [ H = -J \sum_{\langle i,j \rangle} \sigma_i^z \sigma_j^z - h \sum_i \sigma_i^x ] for a periodic chain. The diagonal Ising interaction is emitted with an identity update, while the transverse-field term flips one spin at a time.
import netket as nk
from nkdsl import SymbolicDiscreteJaxOperator, site, write
L = 8
J = 1.0
h = 0.5
hilbert = nk.hilbert.Spin(s=0.5, N=L)
graph = nk.graph.Chain(length=L, pbc=True)
ising = (
SymbolicDiscreteJaxOperator(hilbert, "ising_tfim", hermitian=True)
.for_each(("i", "j"), over=graph.edges())
.emit(
matrix_element=1.2 * site("i").value * site("j").value,
)
.for_each_site("i")
.emit(
write("i", -site("i").value),
matrix_element=-0.7,
)
.compile()
)
# now, `ising` is a NetKet DiscreteJaxOperator subclass, and can be used in NetKet
Installation
Install directly from PyPI:
python -m pip install --upgrade pip
python -m pip install nkdsl
Status
nkdsl is currently a small, focused package for the recent DSL operator work developed in neuraLQX. Right now the goal is clarity and usability rather than a broad, frozen API surface.
License
This project is licensed under Apache License 2.0. See LICENSE for the full text.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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 nkdsl-0.1.0a0.tar.gz.
File metadata
- Download URL: nkdsl-0.1.0a0.tar.gz
- Upload date:
- Size: 94.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01e14e815d46fb32fd8b6d77e7da8cb21aeb88b569008aa85b579e5e1e65ec44
|
|
| MD5 |
066bf307fbfdb0a9fd7b05ba03ecb767
|
|
| BLAKE2b-256 |
faf2c9dcdb9ed4f09fe1cf30adfd07438dc581b756a29aca12d6028ecb63c6b8
|
Provenance
The following attestation bundles were made for nkdsl-0.1.0a0.tar.gz:
Publisher:
publish.yaml on waleed-sh/nkDSL
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nkdsl-0.1.0a0.tar.gz -
Subject digest:
01e14e815d46fb32fd8b6d77e7da8cb21aeb88b569008aa85b579e5e1e65ec44 - Sigstore transparency entry: 1246118623
- Sigstore integration time:
-
Permalink:
waleed-sh/nkDSL@788cef6f3b260ca93ce4de6cef1b176f3a5dc3e9 -
Branch / Tag:
refs/tags/v0.1.0a0 - Owner: https://github.com/waleed-sh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@788cef6f3b260ca93ce4de6cef1b176f3a5dc3e9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file nkdsl-0.1.0a0-py3-none-any.whl.
File metadata
- Download URL: nkdsl-0.1.0a0-py3-none-any.whl
- Upload date:
- Size: 119.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c0695a51db271bb90e2f18e69fd5126211618fb6ec4765b9dfaafd2313f1b2f
|
|
| MD5 |
ba5afb3f977b931f95788372c43d768c
|
|
| BLAKE2b-256 |
ff22284b37193a31b4949f9de4de641053a070a54f91c4fb9514925d36c36d8b
|
Provenance
The following attestation bundles were made for nkdsl-0.1.0a0-py3-none-any.whl:
Publisher:
publish.yaml on waleed-sh/nkDSL
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nkdsl-0.1.0a0-py3-none-any.whl -
Subject digest:
4c0695a51db271bb90e2f18e69fd5126211618fb6ec4765b9dfaafd2313f1b2f - Sigstore transparency entry: 1246118626
- Sigstore integration time:
-
Permalink:
waleed-sh/nkDSL@788cef6f3b260ca93ce4de6cef1b176f3a5dc3e9 -
Branch / Tag:
refs/tags/v0.1.0a0 - Owner: https://github.com/waleed-sh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@788cef6f3b260ca93ce4de6cef1b176f3a5dc3e9 -
Trigger Event:
release
-
Statement type: