US stocks end mostly higher as tech rally pushes Nasdaq, S&P 500 to record highs