# pennylaneai/pennylane architecture

> Architecture diagram of the GitHub repository pennylaneai/pennylane, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pennylaneai/pennylane
- Repository: https://github.com/pennylaneai/pennylane

## Overview

PennyLane is a quantum software platform for building, differentiating, compiling, and executing quantum programs, with applications including quantum machine learning and quantum chemistry. A typical workflow records operations and measurements as a quantum script, transforms or compiles it, executes it on a device, then differentiates results for optimization. The repository also provides chemistry, resource-estimation, drawing, data, and quantum-hardware tooling. Arrows are limited to relationships shown in README statements or SOURCE INDEX references; unsampled subsystems have no asserted internal call flow.

Main entry points: [`pennylane/core/qscript.py`](https://github.com/pennylaneai/pennylane/blob/main/pennylane/core/qscript.py) (Quantum script), [`pennylane/devices/device_api.py`](https://github.com/pennylaneai/pennylane/blob/main/pennylane/devices/device_api.py) (Device interface), [`pennylane/core/operator/base.py`](https://github.com/pennylaneai/pennylane/blob/main/pennylane/core/operator/base.py) (Operators and gates), [`pennylane/core/transforms/compile_pipeline.py`](https://github.com/pennylaneai/pennylane/blob/main/pennylane/core/transforms/compile_pipeline.py) (Compile pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_circuit["Circuit Modeling"]
  node_ops["Operators and gates<br/>[base.py]"]
  node_wires["Wire model<br/>[wires.py]"]
  node_queue["Operation queue<br/>[queuing.py]"]
  node_script["Quantum script<br/>[qscript.py]"]
  node_measure["Measurements<br/>[measurements.py]"]
end

subgraph group_execution["Execution and Compilation"]
  node_transforms["Circuit transforms<br/>[transform.py]"]
  node_decomp["Gate decomposition"]
  node_compile["Compile pipeline"]
  node_device["Device interface<br/>[device_api.py]"]
  node_simulator["Qubit simulators<br/>[simulate.py]"]
  node_hardware["Quantum hardware"]
end

subgraph group_learning["Differentiation and Learning"]
  node_gradients["Gradient transforms<br/>[parameter_shift.py]"]
  node_interfaces["JAX interface<br/>[jax.py]"]
  node_optimizers["Optimizers<br/>[rotosolve.py]"]
end

subgraph group_science["Quantum Applications"]
  node_qchem["Quantum chemistry<br/>[convert.py]"]
  node_fermions["Fermionic operators<br/>[fermionic.py]"]
  node_templates["Circuit templates<br/>[qaoaembedding.py]"]
end

subgraph group_tools["Analysis and Tools"]
  node_resource["Resource estimation<br/>[resource.py]"]
  node_drawer["Circuit drawing<br/>[mpldrawer.py]"]
  node_data[("Quantum data<br/>[dataset.py]")]
  node_qasm["OpenQASM interface"]
end

node_user(("Quantum developer"))
node_api["PennyLane API<br/>[__init__.py]"]

node_user -->|"uses"| node_api
node_api -->|"exposes"| node_ops
node_ops -->|"records in"| node_queue
node_queue -.->|"collects into"| node_script
node_script -->|"stores"| node_measure
node_script -->|"uses"| node_wires
node_script -->|"transformed by"| node_transforms
node_decomp -->|"decomposes"| node_ops
node_compile -->|"processes"| node_script
node_compile -->|"uses"| node_transforms
node_script -->|"executes on"| node_device
node_device -.->|"simulates with"| node_simulator
node_device -.->|"targets"| node_hardware
node_gradients -->|"transforms"| node_script
node_interfaces -->|"binds parameters"| node_script
node_user -.->|"optimizes with"| node_optimizers
node_optimizers -.->|"differentiates through"| node_interfaces
node_user -->|"builds circuits"| node_templates
node_user -->|"models chemistry"| node_qchem
node_qchem -.->|"uses operators"| node_fermions
node_user -->|"estimates resources"| node_resource
node_user -.->|"visualizes circuits"| node_drawer
node_user -.->|"loads datasets"| node_data
node_user -.->|"imports circuits"| node_qasm

click node_api "https://github.com/pennylaneai/pennylane/blob/main/pennylane/__init__.py"
click node_ops "https://github.com/pennylaneai/pennylane/blob/main/pennylane/core/operator/base.py"
click node_wires "https://github.com/pennylaneai/pennylane/blob/main/pennylane/wires.py"
click node_queue "https://github.com/pennylaneai/pennylane/blob/main/pennylane/core/queuing.py"
click node_script "https://github.com/pennylaneai/pennylane/blob/main/pennylane/core/qscript.py"
click node_measure "https://github.com/pennylaneai/pennylane/blob/main/pennylane/core/measurements.py"
click node_transforms "https://github.com/pennylaneai/pennylane/blob/main/pennylane/core/transforms/transform.py"
click node_decomp "https://github.com/pennylaneai/pennylane/blob/main/pennylane/decomposition/decomposition_rule.py"
click node_compile "https://github.com/pennylaneai/pennylane/blob/main/pennylane/core/transforms/compile_pipeline.py"
click node_device "https://github.com/pennylaneai/pennylane/blob/main/pennylane/devices/device_api.py"
click node_simulator "https://github.com/pennylaneai/pennylane/blob/main/pennylane/devices/qubit/simulate.py"
click node_gradients "https://github.com/pennylaneai/pennylane/blob/main/pennylane/gradients/parameter_shift.py"
click node_interfaces "https://github.com/pennylaneai/pennylane/blob/main/pennylane/workflow/interfaces/jax.py"
click node_optimizers "https://github.com/pennylaneai/pennylane/blob/main/pennylane/optimize/rotosolve.py"
click node_qchem "https://github.com/pennylaneai/pennylane/blob/main/pennylane/qchem/convert.py"
click node_fermions "https://github.com/pennylaneai/pennylane/blob/main/pennylane/fermi/fermionic.py"
click node_templates "https://github.com/pennylaneai/pennylane/blob/main/pennylane/templates/embeddings/qaoaembedding.py"
click node_resource "https://github.com/pennylaneai/pennylane/blob/main/pennylane/resource/resource.py"
click node_drawer "https://github.com/pennylaneai/pennylane/blob/main/pennylane/drawer/mpldrawer.py"
click node_data "https://github.com/pennylaneai/pennylane/blob/main/pennylane/data/base/dataset.py"
click node_qasm "https://github.com/pennylaneai/pennylane/blob/main/pennylane/io/qasm_interpreter.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_ops,node_wires,node_queue,node_script,node_measure toneBlue
class node_transforms,node_decomp,node_compile,node_device,node_simulator,node_hardware toneAmber
class node_gradients,node_interfaces,node_optimizers,node_api toneMint
class node_qchem,node_fermions,node_templates toneRose
class node_resource,node_drawer,node_data,node_qasm,node_user toneIndigo
```

## Components

### Circuit Modeling

- [Operators and gates](https://github.com/pennylaneai/pennylane/blob/main/pennylane/core/operator/base.py): `pennylane/core/operator/base.py`
- [Wire model](https://github.com/pennylaneai/pennylane/blob/main/pennylane/wires.py): `pennylane/wires.py`
- [Operation queue](https://github.com/pennylaneai/pennylane/blob/main/pennylane/core/queuing.py): `pennylane/core/queuing.py`
- [Quantum script](https://github.com/pennylaneai/pennylane/blob/main/pennylane/core/qscript.py): `pennylane/core/qscript.py`
- [Measurements](https://github.com/pennylaneai/pennylane/blob/main/pennylane/core/measurements.py): `pennylane/core/measurements.py`

### Execution and Compilation

- [Circuit transforms](https://github.com/pennylaneai/pennylane/blob/main/pennylane/core/transforms/transform.py): `pennylane/core/transforms/transform.py`
- [Gate decomposition](https://github.com/pennylaneai/pennylane/blob/main/pennylane/decomposition/decomposition_rule.py): `pennylane/decomposition/decomposition_rule.py`
- [Compile pipeline](https://github.com/pennylaneai/pennylane/blob/main/pennylane/core/transforms/compile_pipeline.py): `pennylane/core/transforms/compile_pipeline.py`
- [Device interface](https://github.com/pennylaneai/pennylane/blob/main/pennylane/devices/device_api.py): `pennylane/devices/device_api.py`
- [Qubit simulators](https://github.com/pennylaneai/pennylane/blob/main/pennylane/devices/qubit/simulate.py): `pennylane/devices/qubit/simulate.py`
- **Quantum hardware**

### Differentiation and Learning

- [Gradient transforms](https://github.com/pennylaneai/pennylane/blob/main/pennylane/gradients/parameter_shift.py): `pennylane/gradients/parameter_shift.py`
- [JAX interface](https://github.com/pennylaneai/pennylane/blob/main/pennylane/workflow/interfaces/jax.py): `pennylane/workflow/interfaces/jax.py`
- [Optimizers](https://github.com/pennylaneai/pennylane/blob/main/pennylane/optimize/rotosolve.py): `pennylane/optimize/rotosolve.py`

### Quantum Applications

- [Quantum chemistry](https://github.com/pennylaneai/pennylane/blob/main/pennylane/qchem/convert.py): `pennylane/qchem/convert.py`
- [Fermionic operators](https://github.com/pennylaneai/pennylane/blob/main/pennylane/fermi/fermionic.py): `pennylane/fermi/fermionic.py`
- [Circuit templates](https://github.com/pennylaneai/pennylane/blob/main/pennylane/templates/embeddings/qaoaembedding.py): `pennylane/templates/embeddings/qaoaembedding.py`

### Analysis and Tools

- [Resource estimation](https://github.com/pennylaneai/pennylane/blob/main/pennylane/resource/resource.py): `pennylane/resource/resource.py`
- [Circuit drawing](https://github.com/pennylaneai/pennylane/blob/main/pennylane/drawer/mpldrawer.py): `pennylane/drawer/mpldrawer.py`
- [Quantum data](https://github.com/pennylaneai/pennylane/blob/main/pennylane/data/base/dataset.py): `pennylane/data/base/dataset.py`
- [OpenQASM interface](https://github.com/pennylaneai/pennylane/blob/main/pennylane/io/qasm_interpreter.py): `pennylane/io/qasm_interpreter.py`

### Other components

- **Quantum developer**
- [PennyLane API](https://github.com/pennylaneai/pennylane/blob/main/pennylane/__init__.py): `pennylane/__init__.py`

## Connections

- Quantum developer → PennyLane API: uses (evidence: `README.md`)
- PennyLane API → Operators and gates: exposes (evidence: `pennylane/__init__.py`)
- Operators and gates → Operation queue: records in (evidence: `pennylane/core/queuing.py`)
- Operation queue → Quantum script: collects into (evidence: `pennylane/core/qscript.py`)
- Quantum script → Measurements: stores (evidence: `pennylane/core/qscript.py`)
- Quantum script → Wire model: uses (evidence: `pennylane/core/qscript.py`)
- Quantum script → Circuit transforms: transformed by (evidence: `pennylane/core/transforms/compile_pipeline.py`)
- Gate decomposition → Operators and gates: decomposes (evidence: `pennylane/decomposition/decomposition_rule.py`)
- Compile pipeline → Quantum script: processes (evidence: `pennylane/core/transforms/compile_pipeline.py`)
- Compile pipeline → Circuit transforms: uses (evidence: `pennylane/core/transforms/compile_pipeline.py`)
- Quantum script → Device interface: executes on
- Device interface → Qubit simulators: simulates with
- Device interface → Quantum hardware: targets
- Gradient transforms → Quantum script: transforms (evidence: `pennylane/gradients/parameter_shift.py`)
- JAX interface → Quantum script: binds parameters (evidence: `pennylane/workflow/interfaces/jax.py`)
- Quantum developer → Optimizers: optimizes with
- Optimizers → JAX interface: differentiates through
- Quantum developer → Circuit templates: builds circuits (evidence: `README.md`)
- Quantum developer → Quantum chemistry: models chemistry (evidence: `README.md`)
- Quantum chemistry → Fermionic operators: uses operators
- Quantum developer → Resource estimation: estimates resources (evidence: `README.md`)
- Quantum developer → Circuit drawing: visualizes circuits
- Quantum developer → Quantum data: loads datasets
- Quantum developer → OpenQASM interface: imports circuits
