  Recent experiments [Persky {\it{et al.}}, Nature {\bf{607}}, 692 (2022)]
demonstrate a magnetic memory effect in 4Hb-$\mathrm{TaS_2}$ above its
superconducting transition temperature, where Abriokosov vortices are generated
spontaneously by lowering temperature at zero magnetic field after field
training the normal state. Motivated by the experiment, we propose the chiral
quantum spin liquid (QSL) stabilized in the constituent layers of
4Hb-$\mathrm{TaS_2}$ as a mechanism. We model 4Hb-$\mathrm{TaS_2}$ as coupled
layers of the chiral QSL and superconductor. Through the Kondo coupling between
the localized moments and conduction electrons, there is mutual transmutation
between spinons and vortices during the thermal cycling process, which yields
magnetic memory effect as observed in experiments. We also propose a mechanism
to stabilize the chiral and nematic superconductivity in 4Hb-$\mathrm{TaS_2}$
through the Kondo coupling of conduction electrons to the chiral QSL. Our
results suggest 4Hb-$\mathrm{TaS_2}$ as an exciting platform to explore the
interplay between QSL and superconductivity through the Kondo effect.
