# Quantum nodes¶

## Classical and quantum information¶

It is important to distinguish between classical and quantum forms of information. For our purposes, we will consider the value of a number stored within a conventional digital computer (say, a floating point binary representation of a real or complex number) as classical information. Many common functions — like addition, subtraction, multiplication, $$\sin,\cos,\exp,$$ etc. — can all be evaluated efficiently on a classical computer, e.g., using the NumPy library in Python. These functions map floating point numbers to floating point numbers. In other words, they are functions which process classical information.

On the other hand, quantum information will refer to the state of a complex-valued vector in a quantum Hilbert space. Gates in a quantum computer transform quantum states to quantum states, i.e., they process quantum information.

Classical information refers to the state of binary numbers stored on a conventional digital computer. Quantum information refers to the state of a complex-valued vector in a quantum Hilbert space.

Note

Quantum information processing can be simulated on a classical computer, but in general this cannot be done efficiently.

## Interfacing the classical and quantum worlds¶

There are many schemes for loading classical information into quantum systems, but these can often get quite complex. To connect between the classical and quantum worlds, PennyLane uses two straightforward methods:

1. Gate parameters

The gates used in a quantum circuit often have classical parameters associated with them. This classical information determines how a quantum state is transformed — e.g., what angle we should rotate the quantum state by. Thus, gate arguments provide us a way to imprint classical data onto quantum states, converting classical information to quantum information [1].

2. Measurement of a quantum circuit

Measurements convert quantum information (the state of a quantum system) into classical information (the measurement value). Measurements often have a probability distribution of outcomes, with the pattern becoming clear only after a sufficient number of measurements are taken.

In PennyLane, we work with expectation values (i.e., averages) of measurement outcomes as our primary mechanism for obtaining classical information from quantum devices [2].

## The quantum node abstraction¶

A quantum node is a computational encapsulation of a quantum function $$f(x;\mathbf{\theta})$$ which has different resolution for different computational devices.

• For a quantum computing device, a quantum node is a variational circuit whose gates are parameterized by $$x$$ and $$\mathbf{\theta}$$ and whose measurement outcomes are averaged to produce an expectation value.
• For a classical computing device, a quantum node is a callable function, taking the arguments $$(x,\mathbf{\theta})$$ and returning the value $$f(x;\mathbf{\theta})$$. The classical device cannot “zoom in” and see any intermediate state of the quantum circuit.

Quantum nodes are seen differently depending on the computational device. A classical device merely sees a callable function which transforms classical information. A quantum device sees a higher resolution version, with quantum gates and measurements.

Note

For a function $$f(x; \mathbf{\theta})$$, $$x$$ is considered to be the function’s input and $$\mathbf{\theta}$$ are parameters which determine the exact form of $$f$$.

So long as we provide some mechanism for evaluating quantum nodes (i.e., a quantum computing device or simulator), a classical computing device can treat it as it would any other callable function which manipulates classical data. We can thus connect quantum nodes with classical transformations to build complex multistage hybrid quantum-classical computations.