Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

PyPI License Documentation Status codecov

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.3b0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nkDSL 0.1.3b0
File Size Uploaded Provenance
nkdsl-0.1.3b0.tar.gz 165.8 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for nkDSL 0.1.3b0
File Interpreter ABI Platform
nkdsl-0.1.3b0-py3-none-any.whl Python 3 none any Details

Total release size: 368.3 kB

Release files / nkdsl-0.1.3b0.tar.gz

Download URL nkdsl-0.1.3b0.tar.gz
Size 165.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6070a22204fb874e6f0d444c88b9d5f22d11168845736db17abcc7d2ffa0c9f0
BLAKE2b-256 checksum
How to use checksums
590f7788d69c46131f6240a063784d87429cd922a32b5294e3c74ea2a20ebaef
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 log

Release files / nkdsl-0.1.3b0-py3-none-any.whl

Download URL nkdsl-0.1.3b0-py3-none-any.whl
Size 202.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ffc0270cd32b82c440a81bf31acb50390b5a6dbd95533be457be6cc52add31e
BLAKE2b-256 checksum
How to use checksums
7ba4f435fdf1cd80f4da0e23bcad41d2f582a5ea80611cb92f5ccd588b03e97f
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 log

Security for nkDSL 0.1.3b0

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.

Select from 2 files

Attestation for nkdsl-0.1.3b0.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 log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page