mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 01:31:13 +02:00
feat(xyz): add attention and sparse attention axes
Fourteen axes drive the attention subsystem from the grid: the diffusers method, the sdp override chain, the dispatcher kernel, five sdnq attention knobs and six sparse settings. An axis writes shared.opts.data and rebuilds the chain itself, since the onchange for these settings runs through the queue lock a grid cell already holds. SharedSettingsStackHelper saves and restores every attention setting around the grid, keys an axis introduced included, and an axis for a setting a backend owns warns when that backend is not in the active chain.
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
"""Attention backends: one scaled_dot_product_attention router over the registered backends, the per-generation context, and the diffusers-side processor and dispatcher setup."""
|
||||
from modules.attention.registry import AttentionBackend, AttentionCall, Constraints, Platform, Registry, registry
|
||||
from modules.attention.router import Plan, PlanEntry, build_plan, get_plan, install_router, reapply, reapply_options, report
|
||||
from modules.attention.dispatcher import set_diffusers_attention, set_attention_dispatcher, hijack_kernels, get_kernel_hijack, get_hf_api_hijack
|
||||
from modules.attention.dispatcher import set_diffusers_attention, set_attention_dispatcher, list_dispatcher_backends, hijack_kernels, get_kernel_hijack, get_hf_api_hijack
|
||||
from modules.attention import backends, context, debug
|
||||
|
||||
__all__ = [
|
||||
'AttentionBackend', 'AttentionCall', 'Constraints', 'Platform', 'Registry', 'registry',
|
||||
'Plan', 'PlanEntry', 'build_plan', 'get_plan', 'install_router', 'reapply', 'reapply_options', 'report',
|
||||
'set_diffusers_attention', 'set_attention_dispatcher', 'hijack_kernels', 'get_kernel_hijack', 'get_hf_api_hijack',
|
||||
'set_diffusers_attention', 'set_attention_dispatcher', 'list_dispatcher_backends', 'hijack_kernels', 'get_kernel_hijack', 'get_hf_api_hijack',
|
||||
'backends', 'context', 'debug',
|
||||
]
|
||||
|
||||
@@ -94,3 +94,13 @@ def set_attention_dispatcher(pipe):
|
||||
log.warning(f'Attention dispatcher: active={prev[0].value} list={backends} target={attn} not found')
|
||||
else:
|
||||
log.debug(f'Attention dispatcher: active={prev[0].value} list={backends}')
|
||||
|
||||
|
||||
def list_dispatcher_backends() -> list:
|
||||
"""The kernels diffusers can dispatch attention to, for anything that offers hf_attention as a choice."""
|
||||
try:
|
||||
from diffusers.models import attention_dispatch as a
|
||||
return sorted(b.value for b in a._AttentionBackendRegistry.list_backends()) # pylint: disable=protected-access
|
||||
except Exception as e:
|
||||
log.error(f'Attention dispatcher: {e}')
|
||||
return []
|
||||
|
||||
Reference in New Issue
Block a user