Probability / logit of output tokens #2790
Replies: 1 comment
-
|
Yes, this is expected behavior given how the Top-K sampling kernel is implemented. The key point is that the kernel performs Top-K filtering before sampling. By the time execution reaches the sampling stage, only the Top-K candidates remain, and the normalization is performed over those candidates—not over the entire vocabulary. Regarding your observations:
This is normal unless
This typically means the sampled token is the only surviving candidate after filtering. In that case, and therefore or equivalently, which matches your observation: Since everything is internally consistent. If because the denominator should include the exponentials of all retained Top-K candidates. So a few questions that may help narrow this down:
If your goal is to obtain the model's original logits over the full vocabulary, the Top-K sampling kernel is probably not the ideal place, since the logits have already been filtered by then. It would be better to inspect them immediately after the model forward pass and before any sampling or filtering kernels are applied. If this answer helped or pointed you in the right direction, I'd appreciate it if you could mark it as the accepted answer so it's easier for others with the same issue to find. Also, if you found my contribution useful, I'd appreciate it if you could check out my GitHub profile, follow me, and star any repositories you find interesting. GitHub: https://github.com/Advait251206 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to log the probability/logit of output token in top K sampling kernel. This is the place where I am trying to log.
My understanding is that outputLogProbs should contain the probability but it is always 0. Also my understanding is
sSumvariable should contain sum of all logits, but it is always equal to expLogit.here is actual output for one of the selected tokens:
outputLogProbs[curSeqLen * maxBatchSize + batchSlot]= 0.000000
sSum: 0.000201, logSum: -8.511453, logprob: -8.511453, explogit: 0.000201
In summary:
Beta Was this translation helpful? Give feedback.
All reactions