Skip to content

Conversation

fkiwit
Copy link

@fkiwit fkiwit commented Sep 22, 2025

Title:
Add demo on loading classical data with low-depth circuits

Summary:
This pull request adds a new demonstration on how to efficiently load classical image data into quantum states using low-depth quantum circuits, based on the paper "Typical Machine Learning Datasets as Low‑Depth Quantum Circuits". The demo uses the MNIST dataset and shows how to train a variational quantum classifier on the encoded data. This demo leverages the new qml.data module for dataset loading.

Relevant references:

  • "Typical Machine Learning Datasets as Low‑Depth Quantum Circuits" (2025) [1]
  • "A flexible representation of quantum images for polynomial preparation, image compression, and processing operations" [2, 3]
  • "A Multi-Channel Representation for images on quantum computers using the RGBα color space" [4, 5]
  • "Efficient MPS representations and quantum circuits from the Fourier modes of classical image data" [6]

Possible Drawbacks:
The dataset required for this demo is large (~1GB), which might be a consideration for users with limited bandwidth or storage.

Related GitHub Issues:
None


If you are writing a demonstration, please answer these questions to facilitate the marketing process.

  • GOALS — Why are we working on this now?

Promote the new qml.data feature for loading datasets and show a PennyLane implementation of a recent paper on efficient data loading for QML.

  • AUDIENCE — Who is this for?

QML researchers, students, and practitioners interested in efficient data loading techniques and their application to image classification tasks.

  • KEYWORDS — What words should be included in the marketing post?

Quantum Machine Learning, Quantum Datasets, Image Loading, Low-depth circuits, Variational Quantum Classifier, MNIST, PennyLane, qml.data

  • Which of the following types of documentation is most similar to your file?
    (more details here)
  • Tutorial
  • Demo
  • How-to

Copy link

Your preview is ready 🎉!

You can view your changes here

Copy link
Contributor

@DSGuala DSGuala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made an initial skim and left comments. Overall a very nice/complete first draft.

Still pending from my side:

  • In depth review of the text for clarity
  • In depth review of the code for efficiency and output

But basically I think 1 or two more rounds of review and this should be ready to go.

# effectively shifting the gates with the dashed outlines to the right, the gates are applied
# sequentially outward starting from the center. This reduces the circuit depth while maintaining its
# expressivity.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should solve the figure rendering issue.

Suggested change
#

circuit_layout = dataset_params.circuit_layout_d4
circuit = get_circuit(circuit_layout)
params_01 = np.asarray(dataset_params.params_d4)[selection]
states_01 = np.asarray([circuit(params) for params in tqdm(params_01, desc="States for depth 4")])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tqdm causes this to render many lines with a scroll bar. Maybe we can reduce the number of prints?

# 3. Quantum classifiers
# ----------------------
#
# In this demo, we train a **variational quantum circuit** as classifier. Our datasets require
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# In this demo, we train a **variational quantum circuit** as classifier. Our datasets require
# In this demo, we train a **variational quantum circuit** as a classifier. Our datasets require

# - **Quantum‑kernel SVMs** — replacing inner products by quantum state overlaps.
# - **Tensor‑network (MPS/MPO) classifiers** for large qubit counts.
#
# In this demo we use a small linear VQC. The circuit consisits of two qubit gates correspdonding to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# In this demo we use a small linear VQC. The circuit consisits of two qubit gates correspdonding to
# In this demo we use a small linear VQC. The circuit consists of two qubit gates corresponding to

#
# We start by **casting** the FRQI amplitude vectors and their digit labels into JAX arrays. Next, the
# states and labels are shuffled from a pseudorandom key derived from the global ``SEED``. Then, the
# data is split into training and validation. Finally, we gather the tensors corresponding in the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# data is split into training and validation. Finally, we gather the tensors corresponding in the
# data is split into training and validation. Finally, we gather the tensors corresponding to the

r"""Loading classical data with low-depth circuits
==============================================

The encoding of arbitrary classical data into quantum states usually comes at a high computational
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to make sure to preserve your style of writing, so feel free to ignore any suggestions that you don't agree with.

Suggested change
The encoding of arbitrary classical data into quantum states usually comes at a high computational
Encoding arbitrary classical data into quantum states usually comes at a high computational

inherent structure (such as image data) which can be leveraged to load them with a much smaller cost
on a quantum computer. The paper **“Typical Machine Learning Datasets as Low‑Depth Quantum
Circuits”** (2025) [`1 <#References>`__] develops an efficient algorithm for finding low-depth
quantum circuits to load classical image data as quantum states.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe?

Suggested change
quantum circuits to load classical image data as quantum states.
quantum circuits to load classical image data into quantum states.

Comment on lines +12 to +14
Low‑Depth Quantum Circuits”** (2025). We will discuss the following three steps: 1) Quantum image
states, 2) Low-depth image circuits, 3) Training a small variational‑quantum‑circuit (VQC)
classifier on the dataset.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't mind getting a bit more information about what we will discuss. For example, we can include a verb in each item of the list:

  1. Define how images can be encoded in quantum states
  2. Introduce low-depth image circuits to generate these states
  3. ...

(just examples, no need to use those)



######################################################################
# Downloading the quantum image dataset
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can link the datasets page in here somewhere https://pennylane.ai/datasets/collection/low-depth-image-circuits

Comment on lines +124 to +135
# ===================== =============================================================
# Attribute Description
# ===================== =============================================================
# ``exact_state`` The exact state that the corresponding circuit should prepare
# ``labels`` The correct labels classifying the corresponding images
# ``circuit_layout_d4`` The layout of the depth 4 circuit
# ``circuit_layout_d8`` The layout of the depth 8 circuit
# ``params_d4`` Parameters for the depth 4 circuit
# ``params_d8`` Parameters for the depth 8 circuit
# ``fidelities_d4`` Fidelities between the depth 4 state and the exact state
# ``fidelities_d8`` Fidelities between the depth 8 state and the exact state
# ===================== =============================================================
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we link the dataset page, we might not need the table, up to you. In my case the table takes up almost the full page 🤯
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants