That looks like the problem. The compass initialized the IMU yaw value at almost due north, which suggests that there was magnetic interference at the location where you took off:
View attachment 41924
That led to significant discrepancies after takeoff between the compass (magnetic yaw) and the updated IMU yaw derived from the rate gyros. That, in turn, is the cause of the yaw errors and the switch to ATTI mode, after which RTH was not possible.
We can also look at the difference between IMU yaw and magnetic yaw as a function of magnetic yaw:
View attachment 41925
This does not have the characteristic 2π (360°) periodic variation that appears when the issue is a compass calibration problem - for example this is the equivalent comparison in just such a case that I'm looking at for a different aircraft:
View attachment 41926
Well now...sar104 knows his stuff.
If that post wasn't the most helpful in understanding what occurred, I don't what is. Well done!