Compiler Techniques to Fight Bias and Correlated Errors
Compiler Techniques to Fight Bias and Correlated Errors on NISQ Hardware Swamit Tannu APQC 2019 Estes Park, Colorado
Compiler: Program Transformation
Classical Program Transformation P is any classical program P Program Transformation P’ time to execute P > time to execute P’ (lower is better) Caveat: 1. P , P’ are semantically equivalent programs 2. have access to identical instruction set
Error Rates on Existing Quantum Computers Q Program Transformation Q’ Caveat: 1. Semantically equivalent programs 2. have access to identical instruction set Can we design program transformations to improve resilience?
5 “NISQ” Programming Model v Due to probabilistic measurements and qubit errors, program is executed multiple times. v For every execution trial the output is logged Input Program (Like Bernstein-Vazirani ) Error free outcome Compile Erroneous outcome q-executable N Trials Execute Output. String PST = 0. 3 Repeat for N Trials Probability of Successful Trial (PST) is a key metric
Input Program Quantum Computer Frequency Inferring Correct Answer with NISQ Model 30% 20% 10% S 1 15% 5% S 2 S 3 S 4 S 5 Output Strings Inference: Pick output with highest frequency of occurrence S 6
OUTLINE v Background v Variability-Aware Qubit Allocation [ASPLOS-2019] v Ensemble of Diverse Mappings: Spreading Correlated Errors [MICRO-2019] v Flip and Measure: Diversifying Measurement Risk [MICRO-2019]
8 Qubit Allocation Problem cnot cnot A, B C, D A, C A, D Input Program A B C D Program Variable DAG Physical Qubit Connectivity B D 1 2 3 A C 6 5 4 Program to Devices Map Circuit Representation (P 2 D ) Map of program Map program on the physical qubits
9 The Problem of Limited Connectivity CNOT A, B SWAP B, C CNOT A, B Not Possible no link between A and B, CNOT can be performed A B C Q 1 Q 2 Q 3 Q 6 Q 5 Q 4 SWAP facilitate data movement Compiler insert SWAPs are extra instructions which can also fail
10 NISQ Compiler Policies [1] Zulehner+, (DATE’ 18) [2] Siraichi+, (CGO’ 18) [3] Li+, (ASPLOS’ 19) Compiler responsible for qubit allocation and movement A SWAPs = 4 1 SWAPs = 2 2 3 A 1 2 B B 6 5 3 4 6 5 4 Qubit movement policy minimizing SWAPs Existing compiler policies solely focus on minimizing SWAPs
11 CNOT Errors on IBMQ-20 Average error rate 4% 90 th Percentile: Link Error 10% Note: data collected in Feb-April 2018 from IBMQ 20 (IBM Tokyo) reports Two qubit error rate is high and show significant variability
Not All Qubits Are Created Equal 12 Tannu et. al, “Not All Qubits are Created Equal” (ASPLOS - 2019) Best SWAP 6% probability of Failure v Variability: Some qubits and links fail with higher probability than others v Avoiding certain links can improve reliability significantly Worst SWAP 40% Chance of Failure Q 1 Q 2 Q 3 Q 6 Q 5 Q 4 Q 6 Goal: Exploit variation in error rates to improve reliability (assign more operations on reliable qubits/links)
Variation in Two Qubit Gate Errors Worst link: 15% cnot error 13 Link Error Rate > 7% 3% < Link Error Rate < 7% Link Error Rate < 3% Best Link: 2% cnot error Average link error rate for 76 links in IBM-Tokyo machine Some links are consistently more error prone than others
Variation-aware Qubit Movement (VQM) A 1 0. 95 2 0. 9 3 0. 95 6 0. 8 5 4 0. 95 Movement Path Probability of Success 1 -6 -5 40% 1 -2 -3 50% 1 -2 -5 60% B cnot A, B Chose a sequence of swaps that maximizes the reliability 14
15 Variation Aware Qubit Allocation (VQA) cnot A, B cnot B, C cnot C, D A 1 0. 9 B 2 0. 95 A 0. 95 0. 85 6 D 0. 8 SWAPs = 0 5 C 0. 95 1 3 4 PST = 0. 61 0. 95 2 B 0. 9 3 0. 95 0. 85 6 0. 8 5 D SWAPs = 0 0. 95 4 C PST = 0. 77 Choose qubits that maximizes the reliability
16 Variation-Aware Policy Input Program Connectivity Map Variation-aware Compiler Variation-aware Qubit Allocation (VQA) Variation-aware Qubit Movement (VQM) Noise Characteristics We propose variation-aware policy , to generate initial assignment and operation schedule that maximize the reliability, not just SWAP count
17 Evaluations on ibmqx 4 1. 5 90% Variation unaware baseline 1 0. 5 Tr 3 ZH G i-S W AP -4 BV -3 0 BV Relative PST 2 BV 3 – Bernstein Vazirani with 3 bits BV 4 -- Bernstein Vazirani with 3 bits Tri-SWAP – 3 SWAPs On IBM-Q 5, VQA+VQM improves the reliability up to 1. 9 x
Variability-aware Compilation for NISQ • Not All Qubits Are Created Equal by Tannu et. al (2018) [Georgia Tech] • Noise-adaptive compiler mappings by Murli et. al (2019) [Princeton] • Extracting Success from IBM's 20 -Qubit Machines by Nishio et. al (2019) [Keio] • Near-optimal routing of noisy quantum states by Sadlier et. al. (2019) [Oak Ridge] • Quantum Circuit Compilation by Venturelli et. al (2019) [NASA] • QURE: Qubit Re-allocation in NISQ by Ash- Saki et. al (2019) [Penn State] • And many more ……. IBM QISkit now offers Variability Aware Mapping
Variability-aware Compilation for NISQ Input Program Connectivity Map Variation-aware Compiler One Best Mapping Noise Characteristics Should we use one best mapping for all our trials?
OUTLINE v Background v Variability-Aware Qubit Allocation v Ensemble of Diverse Mappings: Spreading Errors v Flip and Measure: Diversifying Measurements to Fight Bias
21 NISQ with Correlated Errors Input Program Error free outcome Erroneous outcome Expectation Compile q-executable Repeat for N Trials Execute Reality Output Log 30% 10% 15% High Probability of Successful Trial (PST) doesn’t guarantee correct inference
Figure of Merit: Inference Strength (IST) 35 % A 40 % 10 % 5% B C D 30 % A 25 % 20 % B C 25 % D IST captures quality of inference. IST > 1 ensures correct answer is strongest
Goal Software can significantly affect the ability to infer the right answer on NISQ Goal: Develop software transformation for NISQ programs to reduce the impact of hardware errors
One Mapping For All Trials Prior work searches for best qubit mapping and uses it for all N trials
Running Bernstein Vazirani (BV) on IBMQ-14 Experiment with 8192 shots Batch BV-6 Bernstein Vazirani Algorithm with 6 -bit Key
Impact of Running Identical Program for All Trials KL-Divergence Similarity between Probability Distributions KL(Batch-1, Batch-8) = 0. 035 Running a program with identical mapping produces similar output distributions
Can We Suppress Incorrect Answers with Diversity?
Running Program with Diverse Mappings on IBMQ Diversity in qubit mapping produces dissimilar output distributions
Ensemble of Diverse Mapping: Design Variation Aware Qubit Mapper MAP best Subgraph Search M 1 E 1 O 1 M 2 E 2 O 2 M 3 Q Assembler E 3 Execute on NISQ O 3 M 4 E 4 O 4 Qubit Mappings Quantum Executables Output PDF Merge PDFs
Ensemble of Diverse Mappings EDM creates four copies of the program using mappings A, B, C, and D With diverse set of mappings we can orchestrate dissimilar mistakes
Evaluations on IBM-Q 14 system For current quantum kernels, EDM improves the IST by up to 1. 5 x
OUTLINE v Background v Variability-Aware Qubit Allocation v Ensemble of Diverse Mappings: Spreading Correlated Errors v Flip and Measure: Diversifying Measurement Risk
Qubit Measurement (N trials) Probability Data Dependent Bias in Measurement Correct Answer 84% Incorrect Answers Qubit Measurement (N trials) Probability 16% Correct Answer 62% 38% On IBM-Q 5, measurement errors have directional bias Incorrect Answers
Measurement Strength Measurement Bias on IBMQ-14 1. 0 0. 9 0. 8 0. 7 0. 6 0. 5 0. 4 0 6 4 2 8 Hamming weight of basis state 10 Measurement Strength is negatively corelated to Hamming weight of data
Measurement Bias for GHZ-5 State GHZ-5 state
Insight – Leveraging Measurement Bias v Not all states are created equal: Some basis states are more vulnerable to measurement errors than others v Avoiding such weak states can improve reliability significantly Goal: Exploit state-dependent bias in measurement error to improve reliability (transform weak states to strong states) 36
5 X gate Qubit Measurement (N trials) Correct Answer Incorrect Answers 62% 38% Probability Qubit Measurement (N trials) Probability Invert and Measure on ibmqx 4 Correct Answer 78% Incorrect Answers 22% Inverting a weak state (11. . 1) to produce strong state (00. . 0)
Invert and Measure: Design Create two copies of program: one with inverted measurement and other with standard measurement
Invert and Measure on IBMQ Baseline Invert and Measure
Summary v Correlation in qubit errors and bias in measurements degrade the inference strength (ability to infer right answer) on NISQ machines v Executing Identical program that uses single best mapping for all trials produces correlated errors v Proposed Ensemble of Diverse Mapping (EDM) and Flip and Measure (FNM), creates multiple copies of the program to mitigate correlated errors and bias
Transformation: The Key to Computation Problem (Conv. Hard, Quantum Easy) Algorithms Language/Compilers Q-Software Architecture Hardware Architecture Integrated Circuits Characterization(QCVV) Devices/Technology Qubit Devices Electrons Photons/Ions/Electrons 41
Thank you Moin Qureshi Professor, moin@gatech. edu Swamit Tannu Ph. D. Candidate swamit@gatech. edu
Backup Slides -- ASPLOS
44 Implementation Example cnot cnot A, B C, D A, C A, D Input Program A B C D Logical Qubit DAG Physical Qubit Connectivity B D 1 2 A C 4 3 Circuit Representation of program L 2 P Map program on the physical qubits to maximize reliability
45 Variation-Aware Movement Design 1 0. 9 4 A L 1 2 A 0. 8 0. 95 3 Form Layers B C D L 3 L 2 P Map for Layer A 1 B 2 A 1 M 1 4 C B 2 A 1 M 3 M 2 3 D 4 C B 2 3 D 4 D 3 C Partition circuit in Layers (L ) & Find L 2 P Map (M )
46 Variation-Aware Movement Design 1 0. 9 L 1 2 4 0. 95 3 A L 3 A 0. 8 0. 9 S 23 L 2 S 12 Form Layers B ? ? C D B C D Input Circuit L 2 P Map for Layer A 1 B 2 S 12 A 1 M 1 4 C B 2 S 23 A 1 M 3 M 2 3 D 4 C 3 D B 2 4 D 3 C Search for set of optimal SWAPs (Si, i+1 ) to transform M i to M i+1
47 Variation-Aware Movement Design v Find set of least number of SWAPs (Si, i+1 ) to transform Mi into Mi+1 using A-star search A 1 0. 9 4 C B 2 0. 8 0. 95 3 D Initial L 2 P Mapping A AB BC D C DA BA C 1 D 4 C Final Schedule with SWAP (VQM) L 3 L 1 L 2 S 12 S 23 ? PST: 0. 65 ? SWAP = 1 B 2 M 1 A 1 PST: 0. 55 M 2 B 2 A 1 B 2 M 3 4 3 Schedule 3 4 with SWAP 3 Final (baseline) D C D D C Variability-aware movement actively avoid unreliable links
48 VQA Design: Balancing Reliability and Connectivity Strongest subgraph with degree > 3 Find strongest subgraph (SGk) by pruning the weak qubits Map program qubits with high activity on strong qubits (nodes)
Backup Slides -- EDM
50 ESP vs PST
51 ESP vs PST g gate error e m Measurement error e
Benchmarks 52
53 Weighted EDM
Backup Slides – Measurement Bias
Arbitrary Bias on ibmqx 4
Adaptive Flip and Measure
Evaluations: Bernstein Vazirani on ibmqx 4
- Slides: 57