  Precise control of quantum systems is of fundamental importance for quantum
device engineering, such as is needed in the fields of quantum information
processing, high-resolution spectroscopy and quantum metrology. When scaling up
the quantum registers in such devices, several challenges arise: individual
addressing of qubits in a dense spectrum while suppressing crosstalk, creation
of entanglement between distant nodes, and decoupling from unwanted
interactions. The experimental implementation of optimal control is a
prerequisite to meeting these challenges. Using engineered microwave pulses, we
experimentally demonstrate optimal control of a prototype solid state spin
qubit system comprising thirty six energy levels. The spin qubits are
associated with proximal nitrogen-vacancy (NV) centers in diamond. We
demonstrate precise single-electron spin qubit operations with an unprecedented
fidelity F \approx 0.99 in combination with high-efficiency storage of electron
spin states in a nuclear spin quantum memory. Matching single-electron spin
operations with spin-echo techniques, we further realize high-quality entangled
states (F > 0.82) between two electron spins on demand. After exploiting
optimal control, the fidelity is mostly limited by the coherence time and
imperfect initialization. Errors from crosstalk in a crowded spectrum of 8
lines as well as detrimental effects from active dipolar couplings have been
simultaneously eliminated to unprecedented extent. Finally, by entanglement
swapping to nuclear spins, nuclear spin entanglement over a length scale of 25
nm is demonstrated. This experiment underlines the importance of optimal
control for scalable room temperature spin-based quantum information devices.
