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 32f9214b8f89a120607b91e2a29777a94e253c54:

  • 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:

  • 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

🔵 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)

@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 2144
UT_TEST FAILURE 2144

@shawny999

Copy link
Copy Markdown
Contributor Author

/retest

1 similar comment
@shawny999

Copy link
Copy Markdown
Contributor Author

/retest

@mindspore-ai-bot

Copy link
Copy Markdown

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

@shawny999

Copy link
Copy Markdown
Contributor Author

/retest

@mindspore-ai-bot

Copy link
Copy Markdown

🔵 The pipeline #2160 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 372.466s 450.0s
- activation_memory 417.279s 375.0s
- pipeline_parallel 762.32s 675.0s
- shard 204.178s 300.0s
- clip_grad 124.889s 120.0s
- optimizer 365.373s 300.0s
- auto_models 109.261s 150.0s
- swap_optimizer 376.385s 300.0s
- accuracy 125.145s 120.0s
- tensor_parallel 267.932s 300.0s
- fully_shard 417.278s 600.0s
- llama3_examples 109.104s 120.0s
- expert_parallel 287.58037s 200.0s
- process_group 104.23s 90.0s
- distributed_checkpoint 109.564s 120.0s
- dtensor 89.065s 120.0s
- init_weights 80.853s 118.75s
- context_parallel 85.542s 240.0s

@mindspore-ai-bot

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

@mindspore-ai-bot

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

@mindspore-ai-bot

Copy link
Copy Markdown
Platform Type Module Excution Time Time Limit
- distributed_data 399.337s 450.0s
- activation_memory 390.513s 375.0s
- shard 208.855s 300.0s
- optimizer 314.252s 300.0s
- clip_grad 96.02s 120.0s
- accuracy 121.274s 120.0s
- pipeline_parallel 708.55s 675.0s
- fully_shard 432.596s 600.0s
- auto_models 99.038s 150.0s
- tensor_parallel 279.168s 300.0s
- process_group 110.245s 90.0s
- expert_parallel 280.251s 200.0s
- llama3_examples 99.911s 120.0s
- swap_optimizer 410.029s 300.0s
- distributed_checkpoint 90.507s 120.0s
- context_parallel 105.433s 240.0s
- dtensor 100.33s 120.0s
- init_weights 90.593s 118.75s

@mindspore-ai-bot

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

@shawny999

Copy link
Copy Markdown
Contributor Author

/retest

@mindspore-ai-bot

Copy link
Copy Markdown

🔵 The pipeline #2164 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 2164
Smoke_Ascend910b_Torch ❌ FAILURE Error_Logs

@shawny999

Copy link
Copy Markdown
Contributor Author

/retest

@mindspore-ai-bot

Copy link
Copy Markdown

🔵 The pipeline #2165 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