Skip to content
Open
Show file tree
Hide file tree
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: 16 additions & 2 deletions python/minisgl/engine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@
from minisgl.layers import set_rope_device
from minisgl.models import create_model, load_weight
from minisgl.moe import create_moe_backend
from minisgl.utils import div_even, init_logger, is_sm90_supported, is_sm100_supported, torch_dtype
from minisgl.utils import (
div_even,
init_logger,
is_sm90_supported,
is_sm100_supported,
is_sm120_supported,
torch_dtype,
)

from .config import EngineConfig
from .graph import GraphRunner, get_free_memory, mem_GB
Expand Down Expand Up @@ -220,7 +227,14 @@ def override(attr: str, value: Any): # this is dangerous, use with caution
object.__setattr__(config, attr, value)

if config.attention_backend == "auto":
backend = "trtllm" if is_sm100_supported() else ("fa,fi" if is_sm90_supported() else "fi")
if is_sm120_supported():
backend = "fi"
elif is_sm100_supported():
backend = "trtllm"
elif is_sm90_supported():
backend = "fa,fi"
else:
backend = "fi"
override("attention_backend", backend)
logger.info_rank0(f"Auto-selected attention backend: {config.attention_backend}")

Expand Down
3 changes: 2 additions & 1 deletion python/minisgl/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .arch import is_arch_supported, is_sm90_supported, is_sm100_supported
from .arch import is_arch_supported, is_sm90_supported, is_sm100_supported, is_sm120_supported
from .hf import cached_load_hf_config, download_hf_weight, load_tokenizer
from .logger import init_logger
from .misc import UNSET, Unset, align_ceil, align_down, call_if_main, div_ceil, div_even
Expand All @@ -21,6 +21,7 @@
"is_arch_supported",
"is_sm90_supported",
"is_sm100_supported",
"is_sm120_supported",
"call_if_main",
"div_even",
"div_ceil",
Expand Down
6 changes: 6 additions & 0 deletions python/minisgl/utils/arch.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ def is_sm90_supported() -> bool:

def is_sm100_supported() -> bool:
return is_arch_supported(10, 0)


def is_sm120_supported() -> bool:
# Consumer Blackwell (sm120) numerically passes the sm100 check but doesn't support
# trtllm-gen/FA4 kernels, which target datacenter Blackwell (sm100/B200) only.
return is_arch_supported(12, 0)