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

[compiler driver] improving pipeline parsing #1519

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

erick-xanadu
Copy link
Contributor

@erick-xanadu erick-xanadu commented Feb 13, 2025

Context: MLIR uses pipelines, Catalyst also uses pipelines. However, unlike MLIR pipelines, Catalyst's pipelines have names. This makes the syntax for denoting pipelines a little bit different.

Description of the Change: Make the syntax match better. Use multiple --catalyst-pipeline commands to denote multiple pipelines. Detects whether async is necessary by checking the passes instead of passing it through the command line.

Benefits: Avoid custom parsing. Have the same syntax for MLIR pipelines and Catalyst pipelines. Unlocks the possibility of multithreading compilation by using the regular pipeline syntax to denote function level passes.

Possible Drawbacks:

Related GitHub Issues:

Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.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.

@erick-xanadu erick-xanadu force-pushed the eochoa/2025-02-13/improving-pipeline-parsing branch from d68e5dc to c22bc18 Compare February 13, 2025 18:36
@erick-xanadu erick-xanadu marked this pull request as ready for review February 13, 2025 18:39
@erick-xanadu erick-xanadu force-pushed the eochoa/2025-02-13/improving-pipeline-parsing branch from c22bc18 to 765267a Compare February 18, 2025 15:52
Copy link
Contributor

@mehrdad2m mehrdad2m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @erick-xanadu, This looks good. The only comment I have is that this change should be reflected on the catalyst CLI documentation as well.

@erick-xanadu erick-xanadu force-pushed the eochoa/2025-02-13/improving-pipeline-parsing branch from 765267a to 6c854ee Compare March 25, 2025 20:22
Copy link

codecov bot commented Mar 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.08%. Comparing base (a31bc29) to head (228f33f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1519      +/-   ##
==========================================
- Coverage   96.08%   96.08%   -0.01%     
==========================================
  Files          81       81              
  Lines        8615     8614       -1     
  Branches      816      817       +1     
==========================================
- Hits         8278     8277       -1     
  Misses        280      280              
  Partials       57       57              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@@ -212,7 +221,7 @@ pass that is applied, and the ``-o`` option to set the name of the output IR fil

catalyst my_circuit.mlir \
--tool=opt \
--catalyst-pipeline="pipe(remove-chained-self-inverse;merge-rotations)" \
--catalyst-pipeline="pipe:builtin(remove-chained-self-inverse,merge-rotations)" \
Copy link
Contributor

@mehrdad2m mehrdad2m Mar 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--catalyst-pipeline="pipe:builtin(remove-chained-self-inverse,merge-rotations)" \
--catalyst-pipeline="pipe:remove-chained-self-inverse,merge-rotations" \

same here and some other places in the docs

applies the passes ``split-multiple-tapes`` and ``apply-transform-sequence``, and where ``pipe2``
applies the pass ``inline-nested-module``, we would specify this pipeline configuration as:

.. code-block::

--catalyst-pipeline="pipe1(split-multiple-tapes;apply-transform-sequence),pipe2(inline-nested-module)"
--catalyst-pipeline='pipe1:builtin-module(split-multiple-tapes,apply-transform-sequence)'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--catalyst-pipeline='pipe1:builtin-module(split-multiple-tapes,apply-transform-sequence)'
--catalyst-pipeline='pipe1:split-multiple-tapes,apply-transform-sequence'

I don't think we actually need to have the builtin.module wrapper anymore do we?
This is how the tests are calling the pipeline anyways.

// RUN: catalyst --tool=opt %s -cse --dump-catalyst-pipeline --verify-diagnostics 2>&1 | FileCheck %s --check-prefix=CHECK-ONE-PASS
// RUN: not catalyst --tool=opt %s -cse --catalyst-pipeline="pipe1(split-multiple-tapes;apply-transform-sequence),pipe2(inline-nested-module)" --dump-catalyst-pipeline --verify-diagnostics 2>&1 | FileCheck %s --check-prefix=CHECK-FAIL
// RUN: not catalyst --tool=opt %s -cse --catalyst-pipeline="pipe1:builtin.module(split-multiple-tapes,apply-transform-sequence)" --catalyst-pipeline="pipe2:inline-nested-module" --dump-catalyst-pipeline --verify-diagnostics 2>&1 | FileCheck %s --check-prefix=CHECK-FAIL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we have one case with builtin.module here, but this is a case that should fail so it is not actually verifying whether builtin.module is working.

Suggested change
// RUN: not catalyst --tool=opt %s -cse --catalyst-pipeline="pipe1:builtin.module(split-multiple-tapes,apply-transform-sequence)" --catalyst-pipeline="pipe2:inline-nested-module" --dump-catalyst-pipeline --verify-diagnostics 2>&1 | FileCheck %s --check-prefix=CHECK-FAIL
// RUN: not catalyst --tool=opt %s -cse --catalyst-pipeline="pipe1:split-multiple-tapes,apply-transform-sequence" --catalyst-pipeline="pipe2:inline-nested-module" --dump-catalyst-pipeline --verify-diagnostics 2>&1 | FileCheck %s --check-prefix=CHECK-FAIL

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

Successfully merging this pull request may close these issues.

2 participants