Although simulations excel at mapping an input material to its output property, their application to inverse design has traditionally been limited by their high computing cost and lack of differentiability—so that simulations are often replaced by surrogate machine learning models in inverse design problems. Here, taking the example of the inverse design of a porous matrix featuring targeted sorption isotherm, we introduce an inverse design framework that addresses these challenges. We reformulate a lattice density functional theory of sorption in terms of a convolutional neural network with fixed hard-coded weights that leverages automated end-to-end differentiation. Thanks to its differentiability, the simulation is used to directly train a deep generative model, which outputs an optimal porous matrix. Importantly, this pipeline leverages for the first time the power of TPUs—an emerging family of dedicated chips, which, although they are specialized in deep learning, are flexible enough for intensive scientific simulations.