Code Monkey home page Code Monkey logo

amazon-braket-examples's People

Contributors

ajberdy avatar ashlhans avatar christianbmadsen avatar dependabot[bot] avatar duanyh12 avatar emkessler avatar floralph avatar gsalton avatar guomanmin avatar jbrubaker avatar jcjaskula-aws avatar krneta avatar kshitijc avatar kshyatt-aws avatar licedric avatar lundql avatar maolinml avatar math411 avatar mbeach-aws avatar peitsche avatar rmshaffer avatar shpface avatar shrikantk-aws avatar speller26 avatar thisac avatar trbromley avatar virajvchaudhari avatar xiaosi-xu avatar yitchen-tim avatar ykharkov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

amazon-braket-examples's Issues

QPE example equation issue in Example 4

In the QPE Notebook under ./examples/advanced_circuits_algorithms/QPE/QPE.ipynb, the description in "NUMERICAL TEST EXAMPLE 4" stated that

... the eigenstate $|\Psi\rangle = |+\rangle \otimes |1\rangle = H|0\rangle \otimes Z|0\rangle$.

IMHO, it should read

... the eigenstate $|\Psi\rangle = |+\rangle \otimes |1\rangle = H|0\rangle \otimes X|0\rangle$.

with the last gate being X instead of Z, as X|0> gives a |1> correctly (while Z|0> would give a |0>).

This is a documentation issue only. The code in the notebook is correctly using .x(query_qubits[1]):

# State preparation for eigenstate |+,1> of U=X \otimes Z
query = Circuit().h(query_qubits[0]).x(query_qubits[1])

Example notebook demonstrating use of tags for organizing and retrieving resources and cost breakdown

Is your feature request related to a problem? Please describe.
Customers want to organize Braket resources they create. For instance, they might want to group quantum tasks that belong to the same experiment and later retrieve them.

Describe the solution you'd like
An example notebook which should demonstrate:

  • Using tags to tag Braket resources (AwsQuantumTask, AwsQuantumTaskBatch, AwsQuantumJob)
  • Retrieving these tagged resources using the tag names/values (See this for reference)
  • Using tags to view detailed breakdown for the costs (See this for details)

Describe alternatives you've considered
We could put this in the Developer guide

incorrect AHS output from amazon-braket-default-simulator 1.17.0

Describe the bug
the Podman container build with
pip3 install quera_ahs_utils
assembles non-functioning AHS Braket library.

To Reproduce
When I run AHS emulation of a simple few atom system I see only 'ggggg..' state is being produced.
Also I see this warning:
/usr/local/lib/python3.10/dist-packages/braket/analog_hamiltonian_simulator/rydberg/rydberg_simulator_helpers.py:504: UserWarning: The solver uses intermediate time value that is larger than the maximum time value specified. The final time value of the specified range is used as an approximation.
Despite I used a lot of steps for a Hamiltonina which lasts for just 1.2 us

job = device.run(ahs_program, shots=shots, steps=480, solver_method="bdf")

Known workaround (if applicable)
I think it is related to the newer amazon-braket version. I have an old image build about 2 months ago which uses this this software stack and it has no problems - all my emulations work

$ pip3 list |grep braket
amazon-braket-default-simulator 1.14.0.post0
amazon-braket-schemas           1.17.0
amazon-braket-sdk               1.42.1

But when I build a fresh image, I get this software stack, for which AHS is producing only 'ggggg...' state.

amazon-braket-default-simulator 1.17.0
amazon-braket-schemas           1.18.0
amazon-braket-sdk               1.48.1

Mid Circuit Measurements

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Implementation Checklist (if applicable)
[ ] # issue_id
[ ] # issue_id

Additional context
Add any other context or screenshots about the feature request here.

AwsQuantumJob for QuEra has incomplete software stack

Describe the bug
Attached example should submit, execute, and measure the cost of a hybrid job running on AWS and the QuEra QPU.
It encountered 3 problems:

  1. quera_ahs_utils module does not exist in the image started on AWS by AwsQuantumJob.create(..)
    (after I hacked it)
  2. AttributeError: 'AnalogHamiltonianSimulationQuantumTaskResult' object has no attribute 'get_counts',
    meaning the version of amazon-braket-sdk on the image is far behind https://amazon-braket-sdk-python.readthedocs.io/en/latest/index.html
    (after I hacked that)
  3. The cost tracking is not working, because for a successfully executed task on Aquila (which is not free) this code
 with Tracker() as tracker:
                full_task(device,ahs_prog,shots)
                print('cost tracker, charge/$:',tracker.simulator_tasks_cost())

run against :
deviceArn='arn:aws:braket:us-east-1::device/qpu/quera/Aquila'
results with the output:
cost tracker, charge/$: 0

To Reproduce

  1. pull this 2 files:
    https://bitbucket.org/balewski/quantummind/src/master/QuEra/python/issues/hybrid_task.py
    https://bitbucket.org/balewski/quantummind/src/master/QuEra/python/issues/hybrid_submit.py
  2. execute the script
    python hybrid_submit.py

Expected behavior
there is no crash and the printed cost is 0.60 $

Known workaround (if applicable)
I can cut out get_drive(.) and get_counts(.) functions from the Amazon Braket Python SDK 'stable' version and place them in my code.

Exceptions when pip install and import tensorflow-quantum

Our project needs to define a quantum convolutional layer. When implementing it, we choose to use tensorflow and tensorflow-quantum library. tensorflow-quantum is not installed by default under conda_braket environment. When pip install it, it seems there's a version conflict with cirq and an exception is thrown. However it is not easy to upgrade/downgrade cirq or tensorflow as they have dependencies with multiple other quantum libraries.

The problem can be reproduced on amazon braket notebooks

import tensorflow
import cirq
print(tensorflow.__version__) # 2.6.0
print(cirq.__version__) # 0.9.1

!pip install tensorflow-quantum

import tensorflow_quantum

The exception is shown as attached:
tfq_error_reproduce

Parallelize_training_for_QML

When I run the following code using Amazon Braket SDK on my local ARM processor I get the error message: botocore.errorfactory.AccessDeniedException: An error occurred (AccessDeniedException) when calling the CreateJob operation: This account is not authorized to use this resource. In order to access additional resources, please contact customer support.

input_file_path = "data/sonar.all-data"

from braket.jobs.config import InstanceConfig
from braket.aws import AwsSession
from braket.jobs.image_uris import Framework, retrieve_image

instance_config = InstanceConfig(instanceType='ml.p3.2xlarge')

hyperparameters={"nwires": "10",
"ndata": "64",
"batch_size": "64",
"epochs": "5",
"gamma": "0.99",
"lr": "0.1",
"seed": "42",
}

input_file_path = "data/sonar.all-data"

image_uri = retrieve_image(Framework.PL_PYTORCH, AwsSession().region)

import time
from braket.aws import AwsQuantumJob

job = AwsQuantumJob.create(
device="local:pennylane/lightning.gpu",
source_module="qml_script",
entry_point="qml_script.train_single",
job_name="qml-single-" + str(int(time.time())),
hyperparameters=hyperparameters,
input_data={"input-data": input_file_path},
instance_config=instance_config,
image_uri=image_uri,
wait_until_complete=False,
)

print(job.result())

The code was used from the following Amazon Braket example:

https://github.com/aws/amazon-braket-examples/blob/main/examples/hybrid_jobs/5_Parallelize_training_for_QML/Parallelize_training_for_QML.ipynb

Could the error be related to insufficient quota for the ml.p3.2xlarge SageMaker Notebook instance?

feature: Parameterized circuit example

Is your feature request related to a problem? Please describe.
amazon-braket-sdk-python supports parameterizing circuits but there is no example for how to use the feature.

Describe the solution you'd like
A notebook that shows how and when to use parameterized circuits.

Describe alternatives you've considered
Updating documentation in the Braket SDK

Implementation Checklist (if applicable)
N/A

Additional context
N/A

bug: images broken for some example notebooks on github

Describe the bug
Images not visible for below notebooks on github.

  1. https://github.com/aws/amazon-braket-examples/blob/main/examples/quantum_annealing/Dwave_Anatomy.ipynb
  2. https://github.com/aws/amazon-braket-examples/blob/main/examples/getting_started/1_Running_quantum_circuits_on_simulators.ipynb
  3. https://github.com/aws/amazon-braket-examples/blob/main/examples/getting_started/2_Running_quantum_circuits_on_QPU_devices.ipynb
  4. https://github.com/aws/amazon-braket-examples/blob/main/examples/advanced_circuits_algorithms/Simons_Algorithm/Simons_Algorithm.ipynb

To Reproduce
Steps to reproduce the behavior:

  1. Go to examples folder in amazon-braket-examples repository
  2. Click on particular example notebook i.e. ipynb file listed above.
  3. Scroll down to view the embedded images.
  4. Check if images are broken.

