You will have to deplane in LIM. I was just on MIA-LIM/LIM-GRU last week and the SFO-LIM passengers all had to deplane for the LIM-GRU flight. They were offered priority boarding for the LIM-GRU flight since that flight was a continuation of the SFO-LIM-GRU flight.
On my return: GRU-LIM/LIM-MIA, we arrived at Gate 22 which was also the departure gate for LIM-MIA; all passengers were required to deplane and go through the International Connections route at LIM which involves an x-ray carry-on inspection to reenter the secured zone of LIM.