NEW YORK - As the U.S. stock market continues its climb, investors holding shares of the massive tech and growth companies leading the charge are debating whether to cash out or stay on for the ride.

A record $8.5 billion flowed into tech stocks in the latest week, data from BofA Global Research showed, as investors piled into a rally that has seen the tech-heavy Nasdaq 100 gain 33% in 2023. The benchmark S&P 500 has risen 11.5% this year and stands at a 10-month high.

Yet others see reasons for caution. Among them is the narrowness of the market’s rally: the five largest stocks in the S&P 500 have a combined weighting of 24.7% in the index, a record high dating back to 1972, Ned Davis Research said in a recent report. The heavy weightings could mean more significant fallout for broader markets should those names falter.

"We had this big run and the essential question is, do you believe it’s going to continue or do you believe things are going to return to the mean?" said Peter Tuz, president of Chase Investment Counsel.

Excitement over advances in artificial intelligence is a key factor fueling gains in megacap stocks. Big movers include shares of Nvidia, which are up about 170% this year, while Apple and Microsoft, the top two U.S. companies by market value, have both climbed nearly 40%.

Jay Hatfield, CEO of hedge fund InfraCap, believes excitement over AI will keep boosting megacap stocks. He is overweight megacaps, including Nvidia, Microsoft and Google-parent Alphabet.

“We 100% believe in the AI boom,” Hatfield said. “I would be shocked if by the end of the year these stocks are not significantly higher."

Data on Friday showed U.S. job growth accelerating in May, even as a jump in the unemployment rate suggested labor market conditions were easing, boosting investors’ appetite for stocks amid hopes that the Federal Reserve will be able to bring down inflation without badly hurting growth. The S&P 500 rose 1.45%.

Megacap stocks led markets for much of the decade after the financial crisis and betting against them has been a perilous strategy in 2023. Investors' allocation to cash is higher than it has been historically, data from BofA showed, which some market observers believe leaves plenty of fuel to push the rally further.

Strong momentum can also continue to propel stocks higher.

Michael Purves, CEO of Tallbacken Capital Advisors, wrote earlier this week that technical analysis showed the Nasdaq 100 is overbought, a condition that can make an asset more vulnerable to sharp declines. However, the index managed to rally another 10% over three months when it reached the same condition two years ago, according to Purves.

The recent surge in Nvidia showed how a stock can keep climbing even after posting hefty gains. Shares were already up 109% heading into its May 24 earnings report, but rose another 30% in the past week after the chipmaker's surprisingly upbeat sales forecast.

Kevin Mahn, chief investment officer at Hennion & Walsh Asset Management, said shares of Nvidia, which now trade at 44 times forward earnings estimates, according to Refinitiv Datastream, have become "a little rich."

“I still like the technology sector over the next two years, but I now have to be a lot more focused on valuation given the run up in a lot of these megacap stocks,” said Mahn, who says Microsoft shares remain attractive due in part to the company's impressive cash flow and healthy dividend yield.

Others are growing wary, citing factors such as rising valuations and signs that the rest of the market is languishing while a small cluster of stocks soars.

The performance of just seven stocks, Apple, Microsoft, Alphabet, Amazon, Nvdia, Meta Platforms and Tesla, accounted for all of the S&P 500’s 2023 total return through May, according to S&P Dow Jones Indices.

At the same time, only 20.3% of S&P 500 stocks have outperformed the index on a rolling three-month basis, a record low dating back five decades, according to Ned Davis. Levels below 30% have preceded weaker performance for the broader market, with the S&P 500 rising 4.4% over the next year versus an average of 8.2% for all one year periods, the firm’s research showed.

David Kotok, chief investment officer at Cumberland Advisors, in recent days pared back holdings of the iShares semiconductor ETF following the latest spike in shares of Nvidia.

Kotok views narrowing breadth as an ominous sign for the broader stock market, saying that equities also look less favorable in certain asset valuation metrics.

In one commonly used valuation metric, the S&P 500 is trading at 18.5 times forward earnings estimates compared to its historic average of 15.6 times, according to Refinitiv Datastream.

"You can have (market) concentration and it can go on for a while," he said. But, he said, “for me, the narrowing is a warning.”

(Reporting by Lewis Krauskopf; Editing by Ira Iosebashvili, Nick Zieminski and Diane Craft)