Meta will take a stake in the chipmaker in exchange for a commitment to buy billions of dollars' worth of AI chips.