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

Handle Qudits #933

Closed
dabacon opened this issue Sep 18, 2018 · 14 comments · Fixed by #2100
Closed

Handle Qudits #933

dabacon opened this issue Sep 18, 2018 · 14 comments · Fixed by #2100
Assignees

Comments

@dabacon
Copy link
Collaborator

dabacon commented Sep 18, 2018

Currently we use "QubitId" everywhere, but tying ourselves to two level systems seems bad. How are we going to work with higher dimensional quantum systems, or boson or fermion (or heaven forbit para-fermion) based systems?

@Strilanc
Copy link
Contributor

Strilanc commented Sep 18, 2018

Everything we do with operations should correspond to twiddling some kind of quantum control knob. A Qnob if you will. QubitId doesn't have anything inherently binary about it. We could just rename it.

@dabacon dabacon changed the title Qudits Handle Qudits Sep 18, 2018
@singular-value
Copy link

I'm going to start making some changes in my local Cirq fork to support qudit handling (well specifically, I want qutrit simulation, but I'll plan to write qutrits as the d=3 case of qudits).

Do you think there will be a reasonable case to merge my (planned) local changes into Cirq? I can see a case for keeping everything in core Cirq in qubits (it could be irritating for beginners to need to be aware of qudits). But if you were definitely planning on building qudits into Cirq, I could do my best to do it exactly as you planned (e.g. rename Qubit to Qudit?). Let me know if you have any comments/suggestions. Thanks!

-Pranav Gokhale (PhD student at UChicago with Fred Chong)

@Strilanc
Copy link
Contributor

The main blocker for supporting qudits is the fact that cirq.Operation has a method called qubits, and I suspect there is code that assumes the matrix of an operation should have a width and height equal to 2**len(qubits).

One possible way to fix this would be to replace all matrices with tensors. This would replace the size assumption with a dimension-of-shape assumption (len(cirq.unitary(op)) = 2*len(op.quwhatevers)).

@dabacon
Copy link
Collaborator Author

dabacon commented Jan 29, 2019

Suggested names for QubitId:

QuId
QId
Quid
Qid

The thing that will happen here that is odd is that methods that return "qubits" now return "quids" which is not really discoverable. Also places where we pass in Qubits no take quids, which is also kind of odd.

@Strilanc
Copy link
Contributor

Strilanc commented Jan 29, 2019

I vote Qid. Get your votes in now, everyone! @kevinsung @viathor @vtomole @maffoo @kevinsung @babbush @mrwojtek @Ashalynd @cduck @bryano @ Ican'tremembereveryone'sscreennames

@bryano
Copy link
Collaborator

bryano commented Jan 29, 2019

What about QuditId? Or just Qudit?

The easy thing here is to have QubitId just be a special case of QuditId with the dimension attribute set to 2. Things could then be generalized to qudits gradually.

@bryano
Copy link
Collaborator

bryano commented Jan 29, 2019

Of the given options, I'm for Qid as well.

@mrwojtek
Copy link
Collaborator

My vote goes to quid; it has a nice ring to it and one can make useful variations out of it easily: qubid, qutid, quqid, qupid, etc,. if ever needed.

@vtomole
Copy link
Collaborator

vtomole commented Jan 29, 2019

I'll go with @bryano. QuditId is self-documenting. From the multiple choices, i pick Qid cause it's the shortest.

@Strilanc
Copy link
Contributor

Note that this concept is slightly more general than qudits. An id could also refer to e.g. couplers and resonators that are control elements of the system instead of state elements. Things you want to give commands to.

@bryano
Copy link
Collaborator

bryano commented Jan 30, 2019

@Strilanc Do you have specific examples in mind of a "Qnob" that is not a qudit?

In any case, it seems useful to have all three constructs: qubit, qudit, and q-whatever.

Half-serious suggestion for the latter: "Qbar" (rhymes with "foobar")

@Strilanc
Copy link
Contributor

I just think of it as "generic target of operation", or "things I might want to bounce particular microwaves off of at particular times". I think Qid is generic sounding enough to include stuff like resonators, plus it's short and I like short.

@maffoo
Copy link
Contributor

maffoo commented Jan 30, 2019

+1 for Qid

Strilanc added a commit that referenced this issue Feb 27, 2019
- Did a replace-all "QubitId" -> "Qid"
- Tweaked QubitId's docstring
- Manually tweaked instances of "qubit id" in prose
- Left GridQubit/NamedQubit/LineQubit alone

Part of #933
CirqBot pushed a commit that referenced this issue Mar 15, 2019
- Did a replace-all "QubitId" -> "Qid"
- Tweaked QubitId's docstring
- Manually tweaked instances of "qubit id" in prose
- Left GridQubit/NamedQubit/LineQubit alone

Part of #933
@vtomole
Copy link
Collaborator

vtomole commented May 29, 2019

Casey, Pranav, et.al. have open sourced their Cirq fork implementation for Qudits (but mostly qutrits): https://github.com/epiqc/qutrits

@vtomole vtomole added the good part time project A meaty non-urgent issue with a substantial amount of work to be done. label Jun 13, 2019
@dabacon dabacon removed the good part time project A meaty non-urgent issue with a substantial amount of work to be done. label Jun 21, 2019
CirqBot pushed a commit that referenced this issue Jul 16, 2019
…#1771)

For #933.  Part 2 after #1777.

- `cirq.unitary` and `cirq.apply_unitary` check for the `qid_shape` protocol and use properly sized numpy arrays.
- `Circuit` also checks for the `qid_shape` protocol for `Circuit.unitary` and related methods.
- `Circuit` now implements the `qid_shape` protocol.

Qudit features not in this PR are channels, mixtures, simulators, measurements, optimizers.
CirqBot pushed a commit that referenced this issue Sep 4, 2019
…ols (#2056)

Part of #933.

Support added:
- IdentityGate and Measurement can be applied to qudits.
- Protocols apply_channel, pauli_expansion, phase_by, and qasm either support qudits or don't crash when given qudit values.
- `testing.assert_implements_consistent_protocols()` correctly tests qudit values.
CirqBot pushed a commit that referenced this issue Sep 6, 2019
Part of #933.

Where the invert mask is True, switches the measurements of |0> and |1> without modifying |2> and above.

Also fix `str(TrialResult)` for qudits.
CirqBot pushed a commit that referenced this issue Sep 10, 2019
…2089)

Part of #933.

This is a minor API change.
- `def _decompose_(self, qids):` will now work.
- `def _decompose_(self, **kwargs):` will no longer work.
- `def _decompose_(self, something_else=5, qubits=None):` will no longer work.
CirqBot pushed a commit that referenced this issue Sep 26, 2019
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 a pull request may close this issue.

8 participants