pyqpanda

QPanda Python

Copyright (C) Origin Quantum 2017-2018

Licensed Under Apache Licence 2.0

Submodules

Classes

AbstractOptimizer

quantum AbstractOptimizer class

AdaGradOptimizer

variational quantum AdaGradOptimizer

AdamOptimizer

variational quantum AdamOptimizer

Ansatz

quantum ansatz class

AnsatzGate

ansatz gate struct

AnsatzGateType

Quantum ansatz gate type

BackendType

Quantum machine backend type

CBit

quantum classical bit

CPUQVM

quantum machine cpu

CPUSingleThreadQVM

quantum machine class for cpu single thread

ChipID

origin quantum real chip type

ClassicalCondition

Classical condition class Proxy class of cexpr class

ClassicalProg

quantum ClassicalProg

CommProtocolConfig

ComplexVertexSplitMethod

quantum complex vertex split method

DAGNodeType

Quantum dag node type

DecompositionMode

Quantum matrix decomposition mode

DensityMatrixSimulator

simulator for density matrix

DoubleGateTransferType

Quantum double gate transfer type

Encode

quantum amplitude encode

ErrorCode

pliot error code

Fusion

quantum fusion operation

GateType

quantum gate type

HHLAlg

quantum hhl algorithm class

LATEX_GATE_TYPE

Quantum latex gate type

LatexMatrix

Generate quantum circuits latex src code can be compiled on latex package 'qcircuit'

MPSQVM

quantum matrix product state machine class

MomentumOptimizer

variational quantum MomentumOptimizer

NodeInfo

Detailed information of a QProg node

NodeIter

quantum node iter

NodeType

quantum node type

Noise

Quantum machine for noise simulation

NoiseModel

noise model type

NoiseQVM

quantum machine class for simulate noise prog

Optimizer

variational quantum Optimizer class

OptimizerFactory

quantum OptimizerFactory class

OptimizerMode

variational quantum OptimizerMode

OptimizerType

quantum OptimizerType

OriginCMem

origin quantum cmem

OriginCollection

A relatively free data collection class for saving data

OriginQubitPool

quantum qubit pool

PartialAmpQVM

quantum partial amplitude machine class

PhysicalQubit

Physical Qubit abstract class

PilotNoiseParams

pliot noise simulate params

ProgCount

QCircuit

quantum circuit node

QCircuitOPtimizerMode

Quantum circuit optimize mode

QError

Quantum QError Type

QGate

quantum gate node

QITE

quantum imaginary time evolution

QIfProg

quantum if prog node

QMachineType

Quantum machine type

QMeasure

quantum measure node

QOperator

quantum operator class

QOptimizationResult

quantum QOptimizationResult class

QPilotOSService

origin quantum pilot OS Machine

QProg

Quantum program,can construct quantum circuit,data struct is linked list

QProgDAG

quantum prog dag class

QProgDAGEdge

quantum prog dag edge

QProgDAGVertex

quantum prog dag vertex node

QReset

quantum reset node

QResult

QResult abstract class, this class contains the result of the quantum measurement

QVec

Qubit vector basic class

QWhileProg

quantum while node

QuantumMachine

quantum machine base class

QuantumStateTomography

quantum state tomography class

Qubit

Qubit abstract class

RMSPropOptimizer

variational quantum RMSPropOptimizer

SingleAmpQVM

quantum single amplitude machine class

SingleGateTransferType

Quantum single gate transfer type

SparseQVM

quantum sparse machine class

Stabilizer

simulator for basic clifford simulator

UpdateMode

quantum imaginary time evolution update mode

VanillaGradientDescentOptimizer

variational quantum VanillaGradientDescentOptimizer

VariationalQuantumCircuit

variational quantum CIRCUIT class

VariationalQuantumGate

variational quantum gate base class

VariationalQuantumGate_CNOT

variational quantum CNOT gate class

VariationalQuantumGate_CR

variational quantum CR gate class

VariationalQuantumGate_CRX

variational quantum CRX gate class

VariationalQuantumGate_CRY

variational quantum CRY gate class

VariationalQuantumGate_CRZ

variational quantum CRZ gate class

VariationalQuantumGate_CU

variational quantum CU gate class

VariationalQuantumGate_CZ

variational quantum CZ gate class

VariationalQuantumGate_H

variational quantum H gate class

VariationalQuantumGate_I

variational quantum I gate class

VariationalQuantumGate_RX

variational quantum RX gate class

VariationalQuantumGate_RY

variational quantum RY gate class

VariationalQuantumGate_RZ

variational quantum RZ gate class

VariationalQuantumGate_S

variational quantum S gate class

VariationalQuantumGate_SWAP

variational quantum SWAP gate class

VariationalQuantumGate_SqiSWAP

variational quantum SqiSWAP gate class

VariationalQuantumGate_T

variational quantum T gate class

VariationalQuantumGate_U1

variational quantum U1 gate class

VariationalQuantumGate_U2

variational quantum U2 gate class

VariationalQuantumGate_U3

variational quantum U3 gate class

VariationalQuantumGate_U4

variational quantum U4 gate class

VariationalQuantumGate_X

variational quantum X gate class

VariationalQuantumGate_X1

variational quantum X1 gate class

VariationalQuantumGate_Y

variational quantum Y gate class

VariationalQuantumGate_Y1

variational quantum Y1 gate class

VariationalQuantumGate_Z

variational quantum Z gate class

VariationalQuantumGate_Z1

variational quantum Z1 gate class

VariationalQuantumGate_iSWAP

variational quantum iSWAP gate class

em_method

origin quantum real chip error_mitigation type

expression

variational quantum expression class

hadamard_circuit

hadamard circuit class

real_chip_type

origin quantum real chip type enum

var

quantum variational class

QPilotOSMachine

This class can submit Quantum Program to PilotOS.

Functions

BARRIER(…)

Create a BARRIER gate for a list of qubit addresses.

CNOT(…)

Returns:

CP(…)

Returns:

CR(…)

Returns:

CU(…)

Create a CU gate.

CZ(…)

Returns:

CreateEmptyCircuit(→ QCircuit)

Create an empty QCircuit container.

CreateEmptyQProg(→ QProg)

Create an empty QProg container.

CreateIfProg(…)

Create an IfProg that executes one of two quantum operations based on a classical condition.

CreateWhileProg(→ QWhileProg)

Create a WhileProg that executes while a classical condition is true.

Grover(→ Any)

Quantum grover circuit

Grover_search(…)

use Grover algorithm to search target data, return QProg and search_result

H(…)

Create a H gate

HHL_solve_linear_equations(→ List[complex])

Use HHL algorithm to solve the target linear systems of equations : Ax = b

I(…)

Create a I gate

MAJ(→ QCircuit)

Quantum adder MAJ module

MAJ2(→ QCircuit)

Quantum adder MAJ2 module

MS(…)

Returns:

Measure(…)

Create a measure node.

OBMT_mapping(…)

OPT_BMT mapping

P(…)

Create a P gate

PMeasure(→ List[Tuple[int, float]])

Deprecated, use pmeasure instead.

PMeasure_no_index(→ List[float])

Deprecated, use pmeasure_no_index instead.

QAdd(→ QCircuit)

Quantum adder that supports signed operations, but ignore carry

QAdder(→ QCircuit)

Quantum adder with carry

QAdderIgnoreCarry(→ QCircuit)

Args:

QComplement(→ QCircuit)

Convert quantum state to binary complement representation

QDiv(→ QProg)

Quantum division

QDivWithAccuracy(→ QProg)

Args:

QDivider(→ QProg)

Quantum division, only supports positive division, and the highest position of a and b and c is sign bit

QDividerWithAccuracy(→ QProg)

Args:

QDouble(…)

Returns:

QFT(→ QCircuit)

Build QFT quantum circuit

QMul(→ QCircuit)

Quantum multiplication

QMultiplier(→ QCircuit)

Quantum multiplication, only supports positive multiplication

QOracle(→ QGate)

Generate QOracle Gate.

QPE(→ QCircuit)

Quantum phase estimation

QSub(→ QCircuit)

Quantum subtraction

RX(…)

Create a RX gate

RXX(…)

Create a RXX gate

RY(…)

Create a RY gate

RYY(…)

Create a RYY gate

RZ(…)

Create a RZ gate

RZX(…)

Create a RZX gate

RZZ(…)

Create a RZZ gate

Reset(…)

Create a Reset node.

S(…)

Create a S gate

SWAP(…)

Returns:

Shor_factorization(→ Tuple[bool, Tuple[int, int]])

Use Shor factorize integer num

SqiSWAP(…)

Returns:

T(…)

Create a T gate

Toffoli(…)

Create a Toffoli gate.

U1(…)

Create a U1 gate

U2(…)

Create a U2 gate

U3(…)

Create a U3 gate

U4(…)

Create a U4 gate.

UMA(→ QCircuit)

Quantum adder UMA module

VQG_CNOT_batch(→ Any)

variational quantum CNOT batch gates

VQG_CU_batch(→ Any)

variational quantum CU batch gates

VQG_CZ_batch(→ Any)

variational quantum CZ batch gates

VQG_H_batch(→ Any)

variational quantum H batch gates

VQG_I_batch(→ Any)

variational quantum I batch gates

VQG_SWAP_batch(→ Any)

variational quantum SWAP batch gates

VQG_S_batch(→ Any)

variational quantum S batch gates

VQG_SqiSWAP_batch(→ Any)

variational quantum SqiSWAP batch gates

VQG_T_batch(→ Any)

variational quantum T batch gates

VQG_U1_batch(→ Any)

variational quantum U1 batch gates

VQG_U2_batch(→ Any)

variational quantum U2 batch gates

VQG_U3_batch(→ Any)

variational quantum U3 batch gates

VQG_U4_batch(→ Any)

variational quantum U4 batch gates

VQG_X1_batch(→ Any)

variational quantum X1 batch gates

VQG_X_batch(→ Any)

variational quantum X batch gates

VQG_Y1_batch(→ Any)

variational quantum Y1 batch gates

VQG_Y_batch(→ Any)

variational quantum Y batch gates

VQG_Z1_batch(→ Any)

variational quantum Z1 batch gates

VQG_Z_batch(→ Any)

variational quantum Z batch gates

VQG_iSWAP_batch(→ Any)

variational quantum iSWAP batch gates

X(…)

Create a X gate

X1(…)

Create a X1 gate

Y(…)

Create a Y gate

Y1(…)

Create a Y1 gate

Z(…)

Create a Z gate

Z1(…)

Create a Z1 gate

accumulateProbability(→ List[float])

Accumulate the probability from a probability list.

accumulate_probabilities(→ List[float])

Accumulate the probability from a probability list.

accumulate_probability(→ List[float])

Accumulate the probability from a probability list.

acos(→ var)

add(…)

Add a bit size and a ClassicalCondition.

all_cut_of_graph(→ float)

Generate a graph representation for the max cut problem.

amplitude_encode(…)

Encode the input double data to the amplitude of qubits

apply_QGate(…)

Apply a quantum gate operation to a list of qubit addresses.

asin(→ var)

assign(…)

Assign a bit size value to a ClassicalCondition.

atan(→ var)

average_gate_fidelity(…)

Calculate the average gate fidelity between two quantum operation matrices.

bin_to_prog(→ bool)

Parse binary data to transform into a quantum program.

bind_data(→ QCircuit)

Args:

bind_nonnegative_data(→ QCircuit)

Args:

build_HHL_circuit(→ QCircuit)

build the quantum circuit for HHL algorithm to solve the target linear systems of equations : Ax = b

cAlloc(…)

Allocate a CBit

cAlloc_many(→ List[ClassicalCondition])

Allocate several CBits

cFree(→ None)

Free a CBit

cFree_all(…)

Free all CBits

cast_qprog_qcircuit(→ QCircuit)

Cast a quantum program into a quantum circuit.

cast_qprog_qgate(→ QGate)

Cast a quantum program into a quantum gate.

cast_qprog_qmeasure(→ QMeasure)

Cast a quantum program into a quantum measurement.

circuit_layer(→ list)

Quantum circuit layering.

circuit_optimizer(→ QProg)

Optimize a quantum circuit.

circuit_optimizer_by_config(→ QProg)

Optimize a quantum circuit using configuration data.

comm_protocol_decode(→ Tuple[List[QProg], ...)

Decode binary data into a list of quantum programs using the communication protocol.

comm_protocol_encode(…)

Encode a list of quantum programs into binary communication protocol data.

constModAdd(→ QCircuit)

Args:

constModExp(→ QCircuit)

Args:

constModMul(→ QCircuit)

Args:

convert_binary_data_to_qprog(→ QProg)

Parse binary data into a quantum program.

convert_originir_str_to_qprog(→ list)

Transform OriginIR string into QProg.

convert_originir_to_qprog(→ list)

Read an OriginIR file and transform it into QProg.

convert_qasm_string_to_qprog(→ list)

Transform QASM string into QProg.

convert_qasm_to_qprog(→ list)

Read a QASM file and transform it into QProg.

convert_qprog_to_binary(…)

Store the quantum program in a binary file.

convert_qprog_to_originir(→ Any)

Convert QProg to OriginIR string.

convert_qprog_to_qasm(→ str)

Convert a quantum program to a QASM instruction string.

convert_qprog_to_quil(→ str)

Convert QProg to Quil instruction.

cos(→ var)

count_gate(…)

Count quantum gate number in the quantum circuit.

count_prog_info(…)

Count quantum program information.

count_qgate_num(…)

Count quantum gate number in the quantum circuit.

create_empty_circuit(→ QCircuit)

Create an empty QCircuit container.

create_empty_qprog(→ QProg)

Create an empty QProg container.

create_if_prog(…)

Create a classical quantum IfProg.

create_while_prog(→ QWhileProg)

Create a WhileProg.

crossEntropy(→ var)

decompose_multiple_control_qgate(…)

Decompose multiple control QGate.

deep_copy(…)

Create a deep copy of the given quantum program node.

del_weak_edge(→ None)

Delete weakly connected edges from the quantum program topology.

del_weak_edge2(→ list)

Delete weakly connected edges from the quantum program topology.

del_weak_edge3(→ list)

Delete weakly connected edges based on specified parameters.

destroy_quantum_machine(→ None)

Destroy a quantum machine.

directly_run() → Dict[str, bool])

Directly run a quantum program

div(…)

Divide a bit size by a ClassicalCondition.

dot(→ var)

draw_qprog_latex(, itr_end)

Convert a quantum prog/circuit to LaTeX representation,

draw_qprog_latex_with_clock(, itr_end)

Convert a quantum prog/circuit to LaTeX source code with time sequence,

draw_qprog_text(, itr_end)

Convert a quantum prog/circuit to text-pic (UTF-8 code),

draw_qprog_text_with_clock(, itr_end)

Convert a quantum prog/circuit to text-pic (UTF-8 code) with time sequence,

dropout(→ var)

equal(…)

Check if a bit size is equal to a ClassicalCondition.

estimate_topology(→ float)

Evaluate topology performance.

eval(…)

exp(→ var)

expMat(→ numpy.ndarray[numpy.complex128[m, n]])

Calculate the matrix power of e.

expand_linear_equations(…)

Extending linear equations to N dimension, N = 2 ^ n

fill_qprog_by_I(→ QProg)

Fill the input quantum program with I gates and return a new quantum program.

finalize(→ None)

Finalize the environment and destroy global unique quantum machine.

fit_to_gbk(→ str)

Special character conversion.

flatten(…)

Flatten a quantum circuit in place.

getAllocateCMem(→ int)

Deprecated, use get_allocate_cmem_num instead.

getAllocateQubitNum(→ int)

Deprecated, use get_allocate_qubit_num instead.

get_adjacent_qgate_type(→ List[NodeInfo])

Get the adjacent quantum gates' (the front one and the back one) type info from QProg.

get_all_used_qubits(→ List[Qubit])

Get all the quantum bits used in the input program.

get_all_used_qubits_to_int(→ List[int])

Get the addresses of all used quantum bits in the input program.

get_allocate_cbits(→ List[ClassicalCondition])

Get allocated cbits of QuantumMachine

get_allocate_cmem_num(→ int)

Get allocate cmem num.

get_allocate_qubit_num(→ int)

Get allocate qubit num.

get_allocate_qubits(→ List[Qubit])

Get allocated qubits of QuantumMachine

get_bin_data(→ List[int])

Get quantum program binary data.

get_bin_str(→ str)

Transform a quantum program into a string representation.

get_circuit_optimal_topology(→ List[List[int]])

Retrieve the optimal topology of the input quantum circuit.

get_clock_cycle(→ int)

Get quantum program clock cycle.

get_complex_points(→ List[int])

Retrieve complex points from the given topology data.

get_double_gate_block_topology(→ List[List[int]])

Retrieve the double gate block topology from the input quantum program.

get_matrix(→ Any)

Get the target matrix between the input two NodeIters.

get_prob_dict(→ Dict[str, float])

Get pmeasure result as dict

get_prob_list(→ List[float])

Get pmeasure result as list

get_qgate_num(…)

Count the number of quantum gates in a quantum program.

get_qprog_clock_cycle(→ int)

Get Quantum Program Clock Cycle.

get_qstate(…)

get_sub_graph(→ List[int])

Retrieve a subgraph from the provided topology data.

get_tuple_list(→ List[Tuple[int, float]])

Get pmeasure result as tuple list

get_unitary(→ Any)

Get the target unitary matrix between the input two NodeIters.

get_unsupport_qgate_num(→ int)

Count the number of unsupported gates in a quantum program.

getstat(→ Any)

Get the status of the Quantum machine

iSWAP(…)

Returns:

init(→ bool)

Init the global unique quantum machine at background.

init_quantum_machine(→ QuantumMachine)

Create and initialize a new quantum machine, and let it be a globally unique quantum machine.

inverse(→ var)

isCarry(→ QCircuit)

Construct a circuit to determine if there is a carry

is_match_topology(→ bool)

Judge if the QGate matches the target topologic structure of the quantum circuit.

is_supported_qgate_type(→ bool)

Judge if the target node is a QGate type.

is_swappable(→ bool)

Judge whether the specified two NodeIters in the quantum program can be exchanged.

iterative_amplitude_estimation(→ float)

estimate the probability corresponding to the ground state |1> of the last bit

ldd_decompose(→ QProg)

Decompose a multiple control quantum gate using LDD.

log(→ var)

matrix_decompose(…)

Matrix decomposition

matrix_decompose_paulis(…)

decompose matrix into paulis combination

measure_all(…)

Create a list of measure nodes.

mul(…)

Multiply a bit size by a ClassicalCondition.

originir_to_qprog(→ QProg)

Read an OriginIR file and transform it into QProg.

pauli_combination_replace(→ List[Tuple[float, QCircuit]])

planarity_testing(→ bool)

Perform planarity testing.

pmeasure(→ List[Tuple[int, float]])

Get the probability distribution over qubits.

pmeasure_no_index(→ List[float])

Get the probability distribution over qubits.

poly(→ var)

print_matrix(→ str)

Print matrix elements.

prob_run_dict(→ Dict[str, float])

Run quantum program and get pmeasure result as dict

prob_run_list(→ List[float])

Run quantum program and get pmeasure result as list

prob_run_tuple_list(→ List[Tuple[int, float]])

Run quantum program and get pmeasure result as tuple list

prog_layer(→ Any)

Process the given quantum program layer.

prog_to_dag(→ QProgDAG)

Convert a quantum program into a directed acyclic graph (DAG).

qAlloc(…)

Allocate a qubit

qAlloc_many(→ List[Qubit])

Allocate several qubits

qFree(→ None)

Free a qubit

qFree_all(…)

Free a list of qubits

qop(…)

qop_pmeasure(→ var)

quantum_chip_adapter(→ list)

Perform adaptive conversion for the quantum chip.

quantum_walk_alg(→ Any)

Build quantum-walk algorithm quantum circuit

quantum_walk_search(→ quantum_walk_search.list)

Use Quantum-walk Algorithm to search target data, return QProg and search_result

quick_measure(→ Dict[str, int])

Quick measure.

random_qcircuit(→ QCircuit)

Generate a random quantum circuit.

random_qprog(→ QProg)

Generate a random quantum program.

recover_edges(→ List[List[int]])

Recover edges using the specified candidate edges.

remap(→ QProg)

Map the source quantum program to the target qubits.

replace_complex_points(→ None)

Replace complex points in the source topology with subgraphs.

run_with_configuration(→ Any)

sabre_mapping(…)

sabre mapping

sigmoid(→ var)

sin(→ var)

softmax(→ var)

split_complex_points(→ List[Tuple[int, List[List[int]]]])

Split complex points into multiple discrete points.

stack(→ var)

state_fidelity(…)

Compare a quantum state matrix with a quantum state and calculate their fidelity.

sub(…)

Subtract a ClassicalCondition from a bit size.

sum(→ var)

tan(→ var)

to_Quil(→ str)

Transform QProg to Quil instruction.

to_originir(…)

Transform QProg to OriginIR string.

topology_match(→ list)

Judge whether a quantum program matches the topology of the physical qubits.

transform_binary_data_to_qprog(→ QProg)

Parse binary data to transform it into a quantum program.

transform_originir_to_qprog(→ QProg)

Transform OriginIR instruction from a file into a QProg.

transform_qprog_to_binary(…)

Save quantum program to file as binary data.

transform_qprog_to_originir(→ str)

Transform a quantum program into an OriginIR instruction string.

transform_qprog_to_quil(→ str)

Transform QProg to Quil instruction.

transform_to_base_qgate(…)

Convert quantum gates to basic gates.

transfrom_pauli_operator_to_matrix(→ List[complex])

transfrom pauli operator to matrix

transpose(→ var)

validate_double_qgate_type(→ list)

Get valid QGates and valid double bit QGate type.

validate_single_qgate_type(→ list)

Get valid QGates and valid single bit QGate type.

vector_dot(→ float)

Compute the inner product of two vectors.

virtual_z_transform(→ QProg)

virtual z transform

single_gate_apply_to_all(gate, qubit_list)

Applies a specified quantum gate to each qubit within the provided list.

single_gate(gate, qubit[, angle])

Constructs a quantum gate operation on a specified qubit.

meas_all(qubits, cbits)

Constructs a quantum program by measuring specified qubits and mapping their outcomes to classical bits.

get_fidelity(result, shots, target_result)

Calculate the fidelity between a given quantum state and a target state.

draw_qprog(prog[, output, scale, fold, filename, ...])

Visualizes a quantum circuit in various formats based on the specified output type.

show_prog_info_count(prog)

Visualizes the distribution of nodes and layers within a quantum circuit represented by prog.

draw_probability(list)

Generate a bar plot visualizing the probabilities of a quantum state.

draw_probability_dict(prob_dict)

Generate a bar plot representing the probabilities of a quantum state from a given dictionary.

plot_state_city(state[, title, figsize, color, ...])

Plots the real and imaginary parts of a quantum state in a 3D bar plot.

plot_density_matrix(M[, xlabels, ylabels, title, ...])

Plots the density matrix of a quantum state as a 3D bar plot, visualizing the

state_to_density_matrix(quantum_state)

Converts a given quantum state into its corresponding density matrix representation.

plot_bloch_circuit(circuit[, trace, saveas, fps, ...])

Visualizes the evolution of a quantum circuit on a Bloch sphere.

plot_bloch_vector(bloch[, title, axis_obj, fig_size])

Visualizes the evolution of a quantum circuit on a Bloch sphere.

plot_bloch_multivector(state[, title, fig_size])

Visualizes a quantum state on a Bloch sphere.

Package Contents

class pyqpanda.AbstractOptimizer(*args, **kwargs)[源代码]

quantum AbstractOptimizer class

exec() None[源代码]

Execute the optimization process.

Args:

None: This method takes no parameters.

Returns:

result: The result of the optimization process.

getResult(*args, **kwargs) Any[源代码]

Retrieve the result of the last optimization.

Args:

None: This method takes no parameters.

Returns:

result: The result of the last optimization.

registerFunc(arg0: Callable[[List[float], List[float], int, int], Tuple[str, float]], arg1: List[float]) None[源代码]

Register an optimization function.

Args:

func: The optimization function to be registered.

Returns:

None

setAdaptive(arg0: bool) None[源代码]

Set whether the optimizer should use adaptive methods.

Args:

adaptive: A boolean indicating whether to enable adaptive optimization.

Returns:

None

setCacheFile(arg0: str) None[源代码]

Set the path for the cache file used in optimization.

Args:

cache_file: A string representing the path to the cache file.

Returns:

None

setDisp(arg0: bool) None[源代码]

Set the display flag for the optimizer.

Args:

disp: A boolean indicating whether to display optimization progress.

Returns:

None

setFatol(arg0: float) None[源代码]

Set the function absolute tolerance for optimization.

Args:

fatol: The function absolute tolerance value to be set.

Returns:

None

setMaxFCalls(arg0: int) None[源代码]

Set the maximum number of function calls allowed during optimization.

Args:

max_calls: The maximum number of function calls to be set.

Returns:

None

setMaxIter(arg0: int) None[源代码]

Set the maximum number of iterations allowed during optimization.

Args:

max_iter: The maximum number of iterations to be set.

Returns:

None

setRestoreFromCacheFile(arg0: bool) None[源代码]

Set whether to restore the optimization state from a cache file. Args:

cache_file: A string representing the path to the cache file.

Returns:

None

setXatol(arg0: float) None[源代码]

Set the absolute tolerance for optimization.

Args:

atol: The absolute tolerance value to be set.

Returns:

None

class pyqpanda.AdaGradOptimizer(arg0: var, arg1: float, arg2: float, arg3: float)[源代码]

variational quantum AdaGradOptimizer

get_loss() float[源代码]
get_variables() List[var][源代码]
minimize(arg0: float, arg1: float, arg2: float) Optimizer[源代码]
run(arg0: List[var], arg1: int) bool[源代码]
class pyqpanda.AdamOptimizer(arg0: var, arg1: float, arg2: float, arg3: float, arg4: float)[源代码]

variational quantum AdamOptimizer

get_loss() float[源代码]
get_variables() List[var][源代码]
minimize(arg0: float, arg1: float, arg2: float, arg3: float) Optimizer[源代码]
run(arg0: List[var], arg1: int) bool[源代码]
class pyqpanda.Ansatz[源代码]
class pyqpanda.Ansatz(arg0: QGate)
class pyqpanda.Ansatz(arg0: AnsatzGate)
class pyqpanda.Ansatz(ansatz: List[AnsatzGate], thetas: List[float] = [])
class pyqpanda.Ansatz(ansatz_circuit: Ansatz, thetas: List[float] = [])
class pyqpanda.Ansatz(circuit: QCircuit, thetas: List[float] = [])

quantum ansatz class

get_ansatz_list() List[AnsatzGate][源代码]
get_thetas_list() List[float][源代码]
insert(gate: QGate) None[源代码]
insert(gate: AnsatzGate) None
insert(gate: List[AnsatzGate]) None
insert(gate: QCircuit) None
insert(gate: Ansatz, thetas: List[float] = []) None
set_thetas(thetas: List[float]) None[源代码]
class pyqpanda.AnsatzGate(arg0: AnsatzGateType, arg1: int)[源代码]
class pyqpanda.AnsatzGate(arg0: AnsatzGateType, arg1: int, arg2: float)
class pyqpanda.AnsatzGate(arg0: AnsatzGateType, arg1: int, arg2: float, arg3: int)

ansatz gate struct

control: int
target: int
theta: float
type: AnsatzGateType
class pyqpanda.AnsatzGateType(value: int)[源代码]

Quantum ansatz gate type

Members:

AGT_X

AGT_H

AGT_RX

AGT_RY

AGT_RZ

AGT_H: ClassVar[AnsatzGateType] = Ellipsis
AGT_RX: ClassVar[AnsatzGateType] = Ellipsis
AGT_RY: ClassVar[AnsatzGateType] = Ellipsis
AGT_RZ: ClassVar[AnsatzGateType] = Ellipsis
AGT_X: ClassVar[AnsatzGateType] = Ellipsis
property name: str
property value: int
class pyqpanda.BackendType(value: int)[源代码]

Quantum machine backend type

Members:

CPU

GPU

CPU_SINGLE_THREAD

NOISE

MPS

CPU: ClassVar[BackendType] = Ellipsis
CPU_SINGLE_THREAD: ClassVar[BackendType] = Ellipsis
GPU: ClassVar[BackendType] = Ellipsis
MPS: ClassVar[BackendType] = Ellipsis
NOISE: ClassVar[BackendType] = Ellipsis
property name: str
property value: int
class pyqpanda.CBit(*args, **kwargs)[源代码]

quantum classical bit

getName() str[源代码]

Retrieve the name of the classical bit.

Args:

None

Returns:

The name of the CBit as a string.

class pyqpanda.CPUQVM[源代码]

Bases: QuantumMachine

quantum machine cpu

get_prob_dict(qubit_list: QVec, select_max: int = -1) Dict[str, float][源代码]

Get a dictionary of probabilities for the specified qubits.

Args:

qubit_list: List of qubits to measure.

select_max: int, optional, maximum number of entries to return (default: -1).

Returns:

Dictionary of probabilities as a reference.

get_prob_list(qubit_list: QVec, select_max: int = -1) List[float][源代码]

Get a list of probabilities for the specified qubits.

Args:

qubit_list: List of qubits to measure.

select_max: int, optional, maximum number of probabilities to return (default: -1).

Returns:

List of probabilities as a reference.

get_prob_tuple_list(qubit_list: QVec, select_max: int = -1) List[Tuple[int, float]][源代码]

Get a list of probability tuples for the specified qubits.

Args:

qubit_list: List of qubits to measure.

select_max: int, optional, maximum number of tuples to return (default: -1).

Returns:

List of probability tuples as a reference.

init_qvm(arg0: bool) None[源代码]
init_qvm() None

Initialize the quantum virtual machine (QVM).

This method sets up the necessary environment for the QVM to execute quantum programs.

Returns:

None: This method does not return a value.

pmeasure(qubit_list: QVec, select_max: int = -1) List[Tuple[int, float]][源代码]

Get the probability distribution over qubits.

Args:

qubit_list: List of qubits to measure.

select_max: int, optional, maximum number of results to select (default: -1).

Returns:

Probability distribution as a reference.

pmeasure_no_index(qubit_list: QVec) List[float][源代码]

Get the probability distribution over qubits without index.

Args:

qubit_list: List of qubits to measure.

Returns:

Probability distribution as a reference.

prob_run_dict(program: QProg, qubit_list: QVec, select_max: int = -1) Dict[str, float][源代码]
prob_run_dict(program: QProg, qubit_addr_list: List[int], select_max: int = -1) Dict[str, float]

Execute a quantum program and retrieve a dictionary of probabilities using qubit addresses.

Args:

program: The quantum program to execute.

qubit_addr_list: List of qubit addresses to measure.

select_max: int, optional, maximum number of entries in the dictionary to return (default: -1).

Returns:

Dictionary of probabilities.

prob_run_list(program: QProg, qubit_list: QVec, select_max: int = -1) List[float][源代码]
prob_run_list(program: QProg, qubit_addr_list: List[int], select_max: int = -1) List[float]

Execute a quantum program and retrieve a list of probabilities using qubit addresses.

Args:

program: The quantum program to execute.

qubit_addr_list: List of qubit addresses to measure.

select_max: int, optional, maximum number of probabilities to return (default: -1).

Returns:

List of probabilities.

prob_run_tuple_list(program: QProg, qubit_list: QVec, select_max: int = -1) List[Tuple[int, float]][源代码]
prob_run_tuple_list(program: QProg, qubit_addr_list: List[int], select_max: int = -1) List[Tuple[int, float]]

Execute a quantum program and get a list of probability tuples using qubit addresses.

Args:

program: The quantum program to execute.

qubit_addr_list: List of qubit addresses to measure.

select_max: int, optional, maximum number of tuples to return (default: -1).

Returns:

List of probability tuples.

quick_measure(qubit_list: QVec, shots: int) Dict[str, int][源代码]

Perform a quick measurement on the specified qubits.

Args:

qubit_list: List of qubits to measure.

shots: Number of measurement shots to perform.

Returns:

Reference to the measurement results.

set_max_threads(size: int) None[源代码]

Set the maximum number of threads for the CPU quantum virtual machine (QVM).

Args:

size: The maximum number of threads to use.

Returns:

None: This method does not return a value.

class pyqpanda.CPUSingleThreadQVM[源代码]

Bases: QuantumMachine

quantum machine class for cpu single thread

get_prob_dict(qubit_list: QVec, select_max: int = -1) Dict[str, float][源代码]

Get a dictionary of probabilities for the specified qubits.

Args:

qubit_list: List of qubits to measure.

select_max: int, optional, maximum number of entries to return (default: -1).

Returns:

Dictionary of probabilities as a reference.

get_prob_list(qubit_list: QVec, select_max: int = -1) List[float][源代码]

Get a list of probabilities for the specified qubits.

Args:

qubit_list: List of qubits to measure.

select_max: int, optional, maximum number of probabilities to return (default: -1).

Returns:

List of probabilities as a reference.

