MCPcopy Index your code
hub / github.com/FlashSampling/FlashSampling / verify_greedy_tp2

Function verify_greedy_tp2

src/fused_mm_sampling/testing.py:190–208  ·  view source on GitHub ↗

Worker function for TP2 greedy tests (passed to run_maybe_distributed).

()

Source from the content-addressed store, hash-verified

188
189
190def verify_greedy_tp2() -> None:
191 """Worker function for TP2 greedy tests (passed to run_maybe_distributed)."""
192 tp = TPInfo.from_world()
193 for vocab_size, n_hidden_states in product([100, 256, 512], [1, 2]):
194 inputs = make_synthetic_inputs(
195 vocab_size=vocab_size, n_hidden_states=n_hidden_states, tp=tp
196 )
197 sampler = get_sampler("greedy", weights=inputs.weights)
198 sampler.prepare()
199 samples = sampler.sample(
200 weights=inputs.weights,
201 hidden_states=inputs.hidden_states,
202 num_samples=1,
203 temperature=torch.empty((), device="cuda"),
204 tp=tp,
205 )
206 expected = inputs.logits.argmax(dim=-1)
207 torch.testing.assert_close(samples[:, 0], expected)
208 tp.rank0_print(f"✅ Passed: greedy V={vocab_size} H={n_hidden_states}")
209
210
211def shift_logits_negative(

Callers 1

verify_correctness_tp2Function · 0.85

Calls 6

make_synthetic_inputsFunction · 0.85
get_samplerFunction · 0.85
from_worldMethod · 0.80
rank0_printMethod · 0.80
prepareMethod · 0.45
sampleMethod · 0.45

Tested by

no test coverage detected