Expected behavior
We should see images for circuits/graphs properly.

Screenshots
If applicable, add screenshots to help explain your problem.

System information (please complete the following information as applicable):

  • Package Versions [e.g. amazon-braket-sdk==1.9.5]: N/A
  • Working Environment: [e.g. Local, Braket Notebook Instances]: Local/Github
  • Browser [e.g. chrome, safari]: Firefox
  • Region [e.g. us-west-2]: N/A

Additional context
Images are visible in notebook instance provided by Braket.

access to CCD images from QuEra

Currently you provide access to bitstrings from the measured final state of AHS evolution.

job = AwsQuantumTask(arn=task_arn, poll_timeout_seconds=30)
rawBitstr=job.result().get_counts()

For debugging purposes I'd like to have access to the CCD image from each shot
rawCCD_mages=job.result().????() --> shape [numShots, 1K,1K]

mounting persistent S3 to hybrid job

Hi,
This 2 files allow me to execute a basic hybrid job against QuEra Aquila

https://bitbucket.org/balewski/quantummind/src/master/QuEra/python/toys/hybrid_submit.py
https://bitbucket.org/balewski/quantummind/src/master/QuEra/python/toys/hybrid_task.py

The hybrid job is executed on my laptop as follows:
python ./hybrid_submit.py

Can you please help me in upgrading them to achieve the following functionality and provide instruction to accomplish the following:

  1. I'd like to crate a persistent S3 storage belonging to: arn:aws:iam::765483381942:user/balewski
  2. I'd like to copy file named myFunc.py from my Ubuntu laptop to this persistent S3, using a command line executed on my laptop, w/o using any GUI
  3. please modify hybrid_submit.py so the following works:
  • 'from myFunc import myFunc' executed by hybrid_task.py finds this file stored on persistent S3
  • pass number 4 as argument: run_hybrid_task(nRepeat=4) in hybrid_submit.py
  • output files generated by hybrid_task.py, e.g. ahs_task0.emul.json, are saved on the persistent S3

Thanks
Jan

The link to AllSinglesDoubles is broken

Describe the bug
The link to the AllSinglesDoubles Pennylane documentation in the "Defining an ansatz circuit" section of the amazon-braket-examples/examples/pennylane/3_Hydrogen_Molecule_geometry_with_VQE/ notebook is broken. It should point to: https://docs.pennylane.ai/en/stable/code/api/pennylane.AllSinglesDoubles.html

To Reproduce
Steps to reproduce the behavior:

  1. Go to amazon-braket-examples/examples/pennylane/3_Hydrogen_Molecule_geometry_with_VQE/
  2. Scroll down to 'Defining an ansatz circuit section'
  3. Click 'AllSinglesDoubles' link
  4. See error

Expected behavior
Open Pennylane documentation on the AllSinglesDoubles ansatz: https://docs.pennylane.ai/en/stable/code/api/pennylane.AllSinglesDoubles.html

Solve an annealing problem with `Device.run`

In the D-Wave MaxCut example, an AwsDevice is created in the 4th code block:

device = AwsDevice("arn:aws:braket:::device/qpu/d-wave/Advantage_system1")

However, device is never used again in the notebook. Instead, the MaxCut problem is solved using a sampler object:

sampler = BraketDWaveSampler(s3_folder,'arn:aws:braket:::device/qpu/d-wave/Advantage_system1')
sampler = EmbeddingComposite(sampler)
response = sampler.sample_qubo(Q, chain_strength=chainstrength, num_reads=numruns)

Is this the only way to use the D-Wave devices and solve annealing problems? Or is it possible to use the device.run() function? The run function has the option of passing in a Problem as the task specification (instead of a Circuit), but I have so far been unable to get this to work.

Any help or directions to relevant tutorials would be greatly appreciated!

feat: Update AHS examples that utilize ahs_utils methods

In PR #508 we moved functionality realized in ahs_utils.py to BDK.

The next step is to update all AHS examples, that utilze result.get_counts(), result.get_avg_density(), TimeSeries.from_lists() etc.
This will make the Jupyter notebooks more concise and more readable.

Clarify cost function vs. monetary cost in Hybrid Jobs with PennyLane notebook

Is your feature request related to a problem? Please describe.
In this notebook, the term "cost" without a modifier is used several times in back-to-back cells to describe different things: the cost function one is trying to minimize, and the actual cost in dollars to the customer.

Describe the solution you'd like
A clear and concise description of what you want to happen.
Need to explicitly call out which cost is being referred to in each plot, and in each call to the cost tracker. Change the axes for the evaluation of the cost function over iterations to say "cost function," and add a section header before the cost tracking calls to say something along the lines of "Tracking Customer Costs."

Typo: Conflicting number of shots in example notebook

This is minor, but in the following example Jupyter notebook:

Under the "Aria" section, the first sentence states:

First, run we the QPE circuit on the Aria device with the maximum number of shots per task (5,000).

with a subsequent line of:

task = device.run(circ, shots=2500)
print(task)

A few things:

  • "we" and "run" should be switched
  • Perhaps this is implied, but from the reading of this sentence it seems to indicate that you are running for the maximum number of shots (5,000), but then subsequently run it for the minimum number of shots required for debiasing (2,500).

transpiled circuit for Lucy

I recently had the opportunity to submit my first circuit on Oxford-Lucy via Braket, following a prior experiment on IonQ. I'm keen to analyze how the two compare. Could you guide me on how to access the transpiled circuit for Lucy from Braket? Given my original 7-qubit circuit's extensive connectivity and 30 entangling gates, I anticipate the Lucy version might be significantly longer due to the necessary swap operations. How can I retrieve this detailed information from Braket?

Furthermore, I'm looking for the latest specifications of Lucy, including T1, T2, the typical duration of entangling gates, readout fidelity per qubit, and any limitations on concurrent gate execution. Where might I find these details?

Thank you for your assistance.

multi threaded Braket execution

I'm running Braket simulation locally on machines with 64 cores and ~420 GB of RAM. I can allocate 10 such nodes for few hours.
I'd like to be able to tell Braket:

  • how many cores it can use per node
  • give it list of nodes by hostname or IP
    So a single quantum circuit can be computed faster using all cores on all nodes and by total RAM bound rather than timeout and use 3 out of 64 cores and 1/4 of RAM.
    Thanks
    Jan

bug

Distorted histogram output in 2_Graph_optimization_with_QAOA

Describe the bug
Executing the 2_Graph_optimization_with_QAOA notebook produces the following output for cell 13:

Screen Shot 2022-10-20 at 5 38 55 PM

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
See the notebook for the expected histogram.

Screenshots
If applicable, add screenshots to help explain your problem.

System information (please complete the following information as applicable):

  • Package Versions [e.g. amazon-braket-sdk==1.9.5]
  • Working Environment: [e.g. Local, Braket Notebook Instances]
  • Browser [e.g. chrome, safari]
  • Region [e.g. us-west-2]

Known workaround (if applicable)
Add a known workaround with steps to follow.

Additional context
Add any other context about the problem here.

Can't find controlled-RY gate in Amazon Braket SDK.

I am searching for qiskit.circuit.QuantumCircuit.cry( ) methods equivalent function in Amazon Braket SDK. I also tried writing the code in Qiskit first and then run it using the Qiskit provider for Amazon Braket. But it also throws key error for cry( ) function. Please help.

image

example notebook for setting cost limits in Hybrid Jobs using cost tracker

Is your feature request related to a problem? Please describe.
We don't yet have an explicit notebook demonstrating how to use the new cost tracker feature to set limits for cost in Hybrid Jobs.

Describe the solution you'd like
We need to create a notebook demonstrating how to do this.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Issue loading SV1 and TN1

While attempting to run the notebook 1_Running_quantum_circuits_on_simulators.ipynb, I'm unable to load either the SV1 or TN1 devices. I receive the error:

>>> device = AwsDevice("arn:aws:braket:::device/quantum-simulator/amazon/sv1")
# ...
# lots of error message that I can post if useful
# ...
EndpointConnectionError: Could not connect to the endpoint URL: "https://braket.us-east-2.amazonaws.com/device/arn%3Aaws%3Abraket%3A%3A%3Adevice%2Fquantum-simulator%2Famazon%2Fsv1"

and

>>> device = AwsDevice("arn:aws:braket:::device/quantum-simulator/amazon/tn1")
# ...
# lots of error message that I can post if useful
# ...
EndpointConnectionError: Could not connect to the endpoint URL: "https://braket.us-east-2.amazonaws.com/device/arn%3Aaws%3Abraket%3A%3A%3Adevice%2Fquantum-simulator%2Famazon%2Ftn1"

