microsoft / microsoft/qdk

QIR generation fails when code includes comparison of tuples or arrays

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

Nobody has claimed this yet.

bug needs triage
Dominant language
Rust
Stars
1k
Forks
212
Avg merge
3d 8h
Merged PRs (30d)
65

Description

RCA does not block programs with comparisons of Result tuples or Result arrays, because Results are considered supported dynamic types. However, comparison across aggregates is not supported in partial eval, so it hits an unexpected failure at QIR generation time.

Here's some example code:
```qsharp
operation Main() : Bool {
use (q0, q1) = (Qubit(), Qubit());
let (r0, r1) = (M(q0), M(q1));

// This version succeeds because it does individual comparisons
// r0 == Zero and r1 == Zero

// This version fails because it compares across arrays.
// [r0, r1] == [Zero, Zero]

// This version also fails because it compares across tuples.
(r0, r1) == (Zero, Zero)
}
```

We need to decide to either support destructing aggregate comparison into individual comparisons in RCA or block comparison of aggregates in RCA so the user gets a design time error.

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 by reproducing the Q# example through RCA and follow the failure at partial evaluation and QIR generation. The work is complete when the project has chosen and implemented either aggregate comparison decomposition into individual comparisons or a design-time error for unsupported aggregate comparisons.

Written by the indexing model from the issue text.

Assessment

Domain
compilers, quantum-computing
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.