0
$\begingroup$

I would like to see, in terms of complexity, the cost of a circuit. For example: I have written two algorithm that does the same thing, but in one of them I initialize data differently, so I would like to compare them.

I've seen that there is a function called count_ops() , but it return only the number of each gate and I think it is not useful for my purpose, because is not an appropriate metric (i.e it is possible that one circuit is computationally more expensive but has less gate than the other). I am wondering if there is a function which calculate the complexity, given the gate, or something like that.

Thanks very much.

$\endgroup$
2
  • $\begingroup$ Hi Dylan! You will have to define more clearly what you mean by "complexity", "cost of a circuit" and "computationally more expensive" here. Complexity is a theoretical behaviour when the inputs of the algorithm becomes larger and larger, "cost of a circuit" can literally be a dozen of different things and "computationally more expensive" depends on the "cost of a circuit" you pick. $\endgroup$ Aug 7, 2022 at 10:55
  • 1
    $\begingroup$ Hi! you're right, I'm sorry. In any case, Ohad gave me a very well describing of the problem. Thanks anyway :). $\endgroup$ Aug 7, 2022 at 11:58

1 Answer 1

2
$\begingroup$

I think what you are looking for is the notion of circuit depth - which is basically the amount of steps being done by the quantum computer that runs the circuit. Some gate operations can be executed in parallel and therefore we count them as 1 step. The exact implementation of each circuit depends both on the physical properties of the hardware and on the structure of the circuit.

In qiskit a QuantumCircuit object has a method called depth() (Just like the count_ops() method that you have mentioned) - So you can easily test the circuit depth of any circuit.

In addition, needed to mention here that for a qunatum hardware to run a circuit we need to transpile it first to a circuit with only "native gates" (which are gates that a given quantum computer can physically perform) - so the depth of a circuit and its transpiled version are usually not the same.

I think this post explains the issue well.

$\endgroup$
1
  • $\begingroup$ Thanks! It is a perfect answer! I'll try this way. $\endgroup$ Aug 7, 2022 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.