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

Add more information about gates and best practices #3287

Merged
merged 7 commits into from Sep 3, 2020

Conversation

dstrain115
Copy link
Collaborator

  • Added information about supported gates and their unitaries
  • Organized best practices and added more information
    -- organized into running at all, improving error, and rep rate
    -- Added info about delaying initialization
    -- Added more details about aligning gates.

- Added information about supported gates and their unitaries
- Organized best practices and added more information
  -- organized into running at all, improving error, and rep rate
  -- Added info about delaying initialization
  -- Added more details about aligning gates.
@googlebot googlebot added the cla: yes Makes googlebot stop complaining. label Sep 2, 2020
```
cirq.Z(cirq.GridQubit(5, 5)).with_tags(cirq.google.PhysicalZTag())
```

Copy link
Collaborator

Choose a reason for hiding this comment

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

Are these implemented using two microwave pulses?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not totally sure actually. I think I recall that it was some sort of frequency detuning, but I don't remember exactly what the hardware people told me. Anyway, we don't have implementation details for other gates, so I think it is okay not including this here.

The following sections give tips and tricks that allow you to improve your
repetition rate (how many repetitions per second the device will run).

These tips will not improve your results or your fidelity but will help you
Copy link
Collaborator

Choose a reason for hiding this comment

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

This could improve fidelity if you are doing your own characterization, since drift can be smaller.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's true. Changed.

\left[
\begin{matrix}
1 & 0 & 0 & 0 \\
0 & 0.5sqrt{2} 0 & 0.5 i sqrt{2} & 0 \\
Copy link
Collaborator

Choose a reason for hiding this comment

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

does this latex render correctly? Think you need \sqrt?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

\begin{matrix}
1 & 0 & 0 & 0 \\
0 & 0.5sqrt{2} 0 & 0.5 i sqrt{2} & 0 \\
0 & 0.5 i sqrt{2} 0 & 0.5 sqrt{2} & 0 \\
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggest making these \frac{1}{\sqrt{2}} or \frac{i}{\sqrt{2}}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

\left[
\begin{matrix}
1 & 0 & 0 & 0 \\
0 & 0.5sqrt{2} 0 & 0.5 i sqrt{2} & 0 \\
Copy link
Collaborator

Choose a reason for hiding this comment

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

extra 0 in 0.5sqrt{2} 0

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

In addition, by using this combined gate set, the FSimGate can be parameterized,
which allows for efficient sweeps across varying two-qubit gates.
Note that providing a theta/phi combination that
is not one of the above gates, the circuit will not execute properly.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will it actually serialize? "Execute properly" makes it sound like it will silently run, just not properly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wording changed. If the theta/phi combination is explicitly wrong, it will fail to serialize. If the invalid combination is hidden in a sweep, the error will occur server side.

Copy link
Collaborator

@mpharrigan mpharrigan left a comment

Choose a reason for hiding this comment

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

cool

This guide is split into three parts:
* Getting your circuit to run
* Lowering error
* Making it run faster
Copy link
Collaborator

Choose a reason for hiding this comment

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

change the order of these? i.e. 1) get circuits to run 2) make them fast 3) lower error. The thought being: it's easier to try error reduction techniques if it's already faster :)

otherwise: splitting this doc up into meaningful sections like these is a very good idea

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

device supports. Using inactive qubits, non-adjacent qubits, or non-native
gates will immediately cause a circuit to fail.

Attaching a `cirq.Device` to a circuit will test a lot of these conditions for
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this something we want to lean in to? I always considered the fact that circuits have a device to be a vestigial design choice that no one uses in practice and IMO doesn't make much sense. From my point of view, it would make sense for devices to validate circuits: cirq.google.Sycamore.validate_circuit(circuit). You could even imagine a scheme where instead of just raising an exception at the first problem it could return a structured list of problems and suggestions on how to fix them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is this something we are trying to get rid of? I guess either way doesn't matter much to me. I changed it to validate using the device.

Copy link
Collaborator

