Skip to content

feat: implement CPT-MoE Router v1 from the frozen specification - #1

Open
wwd43 wants to merge 2 commits into
mikecovlee:mainfrom
wwd43:cpt_v1
Open

feat: implement CPT-MoE Router v1 from the frozen specification#1
wwd43 wants to merge 2 commits into
mikecovlee:mainfrom
wwd43:cpt_v1

Conversation

@wwd43

@wwd43 wwd43 commented Aug 1, 2026

Copy link
Copy Markdown

Summary

  • Implements CPT-MoE Router v1 strictly following the frozen specification.
  • Uses Px followed by per-token stable L2 normalization, without projection softmax.
  • Adds Native/HF parity, checkpoint identity validation, continuation state, recompute policies, training transactions, and safety tests.
  • Preserves the existing post-router Top-2 MoE behavior.

Validation

  • CUDA: 669 passed
  • CPU-only: 650 passed, 19 skipped
  • Cross-version compatibility checks: 122/122 passed

No formal long-training, quality, specialization, or throughput claims are made.

@mikecovlee mikecovlee left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

请先rebase main

Comment thread model/modeling.py Outdated
)
# padding: [B, 1, 1, S] → 控制哪些 key 可见
combined = combined & attention_mask[:, None, None, :]
if segment_ids is not None:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

为什么这里需要在Attention里面注入segment_ids

Comment thread model/modeling.py Outdated
pad_4d = attention_mask[:, None, None, :] # [B, 1, 1, S]
combined = causal[None, None, :, :] & pad_4d # [B, 1, S, S]
combined = causal[None, None, :, :]
if attention_mask is not None:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

是否是必要的更改?考虑rebase main后再看

Comment thread model/cpt_router.py

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

代码风格不一致,有的用nn.Parameters, 有的用register,考虑统一

@mikecovlee
mikecovlee requested a review from Copilot August 1, 2026 10:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

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.

3 participants