You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix sampling returning a constant wrong token for vocabularies larger than 65,536 (#384)
* Fix multinomial sampling for vocabularies larger than 65,536 tokens
The Bool mask pipeline in selectNextTokenUsingSampling (cumsum < rnd
combined with arithmetic ops feeding argmin) truncates at 2^16 elements,
so any model with a vocabulary above 65,536 tokens sampled a constant
wrong token id on every step, and the same op sequence can crash in
libBNNS (issue #365). Replace it with an inverse-CDF binary search on
the CPU: read back the cumulative probabilities once per token and find
the first index reaching the drawn value, which is correct for any
vocabulary size.
* Simplify comment
---------
Co-authored-by: Pedro Cuenca <pedro@huggingface.co>
0 commit comments