classiq-library
The Classiq Library is the largest collection of quantum algorithms and applications. It is the best way to explore quantum computing software. We welcome community contributions to our Library 🙌
Science Score: 67.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 3 DOI reference(s) in README -
✓Academic publication links
Links to: zenodo.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (18.4%) to scientific vocabulary
Keywords
Repository
The Classiq Library is the largest collection of quantum algorithms and applications. It is the best way to explore quantum computing software. We welcome community contributions to our Library 🙌
Basic Info
- Host: GitHub
- Owner: Classiq
- License: mit
- Language: Jupyter Notebook
- Default Branch: main
- Homepage: https://platform.classiq.io
- Size: 136 MB
Statistics
- Stars: 1,922
- Watchers: 10
- Forks: 867
- Open Issues: 43
- Releases: 56
Topics
Metadata Files
README.md
Classiq: High-Level Quantum Modeling Language
Classiq provides a powerful platform for designing, optimizing, analyzing, and executing quantum programs. This repository hosts a comprehensive collection of quantum functions, algorithms, applications, and tutorials built using the Classiq SDK and our native Qmod language.
Whether you're a researcher, developer, or student, Classiq helps you simplify complex quantum workflows and seamlessly transform quantum logic into optimized circuits by leveraging our high-level functional design approach. A user-friendly interface allows you to model, simulate, visualize, and execute quantum programs across various quantum hardware platforms.
⚛️ Platform | 👋 Join Slack | 📖 Documentation | Getting Started
Installation
Working with Classiq's latest GUI requires no installations! Just head over to Classiq's platform and follow the examples below over there :)
If you'd rather work programmatically using Python, Classiq also provides an SDK, which can be installed as follows:
bash
pip install classiq
Alternatively, after cloning this repository, you may run
bash
pip install --upgrade -r requirements.txt
Running This Repository's Demos
This repository has 2 kinds of demos: .qmod and .ipynb.
The .qmod files are intended for usage with Classiq's platform.
Upload those .qmod files into the Synthesis tab
The .ipynb files are intended to be viewed inside JupyterLab (or by programs that support such files, such as VSCode).
Use the library with AI agents
See the Classiq documentation to learn how to use the Classiq library with AI agents.
Create Quantum Programs with Classiq
The simplest quantum circuit has 1 qubit and has a single X gate.
Using Classiq's SDK, it would look like this:
```python from classiq import *
NUM_QUBITS = 1
@qfunc def main(res: Output[QBit]): allocate(NUM_QUBITS, res) X(res)
quantum_program = synthesize(main)
show(quantum_program)
result = execute(quantumprogram).resultvalue() print(result.dataframe) ```
| | res | count | probability | bitstring | | --: | --: | ----: | ----------: | --------: | | 0 | 1 | 2048 | 1 | 1 |
Let's unravel the code above:
def main: We define the logic of our quantum program. We'll expand on this point soon below.synthesize: We synthesize the logic we defined into a Quantum Program. From a logical definition of quantum operations, into a series of quantum gates.execute: Executing the quantum program. Can be executed on a physical quantum computer, or on simulations. Defaults to simulations.
1) Defining the Logic of Quantum Programs
The function above had 4 lines:
python
@qfunc
def main(res: Output[QBit]):
allocate(NUM_QUBITS, res)
X(res)
The 1st line states that the function will be a quantum one. Further documentation.
The 2nd line defines the type of the output. Further examples on types
The 3rd line allocates several qubits (in this example, only 1) in this quantum variable. Further details on allocate
The 4th line applies an X operator on the quantum variable. Further details on quantum operators
More Examples
Initializing $\ket{-}$ state:
python
@qfunc
def prep_minus(out: Output[QBit]) -> None:
allocate(1, out)
X(out)
H(out)
A part of the Deutsch Jozsa algorithm (see the full algorithm here)
python
@qfunc
def deutsch_jozsa(predicate: QCallable[QNum, QBit], x: QNum) -> None:
hadamard_transform(x)
my_oracle(predicate=lambda x, y: predicate(x, y), target=x)
hadamard_transform(x)
A part of a QML encoder (see the full algorithm here)
python
@qfunc
def angle_encoding(exe_params: CArray[CReal], qbv: Output[QArray[QBit]]) -> None:
allocate(exe_params.len, qbv)
repeat(
count=exe_params.len,
iteration=lambda index: RY(pi * exe_params[index], qbv[index]),
)
For more, see this repository :)
2) Synthesis : Logic to Quantum Program
This is where the magic happens.
Taking a the main function, which is a set of logical operations, and synthesizing it into physical qubits and the gates entangling them, is not an easy task.
Classiq's synthesis engine is able to optimize this process, whether by requiring the minimal amount of physical qubits, thus reusing as many qubits as possible, or by requiring minimal circuit width, thus lowering execution time and possible errors.
3) Execution
Classiq provides an easy-to-use way to execute quantum programs, and provides various insights of the execution results together with a familiar interface: pandas.DataFrame.
Diagrams
1 diagram is worth a thousand words
```mermaid flowchart IDEInput[Classiq IDE]
SDKInput[<a href='https://docs.classiq.io/latest/sdk-reference/'>Classiq python SDK</a>]
Model[<a href='https://docs.classiq.io/latest/qmod-reference/'>Quantum Model</a>]
Synthesis[<a href='https://docs.classiq.io/latest/classiq_101/classiq_concepts/optimize/'>Synthesis Engine</a>]
QuantumProgram[Quantum Program]
Execution[<a href='https://docs.classiq.io/latest/classiq_101/classiq_concepts/execute/'>Execution</a>]
Analyze[<a href='https://docs.classiq.io/latest/classiq_101/classiq_concepts/analyze/'>Analyze & Debug</a>]
IBM[IBM]
Amazon[Amazon Braket]
Azure[Azure Quantum]
Nvidia[Nvidia]
IDEInput --> Model;
SDKInput --> Model;
Model --> Synthesis;
Synthesis --> QuantumProgram;
ExternalProgram <--> QuantumProgram;
QuantumProgram --> Analyze;
QuantumProgram --> Execution;
Execution --> IBM
Execution --> Amazon
Execution --> Azure
Execution --> Nvidia
```
Build Your Own
With Classiq, you can build anything. Classiq provides a powerful modeling language to describe any quantum program, which can then be synthesized and executed on any hardware or simulator. Explore our Documentation to learn everything.
SDK : Classiq's Python Interface
Example: Calculating 3+5 with Classiq
```python from classiq import *
@qfunc def prepare_3(var: Output[QArray]) -> None: allocate(2, var) X(var[0]) X(var[1])
@qfunc def prepare_5(var: Output[QArray]) -> None: allocate(3, var) X(var[0]) X(var[2])
@qfunc def main(res: Output[QNum]) -> None: a = QNum("a") b = QNum("b")
prepare_3(a)
prepare_5(b)
res |= a + b # 3+5 should be 8
quantum_program = synthesize(main)
show(quantum_program)
result = execute(quantumprogram).resultvalue() print(result.dataframe) ```
| | res | count | probability | bitstring | | --: | --: | ----: | ----------: | --------: | | 0 | 8 | 2048 | 1 | 1000 |
For some pre-built state preparations, read here
IDE : Classiq's Platform
Every example found in this repository can also be accessed via Classiq's platform, in the model tab, under the same folder structure.
Additionally, one may write their own model in the model editor (highlighted in green) or upload his own model (highlighted in red)

