Skip to content

Feature/postselect-mbqc-demo - #295

Closed
Roll249 wants to merge 3 commits into
TeamGraphix:masterfrom
Roll249:feature/postselect-mbqc-demo
Closed

Feature/postselect-mbqc-demo#295
Roll249 wants to merge 3 commits into
TeamGraphix:masterfrom
Roll249:feature/postselect-mbqc-demo

Conversation

@Roll249

@Roll249 Roll249 commented Jun 4, 2025

Copy link
Copy Markdown

Before submitting, please check the following:

  • Make sure you have tests for the new code and that test passes (run nox)
  • If applicable, add a line to the [unreleased] part of CHANGELOG.md, following keep-a-changelog.
  • Format added code by ruff
    • See CONTRIBUTING.md for more details
  • Make sure the checks (github actions) pass.

Then, please fill in below:

Context (if applicable):

Description of the change:

Related issue:

@Roll249

Roll249 commented Jun 4, 2025

Copy link
Copy Markdown
Author

@mgarnier59 could you check that please

@EarlMilktea

Copy link
Copy Markdown
Contributor

@Roll249 Could you remove graph_state.png ?

@codecov

codecov Bot commented Jun 5, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 51.85185% with 13 lines in your changes missing coverage. Please review.

Project coverage is 79.68%. Comparing base (92031c9) to head (b63cd8f).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
graphix/simulator.py 38.46% 8 Missing ⚠️
graphix/sim/base_backend.py 42.85% 4 Missing ⚠️
graphix/sim/tensornet.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #295      +/-   ##
==========================================
- Coverage   79.86%   79.68%   -0.18%     
==========================================
  Files          36       36              
  Lines        5433     5450      +17     
==========================================
+ Hits         4339     4343       +4     
- Misses       1094     1107      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Roll249

Roll249 commented Jun 5, 2025

Copy link
Copy Markdown
Author

@EarlMilktea oke i have delete that

@mgarnier59

Copy link
Copy Markdown
Contributor

Hi @Roll249 ,
Thanks for your contribution. I will start having a look at what you did. Can you please detail what you have done and how it relates to the proposed reference?
Note that we will soon merge a postselection mechanism.

Thanks!

@Roll249

Roll249 commented Jun 5, 2025

Copy link
Copy Markdown
Author

This pull request introduces post-selection functionality for measurements in the Graphix quantum simulator, allowing users to specify desired measurement outcomes for certain nodes. The changes include updates to the simulator's API, backend logic, and an example script demonstrating the feature.

New Feature: Post-Selection Support

  • graphix/pattern.py: Added a postselect parameter to the simulate_pattern method, enabling users to specify a dictionary of node indices and their desired measurement outcomes. The parameter is passed to the PatternSimulator for execution. [1] [2] [3]
  • graphix/simulator.py: Updated the PatternSimulator class to handle the postselect parameter. Included logic in the run method to enforce the specified outcomes during measurement, even in noisy scenarios. [1] [2] [3] [4]

Backend Enhancements for Post-Selection

  • graphix/sim/base_backend.py: Modified the measure method to accept a forced_result parameter, allowing the backend to enforce specific measurement outcomes.
  • graphix/sim/tensornet.py: Updated the measure method to support forced_result for tensor network simulations, ensuring compatibility with the new post-selection feature. [1] [2]

Example Script

  • examples/postselected_measurement.py: Added a new example script demonstrating how to create a simple graph state, perform a measurement with post-selection, and visualize the resulting state. This serves as a prototype for simulating non-unitary gates.

@Roll249

Roll249 commented Jun 6, 2025

Copy link
Copy Markdown
Author

@EarlMilktea check it

@EarlMilktea

EarlMilktea commented Jun 6, 2025

Copy link
Copy Markdown
Contributor

@EarlMilktea check it

@Roll249 Please resolve CI errors (as for mypy-pyright you can ignore it for now)

Comment on lines +16 to +18
warnings.filterwarnings("ignore", message="Couldn't find `optuna`", module="cotengra")
warnings.filterwarnings("ignore", message="Couldn't import `kahypar`", module="cotengra")
warnings.filterwarnings("ignore", message="Couldn't find `optuna`, `cmaes`, or `nevergrad`", module="cotengra")

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.

Please remove.

Comment thread graphix/pattern.py

def simulate_pattern(
self, backend: str = "statevector", input_state: BasicStates = BasicStates.PLUS, **kwargs
self, backend: str = "statevector", input_state: BasicStates = BasicStates.PLUS, postselect: dict = None, **kwargs

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.

Please use collections.abc.Mapping instead.

Comment thread graphix/simulator.py
self.backend.entangle_nodes(edge=cmd.nodes)
elif cmd.kind == CommandKind.M:
self.__measure_method.measure(self.backend, cmd)
# Post-selection logic

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.

Please add extra tests that cover your contributions.

@thierry-martinez

Copy link
Copy Markdown
Collaborator

We already implemented a more general approach for branch selection that we did not released yet, sorry: I opened the PR #300. Anyway, this is only remotely related to #278.

@Roll249 Roll249 closed this Jun 10, 2025
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.

4 participants