Skip to content

✨ Switch the default technology mapper from mockturtle::map to mockturtle::emap - #866

Open
marcelwa wants to merge 55 commits into
mainfrom
emap
Open

✨ Switch the default technology mapper from mockturtle::map to mockturtle::emap#866
marcelwa wants to merge 55 commits into
mainfrom
emap

Conversation

@marcelwa

@marcelwa marcelwa commented Oct 24, 2025

Copy link
Copy Markdown
Collaborator

Description

This PR switches the default technology mapper in fiction from mockturtle::map to mockturtle::emap in both the fiction::technology_mapping function and the map CLI command. The change is made because mockturtle::emap supports multi-output cells, whereas mockturtle::map does not.

Checklist:

  • The pull request only contains commits that are related to it.
  • I have added appropriate tests and documentation.
  • I have added a changelog entry.
  • I have created/adjusted the Python bindings for any new or updated functionality.
  • 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.

Summary by CodeRabbit

  • New Features

    • Default mapper switched to EMAP; half-adder support added; new Python exception for missing required gates.
  • Changes

    • CLI: removed --logic_sharing flag; warns on already-mapped networks and reports mapping errors instead of storing failures; mapping failures print exception messages.
  • Breaking Changes

    • Several public constant/API signatures changed; mapping statistics no longer expose a Python repr.
  • Documentation

    • Expanded docstrings and changelog entries for mapping and related APIs.
  • Tests

    • Added tests for required-gates validation and mapping outcomes.
  • Chores

    • Build/CI and packaging updates (compile database, build-type, lint include paths).

@marcelwa marcelwa self-assigned this Oct 24, 2025
@marcelwa marcelwa added the enhancement New feature or request label Oct 24, 2025
@coderabbitai

coderabbitai Bot commented Oct 24, 2025

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Replaces mockturtle::map with mockturtle::emap across technology mapping, adds fiction::missing_required_gates_exception and validate_required_gates(), converts many public string constexprs to auto and adds half‑adder gate/constants, updates Python bindings/docs/tests, and adjusts CLI, build, and CI settings.

Changes

Cohort / File(s) Summary
Technology Mapping Core
include/fiction/algorithms/network_transformation/technology_mapping.hpp
Switch map→emap; add fiction::missing_required_gates_exception and validate_required_gates(); change mapper param/stat types to EMAP variants; make run() [[nodiscard]] & const; call validation before mapping.
Gate Library
include/fiction/technology/technology_mapping_library.hpp
Change gate-name constants from inline constexpr const char*inline constexpr auto; add GATE_HA (half‑adder) and new 3‑ary/multi‑output gate constants/decay variants.
Type System
include/fiction/types.hpp
Replace string-pointer constexprs with inline constexpr auto; add dispatch helpers (get_ntk_type_name, get_tech_impl_name, get_tech_cell_name, get_sidb_lattice_name) and template aliases.
Python Bindings & Docstrings
bindings/mnt/pyfiction/include/pyfiction/algorithms/.../technology_mapping.hpp, bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp
Register fiction::missing_required_gates_exception in pybind11; add many docstring constants; remove __repr__ binding for fiction::technology_mapping_stats; minor pybind11 NOLINT wiring.
CLI Map Command
cli/cmd/logic/include/map.hpp, cli/cmd/logic/src/map.cpp
Remove --logic_sharing flag, add --ha flag; warn on already‑mapped networks; wrap technology_mapping in try/catch to handle missing_required_gates_exception; adjust flag save/restore and store extension on success.
Tests
test/algorithms/network_transformation/technology_mapping.cpp
Narrow several test suites to mig_network; add tests asserting exceptions when required gates are missing and success cases when required gates are present.
Docs & Changelog
docs/algorithms/network_transformation.rst, docs/changelog.rst
Document new missing_required_gates_exception in C++/Python docs; note default mapper change from mapemap and removal of --logic_sharing.
Build & CI
CMakeLists.txt, .github/workflows/clang-tidy-review.yml, bindings/mnt/pyfiction/CMakeLists.txt, pyproject.toml, .readthedocs.yml
Enable CMAKE_EXPORT_COMPILE_COMMANDS; adjust clang‑tidy args to include pyfiction headers; make pyfiction LTO conditional on FICTION_ENABLE_IPO; set default CMake build-type to Release; add ReadTheDocs/mold packaging/build overrides.
Bindings Header Removal
bindings/mnt/pyfiction/include/pyfiction/algorithms/.../technology_mapping.hpp
Removed __repr__ binding for fiction::technology_mapping_stats (previously returned stats.report()).

Sequence Diagram(s)

sequenceDiagram
    rect rgba(200,200,255,0.5)
    participant CLI
    end
    rect rgba(200,255,200,0.5)
    participant TechMapping as TechnologyMappingImpl
    end
    rect rgba(255,200,200,0.5)
    participant EMAP as mockturtle::emap
    end
    rect rgba(255,255,200,0.5)
    participant Store
    end

    CLI->>TechMapping: call technology_mapping(params)
    TechMapping->>TechMapping: validate_required_gates(params)
    alt missing gates
        TechMapping-->>CLI: throws missing_required_gates_exception
        CLI->>CLI: catch and print exception message
    else all gates present
        TechMapping->>EMAP: invoke mockturtle::emap(ntk, lib, emap_params)
        EMAP-->>TechMapping: mapping result & stats
        TechMapping->>Store: extend with mapped tec_nt (on success)
        CLI-->>CLI: report success
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

tooling, documentation

Poem

🐰 I hopped from map to emap with glee,

I checked for gates — INV, AND, MAJ, and A‑B,
A half‑adder snug in my patchwork sack,
Docs, bindings, tests — all on the track,
I nibble code carrots and then hop back.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly describes the main change: switching from mockturtle::map to mockturtle::emap as the default technology mapper.
Description check ✅ Passed The PR description explains the motivation (emap supports multi-output cells) and the scope (technology_mapping function and map CLI command), though the checklist items are unchecked.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch emap

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.

marcelwa and others added 2 commits October 24, 2025 13:56
Signed-off-by: Marcel Walter <marcel.walter@tum.de>
Signed-off-by: GitHub Actions <actions@github.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
include/fiction/types.hpp (1)

211-213: Probable alias bug: cube CDS uses SIQAD type

cds_sidb_cell_clk_lyt_cube aliases charge_distribution_surface<sidb_cell_clk_lyt_siqad>, but should use sidb_cell_clk_lyt_cube.

-using cds_sidb_cell_clk_lyt_cube     = charge_distribution_surface<sidb_cell_clk_lyt_siqad>;
+using cds_sidb_cell_clk_lyt_cube     = charge_distribution_surface<sidb_cell_clk_lyt_cube>;
include/fiction/algorithms/network_transformation/technology_mapping.hpp (1)

316-319: Fix technology_mapping_stats::report() return type—Python bindings expect a string

The Python binding at line 78 of bindings/mnt/pyfiction/include/pyfiction/algorithms/network_transformation/technology_mapping.hpp defines __repr__ as return stats.report(), which requires report() to return a string. The current void return type will break this binding.

