Use the following script in QGIS Code Editor. It also works on nested rules. Select the layer before running the script.
layer = iface.activeLayer()
renderer = layer.renderer().clone()
def set_output_unit(rules):
for rule in rules.children():
rule.symbol().setOutputUnit(1) # 1: MapUnits
if rule.children():
set_output_unit(rule)
rules = renderer.rootRule()
set_output_unit(rules)
layer.setRenderer(renderer)
layer.triggerRepaint()