nkDSL
nkDSL is a standalone symbolic operator DSL which provides a compact, declarative way to define discrete operators in
NetKet and compile them into executable JAX-backed operator kernels.
[!NOTE]
nkDSLis currently in beta. The core DSL and compiler workflow are ready for broader testing, while some advanced APIs may still evolve before a fully stable release.
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
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.0 * site("i").value * site("j").value,
)
.for_each_site("i")
.emit(
write("i", -site("i").value),
matrix_element=-0.5,
)
.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.
Metadata
Release files for nkDSL 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nkdsl-0.1.2.tar.gz | 134.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nkdsl-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 315.3 kB
Release files / nkdsl-0.1.2.tar.gz
| Download URL | nkdsl-0.1.2.tar.gz |
|---|---|
| Size | 134.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
991413d76c4a3d543c31babf84065e54a508eabdadca906c5c54dfbc856d30b1
|
|
BLAKE2b-256 checksum How to use checksums |
00ef0d451eeea095f48ed51acd8553827ec394c08c33319fccf4476d6d014970
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 19, 2026.
Transparency logRelease files / nkdsl-0.1.2-py3-none-any.whl
| Download URL | nkdsl-0.1.2-py3-none-any.whl |
|---|---|
| Size | 180.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
323732456820459f8e274d9d40fac8eb3d27a71aa29473ba640fee20965ddecd
|
|
BLAKE2b-256 checksum How to use checksums |
b77815fb986e3c2c00996ab3b974369bc41c356eade33dccc59fdf1bfab652a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 19, 2026.
Transparency log