Ideal factor ratio is achieved when during the second stage of production. This stage starts from the maximum point of AP and continues till the moment TP is maximum.
When MP is maximum, it happens during the first stage of production, where the ideal factor ratio is not achieved, since there exists inadequate number of variable inputs who can fully exploit the available fixed factor.