Deferred Shading

in first pass, we execute VS and FS for all the objects in a scene so MRT will have values for closest pixels. Now in light pass, do we execute the VS for all the objects a scene ? if yes, then FS should execute for all the pixels(extra pixels which wont get rendered) unless early Z is enabled. how does it work? how does the FS executes only for closest pixels?

After you’ve filled your G-Buffer you only render full screen quads or (more efficiently) geometry that corresponds to the area affected by a light source, e.g. a cone for a spot light or a sphere for a point light. That way you execute the lighting fragment shader only for pixels affected by the light source.