{"id":21375260,"url":"https://github.com/qbraid/qbraid-algorithms","last_synced_at":"2025-10-12T06:27:02.655Z","repository":{"id":239083077,"uuid":"798458995","full_name":"qBraid/qbraid-algorithms","owner":"qBraid","description":"Build quantum algorithms with qBraid","archived":false,"fork":false,"pushed_at":"2025-09-19T05:32:09.000Z","size":1062,"stargazers_count":7,"open_issues_count":1,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-19T07:34:24.830Z","etag":null,"topics":["algorithms","openqasm","qbraid","quantum"],"latest_commit_sha":null,"homepage":"http://sdk.qbraid.com/qbraid-algorithms/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qBraid.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-05-09T20:24:58.000Z","updated_at":"2025-09-16T17:04:47.000Z","dependencies_parsed_at":"2024-12-18T02:33:07.727Z","dependency_job_id":"f0699251-d9b3-41eb-b336-bdb872cdeb3c","html_url":"https://github.com/qBraid/qbraid-algorithms","commit_stats":null,"previous_names":["qbraid/qbraid-algorithms"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/qBraid/qbraid-algorithms","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qBraid%2Fqbraid-algorithms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qBraid%2Fqbraid-algorithms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qBraid%2Fqbraid-algorithms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qBraid%2Fqbraid-algorithms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qBraid","download_url":"https://codeload.github.com/qBraid/qbraid-algorithms/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qBraid%2Fqbraid-algorithms/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279010483,"owners_count":26084757,"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","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["algorithms","openqasm","qbraid","quantum"],"created_at":"2024-11-22T09:09:31.862Z","updated_at":"2025-10-12T06:27:02.649Z","avatar_url":"https://github.com/qBraid.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# qbraid-algorithms\n\n\u003cp align=\"left\"\u003e\n  \u003ca href=\"https://github.com/qBraid/qbraid-algorithms/actions/workflows/main.yml\"\u003e\n    \u003cimg src=\"https://github.com/qBraid/qbraid-algorithms/actions/workflows/main.yml/badge.svg?branch=main\" alt=\"CI\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/qBraid/qbraid-algorithms\"\u003e \n    \u003cimg src=\"https://codecov.io/gh/qBraid/qbraid-algorithms/graph/badge.svg?token=7jYcnneDys\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://pypi.org/project/qbraid-algorithms/\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/v/qbraid-algorithms.svg?color=blue\" alt=\"PyPI version\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://pypi.org/project/qbraid-algorithms/\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/pyversions/qbraid-algorithms.svg?color=blue\" alt=\"PyPI version\"/\u003e\n  \u003c/a\u003e\n  \u003ca href='http://www.apache.org/licenses/LICENSE-2.0'\u003e\n    \u003cimg src='https://img.shields.io/github/license/qBraid/qbraid-qir.svg' alt='License'/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://discord.gg/TPBU2sa8Et\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Discord-%235865F2.svg?logo=discord\u0026logoColor=white\" alt=\"Discord\"/\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\nPython package for building, simulating, and benchmarking hybrid quantum-classical algorithms.\n\n[\u003cimg src=\"https://qbraid-static.s3.amazonaws.com/logos/Launch_on_qBraid_white.png\" width=\"150\"\u003e](https://account.qbraid.com?gitHubUrl=https://github.com/qBraid/qbraid-algorithms.git)\n\n## Installation\n\nqbraid-algorithms requires Python 3.11 or greater, and can be installed with pip as follows:\n\n```bash\npip install qbraid-algorithms\n```\n\n\u003e[!WARNING]\n\u003e **This project is \"pre-alpha\", and is not yet stable or fully realized. Use with caution, as the API and functionality are subject to significant changes.**\n\n### Install from source\n\nYou can also install from source by cloning this repository and running a pip install command\nin the root directory of the repository:\n\n```bash\ngit clone https://github.com/qBraid/qbraid-algorithms.git\ncd qbraid-algorithms\npip3 install .\n```\n\n## Check version\n\nYou can view the version of qbraid-algorithms you have installed within a Python shell as follows:\n\n```python\nimport qbraid_algorithms\n\nqbraid_algorithms.__version__\n```\n\n## Key Features: Load algorithms as PyQASM modules and QASM files\n\nqBraid Algorithms provides a collection of quantum algorithms that can be loaded\nas [PyQASM](https://docs.qbraid.com/pyqasm/user-guide/overview) modules, or\nyou can generate .qasm files to use them as subroutines in your own circuits.\n\n### Loading Algorithms as PyQASM Modules\n\nTo load an algorithm as a PyQASM module, use the `load_algorithm` function from the `qbraid_algorithms` package, passing algorithm-specific parameters. For example, to load the Quantum Fourier Transform (QFT) algorithm:\n\n```python\nfrom qbraid_algorithms import qft\n\nqft_module = qft.load_algorithm(3) # Load QFT for 3 qubits\n```\n\nNow, you can perform operations with the PyQASM module, such as unrolling, and\nconverting back to a QASM string:\n\n```python\nqft_module.unroll()\nqasm_str = pyqasm.dumps(qft_module)\n```\n\n### Loading Algorithms as `.qasm` Files\n\nIn order to utilize algorithms as subroutines in your own circuits, use the\n`generate_subroutine` function for your desired algorithm. By passing algorithm-specific parameters, and optionally a desired output path, you can\ngenerate a .qasm file containing a subroutine for the paramterized circuit. For\nexample, to generate a QFT subroutine for 4 qubits:\n\n```python\nfrom qbraid_algorithms import qft, iqft\npath = \"path/to/output\" # Specify your desired output path\nqft.generate_subroutine(4) # Generate 4-qubit QFT in the current directory\niqft.generate_subroutine(4, path=path) # Generate 4-qubit IQFT in specified path\n\n```\n\nTo utilize the generated subroutine in your own circuit, include the generated\n.qasm file, and call the subroutine on an qubit register of the size specified\nwhen generating the subroutine. For example, after running\n\n```python\nqft.generate_subroutine(4)\n```\n\nyou can append `include \"qft.qasm\";` to your OpenQASM file, and call the\nsubroutine. For example:\n\n```qasm\nOPENQASM 3.0;\ninclude \"qft.qasm\";\n\nqubit[4] q;\nbit[4] c;\n\nqft(q);\nmeasure q -\u003e c;\n```\n\n## CLI Usage\n\nqBraid Algorithms includes a command-line interface (CLI) for generating quantum algorithm subroutines.\n\n### Installation\n\nTo use the CLI, install with CLI dependencies:\n\n```bash\npip install \"qbraid-algorithms[cli]\"\n```\n\nOr install from source:\n\n```bash\npip install -e \".[cli]\"\n```\n\n### Generate Subroutines\n\nGenerate quantum algorithm subroutines that can be included in other circuits:\n\n```bash\n# Generate QFT subroutine for 4 qubits\nqbraid-algorithms generate qft --qubits 4\n\n# Generate IQFT subroutine for 3 qubits with custom name and show the circuit\nqbraid-algorithms generate iqft -q 3 -o my_iqft.qasm --gate-name my_iqft --show\n\n# Generate Bernstein-Vazirani circuit for secret \"101\" and display it\nqbraid-algorithms generate bernvaz --secret \"101\" --show\n\n# Generate only the oracle for Bernstein-Vazirani\nqbraid-algorithms generate bernvaz -s \"1001\" --oracle-only --show\n\n# Generate QPE subroutine for 4 qubits with a custom unitary gate\nqbraid-algorithms generate qpe --unitary-file my_gate.qasm --qubits 4\n\n# Generate QPE with custom output and show the circuit\nqbraid-algorithms generate qpe -u gate.qasm -q 3 -o my_qpe.qasm --show\n```\n\n### Help\n\nGet help for any command:\n\n```bash\nqbraid-algorithms --help\nqbraid-algorithms generate --help\nqbraid-algorithms generate qft --help\nqbraid-algorithms generate iqft --help\nqbraid-algorithms generate bernvaz --help\nqbraid-algorithms generate qpe --help\nqbraid-algorithms generate bernvaz --help\n```\n\n### Examples\n\n#### Complete Workflow\n\n1. Generate a QFT subroutine:\n\n   ```bash\n   qbraid-algorithms generate qft --qubits 3\n   ```\n\n2. Generate a Bernstein-Vazirani oracle and view it:\n\n   ```bash\n   qbraid-algorithms generate bernvaz --secret \"101\" --oracle-only --show\n   ```\n\n3. Generate an IQFT circuit with custom output:\n\n   ```bash\n   qbraid-algorithms generate iqft --qubits 4 --output my_iqft_4.qasm --show\n   ```\n\n4. Generate a QPE subroutine for phase estimation:\n   ```bash\n   qbraid-algorithms generate qpe --unitary-file t_gate.qasm --qubits 3 --show\n   ```\n\n## Community\n\n**We are actively looking for new contributors!**\n\n- Interested in contributing code, or making a PR? See\n  [CONTRIBUTING.md](CONTRIBUTING.md)\n- For feature requests and bug reports: [Submit an issue](https://github.com/qBraid/qbraid-algorithms/issues)\n- For discussions and/or specific questions about qBraid services, [join our discord community](https://discord.gg/TPBU2sa8Et)\n- For questions that are more suited for a forum, post to [Stack Exchange](https://quantumcomputing.stackexchange.com/) with the [`qbraid`](https://quantumcomputing.stackexchange.com/questions/tagged/qbraid) tag.\n- By participating, you are expected to uphold our [code of conduct](CODE_OF_CONDUCT).\n\n## License\n\n[Apache-2.0 License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqbraid%2Fqbraid-algorithms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqbraid%2Fqbraid-algorithms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqbraid%2Fqbraid-algorithms/lists"}