Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qudit Circuit Interface #10

Open
refraction-ray opened this issue Feb 4, 2025 · 0 comments
Open

Qudit Circuit Interface #10

refraction-ray opened this issue Feb 4, 2025 · 0 comments
Labels
idea Ideas for enhancement

Comments

@refraction-ray
Copy link
Member

TEP - Built-in Qudit Circuit Support in TensorCircuit-NG

Author
@refraction-ray

Status
Draft

Created
2025-02-04

Abstract

This TEP proposes the introduction of native qudit circuit support within TensorCircuit. This will enable users to define and manipulate quantum circuits based on qudits (d-level quantum systems) directly, moving beyond the current qubit-centric approach. The aim is to provide a user-friendly and efficient interface for qudit quantum computation, enhancing TensorCircuit's capabilities and broadening its applicability.

Motivation and Scope

Currently, TensorCircuit primarily focuses on qubit-based quantum circuits. While workarounds exist to simulate qudit systems (as demonstrated in the current hacky implementation), these are often less intuitive, and do not fully leverage the elegance of TensorCircuit-NG's interfaces.

This limitation affects users interested in exploring quantum computation beyond qubits, such as:

  • Quantum algorithms designed for qudits: Certain quantum algorithms are naturally formulated and potentially more efficient using qudits (e.g., some quantum walks, high-dimensional quantum information processing).
  • Simulation of physical systems with higher-dimensional degrees of freedom: Modeling systems in quantum chemistry or condensed matter physics may benefit from direct qudit representations.
  • Quantum information theory research: Exploring the theoretical advantages of higher-dimensional quantum systems requires tools for manipulating and simulating qudit circuits.

This TEP aims to address these limitations by providing:

  • Native qudit circuit representation: A new class, tc.QuditCircuit, will be introduced to represent quantum circuits composed of qudits.
  • Intuitive user interface: The interface should be consistent with the existing tc.Circuit for qubits, allowing for a smooth transition for users and leveraging existing TensorCircuit functionalities. The target interface is tc.QuditCircuit(n_qudits, d=dimension).
  • Efficient simulation: Leverage TensorCircuit's tensor network capabilities to ensure efficient simulation of qudit circuits, potentially optimizing for qudit-specific operations. If possible, MPS + Qudit simulation with tc.MPSQuditCircuit interface can also be implemented.
  • Extensibility: Design the framework to be extensible, allowing for the addition of new qudit gates and functionalities in the future.

The scope of this initial TEP focuses on:

  • Core QuditCircuit class: Implementing the basic structure and functionalities for defining qudit circuits.
  • Fundamental qudit gates: Implementing a set of essential qudit gates which can be found in https://arxiv.org/abs/2501.07812
  • State preparation and measurement: Supporting initialization of qudit states and measurement in computational basis.
  • Integration with existing TensorCircuit functionalities: Ensuring compatibility with existing TensorCircuit features like automatic differentiation, JIT, and GPU support which should automatically work for a successful implementation.

Usage and Impact

Users will be able to create and manipulate qudit circuits using the tc.QuditCircuit class in a manner analogous to tc.Circuit.

Example Usage:

import tensorcircuit as tc
import numpy as np

# Create a qudit circuit with 3 qudits, dimension d=3
n_qudits = 3
d = 3
qc = tc.QuditCircuit(n_qudits, d=d)

# Apply a generalized Pauli-X gate on qudit 0
qc.x(0) # Generalized X, equivalent to cyclic permutation

# Apply a generalized Hadamard gate on qudit 1
qc.h(1) # Generalized Hadamard

# Apply a controlled-phase gate between qudit 0 (control) and qudit 2 (target)
phase = np.exp(1j * np.pi / 4)
qc.cphase(0, 2, phase=phase)


# Get the state vector of the qudit circuit
state_vector = qc.state()

# Measure qudit 0 in the computational basis
measurement_result = qc.measure(0)

print(state_vector)
print(measurement_result)

Backward compatibility

Existing code relying on tc.Circuit and many other functions might implicitly assume qubit computations which should be also corrected accordingly for any $d$.

Implementation

Maybe after refactoring Circuit class is just a wrapper for the more genralized QuditCircuit class with $d=2$.

@refraction-ray refraction-ray added the idea Ideas for enhancement label Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idea Ideas for enhancement
Projects
None yet
Development

No branches or pull requests

1 participant