Measuring 4 qubits results why only 3 qubits results

The above is the quantum circuit I built. A total of 20 QUBITs were used, and the measurement results of qubits 0-1 were unexpected, as shown in the following figure

The dimension of the result is 8, 4 qubits give rise to 16 dimensions, is this where the error is

Hi @RX1,

This is a very good question.

You should note a few things:

1 - You have a Qiskit classical register of 6 classical bits but you’re only measuring 4 qubits so you will have a strange dimension because you have 2 unused classical bits that will just be 0. In PennyLane you don’t need to create a classical register so you wouldn’t have this problem.

2 - If you measure 4 qubits you get 4 answers, so basically you project your measurements onto 4 classical bits. You may be confused with the dimensions of the classical data that you can encode into qubits (eg. encoding 2 bits of information into 1 qubit). Note that this is different from the measurement of such qubits.

I hope this answers your question, if it doesn’t please feel free to clarify it.