From Block Diagrams to Bloch Spheres: Graphical Quantum Circuit Simulation in LabVIEW Murtaza Vefadar Abstract As quantum computing transitions from theoretical physics to engineering applications, there is a growing need for accessible simulation tools that bridge the gap between abstract linear algebra and practical implementation. While text-based frameworks (like Qiskit or Cirq) are standard, they often present a steep learning curve for students and engineers accustomed to graphical system design. This paper introduces QuVI (Quantum Virtual Instrument), an open-source quantum circuit toolkit developed natively within the NI LabVIEW environment. Moving beyond initial proof-of-concept models, QuVI establishes a robust framework that leverages LabVIEW’s “dataflow” paradigm, in which wires represent data and nodes represent operations, to provide an intuitive, visual analog to standard quantum circuit notation while enabling the seamless integration of classical control structures like loops and conditionals. The toolkit’s capabilities are demonstrated by constructing and visualizing fundamental quantum algorithms and verifying results against theoretical predictions. By translating “Block Diagrams” directly into quantum state evolutions (“Bloch Spheres”), QuVI offers researchers and educators a powerful platform for prototyping quantum logic without leaving the graphical engineering workspace. I Introduction Quantum computing simulation serves as a crucial intermediary step between algorithm design and hardware execution 9 ; 10 . It allows researchers to verify logic, estimate resource requirements, and understand noise impacts in a controlled environment. Currently, the ecosystem is dominated by text-based frameworks such as Qiskit 1 and Cirq 3 , which require a shift from the visual intuition of circuit diagrams to code. Conversely, web-based graphical simulators like IBM Quantum Composer 7 and Quirk 4 provide intuitive, drag-and-drop interfaces for circuit construction. However, these tools generally lack robust integration with classical control logic. They are typically limited to static circuit execution or simple visualizations, making it difficult to implement dynamic, hybrid quantum-classical workflows involving conditional branching, iterative loops, or complex data processing. LabVIEW (Laboratory Virtual Instrument Engineering Workbench) offers a unique alternative that bridges this gap. Its graphical programming language (G) is inherently parallel and isomorphic to quantum circuit diagrams: wires carry state information, and nodes perform operations. Unlike web-based simulators, LabVIEW is a full-featured programming environment. This work presents QuVI, a versatile quantum circuit toolkit for LabVIEW, which allows its users to wrap quantum circuits inside standard structures (such as For Loops, While Loops, and Case Structures), enabling the seamless construction of complex algorithms where classical logic controls quantum execution flow. A custom state-vector update engine is implemented to exploit CPU parallelism for both single-qubit controlled gates and multi-qubit operations, and the system is validated against standard quantum benchmarks. QuVI is publicly available via the VI Package Manager 1 1 1 https://www.vipm.io/package/murtaza_vefadar_lib_quvi___quantum_circuit_toolkit/ . II QuVI Toolkit Architecture Unique to this implementation is the mapping of LabVIEW’s graphical primitives to quantum circuit components. The simulation architecture relies on specific synchronization structures to maintain the global quantum state while permitting parallel execution of independent operations. II.1 State Management via Queues A critical challenge in graphical dataflow programming is managing large datasets without incurring memory copy overhead at every node. In QuVI, the visual wires connecting quantum gates do not carry the state vector data directly. Instead, a LabVIEW Queue of size 1 is utilized as a global storage buffer for the state vector and system parameters (e.g., qubit count). The wire transmits a reference to this queue, allowing gates to access and modify the shared state vector ”in-place.” II.2 Circuit Composition The simulation environment is constructed using a Flat Sequence Structure , which serves as the canvas for the quantum circuit. 1. Initialization: The circuit begins with ”QuVI Wire” subVIs, each initializing a qubit in the |0\rangle state. These are stacked vertically to define the register size, following the convention that the topmost wire corresponds to q_{0} . 2. Wiring: The horizontal output of each initialization VI is connected to the left border of the sequence structure, establishing the ”quantum wires” that flow from left to right. 3. Execution Flow: Inside the sequence structure, single-qubit gates placed on different wires execute independently via LabVIEW’s native parallelism. Conversely, multi-qubit operations (e.g. controlled gates) introduce dependencies that require explicit synchronization mechanisms to ensure correct state evolution. II.3 Synchronization with Notifiers When entangling operations (controlled gates) occur, data dependencies arise between qubits (see Figure 1 ). To enforce this ordering, a “Watch List” mechanism is implemented. This list acts as a synchronization registry, stored in a LabVIEW Queue of size 1 containing an array of bits representing wire indices. Figure 1: QuVI architecture demonstrating execution flow. Top wire: independent operations execute in parallel via native dataflow. Bottom wires: entangling gates (e.g., CNOT) enforce synchronization using Notifiers to handle state dependencies between control and target qubits. When a controlled gate is executed, the target gate first performs the necessary calculations on the global state vector. Once the update is complete, the Watch List bits are modified according to the control bitmask (”inclusion mask” in the next section). A LabVIEW Notifier is then employed to signal the waiting gates situated immediately after the control and anti-control nodes. Upon receiving this notification, these gates access the updated Watch List. Execution for a specific wire proceeds only if the corresponding bit in the array is observed to be “off,” allowing the gate to safely begin its own operations on the state vector. III Methodology III.1 Single Qubit Gate Update Algorithm To implement the simulation efficiently in a graphical environment, a perfectly parallelizable update scheme is utilized for arbitrary single-qubit gates (controlled or anti-controlled). This method iterates linearly through the state vector, a structure that maps directly to LabVIEW’s Parallel For loops which automatically distribute iterations across processor cores. III.1.1 State Vector Update Rule The core of the QuVI engine avoids constructing the full Hilbert space operator O=I\otimes\dots\otimes U\otimes\dots\otimes I . Instead, it utilizes a per-element update strategy that is pleasingly parallel. For a 2\times 2 gate matrix U , applied to target qubit k , the algorithm iterates through every index i of the state vector independently. For each i , a “partner” index j separated by a stride distance of 2^{k} (specifically, j=i\oplus 2^{k} ) is identified. The update logic calculates the new amplitude b_{i} by mixing the input amplitudes a_{i} and a_{j} according to the gate matrix U . This relationship is illustrated by the butterfly structure in Figure 2 . Because the computation of any output element b_{i} relies only on the input state vector and does not depend on other output elements, the loop can be executed in parallel without race conditions. Importantly, this approach minimizes memory overhead for the operator itself. Storing the full unitary matrix for an n -qubit system would require O(4^{n}) memory 8 . In contrast, the kernel-based approach requires only O(1) memory to store the gate parameters U , while maintaining the standard O(N) memory requirement for the state vector itself (where N=2^{n} ). Figure 2: Butterfly crossovers illustrating the stride logic for qubit k (adapted from 8 ). The figure details the transformation formula of |b\rangle from |a\rangle for each case of a three-qubit system ( k=0,1,2 ), where I_{2} denotes the 2\times 2 Identity matrix. The arrow of the partner amplitude a_{\text{partner}} is colored blue for i_{k}=0 and red for i_{k}=1 (dashed arrows mark i_{k} indices for each case). III.1.2 Controlled Gate Logic To handle arbitrary control configurations, the update is generalized to a conditional element-wise rule using two bitmasks: 1. Inclusion Mask ( \mathcal{M}_{\text{inc}} ) : A bitmask identifying which qubits act as controls. Bits are set to 1 at the positions of all control qubits. 2. Value Mask ( \mathcal{M}_{\text{val}} ) : A bitmask specifying the required state for each control qubit. A bit is set to 1 for a standard control and 0 for an anti-control (conditioned on the qubit being |0\rangle ). Let \mathbf{a},\mathbf{b}\in\mathbb{C}^{N} (where N=2^{n} ) be the input and output state vectors, and let U be a 2\times 2 unitary matrix acting on target qubit k . The update rule for every element i\in\{0,\dots,N-1\} is: b_{i}=\begin{cases}u_{00}a_{i}+u_{01}a_{\text{partner}}&\text{if }i\in\mathcal{C}\text{ and }i_{k}=0\\ u_{10}a_{\text{partner}}+u_{11}a_{i}&\text{if }i\in\mathcal{C}\text{ and }i_{k}=1\\ a_{i}&\text{if }i\notin\mathcal{C}\end{cases} (1) where the partner index is defined as i\oplus 2^{k} , and \mathcal{C} is the set of indices satisfying the control condition (i\,\&\,\mathcal{M}_{\text{inc}})==\mathcal{M}_{\text{val}} . III.1.3 Algorithm Implementation The implementation of this formulation is detailed in Algorithm 1 . By calculating the partner index and control logic using bitwise operations, the branching logic remains local to each thread, minimizing synchronization overhead. Algorithm 1 Parallel Per-Element Single Qubit Gate Multiplication 1: 2: n : Number of qubits 3: \mathbf{a} : Input State Vector (size N=2^{n} ) 4: U : 2\times 2 Unitary Matrix 5: k : Target Qubit Index 6: \mathcal{M}_{\text{inc}} : Inclusion Mask (Active Control Bits) 7: \mathcal{M}_{\text{val}} : Desired Value Mask (Control States) 8: \mathbf{b} : Updated State Vector 9: \text{targetStride}\leftarrow 1\ll k 10: N\leftarrow 1\ll n \triangleright Number of States 11: \triangleright Main Loop: Perfectly Parallelizable in LabVIEW 12: for i\leftarrow 0 to N-1 do 13: \triangleright Check Control Logic 14: if (i\,\&\,\mathcal{M}_{\text{inc}})==\mathcal{M}_{\text{val}} then 15: \text{partner}\leftarrow i\,\oplus\,\text{targetStride} 16: if (i\,\&\,\text{targetStride})==0 then 17: \triangleright Case: Target bit is 0 18: b[i]\leftarrow(U_{00}\cdot a[i])+(U_{01}\cdot a[\text{partner}]) 19: else 20: \triangleright Case: Target bit is 1 21: b[i]\leftarrow(U_{10}\cdot a[\text{partner}])+(U_{11}\cdot a[i]) 22: end if 23: else 24: \triangleright Control condition failed. No change. 25: b[i]\leftarrow a[i] 26: end if 27: end for 28: return \mathbf{b} III.2 Efficient SWAP Gate Implementation Simulating a SWAP gate typically requires exchanging states between two qubits q_{a} and q_{b} . In a naive implementation, this might involve complex matrix permutations. However, another algorithm is utilized for the swap gate in a similar per-element parallel method, defining a direct mapping between input and output indices. For a SWAP operation between qubits q_{a} and q_{b} , the amplitude at index i in the output vector corresponds to the amplitude at index j in the input vector, where j is obtained by swapping the bit values of i at positions a and b . This allows the construction of Algorithm 2 , which remains perfectly parallelizable and supports arbitrary control masks. Algorithm 2 Parallel Swap Update 1: 2: n : Number of qubits 3: \mathbf{a} : Input State Vector 4: q_{a},q_{b} : Indices of qubits to SWAP 5: \mathcal{M}_{\text{inc}},\mathcal{M}_{\text{val}} : Control Masks 6: \mathbf{b} : Updated State Vector 7: \text{maskA}\leftarrow 1\ll q_{a} 8: \text{maskB}\leftarrow 1\ll q_{b} 9: \text{swapMask}\leftarrow\text{maskA}\,|\,\text{maskB} 10: N\leftarrow 1\ll n \triangleright Iterate over all states in parallel 11: for i\leftarrow 0 to N-1 do 12: if (i\,\&\,\mathcal{M}_{\text{inc}})==\mathcal{M}_{\text{val}} then 13: \text{bitA}\leftarrow(i\,\&\,\text{maskA})\neq 0 14: \text{bitB}\leftarrow(i\,\&\,\text{maskB})\neq 0 15: if \text{bitA}\,\oplus\,\text{bitB} then 16: \text{source}\leftarrow i\,\oplus\,\text{swapMask} 17: b[i]\leftarrow a[\text{source}] 18: else 19: b[i]\leftarrow a[i] 20: end if 21: else 22: b[i]\leftarrow a[i] 23: end if 24: end for 25: return \mathbf{b} IV Validation and Application Examples To demonstrate the capabilities of QuVI, we present two examples that highlight different aspects of the toolkit: classical feed-forward control in quantum teleportation, and iterative algorithmic structures in Grover’s search. IV.1 Quantum Teleportation The quantum teleportation protocol 2 was constructed to transfer an arbitrary qubit state |\psi\rangle=\alpha|0\rangle+\beta|1\rangle between two parties (Alice and Bob) using a Bell pair and classical communication. Figure 3 illustrates the implementation in QuVI. This example explicitly showcases the toolkit’s ”hybrid” nature. The measurement gates on Alice’s side (top two wires) output boolean values which are transmitted via standard LabVIEW data wires (the green dashed lines acting as the ”classical channel”) to Bob’s side. These boolean signals drive standard LabVIEW Case Structures , which conditionally apply the X and Z corrections to Bob’s qubit. This effectively simulates the feed-forward logic required for teleportation without needing separate classical and quantum simulation environments. Figure 3: Quantum Teleportation implemented in QuVI. The green dashed wires represent the classical channel, carrying measurement results from Alice’s qubits to control Case Structures that apply corrections ( X and Z gates) to Bob’s qubit. IV.2 Grover’s Search Algorithm A 4-qubit Grover’s search algorithm 5 was implemented to locate a marked state within a search space of N=16 items. This example highlights the use of LabVIEW’s iterative structures to simplify circuit design. The core sequence of the algorithm, the Oracle ( O ) followed by the Diffusion operator ( D ), is placed inside a LabVIEW For Loop structure (see Figure 4 ). This allows the user to automate the amplitude amplification process, running the sequence R\approx\frac{\pi}{4}\sqrt{N} times (here R=3 ) without manually duplicating the block diagram components. Additionally, a Case Structure is used to dynamically select the Phase Oracle based on a user input (here set to tagged state |0110\rangle ), allowing a single VI to search for any target state. The system was initialized in the equal superposition state |s\rangle=H^{\otimes 4}|0\rangle . After 3 iterations determined by the For Loop, the simulator correctly amplified the probability of measuring the dynamically selected target state ( |0110\rangle ) to >96\% , consistent with theoretical predictions. Figure 4: 4-Qubit Grover Search in QuVI. (a) LabVIEW Block Diagram utilizing a For Loop for algorithm iterations and a Case Structure for dynamic Oracle selection. The tagged state is set to |0110\rangle . (b) Simulation result showing the probability distribution of the final state, with a dominant peak ( >96\% ) at the index 0110. V Conclusion QuVI successfully demonstrates that a versatile quantum circuit simulator can be built natively in LabVIEW, offering robust integration between quantum operations and classical control logic. By implementing a pleasingly parallel per-element update engine within a synchronization architecture utilizing Queues and Notifiers, a modular system was achieved that adheres to the graphical dataflow paradigm while enabling complex, hybrid algorithm design. This tool provides a unique platform for engineering students and researchers to prototype and visualize quantum mechanics using familiar instrumentation metaphors. Future enhancements will focus on extending the simulator beyond pure state vectors to support mixed states via the density matrix formalism. This development will enable the simulation of real, noisy quantum systems through the incorporation of decoherence channels. Furthermore, diagnostic tools for quantifying entanglement, such as von Neumann entropy and concurrence 6 , and computing reduced density matrices via partial traces 8 will be implemented.