Quantum computing and AIMiddleLesson 3076 min read

What quantum computers might do for AI

Quantum machine learning is an active research area with interesting ideas and serious open problems. Learn the main ideas, the data loading problem, and what is not yet known.

Lesson in motion

In 60 seconds

What quantum computers might do for AI

Quantum machine learning is an active research area with interesting ideas and serious open problems. Learn the main ideas, the data loading problem, and what is not yet known.

1/4
In simple words
Imagine a very fast cook in a kitchen with a tiny door. The cook can make dishes quickly, but every ingredient has to be passed in through the tiny door, one by one. If the ingredients take longer to pass in than the whole meal takes to cook in a normal kitchen, the fast cook does not help. Quantum computers for AI can have a problem like this tiny door.
Quantum machine learning (QML) asks whether quantum computers can help learn from data: faster, with less data, or with better models. It is an active research field. There are good ideas, but no proven, practical speed-up for everyday AI tasks such as training large language models or image classifiers.

The main ideas people explore

IdeaWhat it meansOpen questions
Variational quantum circuitsA small quantum circuit with adjustable angles, trained by a normal computer, a bit like a tiny neural networkTraining can get stuck on very flat landscapes ("barren plateaus"); noise hurts; unclear advantage
Quantum kernelsUse a quantum circuit to measure how similar two data points are, then use a classical method like a support vector machineMust beat strong classical kernels; some quantum kernels become hard to use as qubits grow
Quantum linear algebraAlgorithms that, under strict conditions, handle some matrix problems much faster in theoryThe conditions are strict; data loading and reading answers out can cancel the gain
Quantum dataLearning from data that already comes from quantum experiments or sensorsPromising in theory, because the data is quantum from the start

The data loading problem

One tempting idea is amplitude encoding: put a list of 2ⁿ numbers into the amplitudes of just n qubits. A 1024-number vector would fit into 10 qubits. That sounds like a huge saving.
The tempting story
  • n qubits hold 2ⁿ numbers, so big data fits in a few qubits
  • The quantum computer then processes all the numbers at once
  • So machine learning becomes exponentially faster
The catch
  • Loading 2ⁿ arbitrary numbers into amplitudes generally takes a lot of steps, often about as many as the numbers themselves
  • Measuring gives only n bits per shot, so reading out a big answer takes many runs
  • Some claimed quantum speed-ups were later matched by new classical algorithms that make similar assumptions
So a speed-up must survive the whole pipeline: load the data, compute, and read out the answer. Many proposals only speed up the middle part.

A simpler encoding you can run

Another way is angle encoding: turn one number x into a rotation of one qubit. Here the state is cos(x/2)|0⟩ + sin(x/2)|1⟩. It is easy to load, but uses one qubit per number.
Python: angle encoding one numberpython
import numpy as np

def angle_encode(x):
    return np.array([np.cos(x / 2), np.sin(x / 2)])

for x in [0.0, np.pi / 3, np.pi / 2, np.pi]:
    state = angle_encode(x)
    p1 = abs(state[1]) ** 2
    print(f"x = {x:.3f}  state = {np.round(state, 3)}  P(1) = {p1:.3f}")

It also goes the other way: AI for quantum

Machine learning is also used to help build quantum computers: for example to tune and calibrate hardware, to design pulses that control qubits, and to decode errors quickly in error correction. Here the benefit is practical today, because the AI runs on normal computers.
Note
How to read a quantum AI headline: ask (1) Is the speed-up proven, or suggested? (2) Is it compared with the best classical method, not a weak one? (3) Does it count the time to load data and read results? (4) Was it run on real hardware, or only simulated, and at what size?
Try this. How many qubits would amplitude encoding need for a 28 × 28 grey image (784 pixels)? Round up to the next power of 2.

Watch and read more

Lab

Two functions: how many qubits amplitude encoding needs, and an encoder that pads and normalises a data vector.

~25 min

The problem

Run this in the browser, or with Python 3 and numpy.

  1. Finish qubits_needed(length): the smallest n with 2ⁿ ≥ length. For length 1, return 1.
  2. Finish amplitude_encode(x): pad the list with zeros up to length 2ⁿ, then divide by its length (norm) so the squared amplitudes add to 1. Return a numpy array.
  3. Run the starter. How many qubits does a 784-pixel image need? Then write two sentences on why "10 qubits hold 784 pixels" does not by itself make learning faster.

Practice lab

Edit the code and run it. Python runs in your browser — nothing is sent to our server.

Output

No output. Add print(...) to see values.

You are done when

Hard questions

Try to answer before you reveal. If you can answer these, you understood the lesson.

Q1Amplitude encoding divides by the norm. What information about the original data is lost, and when does that matter?Reveal

The overall size (length) of the vector is lost: [3, 4] and [30, 40] give the same state. If the size matters for your task, for example total rainfall, you must store it separately as an ordinary number or add it as an extra feature before encoding.

Q2Why might learning from quantum data be more promising than loading classical data like images?Reveal

With quantum data, such as states produced by a quantum sensor or a chemistry experiment, the data is already in quantum form, so there is no costly step of loading classical numbers into amplitudes. Some theory results suggest real advantages in such settings. With classical images, the loading step and the strength of existing classical methods make an advantage much harder to show.

Please sign in to continue.

Questions people ask

Will quantum computers train large chatbot models soon?

There is no known way to do that with a proven advantage, and today's quantum machines are far too small and noisy. Large models need huge amounts of data loaded and processed, which is exactly where quantum computers are weak. This may change with new research, but no one can promise it.

Is quantum machine learning a waste of time, then?

No. It is a real research field asking real questions. Knowing what does not work is also progress. Some directions, like learning from quantum data and AI that helps build quantum hardware, look especially interesting.

What is a barren plateau?

When training some variational quantum circuits with many qubits, the slope of the loss can become extremely small almost everywhere, so the training has almost no signal about which way to move. It is like looking for a valley on a huge, almost perfectly flat field.

Where can students in India study this?

Many universities and research institutes teach quantum information, often through physics, computer science or electrical engineering. India also has a National Quantum Mission that supports research and skills in this area. Check current programmes on official institute websites.

Lesson test

5 questions. Get 3 right (60%) to pass and complete this lesson.

Sign in to take the test and save your progress