MCPcopy
hub / github.com/SesameAILabs/csm / _multinomial_sample_one_no_sync

Function _multinomial_sample_one_no_sync

models.py:72–74  ·  view source on GitHub ↗
(probs)

Source from the content-addressed store, hash-verified

70
71
72def _multinomial_sample_one_no_sync(probs): # Does multinomial sampling without a cuda synchronization
73 q = torch.empty_like(probs).exponential_(1)
74 return torch.argmax(probs / q, dim=-1, keepdim=True).to(dtype=torch.int)
75
76
77def sample_topk(logits: torch.Tensor, topk: int, temperature: float):

Callers 1

sample_topkFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected