Skip to content

Conversation

@MatthiasReumann
Copy link
Collaborator

@MatthiasReumann MatthiasReumann commented Oct 31, 2025

Description

This pull request adds an option --arch to the placement, routing, and verification pass which specifies the name of the targeted architecture. I've also updated the interface s.t. the getArchitecture function takes a string instead of an enum to prepare for the eventual use of QDMI. The tests are updated accordingly.

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.

Summary by CodeRabbit

  • New Features

    • Added architecture selection option to placement, routing, and verification passes.
    • Added support for the IBM‑Falcon quantum processor architecture.
  • Bug Fixes

    • Improved preflight validation with clearer error reporting for missing or unknown architecture options.
  • Tests

    • Expanded tests to cover multiple architectures and routing strategies.
    • Added tests for invalid and missing architecture option scenarios.
  • Chores

    • Updated changelog entries to reference related changes.

@codecov
Copy link

codecov bot commented Oct 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Member

@burgholzer burgholzer left a comment

Choose a reason for hiding this comment

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

Just some very quick drive-by comments because I had some time during taxiing ✈️

@MatthiasReumann
Copy link
Collaborator Author

@coderabbitai full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 31, 2025

✅ Actions performed

Full review triggered.

@MatthiasReumann MatthiasReumann marked this pull request as ready for review October 31, 2025 12:43
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 31, 2025

📝 Walkthrough

Walkthrough

Refactors architecture selection from enum-based to string-based (llvm::StringRef), removes a RoutingMethod enum, adds a required arch pass option to three MLIR passes, introduces "IBM-Falcon" architecture, adds preflight/validation to passes, updates ownership to std::unique_ptr<Architecture>, and adds tests for missing/invalid archs and arch-specific runs.

Changes

