Adds a simple spin Wigner function calculator example#3
Adds a simple spin Wigner function calculator example#3markjeveritt wants to merge 2 commits intoQiskit:masterfrom markjeveritt:master
Conversation
Needs updating following mine and Russell's conversation with Lev to use the jobs interface and to be more general in its construction so that it can become an effective library routine rather than simple calculator.
|
This is exactly the kind of thing we'd like to bring into the sdk. |
|
Very happy to hear this - how do we proceed please? |
|
Hi @markjeveritt I have delayed looking at this as we were changing QISKit. Now we have finished r0.2 I would like to help you add this to QISKit. I see that you have a function for Wigner function that generates the set of experiments needed to make the plot. I would like to have this also work with data from local simulators so i want to abstract this away from the backend and make it work on data that is generated either by simulation or experiment. I think the way to do this is add this to a new folder that we call plotters or tomography as it is a more advance plotter than basic plotters (and general state tomography for example we will put in there as well) and it will have both the tools to generate the quantum program for this state and then plot this quantum program. Let me think about this for a bit and I will comment here with a suggestion soon. @awcross1 and @ismaelfaro what do you think. Do you feel that all tomography tools should go in a folder for tomography or are the a method for a quantum program to plot or a tool extension like the optimization one i am currently working on. I have a concern that since we changed QISKit so much it might be hard to merge this in or make edits on it so I might have to copy this into a working branch to work with the new version of QISKit and close this request to get it in. |
Creates GHZ states but may not work for two qubits and has problems above five.
|
Hi @jaygambetta - we guessed something like this had caused the delay - no problem - we were very excited to hear the 16/17 qubit announcement. Russell Rundle has been looking at this and we think we have batched code that will work with r0.2. It works for five quits but we have been having trouble getting it to work in the simulator for more (we were hoping to rush out a nice example demonstrating your machine could make a 16qubit GHZ or something like this). We have updated the code to reflect these changes (example plot attached) I agree we want to abstract away from the backend - its good practice to separate concerns. A folder for plotters and tomography would make sense but just so you know we think we may be able to also derive some good new entanglement measures (working on this with Todd Tilma but its not ready yet). Not sure if this effects your planning (folder by method, application or more layers?). |
|
Hi @markjeveritt, Now that we have the next release up we can come back to this, sorry for the wait! Unfortunately some things have changed in how we’ve structured qiskit so this would require some modifications. Some of the functions themselves would be good to add some to our new tools modules with a few changes, and then if you’re interested it would be nice for you to make a Jupyter notebook demonstrating this which could be added to qiskit-tutorial. Now onto the specifics. Our philosophy is for these types of modules to be abstracted in the following way:
I’d suggest looking at the new tomography module and the state_tomography tutorial notebook for an idea of how to implement this. In the state tomography case we break it down into three functions:
For the Wigner code you code I would suggest breaking this into something like For specific comments for you code:
The mundane: to keep the codebase organised and well documented we need
After all that, we look forward to your resubmission to help flesh out the qiskit tool! (Sorry if it was a bit long winded) If you need help or have further questions with regards to any of this feel free to send me an email or comment here. Cheers |
|
No worries - I quite understand. Just to say we are working on it. Thank you for the detailed instructions of what we need to do. We are not masters of Git - how do we make sure that our pull request goes to QISKit:dev please? Also - would it be ok to include author information in the Jupiter notebook or somewhere else please (some record of our contribution would be potentially useful for us for a research assessment exercise we have to go though here). Cheers Mark |
|
Hi @markjeveritt, You can edit the pull request to change branch like this. Though it might make more sense to close this request and start a new one when you're ready. I believe its fine to include author/affiliation information in an example Jupyter notebook in the qiskit-tutorials, and we will maintain a list of contributors to this repo with the Github history keeping track of who submits what. Cheers, |
|
I am trying to upload our files but cannot see the branch QISKit:dev (I see other branches but not this one). What should we do please? Best wishes Mark |
|
Hi @markjeveritt , there have been a number of changes related to the organization of the repository - in practice, it means your pull request should be issued against However, there have also been a number of commits and changes since your PR was issued, which caused your fork's
Alternatively, as Chris and Jay suggested, it might be cleaner to just "start from scratch" on a new fork, and issue a new PR - please let us know if you need any comments at any step! |
|
Opening new pull request to try again |
|
Re-issued as #132. |
rename channel bank->store and change its interface
Add pro forma tests
* optimize qubit usage in Pwl * optimize helper qubits in poly PR * optimize weighted adder * add reno * Optimize ancilla (#3) * added a method that implements piecewise polynomials that extends the piecewise linear class functionality, and a class to approximate the inverse function * release notes * updated header * removed header encoding * fixed ancilla * remove old files * Apply suggestions from code review Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: Julien Gacon <gaconju@gmail.com> * don't include last breakpoint Co-authored-by: Luciano Bello <luciano.bello@ibm.com> Co-authored-by: Almudena Carrera Vazquez <almudenacarreravazquez@hotmail.com> Co-authored-by: Kevin Krsulich <kevin.krsulich@ibm.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
first pass on adding CircuitElement mixin to Clifford by @alexanderivrii
VarQRTE Fix
…tes-new adding commutes method to QubitSparsePauli
Visualization matrix groundwork
…on test Covers the case where both the circuit and the template carry a nonzero global_phase simultaneously, confirming that fixes Qiskit#2 (circuit phase preserved across substitution) and Qiskit#3 (per-match template phase subtracted) compose correctly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
#15943) * fix(transpiler): TemplateOptimization drops circuit global_phase on substitution circuit_to_dagdependency did not copy global_phase when converting a template QuantumCircuit to DAGDependency, so template phases were lost before matching. TemplateSubstitution.run_dag_opt also constructed a new DAGDependency for the optimised output without inheriting the original circuit's global_phase, resetting it to zero whenever at least one substitution was applied. Fixed by copying global_phase in circuit_to_dagdependency and seeding dag_dep_opt.global_phase from the circuit DAG at construction time. Also added the per-match phase subtraction (Fix 3) for when templates with nonzero global_phase become accepted via the identity check fix in #14538. Fixes #14537. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(transpiler): TemplateOptimization drops circuit global_phase on substitution circuit_to_dagdependency did not copy global_phase when converting a template QuantumCircuit to DAGDependency, so template phases were lost before matching. TemplateSubstitution.run_dag_opt also constructed a new DAGDependency for the optimised output without inheriting the original circuit's global_phase, resetting it to zero whenever at least one substitution was applied. Additionally, when a template carries a nonzero global_phase phi_T (gate content implements e^{-i*phi_T} * I while the full operator is I), the per-match phase contribution was not being subtracted from the output circuit. Fixes #14537. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * style: black reformat test_template_matching.py Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs: use RST hyperlink for issue reference in release note The :issue: role is not available in this project's Sphinx config. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test(transpiler): add combined circuit+template global_phase regression test Covers the case where both the circuit and the template carry a nonzero global_phase simultaneously, confirming that fixes #2 (circuit phase preserved across substitution) and #3 (per-match template phase subtracted) compose correctly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test(transpiler): use assertEqual for Operator comparisons in template tests Replace assertTrue(Operator(x) == Operator(y)) with assertEqual(Operator(x), Operator(y)) so that assertion failures show the actual vs expected values rather than just "False is not True". Also shorten multi-line test docstrings to concise one-liners. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Address review feedback on template optimization global phase fix - Simplify comment on global phase update in template_substitution.py - Split release note into per-bug files; add fix-circuit-to-dagdependency-global-phase-14537.yaml - Update tests: use issue reproducer (4-gate circuit) in test_template_nonzero_global_phase_applied_to_circuit, merge single/multiple match tests, drop modulo from assertAlmostEqual Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix test assertions and remove duplicate test - Fix test_circuit_and_template_both_have_nonzero_global_phase expected value from np.pi/4 to 7*np.pi/12 (pi/3 + pi/4) - Remove duplicate test_circuit_global_phase_preserved_with_multiple_template_matches - Update test_template_nonzero_global_phase_applied_to_circuit to use Operator equivalence instead of phase/count assertions since partial template match does occur Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Update releasenotes/notes/fix-circuit-to-dagdependency-global-phase-14537.yaml Co-authored-by: Julien Gacon <gaconju@gmail.com> * Update releasenotes/notes/fix-template-optimization-global-phase-14537.yaml Co-authored-by: Julien Gacon <gaconju@gmail.com> * Update test/python/transpiler/test_template_matching.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Update test/python/transpiler/test_template_matching.py Actually I removed all reference to "Regression test" in the test descriptions based on this comment #15943 (comment) Co-authored-by: Julien Gacon <gaconju@gmail.com> * Remove 'Regression test' from docstring per review feedback Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Julien Gacon <gaconju@gmail.com>

Needs updating following mine and Russell's conversation with Lev to use the jobs interface and to be more general in its construction so that it can become an effective library routine rather than simple calculator.