Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
287 changes: 133 additions & 154 deletions CHANGELOG.md

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pip install "bloqade-tsim[cuda13]" # or bloqade-tsim[cuda12]
## Quick Start
An introductory tutorial is available [here](docs/demos/encoding_demo.ipynb). Please also refer to the [documentation](https://tsim.mintlify.app/).

For many existing scripts, replacing `stim` with `tsim` should just work. Tsim mirrors the Stim API and supports all [Stim instructions](https://github.com/quantumlib/Stim/wiki/Stim-v1.13-Gate-Reference), plus the [non-Clifford instructions](#supported-instructions) listed below.
For many existing scripts, replacing `stim` with `tsim` should just work. Tsim mirrors the Stim API and supports all [Stim instructions](https://github.com/quantumlib/Stim/blob/v1.16.0/doc/gates.md), plus the [non-Clifford instructions](#supported-instructions) listed below.

```python
import tsim
Expand Down Expand Up @@ -121,7 +121,7 @@ Note that this feature should be used carefully. If detectors or observables are

## Supported Instructions

Tsim supports all [Stim instructions](https://github.com/quantumlib/Stim/wiki/Stim-v1.13-Gate-Reference). In addition, Tsim defines the following non-Clifford instructions. Angles are given in units of π (half-turns).
Tsim supports all [Stim instructions](https://github.com/quantumlib/Stim/blob/v1.16.0/doc/gates.md). In addition, Tsim defines the following non-Clifford instructions. Angles are given in units of π (half-turns).

| Instruction | Targets | Action |
|---|---|---|
Expand Down Expand Up @@ -149,10 +149,12 @@ CCX 0 1 2 # Toffoli with controls 0, 1 and target 2
Tsim 1.0 changes some defaults and APIs. See the [changelog](CHANGELOG.md) for the full list.

- Samplers default to `strategy="active_statevector"`. Pass `strategy="cat5"` for the previous behavior.
- With a `postselection_mask`, `CompiledDetectorSampler.sample` returns only the surviving shots, so the acceptance rate is the number of returned rows divided by `shots` (`len(result[0]) / shots` with `separate_observables=True`).
- Samples for a fixed seed differ from earlier versions.
- Tsim requires Python 3.11 or later and `stim>=1.15.0`.
- `Circuit.get_graph()` and `Circuit.get_sampling_graph()` return `zxparam.Graph`; Tsim no longer depends on `pyzx-param`.
- `Circuit.to_matrix()` is removed. `Circuit.to_tensor()` returns the circuit's channel and needs `zxparam[quimb]`.
- The `"pyzx"`, `"pyzx-dets"` and `"pyzx-meas"` diagram types are deprecated in favor of `"zx"`, `"zx-dets"` and `"zx-meas"`.
- The `"pyzx"`, `"pyzx-dets"` and `"pyzx-meas"` diagram types are now `"zx"`, `"zx-dets"` and `"zx-meas"`.


## Publications Using Tsim
Expand Down
6 changes: 3 additions & 3 deletions docs/demos/overview.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"source": [
"### Clifford Instructions\n",
"\n",
"Tsim supports all instructions [supported by Stim](https://github.com/quantumlib/Stim/wiki/Stim-v1.13-Gate-Reference). Below, we show the standard generating set of Clifford gates:"
"Tsim supports all instructions [supported by Stim](https://github.com/quantumlib/Stim/blob/v1.16.0/doc/gates.md). Below, we show the standard generating set of Clifford gates:"
]
},
{
Expand Down Expand Up @@ -204,7 +204,7 @@
"source": [
"### Measurement and Reset instructions\n",
"\n",
"Tsim supports all collapsing gates [supported by Stim](https://github.com/quantumlib/Stim/wiki/Stim-v1.9-Gate-Reference#collapsing-gates)."
"Tsim supports all collapsing gates [supported by Stim](https://github.com/quantumlib/Stim/blob/v1.16.0/doc/gates.md#collapsing-gates)."
]
},
{
Expand Down Expand Up @@ -369,7 +369,7 @@
"source": [
"### Noise Channels\n",
"\n",
"Tsim supports all noise channels [supported by Stim](https://github.com/quantumlib/Stim/wiki/Stim-v1.9-Gate-Reference#noise-channels).\n",
"Tsim supports all noise channels [supported by Stim](https://github.com/quantumlib/Stim/blob/v1.16.0/doc/gates.md#noise-channels).\n",
"\n",
"The `X_ERROR(p)` instruction is a `X` instruction that is applied with probability `p`."
]
Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A detailed description of Tsim is given in [arXiv:2604.01059](https://arxiv.org/

## Quick Start

An introductory tutorial is available [here](demos/encoding_demo.ipynb). For many existing scripts, replacing `stim` with `tsim` should just work. Tsim mirrors the Stim API and supports all [Stim instructions](https://github.com/quantumlib/Stim/wiki/Stim-v1.13-Gate-Reference), plus the [non-Clifford instructions](#supported-instructions) listed below.
An introductory tutorial is available [here](demos/encoding_demo.ipynb). For many existing scripts, replacing `stim` with `tsim` should just work. Tsim mirrors the Stim API and supports all [Stim instructions](https://github.com/quantumlib/Stim/blob/v1.16.0/doc/gates.md), plus the [non-Clifford instructions](#supported-instructions) listed below.

```python
import tsim
Expand Down Expand Up @@ -106,7 +106,7 @@ Note that this feature should be used carefully. If detectors or observables are

## Supported Instructions

Tsim supports all [Stim instructions](https://github.com/quantumlib/Stim/wiki/Stim-v1.13-Gate-Reference). In addition, Tsim defines the following non-Clifford instructions. Angles are given in units of π (half-turns).
Tsim supports all [Stim instructions](https://github.com/quantumlib/Stim/blob/v1.16.0/doc/gates.md). In addition, Tsim defines the following non-Clifford instructions. Angles are given in units of π (half-turns).

| Instruction | Targets | Action |
|---|---|---|
Expand Down
14 changes: 7 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "bloqade-tsim"
version = "0.1.5"
description = "A low-magic universal quantum circuit sampler based on ZX stabilizer rank decomposition"
version = "1.0.0"
description = "A fast sampler for noisy quantum circuits with non-Clifford gates, built on the ZX-calculus"
authors = [
{ name = "Rafael Haenel", email = "rhaenel@quera.com" },
{ name = "Chen Zhao", email = "czhao@quera.com" },
Expand All @@ -19,7 +19,7 @@ keywords = [
"quantum-error-correction",
]
classifiers = [
"Development Status :: 4 - Beta",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
Expand All @@ -33,12 +33,12 @@ classifiers = [
]

dependencies = [
"equinox>=0.11.0",
"equinox>=0.11.5",
"ipywidgets>=8.0.0",
"jax>=0.4.38",
"lxml>=5.0.0",
"numba>=0.61",
"numpy>=1.25.0",
"numpy>=2.0",
"psutil>=5.9.0",
"stim>=1.15.0",
"stim-timeline-text>=0.1.0",
Expand All @@ -47,13 +47,13 @@ dependencies = [

[project.urls]
Homepage = "https://github.com/QuEraComputing/tsim"
Documentation = "https://queracomputing.github.io/tsim/latest"
Documentation = "https://tsim.mintlify.app/"
Repository = "https://github.com/QuEraComputing/tsim"
Issues = "https://github.com/QuEraComputing/tsim/issues"

[project.optional-dependencies]
cuda12 = ["jax[cuda12]>=0.4.38"]
cuda13 = ["jax[cuda13]>=0.6.0"]
cuda13 = ["jax[cuda13]>=0.7.0"]

[build-system]
requires = ["hatchling"]
Expand Down
2 changes: 1 addition & 1 deletion src/tsim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
module is internal and may change without notice, even where it is importable.
"""

__version__ = "0.1.5"
__version__ = "1.0.0"

from tsim.circuit import Circuit as Circuit
from tsim.sampler import (
Expand Down
19 changes: 5 additions & 14 deletions src/tsim/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from __future__ import annotations

import warnings
from collections.abc import Mapping
from typing import (
TYPE_CHECKING,
Expand Down Expand Up @@ -42,7 +41,7 @@
{"MPP", "SPP", "SPP_DAG", "OBSERVABLE_INCLUDE", "TPP", "TPP_DAG", "R_PAULI"}
)

_DEPRECATED_DIAGRAM_TYPES: dict[str, Literal["zx", "zx-dets", "zx-meas"]] = {
_REMOVED_DIAGRAM_TYPES = {
"pyzx": "zx",
"pyzx-dets": "zx-dets",
"pyzx-meas": "zx-meas",
Expand Down Expand Up @@ -741,9 +740,6 @@ def diagram(
"zx",
"zx-dets",
"zx-meas",
"pyzx",
"pyzx-dets",
"pyzx-meas",
"timeline-svg",
"timeslice-svg",
"timeline-text",
Expand All @@ -766,8 +762,6 @@ def diagram(
used to compute probabilities of detectors and observables.
"zx-meas": A zxparam D3 drawing of the reduced ZX graph that is
used to compute probabilities of measurements.
"pyzx", "pyzx-dets", "pyzx-meas": Deprecated aliases for
"zx", "zx-dets" and "zx-meas".
"timeline-svg": An SVG image of the operations applied by
the circuit over time. Includes annotations showing the
measurement record index that each measurement writes
Expand Down Expand Up @@ -824,14 +818,11 @@ def diagram(
viewer instead of as raw text.

"""
if type in _DEPRECATED_DIAGRAM_TYPES:
replacement = _DEPRECATED_DIAGRAM_TYPES[type]
warnings.warn(
f"Diagram type {type!r} is deprecated; use {replacement!r} instead.",
DeprecationWarning,
stacklevel=2,
if type in _REMOVED_DIAGRAM_TYPES:
replacement = _REMOVED_DIAGRAM_TYPES[type]
raise ValueError(
f"Diagram type {type!r} was removed in Tsim 1.0; use {replacement!r}."
)
type = replacement
if type in [
"timeline-svg",
"timeslice-svg",
Expand Down
11 changes: 3 additions & 8 deletions test/unit/test_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1095,15 +1095,10 @@ def test_diagram_zx_with_zero_scale_draws(type: Literal["zx", "zx-meas", "zx-det


@pytest.mark.parametrize("type", ["pyzx", "pyzx-dets", "pyzx-meas"])
def test_pyzx_diagram_types_are_deprecated_aliases(
type: Literal["pyzx", "pyzx-dets", "pyzx-meas"],
):
def test_removed_pyzx_diagram_types_raise(type: str):
replacement = type.replace("pyzx", "zx")
with pytest.warns(
DeprecationWarning, match=re.escape(f"use {replacement!r} instead")
):
html = Circuit("H 0\nM 0").diagram(type=type)
assert "renderZx" in html._repr_html_()
with pytest.raises(ValueError, match=re.escape(f"use {replacement!r}")):
Circuit("H 0\nM 0").diagram(type=type) # type: ignore[arg-type]


def test_append():
Expand Down
8 changes: 4 additions & 4 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading