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

Qsoverlay switches order of gates? #18

Closed
Astlaan opened this issue Nov 11, 2019 · 3 comments
Closed

Qsoverlay switches order of gates? #18

Astlaan opened this issue Nov 11, 2019 · 3 comments

Comments

@Astlaan
Copy link

Astlaan commented Nov 11, 2019

Hello,

I'm having a strange behaviour when using qsoverlay:

# Quantumsim (via Qsoverlay) program generated by OpenQL
# Please modify at your will to obtain extra information from Quantumsim

import numpy as np
from qsoverlay import DiCarlo_setup
from qsoverlay.circuit_builder import Builder
from quantumsim.sparsedm import SparseDM

# print('GPU is used:', sparsedm.using_gpu)
#Now the circuit is created

def circuit_generated(noise_flag, setup_name = 'DiCarlo_setup'):
	qubit_list = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16']
	if setup_name == 'DiCarlo_setup':
		setup = DiCarlo_setup.quick_setup(qubit_list, noise_flag = noise_flag)
	b = Builder(setup)
	b.add_gate('prepz', ['5'], time = 620)
	b.add_gate('X', ['5'], time = 630)

	b.finalize()
	return b.circuit

c = circuit_generated(False)
bell_state = SparseDM(c.get_qubit_names())
c.apply_to(bell_state)
measurement_result = bell_state.peak_multiple_measurements(c.get_qubit_names())
print(measurement_result)
print(c.gates)
print(c.gates[0].time)
print(c.gates[1].time)

When I run this program, this is what I get:

[({'0': 0, '1': 0, '10': 0, '11': 0, '12': 0, '13': 0, '14': 0, '15': 0, '16': 0, '2': 0, '3': 0, '4': 0, '6': 0, '7': 0, '8': 0, '9': 0, '5': 0}, 1.0000000000000004), ({'0': 0, '1': 0, '10': 0, '11': 0, '12': 0, '13': 0, '14': 0, '15': 0, '16': 0, '2': 0, '3': 0, '4': 0, '6': 0, '7': 0, '8': 0, '9': 0, '5': 1}, 0.0)]
[<quantumsim.circuit.RotateX object at 0x000001C47C7BA710>, <quantumsim.circuit.ResetGate object at 0x000001C47894F940>]
10.0
620

As it can be seen, the computed output is one of full zeros, despite applying an x gate.
I then checked the gate list in the quantumsim circuit object and, apparently, changed the time of the x gate (in such a manner that it even inverted the order of the gates).

@Astlaan
Copy link
Author

Astlaan commented Nov 19, 2019

Hello,
Any idea on this?
Urgent help is appreciated,

Thanks

@obriente
Copy link
Collaborator

That's very weird, it looks like a bug, but I can't see where it can be in the code. I'm away for the next week though - I'll try to find the time to look at it but I can't promise anything for a while.

@Astlaan
Copy link
Author

Astlaan commented Nov 24, 2019

After verifying a similar behaviour in #19 , made a pull request #20 that should also fix this.

@Astlaan Astlaan closed this as completed Nov 24, 2019
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