Skip to content

Ghost qubit in library mode #981

Description

@boschmitt

Required prerequisites

  • 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

The sampling of a circuit with a single qubit returns a result with a bitstring with two bits.

Steps to reproduce the bug

Compile the following circuit in library mode:

#include <cudaq.h>
#include <iostream>

void bar() __qpu__ {
  cudaq::qubit a;
  cudaq::x(a);
  auto a0 = cudaq::mz(a);
  cudaq::reset(a);
  auto a1 = cudaq::mz(a);
}

int main() {
  std::cout << "Bar:\n";
  auto result = cudaq::sample(bar);
  result.dump();

  return 0;
}

It's execution returns:

Bar:
{ 00:1000 }

Note: this problem seems to not happen when we add a quantum operator after the reset.

Expected behavior

It should return:

Bar:
{ 0:1000 }

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

Not a regression

Environment

  • CUDA Quantum version: nvq++ proto-0.6.0 (main branch)
  • C++ compiler: g++ 13.2.0
  • Operating system: Ubuntu 23.10 (Docker container)

Suggestions

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions