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

fix: Convert amplitude result to a complex number #144

Merged
merged 4 commits into from
Aug 17, 2020
Merged

Conversation

kshitijc
Copy link
Contributor

Issue #, if available:

Description of changes:

  • Converted amplitude result types to a complex number.
  • Added integration test for validating amplitudes for SV1.
  • Enabled integration tests for simulators for shots=0.

Testing done:

>>> import boto3
>>> from braket.aws import AwsDevice
>>> from braket.circuits import Circuit
>>>
>>> aws_account_id = boto3.client("sts").get_caller_identity()["Account"]
>>> c = AwsDevice("arn:aws:braket:::device/quantum-simulator/amazon/sv1")
>>> s3_folder = (f"amazon-braket-{aws_account_id}", "folder-name")
>>> c = Circuit().x(0).amplitude(state=["1"])
>>> task = device.run(c, s3_folder, shots=0)
>>> print(task.result().values[0])
{'1': (1+0j)}

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

Tests

  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • 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.

@kshitijc kshitijc changed the title Amplitude result fix: Convert amplitude result to a complex number Aug 15, 2020
@amazon-braket-ci-bot
Copy link
Contributor

AWS CodeBuild CI Report

  • CodeBuild project: SDKPullRequestBuild
  • Commit ID: 7104e53
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@@ -426,6 +426,12 @@ def _format_result(result):

@_format_result.register
def _(result: GateModelTaskResult) -> GateModelQuantumTaskResult:
if result.resultTypes:
Copy link
Contributor

Choose a reason for hiding this comment

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

There's also other conversions in here: https://github.com/aws/amazon-braket-sdk-python/blob/main/src/braket/tasks/gate_model_quantum_task_result.py#L220. These checks should probably get migrated into a function, that both from_string and this function call

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@amazon-braket-ci-bot
Copy link
Contributor

AWS CodeBuild CI Report

  • CodeBuild project: SDKPullRequestBuild
  • Commit ID: 8d08830
  • Result: SUCCEEDED
  • 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: cfff5ea
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@kshitijc kshitijc merged commit c109467 into main Aug 17, 2020
@kshitijc kshitijc deleted the amplitude_result branch August 17, 2020 21:52
kshitijc pushed a commit that referenced this pull request Nov 29, 2021
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.

4 participants