Skip to main content

Symbolic operator DSL for NetKet discrete JAX operators

Project description

nkDSL logo

Documentation Status

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] nkDSL is 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nkdsl-0.1.0a0.tar.gz (94.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nkdsl-0.1.0a0-py3-none-any.whl (119.6 kB view details)

Uploaded Python 3

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

Hashes for nkdsl-0.1.0a0.tar.gz
Algorithm Hash digest
SHA256 01e14e815d46fb32fd8b6d77e7da8cb21aeb88b569008aa85b579e5e1e65ec44
MD5 066bf307fbfdb0a9fd7b05ba03ecb767
BLAKE2b-256 faf2c9dcdb9ed4f09fe1cf30adfd07438dc581b756a29aca12d6028ecb63c6b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for nkdsl-0.1.0a0.tar.gz:

Publisher: publish.yaml on waleed-sh/nkDSL

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for nkdsl-0.1.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c0695a51db271bb90e2f18e69fd5126211618fb6ec4765b9dfaafd2313f1b2f
MD5 ba5afb3f977b931f95788372c43d768c
BLAKE2b-256 ff22284b37193a31b4949f9de4de641053a070a54f91c4fb9514925d36c36d8b

See more details on using hashes here.

Provenance

The following attestation bundles were made for nkdsl-0.1.0a0-py3-none-any.whl:

Publisher: publish.yaml on waleed-sh/nkDSL

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