Skip to content

Define the public API and qualify seed reproducibility for 1.0.0 - #268

Merged
rafaelha merged 5 commits into
mainfrom
public-api-1.0
Nov 4, 2026
Merged

rafaelha merged 5 commits into
mainfrom
public-api-1.0

Conversation

@rafaelha

@rafaelha rafaelha commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Defines what tsim 1.0.0 commits to under semantic versioning.

Public API

  • tsim.__all__ = ["Circuit", "CompiledDetectorSampler", "CompiledMeasurementSampler"]. These are the only objects semver covers. tsim.__init__'s docstring and the docs index ("API stability") say that every other module is internal, even where it is importable.
  • New tsim.experimental re-exports CompiledStateProbs, SteaneEncoder and ColorEncoder5, which the tutorials use. They may change in any release. The old import paths still work.
  • docs/scripts/gen_ref_nav.py no longer generates a page per module. The API reference has two pages, "Tsim API" (the three public objects) and "Experimental".
  • overview.ipynb and magic_state_distillation.ipynb import from tsim.experimental.

Sampling strategies

Only strategy="active_statevector" is fully stable. The stabilizer rank strategies ("cat5", "bss", "cutting") are provisional: they may be removed in a minor release, after at least one minor release in which they emit a DeprecationWarning. The docstrings say only "provisional"; the policy is in the "API stability" section of docs/index.md and in the CHANGELOG.

Seed reproducibility

The seed docstrings of compile_sampler, compile_detector_sampler, the sampler classes and CompiledStateProbs now say that a seed reproduces its samples only with the same Tsim version and backend (CPU or GPU). Without this, changing a random stream (as #263 did), or adding a float32 GPU executor (#219), would technically be a breaking change.

Test plan

  • uv run pytest test/unit: 2072 passed. Includes a new test/unit/test_public_api.py.
  • pre-commit (black, isort, ruff, pyright, codespell)
  • mkdocs build from a clean checkout. The tutorials run, and the reference contains only tsim.Circuit, the two samplers and the tsim.experimental objects.

🤖 Generated with Claude Code

Copilot AI balanced review requested due to automatic review settings November 4, 2026 11:14
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T11:15:42.632339Z fdefd59 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.2
Preview removed because the pull request was closed.
2026-11-04 13:29 UTC

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Removing the base-class reference entry leaves inherited encoder operations undocumented because inherited-member rendering is not enabled, including methods used by the distillation tutorial.

1 open issue
What changed in this PR

This PR defines Tsim’s stable API for 1.0.0 and clarifies seed reproducibility guarantees, while separating experimental helpers from the semantic-versioning contract.

Changes:

  • Declares three stable public objects and adds experimental re-exports with API tests.
  • Limits the generated reference to public and experimental objects and updates tutorial imports.
  • Documents that seeded samples may differ across Tsim versions and CPU/GPU backends.
File Description
test/​unit/​test_public_api.py Tests public exports and experimental aliases.
src/​tsim/​sampler.py Qualifies seed reproducibility in sampler docstrings.
src/​tsim/​experimental.py Re-exports three experimental helpers.
src/​tsim/​circuit.py Updates compilation-method seed documentation.
src/​tsim/​__init__.py Declares stable exports and API boundaries.
README.md Documents stability guarantees and migration guidance.
docs/​scripts/​gen_ref_nav.py Generates public and experimental reference pages.
docs/​index.md Adds API stability and seed guarantees.
docs/​demos/​overview.ipynb Uses the experimental probability-sampler import.
docs/​demos/​magic_state_distillation.ipynb Uses and labels the experimental encoder.
CHANGELOG.md Records API boundaries and reproducibility guarantees.

Review effort: Balanced

Comment thread docs/scripts/gen_ref_nav.py Resolved
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

☂️ Code Coverage

current status: ✅

Overall Coverage

Statements Covered Coverage Threshold Status
4784 4151 87% 0% 🟢

New Files

File Coverage Status
src/tsim/experimental.py 100% 🟢
TOTAL 100% 🟢

Modified Files

File Coverage Status
src/tsim/_init_.py 100% 🟢
src/tsim/circuit.py 95% 🟢
src/tsim/sampler.py 95% 🟢
TOTAL 96% 🟢

updated for commit: d8b01f0 by action🐍

The public API is tsim.Circuit, tsim.CompiledMeasurementSampler and
tsim.CompiledDetectorSampler (tsim.__all__). CompiledStateProbs,
SteaneEncoder and ColorEncoder5 are re-exported from tsim.experimental, which
may change in any release; every other module is internal. The API reference
documents only these objects, and the tutorials import from
tsim.experimental.

Seed docstrings say a seed reproduces its samples only with the same Tsim
version and backend (CPU or GPU).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 4, 2026 12:16
@rafaelha
rafaelha changed the base branch from release-1.0.0 to main November 4, 2026 12:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain in the public API boundary and seed-reproducibility changes.

1 open issue

Review effort: Balanced

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 4, 2026 12:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The encoder reference directives omit inherited members while removing the base class reference page, leaving both encoders’ usable methods undocumented.

1 open issue

Review effort: Balanced

- Seed docs name dependency versions and, for stabilizer-rank strategies,
  an explicit batch_size (the default depends on the free memory).
- The API reference shows inherited members and hides bases and inheritance
  diagrams, so the encoders list their methods and no internal class shows.
- docs/index.md links to the API reference; the public API test checks that
  every name in `tsim.__all__` resolves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 4, 2026 12:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the changes defining public API boundaries and clarifying reproducibility guarantees.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Only strategy="active_statevector" is stable; "cat5", "bss" and "cutting"
may change or be removed in any release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 4, 2026 12:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the public API boundary and reproducibility documentation changes.

No open issues 🎉

Review effort: Balanced

They may be removed in a minor release, after at least one minor release in
which they emit a DeprecationWarning. Docstrings say only that they are
provisional; docs/index.md and the changelog state the policy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 4, 2026 13:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the changes defining public API boundaries and documenting compatibility and seed-reproducibility guarantees.

No open issues 🎉

Review effort: Balanced

@rafaelha
rafaelha merged commit f1fcd50 into main Nov 4, 2026
10 checks passed
@rafaelha
rafaelha deleted the public-api-1.0 branch November 4, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants