내용으로 건너뛰기

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?

질문됨 2년 전369회 조회

1개 답변
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

답변함 2년 전

  • 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.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

관련 콘텐츠