A numerical tool for predicting the evolution of internal and residual stresses during the processing of thermoplastic matrix composites has been developed. Based on a finite element formulation, the model accounts for the anisotropy, viscoelasticity and heterogeneity of the materials and represents mechanisms of both stress generation and stress relaxation. The viscoelastic properties are described by a linear thermoviscoelastic formulation. The model allows the buildup of stresses during processing to be monitored, in particular when the material is cooling through its transition temperatures, and enables the prediction of stress release and the resulting part warpage on demolding. Its use is demonstrated for unidirectional and crossply polyetherimide/glass fiber (PEI/GF) laminates processed by compression molding, and the influence of cooling conditions on stress levels is shown.