Skip to content

[k3] declare packed_modules_mapping on KimiK3ForConditionalGeneration - #36211

Merged
ispobock merged 2 commits into
sgl-project:mainfrom
klshuster:kurt/k3-upstream-fixes
Aug 28, 2026
Merged

ispobock merged 2 commits into
sgl-project:mainfrom
klshuster:kurt/k3-upstream-fixes

Conversation

@klshuster

@klshuster klshuster commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

We need this packed modules mapping for reading excluded modules from quantization configs. This is primarily a concern for nvfp4 weights, such as NVIDIA's checkpoint here. Note that this checkpoint is OK because of wildcards but a more intentional/systematic approach is desired.

The following is AI's slightly-verbose rationale:

KimiK3's runtime fuses checkpoint shards into merged modules (qkv_conv1d, fused_qkvg_proj, fused_qkvbfg_a_proj, fused_fg_b_proj, ...), but the model class declares no packed_modules_mapping, so quantization configs cannot match per-shard exclude_modules against the fused runtime prefixes.

Concretely, NVIDIA's Kimi-K3-NVFP4 hf_quant_config.json excludes self_attn.q_conv1d / self_attn.k_conv1d / self_attn.v_conv1d; today the fused qkv_conv1d module is only excluded because the v_conv1d pattern happens to substring-match the fused name 'qkv_conv1d' -- the q_ and k_ patterns match nothing. Any checkpoint whose excludes do not get that one-character accident quantizes modules the producer excluded.

Declare the mapping (same shape as the 80+ other model classes), so ModelOptFp4Config and friends resolve fused prefixes to their shard names structurally.

Modifications

Added packed modules mapping to K3

Accuracy Tests

Speed Tests and Profiling

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test (Base): ✅ Run #33060683597
Latest PR Test (Extra): ❌ Run #33060683273
Latest PR Test (AMD ROCm 7.2): ❌ Run #33060683637

KimiK3's runtime fuses checkpoint shards into merged modules (qkv_conv1d,
fused_qkvg_proj, fused_qkvbfg_a_proj, fused_fg_b_proj, ...), but the model
class declares no packed_modules_mapping, so quantization configs cannot
match per-shard exclude_modules against the fused runtime prefixes.

Concretely, NVIDIA's Kimi-K3-NVFP4 hf_quant_config.json excludes
*self_attn.q_conv1d* / *self_attn.k_conv1d* / *self_attn.v_conv1d*; today
the fused qkv_conv1d module is only excluded because the *v_conv1d*
pattern happens to substring-match the fused name 'qkv_conv1d' -- the q_
and k_ patterns match nothing. Any checkpoint whose excludes do not get
that one-character accident quantizes modules the producer excluded.

Declare the mapping (same shape as the 80+ other model classes), so
ModelOptFp4Config and friends resolve fused prefixes to their shard names
structurally.
@ispobock ispobock added run-ci CI: run the baseline test suite on this PR bypass-fastfail run-ci-extra CI: also run the extra suite (requires run-ci) labels Aug 27, 2026
@ispobock
ispobock merged commit b7686e1 into sgl-project:main Aug 28, 2026
191 of 219 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bypass-fastfail run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants