Craft 3 Docs Group Filter Not Working
You were close!  In Craft 3, postDate is a full PHP DateTime object, so it'd need to be something like:

{% set allEntriesByYear = allEntries|group('postDate|date("Y")') %}