Skip to content

Codegen family minimal adaptation - #1640

Open
shawny999 wants to merge 1 commit into
mindspore-ai:masterfrom
shawny999:codegen_family_minimal_adaptation
Open

shawny999 wants to merge 1 commit into
mindspore-ai:masterfrom
shawny999:codegen_family_minimal_adaptation

Conversation

@shawny999

@shawny999 shawny999 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Paired: GitHub #1640 ↔ GitCode !2009

What type of PR is this?

/kind bug
/kind refactor

What does this PR do / why do we need it:

Adapt Codegen to native module-family preparation so generated model source visibly preserves the selected module replacements and forward patches for review and debugging.

  • Reuse native model construction, replacement decisions and Planner results without changing Trainer or component APIs, creating process groups, or initializing accelerator devices during generation.
  • Emit concrete module constructors at their construction sites where supported; preserve source-module wrapping where required. Reuse existing layer preparation loops for imported constructors.
  • Preserve layer-specific configuration, shared modules, layer indices, native weight tying and effective RMSNorm precision settings. Remove unused constructor arguments and redundant replacement scaffolding.
  • Reuse native imports for unchanged family members and helper types; retain source-visible CP/EP forward changes without copying entire component implementations.
  • Separate SDPA CP dispatch from the preserved local forward to prevent recursive re-entry in generated source.
  • Observe factory-tail forward changes before publication and validate that recorded patches are materialized in the emitted source.
  • Fix Kimi CP closure emission: recognize native-context-derived CP size/rank bindings and reuse existing runtime CP expressions, without freezing the observed rank or querying real communication groups during generation. Unsupported captures still fail explicitly.
  • Regenerate the tracked bundles for DeepSeek-V3, DeepSeek-V3.2, Kimi-K2.6 and Qwen3-MoE. This PR does not modify native model adapters, data batching or Trainer execution.

Validation for 35dc63e1:

  • Local and server 129 Codegen UT: 253 passed and 37 subtests passed on each environment.
  • All four tracked model configurations passed CLI/Trainer-sidecar file-inventory and SHA256 comparison, with three regular files per bundle. All 12 committed bundle files match the verified outputs.
  • The additional Kimi CP2 configuration passed single-process offline generation and CLI/sidecar byte parity. Its generated closure was checked against native behavior for both CP ranks; observation rank does not change the emitted source.
  • Offline resource guards, local pylint, lizard and AGENTS catalog checks passed.
  • After the final complexity cleanup, all four recipe bundles remained byte-identical to the previous verified outputs; the additional Kimi CP2 bundle also remained byte-identical to the initial closure fix.

DeepSeek-V3 validation retains the existing TP1 override. The committed Kimi bundle follows its canonical CP1 recipe; the additional CP2 artifacts remain in isolated validation output. No training or loss-alignment run is claimed by this validation.

Which issue(s) this PR fixes:

N/A — no issue is automatically closed by this PR.

Code review checklist [illustration]:

  • whether to verify the function's return value (It is forbidden to use void to mask the return values of security functions and self-developed functions. C++ STL functions can be masked if there is no problem)
  • Whether to comply with SOLID principle / Demeter's law
  • Whether there is UT test case && the test case is a valid (if there is no test case, please explain the reason)
  • Whether the API change is involved
  • Whether official document modification is involved

Special notes for your reviewers:

  • The branch has been rebased onto master at 11646fd9 and retains one commit. The earlier V4.1 bundle modify/delete conflict and UT conflict have been resolved; CI gate results are separate from the validation above.
  • DeepSeek-V4.1 has no tracked bundle in the current scope. Its pending local model-adapter fixes are not included in this PR.
  • Native Kimi CP2 batch/media-boundary failures and the temporary Kimi/MLA CP input-contract incompatibility are not addressed by this change.
  • Remaining KDA/GDN executor source-materialization limitations are not claimed as resolved. Codegen preserves native executor ownership and does not add registered executor back-references to native models.
  • Generated source is intended for review and debugging; generated-model training support and loss alignment are outside this change.

@shawny999

Copy link
Copy Markdown
Contributor Author

/check-pr

@shawny999
shawny999 force-pushed the codegen_family_minimal_adaptation branch from 86a54bb to 7cda6d5 Compare November 21, 2026 15:54
@shawny999

Copy link
Copy Markdown
Contributor Author

/retest

@mindspore-ai-bot

Copy link
Copy Markdown

🔵 The pipeline #1947 is running. Please wait a moment... (Link)

