Density matrix returning complex conjugate
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1.1k
- Forks
- 456
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 165
Description
Required prerequisites
- Consult the security policy. If reporting a security vulnerability, do not report the bug using this form. Use the process described in the policy to report the issue.
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker to verify that this hasn't already been reported. +1 or comment there if it has.
- If possible, make a PR with a failing test to give us a starting point to work on!
Describe the bug
import cudaq
import numpy as np
@cudaq.kernel
def kernel_a():
q = cudaq.qvector(1)
u3(1,2,3, q[0])
cudaq.set_target('density-matrix-cpu')
a0 = cudaq.get_state(kernel_a)
print(np.array(a0))
cudaq.set_target('qpp-cpu')
statevec = cudaq.get_state(kernel_a)
psi = np.array(statevec).reshape(-1,1)
psi_dagger = psi.conj().T
rho = np.outer(psi, psi_dagger)
The code above shows how one can manually compute the density matrix via the statevec simulator or directly via the density matrix simulator.
a0 and rho differ by a complex conjugate.
Physically they are the same states hence it does not matter but we should keep our convention consistent.
Steps to reproduce the bug
NA
Expected behavior
NA
Is this a regression? If it is, put the last known working version (or commit) here.
Not a regression
Environment
- CUDA-Q version:
- Python version:
- C++ compiler:
- Operating system:
Suggestions
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied Python snippet with the density-matrix-cpu and qpp-cpu targets, comparing a0 with the manually computed rho. Trace the get_state paths for both targets and identify where the conjugation convention differs. Done means both paths return the same density-matrix convention, with a regression test covering the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- quantum-computing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100