|
17 | 17 | import torch |
18 | 18 |
|
19 | 19 | from ..runtime.settings import _env_get_bool |
20 | | -from ..runtime.settings import _get_backend |
21 | 20 | from ..runtime.settings import is_pallas_interpret |
22 | 21 | from .progress_bar import iter_with_progress |
23 | 22 | from helion._dist_utils import sync_object |
@@ -138,33 +137,8 @@ def _get_tpu_tensors(result: object) -> list[torch.Tensor]: |
138 | 137 |
|
139 | 138 |
|
140 | 139 | def synchronize_device(result: object = None) -> None: |
141 | | - """Wait for device computation to complete. |
142 | | -
|
143 | | - For TPU tensors, uses ``torch_tpu``'s tensor-level sync which truly |
144 | | - blocks until the device finishes (``torch.accelerator.synchronize()`` |
145 | | - does not reliably wait on ``torch_tpu``). For all other cases, falls |
146 | | - back to ``torch.accelerator.synchronize()``. |
147 | | - """ |
148 | | - tpu_tensors = _get_tpu_tensors(result) |
149 | | - if tpu_tensors: |
150 | | - try: |
151 | | - from torch_tpu._internal.sync import ( # pyrefly: ignore[missing-import] |
152 | | - synchronize as tpu_sync, |
153 | | - ) |
154 | | - |
155 | | - tpu_sync(tpu_tensors, wait=True) |
156 | | - return |
157 | | - except ImportError: |
158 | | - raise ImportError( |
159 | | - "torch_tpu is required for reliable device synchronization on TPU. " |
160 | | - "Install torch_tpu or torch.accelerator.synchronize() will return " |
161 | | - "before device computation finishes, producing incorrect benchmarks." |
162 | | - ) from None |
163 | | - if ( |
164 | | - not is_pallas_interpret() |
165 | | - and _get_backend() != "pallas" |
166 | | - and torch.accelerator.is_available() |
167 | | - ): |
| 140 | + """Wait for device computation to complete.""" |
| 141 | + if not is_pallas_interpret() and torch.accelerator.is_available(): |
168 | 142 | torch.accelerator.synchronize() |
169 | 143 |
|
170 | 144 |
|
|
0 commit comments