@mindspore-ai-bot

Copy link
Copy Markdown
Project Name Build_Stage Build Result Details
Hyper-parallel_Github_Gate - ❌ FAILURE 1947

@shawny999
shawny999 force-pushed the codegen_family_minimal_adaptation branch 2 times, most recently from ef95933 to 521383c Compare November 21, 2026 17:17
@shawny999

Copy link
Copy Markdown
Contributor Author

/retest

@mindspore-ai-bot

Copy link
Copy Markdown

🔵 The pipeline #1948 is running. Please wait a moment... (Link)

@mindspore-ai-bot

Copy link
Copy Markdown
Project Name Build_Stage Build Result Details
Hyper-parallel_Github_Gate - ❌ FAILURE 1948

@shawny999

Copy link
Copy Markdown
Contributor Author

/retest

@mindspore-ai-bot

Copy link
Copy Markdown

🔵 The pipeline #1950 is running. Please wait a moment... (Link)

@mindspore-ai-bot

Copy link
Copy Markdown
Project Name Build_Stage Build Result Details
Hyper-parallel_Github_Gate - ❌ FAILURE 1950
Check_Pylint FAILURE 1950

@mindspore-ai-bot

Copy link
Copy Markdown

@shawny999, your gate pipeline failed at the code check stage. You can configure some code check tools locally following the (pre-push quick guide), to enable automatic checking when you push your code every time. Tools included are: Check_CMakelint, Check_Codespell, Check_Cpplint, Check_Lizard, Check_Pylint, Check_ClangFormat, Check_ShellCheck.

@mindspore-ai-bot

Copy link
Copy Markdown
Project Name Build_Stage Build Result Details
Hyper-parallel_Github_Gate - ❌ FAILURE 2089
Smoke_Ascend910b_Torch ❌ FAILURE Error_Logs

@shawny999

Copy link
Copy Markdown
Contributor Author

/retest

@mindspore-ai-bot

Copy link
Copy Markdown

🔵 The pipeline #2094 is running. Please wait a moment... (Link)

@mindspore-ai-bot

Copy link
Copy Markdown
Project Name Build_Stage Build Result Details(Full/Incremental) Detail
Coverage Line Coverage ❌ FAILURE 21%/13% Link

@mindspore-ai-bot

Copy link
Copy Markdown
Project Name Build_Stage Build Result Details
Hyper-parallel_Github_Gate - ❌ FAILURE 2094
Smoke_Ascend910b_Torch ❌ FAILURE Error_Logs

suteng
suteng previously approved these changes Nov 24, 2026
@shawny999

Copy link
Copy Markdown
Contributor Author

/retest

@mindspore-ai-bot

Copy link
Copy Markdown

🔵 The pipeline #2100 is running. Please wait a moment... (Link)

@mindspore-ai-bot

Copy link
Copy Markdown
Project Name Build_Stage Build Result Details(Full/Incremental) Detail
Coverage Line Coverage ❌ FAILURE 79%/91% Link

@mindspore-ai-bot

Copy link
Copy Markdown
Platform Type Module Excution Time Time Limit
- distributed_data 367.045s 450.0s
- activation_memory 366.646s 375.0s
- shard 172.279s 300.0s
- accuracy 80.073s 120.0s
- pipeline_parallel 568.862s 675.0s
- auto_models 93.623s 150.0s
- optimizer 245.411s 300.0s
- fully_shard 318.612s 600.0s
- context_parallel 72.075s 240.0s
- init_weights 77.208s 118.75s
- swap_optimizer 307.814s 300.0s
- llama3_examples 73.958s 120.0s
- process_group 84.442s 90.0s
- clip_grad 90.136s 120.0s
- dtensor 66.948s 120.0s
- expert_parallel 166.08612s 200.0s
- tensor_parallel 215.029s 300.0s
- distributed_checkpoint 79.475s 120.0s
- multicore 3.69563s 120.0s

@mindspore-ai-bot

Copy link
Copy Markdown
Project Name Build_Stage Build Result Details
Hyper-parallel_Github_Gate - ❌ FAILURE 2100
UT_TEST FAILURE 2100

@shawny999

Copy link
Copy Markdown
Contributor Author

/retest

@mindspore-ai-bot

Copy link
Copy Markdown

🔵 The pipeline #2123 is running. Please wait a moment... (Link)

@shawny999

Copy link
Copy Markdown
Contributor Author

/retest

@mindspore-ai-bot

Copy link
Copy Markdown

