Closed liu-zixiong closed 1 year ago
I think this is an issue @kevincsmith and I spoke about last week -- we should be sure to use the cutoff for the appropriate register. CVCircuit has one generic cutoff property that just returns the last register's cutoff. Any uses of this function should be modified to get the appropriate registers' cutoffs instead. See https://github.com/C2QA/bosonic-qiskit/blob/main/c2qa/circuit.py#L108-L111
We might be able to correct at least a part of this without having to redefine the CVCircuit.cutoff that also relates to #86.
The existing cv_initialize doesn't use the cutoff property function, but instead references the last qumode's cutoff directly instead. See:
I believe in all cases we could use the qumode index instead and lookup the actual cutoff vs using the [-1]
last syntax. Lines 215 and 224 would need to be moved into the loops in order to check the param value against each qumode's cutoff.
Though if the qumodes is just a list of qubits (as it appears the the docs it can be), we'd still have to lookup which regster the qubit belongs to.
@liu-zixiong -- you'll find in branch cv-initialize-per-qumode and PR #89 your test code above "working" in that it doesn't throw an error. No real test validating data, though. We could compare the counts / state vector that comes from the simulation? I changed the cv_initialize
to use each qumode's cutoff, but I would expect we may need to do the same across all of our gates, too.
Thanks for the update Tim! As far as I'm aware, the current repo does not have gates that work with separate qumode registers, so it might not be possible to produce validating data via simulate without first addressing #86.
Nonetheless, do you have plans to merge PR #89 already? We could close this report after merging since the details on qumode cutoff for all gates is already reported in issue #86.
I think it can be merged now, I'm comfortable with that. Especially if it can help us address #86 and then get more tests implemented.
When creating multiple qumode registers, if the qumodes in all registers are not the same size, there will be errors when cv_initialize attempts to initialize a fock state on the qumodes.
Here is a circuit demonstrating the issue.
Note that the traceback changes depending on which qumode register object holds the qumode of a different size. For the case above, if num_qubits_per_qumode = 3 for qmr3, error occurs when initializing qmr3. But if I feed num_qubits_per_qumode = 3 into qmr6, I actually get an error when initializing qmr1.