Nice work @alexfry!
One thing I found I had to do to get a match was to make sure “Compensate for Scene-referred Profiles” was switched off in the Color Settings. Otherwise Photoshop treats the ACEScg as scene-referred and applies a “system gamma” of about 1.1 to the image. Since your LUT is doing the scene to display conversion, this system gamma is unnecessary, and indeed gives an incorrect result.
Correction. I appear to have two ACEScg profiles installed on my system, and originally I had the one called “ACEScg ACES Working Space AMPAS S-2014-004” set as the working space. With this selected, the “Compensate for Scene-referred Profiles” check-box changes the image. With the other one called “ACES CG Linear (Academy Colour Encoding System AP1)” as the working space, that check-box has no effect.