entangled-xyz / scotty

Quantum computing framework for Java and Scala developers.
https://www.entangled.xyz/scotty/
Apache License 2.0
24 stars 2 forks source link

Incorrect measurements for simplest circuits #50

Closed RomanPylypchuk closed 3 years ago

RomanPylypchuk commented 3 years ago

For trivial circuits on 2 qbits like:

  1. Circuit(X(0), X(1), X(0)) stats should be |01> only, for some reason simulation gives only 10.
  2. Circuit(X(0), CNOT(0, 1), X(0)) [this is inverse CNOT], stats should be |01> only, again, for some reason simulation gives only 10.
vasinov commented 3 years ago

@RomanPylypchuk Scotty uses little-endian for registers and redouts, so the results you're getting are correct.

RomanPylypchuk commented 3 years ago

Yes, sorry, I understood it just a while after posting this issue, and closed it. It is strange for a person with physics background to see such notation for qubit basis states. Will someone be adding any new features to this framework? It seems like there were no commits for the last 2 years) I've started writing some quantum machine learning code using Scotty for learning purposes, and faced the problem of having to write many essential things from scratch. For example, there is no inverse CNOT gate. I've built it is as CompositeGate, but then if you try to build inverse CCNOT using Controlled of that inverse CNOT, this fails type match in finalTarget in ControlGate trait, since CompositeGate is neither a ControlGate nor TargetGate. And this also applies to building any single qubit unitary, controlled by a few qubits pattern as one gate. For now, I've implemented this on a circuit level, but I expect, that for bigger quantum algorithms such limitations might quickly become a nuisance.

vasinov commented 3 years ago

@RomanPylypchuk, sorry for the delayed response!

It is strange for a person with physics background to see such notation for qubit basis states.

I've definitely seen both. For example, the pyQuil Wavefunction Simulator also uses little-endian.

Will someone be adding any new features to this framework?

If there is any meaningful demand for new features I will work on it. Currently, the simulator is only useful for toy projects as it doesn't scale out horizontally. One interesting possibility is adding support for distributed states and gate applications via Ray, Dask, or Spark distributed primitives.

I've started writing some quantum machine learning code using Scotty for learning purposes, and faced the problem of having to write many essential things from scratch

It would definitely help to have more gate implementations added. Currently, it should be possible to implement most gates with existing primitives though.

I've built it is as CompositeGate, but then if you try to build inverse CCNOT using Controlled of that inverse CNOT

Could you post example code for this?