  We study the dust evolution in galaxies by implementing a detailed dust
prescription in the SAGE semi-analytical model for galaxy formation. The new
model, called Dusty SAGE, follows the condensation of dust in the ejecta of
type II supernovae and asymptotic giant branch (AGB) stars, grain growth in the
dense molecular clouds, destruction by supernovae shocks, and the removal of
dust from the ISM by star formation, reheating, inflows and outflows. Our model
successfully reproduces the observed dust mass function at redshift z = 0 and
the observed scaling relations for dust across a wide range of redshifts. We
find that the dust mass content in the present Universe is mainly produced via
grain growth in the interstellar medium (ISM). By contrast, in the early
Universe, the primary production mechanism for dust is the condensation in
stellar ejecta. The shift of the significant production channel for dust
characterises the scaling relations of dust-to-gas (DTG) and dust-to-metal
(DTM) ratios. In galaxies where the grain growth dominates, we find positive
correlations for DTG and DTM ratios with both metallicity and stellar mass. On
the other hand, in galaxies where dust is produced primarily via condensation,
we find negative or no correlation for DTM and DTG ratios with either
metallicity or stellar mass. In agreement with observation showing that the
circumgalactic medium (CGM) contains more dust than the ISM, our model also
shows the same trend for z < 4. Our semi-analytic model is publicly available
at https: //github.com/dptriani/dusty-sage.
