| 158 | greedy_sample_compiled = nvtx.annotate()(torch.compile(greedy_sample, fullgraph=True)) |
| 159 | |
| 160 | _sample_compiled = torch.compile(sample, fullgraph=True) |
| 161 | |
| 162 | |
| 163 | @nvtx.annotate() |
| 164 | def sample_compiled(*args, seed: int | None = None, **kwargs): |
| 165 | # torch.manual_seed is dynamo-skipped, so seed handling has to live outside |
| 166 | # the compiled region. Pass seed=None into the compiled inner; the dead |
| 167 | # `if seed is not None` branch in sample() is folded at trace time. |
| 168 | if seed is not None: |
| 169 | torch.manual_seed(seed) |