I notice the error URL is pointing to us-east-2 even though both the SV1 and TN1 devices are on us-east-1 and I'm running the notebook on an EC2 instance on us-east-1.

The request to AWS Cost Explorer client asking for the cost of a job given by ARN returns 0$

The request to AWS Cost Explorer client asking for the cost of a job given by ARN returns 0$

To Reproduce
execute the script:
https://bitbucket.org/balewski/quantummind/src/master/QuEra/python/issues/issue2_cost_by_ARN.py

Expected behavior
for the day June 15 there should be a charge of about $1.5
I can see the job completed here:
https://us-east-1.console.aws.amazon.com/braket/home?region=us-east-1#/tasks/arn%3Aaws%3Abraket%3Aus-east-1%3A765483381942%3Aquantum-task%2F484a891b-828d-4127-9853-a447c09880ab

System information (please complete the following information as applicable):
$ pip3 list |grep braket
amazon-braket-default-simulator 1.15.0
amazon-braket-schemas 1.17.0
amazon-braket-sdk 1.42.1

Known workaround (if applicable)
read number of shots on the AWS web page and use calculator to compute the cost

Broken Link in README

The link to the Deep Dive into the anatomy of quantum circuits notebook is broken

get list of measured bistrings from Aquila

For some analysis, say evaluation of stability of the HW, one needs to see the bistrings from all shots, presented as a list.
Currently you provide only the summary in the form of dictionary of all unique bistrings and the number of occurences. It is done by get_counts():
https://amazon-braket-sdk-python.readthedocs.io/en/latest/_modules/braket/tasks/analog_hamiltonian_simulation_quantum_task_result.html#AnalogHamiltonianSimulationQuantumTaskResult.get_counts
Can you provide also new function get_shots(), which would differ very little from get_counts(), namely instead of accumulating the dictionary:

state_counts = Counter()
 for shot in self.measurements:
 ...
      state_counts.update((state,))
return dict(state_counts)

it would append a list:

state_list = []
 for shot in self.measurements:
 ...
      state_list.append(state)
return state_list

I can hack it for now, but this type of functionality is of general use. E.g. it is available in Qiskit or TKet.
Thanks, Jan

Compatibility with python>=3.8

Hey there!

I managed to get my own container to work by downgrading my usual python version to 3.7.

I had an attempt to use python 3.8, but I failed. I manage to start from FROM 292282985366.dkr.ecr.us-west-2.amazonaws.com/amazon-braket-base-jobs:1.0-cpu-py37-ubuntu18.04, remove the present python installation and reinstall the version 3.8, but then from them CloudWatch I see that the main script is still called with python 3.7

Invoking script with the following command:
/usr/local/bin/python3.7 braket_container.py

While the libraries used in the docker the docker seems to, correctly, point to python 3.8

Error processing line 1 of /usr/local/lib/python3.8/site-packages/sphinxcontrib_serializinghtml-1.1.5-py3.9-nspkg.pth:
  Traceback (most recent call last):
    File "/usr/local/lib/python3.7/site.py", line 168, in addpackage
      exec(line)
    File "<string>", line 1, in <module>
    File "/usr/local/lib/python3.7/importlib/__init__.py", line 51, in <module>
      _w_long = _bootstrap_external._w_long
  AttributeError: module 'importlib._bootstrap_external' has no attribute '_w_long'

Anyway, before trying to debug what was going wrong in my docker could you confirm whether, currently, we need to run python3.7? Or are other versions supported?

Getting_notifications_when_a_task_completes.ipynb does not render successfully

Describe the bug
The "Getting_notifications_when_a_task_completes.ipynb" in folder "/examples/braket_features/Getting_notifications_when_a_task_completes" does not load the the github preview

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://github.com/aws/amazon-braket-examples/tree/main/examples/braket_features/Getting_notifications_when_a_task_completes
  2. Click on 'Getting_notifications_when_a_task_completes.ipynb'
  3. See error "An error occurred"

Expected behavior
The notebook preview should display

Screenshots
If applicable, add screenshots to help explain your problem.
error-msg 'An error occurred'

Braket is not respecting my choice of measured qubits

Describe the bug
Braket is not respecting my choice of measured qubits. It measures all 3 qubits and changes my order of measurement. This circuit produces: Counter({'110': 7, '000': 3}) , but it should produce : Counter({'01': 7, '00': 3})

