What happens to matter compressed beyond the density of an atomic nucleus? How do massive stars lose mass, and how does that shape which of them leave behind neutron stars or black holes? Answering questions like these requires comparing observations to physical models, but many state-of-the-art models are too slow for full statistical inference or or so complex that we can simulate realistic data from them but cannot directly calculate how well they match an observation. In this talk, I will discuss how machine learning methods trained on simulations can address both problems. Neural network surrogate models replace slow physical models with fast approximations, reducing inference of X-ray reverberation around black holes from weeks to hours. Simulation-based inference learns parameter probability distributions directly from simulated data, allowing us to use observations that would otherwise be discarded, such as X-ray data distorted by detector effects. I will show recent results and ongoing work on a range of astrophysical problems, from massive stars, black holes and neutron stars to Fast Radio Bursts. I will also discuss where these methods can fail, especially when the simulations don’t capture all of the physics present in the real data.