Make `Identity` an `n` qubit bloq
fixes #1207
-
Identitynow accepts abitsize, and has a single registerqofQAny(bitsize). -
Identity(n).controlled(m)isIdentity(n + m).
more discussion: https://github.com/quantumlib/Qualtran/pull/1322#issuecomment-2299989824
I'm still a little confused about why the Identity being a single qubit bloq is problematic, doesOnEach(Identity(), n).controlled(m) not do the same thing?
I think OnEach(Identity(), n).controlled(m) would probably do the same thing; but I think it's nicer and cleaner to have an n-bit Identity operation that returns itself when controlled.
Ok, should this still be a basic gate? I think the justification for moving it back to basic gates from #1322 was that it was more logically consistent to be among $I$, $X$, $Y$ and $Z$ and basic gates should probably be restricted to one and two qubit gates maybe? Please ignore me if it makes things easier / better / cleaner it's just the identity after all.
Another subtle issue with OnEach(Identity(), n).controlled(m) is that it would produce m bloqs of OnEach(Identity(), n + 1) (because the control qubits are common), and therefore m * (n + 1) Identity() bloqs. Having a single Identity(n) makes it cleaner imo.
It also matches cirq.IdentityGate which accepts n qubits (with cirq.I being the one qubit specialization)
SGTM. Do we need to have both? Probably not right?
both as in?
I'm still a little confused about why the Identity being a single qubit bloq is problematic, doesOnEach(Identity(), n).controlled(m) not do the same thing?
The motivation is that we have an identity bloq (that is somewhat out of our control; e.g. passed as a class attribute; e.g. in applyLthgate) that we want to control. We could return OnEach; but the spirit of qualtran is to give names to things
SGTM. Do we need to have both? Probably not right?
Not 100% sure what's being asked here, but this PR keeps one Identity bloq that has a bitsize that defaults to 1, so there's only one thing to contend with.