[Bugfix][Model] Restore causal image SWA for DeepSeek V4.1 (#57152)
Signed-off-by: Juntian Liu <Juntianl777@gmail.com> Signed-off-by: Isotr0py <Isotr0py@outlook.com> Co-authored-by: Codex <noreply@openai.com> Co-authored-by: Isotr0py <Isotr0py@outlook.com>
This commit is contained in:
co-authored by
Codex
Isotr0py
parent
651a88c09a
commit
9f9e1dac26
@@ -452,13 +452,15 @@ class DeepseekSparseSWAMetadataBuilder(AttentionMetadataBuilder):
|
||||
assert hasattr(hf_config, "sliding_window")
|
||||
self.window_size = hf_config.sliding_window
|
||||
|
||||
# Vision variant: image spans (up to vision_max_n_token tokens) are
|
||||
# V4 vision variant: image spans (up to vision_max_n_token tokens) are
|
||||
# visible bidirectionally, so prefill index rows widen from
|
||||
# window_size to window_size + max_image_tokens. Text-only models keep
|
||||
# max_image_tokens == 0 and take the original code paths everywhere.
|
||||
# window_size to window_size + max_image_tokens. The V4 config sets
|
||||
# mm_prefix_clamp_sliding_window exactly for these in-kernel-widened
|
||||
# ranges; V4.1 image tokens use the plain causal window, and text-only
|
||||
# models keep max_image_tokens == 0 everywhere.
|
||||
self.max_image_tokens = (
|
||||
getattr(hf_config, "vision_max_n_token", 0)
|
||||
if getattr(hf_config, "vision_n_layers", 0) > 0
|
||||
if getattr(hf_config, "mm_prefix_clamp_sliding_window", False)
|
||||
else 0
|
||||
)
|
||||
self.prefill_index_width = self.window_size + self.max_image_tokens
|
||||
|
||||
Reference in New Issue
Block a user