What about a hundred million files?
The paths fill the memory. If a path averages 100 bytes, a hundred million of them is 10 GB, before Python's overhead per string.
So keep them on disk. Write (size, path) records to a file and sort them by size with an external sort, a sort that works through the disk when the data doesn't fit in memory. Then stream through one size at a time:
Or split the work across machines by size. Each machine owns every file of the sizes given to it, so no group spans two machines.
Watch for hard links too. Two paths with the same st_dev and st_ino from os.stat are one file, not two copies.
groupby from itertools hands you each run of neighbors that share a key, one run at a time. Each run holds the whole records:
from itertools import groupby
records = [(10, "a"), (10, "b"), (17, "c")]
for size, run in groupby(records, key=lambda r: r[0]):
print(size, list(run))
10 [(10, 'a'), (10, 'b')]
17 [(17, 'c')]
A function with yield in it is a generator: each yield hands one value to the caller's loop and pauses until the loop asks for the next. In the editor, RECORDS are (size, path) pairs, already sorted by size. Finish size_runs(records): collect each run's paths in a list, and yield the list only when it holds two or more.