Hmm. Well, first off, he's probably trying to keep his shit together. INTPs *hate* letting that Fe monster off the leash, and when we're upset, Ti desperately tries to keep it under control. If it slips off the leash entirely, he'll probably withdraw as fast as he can so he doesn't take it out on you. If he does that, let him. He'll come back once Ti has it under control again.
If he's capable of talking about it, let him talk about it, run down a bit. It probably wouldn't be a good idea to touch him, but you may need to ask some leading questions.
After he's got it under control, what he'd really want, I think, is to have somebody go over his actions, and see if he did the Right Thing. I'm assuming, here, that he's mainly upset with himself, which I think would probably be the case if he's got that much of a head of steam. Our Ti gives a Thing about our own competence. We want to be able to handle the situation with as much finesse as we can, make the people we care about happy. (Fe) We're very hard on ourselves if we think there was something the slightest bit off with our performance. So it would probably help a lot for somebody to walk us through our actions, and see if there was anything that we could have done different.
The key thing here is to be *honest*. Don't be overly critical, but don't try to sugar-coat the truth either. INTPs have just as good bullshit detection sensors as INFPs (even if they are a bit different - focused on the facts, rather than on emotional authenticity). If he thinks you're trying to be polite, he won't trust you when you tell him he did the Right Thing. If he did turn in a less than completely optimal performance, help him to see that it isn't his fault, and help him come up with ways he can do better next time.
When I say "don't be overly critical," the main thing I mean is that you should assume he acted on good faith on his part. His motivations were good, and he did try to turn in the best performance he could. Critique his performance, not him, if that makes any sense.
After that, *then* the cuddling.
It's possible that he's pissed at somebody else, probably because they insulted his competence or *him*, rather than his actions or his ideas. Or because they hurt somebody he cares about. In which case, then thing to do is to help him plot revenge. The more ridiculous, the better.