Skip to content
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

Hyper-efficient unitary diamond distance #12343

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open

Conversation

owenagnel
Copy link

@owenagnel owenagnel commented May 5, 2024

Summary

Adds a new method unitary_diamond_distance to qiskit.quantum_info.operators.measures. This method implements a trick discussed in [1] for calculating the diamond norm (completely bounded trace norm) of a difference of unitary channels (also known as the diamond distance). The implementation is composed of three steps:

  • Find the eigenvalues of $U^† V$ where channel1 = $U \cdot U^†$ and channel2 = $V \cdot V^†$
  • Find the distance $d$ between origin and convex hull of eigenvalues
  • Plug this distance into $2\sqrt{1-d^2}$

Refer to issue #12341 for more details.

Citations

[1] D. Aharonov, A. Kitaev, and N. Nisan, “Quantum circuits with mixed states,” in Proceedings of the thirtieth annual ACM symposium on Theory of computing, pp. 20–30, 1998.

fixes #12341

@owenagnel owenagnel requested a review from a team as a code owner May 5, 2024 12:45
@qiskit-bot qiskit-bot added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label May 5, 2024
@CLAassistant
Copy link

CLAassistant commented May 5, 2024

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

One or more of the the following people are requested to review this:

  • @Qiskit/terra-core

@kevinsung
Copy link
Contributor

Is this ready for review? If not, please convert it to a draft PR.

@owenagnel
Copy link
Author

owenagnel commented May 5, 2024

Hi Kevin, I'm pretty happy with it as is. Went through the CONTRIBUTING.md document and hopefully checked off everything. Would be great if someone with more experience contributing could go through it quickly (only a couple changes). All tests and lifting are passing on my machine using tox.

@owenagnel owenagnel changed the title [WIP] Hyper-efficient unitary diamond distance Hyper-efficient unitary diamond distance May 5, 2024
@ShellyGarion ShellyGarion added the mod: quantum info Related to the Quantum Info module (States & Operators) label May 5, 2024
@owenagnel owenagnel requested a review from kevinsung May 8, 2024 08:39
qiskit/quantum_info/operators/measures.py Outdated Show resolved Hide resolved
qiskit/quantum_info/operators/measures.py Outdated Show resolved Hide resolved
qiskit/quantum_info/operators/measures.py Outdated Show resolved Hide resolved
qiskit/quantum_info/operators/measures.py Outdated Show resolved Hide resolved
qiskit/quantum_info/operators/measures.py Outdated Show resolved Hide resolved
qiskit/quantum_info/operators/measures.py Outdated Show resolved Hide resolved
qiskit/quantum_info/operators/measures.py Outdated Show resolved Hide resolved
test/python/quantum_info/operators/test_measures.py Outdated Show resolved Hide resolved
@owenagnel owenagnel requested a review from kevinsung May 8, 2024 22:00
@owenagnel owenagnel requested a review from kevinsung May 9, 2024 06:12
@owenagnel owenagnel requested a review from kevinsung May 9, 2024 11:51
kevinsung
kevinsung previously approved these changes May 9, 2024
@coveralls
Copy link

Pull Request Test Coverage Report for Build 9016815724

Details

  • 30 of 34 (88.24%) changed or added relevant lines in 3 files are covered.
  • 7 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.02%) to 89.648%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/quantum_info/operators/measures.py 28 32 87.5%
Files with Coverage Reduction New Missed Lines %
qiskit/transpiler/passes/synthesis/unitary_synthesis.py 3 88.02%
crates/qasm2/src/lex.rs 4 92.37%
Totals Coverage Status
Change from base Build 9004289325: 0.02%
Covered Lines: 62237
Relevant Lines: 69424

💛 - Coveralls

Copy link
Member

@chriseclectic chriseclectic left a comment

Choose a reason for hiding this comment

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

I look forward to seeing the proof of this result.

In general I think it makes more sense to make this function a more general diamond_distance function with a specialized efficient case for two unitary inputs (like we have specialized cases for fidelity and other functions with unitary inputs), and the general case can be a call to the existing diamond_norm function.

qiskit/quantum_info/operators/measures.py Outdated Show resolved Hide resolved
qiskit/quantum_info/operators/measures.py Outdated Show resolved Hide resolved
qiskit/quantum_info/operators/measures.py Outdated Show resolved Hide resolved
self.skipTest("CVXPY not installed.")

rng = np.random.default_rng(1234)
op1 = random_unitary(2**num_qubits, seed=rng)
Copy link
Member

Choose a reason for hiding this comment

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

If these tests aren't too slow it it might be nice to add a loop here to run over a bunch of random unitaries rather than just 1.

Copy link
Author

Choose a reason for hiding this comment

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

On my machine it takes around 5.22s to evaluate the diamond norm for 3 qubit channels. Maybe we can run over a bunch of unitaries when num_qubits < 3 and only run one test otherwise?

self.assertAlmostEqual(unitary_diamond_distance(op1, op2), target, places=7)

@combine(num_qubits=[1, 2, 3])
def test_unitary_diamond_distance_random(self, num_qubits):
Copy link
Member

Choose a reason for hiding this comment

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

It would also be good to add some random unit tests for comparing random cliffords, and random paulis for the new function to the diamond norm.

Copy link
Author

Choose a reason for hiding this comment

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

I'm curious what this adds at the moment. Perhaps if optimisations are added in the future for Pauli channels or Cliffords this would make sense... But to be honest, I can't think of a simple optimisation for Clifford circuits (please let me know if you have something in mind).

@owenagnel
Copy link
Author

owenagnel commented May 20, 2024

I look forward to seeing the proof of this result.

In general I think it makes more sense to make this function a more general diamond_distance function with a specialized efficient case for two unitary inputs (like we have specialized cases for fidelity and other functions with unitary inputs), and the general case can be a call to the existing diamond_norm function.

Hi Chris! Thanks for the comments, and I completely agree, it makes more sense to generalise the function to all CPTP channels. Regarding the proof, I'm quite happy to send it to you, however, it is part of a dissertation submitted for examination and shouldn't be circulated for the time being. Shall I send it to your IBM email?

I'll make the changes you outlined ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community PR PRs from contributors that are not 'members' of the Qiskit repo mod: quantum info Related to the Quantum Info module (States & Operators)
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Hyper efficient and more accurate diamond norm implementation
8 participants