  Subsurface porous rocks have the potential to store large volumes of hydrogen
(H$_2$) required for transitioning towards a H$_2$-based energy future.
Understanding the flow and trapping behavior of H$_2$ in subsurface storage
systems, which is influenced by pore-scale heterogeneities inherent to
subsurface rocks, is crucial to reliably evaluate the storage efficiency of a
geological formation. In this work, we performed 3D X-ray imaging and flow
experiments to investigate the impact of pore-scale heterogeneity on H$_2$
distribution after its cyclic injection (drainage) and withdrawal (imbibition)
from a layered rock sample, characterized by varying pore and throat sizes. Our
findings reveal that even subtle variations in rock structure and properties
significantly influence H$_2$ displacement and storage efficiency. During
drainage, H$_2$ follows a path consisting of large pores and throats, bypassing
the majority of the low permeability rock layer consisting of smaller pores and
throats. This bypassing substantially reduces the H$_2$ storage capacity.
Moreover, due to the varying pore and throat sizes in the layered sample,
depending on the experimental flow strategy, we observe a higher H$_2$
saturation after imbibition compared to drainage, which is counterintuitive and
opposite to that observed in homogeneous rocks. These findings emphasize that
small-scale rock heterogeneity, which is often unaccounted for in
reservoir-scale models, can play a vital role in the displacement and trapping
of H$_2$ in subsurface porous media.
