Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
UTSAVS26 authored Oct 21, 2024
1 parent 74172d7 commit c4f1ba1
Showing 1 changed file with 37 additions and 42 deletions.
79 changes: 37 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<img src="README_resources/classiq-logo.svg" width="300" height="150">
</div>

# Classiq: High-Level Quantum Modeling Language
# Classiq

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.
Your entry-point for creating & running quantum programs.

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.
This repository holds a wide collection of quantum functions, algorithms, applications, and tutorials built with Classiq.

<hr> <br>

Expand All @@ -20,7 +20,7 @@ Whether you're a researcher, developer, or student, Classiq helps you simplify c
<a href="https://short.classiq.io/join-slack">👋 Join Slack</a>
&emsp;|&emsp;
<a href="https://docs.classiq.io/latest/">📖 Documentation</a>
&emsp; | &emsp;
&emsp;|&emsp;
<a href="https://docs.classiq.io/latest/">Getting Started</a>
&emsp;
</p>
Expand All @@ -29,10 +29,9 @@ Whether you're a researcher, developer, or student, Classiq helps you simplify c

# Installation

Working with Classiq's latest GUI requires no installations!
Just head over to [Classiq's platform](https://platform.classiq.io/) and follow the examples below over there :)
Working with Classiq's latest GUI requires no installations! Just head over to [Classiq's platform](https://platform.classiq.io/) 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:
If you'd rather work programmatically, using Python, Classiq also provides an SDK, which can be installed as follows:

```bash
pip install classiq
Expand All @@ -42,16 +41,15 @@ Please note that the latest Classiq SDK for Python doesn't work in Python 3.12 y

## Running This Repository's Demos

This repository has 2 kinds of demos: `.qmod` and `.ipynb`.
This repository has two kinds of demos: `.qmod` and `.ipynb`.

The `.qmod` files are intended for usage with [Classiq's platform](https://platform.classiq.io/).
Upload those `.qmod` files into the [Synthesis tab](https://platform.classiq.io/synthesis)
The `.qmod` files are intended for use with [Classiq's platform](https://platform.classiq.io/). Upload those `.qmod` files into the [Synthesis tab](https://platform.classiq.io/synthesis).

The `.ipynb` files are intended to be viewed inside [JupyterLab](https://jupyter.org/).

# Create Quantum Programs with Classiq

The simplest quantum circuit has 1 qubit and has a single `X` gate.
The simplest quantum circuit has one qubit and has a single `X` gate.

Using Classiq's SDK, it would look like this:

Expand Down Expand Up @@ -79,14 +77,14 @@ print(result[0].value.parsed_counts)

Let's unravel the code above:

1. `def main` : We define the logic of our quantum program. We'll expand on this point soon below.
2. `create_model` : We convert the logic we defined into a Model.
3. `synthesize` : We synthesize the Model into a Quantum Program. From a logical definition of quantum operations, into a series of quantum gates.
4. `execute` : Executing the quantum program. Can be executed on a physical quantum computer, or on simulations.
1. `def main`: We define the logic of our quantum program. We'll expand on this point soon below.
2. `create_model`: We convert the logic we defined into a Model.
3. `synthesize`: We synthesize the Model into a Quantum Program. From a logical definition of quantum operations into a series of quantum gates.
4. `execute`: Executing the quantum program. It can be executed on a physical quantum computer or on simulations.

## 1) Defining the Logic of Quantum Programs

The function above had 4 lines:
The function above had four lines:

```python
@qfunc
Expand All @@ -95,17 +93,17 @@ def main(res: Output[QBit]):
X(res)
```

The 1st line states that the function will be a quantum one. [Further documentation](https://docs.classiq.io/latest/qmod-reference/language-reference/functions/).
The first line states that the function will be a quantum one. [Further documentation](https://docs.classiq.io/latest/qmod-reference/language-reference/functions/).

The 2nd line defines the type of the output. [Further examples on types](https://docs.classiq.io/latest/qmod-reference/language-reference/classical-types/)
The second line defines the type of the output. [Further examples on types](https://docs.classiq.io/latest/qmod-reference/language-reference/classical-types/).

The 3rd line allocates several qubits (in this example, only 1) in this quantum variable. [Further details on allocate](https://docs.classiq.io/latest/qmod-reference/language-reference/quantum-variables/)
The third line allocates several qubits (in this example, only one) in this quantum variable. [Further details on allocate](https://docs.classiq.io/latest/qmod-reference/language-reference/quantum-variables/).

The 4th line applies an `X` operator on the quantum variable. [Further details on quantum operators](https://docs.classiq.io/latest/qmod-reference/language-reference/operators/)
The fourth line applies an `X` operator on the quantum variable. [Further details on quantum operators](https://docs.classiq.io/latest/qmod-reference/language-reference/operators/).

### More Examples

Initializing $\ket{-}$ state:
Initializing the \(\ket{-}\) state:

```python
@qfunc
Expand All @@ -115,7 +113,7 @@ def prep_minus(out: Output[QBit]) -> None:
H(out)
```

A part of the Deutsch Jozsa algorithm (see the full algorithm [here](/algorithms/deutsch_jozsa/deutsch_jozsa.ipynb))
A part of the Deutsch-Josza algorithm (see the full algorithm [here](/algorithms/deutsch_josza/deutsch_jozsa.ipynb)):

```python
@qfunc
Expand All @@ -125,7 +123,7 @@ def deutsch_jozsa(predicate: QCallable[QNum, QBit], x: QNum) -> None:
hadamard_transform(x)
```

A part of a QML encoder (see the full algorithm [here](/algorithms/qml/quantum_autoencoder/quantum_autoencoder.ipynb))
A part of a QML encoder (see the full algorithm [here](/algorithms/qml/quantum_autoencoder/quantum_autoencoder.ipynb)):

```python
@qfunc
Expand All @@ -143,32 +141,29 @@ For more, see this repository :)

