Skip to main content

Rust acceleration core for g2n (quantum statevector kernels, token sampling). Optional: g2n falls back to pure torch without it.

Project description

g2n-native

Rust acceleration core for g2n: in-place quantum statevector kernels and fast token sampling.

You normally don't install this directly — pip install g2n[native] pulls it in on supported platforms (Linux x86_64). g2n detects it at import time and falls back to its pure-torch paths if it's missing or G2N_NATIVE=0 is set.

API

  • apply_gates(psi, gates) — apply a gate list in place to a (B, 2**n) complex64 C-contiguous statevector. Each gate is (bit_positions, matrix) with bit = n-1-qubit; matrices are (2,2)/(4,4) shared or (B,2,2)/(B,4,4) per batch row.
  • sample_topp(logits, temperature, top_p, top_k=0, seed=0) — sample one token id from a (V,) f32 logits vector. temperature <= 0 means argmax. Deterministic for a given seed.

Parity with the torch reference paths is enforced by tests/test_native_parity.py in the g2n repo.

Building

maturin build --release --zig --compatibility manylinux_2_28

Proprietary — © g2n.dev.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

g2n_native-0.1.0-cp310-abi3-manylinux_2_28_x86_64.whl (282.9 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ x86-64

File details

Details for the file g2n_native-0.1.0-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for g2n_native-0.1.0-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0f596c93bd89fbde071caecfa9d3465df9eef25f6c0df6a2fdc64a97cc5eb55c
MD5 d2c16b130a5ecbeb2418d63b8052ed62
BLAKE2b-256 a1c8a3ef3764a6fcf3da28d1682d9fd414db91ea33730836ff65971ac6e3ac9a

See more details on using hashes here.

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