-
Notifications
You must be signed in to change notification settings - Fork 56
Visualization of classically-controlled operations for %trace #158
Description
Is your feature request related to a problem? Please describe.
As a developer, I might want to visualize the circuit associated with the execution of a Q# operation at any point in time. This would make debugging easier and even allow tutorials/notebooks to be more visual.
Describe the solution you'd like
The circuit should be displayed (as an SVG/HTML/image) based on a new magic command (i.e. %trace operation_name
). This %view
command will follow similar semantics for arguments as %simulate
with the result instead being the printing/visualization of the circuit.
The circuit displayed should represent the operations invoked starting directly from the EntryPoint
up to n
levels deep (where n
is a configurable attribute via %config trace.defaultDepth={n}
).
For certain well-known operations, we will show their custom display, such as:
- SWAP
- M
- Measure
- Operations under the
Microsoft.Quantum.Array
namespace - CNOT
- Controlled operations (can be controlled on classical registers)
- Adjoint operations
Other operations will just show their name as a label (with non-qubit arguments) inside a box. The boxes should increase in width to fit the label.
Additional context
Other examples of quantum circuit visualizers:
Components to implementing this feature
- Simulator hook to convert incoming operations into a JSON string for rendering (#301 and Add
ExecutionPathTracer
to repo. #195) - JS visualizer that takes in above JSON and returns the HTML visualization (Add path visualizer JS files #201)
- Add magic command to IQ# to tie everything together (Add trace magic command #209)
- Implement ApplyToEach functionality (#296 and Add composite operation handling #219)
- Implement classical control functionality.
- Add sample doc to document feature (#390).