{"id":13536166,"url":"https://github.com/boschmitt/tweedledum","last_synced_at":"2025-04-06T17:11:41.558Z","repository":{"id":34148756,"uuid":"140888411","full_name":"boschmitt/tweedledum","owner":"boschmitt","description":"C++17 Library for analysis, compilation/synthesis, and optimization of quantum circuits","archived":false,"fork":false,"pushed_at":"2023-07-13T00:34:12.000Z","size":14164,"stargazers_count":92,"open_issues_count":22,"forks_count":34,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-03-15T09:48:18.017Z","etag":null,"topics":["optimization","quantum","quantum-circuit","quantum-compiler","quantum-computing","synthesis"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/boschmitt.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-07-13T20:03:36.000Z","updated_at":"2024-03-09T20:15:17.000Z","dependencies_parsed_at":"2023-10-20T18:35:13.933Z","dependency_job_id":null,"html_url":"https://github.com/boschmitt/tweedledum","commit_stats":{"total_commits":263,"total_committers":7,"mean_commits":37.57142857142857,"dds":0.03041825095057038,"last_synced_commit":"9d3a2fab17e8531e1edc0ab927397d449b9942a4"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boschmitt%2Ftweedledum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boschmitt%2Ftweedledum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boschmitt%2Ftweedledum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boschmitt%2Ftweedledum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boschmitt","download_url":"https://codeload.github.com/boschmitt/tweedledum/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247517912,"owners_count":20951718,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["optimization","quantum","quantum-circuit","quantum-compiler","quantum-computing","synthesis"],"created_at":"2024-08-01T09:00:35.390Z","updated_at":"2025-04-06T17:11:41.536Z","avatar_url":"https://github.com/boschmitt.png","language":"C++","funding_links":[],"categories":["Quantum Software Packages","Quantum simulators"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://cdn.rawgit.com/boschmitt/tweedledum/master/tweedledum.svg\" width=\"128\" height=\"128\" style=\"margin-right: 12pt\"/\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/license-MIT-000000.svg\"\u003e\n  \u003ca href=\"https://github.com/boschmitt/tweedledum/actions/workflows/macos.yml\"\u003e\n    \u003cimg src=\"https://github.com/boschmitt/tweedledum/workflows/MacOS/badge.svg\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/boschmitt/tweedledum/actions/workflows/ubuntu.yml\"\u003e\n    \u003cimg src=\"https://github.com/boschmitt/tweedledum/workflows/Ubuntu/badge.svg\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/boschmitt/tweedledum/actions/workflows/windows.yml\"\u003e\n    \u003cimg src=\"https://github.com/boschmitt/tweedledum/workflows/Windows/badge.svg\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/boschmitt/tweedledum/actions/workflows/build_wheels.yml.yml\"\u003e\n    \u003cimg src=\"https://github.com/boschmitt/tweedledum/actions/workflows/build_wheels.yml/badge.svg\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n    /!\\ (Warning) If you have used tweedledum before: the master branch history is broken.\n    /!\\ The new master branch is a completely rewrite of the library. The old version can be found\n    /!\\ on **alpha** branch. (Sorry for the inconvenience!!---but it is for a great cause)\n\n**tweedledum** is a library for synthesis, compilation, and optimization of\nquantum circuits.  The library is written to be scalable up to problem sizes in\nwhich quantum circuits outperform classical ones. Also, it is meant to be used\nboth independently and alongside established tools.\n\n\nIts design is guided by three mantras:\n\n- __Gotta run fast__: execution-time performance is a priority.\n\n- __Your compiler, your rules__.  You know better. At least, Tweedledum \nhopes so! The library provides a standard set of operators that can be easily \nextended (thanks to some type-erasure black magic).  However, the library will \nleave your operators completely alone if you don't write passes that \nspecifically manipulate them.  Furthermore, Tweedledum will rarely take any\ndecision in your behalf, i.e., it does not provide generic methods to optimize\nor synthesize circuits, you need to specifically call the algorithms you want.\n\n- __Opinionated, but not stubborn__.  Many passes and synthesis algorithms have\nmany configuration parameters.  Tweedledum comes with reasonable defaults and \ncurated opinions of what value such parameters should take.  But in the end,\nit all up to you.\n\n__Corollary__:  Because of it's flexibility, Tweedledum is capable of accepting\ngates/operators that are defined as python classes.  Indeed, any pythonic \nframework can use the library as a circuit manager.  Meaning that the library \ncan be used to slowly transition the core and performance sensitive parts of a \npythonic framework to C++, while maintaining the capability of users to develop\npasses in python.\n\n# Installation\n\n[Known issues](#known-issues) with _macOS High Sierra (10.13)_ and _macOS Mojave (10.14)_.\n\n`tweedledum` has two python packages that can be installed using `pip`.  For\nboth, you will at least __Python 3.6__.  The `tweedledum` package contains the\nlatest stable release.  You can install it from PyPI using:\n\n* Latest stable release (Linux/Mac/Windows)\n\n```\npip install tweedledum\n```\n\nFor the developers, users or researchers who are comfortable living on the \nabsolute bleeding edge, `tweedledum-dev` contains that latest developments \nmerged into the master branch.\n\n* Latest (Linux/Mac/Windows)\n\n```\npip install tweedledum-dev\n```\n\n__Warning__: The two packages cannot be installed together.\n\n# Installation from source (Development)\n\nInstalling `tweedledum` from the source, instead of using the Python Package \nIndex (PyPI) repository version, allows you to extend the latest version of the\ncode. In the following, I will explain two workflows I personally use for\ndevelopment. Choose one that best suits your needs.\n\nAlright, both workflows start the same way. You clone the repository:\n```\ngit clone https://github.com/boschmitt/tweedledum.git\n```\n\n## C++\nThe first workflow is pure C++. We start by creating a directory to hold the \nbuild output:\n\n```\nmkdir build      \ncd build\n```\n\nNote that the library has a directory named `examples/`.  If we set the\n``TWEEDLEDUM_EXAMPLES`` CMake variable to ``TRUE``.  Any `.cpp` file in this\ndirectory will be compiled to its own executable. \n\nSo, lets assume you have a file named `hello_world.cpp` in the `examples/`.\nFirst we configure our project and enable the examples:\n\n```\ncmake -DTWEEDLEDUM_EXAMPLES=TRUE ..\n```\n\nIf you are on a \\*nix system, you should now see a Makefile in the current\ndirectory. Now you can build the library by running `make`. At this point you\ncan build the `hello_world` executable by calling\n\n```\nmake hello_world\n```\n\nOnce the examples have been built you can run it:\n\n```\n./examples/hello_world\n```\n\n## C++ and Python\n\nThe second workflow is a bit of a hack.  In Python we can install libraries in\neditable mode, meaning that code changes to the _Python code_ in the project\ndon't require a reinstall to be applied. \n\nIf you want to install it in editable mode, you can do this with:\n```\npip install -e .\n```\n\nThe only problem now, is that if we change the C++ code, we will need to \nreinstall the library.  Fortunately, there is a way to circumvent this \nannoyance.  \n\nAfter installing in editable mode, you will see that in `python/tweedledum/` \nthere is a cpython shared library `_tweedledum.cpython-...` Remove this file:\n\n```sh\nrm python/tweedledum/_tweedledum.cpython-...\n```\n\nNow, we create a build directory as we did with the C++ workflow:\n```sh\nmkdir build      \ncd build\n```\n\nWe can manually build the cpython shared library using:\n```sh\nmake _tweedledum\n```\n\nThis will create the library in the `build/` directory. Now, all we need to\ncreate a symbolic link in `python/tweedledum/` that points the library in \n`build/`:\n\n```sh\nln -s _tweedledum.cpython-39-darwin.so ../python/tweedledum/\n```\n\nNow, whenever we change the C++ code and rebuild the python library, the changes\nwon't require a reinstall of the library to be available.\n\n# Used third-party tools\n\nThe library it is built, tested, bind to python, and whatnot using many\nthird-party tools and services. Thanks a lot!\n\n- [**abc**](https://github.com/berkeley-abc/abc) - ABC: System for Sequential Logic Synthesis and Formal Verification\n- [**bill**](https://github.com/lsils/bill) - C++ header-only reasoning library\n- [**Catch2**](https://github.com/catchorg/Catch2) test framework for unit-tests, TDD and BDD\n- [**CMake**](https://cmake.org) for build automation\n- [**Eigen**](https://gitlab.com/libeigen/eigen) template library for linear algebra\n- [**{fmt}**](https://github.com/fmtlib/fmt) - A modern formatting library\n- [**kitty**](https://github.com/msoeken/kitty) - truth table library \n- [**lorina**](https://github.com/hriener/lorina) - C++ parsing library for simple formats used in logic synthesis and formal verification \n- [**mockturtle**](https://github.com/lsils/mockturtle) - C++ logic network library\n- [**nlohmann/json**](https://github.com/nlohmann/json) - JSON for Modern C++\n- [**parallel_hashmap**](https://github.com/greg7mdp/parallel-hashmap) - A family of header-only, very fast and memory-friendly hashmap and btree containers.\n- [**percy**](https://github.com/lsils/percy) - C++ header-only exact synthesis library\n- [**pybind11**](https://github.com/pybind/pybind11) - Seamless operability between C++11 and Python\n- [**rang**](https://github.com/agauniyal/rang) - A Minimal, Header only Modern c++ library for terminal goodies\n\n## Known issues\n\nThese are issues that hopefully will be fixed, but currently are unsolved.  If\nyou know how to help with one of these issues, contributions are welcome!\n\n### macOS: High Sierra (10.13) and Mojave (10.14)\n\n`tweedledum` offers limited support for both systems.  While wheels might be\navailable for some releases, it is strongly advised to install `tweedledum` or\n`tweedledum-dev` by building them directly from source.  For example:\n\n```sh\nCC=gcc-10 CXX=g++-10 CXXFLAGS=\"-static-libgcc -static-libstdc++\" pip install tweedledum --no-binary :all:\n```\n\nNote that such command requires a working `gcc10` installation. (It also works\nwith `gcc11`, but no further tests were made.) I recommend the use of \n[Homebrew](https://brew.sh) to install `gcc`. (Or maybe \n[Tigerbrew](https://github.com/mistydemeo/tigerbrew))\n\n## License\n\nThis software is licensed under the MIT licence (see \n[LICENSE](https://github.com/boschmitt/tweedledum/blob/master/LICENSE)).\n\n## EPFL logic synthesis libraries\n\ntweedledum is part of the\n[EPFL logic synthesis](https://lsi.epfl.ch/page-138455-en.html) libraries.\nThe other libraries and several examples on how to use and integrate the \nlibraries can be found in the \n[logic synthesis tool showcase](https://github.com/lsils/lstools-showcase).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboschmitt%2Ftweedledum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboschmitt%2Ftweedledum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboschmitt%2Ftweedledum/lists"}