Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions python/sglang/srt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1443,6 +1443,15 @@ def is_habana_available() -> bool:

@lru_cache(maxsize=8)
def get_device(device_id: Optional[int] = None) -> str:
if is_cpu():
if cpu_has_amx_support():
logger.info("Intel AMX is detected, using CPU with Intel AMX support.")
else:
logger.warning(
"CPU device enabled, using torch native backend, low performance expected."
)
return "cpu"

if hasattr(torch, "cuda") and torch.cuda.is_available():
if device_id is None:
return "cuda"
Expand Down Expand Up @@ -1471,15 +1480,6 @@ def get_device(device_id: Optional[int] = None) -> str:
"Habana frameworks detected, but failed to import 'habana_frameworks.torch.hpu'."
)

if is_cpu():
if cpu_has_amx_support():
logger.info("Intel AMX is detected, using CPU with Intel AMX support.")
else:
logger.warning(
"CPU device enabled, using torch native backend, low performance expected."
)
return "cpu"

raise RuntimeError("No accelerator (CUDA, XPU, HPU) is available.")


Expand Down
Loading