Metadata-Version: 2.4
Name: g2n-native
Version: 0.1.0
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Operating System :: POSIX :: Linux
Summary: Rust acceleration core for g2n (quantum statevector kernels, token sampling). Optional: g2n falls back to pure torch without it.
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Documentation, https://g2n.dev/docs/
Project-URL: Homepage, https://g2n.dev

# g2n-native

Rust acceleration core for [g2n](https://g2n.dev): 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

```sh
maturin build --release --zig --compatibility manylinux_2_28
```

Proprietary — © g2n.dev.

