  We introduce the Quantum Operating System (QOS), a unified system stack for
managing quantum resources while mitigating their inherent limitations, namely
their limited and noisy qubits, (temporal and spatial) heterogeneities, and
load imbalance. QOS features the $\textit{QOS compiler}$ -- a modular and
composable compiler for analyzing and optimizing quantum applications to run on
small and noisy quantum devices with high performance and configurable
overheads. For scalable execution of the optimized applications, we propose the
$\textit{QOS runtime}$ -- an efficient quantum resource management system that
multi-programs and schedules the applications across space and time while
achieving high system utilization, low waiting times, and high-quality results.
  We evaluate QOS on real quantum devices hosted by IBM, using 7000 real
quantum runs of more than 70.000 benchmark instances. We show that the QOS
compiler achieves 2.6--456.5$\times$ higher quality results, while the QOS
runtime further improves the quality by 1.15--9.6$\times$ and reduces the
waiting times by up to 5$\times$ while sacrificing only 1--3\% of results
quality (or fidelity).
