2
$\begingroup$

In their to_ising documantation page, Qiskit devs mark the comment:

Variables are mapped to qubits in the same order, i.e., $i$-th variable is mapped to $i$-th qubit.

I'm aware that Qiskit follows little endian, the rightmost bit being the least significant, but still a bit confused about the statement.

Suppose an example Ising Hamiltonian generated with to_ising:

...
+ 0.12072225349199095 * IIIIIZ
...

If I want to build a circuit with it, on which qubit should I apply the $Z$-gate? My initial guess was q[5](the bottommost qubit in the circuit), since the comment states that they're in the same order, but automatically building the circuit with the Hamiltonian and QAOAAnsatz shows it mirrored, i.e. $Z$ applied to q[0](the uppermost in the circuit).

Is that corresponding to what's intended, or am I missing something?

$\endgroup$

1 Answer 1

2
$\begingroup$

Using little-endian ordering implies that if $A$ and $B$ are two operators, then $B \otimes A$ means: apply $A$ to first qubit and $B$ to second qubit.

So, while in most quantum computing textbooks the bitstring $011$ means that the first bit equals zero, in Qiskit it will mean that the last bit equals zero. Similary, the Pauli string $XYZ$ will be written in Qiskit as $ZYX$.

Hence, in your case you should apply $Z$ operator to the first qubit (i.e., q[0])

You can find more information here.

$\endgroup$
4
  • $\begingroup$ So q[0] is indeed the 6th (last) qubit, as far as I understand? In the example above the Z operator is the 6th variable, so it should be mapped to the 6th qubit, according to the doc page. $\endgroup$ Oct 6, 2023 at 7:52
  • $\begingroup$ No! I updated my answer. I hope it is clearer now. $\endgroup$ Oct 6, 2023 at 8:29
  • 1
    $\begingroup$ Ok. So Z in the example should be referred to as the first variable, which is then applied to the first qubit, q[0]. Makes more sense now. Thank you! $\endgroup$ Oct 6, 2023 at 8:58
  • 1
    $\begingroup$ Yes! That's correct. $\endgroup$ Oct 6, 2023 at 9:04

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.