One of the solutions is to use a list of byte offsets and construct sub-datasets based on the byte offsets. An example is here 78.
Another solution is IterableDataset supported by pytorch torch.utils.data. A relevant example is here 197.