MCPcopy Create free account
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 chi_squared, p_value = chisquare(obs, exp)
189 degrees_of_freedom = len(obs) - 1
190 reduced_chi_squared = chi_squared / degrees_of_freedom
191 if print_result:
192 print(
193 f"Chi-squared: provider={provider}, V={vocab_size}, H={n_hidden_states}, "
194 f"samples={num_samples}, tested_bins={mask.sum()}, "
195 f"tested_probability_mass={tested_probability_mass:.6f}, "
196 f"statistic={chi_squared:.3f}, df={degrees_of_freedom}, "
197 f"reduced_statistic={reduced_chi_squared:.6f}, p={p_value:.6g}"
198 )
199 assert not np.isnan(p_value), (
200 f"Chi-squared returned NaN for seq {seq_idx} — likely all samples "
201 f"landed in a single tile. {provider} may have a masked-fill bug."
202 )
203 assert p_value > 0.001, (
204 f"Sampling distribution mismatch for seq {seq_idx}: p={p_value:.6f}. "
205 f"{provider} does not match the expected softmax distribution."
206 )
207
208
209def assert_sampling_distribution_large_vocab(
210 vocab_size: int = 32_768,
211 num_samples: int = 1_000_000,

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