Add noise model API for Stim circuit compilation#160
Open
Add noise model API for Stim circuit compilation#160
Conversation
Enhance noise_model.py with detailed NumPy-style docstrings including: - Module-level documentation with usage examples - NoiseKind enum descriptions for each event type - NoiseOp and NoiseEvent parameter documentation with examples - NoiseModel abstract class with comprehensive examples and notes Add Sphinx documentation: - Create docs/source/noise_model.rst for API reference - Add noise_model to module reference in references.rst Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…odel] - Replace string-based noise API with typed NoiseOp dataclasses (PauliChannel1, PauliChannel2, HeraldedPauliChannel1, HeraldedErase, RawStimOp) - Add typed event classes (PrepareEvent, EntangleEvent, MeasureEvent, IdleEvent) with NodeInfo and Coordinate for position-dependent noise models - Change NoiseModel method return type from Iterable[NoiseOp] to Sequence[NoiseOp] for covariance (allows subclasses to return Sequence[PauliChannel1] etc.) - Update stim_compile to accept Sequence[NoiseModel] instead of single NoiseModel for composing multiple independent noise sources - Add NoisePlacement enum (AUTO, BEFORE, AFTER) for controlling noise insertion - Add comprehensive tests for noise_model module Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update module docstrings to use the standard "This module provides:" format with a list of public exports. Replace all double backticks with single backticks for inline code references to match the project's documentation style conventions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use double backticks for non-Python references (Stim instruction names, parameter names, example values) and proper Sphinx roles (:data:) for module constants. Single backticks remain only for Python object cross- references. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add utility function that creates a probability dict with all 15 Pauli pairs having equal probability p/15. Update the module docstring example to use this utility for proper 2-qubit depolarizing noise instead of the simplified ZZ-only version. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add utility function that creates px, py, pz probabilities each set to p/3 for single-qubit depolarizing channel. Update the module docstring example to use both depolarize1_probs and depolarize2_probs. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace old parameter-based noise API with the new NoiseModel classes: - Use DepolarizingNoiseModel instead of p_depol_after_clifford - Use MeasurementFlipNoiseModel instead of p_before_meas_flip Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #160 +/- ##
==========================================
+ Coverage 84.19% 85.41% +1.22%
==========================================
Files 22 23 +1
Lines 2606 2956 +350
Branches 476 513 +37
==========================================
+ Hits 2194 2525 +331
- Misses 308 319 +11
- Partials 104 112 +8 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a571d0fef9
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NoiseModelAPI for injecting custom noise into Stim circuits during pattern compilationNoiseOpdataclasses (PauliChannel1,PauliChannel2,HeraldedPauliChannel1,HeraldedErase,RawStimOp,MeasurementFlip)DepolarizingNoiseModelandMeasurementFlipNoiseModelimplementationsdepolarize1_probs()anddepolarize2_probs()utility functionsstim_compile()to acceptnoise_modelsparameter withSequence[NoiseModel]supportTest plan
🤖 Generated with Claude Code