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.
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
NetKet is the default compiled operator family. For neuraLQX, install
"nkDSL[neuralqx]", which selects a compatible NetKet version
(>=3.20.0,<3.22.0). Then select its built-in target once:
import nkdsl
nkdsl.config.LOWERING = "neuralqx"
Subsequent .compile() calls use that choice. Custom operator families can
be registered and selected with nkdsl.LOWERING_REGISTRY.register(...).
Per-call operator_lowering=... overrides remain available. See
choosing the compiled operator type
for the complete workflow.
Status
nkdsl is a small, focused beta package for the symbolic operator work developed in neuraLQX. The goal is a clear, usable DSL with a stable core workflow and room for advanced APIs to continue maturing.
License
This project is licensed under Apache License 2.0. See LICENSE for the full text.
Documentation
The documentation uses MkDocs and Material. To preview it locally:
python -m pip install -r docs/requirements.txt
python -m mkdocs serve
Notebook pages display verified, saved outputs and do not execute during site builds. See the documentation guide for refreshing notebooks and running the checks used by CI and Read the Docs.
Metadata
Release files for nkDSL 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| nkdsl-0.1.3.tar.gz | 165.7 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nkdsl-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 368.3 kB
Release files / nkdsl-0.1.3.tar.gz
| Download URL | nkdsl-0.1.3.tar.gz |
|---|---|
| Size | 165.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
466db3f6da2f46e87428d80f322ec2e057837a2865b120a5849b6cdd244228a5
|
|
BLAKE2b-256 checksum How to use checksums |
90d473a2abd9ac4df35353ebdbf7e53555f6fbd6a2fa411afd9763f91189e33f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Oct 23, 2026.
Transparency logRelease files / nkdsl-0.1.3-py3-none-any.whl
| Download URL | nkdsl-0.1.3-py3-none-any.whl |
|---|---|
| Size | 202.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d2b262259d7ef8e5f878be7ae6b5bb6c2f3407967e49214a3172b4616f419156
|
|
BLAKE2b-256 checksum How to use checksums |
da2ee273cb3fc206921bae9745c8ffc75150bb3cbd848b2f7f22d79cd6f15d66
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Oct 23, 2026.
Transparency logSecurity for nkDSL 0.1.3
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for nkdsl-0.1.3.tar.gz
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 Oct 23, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.