Change report() to return std::string and aggregate mapper_stats.report() output using std::stringstream, following the pattern used by other stat classes in the codebase (e.g., orthogonal_physical_design_stats, exact_physical_design_stats).

🧹 Nitpick comments (15)
bindings/mnt/pyfiction/test/algorithms/network_transformation/test_technology_mapping.py (1)

59-71: Consider importing and testing the specific exception type.

The test correctly validates that an exception is raised with the appropriate message when no gates are enabled. However, it checks for RuntimeError rather than the specific missing_required_gates_exception type.

While pybind11's py::register_exception typically creates exceptions that inherit from RuntimeError, you could make the test more precise by importing and checking for the specific exception type:

from mnt.pyfiction import (
    # ... existing imports ...
    missing_required_gates_exception,
)

# In the test:
with self.assertRaises(missing_required_gates_exception) as context:
    technology_mapping(network, params)

This would catch cases where a different RuntimeError is raised for unrelated reasons.

bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp (3)

10651-10656: Tighten wording and add a cross‑reference for discoverability.

Small style tweak and a See also to the exception.

 static const char *__doc_fiction_detail_technology_mapping_impl_validate_required_gates =
-R"doc(Validate that the technology library contains the required gates for
-the base network type.
-
-Throws:
-    missing_required_gates_exception if required gates are missing.)doc";
+R"doc(Validates that the technology library contains the gates required by
+the base network type.
+
+Throws:
+    missing_required_gates_exception if required gates are missing.
+
+See also:
+    missing_required_gates_exception.)doc";

16977-16982: Clarify what the exception surfaces to help debugging.

If the implementation includes the missing gate kinds in the message, reflect that here.

 static const char *__doc_fiction_missing_required_gates_exception =
-R"doc(Exception thrown when a technology mapping library does not contain
-the required gates for the base network type.)doc";
+R"doc(Exception thrown when a technology mapping library does not contain
+the required gates for the base network type.
+
+The exception message lists the missing gate kinds to aid debugging.)doc";

If messages do not yet include the missing kinds, would you like a follow‑up change to add them?


21985-21986: LGTM: MUX parameter doc reads well.

Optional: if mapper_params (Line 21983) now refers specifically to emap’s parameter struct, consider clarifying that in its docstring.

test/algorithms/network_transformation/technology_mapping.cpp (7)

229-234: MIG-only AOIM tests: confirm intentional backend reduction

Switching this case to mig_network only looks consistent with EMAP’s MAJ support. Please confirm dropping AIG/XAG/XMG here is intentional and not a coverage regression.


256-260: MIG-only 3‑input tests: verify intended scope

Limiting to mig_network makes sense for MAJ-focused coverage. If XMG is unsupported/irrelevant under EMAP, all good—otherwise consider retaining it for parity.


265-271: Use of all_supported_standard_functions is correct

Good move to cover both 2‑ and 3‑input gates in one go. Optionally, assert some gate-type counts to ensure expected families are actually used.


288-314: AIG missing-gates tests are sound; re-init params within each SECTION

Looks correct. For clarity and isolation, consider constructing a fresh technology_mapping_params inside each SECTION to avoid accidental flag carry-over if sections change later.

-technology_mapping_params params{};
-SECTION("Missing INV") { params.and2 = true; /* ... */ }
+SECTION("Missing INV") {
+    technology_mapping_params params{};
+    params.and2 = true;
+    CHECK_THROWS_AS(technology_mapping(aig, params), missing_required_gates_exception);
+}

315-350: XAG missing-gates matrix is complete

INV/AND/XOR combinations covered well. Same suggestion to re-init params within each SECTION for robustness.


352-377: MIG missing-gates checks are correct

INV/MAJ requirements validated. Consider local params per SECTION for consistency with other blocks.


379-411: Positive cases: add a basic correctness/health assertion

Since you’re already constructing networks here, add a quick stats or equivalence check to ensure mapping ran and didn’t silently degrade:

- CHECK_NOTHROW(technology_mapping(aig, params));
+ CHECK_NOTHROW(technology_mapping(aig, params));
+ // Optional: sanity check via stats
+ technology_mapping_stats st{};
+ (void)technology_mapping(aig, params, &st);
+ CHECK_FALSE(st.mapper_stats.mapping_error);
include/fiction/types.hpp (2)

58-74: Prefer constexpr std::string_view for names

Using inline constexpr auto with string literals deduces to char[N], which decays fine but is less explicit. std::string_view avoids decay pitfalls and is header‑only.

- inline constexpr auto aig_name = "AIG";
- inline constexpr auto xag_name = "XAG";
- inline constexpr auto mig_name = "MIG";
- inline constexpr auto tec_name = "TEC";
+ inline constexpr std::string_view aig_name = "AIG";
+ inline constexpr std::string_view xag_name = "XAG";
+ inline constexpr std::string_view mig_name = "MIG";
+ inline constexpr std::string_view tec_name = "TEC";

78-82: Make ntk_type_name a string_view

Align return type to std::string_view for consistency with the name constants and to avoid pointer decay.

-template <class Ntk>
-inline constexpr auto ntk_type_name = std::is_same_v<std::decay_t<Ntk>, aig_nt> ? aig_name :
-                                      std::is_same_v<std::decay_t<Ntk>, xag_nt> ? xag_name :
-                                      std::is_same_v<std::decay_t<Ntk>, mig_nt> ? mig_name :
-                                      std::is_same_v<std::decay_t<Ntk>, tec_nt> ? tec_name :
-                                                                                  "?";
+template <class Ntk>
+inline constexpr std::string_view ntk_type_name =
+    std::is_same_v<std::decay_t<Ntk>, aig_nt> ? aig_name :
+    std::is_same_v<std::decay_t<Ntk>, xag_nt> ? xag_name :
+    std::is_same_v<std::decay_t<Ntk>, mig_nt> ? mig_name :
+    std::is_same_v<std::decay_t<Ntk>, tec_nt> ? tec_name :
+                                                std::string_view{"?"};
cli/cmd/logic/map.hpp (1)

136-141: Optional: print stats when verbose

If ps.mapper_params.verbose is set, consider printing st.mapper_stats.report() after mapping to mirror Mockturtle behavior.

include/fiction/algorithms/network_transformation/technology_mapping.hpp (1)

379-443: Validation step is correct; make header self-contained

Gate checks per base network are right. To avoid relying on transitive includes, add <type_traits> in this header since validate_required_gates uses std::is_same_v.

 #include <sstream>
-#include <stdexcept>
-#include <string>
+#include <stdexcept>
+#include <string>
+#include <type_traits>
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e711c0b and 2b2b2a5.