Choose a reason for hiding this comment

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

opened #3295 to discuss the broader question

Currently, only terminal measurements are supported by the hardware. If you
absolutely need intermediate measurements for your application, reach out to
your Google sponsor to see if they can help devise a proper circuit using
intermediate measurements.
Copy link
Collaborator

Choose a reason for hiding this comment

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

there's no checks against this and in fact you can get intermediate measurements to work (where work is defined as return bits without crashing)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, but I don't think we want people doing this unless they have help. It will be difficult to get working correctly (where correctly is defined as getting return bits that are not random noise).

@@ -201,3 +260,10 @@ print(list(flat_sweep.param_tuples()))
# (('<2**t - 1>', 0.681792830507429),),
# (('<2**t - 1>', 1.0),)]
```

### Measure less qubits
Copy link
Collaborator

Choose a reason for hiding this comment

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

fewer

Copy link
Collaborator

Choose a reason for hiding this comment

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

also this might be subtly bad advice? I always have a sneaking suspicion that measuring spectator qubits could be useful. For example: what if you throw out any repetitions where spectator qubits are excited? I don't know if anyone's actually tried this though

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I was on the fence for including this advice anyway. I'll drop it.

1 & 0 & 0 & 0 \\
0 & 0 & -i & 0 \\
0 & -i & 0 & 0 \\
0 & 0 & 0 & e^{-i \pi \over 6}
Copy link
Collaborator

Choose a reason for hiding this comment

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

slight pref for e^{-i \frac{\pi}{6}}. Puts the -iout front instead of the minus in the numerator, and also LaTeX people yell at me for using\over`.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure. Done.

Copy link
Collaborator

@mrwojtek mrwojtek left a comment

Choose a reason for hiding this comment

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

Hi Doug, I put some comments related to our email conversation.

included in optimizer lists for each device will generally compile these operations out
of the circuit by pushing them back to the next non-commuting operator. If the resulting
circuit still contains Z operations, they should be aggregated into their own moment,
if possible.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't the EjectZ optimizer a completely optional operation on the client-side? Those Z gates will be compiled away server-side anyway? Does aggregation of Z gates makes any difference for circuit runtime?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If you have extra moments because of the Z gates, it can lengthen the duration of the circuit. I tried to clarify my comments. See if you like the new wording better.

Like, if you have

---Z---X---
---X-------

if possible.

See the function `cirq.stratified_circuit` for an automated way to pack gates
into moments with similar gates.
Copy link
Collaborator

Choose a reason for hiding this comment

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

As far as I understand the stratifier works to other way around - it unpacks moments when they contain mixed gates, it doesn't merge them together.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought someone optimizer that aligned one and two qubit layers. If this isn't the way to do it, I am not sure what to recommend.

## Gates supported

The following lists the gates supported by Google devices.
Please note that gate durations are subject to change as hardware isxi
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo ("isxi")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.


#### Virtual Z gates

Rotation around the Z axis is generally not a hardware operation.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not strictly true. Virtual Z gates are realized on the hardware, they are just bundled together with two-qubit gates and microwaves. Their presence changes the signals applied to the gates.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Adjusted wording to say that it is not a hardware operation on its own.


For decay experiments and other applications, a WaitGate is provided
that causes the device to idle for a specified amount of time.
This can be accomplished by specifying a `cirq.WaitGate`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the behavior of wait gate when run with other gates? Will the moment last the maximum of the gates in that moment, including a wait gate?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I believe so. I clarified that for the general case in the moment section above (that the duration of a moment is its longest gate) but did not specifically call it out in this section.

Note that real hardware does not always have all qubits enabled, and it
is important to check the device specification for the processor that you
will attempt to run on to make sure that the qubits your circuit uses
are actually active.
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be good to mention here that some qubits might be disabled and re-enabled at different days (result of maintenance).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@dstrain115 dstrain115 merged commit 1a41835 into quantumlib:master Sep 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Makes googlebot stop complaining.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants