PennyLaneAI / PennyLaneAI/catalyst

OpenQASM runner does not use virtual environment when run from C++

Open
#1,725 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug runtime
Dominant language
Python
Stars
234
Forks
84
Avg merge
2d 15h
Merged PRs (30d)
66

Description

Our OpenQASM runtime tests fail trying to import required packages when a virtual environment is used and the global environment does not have numpy and amazon-braket-sdk installed:

(new_env) ➜ catalyst git:(main) ✗ make test-runtime

/catalyst/runtime/tests/Test_OpenQasmDevice.cpp:624: FAILED:
due to unexpected exception with message:
  Traceback (most recent call last):
    File "<string>", line 3, in <module>
  ModuleNotFoundError: No module named 'braket.aws'

===============================================================================
test cases:  34 |  28 passed |  6 failed
assertions: 183 | 151 passed | 32 failed

At least this is the behaviour observed on macOS with the official Python installer and the built-in venv module.

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 runtime/lib/backend/openqasm/openqasm_python_module.cpp at lines 25-26 and reproduce the failure with make test-runtime, focusing on how the C++ runtime selects Python packages. Use runtime/tests/Test_OpenQasmDevice.cpp around line 624 as the regression check. Done means the runtime tests can import packages installed only in the active virtual environment.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
backend, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.