qc_br = Circuit()
qc_br.h(0).cnot(0, 1).x(2).x(2)
qc_br.probability(target=[2,1])

To Reproduce

from braket.aws import AwsDevice
device = AwsDevice("arn:aws:braket:::device/quantum-simulator/amazon/sv1")
from braket.circuits import Circuit
qc_br = Circuit()
qc_br.h(0).cnot(0, 1).x(2).x(2)
qc_br.probability(target=[1,2])
print(qc_br)
print('\nMeasured qubits:',qc_br._qubit_observable_mapping)
job = device.run(qc_br, shots=10)
jobRes=job.result()
print('M: counts',jobRes.measurement_counts)

Expected behavior
Counter({'01': 7, '00': 3})

System information (please complete the following information as applicable):
Ubuntu 22.04
core@a53c3c6fe9f2:$ pip3 list |grep bra
amazon-braket-default-simulator 1.21.0
amazon-braket-schemas 1.20.2
amazon-braket-sdk 1.74.0
qbraid 0.5.3
core@a53c3c6fe9f2:
$ python3 -V
Python 3.10.12

AtomArrangementValidator throws 4um error for no reason

Describe the bug
For a non-trivial atom geometry, AtomArrangementValidator throws error for no reason.
None of atoms in the register is closer than 4.8 um

The error reads:

 error for AtomArrangementValidator
  Sites [Decimal('0.0000167'), Decimal('0.0000282')] and site [Decimal('0.0000064'), Decimal('0.0000316')] have y-separation (0.0000034). It must either be exactly zero or not smaller than 0.000004 meters (type=value_error)

The code below proves the distance between those 2 sites is above 10um

a=np.array([0.0000167,0.0000282]) 
b=np.array([0.0000064,0.0000316])
d=a-b
dd=np.sqrt(np.sum(d**2))
print(a,b)
print('dV',d,'l=',dd)
OUTPUT:
[1.67e-05 2.82e-05] [6.40e-06 3.16e-05]
dV [ 1.03e-05 -3.40e-06] l= 1.0846658471621571e-05

To Reproduce
Steps to reproduce the behavior execute the following code
https://bitbucket.org/balewski/quantummind/src/master/QuEra/python/issues/issue3_atom_dist_crash.py

Alternatively, just use this definition of atom register in Braket

def placeAtoms():
        posL=[[0.0, 0.0], [0.0, 5.7e-06], [0.0, 1.14e-05], [0.0, 1.71e-05], [0.0, 2.28e-05], [1.7613e-06, 2.82207e-05], [6.37317e-06, 3.157116e-05], [1.20726e-05, 3.157116e-05], [1.66839e-05, 2.82207e-05], [1.84452e-05, 2.28e-05], [1.84452e-05, 1.71e-05], [1.84452e-05, 1.14e-05], [1.84452e-05, 5.7e-06], [2.00919e-05, 3.16287e-05]]
        atoms = AtomArrangement()
        for x,y in posL:   atoms.add([Decimal(x),Decimal(y)])
        return atoms

Expected behavior
Aquila should accept this geometry as valid.

Future-proof pulse control notebook

Is your feature request related to a problem? Please describe.
https://github.com/aws/amazon-braket-examples/blob/main/examples/pulse_control/3_Bell_pair_with_pulses_Rigetti.ipynb

This notebook uses hardcoded qubits:

a=10
b=113

This works for the topology of the current Rigetti devices, but it would be great if the notebook would work for any future Rigetti devices, as well.

Describe the solution you'd like
A random pair of connected qubits can be generated from a given device as follows:

import numpy as np

connectivity = device.properties.paradigm.connectivity.connectivityGraph

qubit_a = np.random.choice(list(connectivity.keys()))
neighbors = connectivity[str(qubit)]
qubit_b = neighbors[np.random.randint(len(neighbors))]

Describe alternatives you've considered

increase shot limit for Aquila to 5k

When I submit Aquila job which requests more than 1k shots it is rejected by Braket.
Can you please bump up this limit to 5k or 10k? I run problems which require higher statistics than 1k shots.
This is the Braket error I see

