Skip to content

Commit

Permalink
Update README example to use poll_timeout_seconds
Browse files Browse the repository at this point in the history
Updated the example algorithm to include poll_timeout_seconds, which lets you increase the default polling time to avoid local timeout errors when QPUs are not immediately available to run a task.
  • Loading branch information
randalld-aws authored May 18, 2020
1 parent e7a5e7a commit 215df9d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ Tasks sent to QPUs don't always run right away. For IonQ, jobs are run once ever
## Running a Quantum Algorithm on a Quantum Computer
With Amazon Braket, you can run your quantum circuit on a physical quantum computer. The steps to do so are the same as those described to validate your environment. Just replace the example code provided in this document with your own code.

The following example executes the same Bell Pair example described to validate your configuration against a Rigetti quantum computer.
The following example executes the same Bell Pair example described to validate your configuration against a Rigetti quantum computer. For the case when the specified QPU is unavailable and tasks are not immediately run, a `poll_timeout_seconds` parameter is included to set a longer polling time. With this parameter, the results are not returned until the task reaches a status of COMPLETE, FAILED, or CANCELLED, or 24 hours passes. When using the default polling time, local timeout errors occur in some cases while waiting for the QPU to process the task. This example sets the polling time to one day (24 hours). Since tasks typically run within 24 hours this keeps the local task from failing before the task is run on the QPU.
```python
import boto3
from braket.circuits import Circuit
Expand All @@ -264,7 +264,8 @@ device = AwsQpu(AwsQpuArns.RIGETTI)
s3_folder = (f"braket-output-{aws_account_id}", "RIGETTI")

bell = Circuit().h(0).cnot(0, 1)
print(device.run(bell, s3_folder).result().measurement_counts)
print(device.run(bell, s3_folder),
poll_timeout_seconds=86400).result().measurement_counts)
```

Specify which quantum computer hardware to use by changing the value of the `device_arn` to the value for quantum computer to use:
Expand Down

0 comments on commit 215df9d

Please sign in to comment.