Skip to content

Invalid qubit mapping on disconnected topology #4681

Description

@1tnguyen

Required prerequisites

  • Consult the security policy. If reporting a security vulnerability, do not report the bug using this form. Use the process described in the policy to report the issue.
  • Make sure you've read the documentation. Your issue may be addressed there.
  • Search the issue tracker to verify that this hasn't already been reported. +1 or comment there if it has.
  • If possible, make a PR with a failing test to give us a starting point to work on!

Describe the bug

When using qubit mapping pass with a topology that contains isolated qubits, it outputs invalid results.

Steps to reproduce the bug

  • Device topology: 10 qubits, only edge {5,6}:
Number of nodes: 10

Number of edges: 1

0 --> {}
1 --> {}
2 --> {}
3 --> {}
4 --> {}
5 --> {}
6 --> {5}
7 --> {}
8 --> {}
9 --> {}
  • Quake code
quake.wire_set @wires[2147483647]

func.func @bell() attributes {"cudaq-entrypoint", "cudaq-kernel"} {
  %0 = quake.null_wire
  %1 = quake.null_wire
  %2 = quake.h %0 : (!quake.wire) -> !quake.wire
  %3:2 = quake.x [%2] %1 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)
  %m0, %4 = quake.mz %3#0 : (!quake.wire) -> (!quake.measure, !quake.wire)
  %m1, %5 = quake.mz %3#1 : (!quake.wire) -> (!quake.measure, !quake.wire)
  quake.sink %4 : !quake.wire
  quake.sink %5 : !quake.wire
  return
}
  • Command:
cudaq-opt --assign-wire-indices '--qubit-mapping=device=file(disconnected.txt)' bell.mlir

The output still maps the Bell pair to physical qubits 0 and 1, even though they are not connected.

Expected behavior

  • We shouldn't allow an invalid mapping to succeed (i.e., gates between disconnected qubits)

  • The mapping pass can find the connected qubit region to map the qubits to.

Is this a regression? If it is, put the last known working version (or commit) here.

Not a regression

Environment

  • CUDA-Q version: main
  • Python version: 3.11
  • C++ compiler: gcc-12
  • Operating system: Ubuntu 24.04

Suggestions

No response

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions