  Here we present qFlex, a flexible tensor network based quantum circuit
simulator. qFlex can compute both exact amplitudes, essential for the
verification of the quantum hardware, as well as low fidelity amplitudes, in
order to mimic sampling from Noisy Intermediate-Scale Quantum (NISQ) devices.
In this work, we focus on random quantum circuits (RQCs) in the range of sizes
expected for supremacy experiments. Fidelity $f$ simulations are performed at a
cost that is $1/f$ lower than perfect fidelity ones. We also present a
technique to eliminate the overhead introduced by rejection sampling in most
tensor network approaches. We benchmark the simulation of square lattices and
Google's Bristlecone QPU. Our analysis is supported by extensive simulations on
NASA HPC clusters Pleiades and Electra. For our most computationally demanding
simulation, the two clusters combined reached a peak of 20 PFLOPS (single
precision), i.e., $64\%$ of their maximum achievable performance, which
represents the largest numerical computation in terms of sustained FLOPs and
number of nodes utilized ever run on NASA HPC clusters. Finally, we introduce a
novel multithreaded, cache-efficient tensor index permutation algorithm of
general application.
