Skip to content

ErrorCode ​

ErrorCode is an enumeration representing error codes returned by QPilot OS operations. These codes indicate the type of failure that occurred during quantum job submission, execution, or result retrieval.

Overview ​

Error codes help diagnose issues when interacting with the QPilot OS platform. Each code corresponds to a specific category of failure, from database errors to chip offline conditions.

Enum Values ​

Success ​

ValueDescription
NO_ERROR_FOUNDNo error occurred; the operation completed successfully

Data and Format Errors ​

ValueDescription
DATABASE_ERRORA database operation failed
ORIGINIR_ERRORThe OriginIR program string is invalid or malformed
JSON_FIELD_ERRORA required JSON field is missing or contains an invalid value
ERR_PARAMETERInvalid or missing parameter in the request
ERR_TASK_CONFIGTask configuration is invalid

Backend and Computation Errors ​

ValueDescription
BACKEND_CALC_ERRORThe backend encountered an error during computation
ERR_UNSUPPORT_BACKEND_TYPEThe specified backend type is not supported
ERR_QVM_INIT_FAILEDQuantum virtual machine initialization failed
ERR_QCOMPILER_FAILEDThe quantum compiler encountered an error
CLUSTER_SIMULATE_CALC_ERRCluster simulation computation failed
CLUSTER_BASEBase cluster error

Resource Limit Errors ​

ValueDescription
ERR_TASK_BUF_OVERFLOWTask buffer overflow; too many tasks queued
EXCEED_MAX_QUBITThe program exceeds the maximum number of qubits supported by the chip
EXCEED_MAX_CLOCKThe program exceeds the maximum circuit depth (clock cycles) allowed
ERR_SUB_GRAPH_OUT_OF_RANGEThe subgraph specification is out of the valid range
ERR_TASK_STATUS_BUF_OVERFLOWTask status buffer overflow
ERR_QPROG_LENGTHThe quantum program exceeds the maximum allowed length

Circuit and Compilation Errors ​

ValueDescription
ERR_PRE_ESTIMATEPre-estimation of circuit resources failed
ERR_MATE_GATE_CONFIGMate gate configuration error
ERR_FIDELITY_MATRIXFidelity matrix computation error
ERR_QST_PROGInvalid Quantum State Tomography program
ERR_EMPTY_PROGThe submitted quantum program is empty
ERR_QUBIT_SIZEInvalid qubit size specification
ERR_QUBIT_TOPOQubit topology error
ERR_QUANTUM_CHIP_PROGQuantum chip program error
ERR_REPEAT_MEASURERepeated measurement configuration error
ERR_OPERATOR_DBOperator database error

Task Management Errors ​

ValueDescription
ERR_UNKNOW_TASK_TYPEUnknown or unsupported task type
ERR_NOT_FOUND_APP_IDThe specified application ID was not found
ERR_NOT_FOUND_TASK_IDThe specified task ID was not found
ERR_PARSER_SUB_TASK_RESULTFailed to parse sub-task results
ERR_TASK_TERMINATEDThe task was terminated before completion

Network and Connection Errors ​

ValueDescription
ERR_SYS_CALL_TIME_OUTSystem call timed out
ERR_INVALID_URLThe provided URL is invalid
ERR_BACKEND_CHIP_TASK_SOCKET_WRONGBackend chip task socket error
ERR_TCP_INIT_FATLTTCP initialization failed
ERR_TCP_SERVER_HALTTCP server is halted or unreachable

Chip Availability ​

ValueDescription
ERR_CHIP_OFFLINEThe target quantum chip is currently offline
ERR_SCHEDULE_CHIP_TOPOLOGY_SUPPORTEDThe chip topology is not supported by the scheduler

General ​

ValueDescription
UNDEFINED_ERRORAn undefined or unrecognized error occurred

Examples ​

The following example demonstrates how to check error codes using the ErrorCode enum. ErrorCode members do not directly compare to integers; use the .value attribute for integer comparison.

python
from pyqpanda3.pilot_service.pilot_service import ErrorCode

# Simulate error codes as returned by service.query_result()
test_cases = [
    (0, ""),          # NO_ERROR_FOUND
    (35, "Offline"),  # ERR_CHIP_OFFLINE
    (6, ""),          # EXCEED_MAX_QUBIT
    (31, "Timeout"),  # ERR_TASK_TERMINATED
    (99, "Unknown"),  # Unrecognized error
]

for err_code, err_info in test_cases:
    if err_code == ErrorCode.NO_ERROR_FOUND.value:
        print("Operation succeeded")
    elif err_code == ErrorCode.ERR_CHIP_OFFLINE.value:
        print("The chip is offline; try a different backend")
    elif err_code == ErrorCode.EXCEED_MAX_QUBIT.value:
        print("Program uses too many qubits for this chip")
    elif err_code == ErrorCode.ERR_TASK_TERMINATED.value:
        print("Task was terminated")
    else:
        print(f"Error {err_code}: {err_info}")

Running the code above produces:

Operation succeeded
The chip is offline; try a different backend
Program uses too many qubits for this chip
Task was terminated
Error 99: Unknown

When using QPilotService.query_result(), the returned dict contains the error code as an integer in the errCode key:

python
from pyqpanda3.pilot_service import QPilotService
from pyqpanda3.pilot_service.pilot_service import ErrorCode

# service = QPilotService(url="https://qpilot.originquantum.cn", api_key="key")
# task_id = service.async_run(prog, shot=1000)
# result = service.query_result(task_id)
# err_code = result["errCode"]
# err_info = result.get("errInfo", "")

See Also ​

Released under the MIT License.