First of all, check if the optimization setting is enabled. Go to Photos > Preferences > iCloud and make sure the “Optimize Mac Storage” option is selected. If it still seems like it’s not working, note that full-resolution photos will only be replaced with “lighter” versions if your Mac is running low on space. Otherwise, there’s no need to do that. So it could be the reason why your photos are not optimizing.