US stocks rallied on Thursday as traders piled into technology stocks on renewed optimism around artificial intelligence.