Skip to content

feat: support Intern-S2-Preview TS encoder - #4810

Open
CUHKSZzxy wants to merge 2 commits into
InternLM:mainfrom
CUHKSZzxy:interns2-preview-ts-encoder-only
Open

feat: support Intern-S2-Preview TS encoder#4810
CUHKSZzxy wants to merge 2 commits into
InternLM:mainfrom
CUHKSZzxy:interns2-preview-ts-encoder-only

Conversation

@CUHKSZzxy

Copy link
Copy Markdown
Collaborator

Summary

  • Add InternS2 Preview encoder-only time-series support in a separated PyTorch/VL model path.
  • Keep the InternS1-Pro time-series encoder rename and shared Whisper K-proj bias loader fix.
  • Skip packaged time-series forecaster checkpoint tensors during loading without exposing forecast API/runtime paths.

Validation

  • python -m py_compile on touched Python files
  • pytest tests/test_lmdeploy/test_vl/test_preprocess_utils.py -q
  • pre-commit hooks from git commit

Assistance

Assisted with Codex + GPT-5.6-Sol xHigh, reviewed manually

@CUHKSZzxy CUHKSZzxy changed the title feat: support interns2 preview time-series encoder feat: support Intern-S2-Preview TS encoder Aug 5, 2026
@CUHKSZzxy
CUHKSZzxy marked this pull request as ready for review August 5, 2026 10:01
Copilot AI lite review requested due to automatic review settings August 5, 2026 10:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_channels through 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 thread lmdeploy/pytorch/models/interns2_preview_ts_encoder.py
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants