Make model.quantize() observable and fail-safe (#23345)