You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make mm_token_type_ids mark the same tokens across processors #51234
mm_token_type_ids does not mark the same tokens across multimodal processors. For some models it also marks the BOI/EOI, separator and tile tokens around the image embeddings. For others it marks only the embedding (placeholder) tokens.
Marks BOI/EOI/separators as well (image_token_ids lists them, or the span is marked whole):
Aya Vision: img_patch_token, tile_token, tile_global_token, start_of_img_token, end_of_img_token
Idefics3: overrides create_mm_token_type_ids and marks the whole expanded span, including the fake image, global image and row/col tokens
Marks only the embedding tokens:
Qwen2-VL family, GLM-4V
So mm_token_type_ids.sum(-1) means "number of image embeddings" for some models and "embeddings plus wrapper tokens" for others. The _get_num_multimodal_tokens tests in #50671 stopped comparing against mm_token_type_ids for this reason, and now count the embedding tokens in text_replacement_offsets instead (see this thread).
Motivation
A single meaning would let downstream code (vLLM, the _get_num_multimodal_tokens tests, model forwards that scatter features using it) rely on mm_token_type_ids without per-model special cases. We discussed making it uniform even if that is a breaking change.
Activity