On the applicability of the thermodynamic identity Under what circumstances does the thermodynamic identity, $$dU = TdS - PdV + \sum_i \mu_i dN_i,$$ apply? For what kinds of systems is it not valid?
 A: This is essentially the first law of thermodynamics, which states energy conservation for an infinitesimal change of the state variables of a closed homogeneous thermodynamic systems. The particular form you have written assumes that entropy $S$, Volume $V$ and particle numbers $N_i$ are the state variables of the system. The law describes the change of the internal energy $U(S,V,\{N_i\})$, when any of the state variables are changed by an infinitesimal amount. On the right hand side, the term $TdS$ is the infinitesimal amount of heat added to the system, when its entropy is increased by $dS$, the term $-pdV$ is the mechanical work done on the system, when its volume is changed by $dV$, and the last term describes the increase in chemical energy in the system in the case that chemical reactions take place.
The expression is not valid, if you describe your system with a different set of state variables, or if your system has state variables that do not occur in this expression.
There is an extended Wikipedia article on the first law of thermodynamics, if your need more details.
A: The above equation provides the  expression of the differential  of internal energy as a function of its independent variables. It is an augmented expression of the first principle. Augmentation refers to the fact that the orginal expression of the first principle was intended for a system of fixed composition and number of particles, so the $dN_i$ terms were missing.
Since it is a relation between state variables, it has a complete and general validity provided one considers infinitesimal or finite variations (in such a case one has to integrate the differential form) between equilibrium states. The way they are reached is instead irrelevant.
Another limit of the formula is connected to the variables it depends on. From the formula for differential, $U$ should be a function of ($S,V,N_i$). This is a reasonable set of extensive variables to describe the so-called (multi-component) fluid systems. however one has to bear in mind that this is only a subset of the possible thermodynamic systems. 
Solid systems would require the independent components of the strain tensor, in place of $V$.
Electric systems would require some electric field, as well as magnetic system would require magnetization density or the external magnetic field ${\bf B}_0$.
Systems where surface effects are important would require the surface area. 
Superfluids would require superfluid velocity.
etc.
I.e. each thermodynamic system may have a more or less extended set of independent variables required to describe its equilibrium states.
