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

one major on missing some key operator like cz and one minor on readme #19

Open
kwccoin opened this issue Oct 16, 2022 · 1 comment
Open

Comments

@kwccoin
Copy link

kwccoin commented Oct 16, 2022

Minor: On the section about "Working with Individual States and gates", one minor issue is that the qc has to be either "qc.reset()" or redefine "qc = ...". I suspect the other issue can be handled.

Major: try to reproduce the circuit of teleport from quirk to composer. It can be done on the IBM openqasm 2.0 composer but not here. The issue is that there is no cz operator. I suspect one can amend these lines but not sure I am expert enough to try.

                ...
		cnot_re=re.compile('^cx (q\[[0-4]\]), (q\[[0-4]\])$')      # <-- need to change to (x|y|z)
		for l in lines:
			l=l.strip()
			if not l: continue
			# CNOT operates on two qubits so gets special processing
			cnot=cnot_re.match(l)
			if cnot:
				control_qubit=cnot.group(1)  #<-- group(2)
				target_qubit=cnot.group(2)   #<-- group(3)
                                # depends upon group(1) and feed group(1) into the function
				l='self.apply_two_qubit_gate_CNOT(%s,%s'%(control_qubit,target_qubit) #<-- major change needed
			for k,v in translation:
				l=l.replace(k,v)
			l=l+')'
			# Now running the code
			exec(l,globals(),locals())
                        ...

Somehow the cx in the first line need to increase to cover cy and cz and then apply the appropriate logic to it (the line l="..." for the "translation".

The regular expression might be easily fixed by changing into something like

cnot_re=re.compile('^c(x|y|z} (q\[[0-4]\]), (q\[[0-4]\])$')

and some change in logic of the "if cnot" so to use group 2 and 3 not 1 and 2 and use group 1 to handle cx/cy/cz

But the logic under self.apply_two_qubit_gate_CNOT is not that easy as it involved different way to handle cx/cy/cz gate change.

@kwccoin kwccoin changed the title One minor on readme one major on missing some key operator like cz one major on missing some key operator like cz and one minor on readme Oct 17, 2022
@kwccoin
Copy link
Author

kwccoin commented Oct 17, 2022

I test the change to the code

		cnot_re=re.compile('^(cx|cy|cz) (q\[[0-4]\]), (q\[[0-4]\])$')
		for l in lines:
			l=l.strip()
			if not l: continue
			# CNOT operates on two qubits so gets special processing
			cnot=cnot_re.match(l)
			if cnot:
				control_qubit=cnot.group(2)
				target_qubit=cnot.group(3)

It should be fine of course that means cy and cz now all cx which is not right.

However to do cy and cz require touching the Gate Class. A lot of not sure about this why there is a need to change basis (see wiki CNOT especially the one on 2 bit using H as its own inverse (See (H1 ⊗ H1)−1 . CNOT . (H1 ⊗ H1)) to H2 . CNOT . H2 which is in the logic. But why CNOT 0->1 use simple logic and CNOT 1-> 0 not. Still working on it. Also the whole class is handcrafted; need some programming as said in the "TODO" section but that is 7 years ago.

Possibly above my "pay grade"!

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

1 participant