get_prob_tuple_list(qubit_list: QVec, select_max: int = -1) List[Tuple[int, float]][源代码]

Get a list of probability tuples for the specified qubits.

Args:

qubit_list: List of qubits to measure.

select_max: int, optional, maximum number of tuples to return (default: -1).

Returns:

List of probability tuples as a reference.

pmeasure(qubit_list: QVec, select_max: int = -1) List[Tuple[int, float]][源代码]

Get the probability distribution over qubits.

Args:

qubit_list: List of qubits to measure.

select_max: int, optional, maximum number of results to select (default: -1).

Returns:

Probability distribution as a reference.

pmeasure_no_index(qubit_list: QVec) List[float][源代码]

Get the probability distribution over qubits without index.

Args:

qubit_list: List of qubits to measure.

Returns:

Probability distribution as a reference.

prob_run_dict(program: QProg, qubit_list: QVec, select_max: int = -1) Dict[str, float][源代码]
prob_run_dict(program: QProg, qubit_addr_list: List[int], select_max: int = -1) Dict[str, float]

Execute a quantum program and retrieve a dictionary of probabilities using qubit addresses.

Args:

program: The quantum program to execute.

qubit_addr_list: List of qubit addresses to measure.

select_max: int, optional, maximum number of entries in the dictionary to return (default: -1).

Returns:

Dictionary of probabilities.

prob_run_list(program: QProg, qubit_list: QVec, select_max: int = -1) List[float][源代码]
prob_run_list(program: QProg, qubit_addr_list: List[int], select_max: int = -1) List[float]

Execute a quantum program and retrieve a list of probabilities using qubit addresses.

Args:

program: The quantum program to execute.

qubit_addr_list: List of qubit addresses to measure.

select_max: int, optional, maximum number of probabilities to return (default: -1).

Returns:

List of probabilities.

prob_run_tuple_list(program: QProg, qubit_list: QVec, select_max: int = -1) List[Tuple[int, float]][源代码]
prob_run_tuple_list(program: QProg, qubit_addr_list: List[int], select_max: int = -1) List[Tuple[int, float]]

Execute a quantum program and get a list of probability tuples using qubit addresses.

Args:

program: The quantum program to execute.

qubit_addr_list: List of qubit addresses to measure.

select_max: int, optional, maximum number of tuples to return (default: -1).

Returns:

List of probability tuples.

quick_measure(qubit_list: QVec, shots: int) Dict[str, int][源代码]

Perform a quick measurement on the specified qubits.

Args:

qubit_list: List of qubits to measure.

shots: Number of measurement shots to perform.

Returns:

Reference to the measurement results.

class pyqpanda.ChipID(value: int)[源代码]

origin quantum real chip type

Members:

Simulation

WUYUAN_1

WUYUAN_2

WUYUAN_3

Simulation: ClassVar[ChipID] = Ellipsis
WUYUAN_1: ClassVar[ChipID] = Ellipsis
WUYUAN_2: ClassVar[ChipID] = Ellipsis
WUYUAN_3: ClassVar[ChipID] = Ellipsis
property name: str
property value: int
class pyqpanda.ClassicalCondition(*args, **kwargs)[源代码]

Classical condition class Proxy class of cexpr class

c_and(arg0: int) ClassicalCondition[源代码]
c_and(arg0: ClassicalCondition) ClassicalCondition

Perform a logical AND operation with another ClassicalCondition.

Args:

other: Another ClassicalCondition to perform AND with.

Returns:

The result of the AND operation.

c_not() ClassicalCondition[源代码]

Perform a logical NOT operation on the classical condition.

Args:

None

Returns:

The result of the NOT operation.

c_or(arg0: int) ClassicalCondition[源代码]
c_or(arg0: ClassicalCondition) ClassicalCondition

Perform a logical OR operation with another ClassicalCondition.

Args:

other: Another ClassicalCondition to perform OR with.

Returns:

The result of the OR operation.

get_val() int[源代码]

Retrieve the current value of the classical condition.

Args:

None

Returns:

The value of the ClassicalCondition.

set_val(arg0: int) None[源代码]

Set a new value for the classical condition.

Args:

value: The new value to set.

Returns:

None

class pyqpanda.ClassicalProg(arg0: ClassicalCondition)[源代码]

quantum ClassicalProg

class pyqpanda.CommProtocolConfig[源代码]
circuits_num: int
open_error_mitigation: bool
open_mapping: bool
optimization_level: int
shots: int
class pyqpanda.ComplexVertexSplitMethod(value: int)[源代码]

quantum complex vertex split method

Members:

METHOD_UNDEFINED

LINEAR

RING

LINEAR: ClassVar[ComplexVertexSplitMethod] = Ellipsis
METHOD_UNDEFINED: ClassVar[ComplexVertexSplitMethod] = Ellipsis
RING: ClassVar[ComplexVertexSplitMethod] = Ellipsis
property name: str
property value: int
class pyqpanda.DAGNodeType(value: int)[源代码]

Quantum dag node type

Members:

NUKNOW_SEQ_NODE_TYPE

MAX_GATE_TYPE

MEASURE

QUBIT

RESET

MAX_GATE_TYPE: ClassVar[DAGNodeType] = Ellipsis
MEASURE: ClassVar[DAGNodeType] = Ellipsis
NUKNOW_SEQ_NODE_TYPE: ClassVar[DAGNodeType] = Ellipsis
QUBIT: ClassVar[DAGNodeType] = Ellipsis
RESET: ClassVar[DAGNodeType] = Ellipsis
property name: str
property value: int
class pyqpanda.DecompositionMode(value: int)[源代码]

Quantum matrix decomposition mode

Members:

QR

HOUSEHOLDER_QR

QSDecomposition

CSDecomposition

CSDecomposition: ClassVar[DecompositionMode] = Ellipsis
HOUSEHOLDER_QR: ClassVar[DecompositionMode] = Ellipsis
QR: ClassVar[DecompositionMode] = Ellipsis
QSDecomposition: ClassVar[DecompositionMode] = Ellipsis
property name: str
property value: int
class pyqpanda.DensityMatrixSimulator[源代码]

Bases: QuantumMachine

simulator for density matrix

get_density_matrix(prog: QProg) numpy.ndarray[numpy.complex128[m, n]][源代码]

Run quantum program and get the full density matrix.

Args:

prog: The quantum program to execute.

Returns:

The full density matrix.

get_expectation(prog: QProg, hamiltonian: List[Tuple[Dict[int, str], float]], qubits: QVec) float[源代码]
get_expectation(prog: QProg, hamiltonian: List[Tuple[Dict[int, str], float]], qubits: List[int]) float

Run the quantum program and calculate the Hamiltonian expectation for the specified qubits.

Args:

prog: The quantum program to execute.

hamiltonian: The QHamiltonian to use for the expectation value.

qubits: The selected qubits for measurement.

Returns:

The Hamiltonian expectation for the specified qubits.

get_probabilities(prog: QProg) List[float][源代码]
get_probabilities(prog: QProg, qubits: QVec) List[float]
get_probabilities(prog: QProg, qubits: List[int]) List[float]
get_probabilities(prog: QProg, indices: List[str]) List[float]

Run the quantum program and get the probabilities for the specified binary indices.

Args:

prog: The quantum program to execute.

indices: The selected binary indices for measurement.

Returns:

The probabilities result of the quantum program.

get_probability(prog: QProg, index: int) float[源代码]
get_probability(prog: QProg, index: str) float

Run the quantum program and get the probability for the specified index.

Args:

prog: The quantum program to execute.

index: The measurement index in [0, 2^N 1].

Returns:

The probability result of the quantum program.

get_reduced_density_matrix(prog: QProg, qubits: QVec) numpy.ndarray[numpy.complex128[m, n]][源代码]
get_reduced_density_matrix(prog: QProg, qubits: List[int]) numpy.ndarray[numpy.complex128[m, n]]

Run quantum program and get the density matrix for current qubits.

Args:

prog: The quantum program to execute.

qubits: The selected qubits from the quantum program.

Returns:

The density matrix for the specified qubits.

init_qvm(is_double_precision: bool = True) None[源代码]
set_noise_model(arg0: numpy.ndarray[numpy.complex128[m, n]]) None[源代码]
set_noise_model(arg0: numpy.ndarray[numpy.complex128[m, n]], arg1: List[GateType]) None
set_noise_model(arg0: List[numpy.ndarray[numpy.complex128[m, n]]]) None
set_noise_model(arg0: List[numpy.ndarray[numpy.complex128[m, n]]], arg1: List[GateType]) None
set_noise_model(arg0: NoiseModel, arg1: GateType, arg2: float) None
set_noise_model(arg0: NoiseModel, arg1: List[GateType], arg2: float) None
set_noise_model(arg0: NoiseModel, arg1: GateType, arg2: float, arg3: QVec) None
set_noise_model(arg0: NoiseModel, arg1: List[GateType], arg2: float, arg3: QVec) None
set_noise_model(arg0: NoiseModel, arg1: GateType, arg2: float, arg3: List[QVec]) None
set_noise_model(arg0: NoiseModel, arg1: GateType, arg2: float, arg3: float, arg4: float) None
set_noise_model(arg0: NoiseModel, arg1: List[GateType], arg2: float, arg3: float, arg4: float) None
set_noise_model(arg0: NoiseModel, arg1: GateType, arg2: float, arg3: float, arg4: float, arg5: QVec) None
set_noise_model(arg0: NoiseModel, arg1: List[GateType], arg2: float, arg3: float, arg4: float, arg5: QVec) None
set_noise_model(arg0: NoiseModel, arg1: GateType, arg2: float, arg3: float, arg4: float, arg5: List[QVec]) None

Set a specific noise model for the density matrix simulator with a given gate type, probability, duration, temperature, and multiple target qubits.

Args:

noise_model: The noise model to apply.

gate_type: The specific gate type associated with the noise model.

probability: The probability of the noise occurring.

duration: The duration for which the noise model is applied.

temperature: The temperature affecting the noise characteristics.

target_qubits: A vector of qubits targeted by the noise model.

Returns:

None.

class pyqpanda.DoubleGateTransferType(value: int)[源代码]

Quantum double gate transfer type

Members:

DOUBLE_GATE_INVALID

DOUBLE_BIT_GATE

DOUBLE_BIT_GATE: ClassVar[DoubleGateTransferType] = Ellipsis
DOUBLE_GATE_INVALID: ClassVar[DoubleGateTransferType] = Ellipsis
property name: str
property value: int
class pyqpanda.Encode[源代码]

quantum amplitude encode

amplitude_encode(qubit: QVec, data: List[float]) None[源代码]
amplitude_encode(qubit: QVec, data: List[complex]) None

Perform amplitude encoding using complex numbers on the given qubits.

Args:

qubit: The quantum vector to be encoded.

data: The classical complex data to be encoded.

Returns:

An encoded quantum state.

amplitude_encode_recursive(qubit: QVec, data: List[float]) None[源代码]
amplitude_encode_recursive(qubit: QVec, data: List[complex]) None

Encode by amplitude recursively.

Args:

QVec: qubits

QStat: amplitude

Returns:

circuit

angle_encode(qubit: QVec, data: List[float], gate_type: GateType = GateType.RY_GATE) None[源代码]

Encode by angle.

Args:

QVec: qubits

prob_vec: data

Returns:

circuit.

approx_mps(qubit: QVec, data: List[float], layers: int = 3, sweeps: int = 100, double2float: bool = False) None[源代码]
approx_mps(qubit: QVec, data: List[complex], layers: int = 3, sweeps: int = 100) None

Approximate Matrix Product State encoding.

Args:

QVec: qubits

std::vector<qcomplex_t>: input data

int: number of layers (default: 3)

int: number of steps (default: 100)

Returns:

Encoded circuit.

basic_encode(qubit: QVec, data: str) None[源代码]

Basic encoding.

Args:

QVec: qubits

string: data

Returns:

circuit

bid_amplitude_encode(qubit: QVec, data: List[float], split: int = 0) None[源代码]

Encode by bid.

Args:

QVec: qubits

QStat: amplitude

split: int

Returns:

circuit

dc_amplitude_encode(qubit: QVec, data: List[float]) None[源代码]

Encode by DC amplitude.

Args:

QVec: qubits

QStat: amplitude

Returns:

circuit

dense_angle_encode(qubit: QVec, data: List[float]) None[源代码]

Encode by dense angle.

Args:

QVec: qubits

prob_vec: data

Returns:

circuit

ds_quantum_state_preparation(qubit: QVec, data: Dict[str, float]) None[源代码]
ds_quantum_state_preparation(qubit: QVec, data: Dict[str, complex]) None
ds_quantum_state_preparation(qubit: QVec, data: List[float]) None
ds_quantum_state_preparation(qubit: QVec, data: List[complex]) None

Prepare a quantum state.

Args:

QVec: qubits

std::vector<std::complex<double>>: state parameters

Returns:

circuit

efficient_sparse(qubit: QVec, data: Dict[str, float]) None[源代码]
efficient_sparse(qubit: QVec, data: Dict[str, complex]) None
efficient_sparse(qubit: QVec, data: List[float]) None
efficient_sparse(qubit: QVec, data: List[complex]) None

Perform an efficient sparse operation.

Args:

QVec: qubits

std::vector<std::complex<double>>: parameters for the operation

Returns:

circuit

get_circuit() QCircuit[源代码]

Retrieve the circuit from the encoder.

Returns:

The corresponding circuit object.

get_fidelity(data: List[float]) float[源代码]
get_fidelity(data: List[complex]) float
get_fidelity(data: List[float]) float

Calculate the fidelity based on the provided float data.

Args:

data: A vector of floats representing the input data.

Returns:

The calculated fidelity value.

get_out_qubits() QVec[源代码]

Retrieve the output qubits from the encoder.

Returns:

A vector of output qubits.

iqp_encode(qubit: QVec, data: List[float], control_list: List[Tuple[int, int]] = [], bool_inverse: bool = False, repeats: int = 1) None[源代码]

Encode by IQP.

Args:

QVec: qubits

prob_vec: data

list: control_list

bool: bool_inverse

int: repeats

Returns:

circuit.

schmidt_encode(qubit: QVec, data: List[float], cutoff: float) None[源代码]

Encode by schmidt.

Args:

QVec: qubits

QStat: amplitude

double: cutoff

Returns:

circuit

sparse_isometry(qubit: QVec, data: Dict[str, float]) None[源代码]
sparse_isometry(qubit: QVec, data: Dict[str, complex]) None
sparse_isometry(qubit: QVec, data: List[float]) None
sparse_isometry(qubit: QVec, data: List[complex]) None

Perform a sparse isometry operation.

Args:

QVec: qubits

std::vector<std::complex<double>>: parameters for the isometry

Returns:

circuit

class pyqpanda.ErrorCode(value: int)[源代码]

pliot error code

Members:

NO_ERROR_FOUND

DATABASE_ERROR

ORIGINIR_ERROR

JSON_FIELD_ERROR

BACKEND_CALC_ERROR

ERR_TASK_BUF_OVERFLOW

EXCEED_MAX_QUBIT

ERR_UNSUPPORT_BACKEND_TYPE

EXCEED_MAX_CLOCK

ERR_UNKNOW_TASK_TYPE

ERR_QVM_INIT_FAILED

ERR_QCOMPILER_FAILED

ERR_PRE_ESTIMATE

ERR_MATE_GATE_CONFIG

ERR_FIDELITY_MATRIX

ERR_QST_PROG

ERR_EMPTY_PROG

ERR_QUBIT_SIZE

ERR_QUBIT_TOPO

ERR_QUANTUM_CHIP_PROG

ERR_REPEAT_MEASURE

ERR_OPERATOR_DB

ERR_TASK_STATUS_BUF_OVERFLOW

ERR_BACKEND_CHIP_TASK_SOCKET_WRONG

CLUSTER_SIMULATE_CALC_ERR

ERR_SCHEDULE_CHIP_TOPOLOGY_SUPPORTED

ERR_TASK_CONFIG

ERR_NOT_FOUND_APP_ID

ERR_NOT_FOUND_TASK_ID

ERR_PARSER_SUB_TASK_RESULT

ERR_SYS_CALL_TIME_OUT

ERR_TASK_TERMINATED

ERR_INVALID_URL

ERR_PARAMETER

ERR_QPROG_LENGTH

ERR_CHIP_OFFLINE

UNDEFINED_ERROR

ERR_SUB_GRAPH_OUT_OF_RANGE

ERR_TCP_INIT_FATLT

ERR_TCP_SERVER_HALT

CLUSTER_BASE

