[Refactor] Replace and ban a few torch.cuda functions in favor of torch.accelerator replacements. (#3365)

Signed-off-by: Nick Cao <ncao@redhat.com>
This commit is contained in:
Nick Cao authored and GitHub committed 2026-05-07 23:23:59 +08:00
1 parent 54277a8dd0
commit e6466cf0e6
40 files changed
+98 -90

No files matched your search

@@ -276,7 +276,9 @@ class MiMoAudioDataParser(MultiModalDataParser):
self.device = torch.device(tokenizer_device)
else:
# Default to cuda (will use current GPU)
self.device = torch.device(f"cuda:{torch.cuda.current_device()}" if torch.cuda.is_available() else "cpu")
self.device = torch.device(
f"cuda:{torch.accelerator.current_device_index()}" if torch.cuda.is_available() else "cpu"
)
self.audio_tokenizer_path = os.environ.get("MIMO_AUDIO_TOKENIZER_PATH", None)
if not self.audio_tokenizer_path:
@@ -793,7 +793,7 @@ class MiMoAudioLLMForConditionalGeneration(nn.Module, SupportsMultiModal, Suppor
local_embeds: torch.FloatTensor, # [1, 1, hidden_size]
tokens_dtype: torch.dtype = torch.int64,
tokens_device: torch.device = torch.device(
f"cuda:{torch.cuda.current_device()}" if torch.cuda.is_available() else "cpu"
f"cuda:{torch.accelerator.current_device_index()}" if torch.cuda.is_available() else "cpu"
),
local_sampler: MiMoSampler | MiMoLocalSamplerTensor | None = None,
):
@@ -847,7 +847,7 @@ class MiMoAudioLLMForConditionalGeneration(nn.Module, SupportsMultiModal, Suppor
local_embeds: torch.FloatTensor, # [1, 1, hidden_size]
tokens_dtype: torch.dtype = torch.int64,
tokens_device: torch.device = torch.device(
f"cuda:{torch.cuda.current_device()}" if torch.cuda.is_available() else "cpu"
f"cuda:{torch.accelerator.current_device_index()}" if torch.cuda.is_available() else "cpu"
),
local_sampler: MiMoSampler | None = None,
):