refactor : use factory for attention backends

- register built-in backends through BaseFactory
- derive benchmark choices from registered backends
- cover string selection and invalid backend names
This commit is contained in:
2026-08-05 15:37:22 +08:00
parent 8c052c99ee
commit 8152760b5f
4 changed files with 43 additions and 21 deletions
+2
View File
@@ -18,6 +18,7 @@ SDPA is handled by the attention backend, not the wrapper functions.
from astrai.extension.attention_backend import (
ATTN_BACKEND,
AttentionBackend,
AttentionBackendFactory,
CudaBackend,
FlashAttnBackend,
TorchNativeBackend,
@@ -37,6 +38,7 @@ from astrai.extension.rotary_backend import apply_rotary_emb
__all__ = [
"ATTN_BACKEND",
"AttentionBackend",
"AttentionBackendFactory",
"CudaBackend",
"TorchNativeBackend",
"FlashAttnBackend",