or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

tessl/pypi-qiskit

An open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/qiskit@2.1.x

To install, run

npx @tessl/cli install tessl/pypi-qiskit@2.1.0

0

# Qiskit

1

2

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives. It provides comprehensive quantum computing capabilities including circuit construction, quantum information processing, hardware-aware transpilation, and quantum algorithm development.

3

4

## Package Information

5

6

- **Package Name**: qiskit

7

- **Language**: Python

8

- **Installation**: `pip install qiskit`

9

- **Version**: 2.1.2

10

11

## Core Imports

12

13

```python

14

import qiskit

15

```

16

17

Essential components:

18

19

```python

20

from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister

21

from qiskit import transpile

22

from qiskit.quantum_info import Statevector, Operator

23

from qiskit.primitives import Sampler, Estimator

24

```

25

26

## Basic Usage

27

28

```python

29

from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, transpile

30

from qiskit.primitives import StatevectorSampler

31

import numpy as np

32

33

# Create quantum and classical registers

34

qreg = QuantumRegister(2, 'q')

35

creg = ClassicalRegister(2, 'c')

36

37

# Build a quantum circuit

38

circuit = QuantumCircuit(qreg, creg)

39

circuit.h(qreg[0]) # Hadamard gate on first qubit

40

circuit.cx(qreg[0], qreg[1]) # CNOT gate creating entanglement

41

circuit.measure(qreg, creg) # Measure all qubits

42

43

# Transpile for optimization

44

transpiled_circuit = transpile(circuit, optimization_level=1)

45

46

# Execute using V2 primitives

47

sampler = StatevectorSampler()

48

job = sampler.run([transpiled_circuit], shots=1024)

49

result = job.result()

50

counts = result[0].data.c.get_counts() # Access by register name

51

print(f"Measurement counts: {counts}")

52

```

53

54

## Architecture

55

56

Qiskit's modular architecture enables quantum computing workflows from high-level algorithms to low-level hardware control:

57

58

- **Circuit Framework**: Quantum circuit construction with registers, gates, and measurements

59

- **Quantum Information**: Mathematical foundation with states, operators, and information measures

60

- **Primitives**: Modern execution interface (Sampler for measurements, Estimator for expectation values)

61

- **Transpiler**: Hardware-aware circuit optimization and mapping system

62

- **Providers**: Hardware abstraction layer for various quantum backends

63

- **Synthesis**: Advanced algorithm synthesis and decomposition techniques

64

65

This design supports the full quantum computing stack from research algorithms to production quantum applications.

66

67

## Capabilities

68

69

### Circuit Construction

70

71

Build and manipulate quantum circuits with comprehensive gate libraries, control flow, and parameterization support.

72

73

```python { .api }

74

class QuantumCircuit:

75

def __init__(self, *args, **kwargs): ...

76

def h(self, qubit): ...

77

def cx(self, control_qubit, target_qubit): ...

78

def measure(self, qubit, clbit): ...

79

def add_register(self, register): ...

80

81

class QuantumRegister:

82

def __init__(self, size: int, name: str = None): ...

83

84

class ClassicalRegister:

85

def __init__(self, size: int, name: str = None): ...

86

```

87

88

[Circuit Construction](./circuit-construction.md)

89

90

### Quantum Information Processing

91

92

Work with quantum states, operators, channels and information-theoretic measures for quantum algorithm development.

93

94

```python { .api }

95

class Statevector:

96

def __init__(self, data, dims=None): ...

97

def evolve(self, other): ...

98

def expectation_value(self, oper): ...

99

100

class Operator:

101

def __init__(self, data, input_dims=None, output_dims=None): ...

102

def compose(self, other): ...

103

def tensor(self, other): ...

104

105

def state_fidelity(state1, state2): ...

106

def process_fidelity(channel1, channel2): ...

107

```

108

109

[Quantum Information](./quantum-information.md)

110

111

### Quantum Primitives

112

113

Execute quantum circuits using modern V2 primitives interface with Primitive Unified Blocs (PUBs) for efficient vectorized computation.

114

115

```python { .api }

116

class StatevectorSampler:

117

def run(self, pubs, *, shots=None): ...

118

119

class StatevectorEstimator:

120

def run(self, pubs, *, precision=None): ...

121

122

class PrimitiveResult:

123

def __getitem__(self, index): ... # Access PubResults

124

125

class SamplerPubResult:

126

data: DataBin # Access via register names, e.g., data.c

127

128

class EstimatorPubResult:

129

data: DataBin # Access expectation values via data.evs

130

```