As we saw above, the `main` function can be converted to a model using `model = create_model(main)`.

A model is built out of 2 parts: a `qmod`, and `synthesis options`.
The former is a quantum language used for defining quantum programs, while the latter is a configuration for the execution of the program.
A model is built out of two parts: a `qmod` and `synthesis options`. The former is a quantum language used for defining quantum programs, while the latter is a configuration for the execution of the program.

The model can be saved via `write_qmod(model, "file_name")`, which will save 2 files: `file_name.qmod` and `file_name.synthesis_options.json`.
You may encounter these files in this repository.
The model can be saved via `write_qmod(model, "file_name")`, which will save two files: `file_name.qmod` and `file_name.synthesis_options.json`. You may encounter these files in this repository.

## 3) Synthesis : Models to Quantum Program
## 3) Synthesis: Models to Quantum Program

This is where the magic happens.
Taking a model, which is a set of logical operations, and synthesizing it into physical qubits and the gates entangling them, is not an easy task.
This is where the magic happens. Taking a model, 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.

## 4) Execution

Classiq provides an easy-to-use way to execute quantum programs, and provides various insights of the execution results.
Classiq provides an easy-to-use way to execute quantum programs and offers various insights into the execution results.

## Diagrams

1 diagram is worth a thousand words
One diagram is worth a thousand words.

```mermaid
flowchart
IDEInput[<a href='https://platform.classiq.io/'>Classiq IDE</a>]
SDKInput[<a href='https://docs.classiq.io/latest/sdk-reference/'>Classiq python SDK</a>]
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>]
Expand All @@ -185,7 +180,6 @@ flowchart
Azure[Azure Quantum]
Nvidia[Nvidia]
IDEInput --> Model;
SDKInput --> Model;
Model --> Synthesis;
Expand All @@ -203,9 +197,9 @@ flowchart

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](https://docs.classiq.io/latest/) to learn everything.

## SDK : Classiq's Python Interface
## SDK: Classiq's Python Interface

### Example: 3+5 with Classiq
### Example: 3 + 5 with Classiq

```python
from classiq import (
Expand Down Expand Up @@ -254,17 +248,19 @@ result = execute(quantum_program).result()
print(result[0].value.parsed_counts)
```

## IDE : Classiq's Platform
## IDE: Classiq's Platform

The examples found in this repository can be accessed via [Classiq's platform](https://platform.classiq.io/), in the [`model`](https://platform.classiq.io/dsl-synthesis) 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)
Additionally, one may write their own model in the model editor (highlighted in green) or upload their own model (highlighted in red).

![writing_models.png](README_resources/writing_models.png)

### Example: 3+5 with Classiq
###

Example: 3 + 5 with Classiq

1. Create a model (paste in the [`model`](https://platform.classiq.io/dsl-synthesis) tab)
1. Create a model (paste in the [`model`](https://platform.classiq.io/dsl-synthesis) tab):

```
qfunc get_3(output x: qnum){
Expand Down Expand Up @@ -318,5 +314,4 @@ qfunc main(output res: qnum){

<hr>

Have questions? Feedback? Something to share?
Welcome to join our open [Slack Community](https://short.classiq.io/join-slack)
Have questions? Feedback? Something to share? Welcome to join our open [Slack Community](https://short.classiq.io/join-slack)

0 comments on commit c4f1ba1

Please sign in to comment.