vllm.model_executor.models.transformers.fusers.attention
¶
Attention fuser: the module that dispatches to the attention interface.
Classes:
-
AttentionFuser–A module that dispatches through the Transformers attention interface.
Functions:
-
cache_offset_arg–The argument
forwardadds toself.layer_idxto get its cache layer, if any. -
interface_call–The attention interface call in
forward, if it makes exactly one.
AttentionFuser
dataclass
¶
Bases: BaseFuser
A module that dispatches through the Transformers attention interface.
Methods:
-
layer_index–The layer
modulecomputes attention for, if it declares one. -
scale–The softmax scale
modulepasses to the interface, orNone. -
sinks–The per-head sink tensor
modulepasses to the interface, orNone. -
validate–Whether
modulewill actually dispatch to vLLM.
Attributes:
-
cache_offset_arg(str | None) –The argument that offsets the module's cache layer, see
cache_offset_arg. -
s_aux_expr(expr | None) –Source of the
s_aux=the module hands the interface, if it hands one. -
scale_expr(expr | None) –Source of the
scaling=the module hands the interface, if it hands one. -
source_cls(str) –Class of the HF module that dispatches (for logging).
Source code in vllm/model_executor/models/transformers/fusers/attention.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
cache_offset_arg = None
class-attribute
instance-attribute
¶
The argument that offsets the module's cache layer, see cache_offset_arg.
s_aux_expr = None
class-attribute
instance-attribute
¶
Source of the s_aux= the module hands the interface, if it hands one.
scale_expr = None
class-attribute
instance-attribute
¶
Source of the scaling= the module hands the interface, if it hands one.
source_cls
instance-attribute
¶
Class of the HF module that dispatches (for logging).
layer_index(module)
¶
The layer module computes attention for, if it declares one.
Source code in vllm/model_executor/models/transformers/fusers/attention.py
scale(module)
¶
The softmax scale module passes to the interface, or None.
Source code in vllm/model_executor/models/transformers/fusers/attention.py
sinks(module)
¶
The per-head sink tensor module passes to the interface, or None.
Source code in vllm/model_executor/models/transformers/fusers/attention.py
validate(module, vllm_config)
¶
Whether module will actually dispatch to vLLM.
Source code in vllm/model_executor/models/transformers/fusers/attention.py
_is_interface_lookup(node)
¶
Whether node reads an entry out of ALL_ATTENTION_FUNCTIONS.
Source code in vllm/model_executor/models/transformers/fusers/attention.py
_resolve(node, module)
¶
The value of node on module, for literals and self.<attr>.
Source code in vllm/model_executor/models/transformers/fusers/attention.py
cache_offset_arg(forward)
cached
¶
The argument forward adds to self.layer_idx to get its cache layer, if any.
Looped models run a module more than once per forward pass and give each pass
its own cache layer this way (e.g. Dory's cache_offset, HRM-Text's
cycle_offset).
Source code in vllm/model_executor/models/transformers/fusers/attention.py
interface_call(forward)
cached
¶
The attention interface call in forward, if it makes exactly one.