📒 Files selected for processing (9)
  • bindings/mnt/pyfiction/include/pyfiction/algorithms/network_transformation/technology_mapping.hpp (1 hunks)
  • bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp (5 hunks)
  • bindings/mnt/pyfiction/test/algorithms/network_transformation/test_technology_mapping.py (2 hunks)
  • cli/cmd/logic/map.hpp (3 hunks)
  • docs/algorithms/network_transformation.rst (2 hunks)
  • docs/changelog.rst (2 hunks)
  • include/fiction/algorithms/network_transformation/technology_mapping.hpp (8 hunks)
  • include/fiction/types.hpp (1 hunks)
  • test/algorithms/network_transformation/technology_mapping.cpp (4 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-13T11:04:24.736Z
Learnt from: marcelwa
PR: cda-tum/fiction#854
File: cli/cmd/logic/src/abc.cpp:78-88
Timestamp: 2025-10-13T11:04:24.736Z
Learning: The `mockturtle::write_aiger` function in the mockturtle library supports writing all kinds of logic networks (AIG, XAG, MIG, TEC), not just AIG networks. No explicit conversion to AIG is required before calling this function.

Applied to files:

  • test/algorithms/network_transformation/technology_mapping.cpp
🧬 Code graph analysis (3)
bindings/mnt/pyfiction/test/algorithms/network_transformation/test_technology_mapping.py (2)
include/fiction/algorithms/network_transformation/technology_mapping.hpp (1)
  • technology_mapping (634-635)
bindings/mnt/pyfiction/include/pyfiction/algorithms/network_transformation/technology_mapping.hpp (4)
  • technology_mapping (23-30)
  • technology_mapping (23-23)
  • technology_mapping (34-97)
  • technology_mapping (34-34)
test/algorithms/network_transformation/technology_mapping.cpp (1)
include/fiction/algorithms/network_transformation/technology_mapping.hpp (4)
  • technology_mapping (634-635)
  • all_supported_standard_functions (245-245)
  • missing_required_gates_exception (33-36)
  • missing_required_gates_exception (33-33)
cli/cmd/logic/map.hpp (3)
include/fiction/algorithms/network_transformation/technology_mapping.hpp (1)
  • technology_mapping (634-635)
bindings/mnt/pyfiction/include/pyfiction/algorithms/network_transformation/technology_mapping.hpp (4)
  • technology_mapping (23-30)
  • technology_mapping (23-23)
  • technology_mapping (34-97)
  • technology_mapping (34-34)
cli/cmd/io/sqd.hpp (1)
  • s (48-108)
🔇 Additional comments (12)
bindings/mnt/pyfiction/include/pyfiction/algorithms/network_transformation/technology_mapping.hpp (1)

38-40: LGTM!

The exception registration follows pybind11 conventions correctly. The placement before the parameter class bindings is appropriate, ensuring the exception type is available when the technology_mapping function is called from Python.

bindings/mnt/pyfiction/test/algorithms/network_transformation/test_technology_mapping.py (1)

14-14: LGTM!

The import of technology_mapping_params is necessary for the new test and correctly added to the existing import statement.

docs/changelog.rst (2)

26-27: LGTM!

The changelog entry accurately documents the switch from mockturtle::map to mockturtle::emap and is appropriately categorized under the "Changed" section for algorithms.


41-42: LGTM!

The changelog entry correctly documents the removal of the --logic_sharing flag with clear rationale that mockturtle::emap does not support it. The entry is appropriately placed in the "Removed > CLI" section.

docs/algorithms/network_transformation.rst (2)

52-53: LGTM!

The documentation correctly exposes the new missing_required_gates_exception class in the C++ API documentation using the appropriate doxygenclass directive. The placement in the Technology Mapping section is logical and consistent with the feature's purpose.


66-67: LGTM!

The Python documentation correctly mirrors the C++ documentation by exposing the missing_required_gates_exception class using the autoclass directive. This maintains symmetry between the C++ and Python API documentation.

bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp (2)

21975-21976: LGTM: clear and consistent parameter description.


21936-21938: Remove unsupported "replaces map backend" claim; verify multi-output relevance.

The codebase shows no evidence of a previous mockturtle::map backend or migration context. While emap does support multi-output cells via emap_params::map_multioutput = true, the suggested docstring addition conflates mockturtle's library design with this project's actual implementation. The function docstring should describe what technology_mapping does, not general emap capabilities, unless this function provably uses multi-output mapping.

Likely an incorrect or invalid review comment.

test/algorithms/network_transformation/technology_mapping.cpp (1)

273-287: Name conservation check retained—LGTM

The MIG-only name preservation case is concise and effective.

cli/cmd/logic/map.hpp (1)

119-128: Warning on remapping tec_nt is helpful

Good proactive UX to warn when attempting to remap an already mapped network.

include/fiction/algorithms/network_transformation/technology_mapping.hpp (2)

27-37: New exception type is well-scoped

Clear, specific error for missing required gates per network family. Good addition.


605-607: EMAP call swap looks correct

Switch to mockturtle::emap with emap_params/stats is consistent with the PR objective.

Comment thread cli/cmd/logic/map.hpp Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
include/fiction/algorithms/network_transformation/technology_mapping.hpp (1)

622-632: Update documentation to mention the new exception.

The documentation correctly references mockturtle::emap, but it should also document that the function may throw missing_required_gates_exception when the provided library lacks required gates for the input network type.

Apply this diff to enhance the documentation:

 /**
  * Performs technology mapping on the given network. Technology mapping is the process of replacing the gates in a
  * network with gates from a given technology library. This function utilizes `mockturtle::emap` to perform the
  * technology mapping. This function is a wrapper around that interface to provide a more convenient usage.
  *
  * @tparam Ntk Input logic network type.
  * @param ntk Input logic network.
  * @param params Technology mapping parameters.
  * @param pst Technology mapping statistics.
  * @return Mapped network exclusively using gates from the provided library.
+ * @throws missing_required_gates_exception if the technology library does not contain required gates for the base
+ *         network type (e.g., AIG requires INV and AND; XAG requires INV, AND, and XOR; MIG requires INV and MAJ).
  */
🧹 Nitpick comments (2)
include/fiction/algorithms/network_transformation/technology_mapping.hpp (1)

431-439: Consider simplifying the comma-separated list construction.

The manual loop to build the comma-separated string is correct but could be more concise.

Apply this diff to simplify using string operations:

-            std::string missing_list{};
-            for (std::size_t i = 0; i < missing_gates.size(); ++i)
-            {
-                missing_list += missing_gates[i];
-                if (i < missing_gates.size() - 1)
-                {
-                    missing_list += ", ";
-                }
-            }
+            std::ostringstream oss;
+            for (std::size_t i = 0; i < missing_gates.size(); ++i)
+            {
+                if (i > 0) oss << ", ";
+                oss << missing_gates[i];
+            }
+            const std::string missing_list = oss.str();

Note: This requires #include <sstream> which is already included (line 19).

cli/cmd/logic/src/map.cpp (1)

115-122: Robust mapping lambda; consider early-return for already-mapped networks

The new perform_mapping lambda with Ntk deduction, warning on fiction::tec_nt, stats-based mapping_error check, and missing_required_gates_exception handling is a solid improvement in robustness: mapped networks are only stored when mapping succeeds and required gates are present.

As an optional refinement, you could:

  • Early-return when Ntk is fiction::tec_nt to avoid invoking technology_mapping on an already mapped network and relying on a warning + potential mapper error.
  • Optionally surface more detail from st.mapper_stats in the error path if that’s useful for users diagnosing mapping failures.

These are polish-level improvements; the current behavior is functionally acceptable.

Also applies to: 126-141

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b2b2a5 and 0c11bee.

📒 Files selected for processing (5)
  • bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp (5 hunks)
  • cli/cmd/logic/include/map.hpp (1 hunks)
  • cli/cmd/logic/src/map.cpp (4 hunks)
  • docs/changelog.rst (2 hunks)
  • include/fiction/algorithms/network_transformation/technology_mapping.hpp (8 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-10-13T11:04:24.736Z
Learnt from: marcelwa
Repo: cda-tum/fiction PR: 854
File: cli/cmd/logic/src/abc.cpp:78-88
Timestamp: 2025-10-13T11:04:24.736Z
Learning: The `mockturtle::write_aiger` function in the mockturtle library supports writing all kinds of logic networks (AIG, XAG, MIG, TEC), not just AIG networks. No explicit conversion to AIG is required before calling this function.

Applied to files:

  • bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp
  • include/fiction/algorithms/network_transformation/technology_mapping.hpp
📚 Learning: 2025-10-13T14:43:13.479Z
Learnt from: hibenj
Repo: cda-tum/fiction PR: 852
File: include/fiction/algorithms/physical_design/orthogonal_planar.hpp:825-826
Timestamp: 2025-10-13T14:43:13.479Z
Learning: In the fiction library, logic networks are required to have at least one primary input (PI). The `orthogonal_planar` algorithm in `include/fiction/algorithms/physical_design/orthogonal_planar.hpp` enforces this invariant with an assertion rather than handling the zero-PI case.

Applied to files:

  • include/fiction/algorithms/network_transformation/technology_mapping.hpp
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
  • GitHub Check: 🐧 ubuntu-24.04-arm with clang++-15
  • GitHub Check: 🐧 ubuntu-22.04 with g++-11
  • GitHub Check: 🐍 windows-latest
  • GitHub Check: 🐳 Build and publish Docker image
  • GitHub Check: 🍎 macos-13 with g++-13
  • GitHub Check: 🍎 macos-13 with clang++
  • GitHub Check: 🍎 macos-13 with g++-14
  • GitHub Check: Analyze python
  • GitHub Check: 🪟 windows-2025 with v143 toolset
  • GitHub Check: Analyze cpp
  • GitHub Check: 🪟 windows-2025 with ClangCL toolset
  • GitHub Check: 🪟 windows-2022 with ClangCL toolset
  • GitHub Check: 🪟 windows-2022 with v143 toolset
  • GitHub Check: 🛞 Wheels for windows-latest
  • GitHub Check: 🛞 Wheels for ubuntu-24.04-arm
  • GitHub Check: 🛞 Wheels for macos-14
  • GitHub Check: 🛞 Wheels for ubuntu-24.04
  • GitHub Check: 🛞 Wheels for macos-13
  • GitHub Check: Coverage on ubuntu-24.04 with g++-13
  • GitHub Check: 🚨 Clang-Tidy
🔇 Additional comments (15)
include/fiction/algorithms/network_transformation/technology_mapping.hpp (6)

53-55: Good documentation improvements.

The clarifications for INV (inverter) and MUX (ITE) improve readability without changing functionality.

Also applies to: 132-132


335-338: Excellent additions to the run() method.

The [[nodiscard]] attribute ensures the returned mapped network is used, and the early validation provides clear error messages when required gates are missing from the library.


374-426: Robust validation logic for network-specific gate requirements.

The validation correctly identifies required gates for each base network type (AIG, XAG, MIG) and provides clear error messages. This fail-fast approach prevents cryptic mapping errors.


605-605: emap migration properly implemented with correct parameter types.

Verification confirms the code is correct: emap uses its own emap_params/emap_stats, and the codebase at lines 44 and 312 has already been updated to use mockturtle::emap_params and mockturtle::emap_stats respectively. The function call at line 605 passes the correct parameter types, enabling the multi-output cell support objective.


27-37: Exception implementation verified and approved.

The missing_required_gates_exception class is well-designed and follows best practices. Verification confirms that the fmt library is properly integrated in the project—it's bundled from the alice/mockturtle submodules and the CMake build system is correctly configured to prevent version conflicts. The exception's use of fmt::format is consistent with extensive usage throughout the codebase.


44-44: Verify API compatibility and field availability for emap_params.

The web search confirms that mockturtle::emap_params and mockturtle::map_params are not API-compatible and cannot be substituted for each other. The codebase has swapped them globally, which introduces several risks:

  1. Missing field access: CLI code (cli/cmd/logic/src/map.cpp:54, 78, 97) accesses mapper_params.verbose, but the emap_params documentation does not list this field. This may cause compilation or runtime errors.

  2. Cut enumeration default change: emap_params uses a default cut limit of 20, whereas map_params uses 49. This is a significant behavior change that may affect mapping quality.

  3. Incompatible field sets: emap_params adds fields like matching_mode_t, area_oriented_mapping, and map_multioutput that map_params does not have.

Before merging, verify:

  • That emap_params actually has a verbose field (or update CLI code)
  • That the cut limit change from 49 to 20 is intentional
  • That all existing code compiles and tests pass with these changes
bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp (5)

10651-10656: Docstring for validate_required_gates is clear and aligned with behavior

The description and Throws: clause accurately document the validation step and the missing_required_gates_exception. No issues from a documentation perspective.


16977-16982: Exception documentation is consistent with validation semantics

The new missing_required_gates_exception docstring clearly states when it is thrown and matches the wording used in the validator doc. The empty constructor doc entry is acceptable for generated bindings.


21942-21947: Technology mapping doc correctly reflects switch to mockturtle::emap

The updated description now explicitly mentions mockturtle::emap, which matches the PR’s goal of changing the default mapper. This keeps the Python docs consistent with the new underlying implementation.


21984-21984: Inverter parameter docstring is precise and consistent

The description “1-input NOT gate (inverter).” is concise and matches the parameter name and expected semantics.


21994-21994: MUX parameter docstring is accurate

The “3-input MUX gate (ITE).” description is correct and consistent with typical terminology for this gate type and its use in mapping parameters.

cli/cmd/logic/include/map.hpp (1)

28-32: Docstring correctly reflects EMAP-based mapping

The updated comment to mention mockturtle::emap aligns with the new default mapper and keeps the interface documentation accurate.

docs/changelog.rst (1)

15-17: Changelog entry for EMAP switch is clear

The Algorithms/Changed note concisely documents the behavioral change to use mockturtle::emap for both map and technology_mapping, which matches the PR’s intent.

cli/cmd/logic/src/map.cpp (2)

13-13: New includes match usage; just ensure fmt is linked for the CLI target

Adding <fmt/format.h> and <type_traits> is consistent with the later use of fmt::format, std::decay_t, and std::is_same_v. Build should remain fine as long as the CLI target already links against fmt (or this translation unit is within a target that does).

Also applies to: 18-18


76-79: Gate flag handling and preservation of control flags look sound

Storing ps.decay and ps.mapper_params.verbose before applying --all2/--all3/--all and restoring them afterward avoids clobbering these controls when aggregate gate selections are used. The gate_flags array combined with the std::none_of check correctly enforces that at least one gate-related or aggregate flag is set before mapping.

No functional issues spotted here.

Also applies to: 96-98, 100-104

Comment thread docs/changelog.rst
@codecov

codecov Bot commented Nov 16, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.17%. Comparing base (34b67b0) to head (fdc922e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##             main     #866    +/-   ##
========================================
  Coverage   98.16%   98.17%            
========================================
  Files         261      261            
  Lines       40105    40226   +121     
  Branches     2109     2118     +9     
========================================
+ Hits        39369    39490   +121     
  Misses        736      736            
Files with missing lines Coverage Δ
...thms/network_transformation/technology_mapping.hpp 96.19% <100.00%> (+1.45%) ⬆️
...thms/network_transformation/technology_mapping.cpp 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 527577f...fdc922e. Read the comment docs.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (6)
bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp (5)

10651-10656: validate_required_gates docstring is clear; consider qualifying the exception type

The description of what is validated and that missing_required_gates_exception is thrown is good. For extra clarity in the Python docs, you might name it fiction::missing_required_gates_exception to match other fully qualified types (if you follow that convention elsewhere), but this is optional.


14173-14173: Fill in the empty docstring for get_ntk_type_name

Right now the docstring is empty (R"doc()doc"), so help() in Python won’t give users any indication of what this returns (e.g., whether it’s a human-readable name, enum-like string, etc.). Adding even a one-line summary like “Returns a human-readable type name for the given network/layout” would improve usability.


14189-14189: Fill in the empty docstring for get_sidb_lattice_name

Similarly, this empty docstring doesn’t tell Python users what form the lattice name takes or how it’s derived. A short sentence (e.g., “Returns the canonical lattice name for a given SiDB layout”) would make the binding self-explanatory.


14209-14212: Add minimal descriptions for get_tech_cell_name and get_tech_impl_name

Both bindings currently have empty docstrings, which is a missed opportunity—these names are likely important concepts in the tech library. Adding brief docs (e.g., that one returns a human-readable cell name and the other the implementation name / variant) would help Python users navigate the API.


21953-21955: technology_mapping doc correctly references mockturtle::emap; consider noting multi-output support

Updating the docs to mention mockturtle::emap aligns the Python help text with the implementation change. You might optionally add a short remark that emap supports multi-output cells (the core motivation of this PR) so Python users understand why this mapper is used by default. Since this is in a pyfiction binding header, it only affects Python docs, not the public C++ API. Based on learnings, ...

test/algorithms/network_transformation/technology_mapping.cpp (1)

279-293: Exception tests for missing/complete gate sets match the new validation logic

The new tests:

  • Verify that technology_mapping throws missing_required_gates_exception for AIG/XAG/MIG when any of the required gates (INV, AND, XOR, MAJ) are missing, including “all missing” combinations.
  • Verify that no exception is thrown when the minimal required set is present for each network type.
  • Keep a separate MIG name‑conservation test using names_view, ensuring the mapping and name restoration still behave as expected.

This test matrix maps cleanly onto the validate_required_gates() implementation and should catch regressions if the required‑gate sets or the exception wiring change. The only (very minor) enhancement you might consider later is asserting on the exception message contents in at least one case to lock down the network_type and missing_gates formatting, but it’s not strictly necessary for this PR.

Also applies to: 294-417

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0c11bee and aacc2df.

📒 Files selected for processing (5)
  • bindings/mnt/pyfiction/include/pyfiction/algorithms/network_transformation/technology_mapping.hpp (1 hunks)
  • bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp (8 hunks)
  • include/fiction/algorithms/network_transformation/technology_mapping.hpp (8 hunks)
  • include/fiction/types.hpp (2 hunks)
  • test/algorithms/network_transformation/technology_mapping.cpp (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • bindings/mnt/pyfiction/include/pyfiction/algorithms/network_transformation/technology_mapping.hpp
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2025-09-25T10:31:01.287Z
Learnt from: marcelwa
Repo: cda-tum/fiction PR: 840
File: bindings/mnt/pyfiction/CMakeLists.txt:30-37
Timestamp: 2025-09-25T10:31:01.287Z
Learning: Headers in the pyfiction Python bindings target (bindings/mnt/pyfiction/) are private implementation details for the Python bindings and should not be made public or exported as part of the C++ API.

Applied to files:

  • bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp
📚 Learning: 2025-10-13T11:04:24.736Z
Learnt from: marcelwa
Repo: cda-tum/fiction PR: 854
File: cli/cmd/logic/src/abc.cpp:78-88
Timestamp: 2025-10-13T11:04:24.736Z
Learning: The `mockturtle::write_aiger` function in the mockturtle library supports writing all kinds of logic networks (AIG, XAG, MIG, TEC), not just AIG networks. No explicit conversion to AIG is required before calling this function.

Applied to files:

  • bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp
  • test/algorithms/network_transformation/technology_mapping.cpp
  • include/fiction/algorithms/network_transformation/technology_mapping.hpp
  • include/fiction/types.hpp
📚 Learning: 2025-10-13T14:43:13.479Z
Learnt from: hibenj
Repo: cda-tum/fiction PR: 852
File: include/fiction/algorithms/physical_design/orthogonal_planar.hpp:825-826
Timestamp: 2025-10-13T14:43:13.479Z
Learning: In the fiction library, logic networks are required to have at least one primary input (PI). The `orthogonal_planar` algorithm in `include/fiction/algorithms/physical_design/orthogonal_planar.hpp` enforces this invariant with an assertion rather than handling the zero-PI case.

Applied to files:

  • include/fiction/algorithms/network_transformation/technology_mapping.hpp
  • include/fiction/types.hpp
📚 Learning: 2025-09-10T16:31:45.364Z
Learnt from: marcelwa
Repo: cda-tum/fiction PR: 828
File: include/fiction/technology/area.hpp:0-0
Timestamp: 2025-09-10T16:31:45.364Z
Learning: In include/fiction/technology/area.hpp, both fiction::area overloads should accept parameters as `const area_params<technology<Lyt>>& ps = {}` to allow binding the default temporary and ensure const-correctness. Docs in docs/technology/properties.rst should mirror these signatures.

Applied to files:

  • include/fiction/types.hpp
🧬 Code graph analysis (1)
test/algorithms/network_transformation/technology_mapping.cpp (2)
bindings/mnt/pyfiction/include/pyfiction/algorithms/network_transformation/technology_mapping.hpp (4)
  • technology_mapping (23-30)
  • technology_mapping (23-23)
  • technology_mapping (34-96)
  • technology_mapping (34-34)
include/fiction/algorithms/network_transformation/technology_mapping.hpp (4)
  • technology_mapping (638-639)
  • all_supported_standard_functions (249-249)
  • missing_required_gates_exception (37-40)
  • missing_required_gates_exception (37-37)
🔇 Additional comments (7)
bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp (3)

16985-16990: missing_required_gates_exception documentation is well-scoped

The new exception docstring clearly states when it is thrown and ties it to missing required gates for the base network type, which matches the surrounding mapping changes. The separate (empty) ctor docstring is fine given that the default constructor has no extra semantics to explain.


21992-21993: Docstring for technology_mapping_params_inv looks consistent

The description “1-input NOT gate (inverter).” matches the naming and style of the other gate parameter docstrings (e.g., gt2, le2) and should be clear to users.


22002-22003: Docstring for technology_mapping_params_mux is clear and consistent

“3-input MUX gate (ITE).” accurately and succinctly describes the gate and matches the style of neighboring parameter docs, so this looks good.

test/algorithms/network_transformation/technology_mapping.cpp (2)

6-7: Test scaffolding improvements are appropriate

Adding <catch2/catch_test_macros.hpp> and moving the helper functions into an anonymous namespace are both sensible: the former is required for the new TEST_CASEs, and the latter avoids polluting the global namespace from test helpers. No issues here.

Also applies to: 21-23, 226-227


262-277: Complex all‑function mapping test aligns well with EMAP behavior

The new “Complex 3‑input” MIG‑only test and the “Complex all function” test using all_supported_standard_functions() give good coverage of EMAP with richer gate libraries across AIG/XAG/MIG/XMG:

  • They assert !mapping_error and logical equivalence via check_eq.
  • all_supported_standard_functions() correctly exercises both 2‑ and 3‑input gate cases, matching the EMAP use case for multi‑output cells.

This looks like a solid regression test for the mapper switch.

include/fiction/types.hpp (1)

57-73: Original concern about raw network type usage is unfounded—refactor is working as intended

Verification shows the codebase consistently uses the aliased network types (aig_nt, xag_nt, mig_nt, tec_nt), not raw mockturtle types. The logic_network_t variant stores only aliased pointer types (aig_ptr, xag_ptr, mig_ptr, tec_ptr), all instantiations create aliased types, and all call sites pass the extracted aliased types to ntk_type_name. The hypothetical behavioral concern about silent failures with raw network types does not occur in practice—there are no raw network types being passed anywhere. The refactor is clean and correct.

Likely an incorrect or invalid review comment.

include/fiction/algorithms/network_transformation/technology_mapping.hpp (1)

14-18: EMAP migration verified and correct

The mockturtle::emap function signature is emap(Ntk const &ntk, tech_library<NInputs, Configuration> const &library, emap_params const &ps = {}, emap_stats *pst = nullptr). This matches the parameter ordering, types, and defaults reflected in your code: the includes, emap_params, emap_stats, and the call in perform_mapping are all correctly wired to the v0.4 API. No issues with the EMAP migration.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp (1)

14173-14174: Consider adding documentation for helper functions.

Several new helper functions have empty docstrings:

  • get_ntk_type_name (network type name resolution)
  • get_sidb_lattice_name (lattice name resolution)
  • get_tech_cell_name (technology cell naming)
  • get_tech_impl_name (technology implementation naming)

Since this is an auto-generated file, add docstrings to the corresponding C++ source code if these functions are part of the public Python API.

Note: This aligns with the unchecked "added documentation" item in the PR checklist.

Also applies to: 14189-14190, 14209-14212

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bb49484 and a2d3986.

📒 Files selected for processing (4)
  • bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp (9 hunks)
  • cli/cmd/logic/src/map.cpp (5 hunks)
  • include/fiction/algorithms/network_transformation/technology_mapping.hpp (11 hunks)
  • include/fiction/technology/technology_mapping_library.hpp (1 hunks)
🧰 Additional context used
🧠 Learnings (5)
📚 Learning: 2025-09-25T10:31:01.287Z
Learnt from: marcelwa
Repo: cda-tum/fiction PR: 840
File: bindings/mnt/pyfiction/CMakeLists.txt:30-37
Timestamp: 2025-09-25T10:31:01.287Z
Learning: Headers in the pyfiction Python bindings target (bindings/mnt/pyfiction/) are private implementation details for the Python bindings and should not be made public or exported as part of the C++ API.

Applied to files:

  • bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp
📚 Learning: 2025-10-13T11:04:24.736Z
Learnt from: marcelwa
Repo: cda-tum/fiction PR: 854
File: cli/cmd/logic/src/abc.cpp:78-88
Timestamp: 2025-10-13T11:04:24.736Z
Learning: The `mockturtle::write_aiger` function in the mockturtle library supports writing all kinds of logic networks (AIG, XAG, MIG, TEC), not just AIG networks. No explicit conversion to AIG is required before calling this function.

Applied to files:

  • bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp
  • include/fiction/algorithms/network_transformation/technology_mapping.hpp
📚 Learning: 2025-09-08T13:33:29.693Z
Learnt from: Drewniok
Repo: cda-tum/fiction PR: 826
File: experiments/figure_of_merit_analysis/fom_analysis_2_input_1_output.cpp:5-6
Timestamp: 2025-09-08T13:33:29.693Z
Learning: In the fiction codebase, the preprocessor guard pattern `#if (FICTION_ALGLIB_ENABLED)` is preferred over `#if defined(FICTION_ALGLIB_ENABLED) && FICTION_ALGLIB_ENABLED` for ALGLIB feature detection. The current approach is sufficient for their build system configuration.

Applied to files:

  • include/fiction/algorithms/network_transformation/technology_mapping.hpp
📚 Learning: 2025-09-10T16:31:45.364Z
Learnt from: marcelwa
Repo: cda-tum/fiction PR: 828
File: include/fiction/technology/area.hpp:0-0
Timestamp: 2025-09-10T16:31:45.364Z
Learning: In include/fiction/technology/area.hpp, both fiction::area overloads should accept parameters as `const area_params<technology<Lyt>>& ps = {}` to allow binding the default temporary and ensure const-correctness. Docs in docs/technology/properties.rst should mirror these signatures.

Applied to files:

  • include/fiction/algorithms/network_transformation/technology_mapping.hpp
📚 Learning: 2025-10-13T14:43:13.479Z
Learnt from: hibenj
Repo: cda-tum/fiction PR: 852
File: include/fiction/algorithms/physical_design/orthogonal_planar.hpp:825-826
Timestamp: 2025-10-13T14:43:13.479Z
Learning: In the fiction library, logic networks are required to have at least one primary input (PI). The `orthogonal_planar` algorithm in `include/fiction/algorithms/physical_design/orthogonal_planar.hpp` enforces this invariant with an assertion rather than handling the zero-PI case.

Applied to files:

  • include/fiction/algorithms/network_transformation/technology_mapping.hpp
  • include/fiction/technology/technology_mapping_library.hpp
🧬 Code graph analysis (1)
cli/cmd/logic/src/map.cpp (1)
include/fiction/algorithms/network_transformation/technology_mapping.hpp (1)
  • technology_mapping (642-643)
🔇 Additional comments (25)
bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp (4)

10651-10656: LGTM!

The docstring accurately documents the validation function and its exception behavior, aligning with the new technology mapping validation feature.


16985-16990: LGTM!

The exception class is properly documented with a clear description of when it's thrown. The empty constructor docstring is acceptable for standard exception constructors.


21950-21976: LGTM!

The documentation accurately reflects the change from mockturtle::map to mockturtle::emap and provides comprehensive information about:

  • The new validation behavior
  • The exception that can be thrown
  • Required gates for different network types (AIG, XAG, MIG)

This aligns perfectly with the PR objectives.


21998-22000: LGTM!

The parameter docstrings provide clear, concise descriptions of the gate types. The technical terminology (half-adder, inverter, ITE) is accurate and appropriate for the target audience.

Also applies to: 22010-22010

cli/cmd/logic/src/map.cpp (6)

13-18: LGTM! Appropriate includes for new functionality.

The fmt/format.h include supports the new formatted warning/error messages, and type_traits is needed for std::decay_t and std::is_same_v used in the mapping lambda.


37-37: LGTM! Half-adder gate flag added correctly.

The new --ha flag aligns with the expanded gate support in the EMAP-based technology mapping.


78-99: LGTM! Simplified control flag handling.

The removal of logic_sharing flag handling is consistent with the switch to EMAP, which does not use this parameter. The save/restore pattern for decay and verbose flags is correctly preserved.


101-105: LGTM! Gate flags array updated to include new gates.

The array correctly includes ha and maintains proper alignment with the available gate flags.


116-123: Good defensive warning for remapping scenarios.

The warning when attempting to map an already-mapped tec_nt network helps users understand potential issues. However, note that the warning will always be printed for tec_nt networks even if remapping succeeds without errors.


127-142: Exception handling correctly integrated.

The try/catch block properly catches fiction::missing_required_gates_exception and prints the exception message. The early return on mapping_error prevents adding an invalid network to the store.

One observation: when mapping_error is set, the network is not added to the store, which is correct. However, when missing_required_gates_exception is caught, the exception is printed but flow continues normally (no store extension, which is also correct).

include/fiction/algorithms/network_transformation/technology_mapping.hpp (11)

13-25: LGTM! Includes properly updated for EMAP integration.

The explicit #include <fmt/format.h> addresses the previous review comment about fragile header ordering. The mockturtle network headers are appropriately added to support the std::is_same_v checks in validate_required_gates().


31-41: Well-designed exception class for gate validation failures.

The exception inherits from std::logic_error appropriately since missing required gates represents a programming/configuration error. The formatted message clearly indicates both the network type and missing gates.


104-107: LGTM! Half-adder gate parameter added.

The ha boolean flag is correctly added to the 2-input functions section with appropriate documentation.


337-342: Consider passing technology_mapping_params by const reference.

The static analysis hint from a past review noted that technology_mapping_params is 136 bytes. The constructor already takes it by const reference (const technology_mapping_params& ps), which is appropriate.


344-348: Good addition of [[nodiscard]] and const qualifiers.

The [[nodiscard]] attribute ensures the mapped result isn't accidentally discarded, and making run() const-qualified is appropriate since it doesn't modify the impl object's state.


358-359: LGTM! Half-adder gate included in 2-input mapping path.

The params.ha check is correctly added to the condition that triggers 2-input gate mapping.


384-445: Well-structured gate validation with comprehensive coverage.

The validate_required_gates() function correctly validates:

  • AIG networks require INV and AND
  • XAG networks require INV, AND, and XOR
  • MIG networks require INV and MAJ

The use of Ntk::base_type for type detection is the established pattern in mockturtle. Networks not matching these base types (e.g., tec_nt being remapped) will pass validation without checks, which aligns with the CLI warning for remapping scenarios.


504-507: LGTM! Half-adder gate library integration.

The conditional addition of GATE_HA to the library stream follows the same pattern as other 2-input gates.


611-611: Core change: Switch to mockturtle::emap.

This is the central change of the PR—replacing mockturtle::map with mockturtle::emap. The EMAP algorithm supports multi-output cells (like the new half-adder), which is the stated motivation for this change.


628-643: Documentation correctly updated for new exception behavior.

The @throws documentation clearly specifies the exception type and conditions under which it's thrown, which is good practice for API documentation.


48-48: Let me search for mockturtle API documentation to verify the compatibility:

mockturtle emap_params documentation and API
include/fiction/technology/technology_mapping_library.hpp (4)

18-25: LGTM! Type declarations simplified to auto.

Changing from inline constexpr const char* to inline constexpr auto is a stylistic improvement. The deduced type remains const char*, maintaining the same semantics while reducing verbosity.


30-42: LGTM! 2-ary gate declarations updated consistently.

All 2-input gate constants follow the same pattern with the auto type specifier.


44-48: New half-adder gate enables multi-output cell support.

The GATE_HA definition correctly specifies both outputs of a half-adder:

  • C=a*b (carry output)
  • S=!a*b+a*!b (sum output, equivalent to XOR)

This is the key addition that leverages EMAP's multi-output cell capability. The genlib format with two GATE lines for the same cell name is the standard way to define multi-output gates.


54-99: LGTM! 3-ary gates and decay variants updated consistently.

All 3-input gate definitions and their decay variants maintain correct genlib syntax. The multi-line string concatenation for decay variants is clean and readable.

# Conflicts:
#	.github/workflows/clang-tidy-review.yml
#	bindings/mnt/pyfiction/CMakeLists.txt
#	docs/changelog.rst

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Fix all issues with AI agents
In `@bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp`:
- Around line 14189-14190: Add a proper Doxygen comment block to the C++
declaration for get_sidb_lattice_name (e.g., /** `@brief` ... `@return` ... */)
describing what the function does and its return value, then regenerate the
mkdoc output so __doc_fiction_get_sidb_lattice_name is populated; update the
declaration for get_sidb_lattice_name (and any overloads) with `@brief` and
`@return` tags following the project's Doxygen style and run the mkdoc generation
step to refresh pybind11_mkdoc_docstrings.hpp.
- Around line 14173-14174: The docstring for get_ntk_type_name is empty (static
const char *__doc_fiction_get_ntk_type_name), so the Python binding exposes no
help text; fix by adding a Doxygen comment block to the C++ declaration of
get_ntk_type_name (use /** `@brief` ... `@return` ... */ with appropriate
description of what the function returns and any parameters if present) in the
source header where get_ntk_type_name is declared, then regenerate the mkdoc
output so the generated __doc_fiction_get_ntk_type_name contains the new text;
ensure you follow the project guideline to use modern Doxygen tags (`@brief`,
`@return`, etc.) and apply it to the exact symbol get_ntk_type_name so bindings
pick it up.
- Around line 14209-14212: Add Doxygen /** ... */ comments to the underlying C++
declarations for get_tech_cell_name and get_tech_impl_name (not just the
generated mkdoc strings) including `@brief` describing what each function returns
and an `@return` describing the return value; after updating the function
declarations, regenerate the mkdoc output so __doc_fiction_get_tech_cell_name
and __doc_fiction_get_tech_impl_name are populated. Ensure the Doxygen blocks
use modern commands (e.g., `@brief`, `@return`, `@param` if any) and are placed
immediately above the function signatures for get_tech_cell_name and
get_tech_impl_name.
- Around line 16986-16991: The docstring for the constructor of
missing_required_gates_exception is empty; add a Doxygen /** ... */ comment to
the C++ constructor declaration/definition for class
missing_required_gates_exception (include an `@brief` describing the exception and
`@throws` or `@param` tags as appropriate) in the original C++ source where the
constructor is defined, then regenerate the mkdoc output so
pybind11_mkdoc_docstrings.hpp contains the populated
__doc_fiction_missing_required_gates_exception_missing_required_gates_exception
entry; ensure the Doxygen uses modern commands (`@brief`, `@throws`) per guidelines.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@bindings/mnt/pyfiction/CMakeLists.txt`:
- Around line 11-18: PYFICTION_LTO_OPTIONS may retain a value from parent scope
when FICTION_ENABLE_IPO is OFF, causing unwanted LTO flags to be passed to
pybind11_add_module; update the CMake logic around FICTION_ENABLE_IPO to
explicitly unset or clear the PYFICTION_LTO_OPTIONS variable when
FICTION_ENABLE_IPO is false so only when FICTION_ENABLE_IPO is true you set
PYFICTION_LTO_OPTIONS to THIN_LTO, and ensure pybind11_add_module(pyfiction ...)
only sees PYFICTION_LTO_OPTIONS when it was explicitly set by this CMakeLists
(reference FICTION_ENABLE_IPO, PYFICTION_LTO_OPTIONS, and pybind11_add_module).

Comment thread bindings/mnt/pyfiction/CMakeLists.txt
@cda-tum cda-tum deleted a comment Feb 6, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pyproject.toml`:
- Around line 62-63: The global CMake default is set to cmake.build-type =
"Release" but the ReadTheDocs override still injects -O0; update the
ReadTheDocs-specific configuration so it explicitly sets cmake.build-type =
"Debug" (instead of relying on individual CFLAGS/LDFLAGS) to consolidate
optimization settings, remove or stop overriding with -O0 in that override
block, and ensure the ReadTheDocs override and the global cmake.build-type
setting are consistent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3ab655bb-e316-49de-9b75-feaaeeb701f6

📥 Commits

Reviewing files that changed from the base of the PR and between 867b64e and ea3ebca.

📒 Files selected for processing (3)
  • .github/workflows/clang-tidy-review.yml
  • bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp
  • pyproject.toml

Comment thread pyproject.toml
Comment on lines +62 to +63
# Set default build type to Release
cmake.build-type = "Release"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n "READTHEDOCS|mold|CMAKE_CXX_FLAGS|cmake.build-type|-fuse-ld" pyproject.toml
rg -n "apt(-get)? .*mold|brew .*mold|choco .*mold|dnf .*mold|pacman .*mold" -g "*.yml" -g "*.yaml" -g "*.toml" -g "*.md"
fd -HI '^\.readthedocs\.ya?ml$' -x sed -n '1,200p' {} || true

Repository: cda-tum/fiction

Length of output: 310


🏁 Script executed:

find . -name ".readthedocs*" -type f | head -20

Repository: cda-tum/fiction

Length of output: 77


🏁 Script executed:

sed -n '115,135p' pyproject.toml

Repository: cda-tum/fiction

Length of output: 628


🏁 Script executed:

rg -l "mold" --type py --type sh --type json --type toml --type yaml

Repository: cda-tum/fiction

Length of output: 90


🏁 Script executed:

cat -n .readthedocs.yml

Repository: cda-tum/fiction

Length of output: 1447


Consolidate conflicting optimization levels in ReadTheDocs override.

The global cmake.build-type = "Release" on line 63 conflicts with the -O0 flag in the ReadTheDocs override (line 125). The ReadTheDocs override should explicitly set cmake.build-type = "Debug" instead of relying on per-flag overrides.

Note: mold is properly provisioned in .readthedocs.yml (line 9), so the linker flags are not a fragility concern. However, consolidating the build type setting is cleaner and prevents potential configuration confusion.

Suggested config adjustment
 [[tool.scikit-build.overrides]]
 if.env.READTHEDOCS = "True"
 inherit.cmake.define = "append"
 cmake.define.FICTION_ENABLE_IPO = "OFF"
+cmake.build-type = "Debug"
 cmake.args = [
     "-DCMAKE_VERBOSE_MAKEFILE=ON",
-    "-DCMAKE_CXX_FLAGS=-O0",
-    "-DCMAKE_MODULE_LINKER_FLAGS=-fuse-ld=mold",
-    "-DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=mold",
-    "-DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=mold"
 ]

Also applies to: 123-128

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pyproject.toml` around lines 62 - 63, The global CMake default is set to
cmake.build-type = "Release" but the ReadTheDocs override still injects -O0;
update the ReadTheDocs-specific configuration so it explicitly sets
cmake.build-type = "Debug" (instead of relying on individual CFLAGS/LDFLAGS) to
consolidate optimization settings, remove or stop overriding with -O0 in that
override block, and ensure the ReadTheDocs override and the global
cmake.build-type setting are consistent.

marcelwa and others added 3 commits July 17, 2026 22:15
Fixes discovered during review of the mockturtle::map -> emap switch:

- technology_mapping_library.hpp: the two GATE_HA lines shared the same
  genlib name "ha", so mockturtle classified them as a single multi-output
  cell and (with default library settings) excluded them from the
  single-output library, making `ps.ha`/`--ha` a no-op that could only ever
  produce a mapping error. Give the sum/carry gates distinct names
  (ha_carry/ha_sum) so they load as two usable single-output gates.

- Add C++ tests exercising the half-adder path: mapping a technology_network
  half-adder/full-adder using only the ha gates (verifying both carry and sum
  are used and the result is equivalent), plus ha combined with the standard
  2-input library.

- Expose the `ha` parameter in the pyfiction technology_mapping_params binding
  and add a Python test.

- Restore the technology mapping test matrix that had been narrowed to
  mig-only: AIG/MIG/XMG for the AOIM and name-conservation cases and MIG/XMG
  for the 3-input case. The remaining exclusions (XAG everywhere, AIG in the
  3-input case) are intentional: the new validate_required_gates() correctly
  rejects those combinations because the chosen helper params omit XOR/AND.

- Remove the now-dead map_and_check_all_func / map_and_check_all_standard_func
  test helpers.

- changelog: add entries for half-adder support, the new
  missing_required_gates_exception, and the breaking emap_params/emap_stats
  and CLI behavior changes; move the already-released "macOS 13 / x86_64"
  removal note back under v0.6.12.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AABcKjPw3jsm6kboRDrMdi
Signed-off-by: Marcel Walter <marcel.walter@tum.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants