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

Change --split-multiple-tapes into a module pass #1130

Merged
merged 7 commits into from
Sep 12, 2024

Conversation

paul0403
Copy link
Contributor

@paul0403 paul0403 commented Sep 11, 2024

Context:
It was discovered that if --split-multiple-tapes is a function pass, then the outlining for the multitape functions will be done in parallel, causing their outlined functions to be created (and hence injected into the parent module) at stochastic times, so the order of the outlined functions is not guaranteed. This is causing a mlir lit test to be flaky https://github.com/PennyLaneAI/catalyst/blob/main/mlir/test/Catalyst/SplitMultipleTapesTest.mlir#L67.

Moreover, MLIR mandates that OperationPass cannot change the parent operation of the pass's target https://mlir.llvm.org/docs/PassManagement/#operation-pass. In our case the target of the pass is the multitape functions, but the outlined single tape functions are injected into their parent module. This violates the MLIR standards.

Description of the Change:
Change --split-multiple-tapes to a module pass.
Also move the pass to Quantum dialect.

Benefits:
No race condition during tests; better conforming to MLIR standards.

Copy link

codecov bot commented Sep 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.62%. Comparing base (d79ac79) to head (8642d39).
Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1130   +/-   ##
=======================================
  Coverage   97.62%   97.62%           
=======================================
  Files          75       75           
  Lines       10758    10758           
  Branches     1251     1251           
=======================================
  Hits        10503    10503           
  Misses        205      205           
  Partials       50       50           

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

@paul0403 paul0403 merged commit 5521a9c into main Sep 12, 2024
42 of 43 checks passed
@paul0403 paul0403 deleted the split_tapes_module_pass branch September 12, 2024 13:43
mehrdad2m pushed a commit that referenced this pull request Sep 17, 2024
**Context:**
It was discovered that if `--split-multiple-tapes` were a function pass,
then the outlining for the multitape functions will be done in parallel,
causing their outlined functions to be created (and hence injected into
the parent module) at stochastic times, so the order of the outlined
functions is not guaranteed. This is causing a mlir lit test to be flaky
https://github.com/PennyLaneAI/catalyst/blob/main/mlir/test/Quantum/SplitMultipleTapesTest.mlir#L67.

Moreover, MLIR mandates that `OperationPass` cannot change the parent
operation of the pass's target
https://mlir.llvm.org/docs/PassManagement/#operation-pass. In our case
the target of the pass is the multitape functions, but the outlined
single tape functions are injected into their parent module. This
violates the MLIR standards.

**Description of the Change:**
Change `--split-multiple-tapes` to a module pass.
Also move the pass to `Quantum` dialect.

**Benefits:** 
No race condition during tests; better conforming to MLIR standards.
rauletorresc pushed a commit that referenced this pull request Oct 9, 2024
**Context:**
It was discovered that if `--split-multiple-tapes` were a function pass,
then the outlining for the multitape functions will be done in parallel,
causing their outlined functions to be created (and hence injected into
the parent module) at stochastic times, so the order of the outlined
functions is not guaranteed. This is causing a mlir lit test to be flaky
https://github.com/PennyLaneAI/catalyst/blob/main/mlir/test/Quantum/SplitMultipleTapesTest.mlir#L67.

Moreover, MLIR mandates that `OperationPass` cannot change the parent
operation of the pass's target
https://mlir.llvm.org/docs/PassManagement/#operation-pass. In our case
the target of the pass is the multitape functions, but the outlined
single tape functions are injected into their parent module. This
violates the MLIR standards.

**Description of the Change:**
Change `--split-multiple-tapes` to a module pass.
Also move the pass to `Quantum` dialect.

**Benefits:**
No race condition during tests; better conforming to MLIR standards.
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