I am working with the QNG optimizer and variational circuit. But some of the diff_method does not work. could you please tell which device, diff_method can compute results quickly with QNG optimizer? I used lightning qubit with adjoint, does not support. Due to high dimensional data, can you suggest which settings (device, diff method) can work best to compute results quick while using qng optimizer.
dev = qml.device(“lightning.qubit”, wires=n_qubits)
@qml.qnode(dev, )
def circuit( weights,inputs):
inputs_1 = inputs / np.linalg.norm(inputs)
qml.QubitStateVector(inputs_1, wires = range(n_qubits))
for i, j in enumerate(weights):
layerx(j)
return [qml.expval(qml.PauliZ(i)) for i in range(n_qubits)]
for batch_idx in range(n_batches):
X_batch = X_tr[batch_idx * batch_size : (batch_idx + 1) * batch_size]
y_batch = y_tr[batch_idx * batch_size : (batch_idx + 1) * batch_size]
cost_fn = lambda p: cost(p, X_batch, y_batch)
metric_fn = lambda p: qml.metric_tensor(circuit, approx="block-diag")(p, X_batch[0])
# Perform optimization step
params, loss = opt.step_and_cost(cost_fn, params, metric_tensor_fn=metric_fn)