Is swap gate equivalent to just exchanging the wire of the two qubits?
if yes why not just switching the wire whenever we want to apply a swap gate?
Quantum Computing Stack Exchange is a question and answer site for engineers, scientists, programmers, and computing professionals interested in quantum computing. It only takes a minute to sign up.
Sign up to join this communityYes, it is equivalent. That's a perfectly valid way to represent it in a quantum circuit diagram.
In practice, it depends what physical implementation you're talking about. If you have 'flying' qubits, then it is possible to just reorder them, or even simply relabel them without actively doing anything. However, many physical implementations of quantum computation use static qubits. That means one particular physical qubit is in a particular place. If you want to make it interact (e.g. perform controlled-not) with another qubit, they usually have to be next to each other. That means performing swap operations along some path, exchanging the states of the qubits so that the state that was on one physical qubit is now on a different one, where you need it to be.
why not just switching the wire whenever we want to apply a swap gate?
If this is the crux of the question I think the main rationale here is to treat the swap gate as an actual gate.
I only rarely see raw swap gates on their own in diagrams, typically I see them as part of a Fredkin Gate. Basically, by treating it as a gate rather than a crossing of wires, it makes it easier to understand how it can be "controlled" like any other gate.
But yes, an un-controlled swap gate could be implemented on classical bits in electrical wires by swapping the wires' positions.
I find it somewhat interesting to analogize to classical computers for all of these kinds of questions - and yes, classical computer engineers would be confused about the need for a SWAP gate for precisely the reasons identified in the question and in the other answers, but it's a very natural gate in quantum computing.
Indeed even back to 1985 in Quantum Mechanical Computers Feynman referred to swapping qubits with an "EXCHANGE" operation. As shown below he also wrote the SWAP gates as a series of three CNOT gates - but, a classical computer engineer would not likely worry about the CNOT decomposition and would instead just swap the wires with vias and metal jumpers/metal runners.
Feynman's decomposition of a SWAP gate into three CNOT gates. Nowadays we would use a filled-in bubble $\bullet$ for the control qubit (where Feynman uses an open bubble $\circ$), and we'd use a circled "+" sign $\oplus$ for the target qubit (where Feynman uses an X).
The above paper was mostly about using quantum mechanics to perform classical computational tasks - but, one thing that is uniquely quantum is taking the square-root of the SWAP (EXCHANGE) gate. I'm not sure who first took the square-roots of these gates.
Also tangentially, Feynman considered creation and annihilation operators as the really basic primitives of his quantum computers, much as for classical computers, NMOS and PMOS transistors are at a lower level of abstraction than logic gates themselves.