NVIDIA / NVIDIA/cuda-quantum

Support backends using OpenQasm2

Open
#2,396 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

codegen enhancement stale-notified
Dominant language
C++
Stars
1.1k
Forks
456
Avg merge
1d 22h
Merged PRs (30d)
165

Description

Required prerequisites
  • Search the issue tracker to check if your feature has already been mentioned or rejected in other issues.
Describe the feature

We have a pipeline support for backends using OpenQasm2 but bunch of tests fail due to missing optimizations.

  • Some unused globals are not removed:

    • custom_operation_basic.cpp
    • custom_operation_adj.cpp
    • int8_t.cpp
    • int8_t_free_func.cpp
    • load_value.cpp
    • swap_gate.cpp
    • variable_size_qreg.cpp
  • https://github.com/NVIDIA/cuda-quantum/pull/2379/

  • CCZ and r?<adj> operations need to be decomposed

    • graph_coloring-1.cpp
    • graph-coloring.cpp
    • sudoku_2x2.cpp
    • sudoku_2x2-1.cpp
    • sudoku_2x2-bit_names.cpp
    • sudoku_2x2-reg_name.cpp
  • https://github.com/NVIDIA/cuda-quantum/pull/2379

  • quake.concat and quake.subveq need expansion

    • custom_operation_ctrl.cpp
    • qspan_slices.cpp
  • quake.subveq used in mz(veq)

    • phase-estimation.cpp
  • in Python, mz(veq) generates allocations and stores are not optimized away

    • Note that using cudaq.translate API instead of cudaq.sample works.
      Looks like the loop might be created by expand-measurements pass in one case but not in the other.
      Consider optimizing away unused array allocations.
  • Add tests for python

  • The following generated code is not accepted on some backends, it errors out with
    RuntimeError: [line 10] cannot declare bit register. Only 1 bit register(s) is/are supported:

OPENQASM 2.0;

qreg var0[2];
h var0[0]; cnot var0[0], var0[1];
creg var3[1];
measure var0[0] -> var3[0];
creg var4[1];
measure var0[1] -> var4[0];

Related: https://github.com/NVIDIA/cuda-quantum/issues/2325

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the failing C++ cases listed in the issue and review PR 2379, then compare the cudaq.translate and cudaq.sample paths for Python measurement handling. Inspect the expand-measurements pass and the generated OpenQASM 2.0 example. Done means the listed optimizations and decompositions work, Python tests exist, and affected backends accept the generated code.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.