Traceback (most recent call last):
  File "/quera/problem_Z2Phase1D/./submit_Z2Phase_job.py", line 148, in <module>
    job = device.run(discr_ahs_program, shots=shots)  
  File "/usr/local/lib/python3.10/dist-packages/braket/aws/aws_device.py", line 184, in run
    return AwsQuantumTask.create(
  File "/usr/local/lib/python3.10/dist-packages/braket/aws/aws_quantum_task.py", line 189, in create
    return _create_internal(
  File "/usr/lib/python3.10/functools.py", line 889, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
  File "/usr/local/lib/python3.10/dist-packages/braket/aws/aws_quantum_task.py", line 676, in _
    task_arn = aws_session.create_quantum_task(**create_task_kwargs)
  File "/usr/local/lib/python3.10/dist-packages/braket/aws/aws_session.py", line 230, in create_quantum_task
    response = self.braket_client.create_quantum_task(**boto3_kwargs)
  File "/usr/local/lib/python3.10/dist-packages/botocore/client.py", line 535, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/local/lib/python3.10/dist-packages/botocore/client.py", line 980, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.ValidationException: An error occurred (ValidationException) when calling the CreateQuantumTask operation: shots must be between #[1, 1000]

Dwave_factoring example fails to run due to validation error of the device schema

The following cell in quantum_anealing/Dwave_Factoring/Dwave_factoring.ipynb throws ValidationException with error messages below.

sampleset = sampler_fixed_embedding.sample(bqm, num_reads=100)
print("Best solution found: \n",sampleset.first.sample)
---------------------------------------------------------------------------
ValidationException                       Traceback (most recent call last)
<ipython-input-54-656093bed65b> in <module>
----> 1 sampleset = sampler_fixed_embedding.sample(bqm, num_reads=100)
      2 print("Best solution found: \n",sampleset.first.sample)

~/anaconda3/envs/Braket/lib/python3.7/site-packages/dwave/system/composites/embedding.py in sample(self, bqm, **parameters)
    501             self._fix_embedding(embedding)
    502 
--> 503         return super(LazyFixedEmbeddingComposite, self).sample(bqm, **parameters)
    504 
    505 

~/anaconda3/envs/Braket/lib/python3.7/site-packages/dwave/system/composites/embedding.py in sample(self, bqm, chain_strength, chain_break_method, chain_break_fraction, embedding_parameters, return_embedding, warnings, **parameters)
    277             parameters['ignored_interactions'] = ignored
    278 
--> 279         response = child.sample(bqm_embedded, **parameters)
    280 
    281         def async_unembed(response):

~/anaconda3/envs/Braket/lib/python3.7/site-packages/dimod/core/sampler.py in sample(self, bqm, **parameters)
    169                 # sample_qubo is implemented
    170                 Q, offset = bqm.to_qubo()
--> 171                 sampleset = self.sample_qubo(Q, **parameters)
    172             else:
    173                 h, J, offset = bqm.to_ising()

~/anaconda3/envs/Braket/lib/python3.7/site-packages/braket/ocean_plugin/braket_dwave_sampler.py in sample_qubo(self, Q, **kwargs)
    207             {0: 1, 4: 0}
    208         """
--> 209         return super().sample_qubo(Q, **kwargs)
    210 
    211     def sample_qubo_quantum_task(self, Q: Dict[Tuple[int, int], int], **kwargs) -> QuantumTask:

~/anaconda3/envs/Braket/lib/python3.7/site-packages/braket/ocean_plugin/braket_sampler.py in sample_qubo(self, Q, **kwargs)
    281             {0: 1, 4: 0}
    282         """
--> 283         aws_task = self.sample_qubo_quantum_task(Q, **kwargs)
    284         variables = set().union(*Q)
    285         return BraketSampler.get_task_sample_set(aws_task, variables)

~/anaconda3/envs/Braket/lib/python3.7/site-packages/braket/ocean_plugin/braket_dwave_sampler.py in sample_qubo_quantum_task(self, Q, **kwargs)
    237             {0: 1, 4: 0}
    238         """
--> 239         return super().sample_qubo_quantum_task(Q, **kwargs)
    240 
    241     def _process_solver_kwargs(self, **kwargs) -> Dict[str, Any]:

~/anaconda3/envs/Braket/lib/python3.7/site-packages/braket/ocean_plugin/braket_sampler.py in sample_qubo_quantum_task(self, Q, **kwargs)
    340             self._s3_destination_folder,
    341             logger=self._logger,
--> 342             **solver_kwargs,
    343         )
    344 

~/anaconda3/envs/Braket/lib/python3.7/site-packages/braket/aws/aws_device.py in run(self, task_specification, s3_destination_folder, shots, poll_timeout_seconds, poll_interval_seconds, *aws_quantum_task_args, **aws_quantum_task_kwargs)
    147             poll_interval_seconds=poll_interval_seconds,
    148             *aws_quantum_task_args,
--> 149             **aws_quantum_task_kwargs,
    150         )
    151 

~/anaconda3/envs/Braket/lib/python3.7/site-packages/braket/aws/aws_quantum_task.py in create(aws_session, device_arn, task_specification, s3_destination_folder, shots, device_parameters, disable_qubit_rewiring, tags, *args, **kwargs)
    130             disable_qubit_rewiring,
    131             *args,
--> 132             **kwargs,
    133         )
    134 

~/anaconda3/envs/Braket/lib/python3.7/functools.py in wrapper(*args, **kw)
    838                             '1 positional argument')
    839 
--> 840         return dispatch(args[0].__class__)(*args, **kw)
    841 
    842     funcname = getattr(func, '__name__', 'singledispatch function')

~/anaconda3/envs/Braket/lib/python3.7/site-packages/braket/aws/aws_quantum_task.py in _(problem, aws_session, create_task_kwargs, device_arn, device_parameters, disable_qubit_rewiring, *args, **kwargs)
    448     )
    449 
--> 450     task_arn = aws_session.create_quantum_task(**create_task_kwargs)
    451     return AwsQuantumTask(task_arn, aws_session, *args, **kwargs)
    452 

~/anaconda3/envs/Braket/lib/python3.7/site-packages/braket/aws/aws_session.py in create_quantum_task(self, **boto3_kwargs)
     90             str: The ARN of the quantum task.
     91         """
---> 92         response = self.braket_client.create_quantum_task(**boto3_kwargs)
     93         return response["quantumTaskArn"]
     94 

~/anaconda3/envs/Braket/lib/python3.7/site-packages/botocore/client.py in _api_call(self, *args, **kwargs)
    314                     "%s() only accepts keyword arguments." % py_operation_name)
    315             # The "self" in this scope is referring to the BaseClient.
--> 316             return self._make_api_call(operation_name, kwargs)
    317 
    318         _api_call.__name__ = str(py_operation_name)

~/anaconda3/envs/Braket/lib/python3.7/site-packages/botocore/client.py in _make_api_call(self, operation_name, api_params)
    633             error_code = parsed_response.get("Error", {}).get("Code")
    634             error_class = self.exceptions.from_code(error_code)
--> 635             raise error_class(parsed_response, operation_name)
    636         else:
    637             return parsed_response

ValidationException: An error occurred (ValidationException) when calling the CreateQuantumTask operation: The field deviceParameters does not match the expected schema for the selected device. Please refer to the github repo amazon-braket-schemas-python for examples

I did not change any parts except for a bucket name and its prefix. A region I am using is us-west-2.

VQE example is broken due to SDK mismatch in Braket notebooks

Currently, the VQE Chemistry example notebook uses FreeParameter in the notebook. The SDK in notebooks uses an older version than where FreeParameter occurs. Long term fix is being worked on internally.

Short term fix:
under the Imports and setup cell, you can change it to read::

# create a directory named "data" to store intermediate classical computation results from OpenFermion
!mkdir -p "data"
!pip install amazon-braket-sdk==1.17.0
!pip show amazon-braket-sdk

`ImportError: cannot import name 'Markup' from 'jinja2'` in `Dwave_StructuralImbalance` and `Dwave_factoring` notebooks

Describe the bug
The Dwave_StructuralImbalance and Dwave_factoring notebooks fail with the error:

ImportError: cannot import name 'Markup' from 'jinja2'

To Reproduce
Steps to reproduce the behavior:

  1. Create an Amazon Braket Notebook instance.
  2. Open the Dwave_factoring notebook and run all cells.
  3. Scroll down to cell 12
  4. See error

Expected behavior
Cell 12 should produce an image rendered using Bokeh

Screenshots
If applicable, add screenshots to help explain your problem.

System information (please complete the following information as applicable):

  • Package Versions [e.g. amazon-braket-sdk==1.9.5]
  • Working Environment: [e.g. Local, Braket Notebook Instances]
  • Browser [e.g. chrome, safari]
  • Region [e.g. us-west-2]

Known workaround (if applicable)
Pin Jinja2 version to 3.0.3. This can be accomplished by including the following command at the top of the notebook:

!pip install Jinja2==3.0.3

Additional context
Starting with version 3.1.0 Jinja2 dropped support for importing Markup. See changelog here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.