Skip to main content

Symbolic operator DSL for NetKet discrete JAX operators

Project description

nkDSL logo

PyPI License 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.1a0.tar.gz (110.8 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.1a0-py3-none-any.whl (146.1 kB view details)

Uploaded Python 3

File details

Details for the file nkdsl-0.1.1a0.tar.gz.

File metadata

  • Download URL: nkdsl-0.1.1a0.tar.gz
  • Upload date:
  • Size: 110.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for nkdsl-0.1.1a0.tar.gz
Algorithm Hash digest
SHA256 bb0fcd1e2c5507b9d19834b38cc81653c4de78c0b8d8248554f82976e78e6b0c
MD5 606f72dbde6b78d6a704985cffe3781c
BLAKE2b-256 ecdafd59106b6f18be2ae2405760df1b9bbcbbbeca618e255d1eb561a6c67b62

See more details on using hashes here.

Provenance

The following attestation bundles were made for nkdsl-0.1.1a0.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.1a0-py3-none-any.whl.

File metadata

  • Download URL: nkdsl-0.1.1a0-py3-none-any.whl
  • Upload date:
  • Size: 146.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for nkdsl-0.1.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 cc568788dc80329414bc82d709cbd9ed1a5d0172e7bf35333f3f37085c8cb985
MD5 54f2246eec235bae27713ba8d2c9e7a5
BLAKE2b-256 9754131ad463761e05b7f19e88f10a14815a1bde3560ea2ae3b26e413d580b3c

See more details on using hashes here.

Provenance

The following attestation bundles were made for nkdsl-0.1.1a0-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