Example: 3+5 with Classiq
- Create a model (paste in the
modeltab)
``` qfunc get_3(output x: qbit[]){ allocate(2,x); X(x[0]); X(x[1]); }
qfunc get_5(output x: qbit[]){ allocate(3,x); X(x[0]); X(x[2]); }
qfunc main(output res: qnum){ a: qnum; b: qnum; get3(a); get5(b); res = a + b; } ```
- Press Synthesize:

- Press Execute:

- Press Run:

- View Results:

Have questions? Feedback? Something to share? Welcome to join our open Slack Community
Owner
- Name: Classiq
- Login: Classiq
- Kind: organization
- Repositories: 1
- Profile: https://github.com/Classiq
Citation (CITATION.bib)
@misc{classiq-library2024,
title={Design and synthesis of scalable quantum programs},
author={Goldfriend, Tomer and Reichental, Israel and Naveh, Amir and Gazit, Lior and Yoran, Nadav and Alon, Ravid and Ur, Shmuel and Lahav, Shahak and Cornfeld, Eyal and Elazari, Avi and Emanuel, Peleg and Harpaz, Dor and Michaeli, Tal and Erez, Nati and Preminger, Lior and Shapira, Roman and Garcell, Erik Michael and Samimi, Or and Kisch, Sara and Hallel, Gil and Kishony, Gilad and Wingerden, Vincent van and Rosenbloom, Nathaniel A. and Opher, Ori and Vax, Matan and Smoler, Ariel and Danzig, Tamuz and Schirman, Eden and Sella, Guy and Cohen, Ron and Garfunkel, Roi and Cohn, Tali and Rosemarin, Hanan and Hass, Ron and Jankiewicz, Klem and Gharra, Karam and Roth, Ori and Azar, Barak and Asban, Shahaf and Linkov, Natalia and Segman, Dror and Sahar, Ohad and Davidson, Niv and Minerbi, Nir and Naveh, Yehuda},
year={2024},
doi={10.48550/arXiv.2412.07372},
eprint={2412.07372},
archivePrefix={arXiv},
primaryClass={quant-ph}
}
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 99
- Total pull requests: 979
- Average time to close issues: about 1 month
- Average time to close pull requests: 6 days
- Total issue authors: 72
- Total pull request authors: 291
- Average comments per issue: 2.38
- Average comments per pull request: 1.19
- Merged pull requests: 493
- Bot issues: 0
- Bot pull requests: 19
Past Year
- Issues: 71
- Pull requests: 567
- Average time to close issues: about 1 month
- Average time to close pull requests: 4 days
- Issue authors: 56
- Pull request authors: 72
- Average comments per issue: 2.04
- Average comments per pull request: 0.96
- Merged pull requests: 290
- Bot issues: 0
- Bot pull requests: 19
Top Authors
Issue Authors
- NadavClassiq (8)
- orsa-classiq (4)
- amir-naveh (4)
- TomerGoldfriend (4)
- EdenSchirmanClassiq (3)
- RAHUL2418 (2)
- FipNad (2)
- virajd98 (2)
- bpatel1121 (2)
- zzz845zz (2)
- VidurangaLanders (2)
- gzemlevskiy17 (2)
- Death0004 (2)
- mitul3737 (2)
- ajayarulkumaran5678 (1)
Pull Request Authors
- classiqdor (110)
- NadavClassiq (89)
- orsa-classiq (63)
- AnnePicus (51)
- Nadav138 (36)
- ravidalon (33)
- OriRothClassiq (28)
- TomerGoldfriend (19)
- Adamg-classiq (16)
- zach-classiq (13)
- Alexandre-Classiq (13)
- Infi-DOS (11)
- classiq-library-bot-app[bot] (11)
- arielsmoler (10)
- NoahNzeki (10)