concept olmo block - #4927
Open
grimoire wants to merge 20 commits into
Open
concept olmo block#4927grimoire wants to merge 20 commits into
grimoire wants to merge 20 commits into
Conversation
…block # Conflicts: # lmdeploy/pytorch/backends/cuda/op_backend.py # lmdeploy/pytorch/nn/__init__.py # tests/pytorch/config/test_model_config.py
…block # Conflicts: # lmdeploy/pytorch/backends/cuda/op_backend.py
grimoire
force-pushed
the
codex/concept-olmo-block
branch
from
September 3, 2026 07:40
9ad5553 to
7a9a64d
Compare
grimoire
marked this pull request as ready for review
September 4, 2026 03:20
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
It unconditionally enables trust_remote_code=True when loading a tokenizer during config building, which is a security-sensitive behavior that should be explicitly user-controlled.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds initial runtime + model implementation support for ConceptLM v2.2 VQ (“intern_ncp”), including model configuration backfilling from exported training config, backend runtime ops (Torch + Triton), and CUDA kernels to support chunk-based concept prediction during prefill/decode.
Changes:
- Introduces
ConceptLMV22VQForCausalLMmodel implementation (modules/metadata/weight loading) and wires it intoMODULE_MAP. - Adds ConceptLM runtime ops contract + default/cuda backend implementations and Triton kernels for chunk merge + cache updates.
- Adds a ConceptLM config builder that can backfill sparse HF exports from
training_config.yaml, plus tests for backfill and YaRN rotary normalization.
File summaries
| File | Description |
|---|---|
| tests/pytorch/config/test_model_config.py | Adds unit tests for ConceptLM training-config backfill and YaRN rotary normalization behavior. |
| lmdeploy/pytorch/nn/conceptlm.py | Adds ConceptLMRuntimeOps nn.Module wrapper to dispatch runtime ops via backend. |
| lmdeploy/pytorch/nn/init.py | Exports ConceptLMRuntimeOps from the nn package. |
| lmdeploy/pytorch/models/module_map.py | Registers ConceptLMV22VQForCausalLM for dynamic model loading. |
| lmdeploy/pytorch/models/intern_ncp/init.py | Declares the intern_ncp model package export. |
| lmdeploy/pytorch/models/intern_ncp/weight.py | Adds weight utilities (OLMo QKV repack, stacked codebook slice loading). |
| lmdeploy/pytorch/models/intern_ncp/modules.py | Implements ConceptLM/OLMo blocks, routing, quantizer, and weight-loading logic. |
| lmdeploy/pytorch/models/intern_ncp/modeling.py | Adds top-level ConceptLMV22VQForCausalLM forward path, cache plumbing, and weight loading. |
| lmdeploy/pytorch/models/intern_ncp/metadata.py | Adds ConceptLM metadata + cache view helpers (KV split, named state cache access). |
| lmdeploy/pytorch/configurations/conceptlm.py | Adds ConceptLM model-config builder with training-config backfill and rotary normalization. |
| lmdeploy/pytorch/backends/base.py | Adds new OpType.ConceptLMRuntimeOps. |
| lmdeploy/pytorch/backends/conceptlm.py | Adds backend contract types for ConceptLM runtime ops and metadata structs. |
| lmdeploy/pytorch/backends/default/op_backend.py | Registers default backend builder for ConceptLMRuntimeOps. |
| lmdeploy/pytorch/backends/default/conceptlm.py | Implements Torch fallback ConceptLM runtime ops (prefill compaction, decode update, KV snapshot/restore). |
| lmdeploy/pytorch/kernels/cuda/conceptlm.py | Adds Triton kernels for ConceptLM chunk merge and cache updates. |
| lmdeploy/pytorch/backends/cuda/op_backend.py | Registers CUDA backend builder for ConceptLMRuntimeOps. |
| lmdeploy/pytorch/backends/cuda/conceptlm.py | Connects CUDA backend ops to Triton kernels with fallbacks. |
| lmdeploy/pytorch/backends/cuda/attention/fa3.py | Uses attn_metadata.max_q_seqlen when provided. |
| autotest/interface/restful/tool_parser/test_tool_call_anthropic_sdk.py | Minor docstring wording tweak. |
Review details
- Files reviewed: 19/19 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+287
to
+295
| def _fill_special_tokens(hf_config, model_path: str = None): | ||
| try: | ||
| from transformers import AutoTokenizer | ||
| tok = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True) | ||
| hf_config.bos_token_id = tok.bos_token_id | ||
| hf_config.eos_token_id = tok.eos_token_id | ||
| if getattr(hf_config, 'pad_token_id', None) is None: | ||
| hf_config.pad_token_id = tok.pad_token_id | ||
| except Exception as e: # noqa: BLE001 |
Comment on lines
+679
to
+681
| qkv_states = self.qkv_proj(hidden_states) | ||
| qkv_states = qkv_states.flatten(0, -2) # (-1, heads_total, head_dim) | ||
| query_states, key_states, value_states = self.qkv_proj.split_qkv(qkv_states) |
…block # Conflicts: # lmdeploy/pytorch/backends/cuda/op_backend.py # lmdeploy/pytorch/backends/default/op_backend.py
…block # Conflicts: # autotest/interface/restful/tool_parser/test_tool_call_anthropic_sdk.py
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.
Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily receiving feedbacks. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.
Motivation
Please describe the motivation of this PR and the goal you want to achieve through this PR.
Modification
Please briefly describe what modification is made in this PR.
BC-breaking (Optional)
Does the modification introduce changes that break the backward-compatibility of the downstream repositories?
If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR.
Use cases (Optional)
If this PR introduces a new feature, it is better to list some use cases here, and update the documentation.
Checklist