🔵 The pipeline #2133 is running. Please wait a moment... (Link)

@mindspore-ai-bot

Copy link
Copy Markdown
Project Name Build_Stage Build Result Details(Full/Incremental) Detail
Coverage Line Coverage ❌ FAILURE 79%/91% Link

@mindspore-ai-bot

Copy link
Copy Markdown
Platform Type Module Excution Time Time Limit
- distributed_data 354.829s 450.0s
- activation_memory 423.712s 375.0s
- fully_shard 442.386s 600.0s
- optimizer 329.134s 300.0s
- pipeline_parallel 800.446s 675.0s
- shard 219.332s 300.0s
- clip_grad 124.843s 120.0s
- accuracy 129.862s 120.0s
- swap_optimizer 372.122s 300.0s
- distributed_checkpoint 99.112s 120.0s
- tensor_parallel 287.23s 300.0s
- expert_parallel 298.77788s 200.0s
- process_group 103.949s 90.0s
- llama3_examples 89.141s 120.0s
- context_parallel 83.907s 240.0s
- auto_models 110.205s 150.0s
- dtensor 89.113s 120.0s
- init_weights 94.025s 118.75s
- multicore 3.42837s 120.0s

@mindspore-ai-bot

Copy link
Copy Markdown
Project Name Build_Stage Build Result Details
Hyper-parallel_Github_Gate - ❌ FAILURE 2123
Smoke_CPU_X86_CentOS_Level0 FAILURE 2133

@shawny999

Copy link
Copy Markdown
Contributor Author

/retest

@mindspore-ai-bot

Copy link
Copy Markdown

🔵 The pipeline #2137 is running. Please wait a moment... (Link)

@mindspore-ai-bot

Copy link
Copy Markdown
Project Name Build_Stage Build Result Details(Full/Incremental) Detail
Coverage Line Coverage ❌ FAILURE 21%/13% Link

@mindspore-ai-bot

Copy link
Copy Markdown
Platform Type Module Excution Time Time Limit
- distributed_data 367.094s 450.0s
- activation_memory 389.555s 375.0s
- auto_models 91.21s 150.0s
- shard 175.511s 300.0s
- optimizer 237.663s 300.0s
- pipeline_parallel 561.128s 675.0s
- swap_optimizer 306.68s 300.0s
- accuracy 89.692s 120.0s
- clip_grad 89.925s 120.0s
- distributed_checkpoint 73.762s 120.0s
- fully_shard 319.318s 600.0s
- process_group 79.31s 90.0s
- tensor_parallel 217.236s 300.0s
- context_parallel 72.88s 240.0s
- expert_parallel 244.85537s 200.0s
- init_weights 70.72s 118.75s
- dtensor 81.019s 120.0s
- llama3_examples 74.62s 120.0s

@mindspore-ai-bot

Copy link
Copy Markdown
Project Name Build_Stage Build Result Details
Hyper-parallel_Github_Gate - ❌ FAILURE 2133
UT_TEST FAILURE 2137

@mindspore-ai-bot

Copy link
Copy Markdown
Project Name Build_Stage Build Result Details(Full/Incremental) Detail
Coverage Line Coverage ❌ FAILURE 21%/13% Link

@mindspore-ai-bot

Copy link
Copy Markdown
Platform Type Module Excution Time Time Limit
- distributed_data 344.313s 450.0s
- activation_memory 311.182s 375.0s
- auto_models 84.678s 150.0s
- shard 133.981s 300.0s
- pipeline_parallel 466.324s 675.0s
- optimizer 206.823s 300.0s
- swap_optimizer 246.556s 300.0s
- fully_shard 251.399s 600.0s
- distributed_checkpoint 63.898s 120.0s
- accuracy 69.336s 120.0s
- tensor_parallel 181.185s 300.0s
- expert_parallel 206.83187s 200.0s
- context_parallel 60.745s 240.0s
- init_weights 61.962s 118.75s
- dtensor 56.277s 120.0s
- clip_grad 65.379s 120.0s
- process_group 50.698s 90.0s
- llama3_examples 49.906s 120.0s

@mindspore-ai-bot

Copy link
Copy Markdown
Project Name Build_Stage Build Result Details
Hyper-parallel_Github_Gate - ❌ FAILURE 2137
UT_TEST FAILURE 2137

@shawny999

Copy link
Copy Markdown
Contributor Author

/retest

@mindspore-ai-bot

Copy link
Copy Markdown

🔵 The pipeline #2144 is running. Please wait a moment... (Link)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants