Variational quantization for state space models