Skip to content

Conversation

@denialhaag
Copy link
Member

Description

This PR adds conversions for the Jeff dialect.

Related to #1196

Checklist:

  • The pull request only contains commits that are focused and relevant to this change.
  • I have added appropriate tests that cover the new/changed functionality.
  • I have updated the documentation to reflect these changes.
  • I have added entries to the changelog for any noteworthy additions, changes, fixes, or removals.
  • I have added migration instructions to the upgrade guide (if needed).
  • The changes follow the project's style guidelines and introduce no new warnings.
  • The changes are fully tested and pass the CI checks.
  • I have reviewed my own code changes.

@denialhaag denialhaag self-assigned this Jan 27, 2026
@denialhaag denialhaag added feature New feature or request MLIR Anything related to MLIR labels Jan 27, 2026
@codecov
Copy link

codecov bot commented Jan 27, 2026

Codecov Report

❌ Patch coverage is 92.89773% with 25 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
mlir/lib/Conversion/JeffToQC/JeffToQC.cpp 87.5% 17 Missing ⚠️
mlir/lib/Conversion/QCToJeff/QCToJeff.cpp 96.3% 7 Missing ⚠️
mlir/lib/Conversion/QCToQCO/QCToQCO.cpp 94.7% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Member Author

@denialhaag denialhaag left a comment

Choose a reason for hiding this comment

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

Two problems I have stumbled across so far:

Comment on lines +49 to +50
# Restore C++ standard changed by jeff-mlir
set(CMAKE_CXX_STANDARD 20)
Copy link
Member Author

@denialhaag denialhaag Jan 27, 2026

Choose a reason for hiding this comment

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

The build would currently fail without this workaround, as CMAKE_CXX_STANDARD is set to 17 in jeff-mlir: https://github.com/PennyLaneAI/jeff-mlir/blob/ec59bc0440f45b659ff8b680337ffdbb3c9d6495/CMakeLists.txt#L5

Copy link
Member

Choose a reason for hiding this comment

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

I will try to submit a PR to fix that. We probably want a similar fix in the MQT, where we similarly set the CXX standard to 20.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for fixing it in jeff-mlir! I have created #1480 to fix this issue here. 😌

Comment on lines -149 to -157
add_custom_command(
TARGET mlir-doc
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/docs/
${CMAKE_CURRENT_SOURCE_DIR}/docs/mlir/
COMMAND ${CMAKE_COMMAND} -D DOCS_DIR:PATH=${CMAKE_CURRENT_SOURCE_DIR}/docs/mlir -P
${CMAKE_CURRENT_SOURCE_DIR}/cmake/CleanMLIRDocs.cmake
COMMENT "Copying and cleaning up generated MLIR documentation"
VERBATIM)
Copy link
Member Author

Choose a reason for hiding this comment

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

This currently makes the configuration fail. I don't exactly understand what's going on, but it looks like the mlir-doc target is also being created by jeff-mlir, leading to interference.

Another problem seems to be that calling mlir-doc also triggers the generation of the Jeff documentation in the _deps directory.

Maybe it's possible to add flags to jeff-mlir to toggle the documentation generation. 🤔

@denialhaag
Copy link
Member Author

denialhaag commented Jan 28, 2026

A brief overview of everything that remains open:

Main Function

I have not yet looked into the proper conversion of a QC-style main function to a Jeff-style main function. The current implementation of the tests relies on bare-bones modules without a properly defined entry point. This might require some coordination with Xanadu, as we should align on what a Jeff-style main function exactly looks like. That said, the implementation of the conversion itself should be straightforward.

Unconvertible QC Operations

The following QC operations can currently not be converted to Jeff because they do not have a direct counterpart:

  • SXOp and SXdgOp
  • ROp and U2Op
  • iSWAPOp, DCXOp, and ECROp
  • RXXOp, RYYOp, RZXOp, and RZZOp
  • XXPlusYYOp and XXMinusYYOp
  • BarrierOp

Unconvertible Jeff Operations

The following Jeff operations can currently not be converted to QC because they do not have a direct counterpart:

  • QubitFreeZeroOp (we can convert QubitFreeOps)
  • QubitMeasureOp (we can convert QubitMeasureNDOps)
  • PPROp and CustomOp
  • Everything related to quantum registers

In addition, the following additional conversions are not implemented yet, as I believe their implementation needs further discussion:

  • All numerical operations
  • All SCF operations

Tests

The current version of the tests does not perform proper equivalence checking but relies on (very minimal) string comparisons.

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

None yet

Development

Successfully merging this pull request may close these issues.

3 participants