Skip to content

Enhance CompiledDetectorSampler.sample with postselection support#157

Open
axif0 wants to merge 2 commits into
QuEraComputing:mainfrom
axif0:postselectionn
Open

Enhance CompiledDetectorSampler.sample with postselection support#157
axif0 wants to merge 2 commits into
QuEraComputing:mainfrom
axif0:postselectionn

Conversation

@axif0

@axif0 axif0 commented Jun 7, 2026

Copy link
Copy Markdown

Added an optional postselection_mask argument to CompiledDetectorSampler.sample for improved simulation efficiency. This allows for the discarding of shots based on masked detectors, optimizing performance by skipping the JAX autoregressive loop for direct discarded shots.

Closes: #41

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 37c180c842

ℹ️ 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".

Comment thread src/tsim/sampler.py Outdated

discarded = (det_cols & postselect_direct).any(axis=1)

result[shot_idx : shot_idx + chunk] = direct_full

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Zero direct observables on skipped discarded rows

When a masked direct detector discards a shot, this copies direct_full into the entire output row before skipping JAX, so any independent direct observable columns are returned with their sampled values even though the documented partial-row contract says discarded rows retain direct detector columns and fill all other columns with False. This shows up with append_observables/separate_observables on circuits where one direct detector is postselected and a different observable is also direct; the observable bits for rows that callers are told are partial can be nonzero and are not later reference-XORed.

Useful? React with 👍 / 👎.

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.

feat: Support postselection masks

1 participant