> ## Documentation Index
> Fetch the complete documentation index at: https://docs.classiq.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Cudaq

\<!-- cspell:ignore cudaq -->

Classiq to [CUDA-Q](https://developer.nvidia.com/cuda-q) translation.
These functions require the `cudaq` extra (install `classiq[cudaq]`).
Note that the `cudaq` extra is only available in Classiq Studio and on any Linux
Machine.

## Functions

### qprog\_to\_cudaq\_kernel

<pre>`qprog_to_cudaq_kernel(
quantum_program: QuantumProgram,
is_main_kernel: bool = True
) -> cudaq.PyKernel | tuple`</pre>

Translates a quantum program into a CUDA-Q kernel.

The 'is\_main\_kernel' parameter controls the kind of the returned kernel.
If 'is\_main\_kernel' is True, the returned kernel can be used with CUDA-Q functions
such as 'cudaq.draw()' and 'cudaq.get\_state()', but it cannot be added to another
kernel via 'apply\_call()'.
If 'is\_main\_kernel' is False, the reverse holds: The returned kernel cannot be used
with CUDA-Q functions but can be added to another kernel.

**Parameters:**

| Name | Type | Description | Default |
| - | - | - | - |
| `quantum_program` | `QuantumProgram` | The quantum program to translate into CUDA-Q kernel. This is the result of the function 'synthesize()'. | *required* |
| `is_main_kernel` | `bool` | Whether the kernel is compatible with CUDA-Q functions (`is_main_kernel=True`, the default behavior) or 'apply\_call()' (`is_main_kernel=False`). | True |

**Returns:**

* **Type:** `cudaq.PyKernel \| tuple`
* A CUDA-Q kernel. If the quantum program includes foreach statements, a tuple
* containing a CUDA-Q kernel and its foreach arguments will be returned.

### pauli\_operator\_to\_cudaq\_spin\_op

<pre>`pauli_operator_to_cudaq_spin_op(
operator: SparsePauliOp
) -> cudaq.SpinOperator`</pre>

Transforms Qmod's SparsePauliOp data structure to CUDA-Q's SpinOperator.

**Parameters:**

| Name | Type | Description | Default |
| - | - | - | - |
| `operator` | `SparsePauliOp` | The operator to be transformed | *required* |

**Returns:**

* **Type:** `cudaq.SpinOperator`
* The equivalent operator in CUDA-Q's data structure

### parse\_cudaq\_result

<pre>`parse_cudaq_result(
qprog: QuantumProgram,
counts: Mapping[str, int]
) -> pd.DataFrame`</pre>

Parse a CUDA-Q sampling histogram into typed Qmod output registers.

**Parameters:**

| Name | Type | Description | Default |
| - | - | - | - |
| `qprog` | `QuantumProgram` | The synthesized `QuantumProgram` -- the same object passed to `qprog_to_cudaq_kernel`. | *required* |
| `counts` | `Mapping[str, int]` | The result of `cudaq.sample(...)` (a `cudaq.SampleResult`) or any mapping of bitstring to shot count. | *required* |

**Returns:**

* **Type:** `pd.DataFrame`
* A `pandas.DataFrame` identical to the one returned by
* `classiq.sample`: one column per `main` output plus `counts`,
* `probability` and `bitstring`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.