| 13 | |
| 14 | class WeightAsyncStreamManager(object): |
| 15 | def __init__(self, offload_granularity): |
| 16 | self.offload_granularity = offload_granularity |
| 17 | self.init_stream = torch_device_module.Stream(priority=0) |
| 18 | self.need_init_first_buffer = True |
| 19 | self.lazy_load = False |
| 20 | self.contiguous_group = None |
| 21 | self.contiguous_transfer = None |
| 22 | torch_version = parse(torch.__version__.split("+")[0]) |
| 23 | # Legacy name: this is the active device backend's weight-loading stream, not a CUDA-only stream. |
| 24 | if PLATFORM == "cuda" and torch_version >= parse("2.7"): |
| 25 | self.cuda_load_stream = torch_device_module.Stream(priority=1) |
| 26 | self.compute_stream = torch_device_module.Stream(priority=1) |
| 27 | else: |
| 28 | self.cuda_load_stream = torch_device_module.Stream(priority=0) |
| 29 | self.compute_stream = torch_device_module.Stream(priority=-1) |