mm: wrap the raw stream in context manager (#10958)

The documentation of torch.foo.Stream being usable with with: suggests
it starts at version 2.7. Use the old API for backwards compatibility.
This commit is contained in:
rattus
2025-11-29 07:38:12 +10:00
committed by GitHub
parent 6484ac89dc
commit 0ff0457892
2 changed files with 17 additions and 4 deletions

View File

@@ -95,6 +95,8 @@ def cast_bias_weight(s, input=None, dtype=None, device=None, bias_dtype=None, of
if offload_stream is not None:
wf_context = offload_stream
if hasattr(wf_context, "as_context"):
wf_context = wf_context.as_context(offload_stream)
else:
wf_context = contextlib.nullcontext()