Skip to content

How to pass shot number to Quantum tasks within AwsQuantumJob correctly

0

Hi there,

I am trying to run a Hybrid job and I am not sure how to pass the shot number correctly to the tasks within the hybrid job. My script works as expected on SV1 simulators but as soon as I switch to IQM hardware, I obtain the following error:

botocore.errorfactory.ValidationException: An error occurred (ValidationException) when calling the CreateQuantumTask operation: shots must be between #[1, 20000]

The relevant parts of my scripts are the following:

  1. I initialize the hybrid job device_parameters = { 'name' : 'braket.aws.qubit', 'device_arn' : 'arn:aws:braket:eu-north-1::device/qpu/iqm/Garnet', 'shots' = 10 }

job = AwsQuantumJob.create( device = device_parameters["device_arn"], source_module="A", entry_point="A.script:run", .... )

  1. Within the run function, I define a qnode function def qnode_func(device_parameters, weights): dev = qml.device(**device_parameters, wires=n_qubits) qnode = qml.QNode(qnode_fn, dev, diff_method=None, interface="jax") return qnode(weights)

  2. I call the qnode_func as samples = qnode_func(device_parameters, weights)


Where would the correct location be to set the shot number? Already within AwsQuantumJob.create(...), for example by passing a device that has a shot number configured?

It seems that I am creating a new device in qnode_func. Should I somehow call the device of the AwsQuantumJob instead?

asked 2 years ago328 views

1 Answer
1

Hi there, in PennyLane the number of shots is specified in qml.device, in your example something like

dev = qml.device("braket.aws.qubit", device_arn='arn:aws:braket:eu-north-1::device/qpu/iqm/Garnet', wires=n_qubits, *shots=10*)

With Hybrid Jobs you can run your algorithm script on a classical instance managed by Braket (instead of on your laptop for instance). The reason you pass the device ARN into the AwsQuantumJob call is to ensure your job will have priority access (meaning each task from your algorithm will jump to the front of the queue) to the device for the duration of your algorithm. But you don't need to specify any details, such as, shots at that point.

AWS

answered 2 years ago

  • Thanks for the reply. I still don't quite understand why the error occurs when I switch to an IQM device. My dictionary ´device_parameters´ contains a shot number declaration and there shouldn't be any difference to your example as ** simply unpacks the dict as keyword arguments.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.