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

MLIR Plugin #881

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

MLIR Plugin #881

wants to merge 3 commits into from

Conversation

flowerthrower
Copy link
Contributor

Description

This PR introduces a MLIR plguin such that the round-trip pass can be executed with Pennylane Catalyst.
It additionally provides the plugin as a wheel.

Checklist:

  • The pull request only contains commits that are related to it.
  • I have added appropriate tests and documentation.
  • I have made sure that all CI jobs on GitHub pass.
  • The pull request introduces no new warnings and follows the project's style guidelines.

flush_peephole_opted_mlir_to_iostream(test_pipeline_lowering_workflow)


def test_MQT_plugin() -> bool | None:

Check notice

Code scanning / CodeQL

Explicit returns mixed with implicit (fall through) returns Note test

Mixing implicit and explicit returns may indicate an error as implicit returns always return None.

Copilot Autofix AI 3 days ago

To fix the problem, we need to add an explicit return statement at the end of the test_MQT_plugin function. This will ensure that the function's return value is always clear and consistent, regardless of whether an exception is raised or not. Specifically, we should add a return True statement at the end of the function to indicate that the function completed successfully when no exception is raised.

Suggested changeset 1
mqt_plugin_wheel/mqt_plugin/test/test_mlir_plugin.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/mqt_plugin_wheel/mqt_plugin/test/test_mlir_plugin.py b/mqt_plugin_wheel/mqt_plugin/test/test_mlir_plugin.py
--- a/mqt_plugin_wheel/mqt_plugin/test/test_mlir_plugin.py
+++ b/mqt_plugin_wheel/mqt_plugin/test/test_mlir_plugin.py
@@ -127,2 +127,3 @@
         flush_peephole_opted_mlir_to_iostream(test_pipeline_mqtplugin_workflow)
+        return True
 
EOF
@@ -127,2 +127,3 @@
flush_peephole_opted_mlir_to_iostream(test_pipeline_mqtplugin_workflow)
return True

Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
try:
mlir_str = error_msg.split("module @module_test_pipeline_mqtplugin_workflow_transformed {")[1]
mlir_str = error_msg.split("}\n}")[0]
except:

Check notice

Code scanning / CodeQL

Except block handles 'BaseException' Note test

Except block directly handles BaseException.

Copilot Autofix AI 3 days ago

To fix the problem, we should replace the broad except: block with more specific exception handling. We should catch Exception to handle general errors and allow KeyboardInterrupt and SystemExit to propagate. This ensures that the program can still be interrupted or terminated as expected.

  • Replace the except: block with except Exception: to handle general exceptions.
  • Ensure that KeyboardInterrupt and SystemExit are not caught by this block.
Suggested changeset 1
mqt_plugin_wheel/mqt_plugin/test/test_mlir_plugin.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/mqt_plugin_wheel/mqt_plugin/test/test_mlir_plugin.py b/mqt_plugin_wheel/mqt_plugin/test/test_mlir_plugin.py
--- a/mqt_plugin_wheel/mqt_plugin/test/test_mlir_plugin.py
+++ b/mqt_plugin_wheel/mqt_plugin/test/test_mlir_plugin.py
@@ -133,3 +133,3 @@
             mlir_str = error_msg.split("}\n}")[0]
-        except:
+        except Exception:
             return False
EOF
@@ -133,3 +133,3 @@
mlir_str = error_msg.split("}\n}")[0]
except:
except Exception:
return False
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Copy link

codecov bot commented Mar 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.3%. Comparing base (96b46fc) to head (54f1f19).

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main    #881   +/-   ##
=====================================
  Coverage   92.3%   92.3%           
=====================================
  Files        145     145           
  Lines      13850   13850           
  Branches    2107    2107           
=====================================
+ Hits       12789   12790    +1     
+ Misses      1061    1060    -1     
Flag Coverage Δ
cpp 92.0% <ø> (+<0.1%) ⬆️
python 98.4% <ø> (ø)

see 1 file with indirect coverage changes

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

@flowerthrower flowerthrower added MLIR Anything related to MLIR feature New feature or request labels Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request MLIR Anything related to MLIR
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

1 participant