BACKEND_CALC_ERROR: ClassVar[ErrorCode] = Ellipsis
CLUSTER_BASE: ClassVar[ErrorCode] = Ellipsis
CLUSTER_SIMULATE_CALC_ERR: ClassVar[ErrorCode] = Ellipsis
DATABASE_ERROR: ClassVar[ErrorCode] = Ellipsis
ERR_BACKEND_CHIP_TASK_SOCKET_WRONG: ClassVar[ErrorCode] = Ellipsis
ERR_CHIP_OFFLINE: ClassVar[ErrorCode] = Ellipsis
ERR_EMPTY_PROG: ClassVar[ErrorCode] = Ellipsis
ERR_FIDELITY_MATRIX: ClassVar[ErrorCode] = Ellipsis
ERR_INVALID_URL: ClassVar[ErrorCode] = Ellipsis
ERR_MATE_GATE_CONFIG: ClassVar[ErrorCode] = Ellipsis
ERR_NOT_FOUND_APP_ID: ClassVar[ErrorCode] = Ellipsis
ERR_NOT_FOUND_TASK_ID: ClassVar[ErrorCode] = Ellipsis
ERR_OPERATOR_DB: ClassVar[ErrorCode] = Ellipsis
ERR_PARAMETER: ClassVar[ErrorCode] = Ellipsis
ERR_PARSER_SUB_TASK_RESULT: ClassVar[ErrorCode] = Ellipsis
ERR_PRE_ESTIMATE: ClassVar[ErrorCode] = Ellipsis
ERR_QCOMPILER_FAILED: ClassVar[ErrorCode] = Ellipsis
ERR_QPROG_LENGTH: ClassVar[ErrorCode] = Ellipsis
ERR_QST_PROG: ClassVar[ErrorCode] = Ellipsis
ERR_QUANTUM_CHIP_PROG: ClassVar[ErrorCode] = Ellipsis
ERR_QUBIT_SIZE: ClassVar[ErrorCode] = Ellipsis
ERR_QUBIT_TOPO: ClassVar[ErrorCode] = Ellipsis
ERR_QVM_INIT_FAILED: ClassVar[ErrorCode] = Ellipsis
ERR_REPEAT_MEASURE: ClassVar[ErrorCode] = Ellipsis
ERR_SCHEDULE_CHIP_TOPOLOGY_SUPPORTED: ClassVar[ErrorCode] = Ellipsis
ERR_SUB_GRAPH_OUT_OF_RANGE: ClassVar[ErrorCode] = Ellipsis
ERR_SYS_CALL_TIME_OUT: ClassVar[ErrorCode] = Ellipsis
ERR_TASK_BUF_OVERFLOW: ClassVar[ErrorCode] = Ellipsis
ERR_TASK_CONFIG: ClassVar[ErrorCode] = Ellipsis
ERR_TASK_STATUS_BUF_OVERFLOW: ClassVar[ErrorCode] = Ellipsis
ERR_TASK_TERMINATED: ClassVar[ErrorCode] = Ellipsis
ERR_TCP_INIT_FATLT: ClassVar[ErrorCode] = Ellipsis
ERR_TCP_SERVER_HALT: ClassVar[ErrorCode] = Ellipsis
ERR_UNKNOW_TASK_TYPE: ClassVar[ErrorCode] = Ellipsis
ERR_UNSUPPORT_BACKEND_TYPE: ClassVar[ErrorCode] = Ellipsis
EXCEED_MAX_CLOCK: ClassVar[ErrorCode] = Ellipsis
EXCEED_MAX_QUBIT: ClassVar[ErrorCode] = Ellipsis
JSON_FIELD_ERROR: ClassVar[ErrorCode] = Ellipsis
NO_ERROR_FOUND: ClassVar[ErrorCode] = Ellipsis
ORIGINIR_ERROR: ClassVar[ErrorCode] = Ellipsis
UNDEFINED_ERROR: ClassVar[ErrorCode] = Ellipsis
property name: str
property value: int
class pyqpanda.Fusion[源代码]

quantum fusion operation

aggregate_operations(circuit: QCircuit) None[源代码]
aggregate_operations(qprog: QProg) None

Aggregate operations into the provided quantum program.

Args:

qprog: The quantum program to which operations will be added.

Returns:

A reference to the modified program.

class pyqpanda.GateType(value: int)[源代码]

quantum gate type

Members:

GATE_NOP

GATE_UNDEFINED

P0_GATE

P1_GATE

PAULI_X_GATE

PAULI_Y_GATE

PAULI_Z_GATE

X_HALF_PI

Y_HALF_PI

Z_HALF_PI

HADAMARD_GATE

T_GATE

S_GATE

P_GATE

CP_GATE

RX_GATE

RY_GATE

RZ_GATE

RXX_GATE

RYY_GATE

RZZ_GATE

RZX_GATE

U1_GATE

U2_GATE

U3_GATE

U4_GATE

CU_GATE

CNOT_GATE

CZ_GATE

MS_GATE

CPHASE_GATE

ISWAP_THETA_GATE

ISWAP_GATE

SQISWAP_GATE

SWAP_GATE

TWO_QUBIT_GATE

P00_GATE

P11_GATE

TOFFOLI_GATE

ORACLE_GATE

I_GATE

BARRIER_GATE

RPHI_GATE

BARRIER_GATE: ClassVar[GateType] = Ellipsis
CNOT_GATE: ClassVar[GateType] = Ellipsis
CPHASE_GATE: ClassVar[GateType] = Ellipsis
CP_GATE: ClassVar[GateType] = Ellipsis
CU_GATE: ClassVar[GateType] = Ellipsis
CZ_GATE: ClassVar[GateType] = Ellipsis
GATE_NOP: ClassVar[GateType] = Ellipsis
GATE_UNDEFINED: ClassVar[GateType] = Ellipsis
HADAMARD_GATE: ClassVar[GateType] = Ellipsis
ISWAP_GATE: ClassVar[GateType] = Ellipsis
ISWAP_THETA_GATE: ClassVar[GateType] = Ellipsis
I_GATE: ClassVar[GateType] = Ellipsis
MS_GATE: ClassVar[GateType] = Ellipsis
ORACLE_GATE: ClassVar[GateType] = Ellipsis
P00_GATE: ClassVar[GateType] = Ellipsis
P0_GATE: ClassVar[GateType] = Ellipsis
P11_GATE: ClassVar[GateType] = Ellipsis
P1_GATE: ClassVar[GateType] = Ellipsis
PAULI_X_GATE: ClassVar[GateType] = Ellipsis
PAULI_Y_GATE: ClassVar[GateType] = Ellipsis
PAULI_Z_GATE: ClassVar[GateType] = Ellipsis
P_GATE: ClassVar[GateType] = Ellipsis
RPHI_GATE: ClassVar[GateType] = Ellipsis
RXX_GATE: ClassVar[GateType] = Ellipsis
RX_GATE: ClassVar[GateType] = Ellipsis
RYY_GATE: ClassVar[GateType] = Ellipsis
RY_GATE: ClassVar[GateType] = Ellipsis
RZX_GATE: ClassVar[GateType] = Ellipsis
RZZ_GATE: ClassVar[GateType] = Ellipsis
RZ_GATE: ClassVar[GateType] = Ellipsis
SQISWAP_GATE: ClassVar[GateType] = Ellipsis
SWAP_GATE: ClassVar[GateType] = Ellipsis
S_GATE: ClassVar[GateType] = Ellipsis
TOFFOLI_GATE: ClassVar[GateType] = Ellipsis
TWO_QUBIT_GATE: ClassVar[GateType] = Ellipsis
T_GATE: ClassVar[GateType] = Ellipsis
U1_GATE: ClassVar[GateType] = Ellipsis
U2_GATE: ClassVar[GateType] = Ellipsis
U3_GATE: ClassVar[GateType] = Ellipsis
U4_GATE: ClassVar[GateType] = Ellipsis
X_HALF_PI: ClassVar[GateType] = Ellipsis
Y_HALF_PI: ClassVar[GateType] = Ellipsis
Z_HALF_PI: ClassVar[GateType] = Ellipsis
property name: str
property value: int
class pyqpanda.HHLAlg(arg0: QuantumMachine)[源代码]

quantum hhl algorithm class

check_QPE_result() str[源代码]

check QPE result

get_amplification_factor() float[源代码]

get_amplification_factor

get_ancillary_qubit() QVec[源代码]

get_ancillary_qubit

get_hhl_circuit(matrix_A: List[complex], data_b: List[float], precision_cnt: int = 0) QCircuit[源代码]
get_qubit_for_QFT() List[Qubit][源代码]

get_qubit_for_QFT

get_qubit_for_b() List[Qubit][源代码]

get_qubit_for_b

query_uesed_qubit_num() int[源代码]

query_uesed_qubit_num

class pyqpanda.LATEX_GATE_TYPE(value: int)[源代码]

Quantum latex gate type

Members:

GENERAL_GATE

CNOT_GATE

SWAP_GATE

CNOT_GATE: ClassVar[LATEX_GATE_TYPE] = Ellipsis
GENERAL_GATE: ClassVar[LATEX_GATE_TYPE] = Ellipsis
SWAP_GATE: ClassVar[LATEX_GATE_TYPE] = Ellipsis
property name: str
property value: int
class pyqpanda.LatexMatrix[源代码]

Generate quantum circuits latex src code can be compiled on latex package 'qcircuit' circuits element treated as matrix element in latex syntax

