vllm.model_executor.models.transformers.fuser ¶
Fuser detection for the Transformers modeling backend.
get_fusers traces a module class once (see fx_utils) and matches it against each concrete fuser in fusers; Fusers caches the result per class for a whole model. At most one match may give the module a different forward, and any number of fusers that leave the forward alone apply alongside. base.recursive_replace then applies them per instance. RMSNorm-shaped modules the tracer cannot match are warned about.
Classes:
-
Fusers–Mapping from module class and shape to fusers, for all fusable modules.
Functions:
-
get_fuser–The first
fuser_clsthat applies tomodule, if one does. -
get_fusers–Every fuser that applies to
module's class and shape (cached). -
key–Cache key for
get_fusers. Considers module type and its immediate children.
Attributes:
-
FUSERS(tuple[type[BaseFuser], ...]) –Every fuser, in match order: those that redefine the forward first, then those
FUSERS = (MLAFuser, GLUFuser, QKVFuser, PackedQKVFuser, RMSNormFuser, AttentionFuser) module-attribute ¶
Every fuser, in match order: those that redefine the forward first, then those that leave it alone. A new fuser is added here.
Fusers ¶
Bases: UserDict
Mapping from module class and shape to fusers, for all fusable modules.
Methods:
-
__getitem__–The fusers this instance can take, in the order to apply them.
Source code in vllm/model_executor/models/transformers/fuser.py
__getitem__(m) ¶
The fusers this instance can take, in the order to apply them.
Source code in vllm/model_executor/models/transformers/fuser.py
get_fuser(module, fuser_cls) ¶
The first fuser_cls that applies to module, if one does.
get_fusers(module) ¶
Every fuser that applies to module's class and shape (cached).
The one that redefines the forward comes first, so applying them in order fuses before the rest read or adjust the result.
Source code in vllm/model_executor/models/transformers/fuser.py
key(module) ¶
Cache key for get_fusers. Considers module type and its immediate children.