I don't think you got the point of the movie, the movie is playing on your expectations. You expect the AI to be the bad guy and the movie knows this.
Spoilers: Throughout the movie it's trying to make you think what the AI is doing is bad, while subtly giving reasons why it's not. At the end the movie explains how all of the AI's actions were done to improve the lives of everyone, but the closed minded views of the terrorist group and the government stopped that and threw the world into socioeconomic collapse. The self replicators in the movie is the "oh shit" moment for our female lead, who now "understands" that the AI is no longer her husband, part of the reason why she comes to this conclusion is that her husband never wanted to change the world. so she decides to help upload the virus. But it is revealed that these self replicators were to help make the ground more fertile for growing (helping with world hunger) and to make all the rivers on the planet drinkable (eliminating the water shortage), it also turns out that he was trying to improve the world because that's what HER dream was. The AI wasn't the bad guy here.
Though I did find the partial take over of patients to be morally iffy to say the least.