Optimal partial regularity of weak solutions for nonlinear sub-elliptic systems in Heisenberg groups