Problem
In QuantumSystem.SetFromTensorProduct, promoted local qubits appear to have weights applied using WithWeights(...), but the returned value may be discarded.
If WithWeights returns a new qubit for local/non-system qubits, then calling it without assigning the result may silently lose the intended weights.
Why this matters
This could produce incorrect global wavefunctions when constructing a QuantumSystem from locally weighted qubits.
It is also an API trap because WithWeights appears to behave differently depending on whether a qubit is system-managed or local.
Suggested approach
Review the SetFromTensorProduct promotion path and ensure the result of WithWeights(...) is preserved.
For example:
sysQ = sysQ.WithWeights(weights, false);
or replace this with a clearer explicit in-place system method if that better matches the intended design.
Acceptance criteria
- Weighted local qubits retain their amplitudes after being promoted into a
QuantumSystem.
- A regression test proves exact amplitude preservation after
SetFromTensorProduct.
- The test fails against the old behaviour and passes after the fix.
Problem
In
QuantumSystem.SetFromTensorProduct, promoted local qubits appear to have weights applied usingWithWeights(...), but the returned value may be discarded.If
WithWeightsreturns a new qubit for local/non-system qubits, then calling it without assigning the result may silently lose the intended weights.Why this matters
This could produce incorrect global wavefunctions when constructing a
QuantumSystemfrom locally weighted qubits.It is also an API trap because
WithWeightsappears to behave differently depending on whether a qubit is system-managed or local.Suggested approach
Review the
SetFromTensorProductpromotion path and ensure the result ofWithWeights(...)is preserved.For example:
or replace this with a clearer explicit in-place system method if that better matches the intended design.
Acceptance criteria
QuantumSystem.SetFromTensorProduct.