MCPcopy Create free account
hub / github.com/FlashSampling/FlashSampling / optimal_k

Function optimal_k

src/fused_mm_sampling/core.py:724–727  ·  view source on GitHub ↗

Source: https://cs.stanford.edu/people/mmahoney/cs369m/Lectures/lecture1.pdf

(n: int, epsilon: float)

Source from the content-addressed store, hash-verified

722
723
724def optimal_k(n: int, epsilon: float) -> int:
725 """Source: https://cs.stanford.edu/people/mmahoney/cs369m/Lectures/lecture1.pdf"""
726 k_float = 24 * math.log(n, math.e) / (3 * epsilon**2 - 2 * epsilon**3)
727 return int(math.ceil(k_float))
728
729
730def get_sampler(provider: str, weights: torch.Tensor) -> Sampler:

Callers 1

from_weightsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected