I see a disparity on my devices as well. I have a lot of shared albums from others. I wonder if this is the reason for the difference in size on iCloud (smaller in iCloud). Maybe my iCloud only stores my photos and the shared albums are not part of my iCloud storage.
I have done several wipes and restores and have never lost any photos however
Edit:
Shared Album storage limits
A shared album can hold up to 5000 photos and videos. If you reach
your Shared Album limit, you need to delete some photos or videos before adding new ones. The photos and videos you share (and the comments or likes associated with those photos) stay in iCloud until you or the contributor delete them manually, or until you delete the shared album completely.
The photos and videos in your Shared Albums are kept in iCloud, but they don't count against your iCloud storage limit.
Share photos and videos easily with Shared Albums.
support.apple.com