Extend base/adaptive profile capabilities by performing classical computations while "offline"
- Dominant language
- Rust
- Stars
- 1k
- Forks
- 212
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 65
Description
A few important algorithms (such as VQE) are structured in the following way:
1. Prepare quantum state using parameters
2. Run quantum operations and measure results
3. Analyze measured results and make adjustments to preparation parameters
4. Repeat
Note that step (3) has only classical calculations, potentially complex, that won't work in base or adaptive profile. However, algorithm doesn't need to maintain coherent quantum state between iterations of the cycle. Such computations could be done on a classical computer between "shots" of quantum computation. Base profile setup should potentially be capable of doing this if classical computations are done on a device outside quantum computer.
Currently this can be done in Python with Q# used as a subroutine but cannot be done from within Q#.
One approach to allow this is to introduce 'procedure' (in addition to 'function' and 'operation'). Procedure would only allow to use classical computations and call into procedures, functions and operations, but functions and operations won't be allowed to call into procedures. Once procedure calls into operation, a new instance of quantum computing unit is started and completes all necessary quantum computation. No quantum state needs to be saved between invocation of operations from procedures.
Alternatively, compiler may be smart enough to detect this from the code. A quantum computing unit may be initialized only when the first operation is called that allocates qubits. Once this operation exits, quantum state is no longer accessible, and quantum computing unit may be shut down. All computations between invocations of quantum computing units can be done on classical computer without limitations.
Contributor guide
Research direction
No files, tests, or entry points are named. Start by locating the base and adaptive profile implementations and the Q# compiler/runtime handling for operation invocations, then resolve whether procedures or compiler detection is intended. Done means classical computation can run between quantum invocations without preserving quantum state.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100