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

feature: Add noise operations and methods to add noise to circuits #149

Closed
wants to merge 48 commits into from

Conversation

yitinche
Copy link
Contributor

@yitinche yitinche commented Aug 19, 2020

Description of changes:
Add operations and a result type (density matrix) that are related to noise simulation.
Add add_noise method to Circuits class.

Build directory: build_files.tar.gz

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

  • [ x ] I have read the CONTRIBUTING doc
  • [ x ] I used the commit message format described in CONTRIBUTING
  • [ x ] I have updated any necessary documentation, including READMEs and API docs (if appropriate)

Tests

  • [ x ] I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • [ x ] I have checked that my tests are not configured for a specific region or account (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Noise classes are the building blocks of circuit for noise simulations. They can be used as operator in Instruction.
This function checks if the matrices of a Noise satisfy the condition of completely-positive trace-preserving (CPTP) maps.
This function allows user to add many Noise to a circuit at once at specified gates, qubits and times.
In circuit.moments, Instruction with Noise is keyed by NoiseMomentsKey() instead of MomentsKy. This prevents Noise from occupying additonal time stamp.
Previous check did not catch when probability = nan
When insert_strategy="inclusive", only add 1-qubit noise to a gate if gate.target is a subset of target_qubits.
@amazon-braket-ci-bot
Copy link
Contributor

AWS CodeBuild CI Report

  • CodeBuild project: SDKPullRequestBuild
  • Commit ID: 840561e
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@yitinche
Copy link
Contributor Author

The CodeBuild CI fails because this repo has dependency on the "noise" branch of Schemas repo. I have checked that the CI will pass with the noise branch of Schemas.

@amazon-braket-ci-bot
Copy link
Contributor

AWS CodeBuild CI Report

  • CodeBuild project: SDKPullRequestBuild
  • Commit ID: 3937d9c
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

src/braket/circuits/circuit.py Outdated Show resolved Hide resolved
src/braket/circuits/circuit.py Outdated Show resolved Hide resolved
src/braket/circuits/circuit.py Show resolved Hide resolved
src/braket/circuits/quantum_operator_helpers.py Outdated Show resolved Hide resolved
src/braket/circuits/noises.py Outdated Show resolved Hide resolved
src/braket/circuits/noise_helpers.py Outdated Show resolved Hide resolved
src/braket/circuits/circuit.py Outdated Show resolved Hide resolved
src/braket/circuits/noise_helpers.py Outdated Show resolved Hide resolved

new_moments = Moments()
time_slices = circuit.moments.time_slices()
for time in range(circuit.depth):
Copy link
Contributor

Choose a reason for hiding this comment

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

I get the following (which seems off to me):

>>> from braket.circuits import Noise, Circuit
>>> noise = Noise.BitFlip(probability=0.2)
>>> circ = Circuit().x(0).cnot(0, 1).y(2)
>>> print(circ.add_noise(noise))
T  : |            0             |    1     |

q0 : -X--------NBF(0.2)----------C-NBF(0.2)-
                                 |
q1 : -NBF(0.2)-------------------X-NBF(0.2)-

q2 : -Y--------NBF(0.2)-NBF(0.2)------------

T  : |            0             |    1     |

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed now. The output is now:

T  : |        0        |        1        |
                                          
q0 : -X--------NBF(0.2)-C--------NBF(0.2)-
                        |                 
q1 : -NBF(0.2)----------X--------NBF(0.2)-
                                          
q2 : -Y--------NBF(0.2)-NBF(0.2)----------

T  : |        0        |        1        |

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 test for this case (not the exact same circuit, but a similar case) was added.

src/braket/circuits/noise_helpers.py Outdated Show resolved Hide resolved
@amazon-braket-ci-bot
Copy link
Contributor

AWS CodeBuild CI Report

  • CodeBuild project: SDKPullRequestBuild
  • Commit ID: e955961
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

src/braket/circuits/noise_helpers.py Outdated Show resolved Hide resolved
src/braket/circuits/noises.py Outdated Show resolved Hide resolved
@amazon-braket-ci-bot
Copy link
Contributor

AWS CodeBuild CI Report

  • CodeBuild project: SDKPullRequestBuild
  • Commit ID: b04c5d5
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@amazon-braket-ci-bot
Copy link
Contributor

AWS CodeBuild CI Report

  • CodeBuild project: SDKPullRequestBuild
  • Commit ID: 4d702f3
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@amazon-braket-ci-bot
Copy link
Contributor

AWS CodeBuild CI Report

  • CodeBuild project: SDKPullRequestBuild
  • Commit ID: 5916077
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@speller26 speller26 requested a review from a team as a code owner May 15, 2021 00:52
@speller26
Copy link
Member

Completed in #212

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.

7 participants