qcircuit package tutorial [https://physics.unm.edu/CQuIC/Qcircuit/Qtutorial.pdf]

insert_barrier(rows: List[int], from_col: int) int[源代码]

Insert a barrier into the circuit.

Args:

rows: The rows of the LaTeX matrix where the barrier is applied.

from_col: Desired column position for the barrier; if space is insufficient, a suitable column will be found.

Returns:

int: Actual column number where the barrier is placed.

insert_gate(target_rows: List[int], ctrl_rows: List[int], from_col: int, gate_type: LATEX_GATE_TYPE, gate_name: str = '', dagger: bool = False, param: str = '') int[源代码]

Insert a gate into the circuit.

Args:

target_rows: Gate target rows of the LaTeX matrix.

ctrl_rows: Control rows for the gate.

from_col: Desired column position for the gate; if space is insufficient, a suitable column will be found.

gate_type: Enum type of LATEX_GATE_TYPE.

gate_name: Name of the gate (default: '').

dagger: Flag indicating if the gate is a dagger (default: false).

param: Parameter string for the gate (default: '').

Returns:

int: Actual column number where the gate is placed.

insert_measure(q_row: int, c_row: int, from_col: int) int[源代码]

Insert a measurement operation into the circuit.

Args:

q_row: The row of the qubit being measured.

c_row: The row of the classical bit that will store the measurement result.

from_col: The desired column position for the measurement.

Returns:

None, as the function modifies the matrix in place.

insert_reset(q_row: int, from_col: int) int[源代码]

Insert a reset operation into the circuit.

Args:

q_row: The row of the qubit to be reset.

from_col: The desired column position for the reset.

Returns:

None, as the function modifies the matrix in place.

insert_timeseq(t_col: int, time_seq: int) None[源代码]

Insert a time sequence into the circuit.

Args:

t_col: The column position where the time sequence will be inserted.

time_seq: The time sequence data to be inserted.

Warning:

This function does not check for column number validity, which may cause overwriting.

Users must ensure the column number is managed correctly to avoid conflicts.

set_label(qubit_label: Dict[int, str], cbit_label: Dict[int, str] = {}, time_seq_label: str = '', head: bool = True) None[源代码]

Set label at the leftmost head column or rightmost tail column. Labels can be reset at any time.

Args:

qubit_label: Label for the qubit wire's leftmost head label, specified in LaTeX syntax.If not given, the row will remain empty (e.g., {0: 'q_{1}', 2:'q_{2}'}).

cbit_label: Classic label string, supports LaTeX formatting.

time_seq_label: If given, sets the time sequence label.

head: If true, appends the label at the head; if false, appends at the tail.

Returns:

None, as the function modifies the matrix in place.

Add a logo string.

Args:

logo: The logo string to be added. If not provided, the logo will be set to an empty string.

Returns:

None, as the function modifies the matrix in place.

str(with_time: bool = False) str[源代码]

Return the final LaTeX source code representation of the matrix.

Args:

with_time: A boolean flag indicating whether to include timing information in the output.

Returns:

str: The LaTeX source code as a string. This method can be called at any time to obtain the current state of the matrix.

class pyqpanda.MPSQVM[源代码]

Bases: QuantumMachine

quantum matrix product state machine class

add_single_noise_model(arg0: NoiseModel, arg1: GateType, arg2: float) None[源代码]
add_single_noise_model(arg0: NoiseModel, arg1: GateType, arg2: float, arg3: float, arg4: float) None

Add a noise model to a specific gate with multiple error rates.

Args:

noise_model: NOISE_MODEL, the type of noise model to apply.

gate_type: GateType, the type of gate affected by the noise.

error_rate_1: float, the first error rate.

error_rate_2: float, the second error rate.

error_rate_3: float, the third error rate.

Returns:

None.

get_prob_dict(qubit_list: QVec, select_max: int = -1) Dict[str, float][源代码]

Get pmeasure result as dict.

Args:

qubit_list: List of qubits for pmeasure.

select_max: Maximum number of returned elements in the result tuple; should be in [-1, 1<<len(qubit_list)]. Default is -1, meaning no limit.

Returns:

Measure result of the quantum machine.

get_prob_list(qubit_list: QVec, select_max: int = -1) List[float][源代码]

Get pmeasure result as list.

Args:

qubit_list: List of qubits for pmeasure.

select_max: Maximum number of returned elements in the result tuple; should be in [-1, 1<<len(qubit_list)]. Default is -1, meaning no limit.

Returns:

Measure result of the quantum machine.

get_prob_tuple_list(qubit_list: QVec, select_max: int = -1) List[Tuple[int, float]][源代码]

Get pmeasure result as list.

Args:

qubit_list: List of qubits for pmeasure.

select_max: Maximum number of returned elements in the result tuple; should be in [-1, 1<<len(qubit_list)]. Default is -1, meaning no limit.

Returns:

Measure result of the quantum machine.

pmeasure(qubit_list: QVec, select_max: int = -1) List[Tuple[int, float]][源代码]

Get the probability distribution over qubits.

Args:

qubit_list: List of qubits to measure.

select_max: Maximum number of returned elements in the result tuple; should be in [-1, 1<<len(qubit_list)]. Default is -1, which means no limit.

Returns:

Measure result of the quantum machine in tuple form.

pmeasure_bin_index(program: QProg, string: str) complex[源代码]

Get pmeasure bin index quantum state amplitude.

Args:

string: Bin string.

Returns:

Complex: Bin amplitude.

pmeasure_bin_subset(program: QProg, string_list: List[str]) List[complex][源代码]

Get pmeasure quantum state amplitude subset.

Args:

list: List of bin state strings.

Returns:

List: Bin amplitude result list.

pmeasure_dec_index(program: QProg, string: str) complex[源代码]

Get pmeasure decimal index quantum state amplitude.

Args:

string: Decimal string.

Returns:

Complex: Decimal amplitude.

pmeasure_dec_subset(program: QProg, string_list: List[str]) List[complex][源代码]

Get pmeasure quantum state amplitude subset.

Args:

list: List of decimal state strings.

Returns:

List: Decimal amplitude result list.

pmeasure_no_index(qubit_list: QVec) List[float][源代码]

Get the probability distribution over qubits.

Args:

qubit_list: List of qubits to measure.

Returns:

Measure result of the quantum machine in list form.

prob_run_dict(program: QProg, qubit_list: QVec, select_max: int = -1) Dict[str, float][源代码]

Run quantum program and get pmeasure result as dict. Args:

program: Quantum program to run.

qubit_list: List of qubits for pmeasure.

select_max: Maximum number of returned elements in the result; should be in [-1, 1<<len(qubit_list)]. Default is -1, meaning no limit.

Returns:

Measure result of the quantum machine.

prob_run_list(program: QProg, qubit_list: QVec, select_max: int = -1) List[float][源代码]

Run quantum program and get pmeasure result as list.

Args:

program: Quantum program to run.

qubit_list: List of qubits for pmeasure.

select_max: Maximum number of returned elements in the result; should be in [-1, 1<<len(qubit_list)]. Default is -1, meaning no limit.

Returns:

Measure result of the quantum machine.

prob_run_tuple_list(program: QProg, qubit_list: QVec, select_max: int = -1) List[Tuple[int, float]][源代码]

Run quantum program and get pmeasure result as tuple list.

Args:

program: Quantum program to run.

qubit_list: List of qubits for pmeasure.

select_max: Maximum number of returned elements in the result tuple; should be in [-1, 1<<len(qubit_list)]. Default is -1, meaning no limit.

Returns:

Measure result of the quantum machine.

quick_measure(qubit_list: QVec, shots: int) Dict[str, int][源代码]

Quick measure.

Args:

qubit_list: List of qubits to measure.

shots: The number of repetitions for the measurement operation.

Returns:

Result of the quantum program.

set_measure_error(arg0: NoiseModel, arg1: float) None[源代码]
set_measure_error(arg0: NoiseModel, arg1: float, arg2: float, arg3: float) None

Set the measurement error with multiple error rates for the specified noise model.

Args:

noise_model: The type of noise model to apply.

error_rate1: First error rate.

error_rate2: Second error rate.

error_rate3: Third error rate.

set_mixed_unitary_error(arg0: GateType, arg1: List[List[complex]], arg2: List[QVec]) None[源代码]
set_mixed_unitary_error(arg0: GateType, arg1: List[List[complex]], arg2: List[float], arg3: List[QVec]) None
set_mixed_unitary_error(arg0: GateType, arg1: List[List[complex]]) None
set_mixed_unitary_error(arg0: GateType, arg1: List[List[complex]], arg2: List[float]) None

Set mixed unitary errors with associated probabilities for the specified gate type.

Args:

gate_type: Type of gate affected by the error.

unitary_errors: List of unitary error matrices.

probabilities: Probabilities associated with each unitary error.

set_noise_model(arg0: NoiseModel, arg1: GateType, arg2: float) None[源代码]
set_noise_model(arg0: NoiseModel, arg1: GateType, arg2: float, arg3: List[QVec]) None
set_noise_model(arg0: NoiseModel, arg1: GateType, arg2: float, arg3: float, arg4: float) None
set_noise_model(arg0: NoiseModel, arg1: GateType, arg2: float, arg3: float, arg4: float, arg5: List[QVec]) None

Set the noise model for the quantum simulation with specific noise levels and qubits.

Args:

noise_model: Type of noise model (bit-flip, phase-flip, etc.).

gate_type: Type of gate affected by the noise.

noise_level_1: First noise level to apply.

noise_level_2: Second noise level to apply.

noise_level_3: Third noise level to apply.

qubits: List of qubits to which the noise model will be applied.

set_readout_error(readout_params: List[List[float]], qubits: QVec) None[源代码]

Set readout error parameters for the specified qubits.

Args:

readout_params: Parameters defining the readout errors.

qubits: List of qubits to which the readout errors apply.

set_reset_error(reset_0_param: float, reset_1_param: float) None[源代码]

Set the reset error for the quantum state.

Args:

reset_0_param: float, error probability for resetting qubit to 0.

reset_1_param: float, error probability for resetting qubit to 1.

Returns:

None.

set_rotation_error(param: float) None[源代码]

Set the rotation error parameters.

Args:

param: The parameters defining the rotation error.

Returns:

A reference to the updated instance of the class.

class pyqpanda.MomentumOptimizer(arg0: var, arg1: float, arg2: float)[源代码]

variational quantum MomentumOptimizer

get_loss() float[源代码]
get_variables() List[var][源代码]
minimize(arg0: float, arg1: float) Optimizer[源代码]
run(arg0: List[var], arg1: int) bool[源代码]
class pyqpanda.NodeInfo[源代码]
class pyqpanda.NodeInfo(iter: NodeIter, target_qubits: QVec, control_qubits: QVec, type: int, dagger: bool)

Detailed information of a QProg node

m_cbits: List[int]
m_control_qubits: QVec
m_gate_type: GateType
m_is_dagger: bool
m_iter: NodeIter
m_name: str
m_node_type: NodeType
m_params: List[float]
m_target_qubits: QVec
reset() None[源代码]

Reset the NodeInfo instance to its initial state. This function clears any current data in the NodeInfo and prepares it for reuse.

Args:

None

Returns:

None

class pyqpanda.NodeIter[源代码]

quantum node iter

get_next() NodeIter[源代码]

Get the next node iterator.

Args:

None

Returns:

The next NodeIter instance.

get_node_type() NodeType[源代码]

Retrieve the type of the current node.

Args:

None

Returns:

The type of the node.

get_pre() NodeIter[源代码]

Get the previous node iterator.

Args:

None

Returns:

The previous NodeIter instance.

class pyqpanda.NodeType(value: int)[源代码]

quantum node type

Members:

NODE_UNDEFINED

GATE_NODE

CIRCUIT_NODE

PROG_NODE

MEASURE_GATE

WHILE_START_NODE

QIF_START_NODE

CLASS_COND_NODE

RESET_NODE

CIRCUIT_NODE: ClassVar[NodeType] = Ellipsis
CLASS_COND_NODE: ClassVar[NodeType] = Ellipsis
GATE_NODE: ClassVar[NodeType] = Ellipsis
MEASURE_GATE: ClassVar[NodeType] = Ellipsis
NODE_UNDEFINED: ClassVar[NodeType] = Ellipsis
PROG_NODE: ClassVar[NodeType] = Ellipsis
QIF_START_NODE: ClassVar[NodeType] = Ellipsis
RESET_NODE: ClassVar[NodeType] = Ellipsis
WHILE_START_NODE: ClassVar[NodeType] = Ellipsis
property name: str
property value: int
class pyqpanda.Noise[源代码]

Quantum machine for noise simulation

add_mixed_unitary_error(gate_types: GateType, unitary_matrices: List[List[complex]], probs: List[float]) None[源代码]
add_mixed_unitary_error(gate_types: GateType, unitary_matrices: List[List[complex]], probs: List[float], qubits: QVec) None
add_mixed_unitary_error(gate_types: GateType, unitary_matrices: List[List[complex]], probs: List[float], qubits: List[QVec]) None

Add mixed unitary errors to specified gate types for multiple qubits.

Args:

gate_types: The type of gates to which the mixed unitary errors apply.

unitary_matrices: A vector of unitary matrices representing the errors.

probs: A vector of probabilities corresponding to each unitary matrix.

qubits: A vector of QVec instances indicating which qubits the errors affect.

Returns:

None.

add_noise_model(noise_model: NoiseModel, gate_type: GateType, prob: float) None[源代码]
add_noise_model(noise_model: NoiseModel, gate_types: List[GateType], prob: float) None
add_noise_model(noise_model: NoiseModel, gate_type: GateType, prob: float, qubits: QVec) None
add_noise_model(noise_model: NoiseModel, gate_types: List[GateType], prob: float, qubits: QVec) None
add_noise_model(noise_model: NoiseModel, gate_type: GateType, prob: float, qubits: List[QVec]) None
add_noise_model(noise_model: NoiseModel, gate_type: GateType, t1: float, t2: float, t_gate: float) None
add_noise_model(noise_model: NoiseModel, gate_types: List[GateType], t1: float, t2: float, t_gate: float) None
add_noise_model(noise_model: NoiseModel, gate_type: GateType, t1: float, t2: float, t_gate: float, qubits: QVec) None
add_noise_model(noise_model: NoiseModel, gate_types: List[GateType], t1: float, t2: float, t_gate: float, qubits: QVec) None
add_noise_model(noise_model: NoiseModel, gate_type: GateType, t1: float, t2: float, t_gate: float, qubits: List[QVec]) None

Add a noise model to a specific gate with specified time parameters and targeted qubits.

Args:

noise_model: An instance of NOISE_MODEL to be added.

gate_type: The type of gate to which the noise model applies.

t1: The time constant for relaxation (T1).

t2: The time constant for dephasing (T2).

t_gate: The duration of the gate operation.

qubits: A vector of vectors of qubit indices that the noise affects.

Returns:

None.

set_measure_error(noise_model: NoiseModel, prob: float, qubits: QVec = ...) None[源代码]
set_measure_error(noise_model: NoiseModel, t1: float, t2: float, t_gate: float, qubits: QVec = ...) None

Set the measurement error using time parameters for the specified qubits.

Args:

noise_model: An instance of NOISE_MODEL to be used.

t1: The time constant for relaxation (T1).

t2: The time constant for dephasing (T2).

t_gate: The duration of the gate operation.

qubits: A vector of qubit indices to which the measurement error applies. Defaults to an empty QVec.

Returns:

None.

set_readout_error(prob_list: List[List[float]], qubits: QVec = ...) None[源代码]

Set readout errors for specified qubits.

Args:

prob_list: A list of probabilities for readout errors.

qubits: A vector of qubit indices that the readout errors apply to (default is all qubits).

Returns:

None.

set_reset_error(p0: float, p1: float, qubits: QVec) None[源代码]

Set reset errors for specified qubits.

Args:

p0: The probability of resetting to state |0>.

p1: The probability of resetting to state |1>.

qubits: A vector of qubit indices that the reset errors apply to.

Returns:

None.

set_rotation_error(error: float) None[源代码]

Set rotation error for gates.

Args:

error: The error model for rotation operations.

Returns:

None.

class pyqpanda.NoiseModel(value: int)[源代码]

noise model type

Members:

DAMPING_KRAUS_OPERATOR

DECOHERENCE_KRAUS_OPERATOR

DEPHASING_KRAUS_OPERATOR

PAULI_KRAUS_MAP

BITFLIP_KRAUS_OPERATOR

DEPOLARIZING_KRAUS_OPERATOR

BIT_PHASE_FLIP_OPRATOR

PHASE_DAMPING_OPRATOR

BITFLIP_KRAUS_OPERATOR: ClassVar[NoiseModel] = Ellipsis
BIT_PHASE_FLIP_OPRATOR: ClassVar[NoiseModel] = Ellipsis
DAMPING_KRAUS_OPERATOR: ClassVar[NoiseModel] = Ellipsis
DECOHERENCE_KRAUS_OPERATOR: ClassVar[NoiseModel] = Ellipsis
DEPHASING_KRAUS_OPERATOR: ClassVar[NoiseModel] = Ellipsis
DEPOLARIZING_KRAUS_OPERATOR: ClassVar[NoiseModel] = Ellipsis
PAULI_KRAUS_MAP: ClassVar[NoiseModel] = Ellipsis
PHASE_DAMPING_OPRATOR: ClassVar[NoiseModel] = Ellipsis
property name: str
property value: int
class pyqpanda.NoiseQVM[源代码]

Bases: QuantumMachine

quantum machine class for simulate noise prog

initQVM(arg0: dict) None[源代码]

init quantum virtual machine

init_qvm(json_config: dict) None[源代码]
init_qvm() None

init quantum virtual machine

set_max_threads(size: int) None[源代码]

Set the maximum number of threads for the noise quantum virtual machine (NoiseQVM).

Args:

size: The maximum number of threads to utilize.

Returns:

None: This method does not return a value.

set_measure_error(model: NoiseModel, prob: float, qubits: QVec = ...) None[源代码]
set_measure_error(model: NoiseModel, T1: float, T2: float, t_gate: float, qubits: QVec = ...) None

Set the measurement error model in the quantum virtual machine with specific error parameters.

Args:

model: The noise model to be applied for measurement errors.

T1: A double representing the relaxation time constant for the qubits.

T2: A double representing the dephasing time constant for the qubits.

t_gate: A double representing the time duration of the gate operation.

qubits: A specific qubit vector (QVec) for which the measurement error applies (default is an empty QVec).

Returns:

None, as the function configures the measurement error model in place for the specified qubit vector.

set_mixed_unitary_error(arg0: GateType, arg1: List[List[complex]], arg2: List[float]) None[源代码]
set_mixed_unitary_error(arg0: GateType, arg1: List[List[complex]], arg2: List[float], arg3: QVec) None
set_mixed_unitary_error(arg0: GateType, arg1: List[List[complex]], arg2: List[float], arg3: List[QVec]) None

Set a mixed unitary error model for a specific gate type in the quantum virtual machine, targeting multiple qubits.

Args:

gate_type: The type of gate for which the mixed unitary error model applies.

unitary_ops: A vector of unitary operations (QStat) representing the error model.

probabilities: A vector of doubles representing the probabilities associated with each unitary operation.

qubit_groups: A vector of qubit vectors (QVec) specifying the qubits affected by the error model.

Returns:

None, as the function configures the mixed unitary error model in place for the specified gate type and qubit groups.

set_noise_model(arg0: NoiseModel, arg1: GateType, arg2: float) None[源代码]
set_noise_model(arg0: NoiseModel, arg1: List[GateType], arg2: float) None
set_noise_model(arg0: NoiseModel, arg1: GateType, arg2: float, arg3: QVec) None
set_noise_model(arg0: NoiseModel, arg1: List[GateType], arg2: float, arg3: QVec) None
set_noise_model(arg0: NoiseModel, arg1: GateType, arg2: float, arg3: List[QVec]) None
set_noise_model(arg0: NoiseModel, arg1: GateType, arg2: float, arg3: float, arg4: float) None
set_noise_model(arg0: NoiseModel, arg1: List[GateType], arg2: float, arg3: float, arg4: float) None
set_noise_model(arg0: NoiseModel, arg1: GateType, arg2: float, arg3: float, arg4: float, arg5: QVec) None
set_noise_model(arg0: NoiseModel, arg1: List[GateType], arg2: float, arg3: float, arg4: float, arg5: QVec) None
set_noise_model(arg0: NoiseModel, arg1: GateType, arg2: float, arg3: float, arg4: float, arg5: List[QVec]) None

Set the noise model for a specific gate type with multiple noise parameters affecting a vector of qubit vectors in the quantum virtual machine.

Args:

noise_model: The noise model to be applied.

gate_type: The type of gate for which the noise model is relevant.

noise_level1: A double representing the first level of noise to apply.

noise_level2: A double representing the second level of noise to apply.

noise_level3: A double representing the third level of noise to apply.

qubits_list: A vector of qubit vectors (QVec) affected by the noise model.

Returns:

None, as the function configures the noise model in place for the specified gate type and qubit vectors.

set_readout_error(probs_list: List[List[float]], qubits: QVec = ...) None[源代码]

Set a readout error model for the quantum virtual machine.

Args:

probs_list: A list of probabilities for readout errors associated with each qubit.

qubits: A vector of qubits (QVec) for which the readout error model applies. Defaults to all qubits if not specified.

Returns:

None, as this function configures the readout error model in place for the specified qubits.

set_reset_error(p0: float, p1: float, qubits: QVec = ...) None[源代码]

Set a reset error model for the quantum virtual machine.

Args:

p0: Probability of the qubit resetting to state 0.

p1: Probability of the qubit resetting to state 1.

qubits: A vector of qubits (QVec) for which the reset error model applies. Defaults to all qubits if not specified.

Returns:

None, as this function configures the reset error model in place for the specified qubits.

set_rotation_error(arg0: float) None[源代码]

Set a rotation error model for the quantum virtual machine.

Args:

None specified in the function signature, but typically would include error parameters for the rotation.

Returns:

None, as this function configures the rotation error model in place for the quantum operations.

class pyqpanda.Optimizer(*args, **kwargs)[源代码]

variational quantum Optimizer class

get_loss() float[源代码]
get_variables() List[var][源代码]
run(arg0: List[var], arg1: int) bool[源代码]
class pyqpanda.OptimizerFactory[源代码]

quantum OptimizerFactory class

makeOptimizer() AbstractOptimizer[源代码]
makeOptimizer() AbstractOptimizer

Create an optimizer using its name.

Args:

optimizer_name: A string representing the name of the desired optimizer.

Returns:

An instance of the created optimizer.

class pyqpanda.OptimizerMode(value: int)[源代码]

variational quantum OptimizerMode

Members:

property name: str
property value: int
class pyqpanda.OptimizerType(value: int)[源代码]

quantum OptimizerType

Members:

NELDER_MEAD

POWELL

GRADIENT

GRADIENT: ClassVar[OptimizerType] = Ellipsis
NELDER_MEAD: ClassVar[OptimizerType] = Ellipsis
POWELL: ClassVar[OptimizerType] = Ellipsis
property name: str
property value: int
class pyqpanda.OriginCMem[源代码]

origin quantum cmem

Allocate_CBit() CBit[源代码]
Allocate_CBit(cbit_num: int) CBit

Allocate a specified number of classical bits.

Args:

cbit_num: The number of classical bits to allocate.

Returns:

A reference to the allocated classical bits.

Free_CBit(cbit: CBit) None[源代码]

Free a previously allocated classical bit.

Args:

cbit: The classical bit to be freed.

cAlloc() CBit[源代码]
cAlloc(arg0: int) CBit

Allocate memory for classical bits. This method initializes or resets the memory allocation for classical bits.

cAlloc_many(count: int) List[ClassicalCondition][源代码]

Allocate memory for multiple classical bits.

Args:

count: The number of classical bits to allocate.

cFree(classical_cond: ClassicalCondition) None[源代码]

Free the allocated memory for a classical condition.

Args:

classical_cond: The classical condition to be freed.

cFree_all(classical_cond_list: List[ClassicalCondition]) None[源代码]
cFree_all() None

Free all allocated classical memory. This method releases all memory associated with classical conditions.

clearAll() None[源代码]

Clear all allocated classical bits. This method releases all resources associated with classical bits.

getIdleMem() int[源代码]

Get the amount of idle memory currently available.

Returns:

The amount of idle memory in terms of qubits.

getMaxMem() int[源代码]

Get the maximum memory capacity.

Returns:

The maximum memory capacity in terms of qubits.

get_allocate_cbits() List[ClassicalCondition][源代码]

Retrieve allocated classical bits. Returns a vector of ClassicalCondition representing the allocated cbits.

get_capacity() int[源代码]

Get the capacity of the memory.

Returns:

The total capacity of the memory in terms of qubits.

get_cbit_by_addr(cbit_addr: int) CBit[源代码]

Get a classical bit by its address.

Args:

cbit_addr: The address of the classical bit.

Returns:

A reference to the classical bit associated with the given address

.

set_capacity(arg0: int) None[源代码]

Set the capacity of the memory.

Args:

capacity: The new capacity for the memory in terms of qubits.

class pyqpanda.OriginCollection[源代码]
class pyqpanda.OriginCollection(file_name: str)
class pyqpanda.OriginCollection(arg0: OriginCollection)

A relatively free data collection class for saving data

getFilePath() str[源代码]

Retrieve the file path associated with the OriginCollection. This function returns the path to the file linked to the collection.

Returns:

A string containing the file path.

getJsonString() str[源代码]

Retrieve the JSON string representation of the OriginCollection. This function converts the collection's data into a JSON format string.

Returns:

A string containing the JSON representation of the collection.

getKeyVector() List[str][源代码]

Retrieve the vector of keys associated with the OriginCollection. This function returns a vector containing all the keys in the collection.

Returns:

A vector of keys.

getValue(key_name: str) List[str][源代码]

Get the value associated with the specified key name. This function retrieves the value stored in the OriginCollection for the given key.

Args:

key_name: The name of the key whose value is to be retrieved.

Returns:

The value associated with the specified key.

getValueByKey(key_value: str) str[源代码]
getValueByKey(key_value: int) str

Retrieve the value associated with a specified key. This function returns the value that corresponds to the given key.

Args:

key_value: The key for which to retrieve the associated value.

Returns:

The value associated with the specified key.

insertValue(key: str, *args) None[源代码]

Insert values into the OriginCollection under the specified key. This function adds the first value associated with the provided key and then inserts additional values from the provided arguments.

Args:

key: The key under which to insert the values.

args: A variable number of values to be inserted.

Returns:

None.

open(file_name: str) bool[源代码]

Open and read the JSON file at the specified path. This function reads the contents of the JSON file provided.

Args:

file_name: The path to the JSON file to be read.

Returns:

None.

setNames(*args) None[源代码]

Set names in the OriginCollection. This function accepts a variable number of name arguments and sets them in the OriginCollection.

Args:

args: A variable number of name strings to be set.

Returns:

None.

write() bool[源代码]

Write the current data to a JSON file. This function saves the current contents to a specified JSON file.

Args:

None.

Returns:

None.

class pyqpanda.OriginQubitPool[源代码]

quantum qubit pool

allocateQubitThroughPhyAddress(qubit_addr: int) Qubit[源代码]

Allocate a qubit using its physical address.

Args:

qubit_addr: The physical address of the qubit to allocate.

Returns:

A reference to the allocated qubit.

allocateQubitThroughVirAddress(qubit_num: int) Qubit[源代码]

Allocate a qubit using its virtual address.

Args:

qubit_num: The virtual address of the qubit to allocate.

Returns:

A reference to the allocated qubit.

clearAll() None[源代码]

Clear all qubits from the OriginQubitPool. This method removes all qubits, resetting the pool to its initial state.

getIdleQubit() int[源代码]

Retrieve an idle qubit from the OriginQubitPool.

Returns:

An idle qubit if available, otherwise may return a null reference or indicate no idle qubits.

getMaxQubit() int[源代码]

Retrieve the maximum qubit from the OriginQubitPool.

Returns:

The maximum qubit available in the pool.

getPhysicalQubitAddr(qubit: Qubit) int[源代码]

Retrieve the physical address of a specified qubit.

Args:

qubit: The qubit for which to retrieve the physical address.

Returns:

The physical address of the specified qubit.

getVirtualQubitAddress(qubit: Qubit) int[源代码]

Retrieve the virtual address of a specified qubit.

Args:

qubit: The qubit for which to retrieve the virtual address.

Returns:

The virtual address of the specified qubit.

get_allocate_qubits() QVec[源代码]

Retrieve currently allocated qubits.

Returns:

A reference to the vector of currently allocated qubits.

get_capacity() int[源代码]

Get the capacity of the OriginQubitPool.

Returns:

An integer representing the capacity of the pool.

get_max_usedqubit_addr() int[源代码]

Retrieve the address of the maximum used qubit in the OriginQubitPool.

Returns:

The address of the maximum used qubit, or an indication if no qubits are in use.

get_qubit_by_addr(qubit_addr: int) Qubit[源代码]

Retrieve a qubit from the pool using its address.

Args:

qubit_addr: The address of the qubit to retrieve.

Returns:

A reference to the requested qubit.

qAlloc() Qubit[源代码]

Allocate a qubit.

Returns:

A reference to the allocated qubit.

qAlloc_many(qubit_num: int) List[Qubit][源代码]

Allocate a list of qubits.

Args:

qubit_num: The number of qubits to allocate.

Returns:

A reference to the vector of allocated qubits.

qFree(arg0: Qubit) None[源代码]

Free a previously allocated qubit.

Args:

qubit: The qubit to be freed.

qFree_all(arg0: QVec) None[源代码]
qFree_all() None

Free all allocated qubits in the pool. This method releases all qubits that have been allocated previously.

set_capacity(arg0: int) None[源代码]

Set the capacity of the OriginQubitPool.

Args:

capacity: An integer representing the new capacity to be set.

class pyqpanda.PartialAmpQVM[源代码]

Bases: QuantumMachine

quantum partial amplitude machine class

get_prob_dict(arg0: QVec) Dict[str, float][源代码]

Get the measurement results as a dictionary.

Args:

qubit_list: A list of qubits to measure.

Returns:

A dictionary containing the measurement results of the quantum machine.

init_qvm(backend_type: int = 0) None[源代码]
pmeasure_bin_index(bin_index: str) complex[源代码]

Get the amplitude of the quantum state for the specified bin index.

Args:

bin_index: A string representing the bin.

Returns:

A complex number representing the amplitude of the bin.

pmeasure_dec_index(dec_index: str) complex[源代码]

Get the amplitude of the quantum state for the specified decimal index.

Args:

dec_index: A string representing the decimal.

Returns:

A complex number representing the amplitude of the decimal.

pmeasure_subset(index_list: List[str]) Dict[str, complex][源代码]

Get the amplitudes of the quantum state for a subset of indices.

Args:

index_list: A list of strings representing decimal states.

Returns:

A list of complex numbers representing the amplitude results.

prob_run_dict(arg0: QProg, arg1: QVec) Dict[str, float][源代码]

Run the quantum program and get the measurement results as a dictionary.

Args:

qprog: The quantum program to execute.

qubit_list: A list of qubits to measure.

Returns:

A dictionary containing the measurement results of the quantum machine.

run(qprog: QProg, noise_model: Noise = NoiseModel()) None[源代码]
run(qprog: QCircuit, noise_model: Noise = NoiseModel()) None

Run the quantum program.

Args:

qprog: The quantum circuit to execute.

noise_model: An optional noise model (default is NoiseModel()).

Returns:

None.

class pyqpanda.PhysicalQubit(*args, **kwargs)[源代码]

Physical Qubit abstract class

getQubitAddr() int[源代码]

Retrieve the address of the physical qubit.

This function returns the address of the physical qubit associated with the instance.

Args:

None

Returns:

The address of the physical qubit.

class pyqpanda.PilotNoiseParams(*args, **kwargs)[源代码]

pliot noise simulate params

double_gate_param: float
double_p2: float
double_pgate: float
noise_model: str
single_gate_param: float
single_p2: float
single_pgate: float
class pyqpanda.ProgCount[源代码]
double_gate_layer_num: int
double_gate_num: int
gate_num: int
layer_num: int
multi_control_gate_num: int
node_num: int
selected_gate_nums: Dict[GateType, int]
single_gate_layer_num: int
single_gate_num: int
class pyqpanda.QCircuit[源代码]
class pyqpanda.QCircuit(arg0: NodeIter)

quantum circuit node

begin() NodeIter[源代码]

Get an iterator to the first node in the circuit.

Returns:

Iterator: An iterator pointing to the first node.

control(control_qubits: QVec) QCircuit[源代码]

Apply a control operation to the circuit.

Args:

control_qubits (list): A list of qubits that will act as control qubits.

Returns:

QCircuit: The circuit with the control operation applied.

dagger() QCircuit[源代码]

Compute the adjoint (dagger) of the circuit.

Returns:

QCircuit: The adjoint of this circuit.

end() NodeIter[源代码]

Get an iterator to the end of the circuit.

Returns:

Iterator: An iterator pointing to the end of the nodes.

head() NodeIter[源代码]

Get an iterator to the head of the circuit.

Returns:

Iterator: An iterator pointing to the head node.

insert(arg0: QCircuit) QCircuit[源代码]
insert(arg0: QGate) QCircuit

Insert a QGate into this circuit.

Args:

gate (QGate): The gate to be inserted.

Returns:

QCircuit: A reference to this circuit after the gate insertion.

is_empty() bool[源代码]

Check if the circuit is empty.

Returns:

bool: True if the circuit has no gates; otherwise, False.

last() NodeIter[源代码]

Get an iterator to the last node in the circuit.

Returns:

Iterator: An iterator pointing to the last node.

set_control(control_qubits: QVec) None[源代码]

Set control qubits for the circuit.

Args:

control_qubits (list): A list of qubits to be set as control qubits.

set_dagger(arg0: bool) None[源代码]

Set the dagger property of the circuit.

This method modifies the circuit to represent its adjoint.

class pyqpanda.QCircuitOPtimizerMode(value: int)[源代码]

Quantum circuit optimize mode

Members:

Merge_H_X

Merge_U3

Merge_RX

Merge_RY

Merge_RZ

Merge_H_X: ClassVar[QCircuitOPtimizerMode] = Ellipsis
Merge_RX: ClassVar[QCircuitOPtimizerMode] = Ellipsis
Merge_RY: ClassVar[QCircuitOPtimizerMode] = Ellipsis
Merge_RZ: ClassVar[QCircuitOPtimizerMode] = Ellipsis
Merge_U3: ClassVar[QCircuitOPtimizerMode] = Ellipsis
property name: str
property value: int
class pyqpanda.QError(value: int)[源代码]

Quantum QError Type

Members:

UndefineError

qErrorNone

qParameterError

qubitError

loadFileError

initStateError

destroyStateError

setComputeUnitError

runProgramError

getResultError

getQStateError

UndefineError: ClassVar[QError] = Ellipsis
destroyStateError: ClassVar[QError] = Ellipsis
getQStateError: ClassVar[QError] = Ellipsis
getResultError: ClassVar[QError] = Ellipsis
initStateError: ClassVar[QError] = Ellipsis
loadFileError: ClassVar[QError] = Ellipsis
qErrorNone: ClassVar[QError] = Ellipsis
qParameterError: ClassVar[QError] = Ellipsis
qubitError: ClassVar[QError] = Ellipsis
runProgramError: ClassVar[QError] = Ellipsis
setComputeUnitError: ClassVar[QError] = Ellipsis
property name: str
property value: int
class pyqpanda.QGate(arg0: NodeIter)[源代码]

quantum gate node

control(control_qubits: QVec) QGate[源代码]

Get a controlled quantum gate based on the current QGate instance. This function creates a control version of the quantum gate using the specified control qubits.

Args:

control_qubits: A list of qubits that serve as control qubits for the gate.

Returns:

A new QGate instance representing the controlled gate.

dagger() QGate[源代码]
dagger() Any
gate_matrix() List[complex][源代码]

Get the matrix representation of the quantum gate.

Args:

qgate: The quantum gate instance.

Returns:

QStat: The matrix representation of the quantum gate.

gate_type() int[源代码]

Get the type of the quantum gate.

Args:

qgate: The quantum gate instance.

Returns:

The type of the quantum gate.

get_control_qubit_num() int[源代码]

Retrieve the number of control qubits for the QGate instance. This function returns the count of qubits that act as control qubits for the gate.

Args:

None

Returns:

An integer representing the number of control qubits.

get_control_qubits(control_qubits: QVec) int[源代码]

Get the control vector from the current quantum gate node.

Args:

control_qubits: The control qubits output vector.

Returns:

int: Size of the control qubits.

get_qubits(qubits: QVec) int[源代码]

Get the qubit vector inside this quantum gate.

Args:

qubits: The qubits output vector.

Returns:

int: Size of the qubits.

get_target_qubit_num() int[源代码]

Retrieve the number of target qubits for the QGate instance. This function returns the count of qubits that the quantum gate affects.

Args:

None

Returns:

An integer representing the number of target qubits.

is_dagger() bool[源代码]

Check if the QGate instance is a dagger (Hermitian conjugate) of another gate. This function determines whether the current gate is the adjoint of its corresponding gate.

Args:

None

Returns:

A boolean indicating whether the current gate is a dagger.

set_control(arg0: QVec) bool[源代码]

Set the control qubits for the QGate instance. This function specifies which qubits will act as control qubits for the gate.

Args:

control_qubits: A list of qubits that will serve as control qubits.

Returns:

None

set_dagger(arg0: bool) bool[源代码]

Set the QGate instance to be a dagger (Hermitian conjugate) of another gate. This function configures the current gate to represent its adjoint.

Args:

None

Returns:

None

class pyqpanda.QITE[源代码]

quantum imaginary time evolution

exec(is_optimization: bool = True) int[源代码]
get_all_exec_result(reverse: bool = False, sort: bool = False) List[List[Tuple[int, float]]][源代码]
get_ansatz_list(*args, **kwargs) Any[源代码]
get_ansatz_theta_list() List[List[float]][源代码]
get_arbitary_cofficient(arg0: float) None[源代码]
get_exec_result(reverse: bool = False, sort: bool = False) List[Tuple[int, float]][源代码]
get_result() List[Tuple[int, float]][源代码]
set_Hamiltonian(arg0) None[源代码]
set_ansatz_gate(arg0) None[源代码]
set_convergence_factor_Q(arg0: float) None[源代码]
set_delta_tau(arg0: float) None[源代码]
set_iter_num(arg0: int) None[源代码]
set_log_file(arg0: str) None[源代码]
set_para_update_mode(arg0: UpdateMode) None[源代码]
set_pauli_matrix(arg0: QuantumMachine, arg1: numpy.ndarray[numpy.float64[m, n]]) None[源代码]
set_quantum_machine_type(arg0: QMachineType) None[源代码]
set_upthrow_num(arg0: int) None[源代码]
class pyqpanda.QIfProg(arg0: NodeIter)[源代码]
class pyqpanda.QIfProg(classical_cond: ClassicalCondition, true_branch_qprog: QProg)
class pyqpanda.QIfProg(classical_cond: ClassicalCondition, true_branch_qprog: QProg, false_branch_qprog: QProg)

quantum if prog node

get_classical_condition() ClassicalCondition[源代码]

Retrieve the classical condition associated with the quantum if program.

Returns:

The classical condition object used in the if statement.

get_false_branch() QProg[源代码]

Get the quantum program corresponding to the false branch.

Returns:

QProg: The quantum program for the false branch, or an empty QProg if null.

Raises:

runtime_error: If the false branch has an incorrect node type.

get_true_branch() QProg[源代码]

Get the quantum program corresponding to the true branch.

Returns:

QProg: The quantum program for the true branch.

Raises:

runtime_error: If the true branch is null or has an incorrect node type.

class pyqpanda.QMachineType(value: int)[源代码]

Quantum machine type

Members:

CPU

GPU

CPU_SINGLE_THREAD

NOISE

CPU: ClassVar[QMachineType] = Ellipsis
CPU_SINGLE_THREAD: ClassVar[QMachineType] = Ellipsis
GPU: ClassVar[QMachineType] = Ellipsis
NOISE: ClassVar[QMachineType] = Ellipsis
property name: str
property value: int
class pyqpanda.QMeasure(arg0: NodeIter)[源代码]

quantum measure node

class pyqpanda.QOperator[源代码]
class pyqpanda.QOperator(arg0: QGate)
class pyqpanda.QOperator(arg0: QCircuit)

quantum operator class

get_matrix() List[complex][源代码]

Retrieve the matrix representation of the QOperator.

Args:

None

Returns:

The matrix representation of the QOperator.

to_instruction(arg0: str) str[源代码]

Convert the QOperator to an instruction representation.

Args:

None

Returns:

The instruction representation of the QOperator.

class pyqpanda.QOptimizationResult(arg0: str, arg1: int, arg2: int, arg3: str, arg4: float, arg5: List[float])[源代码]

quantum QOptimizationResult class

fcalls: int
fun_val: float
iters: int
key: str
message: str
para: List[float]
class pyqpanda.QPilotOSService(machine_type: str = 'CPU')[源代码]

Bases: QuantumMachine

origin quantum pilot OS Machine

build_expectation_task_msg(prog: QProg, hamiltonian: str, qubits: List[int] = [], shot: int = 1000, chip_id: int = 33554432, is_amend: bool = True, is_mapping: bool = True, is_optimization: bool = True, specified_block: List[int] = [], task_describe: str = '') str[源代码]

use C++ to build a expectation task body.

build_init_msg(api_key: str) str[源代码]
build_qst_task_msg(prog: QProg, shot: int = 1000, chip_id: int = 33554432, is_amend: bool = True, is_mapping: bool = True, is_optimization: bool = True, specified_block: List[int] = [], task_describe: str = '') str[源代码]

use C++ to build ordinary qst task msg body

build_query_msg(task_id: str) str[源代码]
build_task_msg(prog: List[QProg], shot: int, chip_id: int, is_amend: bool, is_mapping: bool, is_optimization: bool, specified_block: List[int], task_describe: str) str[源代码]

use c++ to build real chip measure task msg body.

cAlloc() ClassicalCondition[源代码]
cAlloc(cbit: int) ClassicalCondition

Allocate a cbit

cAlloc_many(cbit_num: int) List[ClassicalCondition][源代码]

Allocate a list of cbits

cFree(arg0: ClassicalCondition) None[源代码]

Free a cbit

cFree_all(cbit_list: List[ClassicalCondition]) None[源代码]
cFree_all() None

Free all of cbits

finalize() None[源代码]

finalize

get_token(rep_json: str) ErrorCode[源代码]
init() None[源代码]
init_config(url: str, log_cout: bool) None[源代码]
parse_prob_counts_result(result_str: List[str]) List[Dict[str, int]][源代码]

Parse result str to map<string, double> Args:

result_str: Taeget result string

Returns:

array: vector<map<string, double>>

Raises:

none

parse_probability_result(result_str: List[str]) List[Dict[str, float]][源代码]

Parse result str to map<string, double> Args:

result_str: Taeget result string

Returns:

array: vector<map<string, double>>

Raises:

none

parse_task_result(result_str: str) Dict[str, float][源代码]

Parse result str to map<string, double> Args:

result_str: Taeget result string

Returns:

dict: map<string, double>

Raises:

none

parser_expectation_result(json_str: str) list[源代码]

deprecated, use Python's json lib.

parser_sync_result(json_str: str) list[源代码]
qAlloc() Qubit[源代码]

Allocate a qubit

qAlloc_many(qubit_num: int) List[Qubit][源代码]

Allocate a list of qubits

qFree(qubit: Qubit) None[源代码]

Free a qubit

qFree_all(qubit_list: QVec) None[源代码]
qFree_all(arg0: QVec) None

Free all of qubits

set_config(max_qubit: int, max_cbit: int) None[源代码]

set QVM max qubit and max cbit

Args:

max_qubit: quantum machine max qubit num max_cbit: quantum machine max cbit num

Returns:

none

Raises:

run_fail: An error occurred in set_configure

tcp_recv(ip: str, port: int, task_id: str) list[源代码]
class pyqpanda.QProg[源代码]
class pyqpanda.QProg(arg0: QProg)
class pyqpanda.QProg(arg0: QCircuit)
class pyqpanda.QProg(arg0: QIfProg)
class pyqpanda.QProg(arg0: QWhileProg)
class pyqpanda.QProg(arg0: QGate)
class pyqpanda.QProg(arg0: QMeasure)
class pyqpanda.QProg(arg0: QReset)
class pyqpanda.QProg(arg0: ClassicalCondition)
class pyqpanda.QProg(arg0: NodeIter)

Quantum program,can construct quantum circuit,data struct is linked list

begin() NodeIter[源代码]

Get an iterator to the first node in the program.

Returns:

A reference to the iterator pointing to the first node.

end() NodeIter[源代码]

Get an iterator to the end of the program.

Returns:

A reference to the iterator pointing past the last node.

get_max_qubit_addr() int[源代码]
get_qgate_num() int[源代码]
get_used_cbits(cbit_vector: List[ClassicalCondition]) List[ClassicalCondition][源代码]

Get a list of classical bits used in the program.

Args:

cbit_vector: The vector to store the used classical bits.

Returns:

A reference to the updated classical bit vector.

get_used_qubits(qubit_vector: QVec) QVec[源代码]

Get a list of qubits used in the program.

Args:

qubit_vector: The vector to store the used qubits.

Returns:

A reference to the updated qubit vector.

head() NodeIter[源代码]

Get an iterator to the head node of the program.

Returns:

A reference to the iterator pointing to the head node.

insert(arg0: QProg) QProg[源代码]
insert(arg0: QGate) QProg
insert(arg0: QCircuit) QProg
insert(arg0: QIfProg) QProg
insert(arg0: QWhileProg) QProg
insert(arg0: QMeasure) QProg
insert(arg0: QReset) QProg
insert(arg0: ClassicalCondition) QProg

Insert a ClassicalCondition into the program.

Args:

condition_op: The classical condition operation to be inserted.

Returns:

A reference to the updated program.

is_empty() bool[源代码]
is_measure_last_pos() bool[源代码]

Check if the last operation in the program is a measurement.

Returns:

True if the last operation is a measurement, otherwise False.

last() NodeIter[源代码]

Get an iterator to the last node in the program.

Args:

None

Returns:

A reference to the iterator pointing to the last node.

class pyqpanda.QProgDAG[源代码]

quantum prog dag class

get_edges() List[QProgDAGEdge][源代码]

Retrieve the set of edges in the quantum program DAG.

Returns:

List[QProgDAGEdge]: A list of edges in the DAG.

get_target_vertex(vertice_num: int) QProgDAGVertex[源代码]

Retrieve a target vertex from the quantum program DAG.

Args:

vertice_num: The index of the vertex to retrieve.

Returns:

QVertex: A reference to the specified vertex in the DAG.

get_vertex_set() List[QProgDAGVertex][源代码]

Retrieve the set of vertices in the quantum program DAG.

Args:

QVec: The set of vertices.

Returns:

QVec: A reference to the vector of vertices in the DAG.

class pyqpanda.QProgDAGEdge(from_arg: int, to_arg: int, qubit_arg: int)[源代码]

quantum prog dag edge

m_from: int
m_qubit: int
m_to: int
class pyqpanda.QProgDAGVertex[源代码]

quantum prog dag vertex node

m_id: int
m_layer: int
m_pre_node: List[int]
m_succ_node: List[int]
m_type: DAGNodeType
get_control_vec() QVec[源代码]

Retrieve the vector of control qubits associated with the vertex.

get_iter() NodeIter[源代码]

Retrieve the iterator associated with the vertex.

get_qubits_vec() QVec[源代码]

Retrieve the vector of qubits associated with the vertex.

is_dagger() bool[源代码]

Check if the vertex is a dagger operation.

class pyqpanda.QReset(arg0: NodeIter)[源代码]

quantum reset node

class pyqpanda.QResult(*args, **kwargs)[源代码]

QResult abstract class, this class contains the result of the quantum measurement

getResultMap() Dict[str, bool][源代码]
class pyqpanda.QVec[源代码]
class pyqpanda.QVec(qubit_list: List[Qubit])
class pyqpanda.QVec(qvec: QVec)
class pyqpanda.QVec(qubit: Qubit)

Qubit vector basic class

append(qubit: Qubit) None[源代码]

Add a qubit to the end of the QVec.

Args:

qubit: A pointer to the Qubit to be added.

Returns:

None.

pop() None[源代码]

Remove and return the last qubit from the QVec.

Args:

None

Returns:

A pointer to the removed Qubit.

to_list() List[Qubit][源代码]

Convert the QVec to a standard vector of qubit pointers.

Args:

None

Returns:

A vector containing pointers to the qubits in the QVec.

class pyqpanda.QWhileProg(arg0: NodeIter)[源代码]
class pyqpanda.QWhileProg(arg0: ClassicalCondition, arg1: QProg)

quantum while node

get_classical_condition() ClassicalCondition[源代码]

Retrieve the classical condition associated with the while program.

Returns:

The classical condition object used in the while statement.

get_true_branch() QProg[源代码]

Retrieve the quantum program corresponding to the true branch.

Returns:

QProg: The quantum program for the true branch.

Raises:

runtime_error: If the true branch is null or has an incorrect node type.

class pyqpanda.QuantumMachine(*args, **kwargs)[源代码]

quantum machine base class

allocate_qubit_through_phy_address(address: int) Qubit[源代码]

Allocate qubits through physical address.

This function allocates qubits using the specified physical address.

Args:

address: The physical address of the qubit.

Returns:

The allocated qubit.

allocate_qubit_through_vir_address(address: int) Qubit[源代码]

Allocate a qubit using its physical address.

This function allocates a qubit based on the specified physical address.

Args:

address: The physical address of the qubit to allocate.

Returns:

A reference to the allocated Qubit.

async_run(qprog: QProg, noise_model: Noise = NoiseModel()) None[源代码]

Execute the quantum program asynchronously in the background.

This function runs the specified quantum program without blocking the main thread.

You can check the progress using get_processed_qgate_num(), determine if the process

is finished with is_async_finished(), and retrieve results with get_async_result().

Args:

qprog: The quantum program to run.

noise_model: (optional) The noise model to apply (default is NoiseModel()).

Returns:

A reference indicating the status of the asynchronous operation.

cAlloc() ClassicalCondition[源代码]
cAlloc(cbit: int) ClassicalCondition

Allocate a classical bit (CBit) in the QuantumMachine.

This function allocates a CBit after the quantum machine has been initialized.

Args:

cbit_addr: The address of the CBit to allocate, which should be in the range [0, 29).

Returns:

Reference to the allocated CBit.

cAlloc_many(cbit_num: int) List[ClassicalCondition][源代码]

Allocate multiple classical bits (CBits).

This function must be called after init().

Args:

cbit_num: The number of classical bits to allocate.

Returns:

list[CBit]: A list of allocated classical bits.

cFree(arg0: ClassicalCondition) None[源代码]

Free a classical bit (CBit).

This function deallocates a previously allocated classical bit.

Args:

CBit: The classical bit to be freed.

Returns:

None: This function does not return a value.

cFree_all(cbit_list: List[ClassicalCondition]) None[源代码]
cFree_all() None

Free all classical bits (CBits).

This function deallocates all classical bits that have been previously allocated.

Args:

None

Returns:

None: This function does not return a value.

directly_run(qprog: QProg, noise_model: Noise = NoiseModel()) Dict[str, bool][源代码]

Directly execute the quantum program.

This function runs the specified quantum program immediately after the

initialization (init()). It supports an optional noise model, which is

currently only applicable to CPUQVM.

Args:

qprog: The quantum program to run.

noise_model: (optional) The noise model to apply (default is no noise).

Returns:
A dictionary with the execution results:

The final qubit register state. The measurement probabilities.

finalize() None[源代码]

Finalize the quantum machine.

Args:

None

Returns:

None

getAllocateCMem() int[源代码]

Get the list of allocated classical bits (cbits) in the QuantumMachine.

This function retrieves the cbits that have been allocated for use in the quantum machine.

Args:

None

Returns:

List of allocated cbits.

getAllocateQubitNum() int[源代码]

Get the list of allocated qubits in the QuantumMachine.

This function retrieves the qubits that have been allocated for use in the quantum machine.

Args:

None

Returns:

List of allocated qubits.

getStatus(*args, **kwargs) Any[源代码]

Get the status of the Quantum machine.

This function retrieves the current status of the Quantum machine.

Args:

None

Returns:

QMachineStatus: The status of the Quantum machine.

get_allocate_cbits() List[ClassicalCondition][源代码]

Retrieve the list of allocated cbits in the QuantumMachine.

This function returns a list of currently allocated cbits.

Args:

None

Returns:

A list of allocated cbits.

get_allocate_cmem_num() int[源代码]

Retrieve the list of allocated cbits in the QuantumMachine.

This function returns the currently allocated cbits.

Args:

None

Returns:

A list of allocated cbits.

get_allocate_qubit_num() int[源代码]

Retrieve the list of allocated qubits in the QuantumMachine.

This function returns the currently allocated qubits.

Args:

None

Returns:

A list of allocated qubits.

get_allocate_qubits() List[Qubit][源代码]

Retrieve the list of allocated qubits in the QuantumMachine.

This function returns a list of currently allocated qubits.

Args:

None

Returns:

A list of allocated qubits.

get_async_result() Dict[str, bool][源代码]

Retrieve the result of the asynchronous quantum program execution.

This function blocks the current code until the asynchronous process initiated

by async_run() is complete, then returns the results.

Returns:

The result of the asynchronous execution.

get_expectation(qprog: QProg, hamiltonian: List[Tuple[Dict[int, str], float]], qubit_list: QVec) float[源代码]
get_expectation(qprog: QProg, hamiltonian: List[Tuple[Dict[int, str], float]], qubit_list: QVec, shots: int) float

Calculate the expectation value of the given Hamiltonian with specified measurement shots.

This function computes the expectation value based on the provided quantum program,

Hamiltonian, list of qubits to measure, and the number of measurement shots.

Args:

qprog: The quantum program to execute.

hamiltonian: The Hamiltonian for which the expectation is calculated.

qubit_list: A list of qubits to measure.

shots: The number of measurement shots to perform.

Returns:

A double representing the expectation value of the current Hamiltonian.

get_gate_time_map() Dict[GateType, int][源代码]

Retrieve the gate time mapping for the QuantumMachine.

This function returns a map of gates to their corresponding execution times.

Args:

None

Returns:

A reference to the gate time map.

get_processed_qgate_num() int[源代码]

Retrieve the number of processed quantum gates.

This function returns the total count of quantum gates that have been processed

by the QuantumMachine.

Returns:

An integer representing the number of processed quantum gates.

get_qstate() List[complex][源代码]

Get the status of the quantum machine.

Args:

None

Returns:

QMachineStatus: The current status of the quantum machine.

get_status(*args, **kwargs) Any[源代码]

Retrieve the status of the QuantumMachine.

This function returns the current status of the quantum machine.

Args:

None

Returns:

The status of the Quantum machine, represented as a QMachineStatus.

initQVM() None[源代码]

Initialize the global unique quantum machine in the background.

This function sets up the quantum machine based on the specified type.

Args:

machine_type: The type of quantum machine to initialize, as defined in pyQPanda.QMachineType.

Returns:

bool: True if the initialization is successful, otherwise false.

init_qvm() None[源代码]

Initialize the global unique quantum machine in the background.

This function sets up the quantum machine based on the specified type.

Args:

machine_type: The type of quantum machine to initialize, as defined in pyQPanda.QMachineType.

Returns:

bool: True if the initialization is successful, otherwise false.

init_sparse_state(*args, **kwargs) Any[源代码]

Initialize a sparse quantum state for the QuantumMachine.

This function sets the initial sparse state of the quantum machine.

Args:

state: A map representing the sparse state, where keys are state identifiers and values are qcomplex_t. Defaults to an empty map.

qlist: The list of qubits to which the sparse state will be applied, represented as a QVec object. Defaults to QVec().

Returns:

Reference to the updated quantum machine.

init_state(state: List[complex] = QStat(), qlist: QVec = QVec()) None[源代码]

Initialize the quantum state of the QuantumMachine.

This function sets the initial state of the quantum machine.

Args:

state: The initial quantum state, represented as a QStat object. Defaults to QStat().

qlist: The list of qubits to which the state will be applied, represented as a QVec object. Defaults to QVec().

Returns:

Reference to the updated quantum machine.

is_async_finished() bool[源代码]

Check if the asynchronous quantum program execution is complete.

This function returns a boolean indicating whether the asynchronous process

initiated by async_run() has finished.

Returns:

True if the process is complete, False otherwise.

qAlloc() Qubit[源代码]

Allocate a qubit.

This function must be called after init().

Args:

qubit_addr: The physical address of the qubit, should be in the range [0, 29).

qAlloc_many(qubit_num: int) List[Qubit][源代码]

Allocate multiple qubits.

This function must be called after init().

Args:

qubit_num: The number of qubits to allocate.

Returns:

list[Qubit]: A list of allocated qubits.

qFree(qubit: Qubit) None[源代码]

Free a qubit.

This function deallocates a previously allocated qubit.

Args:

qubit: The Qubit to be freed.

Returns:

None: This function does not return a value.

qFree_all(qubit_list: QVec) None[源代码]
qFree_all(arg0: QVec) None

Free all qubits.

This function deallocates all qubits provided in the input vector.

Args:

None

Returns:

None: This function does not return a value.

run_with_configuration(qprog: QProg, cbit_list: List[ClassicalCondition], data: dict, noise_model: Noise = NoiseModel()) Dict[str, int][源代码]
run_with_configuration(qprog: QProg, cbit_list: List[ClassicalCondition], shot: int, noise_model: Noise = NoiseModel()) Dict[str, int]
run_with_configuration(qprog: QProg, shot: int, noise_model: Noise = NoiseModel()) Dict[str, int]
run_with_configuration(qprog: QProg, cbit_list: List[int], shot: int, noise_model: Noise = NoiseModel()) Dict[str, int]

Execute the quantum program with a specified configuration.

This function runs the quantum program using the provided classical bits,

the number of shots for repeated execution, and an optional noise model.

Args:

qprog: The quantum program to execute.

cbit_list: The list of classical bits.

shot: The number of times to repeat the execution.

noise_model: (optional) The noise model to apply (default is no noise). Note: Noise models currently work only on CPUQVM.

Returns:
A tuple containing the execution results over the specified shots:

The final qubit register state. The count of hits for each outcome.

set_configure(max_qubit: int, max_cbit: int) None[源代码]

Set the maximum qubit and cbit numbers for the QVM.

Args:

max_qubit: Maximum number of qubits in the quantum machine.

max_cbit: Maximum number of cbits in the quantum machine.

Returns:

None

class pyqpanda.QuantumStateTomography[源代码]

quantum state tomography class

caculate_tomography_density() List[List[complex]][源代码]

Calculate the tomography density.

Returns:

A reference to the calculated density matrix.

combine_qprogs(circuit: QProg, qlist: QVec) List[QProg][源代码]
combine_qprogs(circuit: QCircuit, qlist: QVec) List[QProg]
combine_qprogs(circuit: QProg, qlist: List[int]) List[QProg]
combine_qprogs(circuit: QCircuit, qlist: List[int]) List[QProg]

Return a list of quantum state tomography quantum programs.

Args:

circuit: The quantum circuit to be combined.

qlist: A vector of indices representing the qubits involved.

Returns:

A reference to the combined quantum programs.

exec(qm, shots: int) List[List[complex]][源代码]

Run state tomography quantum programs.

Args:

qm: The quantum machine to execute the programs on.

shots: The number of shots for the execution.

Returns:

A reference to the execution results.

set_qprog_results(qlist: int, results: List[Dict[str, float]]) None[源代码]

Set the results of combined quantum programs.

Args:

qlist: The index of the qubit list.

results: A vector of maps containing the result data.

Returns:

A reference to the updated state.

Raises:

run_fail: An error occurred while setting the results.

class pyqpanda.Qubit(*args, **kwargs)[源代码]

Qubit abstract class

getPhysicalQubitPtr() PhysicalQubit[源代码]

Retrieve a pointer to the associated physical qubit.

This function returns a pointer to the physical qubit that corresponds to this qubit instance.

Args:

None

Returns:

A pointer to the associated physical qubit.

get_phy_addr() int[源代码]

Retrieve the physical address of the qubit.

This function returns the physical address associated with this qubit instance.

Args:

None

Returns:

The physical address of the qubit.

class pyqpanda.RMSPropOptimizer(arg0: var, arg1: float, arg2: float, arg3: float)[源代码]

variational quantum RMSPropOptimizer

get_loss() float[源代码]
get_variables() List[var][源代码]
minimize(arg0: float, arg1: float, arg2: float) Optimizer[源代码]
run(arg0: List[var], arg1: int) bool[源代码]
class pyqpanda.SingleAmpQVM[源代码]

Bases: QuantumMachine

quantum single amplitude machine class

get_prob_dict(arg0: QVec) Dict[str, float][源代码]
get_prob_dict(arg0: List[int]) Dict[str, float]

Get the pmeasure result as a dictionary.

Args:

qubit_list: A list of qubits for pmeasure.

Returns:

A dictionary containing the measurement results of the quantum machine.

get_quick_map_vertice(arg0: List[Tuple[int, int]]) None[源代码]

Get the quick map vertices.

Returns:

A reference to the quick map vertices.

get_sequence(arg0: List[int], arg1: List[List[Tuple[int, bool]]]) int[源代码]

Get the program sequence.

Returns:

A reference to the current program sequence.

pmeasure_bin_amplitude(arg0: str) complex[源代码]

Measure the bin amplitude of the quantum state.

Args:

bin_string: A string representing the bin.

Returns:

A complex number representing the bin amplitude.

pmeasure_bin_index(arg0: str) float[源代码]

Measure the bin index of the quantum state amplitude.

Args:

bin_string: A string representing the bin.

Returns:

A double representing the amplitude probability of the bin.

pmeasure_dec_amplitude(arg0: str) complex[源代码]

Measure the dec amplitude of the quantum state.

Args:

dec_string: A string representing the dec.

Returns:

A complex number representing the dec amplitude.

pmeasure_dec_index(arg0: str) float[源代码]

Measure the dec index of the quantum state amplitude.

Args:

dec_string: A string representing the dec.

Returns:

A double representing the amplitude probability of the dec.

prob_run_dict(arg0: QProg, arg1: QVec) Dict[str, float][源代码]
prob_run_dict(arg0: QProg, arg1: List[int]) Dict[str, float]

Run the quantum program and get the pmeasure result as a dictionary.

Args:

qprog: The quantum program to run.

qubit_list: A list of qubits for pmeasure.

Returns:

A dictionary containing the measurement results of the quantum machine.

run(prog: QProg, qv: QVec, max_rank: int = 30, alloted_time: int = 5) None[源代码]
run(arg0: QProg, arg1: QVec, arg2: int, arg3: List[List[Tuple[int, bool]]]) None

Run the quantum program.

Args:

prog: A quantum program (QProg) to be executed.

qv: A list of qubits (QVec) involved in the program.

max_rank: The maximum rank to consider during execution.

sequences: A list of sequences (std::vector<qprog_sequence_t>).

Returns:

None, as the function executes the program in place.

class pyqpanda.SingleGateTransferType(value: int)[源代码]

Quantum single gate transfer type

Members:

SINGLE_GATE_INVALID

ARBITRARY_ROTATION

DOUBLE_CONTINUOUS

SINGLE_CONTINUOUS_DISCRETE

DOUBLE_DISCRETE

ARBITRARY_ROTATION: ClassVar[SingleGateTransferType] = Ellipsis
DOUBLE_CONTINUOUS: ClassVar[SingleGateTransferType] = Ellipsis
DOUBLE_DISCRETE: ClassVar[SingleGateTransferType] = Ellipsis
SINGLE_CONTINUOUS_DISCRETE: ClassVar[SingleGateTransferType] = Ellipsis
SINGLE_GATE_INVALID: ClassVar[SingleGateTransferType] = Ellipsis
property name: str
property value: int
class pyqpanda.SparseQVM[源代码]

Bases: QuantumMachine

quantum sparse machine class

directlyRun(arg0: QProg) Dict[str, bool][源代码]

Run the quantum program and get the measurement results as a dictionary.

Args:

qprog: The quantum program to execute.

Returns:

Dict[str, bool]: The result of the quantum program execution in one shot.

directly_run(arg0: QProg) Dict[str, bool][源代码]

Run the quantum program and get the measurement results as a dictionary.

Args:

qprog: The quantum program to execute.

Returns:

The measurement results of the quantum machine.

init_qvm() None[源代码]

init quantum virtual machine

prob_run_dict(arg0: QProg) Dict[str, float][源代码]

Run the quantum program and get the measurement results as a dictionary.

Args:

qprog: The quantum program to execute.

Returns:

A dictionary containing the measurement results of the quantum machine.

run_with_configuration(arg0: QProg, arg1: List[ClassicalCondition], arg2: int) Dict[str, int][源代码]

Run the quantum program with the specified configuration and get the measurement results as a dictionary.

Args:

qprog: The quantum program to execute.

cbits: The quantum classical bits.

shots: The number of sample shots.

Returns:

The measurement results of the quantum machine.

class pyqpanda.Stabilizer[源代码]

Bases: QuantumMachine

simulator for basic clifford simulator

init_qvm() None[源代码]

init quantum virtual machine

prob_run_dict(qprog: QProg, qubits: QVec, select_max: int = -1) Dict[str, float][源代码]

Run quantum program and get probabilities.

Args:

qprog: Quantum program to execute.

qubits: Qubits to be measured for probabilities.

select_max: Optional, selects the maximum number of probabilities to return.

Returns:

Probabilities result of the quantum program.

run_with_configuration(qprog: QProg, shot: int) Dict[str, int][源代码]

Run quantum program and get shots result.

Args:

qprog: Quantum program to execute.

shot: Number of measurement shots.

Returns:

Shots result of the quantum program.

set_noise_model(arg0: NoiseModel, arg1: GateType, arg2: float) None[源代码]
set_noise_model(arg0: NoiseModel, arg1: List[GateType], arg2: float) None
set_noise_model(arg0: NoiseModel, arg1: GateType, arg2: float, arg3: QVec) None
set_noise_model(arg0: NoiseModel, arg1: List[GateType], arg2: float, arg3: QVec) None
set_noise_model(arg0: NoiseModel, arg1: GateType, arg2: float, arg3: List[QVec]) None

Set a noise model for the Stabilizer simulator with a specific gate type, probability, and multiple targeted qubits.

Args:

noise_model: The noise model to apply (e.g., bit-flip, phase-flip, etc.).

gate_type: The specific gate type associated with the noise model.

probability: The probability of the noise occurring.

target_qubits: A vector of qubit vectors targeted by the noise model.

Returns:

None.

class pyqpanda.UpdateMode(value: int)[源代码]

quantum imaginary time evolution update mode

Members:

GD_VALUE

GD_DIRECTION

GD_DIRECTION: ClassVar[UpdateMode] = Ellipsis
GD_VALUE: ClassVar[UpdateMode] = Ellipsis
property name: str
property value: int
class pyqpanda.VanillaGradientDescentOptimizer(arg0: var, arg1: float, arg2: float, arg3: OptimizerMode)[源代码]

variational quantum VanillaGradientDescentOptimizer

get_loss() float[源代码]
get_variables() List[var][源代码]
minimize(arg0: float, arg1: float) Optimizer[源代码]
run(arg0: List[var], arg1: int) bool[源代码]
class pyqpanda.VariationalQuantumCircuit[源代码]
class pyqpanda.VariationalQuantumCircuit(arg0: QCircuit)

variational quantum CIRCUIT class

control(arg0: QVec) VariationalQuantumCircuit[源代码]
dagger() VariationalQuantumCircuit[源代码]
feed() QCircuit[源代码]
feed(arg0) QCircuit
get_control_qubit() QVec[源代码]
insert(arg0: VariationalQuantumGate_I) VariationalQuantumCircuit[源代码]
insert(arg0: VariationalQuantumGate_H) VariationalQuantumCircuit
insert(arg0: VariationalQuantumGate_X) VariationalQuantumCircuit
insert(arg0: VariationalQuantumGate_Y) VariationalQuantumCircuit
insert(arg0: VariationalQuantumGate_T) VariationalQuantumCircuit
insert(arg0: VariationalQuantumGate_S) VariationalQuantumCircuit
insert(arg0: VariationalQuantumGate_Z) VariationalQuantumCircuit
insert(arg0: VariationalQuantumGate_X1) VariationalQuantumCircuit
insert(arg0: VariationalQuantumGate_Y1) VariationalQuantumCircuit
insert(arg0: VariationalQuantumGate_Z1) VariationalQuantumCircuit
insert(arg0: VariationalQuantumGate_U1) VariationalQuantumCircuit
insert(arg0: VariationalQuantumGate_U2) VariationalQuantumCircuit
insert(arg0: VariationalQuantumGate_U3) VariationalQuantumCircuit
insert(arg0: VariationalQuantumGate_U4) VariationalQuantumCircuit
insert(arg0: VariationalQuantumGate_RX) VariationalQuantumCircuit
insert(arg0: VariationalQuantumGate_RY) VariationalQuantumCircuit
insert(arg0: VariationalQuantumGate_RZ) VariationalQuantumCircuit
insert(arg0: VariationalQuantumGate_CNOT) VariationalQuantumCircuit
insert(arg0: VariationalQuantumGate_CR) VariationalQuantumCircuit
insert(arg0: VariationalQuantumGate_CZ) VariationalQuantumCircuit
insert(arg0: VariationalQuantumGate_CRX) VariationalQuantumCircuit
insert(arg0: VariationalQuantumGate_CRY) VariationalQuantumCircuit
insert(arg0: VariationalQuantumGate_CRZ) VariationalQuantumCircuit
insert(arg0: VariationalQuantumGate_SWAP) VariationalQuantumCircuit
insert(arg0: VariationalQuantumGate_iSWAP) VariationalQuantumCircuit
insert(arg0: VariationalQuantumGate_SqiSWAP) VariationalQuantumCircuit
insert(arg0: VariationalQuantumCircuit) VariationalQuantumCircuit
insert(arg0: QCircuit) VariationalQuantumCircuit
insert(arg0: QGate) VariationalQuantumCircuit
is_dagger() bool[源代码]
set_control(arg0: QVec) bool[源代码]
set_dagger(arg0: bool) bool[源代码]
class pyqpanda.VariationalQuantumGate(*args, **kwargs)[源代码]

variational quantum gate base class

feed(arg0: Dict[int, float]) QGate[源代码]
get_constants() List[float][源代码]
get_control_qubit() QVec[源代码]
get_vars() List[var][源代码]
is_dagger() bool[源代码]
set_control(arg0: QVec) bool[源代码]
set_dagger(arg0: bool) bool[源代码]
class pyqpanda.VariationalQuantumGate_CNOT(arg0: Qubit, arg1: Qubit)[源代码]

Bases: VariationalQuantumGate

variational quantum CNOT gate class

control(arg0: QVec) VariationalQuantumGate_CNOT[源代码]
dagger() VariationalQuantumGate_CNOT[源代码]
class pyqpanda.VariationalQuantumGate_CR(arg0: Qubit, arg1: Qubit, arg2: float)[源代码]
class pyqpanda.VariationalQuantumGate_CR(arg0: Qubit, arg1: Qubit, arg2: var)
class pyqpanda.VariationalQuantumGate_CR(arg0: VariationalQuantumGate_CR)

Bases: VariationalQuantumGate

variational quantum CR gate class

control(arg0: QVec) VariationalQuantumGate_CR[源代码]
dagger() VariationalQuantumGate_CR[源代码]
class pyqpanda.VariationalQuantumGate_CRX(arg0: Qubit, arg1: QVec, arg2: float)[源代码]
class pyqpanda.VariationalQuantumGate_CRX(arg0: Qubit, arg1: QVec, arg2: var)
class pyqpanda.VariationalQuantumGate_CRX(arg0: VariationalQuantumGate_CRX)

Bases: VariationalQuantumGate

variational quantum CRX gate class

control(arg0: QVec) VariationalQuantumGate_CRX[源代码]
dagger() VariationalQuantumGate_CRX[源代码]
class pyqpanda.VariationalQuantumGate_CRY(arg0: Qubit, arg1: QVec, arg2: float)[源代码]
class pyqpanda.VariationalQuantumGate_CRY(arg0: Qubit, arg1: QVec, arg2: var)
class pyqpanda.VariationalQuantumGate_CRY(arg0: VariationalQuantumGate_CRY)

Bases: VariationalQuantumGate

variational quantum CRY gate class

control(arg0: QVec) VariationalQuantumGate_CRY[源代码]
dagger() VariationalQuantumGate_CRY[源代码]
class pyqpanda.VariationalQuantumGate_CRZ(arg0: Qubit, arg1: QVec, arg2: float)[源代码]
class pyqpanda.VariationalQuantumGate_CRZ(arg0: Qubit, arg1: QVec, arg2: var)
class pyqpanda.VariationalQuantumGate_CRZ(arg0: VariationalQuantumGate_CRZ)

Bases: VariationalQuantumGate

variational quantum CRZ gate class

control(arg0: QVec) VariationalQuantumGate_CRZ[源代码]