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

template library organization #5275

Open
ajavadia opened this issue Oct 22, 2020 · 14 comments · May be fixed by #8191
Open

template library organization #5275

ajavadia opened this issue Oct 22, 2020 · 14 comments · May be fixed by #8191
Labels
help wanted community contributions welcome. For filters like http://github-help-wanted.com/ type: enhancement It's working, but needs polishing
Projects

Comments

@ajavadia
Copy link
Member

The template circuits used in the template optimization pass are currently stored in a directory under qiskit.circuit.library.templates. It would be better to store them in a proper library structure like the EquivalenceLibrary, where each entry in the library can be verified for correctness.

@ajavadia ajavadia added the type: enhancement It's working, but needs polishing label Oct 22, 2020
@1ucian0 1ucian0 added this to To do in Circuits via automation Oct 23, 2020
@born-2learn
Copy link

I would like to give this a try, @ajavadia.

@1ucian0
Copy link
Member

1ucian0 commented Dec 14, 2021

hi @born-2learn ! Sorry this felt between the cracks. Are you still interested?

@1ucian0 1ucian0 added the help wanted community contributions welcome. For filters like http://github-help-wanted.com/ label Dec 14, 2021
@ShellyGarion
Copy link
Member

In addition, currently the picture of the circuit of the template appears as a comment in the code, but not in the documentation.
I would suggest to move it in a way that it will appear as part of the documentation.

@born-2learn
Copy link

I'll work on this, thanks!

@1ucian0
Copy link
Member

1ucian0 commented Jan 31, 2022

Assigned! Thanks @born-2learn

@born-2learn
Copy link

Hi, I might have to delay working on this issue due to other engagements. Thanks!

@1ucian0 1ucian0 added the unitaryhack-bounty Issues/PR participating (now or in the past) in the UnitaryHack event see https://unitaryhack.dev/ label May 13, 2022
@cometta
Copy link
Contributor

cometta commented May 31, 2022

Hello @ajavadia
can you explain more by giving an example how we should move clifford in temples/clifford folder into the root folder of qisikit.circuit please ?

@divshacker
Copy link
Contributor

I can also give it a try, but I need some guidance regrading how to arrange and classify all the circuits at once.

@1ucian0
Copy link
Member

1ucian0 commented Jun 6, 2022

The goal of this issue is to create a TemplateLibrary class, similar to EquivalenceLibrary, that can be extended with
TemplateLibrary.append.

@alexanderivrii
Copy link
Contributor

fyi: @ShellyGarion

If I remember correctly, some of the clifford templates are only "up to the global phase", for instance the template S * H * S * H * S * H = Id.

I am wondering if this needs to be taken into account when reorganizing the templates.

We also have code that verifies templates; and again please note that self.assertTrue(target.equiv(value)) only checks equivalence up to the global phase.
`

@ajavadia
Copy link
Member Author

ajavadia commented Jun 6, 2022

Yes. The context for this is this review comment when the original templates were added to Qiskit
#4552 (comment)

A "template", by definition, is a circuit that is equivalent to the identity. So there must be some check somewhere that prohibits defining invalid templates. The ones that ship with Qiskit should be verified with CI. The user-defined ones must be verified when they are being defined as a template. So one way to do this is to make this a proper datastructure/library that contains various templates and additions to the library are checked. And then have methods for drawing the contents of the library. Also a method to reduce the library to some subset of the circuits would be useful. Then let the TemplateMatching transpiler pass accept a library or a subset of it.

And yes the equivalence to Identity should be exact including global phase.

@ShellyGarion
Copy link
Member

Clifford group elements and templates are defined up to a global phase, e.g. the template S * H * S * H * S * H = Id is valid only up to a global phase.
Perhaps it's worth to add a filed to the templates indicating whether they are equal to id or equivalent up to a global phase?

@poig
Copy link
Contributor

poig commented Jun 9, 2022

Is anyone working on this?

@1ucian0
Copy link
Member

1ucian0 commented Jun 10, 2022

Hi @poig, it seems to me there were some attempts to approach the issues, but no PR open yet. This issue is part of the unitary hack initiative so I think it is fine if more than one person works on this. So feel free to jump in :)

@mgg39 mgg39 linked a pull request Jun 16, 2022 that will close this issue
@1ucian0 1ucian0 removed the unitaryhack-bounty Issues/PR participating (now or in the past) in the UnitaryHack event see https://unitaryhack.dev/ label Apr 25, 2023
@1ucian0 1ucian0 added the unitaryhack-bounty Issues/PR participating (now or in the past) in the UnitaryHack event see https://unitaryhack.dev/ label May 4, 2023
@1ucian0 1ucian0 removed the unitaryhack-bounty Issues/PR participating (now or in the past) in the UnitaryHack event see https://unitaryhack.dev/ label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted community contributions welcome. For filters like http://github-help-wanted.com/ type: enhancement It's working, but needs polishing
Projects
Circuits
  
To do
Status: Tagged but unassigned
Development

Successfully merging a pull request may close this issue.

8 participants