mirror of
https://github.com/huggingface/text-generation-inference.git
synced 2025-04-22 15:32:08 +00:00
* Improve support for GPUs with capability < 8 - For models that cannot use flashinfer, use flash-attn v1 + paged attention for models with a compute capability older than 8. - Disable prefix caching when using paged attention. - When using flash-attn v1, pass the key/value, rather than the cache, since v1 cannot use block tables. * nix: add flash-attn-v1 to the server environment * Move disabling prefix caching into the block of exceptions * Capability as `usize`s
44 lines
992 B
Python
44 lines
992 B
Python
from text_generation_server.utils.import_utils import SYSTEM
|
|
import os
|
|
|
|
from .common import Seqlen
|
|
|
|
if os.getenv("USE_FLASH_ATTENTION", "").lower() == "false":
|
|
raise ImportError("`USE_FLASH_ATTENTION` is false.")
|
|
if SYSTEM == "cuda":
|
|
from .cuda import (
|
|
attention,
|
|
paged_attention,
|
|
reshape_and_cache,
|
|
SUPPORTS_WINDOWING,
|
|
PREFILL_IN_KV_CACHE,
|
|
)
|
|
elif SYSTEM == "rocm":
|
|
from .rocm import (
|
|
attention,
|
|
paged_attention,
|
|
reshape_and_cache,
|
|
PREFILL_IN_KV_CACHE,
|
|
SUPPORTS_WINDOWING,
|
|
)
|
|
elif SYSTEM == "ipex":
|
|
from .ipex import (
|
|
attention,
|
|
paged_attention,
|
|
reshape_and_cache,
|
|
PREFILL_IN_KV_CACHE,
|
|
SUPPORTS_WINDOWING,
|
|
)
|
|
else:
|
|
raise ImportError(f"System {SYSTEM} doesn't support flash/paged attention")
|
|
|
|
|
|
__all__ = [
|
|
"attention",
|
|
"paged_attention",
|
|
"reshape_and_cache",
|
|
"PREFILL_IN_KV_CACHE",
|
|
"SUPPORTS_WINDOWING",
|
|
"Seqlen",
|
|
]
|