[PR #150] [CLOSED] fix: remove trailing space in 'map' string comparison in reset_classifier #151

Closed
opened 2026-10-26 21:12:45 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/deepseek-ai/DeepSeek-VL2/pull/150
Author: @Mr-Neutr0n
Created: 2/11/2026
Status: ❌ Closed

Base: main ← Head: fix/reset-classifier-map-trailing-space


📝 Commits (1)

  • 4f18a5c fix: remove trailing space in 'map' string comparison in reset_classifier

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 deepseek_vl2/models/siglip_vit.py (+1 -1)

📄 Description

Summary

In deepseek_vl2/models/siglip_vit.py, the VisionTransformer.reset_classifier method has a trailing space in a string comparison on the elif branch:

elif global_pool != 'map ' and self.attn_pool is not None:

The valid pool types are ('', 'avg', 'token', 'map') — without any trailing space — as enforced by the assert on the line above. Because 'map' != 'map ' always evaluates to True, calling reset_classifier(num_classes, global_pool='map') incorrectly destroys the attention pooling layer (self.attn_pool = None) even though the user explicitly requested 'map' pooling.

Fix

Remove the trailing space so the comparison correctly checks against 'map':

elif global_pool != 'map' and self.attn_pool is not None:

This ensures that when global_pool='map' is passed, the existing attn_pool is preserved as intended.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/deepseek-ai/DeepSeek-VL2/pull/150 **Author:** [@Mr-Neutr0n](https://github.com/Mr-Neutr0n) **Created:** 2/11/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/reset-classifier-map-trailing-space` --- ### 📝 Commits (1) - [`4f18a5c`](https://github.com/deepseek-ai/DeepSeek-VL2/commit/4f18a5c017e234a42c13731901dc1893fd489c3b) fix: remove trailing space in 'map' string comparison in reset_classifier ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `deepseek_vl2/models/siglip_vit.py` (+1 -1) </details> ### 📄 Description ## Summary In `deepseek_vl2/models/siglip_vit.py`, the `VisionTransformer.reset_classifier` method has a trailing space in a string comparison on the `elif` branch: ```python elif global_pool != 'map ' and self.attn_pool is not None: ``` The valid pool types are `('', 'avg', 'token', 'map')` — without any trailing space — as enforced by the `assert` on the line above. Because `'map' != 'map '` always evaluates to `True`, calling `reset_classifier(num_classes, global_pool='map')` incorrectly destroys the attention pooling layer (`self.attn_pool = None`) even though the user explicitly requested `'map'` pooling. ## Fix Remove the trailing space so the comparison correctly checks against `'map'`: ```python elif global_pool != 'map' and self.attn_pool is not None: ``` This ensures that when `global_pool='map'` is passed, the existing `attn_pool` is preserved as intended. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
deepseek-ai/DeepSeek-VL2#151
No description provided.