1
$\begingroup$

I have some trouble building an exponential matrix using the latest version of Qiskit that supports Parameters. I am also interested in learning how to use custom loss functions (if this is even possible).

So I am coming from the following direction: I want to build a VQC using this layout

enter image description here

I only want to implement this circuit using these M_Class gates, M_img class I dont need. M_class are of form : $\mathrm{e}^{A(\theta)}$

In particular it is defined by the sum of small 4x4 matrices: $$A = \exp\left(-\frac{\mathrm{i}}{2}\sum_{\rho,\gamma\in[0, 1, 2, 3]}\theta_{\rho,\gamma}\hat{\sigma}^\rho\otimes\hat{\sigma}^\gamma\right)$$

with the matrices being $\hat{\sigma}^0=\mathbf{I}$, $\hat{\sigma}^0=\hat{\sigma}^x$, $\hat{\sigma}^2=\hat{\sigma}^y$ and $\hat{\sigma}^3=\hat{\sigma}^z$.

So my idea was to use a this feature map

qc = QuantumCircuit(num_qbits)
qc.reset(range(num_qbits))
featuremap = qc

then build the Unitary Matrix that encodes M_class in order to build the ansatz that resembles the first graphic. My problem is finding a way to build a parametrized exp matrix. The only way building such a matrix I know use

evol_gate = PauliEvolutionGate(A, time=5, synthesis=SuzukiTrotter(reps=2))

but as far as I understand this aproach does not support Paramter, which can be trained later... My general idea was to program Hermit operator M_class and to built a circuit out of it as ansatz and in the end using something like this

vqc = VQC(
    sampler=sampler,
    feature_map=feature_map,
    ansatz=ansatz,
    optimizer=optimizer,
    callback=callback_graph,
)

# clear objective value history
objective_func_vals = []
vqc.fit(train_features, train_labels)

Hope someone can help :))

$\endgroup$
0

1 Answer 1

1
$\begingroup$

I think EvolvedOperatorAnsatz is a good option. It accepts a list of operators and an evolution synthesis and constructs a parametrized quantum circuit:

from qiskit.circuit.library.n_local import EvolvedOperatorAnsatz
from qiskit.quantum_info import SparsePauliOp
from qiskit.synthesis import SuzukiTrotter

ops = [
    SparsePauliOp('XYIII', 0.5),
    SparsePauliOp('IYZII', 0.5),
    SparsePauliOp('IIZXI', 0.5),
]

ansatz = EvolvedOperatorAnsatz(ops,
    reps=2,
    evolution=SuzukiTrotter(order=2),
    parameter_prefix='θ')
$\endgroup$
4
  • $\begingroup$ Big thanks for your quick reply it really helped me alot getting a bit deeper understanding! I played around with it and it helped me for sure! Some different questions came up, I posted them in a new question as I am not sure if it is allowed or appreciated to continue here. ongoing question $\endgroup$
    – aha san
    Commented May 3 at 13:50
  • $\begingroup$ While working on this, I asked myself the following: Since the EvolvedOperatorAnsatz is used for approximation in the time evolution of a matrix, I wonder if it truly represents the matrix exponential as described above. I suppose it does if we are only approximating one step, but I am not sure if this is considered in the idea you posted above. I appreciate any replies and thank you again. $\endgroup$
    – aha san
    Commented May 23 at 9:02
  • 1
    $\begingroup$ Qiskit supports MatrixExponential for exact operator evolution. you can use it for evolution parameter. But I'm not sure of its applicability in your case. $\endgroup$ Commented May 23 at 10:16
  • $\begingroup$ Thanks alot I will look into this! $\endgroup$
    – aha san
    Commented May 29 at 9:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.