Hydrogen (H) retention and desorption in tungsten (W)-based plasma-facing materials are still not well understood, largely due to the limitations of ex-situ observations in experimental detection methods like thermal desorption spectroscopy (TDS). In order to reveal the fundamental mechanisms behind H retention and desorption, we developed a cluster dynamics model, IRadMat-TDS, for theoretical modeling of depth distribution and TDS of deuterium (D) in polycrystalline W. The model newly includes the saturated absorption and emission of D in inherent sinks like grain boundaries (GBs), as well as the multi-trapping effect of D in various types of GBs with different trapping energies. The simulated TDS spectra are in agreement with experimental ones. For polycrystalline W under D ion irradiation within keV-energy range, two typical thermal desorption peaks in TDS at around 490 and 550 K are explicitly attributed to D emission from GBs and vacancies, respectively. And GBs play a major role in D retention. Moreover, the broad peaks in TDS come from the convolution of multi-trapping of D in sinks with different types of trapping sites rather than a single-site approximation.