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

Polish noise docs #3569

Merged
merged 8 commits into from Dec 3, 2020
Merged

Polish noise docs #3569

merged 8 commits into from Dec 3, 2020

Conversation

rmlarose
Copy link
Contributor

@rmlarose rmlarose commented Dec 3, 2020

Revamped as per discussions with @karlunho.

Let me know what you think! cc @balopat @lamberta as this may be time-sensitive

@rmlarose rmlarose requested review from cduck, vtomole and a team as code owners December 3, 2020 02:36
@google-cla google-cla bot added the cla: yes Makes googlebot stop complaining. label Dec 3, 2020
Copy link
Contributor

@lamberta lamberta left a comment

Choose a reason for hiding this comment

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

Thanks! A few nits

docs/noise.ipynb Outdated Show resolved Hide resolved
docs/noise.ipynb Outdated Show resolved Hide resolved
@rmlarose
Copy link
Contributor Author

rmlarose commented Dec 3, 2020

Thanks @lamberta! Just addressed these.

docs/noise.ipynb Outdated Show resolved Hide resolved
docs/noise.ipynb Outdated Show resolved Hide resolved
docs/noise.ipynb Outdated Show resolved Hide resolved
Copy link
Contributor

@balopat balopat left a comment

Choose a reason for hiding this comment

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

This is looking really good - I added two more nits

docs/noise.ipynb Outdated Show resolved Hide resolved
docs/noise.ipynb Show resolved Hide resolved
@balopat balopat added the kind/docs Documentation related problems, ideas, requests label Dec 3, 2020
Copy link
Collaborator

@obriente obriente left a comment

Choose a reason for hiding this comment

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

Looks good on the whole, but it would be great if we could get more examples of how to build a noisy channel, currently I cant see this. But, very much like that we mention how to extract Kraus operators up-front - I didn't know this was possible.

Cheers,

Tom.

"* A subset of channels which support `cirq.channel` also support the `cirq.mixture` protocol.\n",
" - If magic method `_mixture_` is not defined, `cirq.mixture` looks for `_unitary_`.\n",
"* A subset of channels which support `cirq.mixture` also support the `cirq.unitary` protocol.\n",
" - If `_unitary_` is not defined for an object, the object is probably not meant for a circuit!"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure I understand this - do we expect all channels to have a unitary function? Or do you mean here that 'if a channel does not have a unitary function it is intended only to decorate a circuit e.g. as a noise model for a DensityMatrixSimulator'.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Doubly confused now, because we use an amplitude_damping channel below in a circuit. So now I'm not really sure what this sentence means.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The inclusions should be reversed - something in a circuit must have a channel, not necessarily a mixture or a unitary, though. Some channels have mixtures (e.g. cirq.bit_flip), and some channels have unitaries (e.g. cirq.X).

So, {channels with unitaries} ⊂ {channels with mixtures} ⊂ {channels}.

Thanks for pointing this out, I'm sure others who read it will have the same confusion. I'll add an example to hopefully clarify.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Alright, perhaps remove the last line here though? "If _unitary_ is not defined for an object, the object is probably not meant for a circuit!" sounds like I can't add objects that aren't unitary to a circuit, which is confusing.

docs/noise.ipynb Show resolved Hide resolved
"id": "99ac77a2c896"
},
"source": [
"Other than these general methods, channels can be added to circuits at any moment just as gates are. The channels can be different, be correlated, act on a subset of qubits, be custom defined, etc."
Copy link
Collaborator

Choose a reason for hiding this comment

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

If I remember rightly, it should be possible to generate a 'noisy_moment' function that takes in a moment and adds noise to the entire chip. This could be in principle useful (e.g. if one wants to simulate crosstalk by adding unwanted rotations to nearby gates). Can we include mention + perhaps an example of this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean the Circuit.with_noise method (example in previous cell) or something else?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean the NoiseModel.noisy_moment and NoiseModel.noisy_moments methods. These can be quite useful in some cases (e.g. the example I gave).

"$$\\rho \\rightarrow \\sum_k p_k U_k \\rho U_k^\\dagger {\\rm ~where~} \\sum_k p_k =1 {\\rm ~and~ U_k U_k^\\dagger= I}$$\n",
"\n",
"In this case, it is possible to perform **Monte Carlo simulations** of these gates using a wave function based simulator (and not a density matrix based simulator). An example of this can be seen below: \n"
"To see the Kraus operators of a channel, the `cirq.channel` protocol can be used."
Copy link
Contributor

Choose a reason for hiding this comment

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

we could also link to the Protocols page from somewhere - maybe here or in a new sentence for users who don't understand what a protocol is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. Is there a standard protocol (ha ha ha) to link to docs from docs? Should it be a devsite path like /cirq/protocols or link to GitHub/elsewhere?

Copy link
Contributor

Choose a reason for hiding this comment

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

If you use the full API symbol in backticks it will autolink to the reference page on the site.

For narrative docs, if in the same project/repo you can relative link to the file (w/ extension), like [foo guide](./foo_guide.ipynb).

But if linking to a doc in another project/repo, need the absolute site path. This keeps the links working in GitHub and Colab.

@balopat
Copy link
Contributor

balopat commented Dec 3, 2020

Given the time pressure on this, I'm going to go ahead and merge - @obriente or @mpharrigan - if you have follow-up ideas those will be super welcome as an issue and we'll fix it up soon. Most comments are addressed though as far as I can tell.

@balopat balopat added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Dec 3, 2020
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Dec 3, 2020
@CirqBot CirqBot merged commit 0701327 into quantumlib:master Dec 3, 2020
@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Dec 3, 2020
@obriente
Copy link
Collaborator

obriente commented Dec 4, 2020 via email

@rmlarose
Copy link
Contributor Author

rmlarose commented Dec 4, 2020

Thanks @obriente! No need for another issue, I will open a follow-up PR to address all remaining comments here and ping you to take another look.

@rmlarose rmlarose mentioned this pull request Dec 9, 2020
CirqBot pushed a commit that referenced this pull request Dec 11, 2020
This PR addresses remaining comments from #3569 which was merged due to time constraints.

- Adds link to protocols guide (and custom gates guide) to address comment from @balopat.
- Adds example using `cirq.NoiseModel` and addresses other remaining comments from @obriente.

Also adds section headers to density matrix simulation and monte carlo simulation to make them more apparent in the nav.
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. kind/docs Documentation related problems, ideas, requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants