diff --git a/.internal/docs/qmod-reference/api-reference/functions/core_library/arithmetic.md b/.internal/docs/qmod-reference/api-reference/functions/core_library/arithmetic.md index 8bf86fec8..e25955448 100644 --- a/.internal/docs/qmod-reference/api-reference/functions/core_library/arithmetic.md +++ b/.internal/docs/qmod-reference/api-reference/functions/core_library/arithmetic.md @@ -13,6 +13,7 @@ search: - multiply - multiply_constant - canonical_add + - canonical_add_constant - canonical_multiply - canonical_multiply_constant diff --git a/.internal/docs/qmod-reference/api-reference/functions/core_library/gray_code.md b/.internal/docs/qmod-reference/api-reference/functions/core_library/gray_code.md new file mode 100644 index 000000000..81b93b504 --- /dev/null +++ b/.internal/docs/qmod-reference/api-reference/functions/core_library/gray_code.md @@ -0,0 +1,14 @@ +--- +search: + boost: 2.9 +--- + + + +::: classiq.qmod.builtins.functions.gray_code + options: + show_if_no_docstrings: false + members: + - select_rotation + + diff --git a/.internal/docs/sdk-reference/providers/C12.md b/.internal/docs/sdk-reference/providers/C12.md new file mode 100644 index 000000000..63efca01e --- /dev/null +++ b/.internal/docs/sdk-reference/providers/C12.md @@ -0,0 +1,7 @@ +--- +search: + boost: 3.060 +--- + +::: classiq.interface.backend.backend_preferences.C12BackendPreferences +::: classiq.interface.backend.quantum_backend_providers.C12BackendNames diff --git a/.internal/docs/user-guide/execution/cloud-providers/c12.md b/.internal/docs/user-guide/execution/cloud-providers/c12.md new file mode 100644 index 000000000..7296b77c9 --- /dev/null +++ b/.internal/docs/user-guide/execution/cloud-providers/c12.md @@ -0,0 +1,76 @@ +--- +search: + boost: 0.900 +--- + + + +# Execution on C12 Quantum Cloud + +[C12](https://www.c12qe.com/) is building scalable carbon-based quantum computers. Classiq supports execution on C12 QPU-emulators. + +## Configuration + +C12 introduces several +customizable hardware parameters (Available through SDK only): + +### inilabel + +The initial state specified using a binary label format, such as "00", "01", etc. + +### inistatevector + +The initial state vector for each qubit, provided as a comma-separated list of complex values. +Example: "1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j" + +Note: Either `inilabel` or `inistatevector` can be provided but not both. + +### ininoisy + +Indicates whether noisy initialization of the circuit should be used. + +## Usage Example + +If you are using [Classiq IDE](https://platform.classiq.io/), simply choose C12 in the checkbox menu under Execution page. + +### Setting up Backend Preferences + +[comment]: DO_NOT_TEST + +```python +from classiq.execution import C12BackendPreferences +from classiq import ExecutionPreferences, ExecutionSession, synthesize + +backend_preferences = C12BackendPreferences( + backend_name="c12sim-iswap", + inilabel="00", # Either inilabel or inistatevector must be provided + # inistatevector="1.+0.j, 0.+0.j,", # Either inilabel or inistatevector must be provided + ininoisy=True, +) + +execution_preferences = ExecutionPreferences( + num_shots=1000, + backend_preferences=backend_preferences, +) +``` + +### Execute with ExecutionSession + +Create your model, set execution preferences, synthesize, then run with `ExecutionSession`: + +[comment]: DO_NOT_TEST + +```python +quantum_program = synthesize(your_model, preferences=preferences) +quantum_program = set_quantum_program_execution_preferences( + quantum_program, execution_preferences +) + +with ExecutionSession(quantum_program) as session: + result = session.sample() +``` + +## Supported Backends + +- SIMULATOR = "c12sim_iswap" +- SQUARED = "squared-iswap" diff --git a/.internal/docs/user-guide/execution/cloud-providers/index.md b/.internal/docs/user-guide/execution/cloud-providers/index.md index 91de6b473..76a0caf67 100644 --- a/.internal/docs/user-guide/execution/cloud-providers/index.md +++ b/.internal/docs/user-guide/execution/cloud-providers/index.md @@ -21,3 +21,4 @@ execution of quantum programs on multiple backends. - [IonQ](ionq-backends.md) - [Azure Quantum](azure-backends.md) - [Alice & Bob](alice-and-bob-backends.md) +- [C12](c12.md) diff --git a/.internal/docs/user-guide/modeling/index.md b/.internal/docs/user-guide/modeling/index.md new file mode 100644 index 000000000..2fc5bfcee --- /dev/null +++ b/.internal/docs/user-guide/modeling/index.md @@ -0,0 +1,7 @@ +# Modeling + +This under construction section is where you can learn the concepts and syntax needed to design quantum models—simply put, to write quantum code using Classiq. + +If you prefer a faster, exercise-oriented path to learning, see the [Classiq Tutorial](../../getting-started/classiq_tutorial/index.md). + +For a complete, formal specification of the language, refer to the [language reference](../../qmod-reference/language-reference). diff --git a/.internal/docs/user-guide/modeling/quantum-numbers-arithmetics.md b/.internal/docs/user-guide/modeling/quantum-numbers-arithmetics.md new file mode 100644 index 000000000..d34f42c4f --- /dev/null +++ b/.internal/docs/user-guide/modeling/quantum-numbers-arithmetics.md @@ -0,0 +1,325 @@ +--- +search: + boost: 2.915 +--- + +# Quantum Numbers and Arithmetics + +## Introduction + +Qmod allows modeling quantum data using typed variables that behave much like variables in classical programming languages: you declare them, allocate them, and then use them in arithmetic and logical expressions over them. In this guide, we focus on quantum numeric variables (for example, integers or fixed-point values represented on qubits) and how to use them in arithmetic expressions, such as addition, comparisons, and bitwise logic, to build useful subroutines for quantum algorithms. + +A key motivation is that these expressions are not simply for “doing math”: they are a practical way to encode conditions over quantum states, which appear throughout quantum algorithms. For instance, many search and optimization-style algorithms require marking the states that satisfy a certain condition, often implemented as a phase oracle. In Qmod, such predicates can be written directly as a arithmetic or boolean expression, such as `x + y == target`. We therefore start with a minimal “a + b” example to build intuition about computation over values in superposition, and then expand toward expressing and combining conditions in a way that scales to real algorithmic use cases. + +In this guide, you will find: + +- An introduction to **quantum numeric variables (`QNum`)** in Qmod and how they represent **integers or fixed-point values** stored on qubits. +- An explanation of how to **declare and allocate quantum numbers**, including the meaning of `QNum[size, is_signed, fraction_digits]` and when its type attributes can be **inferred automatically**. +- A walkthrough showing how **superposition affects arithmetic results**, and how computed outputs (e.g., `z = x + y`) become **correlated/entangled** with the input variables. +- A description of **assignment** (`|=`) as the main way to compute expressions and store results in a target variable. +- A clear distinction between **out-of-place** (`z |= x + y`) and **in-place** updates (`x += y`, `z ^= condition`), including when each is useful. +- Examples of how to specify richer **quantum arithmetic and predicate expressions** using arithmetic, comparison, and bitwise operators to **mark target states** (as used in Grover-like algorithms). + +## Quantum numeric variables + +In Qmod, once a quantum variable is allocated, it references a quantum object stored on one or more qubits. Quantum variables are declared with a _quantum type_ that defines characteristics such as how many qubits are used and how the state is interpreted. In the case of a quantum number (`QNum`), the state is interpreted as an integer or a fixed-point real number. + +When expressing algorithm logic, it is often useful to treat a quantum object as a number and write code that resembles classical numeric programming. However, the values stored in quantum variables may present quantum effects, such as entanglement and superposition. Before diving into how to use quantum numbers, consider the following quantum program: + +```python +from classiq import * + + +@qfunc +def prepare_superposition(q: QArray[QBit]): + H(q[1]) + + +@qfunc +def main( + x: Output[QNum[3, UNSIGNED, 0]], y: Output[QNum[3, UNSIGNED, 0]], z: Output[QNum] +): + allocate(x) + allocate(y) + prepare_superposition(x) + prepare_superposition(y) + z |= x + y +``` + +At a high level, this quantum program: + +1. Allocate two different quantum numbers, `x` and `y`. +2. Prepare the following superposition states by applying a Hadamard gate on different qubits using `prepare_superposition`: + +$$\vert x \rangle = \frac{1}{\sqrt{2}}\left(\vert 0 \rangle + \vert 2 \rangle\right), \quad \vert y \rangle = \frac{1}{\sqrt{2}}\left(\vert 0 \rangle + \vert 2 \rangle\right).$$ + +3. Evaluate the arithmetic operation `x + y` and assign its result to the variable `z`. + +A representative sample output may look like this (each outcome should be measured at a ~25% probability): + +| x | y | z | counts | probability | bitstring | +| --- | --- | --- | ------ | ----------- | ---------- | +| 0 | 0 | 0 | 519 | 0.253417 | 0000000000 | +| 2 | 2 | 4 | 497 | 0.242675 | 0100010010 | +| 2 | 0 | 2 | 508 | 0.248046 | 0010000010 | +| 0 | 2 | 2 | 524 | 0.255859 | 0010010000 | + +Since variables `x` and `y` are in superposition, the value of `z` will vary according to the values measured in `x` and `y`. Consequently, `z` is entangled with `x` and `y`. + +### Declaring quantum numbers + +Now, let’s dive into the declaration of the quantum numbers `x` and `y`. In the example above, they are declared using the type hint `Output[QNum[3, UNSIGNED, 0]]`. A type hint is an annotation next to a variable that specifies what kind of value it represents. + +Here, `QNum` indicates that `x` and `y` represent numbers, and their type attributes specifies their numeric attributes: + +- 3: the total number of qubits used to store the number (size) + +- `UNSIGNED`: the number has no sign (i.e., non-negative). This field is optional, and set to `UNSIGNED` by default. + +- 0: the number has no fraction digits. This means the number is interpreted as an integer. If $\text{fraction_digits} > 0$, the value is interpreted as a fixed-point number, scaled by $2^{-\text{fraction_digits}}$. This field is optional, and set to 0 by default. + +This matches the definition of a quantum number type in Qmod as: + +