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

Compile any QuantumWorld to qubits #76

Merged
merged 10 commits into from
Feb 1, 2023

Conversation

smitsanghavi
Copy link
Collaborator

@smitsanghavi smitsanghavi commented Dec 27, 2022

Part of #79

For enabling hardware-based runs, added an option to QuantumWorld that replaces qudits by ancilla qubits and transforms any qudit-based QuantumEffect and measurements to be qubit-based. Uses the utils added in #69 for the actual unitary transformations.

Updated all the applicable tests under unitary/alpha and unitary/examples/tictactoe to run in both regular mode and qubit-compiled mode.

This is still not all-powerful because the underlying qudit-to-qubit transforms assumed that all qudits in the system have the same dimension. Will work on generalizing that further next.

@smitsanghavi
Copy link
Collaborator Author

Sorry for the large PR. The interesting part is just in quantum_world.py, rest is testing.

unitary/alpha/quantum_world.py Show resolved Hide resolved
unitary/alpha/quantum_world.py Outdated Show resolved Hide resolved
unitary/alpha/quantum_world.py Outdated Show resolved Hide resolved
unitary/alpha/quantum_world.py Outdated Show resolved Hide resolved
unitary/alpha/quantum_world.py Outdated Show resolved Hide resolved
self.add_object(new_obj)
self.ancilla_names.add(ancilla_name)
new_obj = self._add_ancilla(namespace=obj.name, value=result)
# Swap the input and ancilla qubits using a remapping dict.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a test case that exercises this new force measurement code?

Copy link
Collaborator Author

@smitsanghavi smitsanghavi Jan 16, 2023

Choose a reason for hiding this comment

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

Added a bunch more tests. During those tests, realized that SparseSimulator does not support qudits at all but we can support that via this compilation.

unitary/examples/tictactoe/tic_tac_toe.py Show resolved Hide resolved
Copy link
Collaborator

@dstrain115 dstrain115 left a comment

Choose a reason for hiding this comment

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

LGTM!

unitary/alpha/quantum_world.py Show resolved Hide resolved
@@ -110,22 +177,98 @@ def test_pop(simulator):
assert all(result[1] != popped for result in results)


# TODO: Consider moving to qudit_effects.py if this can be broadly useful.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed. Can be a separate PR though.

@smitsanghavi smitsanghavi merged commit 2232102 into quantumlib:main Feb 1, 2023
@smitsanghavi smitsanghavi deleted the qubittactoe branch February 1, 2023 22:08
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.

2 participants