feat: support Intern-S2-Preview TS encoder - #4810
Open
CUHKSZzxy wants to merge 2 commits into
Open
Conversation
CUHKSZzxy
marked this pull request as ready for review
August 5, 2026 10:01
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds dedicated Intern-S2-Preview time-series (TS) support by splitting it into a separate VL/PyTorch model path, while also improving TS metadata propagation and fixing Whisper packed-QKV loading for TS encoders.
Changes:
- Introduce new InternS2Preview VL + PyTorch model implementations, including a dedicated TS encoder and forecaster-weight skipping during load.
- Propagate
ts_channelsthrough preprocessing/expanded multimodal items to support multi-channel TS batching. - Remove TS handling from generic Qwen3.5 VL/PyTorch paths and update docs + tests to reflect Intern-S2-Preview TS support.
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_lmdeploy/test_vl/test_preprocess_utils.py | Adds coverage for TS expansion metadata (ts_channels, ts_token_id). |
| lmdeploy/vl/model/qwen3_5.py | Removes InternS2Preview and TS preprocessing from the generic Qwen3.5 VL model path. |
| lmdeploy/vl/model/preprocess_utils.py | Preserves ts_channels when expanding TS multimodal items. |
| lmdeploy/vl/model/interns2_preview.py | Adds a dedicated VL model wrapper for InternS2Preview with TS preprocessing/token counting logic. |
| lmdeploy/vl/model/builder.py | Registers the new InternS2Preview vision model for construction. |
| lmdeploy/vl/model/base.py | Adds ts_channels modality mapping and constrains requests to one TS input. |
| lmdeploy/pytorch/models/whisper.py | Adds helper to synthesize missing Whisper K-proj bias for packed QKV loading in TS modules. |
| lmdeploy/pytorch/models/qwen3_vl.py | Removes TS MultiModalData construction from generic Qwen3VL input processing. |
| lmdeploy/pytorch/models/qwen3_5.py | Removes TS forward/generation plumbing from the generic Qwen3.5 PyTorch model path. |
| lmdeploy/pytorch/models/qwen3_5_moe.py | Stops building legacy TS module in Qwen3.5-MoE and skips forecaster tensors only. |
| lmdeploy/pytorch/models/module_map.py | Maps InternS2Preview architectures to the new PyTorch model implementation. |
| lmdeploy/pytorch/models/interns2_preview.py | Adds InternS2Preview PyTorch model + input processor with TS batching/padding support. |
| lmdeploy/pytorch/models/interns2_preview_ts_encoder.py | Implements InternS2Preview TS encoder stack (Whisper/BERT-derived components). |
| lmdeploy/pytorch/models/interns1_pro.py | Renames TS encoder import and applies the Whisper K-proj bias synthesis during weight load. |
| lmdeploy/pytorch/models/interns1_pro_ts_encoder.py | New/renamed TS encoder implementation for InternS1-Pro. |
| lmdeploy/pytorch/models/bert.py | Adds a lightweight BERT implementation used by the new TS encoder stack. |
| docs/zh_cn/multi_modal/multimodal_inputs.md | Updates Chinese docs to include Intern-S2-Preview TS support and clarify sampling rate. |
| docs/en/multi_modal/multimodal_inputs.md | Updates English docs similarly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+100
to
+108
| ts_placeholder = input_ids == self.config.ts_token_id | ||
| n_ts_placeholders = ts_placeholder.sum().item() | ||
| n_ts_tokens = ts_features.size(0) | ||
| assert n_ts_placeholders == n_ts_tokens, ( | ||
| f'Mismatch: <TS_CONTEXT> tokens={n_ts_placeholders}, ts_embeds_valid={n_ts_tokens}') | ||
|
|
||
| flat_embeds = inputs_embeds.reshape(-1, inputs_embeds.size(-1)) | ||
| flat_embeds[ts_placeholder.reshape(-1)] = ts_features | ||
| inputs_embeds = flat_embeds.reshape_as(inputs_embeds) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validation
python -m py_compileon touched Python filespytest tests/test_lmdeploy/test_vl/test_preprocess_utils.py -qgit commitAssistance
Assisted with Codex + GPT-5.6-Sol xHigh, reviewed manually