Worker function for TP2 greedy tests (passed to run_maybe_distributed).
()
| 188 | |
| 189 | |
| 190 | def 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 | |
| 211 | def shift_logits_negative( |
no test coverage detected