Skip to content

Commit 0d4457a

Browse files
committed
feat(model): add native Inkling text bridge and LoRA support
Signed-off-by: Neil Kale <263453039+kalectory@users.noreply.github.com>
1 parent 8e7077c commit 0d4457a

11 files changed

Lines changed: 1860 additions & 0 deletions

File tree

‎docs/index.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ models/gemma/index.md
4343
models/glm/index.md
4444
models/gpt_oss/index.md
4545
models/hy_v3/hy-v3.md
46+
models/inkling/inkling.md
4647
models/kimi/index.md
4748
models/llama/index.md
4849
models/minimax/index.md

‎docs/models/inkling/inkling.md‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Inkling
2+
3+
The Inkling bridge converts the text backbone of the unquantized
4+
[`thinkingmachines/Inkling-Small`](https://huggingface.co/thinkingmachines/Inkling-Small)
5+
checkpoint (276B total / 12B active parameters). It uses native Megatron tensor
6+
and expert parallel projections, Transformer Engine normalization and grouped
7+
experts, and PyTorch FlexAttention for the learned relative-position bias.
8+
9+
```python
10+
from megatron.bridge import AutoBridge
11+
12+
bridge = AutoBridge.from_hf_pretrained("/shared/models/Inkling-Small")
13+
provider = bridge.to_megatron_provider()
14+
provider.expert_model_parallel_size = 8
15+
provider.expert_tensor_parallel_size = 1
16+
provider.finalize()
17+
model = provider.provide_distributed_model(wrap_with_ddp=False)
18+
```
19+
20+
Download a fixed checkpoint revision to the shared path before launching all
21+
ranks. Conversion reads the published `model.llm.*` safetensors layout directly.
22+
Transformers' materialized model uses different names and is not a conversion
23+
source. Dense, routed, and shared `w13` weights contain interleaved gate/up rows.
24+
Full checkpoint export preserves the source audio, vision, and auxiliary MTP
25+
tensors unchanged; these components are not trained.
26+
27+
For attention-only LoRA, target `linear_qkv`, `linear_r`, and `linear_proj`.
28+
Native adapter export produces Inkling's published `wq_du`, `wk_dv`, `wv_dv`,
29+
`wr_du`, and `wo_ud` names. No downstream adapter-name translation is required.
30+
31+
Supported execution is unpacked text training and full-sequence scoring with
32+
zero dropout and context parallel size 1. Packed sequences, cached generation,
33+
CUDA graphs, quantized checkpoint import, and multimodal/MTP training are not
34+
implemented. FlexAttention backward through the relative bias is tested on
35+
PyTorch 2.13; older releases are not qualified. Use a serving engine for cached
36+
generation.
37+
38+
The two-layer FP32 functional suite passes at TP1/EP1, TP2/EP1, and TP1/EP2
39+
on H200 with full-layer recomputation. It checks all 42 checkpoint tensors,
40+
forward/backward parity against Transformers, nonzero LoRA export (20 tensors),
41+
merged export, and native base/adapter checkpoint restore. Operator tests also
42+
compare relative-attention and convolution gradients against Transformers.
43+
FP32 internal router/convolution weights retain the imported BF16 values but
44+
export in FP32 unless an export dtype is requested.
45+
46+
Full Inkling-Small training, serving parity, and capacity qualification remain
47+
pending; the tiny-model checks do not qualify the 276B checkpoint.

‎src/megatron/bridge/models/__init__.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
HybridModelConfig,
105105
HybridModelProvider,
106106
)
107+
from megatron.bridge.models.inkling import InklingBridge, InklingModelProvider
107108
from megatron.bridge.models.kimi import (
108109
KimiK2Bridge,
109110
KimiK3Bridge,
@@ -257,6 +258,8 @@
257258
"HybridModelBuilder",
258259
"HybridModelConfig",
259260
"HybridModelProvider",
261+
"InklingBridge",
262+
"InklingModelProvider",
260263
"KimiK2Bridge",
261264
"KimiK3Bridge",
262265
"KimiK3ModelProvider",
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from megatron.bridge.models.inkling.inkling_bridge import InklingBridge, InklingModelProvider
16+
17+
18+
__all__ = ["InklingBridge", "InklingModelProvider"]

0 commit comments

Comments
 (0)