topqad_sdk.clients package
Submodules
topqad_sdk.clients.compiler_client module
- class topqad_sdk.clients.compiler_client.CompilerClient(retries: int = 3, retry_delay: int = 10, polling_interval: int = 10, polling_max_attempts: int = 3)[source]
Bases:
TopQADClient
Client for interacting with the Compiler pipeline endpoint.
This class is responsible for: - Sending circuit data and hardware parameters to the Compiler pipeline - Handling authentication headers using the AuthManager - Processing responses and errors from the Compiler pipeline
- get_result(compiler_pipeline_id: str) CompilerPipelineSolutionResponse [source]
Get results of a compilation pipeline run.
- Parameters:
compiler_pipeline_id – id of the instance, provided in the response object of the pipeline instance submission
- Returns:
- Compiler pipeline response object
containing the results of the steps of the compiler pipeline
- Return type:
CompilerPipelineSolutionResponse
- Raises:
TopQADError – for server errors
- run(circuit: Circuit, error_budget: float, remove_clifford_gates: bool = False, insights_only: bool = False) CompilerPipelineResponse [source]
Run the Compilation Pipeline.
- Parameters:
circuit – The quantum circuit to be processed.
error_budget – Allowed synthesis error to be used
remove_clifford_gates – Flag to determine whether or not to bypass the optimization stage
insights_only – Flag to determine if the output of the scheduler is produced
- Returns:
- Compiler pipeline response object
contains compiler_pipeline_id and status
- Return type:
CompilerPipelineResponse
- Raises:
TopQADValueError – if there are missing or incorrect fields
TopQADError – for server errors
- run_and_get_results(circuit: Circuit, error_budget: float, remove_clifford_gates: bool = True, insights_only: bool = False) CompilerPipelineSolutionResponse [source]
Run the Compilation Pipeline and poll the server for a result.
- Parameters:
circuit – The circuit to be compiled
error_budget – Allowed synthesis error to be used
remove_clifford_gates – Flag to determine whether or not to bypass the optimization stage
insights_only – Flag to determine if the output of the scheduler is produced
- Returns:
- Compiler pipeline response object
containing the results of the steps of the compiler pipeline
- Return type:
CompilerPipelineSolutionResponse
- Raises:
TopQADValueError – if the request has missing or incorrect fields, or if the server response is missing a request id
TopQADError – for server errors
topqad_sdk.clients.noise_profiler_client module
- class topqad_sdk.clients.noise_profiler_client.NoiseProfilerClient(retries: int = 3, retry_delay: int = 10, polling_interval: int = 10, polling_max_attempts: int = 20)[source]
Bases:
TopQADClient
NoiseProfilerClient provides methods for Noise Profiler endpoints.
This class facilitates the submission of circuit data and hardware parameters to the Noise Profiler. It manages authentication headers through the Auth Manager and ensures proper handling of responses and errors returned by the Noise Profiler pipeline.
- polling_interval
Interval in seconds between polling attempts.
- Type:
int
- polling_max_attempts
Maximum number of polling attempts.
- Type:
int
- _logger
A logger instance for logging request and response details.
- Type:
logging.Logger
- Note
Additional attributes are managed by the HTTPClient instance. Refer to its documentation for details.
- get_result(request_id: str) FTQCSolutionResponse [source]
Get results for a specific FTQC solution by ID.
- Parameters:
request_id (str) – The ID of the Noise Profiler solution to retrieve.
- Returns:
The response containing the result of the FTQC emulator job.
- Return type:
- Raises:
TopQADValueError – If request_id is not provided.
TopQADError – If the request to get the result fails.
TopQADSchemaError – If the response is not of type FTQCSolutionResponse.
- list_results() list[FTQCSolutionResponse] [source]
List all Noise Profiler solutions for the authenticated user.
- Returns:
A list of Noise Profiler solutions for the user.
- Return type:
list[FTQCSolutionResponse]
- Raises:
TopQADValueError – If user_id is not provided.
TopQADSchemaError – If the response is not of type
list[FTQCSolutionResponse]. –
TopQADError – If the request to list results fails.
- run(hardware_params: HardwareParameters) FTQCResponse [source]
Run a new Noise Profiler.
- Parameters:
hardware_params (HardwareParameters) – The hardware parameters for the FTQC
emulator.
- Returns:
The response from Noise Profiler containing request ID.
- Return type:
- Raises:
TopQADSchemaError – If hardware_params is not an instance of
HardwareParameters. –
TopQADSchemaError – If the response is not of type FTQCResponse.
TopQADError – If the request to run the Noise Profiler fails.
- run_and_get_result(hardware_params: HardwareParameters) FTQCSolutionResponse [source]
Submit a Noise Profiler job and poll for its result until completion.
Note
Default polling interval is 10 seconds, and maximum attempts is 20. In case of timeout, increase the values of ‘self.polling_interval’ and ‘self.polling_max_attempts’.
- Parameters:
hardware_params (HardwareParameters) – The hardware parameters for
Profiler. (the Noise)
- Returns:
Final result of the Noise Profiler job.
- Return type:
- Raises:
TopQADValueError – If hardware_params is not an instance of
HardwareParameters. –
TopQADRuntimeError – If the job submission or polling fails.
TopQADRuntimeError – If the request to run the Noise Profiler fails.
topqad_sdk.clients.qre_client module
- class topqad_sdk.clients.qre_client.QREClient(retries: int = 3, retry_delay: int = 10, polling_interval: int = 10, polling_max_attempts: int = 20)[source]
Bases:
TopQADClient
QREClient provides methods for QRE pipeline endpoints.
This class facilitates the submission of circuit data and hardware parameters to the QRE pipeline. It manages authentication headers through the Auth Manager and ensures proper handling of responses and errors returned by the QRE pipeline.
- _polling_interval
Interval in seconds between polling attempts.
- Type:
int
- _polling_max_attempts
Maximum number of polling attempts.
- Type:
int
- _logger
A logger instance for logging request and response details.
- Type:
logging.Logger
- Note
Additional attributes are managed by the HTTPClient instance. Refer to its documentation for details.
- get_result(pipeline_id: str) PipelineSolutionResponse [source]
Get results for a specific QRE pipeline solution by ID.
- Parameters:
request_id (str) – The ID of the QRE pipeline solution to retrieve.
- Returns:
- The response containing the result of
the QRE pipeline job.
- Return type:
PipelineSolutionResponse
- Raises:
TopQADValueError – If request_id is not provided.
TopQADError – If the request to get the result fails.
TopQADSchemaError – If the response is not of type PipelineSolutionResponse.
- list_results() list[PipelineSolutionResponse] [source]
List all QRE pipeline solutions for the authenticated user.
- Returns:
A list of QRE pipeline solutions for the user.
- Return type:
list[PipelineSolutionResponse]
- Raises:
TopQADValueError – If user_id is not provided.
TopQADSchemaError – If the response is not of type
list[PipelineSolutionResponse]. –
TopQADError – If the request to list results fails.
- run(circuit: Circuit, hardware_params: HardwareParameters | DemoNoiseProfilerSpecs, global_error_budget: float, timeout: str = '0', number_of_repetitions: int = 1, cost: float = 0, remove_clifford_gates: bool = True, insights_only: bool = False) PipelineResponse [source]
Run a new QRE pipeline.
- Parameters:
circuit (Circuit) – The quantum circuit to be processed.
hardware_params (HardwareParameters | DemoNoiseProfilerSpecs) – Hardware parameters or demo spec.
global_error_budget (float) – The global error budget for the pipeline.
timeout (str, optional) – Timeout for pipeline execution. Defaults to “0”.
number_of_repetitions (int, optional) – Number of repetitions. Defaults to 1.
cost (float, optional) – Cost for the pipeline. Defaults to 0.
remove_clifford_gates (bool, optional) – Whether to remove Clifford gates. Defaults to True.
insights_only (bool, optional) – Whether to generate a schedule only. Defaults to False.
- Returns:
- The response from the QRE pipeline containing
the pipeline ID.
- Return type:
PipelineResponse
- Raises:
TopQADSchemaError – If hardware parameters or circuit are invalid.
TopQADValueError – If circuit or global_error_budget is not provided.
TopQADSchemaError – If the response is not of type PipelineResponse.
TopQADError – If the request to run the QRE pipeline fails.
- run_and_get_result(circuit: Circuit, hardware_params: HardwareParameters | DemoNoiseProfilerSpecs, global_error_budget: float, timeout: str = '0', number_of_repetitions: int = 1, cost: float = 0, remove_clifford_gates: bool = True, insights_only: bool = False) PipelineSolutionResponse [source]
Submit a QRE pipeline job and poll for its result until completion.
- Parameters:
circuit (Circuit) – The quantum circuit to be processed.
hardware_params (HardwareParameters | DemoNoiseProfilerSpecs) – Hardware parameters or demo spec.
global_error_budget (float) – The global error budget for the pipeline.
timeout (str) – The timeout for the pipeline execution. Defaults to “0”.
number_of_repetitions (int) – The number of repetitions for the pipeline. Defaults to 1.
cost (float) – The cost for the pipeline. Defaults to 0.
remove_clifford_gates (bool) – Whether to remove clifford gates. Defaults to True.
insights_only (bool) – Whether to generate a schedule. Defaults to False.
- Returns:
Final result of the QRE pipeline job.
- Return type:
PipelineSolutionResponse
- Raises:
TopQADSchemaError – Invalid hardware parameters or circuit provided.
TopQADValueError – If circuit or global_error_budget is not provided.
TopQADRuntimeError – If the job submission or polling fails.
TopQADRuntimeError – If the request to run the QRE pipeline fails.