Exporters¶
Exporters convert EncodedResult objects into framework-specific circuit objects.
All exporters expose:
export(encoded)— single sampleexport_batch(encoded_list)— full batch
QASMExporter¶
No dependencies. Universal OpenQASM 3.0 output.
quprep.export.qasm_export.QASMExporter(version='3.0')
¶
Export EncodedResult objects to OpenQASM 3.0.
No additional dependencies required.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
version
|
str
|
QASM version. Currently only '3.0' is supported. |
'3.0'
|
Source code in quprep/export/qasm_export.py
Functions¶
export(encoded)
¶
Convert an EncodedResult to an OpenQASM 3.0 string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded
|
EncodedResult
|
Output from any QuPrep encoder (except amplitude). |
required |
Returns:
| Type | Description |
|---|---|
str
|
OpenQASM 3.0 circuit string, compatible with Qiskit, Cirq, and hardware backends. |
Source code in quprep/export/qasm_export.py
export_batch(encoded_list)
¶
Export a list of EncodedResults to QASM strings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_list
|
list of EncodedResult
|
|
required |
Returns:
| Type | Description |
|---|---|
list of str
|
One OpenQASM 3.0 string per sample. |
Source code in quprep/export/qasm_export.py
save(encoded, path)
¶
Export an EncodedResult and write the QASM string to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded
|
EncodedResult
|
Output from any QuPrep encoder. |
required |
path
|
str or Path
|
Destination file path (e.g. |
required |
Source code in quprep/export/qasm_export.py
save_batch(encoded_list, directory, stem='circuit')
¶
Export a batch of EncodedResults to individual QASM files.
Files are named {stem}_0000.qasm, {stem}_0001.qasm, etc.
The output directory is created automatically if it does not exist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_list
|
list of EncodedResult
|
Outputs from any QuPrep encoder. |
required |
directory
|
str or Path
|
Output directory. |
required |
stem
|
str
|
Filename stem (default: |
'circuit'
|
Returns:
| Type | Description |
|---|---|
list of Path
|
Paths of the written files, in sample order. |
Source code in quprep/export/qasm_export.py
QiskitExporter¶
Requires pip install quprep[qiskit].
quprep.export.qiskit_export.QiskitExporter(backend=None)
¶
Export EncodedResult objects to Qiskit QuantumCircuit.
Requires: pip install quprep[qiskit]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
str
|
IBM backend name (e.g. 'ibm_brisbane'). Reserved for transpilation hints in a future release — currently stored but not applied. |
None
|
Source code in quprep/export/qiskit_export.py
Functions¶
export(encoded)
¶
Convert an EncodedResult to a Qiskit QuantumCircuit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded
|
EncodedResult
|
Output from any QuPrep encoder. |
required |
Returns:
| Type | Description |
|---|---|
QuantumCircuit
|
Ready-to-transpile Qiskit circuit. |
Source code in quprep/export/qiskit_export.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
export_batch(encoded_list)
¶
Export a list of EncodedResults to Qiskit QuantumCircuits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_list
|
list of EncodedResult
|
|
required |
Returns:
| Type | Description |
|---|---|
list of qiskit.QuantumCircuit
|
One circuit per sample. |
Source code in quprep/export/qiskit_export.py
PennyLaneExporter¶
Requires pip install quprep[pennylane].
quprep.export.pennylane_export.PennyLaneExporter(interface='auto', device='default.qubit')
¶
Export EncodedResult objects to PennyLane QNode circuits.
Returns a callable qml.QNode from :meth:export. Calling the returned
QNode executes the circuit on the configured device and returns the
quantum state.
Requires: pip install quprep[pennylane]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
interface
|
str
|
Autodiff interface: |
'auto'
|
device
|
str
|
PennyLane device string. Default |
'default.qubit'
|
Source code in quprep/export/pennylane_export.py
Functions¶
export(encoded)
¶
Return a PennyLane QNode for an EncodedResult.
The returned QNode is immediately callable — invoke it with no arguments to execute the circuit and obtain the quantum state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded
|
EncodedResult
|
Output from any QuPrep encoder. Supports all 12 encodings:
|
required |
Returns:
| Type | Description |
|---|---|
QNode
|
Callable quantum circuit. Invoke with no arguments to execute and obtain the quantum state vector. |
Source code in quprep/export/pennylane_export.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
export_batch(encoded_list)
¶
Export a list of EncodedResults to PennyLane QNodes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_list
|
list of EncodedResult
|
|
required |
Returns:
| Type | Description |
|---|---|
list of qml.QNode
|
One callable QNode per sample. |
Source code in quprep/export/pennylane_export.py
CirqExporter¶
Requires pip install quprep[cirq].
quprep.export.cirq_export.CirqExporter()
¶
Export EncodedResult objects to Cirq Circuit.
Requires: pip install quprep[cirq]
Functions¶
export(encoded)
¶
Convert an EncodedResult to a Cirq Circuit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded
|
EncodedResult
|
Output from any QuPrep encoder. |
required |
Returns:
| Type | Description |
|---|---|
Circuit
|
Circuit using |
Source code in quprep/export/cirq_export.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
export_batch(encoded_list)
¶
Export a list of EncodedResults to Cirq Circuits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_list
|
list of EncodedResult
|
|
required |
Returns:
| Type | Description |
|---|---|
list of cirq.Circuit
|
One circuit per sample. |
Source code in quprep/export/cirq_export.py
TKETExporter¶
Requires pip install quprep[tket].
quprep.export.tket_export.TKETExporter()
¶
Export EncodedResult objects to TKET/pytket Circuit.
pytket rotation gates use half-turns (\(\text{angle} / \pi\)). This exporter converts all radian angles from QuPrep encoders to the pytket convention automatically.
Requires: pip install quprep[tket]
Functions¶
export(encoded)
¶
Convert an EncodedResult to a pytket Circuit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded
|
EncodedResult
|
Output from any QuPrep encoder. |
required |
Returns:
| Type | Description |
|---|---|
Circuit
|
Circuit with angles converted to pytket half-turns. |
Source code in quprep/export/tket_export.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
export_batch(encoded_list)
¶
Export a list of EncodedResults to pytket Circuits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_list
|
list of EncodedResult
|
|
required |
Returns:
| Type | Description |
|---|---|
list of pytket.Circuit
|
One circuit per sample. |
Source code in quprep/export/tket_export.py
BraketExporter¶
Requires pip install quprep[braket].
quprep.export.braket_export.BraketExporter()
¶
Export EncodedResult objects to Amazon Braket Circuit objects.
Requires: pip install quprep[braket]
Functions¶
export(encoded)
¶
Convert an EncodedResult to a Braket Circuit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded
|
EncodedResult
|
Output from any QuPrep encoder (except amplitude). |
required |
Returns:
| Type | Description |
|---|---|
Circuit
|
|
Source code in quprep/export/braket_export.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
export_batch(encoded_list)
¶
Export a list of EncodedResults to Braket Circuits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_list
|
list of EncodedResult
|
|
required |
Returns:
| Type | Description |
|---|---|
list of braket.circuits.Circuit
|
|
Source code in quprep/export/braket_export.py
QSharpExporter¶
No dependencies for string generation. Requires pip install quprep[qsharp] for Azure Quantum submission.
quprep.export.qsharp_export.QSharpExporter(namespace='QuPrepCircuit', operation_name='Encode')
¶
Export EncodedResult objects to Q# 1.0 program strings.
No additional dependencies required to generate Q# source.
To run locally install the qsharp Python package:
pip install quprep[qsharp]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
str
|
Q# namespace for the generated operation. Default |
'QuPrepCircuit'
|
operation_name
|
str
|
Name of the generated Q# operation. Default |
'Encode'
|
Source code in quprep/export/qsharp_export.py
Functions¶
export(encoded)
¶
Convert an EncodedResult to a Q# program string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded
|
EncodedResult
|
Output from any QuPrep encoder (except amplitude). |
required |
Returns:
| Type | Description |
|---|---|
str
|
Complete Q# 1.0 source file contents. |
Source code in quprep/export/qsharp_export.py
export_batch(encoded_list)
¶
Export a list of EncodedResults to Q# program strings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_list
|
list of EncodedResult
|
|
required |
Returns:
| Type | Description |
|---|---|
list of str
|
|
Source code in quprep/export/qsharp_export.py
IQMExporter¶
No dependencies for dict generation. Requires pip install quprep[iqm] for hardware submission.
quprep.export.iqm_export.IQMExporter(circuit_name='quprep_circuit', qubit_prefix='QB')
¶
Export EncodedResult objects to IQM native circuit format (dict).
Returns a Python dict matching the IQM circuit JSON schema.
No SDK dependencies required — install quprep[iqm] only when
you need to submit directly to IQM hardware via iqm-client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
circuit_name
|
str
|
Name field in the output circuit dict. Default |
'quprep_circuit'
|
qubit_prefix
|
str
|
Prefix for qubit labels. Default |
'QB'
|
Source code in quprep/export/iqm_export.py
Functions¶
export(encoded)
¶
Convert an EncodedResult to an IQM circuit dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded
|
EncodedResult
|
Output from any QuPrep encoder (except amplitude). |
required |
Returns:
| Type | Description |
|---|---|
dict
|
IQM circuit in JSON-serialisable dict form. |
Source code in quprep/export/iqm_export.py
export_batch(encoded_list)
¶
Export a list of EncodedResults to IQM circuit dicts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_list
|
list of EncodedResult
|
|
required |
Returns:
| Type | Description |
|---|---|
list of dict
|
|
Source code in quprep/export/iqm_export.py
Plugin registry¶
Register custom encoders and exporters for use with prepare().
quprep.plugins.register_encoder(name)
¶
Register a custom encoder class under name.
Can be used as a class decorator or called directly:
.. code-block:: python
@register_encoder("my_enc")
class MyEncoder(BaseEncoder): ...
# or:
register_encoder("my_enc")(MyEncoder)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Encoding name used in :func: |
required |
Returns:
| Type | Description |
|---|---|
Callable
|
A decorator that registers and returns the class unchanged. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in quprep/plugins.py
quprep.plugins.register_exporter(name)
¶
Register a custom exporter class under name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Framework name used in :func: |
required |
Returns:
| Type | Description |
|---|---|
Callable
|
A decorator that registers and returns the class unchanged. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in quprep/plugins.py
quprep.plugins.list_encoders()
¶
quprep.plugins.list_exporters()
¶
quprep.plugins.get_encoder_class(name)
¶
quprep.plugins.get_exporter_class(name)
¶
quprep.plugins.unregister_encoder(name)
¶
quprep.plugins.unregister_exporter(name)
¶
Visualization¶
No dependencies for draw_ascii. Requires pip install quprep[viz] for draw_matplotlib.
quprep.export.visualize.draw_ascii(encoded, width=80)
¶
Return an ASCII circuit diagram for an EncodedResult.
No additional dependencies required.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded
|
EncodedResult
|
|
required |
width
|
int
|
Reserved for future use (target line width hint). Default 80. |
80
|
Returns:
| Type | Description |
|---|---|
str
|
Multi-line ASCII string. Print with |
Source code in quprep/export/visualize.py
quprep.export.visualize.draw_matplotlib(encoded, filename=None)
¶
Draw a matplotlib circuit diagram.
Requires: pip install quprep[viz]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded
|
EncodedResult
|
|
required |
filename
|
str or Path
|
Save to file if provided (PNG, PDF, SVG). Returns None. If None, returns the matplotlib Figure object. |
None
|
Returns:
| Type | Description |
|---|---|
Figure or None
|
Figure object if filename is None; None after saving to file. |
Source code in quprep/export/visualize.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | |