TargetLanguage
Enum specifying the output format forexport.
Attributes:
TranspilationConfig
Configuration for transpiling a quantum program to a target basis gate set and qubit connectivity. Pass aTranspilationConfig to the transpilation_config parameter of
export to apply hardware-aware transpilation during export.
Attributes:
FaultTolerantTranspilationConfig
Configuration for fault-tolerant transpilation using Clifford+T gate approximation. Pass aFaultTolerantTranspilationConfig to the transpilation_config
parameter of export to perform fault-tolerant transpilation in two
stages:
- The circuit is first decomposed into the Clifford+T+RZ gate set
(
h,t,s,tdg,cx,rz). - The remaining RZ gates are then approximated using the gridsynth algorithm, which finds an efficient Clifford+T sequence achieving the target rotation within the specified error bound.
QuantumProgram
Methods:
Attributes:
to_base_program
to_base_program(
self:
) -> quantum_code.QuantumBaseCode
Parameters:
to_program
to_program(
self: ,
instruction_set: QuantumInstructionSet | None = None
) -> quantum_code.QuantumCode
Parameters:
save_results
save_results(
self: ,
filename: str | Path | None = None
) -> None
Saves quantum program results as json into a file.
Parameters:
filename (Union[str, Path]): Optional, path + filename of file.
If filename supplied add .json suffix.
Returns:
None
Parameters:
get_debug_info
get_debug_info(
self:
) -> list[FunctionDebugInfoInterface] | None
Parameters:
raise_warnings
raise_warnings(
self:
) -> None
Raises all warnings that were collected during synthesis.
Parameters:
Preferences
Preferences for synthesizing a quantum circuit. Methods:
Attributes:
optimization_timeout_less_than_generation_timeout
optimization_timeout_less_than_generation_timeout(
cls: ,
optimization_timeout_seconds: pydantic.PositiveInt | None,
info: ValidationInfo
) -> pydantic.PositiveInt | None
Parameters:
make_output_format_list
make_output_format_list(
cls: ,
output_format: Any
) -> list
Parameters:
validate_output_format
validate_output_format(
cls: ,
output_format: PydanticConstrainedQuantumFormatList,
info: ValidationInfo
) -> PydanticConstrainedQuantumFormatList
Parameters:
validate_backend_name
validate_backend_name(
cls: ,
backend_name: str | None
) -> str | None
Parameters:
validate_backend
validate_backend(
self:
) -> Self
Parameters:
Constraints
Constraints for the quantum circuit synthesis engine. This class is used to specify constraints such as maximum width, depth, gate count, and optimization parameters for the synthesis engine, guiding the generation of quantum circuits that satisfy these constraints. Attributes:
Functions:
write_qmod
write_qmod(
model: SerializedModel | QFunc | GenerativeQFunc,
name: str,
directory: Path | None = None,
decimal_precision: int = DEFAULT_DECIMAL_PRECISION,
symbolic_only: bool = True
) -> None
Creates a native Qmod file from a serialized model and outputs the synthesis options (Preferences and Constraints) to a file.
The native Qmod file may be uploaded to the Classiq IDE.
Parameters:
Returns:
- Type:
None
Functions
synthesize
synthesize(
model: SerializedModel | BaseQFunc,
auto_show: bool = False,
constraints: Constraints | None = None,
preferences: Preferences | None = None
) -> QuantumProgram
Synthesize a model with the Classiq engine to receive a quantum program.
More details
Parameters:
Returns:
- Type: QuantumProgram
- Quantum program. (See: QuantumProgram)
show
show(
quantum_program: QuantumProgram,
display_url: bool = True
) -> None
Displays the interactive representation of the quantum program in the Classiq IDE.
Parameters:
assign_parameters
assign_parameters(
quantum_program: QuantumProgram,
parameters: ExecutionParams
) -> QuantumProgram
Assign parameters to a parametric quantum program.
Parameters:
Returns:
- Type: QuantumProgram
- The quantum program after assigning parameters.
export
export(
quantum_program: QuantumProgram,
target_language: TargetLanguage | None = TargetLanguage.QASM2,
transpilation_config: TranspilationConfig | FaultTolerantTranspilationConfig | None | Literal[True] = None
) -> str
Export a quantum program as a circuit string in the requested target language.
Non-angle runtime parameters (e.g. integers that affect circuit structure such as
repeat counts) must be assigned first using assign_parameters.
Parameters:
Returns:
- Type:
str - The exported circuit code as a string.
get_circuit_metrics
get_circuit_metrics(
quantum_program: QuantumProgram
) -> CircuitMetrics
Get the logical resource estimation (width, depth and gate counts) of a quantum program.
For parametric programs, depth and gate counts may be returned as symbolic
string expressions (e.g. "n + 1") instead of integers.
Parameters:
Returns:
- Type:
CircuitMetrics - The logical width, depth and gate counts of the quantum program.
get_transpiled_circuit_metrics
get_transpiled_circuit_metrics(
quantum_program: QuantumProgram
) -> CircuitMetrics
Get the hardware resource estimation (width, depth and gate counts) of a transpiled quantum program.
Parameters:
Returns:
- Type:
CircuitMetrics - The width, depth and gate counts of the transpiled program.
set_preferences
set_preferences(
serialized_model: SerializedModel,
preferences: Preferences | None = None,
kwargs: Any =
) -> SerializedModel
Overrides the preferences of a (serialized) model and returns the updated model.
Parameters:
Returns:
- Type:
SerializedModel - The updated model with the new preferences applied.
set_execution_preferences
set_execution_preferences(
serialized_model: SerializedModel,
execution_preferences: ExecutionPreferences | None = None,
kwargs: Any =
) -> SerializedModel
Overrides the execution preferences of a (serialized) model and returns the updated model.
Parameters:
set_constraints
set_constraints(
serialized_model: SerializedModel,
constraints: Constraints | None = None,
kwargs: Any =
) -> SerializedModel
Overrides the constraints of a (serialized) model and returns the updated model.
Parameters:
Returns:
- Type:
SerializedModel - The updated model with the new constraints applied.
create_model
create_model(
entry_point: QFunc | GenerativeQFunc,
constraints: Constraints | None = None,
execution_preferences: ExecutionPreferences | None = None,
preferences: Preferences | None = None,
classical_execution_function: CFunc | None = None,
out_file: str | None = None
) -> SerializedModel
Create a serialized model from a given Qmod entry function and additional parameters.
Parameters:
Returns:
- Type:
SerializedModel - A serialized model.
qasm_to_qmod
qasm_to_qmod(
qasm: str,
qmod_format: QmodFormat
) -> str
Decompiles QASM to Native/Python Qmod.
Returns Qmod code as a string. Native Qmod can be synthesized in the Classiq IDE,
while Python Qmod can be copy-pasted to a Python file (.py) and synthesized by
calling synthesize(main).
Parameters:
Returns:
- Type:
str - The decompiled Qmod program