Cohort / File(s) Summary
Changelog
CHANGELOG.md
Added PR reference [#1279] to Unreleased routing entry and appended corresponding link anchor.
Public API / Headers
mlir/include/mlir/Dialect/MQTOpt/Transforms/Passes.h
Removed RoutingMethod enum declaration.
Pass TableGen
mlir/include/mlir/Dialect/MQTOpt/Transforms/Passes.td
Added archName ("arch", std::string) option to PlacementPassSC, RoutingPassSC, and RoutingVerificationSCPass.
Architecture API
mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Architecture.h
Removed ArchitectureName enum; changed getArchitecture() signature to accept llvm::StringRef; added StringRef include.
Architecture Implementation
mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/Architecture.cpp
Rewrote getArchitecture to dispatch on string names, added "IBM-Falcon" support (static coupling map), updated "MQT-Test" path, and return nullptr for unknown names.
Pass Implementations
mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/PlacementPass.cpp, .../RoutingPass.cpp, .../RoutingVerificationPass.cpp
Added preflight() checks for required arch option; obtain architecture via getArchitecture(archName) and error/signal failure when missing/unsupported; RoutingVerificationPass switched to owning Architecture with std::unique_ptr and updated verification context/constructor and includes; getMapper now accepts architecture.
Tests (updated)
mlir/test/Dialect/MQTOpt/Transforms/Transpilation/basics.mlir, .../grover_5.mlir, .../routing-placement.mlir, .../routing-verification.mlir
Updated RUN lines to pass explicit arch=MQTTest/arch=IBMFalcon, unified FileCheck labels, and expanded routing-run variants to cover architectures and methods.
Tests (new)
mlir/test/Dialect/MQTOpt/Transforms/Transpilation/invalid-arch-option.mlir, mlir/test/Dialect/MQTOpt/Transforms/Transpilation/missing-arch-option.mlir
Added tests verifying diagnostics for invalid architecture names and for missing required arch option.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor User
    participant Pass as MLIR Pass
    participant Preflight as preflight()
    participant Arch as getArchitecture(llvm::StringRef)
    participant Mapper as Mapper / Verifier

    User->>Pass: run (with --arch=<name>)
    Pass->>Preflight: preflight()
    Preflight-->>Pass: success / failure
    alt preflight fails
        Pass->>User: emit error, signalPassFailure
    else preflight succeeds
        Pass->>Arch: getArchitecture(archName)
        alt arch found
            Arch-->>Pass: unique_ptr<Architecture>
            Pass->>Mapper: construct with architecture
            Mapper-->>User: run transforms / verification (success)
        else arch not found
            Arch-->>Pass: nullptr
            Pass->>User: emit error, signalPassFailure
        end
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Areas to inspect closely:
    • Architecture string-dispatch logic and exact name matching (case, spelling).
    • Ownership changes to Architecture (use of std::unique_ptr) and all callsites to prevent dangling references.
    • Pass preflight() behavior, diagnostic messages, and consistent signalPassFailure usage.
    • Tests referencing IBMFalcon coupling map correctness.

Possibly related PRs

Suggested labels

feature, c++, MLIR

Suggested reviewers

  • ystade
  • burgholzer

Poem

🐰 I hopped from enums into StringRef light,
IBM‑Falcon added, ready for flight.
Preflight checks guard the pass at the door,
Tests now ask "arch?" and refuse to ignore.
A little rabbit cheers for code and more. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "Add --arch option to MLIR Routing Pass" is clearly related to the main change in the changeset—specifically, the addition of a new command-line option to specify the targeted architecture. While the changeset shows that the --arch option was added to three passes (PlacementPassSC, RoutingPassSC, and RoutingVerificationSCPass), the title accurately captures a key aspect of the changes by referencing the routing pass. The title is specific, clear, and not misleading, even though it doesn't capture the full scope of all three affected passes.
Description Check ✅ Passed The pull request description aligns well with the template structure. It provides a clear summary of the changes—adding the --arch option to placement, routing, and verification passes, and updating the getArchitecture interface from enum to string—along with helpful context about preparing for QDMI integration. The checklist is fully completed with all boxes checked, indicating the author has verified the required practices. While the description does not explicitly mention dependencies or link to a specific issue, these sections appear not to be applicable for this change, and the description still covers the essential summary and context required by the template.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch enh/mlir-routing-pass-arch-option

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7a2e36d and 9937519.

📒 Files selected for processing (2)
  • mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/PlacementPass.cpp (3 hunks)
  • mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/RoutingPass.cpp (3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-09T13:25:36.887Z
Learnt from: DRovara
Repo: munich-quantum-toolkit/core PR: 1108
File: mlir/lib/Dialect/MQTOpt/Transforms/ReuseQubitsPattern.cpp:98-100
Timestamp: 2025-10-09T13:25:36.887Z
Learning: In MLIR code, when traversing parent operations to find a common block between two operations where one uses the result of another, explicit bounds checking is not necessary. MLIR's SSA properties and scope locality guarantees ensure that operations using results must be in compatible scopes and will always share a common ancestor in the operation hierarchy.

Applied to files:

  • mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/RoutingPass.cpp
🧬 Code graph analysis (2)
mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/PlacementPass.cpp (3)
mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/RoutingPass.cpp (3)
  • preflight (500-518)
  • arch (521-521)
  • archName (538-545)
mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/RoutingVerificationPass.cpp (2)
  • preflight (230-281)
  • archName (284-291)
mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/Architecture.cpp (2)
  • getArchitecture (88-152)
  • getArchitecture (88-88)
mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/RoutingPass.cpp (3)
mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/PlacementPass.cpp (6)
  • preflight (430-450)
  • arch (454-454)
  • archName (472-479)
  • nodiscard (80-84)
  • nodiscard (98-103)
  • nodiscard (453-470)
mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/RoutingVerificationPass.cpp (2)
  • preflight (230-281)
  • archName (284-291)
mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/Architecture.cpp (5)
  • getArchitecture (88-152)
  • getArchitecture (88-88)
  • nodiscard (24-40)
  • nodiscard (42-49)
  • nodiscard (83-86)
🔇 Additional comments (8)
mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/PlacementPass.cpp (4)

33-33: LGTM!

The Diagnostics header is correctly included to support the error emission in preflight validation.


430-442: LGTM!

The preflight validation and architecture retrieval follow the same defensive pattern as in RoutingPass.cpp and RoutingVerificationPass.cpp, ensuring consistency across all three passes. The early return on failure prevents downstream errors.


463-463: LGTM!

The debug message formatting is clear and consistent with logging conventions in the codebase.


471-479: LGTM!

The preflight validation is consistent with the identical implementations in RoutingPass.cpp and RoutingVerificationPass.cpp. The error message is clear and actionable. Based on learnings, this pattern is the accepted workaround for LLVM not supporting required pass parameters at the pass level.

mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/RoutingPass.cpp (4)

35-35: LGTM!

The Diagnostics header is correctly included to support the error emission in preflight validation.


500-512: LGTM!

The preflight validation and architecture retrieval follow the same defensive pattern as in PlacementPass.cpp and RoutingVerificationPass.cpp, ensuring consistency across all three passes. The use of non-const auto is correct since the architecture is moved to getMapper on line 514.


521-536: LGTM!

The updated signature correctly accepts the architecture as a std::unique_ptr, and both routing method branches properly transfer ownership to the Mapper constructor using std::move. This replaces the previous hardcoded architecture with the validated, user-specified one.


538-545: LGTM!

The preflight validation is consistent with the identical implementations in PlacementPass.cpp and RoutingVerificationPass.cpp. The error message is clear and actionable. Based on learnings, this pattern is the accepted workaround for LLVM not supporting required pass parameters at the pass level.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 31, 2025

📝 Walkthrough

Walkthrough

This pull request transitions architecture specification from compile-time enum-based to runtime string-based configuration across MLIR quantum optimization passes. ArchitectureName enum is removed; passes now accept architecture names as string options; Architecture lookup uses llvm::StringRef; preflight validation ensures required arch parameters are provided.

Changes

Cohort / File(s) Summary
Documentation
CHANGELOG.md
Updated unreleased section to reference PR #1279 for A*-search routing algorithm; added corresponding PR link entry.
Pass Declarations
mlir/include/mlir/Dialect/MQTOpt/Transforms/Passes.h
Removed extraneous blank line between public enum declarations.
Pass Configuration
mlir/include/mlir/Dialect/MQTOpt/Transforms/Passes.td
Added archName string option (alias arch) to PlacementPassSC, RoutingPassSC, and RoutingVerificationSCPass for architecture specification.
Architecture Interface
mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Architecture.h
Removed public ArchitectureName enum; changed getArchitecture() signature to accept llvm::StringRef name instead of const ArchitectureName&.
Architecture Implementation
mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/Architecture.cpp
Replaced enum-based dispatcher with string-based lookup; changed function signature to accept llvm::StringRef; added IBM-Falcon architecture (127 nodes); MQT-Test now uses static coupling data; returns nullptr for unrecognized architectures instead of throwing.
Placement Pass Implementation
mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/PlacementPass.cpp
Added preflight() validation method; updated runOnOperation() to validate archName presence before retrieving architecture; emits error on missing or unsupported arch.
Routing Pass Implementation
mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/RoutingPass.cpp
Added preflight() validation; updated runOnOperation() to validate and resolve architecture; changed getMapper() signature to accept std::unique_ptr<Architecture> parameter.
Routing Verification Pass Implementation
mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/RoutingVerificationPass.cpp
Swapped Architecture storage from raw pointer to std::unique_ptr; added constructor inheritance; introduced preflight() validation; reworked initialization to validate archName before constructing VerificationContext.
Test Updates — Existing
mlir/test/Dialect/MQTOpt/Transforms/Transpilation/basics.mlir, grover_5.mlir, routing-placement.mlir, routing-verification.mlir
Updated RUN directives to include arch parameter (MQTTest or IBMFalcon) for placement and routing passes; replaced per-implementation FileCheck prefixes (NAIVE/ASTAR) with uniform CHECK-LABEL patterns.
Test Updates — Error Coverage
mlir/test/Dialect/MQTOpt/Transforms/Transpilation/invalid-arch-option.mlir, missing-arch-option.mlir
Added two new MLIR test files validating error handling: invalid-arch-option tests unsupported architecture errors; missing-arch-option tests missing required arch option.

Sequence Diagram

sequenceDiagram
    participant Pass as Pass (Placement/Routing/Verification)
    participant Preflight as preflight()
    participant GetArch as getArchitecture()
    participant Context as VerificationContext/<br/>Mapper

    Pass->>Preflight: preflight() — validate archName
    alt archName missing
        Preflight-->>Pass: error + failure
        Pass->>Pass: emitError, signal failure
    else archName present
        Preflight-->>Pass: success
        Pass->>GetArch: getArchitecture(archName)
        alt valid architecture
            GetArch-->>Pass: unique_ptr<Architecture>
            Pass->>Context: initialize with arch
            Context-->>Pass: ready
        else invalid architecture
            GetArch-->>Pass: nullptr
            Pass->>Pass: emitError, signal failure
        end
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Architecture signature changes: The getArchitecture() function signature changes from enum-based to string-based dispatch, affecting type safety and validation semantics; review must verify correctness of string comparisons and architecture data (especially new IBM-Falcon topology).
  • Ownership model changes: Transition from raw pointers to std::unique_ptr<Architecture> in VerificationContext and getMapper; verify lifetime management and move semantics are correct across all pass implementations.
  • Validation patterns: New preflight() methods replicate similar validation logic across three passes (PlacementPassSC, RoutingPassSC, RoutingVerificationPassSC); ensure consistency and error reporting.
  • Test updates: Multiple test files updated with arch parameters and CHECK-LABEL changes; verify test coverage is complete and reflects both success and error paths.

Possibly related PRs

Suggested labels

feature, c++, MLIR

Suggested reviewers

  • burgholzer
  • ystade

Poem

🐰 Architectures now bloom in strings so bright,
No enums bound, we've set them free in flight!
From MQT-Test to Falcon's wings unfold,
Preflight checks ensure our story's told.
Runtime routing, validation's delight! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title states "Add --arch option to MLIR Routing Pass," which accurately describes a key aspect of the changeset. The raw summary and PR description indicate that the PR adds the --arch option to three passes: PlacementPassSC, RoutingPassSC, and RoutingVerificationSCPass. While the title specifically mentions only the routing pass and doesn't fully capture the scope (which also includes placement and verification passes), it clearly refers to a real and important part of the change. The title is concise, clear, and would help a teammate understand that architecture selection is being added to MLIR passes.
Description Check ✅ Passed The pull request description follows the provided template structure and includes all required sections. It provides a clear summary of the changes (adding --arch option to placement, routing, and verification passes, and updating getArchitecture to accept strings instead of enums), explains the motivation (preparation for QDMI), and includes a comprehensive checklist with all items marked complete. The description is specific enough to convey meaningful information about the changeset and covers the essential aspects of the PR's objectives.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch enh/mlir-routing-pass-arch-option

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e9991b0 and 49fb32b.

📒 Files selected for processing (14)
  • CHANGELOG.md (2 hunks)
  • mlir/include/mlir/Dialect/MQTOpt/Transforms/Passes.h (0 hunks)
  • mlir/include/mlir/Dialect/MQTOpt/Transforms/Passes.td (3 hunks)
  • mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Architecture.h (2 hunks)
  • mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/Architecture.cpp (2 hunks)
  • mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/PlacementPass.cpp (3 hunks)
  • mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/RoutingPass.cpp (3 hunks)
  • mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/RoutingVerificationPass.cpp (4 hunks)
  • mlir/test/Dialect/MQTOpt/Transforms/Transpilation/basics.mlir (7 hunks)
  • mlir/test/Dialect/MQTOpt/Transforms/Transpilation/grover_5.mlir (1 hunks)
  • mlir/test/Dialect/MQTOpt/Transforms/Transpilation/invalid-arch-option.mlir (1 hunks)
  • mlir/test/Dialect/MQTOpt/Transforms/Transpilation/missing-arch-option.mlir (1 hunks)
  • mlir/test/Dialect/MQTOpt/Transforms/Transpilation/routing-placement.mlir (1 hunks)
  • mlir/test/Dialect/MQTOpt/Transforms/Transpilation/routing-verification.mlir (1 hunks)
💤 Files with no reviewable changes (1)
  • mlir/include/mlir/Dialect/MQTOpt/Transforms/Passes.h
🧰 Additional context used
🧠 Learnings (6)
📚 Learning: 2025-10-09T13:20:11.483Z
Learnt from: DRovara
Repo: munich-quantum-toolkit/core PR: 1108
File: mlir/test/Dialect/MQTOpt/Transforms/lift-measurements.mlir:269-288
Timestamp: 2025-10-09T13:20:11.483Z
Learning: In the MQT MLIR dialect, the `rz` gate should not be included in the `DIAGONAL_GATES` set for the `ReplaceBasisStateControlsWithIfPattern` because its operator matrix does not have the required shape | 1 0 | / | 0 x | for the targets-as-controls optimization. It is only included in `LiftMeasurementsAboveGatesPatterns` where the matrix structure requirement differs.

Applied to files:

  • mlir/test/Dialect/MQTOpt/Transforms/Transpilation/routing-placement.mlir
  • mlir/test/Dialect/MQTOpt/Transforms/Transpilation/basics.mlir
📚 Learning: 2025-10-07T15:30:42.946Z
Learnt from: MatthiasReumann
Repo: munich-quantum-toolkit/core PR: 1237
File: mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Layout.h:219-231
Timestamp: 2025-10-07T15:30:42.946Z
Learning: In the Layout class for MLIR quantum routing (mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Layout.h), the swap method intentionally does NOT swap the hw fields in QubitInfo. This is correct because SSA values represent quantum states at fixed hardware locations, and only their program index associations change during a SWAP gate. The hw field indicates where an SSA value physically resides and remains constant.

Applied to files:

  • mlir/test/Dialect/MQTOpt/Transforms/Transpilation/routing-placement.mlir
📚 Learning: 2025-10-09T13:13:51.224Z
Learnt from: DRovara
Repo: munich-quantum-toolkit/core PR: 1108
File: mlir/lib/Dialect/MQTOpt/Transforms/ReplaceBasisStateControlsWithIfPattern.cpp:171-180
Timestamp: 2025-10-09T13:13:51.224Z
Learning: In MQT Core MLIR, UnitaryInterface operations guarantee 1-1 correspondence between input and output qubits in the same order. When cloning or modifying unitary operations (e.g., removing controls), this correspondence is maintained by construction, so yielding getAllInQubits() in else-branches matches the result types from the operation's outputs.

Applied to files:

  • mlir/test/Dialect/MQTOpt/Transforms/Transpilation/routing-placement.mlir
  • mlir/test/Dialect/MQTOpt/Transforms/Transpilation/routing-verification.mlir
📚 Learning: 2025-10-09T13:28:29.237Z
Learnt from: DRovara
Repo: munich-quantum-toolkit/core PR: 1108
File: mlir/lib/Dialect/MQTOpt/Transforms/DeadGateEliminationPattern.cpp:42-45
Timestamp: 2025-10-09T13:28:29.237Z
Learning: In the MQTOpt MLIR dialect, linear types enforce single-use semantics where each qubit value can only be consumed once, preventing duplicate deallocations and making RAUW operations safe when replacing output qubits with corresponding input qubits in transformation patterns.

Applied to files:

  • mlir/test/Dialect/MQTOpt/Transforms/Transpilation/routing-placement.mlir
📚 Learning: 2025-10-07T15:58:19.247Z
Learnt from: MatthiasReumann
Repo: munich-quantum-toolkit/core PR: 1237
File: mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Planner.h:202-214
Timestamp: 2025-10-07T15:58:19.247Z
Learning: In the QMAP routing algorithm (mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Planner.h), the heuristic function h() intentionally uses a non-admissible heuristic that sums per-gate shortest-path distances. This is a deliberate design choice from the QMAP paper, where admissibility is dropped because locally optimal solutions can negatively affect the overall routing quality. This approach prioritizes global solution quality over guaranteed local optimality.

Applied to files:

  • mlir/test/Dialect/MQTOpt/Transforms/Transpilation/basics.mlir
  • mlir/test/Dialect/MQTOpt/Transforms/Transpilation/grover_5.mlir
  • mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/RoutingPass.cpp
📚 Learning: 2025-10-09T13:25:36.887Z
Learnt from: DRovara
Repo: munich-quantum-toolkit/core PR: 1108
File: mlir/lib/Dialect/MQTOpt/Transforms/ReuseQubitsPattern.cpp:98-100
Timestamp: 2025-10-09T13:25:36.887Z
Learning: In MLIR code, when traversing parent operations to find a common block between two operations where one uses the result of another, explicit bounds checking is not necessary. MLIR's SSA properties and scope locality guarantees ensure that operations using results must be in compatible scopes and will always share a common ancestor in the operation hierarchy.

Applied to files:

  • mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/RoutingVerificationPass.cpp
  • mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/RoutingPass.cpp
🔇 Additional comments (11)
CHANGELOG.md (2)

14-14: LGTM! Proper changelog attribution.

The addition of PR #1279 to the routing algorithm entry correctly tracks this contribution.


223-223: LGTM! PR link correctly added.

The PR reference follows the established format and points to the correct location.

mlir/test/Dialect/MQTOpt/Transforms/Transpilation/grover_5.mlir (1)

11-14: LGTM! Comprehensive architecture-specific test coverage.

The four RUN lines effectively test both architectures (MQTTest and IBMFalcon) with both routing methods (naive and astar), and correctly thread the arch parameter through all three passes in each pipeline.

mlir/test/Dialect/MQTOpt/Transforms/Transpilation/basics.mlir (2)

11-14: LGTM! Consistent architecture-specific test invocation.

The RUN lines follow the same pattern as grover_5.mlir, providing comprehensive test coverage across architectures and routing methods.


17-368: LGTM! Simplified CHECK-LABEL directives.

The consolidation to a single CHECK-LABEL pattern (removing NAIVE-/ASTAR-specific checks) is appropriate since the test validates that both routing methods produce valid output, not that they produce identical output.

mlir/test/Dialect/MQTOpt/Transforms/Transpilation/routing-verification.mlir (1)

9-9: LGTM! Architecture parameter added to verification pass.

The addition of arch=MQTTest properly tests the architecture-aware verification introduced in this PR.

mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Architecture.h (2)

19-19: LGTM! Required include added.

The inclusion of llvm/ADT/StringRef.h is necessary for the updated getArchitecture signature.


109-109: LGTM! Proper use of StringRef for string parameter.

The transition from enum-based to StringRef-based architecture lookup enables runtime architecture specification from command-line options, which is the core objective of this PR. StringRef is the appropriate LLVM type for string parameters that don't require ownership.

mlir/test/Dialect/MQTOpt/Transforms/Transpilation/routing-placement.mlir (1)

9-9: LGTM! Architecture parameter added to placement pass.

The addition of arch=MQTTest properly tests the architecture-aware placement introduced in this PR.

mlir/test/Dialect/MQTOpt/Transforms/Transpilation/invalid-arch-option.mlir (1)

11-15: LGTM! Good negative test for invalid architecture.

This test properly validates that all three passes (placement-sc, route-sc, verify-routing-sc) correctly reject invalid architecture names with a clear error message.

mlir/test/Dialect/MQTOpt/Transforms/Transpilation/missing-arch-option.mlir (1)

11-15: LGTM! Good negative test for missing required parameter.

This test properly validates that all three passes require the arch parameter and provide a clear error message when it's missing. This complements the invalid-arch-option.mlir test to provide comprehensive error handling coverage.

Copy link
Member

@burgholzer burgholzer left a comment

Choose a reason for hiding this comment

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

LGTM. I like that this marks a first step towards QDMI support.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: matthias <[email protected]>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 49fb32b and 7a2e36d.

📒 Files selected for processing (1)
  • mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/RoutingVerificationPass.cpp (4 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-09T13:25:36.887Z
Learnt from: DRovara
Repo: munich-quantum-toolkit/core PR: 1108
File: mlir/lib/Dialect/MQTOpt/Transforms/ReuseQubitsPattern.cpp:98-100
Timestamp: 2025-10-09T13:25:36.887Z
Learning: In MLIR code, when traversing parent operations to find a common block between two operations where one uses the result of another, explicit bounds checking is not necessary. MLIR's SSA properties and scope locality guarantees ensure that operations using results must be in compatible scopes and will always share a common ancestor in the operation hierarchy.

Applied to files:

  • mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/RoutingVerificationPass.cpp
🧬 Code graph analysis (1)
mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/RoutingVerificationPass.cpp (3)
mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/RoutingPass.cpp (3)
  • arch (520-520)
  • preflight (500-517)
  • archName (537-544)
mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/PlacementPass.cpp (3)
  • arch (453-453)
  • preflight (430-449)
  • archName (471-478)
mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/Architecture.cpp (2)
  • getArchitecture (88-152)
  • getArchitecture (88-88)
🔇 Additional comments (5)
mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/RoutingVerificationPass.cpp (5)

22-33: LGTM: Header additions support the refactoring.

The new headers appropriately support the architecture ownership changes (unique_ptr), error reporting enhancements, and move semantics.


50-53: LGTM: Proper ownership semantics with unique_ptr.

The refactoring from raw pointer to std::unique_ptr<Architecture> provides clear ownership semantics and automatic resource management.


227-228: LGTM: Standard MLIR pass pattern.

The base class aliasing correctly exposes base constructors for pass option initialization.


244-244: LGTM: Proper move semantics.

The std::move(arch) correctly transfers ownership to the VerificationContext, ensuring the architecture object is properly managed.


284-291: LGTM: Appropriate validation for required option.

The preflight() method correctly validates that the required arch option is provided, with a clear error message. The pattern is consistent with the other passes.

@burgholzer burgholzer added this to the MLIR Support milestone Oct 31, 2025
@burgholzer burgholzer added enhancement New feature or request MLIR Anything related to MLIR labels Oct 31, 2025
@burgholzer burgholzer merged commit 2e7cc39 into main Oct 31, 2025
30 checks passed
@burgholzer burgholzer deleted the enh/mlir-routing-pass-arch-option branch October 31, 2025 13:41
@coderabbitai coderabbitai bot mentioned this pull request Dec 1, 2025
8 tasks
@coderabbitai coderabbitai bot mentioned this pull request Jan 8, 2026
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request MLIR Anything related to MLIR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants