  We present a photonic integrated circuit architecture for a quantum
programmable gate array (QPGA) capable of preparing arbitrary quantum states
and operators. The architecture consists of a lattice of phase-modulated
Mach-Zehnder interferometers, which perform rotations on path-encoded photonic
qubits, and embedded quantum emitters, which use a two-photon scattering
process to implement a deterministic controlled-$\sigma_z$ operation between
adjacent qubits. By appropriately setting phase shifts within the lattice, the
device can be programmed to implement any quantum circuit without hardware
modifications. We provide algorithms for exactly preparing arbitrary quantum
states and operators on the device and we show that gradient-based optimization
can train a simulated QPGA to automatically implement highly compact
approximations to important quantum circuits with near-unity fidelity.
