Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
4.99k stars 2.32k forks source link

ZZFeatureMap does not accept layer lists for entanglement kwarg #12432

Open nonhermitian opened 3 months ago

nonhermitian commented 3 months ago

Environment

What is happening?


N = 3
layer1 = [(0,1)]
layer2 = [(1,2)]

qc = ZZFeatureMap(N, reps=1, entanglement=[layer1, layer2])
qc.draw()

CircuitError: 'Number of items in qubits parameter (2) does not match number of qubits in the circuit (1).'

How can we reproduce the issue?

run above

What should happen?

It should work like TwoLocal does.

Any suggestions?

No response

shravanpatel30 commented 1 month ago

Hi @nonhermitian ,

I have been looking into this issue and I think I have a fix for this. Because ZZFeatureMap is a child class of PauliFeatureMap I have added a method get_entangler_map() which overrides the method from NLocal (parent class of PauliFeatureMap) for when an entaglement is manually specified. But if the entaglement is not a List[List(int)] the original get_entangler_map() method from NLocal will be used. Will you be able to look at what I have done and give me some feedback?

Sorry, I started working on this issue even though it is not assigned to me.

Thanks