catalyst icon indicating copy to clipboard operation
catalyst copied to clipboard

Added an empty pass boilerplate as a tutorial

Open paul0403 opened this issue 1 year ago • 6 comments

Context: Added a tutorial for writing an empty pass boilerplate in the catalyst dialect that prints out hello world. The boilerplate code is on branch docs/new-pass-tutorial in commit https://github.com/PennyLaneAI/catalyst/commit/a857655b2f7afef6de19cdc1faaa226243e0bb58

Benefits: A tutorial for the pass boilerplate infrastructure for those who want to write custom passes.

[sc-67240]

paul0403 avatar Jun 26 '24 14:06 paul0403

Hello. You may have forgotten to update the changelog! Please edit doc/changelog.md on your branch with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

github-actions[bot] avatar Jun 26 '24 15:06 github-actions[bot]

100 extra points to fuse this with the QubitUnitaryFusion example below. I tried to create a pass using the provided example code but still struggle with the boilerplate and where to put what (I might also just represent the lower bar of potential users for this 😓 )

If I understand it correctly, most passes are organized in two separate files: one for the pattern and one for the pass. In this tutorial we only cover the pass. The QubitUnitaryFusion example covers the patterns (and briefly the pass). Would be amazing to be able to have both 😇

Qottmann avatar Jun 27 '24 12:06 Qottmann

Thanks @paul0403, this is a great idea!

There are four improvements I can think of:

  • Like Korbinian is saying, it would be better if the example pass would actually contain the pass described in the existing tutorial, rather than being a separate example altogether.
  • Rather than committing the pass into the main branch and having useless/example code float around the source tree, we could also put it in a branch and link to it in the guide as an easily cherry-pickable commit. This is the approach I followed in the dialect guide.
  • I would like to see a simplified form of adding a new pass that includes less files and boilerplate than what we usually use in Catalyst (the extra boilerplate only starts to become useful when there many different passes/dialects/patterns/etc to organize, but would be detracting from the main point in the tutorial).
  • I think the "how to run the pass" section should come closer to the end of the guide after the "how to write a pass" has been explained.

dime10 avatar Jul 18 '24 22:07 dime10

@paul0403 It would be nice to have for the release

rmoyard avatar Aug 19 '24 19:08 rmoyard

  • Rather than committing the pass into the main branch and having useless/example code float around the source tree, we could also put it in a branch and link to it in the guide as an easily cherry-pickable commit. This is the approach I followed in the dialect guide.

I have moved all the boilerplate code to a new branch docs/new-pass-tutorial in a commit https://github.com/PennyLaneAI/catalyst/commit/a857655b2f7afef6de19cdc1faaa226243e0bb58

This PR (which is the one that will go into main) now only contains the documentation (which links to that commit)

i.e. we do the same thing as the dialect guide

paul0403 avatar Aug 20 '24 18:08 paul0403

Minor: I think the page is now a bit too long, could we separate it to a new one? Maybe we can have a new page: Your first Catalyst pass. @josh146 @dime10

  • Like Korbinian is saying, it would be better if the example pass would actually contain the pass described in the existing tutorial, rather than being a separate example altogether.
  • I think the "how to run the pass" section should come closer to the end of the guide after the "how to write a pass" has been explained.

So I'm thinking of having all this "boilerplate setup" guide to be its own page. Then on the existing guide (with the fusing unitary example), we supply the full working pass's code listing at the end (with boilerplate), like what llvm Kaleidoscope tutorial does. Thoughts?

paul0403 avatar Aug 20 '24 19:08 paul0403