View decomposed gate in Qiskit Backend

I’d like to know if it’s possible to view the decomposed gates or the number of gates in a circuit when I’m using the Qiskit backend with restricted basic gates.

Name: PennyLane
Version: 0.35.1
Summary: PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
Home-page: GitHub - PennyLaneAI/pennylane: PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
Author:
Author-email:
License: Apache License 2.0
Location: /Users/guohaoyang/pythonProject/venv/lib/python3.10/site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, requests, rustworkx, scipy, semantic-version, toml, typing-extensions
Required-by: PennyLane-qiskit, PennyLane_Lightning

Platform info: macOS-13.0-arm64-arm-64bit
Python version: 3.10.11
Numpy version: 1.26.4
Scipy version: 1.13.0
Installed devices:

  • default.clifford (PennyLane-0.35.1)
  • default.gaussian (PennyLane-0.35.1)
  • default.mixed (PennyLane-0.35.1)
  • default.qubit (PennyLane-0.35.1)
  • default.qubit.autograd (PennyLane-0.35.1)
  • default.qubit.jax (PennyLane-0.35.1)
  • default.qubit.legacy (PennyLane-0.35.1)
  • default.qubit.tf (PennyLane-0.35.1)
  • default.qubit.torch (PennyLane-0.35.1)
  • default.qutrit (PennyLane-0.35.1)
  • null.qubit (PennyLane-0.35.1)
  • lightning.qubit (PennyLane_Lightning-0.36.0)
  • qiskit.aer (PennyLane-qiskit-0.35.0)
  • qiskit.basicaer (PennyLane-qiskit-0.35.0)
  • qiskit.ibmq (PennyLane-qiskit-0.35.0)
  • qiskit.ibmq.circuit_runner (PennyLane-qiskit-0.35.0)
  • qiskit.ibmq.sampler (PennyLane-qiskit-0.35.0)
  • qiskit.remote (PennyLane-qiskit-0.35.0)

Hi @yangguohao ,

If you update your PennyLane version you can use level when you draw. This allows you to view the circuits with different levels of abstraction. For example in the code below you can set level=0 to obtain the first image or level=1 to obtain the second one. You can also use qml.specs to get specific information about the circuit.

I hope this helps!

import pennylane as qml
from pennylane import numpy as pnp
dev = qml.device('qiskit.aer',wires=2)

@qml.qnode(dev)
def circuit(params):
  # Ansatz
  qml.StronglyEntanglingLayers(weights=params, wires=range(4))
  return qml.expval(qml.PauliZ(wires=0))

shape = qml.StronglyEntanglingLayers.shape(n_layers=2, n_wires=4)
init_params = pnp.random.random(size=shape) 

qml.draw_mpl(circuit,style='pennylane',decimals=1,level=0)(init_params)
qml.specs(circuit)(init_params)

Thank you! @CatalinaAlbornoz