-
Notifications
You must be signed in to change notification settings - Fork 0
83 update python interface #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
169f596
Derive Clone for StrategyEnums
2f68e6c
Add new wrapper for Qiskit
5e41391
Stashed implementation
26a57d3
Format clifford tableau
832fe13
Format files
f46f8ad
Add traililng white space
d6da256
Update pyi file
c30603a
Remove unused test
512a01a
Remove stub of function
fe970b5
Add test to ensure qiskit circuit is built
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| pub(crate) mod qiskit; | ||
|
|
||
| extern crate pyo3; | ||
| extern crate pyo3_ffi; | ||
|
|
||
| use std::collections::VecDeque; | ||
|
|
||
| use pyo3::prelude::*; | ||
| use synir::{ | ||
| data_structures::CliffordTableau, | ||
| ir::{ | ||
| clifford_tableau::CliffordTableauSynthStrategy, | ||
| pauli_exponential::{PauliExponential, PauliExponentialSynthesizer}, | ||
| pauli_polynomial::PauliPolynomialSynthStrategy, | ||
| CliffordGates, Gates, Synthesizer, | ||
| }, | ||
| }; | ||
|
|
||
| use crate::wrapper::qiskit::QiskitSynIR; | ||
|
|
||
| #[pyclass] | ||
| pub struct PyPauliExponential { | ||
| pe: PauliExponential, | ||
| pauli_strategy: PauliPolynomialSynthStrategy, | ||
| tableau_strategy: CliffordTableauSynthStrategy, | ||
| } | ||
|
|
||
| #[pymethods] | ||
| impl PyPauliExponential { | ||
| #[new] | ||
| pub fn new(num_qubits: usize) -> Self { | ||
| let pe = PauliExponential::new(VecDeque::from(vec![]), CliffordTableau::new(num_qubits)); | ||
| Self { | ||
| pe, | ||
| pauli_strategy: PauliPolynomialSynthStrategy::Naive, | ||
| tableau_strategy: CliffordTableauSynthStrategy::PermRowCol, | ||
| } | ||
| } | ||
|
|
||
| pub fn synthesize_to_qiskit(&mut self, circuit: &mut QiskitSynIR) { | ||
| synthesize(self, circuit); | ||
| } | ||
|
|
||
| pub fn set_pauli_strategy(&mut self, strategy: String) { | ||
| match strategy.as_str() { | ||
| "Naive" => self.pauli_strategy = PauliPolynomialSynthStrategy::Naive, | ||
| _ => panic!("Unknown Pauli polynomial synthesis strategy: {}", strategy), | ||
| } | ||
| } | ||
|
|
||
| pub fn set_tableau_strategy(&mut self, strategy: String) { | ||
| match strategy.as_str() { | ||
| "Naive" => self.tableau_strategy = CliffordTableauSynthStrategy::Naive, | ||
| "PermRowCol" => self.tableau_strategy = CliffordTableauSynthStrategy::PermRowCol, | ||
| _ => panic!("Unknown Clifford tableau synthesis strategy: {}", strategy), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| pub fn synthesize<G>(pe: &mut PyPauliExponential, circuit: &mut G) | ||
| where | ||
| G: CliffordGates + Gates, | ||
| { | ||
| let mut synth = PauliExponentialSynthesizer::from_strategy( | ||
| pe.pauli_strategy.clone(), | ||
| pe.tableau_strategy.clone(), | ||
| ); | ||
| let pe = std::mem::take(&mut pe.pe); | ||
| synth.synthesize(pe, circuit) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.