CQCL / pytket-cutensornet

cuTensorNet Python API extensions for pytket quantum SDK
Apache License 2.0
8 stars 1 forks source link

[StructuredState] Conflict between `apply_scalar` and normalisation #106

Open PabloAndresCQ opened 1 month ago

PabloAndresCQ commented 1 month ago

The simulation algorithms under StructuredState expect the states are normalised and, in fact whenever there is a truncation, this is enforced. However, the current method apply_scalar allows users to multiply the state by complex numbers with absolute value different to 1. This can lead to bugs when users work with non-normalised states.

As a related issue, the tensors updated by apply_scalar are not currently marked as non-canonicalised. I can't think of a case where the current features would have unexpected behaviour because of this, but there may be edge cases where this also causes a bug.

PabloAndresCQ commented 1 month ago

I possible solution to both problems is not to apply the scalar directly to the tensor network, but instead keep it in a separate variable (similarly to how pytket.Circuit does it), then take it into account where relevant (e.g. when the user asks for amplitudes or statevector).

Another possibility is to just remove apply_scalar altogether, or replace it by an apply_global_phase.