qml.resource.CircuitSpecs¶
- class CircuitSpecs(device_name=None, num_device_wires=None, shots=None, level=None, resources=None)[source]¶
Bases:
objectClass for storing specifications of a qnode. Contains resource information as well as additional data such as the device, number of shots, and level of the requested specs.
- Parameters:
device_name (str) – The name of the device used.
num_device_wires (int) – The number of wires on the device.
shots (Shots) – The shots configuration used.
level (Any) – The level of the specs (see
specs()for more details).resources (SpecsResources | list[SpecsResources] | dict[int | str, SpecsResources | list[SpecsResources]]) – The resource specifications. Depending on the
levelchosen, this may be a singleSpecsResourcesobject, a list ofSpecsResourcesobjects, or a dictionary mapping levels to their corresponding outputs.
Usage Details
Some helpful methods have been added to this data class to allow pretty-printing, as well as indexing into it as a dictionary. See examples below.
Example
>>> from pennylane.resource import SpecsResources, CircuitSpecs >>> specs = CircuitSpecs( ... device_name="default.qubit", ... num_device_wires=2, ... shots=Shots(1000), ... level="device", ... resources=SpecsResources( ... gate_types={"RX": 2, "CNOT": 1}, ... gate_sizes={1: 2, 2: 1}, ... measurements={"expval(PauliZ)": 1}, ... num_allocs=2, ... depth=3, ... ), ... )
>>> print(specs.num_device_wires) 2
>>> print(specs["num_device_wires"]) 2
>>> print(specs) Device: default.qubit Device wires: 2 Shots: Shots(total=1000) Level: device Wire allocations: 2 Total gates: 3 Gate counts: - RX: 2 - CNOT: 1 Measurements: - expval(PauliZ): 1 Depth: 3
Attributes
Methods
to_dict()Convert the CircuitSpecs to a dictionary.
to_pretty_str([tabular])Pretty string representation of the
CircuitSpecsobject.- to_pretty_str(tabular=True)[source]¶
Pretty string representation of the
CircuitSpecsobject.- Parameters:
tabular (bool) – Whether to display the resources in a tabular format.
- Returns:
A pretty representation of this object.
- Return type:
str