Skip to content

Update API dev docs #3693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/api/qiskit-c/dev/_toc.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
"title": "QkComplex64",
"url": "/docs/api/qiskit-c/dev/qk-complex-64"
},
{
"title": "QkElidePermutationsResult",
"url": "/docs/api/qiskit-c/dev/qk-elide-permutations-result"
},
{
"title": "QkExitCode",
"url": "/docs/api/qiskit-c/dev/qk-exit-code"
Expand Down
5 changes: 3 additions & 2 deletions docs/api/qiskit-c/dev/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ As this interface is still new in Qiskit it should be considered experimental an

Using the transpiler from the C API is intended to only cover circuits created solely via the C API. If you are in a hybrid mode where you’re using the C API with Python you should invoke the transpiler via the Python [`qiskit.transpiler`](/docs/api/qiskit/dev/transpiler#module-qiskit.transpiler "qiskit.transpiler") module instead; the functionality is the same Rust internals they just offer different entrypoints. The C API for transpilation makes assumptions about the input only using constructs exposed to the C Quantum Circuit API and you will potentially get incomplete results transpiling circuits from Python via the C API.

* [Transpiler Passes](qk-transpiler-passes)
* [QkVF2LayoutResult](qk-vf-2-layout-result)
* [QkTarget](qk-target)
* [QkTargetEntry](qk-target-entry)
* [Transpiler Passes](qk-transpiler-passes)
* [QkVF2LayoutResult](qk-vf-2-layout-result)
* [QkElidePermutationsResult](qk-elide-permutations-result)

102 changes: 102 additions & 0 deletions docs/api/qiskit-c/dev/qk-elide-permutations-result.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
title: QkElidePermutationsResult (dev version)
description: API reference for QkElidePermutationsResult in the dev version of qiskit-c
in_page_toc_min_heading_level: 2
python_api_type: module
python_api_name: QkElidePermutationsResult
---

# QkElidePermutationsResult

```c
typedef struct QkElidePermutationsResult QkElidePermutationsResult
```

When running the `qk_transpiler_pass_standalone_elide_permutations` function it returns a modified circuit and a permutation array as a QkElidePermutationsResult object. This object contains the outcome of the transpiler pass, whether the pass was able to elide any gates or not, and what the results of that elision were.

## Functions

### qk\_elide\_permutations\_result\_elided\_gates

<Function id="qk_elide_permutations_result_elided_gates" signature="bool qk_elide_permutations_result_elided_gates(const QkElidePermutationsResult *result)">
Check whether the elide permutations was able to elide anything

<span id="group__QkElidePermutationsResult_1autotoc_md94" />

#### Safety

<span id="group__QkElidePermutationsResult_1autotoc_md94" />

Behavior is undefined if `result` is not a valid, non-null pointer to a `QkElidePermutationsResult`.

**Parameters**

**result** – a pointer to the result

**Returns**

`true` if the `qk_transpiler_pass_standalone_elide_permutations()` run elided any gates
</Function>

### qk\_elide\_permutations\_result\_circuit

<Function id="qk_elide_permutations_result_circuit" signature="const QkCircuit *qk_elide_permutations_result_circuit(const QkElidePermutationsResult *result)">
Get the circuit from the elide permutations result

<span id="group__QkElidePermutationsResult_1autotoc_md95" />

#### Safety

<span id="group__QkElidePermutationsResult_1autotoc_md95" />

Behavior is undefined if `result` is not a valid, non-null pointer to a `QkElidePermutationsResult`. The pointer to the returned circuit is owned by the result object, it should not be passed to `qk_circuit_free()` as it will be freed by `qk_elide_permutations_result_free()`.

**Parameters**

**result** – a pointer to the result of the pass. It must have elided gates as checked by `qk_elide_permutations_result_elided_gates()`

**Returns**

A pointer to the circuit with the permutation gates elided
</Function>

### qk\_elide\_permutations\_result\_permutation

<Function id="qk_elide_permutations_result_permutation" signature="const uintptr_t *qk_elide_permutations_result_permutation(const QkElidePermutationsResult *result)">
Get the permutation array for the elided gates

<span id="group__QkElidePermutationsResult_1autotoc_md96" />

#### Safety

<span id="group__QkElidePermutationsResult_1autotoc_md96" />

Behavior is undefined if `layout` is not a valid, non-null pointer to a `QkElidePermutationsResult`. Also qubit must be a valid qubit for the circuit and there must be a result found. The pointer to the permutation array is owned by the result object, it should not be passed to `free()` as it will be freed by `qk_elide_permutations_result_free()` when that is called.

**Parameters**

**result** – a pointer to the result of the pass. It must have elided gates as checked by `qk_elide_permutations_result_elided_gates()`

**Returns**

A pointer to the permutation array caused by the swap elision performed by the pass. This array has a length equal to the number of qubits of the circuit returned by `qk_elide_permutations_result_elided_gates()` (or the circuit passed into `qk_transpiler_pass_standalone_elide_permutations()`). The permutation array maps the virtual qubit in the original circuit at each index to its new output position after all the elision performed by the pass. For example, and array of `[2, 1, 0]` means that qubit 0 is now in qubit 2 on the output of the circuit and qubit 2’s is now at 0 (qubit 1 remains unchanged)
</Function>

### qk\_elide\_permutations\_result\_free

<Function id="qk_elide_permutations_result_free" signature="void qk_elide_permutations_result_free(QkElidePermutationsResult *result)">
Free a `QkElidePermutationsResult` object

<span id="group__QkElidePermutationsResult_1autotoc_md97" />

#### Safety

<span id="group__QkElidePermutationsResult_1autotoc_md97" />

Behavior is undefined if `layout` is not a valid, non-null pointer to a `QkElidePermutationsResult`.

**Parameters**

**result** – a pointer to the result object to free
</Function>

38 changes: 17 additions & 21 deletions docs/api/qiskit-c/dev/qk-target-entry.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,19 @@ qk_target_entry_add(entry, NULL, 0, NAN, 0.003);
### qk\_target\_entry\_new

<Function id="qk_target_entry_new" signature="QkTargetEntry *qk_target_entry_new(QkGate operation)">
Creates an entry to the `QkTarget` based on a `QkGate` instance with no parameters.
Creates an entry to the `QkTarget` based on a `QkGate` instance.

<span id="group__QkTargetEntry_1autotoc_md128" />
<span id="group__QkTargetEntry_1autotoc_md136" />

#### Example

```c
QkTargetEntry *entry = qk_target_entry_new(QkGate_H);
```

<Admonition title="Note" type="note">
If the instance of `QkGate` uses fixed parameters, use `qk_target_entry_new_fixed`. Regular parameters are not currently supported.
</Admonition>

**Parameters**

**operation** – The `QkGate` whose properties this target entry defines.
**operation** – The `QkGate` whose properties this target entry defines. If the `QkGate` takes parameters (which can be checked with `qk_gate_num_params`) it will be added as a an instruction on the target which accepts any parameter value. If the gate only accepts a fixed parameter value you can use `qk_target_entry_new_fixed` instead.

**Returns**

Expand All @@ -64,7 +60,7 @@ qk_target_entry_add(entry, NULL, 0, NAN, 0.003);
<Function id="qk_target_entry_new_measure" signature="QkTargetEntry *qk_target_entry_new_measure(void)">
Creates a new entry for adding a measurement instruction to a `QkTarget`.

<span id="group__QkTargetEntry_1autotoc_md129" />
<span id="group__QkTargetEntry_1autotoc_md137" />

#### Example

Expand Down Expand Up @@ -92,7 +88,7 @@ qk_target_entry_add(entry, NULL, 0, NAN, 0.003);
<Function id="qk_target_entry_new_reset" signature="QkTargetEntry *qk_target_entry_new_reset(void)">
Creates a new entry for adding a reset instruction to a `QkTarget`.

<span id="group__QkTargetEntry_1autotoc_md130" />
<span id="group__QkTargetEntry_1autotoc_md138" />

#### Example

Expand Down Expand Up @@ -120,7 +116,7 @@ qk_target_entry_add(entry, NULL, 0, NAN, 0.003);
<Function id="qk_target_entry_new_fixed" signature="QkTargetEntry *qk_target_entry_new_fixed(QkGate operation, double *params)">
Creates an entry to the `QkTarget` based on a `QkGate` instance with no parameters.

<span id="group__QkTargetEntry_1autotoc_md131" />
<span id="group__QkTargetEntry_1autotoc_md139" />

#### Example

Expand All @@ -129,11 +125,11 @@ qk_target_entry_add(entry, NULL, 0, NAN, 0.003);
QkTargetEntry *entry = qk_target_entry_new(QkGate_CRX, crx_params);
```

<span id="group__QkTargetEntry_1autotoc_md132" />
<span id="group__QkTargetEntry_1autotoc_md140" />

#### Safety

<span id="group__QkTargetEntry_1autotoc_md132" />
<span id="group__QkTargetEntry_1autotoc_md140" />

The `params` type is expected to be a pointer to an array of `double` where the length matches the the expectations of the `QkGate`. If the array is insufficently long the behavior of this function is undefined as this will read outside the bounds of the array. It can be a null pointer if there are no params for a given gate. You can check `qk_gate_num_params` to determine how many qubits are required for a given gate.

Expand All @@ -156,7 +152,7 @@ qk_target_entry_add(entry, NULL, 0, NAN, 0.003);
<Function id="qk_target_entry_num_properties" signature="uintptr_t qk_target_entry_num_properties(const QkTargetEntry *entry)">
Retrieves the number of properties stored in the target entry.

<span id="group__QkTargetEntry_1autotoc_md133" />
<span id="group__QkTargetEntry_1autotoc_md141" />

#### Example

Expand All @@ -166,11 +162,11 @@ qk_target_entry_add(entry, NULL, 0, NAN, 0.003);
size_t props_size = qk_target_entry_num_properties(entry);
```

<span id="group__QkTargetEntry_1autotoc_md134" />
<span id="group__QkTargetEntry_1autotoc_md142" />

#### Safety

<span id="group__QkTargetEntry_1autotoc_md134" />
<span id="group__QkTargetEntry_1autotoc_md142" />

The behavior is undefined if `entry` is not a valid, non-null pointer to a `QkTargetEntry` object.

Expand All @@ -188,7 +184,7 @@ qk_target_entry_add(entry, NULL, 0, NAN, 0.003);
<Function id="qk_target_entry_free" signature="void qk_target_entry_free(QkTargetEntry *entry)">
Frees the entry.

<span id="group__QkTargetEntry_1autotoc_md135" />
<span id="group__QkTargetEntry_1autotoc_md143" />

#### Example

Expand All @@ -197,11 +193,11 @@ qk_target_entry_add(entry, NULL, 0, NAN, 0.003);
qk_target_entry_free(entry);
```

<span id="group__QkTargetEntry_1autotoc_md136" />
<span id="group__QkTargetEntry_1autotoc_md144" />

#### Safety

<span id="group__QkTargetEntry_1autotoc_md136" />
<span id="group__QkTargetEntry_1autotoc_md144" />

The behavior is undefined if `entry` is not a valid, non-null pointer to a `QkTargetEntry` object.

Expand All @@ -219,7 +215,7 @@ qk_target_entry_add(entry, NULL, 0, NAN, 0.003);
<Function id="qk_target_entry_add_property" signature="QkExitCode qk_target_entry_add_property(QkTargetEntry *entry, uint32_t *qargs, uint32_t num_qubits, double duration, double error)">
Adds an instruction property instance based on its assigned qargs.

<span id="group__QkTargetEntry_1autotoc_md137" />
<span id="group__QkTargetEntry_1autotoc_md145" />

#### Example

Expand All @@ -229,11 +225,11 @@ qk_target_entry_add(entry, NULL, 0, NAN, 0.003);
qk_target_entry_add_property(entry, qargs, 2, 0.0, 0.1);
```

<span id="group__QkTargetEntry_1autotoc_md138" />
<span id="group__QkTargetEntry_1autotoc_md146" />

#### Safety

<span id="group__QkTargetEntry_1autotoc_md138" />
<span id="group__QkTargetEntry_1autotoc_md146" />

The behavior is undefined if `entry` is not a valid, non-null pointer to a `QkTargetEntry` object.

Expand Down
Loading