Quantum magnetism on a chip