131

132

[Primitives](./primitives.md)

133

134

### Circuit Transpilation

135

136

Optimize and map quantum circuits for specific hardware backends with comprehensive pass management.

137

138

```python { .api }

139

def transpile(circuits, backend=None, optimization_level=None, **kwargs): ...

140

141

def generate_preset_pass_manager(optimization_level, backend=None, **kwargs): ...

142

143

class PassManager:

144

def run(self, circuits): ...

145

def append(self, passes): ...

146

147

class CouplingMap:

148

def __init__(self, couplinglist=None, description=None): ...

149

```

150

151

[Transpilation](./transpilation.md)

152

153

### Quantum Gates and Operations

154

155

Comprehensive library of quantum gates from basic Pauli operations to advanced multi-qubit gates and composite operations.

156

157

```python { .api }

158

# Single-qubit gates

159

class HGate(Gate): ...

160

class XGate(Gate): ...

161

class RZGate(Gate):

162

def __init__(self, phi): ...

163

164

# Two-qubit gates

165

class CXGate(Gate): ...

166

class CZGate(Gate): ...

167

class SwapGate(Gate): ...

168

169

# Multi-qubit gates

170

class CCXGate(Gate): ...

171

class MCXGate(Gate):

172

def __init__(self, num_ctrl_qubits): ...

173

```

174

175

[Gates and Operations](./gates-operations.md)

176

177

### Hardware Providers

178

179

Abstract interface to quantum hardware backends with configuration, job management, and provider ecosystem.

180

181

```python { .api }

182

class Backend:

183

def run(self, circuits, **kwargs): ...

184

@property

185

def target(self): ...

186

187

class Job:

188

def result(self): ...

189

def status(self): ...

190

191

class BackendConfiguration:

192

n_qubits: int

193

coupling_map: List[List[int]]

194

```

195

196

[Providers](./providers.md)

197

198

### Algorithm Synthesis

199

200

Advanced synthesis techniques for Clifford circuits, permutations, linear functions, and quantum algorithm primitives.

201

202

```python { .api }

203

def synth_clifford_full(clifford): ...

204

def synth_permutation_depth_lnn_kms(pattern): ...

205

def synth_cnot_count_full_pmh(state): ...

206

207

class LieTrotter:

208

def __init__(self, reps=1): ...

209

210

class SuzukiTrotter:

211

def __init__(self, order, reps=1): ...

212

```

213

214

[Synthesis](./synthesis.md)

215

216

### Quantum Circuit Formats

217

218

Import/export quantum circuits in OpenQASM 2.0/3.0 and QPY binary formats for interoperability.

219

220

```python { .api }

221

# QASM2

222

def load(filename): ...

223

def loads(qasm_str): ...

224

def dump(circuit, filename): ...

225

def dumps(circuit): ...

226

227

# QPY

228

def dump(circuits, file_obj): ...

229

def load(file_obj): ...

230

```

231

232

[Circuit Formats](./circuit-formats.md)

233

234

### Visualization

235

236

Comprehensive visualization tools for quantum circuits, states, measurement results, and hardware topologies.

237

238

```python { .api }

239

def circuit_drawer(circuit, output=None, **kwargs): ...

240

def plot_histogram(data, **kwargs): ...

241

def plot_bloch_vector(bloch, **kwargs): ...

242

def plot_state_qsphere(state, **kwargs): ...

243

def visualize_transition(circuit, **kwargs): ...

244

```

245

246

[Visualization](./visualization.md)

247

248

## Types

249

250

```python { .api }

251

from typing import Union, List, Dict, Optional, Tuple, Any

252

import numpy as np

253

254

# Core types

255

Qubit = object # Individual quantum bit

256

Clbit = object # Individual classical bit

257

258

# Circuit types

259

ParameterExpression = object # Mathematical expressions with parameters

260

Instruction = object # Base quantum instruction

261

Gate = object # Unitary quantum gate

262

ControlFlowOp = object # Base control flow operation

263

264

# Quantum information types

265

ArrayLike = Union[List, np.ndarray, 'Statevector', 'DensityMatrix']

266

OperatorLike = Union['Operator', 'Gate', np.ndarray, List]

267

268

# Provider types

269

BackendLike = Union['Backend', str]

270

JobLike = Union['Job', 'JobV1']

271

272

# Result types

273

CountsDict = Dict[str, int] # Measurement counts

274

ProbsDict = Dict[str, float] # Probability distributions

275

DataBin = object # Primitive result data container

276

BitArray = object # Measurement result bit array

277

```