Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simulator accuracy #48

Open
ACE07-Sev opened this issue Feb 9, 2024 · 8 comments
Open

Simulator accuracy #48

ACE07-Sev opened this issue Feb 9, 2024 · 8 comments

Comments

@ACE07-Sev
Copy link

ACE07-Sev commented Feb 9, 2024

Greetings dear D-Wave team,

Hope you are well. So, I am having a bit of an issue with the simulator. It doesn't represent the small values like 0.002 amplitudes, which basically when used with algorithms like FRQI, makes it output a numpy array of all 0s. Anything I can do to fix this?

Here's what I get with Cirq for instance :

[0.125      0.125      0.125      0.125      0.125      0.125
 0.125      0.125      0.125      0.125      0.125      0.125
 0.125      0.1221966  0.12381981 0.125      0.125      0.125
 0.125      0.125      0.12480307 0.11370273 0.125      0.125
 0.125      0.125      0.125      0.12498055 0.1087806  0.125
 0.125      0.125      0.125      0.125      0.125      0.11108285
 0.12499628 0.125      0.125      0.125      0.125      0.125
 0.12250098 0.12246352 0.125      0.125      0.125      0.125
 0.125      0.125      0.10999145 0.12485503 0.125      0.125
 0.125      0.125      0.125      0.125      0.125      0.125
 0.125      0.125      0.125      0.125      0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.0263247
 0.01713632 0.         0.         0.         0.         0.
 0.0070138  0.05192965 0.         0.         0.         0.
 0.         0.00220521 0.06157745 0.         0.         0.
 0.         0.         0.         0.05732016 0.00096478 0.
 0.         0.         0.         0.         0.02486988 0.02505364
 0.         0.         0.         0.         0.         0.
 0.05938755 0.00601839 0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.        ]

And here's what I get with D-Wave :

[0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125
 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125
 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125
 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125
 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125
 0.125 0.125 0.125 0.125 0.    0.    0.    0.    0.    0.    0.    0.
 0.    0.    0.    0.    0.    0.    0.    0.    0.    0.    0.    0.
 0.    0.    0.    0.    0.    0.    0.    0.    0.    0.    0.    0.
 0.    0.    0.    0.    0.    0.    0.    0.    0.    0.    0.    0.
 0.    0.    0.    0.    0.    0.    0.    0.    0.    0.    0.    0.
 0.    0.    0.    0.    0.    0.    0.    0.   ]

You see the difference? This is causing my code to break as you can imagine. Is there a way I can fix this? Again, this is only in D-Wave, I tried the code with Qiskit, Cirq, TKET, and PennyLane, and they are running as expected, and can extract these smaller values. I'd appreciate the help on fixing this.

I don't think sharing the code would help really, since I am just passing a large circuit. I believe the issue is with the number of digits the simulator can generate for the result (I think it's limited to three digits?). Kindly let me know if you absolutely would need the code, and I will see if I can make a toy example to reproduce this.

@thisac
Copy link
Collaborator

thisac commented Feb 26, 2024

Hi @ACE07-Sev. I see there's a difference between the two outputs, although it doesn't seem like the issue is the number of digits using to represent the output, as the precision in dwave-gate is higher than that. If you could post a minimal example of this where the outputs differ between e.g., dwave-gate and Cirq, I could look into what might be going on.

@ACE07-Sev
Copy link
Author

Sure, I'll make a notebook. I'll send it here within 48 hours.

@ACE07-Sev
Copy link
Author

Greetings!

Hope you are well. Apologies for the delay. Here is the notebook for your kind reference.
https://drive.google.com/drive/folders/1rmKPaNygngx8pQVqjKrXTQEm-eegs4wS?usp=sharing

@ACE07-Sev
Copy link
Author

So, if you have a look, you'll see the issue I mentioned with the FRQI encoder. I included Shende to show the circuit implementation is correct, and works for that instance. Kindly let me know if you have any questions!

@ACE07-Sev
Copy link
Author

Greetings there,

Hope you are well. Any updates?

@thisac
Copy link
Collaborator

thisac commented Mar 13, 2024

Thanks @ACE07-Sev. I'd appreciate it if you could either upload the notebook to a GitHub repository and reference it here (so that I can have a look at it directly without having to download it) or just post a minimal example which reproduces this issue directly in this issue.

@ACE07-Sev
Copy link
Author

@thisac
Copy link
Collaborator

thisac commented Mar 27, 2024

Thank you for uploading the notebook. I cannot see any issues after a brief look at it, and it's difficult to say if something isn't working as it should. I don't think it's a precision issue since the values that differ from between the two different outputs above don't seem to be rounding errors (but perhaps rather some issue either with the circuit or how it's simulated).

If you have the time to create a minimal example, using as little code as possible, either printing both outputs above for comparison or at least showing a discrepancy between identical circuits using different frameworks, this would be much easier to debug. Also, if you're able to compile the dwave-gate into OpenQASM 2.0 you could try running it using Qiskit and compare the outputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants