bridge.models.qwen_vl.data.collate_fn#
Qwen VL collator implementations.
Module Contents#
Classes#
One fully processed, unpadded Qwen-VL sequence and its visual payload. |
Functions#
Map path-based video parts to the inline schema expected by Qwen processors. |
|
Process one example into the exact row consumed by THD packing. |
|
Process one Qwen-VL example once for online or collate-time packing. |
|
Build one canonical MCore THD row from prepared Qwen-VL sequences. |
|
Collate function for Qwen2.5 VL model. |
Data#
API#
- bridge.models.qwen_vl.data.collate_fn.MISSING_QWEN_VL_UTILS_MSG#
βqwen_vl_utils is required for Qwen2.5 VL processing. Please
pip install qwen-vl-utilsor provide cβ¦β
- bridge.models.qwen_vl.data.collate_fn.QWEN_VL_MIN_PIXELS#
200704
- bridge.models.qwen_vl.data.collate_fn.QWEN_VL_MAX_PIXELS#
1003520
- bridge.models.qwen_vl.data.collate_fn.CHATML_ASSISTANT_START#
β<|im_start|>assistant\nβ
- bridge.models.qwen_vl.data.collate_fn.CHATML_ASSISTANT_END#
β<|im_end|>\nβ
- bridge.models.qwen_vl.data.collate_fn.CHATML_OTHER_ROLE_STARTS#
None
- bridge.models.qwen_vl.data.collate_fn.QWEN_VISUAL_KEYS#
()
- class bridge.models.qwen_vl.data.collate_fn.QwenVLPreparedSequence#
One fully processed, unpadded Qwen-VL sequence and its visual payload.
.. note::
This model-owned storage layout is provisional and may evolve as more VLMs adopt native packing. Callers should use
sequence_lengthwhen they do not need Qwen-specificroworvisual_valuespayloads.- row: dict[str, torch.Tensor]#
None
- visual_values: dict[str, torch.Tensor]#
None
- property sequence_length: int#
Return the exact post-processor token length.
- bridge.models.qwen_vl.data.collate_fn._normalize_qwen_video_paths(
- example: dict[str, Any],
Map path-based video parts to the inline schema expected by Qwen processors.
- bridge.models.qwen_vl.data.collate_fn._prepare_qwen_vl_sequence(
- example: dict[str, Any],
- processor: Any,
- *,
- text: str,
- images: list[Any],
- videos: list[Any],
- skipped_tokens: torch.Tensor,
- boundary_config: Any,
- min_pixels: int | None,
- max_pixels: int | None,
- require_assistant_matches: bool,
Process one example into the exact row consumed by THD packing.
- bridge.models.qwen_vl.data.collate_fn.prepare_qwen_vl_sequence(
- example: dict[str, Any],
- processor: Any,
- *,
- min_pixels: int | None = QWEN_VL_MIN_PIXELS,
- max_pixels: int | None = QWEN_VL_MAX_PIXELS,
- require_assistant_matches: bool = False,
Process one Qwen-VL example once for online or collate-time packing.
- bridge.models.qwen_vl.data.collate_fn.build_qwen_vl_packed_batch(
- sequences: list[bridge.models.qwen_vl.data.collate_fn.QwenVLPreparedSequence],
- *,
- sequence_length: int | None,
- pad_to_multiple_of: int,
- pad_to_max_length: bool = False,
Build one canonical MCore THD row from prepared Qwen-VL sequences.
When
pad_to_max_lengthis true, the last physical segment is padded so the row reachessequence_lengthwhile the unpadded THD boundaries keep describing only real tokens.
- bridge.models.qwen_vl.data.collate_fn.qwen2_5_collate_fn(
- examples: list,
- processor,
- min_pixels: int | None = QWEN_VL_MIN_PIXELS,
- max_pixels: int | None = QWEN_VL_MAX_PIXELS,
- visual_keys: object = None,
- require_assistant_matches: bool = False,
- sequence_length: int | None = None,
- pad_to_max_length: bool = False,
- pad_to_multiple_of: int = 128,
- enable_in_batch_packing: bool = False,
- in_batch_packing_pad_to_multiple_of: int = 1,
Collate function for Qwen2.5 VL model.