Public report of hpcaitech/ColossalAI, published 25 October 2026. It has the same score, grades and number of findings as the full report. The details of security findings (where they are in the code, which known vulnerabilities and which passwords or keys were found) are left out, so nobody can use them against the project.
Public
Executive report Measured under the Code Assurance Index, an open standard for code quality, using its published scoring rules (rubric version 2026.10.5). Watchdog signed this survey and filed it in the standard's public register, where anyone can look it up by its survey ID. Check this survey → Signed and filed in the standard's public register, 25 October 2026, 07:43 UTC · Survey ID cd_4d3752326107422fb458dd3b2881c8a8

hpcaitech/ColossalAI

Measured 25 October 2026, 07:38 UTC, at code version 0ac6a92

No regression since the last survey

A regression is a drop of 0.5 points or more in the score, or of 2.5 or more out of 10 in a dimension, since the last survey.

CAI score 47out of 100 At risk Down 2 since the last survey

The score is built from these lenses. Each lens grades one area of the code, such as how easy it is to change or how well it is protected. The weakest lens counts most, so one weak area pulls the score down instead of being averaged away.

A large codebase: 213,413 lines of product code in 8 projects, tests not counted · Estimated rebuild effort: about 1.6 person-years · Weakest lens: Security and Compliance, 38

Findings by how serious they are

138 critical 2463 serious 677 minor

21 dimensions are left out of the score. For each one, Watchdog either couldn't measure it in this code, or found no evidence of the safeguard it looks for, such as a tested backup restore. They count neither for nor against the score, and Limitations lists each one with its reason.

This survey was produced by

Watchdog
Producer
Canine Development
Analyzer
Watchdog engine 1.0.0
Measured
25 October 2026, 07:38 UTC

A measurement, not a certificate. The Code Assurance Index records a number together with the evidence it was worked out from, so anyone can recalculate it, but it doesn't certify or guarantee the code. The standard was written by Canine Development, which also builds Watchdog. It is open to any tool that implements it, and today Watchdog is the only one that does.

A critical security finding is open, such as a library with a known critical vulnerability or a password or key found in the code. The score itself is unchanged, but its band shows At risk until the finding is fixed. See the Security and Compliance lens.

The score is deterministic, which means the same code always gets the same score. Watchdog works it out with tools that follow published rules, and an AI model never decides it, so anyone who applies the same rules to the same code gets the same number. How it is done is explained under Methodology ▸

61of 61 dimensions measured by tools.
3208of 3278 findings point to an exact file and line, so you can open each one in the code. The other 70 concern the repository as a whole, such as missing documentation.
61dimensions across 6 lenses, read from 213,413 lines of product code in 8 projects.
Chapters

Executive summary

hpcaitech/ColossalAI is rated At risk because critical security findings are open, most of them in the build pipeline. Its score is held back because nine of the dependencies have a known vulnerability and it has pipeline tools referenced by a changeable name. It scores 47 out of 100, which the At risk rating leaves unchanged. We judged it as a preview release, against a lower bar.

Security and Compliance, at 38, is the weakest lens and counts most in the score. The best first step for the work it takes is replacing the two packages under a banned licence, worth about 4 points. Checking access in every handler comes next, worth about 7 points. Raising Security and Compliance to 68 would lift the score to about 54.

Seventy-seven pipeline tools are referenced by a changeable name, so the build pipeline can be tampered with. Eighteen known security holes in the packages the code depends on can be used by attackers, and fourteen places in the code run text as code, which an attacker could use. Pinning each tool to an exact version, updating the vulnerable packages and replacing text run as code with direct calls would close these risks. The 13 pipeline steps that install packages without pinning their versions need the packages they install pinned to exact versions. The eight unsafe settings in infrastructure or container files need changing to safe values. The two packages under a licence on your banned list need replacing, or clearing with your legal team.

The product code is 213,413 lines, about €230,000 to rebuild.

A lens is capped at Adequate while one of its dimensions scores below 4 out of 10, however well the rest of the lens does. That way a serious problem in one place always shows in the lens's rating.

How the score is built: what each lens counts for The lenses don't count equally. The weakest lens counts most, the next weakest a little less, and so on, so a weak area pulls the score down instead of being averaged away. In the bar below, each part's width shows how much that lens counts and its colour shows its rating. Improving the widest part moves the score most, and as that lens improves, it counts for less, because another lens becomes the weakest.
Security and Compliance 38 · counts for 46%Production Readiness 43 · counts for 25%Code Health 56 · counts for 14%Maturity 59 · counts for 8%Architecture 95 · counts for 4%Performance 100 · counts for 2%

If Security and Compliance rose from 38 to 68, the lowest score rated Strong, the score would rise from 47 to about 54.

Code composition: what the lines of code are
Product code 82%Tests 18%
New since the last survey: 507 findings

These 507 critical or serious findings weren't in the previous survey, on 11 October 2026. The first 100 are listed here, and the findings file in the download package lists them all.

  • Cyclomatic Complexity · LlamaPipelineForwards.llama_model_forward (cyclomatic 61) colossalai/shardformer/modeling/_llama_tf5.py
  • Cyclomatic Complexity · LlamaPipelineForwards.llama_model_forward (cyclomatic 60) colossalai/shardformer/modeling/_llama_tf4.py
  • Cyclomatic Complexity · BertPipelineForwards.bert_model_forward (cyclomatic 56) colossalai/shardformer/modeling/_bert_tf4.py
  • Cyclomatic Complexity · Qwen2PipelineForwards.qwen2_model_forward (cyclomatic 51) colossalai/shardformer/modeling/_qwen2_tf4.py
  • Cyclomatic Complexity · Qwen3PipelineForwards.qwen3_model_forward (cyclomatic 51) colossalai/shardformer/modeling/_qwen3_tf4.py
  • Cyclomatic Complexity · BertPipelineForwards.bert_model_forward (cyclomatic 50) colossalai/shardformer/modeling/_bert_tf5.py
  • Cyclomatic Complexity · MixtralPipelineForwards.mixtral_model_forward (cyclomatic 46) colossalai/shardformer/modeling/_mixtral_tf4.py
  • Cyclomatic Complexity · WhisperPipelineForwards.whisper_decoder_forward (cyclomatic 44) colossalai/shardformer/modeling/_whisper_tf4.py
  • Cyclomatic Complexity · MixtralPipelineForwards.mixtral_model_forward (cyclomatic 39) colossalai/shardformer/modeling/_mixtral_tf5.py
  • Cyclomatic Complexity · _deepseek_v3_tf4.deepseek_v3_model_forward (cyclomatic 38) colossalai/shardformer/modeling/_deepseek_v3_tf4.py
  • Cyclomatic Complexity · Qwen2PipelineForwards.qwen2_model_forward (cyclomatic 37) colossalai/shardformer/modeling/_qwen2_tf5.py
  • Cyclomatic Complexity · Qwen3PipelineForwards.qwen3_model_forward (cyclomatic 37) colossalai/shardformer/modeling/_qwen3_tf5.py
  • Cyclomatic Complexity · DistGaloreAdamW.step (cyclomatic 27) colossalai/nn/optimizer/distributed_galore.py
  • Cyclomatic Complexity · _deepseek_v3_tf5.deepseek_v3_model_forward (cyclomatic 26) colossalai/shardformer/modeling/_deepseek_v3_tf5.py
  • Cyclomatic Complexity · WhisperPolicy.get_held_layers (cyclomatic 24) colossalai/shardformer/policies/_whisper_tf4.py
  • Cyclomatic Complexity · WhisperPolicy.get_held_layers (cyclomatic 24) colossalai/shardformer/policies/_whisper_tf5.py
  • Cyclomatic Complexity · LlamaPipelineForwards.llama_for_sequence_classification_forward (cyclomatic 23) colossalai/shardformer/modeling/_llama_tf4.py
  • Cyclomatic Complexity · LlamaPipelineForwards.llama_for_sequence_classification_forward (cyclomatic 23) colossalai/shardformer/modeling/_llama_tf5.py
  • Cyclomatic Complexity · Qwen2PipelineForwards.qwen2_for_sequence_classification_forward (cyclomatic 23) colossalai/shardformer/modeling/_qwen2_tf4.py
  • Cyclomatic Complexity · WhisperPipelineForwards.whisper_encoder_forward (cyclomatic 22) colossalai/shardformer/modeling/_whisper_tf4.py
  • Cyclomatic Complexity · WhisperPipelineForwards.whisper_model_forward (cyclomatic 22) colossalai/shardformer/modeling/_whisper_tf4.py
  • Cyclomatic Complexity · LlamaPolicy.module_policy (cyclomatic 22) colossalai/shardformer/policies/_llama_tf4.py
  • Cyclomatic Complexity · LlamaPolicy.module_policy (cyclomatic 21) colossalai/shardformer/policies/_llama_tf5.py
  • Cyclomatic Complexity · WhisperPipelineForwards.whisper_model_forward (cyclomatic 20) colossalai/shardformer/modeling/_whisper_tf5.py
  • Cyclomatic Complexity · MixtralPolicy.module_policy (cyclomatic 20) colossalai/shardformer/policies/_mixtral_tf5.py
  • Cyclomatic Complexity · WhisperPipelineForwards.whisper_encoder_forward (cyclomatic 19) colossalai/shardformer/modeling/_whisper_tf5.py
  • Cyclomatic Complexity · MixtralPolicy.module_policy (cyclomatic 19) colossalai/shardformer/policies/_mixtral_tf4.py
  • Cyclomatic Complexity · Qwen2Policy.module_policy (cyclomatic 19) colossalai/shardformer/policies/_qwen2_tf4.py
  • Cyclomatic Complexity · Qwen2Policy.module_policy (cyclomatic 19) colossalai/shardformer/policies/_qwen2_tf5.py
  • Cyclomatic Complexity · Qwen3Policy.module_policy (cyclomatic 19) colossalai/shardformer/policies/_qwen3_tf4.py
  • Cyclomatic Complexity · Qwen3Policy.module_policy (cyclomatic 19) colossalai/shardformer/policies/_qwen3_tf5.py
  • Cyclomatic Complexity · BlipPolicy.module_policy (cyclomatic 18) colossalai/shardformer/policies/blip2.py
  • Cyclomatic Complexity · MoECheckpointIO._model_sharder (cyclomatic 17) colossalai/checkpoint_io/moe_checkpoint.py
  • Cyclomatic Complexity · BertPipelineForwards.bert_for_sequence_classification_forward (cyclomatic 17) colossalai/shardformer/modeling/_bert_tf4.py
  • Cyclomatic Complexity · BertPipelineForwards.bert_for_sequence_classification_forward (cyclomatic 17) colossalai/shardformer/modeling/_bert_tf5.py
  • Cyclomatic Complexity · MixtralPipelineForwards.mixtral_for_causal_lm_forward (cyclomatic 17) colossalai/shardformer/modeling/_mixtral_tf5.py
  • Cyclomatic Complexity · MoECheckpointIO.gather_from_sharded_optimizer_state (cyclomatic 16) colossalai/checkpoint_io/moe_checkpoint.py
  • Cyclomatic Complexity · BertPolicy.module_policy (cyclomatic 16) colossalai/shardformer/policies/_bert_tf4.py
  • Cyclomatic Complexity · BertPolicy.module_policy (cyclomatic 16) colossalai/shardformer/policies/_bert_tf5.py
  • Cognitive Complexity · DistGaloreAdamW.step (cognitive 85) colossalai/nn/optimizer/distributed_galore.py
  • Cognitive Complexity · BertPipelineForwards.bert_model_forward (cognitive 84) colossalai/shardformer/modeling/_bert_tf4.py
  • Cognitive Complexity · LlamaPipelineForwards.llama_model_forward (cognitive 80) colossalai/shardformer/modeling/_llama_tf4.py
  • Cognitive Complexity · LlamaPipelineForwards.llama_model_forward (cognitive 78) colossalai/shardformer/modeling/_llama_tf5.py
  • Cognitive Complexity · WhisperPipelineForwards.whisper_decoder_forward (cognitive 77) colossalai/shardformer/modeling/_whisper_tf4.py
  • Cognitive Complexity · Qwen2PipelineForwards.qwen2_model_forward (cognitive 73) colossalai/shardformer/modeling/_qwen2_tf4.py
  • Cognitive Complexity · Qwen3PipelineForwards.qwen3_model_forward (cognitive 73) colossalai/shardformer/modeling/_qwen3_tf4.py
  • Cognitive Complexity · BertPipelineForwards.bert_model_forward (cognitive 70) colossalai/shardformer/modeling/_bert_tf5.py
  • Cognitive Complexity · MixtralPipelineForwards.mixtral_model_forward (cognitive 65) colossalai/shardformer/modeling/_mixtral_tf4.py
  • Cognitive Complexity · _deepseek_v3_tf4.deepseek_v3_model_forward (cognitive 52) colossalai/shardformer/modeling/_deepseek_v3_tf4.py
  • Cognitive Complexity · WhisperPolicy.get_held_layers (cognitive 50) colossalai/shardformer/policies/_whisper_tf4.py
  • Cognitive Complexity · WhisperPolicy.get_held_layers (cognitive 50) colossalai/shardformer/policies/_whisper_tf5.py
  • Cognitive Complexity · MixtralPipelineForwards.mixtral_model_forward (cognitive 49) colossalai/shardformer/modeling/_mixtral_tf5.py
  • Cognitive Complexity · Qwen2PipelineForwards.qwen2_model_forward (cognitive 49) colossalai/shardformer/modeling/_qwen2_tf5.py
  • Cognitive Complexity · Qwen3PipelineForwards.qwen3_model_forward (cognitive 49) colossalai/shardformer/modeling/_qwen3_tf5.py
  • Cognitive Complexity · WhisperPipelineForwards.whisper_encoder_forward (cognitive 41) colossalai/shardformer/modeling/_whisper_tf4.py
  • Cognitive Complexity · LlamaPipelineForwards.llama_for_sequence_classification_forward (cognitive 38) colossalai/shardformer/modeling/_llama_tf4.py
  • Cognitive Complexity · LlamaPipelineForwards.llama_for_sequence_classification_forward (cognitive 38) colossalai/shardformer/modeling/_llama_tf5.py
  • Cognitive Complexity · Qwen2PipelineForwards.qwen2_for_sequence_classification_forward (cognitive 38) colossalai/shardformer/modeling/_qwen2_tf4.py
  • Cognitive Complexity · _deepseek_v3_tf5.deepseek_v3_model_forward (cognitive 31) colossalai/shardformer/modeling/_deepseek_v3_tf5.py
  • Cognitive Complexity · MixtralPipelineForwards.mixtral_for_causal_lm_forward (cognitive 31) colossalai/shardformer/modeling/_mixtral_tf5.py
  • Cognitive Complexity · BertPipelineForwards.bert_for_sequence_classification_forward (cognitive 30) colossalai/shardformer/modeling/_bert_tf4.py
  • Cognitive Complexity · BertPipelineForwards.bert_for_sequence_classification_forward (cognitive 30) colossalai/shardformer/modeling/_bert_tf5.py
  • Cognitive Complexity · WhisperPipelineForwards.whisper_model_forward (cognitive 27) colossalai/shardformer/modeling/_whisper_tf4.py
  • Cognitive Complexity · WhisperPipelineForwards.whisper_model_forward (cognitive 27) colossalai/shardformer/modeling/_whisper_tf5.py
  • Cognitive Complexity · MixtralPipelineForwards.mixtral_for_causal_lm_forward (cognitive 25) colossalai/shardformer/modeling/_mixtral_tf4.py
  • Cognitive Complexity · hybrid_parallel_checkpoint_io._route_padded_parameter_aliases (cognitive 24) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py
  • Cognitive Complexity · LlamaPolicy.module_policy (cognitive 24) colossalai/shardformer/policies/_llama_tf4.py
  • Cognitive Complexity · verify_image.verify_lora_checkpoints (cognitive 24) docker/torch213/verify_image.py
  • Cognitive Complexity · WhisperPipelineForwards.whisper_encoder_forward (cognitive 23) colossalai/shardformer/modeling/_whisper_tf5.py
  • Cognitive Complexity · LlamaPolicy.module_policy (cognitive 22) colossalai/shardformer/policies/_llama_tf5.py
  • Cognitive Complexity · InterleavedSchedule.backward_step (cognitive 21) colossalai/pipeline/schedule/interleaved_pp.py
  • Cognitive Complexity · OneForwardOneBackwardSchedule.backward_step (cognitive 21) colossalai/pipeline/schedule/one_f_one_b.py
  • Cognitive Complexity · MixtralPolicy.module_policy (cognitive 21) colossalai/shardformer/policies/_mixtral_tf5.py
  • Cognitive Complexity · Qwen2Policy.module_policy (cognitive 21) colossalai/shardformer/policies/_qwen2_tf4.py
  • Cognitive Complexity · Qwen2Policy.module_policy (cognitive 21) colossalai/shardformer/policies/_qwen2_tf5.py
  • Cognitive Complexity · Qwen3Policy.module_policy (cognitive 21) colossalai/shardformer/policies/_qwen3_tf4.py
  • Cognitive Complexity · Qwen3Policy.module_policy (cognitive 21) colossalai/shardformer/policies/_qwen3_tf5.py
  • Cognitive Complexity · run_gpu_batch.find_idle (cognitive 20) .github/scripts/ci/run_gpu_batch.py
  • Cognitive Complexity · BertPipelineForwards.bert_for_multiple_choice_forward (cognitive 20) colossalai/shardformer/modeling/_bert_tf4.py
  • Cognitive Complexity · BertPipelineForwards.bert_for_multiple_choice_forward (cognitive 20) colossalai/shardformer/modeling/_bert_tf5.py
  • Cognitive Complexity · LlamaPipelineForwards.llama_for_causal_lm_forward (cognitive 20) colossalai/shardformer/modeling/_llama_tf4.py
  • Cognitive Complexity · LlamaPipelineForwards.llama_for_causal_lm_forward (cognitive 20) colossalai/shardformer/modeling/_llama_tf5.py
  • Cognitive Complexity · Qwen2PipelineForwards.qwen2_for_sequence_classification_forward (cognitive 20) colossalai/shardformer/modeling/_qwen2_tf5.py
  • Cognitive Complexity · Qwen3PipelineForwards.qwen3_for_sequence_classification_forward (cognitive 20) colossalai/shardformer/modeling/_qwen3_tf4.py
  • Cognitive Complexity · Qwen3PipelineForwards.qwen3_for_sequence_classification_forward (cognitive 20) colossalai/shardformer/modeling/_qwen3_tf5.py
  • Cognitive Complexity · MixtralPolicy.module_policy (cognitive 20) colossalai/shardformer/policies/_mixtral_tf4.py
  • Cognitive Complexity · BertPipelineForwards.bert_for_question_answering_forward (cognitive 19) colossalai/shardformer/modeling/_bert_tf4.py
  • Cognitive Complexity · BertPipelineForwards.bert_for_question_answering_forward (cognitive 19) colossalai/shardformer/modeling/_bert_tf5.py
  • Cognitive Complexity · ViTPolicy.module_policy (cognitive 18) colossalai/shardformer/policies/_vit_tf5.py
  • Cognitive Complexity · _mixtral_tf5._slice_fused_expert_param (cognitive 17) colossalai/shardformer/modeling/_mixtral_tf5.py
  • Cognitive Complexity · BertPolicy.module_policy (cognitive 17) colossalai/shardformer/policies/_bert_tf4.py
  • Cognitive Complexity · BertPolicy.module_policy (cognitive 17) colossalai/shardformer/policies/_bert_tf5.py
  • Cognitive Complexity · DeepseekV3Policy.get_held_layers (cognitive 17) colossalai/shardformer/policies/_deepseek_v3_tf4.py
  • Cognitive Complexity · DeepseekV3Policy.get_held_layers (cognitive 17) colossalai/shardformer/policies/_deepseek_v3_tf5.py
  • Cognitive Complexity · LlamaPolicy.get_held_layers (cognitive 17) colossalai/shardformer/policies/_llama_tf4.py
  • Cognitive Complexity · LlamaPolicy.get_held_layers (cognitive 17) colossalai/shardformer/policies/_llama_tf5.py
  • Cognitive Complexity · MixtralPolicy.get_held_layers (cognitive 17) colossalai/shardformer/policies/_mixtral_tf4.py
  • Cognitive Complexity · MixtralPolicy.get_held_layers (cognitive 17) colossalai/shardformer/policies/_mixtral_tf5.py
  • Cognitive Complexity · Qwen2Policy.get_held_layers (cognitive 17) colossalai/shardformer/policies/_qwen2_tf4.py
  • Cognitive Complexity · Qwen2Policy.get_held_layers (cognitive 17) colossalai/shardformer/policies/_qwen2_tf5.py

Watchdog compares every finding with the previous survey's. A finding that has only moved to another line in the same file counts as the same finding, so only new findings appear here. Advisory notes from the AI model are left out, because the model words them afresh in every survey.

Fixed since the last survey: 283 findings

These 283 critical or serious findings were in the previous survey, on 11 October 2026, and are gone from this one. The first 100 are listed here.

  • Cyclomatic Complexity · LlamaPipelineForwards.llama_model_forward (cyclomatic 60) colossalai/shardformer/modeling/llama.py
  • Cyclomatic Complexity · BertPipelineForwards.bert_model_forward (cyclomatic 56) colossalai/shardformer/modeling/bert.py
  • Cyclomatic Complexity · Qwen2PipelineForwards.qwen2_model_forward (cyclomatic 52) colossalai/shardformer/modeling/qwen2.py
  • Cyclomatic Complexity · Qwen3PipelineForwards.qwen3_model_forward (cyclomatic 52) colossalai/shardformer/modeling/qwen3.py
  • Cyclomatic Complexity · MixtralPipelineForwards.mixtral_model_forward (cyclomatic 46) colossalai/shardformer/modeling/mixtral.py
  • Cyclomatic Complexity · WhisperPipelineForwards.whisper_decoder_forward (cyclomatic 44) colossalai/shardformer/modeling/whisper.py
  • Cyclomatic Complexity · deepseek_v3.deepseek_v3_model_forward (cyclomatic 38) colossalai/shardformer/modeling/deepseek_v3.py
  • Cyclomatic Complexity · DistGaloreAwamW.step (cyclomatic 27) colossalai/nn/optimizer/distributed_galore.py
  • Cyclomatic Complexity · WhisperPolicy.get_held_layers (cyclomatic 24) colossalai/shardformer/policies/whisper.py
  • Cyclomatic Complexity · LlamaPipelineForwards.llama_for_sequence_classification_forward (cyclomatic 23) colossalai/shardformer/modeling/llama.py
  • Cyclomatic Complexity · Qwen2PipelineForwards.qwen2_for_sequence_classification_forward (cyclomatic 23) colossalai/shardformer/modeling/qwen2.py
  • Cyclomatic Complexity · WhisperPipelineForwards.whisper_encoder_forward (cyclomatic 22) colossalai/shardformer/modeling/whisper.py
  • Cyclomatic Complexity · WhisperPipelineForwards.whisper_model_forward (cyclomatic 22) colossalai/shardformer/modeling/whisper.py
  • Cyclomatic Complexity · LlamaPolicy.module_policy (cyclomatic 22) colossalai/shardformer/policies/llama.py
  • Cyclomatic Complexity · MixtralPolicy.module_policy (cyclomatic 19) colossalai/shardformer/policies/mixtral.py
  • Cyclomatic Complexity · Qwen2Policy.module_policy (cyclomatic 19) colossalai/shardformer/policies/qwen2.py
  • Cyclomatic Complexity · Qwen3Policy.module_policy (cyclomatic 19) colossalai/shardformer/policies/qwen3.py
  • Cyclomatic Complexity · HybridParallelZeroOptimizer._compute_grad_norm (cyclomatic 18) colossalai/booster/plugin/hybrid_parallel_plugin.py
  • Cyclomatic Complexity · BertPipelineForwards.bert_for_sequence_classification_forward (cyclomatic 17) colossalai/shardformer/modeling/bert.py
  • Cyclomatic Complexity · ZeroBubbleVPipeScheduler.backward_b_step (cyclomatic 16) colossalai/pipeline/schedule/zero_bubble_pp.py
  • Cyclomatic Complexity · BertPolicy.module_policy (cyclomatic 16) colossalai/shardformer/policies/bert.py
  • Cognitive Complexity · DistGaloreAwamW.step (cognitive 85) colossalai/nn/optimizer/distributed_galore.py
  • Cognitive Complexity · BertPipelineForwards.bert_model_forward (cognitive 84) colossalai/shardformer/modeling/bert.py
  • Cognitive Complexity · LlamaPipelineForwards.llama_model_forward (cognitive 80) colossalai/shardformer/modeling/llama.py
  • Cognitive Complexity · WhisperPipelineForwards.whisper_decoder_forward (cognitive 77) colossalai/shardformer/modeling/whisper.py
  • Cognitive Complexity · Qwen2PipelineForwards.qwen2_model_forward (cognitive 75) colossalai/shardformer/modeling/qwen2.py
  • Cognitive Complexity · Qwen3PipelineForwards.qwen3_model_forward (cognitive 75) colossalai/shardformer/modeling/qwen3.py
  • Cognitive Complexity · MixtralPipelineForwards.mixtral_model_forward (cognitive 65) colossalai/shardformer/modeling/mixtral.py
  • Cognitive Complexity · deepseek_v3.deepseek_v3_model_forward (cognitive 52) colossalai/shardformer/modeling/deepseek_v3.py
  • Cognitive Complexity · WhisperPolicy.get_held_layers (cognitive 50) colossalai/shardformer/policies/whisper.py
  • Cognitive Complexity · HybridParallelZeroOptimizer._compute_grad_norm (cognitive 43) colossalai/booster/plugin/hybrid_parallel_plugin.py
  • Cognitive Complexity · WhisperPipelineForwards.whisper_encoder_forward (cognitive 41) colossalai/shardformer/modeling/whisper.py
  • Cognitive Complexity · LlamaPipelineForwards.llama_for_sequence_classification_forward (cognitive 38) colossalai/shardformer/modeling/llama.py
  • Cognitive Complexity · Qwen2PipelineForwards.qwen2_for_sequence_classification_forward (cognitive 38) colossalai/shardformer/modeling/qwen2.py
  • Cognitive Complexity · BertPipelineForwards.bert_for_sequence_classification_forward (cognitive 30) colossalai/shardformer/modeling/bert.py
  • Cognitive Complexity · WhisperPipelineForwards.whisper_model_forward (cognitive 27) colossalai/shardformer/modeling/whisper.py
  • Cognitive Complexity · MixtralPipelineForwards.mixtral_for_causal_lm_forward (cognitive 25) colossalai/shardformer/modeling/mixtral.py
  • Cognitive Complexity · LlamaPolicy.module_policy (cognitive 24) colossalai/shardformer/policies/llama.py
  • Cognitive Complexity · Qwen2Policy.module_policy (cognitive 21) colossalai/shardformer/policies/qwen2.py
  • Cognitive Complexity · Qwen3Policy.module_policy (cognitive 21) colossalai/shardformer/policies/qwen3.py
  • Cognitive Complexity · BertPipelineForwards.bert_for_multiple_choice_forward (cognitive 20) colossalai/shardformer/modeling/bert.py
  • Cognitive Complexity · LlamaPipelineForwards.llama_for_causal_lm_forward (cognitive 20) colossalai/shardformer/modeling/llama.py
  • Cognitive Complexity · Qwen3PipelineForwards.qwen3_for_sequence_classification_forward (cognitive 20) colossalai/shardformer/modeling/qwen3.py
  • Cognitive Complexity · MixtralPolicy.module_policy (cognitive 20) colossalai/shardformer/policies/mixtral.py
  • Cognitive Complexity · BertPipelineForwards.bert_for_question_answering_forward (cognitive 19) colossalai/shardformer/modeling/bert.py
  • Cognitive Complexity · BertPolicy.module_policy (cognitive 17) colossalai/shardformer/policies/bert.py
  • Cognitive Complexity · DeepseekV3Policy.get_held_layers (cognitive 17) colossalai/shardformer/policies/deepseek_v3.py
  • Cognitive Complexity · LlamaPolicy.get_held_layers (cognitive 17) colossalai/shardformer/policies/llama.py
  • Cognitive Complexity · MixtralPolicy.get_held_layers (cognitive 17) colossalai/shardformer/policies/mixtral.py
  • Cognitive Complexity · Qwen2Policy.get_held_layers (cognitive 17) colossalai/shardformer/policies/qwen2.py
  • Cognitive Complexity · Qwen3Policy.get_held_layers (cognitive 17) colossalai/shardformer/policies/qwen3.py
  • Cognitive Complexity · LowLevelZeroOptimizer._compute_grad_norm (cognitive 17) colossalai/zero/low_level/low_level_optim.py
  • Cognitive Complexity · DistGaloreAwamW.setup_distributed (cognitive 16) colossalai/nn/optimizer/distributed_galore.py
  • Cognitive Complexity · Qwen2PipelineForwards.qwen2_for_causal_lm_forward (cognitive 16) colossalai/shardformer/modeling/qwen2.py
  • Cognitive Complexity · Qwen3PipelineForwards.qwen3_for_causal_lm_forward (cognitive 16) colossalai/shardformer/modeling/qwen3.py
  • God Classes · FileTooLong: modeling/mixtral.py colossalai/shardformer/modeling/mixtral.py
  • God Classes · FileTooLong: modeling/whisper.py colossalai/shardformer/modeling/whisper.py
  • God Classes · FileTooLong: policies/bert.py colossalai/shardformer/policies/bert.py
  • Code Duplication · Near-duplicate member family (8 members, 28 shared lines) colossalai/shardformer/modeling/bert.py
  • Code Duplication · Near-duplicate member family (7 members, 30 shared lines) colossalai/shardformer/modeling/bloom.py
  • Code Duplication · Near-duplicate member family (3 members, 25 shared lines) colossalai/shardformer/modeling/bert.py
  • Code Duplication · Near-duplicate member pair (76 shared lines) colossalai/shardformer/modeling/command.py
  • Code Duplication · Near-duplicate member pair (72 shared lines) colossalai/shardformer/modeling/deepseek.py
  • Code Duplication · Near-duplicate member pair (59 shared lines) colossalai/shardformer/policies/qwen2.py
  • Code Duplication · Near-duplicate member pair (50 shared lines) colossalai/shardformer/modeling/deepseek.py
  • Code Duplication · Members sharing a duplicated core (7 members, 50+ identical tokens) colossalai/booster/plugin/dp_plugin_base.py
  • Code Duplication · Members sharing a duplicated core (7 members, 50+ identical tokens) colossalai/shardformer/layer/_operation.py
  • Code Duplication · Members sharing a duplicated core (7 members, 50+ identical tokens) colossalai/shardformer/modeling/bloom.py
  • Code Duplication · Members sharing a duplicated core (6 members, 50+ identical tokens) colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py
  • Code Duplication · Members sharing a duplicated core (6 members, 50+ identical tokens) colossalai/legacy/moe/openmoe/model/openmoe_policy.py
  • Code Duplication · Members sharing a duplicated core (6 members, 50+ identical tokens) colossalai/shardformer/modeling/command.py
  • Code Duplication · Members sharing a duplicated core (6 members, 50+ identical tokens) colossalai/shardformer/policies/command.py
  • Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) colossalai/shardformer/policies/command.py
  • Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) colossalai/shardformer/policies/deepseek.py
  • Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) colossalai/shardformer/policies/gptj.py
  • Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py
  • Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) colossalai/legacy/moe/openmoe/model/modeling_openmoe.py
  • Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) colossalai/shardformer/modeling/llama.py
  • Code Duplication · Duplicated block (123 lines × 2) colossalai/shardformer/modeling/qwen2.py
  • Code Duplication · Duplicated block (91–93 lines × 2) colossalai/shardformer/modeling/qwen2.py
  • Code Duplication · Duplicated block (16–84 lines × 6) colossalai/shardformer/modeling/bloom.py
  • Code Duplication · Duplicated block (65 lines × 2) colossalai/shardformer/modeling/qwen2.py
  • Code Duplication · Duplicated block (38–51 lines × 2) colossalai/shardformer/policies/qwen2.py
  • Code Duplication · Duplicated block (45–49 lines × 2) colossalai/shardformer/modeling/qwen2.py
  • Code Duplication · Duplicated block (40–45 lines × 5) colossalai/shardformer/policies/deepseek.py
  • Code Duplication · Duplicated block (44 lines × 4) colossalai/shardformer/modeling/command.py
  • Code Duplication · Duplicated block (34–37 lines × 2) colossalai/shardformer/modeling/command.py
  • Code Duplication · Duplicated block (37 lines × 2) colossalai/shardformer/policies/deepseek.py
  • Code Duplication · Duplicated block (35–36 lines × 2) colossalai/shardformer/modeling/mixtral.py
  • Code Duplication · Duplicated block (36 lines × 2) colossalai/shardformer/modeling/qwen2.py
  • Code Duplication · Duplicated block (13–36 lines × 2) colossalai/shardformer/modeling/vit.py
  • Code Duplication · Duplicated block (32 lines × 5) colossalai/shardformer/modeling/command.py
  • Code Duplication · Duplicated block (31–32 lines × 2) colossalai/shardformer/modeling/bert.py
  • Code Duplication · Duplicated block (32 lines × 2) colossalai/shardformer/policies/t5.py
  • Code Duplication · Duplicated block (31 lines × 2) colossalai/shardformer/modeling/deepseek.py
  • Code Duplication · Duplicated block (28–29 lines × 5) colossalai/shardformer/policies/command.py
  • Code Duplication · Duplicated block (28–29 lines × 4) colossalai/shardformer/modeling/llama.py
  • Code Duplication · Duplicated block (27 lines × 2) colossalai/shardformer/modeling/t5.py
  • Code Duplication · Duplicated block (25–26 lines × 2) colossalai/shardformer/policies/bert.py
  • Code Duplication · Duplicated block (25 lines × 2) colossalai/shardformer/modeling/deepseek.py
Rebuild cost: about €230,000 · Estimate
Cost to rebuild€78,000 to €390,000, for 1,300 to 4,125 hours of work, about 1.6 person-years for 1 to 4 engineers
Difficulty of the problemStandard, judged from the kind of software and how it is built. Code that solves a harder problem, such as payments or medical bookings, costs more per line to write.
Quality factor×0.7 at a score of 47. Better code takes more work to write, so the factor is ×1.0 at a score of 70, lower below it and higher above it.
SizeLarge: 213,413 lines of product code

How the estimate is made: Watchdog prices the hours a team would need to write this code again, at €60 to €95 an hour. Declarations and boilerplate are priced at a fast rate and logic at a slower one, and the logic is then multiplied by the difficulty of the problem and by the quality factor. The estimate can be about 30% off either way, and it moves most with the hourly rate and the difficulty. For this code, every line is priced as straight logic, which keeps the estimate on the low side.

Top priorities

The three actions that raise the score most for the work they take. The full ranked list is in the Roadmap.

1
Resolve the 2 Banned license finding(s) in License Compliance.
Raises the score by about 4 points · Low effort · License Compliance
2
Enforce authorization at every handler — a guard on each route, or a global authentication guard/middleware with explicit public opt-outs, so protected-by-default is demonstrable.
Raises the score by about 7 points · Medium effort · Access Controls
3
Resolve the 1 No ADRs found finding(s) in ADR Quality.
Raises the score by about 3 points · Low effort · ADR Quality

Diagnosis: what the measurements show together

Each conclusion below combines several dimensions into one point that no single dimension shows, and lists the measurements it rests on.

Where the investment is most exposed · Value at risk
This code would cost about €230,000 to build again, about 1.6 person-years of work. Its weakest lens is Security and Compliance, at 38 (Weak). Security and Compliance is about how well the product is protected, and how it handles personal data. Because the weakest lens counts most in the score, work on Security and Compliance also moves the score most.
Based on: the rebuild estimate · the Security and Compliance grade · how much each lens counts
What to do: Start with the Security and Compliance actions in Top priorities.
If you do one thing first · First action
Resolve the 2 Banned license finding(s) in License Compliance. Of all the actions in this report, it raises the score most for the work it takes: about 4 points for low effort, because it clears the 2 License Compliance findings. The next survey will show the change in the score.
Based on: the ranked actions in Top priorities, by score gain and effort
What hard-to-read code costs each year · Cost
Four dimensions measure how easy the code is to work in: two measure how tangled its logic is, one how much of it is copied, and one how well each part sticks to a single job. In this codebase they average 6.5 out of 10. Code at that level is slower to change than clean code, and Watchdog estimates the extra work at 4% to 8% on every change. The history of the code shows how much it changes: about 47,009 lines over the last 90 days, which is about 190,648 lines a year. At that pace, the extra work comes to an estimated 17.5 to 104.8 engineer-days a year, and it grows as more code changes.
How this is estimated: The number of changed lines is measured from the history of the code. The rest rests on two assumptions of Watchdog's own: code scoring 8 out of 10 or more adds no extra work, and each point below 8 adds 2.5% to 5.6% to every change; and an engineer changes 150 to 400 lines in a day. The result is a range for planning, not a measurement.
Based on: Cyclomatic Complexity · Cognitive Complexity · Code Duplication · Cohesion (LCOM4) · the code's change history
What to do: Start with the files listed under Churn × Complexity Hotspots, which change often and are hard to read, because that is where the extra work is paid most often.

Architecture: which parts of the code depend on which

The code is divided into modules, groups of code that each handle one part of the product, and a module depends on another when it uses code from it. The table lists the modules both down the side and across the top, in an order where each module should only use modules listed above it. A number in a cell means the module on that row uses the module in that column, and it counts the pairs of building blocks (types) that connect them. The one thing to look for is a mark above the diagonal line. It means two or more modules use each other in a loop (a dependency cycle), so none of them can be changed, tested or released on its own.

1021 modules, with 719 dependencies between them. Every module uses only modules listed above it, so there are no loops.

The table shows the 40 modules with the most connections; 981 more are left out to keep it readable.

Which modules use which. The module on each row uses the module in each column, and the number counts the pairs of types that connect them. A cell above the diagonal is part of a loop.
uses →1 applications.ColossalChat.coati.experience_maker.base2 colossalai.auto_parallel.tensor_shard.sharding_strategy3 colossalai.autochunk.utils4 colossalai.booster.mixed_precision.mixed_precision_base5 colossalai.checkpoint_io.checkpoint_io_base6 colossalai.cluster.dist_coordinator7 colossalai.device.device_mesh8 colossalai.inference.config9 colossalai.interface.model10 colossalai.interface.optimizer11 colossalai.legacy.context.parallel_mode12 colossalai.legacy.context.process_group_initializer.process_group_initializer13 colossalai.legacy.engine.gradient_handler._base_gradient_handler14 colossalai.legacy.nn.layer.base_layer15 colossalai.legacy.tensor.process_group16 colossalai.logging.logger17 colossalai.pipeline.stage_manager18 colossalai.shardformer.layer.parallel_module19 colossalai.shardformer.shard.shard_config20 colossalai.zero.gemini.chunk.manager21 extensions.base_extension22 extensions.cuda_extension23 applications.ColossalEval.colossal_eval.dataset.base24 applications.ColossalEval.colossal_eval.models.huggingface25 colossalai.auto_parallel.tensor_shard.node_handler.node_handler26 colossalai.auto_parallel.tensor_shard.solver.strategies_constructor27 colossalai.booster.booster28 colossalai.booster.plugin.plugin_base29 colossalai.checkpoint_io.general_checkpoint_io30 colossalai.shardformer.policies.base_policy31 colossalai.tensor.sharding_spec32 applications.ColossalChat.coati.trainer.base33 colossalai.auto_parallel.tensor_shard.node_handler.strategy.strategy_generator34 colossalai.booster.plugin.dp_plugin_base35 colossalai.booster.plugin.hybrid_parallel_plugin36 colossalai.inference.core.base_engine37 applications.ColossalChat.coati.trainer.ppo38 colossalai.booster.plugin.gemini_plugin39 colossalai.booster.plugin.torch_ddp_plugin40 colossalai.booster.plugin.low_level_zero_plugin
1 applications.ColossalChat.coati.experience_maker.base
2 colossalai.auto_parallel.tensor_shard.sharding_strategy
3 colossalai.autochunk.utils
4 colossalai.booster.mixed_precision.mixed_precision_base
5 colossalai.checkpoint_io.checkpoint_io_base
6 colossalai.cluster.dist_coordinator
7 colossalai.device.device_mesh
8 colossalai.inference.config
9 colossalai.interface.model
10 colossalai.interface.optimizer
11 colossalai.legacy.context.parallel_mode
12 colossalai.legacy.context.process_group_initializer.process_group_initializer
13 colossalai.legacy.engine.gradient_handler._base_gradient_handler
14 colossalai.legacy.nn.layer.base_layer
15 colossalai.legacy.tensor.process_group
16 colossalai.logging.logger
17 colossalai.pipeline.stage_manager
18 colossalai.shardformer.layer.parallel_module
19 colossalai.shardformer.shard.shard_config
20 colossalai.zero.gemini.chunk.manager
21 extensions.base_extension
22 extensions.cuda_extension
23 applications.ColossalEval.colossal_eval.dataset.base1
24 applications.ColossalEval.colossal_eval.models.huggingface12
25 colossalai.auto_parallel.tensor_shard.node_handler.node_handler41
26 colossalai.auto_parallel.tensor_shard.solver.strategies_constructor1
27 colossalai.booster.booster1
28 colossalai.booster.plugin.plugin_base11
29 colossalai.checkpoint_io.general_checkpoint_io1
30 colossalai.shardformer.policies.base_policy1
31 colossalai.tensor.sharding_spec1
32 applications.ColossalChat.coati.trainer.base121
33 colossalai.auto_parallel.tensor_shard.node_handler.strategy.strategy_generator331
34 colossalai.booster.plugin.dp_plugin_base1
35 colossalai.booster.plugin.hybrid_parallel_plugin12212
36 colossalai.inference.core.base_engine111
37 applications.ColossalChat.coati.trainer.ppo1111
38 colossalai.booster.plugin.gemini_plugin1111
39 colossalai.booster.plugin.torch_ddp_plugin12211
40 colossalai.booster.plugin.low_level_zero_plugin13211
Uses a module listed above itPart of a loopThe module itself
1 applications.ColossalChat.coati.experience_maker.base2 colossalai.auto_parallel.tensor_shard.sharding_strategy3 colossalai.autochunk.utils4 colossalai.booster.mixed_precision.mixed_precision_base5 colossalai.checkpoint_io.checkpoint_io_base6 colossalai.cluster.dist_coordinator7 colossalai.device.device_mesh8 colossalai.inference.config9 colossalai.interface.model10 colossalai.interface.optimizer11 colossalai.legacy.context.parallel_mode12 colossalai.legacy.context.process_group_initializer.process_group_initializer13 colossalai.legacy.engine.gradient_handler._base_gradient_handler14 colossalai.legacy.nn.layer.base_layer15 colossalai.legacy.tensor.process_group16 colossalai.logging.logger17 colossalai.pipeline.stage_manager18 colossalai.shardformer.layer.parallel_module19 colossalai.shardformer.shard.shard_config20 colossalai.zero.gemini.chunk.manager21 extensions.base_extension22 extensions.cuda_extension23 applications.ColossalEval.colossal_eval.dataset.base24 applications.ColossalEval.colossal_eval.models.huggingface25 colossalai.auto_parallel.tensor_shard.node_handler.node_handler26 colossalai.auto_parallel.tensor_shard.solver.strategies_constructor27 colossalai.booster.booster28 colossalai.booster.plugin.plugin_base29 colossalai.checkpoint_io.general_checkpoint_io30 colossalai.shardformer.policies.base_policy31 colossalai.tensor.sharding_spec32 applications.ColossalChat.coati.trainer.base33 colossalai.auto_parallel.tensor_shard.node_handler.strategy.strategy_generator34 colossalai.booster.plugin.dp_plugin_base35 colossalai.booster.plugin.hybrid_parallel_plugin36 colossalai.inference.core.base_engine37 applications.ColossalChat.coati.trainer.ppo38 colossalai.booster.plugin.gemini_plugin39 colossalai.booster.plugin.torch_ddp_plugin40 colossalai.booster.plugin.low_level_zero_pluginapplications.ColossalChat.coati.experience_maker.base1colossalai.auto_parallel.tensor_shard.sharding_strategy2colossalai.autochunk.utils3colossalai.booster.mixed_precision.mixed_precision_base4colossalai.checkpoint_io.checkpoint_io_base5colossalai.cluster.dist_coordinator6colossalai.device.device_mesh7colossalai.inference.config8colossalai.interface.model9colossalai.interface.optimizer10colossalai.legacy.context.parallel_mode11colossalai.legacy.context.process_group_initializer.process_group_initializer12colossalai.legacy.engine.gradient_handler._base_gradient_handler13colossalai.legacy.nn.layer.base_layer14colossalai.legacy.tensor.process_group15colossalai.logging.logger16colossalai.pipeline.stage_manager17colossalai.shardformer.layer.parallel_module18colossalai.shardformer.shard.shard_config19colossalai.zero.gemini.chunk.manager20extensions.base_extension21extensions.cuda_extension22applications.ColossalEval.colossal_eval.dataset.base23applications.ColossalEval.colossal_eval.models.huggingface24colossalai.auto_parallel.tensor_shard.node_handler.node_handler25colossalai.auto_parallel.tensor_shard.solver.strategies_constructor26colossalai.booster.booster27colossalai.booster.plugin.plugin_base28colossalai.checkpoint_io.general_checkpoint_io29colossalai.shardformer.policies.base_policy30colossalai.tensor.sharding_spec31applications.ColossalChat.coati.trainer.base32colossalai.auto_parallel.tensor_shard.node_handler.strategy.strategy_generator33colossalai.booster.plugin.dp_plugin_base34colossalai.booster.plugin.hybrid_parallel_plugin35colossalai.inference.core.base_engine36applications.ColossalChat.coati.trainer.ppo37colossalai.booster.plugin.gemini_plugin38colossalai.booster.plugin.torch_ddp_plugin39colossalai.booster.plugin.low_level_zero_plugin40112411111111121331112212111111111111221113211+981 more modules (most-connected shown)

At a glance — Code Health · 56% · Adequate · gated by D2, X4 ·

At a glance — Architecture · 95% · Exemplary ·

At a glance — Maturity · 59% · Adequate · gated by D34, M2 ·

At a glance — Readiness · 43% · Adequate · gated by P3, P7 ·

At a glance — Security · 38% · Weak · gated by D29, D30, D36, C2 ·

At a glance — Performance · 100% · Exemplary ·

Security & Compliance — OWASP Top-10 mapping

Findings mapped to OWASP categories; the specific CVEs/secrets are in the Security dimension cards below and findings.md (redacted only on the public version of this report).

OWASP categoryFindingsSeverity
A05:2025 — Injection126High / Critical
A03:2025 — Software Supply Chain Failures59High / Critical
A02:2025 — Security Misconfiguration22High / Critical
A07:2025 — Authentication Failures2High / Critical

Roadmap

First, enforce a protect-by-default authorization model by adding global authentication guards with explicit public opt-outs to ensure every route is secured. Next, resolve the two banned license findings and the missing architecture decision records to ensure full compliance and documentation. Then, integrate a static analysis security testing step into the CI pipeline to automatically block security regressions. Finally, address the eleven unscoped long-lived secrets in the GitHub workflows, starting with the build and compatibility test files, to secure the supply chain.

Ranked by impact ÷ effort. "Helps" is the estimated gain on the 0–100 health score.

Do thisHelpsEffortDimension
Resolve the 2 Banned license finding(s) in License Compliance.+4.0 ptsLowLicense Compliance
Enforce authorization at every handler — a guard on each route, or a global authentication guard/middleware with explicit public opt-outs, so protected-by-default is demonstrable.+6.9 ptsMediumAccess Controls
Resolve the 1 No ADRs found finding(s) in ADR Quality.+3.0 ptsLowADR Quality
Resolve the 9 High CVE finding(s) in Dependency Vulnerabilities — start with REDACTED (8), REDACTED.+2.1 ptsLowDependency Vulnerabilities
Add a SAST step to CI running what this repository's stack ships: bandit, `semgrep --config=p/python`, or CodeQL's python pack — so a security regression fails the build instead of landing.+3.8 ptsMediumSecurity & performance tooling
Resolve the 8 Critical CVE finding(s) in Dependency Vulnerabilities — start with REDACTED (7), REDACTED.+1.8 ptsLowDependency Vulnerabilities
Resolve the 8 REDACTED finding(s) in Supply-chain Provenance & Signing — start with REDACTED, REDACTED, REDACTED.+1.8 ptsLowSupply-chain Provenance & Signing
Resolve the 1 REDACTED finding(s) in Secrets (history) — start with REDACTED.+1.3 ptsLowSecrets (history)

File quality

Per-file score 0–10 — a quality signature. Of 533 files carrying findings, judged against the Preview bar: 4% slop · 27% mixed · 69% near-clean.

FileScoreBandWorst signal
REDACTED0.4SlopDependency Vulnerabilities: Critical CVE: REDACTED
REDACTED0.6SlopIaC & Container Security: High IaC: REDACTED
REDACTED0.9SlopIaC & Container Security: High IaC: REDACTED
REDACTED1.0SlopStatic Analysis (SAST): High: REDACTED
REDACTED1.1SlopStatic Analysis (SAST): High: REDACTED
REDACTED1.4SlopStatic Analysis (SAST): High: REDACTED
REDACTED1.4SlopStatic Analysis (SAST): High: REDACTED
REDACTED2.0SlopStatic Analysis (SAST): High: REDACTED
REDACTED2.0SlopStatic Analysis (SAST): High: REDACTED
REDACTED2.0SlopDependency Vulnerabilities: Critical CVE: REDACTED
REDACTED2.3SlopStatic Analysis (SAST): High: REDACTED
REDACTED2.3SlopStatic Analysis (SAST): High: REDACTED
REDACTED2.5SlopStatic Analysis (SAST): High: REDACTED
REDACTED2.5SlopStatic Analysis (SAST): High: REDACTED
REDACTED2.5SlopStatic Analysis (SAST): High: REDACTED
REDACTED2.5SlopStatic Analysis (SAST): High: REDACTED
REDACTED2.7SlopStatic Analysis (SAST): High: REDACTED
REDACTED2.7SlopDependency Vulnerabilities: Critical CVE: REDACTED
REDACTED2.8SlopStatic Analysis (SAST): High: REDACTED
REDACTED3.0SlopStatic Analysis (SAST): High: REDACTED

How the grades work

Every finding carries one of four grades. Three say how serious it is. The fourth says this survey could not settle it — and it is a grade, not a gap.

Critical — 138

A definite problem that already costs you something and drags the score down: a missing authorisation check, a dependency with a known exploit, a build that does not reproduce. Failure here tends to cause failures elsewhere.

Serious — 2463

Likely wrong, but not failing yet. It degrades the codebase over a longer horizon and can cause failures elsewhere — not urgent this week, not something to carry for two years either.

Minor — 677

Recorded, with no effect on how the codebase functions. Present so the survey is complete, not because it needs doing.

Could not be resolved — 21

Something this survey could not settle from the outside, and which could be critical or serious. Either a control was required and no positive evidence of it exists in the repository — a backup job that nothing shows was ever restored from proves nothing about restores — or our own analysis could not run over that part of the tree. This is not a clean result. These are excluded from the score rather than awarded a pass, so the number on the cover neither rewards nor penalises them: if you act on this survey without resolving them, you carry that risk yourself. Each one is named under Limitations.

Methodology & how to trust this report

Watchdog is a deep, periodic assessment — run each sprint, monthly, or quarterly, taking the time to go wider and deeper than a quick check and surfacing in one coherent report what you'd otherwise piece together from a dozen separate tools. It scores deterministically: the same commit yields the same score, every run. 61 of 61 evaluated dimensions are computed purely by tools and static analysis (confidence 1.0); none rely on LLM judgement. Overall confidence is 0.9 — the weighted average across measured dimensions; it falls as more of the score leans on LLM-assisted judgement and rises when it's fully tool-backed.

Every figure here is one of three kinds, and we label which: ✓ Measured — a deterministic fact (LoC, complexity, coverage); ~ Modeled — an estimate from a stated model (cost, effort, value-at-risk), always a range with its assumptions, never a precise fact; ◐ Advisory — an LLM prose judgement. We never present a modelled estimate as if it were measured. Perfect or absent scores carry their provenance too (ADR-0011): ✓ Tool-verified means the property itself was measured across the surface; ○ Nothing flagged means the probes came back clean — a claim bounded by what a repository can show; ⊘ Not evidenced means a working control (a tested restore, an automated rollback) showed no positive evidence — absence of evidence is not evidence of a control, so it's excluded from the score rather than awarded a spurious 10; ◐ Sampled · advisory marks an LLM verdict over a bounded sample — advisory, never a deterministic measurement.

What we checked — 61 dimensions across the health lenses
D1D2D3D4D5D6D9D11D12D13D14D15D16D17D19D20D26D28D29D30D31D34D35D36D43D44AX10AX2AX3AX4C2M1M2M3M4P1P10P2P3P4P6P7PF3X1X12X13X14X15X17X19X21X22X23X24X25X26X27X28X3X30X4

Each chip is a dimension scored from real signals across architecture, testing, dependencies, security & compliance, documentation, git-history and code quality — in one coherent pass. A surface report typically covers a handful.

How to trust any code-health report — three questions
  1. Can you open the finding? Real findings cite a repo-relative file and line you can open at the cited line — never an absolute scratch path. Here, 3208 of 3278 do; the remainder are repo-wide signals — a dimension-level measurement, not a single line. (Every path in this report is repo-relative by construction: paths are normalized at the producer and the report is rejected if any rooted path leaks through.)
  2. Is there a tool behind the number? Every score below names the method that produced it — Roslyn, git, a scanner, or (for a handful of documentation/naming dimensions) an LLM labelled sampled · advisory — not a narrative.
  3. Does re-running give the same result? Run it again on the same commit and the score — and this report, byte for byte — is identical. A report whose numbers move between runs is describing the run, not the code.

This report answers yes to all three. That's the bar to hold any assessment to.

Tools & methods

The actual versions used this run (captured at analysis time) — re-run on the same commit for the identical score.

MethodBacksVersionEvaluator
Roslyn static analysisComplexity, cohesion, coupling, dead code, API surface, layering5.3.0✓ deterministic
Native secret scannerHardcoded secrets / credentials1.0.0✓ deterministic
Watchdog duplication detector (in-process)Code duplication1.0.0✓ deterministic
Coverage (coverlet / dotnet-coverage)Line & branch coverage10.0.400✓ deterministic
NuGet / dotnetOutdated, vulnerable & deprecated dependencies10.0.400✓ deterministic
git / LibGit2SharpChurn hotspots, knowledge concentration, history2.43.0 · 0.31.0✓ deterministic
gitleaks · semgrep · trivy · checkovSecrets in history, SAST, CVEs, IaC & container, PII / GDPR1.86.0 · 0.69.3 · 3.2.533✓ deterministic
LLM (sampled · advisory)Documentation quality, ADR conformance, naming — sampled over a bounded sample; advisory, never a deterministic measurement—◐ LLM · sampled · advisory

Every finding is locatable in findings.md. Run 01a171ff-2c03-7b02-82be-001cd4030dbf.

The exact command behind every deep-scan dimension — tool, version, invocation and retained raw output — is in Appendix B — Reproduction & audit trail.

Run transparency — what happened this run

What ran differently this time — a tool absent, degraded, or that fell back to an estimate. Named openly, not folded silently into the scores. A degraded run also records its exact cause in diagnostics.md.

  • D8 Code Coverage — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Coverage NOT MEASURED: test source is present (.py) but the built-in coverage collector has no runner for this repository's ecosystem — so this suite was never executed by it. Not scored — this is a gap in the analyzer's language coverage, not a defect in the repo. To have real coverage read, produce a coverage report in a standard format (`coverage run -m pytest` then `coverage xml`) and commit it — a hosted scan measures a clone of the repository, so a report that exists only in a working tree, a CI runner's or your own, never reaches it; the artefact is commonly gitignored, so `git add -f` that one file (or un-ignore its path) and commit it alongside the code it measures. You can widen what we reach: optional: produce a coverage report in a standard format (`coverage run -m pytest` then `coverage xml`) and commit it — a hosted scan measures a clone of the repository, so a report that exists only in a working tree, a CI runner's or your own, never reaches it; the artefact is commonly gitignored, so `git add -f` that one file (or un-ignore its path) and commit it alongside the code it measures — then the real number is read on the next scan.
  • D19 Documentation Quality — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. Each ecosystem's manifests (what makes a folder runnable or a published package) need their own proof before D19 judges its units. Until then those folders' READMEs are judged only as documents (boilerplate, structure), never counted as complete.
  • D19 Documentation Quality — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. This kind did not reach the 95 % precision gate in three adjudicated runs (docs/plans/deterministic-engine/adjudication/D19-sample3-v3.md), so by the pre-registered fallback it publishes no row until a re-measurement shows it does. The candidates are counted here, not reported as findings, and the score does not include them.
  • D21 Naming Consistency — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. D21's deterministic naming rules are gated on C# first (docs/plans/deterministic-engine.md, P5): each other language is switched on only after its own concept suite and A/B gate pass. Until then its declarations carry no naming verdict this run — this says nothing about whether its names are consistent.
  • D22 Internal API Consistency — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. D22 identifies the intentionally-exposed surface from `IsPackable` and `.Contracts` project names, MSBuild conventions read off the loaded project set. This target exposed no such projects, so the probe never ran; this says nothing about whether the repository has a public API. This repository commits no C#/VB source at all, so there was never an MSBuild project set to read these conventions off. That is OUR side and it is a COLLECTOR gap, not an environment fault: it declares a published package (applications/ColossalQA/setup.py), but no published-package marker D22 reads admitted any project here, so this ecosystem's public API has no collector, and the remedy is to write one — no change to the scan image can close it.
  • D24 Comment Value — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check's reader does not cover the language this repository's product is written in, so it had nothing of the product to read. That is a gap in this analyzer's language reach — not a finding about this repository.
  • D27 Navigability — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Navigability is taken over call sites whose callee resolved. For C# that population includes calls into referenced assemblies; for this language only calls declared inside the repository count, so the abstention threshold reads the repository's use of its standard library as a resolution failure. That is a limit of this analyzer, not a build problem in this repository.
  • D31 IaC & Container Security — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. Docker/torch213/Dockerfile.dockerignore carries no `FROM` instruction, so it declares no build stage and every REDACTED rule this engine owns — the runtime-hardening, key-material, mutable-clone, no-op-shim, build-context, trust-anchor, install-guard, setuid and world-writable-path rules — is outside its own premise there and returned nothing. That silence is deliberate and correct: with no base image there is no image to reason about. It is reported here because it is NOT the same fact as a clean file, and coverage is stated as 4 of 5 Infrastructure-as-Code manifest(s) fully judged rather than as 100%. The vendor scanners (trivy, checkov) do read these files and their findings above stand; only this engine's own stage-keyed rules are absent. No owner action: a build file with no FROM is a legitimate include fragment.
  • AX1 Captive dependencies — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads Microsoft.Extensions.DependencyInjection registrations in C# and Spring beans in Java/Kotlin only, and this repository defines its own container in colossalai/fx/tracer/registry.py, whose lifetimes are not modelled yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • AX6 Interface segregation — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is computed over the public interfaces this run's compilations declare, and none was loaded, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • AXR1 Runtime accessibility — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Render strategy: boot via REDACTED (REDACTED.dockerignore). docker build failed (exit 1) — #1 DONE 0.0s REDACTED.dockerignore:3 -------------------- 1 | # Only dependency build inputs belong in this context. In particular, do not 2 | # copy the checkout, prebuilt extensions, personal environments or credentials. 3 | >>> ** 4 | !docker/ 5 | !docker/torch213/ -------------------- ERROR: failed to solve: dockerfile parse error on line 3: unknown instruction: **; runtime evidence skipped.
  • C1 Data Protection — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These personal data controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks personal data controls.
  • C3 Audit Trail — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. 'sqlalchemy' is imported (applications/ColossalQA/colossalqa/utils.py:5), but no entity, schema, table or model declaration this check reads was found beside it, so whether personal data is stored could not be decided.
  • C4 Data Retention — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. 'sqlalchemy' is imported (applications/ColossalQA/colossalqa/utils.py:5), but no entity, schema, table or model declaration this check reads was found beside it, so whether personal data is stored could not be decided.
  • C5 Data-Subject Rights — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. 'sqlalchemy' is imported (applications/ColossalQA/colossalqa/utils.py:5), but no entity, schema, table or model declaration this check reads was found beside it, so whether personal data is stored could not be decided.
  • GD1 Unfinished & placeholder code — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, F#, JavaScript/TypeScript, Dart, Ruby and Scala source only, and no C#, F#, JavaScript/TypeScript, Dart, Ruby or Scala was found, and this repository's Python, c, cpp is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • IC1 Incompleteness & stubs — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, JavaScript/TypeScript, Java, Dart, Ruby and Scala source only, and no C#, JavaScript/TypeScript, Java, Dart, Ruby or Scala was found, and this repository's Python, c, cpp is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • M4 Documentation accuracy — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. M4 checks only the claim kinds adjudicated at or above 95 % precision: links and versions (PREREGISTRATION version 9). Paths, command arguments, installs, environment variables, settings, projects, packages, routes, cd targets, infrastructure products and removed modules are read but not checked, and none of them is reported or counted.
  • P8 Schema migrations — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. The schema may be created by a runner, a deploy script or a config file outside what this check reads, so an absence here is our blind spot rather than a missing migration strategy. The card abstains instead of scoring. You can widen what we reach: if the schema is created and evolved by a tool this check does not name, naming it lets us teach the detector to read it.
  • S1 Web-Security Posture — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These web-security controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks web-security controls.
  • X16 Unfloored truncation loop — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, and JavaScript/TypeScript, Java, PHP, Dart, Ruby, Scala and Kotlin source only, and no C# was loaded and no JavaScript/TypeScript, Java, PHP, Dart, Ruby, Scala or Kotlin was found in this repository, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X18 Disposal-pattern correctness — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, and JavaScript/TypeScript, Java, Kotlin, Dart, Ruby, Scala and PHP source only, and no C# was loaded and no JavaScript/TypeScript, Java, Kotlin, Dart, Ruby, Scala or PHP was found in this repository, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X29 Per-element action decided by a fixed element — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, and JavaScript/TypeScript, Java, Rust, Dart, Ruby, Scala and Kotlin source only, and no C# was loaded and no JavaScript/TypeScript, Java, Rust, Dart, Ruby, Scala or Kotlin was found in this repository, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X3 Exception handling — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. 10 further occurrence(s) are not listed individually; the score already reflects all 50.
  • X4 Structured logging — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. 13 further occurrence(s) are not listed individually; the score already reflects all 53.
  • X5 Nullable reference types — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax and MSBuild project configuration, TypeScript source and its tsconfig files, Java source and its package and module declarations, PHP source and its PHPStan and Psalm configuration, Dart source and its pubspec language version, Ruby source and its Sorbet and Steep configuration, Scala source and its build's explicit-nulls, WartRemover and Scalafix settings, and Kotlin source only, and no C# was loaded, no TypeScript was found, and this repository's C, Cpp, Python is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.

Repo exclusion declarations (.gitattributes linguist-generated/vendored, .editorconfig generated_code): none declared — every source file was scored.

Limitations & what we did not check

Watchdog assesses the repository exactly as committed, and only the repository. By design it does not reach outside the source tree: the live cloud account, the running CI/CD pipeline, the host's branch-protection and approval rules, the production configuration, or a restore actually exercised against a backup are all out of scope. That boundary is a feature, not a gap — a repo-relative, deterministic scan re-runs identically on any commit and every finding opens at a real file and line, where a live audit can neither be reproduced nor traced. The visible consequence is that controls which leave no in-repo evidence are reported as "not evidenced" and excluded from the score rather than awarded a number a static scan cannot justify.

Per-dimension blind spots

For each dimension that was measured, what a static, repo-only scan structurally cannot see — the honest edge of the measurement, not a failure of it.

  • D1 Cyclomatic Complexity: Cyclomatic complexity counts branches statically — it cannot tell an essential decision tree from accidental tangle, nor see complexity that lives in data or configuration (large switch-case token tables, DSL lexers/parsers, data-as-code rule tables) rather than control flow: a tokenizer's many single-character cases read as high complexity though each branch is trivial.
  • D2 Cognitive Complexity: Cognitive-complexity heuristics approximate how hard code is to follow; genuine domain difficulty and well-named intent that eases reading are not captured.
  • D3 God Classes: "God class" is sized by members and responsibilities visible in the type — a deliberately broad facade over a coherent subsystem can read the same as an accidental grab-bag. For front-end JS the file-length check is cohesion-aware (a single-responsibility module — one class/IIFE — earns a 3× threshold), but cohesion is approximated from top-level declarations, not true dependency structure.
  • D4 Code Duplication: Duplication is token-similarity — an in-process token-stream comparison over sliding windows, with type-aware normalization — so it finds copy-paste, not semantic duplication expressed differently. Committed machine-written code (scaffolded migrations, designer/codegen output, protobuf/OpenAPI stubs, model snapshots) is EXCLUDED — its repetition is the tool's, not the team's — so the score reflects hand-written duplication only.
  • D5 Coupling: Coupling is measured between projects/assemblies — runtime coupling through DI, reflection, messaging or shared databases is invisible to a static reference graph.
  • D6 Cohesion (LCOM4): LCOM4 cohesion is syntactic — it infers connectivity from which methods touch which fields/methods by name, not from real runtime behaviour or intent.
  • D9 Test Distribution: The test-pyramid shape is inferred from project/folder naming and references, with a single test host bucketed per-file by its path tier and content signals — a suite that names tiers unconventionally and gives no per-file signal can still be mis-bucketed.
  • D11 Test Reliability: Flakiness is inferred from history/markers — Watchdog runs the suite once (for coverage), not the repeated runs under varied conditions that reveal nondeterminism, so a flaky test never recorded as failing is invisible here.
  • D12 Dependency Hygiene: Dependency health reads manifests and lockfiles — a vulnerability in a vendored/copied dependency, or risk from how a dependency is actually used, is outside this view.
  • D13 REDACTED Scanning: REDACTED detection is signature- and entropy-based on the current tree — a secret that does not match a known pattern, or one already rotated, will not be flagged (a clean scan is "nothing matched", not "no secrets exist").
  • D14 License Compliance: License compatibility is checked against declared package metadata and a policy — mislabelled or missing license metadata, and obligations that depend on how you distribute, are not resolved here.
  • D15 Churn × Complexity Hotspots: Churn hotspots come from git history — a freshly imported or squashed repository has no churn signal, and recent rewrites can mask a historically risky file.
  • D16 Bus Factor: Bus-factor is a time-decayed model of commit attribution (who has recently, repeatedly worked a file), not comprehension — pairing, review and reading-without-committing spread knowledge it can't see; bot commits and shared accounts still distort it.
  • D17 Explicit Debt: Acknowledged-debt signals (TODO/FIXME, suppressions, dead code) are textual — undocumented debt that nobody marked, and debt that lives in design rather than annotations, is invisible. Committed machine-written code (scaffolded migrations, designer/codegen output, generated stubs) is excluded — it is never the team's dead code to delete.
  • D19 Documentation Quality: Documentation quality publishes two things only: a runnable or packaged unit with no example, and a multi-project root README that maps none of its parts. It does not judge clarity, and its other checks (overview, licence, boilerplate, structure, empty sections, XML-doc coverage) are withheld after adjudication: their candidates are counted in the card's gaps, not shown as rows. A false statement in a document is M4's; units are .NET projects only.
  • D20 ADR Quality: ADR quality is an LLM read of the decision records present — it cannot know about decisions made and never recorded, and its verdict is sampled and advisory.
  • D26 Project Cohesion: Project focus is sized from members/namespaces per project — a project that is broad by deliberate design reads the same as one that has sprawled.
  • D28 Secrets (history): Secret-history scanning sweeps the git REDACTED for known patterns — a secret that predates the available history, or never matched a signature, is not found (clean means "nothing matched in the history we can see").
  • D29 Static Analysis (SAST): SAST findings are pattern-based (semgrep) — it finds classes of bug it has rules for; logic flaws, auth/authorization gaps and issues needing runtime context are out of reach (and clean means "no rule matched").
  • D30 Dependency Vulnerabilities: CVE matching depends on accurate package/version metadata and on the advisory databases — a vulnerability with no published advisory, or in code not declared as a dependency, is not seen. Coverage needs a RESOLVED graph: an unpinned REDACTED, or a pom without a resolved build, yields partial coverage rather than a clean verdict. An ecosystem the analyzer cannot scan is reported as unmeasured, never as clean.
  • D31 IaC & Container Security: IaC scanning checks Dockerfiles/Terraform/Kubernetes against best-practice rules — it cannot see the live cloud account, runtime configuration, or drift between the committed config and what is actually deployed.
  • D34 Knowledge Freshness: Freshness is decayed commit RECENCY, not comprehension — code read often but rarely committed reads as orphaned, and stable code that genuinely needs no changes is penalised the same as forgotten code; bot/squash commits distort it like the bus factor.
  • D35 Change Coupling: Change coupling is co-change in COMMITS — files split across separate commits, or coupled only through a shared config/build step, read as uncoupled, and a sweeping commit (rename/format) is excluded so it doesn't couple everything. It shows that files change together, not WHY: a high coupling can be a healthy cohesive pair as readily as a hidden leak.
  • D43 Malicious Dependencies: Only packages some vulnerability database has already NAMED as malicious are seen — a compromise published in the last hours, or never reported at all, is invisible here, and this dimension reading 10 is not evidence that a dependency is trustworthy. There is no typosquat or dependency-confusion analysis: a package nobody has reported is simply absent from the feeds. Coverage is the dependency scan's: an ecosystem that could not be scanned is disclosed as unmeasured, never as clean.
  • D44 Platform End-of-Life: The support table is FROZEN, so it goes out of date by losing RECALL: a release that ended support after the table was written is missed until the table is refreshed, and this dimension reading 10 is not evidence that a platform is current. Only platforms the repository DECLARES in a place this pass reads are seen — a runtime named only in a REDACTED (D31's subject), in a CI workflow (D29's), or in a file this pass does not parse (go.mod, a Gemfile ruby directive) is invisible here, which is why a repository declaring none of them abstains rather than scoring. Only frameworks with a PUBLISHED support policy are tracked: React, Flask and Express publish none, so their age cannot be judged and their absence from a report is not a statement that they are supported.
  • AX10 Code composition: Role is inferred from namespace/folder convention, not semantics — a domain concept living in a folder named "Services" reads as application, and the split is lines-of-code, not business value. The business-logic-share score is a SOFT, FLOORED signal: it contributes to the Architecture lens but is floored at the Critical gate, so an infrastructure-heavy design (a gateway, an ETL, a driver) is legitimately low without being nuked to zero.
  • M4 Documentation accuracy: Onboarding quality is an LLM read of the docs/setup present — it cannot run the onboarding or measure how long a real new joiner takes; the verdict is sampled and advisory.
  • P4 Deployment & Rollback: Approval/branch-protection rules live in repository settings the scan cannot see — only their in-repo evidence (config files, workflows) is checked, so a control enforced purely in the host's settings reads as "not evidenced".
  • P6 Release Hygiene: Rollback/observability controls are inferred from repo artefacts (pipelines, dashboards-as-code) — controls configured in external tooling, with no in-repo trace, cannot be credited.

Dimensions

D1 · Cyclomatic Complexity6.5 / 10Adequate✓ Tool-verified

What it measures: How tangled the control flow is — methods with many branches are hard to test and change.

Method: Cyclomatic complexity per method (1 + decision points), computed exhaustively across production source; test projects separated by convention. Deterministic.

Maturity: Documented → Verified → Prevented · effective 6.5 / 10 · rule-coverage 100% · ceiling Prevented

178 method(s) exceeded the cyclomatic complexity threshold of 15; the worst was LlamaPipelineForwards.llama_model_forward at 61.

p2p._communicate (cyclomatic 25) · ×2colossalai/legacy/communication/p2p.py:89
WhisperPolicy.get_held_layers (cyclomatic 24) · ×2colossalai/shardformer/policies/_whisper_tf4.py:593
LlamaPipelineForwards.llama_for_sequence_classification_forward (cyclomatic 23) · ×2colossalai/shardformer/modeling/_llama_tf4.py:377
Qwen2Policy.module_policy (cyclomatic 19) · ×2colossalai/shardformer/policies/_qwen2_tf4.py:55
Qwen3Policy.module_policy (cyclomatic 19) · ×2colossalai/shardformer/policies/_qwen3_tf4.py:55

+ 166 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Bring the 178 bodies over 15 down to 15 or less in Cyclomatic Complexity — start with LlamaPipelineForwards.llama_model_forward (cyclomatic 61), PipelineGraph.try_v_schedule (cyclomatic 60), LlamaPipelineForwards.llama_model_forward (cyclomatic 60). — This score is capped by its worst body, so a finding fixed alone moves it by almost nothing — the next one down takes its place. Refactoring these 178 together lifts Cyclomatic Complexity from 6.5 to about 10.0/10, projected with the scoring formula itself and assuming each lands exactly at 15.
  2. Enforce Cyclomatic Complexity in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d1_recommendation.md · top locations in Appendix A, every location in findings.md.

D2 · Cognitive Complexity2.7 / 10Weak✓ Tool-verified

What it measures: How hard the code is for a person to follow, beyond raw branching.

Method: Cognitive complexity per method (Sonar-style nesting-penalized score), computed exhaustively over production code, excluding test projects. Deterministic.

Maturity: Documented → Verified → Prevented · effective 2.7 / 10 · rule-coverage 100% · ceiling Prevented

409 method(s) exceeded the cognitive complexity threshold of 15; the worst was BaseProducer.loop at 125.

WhisperPolicy.get_held_layers (cognitive 50) · ×2colossalai/shardformer/policies/_whisper_tf4.py:593
LlamaPipelineForwards.llama_for_sequence_classification_forward (cognitive 38) · ×2colossalai/shardformer/modeling/_llama_tf4.py:377
BertPipelineForwards.bert_for_sequence_classification_forward (cognitive 30) · ×2colossalai/shardformer/modeling/_bert_tf4.py:659
ColoTracer._post_check (cognitive 29) · ×2colossalai/_analyzer/fx/tracer/tracer.py:306
train.main (cognitive 27) · ×2applications/ColossalMoE/train.py:142

+ 386 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Bring the 36 bodies over 60 down to 60 or less in Cognitive Complexity — start with BaseProducer.loop (cognitive 125), BaseProducer.loop (cognitive 122), PipelineGraph.try_v_schedule (cognitive 114). — This score is capped by its worst body, so a finding fixed alone moves it by almost nothing — the next one down takes its place. Refactoring these 36 together lifts Cognitive Complexity from 2.7 to about 4.6/10, projected with the scoring formula itself and assuming each lands exactly at 60; a cleaner split scores higher.
  2. Enforce Cognitive Complexity in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d2_recommendation.md · top locations in Appendix A, every location in findings.md.

D3 · God Classes9.2 / 10Stronggated by 37 serious findings✓ Tool-verified

What it measures: Over-large classes that try to do too much ("god classes").

Method: God-class detection by line and method-count thresholds per logical type (partial classes unified), filtered for generated code and registration/contract false positives. Deterministic.

Maturity: Documented → Verified → Prevented · effective 9.2 / 10 · rule-coverage 100% · ceiling Prevented

37 god class(es) detected.

FileTooLong: rpc/_pipeline_base.py · ×30colossalai/legacy/pipeline/rpc/_pipeline_base.py
TooManyMethods: WorkerBase · ×7colossalai/legacy/pipeline/rpc/_pipeline_base.py:96

What to do

  1. Resolve the 30 FileTooLong finding(s) in God Classes — start with _pipeline_base.py, modeling_chatglm.py, hybrid_parallel_checkpoint_io.py. — One of this dimension's main actionable groups (30 warning-level).
  2. Resolve the 7 TooManyMethods finding(s) in God Classes — start with _pipeline_base.py, trace_indice.py, low_level_optim.py. — One of this dimension's main actionable groups (7 warning-level).
  3. Enforce God Classes in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d3_recommendation.md · top locations in Appendix A, every location in findings.md.

D4 · Code Duplication7.0 / 10Strong✓ Tool-verified

What it measures: Copy-pasted code that should be shared instead.

Method: Code duplication via token-stream sliding windows with type-aware normalization (locals masked, type names preserved), density-scored per KLoC of production code. Deterministic.

Maturity: Documented → Verified → Prevented · effective 7.0 / 10 · rule-coverage 100% · ceiling Verified

1290 duplicated block group(s) detected. A further 114 rows report members as variants of one another; they aggregate block groups already counted above and are not themselves counted. 218 of the 1404 are in trees this repository does not ship — vendored, example/demo, project-template, fixture and benchmark code — and are ranked below the shipped groups rather than excluded from them: the duplication there is real and is still counted in this dimension's score. The dimensions that publish a production-file census leave those trees out of theirs, so this count is deliberately drawn over the wider population.

Duplicated block (5 lines × 2) · ×44applications/ColossalChat/coati/experience_maker/naive.py:167
Duplicated block (12 lines × 2) · ×42applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:28
Duplicated block (10 lines × 2) · ×41.github/scripts/ci/run_gpu_batch.py:64
Duplicated block (13 lines × 2) · ×35applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:109
Duplicated block (6 lines × 2) · ×35applications/ColossalChat/coati/distributed/grpo_consumer.py:157

+ 446 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Resolve the 44 Duplicated block (5 lines × 2) finding(s) in Code Duplication — start with gemini_plugin.py (2), convolution.py (2), pooling.py (2). — One of this dimension's main actionable groups (44 warning-level).
  2. Resolve the 42 Duplicated block (12 lines × 2) finding(s) in Code Duplication — start with _bert_tf4.py (4), pooling.py (3), distributed_adafactor.py (3). — One of this dimension's main actionable groups (42 warning-level).
  3. Resolve the 41 Duplicated block (10 lines × 2) finding(s) in Code Duplication — start with layers.py (4), _bert_tf4.py (2), _mixtral_tf4.py (2). — One of this dimension's main actionable groups (41 warning-level).
  4. Enforce Code Duplication in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.

Detailed fixes: d4_recommendation.md · top locations in Appendix A, every location in findings.md.

D5 · Coupling10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether volatile projects sit underneath others that depend on them (so their churn ripples upward), and whether project dependencies form cycles. A widely-depended-on but stable shared/kernel project is healthy, not penalised.

Method: Dependency cycles via elementary-DFS over real .csproj references, plus Martin instability (afferent/efferent) per project. Exhaustive over the reference graph, deterministic.

Coverage: Exhaustive · type-level: afferent/efferent coupling + cycles computed over every production type — the population is all types, not a name convention.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Prevented

6 production modules (Python), 0 dependency cycle(s), 0 unstable depended-on module(s). Read from the build's own module declarations; 0 module(s) off the main sequence.

✓ On the Gold path — maintain.

Detailed fixes: d5_recommendation.md.

D6 · Cohesion (LCOM4)9.9 / 10Stronggated by 4 serious findings✓ Tool-verified

What it measures: Whether a class's methods are focused on a single responsibility.

Method: LCOM4 cohesion per production class with at least two methods: connected components of methods sharing state or calls, computed syntactically. Deterministic, not a proxy.

Coverage: Exhaustive · type-level: LCOM4 cohesion computed over every production class — the population is all types, not a name convention.

Maturity: Documented → Verified → Prevented · effective 9.9 / 10 · rule-coverage 100% · ceiling Verified

4 of 479 classes have LCOM4 above 3.

Low cohesion: WorkerBase (LCOM4 9) · ×4colossalai/legacy/pipeline/rpc/_pipeline_base.py:96

What to do

  1. Resolve the 4 Low cohesion finding(s) in Cohesion (LCOM4) — start with _pipeline_base.py, hybrid_parallel_plugin.py, checkpoint_io_base.py. — One of this dimension's main actionable groups (4 warning-level).
  2. Enforce Cohesion (LCOM4) in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.

Detailed fixes: d6_recommendation.md · top locations in Appendix A, every location in findings.md.

D9 · Test Distribution10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether the test suite has a healthy mix of unit / integration / end-to-end tests.

Method: Test projects classified (Unit/Integration/BDD/E2E) from compiled metadata; test methods counted exhaustively across projects with placement-agnostic disk fallback. Deterministic.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

528 test methods: 510 unit, 18 integration, 0 BDD, 0 e2e. The Python suite contributes 528 test function(s) across 338 file(s) declaring at least one — every `def test…` in a file pytest or unittest would collect, which is those frameworks' own definition of a case; a parametrize table counts once, so this is a floor. Its tier split is read from file names and paths only.

✓ On the Gold path — maintain.

Detailed fixes: d9_recommendation.md.

D11 · Test Reliability10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether the tests pass reliably, with no flakiness.

Method: Suite re-run N times within tiered wall-clock budgets (unit to e2e); tests failing non-deterministically across runs flagged; guarded tests retried when #if guards detected.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Verified

0 flaky across 1 measured tier(s). Python (5 distributions): measured (0 flaky).

✓ On the Gold path — maintain.

Detailed fixes: d11_recommendation.md.

D12 · Dependency Hygiene8.0 6.2 / 10Adequate✓ Tool-verified

What it measures: Whether dependencies are current, secure, and not bloated.

Method: Manifest scan via dotnet list package across all projects; worst-signal-per-package deduction (saturating for vulnerabilities, capped-linear for deprecation/outdated) per KLoC. Exhaustive, deterministic.

Maturity: Documented → Verified → Prevented · effective 6.2 / 10 · rule-coverage 78% · ceiling Verified

49 outdated, 0 yanked pinned Python distributions. 78 of 100 shipped distributions were graded against pypi.org (0 not published there, 22 declared without an exact pin, which installs the newest release the declaration admits and so cannot be behind one). Only EXACT pins are graded for currency: a floor or a range already installs the newest release it admits, so reporting one would report this repository for being current. Whether a deliberate upper cap has itself gone stale is a different and weaker question, and is not asked. Whether any distribution is UNMAINTAINED is not graded — PyPI publishes no maintenance status, and release age does not stand in for one. Lockfiles are not read (poetry.lock, uv.lock, Pipfile.lock, pdm.lock), so a lock-resolved install is outside this verdict. Known CVEs in this dependency graph are D30's question.

Outdated: autoflake · ×49

What to do

  1. Enforce Dependency Hygiene in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.

Detailed fixes: d12_recommendation.md · top locations in Appendix A, every location in findings.md.

D13 · REDACTED Scanning10.0 / 10Exemplary○ Nothing flagged

What it measures: Whether any secrets (keys, tokens, passwords) have leaked into the code.

Method: In-process native secret scanner (entropy plus signature patterns) across all tracked files; no external tool. A clean result is a measured 10, not no-data zero. Deterministic.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Prevented

REDACTED scan ran and found no leaked secrets.

✓ On the Gold path — maintain.

Detailed fixes: d13_recommendation.md.

D14 · License Compliance6.0 / 10Adequate✓ Tool-verified

What it measures: Whether the licenses of third-party packages are compatible with your policy.

Method: Third-party package licenses resolved from declared package metadata and checked against the configured policy (allow/deny/copyleft). Deterministic; clean = no incompatible license found at metadata depth.

Maturity: Documented → Verified → Prevented · effective 6.0 / 10 · rule-coverage 100% · ceiling Verified

2 of 343 shipped Python distribution(s) use a banned license. Licences were resolved from PyPI over the distributions a consumer installs — this repository's 100 declared runtime requirement(s) closed transitively over each distribution's published `requires_dist` (243 reached that way). Requirements it states ONLY under an extra, a PEP 735 dependency group, a Poetry dev group or a dev-named requirements file are excluded: pip does not install any of them for a consumer. ★ This repository commits no dependency lockfile that this pass reads, so each licence is the one PyPI publishes for the distribution's CURRENT release rather than for a pinned version. 39 of them publish no licence on PyPI this pass can read; that is missing data, not a violation, and none of them is charged.

Banned license: contexttimer · ×2

What to do

  1. Resolve the 2 Banned license finding(s) in License Compliance. — One of this dimension's main actionable groups (2 issue-level).
  2. Enforce License Compliance in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.

Detailed fixes: d14_recommendation.md · top locations in Appendix A, every location in findings.md.

D15 · Churn × Complexity Hotspots9.9 / 10Stronggated by 3 serious findings✓ Tool-verified

What it measures: Files that change often and are also complex — the riskiest hotspots.

Method: Per production file churn times cyclomatic complexity over a rolling window, computed from git and Roslyn/JS/Razor analysis. Exhaustive, deterministic per commit date.

Maturity: Documented → Verified → Prevented · effective 9.9 / 10 · rule-coverage 100% · ceiling Documented

Top hotspots: colossalai/lazy/pretrained.py (3×50=150); colossalai/shardformer/policies/command.py (3×23=69); colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py (2×15=30)

Hotspot: colossalai/lazy/pretrained.py · ×3colossalai/lazy/pretrained.py:36

What to do

  1. Resolve the 3 Hotspot finding(s) in Churn × Complexity Hotspots — start with pretrained.py, command.py, hybrid_parallel_checkpoint_io.py. — One of this dimension's main actionable groups (3 warning-level).

Detailed fixes: d15_recommendation.md · top locations in Appendix A, every location in findings.md.

D16 · Bus Factor9.9 / 10Exemplary✓ Tool-verified

What it measures: Whether knowledge is concentrated in too few people (the "bus factor").

Method: Living knowledge per author via time-decayed commit attribution (6-month half-life, focus weighting) across largest source files. Deterministic, avoids blame's mechanical-refactor false positives.

Maturity: Documented → Verified → Prevented · effective 9.9 / 10 · rule-coverage 100% · ceiling Documented

5 source file(s) have their living knowledge concentrated in one author (≥90% of recent, decayed contribution). The largest is colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py. Counted over 599 of the 1024 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.

Off-boarding risk: anonymized user #1
Further sole-owners (lower concentration)

✓ On the Gold path — maintain.

Detailed fixes: d16_recommendation.md · top locations in Appendix A, every location in findings.md.

D17 · Explicit Debt9.7 / 10Stronggated by 307 serious findings✓ Tool-verified

What it measures: Acknowledged debt left in the code — TODOs, dead code, suppressed warnings.

Method: Roslyn syntactic debt markers (suppressions/TODO/FIXME/HACK/empty-catch/commented-code/Obsolete) plus SymbolFinder dead-code analysis; weighted-debt-per-KLoC density deducted 2.0x per unit. Deterministic, exhaustive.

Maturity: Documented → Verified → Prevented · effective 9.7 / 10 · rule-coverage 100% · ceiling Prevented

337 deducted task-comment markers across 213413 LoC (0.2/KLoC) → score 9.7. Task comments only: this repository's language is read without a compiler, so D17's suppression, dead-code and commented-out-code arms did not run and this score counts fewer marker kinds than a .NET repository's would.

TodoComment · ×273tests/test_shardformer/test_model/test_shard_chatglm2.py:116
FixmeComment · ×17tests/test_legacy/test_engine/test_engine.py:18
HackComment · ×15examples/tutorial/sequence_parallel/data/datasets/indexed_dataset.py:243
TodoComment repeated across 15 filescolossalai/shardformer/modeling/_bert_tf4.py:119
XxxCommentcolossalai/inference/modeling/models/glide_llama.py:322

What to do

  1. Resolve the 273 TodoComment finding(s) in Explicit Debt — start with _pipeline_base.py (9), batch_norm_generator.py (8), shard_utils.py (5). — One of this dimension's main actionable groups (273 warning-level).
  2. Resolve the 17 FixmeComment finding(s) in Explicit Debt — start with train.py (3), context_attn_unpad.py (3), test_engine.py. — One of this dimension's main actionable groups (17 warning-level).
  3. Resolve the 15 HackComment finding(s) in Explicit Debt — start with api.py (2), activation_checkpoint_codegen.py (2), indexed_dataset.py. — One of this dimension's main actionable groups (15 warning-level).
  4. Enforce Explicit Debt in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d17_recommendation.md · top locations in Appendix A, every location in findings.md.

D19 · Documentation Quality10.0 / 10Exemplary○ Nothing flagged

What it measures: Whether the project's documentation is clear, complete, and useful.

Method: Every README, docs/ document and root guide parsed by its markup and measured in Unicode letters. Published: a runnable or packaged .NET project whose README (or a document it links, or a root guide) shows no example, and a root README naming none of three or more projects. Overview, licence, boilerplate, wall-of-text, empty-section and XML-doc rows are measured and withheld (counted in gaps) after adjudication. Deterministic, exhaustive, advisory.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

1 of 1 documentation facets pass in full. 118 document(s) read across 1 unit(s).

✓ On the Gold path — maintain.

Detailed fixes: d19_recommendation.md.

D20 · ADR Quality0.0 / 10Critical✓ Tool-verified

What it measures: Whether architecture decisions are recorded well (context, decision, consequences).

Method: Per-ADR judgment by language model at low temperature with two-pass stability; confidence is share of ADRs evaluated; enforcement-field presence detected deterministically. Advisory.

Maturity: Documented → Verified → Prevented · effective 0.0 / 10 · rule-coverage 100% · ceiling Documented

No architecture decision records were found.

No ADRs found

What to do

  1. Resolve the 1 No ADRs found finding(s) in ADR Quality. — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d20_recommendation.md · top locations in Appendix A, every location in findings.md.

D26 · Project Cohesion5.0 / 10Adequate✓ Tool-verified

What it measures: Whether each project is a focused, coherent unit rather than an oversized grab-bag.

Method: Project size overshoot penalties (LoC / public-type count / namespace count, 2-of-3 flag) weighted by REDACTED magnitude. Exhaustive across projects, deterministic, LLM-independent.

Maturity: Documented → Verified → Prevented · effective 5.0 / 10 · rule-coverage 100% · ceiling Documented

2 of 8 build units (Python) flagged as possibly oversized/incoherent.

Projects may be oversized for their cohesion

What to do

  1. Resolve the 1 Projects may be oversized for their cohesion finding(s) in Project Cohesion. — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d26_recommendation.md · top locations in Appendix A, every location in findings.md.

D28 · Secrets (history)9.0 / 10Adequategated by 1 critical finding✓ Tool-verified

What it measures: Whether any secrets were ever committed — scanned across the full git history, not just now.

Method: REDACTED scan via TWO gitleaks detect passes in an isolated checkout — the full git history, then a second --no-git pass over the working tree as it stands — merged and de-duplicated by (rule, file, line); each match flagged High. Both invocations are recorded in the audit trail. Exhaustive; when the tool is absent, or when its output cannot be parsed into the expected shape, the dimension is WITHHELD as an explicit measurement gap on our side — unscored and excluded from the lens, never a hedged middling score.

Maturity: Documented → Verified → Prevented · effective 9.0 / 10 · rule-coverage 100% · ceiling Documented

1 finding(s): 0 critical, 1 high, 0 medium, 0 low. Remediation for historically-committed secrets is credential rotation — they remain in history regardless of later deletion.

REDACTED
REDACTED

What to do

  1. Resolve the 1 REDACTED finding(s) in Secrets (history) — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).
  2. Resolve the 1 Rotate the exposed credentials finding(s) in Secrets (history). — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d28_recommendation.md · top locations in Appendix A, every location in findings.md.

D29 · Static Analysis (SAST)0.0 / 10Critical✓ Tool-verified

What it measures: Real static-analysis (SAST) findings — likely security bugs in the code, any language.

Method: Polyglot static analysis via semgrep across the repo using the pinned, image-baked p/security-audit + p/owasp-top-ten rulesets (no scan-time registry fetch); severity rules (ERROR/WARNING/INFO) map to a full-band severity-weighted score. Exhaustive, deterministic; degrades on parse failure.

Coverage: semgrep pattern rules over all files — exhaustive for the rule set, blind to classes of bug without a rule (clean = no rule matched).

Maturity: Documented → Verified → Prevented · effective 0.0 / 10 · rule-coverage 100% · ceiling Documented

126 finding(s): 0 critical, 109 high, 13 medium, 4 low. 67 unpinned-GitHub-Actions row(s) are reported here but scored by D36 (supply-chain provenance), which measures that posture as `pinned_actions` — one pinning decision is charged once, not once per lens. semgrep hit a parse error in 11 file(s) — `applications/ColossalChat/examples/training_scripts/train_sft.sh` (line 61), `applications/ColossalEval/examples/gpt_evaluation/eval.sh` (line 10), `applications/ColossalMoE/infer.sh` (line 9), `applications/ColossalMoE/train.sh` (line 20), `REDACTED` (lines 4–11, lines 11–21, lines 21–34, …), … (+6 more) — so no absence of findings in the named regions is evidence of anything; rows reported elsewhere in those files are real. Fix the syntax error (or exclude the file deliberately) and re-scan to cover them. Separately, one or more rules could not re-parse an embedded snippet in 5 file(s) (e.g. a workflow `run:` block read as shell). Those files WERE scanned and their other rows are unaffected; only those rules' view of those snippets is missing.

REDACTED
REDACTED
REDACTED
REDACTED
REDACTED

+ 11 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Resolve the 13 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (2), REDACTED (2), REDACTED. — One of this dimension's main actionable groups (13 issue-level).
  2. Resolve the 13 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (4), REDACTED (3), REDACTED (2). — One of this dimension's main actionable groups (13 issue-level).
  3. No action in Static Analysis (SAST) — all 67 REDACTED finding(s) are reported here at file:line but scored by D36 (supply-chain provenance), so none is charged to this dimension. — One of this dimension's main actionable groups (67 issue-level, 0 of them charged here).

Detailed fixes: d29_recommendation.md · top locations in Appendix A, every location in findings.md.

D30 · Dependency Vulnerabilities0.0 / 10Critical✓ Tool-verified

What it measures: Whether any dependency has a known published vulnerability (CVE), direct or transitive, in ANY ecosystem the repository declares — Dart pub, Elixir and Erlang via Hex, Go modules, Java and Kotlin via Maven/Gradle, JavaScript/npm, .NET/NuGet, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift.

Method: Dependency-CVE scan across every ecosystem the repository declares, scored ONCE. Three sources are unioned and deduplicated by advisory identity (rule id + alias closure, CVE<->GHSA) scoped to package+version, keeping the worst severity: `osv-scanner --recursive` over osv.dev for Dart pub, Elixir/Hex (and Erlang, whose `rebar.lock` syft first converts to a CycloneDX SBOM the scanner reads, with rows attributed back to the lock), Go, Java and Kotlin via Maven/Gradle (and Scala, whose sbt build's pinned direct declarations are written into a CycloneDX SBOM the scanner reads, with rows attributed back to the build file), npm, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift; `trivy fs --scanners vuln` for npm lockfiles; and `dotnet list package --vulnerable --include-transitive` for NuGet (with per-advisory collapse of the project x target-framework fan-out), plus a DECLARED-dependency arm that resolves a published gem's gemspec against rubygems.org where no Gemfile.lock is committed. `SeverityScore(c,h,m,l, normalizer 8.0)`. NotApplicable only when NO ecosystem is readable; if any applicable ecosystem could not be scanned the findings are REPORTED and the score is withheld. Supersedes the npm and OSV arms, retired 2026-09-05.

Maturity: Documented → Verified → Prevented · effective 0.0 / 10 · rule-coverage 100% · ceiling Documented

29 finding(s): 9 critical, 9 high, 10 medium, 1 low.

REDACTED
REDACTED
REDACTED
REDACTED
REDACTED

What to do

  1. Resolve the 9 High CVE finding(s) in Dependency Vulnerabilities — start with REDACTED (8), REDACTED. — One of this dimension's main actionable groups (9 issue-level).
  2. Resolve the 8 Critical CVE finding(s) in Dependency Vulnerabilities — start with REDACTED (7), REDACTED. — One of this dimension's main actionable groups (8 issue-level).
  3. Resolve the 1 Critical vulnerability finding(s) in Dependency Vulnerabilities — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).

Detailed fixes: d30_recommendation.md · top locations in Appendix A, every location in findings.md.

D31 · IaC & Container Security5.9 4.7 / 10Weak✓ Tool-verified

What it measures: Whether Dockerfiles / Terraform / Kubernetes config follow security best practices.

Method: IaC/container misconfiguration scan via trivy config (REDACTED/Terraform/K8s/Helm/CloudFormation); severity rules to 0-10 moderate normalizer. NotApplicable without manifests. Exhaustive, deterministic.

Maturity: Documented → Verified → Prevented · effective 4.7 / 10 · rule-coverage 80% · ceiling Documented

22 finding(s): 0 critical, 8 high, 14 medium, 0 low.

REDACTED
REDACTED

What to do

  1. Resolve the 14 Medium IaC finding(s) in IaC & Container Security — start with REDACTED (14). — One of this dimension's main actionable groups (14 warning-level).
  2. Resolve the 8 High IaC finding(s) in IaC & Container Security — start with REDACTED (8). — One of this dimension's main actionable groups (8 issue-level).

Detailed fixes: d31_recommendation.md · top locations in Appendix A, every location in findings.md.

D34 · Knowledge Freshness1.0 / 10Critical✓ Tool-verified

What it measures: Whether anyone still has living knowledge of each file, or it has been orphaned — last understood long ago by someone now gone quiet. The sibling of the bus factor: D16 asks who owns it, D34 asks whether anyone still knows it.

Method: File orphaning as total living-knowledge decay below one focused-commit's worth within a year, computed per-file from the D16 decay model. Exhaustive, deterministic over fixed history.

Maturity: Documented → Verified → Prevented · effective 1.0 / 10 · rule-coverage 100% · ceiling Documented

541 of 599 significant source file(s) are orphaned — their living knowledge has decayed to nothing, so no one currently understands them. The largest is colossalai/legacy/pipeline/rpc/_pipeline_base.py. Counted over 599 of the 1024 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.

Orphaned file · ×538colossalai/shardformer/layer/qkv_fused_linear.py:1
Most significant orphaned file · ×3colossalai/legacy/pipeline/rpc/_pipeline_base.py:1
Concentrated knowledge decay

What to do

  1. Resolve the 538 Orphaned file finding(s) in Knowledge Freshness — start with utils.py (25), layers.py (7), _utils.py (7). — One of this dimension's main actionable groups (538 recommendation-level).
  2. Resolve the 3 Most significant orphaned file finding(s) in Knowledge Freshness — start with _pipeline_base.py, hybrid_parallel_checkpoint_io.py, attn.py. — One of this dimension's main actionable groups (3 recommendation-level).
  3. Resolve the 1 Concentrated knowledge decay finding(s) in Knowledge Freshness. — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d34_recommendation.md · top locations in Appendix A, every location in findings.md.

D35 · Change Coupling9.9 / 10Stronggated by 6 serious findings✓ Tool-verified

What it measures: Whether files that change together actually belong together — pairs that repeatedly co-change in git history despite having no explicit code dependency, surfacing the hidden/logical coupling (and boundaries in the wrong place) a static scan can't see.

Method: Pairwise co-occurrence over the per-commit file sets in git history (production source only — tests and generated dropped): Degree-of-Coupling = shared ÷ min individual revisions, reported above noise floors (each file ≥10 revisions, ≥5 shared commits, ≥50% strength); sweeping commits excluded. Deterministic over fixed history.

Coverage: Population: PRODUCTION source files only — test and generated files are dropped before pairing, so a class co-changing with its own test (trivially ~100%) can't drown the real production↔production coupling. Pairs ranked by Degree-of-Coupling. A non-source file is never a coupling PARTICIPANT either: documentation, schemas, config and data files are dropped with the rest, so a code↔docs pair — a command and the reference page that restates it — is not reported however strongly the two co-change; nor is coupling that runs THROUGH a build step or config file.

Maturity: Documented → Verified → Prevented · effective 9.9 / 10 · rule-coverage 100% · ceiling Documented

Strongest change-coupling: context_attn_unpad.py↔flash_decoding.py 80%; deepseek.py↔mixtral.py 60%; bert.py↔bloom.py 59%

Change coupling: context_attn_unpad.py ↔ flash_decoding.py · ×5colossalai/kernel/triton/context_attn_unpad.py:1
Change-coupling hub: mixtral.py → _operation.py, deepseek.py, deepseek.py, mixtral.pycolossalai/shardformer/modeling/mixtral.py

What to do

  1. Resolve the 5 Change coupling finding(s) in Change Coupling — start with context_attn_unpad.py, deepseek.py, bert.py. — One of this dimension's main actionable groups (5 warning-level).
  2. Resolve the 1 Change-coupling hub finding(s) in Change Coupling — start with mixtral.py. — One of this dimension's main actionable groups (1 warning-level).

Detailed fixes: d35_recommendation.md · top locations in Appendix A, every location in findings.md.

D36 · Supply-chain Provenance & Signing0.0 / 10Critical✓ Tool-verified

What it measures: Whether the build pipeline provides supply-chain integrity — generated provenance/attestation, signed artifacts (cosign/sigstore), an SBOM, and pinned build actions. Presence of the configuration, not a runtime guarantee.

Method: Supply-chain provenance/signing read deterministically from CI/build config (.github/workflows, .gitlab-ci.yml, azure-pipelines, Jenkinsfile, .circleci) + the release surface: four signals — generated provenance/attestation (SLSA/in-toto/actions-attest), artifact signing (cosign/sigstore/gitsign), an SBOM (syft/sbom-action/*.spdx.json/*.cdx.json), and SHA-pinned build actions — scored 10·present/denom. NotApplicable without a build pipeline. Detects configuration presence, not runtime enforcement.

Maturity: Documented → Verified → Prevented · effective 0.0 / 10 · rule-coverage 100% · ceiling Documented

0/4 supply-chain integrity signals present (provenance, signing, SBOM, pinned actions).

REDACTED
REDACTED
REDACTED
REDACTED
REDACTED

+ 7 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Resolve the 11 REDACTED finding(s) in Supply-chain Provenance & Signing — start with REDACTED, REDACTED, REDACTED. — One of this dimension's main actionable groups (11 warning-level).
  2. Resolve the 8 REDACTED finding(s) in Supply-chain Provenance & Signing — start with REDACTED, REDACTED, REDACTED. — One of this dimension's main actionable groups (8 warning-level).
  3. Resolve the 2 REDACTED finding(s) in Supply-chain Provenance & Signing — start with REDACTED, REDACTED. — One of this dimension's main actionable groups (2 warning-level).

Detailed fixes: d36_recommendation.md · top locations in Appendix A, every location in findings.md.

D43 · Malicious Dependencies10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether any dependency the repository declares is published as MALICIOUS rather than merely vulnerable — a package that is an attacker's work, in any ecosystem osv-scanner reads. Scored apart from D30 because the answer is binary: there is no safe version to upgrade to, and the fix is to remove the package and rotate every credential it could have read.

Method: The same dependency scan D30 reads, partitioned on the scanner's own classification rather than rescanned: a row is MALICIOUS when its id is in the `MAL-` space (the ossf/malicious-packages feed) OR its `database_specific.cwe_ids` carries `CWE-506` ("Embedded Malicious Code"). Both channels are structural; the summary text is deliberately NOT read, because a malicious-package record whose summary says only "Critical severity vulnerability" is a real shape ([GHSA redacted]) and a text matcher misses it. Scored BINARY: any surviving row is 0, whatever its severity and however many CVEs sit beside it — a hostile dependency is not a quantity. Applicability and degradation are D30's: NotApplicable only when no ecosystem is readable, and an unscannable ecosystem degrades rather than reading clean. SCORED, not informational.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

No dependency in any ecosystem this repository declares is published as malicious.

✓ On the Gold path — maintain.

Detailed fixes: d43_recommendation.md.

D44 · Platform End-of-Life10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether anyone still ships security patches for the platform this repository RUNS ON — the runtime it pins and the framework majors its own constraints hold it to. Separate from D12 because the question differs: a current Django on an end-of-life Python is perfectly up to date and completely unsupported, and the fix is a migration rather than a version bump. What the repository says it merely SUPPORTS is never charged.

Method: End-of-life PLATFORM read from the repository's own declarations and graded against a FROZEN, dated table of vendor support dates — no network, no feed, no API, so this dimension answers identically inside a closed scan fence. Two subjects: a RUNTIME the project pins (a single or all-end-of-life TargetFramework, a .nvmrc or .python-version, a requires-python CAP) and a FRAMEWORK major a dependency constraint cannot move off (a caret, tilde or exact version; `vue@^2.7.16` pins Vue 2). A FLOOR is deliberately never charged — `requires-python = ">=3.8"` states what a package SUPPORTS, not what it runs on — and a multi-target project is charged only when EVERY target is out of support. Runtime 4.0/product capped 8.0, framework 1.5 capped 4.5. The table is safe to freeze because a statement about support that ended in the past cannot become false: it loses recall as it ages, never precision, and a test asserts every entry predates the freeze date. Disjoint from D31 (a container image's OS layer) and D29 (the toolchain a CI workflow installs). Abstains when the repository declares no platform this pass reads — never scores it clean.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

0 end-of-life runtime(s) and 0 end-of-life framework(s), read from 0 platform declaration(s) and 100 dependency declaration(s). This dimension reads what the repository says about ITSELF — a pinned target framework, a version file, a capped requires-python, a Rust toolchain pin, a framework major a constraint cannot move off. A FLOOR is deliberately never charged: `requires-python = ">=3.8"` states what the package SUPPORTS, not what it runs on, and a well-maintained library declares exactly that while running its own CI on a current release. The end-of-life facts are FROZEN and dated, so this dimension needs no network and answers identically inside a closed scan fence; as the table ages it loses recall and never precision, because a statement about support that ended in the past cannot become false. The OS layer of a container image is D31's question and the toolchain a CI workflow installs is D29's; this row is neither.

✓ On the Gold path — maintain.

Detailed fixes: d44_recommendation.md.

Frontend & cross-cutting dimensions

R = React/JS · M = Maturity · P = Readiness.

AX10 · Code composition9.7 / 10Exemplary✓ Tool-verified

Other · Architecture — How the codebase splits by code ROLE — domain, application, infrastructure, test, generated. The significance map behind the knowledge/coupling weighting, and a DDD signal in its own right: a thin domain core under fat infrastructure is the anemic-domain smell, quantified. How each file's role is decided, because the split is only as good as that: a generated name or a build-output tree makes it Generated, a test project makes it Test, and otherwise the file's NAMESPACE and PATH words are matched against fixed vocabularies in a fixed ORDER — domain, then infrastructure, then application — so a file whose words hit two layers is counted under the earlier one. A production file matching none of them counts as application, so that share reads 'application or unclassified' rather than a measured application layer. Roles come from naming convention, never from what the code does. On this repository the split was taken from the source tree on disk rather than from a loaded .NET workspace, so a file's role is decided by its PATH segments alone — no declared namespace was available to add to the evidence — and generated output is excluded from the census entirely rather than counted as a generated share.

Method: Roslyn line-count by code ROLE: every source file classified Domain/Application/Infrastructure/Test/Generated by namespace + path convention (the shared CodeRoleClassifier), then significant lines summed per role. Deterministic; the advisory score is the business-logic (domain+application) share of production code.

Coverage: Population: ALL source files, each bucketed into ONE of five roles (Domain/Application/Infrastructure/Test/Generated) by namespace + path convention — a file whose layer isn't named in the convention falls to Application (the neutral default), and the split is line-count, not semantic depth or business value.

What to do

  • The domain core is a small share of production code, but most of the rest matched no layer vocabulary at all — so this is not yet an anemic-domain finding. The namespace/path convention could not place that code, which makes the composition above a statement about the naming, not about the design. Name the layers (or check that the repository's conventions differ from the ones this check knows) before reading a thin domain into it.
AX2 · Stateful singletons10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether singleton services avoid mutable shared instance state that concurrent callers would race on.

Method: Roslyn scan: singleton field mutations unguarded by lock or Interlocked, per type; syntax-based guard detection. Deterministic, traceable per field.

AX3 · Project dependency cycles10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether the project-reference graph is acyclic (cycles block independent build/deploy and signal eroding boundaries).

Method: Project reference cycles via elementary-DFS over real .csproj references, using the engine shared with D5/D7; cyclic versus acyclic. Exhaustive, deterministic.

AX4 · Dependency direction10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether dependencies point inward (Domain ← Application ← Infrastructure/Web) — the clean-architecture dependency rule, checked across the project graph.

Method: Layer violations by name-segment inference (Domain/Core to Application to Infrastructure/Web) over the project-reference graph. Exhaustive over all projects, deterministic.

C2 · Access Controls3.0 / 10Weak✓ Tool-verified

Other · Security — Whether access is authorized by default — a framework authorization attribute/decorator or policy, or imperative guard methods (throw-on-violation) called from handlers.

Method: Roslyn scan: [Authorize] usage and authorization policies, plus imperative throw-on-violation guard methods detected via syntax. Deterministic.

  • Authorization rules exist but no route guard, auth middleware or handler that refuses a caller was found.

What to do

  • Enforce authorization at every handler — a guard on each route, or a global authentication guard/middleware with explicit public opt-outs, so protected-by-default is demonstrable.
M1 · Documentation (README)7.3 / 10Strong✓ Tool-verified

Maturity · Maturity — Whether the repo and its projects have a README, and whether it's substantive and current.

Method: Filesystem scan: README presence, word count, and headings for depth; git history for staleness. Exhaustive across root and project dirs, deterministic.

What to do

  • Add an 'Architecture' / 'How it works' section to the root README — the high-level shape.
M2 · Architecture documentation2.0 / 10Weak✓ Tool-verified

Maturity · Maturity — Whether key decisions (ADRs) and the high-level shape (C4/diagrams) are written down.

Method: Filesystem scan: ADR folder/naming conventions or content, plus Mermaid/PlantUML/C4/architecture.md discovery. Exhaustive, deterministic.

  • No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.

What to do

  • Record your significant design decisions. Write one short document per decision, giving its date, the situation, the decision and its consequences, and keep them together with your other design documents. A docs/adr folder with each file named by number and title is the easiest place to find them.
M3 · Folder & project structure8.0 / 10Strong✓ Tool-verified

Maturity · Maturity — Whether the repo is organised deliberately — src/test separation and consistent project naming.

Method: Filesystem scan: src/test folder separation and namespace-prefix consistency (majority RootNamespace agreement). Exhaustive across projects, deterministic.

  • Production code isn't grouped under a src/ folder — it's spread across several top-level directories, so there's no one place that says 'this is the product'.

What to do

  • Group production code under src/ (or split deliberately, e.g. backend/ + frontend/) so production and tooling code aren't mixed at the root.
M4 · Documentation accuracy10.0 / 10Exemplary○ Nothing flagged

Maturity · Maturity — Whether the README actually describes the code that exists (LLM-judged, advisory).

Method: Judged by language model at low temperature: README accuracy versus actual projects, within a disclosed tolerance. Advisory, not a measured number.

P1 · CI/CD gates10.0 / 10Exemplary○ Nothing flagged

Readiness · Readiness — Whether an automated pipeline builds and tests every change.

Method: Filesystem scan: CI workflow files (.github/workflows, .gitlab-ci.yml, etc.) for build and test stages. Exhaustive, deterministic.

P10 · Library API & versioning10.0 / 10Exemplary○ Nothing flagged

Readiness · Readiness — For a library: a deliberate (small) public API surface and explicit semantic versioning so consumers can depend on it safely.

Method: Roslyn scan: public API surface area and semantic-versioning markers (SemVer attributes, changelog entries) for libraries; off .NET, a library is the ecosystem's publication act (an npm package that is not private and names an entry point, a PyPI distribution with a build system, a Rust library crate, a Maven/Gradle module that publishes, a Go module with no package main, a gemspec, a Composer library, a SwiftPM library product, a pub.dev or Hex package), its surface is the share of types the language model records as public (Rust, Swift, Java, Kotlin, Go, Dart; not measured where the model records no type visibility or, as in TypeScript, only module-level export), and its version is read from the manifest, a semver CHANGELOG, release tooling or semver git tags. Exhaustive, deterministic.

P2 · Observability7.1 / 10Strong✓ Tool-verified

Readiness · Readiness — Whether the code is diagnosable in production — structured logging, tracing/metrics, health checks.

Method: Filesystem/Roslyn scan: structured-logging frameworks (Serilog, NLog), OpenTelemetry, and health-check endpoint patterns. Exhaustive, deterministic.

  • Only 5/7 runnable modules use logging (modules with no entry point or server are excluded — they are libraries a runnable module hosts). Silent: `applications/ColossalMoE`, `colossalai/legacy/moe/openmoe`.

What to do

  • Extend structured logging to the remaining runnable modules so everything you run is diagnosable in production.
  • Add OpenTelemetry tracing/metrics (opentelemetry-sdk) so requests are traceable across the system, not just health-probable.
P3 · Security & performance tooling0.0 / 10Critical✓ Tool-verified

Readiness · Readiness — Whether SAST, secret/dependency scanning and performance benchmarking are wired in (presence, not runtime).

Method: Filesystem scan: SAST configuration, dependency-update automation, secret scanning, and a benchmark harness or benchmark step — in this repository's own ecosystem. Exhaustive, deterministic.

  • No static application security testing detected. For this repository's stack, add bandit, `semgrep --config=p/python`, or CodeQL's python pack as a CI step. What was searched, so you can tell an absence from a miss: the 78976 CI workflow file(s) in this repository, and the scanner and linter configuration checked in beside them. A scan that runs outside CI, one configured in your forge's web UI rather than in a committed file, or a tool whose name is none of those this check carries, is not seen — if that is your case the row is wrong, and saying so is more useful than adding a second scanner.

What to do

  • Add a SAST step to CI running what this repository's stack ships: bandit, `semgrep --config=p/python`, or CodeQL's python pack — so a security regression fails the build instead of landing.
  • Enable Dependabot/Renovate or a dependency-review gate.
  • Add gitleaks/trufflehog in CI to block PRs that introduce committed secrets.
P4 · Deployment & Rollback7.0 / 10Strong✓ Tool-verified

Readiness · Readiness — Whether releases are automated and safely reversible (probes, rolling updates, approval gates) — from manifests/pipeline files, not the live environment.

Method: Filesystem scan: deployment manifests/IaC (K8s YAML, Helm, Terraform) for rolling updates, probes, approval gates, migration hooks. Exhaustive, deterministic.

P6 · Release Hygiene5.0 / 10Adequate✓ Tool-verified

Readiness · Readiness — Whether releases are traceable — a maintained changelog and explicit version stamping.

Method: Filesystem scan: changelog file presence and version tags in csproj or git tags. Exhaustive, deterministic.

  • No CHANGELOG/HISTORY/RELEASES file — what shipped when isn't easy to reconstruct for support or audit. (Versioning/tagging makes releases traceable, but a changelog records the what.)

What to do

  • Keep a changelog (e.g. Keep-a-Changelog) recording what shipped in each release.
P7 · Outbound HTTP resilience3.0 / 10Weak✓ Tool-verified

Readiness · Readiness — Whether outbound HTTP calls are wrapped in resilience (retry/timeout/circuit-breaker) so a failing dependency doesn't cascade.

Method: Source scan: outbound HTTP clients and what bounds them — resilience handlers (Polly, AddStandardResilienceHandler) on .NET; on Go, the JVM, Python, JavaScript/TypeScript, Ruby, PHP, Rust, Elixir, Swift, Dart and Erlang, a timeout, deadline, retry or breaker beside each call, or a process-wide client default (a framework-wide deadline such as Drupal core's, Laravel's or actix's awc counts). Exhaustive, deterministic.

  • `requests.post(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout. (×2) — applications/ColossalChat/coati/distributed/reward/code_reward/utils.py:65, applications/ColossalQA/colossalqa/local/colossalcloud_llm.py:115
  • `requests.request(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout. — REDACTED:107
  • `requests.get(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout. (×2) — colossalai/legacy/inference/serving/ray_serve/send_request.py:7, colossalai/legacy/inference/serving/ray_serve/send_requests.py:7

What to do

  • Pass `timeout=` on every `requests`/`httpx` call (requests has no default and will wait forever), mount an `HTTPAdapter(max_retries=Retry(...))` on shared sessions, and wrap calls to flaky dependencies in `tenacity` retries or a `pybreaker` circuit breaker.
PF3 · Async & latency hygiene10.0 / 10Exemplary✓ Tool-verified

Readiness · Performance — Whether asynchronous code stays responsive — it avoids sync-over-async blocking (a .NET .Wait()/.GetAwaiter().GetResult(), a time.sleep or blocking HTTP call inside a Python coroutine, a *Sync call inside an async JavaScript function, block_on inside a Rust async fn, runBlocking inside a Kotlin suspend function, block() inside a Reactor publisher) that stalls a thread or event loop and risks deadlock, and, where the code is a reusable library on .NET, awaits with ConfigureAwait(false) so it never captures and stalls its caller's context.

Method: Production-source scan: sync-over-async blocking counted everywhere — .Wait()/.GetAwaiter().GetResult() in .NET; off .NET, read from the language model, a blocking call inside an async function (Python, TS/JS, Rust, Kotlin, Swift, Dart) or inside a Java method returning a Reactor Mono/Flux or a Scala method returning a Future or effect — and, for a .NET library with ≥5 awaits, the share of awaits using ConfigureAwait(false). Deterministic, syntax/text detection.

X1 · Async correctness10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether the code avoids sync-over-async (deadlock-prone blocking on tasks) and async void.

Method: Roslyn syntax scan: async methods scanned for .Wait()/.GetAwaiter().GetResult() and async-void outside event handlers. Deterministic, hard fact per invocation.

X12 · Unreachable branch10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether any branch is dead by construction — a switch arm whose label can never equal a case-normalised subject, or an `else if` whose predicate the arm above has already swallowed.

Method: Roslyn syntax + semantics: switch labels compared against the subject's own case normaliser, and if/else-if chains checked for a literal an earlier arm's containment test already swallows. Deterministic, provable per finding. Advisory.

X13 · Undrained process stream10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a child process that has BOTH standard streams redirected drains both — reading one to the end while the other is never read deadlocks once the child fills the unread pipe.

Method: Roslyn syntax + semantics: ProcessStartInfo launches with both streams redirected, checked for a drain of each stream across the enclosing type. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `spawn` imported from `child_process` whose stdout and stderr are both pipes (no options, no `stdio`, or `stdio` of `'pipe'`), bound to a local that never leaves its scope, where exactly one of the two streams is read, the other never, and the child’s `close`/`exit` (or the read stream’s end) is awaited; a shell redirect in the call’s arguments or a `kill` of the child suppresses it. The same rule reads Python’s `subprocess.Popen`, Dart’s `Process.start`, Ruby’s `Open3.popen3`, and Scala’s JDK process starts (`new ProcessBuilder(…).start()` with no `redirectErrorStream`/`redirectError`/`redirectOutput`/`inheritIO`, `Runtime.getRuntime.exec`) where one of `getInputStream`/`getErrorStream` is read and the other never while `waitFor()` is called or the read stream is read to its end. Deterministic, provable per finding. Advisory.

X14 · Bypassable address classification10.0 / 10Exemplary○ Nothing flagged

Other · Security — Whether a hand-rolled public/private IP check can be walked past — a method that unwraps IPv4-mapped IPv6 but returns the opposite verdict for the same host written as IPv4-compatible, 6to4 or NAT64.

Method: Roslyn syntax + semantics: methods that unwrap IPv4-mapped IPv6 and hand-roll IPv4 range carve-outs, checked for whether the IPv6 branch also accounts for the IPv4-compatible, 6to4 and NAT64 embeddings. Deterministic, provable per finding. Advisory.

X15 · Unvalidated length from an untrusted reader10.0 / 10Exemplary○ Nothing flagged

Other · Security — Whether a length read out of the stream being parsed is bounded before it is allocated or read — an unchecked count taken from the input lets the input choose the allocation.

Method: Roslyn syntax + semantics: integer lengths read from a BinaryReader and spent on a bulk read or an array allocation, checked for any comparison or bounding call on the value anywhere in the method. Deterministic, provable per finding. Advisory.

X17 · Uncapped recursion over a caller-supplied document1.6 / 10Critical✓ Tool-verified

Other · Security — Whether a walk that recurses through a JSON/XML tree handed in by its caller bounds how deep it will go — an uncapped walk lets the document's nesting choose the stack depth, and the resulting StackOverflowException cannot be caught.

Method: Roslyn syntax + semantics: methods that take a JSON/XML document node and call themselves with a child of it, reachable from an externally-callable member of the same type that accepts a document, checked for any depth parameter, descent counter or threaded arithmetic anywhere in the walk. On a repository with no .NET source it reads TypeScript off the engine’s own token stream (test, vendored, generated and minified paths and `.d.ts` not) with the same rule: a function or method with a parameter typed as a document value — `unknown`, `any`, `object`, `Record<string, unknown|any>`, a JSON alias (`JsonValue`, `JSONObject`, …) or a DOM node global the file does not rebind — that calls itself (bare, or through `this` for a method, or hands itself to a call over the value as in `value.map(walk)`) with something it took out of that value and never through an ancestor accessor such as `closest()` or `parentElement`, that is exported or reached from an exported function (a public method of the same exported class) taking such a value, and that names no depth, level, nesting, recursion, remaining or budget anywhere and threads no `+`/`-` arithmetic through a self-call. Plain JavaScript is not read: with no annotation nothing tells a parsed document from a tree the code built itself. Deterministic, provable per finding. Advisory.

  • `assert_hf_output_close` is public and takes `out1: Any` from its caller, and it calls itself at line 123 (`assert_hf_output_close`) with a piece of `out1` (and at line 136) — and nowhere in `assert_hf_output_close` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `assert_hf_output_close` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — colossalai/testing/comparison.py:123
  • `tree_flatten_hf` is public and takes `pytree: Any` from its caller, and it calls itself at line 47 (`tree_flatten_hf`) with a piece of `pytree` — and nowhere in `tree_flatten_hf` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `tree_flatten_hf` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — colossalai/pipeline/schedule/_utils.py:47
  • `apply_to_tensors` is public and takes `x: Any` from its caller, and it calls itself at line 63 (`apply_to_tensors`) with a piece of `x` (and at line 65, line 67) — and nowhere in `apply_to_tensors` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `apply_to_tensors` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — colossalai/legacy/zero/sharded_model/_utils.py:63
  • `pyobj_map` is public and takes `obj: Any` from its caller, and it calls itself at line 20 (`pyobj_map`) with a piece of `obj` (and at line 22, line 24) — and nowhere in `pyobj_map` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `pyobj_map` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — colossalai/legacy/pipeline/rpc/utils.py:20
  • `pytree_map` is public and takes `obj: Any` from its caller, and it calls itself at line 42 (`pytree_map`) with a piece of `obj` (and at line 44, line 46) — and nowhere in `pytree_map` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `pytree_map` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — colossalai/legacy/pipeline/rpc/utils.py:42
  • `flat_list` is public and takes `inputs: Any` from its caller, and it calls itself at line 77 (`flat_list`) with a piece of `inputs` — and nowhere in `flat_list` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `flat_list` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — colossalai/autochunk/utils.py:77
  • `pytree_map` is public and takes `obj: Any` from its caller, and it calls itself at line 92 (`pytree_map`) with a piece of `obj` (and at line 94, line 96) — and nowhere in `pytree_map` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `pytree_map` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — colossalai/auto_parallel/tensor_shard/utils/misc.py:92

What to do

  • Each finding names the externally-callable member that accepts the document and the self-call that descends, and states that no depth parameter or counter exists anywhere in the walk. Confirm from the two, then thread a depth argument through the walk and reject documents past a fixed maximum, or rewrite it with an explicit stack.
X19 · Unrestored process-global state10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a method that temporarily changes state belonging to the whole process — the working directory, an environment variable — puts it back on EVERY path: a restore reached only when nothing throws leaks the change to the rest of the process.

Method: Roslyn syntax + semantics: method bodies that write the process working directory or an environment variable and write it back in the same body, checked for whether that restore sits in a `finally`/`catch` or only on the straight-line path. On a repository with no .NET source the same rule reads production JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not): `process.chdir`, `process.env.NAME =`/`["NAME"] =` and `delete process.env.NAME`, and Deno’s `Deno.chdir`/`Deno.env.set`/`Deno.env.delete`, paired per function body (a nested function or arrow is its own body, and module top-level code is none), where the last write puts back a local the body captured from the same global or deletes a variable the first write set, with at least one statement between them; a write in a `catch`/`finally` of that body silences it. Deterministic, provable per finding. Advisory.

X21 · Side-effecting pattern guard10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a `when` guard is free of side effects — a guard that increments a counter or assigns while deciding whether its arm matches applies that change during PATTERN MATCHING, on an arm that may not be selected, and skips it entirely when a short-circuit to its left answers first.

Method: Roslyn syntax: `when` guards on case labels and switch-expression arms, read for a mutation (`++`/`--`/assignment) sitting in a position the guard's own `&&`/`||`/`??`/`?:`/`?.` can skip. Deterministic, provable per finding. Advisory.

X22 · Contradicted release guard10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a method that TAKES a lock or semaphore and gives it back from a flag-guarded `finally` returns the value that flag implies — reporting success while the guard hands the primitive back admits a second caller the exclusion was there to keep out, and reporting failure while the guard keeps it leaves nothing to ever give it back.

Method: Roslyn syntax: `try` statements whose `finally` releases a synchronisation primitive under a bare local-bool guard, where the method also TOOK that same primitive before the `try`, checked for a `return` of a bool literal whose value disagrees with the flag state the method's own straight-line assignments put it in. Deterministic, provable per finding. Advisory.

X23 · Unguarded diagnostic materialisation10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether the work a diagnostic REDACTED line costs is paid only when that line is wanted — C# evaluates a call's arguments BEFORE the call, so a trace/debug message joined or projected out of a collection is built in full on every pass, and then discarded by a sink the shipped configuration leaves switched off.

Method: Roslyn syntax: REDACTED calls at a diagnostic level (a `Log`-prefixed method naming Trace/Debug/Verbose, or a bare `Debug`/`Trace`/`Verbose` on a receiver named for a logger), whose argument list is read for a call whose cost scales with a sequence — a LINQ operator, a materialisation, `string.Join`, a serializer — with no enclosing level check or conditional-compilation region. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `debug`/`trace`/`verbose` call on a receiver named for a logger, or a `REDACTED`-prefixed method naming the level, whose argument calls an array operator (`map`/`filter`/`reduce`/`sort`/…), `Array.from`, `Object.keys/values/entries`, `JSON.stringify`/`util.inspect` over anything but a literal, or an array `join` — outside any arrow or function passed as an argument, which the logger calls only when the level is on — with no enclosing `if`, `&&` or `?:` whose condition names a level, a level string, or the `NODE_ENV`/`__DEV__`/`DEV` build switch. Deterministic, provable per finding. Advisory.

X24 · Document value interpolated into markup unescaped10.0 / 10Exemplary○ Nothing flagged

Other · Security — Whether text read out of the document being converted is escaped before it is written into generated markup — a value the document's author chose, interpolated into an attribute the surrounding literal delimits, can close that attribute and open another.

Method: Roslyn semantic model over the whole compilation: a string-typed `Value`/`InnerText`/`InnerXml`/`Text` member declared inside `DocumentFormat.OpenXml` or `System.Xml` is a taint SOURCE, propagated through assignments, returns, arguments, tuple elements and string composition to its transitive closure, then read at interpolated-string holes that sit in a markup position the surrounding literal itself delimits. Escaper/encoder calls and enclosing validator conditions cut the flow. Flow- and container-insensitive by construction. A second arm needs no provenance at all and reports a type that CONTRADICTS ITSELF — the same expression escaped at one delimited markup hole and interpolated raw at another hole in the same markup position of the same type, which the type's own escaping proves is a defect without knowing where the value came from. On a repository with no .NET source it reads JavaScript/TypeScript off the token stream with the same rule: a DOM read of raw document text (`getAttribute`, `textContent`, `innerText`, `nodeValue`) is the source, propagated through local bindings and string composition, and judged at template-literal and concatenation holes in the same two delimited markup positions; escapers and validating conditions cut it, and documentation-site, test, vendored and minified scripts are not read. Deterministic, provable per finding. Advisory.

X25 · Inert configuration knob10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a value the caller is invited to supply is the value the type actually uses — a constructor parameter stored in a private field that nothing ever reads while the default it was given is spelled out a second time at the site that should have read it, a keyed lookup that falls back to a different setting than the one its key names while the same type falls back to the matching one for that same key, or a culture-sensitive parse given no format provider by a type that feeds its own settable culture to the same kind of parse elsewhere, or a number an entry point writes to standard output under the host's culture while the same entry point formats with the invariant culture elsewhere. Either way, every caller who supplies a value silently gets something else.

Method: Roslyn syntax: private instance fields of a non-partial type assigned in a constructor from one of its own parameters with a `??` fallback, checked for whether anything in the type body reads the field and whether that same fallback expression is spelled out again outside the constructor; and `??` fallbacks onto a member access from a lookup call carrying exactly one string literal, grouped by that key across the type and checked for a fallback member whose folded name disagrees with the key while a sibling site for the same key agrees with it. On a repository with no .NET source the first two arms read JavaScript/TypeScript off the engine’s own token stream (tests included, bundles and vendored paths not): a `#x`, `private` or `private` parameter-property instance field filled in the constructor from a parameter (or one member of one) through `??`/`||` or a parameter default, never read anywhere in the file by name, whose constructed default is spelled again in the class body; and `lookup("key") ?? s.member` grouped by key per class, or per module outside every class. The culture arm has no JavaScript counterpart: its parses take no locale. Deterministic, provable per finding. Advisory.

X26 · Unsynchronised callback handoff10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a value handed from a callback to the body that waits on it crosses on something built to be crossed — a `Queue<T>`/`List<T>`/`Dictionary<K,V>` written inside an event handler and read back outside it is mutated by two flows at once, and the semaphore or completion source beside it orders how MANY items exist while leaving the collection's own head, tail and backing array unprotected.

Method: Roslyn syntax: method, accessor, local-function and lambda bodies that declare BOTH a non-thread-safe generic collection (`Queue`/`Stack`/`List`/`Dictionary`/`HashSet`/`Sorted*`/`LinkedList`) and a synchronisation primitive (`SemaphoreSlim`/`TaskCompletionSource`/`ManualResetEvent(Slim)`/`AutoResetEvent`/`CountdownEvent`) as locals, then read for a `+=`-registered lambda that raises that primitive while the body outside every lambda waits on it — and, in that scope, a mutating call on the collection inside the lambda paired with a mention of it outside. Any `lock` in the scope abstains it. On a repository with no .NET source the same handoff is read in Java off the engine’s own token stream (test source sets, vendored and demonstration paths not): an `ArrayList`/`LinkedList`/`ArrayDeque`/`PriorityQueue`/`Hash*`/`LinkedHash*`/`Tree*` local and a `CountDownLatch`/`Semaphore`/`CompletableFuture` local, a lambda or anonymous class that raises the primitive and mutates the collection, and a wait outside it; any `synchronized` or `lock()` abstains the body. Because each of those primitives orders what the callback wrote before raising it, only a touch that provably overlaps the callback is convicted: one after the registration and before the next wait, or one in a loop registered-before, waiting on every pass and not declaring the collection. Deterministic, provable per finding. Advisory.

X27 · Collection changed while being enumerated10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a `for` loop leaves the `dict`, `set` or `deque` it is walking alone — CPython's iterators over those check that the collection has not changed size since the loop began, so a body that removes from (or empties) the very collection the loop is walking makes the next step raise `RuntimeError: dictionary changed size during iteration` and the remaining items are never seen.

Method: Roslyn syntax + semantics: `foreach` statements whose body calls a structural mutator (`Add`/`Remove`/`Clear`/`Insert`/…) on the very expression the loop is enumerating. Two arms. ARM A — the source is a concrete fragile BCL collection, or a live `Keys`/`Values` view over one, and the mutator resolves to that same collection's own member; concurrent and immutable collections and arrays are outside the population by construction, since their enumerators survive a structural change. ARM B — the source is an argument-less accessor CALL on a receiver whose body is in source: the accessor must return a stored field VERBATIM and a sibling member must structurally change that same field, both read off the implementations rather than from the members' names. A mutation the loop provably exits immediately after (`break`/`return`/`throw`/`goto`), or one written inside a nested loop or a lambda, is counted and never reported. Deterministic, provable per finding. Advisory.

X28 · Index access outside its own emptiness guard10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a condition that tests a value for emptiness indexes that same value only where the test holds — an `||` written one parenthesis too far to the left leaves an index access outside the guard beside it, so the empty case the guard exists to anticipate reaches the index and throws.

Method: Roslyn syntax only, no semantic model: the OUTERMOST `&&`/`||` of every boolean condition, read for a symbol the condition tests for emptiness (`string.IsNullOrEmpty`/`IsNullOrWhiteSpace`, a `Length`/`Count` comparison against a literal, `Any()`, a `Length`/`Count` pattern, or a comparison against `""`) and ALSO indexes. Each `symbol[...]` access is placed by a boolean-reachability walk from the access up to the outermost connective: an access is COVERED when some enclosing step has it in the right operand and the left operand, under the truth value that step forces, proves the symbol non-empty — a recursion over `&&`/`||` whose true- and false-directions are asymmetric. A finding needs BOTH an uncovered access and a covered one on the same symbol in the same condition, which is the agreeing twin that separates a misplaced parenthesis from an unrelated length test. Bare index accesses with no emptiness test in the condition are neither counted nor reported; a non-identifier receiver and a lambda nested inside the condition are outside the population. Deterministic, provable per finding. Advisory.

X3 · Exception handling5.0 / 10Adequate✓ Tool-verified

Other · Code Health — Whether exceptions are handled rather than silently swallowed or rethrown with lost stack traces.

Method: Roslyn syntax scan: every catch clause counted; empty catches and bare rethrows flagged. Population is all catch clauses, not estimated. Deterministic, hard fact.

  • `except` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter. (×28) — extensions/cuda_extension.py:34, extensions/triton_extension.py:16, extensions/pybind/flash_attention/__init__.py:10, …
  • `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter. (×4) — colossalai/_compat.py:162, applications/ColossalEval/colossal_eval/evaluate/gpt_evaluate.py:104, applications/ColossalEval/colossal_eval/evaluate/gpt_evaluate.py:690, …
  • An empty catch block silently discards the error — failures vanish with no REDACTED and no rethrow. Log it, handle it, or don't catch it. (×8) — colossalai/shardformer/layer/normalization.py:22, colossalai/legacy/zero/gemini/colo_init_context.py:56, colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:56, …

What to do

  • Swallowed exception (caught, then discarded)
X30 · Support guard that admits what it rejects10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a guard written as a NEGATED `||` says what its author meant — `!(a || b || x != k)` is `!a && !b && x == k` by De Morgan, so a bail-out that mixes capabilities the code needs with a fault it refuses turns inside out: it fires only where the capabilities are ABSENT, and lets every value the fault term names walk straight into the body that cannot handle it.

Method: Roslyn syntax only, no semantic model: every logical-not whose operand is a parenthesised `||` chain of two or more disjuncts, flattened (a left-nested `a || b || c` read once would see `(a || b)` as one disjunct). A site enters the population on that shape alone. A finding additionally needs the disjuncts to DISAGREE in polarity: at least one bare boolean read — an identifier or member access, never an invocation, which is a predicate rather than a capability flag — and at least one `x != <constant>`, the only form that negates into an exact-value pin (`== null` negates into a looser requirement and is outside the fault set). Consistently-polarised disjunctions, all-fault or all-capability, are counted and never reported; a negated `&&` is outside the population entirely. No same-receiver gate: it was measured to cost a real defect and remove no false positive. Deterministic, provable per finding. Advisory.

X4 · Structured logging2.4 / 10Weak✓ Tool-verified

Other · Code Health — Whether REDACTED calls use message templates (queryable) rather than interpolated strings.

Method: Roslyn syntax scan: every REDACTED call-site counted; interpolated-string first-argument violations flagged. Population is all REDACTED calls, not estimated. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `trace`/`debug`/`info`/`warn`/`error`/`fatal`/`verbose`/`silly`/`http`/`REDACTED` call on a receiver named for a logger, in a package whose own or an enclosing `package.json` declares a logger that carries values as fields (pino, pino-http, nestjs-pino, Fastify, winston, bunyan, tslog, LogTape, roarr), whose first deciding argument is a template literal with substitutions; an object-literal fields argument is stepped over, a plain string message clears the call. Python is read the same way: a `debug`/`info`/`warning`/`error`/`exception`/`critical`/`REDACTED` call on a logger in a file that imports the standard library’s `logging` or structlog (loguru, which formats at the call, is not judged), whose message is a whole f-string with a non-constant field; a `%`-formatted, `.format()`-ed or concatenated message is not convicted, as in C#. PHP is read the same way: a PSR-3 level call (`emergency`…`debug`, `REDACTED`) on a logger (`$logger`, `$this->logger`, Laravel’s `Log::`, `logger()`, `\Drupal::logger()`) in a package whose `composer.json` requires a PSR-3 logger or a framework that hands one out (psr/log, Monolog, Laravel, Symfony, Drupal, CakePHP), or a file that imports one, whose message is a double-quoted string interpolating a variable; a single-quoted message clears the call, and `sprintf` or `.` concatenation is not convicted, as in C#. Dart is read the same way: a `trace`/`debug`/`info`/`warn`/`error`/`fatal` call on Sentry’s structured logger (`Sentry.logger`) whose message is a whole string literal interpolating a value (`$name`, `${…}`); the `Sentry.logger.fmt` template API clears the call. Dart that logs only through loggers with one message and no fields (package:logging, package:logger, talker, dart:developer) is not applicable rather than a reach gap. Ruby is read the same way: a `trace`/`debug`/`info`/`warn`/`error`/`fatal` call on the console gem’s `Console` (declared by a Gemfile, gemspec or Gemfile.lock, or required) or, where SemanticLogger, Ougai or dry-logger is declared or required, on a receiver named for a logger (`logger`, `@logger`, `Rails.logger`, `REDACTED`), whose first deciding argument is, as the whole argument, a double-quoted string interpolating a non-constant value (`#{…}`, `#@ivar`); a plain literal clears the call, keyword arguments are the fields, and a block, `%`-format or `+` concatenation is not convicted. Ruby that logs only through the standard Logger (Rails.logger) is not applicable rather than a reach gap. Deterministic.

  • `info` at line 100 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/quantization/bnb.py:100
  • `info` at line 60 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. (×3) — colossalai/legacy/inference/serving/torch_serve/Colossal_Inference_Handler.py:60, colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py:60, colossalai/legacy/inference/dynamic_batching/ray_dist_init.py:60
  • `info` at line 61 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/legacy/inference/serving/torch_serve/Colossal_Inference_Handler.py:61
  • `info` at line 67 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/legacy/inference/serving/torch_serve/Colossal_Inference_Handler.py:67
  • `warning` at line 79 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.warning("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.warning("order moved", order_id=order_id, status=status)` with structlog. — colossalai/legacy/inference/serving/torch_serve/Colossal_Inference_Handler.py:79
  • `info` at line 92 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/legacy/inference/serving/torch_serve/Colossal_Inference_Handler.py:92
  • `info` at line 182 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/legacy/inference/serving/torch_serve/Colossal_Inference_Handler.py:182
  • `info` at line 33 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. (×2) — colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py:33, colossalai/legacy/inference/dynamic_batching/ray_dist_init.py:33
  • `info` at line 34 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py:34
  • `info` at line 38 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py:38
  • `info` at line 42 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py:42
  • `info` at line 83 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py:83
  • `info` at line 86 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py:86
  • `info` at line 91 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py:91
  • `info` at line 139 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py:139
  • `info` at line 24 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/legacy/inference/dynamic_batching/ray_dist_init.py:24
  • `info` at line 25 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/legacy/inference/dynamic_batching/ray_dist_init.py:25
  • `info` at line 29 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/legacy/inference/dynamic_batching/ray_dist_init.py:29
  • `error` at line 51 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.error("order moved", order_id=order_id, status=status)` with structlog. — colossalai/legacy/inference/dynamic_batching/ray_init_config.py:51
  • `error` at line 54 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.error("order moved", order_id=order_id, status=status)` with structlog. — colossalai/legacy/inference/dynamic_batching/ray_init_config.py:54
  • `error` at line 57 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.error("order moved", order_id=order_id, status=status)` with structlog. — colossalai/legacy/inference/dynamic_batching/ray_init_config.py:57
  • `warning` at line 184 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.warning("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.warning("order moved", order_id=order_id, status=status)` with structlog. — colossalai/inference/logit_processors.py:184
  • `info` at line 138 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/inference/server/chat_service.py:138
  • `info` at line 140 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/inference/server/chat_service.py:140
  • `info` at line 107 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/inference/core/async_engine.py:107
  • `info` at line 116 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/inference/core/async_engine.py:116
  • `info` at line 108 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/inference/core/plugin.py:108
  • `info` at line 129 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/inference/core/plugin.py:129
  • `error` at line 123 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.error("order moved", order_id=order_id, status=status)` with structlog. — colossalai/checkpoint_io/general_checkpoint_io.py:123
  • `info` at line 169 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/checkpoint_io/general_checkpoint_io.py:169
  • `error` at line 227 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.error("order moved", order_id=order_id, status=status)` with structlog. — colossalai/checkpoint_io/general_checkpoint_io.py:227
  • `info` at line 265 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/checkpoint_io/general_checkpoint_io.py:265
  • `error` at line 286 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.error("order moved", order_id=order_id, status=status)` with structlog. — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:286
  • `info` at line 336 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:336
  • `info` at line 402 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:402
  • `info` at line 493 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:493
  • `info` at line 514 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog. — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:514

What to do

  • Interpolated REDACTED message defeats structured logging

Reference — by lens

The score is the rank-weighted fold of these lenses (worst-heaviest), each including its meta-dimensions; a lens with a Critical contributor is capped at Fair (its band reads "gated by …") and is never the strongest area however high its average.

LensScoreRatingImpact
Code Health56%Adequate — gated by D2, X4Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Architecture95%ExemplarySolid.
Maturity59%Adequate — gated by D34, M2Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Readiness43%Adequate — gated by P3, P7Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Security38%Weak — gated by D29, D30, D36, C2Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Performance100%ExemplaryStrongest area.
Unscored — 2 check(s) recorded observations but carry no score

These checks ran and found something, but they do not carry a score — either by design (an advisory check reports evidence rather than grading it) or because they could not be scored here. They are excluded from the score for that reason, not because there was nothing to see.

  • X10 Duplicated predicate — 25 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
  • X7 Silent fallback defaults — 1 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
Not evidenced — 4 control(s) we could not find positive evidence for

These checks grade a working control, and the repository shows no evidence of one. That is deliberately not scored as a zero: a repository cannot show an ops runbook, a database TTL or an infrastructure-side audit REDACTED, so absence of evidence here is not evidence the control is missing. It is also not a statement that the check is irrelevant to this codebase — the thing it grades applies; we just could not see it. Excluded from the score either way.

  • C3 Audit Trail — Not assessed: this repository stores data through 'sqlalchemy' (applications/ColossalQA/colossalqa/utils.py:5) but declares no persisted model this check reads (Django, SQLAlchemy, SQLModel, Peewee, Tortoise and MongoEngine model fields, Alembic and Django migration columns, CREATE TABLE and ALTER TABLE … ADD columns in SQL files). Personal data may be written through raw SQL or a hosted backend, so whether its changes need an audit trail could not be established, and the trail's absence is not scored.
  • C4 Data Retention — Not assessed: this repository stores data through 'sqlalchemy' (applications/ColossalQA/colossalqa/utils.py:5) but declares no persisted model this check reads (Django, SQLAlchemy, SQLModel, Peewee, Tortoise and mongoengine model fields, Alembic and Django migration columns, SQL schemas). Personal data may be written through raw SQL or a hosted backend, so whether a retention limit applies here could not be established, and its absence is not scored.
  • C5 Data-Subject Rights — Not assessed: this repository stores data through 'sqlalchemy' (applications/ColossalQA/colossalqa/utils.py:5) but declares no persisted model this check reads (Django, SQLAlchemy, SQLModel, Peewee, Tortoise and mongoengine model fields, Alembic and Django migration columns, CREATE TABLE and ALTER TABLE … ADD columns in SQL files). Personal data may be written through raw SQL or a hosted backend, so whether data-subject rights apply here could not be established, and their absence is not scored.
  • P5 DR & Backup — not evidenced — repo shows no backup/RTO/RPO controls; absence of evidence is not evidence of a working control
Not included — 53 check(s) not relevant to this codebase

These checks had nothing to measure here (no tests, no git history, the codebase is small, or the architecture style doesn't apply), so they're omitted above rather than scored low.

  • AC1 Text alternatives — No web markup found — accessibility is not applicable to this repository.
  • AC2 Forms & labels — No web markup found — accessibility is not applicable to this repository.
  • AC3 Page structure — No web markup found — accessibility is not applicable to this repository.
  • AC4 Keyboard semantics — No web markup found — accessibility is not applicable to this repository.
  • AC5 ARIA correctness — No web markup found — accessibility is not applicable to this repository.
  • AC6 Visual & motion safety — No web markup found — accessibility is not applicable to this repository.
  • AC7 A11y enforcement — No web markup found — accessibility is not applicable to this repository.
  • AX1 Captive dependencies — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • AX5 Architecture & structure — not assessed — architecture style/structure is computed from a project graph (projects, types, module namespaces) that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • AX6 Interface segregation — not assessed — interface segregation is computed over a type surface that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • AX7 Slice cohesion — not applicable — not a vertical-slice architecture
  • AX8 Test isolation — no test/production split to check
  • AX9 CQS / query purity — no CQRS query handlers detected — query purity is not applicable to this codebase
  • AXB2 Runtime readiness — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
  • AXR1 Runtime accessibility — docker build failed (exit 1) — #1 DONE 0.0s REDACTED.dockerignore:3 -------------------- 1 | # Only dependency build inputs belong in this context. In particular, do not 2 | # copy the checkout, prebuilt extensions, personal environments or credentials. 3 | >>> ** 4 | !docker/ 5 | !docker/torch213/ -------------------- ERROR: failed to solve: dockerfile parse error on line 3: unknown instruction: **; runtime evidence skipped This is a statement about this run, not a statement about your application: nothing here says the surface is inaccessible, only that it was never rendered.
  • C1 Data Protection — Not assessed: these personal data controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks personal data controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
  • D10 Test Quality — ~46453 lines of test source are present (.py) but no test cases reached the test census for this repository — no test root we could resolve declared them, or the files we read declare no cases in a test framework we recognise — so skipped/assertion-free tests couldn't be counted. Not scored — this is a gap in the analyzer, not a finding about this repository.
  • D18 Solution Shape — D18 scores the shape of a .NET solution; this repository has no .NET solution or project files, so the dimension does not apply.
  • D21 Naming Consistency — Naming consistency is measured on C# only; Python not measured.
  • D22 Internal API Consistency — The exposed public-API surface could not be collected — no C#/VB projects loaded.
  • D23 Boundary Type-Coupling — No bounded-context organisation was detected either — neither a context-shaped layout, nor 2+ sibling source directories each declaring an aggregate root, nor 2+ projects each declaring an entity of their own. Declaring this codebase's bounded contexts (≥2) would let cross-boundary type coupling be assessed. Declare them in `.codehealth/config.yaml` at the repository root (create it if absent), mapping each context name to the module-path or namespace prefixes that belong to it — e.g. `architecture:` → `contexts:` → `Billing: ["src/billing", "Acme.Billing"]`, `Catalog: ["src/catalog", "Acme.Catalog"]`.
  • D24 Comment Value — D24 reads C# and Visual Basic comments only — this repository's production source is .py, which was left unread. Not scored: this is a gap in the analyzer, not a verdict about this repository.
  • D25 ADR Conformance — no ADRs to check
  • D27 Navigability — D27 counts a call into the standard library or a dependency as unresolved for this repository's language (.py), so too few call sites counted as resolved to assess navigability. Not scored: this is a gap in the analyzer, not a verdict about this repository.
  • D32 Data Compliance (PII/GDPR) — No personal data was found crossing a boundary the PII/GDPR ruleset checks — nothing written to a REDACTED or console sink, placed in a URL or query string, or persisted to browser storage. That is a clean result for the LEAK surface only: this ruleset detects personal data escaping, it does not inventory the personal data a repository holds, so it is not evidence that this repository has no personal-data surface. The personal-data map (Appendix C) and the C1-C5 compliance cards are what speak to that.
  • D37 Vulnerability-disclosure Policy — No vulnerability-disclosure policy file found (SECURITY.md/.markdown/.rst/.txt at root or under .github/.forgejo/.gitea/docs, .well-known/security.txt). A coordinated-disclosure policy may live off-repo, so this is not evidenced rather than failed.
  • D39 IL Efficiency — D39 measures the IL emitted by a .NET build; this repository has no .NET solution or project files, so the dimension does not apply.
  • D40 Network Egress Confinement — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.
  • D41 Kernel & Syscall Confinement — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.
  • D42 Runtime Threat Enforcement — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.
  • D7 Architectural Integrity — no checkable ADRs, and no project-reference graph for the cycle pass to read — so this dimension makes no claim about dependency cycles in either direction (where this repository's language has an import-cycle lens, cycles are reported there). Architectural integrity not assessed
  • D8 Code Coverage — Coverage not included — suite not readable by the collector
  • DM1 Domain Modelling — not scored — this repository shows only 1 of the 3 signals this lens looks for (53 value object(s))
  • ED1 Event-Driven — not scored — this repository shows none of the 3 signals this lens looks for
  • ED5 Idempotency — no mutating command handlers or message consumers detected — idempotency check not applicable
  • ES1 Event Sourcing — not scored — this repository shows none of the 3 signals this lens looks for
  • GD1 Unfinished & placeholder code — no source files were read — this check reads C#, F#, JavaScript/TypeScript, Dart, Ruby and Scala, and none was read for this repository's product. That is a limit of the analyzer, not a finding about your code.
  • IC1 Incompleteness & stubs — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • P12 CI test-gate honesty — Reported, not scored — and nothing was matched here. The coverage check applies to any stack, and the automatic-re-run check to any GitHub-Actions workflow, but the checks for excluded tests, skipped tests and sleep-based synchronisation currently recognise only some ecosystems' test-runner idioms, so on a repository built with another stack the zeros below mean 'not checked', not 'clean'.
  • P8 Schema migrations — SQLAlchemy is declared, but the schema-migration mechanism could not be identified. Our limit, not a verdict on this repository.
  • P9 Domain vs controller coverage — no coverage report found on disk — produce a coverage report in a standard format (`coverage run -m pytest` then `coverage xml`) and commit it — a hosted scan measures a clone of the repository, so a report that exists only in a working tree, a CI runner's or your own, never reaches it; the artefact is commonly gitignored, so `git add -f` that one file (or un-ignore its path) and commit it alongside the code it measures, or wire coverage collection into CI, to enable this cross-layer check
  • PF1 Benchmark discipline — Not applicable: no benchmark suite was found. This check searched for a pytest-benchmark or pytest-codspeed dependency with tests taking the `benchmark` fixture, an asv.conf.json with its `time_`/`mem_`/`peakmem_` benchmarks, or a pyperf Runner, and for a `*benchmark*` script that this repository's CI runs. Benchmarks are credited as a bonus, so their absence is neither scored nor deducted.
  • PF2 Allocation hygiene — Not applicable: Python runs on a garbage-collected runtime that gives a program no allocation-control idiom to choose on a hot path — no pools, stack allocation or value types — so allocation awareness is not something this code can be rated on.
  • S1 Web-Security Posture — Not assessed: these web-security controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks web-security controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
  • X16 Unfloored truncation loop — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • X18 Disposal-pattern correctness — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • X2 Cancellation propagation — no C# was loaded; this repository's Python was read, and no request in it can be cancelled by a caller — a Python request takes no token: asyncio cancels the task and trio or anyio the scope that made it, from outside the call, and requests, httpx, aiohttp and gRPC take a timeout, not a cancellation
  • X20 Mistyped argument guard — This check asks whether an argument guard reports an EMPTY value as a NULL one, which needs a language that throws a null-specific argument exception — .NET's ArgumentNullException, the JVM's NullPointerException, Dart's ArgumentError.notNull. This repository contains none of those languages: the ones it is written in have a single exception for a bad argument, so there is no pair of exceptions to confuse and nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
  • X29 Per-element action decided by a fixed element — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • X32 Type resolved by simple name across every loaded assembly — This check is about how a .NET program searches the assemblies loaded into its process for a type, and this repository contains no .NET source, so there is nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
  • X5 Nullable reference types — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • X6 Hand-rolled structured-format parsing — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
  • X9 Subsumed condition operand — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.

Appendix A — Findings (grouped)

The findings behind the scores, grouped by severity, then by dimension and kind. The high-severity issues are enumerated in full below; items per group are capped at 25 with any overflow stated explicitly per group, never silently truncated. The complete machine-readable list of every finding (all severities) is the companion findings.md in this report's bundle.

Critical — 138 finding(s)
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • + 42 more in this group — see findings.md.
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D30 · Dependency Vulnerabilities · High CVE · ×9
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D30 · Dependency Vulnerabilities · Critical CVE · ×8
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D31 · IaC & Container Security · High IaC · ×8
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D14 · License Compliance · Banned license · ×2
  • Banned license: contexttimer — `contexttimer` 0.3.3 is published on PyPI under `GPL-3.0`, which this policy bans, and it is in the SHIPPED closure of this repository — so it is installed by everything that depends on this repository, not just by its test environment. A distribution offering SEVERAL licences is a choice and is only charged when every one of them is banned. Replace the package, or record an accepted exception.
  • Banned license: fuzzywuzzy — `fuzzywuzzy` 0.18.0 is published on PyPI under `GPL-2.0`, which this policy bans, and it is in the SHIPPED closure of this repository — so it is installed by everything that depends on this repository, not just by its test environment. A distribution offering SEVERAL licences is a choice and is only charged when every one of them is banned. Replace the package, or record an accepted exception.
D29 · Static Analysis (SAST) · REDACTED · ×2
  • REDACTED
  • REDACTED
D28 · Secrets (history) · REDACTED · ×1
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED · ×1
  • REDACTED
D30 · Dependency Vulnerabilities · Critical vulnerability · ×1
  • REDACTED
Serious — 2463 finding(s)
D17 · Explicit Debt · TodoComment · ×273
  • TodoComment tests/test_shardformer/test_model/test_shard_chatglm2.py:116 — # TODO: ChatGLMModel output is [S, B, H], merging batch of pipeline is wrong — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment tests/test_shardformer/test_model/test_shard_t5.py:79 — # TODO he precision in weight checking is too significant. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment tests/test_shardformer/test_model/test_shard_vit.py:94 — # TODO: num_microbatch size = 2 inf loss — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment tests/test_shardformer/test_model/test_shard_vit.py:138 — # TODO: fix bug when settign lazy_init for Conv2D Layers in ViT models — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment tests/test_shardformer/test_model/test_shard_whisper.py:108 — # TODO fix WhisperForConditionalGeneration enable jit fused operato — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment tests/test_shardformer/test_model/test_shard_whisper.py:109 — # TODO(jianghai) fix fp16 — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment tests/test_pipeline/test_schedule/test_zerobubble_pp.py:790 — # TODO: Support MixtralForCausalLM — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment tests/test_pipeline/test_schedule/test_zerobubble_pp.py:948 — # TODO: Support MixtralForCausalLM — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment tests/test_optimizer/_utils.py:236 — # TODO "exp_avg_sq_col", "exp_avg_sq_row", "exp_avg_sq" — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment tests/test_optimizer/_utils.py:268 — # TODO: this case may cause shape mismatch @duanjunwen — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment tests/test_optimizer/_utils.py:300 — # TODO: some sharding checks are currently buggy, but the state values should match — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment tests/test_optimizer/test_dist_adafactor.py:395 — # @duanjunwen TODO: fix this test case. Currently params are sharded but are not dtensor here, throwing an error. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment tests/test_optimizer/test_dist_came.py:217 — # TODO: error in layer: — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment tests/test_optimizer/test_dist_came.py:229 — # TODO: err here; backward diff gard; Only transformers_bert pass; — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment tests/test_optimizer/test_dist_came.py:317 — # TODO: model — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment tests/test_optimizer/test_dist_came.py:349 — # err in TODO layer — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment tests/test_optimizer/test_nvme.py:21 — # TODO Something wrong with ci when running this test. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment tests/test_moe/test_moe_ep_tp.py:99 — # TODO check sharded and sliced moe — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment tests/test_moe/test_moe_ep_tp.py:111 — # TODO check sharded and sliced moe — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment tests/test_legacy/test_moe/test_moe_load_balance.py:162 — # TODO: high atol, check if bug exists — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment tests/test_lazy/test_models.py:20 — # TODO(ver217): lazy init does not support weight norm, skip these models — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment tests/test_infer/test_rpc_engine.py:78 — # TODO: fix the test — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment tests/test_infer/test_kernels/triton/test_context_attn_unpad.py:108 — # TODO(yuanheng-zhao): Since the alibi kernel is pretty similar to the original one, — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment tests/test_infer/test_kernels/triton/test_decoding_attn.py:92 — # TODO(yuanheng-zhao): Since the alibi kernel is pretty similar to the original one, — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment colossalai/kernel/triton/context_attn_unpad.py:607 — # TODO(yuanheng-zhao): Since the alibi kernel is pretty similar to the original one, — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • + 248 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (5 lines × 2) · ×44
  • Duplicated block (5 lines × 2) applications/ColossalChat/coati/experience_maker/naive.py:167 — applications/ColossalChat/coati/experience_maker/naive.py:167-171 | applications/ColossalChat/examples/community/peft/easy_models.py:38-42 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (5 lines × 2) applications/ColossalChat/coati/trainer/grpo.py:284 — applications/ColossalChat/coati/trainer/grpo.py:284-288 | applications/ColossalChat/coati/trainer/ppo.py:284-288 — before extracting anything, compare `applications/ColossalChat/coati/trainer/grpo.py` and `applications/ColossalChat/coati/trainer/ppo.py` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 176 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (5 lines × 2) applications/ColossalChat/coati/trainer/kto.py:351 — applications/ColossalChat/coati/trainer/kto.py:351-355 | applications/ColossalChat/coati/trainer/orpo.py:326-330 — before extracting anything, compare `applications/ColossalChat/coati/trainer/kto.py` and `applications/ColossalChat/coati/trainer/orpo.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 138 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (5 lines × 2) colossalai/auto_parallel/checkpoint/ckpt_solver_base.py:188 — colossalai/auto_parallel/checkpoint/ckpt_solver_base.py:188-192 | colossalai/auto_parallel/offload/region_manager.py:441-445 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (5 lines × 2) colossalai/booster/plugin/gemini_plugin.py:91 — colossalai/booster/plugin/gemini_plugin.py:91-95 | colossalai/booster/plugin/torch_fsdp_plugin.py:109-113 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (5 lines × 2) colossalai/checkpoint_io/moe_checkpoint.py:333 — colossalai/checkpoint_io/moe_checkpoint.py:333-337 | colossalai/checkpoint_io/moe_checkpoint.py:344-348 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (5 lines × 2) colossalai/fx/tracer/meta_patch/patched_function/convolution.py:78 — colossalai/fx/tracer/meta_patch/patched_function/convolution.py:78-82 | colossalai/fx/tracer/meta_patch/patched_function/convolution.py:100-104 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/fx/tracer/meta_patch/patched_function/convolution.py:78` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) colossalai/fx/tracer/meta_patch/patched_function/convolution.py:143 — colossalai/fx/tracer/meta_patch/patched_function/convolution.py:143-147 | colossalai/fx/tracer/meta_patch/patched_function/convolution.py:169-173 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/fx/tracer/meta_patch/patched_function/convolution.py:143` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) colossalai/fx/tracer/meta_patch/patched_module/pooling.py:49 — colossalai/fx/tracer/meta_patch/patched_module/pooling.py:49-53 | colossalai/fx/tracer/meta_patch/patched_module/pooling.py:77-81 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/fx/tracer/meta_patch/patched_module/pooling.py:49` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) colossalai/fx/tracer/meta_patch/patched_module/pooling.py:130 — colossalai/fx/tracer/meta_patch/patched_module/pooling.py:130-134 | colossalai/fx/tracer/meta_patch/patched_module/pooling.py:159-163 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/fx/tracer/meta_patch/patched_module/pooling.py:130` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) colossalai/inference/batch_bucket.py:502 — colossalai/inference/batch_bucket.py:502-506 | colossalai/inference/batch_bucket.py:518-522 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/inference/batch_bucket.py:502` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) colossalai/inference/modeling/models/glide_llama.py:38 — colossalai/inference/modeling/models/glide_llama.py:38-42 | colossalai/legacy/inference/quant/smoothquant/models/llama.py:408-413 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (5 lines × 2) colossalai/inference/modeling/models/nopadding_llama.py:333 — colossalai/inference/modeling/models/nopadding_llama.py:333-337 | colossalai/inference/modeling/models/nopadding_llama.py:599-603 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/inference/modeling/models/nopadding_llama.py:605` calls `hasattr` and `colossalai/inference/modeling/models/nopadding_llama.py:338` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 2) colossalai/legacy/inference/dynamic_batching/ray_dist_init.py:57 — colossalai/legacy/inference/dynamic_batching/ray_dist_init.py:57-61 | colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py:57-61 — before extracting anything, compare `colossalai/legacy/inference/dynamic_batching/ray_dist_init.py` and `colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 42 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (5 lines × 2) colossalai/legacy/inference/quant/smoothquant/models/llama.py:451 — colossalai/legacy/inference/quant/smoothquant/models/llama.py:451-455 | colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:359-363 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/legacy/inference/quant/smoothquant/models/llama.py:456` calls `rotary_emb`, `q_apply_rotary`, `k_apply_rotary` and `colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:366` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 2) colossalai/legacy/inference/quant/smoothquant/models/llama.py:739 — colossalai/legacy/inference/quant/smoothquant/models/llama.py:739-743 | colossalai/legacy/inference/quant/smoothquant/models/llama.py:745-749 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (5 lines × 2) colossalai/legacy/nn/_ops/_utils.py:249 — colossalai/legacy/nn/_ops/_utils.py:249-253 | colossalai/legacy/nn/_ops/_utils.py:258-262 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (5 lines × 2) colossalai/legacy/nn/layer/parallel_2d/_operation.py:130 — colossalai/legacy/nn/layer/parallel_2d/_operation.py:130-134 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:82-86 — `colossalai/legacy/nn/layer/parallel_2d/_operation.py` and `colossalai/legacy/nn/layer/parallel_2p5d/_operation.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 185 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (5 lines × 2) colossalai/legacy/nn/layer/parallel_2d/layers.py:515 — colossalai/legacy/nn/layer/parallel_2d/layers.py:515-519 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:528-532 — `colossalai/legacy/nn/layer/parallel_2d/layers.py` and `colossalai/legacy/nn/layer/parallel_2p5d/layers.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 18 separate duplicated blocks between them, totalling at least 219 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2d/layers.py:515` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) colossalai/legacy/nn/parallel/layers/cache_embedding/parallel_cached_embedding_tablewise.py:41 — colossalai/legacy/nn/parallel/layers/cache_embedding/parallel_cached_embedding_tablewise.py:41-45 | colossalai/legacy/nn/parallel/layers/cache_embedding/parallel_cached_embedding_tablewise_split_cache.py:40-44 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/legacy/nn/parallel/layers/cache_embedding/parallel_cached_embedding_tablewise_split_cache.py:39` calls `super`, `__init__` and `colossalai/legacy/nn/parallel/layers/cache_embedding/parallel_cached_embedding_tablewise.py:40` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 2) colossalai/legacy/trainer/hooks/_log_hook.py:54 — colossalai/legacy/trainer/hooks/_log_hook.py:54-58 | colossalai/legacy/trainer/hooks/_log_hook.py:62-66 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (5 lines × 2) colossalai/quantization/fp8.py:453 — colossalai/quantization/fp8.py:453-457 | colossalai/quantization/fp8.py:479-483 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/quantization/fp8.py:453` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) colossalai/quantization/fp8.py:697 — colossalai/quantization/fp8.py:697-701 | colossalai/quantization/fp8.py:728-732 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (5 lines × 2) colossalai/shardformer/modeling/_whisper_tf4.py:350 — colossalai/shardformer/modeling/_whisper_tf4.py:350-354 | colossalai/shardformer/modeling/_whisper_tf4.py:445-449 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (5 lines × 2) colossalai/shardformer/modeling/chatglm2.py:344 — colossalai/shardformer/modeling/chatglm2.py:344-348 | colossalai/shardformer/modeling/chatglm2.py:647-651 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • + 19 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (12 lines × 2) · ×42
  • Duplicated block (12 lines × 2) applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:28 — applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:28-39 | applications/Colossal-LLaMA/dataset/prepare_sft_dataset.py:25-36 — before extracting anything, compare `applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py` and `applications/Colossal-LLaMA/dataset/prepare_sft_dataset.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 116 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `applications/Colossal-LLaMA/dataset/prepare_sft_dataset.py:38` calls `add_argument` and `applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:41` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12 lines × 2) applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:84 — applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:84-95 | applications/Colossal-LLaMA/dataset/prepare_sft_dataset.py:94-105 — before extracting anything, compare `applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py` and `applications/Colossal-LLaMA/dataset/prepare_sft_dataset.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 116 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:84` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) applications/Colossal-LLaMA/train.py:293 — applications/Colossal-LLaMA/train.py:293-304 | applications/ColossalChat/examples/training_scripts/lora_finetune.py:282-293 — before extracting anything, compare `applications/Colossal-LLaMA/train.py` and `applications/ColossalChat/examples/training_scripts/lora_finetune.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 132 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/Colossal-LLaMA/train.py:293` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) applications/ColossalChat/coati/dataset/loader.py:280 — applications/ColossalChat/coati/dataset/loader.py:280-291 | applications/ColossalChat/coati/dataset/loader.py:299-310 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (12 lines × 2) applications/ColossalChat/coati/distributed/launch.py:85 — applications/ColossalChat/coati/distributed/launch.py:85-96 | applications/ColossalChat/coati/distributed/launch_zero_bubble.py:81-92 — before extracting anything, compare `applications/ColossalChat/coati/distributed/launch.py` and `applications/ColossalChat/coati/distributed/launch_zero_bubble.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 70 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `applications/ColossalChat/coati/distributed/launch_zero_bubble.py:95` calls `remote` and `applications/ColossalChat/coati/distributed/launch.py:97` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12 lines × 2) applications/ColossalChat/coati/ray/callbacks/performance_evaluator.py:79 — applications/ColossalChat/coati/ray/callbacks/performance_evaluator.py:79-90 | applications/ColossalChat/coati/trainer/callbacks/performance_evaluator.py:128-139 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (12 lines × 2) applications/ColossalMoE/train.py:243 — applications/ColossalMoE/train.py:243-254 | colossalai/legacy/moe/openmoe/train.py:347-358 — before extracting anything, compare `applications/ColossalMoE/train.py` and `colossalai/legacy/moe/openmoe/train.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 125 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `applications/ColossalMoE/train.py:241` calls `get_global_loss` and `colossalai/legacy/moe/openmoe/train.py:346` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12 lines × 2) colossalai/booster/plugin/hybrid_parallel_plugin.py:1154 — colossalai/booster/plugin/hybrid_parallel_plugin.py:1154-1165 | colossalai/booster/plugin/moe_hybrid_parallel_plugin.py:372-383 — before extracting anything, compare `colossalai/booster/plugin/hybrid_parallel_plugin.py` and `colossalai/booster/plugin/moe_hybrid_parallel_plugin.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 100 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (12 lines × 2) colossalai/fx/tracer/meta_patch/patched_module/pooling.py:10 — colossalai/fx/tracer/meta_patch/patched_module/pooling.py:10-21 | colossalai/fx/tracer/meta_patch/patched_module/pooling.py:89-100 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (12 lines × 2) colossalai/fx/tracer/meta_patch/patched_module/pooling.py:33 — colossalai/fx/tracer/meta_patch/patched_module/pooling.py:33-44 | colossalai/fx/tracer/meta_patch/patched_module/pooling.py:113-124 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (12 lines × 2) colossalai/fx/tracer/meta_patch/patched_module/pooling.py:60 — colossalai/fx/tracer/meta_patch/patched_module/pooling.py:60-71 | colossalai/fx/tracer/meta_patch/patched_module/pooling.py:141-152 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (12 lines × 2) colossalai/inference/core/llm_engine.py:704 — colossalai/inference/core/llm_engine.py:704-715 | colossalai/inference/core/rpc_engine.py:242-253 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/inference/core/llm_engine.py:704` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) colossalai/inference/modeling/backends/attention_backend.py:73 — colossalai/inference/modeling/backends/attention_backend.py:73-84 | colossalai/inference/modeling/backends/attention_backend.py:117-128 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (12 lines × 2) colossalai/kernel/triton/context_attn_unpad.py:174 — colossalai/kernel/triton/context_attn_unpad.py:174-185 | colossalai/kernel/triton/context_attn_unpad.py:538-549 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (12 lines × 2) colossalai/kernel/triton/no_pad_rotary_embedding.py:55 — colossalai/kernel/triton/no_pad_rotary_embedding.py:55-66 | colossalai/kernel/triton/no_pad_rotary_embedding.py:92-103 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/kernel/triton/no_pad_rotary_embedding.py:55` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) colossalai/legacy/nn/layer/parallel_2p5d/layers.py:76 — colossalai/legacy/nn/layer/parallel_2p5d/layers.py:76-87 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:1075-1086 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (12 lines × 2) colossalai/legacy/trainer/_trainer.py:297 — colossalai/legacy/trainer/_trainer.py:297-308 | colossalai/legacy/trainer/_trainer.py:371-382 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/trainer/_trainer.py:297` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/legacy/trainer/_trainer.py:293` calls `isinstance` and `colossalai/legacy/trainer/_trainer.py:369` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12 lines × 2) colossalai/nn/optimizer/adafactor.py:190 — colossalai/nn/optimizer/adafactor.py:190-201 | colossalai/nn/optimizer/distributed_adafactor.py:429-440 — before extracting anything, compare `colossalai/nn/optimizer/adafactor.py` and `colossalai/nn/optimizer/distributed_adafactor.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 46 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (12 lines × 2) colossalai/nn/optimizer/distributed_adafactor.py:46 — colossalai/nn/optimizer/distributed_adafactor.py:46-57 | colossalai/nn/optimizer/distributed_came.py:45-56 — before extracting anything, compare `colossalai/nn/optimizer/distributed_adafactor.py` and `colossalai/nn/optimizer/distributed_came.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 201 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (12 lines × 2) colossalai/nn/optimizer/distributed_adafactor.py:131 — colossalai/nn/optimizer/distributed_adafactor.py:131-142 | colossalai/nn/optimizer/distributed_came.py:125-136 — before extracting anything, compare `colossalai/nn/optimizer/distributed_adafactor.py` and `colossalai/nn/optimizer/distributed_came.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 201 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (12 lines × 2) colossalai/nn/optimizer/distributed_adafactor.py:220 — colossalai/nn/optimizer/distributed_adafactor.py:220-231 | colossalai/nn/optimizer/distributed_came.py:213-224 — before extracting anything, compare `colossalai/nn/optimizer/distributed_adafactor.py` and `colossalai/nn/optimizer/distributed_came.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 201 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (12 lines × 2) colossalai/nn/optimizer/distributed_galore.py:81 — colossalai/nn/optimizer/distributed_galore.py:81-92 | colossalai/nn/optimizer/galore.py:221-232 — before extracting anything, compare `colossalai/nn/optimizer/distributed_galore.py` and `colossalai/nn/optimizer/galore.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 52 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (12 lines × 2) colossalai/shardformer/layer/_operation.py:156 — colossalai/shardformer/layer/_operation.py:156-167 | colossalai/shardformer/layer/_operation.py:327-338 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/layer/_operation.py:156` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (12 lines × 2) colossalai/shardformer/layer/linear.py:529 — colossalai/shardformer/layer/linear.py:529-540 | colossalai/shardformer/layer/qkv_fused_linear.py:1146-1157 — before extracting anything, compare `colossalai/shardformer/layer/linear.py` and `colossalai/shardformer/layer/qkv_fused_linear.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 261 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (12 lines × 2) colossalai/shardformer/layer/linear.py:556 — colossalai/shardformer/layer/linear.py:556-567 | colossalai/shardformer/layer/qkv_fused_linear.py:593-604 — before extracting anything, compare `colossalai/shardformer/layer/linear.py` and `colossalai/shardformer/layer/qkv_fused_linear.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 261 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/layer/linear.py:556` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • + 17 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (10 lines × 2) · ×41
  • Duplicated block (10 lines × 2) .github/scripts/ci/run_gpu_batch.py:64 — .github/scripts/ci/run_gpu_batch.py:64-73 | .github/scripts/e1/pr_gpu.py:42-51 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (10 lines × 2) applications/Colossal-LLaMA/train.py:352 — applications/Colossal-LLaMA/train.py:352-361 | applications/ColossalChat/examples/training_scripts/lora_finetune.py:323-332 — before extracting anything, compare `applications/Colossal-LLaMA/train.py` and `applications/ColossalChat/examples/training_scripts/lora_finetune.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 132 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 2) applications/ColossalChat/coati/distributed/producer.py:61 — applications/ColossalChat/coati/distributed/producer.py:61-70 | applications/ColossalChat/coati/distributed/zero_bubble/producer.py:61-70 — before extracting anything, compare `applications/ColossalChat/coati/distributed/producer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/producer.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 234 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 2) applications/ColossalChat/coati/trainer/grpo.py:235 — applications/ColossalChat/coati/trainer/grpo.py:235-244 | applications/ColossalChat/coati/trainer/ppo.py:225-235 — before extracting anything, compare `applications/ColossalChat/coati/trainer/grpo.py` and `applications/ColossalChat/coati/trainer/ppo.py` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 176 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/trainer/grpo.py:235` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `applications/ColossalChat/coati/trainer/ppo.py:223` calls `train` and `applications/ColossalChat/coati/trainer/grpo.py:232` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 2) REDACTED:547 — REDACTED:547-556 | REDACTED:560-569 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (10 lines × 2) colossalai/_analyzer/_subclasses/flop_tensor.py:120 — colossalai/_analyzer/_subclasses/flop_tensor.py:120-129 | colossalai/_analyzer/_subclasses/flop_tensor.py:137-146 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10 lines × 2) colossalai/auto_parallel/offload/region_manager.py:473 — colossalai/auto_parallel/offload/region_manager.py:473-482 | colossalai/auto_parallel/offload/region_manager.py:491-500 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10 lines × 2) colossalai/auto_parallel/offload/runtime.py:73 — colossalai/auto_parallel/offload/runtime.py:73-82 | colossalai/auto_parallel/offload/runtime.py:100-109 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/batch_norm_handler.py:30 — colossalai/auto_parallel/tensor_shard/node_handler/batch_norm_handler.py:30-39 | colossalai/auto_parallel/tensor_shard/node_handler/layer_norm_handler.py:28-37 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (10 lines × 2) colossalai/booster/plugin/torch_fsdp_plugin.py:139 — colossalai/booster/plugin/torch_fsdp_plugin.py:139-148 | colossalai/booster/plugin/torch_fsdp_plugin.py:303-312 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (10 lines × 2) colossalai/checkpoint_io/utils.py:1074 — colossalai/checkpoint_io/utils.py:1074-1083 | colossalai/interface/model.py:32-41 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (10 lines × 2) colossalai/fx/tracer/experimental.py:275 — colossalai/fx/tracer/experimental.py:275-284 | colossalai/fx/tracer/tracer.py:346-355 — before extracting anything, compare `colossalai/fx/tracer/experimental.py` and `colossalai/fx/tracer/tracer.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 138 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 2) colossalai/legacy/inference/dynamic_batching/ray_dist_init.py:24 — colossalai/legacy/inference/dynamic_batching/ray_dist_init.py:24-33 | colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py:33-42 — before extracting anything, compare `colossalai/legacy/inference/dynamic_batching/ray_dist_init.py` and `colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 42 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 2) colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:974 — colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:974-983 | colossalai/legacy/moe/openmoe/model/openmoe_policy.py:543-552 — before extracting anything, compare `colossalai/legacy/moe/openmoe/model/modeling_openmoe.py` and `colossalai/legacy/moe/openmoe/model/openmoe_policy.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 95 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:974` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (10 lines × 2) colossalai/legacy/nn/layer/parallel_1d/_operation.py:28 — colossalai/legacy/nn/layer/parallel_1d/_operation.py:28-37 | colossalai/shardformer/layer/_operation.py:54-63 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (10 lines × 2) colossalai/legacy/nn/layer/parallel_1d/layers.py:284 — colossalai/legacy/nn/layer/parallel_1d/layers.py:284-293 | colossalai/legacy/nn/layer/parallel_1d/layers.py:697-706 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10 lines × 2) colossalai/legacy/nn/layer/parallel_1d/layers.py:300 — colossalai/legacy/nn/layer/parallel_1d/layers.py:300-309 | colossalai/legacy/nn/layer/parallel_1d/layers.py:713-722 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_1d/layers.py:300` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) colossalai/legacy/nn/layer/parallel_1d/layers.py:421 — colossalai/legacy/nn/layer/parallel_1d/layers.py:421-430 | colossalai/legacy/nn/layer/parallel_1d/layers.py:554-563 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10 lines × 2) colossalai/legacy/nn/layer/parallel_3d/layers.py:466 — colossalai/legacy/nn/layer/parallel_3d/layers.py:466-475 | colossalai/legacy/nn/layer/parallel_3d/layers.py:647-656 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10 lines × 2) colossalai/legacy/nn/loss/loss_1d.py:31 — colossalai/legacy/nn/loss/loss_1d.py:31-40 | examples/language/gpt/titans/model/embed.py:263-272 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (10 lines × 2) colossalai/legacy/pipeline/rpc/_pipeline_base.py:634 — colossalai/legacy/pipeline/rpc/_pipeline_base.py:634-643 | colossalai/legacy/pipeline/rpc/_pipeline_base.py:738-747 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (10 lines × 2) colossalai/nn/optimizer/distributed_adafactor.py:179 — colossalai/nn/optimizer/distributed_adafactor.py:179-188 | colossalai/nn/optimizer/distributed_came.py:172-181 — before extracting anything, compare `colossalai/nn/optimizer/distributed_adafactor.py` and `colossalai/nn/optimizer/distributed_came.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 201 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (10 lines × 2) colossalai/pipeline/schedule/zero_bubble_pp.py:840 — colossalai/pipeline/schedule/zero_bubble_pp.py:840-849 | colossalai/pipeline/schedule/zero_bubble_pp.py:886-895 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10 lines × 2) colossalai/shardformer/layer/linear.py:547 — colossalai/shardformer/layer/linear.py:547-556 | colossalai/shardformer/layer/qkv_fused_linear.py:1164-1173 — before extracting anything, compare `colossalai/shardformer/layer/linear.py` and `colossalai/shardformer/layer/qkv_fused_linear.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 261 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/layer/linear.py:547` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) colossalai/shardformer/modeling/_bert_tf4.py:1284 — colossalai/shardformer/modeling/_bert_tf4.py:1284-1293 | colossalai/shardformer/modeling/_bert_tf5.py:1273-1282 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • + 16 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (13 lines × 2) · ×35
  • Duplicated block (13 lines × 2) applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:109 — applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:109-121 | applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py:242-254 — before extracting anything, compare `applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py` and `applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 70 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:109` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) applications/ColossalChat/coati/distributed/launch.py:136 — applications/ColossalChat/coati/distributed/launch.py:136-148 | applications/ColossalChat/coati/distributed/launch.py:177-189 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/distributed/launch.py:136` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) REDACTED:101 — REDACTED:101-113 | REDACTED:163-175 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 157 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (13 lines × 2) colossalai/_analyzer/_subclasses/flop_tensor.py:345 — colossalai/_analyzer/_subclasses/flop_tensor.py:345-357 | colossalai/fx/profiler/opcount.py:148-160 — before extracting anything, compare `colossalai/_analyzer/_subclasses/flop_tensor.py` and `colossalai/fx/profiler/opcount.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 153 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (13 lines × 2) REDACTED:54 — REDACTED:54-66 | colossalai/fx/profiler/tensor.py:33-45 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:54` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) colossalai/_analyzer/fx/node_util.py:24 — colossalai/_analyzer/fx/node_util.py:24-36 | colossalai/fx/profiler/memory_utils.py:13-25 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (13 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/split_handler.py:50 — colossalai/auto_parallel/tensor_shard/node_handler/split_handler.py:50-62 | colossalai/auto_parallel/tensor_shard/node_handler/sum_handler.py:69-81 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (13 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:589 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:589-601 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:609-621 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:589` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) colossalai/booster/plugin/hybrid_parallel_plugin.py:1327 — colossalai/booster/plugin/hybrid_parallel_plugin.py:1327-1339 | colossalai/booster/plugin/moe_hybrid_parallel_plugin.py:517-529 — before extracting anything, compare `colossalai/booster/plugin/hybrid_parallel_plugin.py` and `colossalai/booster/plugin/moe_hybrid_parallel_plugin.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 100 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/booster/plugin/hybrid_parallel_plugin.py:1327` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (13 lines × 2) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:962 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:962-974 | colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:990-1002 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (13 lines × 2) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:1191 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:1191-1203 | colossalai/checkpoint_io/moe_checkpoint.py:1019-1031 — before extracting anything, compare `colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py` and `colossalai/checkpoint_io/moe_checkpoint.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 249 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (13 lines × 2) colossalai/inference/core/request_handler.py:190 — colossalai/inference/core/request_handler.py:190-202 | colossalai/inference/core/request_handler.py:204-216 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/inference/core/request_handler.py:190` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) colossalai/kernel/triton/context_attn_unpad.py:161 — colossalai/kernel/triton/context_attn_unpad.py:161-173 | colossalai/kernel/triton/context_attn_unpad.py:525-537 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (13 lines × 2) colossalai/legacy/inference/quant/smoothquant/models/llama.py:483 — colossalai/legacy/inference/quant/smoothquant/models/llama.py:483-495 | colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:414-426 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:412` calls `clone`, `detach` and `colossalai/legacy/inference/quant/smoothquant/models/llama.py:482` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (13 lines × 2) colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:115 — colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:115-127 | colossalai/legacy/inference/tensor_parallel/modeling/llama.py:136-148 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (13 lines × 2) colossalai/legacy/moe/openmoe/train.py:169 — colossalai/legacy/moe/openmoe/train.py:169-181 | examples/images/vit/args.py:34-46 — before extracting anything, compare `colossalai/legacy/moe/openmoe/train.py` and `examples/images/vit/args.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 57 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/moe/openmoe/train.py:169` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (13 lines × 2) colossalai/legacy/nn/layer/parallel_2d/_operation.py:401 — colossalai/legacy/nn/layer/parallel_2d/_operation.py:401-413 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:364-376 — `colossalai/legacy/nn/layer/parallel_2d/_operation.py` and `colossalai/legacy/nn/layer/parallel_2p5d/_operation.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 185 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2d/_operation.py:401` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) colossalai/legacy/nn/layer/parallel_2d/layers.py:283 — colossalai/legacy/nn/layer/parallel_2d/layers.py:283-295 | colossalai/legacy/nn/layer/parallel_2d/layers.py:495-507 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2d/layers.py:283` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) colossalai/legacy/nn/layer/parallel_2p5d/layers.py:296 — colossalai/legacy/nn/layer/parallel_2p5d/layers.py:296-308 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:508-520 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2p5d/layers.py:296` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) colossalai/legacy/nn/layer/parallel_3d/layers.py:935 — colossalai/legacy/nn/layer/parallel_3d/layers.py:935-947 | colossalai/legacy/nn/layer/parallel_3d/layers.py:1073-1085 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_3d/layers.py:935` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) colossalai/legacy/nn/loss/loss_2d.py:81 — colossalai/legacy/nn/loss/loss_2d.py:81-93 | colossalai/legacy/nn/loss/loss_2p5d.py:75-87 — before extracting anything, compare `colossalai/legacy/nn/loss/loss_2d.py` and `colossalai/legacy/nn/loss/loss_2p5d.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 39 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (13 lines × 2) colossalai/shardformer/layer/_operation.py:276 — colossalai/shardformer/layer/_operation.py:276-288 | colossalai/shardformer/layer/_operation.py:363-375 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (13 lines × 2) colossalai/shardformer/layer/qkv_fused_linear.py:267 — colossalai/shardformer/layer/qkv_fused_linear.py:267-279 | colossalai/shardformer/layer/qkv_fused_linear.py:484-496 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/layer/qkv_fused_linear.py:481` calls `divide` and `colossalai/shardformer/layer/qkv_fused_linear.py:264` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (13 lines × 2) colossalai/shardformer/modeling/_llama_tf4.py:604 — colossalai/shardformer/modeling/_llama_tf4.py:604-616 | colossalai/shardformer/modeling/_llama_tf5.py:646-658 — before extracting anything, compare `colossalai/shardformer/modeling/_llama_tf4.py` and `colossalai/shardformer/modeling/_llama_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (13 lines × 2) colossalai/shardformer/modeling/gpt2.py:75 — colossalai/shardformer/modeling/gpt2.py:75-87 | colossalai/shardformer/modeling/gptj.py:39-51 — before extracting anything, compare `colossalai/shardformer/modeling/gpt2.py` and `colossalai/shardformer/modeling/gptj.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 321 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • + 10 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (6 lines × 2) · ×35
  • Duplicated block (6 lines × 2) applications/ColossalChat/coati/distributed/grpo_consumer.py:157 — applications/ColossalChat/coati/distributed/grpo_consumer.py:157-162 | applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py:155-160 — before extracting anything, compare `applications/ColossalChat/coati/distributed/grpo_consumer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 407 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/distributed/grpo_consumer.py:157` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) applications/ColossalChat/coati/models/loss.py:264 — applications/ColossalChat/coati/models/loss.py:264-269 | applications/ColossalChat/coati/models/loss.py:272-277 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) applications/ColossalChat/coati/quant/llama_gptq/quant.py:181 — applications/ColossalChat/coati/quant/llama_gptq/quant.py:181-186 | applications/ColossalChat/coati/quant/llama_gptq/quant.py:188-193 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) applications/ColossalChat/coati/quant/llama_gptq/quant.py:217 — applications/ColossalChat/coati/quant/llama_gptq/quant.py:217-222 | applications/ColossalChat/coati/quant/llama_gptq/quant.py:224-229 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) applications/ColossalChat/coati/utils/ckpt_io.py:47 — applications/ColossalChat/coati/utils/ckpt_io.py:47-52 | applications/ColossalMoE/utils.py:44-49 — before extracting anything, compare `applications/ColossalChat/coati/utils/ckpt_io.py` and `applications/ColossalMoE/utils.py` as WHOLE FILES: 93% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 3 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (6 lines × 2) colossalai/autochunk/select_chunk.py:53 — colossalai/autochunk/select_chunk.py:53-58 | colossalai/autochunk/select_chunk.py:152-157 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) colossalai/autochunk/trace_indice.py:351 — colossalai/autochunk/trace_indice.py:351-356 | colossalai/autochunk/trace_indice.py:373-378 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:842 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:842-847 | colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:864-869 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:1178 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:1178-1183 | colossalai/checkpoint_io/moe_checkpoint.py:778-783 — before extracting anything, compare `colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py` and `colossalai/checkpoint_io/moe_checkpoint.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 249 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (6 lines × 2) colossalai/fx/profiler/experimental/profiler_module/convolution.py:21 — colossalai/fx/profiler/experimental/profiler_module/convolution.py:21-26 | colossalai/fx/tracer/meta_patch/patched_module/convolution.py:15-20 — before extracting anything, compare `colossalai/fx/profiler/experimental/profiler_module/convolution.py` and `colossalai/fx/tracer/meta_patch/patched_module/convolution.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 83 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/fx/profiler/experimental/profiler_module/convolution.py:21` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) colossalai/inference/modeling/layers/distrifusion.py:145 — colossalai/inference/modeling/layers/distrifusion.py:145-150 | colossalai/inference/modeling/layers/distrifusion.py:203-208 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (6 lines × 2) colossalai/kernel/triton/fused_rotary_embedding.py:31 — colossalai/kernel/triton/fused_rotary_embedding.py:31-36 | colossalai/kernel/triton/rotary_cache_copy.py:22-27 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/kernel/triton/fused_rotary_embedding.py:31` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) colossalai/legacy/communication/p2p.py:176 — colossalai/legacy/communication/p2p.py:176-181 | colossalai/legacy/communication/p2p.py:183-190 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/communication/p2p.py:176` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) colossalai/legacy/nn/layer/parallel_2d/layers.py:429 — colossalai/legacy/nn/layer/parallel_2d/layers.py:429-434 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:442-447 — `colossalai/legacy/nn/layer/parallel_2d/layers.py` and `colossalai/legacy/nn/layer/parallel_2p5d/layers.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 18 separate duplicated blocks between them, totalling at least 219 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2d/layers.py:429` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) colossalai/legacy/nn/layer/parallel_3d/layers.py:709 — colossalai/legacy/nn/layer/parallel_3d/layers.py:709-714 | colossalai/legacy/nn/layer/vanilla/layers.py:167-172 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_3d/layers.py:709` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) colossalai/legacy/nn/layer/parallel_3d/layers.py:838 — colossalai/legacy/nn/layer/parallel_3d/layers.py:838-843 | colossalai/legacy/nn/layer/vanilla/layers.py:204-209 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (6 lines × 2) colossalai/legacy/nn/parallel/layers/cache_embedding/parallel_cached_embedding_tablewise.py:139 — colossalai/legacy/nn/parallel/layers/cache_embedding/parallel_cached_embedding_tablewise.py:139-144 | colossalai/legacy/nn/parallel/layers/cache_embedding/parallel_cached_embedding_tablewise_split_cache.py:128-133 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/parallel/layers/cache_embedding/parallel_cached_embedding_tablewise.py:139` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (6 lines × 2) colossalai/nn/optimizer/came.py:126 — colossalai/nn/optimizer/came.py:126-133 | colossalai/nn/optimizer/distributed_came.py:505-510 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (6 lines × 2) colossalai/nn/optimizer/galore.py:82 — colossalai/nn/optimizer/galore.py:82-87 | colossalai/nn/optimizer/galore.py:93-99 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) colossalai/pipeline/schedule/zero_bubble_pp.py:563 — colossalai/pipeline/schedule/zero_bubble_pp.py:563-568 | colossalai/pipeline/schedule/zero_bubble_pp.py:624-629 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) colossalai/shardformer/layer/attn.py:1087 — colossalai/shardformer/layer/attn.py:1087-1092 | colossalai/shardformer/layer/attn.py:1139-1144 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (6 lines × 2) colossalai/shardformer/layer/linear.py:260 — colossalai/shardformer/layer/linear.py:260-266 | colossalai/shardformer/layer/qkv_fused_linear.py:494-499 — before extracting anything, compare `colossalai/shardformer/layer/linear.py` and `colossalai/shardformer/layer/qkv_fused_linear.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 261 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/layer/linear.py:260` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/shardformer/layer/qkv_fused_linear.py:503` calls `chunk_weight` and `colossalai/shardformer/layer/linear.py:268` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 2) colossalai/shardformer/layer/loss.py:63 — colossalai/shardformer/layer/loss.py:63-68 | colossalai/shardformer/layer/loss.py:169-177 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) applications/ColossalChat/coati/ray/callbacks/performance_evaluator.py:24 — applications/ColossalChat/coati/ray/callbacks/performance_evaluator.py:24-29 | applications/ColossalChat/coati/trainer/callbacks/performance_evaluator.py:34-39 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (6 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/addmm_handler.py:65 — colossalai/auto_parallel/tensor_shard/node_handler/addmm_handler.py:65-70 | colossalai/auto_parallel/tensor_shard/node_handler/linear_handler.py:230-235 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • + 10 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (9 lines × 2) · ×34
  • Duplicated block (9 lines × 2) applications/ColossalChat/coati/distributed/grpo_consumer.py:537 — applications/ColossalChat/coati/distributed/grpo_consumer.py:537-545 | applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py:458-466 — before extracting anything, compare `applications/ColossalChat/coati/distributed/grpo_consumer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 407 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py:468` calls `step` and `applications/ColossalChat/coati/distributed/grpo_consumer.py:547` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 2) applications/ColossalChat/coati/distributed/producer.py:242 — applications/ColossalChat/coati/distributed/producer.py:242-250 | applications/ColossalChat/coati/distributed/zero_bubble/producer.py:213-221 — before extracting anything, compare `applications/ColossalChat/coati/distributed/producer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/producer.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 234 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `applications/ColossalChat/coati/distributed/zero_bubble/producer.py:222` calls `REDACTED` and `applications/ColossalChat/coati/distributed/producer.py:251` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 2) applications/ColossalChat/coati/distributed/producer.py:407 — applications/ColossalChat/coati/distributed/producer.py:407-415 | applications/ColossalChat/coati/distributed/zero_bubble/producer.py:431-439 — before extracting anything, compare `applications/ColossalChat/coati/distributed/producer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/producer.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 234 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: `BACKEND_MAP` names `.inference_backend` in one and `coati.distributed.inference_backend` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (9 lines × 2) applications/ColossalChat/coati/trainer/dpo.py:325 — applications/ColossalChat/coati/trainer/dpo.py:325-333 | applications/ColossalChat/coati/trainer/dpo.py:602-610 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (9 lines × 2) applications/ColossalChat/coati/trainer/orpo.py:173 — applications/ColossalChat/coati/trainer/orpo.py:173-181 | applications/ColossalChat/coati/trainer/orpo.py:309-317 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (9 lines × 2) colossalai/_analyzer/fx/tracer/tracer.py:114 — colossalai/_analyzer/fx/tracer/tracer.py:114-122 | colossalai/fx/tracer/experimental.py:211-219 — before extracting anything, compare `colossalai/_analyzer/fx/tracer/tracer.py` and `colossalai/fx/tracer/experimental.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 93 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (9 lines × 2) colossalai/_analyzer/fx/tracer/tracer.py:136 — colossalai/_analyzer/fx/tracer/tracer.py:136-144 | colossalai/fx/tracer/experimental.py:233-241 — before extracting anything, compare `colossalai/_analyzer/fx/tracer/tracer.py` and `colossalai/fx/tracer/experimental.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 93 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (9 lines × 2) colossalai/auto_parallel/offload/runtime.py:177 — colossalai/auto_parallel/offload/runtime.py:177-185 | colossalai/auto_parallel/offload/runtime.py:224-232 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (9 lines × 2) colossalai/cli/check/check_installation.py:66 — colossalai/cli/check/check_installation.py:66-74 | colossalai/cli/check/check_installation.py:77-85 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/cli/check/check_installation.py:65` calls `echo` and `colossalai/cli/check/check_installation.py:76` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 2) colossalai/fx/tracer/experimental.py:577 — colossalai/fx/tracer/experimental.py:577-585 | colossalai/fx/tracer/tracer.py:298-306 — before extracting anything, compare `colossalai/fx/tracer/experimental.py` and `colossalai/fx/tracer/tracer.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 138 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (9 lines × 2) colossalai/inference/core/request_handler.py:152 — colossalai/inference/core/request_handler.py:152-160 | colossalai/inference/core/request_handler.py:411-419 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (9 lines × 2) colossalai/kernel/triton/context_attn_unpad.py:573 — colossalai/kernel/triton/context_attn_unpad.py:573-581 | colossalai/kernel/triton/kvcache_copy.py:229-238 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (9 lines × 2) colossalai/kernel/triton/flash_decoding.py:460 — colossalai/kernel/triton/flash_decoding.py:460-468 | colossalai/kernel/triton/no_pad_rotary_embedding.py:612-620 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (9 lines × 2) colossalai/legacy/inference/dynamic_batching/infer_batch.py:137 — colossalai/legacy/inference/dynamic_batching/infer_batch.py:137-145 | colossalai/legacy/inference/dynamic_batching/infer_batch.py:176-184 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (9 lines × 2) colossalai/legacy/inference/hybridengine/polices/llama.py:50 — colossalai/legacy/inference/hybridengine/polices/llama.py:50-58 | colossalai/legacy/inference/tensor_parallel/policies/llama.py:42-50 — before extracting anything, compare `colossalai/legacy/inference/hybridengine/polices/llama.py` and `colossalai/legacy/inference/tensor_parallel/policies/llama.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 37 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/inference/hybridengine/polices/llama.py:50` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) colossalai/legacy/inference/quant/smoothquant/models/llama.py:472 — colossalai/legacy/inference/quant/smoothquant/models/llama.py:472-480 | colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:400-408 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/inference/quant/smoothquant/models/llama.py:472` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) colossalai/legacy/moe/layer/experts.py:94 — colossalai/legacy/moe/layer/experts.py:94-102 | colossalai/legacy/moe/layer/routers.py:94-102 — before extracting anything, compare `colossalai/legacy/moe/layer/experts.py` and `colossalai/legacy/moe/layer/routers.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 90 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (9 lines × 2) colossalai/legacy/pipeline/rpc/_pipeline_base.py:429 — colossalai/legacy/pipeline/rpc/_pipeline_base.py:429-437 | colossalai/legacy/pipeline/rpc/_pipeline_base.py:481-490 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/pipeline/rpc/_pipeline_base.py:429` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) colossalai/legacy/trainer/hooks/_metric_hook.py:346 — colossalai/legacy/trainer/hooks/_metric_hook.py:346-354 | colossalai/legacy/trainer/hooks/_metric_hook.py:358-366 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (9 lines × 2) colossalai/nn/lr_scheduler/delayed.py:122 — colossalai/nn/lr_scheduler/delayed.py:122-130 | colossalai/nn/lr_scheduler/delayed.py:171-179 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (9 lines × 2) colossalai/shardformer/modeling/_mixtral_tf4.py:314 — colossalai/shardformer/modeling/_mixtral_tf4.py:314-322 | colossalai/shardformer/modeling/_mixtral_tf5.py:662-670 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 581 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (9 lines × 2) colossalai/shardformer/modeling/blip2.py:107 — colossalai/shardformer/modeling/blip2.py:107-115 | colossalai/shardformer/modeling/blip2.py:123-131 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/blip2.py:107` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `self` to `Blip2QFormerSelfOutput` in one and `Blip2QFormerOutput` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (9 lines × 2) colossalai/shardformer/policies/bloom.py:319 — colossalai/shardformer/policies/bloom.py:319-327 | colossalai/shardformer/policies/falcon.py:257-265 — before extracting anything, compare `colossalai/shardformer/policies/bloom.py` and `colossalai/shardformer/policies/falcon.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 132 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (9 lines × 2) colossalai/shardformer/policies/falcon.py:384 — colossalai/shardformer/policies/falcon.py:384-392 | colossalai/shardformer/policies/falcon.py:515-524 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/policies/falcon.py:384` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (9 lines × 2) colossalai/shardformer/policies/gpt2.py:612 — colossalai/shardformer/policies/gpt2.py:612-620 | colossalai/shardformer/policies/t5.py:837-845 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • + 9 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (11 lines × 2) · ×32
  • Duplicated block (11 lines × 2) applications/ColossalMoE/train.py:215 — applications/ColossalMoE/train.py:215-225 | colossalai/legacy/moe/openmoe/train.py:321-331 — before extracting anything, compare `applications/ColossalMoE/train.py` and `colossalai/legacy/moe/openmoe/train.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 125 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalMoE/train.py:215` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `applications/ColossalMoE/train.py:210` calls `print_on_master`, `load_checkpoint` and `colossalai/legacy/moe/openmoe/train.py:320` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11 lines × 2) colossalai/auto_parallel/tensor_shard/utils/reshape.py:98 — colossalai/auto_parallel/tensor_shard/utils/reshape.py:98-108 | colossalai/auto_parallel/tensor_shard/utils/reshape.py:118-128 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11 lines × 2) colossalai/booster/plugin/hybrid_parallel_plugin.py:1473 — colossalai/booster/plugin/hybrid_parallel_plugin.py:1473-1483 | colossalai/booster/plugin/low_level_zero_plugin.py:503-513 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (11 lines × 2) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:477 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:477-487 | colossalai/inference/core/plugin.py:95-105 — before extracting anything, compare `colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py` and `colossalai/inference/core/plugin.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 60 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:490` calls `update_master_params` and `colossalai/inference/core/plugin.py:107` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11 lines × 2) colossalai/fx/profiler/experimental/profiler_module/convolution.py:49 — colossalai/fx/profiler/experimental/profiler_module/convolution.py:49-59 | colossalai/fx/profiler/experimental/profiler_module/convolution.py:79-89 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/fx/profiler/experimental/profiler_module/convolution.py:49` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note first that the copies are not typed on the same thing: the declarations holding them bind `self` to `torch.nn.Conv2d` in one and `torch.nn.Conv3d` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (11 lines × 2) colossalai/fx/profiler/experimental/profiler_module/convolution.py:98 — colossalai/fx/profiler/experimental/profiler_module/convolution.py:98-108 | colossalai/fx/tracer/meta_patch/patched_module/convolution.py:74-84 — before extracting anything, compare `colossalai/fx/profiler/experimental/profiler_module/convolution.py` and `colossalai/fx/tracer/meta_patch/patched_module/convolution.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 83 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (11 lines × 2) colossalai/inference/core/llm_engine.py:672 — colossalai/inference/core/llm_engine.py:672-682 | colossalai/inference/core/rpc_engine.py:214-224 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (11 lines × 2) colossalai/inference/kv_cache/kvcache_manager.py:189 — colossalai/inference/kv_cache/kvcache_manager.py:189-199 | colossalai/inference/kv_cache/kvcache_manager.py:242-252 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/inference/kv_cache/kvcache_manager.py:240` calls `size` and `colossalai/inference/kv_cache/kvcache_manager.py:186` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11 lines × 2) colossalai/legacy/inference/hybridengine/modeling/llama.py:267 — colossalai/legacy/inference/hybridengine/modeling/llama.py:267-277 | colossalai/legacy/inference/tensor_parallel/modeling/llama.py:181-191 — before extracting anything, compare `colossalai/legacy/inference/hybridengine/modeling/llama.py` and `colossalai/legacy/inference/tensor_parallel/modeling/llama.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 250 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/inference/hybridengine/modeling/llama.py:267` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) colossalai/legacy/nn/layer/parallel_1d/_utils.py:45 — colossalai/legacy/nn/layer/parallel_1d/_utils.py:45-55 | colossalai/shardformer/layer/_operation.py:1197-1207 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_1d/_utils.py:45` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (11 lines × 2) colossalai/legacy/nn/layer/parallel_2p5d/layers.py:310 — colossalai/legacy/nn/layer/parallel_2p5d/layers.py:310-320 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:1142-1152 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2p5d/layers.py:310` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) colossalai/legacy/nn/layer/parallel_3d/layers.py:278 — colossalai/legacy/nn/layer/parallel_3d/layers.py:278-288 | colossalai/legacy/nn/layer/parallel_3d/layers.py:610-620 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_3d/layers.py:278` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) colossalai/nn/optimizer/distributed_adafactor.py:343 — colossalai/nn/optimizer/distributed_adafactor.py:343-353 | colossalai/nn/optimizer/distributed_came.py:384-394 — before extracting anything, compare `colossalai/nn/optimizer/distributed_adafactor.py` and `colossalai/nn/optimizer/distributed_came.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 201 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/nn/optimizer/distributed_adafactor.py:343` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) colossalai/nn/optimizer/distributed_came.py:261 — colossalai/nn/optimizer/distributed_came.py:261-271 | colossalai/nn/optimizer/distributed_came.py:314-324 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11 lines × 2) colossalai/pipeline/schedule/interleaved_pp.py:115 — colossalai/pipeline/schedule/interleaved_pp.py:115-125 | colossalai/pipeline/schedule/zero_bubble_pp.py:207-217 — before extracting anything, compare `colossalai/pipeline/schedule/interleaved_pp.py` and `colossalai/pipeline/schedule/zero_bubble_pp.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 82 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (11 lines × 2) colossalai/pipeline/schedule/v_schedule.py:213 — colossalai/pipeline/schedule/v_schedule.py:213-223 | colossalai/pipeline/schedule/v_schedule.py:258-268 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11 lines × 2) colossalai/shardformer/layer/attn.py:854 — colossalai/shardformer/layer/attn.py:854-864 | colossalai/shardformer/layer/attn.py:870-880 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11 lines × 2) colossalai/shardformer/modeling/chatglm2.py:587 — colossalai/shardformer/modeling/chatglm2.py:587-597 | colossalai/shardformer/modeling/chatglm2.py:602-612 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/chatglm2.py:587` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) colossalai/shardformer/policies/_whisper_tf4.py:769 — colossalai/shardformer/policies/_whisper_tf4.py:769-779 | colossalai/shardformer/policies/_whisper_tf5.py:756-766 — before extracting anything, compare `colossalai/shardformer/policies/_whisper_tf4.py` and `colossalai/shardformer/policies/_whisper_tf5.py` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (11 lines × 2) extensions/cpp_extension.py:98 — extensions/cpp_extension.py:98-108 | extensions/cuda_extension.py:103-113 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `extensions/cpp_extension.py:98` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `extensions/cuda_extension.py:102` calls `nvcc_flags` and `extensions/cpp_extension.py:97` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11 lines × 2) colossalai/_analyzer/_subclasses/flop_tensor.py:277 — colossalai/_analyzer/_subclasses/flop_tensor.py:277-287 | colossalai/fx/profiler/opcount.py:67-77 — before extracting anything, compare `colossalai/_analyzer/_subclasses/flop_tensor.py` and `colossalai/fx/profiler/opcount.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 153 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (11 lines × 2) colossalai/_analyzer/_subclasses/flop_tensor.py:291 — colossalai/_analyzer/_subclasses/flop_tensor.py:291-301 | colossalai/fx/profiler/opcount.py:81-91 — before extracting anything, compare `colossalai/_analyzer/_subclasses/flop_tensor.py` and `colossalai/fx/profiler/opcount.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 153 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (11 lines × 2) colossalai/shardformer/policies/_bert_tf4.py:544 — colossalai/shardformer/policies/_bert_tf4.py:544-554 | colossalai/shardformer/policies/_bert_tf5.py:551-561 — before extracting anything, compare `colossalai/shardformer/policies/_bert_tf4.py` and `colossalai/shardformer/policies/_bert_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 475 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (11 lines × 2) colossalai/shardformer/policies/_bert_tf4.py:728 — colossalai/shardformer/policies/_bert_tf4.py:728-738 | colossalai/shardformer/policies/_bert_tf5.py:735-745 — before extracting anything, compare `colossalai/shardformer/policies/_bert_tf4.py` and `colossalai/shardformer/policies/_bert_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 475 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (11 lines × 2) colossalai/shardformer/policies/_bert_tf4.py:801 — colossalai/shardformer/policies/_bert_tf4.py:801-811 | colossalai/shardformer/policies/_bert_tf5.py:808-818 — before extracting anything, compare `colossalai/shardformer/policies/_bert_tf4.py` and `colossalai/shardformer/policies/_bert_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 475 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • + 7 more in this group — see findings.md.
X3 · Exception handling · Swallowed exception (caught, then discarded) · ×32
  • Swallowed exception (caught, then discarded) extensions/cuda_extension.py:34 — `except` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) extensions/triton_extension.py:16 — `except` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) extensions/pybind/flash_attention/__init__.py:10 — `except` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) extensions/pybind/flash_attention/flash_attention_dao_cuda.py:17 — `except` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) extensions/pybind/flash_attention/flash_attention_npu.py:15 — `except` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) extensions/pybind/flash_attention/flash_attention_sdpa_cuda.py:14 — `except` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) colossalai/_compat.py:162 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) colossalai/shardformer/layer/_operation.py:19 — `except` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) colossalai/quantization/fp8.py:20 — `except` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) colossalai/legacy/utils/common.py:22 — `except` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) colossalai/legacy/nn/layer/parallel_1d/_operation.py:8 — `except` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:50 — `except` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:28 — `except` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) colossalai/legacy/amp/naive_amp/_fp16_optimizer.py:21 — `except` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) colossalai/inference/utils.py:183 — `except` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) colossalai/inference/utils.py:191 — `except` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) colossalai/inference/core/request_handler.py:326 — `except` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) colossalai/fx/graph_module.py:17 — `except` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) colossalai/fx/codegen/activation_checkpoint_codegen.py:23 — `except` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) colossalai/cli/check/check_installation.py:145 — `except` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) colossalai/cli/check/check_installation.py:185 — `except` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) colossalai/cli/check/check_installation.py:211 — `except` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) colossalai/auto_parallel/offload/solver.py:8 — `except` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) colossalai/_analyzer/fx/tracer/symbolic_trace.py:13 — `except` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) applications/ColossalEval/colossal_eval/evaluate/gpt_evaluate.py:104 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • + 7 more in this group — see findings.md.
D3 · God Classes · FileTooLong · ×30
  • FileTooLong: rpc/_pipeline_base.py colossalai/legacy/pipeline/rpc/_pipeline_base.py — FileTooLong — 1067 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 567 over it, 2.13× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: chatglm2_6b/modeling_chatglm.py colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py — FileTooLong — 945 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 445 over it, 1.89× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: checkpoint_io/hybrid_parallel_checkpoint_io.py colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py — FileTooLong — 854 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 354 over it, 1.71× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: layer/attn.py colossalai/shardformer/layer/attn.py — FileTooLong — 806 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 306 over it, 1.61× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: modeling/_mixtral_tf5.py colossalai/shardformer/modeling/_mixtral_tf5.py — FileTooLong — 781 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 281 over it, 1.56× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: checkpoint_io/moe_checkpoint.py colossalai/checkpoint_io/moe_checkpoint.py — FileTooLong — 734 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 234 over it, 1.47× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: low_level/low_level_optim.py colossalai/zero/low_level/low_level_optim.py — FileTooLong — 679 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 179 over it, 1.36× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: strategy/matmul_strategy_generator.py colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py — FileTooLong — 676 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 176 over it, 1.35× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: modeling/_mixtral_tf4.py colossalai/shardformer/modeling/_mixtral_tf4.py — FileTooLong — 661 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 161 over it, 1.32× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: plugin/hybrid_parallel_plugin.py colossalai/booster/plugin/hybrid_parallel_plugin.py — FileTooLong — 658 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 158 over it, 1.32× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: modeling/deepseek.py colossalai/shardformer/modeling/deepseek.py — FileTooLong — 632 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 132 over it, 1.26× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: models/llama.py colossalai/legacy/inference/quant/smoothquant/models/llama.py — FileTooLong — 626 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 126 over it, 1.25× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: modeling/_whisper_tf4.py colossalai/shardformer/modeling/_whisper_tf4.py — FileTooLong — 617 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 117 over it, 1.23× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: policies/t5.py colossalai/shardformer/policies/t5.py — FileTooLong — 607 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 107 over it, 1.21× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: gemini/gemini_optimizer.py colossalai/zero/gemini/gemini_optimizer.py — FileTooLong — 593 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 93 over it, 1.19× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: triton/context_attn_unpad.py colossalai/kernel/triton/context_attn_unpad.py — FileTooLong — 576 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 76 over it, 1.15× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: policies/_bert_tf4.py colossalai/shardformer/policies/_bert_tf4.py — FileTooLong — 566 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 66 over it, 1.13× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: policies/_bert_tf5.py colossalai/shardformer/policies/_bert_tf5.py — FileTooLong — 566 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 66 over it, 1.13× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: model/modeling_openmoe.py colossalai/legacy/moe/openmoe/model/modeling_openmoe.py — FileTooLong — 562 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 62 over it, 1.12× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: schedule/_pipeline_schedule.py colossalai/legacy/engine/schedule/_pipeline_schedule.py — FileTooLong — 555 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 55 over it, 1.11× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: modeling/_whisper_tf5.py colossalai/shardformer/modeling/_whisper_tf5.py — FileTooLong — 553 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 53 over it, 1.11× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: modeling/chatglm2.py colossalai/shardformer/modeling/chatglm2.py — FileTooLong — 548 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 48 over it, 1.10× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: autochunk/trace_indice.py colossalai/autochunk/trace_indice.py — FileTooLong — 546 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 46 over it, 1.09× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: REDACTED REDACTED — FileTooLong — 539 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 39 over it, 1.08× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: REDACTED REDACTED — FileTooLong — 526 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 26 over it, 1.05× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • + 5 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (7 lines × 2) · ×29
  • Duplicated block (7 lines × 2) applications/Colossal-LLaMA/colossal_llama/utils/utils.py:12 — applications/Colossal-LLaMA/colossal_llama/utils/utils.py:12-18 | applications/ColossalChat/coati/trainer/utils.py:122-128 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (7 lines × 2) applications/Colossal-LLaMA/train.py:285 — applications/Colossal-LLaMA/train.py:285-291 | applications/ColossalChat/examples/training_scripts/lora_finetune.py:274-280 — before extracting anything, compare `applications/Colossal-LLaMA/train.py` and `applications/ColossalChat/examples/training_scripts/lora_finetune.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 132 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/Colossal-LLaMA/train.py:285` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) applications/ColossalChat/coati/dataset/tokenization_utils.py:273 — applications/ColossalChat/coati/dataset/tokenization_utils.py:273-279 | applications/ColossalChat/coati/dataset/tokenization_utils.py:281-287 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) applications/ColossalChat/coati/distributed/grpo_consumer.py:547 — applications/ColossalChat/coati/distributed/grpo_consumer.py:547-553 | applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py:470-476 — before extracting anything, compare `applications/ColossalChat/coati/distributed/grpo_consumer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 407 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py:468` calls `step` and `applications/ColossalChat/coati/distributed/grpo_consumer.py:545` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 2) colossalai/_analyzer/fx/tracer/tracer.py:272 — colossalai/_analyzer/fx/tracer/tracer.py:272-278 | colossalai/fx/tracer/experimental.py:435-441 — before extracting anything, compare `colossalai/_analyzer/fx/tracer/tracer.py` and `colossalai/fx/tracer/experimental.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 93 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 2) colossalai/auto_parallel/meta_profiler/meta_registry/norm.py:100 — colossalai/auto_parallel/meta_profiler/meta_registry/norm.py:100-106 | colossalai/auto_parallel/meta_profiler/meta_registry/norm.py:159-165 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/meta_profiler/meta_registry/norm.py:100` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) colossalai/auto_parallel/offload/region_manager.py:334 — colossalai/auto_parallel/offload/region_manager.py:334-340 | colossalai/auto_parallel/offload/region_manager.py:366-372 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) colossalai/booster/plugin/gemini_plugin.py:84 — colossalai/booster/plugin/gemini_plugin.py:84-90 | colossalai/booster/plugin/torch_fsdp_plugin.py:102-108 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (7 lines × 2) colossalai/fx/codegen/activation_checkpoint_codegen.py:325 — colossalai/fx/codegen/activation_checkpoint_codegen.py:325-331 | colossalai/fx/codegen/activation_checkpoint_codegen.py:387-393 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) colossalai/fx/profiler/experimental/profiler_module/convolution.py:76 — colossalai/fx/profiler/experimental/profiler_module/convolution.py:76-82 | colossalai/fx/tracer/meta_patch/patched_module/convolution.py:58-64 — before extracting anything, compare `colossalai/fx/profiler/experimental/profiler_module/convolution.py` and `colossalai/fx/tracer/meta_patch/patched_module/convolution.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 83 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/fx/profiler/experimental/profiler_module/convolution.py:76` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) colossalai/fx/tracer/meta_patch/patched_function/convolution.py:91 — colossalai/fx/tracer/meta_patch/patched_function/convolution.py:91-97 | colossalai/fx/tracer/meta_patch/patched_function/convolution.py:163-170 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/fx/tracer/meta_patch/patched_function/convolution.py:163` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (7 lines × 2) colossalai/fx/tracer/meta_patch/patched_module/pooling.py:184 — colossalai/fx/tracer/meta_patch/patched_module/pooling.py:184-190 | colossalai/fx/tracer/meta_patch/patched_module/pooling.py:196-202 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (7 lines × 2) colossalai/legacy/inference/hybridengine/modeling/llama.py:49 — colossalai/legacy/inference/hybridengine/modeling/llama.py:49-55 | colossalai/legacy/inference/tensor_parallel/modeling/llama.py:44-50 — before extracting anything, compare `colossalai/legacy/inference/hybridengine/modeling/llama.py` and `colossalai/legacy/inference/tensor_parallel/modeling/llama.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 250 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (7 lines × 2) colossalai/legacy/nn/layer/parallel_1d/_operation.py:41 — colossalai/legacy/nn/layer/parallel_1d/_operation.py:41-47 | colossalai/shardformer/layer/_operation.py:67-73 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (7 lines × 2) colossalai/legacy/nn/layer/parallel_2d/layers.py:262 — colossalai/legacy/nn/layer/parallel_2d/layers.py:262-268 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:275-281 — `colossalai/legacy/nn/layer/parallel_2d/layers.py` and `colossalai/legacy/nn/layer/parallel_2p5d/layers.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 18 separate duplicated blocks between them, totalling at least 219 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (7 lines × 2) colossalai/legacy/nn/layer/parallel_2p5d/layers.py:174 — colossalai/legacy/nn/layer/parallel_2p5d/layers.py:174-180 | colossalai/legacy/nn/layer/parallel_3d/layers.py:319-325 — `colossalai/legacy/nn/layer/parallel_2p5d/layers.py` and `colossalai/legacy/nn/layer/parallel_3d/layers.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 7 separate duplicated blocks between them, totalling at least 87 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2p5d/layers.py:174` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) colossalai/legacy/nn/layer/parallel_2p5d/layers.py:904 — colossalai/legacy/nn/layer/parallel_2p5d/layers.py:904-910 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:1069-1078 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) colossalai/legacy/nn/layer/parallel_3d/_operation.py:47 — colossalai/legacy/nn/layer/parallel_3d/_operation.py:47-53 | colossalai/legacy/nn/layer/parallel_3d/_operation.py:225-231 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_3d/_operation.py:47` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) colossalai/nn/optimizer/distributed_adafactor.py:378 — colossalai/nn/optimizer/distributed_adafactor.py:378-384 | colossalai/nn/optimizer/distributed_came.py:436-442 — before extracting anything, compare `colossalai/nn/optimizer/distributed_adafactor.py` and `colossalai/nn/optimizer/distributed_came.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 201 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 2) colossalai/shardformer/modeling/_mixtral_tf4.py:146 — colossalai/shardformer/modeling/_mixtral_tf4.py:146-152 | colossalai/shardformer/modeling/deepseek.py:177-183 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/deepseek.py` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 427 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_mixtral_tf4.py:146` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (7 lines × 2) colossalai/tensor/shape_consistency.py:357 — colossalai/tensor/shape_consistency.py:357-363 | colossalai/tensor/shape_consistency.py:364-370 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (7 lines × 2) colossalai/zero/low_level/low_level_optim.py:792 — colossalai/zero/low_level/low_level_optim.py:792-798 | colossalai/zero/low_level/low_level_optim.py:884-890 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) colossalai/legacy/nn/layer/parallel_sequence/layers.py:253 — colossalai/legacy/nn/layer/parallel_sequence/layers.py:253-259 | examples/tutorial/sequence_parallel/model/layers/linear.py:52-58 — before extracting anything, compare `colossalai/legacy/nn/layer/parallel_sequence/layers.py` and `examples/tutorial/sequence_parallel/model/layers/linear.py` as WHOLE FILES: 88% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (7 lines × 2) colossalai/shardformer/policies/_qwen3_tf4.py:383 — colossalai/shardformer/policies/_qwen3_tf4.py:383-389 | colossalai/shardformer/policies/_qwen3_tf5.py:403-409 — before extracting anything, compare `colossalai/shardformer/policies/_qwen3_tf4.py` and `colossalai/shardformer/policies/_qwen3_tf5.py` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 345 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (7 lines × 2) colossalai/shardformer/policies/_vit_tf4.py:300 — colossalai/shardformer/policies/_vit_tf4.py:300-306 | colossalai/shardformer/policies/_vit_tf5.py:150-156 — before extracting anything, compare `colossalai/shardformer/policies/_vit_tf4.py` and `colossalai/shardformer/policies/_vit_tf5.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 133 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • + 4 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (14 lines × 2) · ×28
  • Duplicated block (14 lines × 2) applications/ColossalChat/coati/distributed/grpo_consumer.py:144 — applications/ColossalChat/coati/distributed/grpo_consumer.py:144-157 | applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py:135-148 — before extracting anything, compare `applications/ColossalChat/coati/distributed/grpo_consumer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 407 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (14 lines × 2) applications/ColossalEval/colossal_eval/dataset/safetybench_en.py:39 — applications/ColossalEval/colossal_eval/dataset/safetybench_en.py:39-52 | applications/ColossalEval/colossal_eval/dataset/safetybench_zh.py:39-52 — before extracting anything, compare `applications/ColossalEval/colossal_eval/dataset/safetybench_en.py` and `applications/ColossalEval/colossal_eval/dataset/safetybench_zh.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 86 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (14 lines × 2) colossalai/_analyzer/_subclasses/_meta_registration.py:39 — colossalai/_analyzer/_subclasses/_meta_registration.py:39-52 | colossalai/fx/_meta_regist_12.py:19-32 — before extracting anything, compare `colossalai/_analyzer/_subclasses/_meta_registration.py` and `colossalai/fx/_meta_regist_12.py` as WHOLE FILES: 83% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/_analyzer/_subclasses/_meta_registration.py:55` calls `parse` and `colossalai/fx/_meta_regist_12.py:37` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 2) colossalai/_analyzer/_subclasses/flop_tensor.py:260 — colossalai/_analyzer/_subclasses/flop_tensor.py:260-273 | colossalai/fx/profiler/opcount.py:50-63 — before extracting anything, compare `colossalai/_analyzer/_subclasses/flop_tensor.py` and `colossalai/fx/profiler/opcount.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 153 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (14 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:681 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:681-694 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:829-842 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (14 lines × 2) colossalai/booster/plugin/hybrid_parallel_plugin.py:710 — colossalai/booster/plugin/hybrid_parallel_plugin.py:710-723 | colossalai/booster/plugin/moe_hybrid_parallel_plugin.py:79-92 — before extracting anything, compare `colossalai/booster/plugin/hybrid_parallel_plugin.py` and `colossalai/booster/plugin/moe_hybrid_parallel_plugin.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 100 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/booster/plugin/hybrid_parallel_plugin.py:710` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) colossalai/booster/plugin/low_level_zero_plugin.py:266 — colossalai/booster/plugin/low_level_zero_plugin.py:266-279 | colossalai/checkpoint_io/general_checkpoint_io.py:85-98 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (14 lines × 2) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:393 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:393-406 | colossalai/checkpoint_io/moe_checkpoint.py:275-288 — before extracting anything, compare `colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py` and `colossalai/checkpoint_io/moe_checkpoint.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 249 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: `CheckpointIndexFile` names `.index_file` in one and `colossalai.checkpoint_io` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (14 lines × 2) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:501 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:501-514 | colossalai/inference/core/plugin.py:116-129 — before extracting anything, compare `colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py` and `colossalai/inference/core/plugin.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 60 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (14 lines × 2) colossalai/fx/tracer/experimental.py:266 — colossalai/fx/tracer/experimental.py:266-279 | colossalai/fx/tracer/experimental.py:474-487 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (14 lines × 2) colossalai/inference/modeling/layers/distrifusion.py:452 — colossalai/inference/modeling/layers/distrifusion.py:452-465 | colossalai/inference/modeling/layers/distrifusion.py:608-621 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (14 lines × 2) colossalai/kernel/triton/flash_decoding.py:481 — colossalai/kernel/triton/flash_decoding.py:481-494 | colossalai/kernel/triton/kvcache_copy.py:186-199 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (14 lines × 2) colossalai/legacy/engine/schedule/_pipeline_schedule.py:55 — colossalai/legacy/engine/schedule/_pipeline_schedule.py:55-68 | colossalai/legacy/engine/schedule/_pipeline_schedule_v2.py:20-33 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (14 lines × 2) colossalai/legacy/inference/quant/smoothquant/models/llama.py:529 — colossalai/legacy/inference/quant/smoothquant/models/llama.py:529-542 | colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:44-57 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/inference/quant/smoothquant/models/llama.py:529` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:958 — colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:958-971 | colossalai/legacy/moe/openmoe/model/openmoe_policy.py:527-540 — before extracting anything, compare `colossalai/legacy/moe/openmoe/model/modeling_openmoe.py` and `colossalai/legacy/moe/openmoe/model/openmoe_policy.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 95 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (14 lines × 2) colossalai/legacy/nn/layer/parallel_2d/layers.py:686 — colossalai/legacy/nn/layer/parallel_2d/layers.py:686-699 | colossalai/legacy/nn/layer/parallel_2d/layers.py:832-845 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2d/layers.py:686` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) colossalai/legacy/nn/layer/parallel_2d/layers.py:763 — colossalai/legacy/nn/layer/parallel_2d/layers.py:763-776 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:777-790 — `colossalai/legacy/nn/layer/parallel_2d/layers.py` and `colossalai/legacy/nn/layer/parallel_2p5d/layers.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 18 separate duplicated blocks between them, totalling at least 219 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (14 lines × 2) colossalai/legacy/nn/layer/parallel_2p5d/layers.py:699 — colossalai/legacy/nn/layer/parallel_2p5d/layers.py:699-712 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:842-855 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2p5d/layers.py:699` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) colossalai/shardformer/layer/_operation.py:102 — colossalai/shardformer/layer/_operation.py:102-115 | colossalai/shardformer/layer/_operation.py:192-205 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (14 lines × 2) colossalai/shardformer/layer/parallel_module.py:109 — colossalai/shardformer/layer/parallel_module.py:109-122 | colossalai/shardformer/layer/parallel_module.py:284-297 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/shardformer/layer/parallel_module.py:299` calls `is_padded_tensor`, `to_padded_tensor` and `colossalai/shardformer/layer/parallel_module.py:124` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 2) colossalai/shardformer/modeling/_deepseek_v3_tf5.py:42 — colossalai/shardformer/modeling/_deepseek_v3_tf5.py:42-55 | colossalai/shardformer/modeling/_mixtral_tf5.py:345-358 — before extracting anything, compare `colossalai/shardformer/modeling/_deepseek_v3_tf5.py` and `colossalai/shardformer/modeling/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 62 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (14 lines × 2) colossalai/shardformer/modeling/_mixtral_tf4.py:64 — colossalai/shardformer/modeling/_mixtral_tf4.py:64-77 | colossalai/shardformer/modeling/deepseek.py:78-91 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/deepseek.py` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 427 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/modeling/_mixtral_tf4.py:62` calls `ValueError` and `colossalai/shardformer/modeling/deepseek.py:77` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 2) colossalai/shardformer/modeling/bloom.py:794 — colossalai/shardformer/modeling/bloom.py:794-807 | colossalai/shardformer/modeling/bloom.py:917-930 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/bloom.py:794` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (14 lines × 2) colossalai/shardformer/policies/_deepseek_v3_tf4.py:87 — colossalai/shardformer/policies/_deepseek_v3_tf4.py:87-100 | colossalai/shardformer/policies/_deepseek_v3_tf5.py:92-105 — before extracting anything, compare `colossalai/shardformer/policies/_deepseek_v3_tf4.py` and `colossalai/shardformer/policies/_deepseek_v3_tf5.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 150 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (14 lines × 2) colossalai/shardformer/policies/_whisper_tf4.py:578 — colossalai/shardformer/policies/_whisper_tf4.py:578-591 | colossalai/shardformer/policies/_whisper_tf5.py:565-578 — before extracting anything, compare `colossalai/shardformer/policies/_whisper_tf4.py` and `colossalai/shardformer/policies/_whisper_tf5.py` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • + 3 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (8 lines × 2) · ×27
  • Duplicated block (8 lines × 2) applications/Colossal-LLaMA/colossal_llama/utils/ckpt_io.py:85 — applications/Colossal-LLaMA/colossal_llama/utils/ckpt_io.py:85-92 | applications/ColossalMoE/utils.py:77-84 — before extracting anything, compare `applications/Colossal-LLaMA/colossal_llama/utils/ckpt_io.py` and `applications/ColossalMoE/utils.py` as WHOLE FILES: 95% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 3 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (8 lines × 2) colossalai/_analyzer/_subclasses/flop_tensor.py:387 — colossalai/_analyzer/_subclasses/flop_tensor.py:387-394 | colossalai/fx/profiler/opcount.py:190-197 — before extracting anything, compare `colossalai/_analyzer/_subclasses/flop_tensor.py` and `colossalai/fx/profiler/opcount.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 153 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (8 lines × 2) colossalai/auto_parallel/meta_profiler/meta_registry/norm.py:91 — colossalai/auto_parallel/meta_profiler/meta_registry/norm.py:91-99 | colossalai/auto_parallel/meta_profiler/meta_registry/norm.py:149-156 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/meta_profiler/meta_registry/norm.py:91` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/permute_handler.py:29 — colossalai/auto_parallel/tensor_shard/node_handler/permute_handler.py:29-36 | colossalai/auto_parallel/tensor_shard/node_handler/transpose_handler.py:29-36 — before extracting anything, compare `colossalai/auto_parallel/tensor_shard/node_handler/permute_handler.py` and `colossalai/auto_parallel/tensor_shard/node_handler/transpose_handler.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 32 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (8 lines × 2) colossalai/fx/tracer/meta_patch/patched_function/convolution.py:146 — colossalai/fx/tracer/meta_patch/patched_function/convolution.py:146-153 | colossalai/fx/tracer/meta_patch/patched_function/convolution.py:175-182 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/fx/tracer/meta_patch/patched_function/convolution.py:146` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) colossalai/inference/kv_cache/kvcache_manager.py:62 — colossalai/inference/kv_cache/kvcache_manager.py:62-69 | colossalai/inference/kv_cache/kvcache_manager.py:534-541 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (8 lines × 2) colossalai/inference/modeling/layers/distrifusion.py:134 — colossalai/inference/modeling/layers/distrifusion.py:134-142 | colossalai/inference/modeling/layers/distrifusion.py:193-200 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/inference/modeling/layers/distrifusion.py:134` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) colossalai/legacy/inference/quant/smoothquant/models/base_model.py:287 — colossalai/legacy/inference/quant/smoothquant/models/base_model.py:287-294 | colossalai/legacy/inference/quant/smoothquant/models/base_model.py:379-386 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (8 lines × 2) colossalai/legacy/inference/quant/smoothquant/models/llama.py:442 — colossalai/legacy/inference/quant/smoothquant/models/llama.py:442-449 | colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:350-357 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (8 lines × 2) colossalai/legacy/nn/layer/parallel_3d/layers.py:311 — colossalai/legacy/nn/layer/parallel_3d/layers.py:311-318 | colossalai/legacy/nn/layer/parallel_3d/layers.py:643-650 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_3d/layers.py:311` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) colossalai/nn/optimizer/adafactor.py:60 — colossalai/nn/optimizer/adafactor.py:60-67 | colossalai/nn/optimizer/distributed_adafactor.py:107-114 — before extracting anything, compare `colossalai/nn/optimizer/adafactor.py` and `colossalai/nn/optimizer/distributed_adafactor.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 46 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (8 lines × 2) colossalai/nn/optimizer/distributed_adafactor.py:332 — colossalai/nn/optimizer/distributed_adafactor.py:332-339 | colossalai/nn/optimizer/distributed_came.py:364-371 — before extracting anything, compare `colossalai/nn/optimizer/distributed_adafactor.py` and `colossalai/nn/optimizer/distributed_came.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 201 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/nn/optimizer/distributed_came.py:372` calls `zeros` and `colossalai/nn/optimizer/distributed_adafactor.py:340` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 2) colossalai/quantization/fp8.py:148 — colossalai/quantization/fp8.py:148-155 | colossalai/quantization/fp8.py:436-443 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (8 lines × 2) colossalai/shardformer/layer/linear.py:569 — colossalai/shardformer/layer/linear.py:569-576 | colossalai/shardformer/layer/qkv_fused_linear.py:606-614 — before extracting anything, compare `colossalai/shardformer/layer/linear.py` and `colossalai/shardformer/layer/qkv_fused_linear.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 261 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (8 lines × 2) colossalai/shardformer/modeling/_mixtral_tf4.py:652 — colossalai/shardformer/modeling/_mixtral_tf4.py:652-660 | colossalai/shardformer/modeling/deepseek.py:687-694 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/deepseek.py` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 427 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_mixtral_tf4.py:652` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) applications/ColossalEval/colossal_eval/dataset/safetybench_en.py:115 — applications/ColossalEval/colossal_eval/dataset/safetybench_en.py:115-122 | applications/ColossalEval/colossal_eval/dataset/safetybench_zh.py:115-122 — before extracting anything, compare `applications/ColossalEval/colossal_eval/dataset/safetybench_en.py` and `applications/ColossalEval/colossal_eval/dataset/safetybench_zh.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 86 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (8 lines × 2) colossalai/_analyzer/_subclasses/flop_tensor.py:330 — colossalai/_analyzer/_subclasses/flop_tensor.py:330-337 | colossalai/fx/profiler/opcount.py:133-140 — before extracting anything, compare `colossalai/_analyzer/_subclasses/flop_tensor.py` and `colossalai/fx/profiler/opcount.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 153 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (8 lines × 2) colossalai/shardformer/policies/_bert_tf4.py:814 — colossalai/shardformer/policies/_bert_tf4.py:814-821 | colossalai/shardformer/policies/_bert_tf5.py:821-828 — before extracting anything, compare `colossalai/shardformer/policies/_bert_tf4.py` and `colossalai/shardformer/policies/_bert_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 475 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (8 lines × 2) colossalai/shardformer/policies/_llama_tf4.py:443 — colossalai/shardformer/policies/_llama_tf4.py:443-450 | colossalai/shardformer/policies/_llama_tf5.py:441-448 — before extracting anything, compare `colossalai/shardformer/policies/_llama_tf4.py` and `colossalai/shardformer/policies/_llama_tf5.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 404 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (8 lines × 2) colossalai/shardformer/policies/_llama_tf4.py:527 — colossalai/shardformer/policies/_llama_tf4.py:527-534 | colossalai/shardformer/policies/_llama_tf5.py:525-532 — before extracting anything, compare `colossalai/shardformer/policies/_llama_tf4.py` and `colossalai/shardformer/policies/_llama_tf5.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 404 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (8 lines × 2) colossalai/shardformer/policies/_qwen2_tf4.py:383 — colossalai/shardformer/policies/_qwen2_tf4.py:383-390 | colossalai/shardformer/policies/_qwen2_tf5.py:382-389 — before extracting anything, compare `colossalai/shardformer/policies/_qwen2_tf4.py` and `colossalai/shardformer/policies/_qwen2_tf5.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 399 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (8 lines × 2) applications/Colossal-LLaMA/colossal_llama/dataset/conversation.py:67 — applications/Colossal-LLaMA/colossal_llama/dataset/conversation.py:67-74 | applications/ColossalEval/colossal_eval/utils/conversation.py:106-113 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (8 lines × 2) colossalai/accelerator/cuda_accelerator.py:43 — colossalai/accelerator/cuda_accelerator.py:43-50 | colossalai/accelerator/npu_accelerator.py:49-56 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (8 lines × 2) colossalai/legacy/inference/hybridengine/polices/llama.py:32 — colossalai/legacy/inference/hybridengine/polices/llama.py:32-39 | colossalai/legacy/inference/tensor_parallel/policies/llama.py:24-31 — before extracting anything, compare `colossalai/legacy/inference/hybridengine/polices/llama.py` and `colossalai/legacy/inference/tensor_parallel/policies/llama.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 37 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (8 lines × 2) REDACTED:205 — REDACTED:205-212 | REDACTED:195-202 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 194 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • + 2 more in this group — see findings.md.
D4 · Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) · ×25
  • Members sharing a duplicated core (4 members, 50+ identical tokens) colossalai/_analyzer/fx/tracer/tracer.py:172 — colossalai/_analyzer/fx/tracer/tracer.py:172-233 | colossalai/_analyzer/fx/tracer/tracer.py:309-334 | colossalai/fx/tracer/experimental.py:337-364 | colossalai/fx/tracer/tracer.py:323-445 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:262 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:262-406 | colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:525-692 | colossalai/checkpoint_io/moe_checkpoint.py:155-288 | colossalai/checkpoint_io/moe_checkpoint.py:440-576 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) colossalai/legacy/inference/hybridengine/modeling/llama.py:395 — colossalai/legacy/inference/hybridengine/modeling/llama.py:395-489 | colossalai/legacy/inference/quant/smoothquant/models/llama.py:128-232 | colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:395-545 | colossalai/legacy/inference/tensor_parallel/modeling/llama.py:315-409 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:281 — colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:281-342 | colossalai/shardformer/modeling/bloom.py:338-409 | colossalai/shardformer/modeling/falcon.py:371-450 | colossalai/shardformer/modeling/gpt2.py:365-430 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) colossalai/legacy/moe/openmoe/model/openmoe_policy.py:90 — colossalai/legacy/moe/openmoe/model/openmoe_policy.py:90-106 | colossalai/shardformer/policies/_mixtral_tf4.py:288-308 | colossalai/shardformer/policies/_mixtral_tf5.py:315-335 | colossalai/shardformer/policies/deepseek.py:298-318 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) colossalai/legacy/nn/layer/parallel_1d/layers.py:975 — colossalai/legacy/nn/layer/parallel_1d/layers.py:975-988 | colossalai/legacy/nn/layer/parallel_2d/layers.py:848-858 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:859-872 | colossalai/shardformer/layer/embedding.py:388-400 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) colossalai/legacy/nn/layer/parallel_2d/layers.py:423 — colossalai/legacy/nn/layer/parallel_2d/layers.py:423-463 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:436-476 | colossalai/legacy/nn/layer/parallel_3d/layers.py:703-742 | colossalai/legacy/nn/layer/vanilla/layers.py:166-190 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) colossalai/legacy/zero/sharded_model/sharded_model_v2.py:484 — colossalai/legacy/zero/sharded_model/sharded_model_v2.py:484-581 | colossalai/shardformer/layer/parallel_module.py:73-177 | colossalai/shardformer/layer/parallel_module.py:248-355 | colossalai/zero/gemini/gemini_ddp.py:647-817 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) colossalai/shardformer/modeling/_bert_tf4.py:1017 — colossalai/shardformer/modeling/_bert_tf4.py:1017-1025 | colossalai/shardformer/modeling/_bert_tf4.py:1029-1037 | colossalai/shardformer/modeling/_bert_tf5.py:1030-1038 | colossalai/shardformer/modeling/_bert_tf5.py:1042-1050 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) colossalai/shardformer/modeling/_deepseek_v3_tf5.py:101 — colossalai/shardformer/modeling/_deepseek_v3_tf5.py:101-164 | colossalai/shardformer/modeling/_mixtral_tf4.py:108-173 | colossalai/shardformer/modeling/_mixtral_tf5.py:460-518 | colossalai/shardformer/modeling/deepseek.py:136-203 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) colossalai/shardformer/modeling/_llama_tf4.py:62 — colossalai/shardformer/modeling/_llama_tf4.py:62-261 | colossalai/shardformer/modeling/_llama_tf5.py:97-303 | colossalai/shardformer/modeling/command.py:58-240 | colossalai/shardformer/modeling/falcon.py:208-351 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) colossalai/shardformer/modeling/_vit_tf4.py:140 — colossalai/shardformer/modeling/_vit_tf4.py:140-222 | colossalai/shardformer/modeling/_vit_tf4.py:226-333 | colossalai/shardformer/modeling/_vit_tf5.py:61-147 | colossalai/shardformer/modeling/_vit_tf5.py:151-262 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) colossalai/shardformer/modeling/_whisper_tf4.py:869 — colossalai/shardformer/modeling/_whisper_tf4.py:869-989 | colossalai/shardformer/modeling/_whisper_tf5.py:387-504 | colossalai/shardformer/modeling/t5.py:293-400 | colossalai/shardformer/modeling/t5.py:433-563 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) colossalai/shardformer/policies/_bert_tf4.py:46 — colossalai/shardformer/policies/_bert_tf4.py:46-360 | colossalai/shardformer/policies/_bert_tf5.py:46-367 | colossalai/shardformer/policies/bloom.py:37-274 | colossalai/shardformer/policies/gpt2.py:39-285 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) colossalai/shardformer/policies/_deepseek_v3_tf4.py:158 — colossalai/shardformer/policies/_deepseek_v3_tf4.py:158-164 | colossalai/shardformer/policies/_deepseek_v3_tf5.py:165-171 | colossalai/shardformer/policies/_mixtral_tf4.py:424-431 | colossalai/shardformer/policies/_mixtral_tf5.py:451-458 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) colossalai/shardformer/policies/_qwen2_tf4.py:404 — colossalai/shardformer/policies/_qwen2_tf4.py:404-458 | colossalai/shardformer/policies/_qwen2_tf5.py:403-457 | colossalai/shardformer/policies/_qwen3_tf4.py:403-444 | colossalai/shardformer/policies/_qwen3_tf5.py:423-468 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) colossalai/shardformer/policies/_vit_tf4.py:382 — colossalai/shardformer/policies/_vit_tf4.py:382-398 | colossalai/shardformer/policies/_vit_tf4.py:418-434 | colossalai/shardformer/policies/_vit_tf5.py:232-248 | colossalai/shardformer/policies/_vit_tf5.py:268-284 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) colossalai/shardformer/policies/_whisper_tf4.py:594 — colossalai/shardformer/policies/_whisper_tf4.py:594-679 | colossalai/shardformer/policies/_whisper_tf4.py:682-722 | colossalai/shardformer/policies/_whisper_tf5.py:581-666 | colossalai/shardformer/policies/_whisper_tf5.py:669-709 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) colossalai/shardformer/examples/convergence_benchmark.py:132 — colossalai/shardformer/examples/convergence_benchmark.py:132-164 | examples/language/bert/finetune.py:55-125 | examples/language/gpt/hybridparallelism/finetune.py:52-121 | examples/tutorial/new_api/glue_bert/finetune.py:44-78 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) colossalai/shardformer/examples/data.py:55 — colossalai/shardformer/examples/data.py:55-66 | examples/language/bert/data.py:54-65 | examples/language/gpt/hybridparallelism/data.py:54-67 | examples/tutorial/new_api/glue_bert/data.py:54-65 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) colossalai/shardformer/examples/data.py:69 — colossalai/shardformer/examples/data.py:69-80 | examples/language/bert/data.py:68-79 | examples/language/gpt/hybridparallelism/data.py:70-81 | examples/tutorial/new_api/glue_bert/data.py:68-79 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) colossalai/shardformer/examples/data.py:119 — colossalai/shardformer/examples/data.py:119-132 | examples/language/bert/data.py:111-124 | examples/language/gpt/hybridparallelism/data.py:112-125 | examples/tutorial/new_api/glue_bert/data.py:110-123 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) REDACTED:256 — REDACTED:256-286 | examples/images/dreambooth/train_dreambooth_colossalai.py:281-313 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:282-312 | REDACTED:271-301 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) examples/images/vit/vit_benchmark.py:46 — examples/images/vit/vit_benchmark.py:46-147 | examples/images/vit/vit_train_demo.py:137-238 | examples/language/opt/opt_benchmark.py:49-134 | examples/language/opt/opt_train_demo.py:68-161 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) examples/language/deepseek/benchmark.py:79 — examples/language/deepseek/benchmark.py:79-299 | examples/language/gpt/hybridparallelism/benchmark.py:39-231 | examples/language/llama/benchmark.py:66-395 | examples/language/mixtral/benchmark.py:59-287 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Duplicated block (18 lines × 2) · ×25
  • Duplicated block (18 lines × 2) applications/ColossalChat/coati/trainer/dpo.py:209 — applications/ColossalChat/coati/trainer/dpo.py:209-226 | applications/ColossalChat/coati/trainer/dpo.py:502-519 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/trainer/dpo.py:209` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `applications/ColossalChat/coati/trainer/dpo.py:520` calls `all_reduce_mean` and `applications/ColossalChat/coati/trainer/dpo.py:227` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (18 lines × 2) applications/ColossalEval/colossal_eval/dataset/agieval.py:249 — applications/ColossalEval/colossal_eval/dataset/agieval.py:249-266 | applications/ColossalEval/colossal_eval/dataset/gaokaobench.py:105-122 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (18 lines × 2) applications/ColossalEval/colossal_eval/dataset/safetybench_en.py:134 — applications/ColossalEval/colossal_eval/dataset/safetybench_en.py:134-151 | applications/ColossalEval/colossal_eval/dataset/safetybench_zh.py:134-151 — before extracting anything, compare `applications/ColossalEval/colossal_eval/dataset/safetybench_en.py` and `applications/ColossalEval/colossal_eval/dataset/safetybench_zh.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 86 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (18 lines × 2) applications/ColossalEval/colossal_eval/models/chatglm.py:207 — applications/ColossalEval/colossal_eval/models/chatglm.py:207-224 | REDACTED:485-502 — before extracting anything, compare `applications/ColossalEval/colossal_eval/models/chatglm.py` and `REDACTED` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 72 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalEval/colossal_eval/models/chatglm.py:207` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (18 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:408 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:408-425 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py:248-265 — before extracting anything, compare `colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py` and `colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 143 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (18 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:560 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:560-577 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py:281-298 — before extracting anything, compare `colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py` and `colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 143 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (18 lines × 2) colossalai/booster/plugin/hybrid_parallel_plugin.py:1066 — colossalai/booster/plugin/hybrid_parallel_plugin.py:1066-1083 | colossalai/booster/plugin/moe_hybrid_parallel_plugin.py:289-306 — before extracting anything, compare `colossalai/booster/plugin/hybrid_parallel_plugin.py` and `colossalai/booster/plugin/moe_hybrid_parallel_plugin.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 100 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/booster/plugin/hybrid_parallel_plugin.py:1085` calls `warning` and `colossalai/booster/plugin/moe_hybrid_parallel_plugin.py:307` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (18 lines × 2) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:312 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:312-329 | colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:355-372 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:312` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:576 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:576-593 | colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:632-649 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:576` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) colossalai/inference/modeling/models/nopadding_baichuan.py:185 — colossalai/inference/modeling/models/nopadding_baichuan.py:185-202 | colossalai/inference/modeling/models/nopadding_llama.py:559-576 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/inference/modeling/models/nopadding_baichuan.py:185` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) colossalai/legacy/amp/naive_amp/_utils.py:15 — colossalai/legacy/amp/naive_amp/_utils.py:15-32 | colossalai/zero/low_level/_utils.py:162-179 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (18 lines × 2) colossalai/legacy/nn/layer/parallel_2d/layers.py:124 — colossalai/legacy/nn/layer/parallel_2d/layers.py:124-141 | colossalai/legacy/nn/layer/parallel_2d/layers.py:1117-1134 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (18 lines × 2) colossalai/legacy/nn/layer/parallel_2d/layers.py:901 — colossalai/legacy/nn/layer/parallel_2d/layers.py:901-918 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:916-933 — `colossalai/legacy/nn/layer/parallel_2d/layers.py` and `colossalai/legacy/nn/layer/parallel_2p5d/layers.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 18 separate duplicated blocks between them, totalling at least 219 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (18 lines × 2) colossalai/pipeline/schedule/interleaved_pp.py:129 — colossalai/pipeline/schedule/interleaved_pp.py:129-146 | colossalai/pipeline/schedule/zero_bubble_pp.py:221-238 — before extracting anything, compare `colossalai/pipeline/schedule/interleaved_pp.py` and `colossalai/pipeline/schedule/zero_bubble_pp.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 82 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (18 lines × 2) colossalai/shardformer/layer/qkv_fused_linear.py:290 — colossalai/shardformer/layer/qkv_fused_linear.py:290-307 | colossalai/shardformer/layer/qkv_fused_linear.py:885-902 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (18 lines × 2) colossalai/shardformer/policies/_bert_tf4.py:90 — colossalai/shardformer/policies/_bert_tf4.py:90-107 | colossalai/shardformer/policies/_bert_tf5.py:97-114 — before extracting anything, compare `colossalai/shardformer/policies/_bert_tf4.py` and `colossalai/shardformer/policies/_bert_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 475 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/policies/_bert_tf4.py:90` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) colossalai/tensor/shape_consistency.py:127 — colossalai/tensor/shape_consistency.py:127-144 | colossalai/tensor/shape_consistency.py:321-338 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/tensor/shape_consistency.py:127` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (18 lines × 2) applications/ColossalChat/coati/utils/reward_score/utils.py:59 — applications/ColossalChat/coati/distributed/reward/reward_utils.py:59-76 | applications/ColossalChat/coati/utils/reward_score/utils.py:59-76 — before extracting anything, compare `applications/ColossalChat/coati/distributed/reward/reward_utils.py` and `applications/ColossalChat/coati/utils/reward_score/utils.py` as WHOLE FILES: 100% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 2 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (18 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/strategy/batch_norm_generator.py:164 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/batch_norm_generator.py:164-184 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/layer_norm_generator.py:163-180 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (18 lines × 2) colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:1058 — colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:1058-1075 | colossalai/legacy/nn/layer/parallel_3d/_operation.py:528-545 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (18 lines × 2) examples/community/roberta/pretraining/model/bert.py:1547 — examples/community/roberta/pretraining/model/bert.py:1547-1564 | examples/community/roberta/pretraining/model/bert.py:1745-1762 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (18 lines × 2) examples/images/vit/vit_benchmark.py:46 — examples/images/vit/vit_benchmark.py:46-63 | examples/language/opt/opt_benchmark.py:49-66 — before extracting anything, compare `examples/images/vit/vit_benchmark.py` and `examples/language/opt/opt_benchmark.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 57 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (18 lines × 2) examples/inference/benchmark_ops/benchmark_decoding_attn.py:95 — examples/inference/benchmark_ops/benchmark_decoding_attn.py:95-112 | examples/inference/benchmark_ops/benchmark_decoding_attn.py:117-134 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `examples/inference/benchmark_ops/benchmark_decoding_attn.py:95` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) examples/tutorial/sequence_parallel/data/datasets/builder.py:63 — examples/tutorial/sequence_parallel/data/datasets/builder.py:63-80 | examples/tutorial/sequence_parallel/data/datasets/dataset_utils.py:519-536 — before extracting anything, compare `examples/tutorial/sequence_parallel/data/datasets/builder.py` and `examples/tutorial/sequence_parallel/data/datasets/dataset_utils.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 111 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/tutorial/sequence_parallel/data/datasets/builder.py:63` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) examples/tutorial/sequence_parallel/data/datasets/builder.py:88 — examples/tutorial/sequence_parallel/data/datasets/builder.py:88-105 | examples/tutorial/sequence_parallel/data/datasets/dataset_utils.py:551-568 — before extracting anything, compare `examples/tutorial/sequence_parallel/data/datasets/builder.py` and `examples/tutorial/sequence_parallel/data/datasets/dataset_utils.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 111 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/tutorial/sequence_parallel/data/datasets/builder.py:88` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (17 lines × 2) · ×22
  • Duplicated block (17 lines × 2) applications/ColossalChat/coati/distributed/consumer.py:73 — applications/ColossalChat/coati/distributed/consumer.py:73-89 | applications/ColossalChat/coati/distributed/zero_bubble/consumer.py:72-88 — before extracting anything, compare `applications/ColossalChat/coati/distributed/consumer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/consumer.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 73 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/distributed/consumer.py:73` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `applications/ColossalChat/coati/distributed/consumer.py:71` calls `DistCoordinator` and `applications/ColossalChat/coati/distributed/zero_bubble/consumer.py:70` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (17 lines × 2) REDACTED:60 — REDACTED:60-76 | REDACTED:107-123 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (17 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:181 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:181-197 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:450-469 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:181` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) colossalai/inference/modeling/models/glide_llama.py:84 — colossalai/inference/modeling/models/glide_llama.py:84-100 | colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:908-924 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/inference/modeling/models/glide_llama.py:84` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) colossalai/kernel/triton/flash_decoding.py:473 — colossalai/kernel/triton/flash_decoding.py:473-489 | colossalai/kernel/triton/no_pad_rotary_embedding.py:548-564 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (17 lines × 2) colossalai/legacy/inference/hybridengine/modeling/llama.py:236 — colossalai/legacy/inference/hybridengine/modeling/llama.py:236-252 | colossalai/legacy/inference/tensor_parallel/modeling/llama.py:145-161 — before extracting anything, compare `colossalai/legacy/inference/hybridengine/modeling/llama.py` and `colossalai/legacy/inference/tensor_parallel/modeling/llama.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 250 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (17 lines × 2) colossalai/legacy/inference/hybridengine/modeling/llama.py:473 — colossalai/legacy/inference/hybridengine/modeling/llama.py:473-489 | colossalai/legacy/inference/tensor_parallel/modeling/llama.py:393-409 — before extracting anything, compare `colossalai/legacy/inference/hybridengine/modeling/llama.py` and `colossalai/legacy/inference/tensor_parallel/modeling/llama.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 250 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (17 lines × 2) colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:161 — colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:161-177 | colossalai/legacy/inference/tensor_parallel/modeling/llama.py:163-179 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (17 lines × 2) colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:279 — colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:279-295 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:607-623 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (17 lines × 2) colossalai/nn/optimizer/fused_adam.py:120 — colossalai/nn/optimizer/fused_adam.py:120-136 | colossalai/nn/optimizer/fused_lamb.py:157-173 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (17 lines × 2) colossalai/shardformer/layer/qkv_fused_linear.py:277 — colossalai/shardformer/layer/qkv_fused_linear.py:277-293 | colossalai/shardformer/layer/qkv_fused_linear.py:1080-1096 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/layer/qkv_fused_linear.py:277` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) colossalai/shardformer/modeling/_bert_tf4.py:248 — colossalai/shardformer/modeling/_bert_tf4.py:248-264 | colossalai/shardformer/modeling/_bert_tf5.py:259-275 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (17 lines × 2) colossalai/shardformer/modeling/_llama_tf4.py:500 — colossalai/shardformer/modeling/_llama_tf4.py:500-516 | colossalai/shardformer/modeling/_llama_tf5.py:544-560 — before extracting anything, compare `colossalai/shardformer/modeling/_llama_tf4.py` and `colossalai/shardformer/modeling/_llama_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_llama_tf4.py:500` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/shardformer/modeling/_llama_tf5.py:563` calls `getattr` and `colossalai/shardformer/modeling/_llama_tf4.py:518` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (17 lines × 2) colossalai/shardformer/modeling/_mixtral_tf4.py:788 — colossalai/shardformer/modeling/_mixtral_tf4.py:788-804 | colossalai/shardformer/modeling/deepseek.py:798-814 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/deepseek.py` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 427 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_mixtral_tf4.py:788` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) colossalai/shardformer/modeling/_qwen2_tf5.py:446 — colossalai/shardformer/modeling/_qwen2_tf5.py:446-462 | colossalai/shardformer/modeling/_qwen3_tf5.py:447-463 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf5.py` and `colossalai/shardformer/modeling/_qwen3_tf5.py` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 628 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (17 lines × 2) colossalai/shardformer/policies/_vit_tf4.py:309 — colossalai/shardformer/policies/_vit_tf4.py:309-325 | colossalai/shardformer/policies/_vit_tf5.py:159-175 — before extracting anything, compare `colossalai/shardformer/policies/_vit_tf4.py` and `colossalai/shardformer/policies/_vit_tf5.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 133 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (17 lines × 2) colossalai/tensor/d_tensor/layout_converter.py:111 — colossalai/tensor/d_tensor/layout_converter.py:111-127 | colossalai/tensor/shape_consistency.py:106-122 — before extracting anything, compare `colossalai/tensor/d_tensor/layout_converter.py` and `colossalai/tensor/shape_consistency.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 72 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/tensor/d_tensor/layout_converter.py:111` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) colossalai/fx/profiler/experimental/registry.py:3 — colossalai/fx/profiler/experimental/registry.py:3-19 | colossalai/fx/tracer/registry.py:3-19 — before extracting anything, compare `colossalai/fx/profiler/experimental/registry.py` and `colossalai/fx/tracer/registry.py` as WHOLE FILES: 82% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (17 lines × 2) applications/ColossalChat/coati/distributed/utils.py:124 — applications/ColossalChat/coati/distributed/utils.py:124-140 | applications/ColossalChat/coati/models/utils.py:73-89 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (17 lines × 2) applications/ColossalChat/coati/trainer/grpo.py:34 — applications/ColossalChat/coati/trainer/grpo.py:34-50 | applications/ColossalChat/coati/trainer/ppo.py:34-51 — before extracting anything, compare `applications/ColossalChat/coati/trainer/grpo.py` and `applications/ColossalChat/coati/trainer/ppo.py` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 176 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (17 lines × 2) colossalai/_analyzer/_subclasses/flop_tensor.py:310 — colossalai/_analyzer/_subclasses/flop_tensor.py:310-326 | colossalai/fx/profiler/opcount.py:113-129 — before extracting anything, compare `colossalai/_analyzer/_subclasses/flop_tensor.py` and `colossalai/fx/profiler/opcount.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 153 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (17 lines × 2) examples/tutorial/opt/inference/opt_fastapi.py:33 — examples/tutorial/opt/inference/opt_fastapi.py:33-49 | examples/tutorial/opt/inference/opt_server.py:38-54 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `examples/tutorial/opt/inference/opt_server.py:55` calls `isinstance` and `examples/tutorial/opt/inference/opt_fastapi.py:50` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (16 lines × 2) · ×22
  • Duplicated block (16 lines × 2) applications/ColossalEval/colossal_eval/dataset/ceval.py:103 — applications/ColossalEval/colossal_eval/dataset/ceval.py:103-118 | applications/ColossalEval/colossal_eval/dataset/cmmlu.py:114-129 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (16 lines × 2) applications/ColossalEval/colossal_eval/dataset/cmmlu.py:129 — applications/ColossalEval/colossal_eval/dataset/cmmlu.py:129-144 | applications/ColossalEval/colossal_eval/dataset/mmlu.py:58-73 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `applications/ColossalEval/colossal_eval/dataset/cmmlu.py:128` calls `next` and `applications/ColossalEval/colossal_eval/dataset/mmlu.py:57` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (16 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/addmm_handler.py:76 — colossalai/auto_parallel/tensor_shard/node_handler/addmm_handler.py:76-91 | colossalai/auto_parallel/tensor_shard/node_handler/bmm_handler.py:95-110 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (16 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/strategy/getattr_generator.py:29 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/getattr_generator.py:29-44 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/placeholder_generator.py:35-50 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (16 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:162 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:162-177 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:180-195 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (16 lines × 2) colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:86 — colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:86-101 | colossalai/shardformer/modeling/bloom.py:129-144 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (16 lines × 2) colossalai/legacy/initialize.py:188 — colossalai/legacy/initialize.py:188-203 | colossalai/legacy/initialize.py:224-239 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (16 lines × 2) colossalai/legacy/nn/layer/parallel_1d/layers.py:528 — colossalai/legacy/nn/layer/parallel_1d/layers.py:528-543 | colossalai/legacy/nn/layer/parallel_1d/layers.py:671-686 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_1d/layers.py:528` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) colossalai/legacy/nn/layer/parallel_2p5d/layers.py:188 — colossalai/legacy/nn/layer/parallel_2p5d/layers.py:188-203 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:1160-1175 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2p5d/layers.py:188` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) colossalai/nn/optimizer/cpu_adam.py:135 — colossalai/nn/optimizer/cpu_adam.py:135-150 | colossalai/nn/optimizer/hybrid_adam.py:103-118 — before extracting anything, compare `colossalai/nn/optimizer/cpu_adam.py` and `colossalai/nn/optimizer/hybrid_adam.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (16 lines × 2) colossalai/nn/optimizer/fused_lamb.py:189 — colossalai/nn/optimizer/fused_lamb.py:189-204 | colossalai/nn/optimizer/fused_lamb.py:207-222 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/nn/optimizer/fused_lamb.py:189` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) colossalai/shardformer/modeling/_deepseek_v3_tf4.py:165 — colossalai/shardformer/modeling/_deepseek_v3_tf4.py:165-180 | colossalai/shardformer/modeling/_deepseek_v3_tf5.py:190-205 — before extracting anything, compare `colossalai/shardformer/modeling/_deepseek_v3_tf4.py` and `colossalai/shardformer/modeling/_deepseek_v3_tf5.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 101 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (16 lines × 2) colossalai/shardformer/modeling/_mixtral_tf4.py:511 — colossalai/shardformer/modeling/_mixtral_tf4.py:511-526 | colossalai/shardformer/modeling/_mixtral_tf5.py:889-904 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 581 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_mixtral_tf4.py:511` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (16 lines × 2) colossalai/shardformer/modeling/bloom.py:511 — colossalai/shardformer/modeling/bloom.py:511-526 | colossalai/shardformer/modeling/falcon.py:540-555 — before extracting anything, compare `colossalai/shardformer/modeling/bloom.py` and `colossalai/shardformer/modeling/falcon.py` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 594 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/bloom.py:511` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (16 lines × 2) colossalai/shardformer/modeling/bloom.py:736 — colossalai/shardformer/modeling/bloom.py:736-751 | colossalai/shardformer/modeling/bloom.py:858-873 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/bloom.py:736` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) colossalai/shardformer/policies/_llama_tf4.py:453 — colossalai/shardformer/policies/_llama_tf4.py:453-468 | colossalai/shardformer/policies/_llama_tf5.py:451-466 — before extracting anything, compare `colossalai/shardformer/policies/_llama_tf4.py` and `colossalai/shardformer/policies/_llama_tf5.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 404 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (16 lines × 2) colossalai/tensor/d_tensor/layout_converter.py:324 — colossalai/tensor/d_tensor/layout_converter.py:324-339 | colossalai/tensor/shape_consistency.py:302-317 — before extracting anything, compare `colossalai/tensor/d_tensor/layout_converter.py` and `colossalai/tensor/shape_consistency.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 72 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/tensor/d_tensor/layout_converter.py:324` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (16 lines × 2) colossalai/legacy/inference/async_manager.py:136 — colossalai/legacy/inference/async_manager.py:136-151 | colossalai/legacy/inference/manager.py:281-296 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (16 lines × 2) applications/ColossalChat/examples/training_scripts/train_grpo.py:288 — applications/ColossalChat/examples/training_scripts/train_grpo.py:288-303 | REDACTED:332-347 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_grpo.py` and `REDACTED` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 469 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `REDACTED:348` calls `eval` and `applications/ColossalChat/examples/training_scripts/train_grpo.py:304` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (16 lines × 2) applications/ColossalChat/examples/training_scripts/train_grpo.py:402 — applications/ColossalChat/examples/training_scripts/train_grpo.py:402-417 | REDACTED:469-484 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_grpo.py` and `REDACTED` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 469 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/examples/training_scripts/train_grpo.py:402` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `REDACTED:485` calls `eval` and `applications/ColossalChat/examples/training_scripts/train_grpo.py:419` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (16 lines × 2) examples/language/bert/finetune.py:248 — examples/language/bert/finetune.py:248-266 | examples/tutorial/new_api/glue_bert/finetune.py:148-163 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `examples/language/bert/finetune.py:248` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) examples/language/deepseek/benchmark.py:158 — examples/language/deepseek/benchmark.py:158-173 | examples/language/llama/benchmark.py:240-255 — `examples/language/deepseek/benchmark.py` and `examples/language/llama/benchmark.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 10 separate duplicated blocks between them, totalling at least 150 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (15 lines × 2) · ×20
  • Duplicated block (15 lines × 2) applications/ColossalChat/coati/distributed/launch.py:130 — applications/ColossalChat/coati/distributed/launch.py:130-144 | applications/ColossalChat/coati/distributed/launch_zero_bubble.py:134-148 — before extracting anything, compare `applications/ColossalChat/coati/distributed/launch.py` and `applications/ColossalChat/coati/distributed/launch_zero_bubble.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 70 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (15 lines × 2) applications/ColossalChat/coati/distributed/launch.py:149 — applications/ColossalChat/coati/distributed/launch.py:149-163 | applications/ColossalChat/coati/distributed/launch_zero_bubble.py:152-166 — before extracting anything, compare `applications/ColossalChat/coati/distributed/launch.py` and `applications/ColossalChat/coati/distributed/launch_zero_bubble.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 70 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `applications/ColossalChat/coati/distributed/launch.py:148` calls `get`, `remote` and `applications/ColossalChat/coati/distributed/launch_zero_bubble.py:150` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (15 lines × 2) colossalai/_analyzer/fx/codegen.py:227 — colossalai/_analyzer/fx/codegen.py:227-241 | colossalai/fx/codegen/activation_checkpoint_codegen.py:435-449 — before extracting anything, compare `colossalai/_analyzer/fx/codegen.py` and `colossalai/fx/codegen/activation_checkpoint_codegen.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 101 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (15 lines × 2) colossalai/fx/passes/split_module.py:122 — colossalai/fx/passes/split_module.py:122-136 | colossalai/fx/passes/split_module.py:138-152 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (15 lines × 2) colossalai/kernel/triton/flash_decoding.py:513 — colossalai/kernel/triton/flash_decoding.py:513-527 | colossalai/kernel/triton/kvcache_copy.py:269-283 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (15 lines × 2) colossalai/legacy/engine/schedule/_pipeline_schedule.py:263 — colossalai/legacy/engine/schedule/_pipeline_schedule.py:263-277 | colossalai/legacy/engine/schedule/_pipeline_schedule.py:544-558 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (15 lines × 2) colossalai/legacy/nn/layer/parallel_1d/layers.py:262 — colossalai/legacy/nn/layer/parallel_1d/layers.py:262-276 | colossalai/legacy/nn/layer/parallel_1d/layers.py:677-691 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (15 lines × 2) colossalai/legacy/nn/layer/parallel_1d/layers.py:399 — colossalai/legacy/nn/layer/parallel_1d/layers.py:399-413 | colossalai/legacy/nn/layer/parallel_1d/layers.py:534-548 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (15 lines × 2) colossalai/legacy/nn/layer/parallel_2d/_operation.py:444 — colossalai/legacy/nn/layer/parallel_2d/_operation.py:444-458 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:411-425 — `colossalai/legacy/nn/layer/parallel_2d/_operation.py` and `colossalai/legacy/nn/layer/parallel_2p5d/_operation.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 185 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (15 lines × 2) colossalai/legacy/nn/layer/parallel_2d/_operation.py:601 — colossalai/legacy/nn/layer/parallel_2d/_operation.py:601-615 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:574-588 — `colossalai/legacy/nn/layer/parallel_2d/_operation.py` and `colossalai/legacy/nn/layer/parallel_2p5d/_operation.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 185 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (15 lines × 2) colossalai/legacy/nn/layer/parallel_2p5d/layers.py:964 — colossalai/legacy/nn/layer/parallel_2p5d/layers.py:964-978 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:1127-1141 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2p5d/layers.py:964` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) colossalai/shardformer/layer/qkv_fused_linear.py:674 — colossalai/shardformer/layer/qkv_fused_linear.py:674-688 | colossalai/shardformer/layer/qkv_fused_linear.py:1249-1263 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (15 lines × 2) colossalai/shardformer/modeling/_bert_tf4.py:142 — colossalai/shardformer/modeling/_bert_tf4.py:142-156 | examples/community/roberta/pretraining/model/bert.py:988-1002 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `examples/community/roberta/pretraining/model/bert.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 255 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/shardformer/modeling/_bert_tf4.py:159` calls `is_first_stage` and `examples/community/roberta/pretraining/model/bert.py:1004` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (15 lines × 2) colossalai/shardformer/modeling/_bert_tf4.py:736 — colossalai/shardformer/modeling/_bert_tf4.py:736-750 | colossalai/shardformer/modeling/_bert_tf5.py:749-763 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (15 lines × 2) colossalai/shardformer/modeling/_deepseek_v3_tf4.py:186 — colossalai/shardformer/modeling/_deepseek_v3_tf4.py:186-200 | colossalai/shardformer/modeling/_deepseek_v3_tf5.py:215-229 — before extracting anything, compare `colossalai/shardformer/modeling/_deepseek_v3_tf4.py` and `colossalai/shardformer/modeling/_deepseek_v3_tf5.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 101 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (15 lines × 2) colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py:501 — colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py:501-515 | colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py:516-530 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (15 lines × 2) examples/community/roberta/pretraining/model/deberta_v2.py:1295 — examples/community/roberta/pretraining/model/deberta_v2.py:1295-1309 | examples/community/roberta/pretraining/model/deberta_v2.py:1602-1616 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (15 lines × 2) examples/language/bert/finetune.py:183 — examples/language/bert/finetune.py:183-197 | examples/language/gpt/hybridparallelism/finetune.py:182-196 — before extracting anything, compare `examples/language/bert/finetune.py` and `examples/language/gpt/hybridparallelism/finetune.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 242 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/language/bert/finetune.py:183` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) examples/language/deepseek/benchmark.py:175 — examples/language/deepseek/benchmark.py:175-189 | examples/language/llama/benchmark.py:275-289 — `examples/language/deepseek/benchmark.py` and `examples/language/llama/benchmark.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 10 separate duplicated blocks between them, totalling at least 150 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `examples/language/deepseek/benchmark.py:175` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) examples/language/deepseek/benchmark.py:191 — examples/language/deepseek/benchmark.py:191-205 | examples/language/mixtral/benchmark.py:193-207 — `examples/language/deepseek/benchmark.py` and `examples/language/mixtral/benchmark.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 11 separate duplicated blocks between them, totalling at least 155 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (19 lines × 2) · ×18
  • Duplicated block (19 lines × 2) applications/ColossalChat/coati/distributed/consumer.py:150 — applications/ColossalChat/coati/distributed/consumer.py:150-168 | applications/ColossalChat/coati/distributed/consumer.py:336-354 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (19 lines × 2) applications/ColossalChat/coati/trainer/grpo.py:171 — applications/ColossalChat/coati/trainer/grpo.py:171-189 | applications/ColossalChat/coati/trainer/ppo.py:162-180 — before extracting anything, compare `applications/ColossalChat/coati/trainer/grpo.py` and `applications/ColossalChat/coati/trainer/ppo.py` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 176 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (19 lines × 2) REDACTED:111 — REDACTED:111-129 | REDACTED:132-150 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (19 lines × 2) colossalai/_analyzer/_subclasses/flop_tensor.py:398 — colossalai/_analyzer/_subclasses/flop_tensor.py:398-416 | colossalai/fx/profiler/opcount.py:201-219 — before extracting anything, compare `colossalai/_analyzer/_subclasses/flop_tensor.py` and `colossalai/fx/profiler/opcount.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 153 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (19 lines × 2) colossalai/booster/plugin/hybrid_parallel_plugin.py:444 — colossalai/booster/plugin/hybrid_parallel_plugin.py:444-462 | colossalai/booster/plugin/hybrid_parallel_plugin.py:651-669 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (19 lines × 2) colossalai/checkpoint_io/moe_checkpoint.py:226 — colossalai/checkpoint_io/moe_checkpoint.py:226-244 | colossalai/checkpoint_io/moe_checkpoint.py:508-526 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (19 lines × 2) colossalai/fx/profiler/profiler.py:90 — colossalai/fx/profiler/profiler.py:90-108 | colossalai/fx/profiler/profiler.py:124-142 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (19 lines × 2) colossalai/inference/core/diffusion_engine.py:94 — colossalai/inference/core/diffusion_engine.py:94-112 | colossalai/inference/core/llm_engine.py:170-188 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (19 lines × 2) colossalai/legacy/inference/hybridengine/modeling/llama.py:395 — colossalai/legacy/inference/hybridengine/modeling/llama.py:395-413 | colossalai/legacy/inference/tensor_parallel/modeling/llama.py:315-333 — before extracting anything, compare `colossalai/legacy/inference/hybridengine/modeling/llama.py` and `colossalai/legacy/inference/tensor_parallel/modeling/llama.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 250 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (19 lines × 2) colossalai/legacy/inference/quant/gptq/cai_gptq/cai_quant_linear.py:269 — colossalai/legacy/inference/quant/gptq/cai_gptq/cai_quant_linear.py:269-287 | colossalai/legacy/inference/quant/gptq/cai_gptq/cai_quant_linear.py:323-341 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (19 lines × 2) colossalai/legacy/nn/layer/parallel_2d/_operation.py:449 — colossalai/legacy/nn/layer/parallel_2d/_operation.py:449-467 | colossalai/legacy/nn/layer/parallel_2d/_operation.py:606-624 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (19 lines × 2) colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:416 — colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:416-434 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:579-597 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (19 lines × 2) colossalai/legacy/nn/layer/parallel_3d/layers.py:291 — colossalai/legacy/nn/layer/parallel_3d/layers.py:291-309 | colossalai/legacy/nn/layer/parallel_3d/layers.py:623-641 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_3d/layers.py:291` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 2) colossalai/legacy/nn/layer/parallel_3d/layers.py:431 — colossalai/legacy/nn/layer/parallel_3d/layers.py:431-449 | colossalai/legacy/nn/layer/parallel_3d/layers.py:587-605 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (19 lines × 2) colossalai/shardformer/modeling/_mixtral_tf4.py:550 — colossalai/shardformer/modeling/_mixtral_tf4.py:550-568 | colossalai/shardformer/modeling/_mixtral_tf5.py:930-948 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 581 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_mixtral_tf4.py:550` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/shardformer/modeling/_mixtral_tf5.py:952` calls `getattr` and `colossalai/shardformer/modeling/_mixtral_tf4.py:571` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (19 lines × 2) colossalai/shardformer/modeling/_whisper_tf4.py:962 — colossalai/shardformer/modeling/_whisper_tf4.py:962-980 | colossalai/shardformer/modeling/t5.py:373-391 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/t5.py:373` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (19 lines × 2) examples/tutorial/opt/opt/run_clm.py:105 — examples/tutorial/opt/opt/run_clm.py:105-124 | examples/tutorial/opt/opt/run_clm.py:201-219 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `examples/tutorial/opt/opt/run_clm.py:105` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 2) examples/tutorial/sequence_parallel/data/datasets/builder.py:44 — examples/tutorial/sequence_parallel/data/datasets/builder.py:44-62 | examples/tutorial/sequence_parallel/data/datasets/dataset_utils.py:498-516 — before extracting anything, compare `examples/tutorial/sequence_parallel/data/datasets/builder.py` and `examples/tutorial/sequence_parallel/data/datasets/dataset_utils.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 111 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D17 · Explicit Debt · FixmeComment · ×17
  • FixmeComment tests/test_legacy/test_engine/test_engine.py:18 — # FIXME: test bert — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment tests/test_fx/test_tracer/test_timm_model/test_timm_model.py:47 — # FIXME(ver217): timm/models/convit.py:71: in forward — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment tests/test_booster/test_plugin/test_low_level_zero_plugin.py:80 — # FIXME(ver217): fix these models — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment tests/test_autochunk/test_autochunk_transformer/test_autochunk_gpt.py:35 — # FIXME(ver217, oahzxl): implement full op — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment examples/tutorial/new_api/cifar_vit/train.py:125 — # FIXME(ver217): gemini is not supported resnet now — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment examples/tutorial/new_api/cifar_resnet/train.py:105 — # FIXME(ver217): gemini is not supported resnet now — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment examples/images/resnet/train.py:105 — # FIXME(ver217): gemini is not supported resnet now — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment REDACTED:62 — # NOTE: FIXME: NPU DOES NOT support isend nor irecv, so broadcast is kept for future use — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment colossalai/legacy/zero/sharded_optim/sharded_optim_v2.py:336 — # FIXME(ver217): p.data here is an empty tensor on CUDA and has no useful information — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment colossalai/legacy/zero/sharded_model/sharded_model_v2.py:387 — # FIXME(ver217): refactor the below line when impl eviction policy — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment colossalai/legacy/utils/profiler/stateful_tensor_mem_extention.py:129 — # FIXME(ver217): uncomment below line when remove_hook is implemented — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment colossalai/lazy/lazy_init.py:300 — # FIXME(ver217): torch script functions are not verified — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment colossalai/kernel/triton/context_attn_unpad.py:67 — # FIXME might want to explore better way to get the summation of prev seq lengths. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment colossalai/kernel/triton/context_attn_unpad.py:245 — # FIXME might want to explore better way to get the summation of prev seq lengths. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment colossalai/kernel/triton/context_attn_unpad.py:422 — # FIXME might want to explore better way to get the summation of prev seq lengths. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment colossalai/booster/plugin/gemini_plugin.py:666 — # FIXME(ver217): gemini does not support sync bn — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment colossalai/_analyzer/fx/tracer/tracer.py:22 — # FIXME: don't know why but torch.fx always gets a suffix like '_1' in the name — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
D4 · Code Duplication · Duplicated block (22 lines × 2) · ×17
  • Duplicated block (22 lines × 2) applications/ColossalChat/coati/distributed/consumer.py:115 — applications/ColossalChat/coati/distributed/consumer.py:115-136 | applications/ColossalChat/coati/distributed/zero_bubble/consumer.py:130-151 — before extracting anything, compare `applications/ColossalChat/coati/distributed/consumer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/consumer.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 73 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (22 lines × 2) applications/ColossalChat/coati/distributed/grpo_consumer.py:45 — applications/ColossalChat/coati/distributed/grpo_consumer.py:45-66 | applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py:46-67 — before extracting anything, compare `applications/ColossalChat/coati/distributed/grpo_consumer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 407 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/distributed/grpo_consumer.py:45` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: `BaseConsumer` names `coati.distributed.consumer` in one and `coati.distributed.zero_bubble.consumer` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (22 lines × 2) applications/ColossalChat/coati/distributed/grpo_consumer.py:82 — applications/ColossalChat/coati/distributed/grpo_consumer.py:82-103 | applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py:80-101 — before extracting anything, compare `applications/ColossalChat/coati/distributed/grpo_consumer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 407 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/distributed/grpo_consumer.py:82` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: `BaseConsumer` names `coati.distributed.consumer` in one and `coati.distributed.zero_bubble.consumer` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `applications/ColossalChat/coati/distributed/grpo_consumer.py:104` calls `get` and `applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py:102` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (22 lines × 2) REDACTED:545 — REDACTED:545-566 | REDACTED:445-466 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 157 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (22 lines × 2) applications/ColossalMoE/train.py:118 — applications/ColossalMoE/train.py:118-139 | colossalai/legacy/moe/openmoe/train.py:181-202 — before extracting anything, compare `applications/ColossalMoE/train.py` and `colossalai/legacy/moe/openmoe/train.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 125 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalMoE/train.py:118` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (22 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py:142 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py:142-165 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py:238-259 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (22 lines × 2) colossalai/booster/plugin/torch_fsdp_plugin.py:65 — colossalai/booster/plugin/torch_fsdp_plugin.py:65-86 | colossalai/booster/plugin/torch_fsdp_plugin.py:398-419 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (22 lines × 2) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:373 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:373-394 | colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:650-671 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:373` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (22 lines × 2) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:912 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:912-933 | colossalai/checkpoint_io/moe_checkpoint.py:873-894 — before extracting anything, compare `colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py` and `colossalai/checkpoint_io/moe_checkpoint.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 249 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (22 lines × 2) colossalai/shardformer/modeling/_vit_tf4.py:153 — colossalai/shardformer/modeling/_vit_tf4.py:153-174 | colossalai/shardformer/modeling/_vit_tf5.py:76-97 — before extracting anything, compare `colossalai/shardformer/modeling/_vit_tf4.py` and `colossalai/shardformer/modeling/_vit_tf5.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 183 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_vit_tf4.py:153` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: `ImageClassifierOutput` names `transformers.modeling_outputs` in one and `transformers.models.vit.modeling_vit` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (22 lines × 2) colossalai/shardformer/modeling/chatglm2.py:213 — colossalai/shardformer/modeling/chatglm2.py:213-234 | colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py:746-767 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (22 lines × 2) colossalai/tensor/d_tensor/api.py:210 — colossalai/tensor/d_tensor/api.py:210-231 | colossalai/tensor/d_tensor/api.py:239-260 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (22 lines × 2) extensions/cpp_extension.py:76 — extensions/cpp_extension.py:76-97 | extensions/cuda_extension.py:80-101 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `extensions/cpp_extension.py:76` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `extensions/cuda_extension.py:102` calls `nvcc_flags` and `extensions/cpp_extension.py:98` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (22 lines × 2) colossalai/auto_parallel/meta_profiler/registry.py:6 — colossalai/auto_parallel/meta_profiler/registry.py:6-27 | colossalai/auto_parallel/tensor_shard/node_handler/registry.py:3-24 — before extracting anything, compare `colossalai/auto_parallel/meta_profiler/registry.py` and `colossalai/auto_parallel/tensor_shard/node_handler/registry.py` as WHOLE FILES: 95% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (22 lines × 2) extensions/pybind/inference/inference_ops_cuda.py:6 — extensions/pybind/inference/inference_ops_cuda.py:6-30 | extensions/pybind/optimizer/fused_optimizer_cuda.py:6-27 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (22 lines × 2) REDACTED:50 — REDACTED:50-71 | REDACTED:93-114 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 24 separate duplicated blocks between them, totalling at least 499 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:50` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (22 lines × 2) examples/language/llama/benchmark.py:373 — examples/language/llama/benchmark.py:373-394 | examples/language/mixtral/benchmark.py:265-286 — `examples/language/llama/benchmark.py` and `examples/language/mixtral/benchmark.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 11 separate duplicated blocks between them, totalling at least 164 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (23 lines × 2) · ×16
  • Duplicated block (23 lines × 2) applications/ColossalChat/coati/distributed/launch.py:97 — applications/ColossalChat/coati/distributed/launch.py:97-119 | applications/ColossalChat/coati/distributed/launch_zero_bubble.py:99-121 — before extracting anything, compare `applications/ColossalChat/coati/distributed/launch.py` and `applications/ColossalChat/coati/distributed/launch_zero_bubble.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 70 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `applications/ColossalChat/coati/distributed/launch_zero_bubble.py:95` calls `remote` and `applications/ColossalChat/coati/distributed/launch.py:96` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (23 lines × 2) applications/ColossalChat/coati/distributed/producer.py:290 — applications/ColossalChat/coati/distributed/producer.py:290-312 | applications/ColossalChat/coati/distributed/zero_bubble/producer.py:338-360 — before extracting anything, compare `applications/ColossalChat/coati/distributed/producer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/producer.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 234 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (23 lines × 2) colossalai/_analyzer/_subclasses/flop_tensor.py:361 — colossalai/_analyzer/_subclasses/flop_tensor.py:361-383 | colossalai/fx/profiler/opcount.py:164-186 — before extracting anything, compare `colossalai/_analyzer/_subclasses/flop_tensor.py` and `colossalai/fx/profiler/opcount.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 153 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (23 lines × 2) colossalai/_analyzer/fx/codegen.py:61 — colossalai/_analyzer/fx/codegen.py:61-83 | colossalai/fx/codegen/activation_checkpoint_codegen.py:100-122 — before extracting anything, compare `colossalai/_analyzer/fx/codegen.py` and `colossalai/fx/codegen/activation_checkpoint_codegen.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 101 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (23 lines × 2) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:670 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:670-692 | colossalai/checkpoint_io/moe_checkpoint.py:554-576 — before extracting anything, compare `colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py` and `colossalai/checkpoint_io/moe_checkpoint.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 249 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: `CheckpointIndexFile` names `.index_file` in one and `colossalai.checkpoint_io` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (23 lines × 2) colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:212 — colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:212-234 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:534-556 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:235` calls `copy_`, `broadcast` and `colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:557` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (23 lines × 2) colossalai/shardformer/modeling/_bert_tf4.py:845 — colossalai/shardformer/modeling/_bert_tf4.py:845-867 | colossalai/shardformer/modeling/_bert_tf5.py:858-880 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (23 lines × 2) colossalai/shardformer/modeling/_llama_tf4.py:149 — colossalai/shardformer/modeling/_llama_tf4.py:149-171 | colossalai/shardformer/modeling/_llama_tf5.py:205-227 — before extracting anything, compare `colossalai/shardformer/modeling/_llama_tf4.py` and `colossalai/shardformer/modeling/_llama_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_llama_tf4.py:149` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (23 lines × 2) colossalai/shardformer/modeling/_mixtral_tf4.py:724 — colossalai/shardformer/modeling/_mixtral_tf4.py:724-746 | colossalai/shardformer/modeling/_mixtral_tf5.py:1123-1145 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 581 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (23 lines × 2) colossalai/shardformer/modeling/_qwen2_tf4.py:316 — colossalai/shardformer/modeling/_qwen2_tf4.py:316-338 | colossalai/shardformer/modeling/_qwen2_tf5.py:225-247 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf4.py` and `colossalai/shardformer/modeling/_qwen2_tf5.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 242 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_qwen2_tf4.py:316` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (23 lines × 2) colossalai/shardformer/modeling/_qwen3_tf4.py:314 — colossalai/shardformer/modeling/_qwen3_tf4.py:314-336 | colossalai/shardformer/modeling/_qwen3_tf5.py:226-248 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen3_tf4.py` and `colossalai/shardformer/modeling/_qwen3_tf5.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 278 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_qwen3_tf4.py:314` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (23 lines × 2) colossalai/shardformer/policies/_bert_tf4.py:175 — colossalai/shardformer/policies/_bert_tf4.py:175-197 | colossalai/shardformer/policies/_bert_tf5.py:182-204 — before extracting anything, compare `colossalai/shardformer/policies/_bert_tf4.py` and `colossalai/shardformer/policies/_bert_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 475 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/policies/_bert_tf4.py:175` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (23 lines × 2) applications/ColossalChat/examples/training_scripts/train_grpo.py:195 — applications/ColossalChat/examples/training_scripts/train_grpo.py:195-217 | REDACTED:233-255 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_grpo.py` and `REDACTED` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 469 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/examples/training_scripts/train_grpo.py:195` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (23 lines × 2) REDACTED:62 — REDACTED:62-84 | REDACTED:58-80 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 194 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `REDACTED:89` calls `get_accelerator` and `REDACTED:85` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (23 lines × 2) examples/images/dreambooth/train_dreambooth_colossalai.py:503 — examples/images/dreambooth/train_dreambooth_colossalai.py:503-525 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:524-546 — before extracting anything, compare `examples/images/dreambooth/train_dreambooth_colossalai.py` and `examples/images/dreambooth/train_dreambooth_colossalai_lora.py` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 757 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/images/dreambooth/train_dreambooth_colossalai.py:503` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (23 lines × 2) examples/images/dreambooth/train_dreambooth_colossalai.py:661 — examples/images/dreambooth/train_dreambooth_colossalai.py:661-683 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:681-703 — before extracting anything, compare `examples/images/dreambooth/train_dreambooth_colossalai.py` and `examples/images/dreambooth/train_dreambooth_colossalai_lora.py` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 757 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D17 · Explicit Debt · HackComment · ×15
  • HackComment examples/tutorial/sequence_parallel/data/datasets/indexed_dataset.py:243 — # Hack just to make this work, can optimizer later if necessary — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
  • HackComment colossalai/tensor/d_tensor/api.py:143 — # hack some tensor methods — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
  • HackComment colossalai/tensor/d_tensor/api.py:158 — # hack some tensor methods — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
  • HackComment colossalai/quantization/utils.py:31 — # HACK this should be handled by C10D — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
  • HackComment colossalai/lazy/lazy_init.py:434 — # hack isinstance check of parameter — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
  • HackComment colossalai/kernel/triton/context_attn_unpad.py:344 — # HACK: KCache must be contiguous in order to apply the following offsets calculation — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
  • HackComment colossalai/inference/core/llm_engine.py:424 — # HACK Retrieve the running batch — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
  • HackComment colossalai/fx/codegen/activation_checkpoint_codegen.py:644 — # HACK: workaround for how torch custom ops are registered. We — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
  • HackComment colossalai/fx/codegen/activation_checkpoint_codegen.py:886 — # HACK: workaround for how torch custom ops are registered. We — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
  • HackComment colossalai/autochunk/autochunk_codegen.py:393 — # HACK: workaround for how torch custom ops are registered. We — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
  • HackComment colossalai/_analyzer/fx/codegen.py:265 — # HACK: workaround for how torch custom ops are registered. We — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
  • HackComment colossalai/device/device_mesh.py:219 — # hack the device attribute — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
  • HackComment applications/ColossalChat/examples/training_scripts/train_grpo.py:399 — # Hack: some old model's default update_model_kwargs_fn/prepare_inputs_fn may doesn't work due to version conflict with transformers, you can overwrite them — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
  • HackComment applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py:214 — # Hack: Skip empty dataset. If dataset contains less than num_of_rank samples, some rank may have empty dataset and leads to error — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
  • HackComment applications/ColossalChat/coati/experience_maker/naive.py:120 — # Hack: manually initialize cache_position to address transformer version conflict — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
D4 · Code Duplication · Duplicated block (11 lines × 3) · ×15
  • Duplicated block (11 lines × 3) colossalai/fx/tracer/meta_patch/patched_module/pooling.py:15 — colossalai/fx/tracer/meta_patch/patched_module/pooling.py:15-25 | colossalai/fx/tracer/meta_patch/patched_module/pooling.py:38-48 | colossalai/fx/tracer/meta_patch/patched_module/pooling.py:65-75 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/fx/tracer/meta_patch/patched_module/pooling.py:77` calls `floor` and `colossalai/fx/tracer/meta_patch/patched_module/pooling.py:51` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11 lines × 3) colossalai/inference/modeling/models/glide_llama.py:156 — colossalai/inference/modeling/models/glide_llama.py:156-166 | colossalai/shardformer/modeling/mistral.py:68-78 | colossalai/shardformer/modeling/mistral.py:411-421 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (11 lines × 3) colossalai/kernel/triton/context_attn_unpad.py:124 — colossalai/kernel/triton/context_attn_unpad.py:124-134 | colossalai/kernel/triton/context_attn_unpad.py:302-312 | colossalai/kernel/triton/context_attn_unpad.py:484-494 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (11 lines × 3) colossalai/legacy/moe/openmoe/model/openmoe_policy.py:336 — colossalai/legacy/moe/openmoe/model/openmoe_policy.py:336-346 | colossalai/shardformer/modeling/_mixtral_tf4.py:322-332 | colossalai/shardformer/modeling/deepseek.py:412-422 — before extracting anything, compare `colossalai/legacy/moe/openmoe/model/openmoe_policy.py` and `colossalai/shardformer/modeling/_mixtral_tf4.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 130 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (11 lines × 3) colossalai/legacy/moe/openmoe/train.py:171 — colossalai/legacy/moe/openmoe/train.py:171-184 | examples/images/vit/args.py:36-46 | examples/language/opt/args.py:24-34 — before extracting anything, compare `colossalai/legacy/moe/openmoe/train.py` and `examples/images/vit/args.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 57 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/moe/openmoe/train.py:171` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `examples/images/vit/args.py:48` calls `add_argument` and `examples/language/opt/args.py:37` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11 lines × 3) colossalai/legacy/nn/layer/parallel_2d/layers.py:122 — colossalai/legacy/nn/layer/parallel_2d/layers.py:122-132 | colossalai/legacy/nn/layer/parallel_2d/layers.py:953-963 | colossalai/legacy/nn/layer/parallel_2d/layers.py:1115-1125 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2d/layers.py:122` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 3) colossalai/legacy/nn/layer/parallel_2d/layers.py:133 — colossalai/legacy/nn/layer/parallel_2d/layers.py:133-143 | colossalai/legacy/nn/layer/parallel_2d/layers.py:297-307 | colossalai/legacy/nn/layer/parallel_2d/layers.py:1126-1136 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2d/layers.py:133` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 3) colossalai/legacy/nn/loss/loss_1d.py:64 — colossalai/legacy/nn/loss/loss_1d.py:64-74 | examples/language/gpt/titans/model/embed.py:301-311 | examples/tutorial/sequence_parallel/loss_func/cross_entropy.py:49-59 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
  • Duplicated block (11 lines × 3) colossalai/shardformer/layer/linear.py:526 — colossalai/shardformer/layer/linear.py:526-536 | colossalai/shardformer/layer/qkv_fused_linear.py:564-574 | colossalai/shardformer/layer/qkv_fused_linear.py:1143-1153 — before extracting anything, compare `colossalai/shardformer/layer/linear.py` and `colossalai/shardformer/layer/qkv_fused_linear.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 261 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (11 lines × 3) colossalai/shardformer/layer/qkv_fused_linear.py:287 — colossalai/shardformer/layer/qkv_fused_linear.py:287-297 | colossalai/shardformer/layer/qkv_fused_linear.py:882-892 | colossalai/shardformer/layer/qkv_fused_linear.py:1090-1100 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (11 lines × 3) colossalai/shardformer/modeling/_qwen2_tf4.py:634 — colossalai/shardformer/modeling/_qwen2_tf4.py:634-644 | colossalai/shardformer/modeling/_qwen3_tf4.py:626-636 | colossalai/shardformer/modeling/mistral.py:399-409 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf4.py` and `colossalai/shardformer/modeling/_qwen3_tf4.py` as WHOLE FILES: this scan already matched 52 separate duplicated blocks between them, totalling at least 1214 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (11 lines × 3) colossalai/shardformer/modeling/deepseek.py:716 — colossalai/shardformer/modeling/deepseek.py:716-726 | colossalai/shardformer/modeling/gptj.py:658-668 | colossalai/shardformer/modeling/gptj.py:834-844 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/deepseek.py:716` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 3) colossalai/shardformer/policies/_bert_tf4.py:468 — colossalai/shardformer/policies/_bert_tf4.py:468-478 | colossalai/shardformer/policies/_bert_tf5.py:475-485 | colossalai/shardformer/policies/_vit_tf4.py:262-272 — before extracting anything, compare `colossalai/shardformer/policies/_bert_tf4.py` and `colossalai/shardformer/policies/_bert_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 475 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/shardformer/policies/_bert_tf4.py:479` calls `is_last_stage` and `colossalai/shardformer/policies/_vit_tf4.py:273` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11 lines × 3) REDACTED:497 — REDACTED:497-507 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:539-549 | REDACTED:499-509 — before extracting anything, compare `REDACTED` and `examples/images/dreambooth/train_dreambooth_colossalai_lora.py` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 425 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (11 lines × 3) examples/images/vit/vit_benchmark.py:49 — examples/images/vit/vit_benchmark.py:49-59 | examples/images/vit/vit_train_demo.py:140-150 | examples/language/opt/opt_benchmark.py:52-62 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
D31 · IaC & Container Security · Medium IaC · ×14
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Duplicated block (20 lines × 2) · ×14
  • Duplicated block (20 lines × 2) applications/Colossal-LLaMA/colossal_llama/dataset/loader.py:28 — applications/Colossal-LLaMA/colossal_llama/dataset/loader.py:28-47 | applications/ColossalChat/coati/dataset/loader.py:35-54 — before extracting anything, compare `applications/Colossal-LLaMA/colossal_llama/dataset/loader.py` and `applications/ColossalChat/coati/dataset/loader.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 90 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (20 lines × 2) applications/ColossalEval/colossal_eval/models/chatglm.py:115 — applications/ColossalEval/colossal_eval/models/chatglm.py:115-134 | REDACTED:151-170 — before extracting anything, compare `applications/ColossalEval/colossal_eval/models/chatglm.py` and `REDACTED` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 72 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (20 lines × 2) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:751 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:751-770 | colossalai/checkpoint_io/moe_checkpoint.py:640-659 — before extracting anything, compare `colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py` and `colossalai/checkpoint_io/moe_checkpoint.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 249 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (20 lines × 2) colossalai/kernel/triton/flash_decoding.py:111 — colossalai/kernel/triton/flash_decoding.py:111-130 | colossalai/kernel/triton/flash_decoding.py:234-253 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (20 lines × 2) colossalai/legacy/inference/hybridengine/polices/llama.py:94 — colossalai/legacy/inference/hybridengine/polices/llama.py:94-113 | colossalai/legacy/inference/tensor_parallel/policies/llama.py:86-105 — before extracting anything, compare `colossalai/legacy/inference/hybridengine/polices/llama.py` and `colossalai/legacy/inference/tensor_parallel/policies/llama.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 37 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/inference/hybridengine/polices/llama.py:94` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 2) colossalai/legacy/nn/layer/parallel_2d/_operation.py:93 — colossalai/legacy/nn/layer/parallel_2d/_operation.py:93-112 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:45-64 — `colossalai/legacy/nn/layer/parallel_2d/_operation.py` and `colossalai/legacy/nn/layer/parallel_2p5d/_operation.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 185 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (20 lines × 2) colossalai/legacy/nn/layer/parallel_2d/layers.py:651 — colossalai/legacy/nn/layer/parallel_2d/layers.py:651-670 | colossalai/legacy/nn/layer/parallel_2d/layers.py:797-816 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2d/layers.py:651` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 2) colossalai/legacy/nn/layer/parallel_2p5d/layers.py:664 — colossalai/legacy/nn/layer/parallel_2p5d/layers.py:664-683 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:807-826 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2p5d/layers.py:664` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 2) colossalai/shardformer/modeling/_bert_tf4.py:341 — colossalai/shardformer/modeling/_bert_tf4.py:341-360 | colossalai/shardformer/modeling/_bert_tf5.py:354-373 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (20 lines × 2) colossalai/shardformer/modeling/gpt2.py:712 — colossalai/shardformer/modeling/gpt2.py:712-731 | colossalai/shardformer/modeling/gptj.py:375-394 — before extracting anything, compare `colossalai/shardformer/modeling/gpt2.py` and `colossalai/shardformer/modeling/gptj.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 321 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (20 lines × 2) REDACTED:187 — REDACTED:187-206 | REDACTED:208-227 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 24 separate duplicated blocks between them, totalling at least 499 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:187` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 2) REDACTED:648 — REDACTED:648-667 | REDACTED:696-715 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 24 separate duplicated blocks between them, totalling at least 499 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (20 lines × 2) examples/images/vit/args.py:5 — examples/images/vit/args.py:5-24 | examples/language/opt/args.py:5-24 — before extracting anything, compare `examples/images/vit/args.py` and `examples/language/opt/args.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 115 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (20 lines × 2) examples/language/gpt/titans/model/embed.py:91 — examples/language/gpt/titans/model/embed.py:91-110 | examples/language/gpt/titans/model/embed.py:436-455 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (21 lines × 2) · ×13
  • Duplicated block (21 lines × 2) applications/ColossalChat/coati/distributed/grpo_consumer.py:112 — applications/ColossalChat/coati/distributed/grpo_consumer.py:112-132 | applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py:112-132 — before extracting anything, compare `applications/ColossalChat/coati/distributed/grpo_consumer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 407 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: `BaseConsumer` names `coati.distributed.consumer` in one and `coati.distributed.zero_bubble.consumer` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (21 lines × 2) applications/ColossalChat/coati/distributed/producer.py:484 — applications/ColossalChat/coati/distributed/producer.py:484-504 | applications/ColossalChat/coati/distributed/zero_bubble/producer.py:511-531 — before extracting anything, compare `applications/ColossalChat/coati/distributed/producer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/producer.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 234 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (21 lines × 2) applications/ColossalChat/coati/trainer/grpo.py:296 — applications/ColossalChat/coati/trainer/grpo.py:296-316 | applications/ColossalChat/coati/trainer/ppo.py:296-316 — before extracting anything, compare `applications/ColossalChat/coati/trainer/grpo.py` and `applications/ColossalChat/coati/trainer/ppo.py` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 176 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (21 lines × 2) applications/ColossalEval/colossal_eval/dataset/safetybench_en.py:84 — applications/ColossalEval/colossal_eval/dataset/safetybench_en.py:84-104 | applications/ColossalEval/colossal_eval/dataset/safetybench_zh.py:84-104 — before extracting anything, compare `applications/ColossalEval/colossal_eval/dataset/safetybench_en.py` and `applications/ColossalEval/colossal_eval/dataset/safetybench_zh.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 86 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (21 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py:116 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py:116-136 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py:170-190 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py:116` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (21 lines × 2) colossalai/auto_parallel/tensor_shard/utils/misc.py:80 — colossalai/auto_parallel/tensor_shard/utils/misc.py:80-100 | colossalai/legacy/pipeline/rpc/utils.py:30-50 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (21 lines × 2) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:320 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:320-340 | colossalai/checkpoint_io/moe_checkpoint.py:211-231 — before extracting anything, compare `colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py` and `colossalai/checkpoint_io/moe_checkpoint.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 249 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:320` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/checkpoint_io/moe_checkpoint.py:233` calls `barrier` and `colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:342` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (21 lines × 2) colossalai/inference/kv_cache/kvcache_manager.py:71 — colossalai/inference/kv_cache/kvcache_manager.py:71-91 | colossalai/inference/kv_cache/kvcache_manager.py:548-568 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (21 lines × 2) colossalai/inference/modeling/layers/distrifusion.py:377 — colossalai/inference/modeling/layers/distrifusion.py:377-397 | colossalai/inference/modeling/layers/distrifusion.py:533-553 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (21 lines × 2) colossalai/legacy/nn/layer/parallel_2d/_operation.py:257 — colossalai/legacy/nn/layer/parallel_2d/_operation.py:257-277 | colossalai/legacy/nn/layer/parallel_2d/_operation.py:563-583 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/legacy/nn/layer/parallel_2d/_operation.py:278` calls `copy_`, `broadcast` and `colossalai/legacy/nn/layer/parallel_2d/_operation.py:584` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (21 lines × 2) colossalai/shardformer/modeling/_mixtral_tf4.py:324 — colossalai/shardformer/modeling/_mixtral_tf4.py:324-344 | colossalai/shardformer/modeling/deepseek.py:414-434 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/deepseek.py` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 427 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_mixtral_tf4.py:324` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/shardformer/modeling/deepseek.py:437` calls `decoder_layer` and `colossalai/shardformer/modeling/_mixtral_tf4.py:345` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (21 lines × 2) colossalai/shardformer/modeling/_qwen2_tf4.py:609 — colossalai/shardformer/modeling/_qwen2_tf4.py:609-629 | colossalai/shardformer/modeling/_qwen3_tf4.py:601-621 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf4.py` and `colossalai/shardformer/modeling/_qwen3_tf4.py` as WHOLE FILES: this scan already matched 52 separate duplicated blocks between them, totalling at least 1214 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (21 lines × 2) examples/language/bert/finetune.py:199 — examples/language/bert/finetune.py:199-219 | examples/language/gpt/hybridparallelism/finetune.py:196-216 — before extracting anything, compare `examples/language/bert/finetune.py` and `examples/language/gpt/hybridparallelism/finetune.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 242 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (10–11 lines × 2) · ×12
  • Duplicated block (10–11 lines × 2) applications/ColossalChat/coati/dataset/tokenization_utils.py:154 — applications/ColossalChat/coati/dataset/tokenization_utils.py:154-163 | applications/ColossalChat/coati/dataset/tokenization_utils.py:242-252 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10–11 lines × 2) colossalai/auto_parallel/checkpoint/ckpt_solver_base.py:158 — colossalai/auto_parallel/checkpoint/ckpt_solver_base.py:158-168 | colossalai/auto_parallel/offload/region_manager.py:387-396 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (10–11 lines × 2) colossalai/fx/proxy.py:81 — colossalai/fx/proxy.py:81-90 | colossalai/fx/tracer/_tracer_utils.py:24-34 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (10–11 lines × 2) colossalai/inference/core/diffusion_engine.py:174 — colossalai/inference/core/diffusion_engine.py:174-183 | colossalai/inference/core/llm_engine.py:630-640 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (10–11 lines × 2) colossalai/inference/core/llm_engine.py:194 — colossalai/inference/core/llm_engine.py:194-203 | colossalai/inference/executor/rpc_worker.py:242-252 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/inference/core/llm_engine.py:194` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10–11 lines × 2) colossalai/inference/modeling/layers/attention.py:217 — colossalai/inference/modeling/layers/attention.py:217-227 | colossalai/inference/modeling/layers/attention.py:279-288 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10–11 lines × 2) colossalai/legacy/nn/layer/parallel_2d/_operation.py:269 — colossalai/legacy/nn/layer/parallel_2d/_operation.py:269-279 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:227-236 — `colossalai/legacy/nn/layer/parallel_2d/_operation.py` and `colossalai/legacy/nn/layer/parallel_2p5d/_operation.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 185 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2d/_operation.py:269` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10–11 lines × 2) colossalai/legacy/nn/layer/parallel_3d/layers.py:237 — colossalai/legacy/nn/layer/parallel_3d/layers.py:237-246 | colossalai/legacy/nn/layer/parallel_3d/layers.py:567-577 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10–11 lines × 2) colossalai/legacy/nn/parallel/layers/cache_embedding/cache_mgr.py:417 — colossalai/legacy/nn/parallel/layers/cache_embedding/cache_mgr.py:417-427 | colossalai/legacy/nn/parallel/layers/cache_embedding/cache_mgr.py:435-444 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10–11 lines × 2) colossalai/pipeline/schedule/interleaved_pp.py:482 — colossalai/pipeline/schedule/interleaved_pp.py:482-491 | colossalai/pipeline/schedule/interleaved_pp.py:510-520 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10–11 lines × 2) colossalai/shardformer/layer/attn.py:723 — colossalai/shardformer/layer/attn.py:723-732 | colossalai/shardformer/layer/attn.py:743-753 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/layer/attn.py:723` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10–11 lines × 2) colossalai/shardformer/policies/blip2.py:49 — colossalai/shardformer/policies/blip2.py:49-59 | colossalai/shardformer/policies/sam.py:26-35 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
D36 · Supply-chain Provenance & Signing · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) · ×11
  • Members sharing a duplicated core (5 members, 50+ identical tokens) applications/Colossal-LLaMA/colossal_llama/utils/utils.py:26 — applications/Colossal-LLaMA/colossal_llama/utils/utils.py:26-36 | examples/language/deepseek/model_utils.py:22-32 | examples/language/llama/model_utils.py:22-32 | examples/language/mixtral/model_utils.py:22-32 | examples/language/model_utils.py:22-32 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:161 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:161-192 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:201-238 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/softmax_generator.py:66-95 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/sum_generator.py:63-103 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/unary_elementwise_generator.py:54-80 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) colossalai/inference/modeling/models/nopadding_llama.py:328 — colossalai/inference/modeling/models/nopadding_llama.py:328-371 | colossalai/inference/modeling/models/nopadding_llama.py:595-674 | colossalai/legacy/zero/sharded_model/sharded_model_v2.py:484-581 | colossalai/shardformer/layer/parallel_module.py:73-177 | colossalai/shardformer/layer/parallel_module.py:248-355 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) colossalai/inference/utils.py:23 — colossalai/inference/utils.py:23-64 | colossalai/legacy/inference/hybridengine/modeling/_utils.py:27-68 | colossalai/legacy/inference/quant/smoothquant/models/llama.py:513-554 | colossalai/legacy/inference/tensor_parallel/modeling/_utils.py:27-68 | colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:35-65 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) colossalai/legacy/inference/hybridengine/modeling/llama.py:212 — colossalai/legacy/inference/hybridengine/modeling/llama.py:212-339 | colossalai/legacy/inference/quant/smoothquant/models/llama.py:571-714 | colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:84-263 | colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:111-215 | colossalai/legacy/inference/tensor_parallel/modeling/llama.py:130-259 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:717 — colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:717-830 | colossalai/legacy/moe/openmoe/model/openmoe_policy.py:249-406 | colossalai/shardformer/modeling/_mixtral_tf4.py:202-405 | colossalai/shardformer/modeling/_mixtral_tf5.py:547-771 | colossalai/shardformer/modeling/deepseek.py:302-473 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) colossalai/legacy/nn/layer/parallel_1d/layers.py:566 — colossalai/legacy/nn/layer/parallel_1d/layers.py:566-587 | colossalai/shardformer/layer/linear.py:154-178 | colossalai/shardformer/layer/linear.py:332-376 | colossalai/shardformer/layer/qkv_fused_linear.py:956-998 | colossalai/shardformer/layer/qkv_fused_linear.py:1337-1355 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) examples/language/deepseek/performance_evaluator.py:40 — examples/language/deepseek/performance_evaluator.py:40-85 | examples/language/gpt/gemini/commons/performance_evaluator.py:40-85 | examples/language/llama/performance_evaluator.py:40-85 | examples/language/mixtral/performance_evaluator.py:40-85 | examples/language/performance_evaluator.py:40-85 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) examples/language/deepseek/performance_evaluator.py:127 — examples/language/deepseek/performance_evaluator.py:127-140 | examples/language/gpt/gemini/commons/performance_evaluator.py:127-140 | examples/language/llama/performance_evaluator.py:127-140 | examples/language/mixtral/performance_evaluator.py:127-140 | examples/language/performance_evaluator.py:127-140 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) examples/language/deepseek/performance_evaluator.py:150 — examples/language/deepseek/performance_evaluator.py:150-164 | examples/language/gpt/gemini/commons/performance_evaluator.py:150-164 | examples/language/llama/performance_evaluator.py:150-164 | examples/language/mixtral/performance_evaluator.py:150-164 | examples/language/performance_evaluator.py:150-164 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) examples/language/deepseek/performance_evaluator.py:167 — examples/language/deepseek/performance_evaluator.py:167-178 | examples/language/gpt/gemini/commons/performance_evaluator.py:167-178 | examples/language/llama/performance_evaluator.py:167-178 | examples/language/mixtral/performance_evaluator.py:167-178 | examples/language/performance_evaluator.py:167-178 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication · Duplicated block (24 lines × 2) · ×11
  • Duplicated block (24 lines × 2) applications/Colossal-LLaMA/colossal_llama/dataset/loader.py:115 — applications/Colossal-LLaMA/colossal_llama/dataset/loader.py:115-138 | applications/ColossalChat/coati/dataset/loader.py:119-142 — before extracting anything, compare `applications/Colossal-LLaMA/colossal_llama/dataset/loader.py` and `applications/ColossalChat/coati/dataset/loader.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 90 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/Colossal-LLaMA/colossal_llama/dataset/loader.py:115` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (24 lines × 2) applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:39 — applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:39-62 | applications/Colossal-LLaMA/dataset/prepare_sft_dataset.py:37-60 — before extracting anything, compare `applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py` and `applications/Colossal-LLaMA/dataset/prepare_sft_dataset.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 116 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `applications/Colossal-LLaMA/dataset/prepare_sft_dataset.py:36` calls `add_argument` and `applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:38` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (24 lines × 2) applications/ColossalEval/colossal_eval/evaluate/gpt_evaluate.py:565 — applications/ColossalEval/colossal_eval/evaluate/gpt_evaluate.py:565-588 | applications/ColossalEval/colossal_eval/evaluate/gpt_evaluate.py:600-623 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (24 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:241 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:241-264 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:358-381 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (24 lines × 2) colossalai/initialize.py:85 — colossalai/initialize.py:85-108 | colossalai/legacy/initialize.py:134-157 — before extracting anything, compare `colossalai/initialize.py` and `colossalai/legacy/initialize.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 107 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/initialize.py:85` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (24 lines × 2) colossalai/shardformer/modeling/_mixtral_tf4.py:382 — colossalai/shardformer/modeling/_mixtral_tf4.py:382-405 | colossalai/shardformer/modeling/_mixtral_tf5.py:748-771 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 581 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (24 lines × 2) colossalai/shardformer/policies/_bert_tf4.py:640 — colossalai/shardformer/policies/_bert_tf4.py:640-663 | colossalai/shardformer/policies/_bert_tf5.py:647-670 — before extracting anything, compare `colossalai/shardformer/policies/_bert_tf4.py` and `colossalai/shardformer/policies/_bert_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 475 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (24 lines × 2) colossalai/shardformer/policies/_bert_tf4.py:684 — colossalai/shardformer/policies/_bert_tf4.py:684-707 | colossalai/shardformer/policies/_bert_tf5.py:691-714 — before extracting anything, compare `colossalai/shardformer/policies/_bert_tf4.py` and `colossalai/shardformer/policies/_bert_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 475 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (24 lines × 2) colossalai/shardformer/policies/_bert_tf4.py:758 — colossalai/shardformer/policies/_bert_tf4.py:758-781 | colossalai/shardformer/policies/_bert_tf5.py:765-788 — before extracting anything, compare `colossalai/shardformer/policies/_bert_tf4.py` and `colossalai/shardformer/policies/_bert_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 475 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (24 lines × 2) examples/community/roberta/pretraining/model/bert.py:1350 — examples/community/roberta/pretraining/model/bert.py:1350-1373 | examples/community/roberta/pretraining/model/deberta_v2.py:1159-1182 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `examples/community/roberta/pretraining/model/bert.py:1350` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (24 lines × 2) examples/tutorial/hybrid_parallel/train.py:112 — examples/tutorial/hybrid_parallel/train.py:112-135 | examples/tutorial/large_batch_optimizer/train.py:77-100 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `examples/tutorial/hybrid_parallel/train.py:112` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `examples/tutorial/hybrid_parallel/train.py:136` calls `destroy` and `examples/tutorial/large_batch_optimizer/train.py:103` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (10 lines × 3) · ×11
  • Duplicated block (10 lines × 3) applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:28 — applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:28-37 | applications/Colossal-LLaMA/dataset/prepare_sft_dataset.py:25-34 | applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py:61-75 — before extracting anything, compare `applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py` and `applications/Colossal-LLaMA/dataset/prepare_sft_dataset.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 116 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py:61` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (10 lines × 3) colossalai/auto_parallel/tensor_shard/node_handler/addmm_handler.py:77 — colossalai/auto_parallel/tensor_shard/node_handler/addmm_handler.py:77-86 | colossalai/auto_parallel/tensor_shard/node_handler/binary_elementwise_handler.py:101-110 | colossalai/auto_parallel/tensor_shard/node_handler/bmm_handler.py:96-105 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/tensor_shard/node_handler/addmm_handler.py:77` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 3) colossalai/fx/tracer/meta_patch/patched_module/pooling.py:94 — colossalai/fx/tracer/meta_patch/patched_module/pooling.py:94-103 | colossalai/fx/tracer/meta_patch/patched_module/pooling.py:118-127 | colossalai/fx/tracer/meta_patch/patched_module/pooling.py:146-155 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/fx/tracer/meta_patch/patched_module/pooling.py:159` calls `floor` and `colossalai/fx/tracer/meta_patch/patched_module/pooling.py:132` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 3) colossalai/legacy/moe/openmoe/model/convert_openmoe_ckpt.py:54 — colossalai/legacy/moe/openmoe/model/convert_openmoe_ckpt.py:54-63 | colossalai/legacy/moe/openmoe/model/convert_openmoe_ckpt.py:67-76 | colossalai/legacy/moe/openmoe/model/convert_openmoe_ckpt.py:80-89 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (10 lines × 3) colossalai/legacy/nn/layer/parallel_3d/layers.py:259 — colossalai/legacy/nn/layer/parallel_3d/layers.py:259-268 | colossalai/legacy/nn/layer/parallel_3d/layers.py:435-444 | colossalai/legacy/nn/layer/parallel_3d/layers.py:591-600 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_3d/layers.py:259` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 3) colossalai/nn/optimizer/distributed_adafactor.py:234 — colossalai/nn/optimizer/distributed_adafactor.py:234-243 | colossalai/nn/optimizer/distributed_came.py:227-237 | colossalai/nn/optimizer/distributed_came.py:281-290 — before extracting anything, compare `colossalai/nn/optimizer/distributed_adafactor.py` and `colossalai/nn/optimizer/distributed_came.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 201 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 3) colossalai/shardformer/modeling/_bert_tf4.py:85 — colossalai/shardformer/modeling/_bert_tf4.py:85-94 | colossalai/shardformer/modeling/_bert_tf5.py:87-96 | examples/community/roberta/pretraining/model/bert.py:945-954 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 3) colossalai/shardformer/modeling/_mixtral_tf4.py:675 — colossalai/shardformer/modeling/_mixtral_tf4.py:675-684 | colossalai/shardformer/modeling/_mixtral_tf5.py:1069-1078 | colossalai/shardformer/modeling/deepseek.py:710-719 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 581 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_mixtral_tf4.py:675` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 3) colossalai/shardformer/policies/_mixtral_tf4.py:55 — colossalai/shardformer/policies/_mixtral_tf4.py:55-65 | colossalai/shardformer/policies/_mixtral_tf5.py:61-71 | colossalai/shardformer/policies/deepseek.py:63-72 — before extracting anything, compare `colossalai/shardformer/policies/_mixtral_tf4.py` and `colossalai/shardformer/policies/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 408 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 3) colossalai/shardformer/policies/_vit_tf4.py:42 — colossalai/shardformer/policies/_vit_tf4.py:42-51 | colossalai/shardformer/policies/gptj.py:50-59 | colossalai/shardformer/policies/opt.py:83-92 — before extracting anything, compare `colossalai/shardformer/policies/gptj.py` and `colossalai/shardformer/policies/opt.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 64 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 3) examples/language/deepseek/benchmark.py:193 — examples/language/deepseek/benchmark.py:193-202 | examples/language/llama/benchmark.py:292-301 | examples/language/mixtral/benchmark.py:195-204 — `examples/language/deepseek/benchmark.py` and `examples/language/llama/benchmark.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 10 separate duplicated blocks between them, totalling at least 150 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `examples/language/deepseek/benchmark.py:193` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (7 lines × 3) · ×11
  • Duplicated block (7 lines × 3) applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:112 — applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:112-118 | applications/Colossal-LLaMA/dataset/prepare_sft_dataset.py:126-132 | applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py:245-251 — before extracting anything, compare `applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py` and `applications/Colossal-LLaMA/dataset/prepare_sft_dataset.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 116 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:111` calls `time` and `applications/Colossal-LLaMA/dataset/prepare_sft_dataset.py:124` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 3) applications/Colossal-LLaMA/train.py:369 — applications/Colossal-LLaMA/train.py:369-375 | applications/ColossalChat/examples/training_scripts/lora_finetune.py:302-308 | applications/ColossalChat/examples/training_scripts/lora_finetune.py:340-346 — before extracting anything, compare `applications/Colossal-LLaMA/train.py` and `applications/ColossalChat/examples/training_scripts/lora_finetune.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 132 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 3) colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:318 — colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:318-325 | colossalai/shardformer/modeling/falcon.py:410-416 | colossalai/shardformer/modeling/falcon.py:784-790 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (7 lines × 3) colossalai/shardformer/layer/_operation.py:110 — colossalai/shardformer/layer/_operation.py:110-116 | colossalai/shardformer/layer/_operation.py:200-206 | colossalai/shardformer/layer/_operation.py:922-928 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (7 lines × 3) colossalai/shardformer/modeling/_bert_tf4.py:107 — colossalai/shardformer/modeling/_bert_tf4.py:107-113 | colossalai/shardformer/modeling/_bert_tf5.py:109-115 | examples/community/roberta/pretraining/model/bert.py:974-980 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `examples/community/roberta/pretraining/model/bert.py:972` calls `ones` and `colossalai/shardformer/modeling/_bert_tf4.py:106` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 3) colossalai/shardformer/modeling/_deepseek_v3_tf5.py:116 — colossalai/shardformer/modeling/_deepseek_v3_tf5.py:116-122 | colossalai/shardformer/modeling/_mixtral_tf4.py:122-128 | colossalai/shardformer/modeling/_mixtral_tf5.py:470-476 — before extracting anything, compare `colossalai/shardformer/modeling/_deepseek_v3_tf5.py` and `colossalai/shardformer/modeling/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 62 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 3) colossalai/shardformer/modeling/_llama_tf4.py:574 — colossalai/shardformer/modeling/_llama_tf4.py:574-580 | colossalai/shardformer/modeling/_qwen2_tf4.py:570-576 | colossalai/shardformer/modeling/_qwen3_tf4.py:562-568 — before extracting anything, compare `colossalai/shardformer/modeling/_llama_tf4.py` and `colossalai/shardformer/modeling/_qwen2_tf4.py` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 241 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 3) colossalai/shardformer/modeling/_qwen2_tf4.py:491 — colossalai/shardformer/modeling/_qwen2_tf4.py:491-497 | colossalai/shardformer/modeling/_qwen3_tf4.py:477-483 | colossalai/shardformer/modeling/deepseek.py:599-605 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf4.py` and `colossalai/shardformer/modeling/_qwen3_tf4.py` as WHOLE FILES: this scan already matched 52 separate duplicated blocks between them, totalling at least 1214 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_qwen2_tf4.py:491` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 3) colossalai/shardformer/policies/bloom.py:318 — colossalai/shardformer/policies/bloom.py:318-324 | colossalai/shardformer/policies/falcon.py:256-262 | colossalai/shardformer/policies/gptj.py:280-286 — before extracting anything, compare `colossalai/shardformer/policies/bloom.py` and `colossalai/shardformer/policies/falcon.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 132 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 3) colossalai/shardformer/policies/bloom.py:574 — colossalai/shardformer/policies/bloom.py:574-580 | colossalai/shardformer/policies/falcon.py:549-555 | colossalai/shardformer/policies/t5.py:834-842 — before extracting anything, compare `colossalai/shardformer/policies/bloom.py` and `colossalai/shardformer/policies/falcon.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 132 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 3) examples/images/vit/vit_benchmark.py:18 — examples/images/vit/vit_benchmark.py:18-24 | examples/language/bert/benchmark_utils.py:21-27 | examples/language/opt/opt_benchmark.py:24-30 — before extracting anything, compare `examples/images/vit/vit_benchmark.py` and `examples/language/opt/opt_benchmark.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 57 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `examples/language/opt/opt_benchmark.py:20` calls `require_version` and `examples/images/vit/vit_benchmark.py:14` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D30 · Dependency Vulnerabilities · Medium CVE · ×10
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Duplicated block (30 lines × 2) · ×10
  • Duplicated block (30 lines × 2) applications/Colossal-LLaMA/train.py:313 — applications/Colossal-LLaMA/train.py:313-342 | applications/Colossal-LLaMA/train.py:384-413 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (30 lines × 2) colossalai/legacy/moe/layer/experts.py:112 — colossalai/legacy/moe/layer/experts.py:112-141 | colossalai/legacy/moe/layer/routers.py:112-141 — before extracting anything, compare `colossalai/legacy/moe/layer/experts.py` and `colossalai/legacy/moe/layer/routers.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 90 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (30 lines × 2) colossalai/legacy/pipeline/rpc/_pipeline_base.py:586 — colossalai/legacy/pipeline/rpc/_pipeline_base.py:586-615 | colossalai/legacy/pipeline/rpc/_pipeline_base.py:673-702 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (30 lines × 2) colossalai/legacy/utils/memory.py:28 — colossalai/legacy/utils/memory.py:28-57 | colossalai/utils/memory.py:15-44 — before extracting anything, compare `colossalai/legacy/utils/memory.py` and `colossalai/utils/memory.py` as WHOLE FILES: 89% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (30 lines × 2) colossalai/shardformer/modeling/_bert_tf4.py:179 — colossalai/shardformer/modeling/_bert_tf4.py:179-208 | colossalai/shardformer/modeling/_bert_tf5.py:207-236 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (30 lines × 2) colossalai/shardformer/modeling/_qwen2_tf5.py:241 — colossalai/shardformer/modeling/_qwen2_tf5.py:241-270 | colossalai/shardformer/modeling/_qwen3_tf5.py:242-271 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf5.py` and `colossalai/shardformer/modeling/_qwen3_tf5.py` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 628 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_qwen2_tf5.py:241` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (30 lines × 2) colossalai/shardformer/modeling/_qwen2_tf5.py:414 — colossalai/shardformer/modeling/_qwen2_tf5.py:414-443 | colossalai/shardformer/modeling/_qwen3_tf5.py:415-444 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf5.py` and `colossalai/shardformer/modeling/_qwen3_tf5.py` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 628 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (30 lines × 2) colossalai/shardformer/policies/_whisper_tf4.py:474 — colossalai/shardformer/policies/_whisper_tf4.py:474-503 | colossalai/shardformer/policies/_whisper_tf5.py:461-490 — before extracting anything, compare `colossalai/shardformer/policies/_whisper_tf4.py` and `colossalai/shardformer/policies/_whisper_tf5.py` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/policies/_whisper_tf4.py:474` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (30 lines × 2) colossalai/shardformer/policies/_whisper_tf4.py:782 — colossalai/shardformer/policies/_whisper_tf4.py:782-811 | colossalai/shardformer/policies/_whisper_tf5.py:769-798 — before extracting anything, compare `colossalai/shardformer/policies/_whisper_tf4.py` and `colossalai/shardformer/policies/_whisper_tf5.py` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (30 lines × 2) applications/ColossalChat/examples/training_scripts/train_grpo.py:50 — applications/ColossalChat/examples/training_scripts/train_grpo.py:50-79 | REDACTED:59-88 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_grpo.py` and `REDACTED` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 469 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (6 lines × 3) · ×10
  • Duplicated block (6 lines × 3) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:193 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:193-198 | colossalai/checkpoint_io/utils.py:418-423 | colossalai/zero/gemini/gemini_ddp.py:980-985 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
  • Duplicated block (6 lines × 3) colossalai/fx/tracer/meta_patch/patched_function/convolution.py:122 — colossalai/fx/tracer/meta_patch/patched_function/convolution.py:122-127 | colossalai/fx/tracer/meta_patch/patched_function/convolution.py:147-152 | colossalai/fx/tracer/meta_patch/patched_function/convolution.py:176-181 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/fx/tracer/meta_patch/patched_function/convolution.py:122` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 3) colossalai/legacy/nn/layer/parallel_2d/layers.py:543 — colossalai/legacy/nn/layer/parallel_2d/layers.py:543-548 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:556-561 | colossalai/legacy/nn/layer/parallel_3d/layers.py:826-831 — `colossalai/legacy/nn/layer/parallel_2d/layers.py` and `colossalai/legacy/nn/layer/parallel_2p5d/layers.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 18 separate duplicated blocks between them, totalling at least 219 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2d/layers.py:543` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 3) colossalai/nn/optimizer/distributed_adafactor.py:162 — colossalai/nn/optimizer/distributed_adafactor.py:162-167 | colossalai/nn/optimizer/distributed_adafactor.py:195-200 | colossalai/nn/optimizer/distributed_adafactor.py:243-248 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (6 lines × 3) colossalai/shardformer/layer/_operation.py:283 — colossalai/shardformer/layer/_operation.py:283-288 | colossalai/shardformer/layer/_operation.py:370-375 | colossalai/shardformer/layer/_operation.py:588-593 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (6 lines × 3) colossalai/shardformer/layer/linear.py:268 — colossalai/shardformer/layer/linear.py:268-273 | colossalai/shardformer/layer/qkv_fused_linear.py:292-297 | colossalai/shardformer/layer/qkv_fused_linear.py:887-892 — before extracting anything, compare `colossalai/shardformer/layer/linear.py` and `colossalai/shardformer/layer/qkv_fused_linear.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 261 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (6 lines × 3) colossalai/shardformer/modeling/_whisper_tf4.py:683 — colossalai/shardformer/modeling/_whisper_tf4.py:683-688 | colossalai/shardformer/modeling/_whisper_tf4.py:904-909 | colossalai/shardformer/modeling/opt.py:89-94 — before extracting anything, compare `colossalai/shardformer/modeling/_whisper_tf4.py` and `colossalai/shardformer/modeling/opt.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 105 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (6 lines × 3) colossalai/legacy/nn/parallel/data_parallel.py:15 — colossalai/legacy/nn/parallel/data_parallel.py:15-20 | colossalai/legacy/zero/sharded_model/_utils.py:17-22 | colossalai/utils/common.py:58-63 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
  • Duplicated block (6 lines × 3) applications/ColossalChat/examples/training_scripts/train_dpo.py:140 — applications/ColossalChat/examples/training_scripts/train_dpo.py:140-145 | applications/ColossalChat/examples/training_scripts/train_kto.py:140-145 | applications/ColossalChat/examples/training_scripts/train_orpo.py:129-134 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_dpo.py` and `applications/ColossalChat/examples/training_scripts/train_kto.py` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 289 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `applications/ColossalChat/examples/training_scripts/train_dpo.py:138` calls `train` and `applications/ColossalChat/examples/training_scripts/train_kto.py:138` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 3) examples/images/resnet/train.py:198 — examples/images/resnet/train.py:198-203 | examples/tutorial/new_api/cifar_resnet/train.py:198-203 | examples/tutorial/new_api/cifar_vit/train.py:218-223 — before extracting anything, compare `examples/images/resnet/train.py` and `examples/tutorial/new_api/cifar_resnet/train.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 158 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (25 lines × 2) · ×9
  • Duplicated block (25 lines × 2) applications/ColossalChat/coati/trainer/dpo.py:136 — applications/ColossalChat/coati/trainer/dpo.py:136-160 | applications/ColossalChat/coati/trainer/dpo.py:427-451 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `applications/ColossalChat/coati/trainer/dpo.py:425` calls `no_grad` and `applications/ColossalChat/coati/trainer/dpo.py:134` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (25 lines × 2) applications/ColossalChat/coati/trainer/grpo.py:362 — applications/ColossalChat/coati/trainer/grpo.py:362-386 | applications/ColossalChat/coati/trainer/ppo.py:372-396 — before extracting anything, compare `applications/ColossalChat/coati/trainer/grpo.py` and `applications/ColossalChat/coati/trainer/ppo.py` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 176 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (25 lines × 2) applications/ColossalEval/colossal_eval/dataset/safetybench_en.py:56 — applications/ColossalEval/colossal_eval/dataset/safetybench_en.py:56-80 | applications/ColossalEval/colossal_eval/dataset/safetybench_zh.py:56-80 — before extracting anything, compare `applications/ColossalEval/colossal_eval/dataset/safetybench_en.py` and `applications/ColossalEval/colossal_eval/dataset/safetybench_zh.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 86 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (25 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/node_handler.py:264 — colossalai/auto_parallel/tensor_shard/node_handler/node_handler.py:264-288 | colossalai/auto_parallel/tensor_shard/node_handler/node_handler.py:319-343 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (25 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:847 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:847-871 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:889-913 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:847` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (25 lines × 2) colossalai/initialize.py:122 — colossalai/initialize.py:122-146 | colossalai/legacy/initialize.py:173-197 — before extracting anything, compare `colossalai/initialize.py` and `colossalai/legacy/initialize.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 107 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/initialize.py:122` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (25 lines × 2) colossalai/shardformer/modeling/_bert_tf4.py:1224 — colossalai/shardformer/modeling/_bert_tf4.py:1224-1248 | colossalai/shardformer/modeling/_bert_tf5.py:1218-1242 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_bert_tf4.py:1224` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (25 lines × 2) colossalai/shardformer/modeling/_deepseek_v3_tf4.py:232 — colossalai/shardformer/modeling/_deepseek_v3_tf4.py:232-256 | colossalai/shardformer/modeling/deepseek.py:808-832 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_deepseek_v3_tf4.py:232` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (25 lines × 2) colossalai/shardformer/modeling/_mixtral_tf4.py:764 — colossalai/shardformer/modeling/_mixtral_tf4.py:764-788 | colossalai/shardformer/modeling/_mixtral_tf5.py:1158-1182 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 581 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_mixtral_tf4.py:764` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (11 lines × 4) · ×9
  • Duplicated block (11 lines × 4) colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:289 — colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:289-299 | colossalai/shardformer/modeling/bloom.py:346-356 | colossalai/shardformer/modeling/bloom.py:438-448 | colossalai/shardformer/modeling/bloom.py:564-574 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (11 lines × 4) colossalai/legacy/zero/sharded_model/sharded_model_v2.py:568 — colossalai/legacy/zero/sharded_model/sharded_model_v2.py:568-578 | colossalai/shardformer/layer/parallel_module.py:164-174 | colossalai/shardformer/layer/parallel_module.py:342-352 | colossalai/zero/gemini/gemini_ddp.py:805-815 — before extracting anything, compare `colossalai/legacy/zero/sharded_model/sharded_model_v2.py` and `colossalai/shardformer/layer/parallel_module.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 96 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (11 lines × 4) colossalai/shardformer/modeling/_qwen2_tf4.py:249 — colossalai/shardformer/modeling/_qwen2_tf4.py:249-259 | colossalai/shardformer/modeling/_qwen3_tf4.py:247-257 | colossalai/shardformer/modeling/deepseek.py:459-469 | colossalai/shardformer/modeling/gptj.py:243-256 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf4.py` and `colossalai/shardformer/modeling/_qwen3_tf4.py` as WHOLE FILES: this scan already matched 52 separate duplicated blocks between them, totalling at least 1214 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (11 lines × 4) colossalai/shardformer/policies/_bert_tf4.py:584 — colossalai/shardformer/policies/_bert_tf4.py:584-594 | colossalai/shardformer/policies/_bert_tf4.py:624-634 | colossalai/shardformer/policies/_bert_tf5.py:591-601 | colossalai/shardformer/policies/_bert_tf5.py:631-641 — before extracting anything, compare `colossalai/shardformer/policies/_bert_tf4.py` and `colossalai/shardformer/policies/_bert_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 475 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (11 lines × 4) colossalai/shardformer/policies/gpt2.py:363 — colossalai/shardformer/policies/gpt2.py:363-373 | colossalai/shardformer/policies/gptj.py:326-336 | colossalai/shardformer/policies/gptj.py:429-439 | colossalai/shardformer/policies/gptj.py:465-475 — before extracting anything, compare `colossalai/shardformer/policies/gpt2.py` and `colossalai/shardformer/policies/gptj.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 65 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (11 lines × 4) applications/ColossalChat/examples/training_scripts/train_dpo.py:175 — applications/ColossalChat/examples/training_scripts/train_dpo.py:175-185 | applications/ColossalChat/examples/training_scripts/train_kto.py:197-207 | applications/ColossalChat/examples/training_scripts/train_orpo.py:164-175 | applications/ColossalChat/examples/training_scripts/train_rm.py:174-185 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_dpo.py` and `applications/ColossalChat/examples/training_scripts/train_kto.py` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 289 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (11 lines × 4) colossalai/shardformer/examples/convergence_benchmark.py:154 — colossalai/shardformer/examples/convergence_benchmark.py:154-164 | examples/language/bert/finetune.py:115-125 | examples/language/gpt/hybridparallelism/finetune.py:111-121 | examples/tutorial/new_api/glue_bert/finetune.py:68-78 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (11 lines × 4) colossalai/shardformer/examples/data.py:55 — colossalai/shardformer/examples/data.py:55-65 | examples/language/bert/data.py:54-64 | examples/language/gpt/hybridparallelism/data.py:54-64 | examples/tutorial/new_api/glue_bert/data.py:54-64 — before extracting anything, compare `colossalai/shardformer/examples/data.py` and `examples/language/bert/data.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 41 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `examples/language/gpt/hybridparallelism/data.py:65` calls `getattr` and `colossalai/shardformer/examples/data.py:66` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11 lines × 4) examples/language/bert/benchmark.py:93 — examples/language/bert/benchmark.py:93-103 | examples/tutorial/new_api/cifar_resnet/train.py:142-152 | examples/tutorial/new_api/cifar_vit/train.py:162-172 | examples/tutorial/new_api/glue_bert/finetune.py:138-148 — `examples/tutorial/new_api/cifar_resnet/train.py` and `examples/tutorial/new_api/cifar_vit/train.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 136 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (9 lines × 3) · ×9
  • Duplicated block (9 lines × 3) applications/Colossal-LLaMA/colossal_llama/model/init_model.py:19 — applications/Colossal-LLaMA/colossal_llama/model/init_model.py:19-27 | applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:27-37 | applications/Colossal-LLaMA/dataset/prepare_sft_dataset.py:24-34 — before extracting anything, compare `applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py` and `applications/Colossal-LLaMA/dataset/prepare_sft_dataset.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 116 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (9 lines × 3) applications/Colossal-LLaMA/colossal_llama/utils/ckpt_io.py:60 — applications/Colossal-LLaMA/colossal_llama/utils/ckpt_io.py:60-68 | applications/ColossalChat/coati/utils/ckpt_io.py:61-69 | applications/ColossalMoE/utils.py:52-60 — before extracting anything, compare `applications/Colossal-LLaMA/colossal_llama/utils/ckpt_io.py` and `applications/ColossalChat/coati/utils/ckpt_io.py` as WHOLE FILES: 89% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 2 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (9 lines × 3) applications/ColossalChat/coati/dataset/tokenization_utils.py:57 — applications/ColossalChat/coati/dataset/tokenization_utils.py:57-65 | applications/ColossalChat/coati/dataset/tokenization_utils.py:158-166 | applications/ColossalChat/coati/dataset/tokenization_utils.py:246-254 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (9 lines × 3) applications/ColossalEval/colossal_eval/dataset/ceval.py:108 — applications/ColossalEval/colossal_eval/dataset/ceval.py:108-116 | applications/ColossalEval/colossal_eval/dataset/cmmlu.py:119-127 | applications/ColossalEval/colossal_eval/dataset/mmlu.py:49-57 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `applications/ColossalEval/colossal_eval/dataset/cmmlu.py:128` calls `next` and `applications/ColossalEval/colossal_eval/dataset/mmlu.py:58` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 3) colossalai/_analyzer/fx/tracer/tracer.py:343 — colossalai/_analyzer/fx/tracer/tracer.py:343-351 | colossalai/fx/tracer/experimental.py:370-378 | colossalai/fx/tracer/tracer.py:157-165 — before extracting anything, compare `colossalai/_analyzer/fx/tracer/tracer.py` and `colossalai/fx/tracer/experimental.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 93 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/_analyzer/fx/tracer/tracer.py:343` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 3) colossalai/fx/tracer/experimental.py:273 — colossalai/fx/tracer/experimental.py:273-281 | colossalai/fx/tracer/experimental.py:481-489 | colossalai/fx/tracer/tracer.py:344-352 — before extracting anything, compare `colossalai/fx/tracer/experimental.py` and `colossalai/fx/tracer/tracer.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 138 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (9 lines × 3) colossalai/shardformer/policies/bloom.py:472 — colossalai/shardformer/policies/bloom.py:472-480 | colossalai/shardformer/policies/falcon.py:420-428 | colossalai/shardformer/policies/mistral.py:472-480 — before extracting anything, compare `colossalai/shardformer/policies/bloom.py` and `colossalai/shardformer/policies/falcon.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 132 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (9 lines × 3) extensions/pybind/flash_attention/flash_attention_dao_cuda.py:51 — extensions/pybind/flash_attention/flash_attention_dao_cuda.py:51-59 | extensions/pybind/flash_attention/flash_attention_npu.py:43-51 | extensions/pybind/flash_attention/flash_attention_sdpa_cuda.py:38-46 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `extensions/pybind/flash_attention/flash_attention_dao_cuda.py:51` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 3) examples/images/vit/args.py:71 — examples/images/vit/args.py:71-79 | examples/language/opt/args.py:22-33 | examples/language/opt/args.py:54-64 — before extracting anything, compare `examples/images/vit/args.py` and `examples/language/opt/args.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 115 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/images/vit/args.py:71` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `examples/images/vit/args.py:69` calls `add_argument` and `examples/language/opt/args.py:53` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D36 · Supply-chain Provenance & Signing · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Duplicated block (28 lines × 2) · ×8
  • Duplicated block (28 lines × 2) applications/ColossalChat/coati/distributed/consumer.py:190 — applications/ColossalChat/coati/distributed/consumer.py:190-217 | applications/ColossalChat/coati/distributed/consumer.py:279-306 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (28 lines × 2) colossalai/fx/passes/concrete_info_prop.py:232 — colossalai/fx/passes/concrete_info_prop.py:232-259 | colossalai/fx/passes/meta_info_prop.py:261-288 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (28 lines × 2) colossalai/initialize.py:155 — colossalai/initialize.py:155-182 | colossalai/legacy/initialize.py:209-236 — before extracting anything, compare `colossalai/initialize.py` and `colossalai/legacy/initialize.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 107 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/initialize.py:155` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (28 lines × 2) colossalai/shardformer/modeling/_bert_tf4.py:629 — colossalai/shardformer/modeling/_bert_tf4.py:629-656 | colossalai/shardformer/modeling/_bert_tf5.py:642-669 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_bert_tf4.py:629` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (28 lines × 2) colossalai/shardformer/modeling/bloom.py:38 — colossalai/shardformer/modeling/bloom.py:38-65 | colossalai/shardformer/modeling/falcon.py:33-60 — before extracting anything, compare `colossalai/shardformer/modeling/bloom.py` and `colossalai/shardformer/modeling/falcon.py` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 594 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/bloom.py:38` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (28 lines × 2) colossalai/shardformer/modeling/bloom.py:252 — colossalai/shardformer/modeling/bloom.py:252-279 | colossalai/shardformer/modeling/bloom.py:1033-1060 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/bloom.py:252` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (28 lines × 2) colossalai/shardformer/policies/_mixtral_tf4.py:452 — colossalai/shardformer/policies/_mixtral_tf4.py:452-479 | colossalai/shardformer/policies/_mixtral_tf5.py:479-506 — before extracting anything, compare `colossalai/shardformer/policies/_mixtral_tf4.py` and `colossalai/shardformer/policies/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 408 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (28 lines × 2) REDACTED:398 — REDACTED:398-425 | REDACTED:424-451 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 24 separate duplicated blocks between them, totalling at least 499 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (16 lines × 3) · ×8
  • Duplicated block (16 lines × 3) applications/ColossalChat/coati/trainer/dpo.py:427 — applications/ColossalChat/coati/trainer/dpo.py:427-442 | applications/ColossalChat/coati/trainer/dpo.py:553-568 | applications/ColossalChat/coati/trainer/orpo.py:261-276 — before extracting anything, compare `applications/ColossalChat/coati/trainer/dpo.py` and `applications/ColossalChat/coati/trainer/orpo.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 133 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `applications/ColossalChat/coati/trainer/orpo.py:257` calls `reset` and `applications/ColossalChat/coati/trainer/dpo.py:550` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (16 lines × 3) colossalai/legacy/inference/quant/smoothquant/models/linear.py:19 — colossalai/legacy/inference/quant/smoothquant/models/linear.py:19-34 | colossalai/legacy/inference/quant/smoothquant/models/linear.py:69-84 | colossalai/legacy/inference/quant/smoothquant/models/linear.py:125-140 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/inference/quant/smoothquant/models/linear.py:19` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 3) colossalai/legacy/nn/layer/parallel_2d/layers.py:149 — colossalai/legacy/nn/layer/parallel_2d/layers.py:149-164 | colossalai/legacy/nn/layer/parallel_2d/layers.py:313-328 | colossalai/legacy/nn/layer/parallel_2d/layers.py:1144-1159 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2d/layers.py:149` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 3) colossalai/shardformer/modeling/_llama_tf4.py:335 — colossalai/shardformer/modeling/_llama_tf4.py:335-350 | colossalai/shardformer/modeling/_llama_tf5.py:377-392 | colossalai/shardformer/modeling/gpt2.py:381-396 — before extracting anything, compare `colossalai/shardformer/modeling/_llama_tf4.py` and `colossalai/shardformer/modeling/_llama_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_llama_tf4.py:335` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 3) colossalai/shardformer/modeling/_qwen2_tf4.py:178 — colossalai/shardformer/modeling/_qwen2_tf4.py:178-193 | colossalai/shardformer/modeling/_qwen3_tf4.py:176-191 | colossalai/shardformer/modeling/command.py:162-177 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf4.py` and `colossalai/shardformer/modeling/_qwen3_tf4.py` as WHOLE FILES: this scan already matched 52 separate duplicated blocks between them, totalling at least 1214 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_qwen2_tf4.py:178` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 3) colossalai/shardformer/modeling/t5.py:328 — colossalai/shardformer/modeling/t5.py:328-343 | colossalai/shardformer/modeling/t5.py:469-484 | colossalai/shardformer/modeling/t5.py:589-604 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (16 lines × 3) examples/community/roberta/pretraining/model/bert.py:1547 — examples/community/roberta/pretraining/model/bert.py:1547-1562 | examples/community/roberta/pretraining/model/bert.py:1658-1673 | examples/community/roberta/pretraining/model/bert.py:1745-1760 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `examples/community/roberta/pretraining/model/bert.py:1674` calls `view` and `examples/community/roberta/pretraining/model/bert.py:1564` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (16 lines × 3) examples/images/resnet/train.py:82 — examples/images/resnet/train.py:82-97 | examples/tutorial/new_api/cifar_resnet/train.py:82-97 | examples/tutorial/new_api/cifar_vit/train.py:102-117 — before extracting anything, compare `examples/images/resnet/train.py` and `examples/tutorial/new_api/cifar_resnet/train.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 158 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (9–10 lines × 2) · ×8
  • Duplicated block (9–10 lines × 2) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:353 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:353-361 | colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:629-638 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:353` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9–10 lines × 2) colossalai/checkpoint_io/moe_checkpoint.py:247 — colossalai/checkpoint_io/moe_checkpoint.py:247-256 | colossalai/checkpoint_io/moe_checkpoint.py:527-535 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/checkpoint_io/moe_checkpoint.py:247` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9–10 lines × 2) colossalai/kernel/triton/flash_decoding.py:91 — colossalai/kernel/triton/flash_decoding.py:91-99 | colossalai/kernel/triton/flash_decoding.py:208-217 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/kernel/triton/flash_decoding.py:208` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/kernel/triton/flash_decoding.py:218` calls `load` and `colossalai/kernel/triton/flash_decoding.py:100` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9–10 lines × 2) colossalai/legacy/inference/quant/smoothquant/models/llama.py:607 — colossalai/legacy/inference/quant/smoothquant/models/llama.py:607-615 | colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:140-149 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:140` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (9–10 lines × 2) colossalai/legacy/nn/layer/parallel_2d/_operation.py:136 — colossalai/legacy/nn/layer/parallel_2d/_operation.py:136-144 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:88-97 — `colossalai/legacy/nn/layer/parallel_2d/_operation.py` and `colossalai/legacy/nn/layer/parallel_2p5d/_operation.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 185 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (9–10 lines × 2) colossalai/legacy/nn/layer/parallel_3d/layers.py:109 — colossalai/legacy/nn/layer/parallel_3d/layers.py:109-118 | colossalai/legacy/nn/layer/parallel_3d/layers.py:261-269 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_3d/layers.py:109` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (9–10 lines × 2) colossalai/pipeline/schedule/generate.py:161 — colossalai/pipeline/schedule/generate.py:161-170 | colossalai/pipeline/schedule/generate.py:398-406 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (9–10 lines × 2) colossalai/pipeline/schedule/interleaved_pp.py:407 — colossalai/pipeline/schedule/interleaved_pp.py:407-415 | colossalai/pipeline/schedule/interleaved_pp.py:469-478 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (7 lines × 4) · ×8
  • Duplicated block (7 lines × 4) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:598 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:598-604 | colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:676-682 | colossalai/checkpoint_io/moe_checkpoint.py:498-504 | colossalai/checkpoint_io/moe_checkpoint.py:560-566 — before extracting anything, compare `colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py` and `colossalai/checkpoint_io/moe_checkpoint.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 249 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 4) colossalai/legacy/nn/layer/parallel_1d/layers.py:975 — colossalai/legacy/nn/layer/parallel_1d/layers.py:975-982 | colossalai/legacy/nn/layer/parallel_2d/layers.py:848-854 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:859-866 | colossalai/shardformer/layer/embedding.py:388-394 — `colossalai/legacy/nn/layer/parallel_1d/layers.py` and `colossalai/legacy/nn/layer/parallel_2d/layers.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 56 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/legacy/nn/layer/parallel_2d/layers.py:844` calls `get_local_rank` and `colossalai/legacy/nn/layer/parallel_1d/layers.py:970` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 4) colossalai/legacy/nn/layer/parallel_2d/_operation.py:435 — colossalai/legacy/nn/layer/parallel_2d/_operation.py:435-441 | colossalai/legacy/nn/layer/parallel_2d/_operation.py:592-598 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:400-408 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:565-571 — `colossalai/legacy/nn/layer/parallel_2d/_operation.py` and `colossalai/legacy/nn/layer/parallel_2p5d/_operation.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 185 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:400` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 4) colossalai/shardformer/modeling/_mixtral_tf4.py:724 — colossalai/shardformer/modeling/_mixtral_tf4.py:724-730 | colossalai/shardformer/modeling/_mixtral_tf5.py:1123-1129 | colossalai/shardformer/modeling/_qwen2_tf4.py:653-659 | colossalai/shardformer/modeling/_qwen3_tf4.py:645-651 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 581 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 4) colossalai/shardformer/policies/_deepseek_v3_tf4.py:158 — colossalai/shardformer/policies/_deepseek_v3_tf4.py:158-164 | colossalai/shardformer/policies/_deepseek_v3_tf5.py:165-171 | colossalai/shardformer/policies/_mixtral_tf4.py:425-431 | colossalai/shardformer/policies/_mixtral_tf5.py:452-458 — before extracting anything, compare `colossalai/shardformer/policies/_deepseek_v3_tf4.py` and `colossalai/shardformer/policies/_deepseek_v3_tf5.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 150 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (7 lines × 4) colossalai/shardformer/policies/bloom.py:542 — colossalai/shardformer/policies/bloom.py:542-548 | colossalai/shardformer/policies/falcon.py:491-497 | colossalai/shardformer/policies/gpt2.py:614-620 | colossalai/shardformer/policies/t5.py:839-845 — before extracting anything, compare `colossalai/shardformer/policies/bloom.py` and `colossalai/shardformer/policies/falcon.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 132 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 4) colossalai/legacy/nn/layer/parallel_1d/layers.py:939 — colossalai/legacy/nn/layer/parallel_1d/layers.py:939-945 | colossalai/legacy/nn/layer/parallel_2d/layers.py:788-794 | colossalai/legacy/nn/layer/parallel_3d/layers.py:1064-1070 | colossalai/shardformer/layer/embedding.py:369-375 — `colossalai/legacy/nn/layer/parallel_1d/layers.py` and `colossalai/legacy/nn/layer/parallel_2d/layers.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 56 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (7 lines × 4) REDACTED:337 — REDACTED:337-343 | examples/images/dreambooth/train_dreambooth_colossalai.py:364-370 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:363-369 | REDACTED:356-362 — before extracting anything, compare `REDACTED` and `examples/images/dreambooth/train_dreambooth_colossalai.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 401 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (6 lines × 4) · ×8
  • Duplicated block (6 lines × 4) colossalai/booster/plugin/gemini_plugin.py:85 — colossalai/booster/plugin/gemini_plugin.py:85-90 | colossalai/booster/plugin/torch_fsdp_plugin.py:103-108 | colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:836-841 | colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:858-863 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (6 lines × 4) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:389 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:389-394 | colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:666-671 | colossalai/checkpoint_io/moe_checkpoint.py:271-276 | colossalai/checkpoint_io/moe_checkpoint.py:550-555 — before extracting anything, compare `colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py` and `colossalai/checkpoint_io/moe_checkpoint.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 249 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: `CheckpointIndexFile` names `.index_file` in one and `colossalai.checkpoint_io` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (6 lines × 4) colossalai/fx/profiler/experimental/profiler_module/convolution.py:46 — colossalai/fx/profiler/experimental/profiler_module/convolution.py:46-51 | colossalai/fx/profiler/experimental/profiler_module/convolution.py:75-80 | colossalai/fx/tracer/meta_patch/patched_module/convolution.py:34-39 | colossalai/fx/tracer/meta_patch/patched_module/convolution.py:57-62 — before extracting anything, compare `colossalai/fx/profiler/experimental/profiler_module/convolution.py` and `colossalai/fx/tracer/meta_patch/patched_module/convolution.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 83 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/fx/profiler/experimental/profiler_module/convolution.py:46` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `self` to `torch.nn.Conv2d` in one and `torch.nn.Conv3d` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (6 lines × 4) colossalai/nn/optimizer/distributed_came.py:155 — colossalai/nn/optimizer/distributed_came.py:155-160 | colossalai/nn/optimizer/distributed_came.py:188-193 | colossalai/nn/optimizer/distributed_came.py:237-242 | colossalai/nn/optimizer/distributed_came.py:290-295 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (6 lines × 4) colossalai/shardformer/modeling/_bert_tf4.py:870 — colossalai/shardformer/modeling/_bert_tf4.py:870-875 | colossalai/shardformer/modeling/_bert_tf5.py:883-888 | examples/community/roberta/pretraining/model/bert.py:1651-1656 | examples/community/roberta/pretraining/model/deberta_v2.py:1595-1600 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (6 lines × 4) colossalai/shardformer/modeling/_bert_tf4.py:1020 — colossalai/shardformer/modeling/_bert_tf4.py:1020-1025 | colossalai/shardformer/modeling/_bert_tf4.py:1032-1037 | colossalai/shardformer/modeling/_bert_tf5.py:1033-1038 | colossalai/shardformer/modeling/_bert_tf5.py:1045-1050 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `self` to `BertSelfOutput` in one and `BertOutput` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (6 lines × 4) colossalai/shardformer/modeling/_deepseek_v3_tf5.py:123 — colossalai/shardformer/modeling/_deepseek_v3_tf5.py:123-129 | colossalai/shardformer/modeling/_mixtral_tf4.py:129-135 | colossalai/shardformer/modeling/_mixtral_tf5.py:477-483 | colossalai/shardformer/modeling/deepseek.py:163-168 — before extracting anything, compare `colossalai/shardformer/modeling/_deepseek_v3_tf5.py` and `colossalai/shardformer/modeling/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 62 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_deepseek_v3_tf5.py:123` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 4) examples/language/deepseek/benchmark.py:91 — examples/language/deepseek/benchmark.py:91-96 | examples/language/gpt/hybridparallelism/benchmark.py:51-56 | examples/language/llama/benchmark.py:78-83 | examples/language/mixtral/benchmark.py:71-76 — `examples/language/deepseek/benchmark.py` and `examples/language/llama/benchmark.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 10 separate duplicated blocks between them, totalling at least 150 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `examples/language/deepseek/benchmark.py:97` calls `add_argument` and `examples/language/gpt/hybridparallelism/benchmark.py:57` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (5 lines × 4) · ×8
  • Duplicated block (5 lines × 4) colossalai/legacy/nn/layer/parallel_2d/_operation.py:287 — colossalai/legacy/nn/layer/parallel_2d/_operation.py:287-291 | colossalai/legacy/nn/layer/parallel_2d/_operation.py:432-436 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:244-250 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:397-403 — `colossalai/legacy/nn/layer/parallel_2d/_operation.py` and `colossalai/legacy/nn/layer/parallel_2p5d/_operation.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 185 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (5 lines × 4) colossalai/nn/optimizer/distributed_adafactor.py:179 — colossalai/nn/optimizer/distributed_adafactor.py:179-184 | colossalai/nn/optimizer/distributed_adafactor.py:204-208 | colossalai/nn/optimizer/distributed_came.py:172-177 | colossalai/nn/optimizer/distributed_came.py:197-201 — before extracting anything, compare `colossalai/nn/optimizer/distributed_adafactor.py` and `colossalai/nn/optimizer/distributed_came.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 201 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (5 lines × 4) colossalai/nn/optimizer/distributed_came.py:165 — colossalai/nn/optimizer/distributed_came.py:165-169 | colossalai/nn/optimizer/distributed_came.py:205-209 | colossalai/nn/optimizer/distributed_came.py:251-257 | colossalai/nn/optimizer/distributed_came.py:304-310 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/nn/optimizer/distributed_came.py:165` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/nn/optimizer/distributed_came.py:250` calls `_split`, `view` and `colossalai/nn/optimizer/distributed_came.py:164` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 4) colossalai/shardformer/modeling/_mixtral_tf4.py:681 — colossalai/shardformer/modeling/_mixtral_tf4.py:681-685 | colossalai/shardformer/modeling/_mixtral_tf5.py:1075-1079 | colossalai/shardformer/modeling/deepseek.py:716-720 | colossalai/shardformer/modeling/opt.py:621-625 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 581 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (5 lines × 4) applications/Colossal-LLaMA/colossal_llama/utils/ckpt_io.py:29 — applications/Colossal-LLaMA/colossal_llama/utils/ckpt_io.py:29-33 | applications/ColossalChat/coati/models/utils.py:124-128 | applications/ColossalChat/coati/utils/ckpt_io.py:29-33 | applications/ColossalMoE/utils.py:26-30 — before extracting anything, compare `applications/Colossal-LLaMA/colossal_llama/utils/ckpt_io.py` and `applications/ColossalChat/coati/utils/ckpt_io.py` as WHOLE FILES: 89% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 2 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (5 lines × 4) colossalai/legacy/nn/layer/parallel_1d/layers.py:378 — colossalai/legacy/nn/layer/parallel_1d/layers.py:378-382 | colossalai/legacy/nn/layer/parallel_2d/layers.py:1098-1102 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:1114-1118 | colossalai/legacy/nn/layer/vanilla/layers.py:266-272 — `colossalai/legacy/nn/layer/parallel_1d/layers.py` and `colossalai/legacy/nn/layer/parallel_2d/layers.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 56 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (5 lines × 4) REDACTED:186 — REDACTED:186-190 | examples/images/dreambooth/train_dreambooth_colossalai.py:199-203 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:202-208 | REDACTED:207-211 — before extracting anything, compare `REDACTED` and `examples/images/dreambooth/train_dreambooth_colossalai.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 401 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:186` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `examples/images/dreambooth/train_dreambooth_colossalai.py:203` calls `add_argument` and `REDACTED:190` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 4) examples/language/deepseek/benchmark.py:85 — examples/language/deepseek/benchmark.py:85-89 | examples/language/gpt/hybridparallelism/benchmark.py:45-49 | examples/language/llama/benchmark.py:72-76 | examples/language/mixtral/benchmark.py:65-69 — `examples/language/deepseek/benchmark.py` and `examples/language/llama/benchmark.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 10 separate duplicated blocks between them, totalling at least 150 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `examples/language/deepseek/benchmark.py:85` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
X3 · Exception handling · Swallowed exception (empty catch) · ×8
  • Swallowed exception (empty catch) colossalai/shardformer/layer/normalization.py:22 — An empty catch block silently discards the error — failures vanish with no REDACTED and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) colossalai/legacy/zero/gemini/colo_init_context.py:56 — An empty catch block silently discards the error — failures vanish with no REDACTED and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:56 — An empty catch block silently discards the error — failures vanish with no REDACTED and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) colossalai/legacy/inference/quant/smoothquant/models/llama.py:541 — An empty catch block silently discards the error — failures vanish with no REDACTED and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) colossalai/fx/_meta_regist_12.py:26 — An empty catch block silently discards the error — failures vanish with no REDACTED and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) colossalai/accelerator/api.py:53 — An empty catch block silently discards the error — failures vanish with no REDACTED and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) colossalai/_analyzer/fx/codegen.py:7 — An empty catch block silently discards the error — failures vanish with no REDACTED and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) colossalai/_analyzer/_subclasses/_meta_registration.py:46 — An empty catch block silently discards the error — failures vanish with no REDACTED and no rethrow. Log it, handle it, or don't catch it.
D3 · God Classes · TooManyMethods · ×7
  • TooManyMethods: WorkerBase colossalai/legacy/pipeline/rpc/_pipeline_base.py:96 — TooManyMethods — 51 methods. The bar is 30 methods; this is 21 over it, 1.70× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: TraceIndice colossalai/autochunk/trace_indice.py:9 — TooManyMethods — 44 methods. The bar is 30 methods; this is 14 over it, 1.47× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: LowLevelZeroOptimizer colossalai/zero/low_level/low_level_optim.py:74 — TooManyMethods — 42 methods. The bar is 30 methods; this is 12 over it, 1.40× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: CpuAccelerator colossalai/accelerator/cpu_accelerator.py:15 — TooManyMethods — 41 methods. The bar is 30 methods; this is 11 over it, 1.37× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: CudaAccelerator colossalai/accelerator/cuda_accelerator.py:13 — TooManyMethods — 41 methods. The bar is 30 methods; this is 11 over it, 1.37× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: NpuAccelerator colossalai/accelerator/npu_accelerator.py:19 — TooManyMethods — 41 methods. The bar is 30 methods; this is 11 over it, 1.37× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: ParallelContext colossalai/legacy/context/parallel_context.py:24 — TooManyMethods — 33 methods. The bar is 30 methods; this is 3 over it, 1.10× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
D4 · Code Duplication · Duplicated block (29 lines × 2) · ×7
  • Duplicated block (29 lines × 2) applications/ColossalChat/coati/distributed/producer.py:91 — applications/ColossalChat/coati/distributed/producer.py:91-119 | applications/ColossalChat/coati/distributed/zero_bubble/producer.py:95-123 — before extracting anything, compare `applications/ColossalChat/coati/distributed/producer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/producer.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 234 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (29 lines × 2) colossalai/_analyzer/_subclasses/flop_tensor.py:226 — colossalai/_analyzer/_subclasses/flop_tensor.py:226-254 | colossalai/fx/profiler/opcount.py:16-44 — before extracting anything, compare `colossalai/_analyzer/_subclasses/flop_tensor.py` and `colossalai/fx/profiler/opcount.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 153 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (29 lines × 2) colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:282 — colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:282-310 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:447-475 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:282` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (29 lines × 2) colossalai/nn/optimizer/distributed_came.py:452 — colossalai/nn/optimizer/distributed_came.py:452-480 | colossalai/nn/optimizer/distributed_came.py:510-538 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (29 lines × 2) colossalai/shardformer/modeling/bloom.py:765 — colossalai/shardformer/modeling/bloom.py:765-793 | colossalai/shardformer/modeling/bloom.py:888-916 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/bloom.py:765` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (29 lines × 2) colossalai/shardformer/policies/_whisper_tf4.py:506 — colossalai/shardformer/policies/_whisper_tf4.py:506-534 | colossalai/shardformer/policies/_whisper_tf5.py:493-521 — before extracting anything, compare `colossalai/shardformer/policies/_whisper_tf4.py` and `colossalai/shardformer/policies/_whisper_tf5.py` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note first that the copies are not typed on the same thing: `WhisperForConditionalGeneration` names `transformers` in one and `transformers.models.whisper.modeling_whisper` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (29 lines × 2) REDACTED:347 — REDACTED:347-375 | REDACTED:367-395 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 24 separate duplicated blocks between them, totalling at least 499 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (14 lines × 3) · ×7
  • Duplicated block (14 lines × 3) colossalai/auto_parallel/offload/runtime.py:150 — colossalai/auto_parallel/offload/runtime.py:150-163 | colossalai/auto_parallel/passes/runtime_apply_pass.py:201-214 | colossalai/auto_parallel/passes/runtime_preparation_pass.py:182-195 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (14 lines × 3) colossalai/auto_parallel/tensor_shard/solver/strategies_constructor.py:128 — colossalai/auto_parallel/tensor_shard/solver/strategies_constructor.py:128-141 | colossalai/auto_parallel/tensor_shard/solver/strategies_constructor.py:143-156 | colossalai/auto_parallel/tensor_shard/solver/strategies_constructor.py:158-171 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/auto_parallel/tensor_shard/solver/strategies_constructor.py:126` calls `get_submodule` and `colossalai/auto_parallel/tensor_shard/solver/strategies_constructor.py:142` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 3) colossalai/kernel/triton/flash_decoding.py:485 — colossalai/kernel/triton/flash_decoding.py:485-498 | colossalai/kernel/triton/kvcache_copy.py:278-291 | colossalai/kernel/triton/no_pad_rotary_embedding.py:640-653 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/kernel/triton/kvcache_copy.py:275` calls `stride` and `colossalai/kernel/triton/flash_decoding.py:484` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 3) colossalai/legacy/nn/layer/parallel_2d/_operation.py:336 — colossalai/legacy/nn/layer/parallel_2d/_operation.py:336-349 | colossalai/legacy/nn/layer/parallel_2d/_operation.py:494-507 | colossalai/legacy/nn/layer/parallel_2d/_operation.py:651-664 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2d/_operation.py:336` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (14 lines × 3) colossalai/legacy/nn/layer/parallel_2d/layers.py:909 — colossalai/legacy/nn/layer/parallel_2d/layers.py:909-922 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:924-937 | colossalai/legacy/nn/layer/parallel_3d/layers.py:390-403 — `colossalai/legacy/nn/layer/parallel_2d/layers.py` and `colossalai/legacy/nn/layer/parallel_2p5d/layers.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 18 separate duplicated blocks between them, totalling at least 219 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2d/layers.py:909` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 3) colossalai/legacy/zero/sharded_model/sharded_model_v2.py:568 — colossalai/legacy/zero/sharded_model/sharded_model_v2.py:568-581 | colossalai/shardformer/layer/parallel_module.py:164-177 | colossalai/shardformer/layer/parallel_module.py:342-355 — before extracting anything, compare `colossalai/legacy/zero/sharded_model/sharded_model_v2.py` and `colossalai/shardformer/layer/parallel_module.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 96 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (14 lines × 3) examples/images/resnet/train.py:57 — examples/images/resnet/train.py:57-70 | examples/tutorial/new_api/cifar_resnet/train.py:57-70 | examples/tutorial/new_api/cifar_vit/train.py:77-90 — before extracting anything, compare `examples/images/resnet/train.py` and `examples/tutorial/new_api/cifar_resnet/train.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 158 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (13–14 lines × 2) · ×7
  • Duplicated block (13–14 lines × 2) applications/Colossal-LLaMA/colossal_llama/utils/stream_chat_patch.py:186 — applications/Colossal-LLaMA/colossal_llama/utils/stream_chat_patch.py:186-198 | colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py:1310-1323 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `applications/Colossal-LLaMA/colossal_llama/utils/stream_chat_patch.py:186` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13–14 lines × 2) applications/ColossalChat/coati/models/generation.py:74 — applications/ColossalChat/coati/models/generation.py:74-86 | applications/ColossalChat/examples/inference/web_chatbot/utils.py:13-26 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/examples/inference/web_chatbot/utils.py:13` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (13–14 lines × 2) colossalai/booster/plugin/hybrid_parallel_plugin.py:1006 — colossalai/booster/plugin/hybrid_parallel_plugin.py:1006-1018 | colossalai/booster/plugin/moe_hybrid_parallel_plugin.py:240-253 — before extracting anything, compare `colossalai/booster/plugin/hybrid_parallel_plugin.py` and `colossalai/booster/plugin/moe_hybrid_parallel_plugin.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 100 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/booster/plugin/hybrid_parallel_plugin.py:1006` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (13–14 lines × 2) REDACTED:493 — REDACTED:493-505 | REDACTED:522-535 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:522` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13–14 lines × 2) colossalai/shardformer/layer/linear.py:461 — colossalai/shardformer/layer/linear.py:461-474 | colossalai/shardformer/layer/qkv_fused_linear.py:499-511 — before extracting anything, compare `colossalai/shardformer/layer/linear.py` and `colossalai/shardformer/layer/qkv_fused_linear.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 261 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/shardformer/layer/linear.py:477` calls `fork_rng` and `colossalai/shardformer/layer/qkv_fused_linear.py:515` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (13–14 lines × 2) colossalai/shardformer/modeling/_whisper_tf4.py:762 — colossalai/shardformer/modeling/_whisper_tf4.py:762-774 | colossalai/shardformer/modeling/opt.py:210-223 — before extracting anything, compare `colossalai/shardformer/modeling/_whisper_tf4.py` and `colossalai/shardformer/modeling/opt.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 105 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (13–14 lines × 2) colossalai/shardformer/examples/convergence_benchmark.py:139 — colossalai/shardformer/examples/convergence_benchmark.py:139-151 | examples/tutorial/new_api/glue_bert/finetune.py:51-64 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
D4 · Code Duplication · Duplicated block (11–12 lines × 2) · ×7
  • Duplicated block (11–12 lines × 2) applications/ColossalChat/coati/models/lora.py:147 — applications/ColossalChat/coati/models/lora.py:147-157 | applications/ColossalChat/coati/models/lora.py:201-212 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11–12 lines × 2) applications/ColossalChat/coati/trainer/grpo.py:254 — applications/ColossalChat/coati/trainer/grpo.py:254-264 | applications/ColossalChat/coati/trainer/ppo.py:238-249 — before extracting anything, compare `applications/ColossalChat/coati/trainer/grpo.py` and `applications/ColossalChat/coati/trainer/ppo.py` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 176 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/trainer/ppo.py:238` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11–12 lines × 2) colossalai/legacy/inference/dynamic_batching/ray_dist_init.py:65 — colossalai/legacy/inference/dynamic_batching/ray_dist_init.py:65-75 | colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py:65-76 — before extracting anything, compare `colossalai/legacy/inference/dynamic_batching/ray_dist_init.py` and `colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 42 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (11–12 lines × 2) colossalai/nn/optimizer/distributed_adafactor.py:204 — colossalai/nn/optimizer/distributed_adafactor.py:204-214 | colossalai/nn/optimizer/distributed_came.py:197-208 — before extracting anything, compare `colossalai/nn/optimizer/distributed_adafactor.py` and `colossalai/nn/optimizer/distributed_came.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 201 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (11–12 lines × 2) colossalai/nn/optimizer/distributed_adafactor.py:336 — colossalai/nn/optimizer/distributed_adafactor.py:336-346 | colossalai/nn/optimizer/distributed_adafactor.py:350-361 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11–12 lines × 2) colossalai/nn/optimizer/distributed_adafactor.py:357 — colossalai/nn/optimizer/distributed_adafactor.py:357-368 | colossalai/nn/optimizer/distributed_came.py:408-418 — before extracting anything, compare `colossalai/nn/optimizer/distributed_adafactor.py` and `colossalai/nn/optimizer/distributed_came.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 201 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/nn/optimizer/distributed_adafactor.py:357` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11–12 lines × 2) colossalai/shardformer/modeling/_mixtral_tf4.py:718 — colossalai/shardformer/modeling/_mixtral_tf4.py:718-728 | colossalai/shardformer/modeling/deepseek.py:748-759 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/deepseek.py` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 427 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (9 lines × 4) · ×7
  • Duplicated block (9 lines × 4) applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py:83 — applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py:83-91 | applications/ColossalMoE/train.py:61-73 | colossalai/legacy/moe/openmoe/train.py:94-106 | examples/images/vit/args.py:61-71 — before extracting anything, compare `applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py` and `examples/images/vit/args.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 59 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py:83` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (9 lines × 4) colossalai/legacy/inference/quant/smoothquant/models/llama.py:479 — colossalai/legacy/inference/quant/smoothquant/models/llama.py:479-487 | colossalai/shardformer/modeling/_llama_tf4.py:584-592 | colossalai/shardformer/modeling/_qwen2_tf4.py:577-585 | colossalai/shardformer/modeling/_qwen3_tf4.py:569-577 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times.
  • Duplicated block (9 lines × 4) colossalai/legacy/nn/layer/parallel_1d/layers.py:297 — colossalai/legacy/nn/layer/parallel_1d/layers.py:297-305 | colossalai/legacy/nn/layer/parallel_1d/layers.py:710-718 | colossalai/shardformer/layer/linear.py:544-552 | colossalai/shardformer/layer/qkv_fused_linear.py:1161-1169 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_1d/layers.py:297` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 4) colossalai/shardformer/modeling/_qwen2_tf4.py:695 — colossalai/shardformer/modeling/_qwen2_tf4.py:695-704 | colossalai/shardformer/modeling/_qwen2_tf5.py:504-512 | colossalai/shardformer/modeling/_qwen3_tf4.py:687-696 | colossalai/shardformer/modeling/_qwen3_tf5.py:505-513 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf4.py` and `colossalai/shardformer/modeling/_qwen2_tf5.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 242 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (9 lines × 4) colossalai/shardformer/policies/_qwen2_tf4.py:544 — colossalai/shardformer/policies/_qwen2_tf4.py:544-552 | colossalai/shardformer/policies/_qwen2_tf5.py:543-551 | colossalai/shardformer/policies/_qwen3_tf4.py:529-537 | colossalai/shardformer/policies/_qwen3_tf5.py:553-561 — before extracting anything, compare `colossalai/shardformer/policies/_qwen2_tf4.py` and `colossalai/shardformer/policies/_qwen2_tf5.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 399 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (9 lines × 4) REDACTED:612 — REDACTED:612-620 | examples/images/dreambooth/train_dreambooth_colossalai.py:625-633 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:645-653 | REDACTED:657-665 — before extracting anything, compare `REDACTED` and `examples/images/dreambooth/train_dreambooth_colossalai.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 401 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `REDACTED:668` calls `cat` and `REDACTED:623` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 4) examples/images/vit/vit_benchmark.py:75 — examples/images/vit/vit_benchmark.py:75-83 | examples/images/vit/vit_train_demo.py:178-186 | examples/language/opt/opt_benchmark.py:69-77 | examples/language/opt/opt_train_demo.py:86-94 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times.
D4 · Code Duplication · Duplicated block (8 lines × 3) · ×7
  • Duplicated block (8 lines × 3) applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:55 — applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:55-62 | applications/Colossal-LLaMA/dataset/prepare_sft_dataset.py:53-60 | applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py:112-119 — before extracting anything, compare `applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py` and `applications/Colossal-LLaMA/dataset/prepare_sft_dataset.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 116 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (8 lines × 3) applications/ColossalEval/colossal_eval/models/chatglm.py:20 — applications/ColossalEval/colossal_eval/models/chatglm.py:20-27 | applications/ColossalEval/colossal_eval/models/chatglm.py:157-164 | REDACTED:203-210 — before extracting anything, compare `applications/ColossalEval/colossal_eval/models/chatglm.py` and `REDACTED` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 72 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (8 lines × 3) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:712 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:712-719 | colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:1007-1022 | colossalai/checkpoint_io/moe_checkpoint.py:596-603 — before extracting anything, compare `colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py` and `colossalai/checkpoint_io/moe_checkpoint.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 249 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (8 lines × 3) colossalai/legacy/nn/layer/parallel_1d/layers.py:977 — colossalai/legacy/nn/layer/parallel_1d/layers.py:977-985 | colossalai/legacy/nn/layer/parallel_2d/layers.py:849-856 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:861-869 — `colossalai/legacy/nn/layer/parallel_1d/layers.py` and `colossalai/legacy/nn/layer/parallel_2d/layers.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 56 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (8 lines × 3) colossalai/nn/optimizer/distributed_lamb.py:49 — colossalai/nn/optimizer/distributed_lamb.py:49-56 | colossalai/nn/optimizer/lamb.py:32-39 | examples/images/diffusion/ldm/util.py:104-111 — before extracting anything, compare `colossalai/nn/optimizer/distributed_lamb.py` and `colossalai/nn/optimizer/lamb.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 49 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (8 lines × 3) colossalai/shardformer/layer/attn.py:723 — colossalai/shardformer/layer/attn.py:723-730 | colossalai/shardformer/layer/attn.py:744-751 | colossalai/shardformer/layer/attn.py:1019-1026 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (8 lines × 3) examples/language/deepseek/benchmark.py:291 — examples/language/deepseek/benchmark.py:291-299 | examples/language/llama/benchmark.py:388-395 | examples/language/mixtral/benchmark.py:280-287 — `examples/language/deepseek/benchmark.py` and `examples/language/llama/benchmark.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 10 separate duplicated blocks between them, totalling at least 150 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (5 lines × 3) · ×7
  • Duplicated block (5 lines × 3) applications/ColossalChat/coati/trainer/dpo.py:639 — applications/ColossalChat/coati/trainer/dpo.py:639-643 | applications/ColossalChat/coati/trainer/sft.py:216-220 | applications/ColossalChat/coati/trainer/sft.py:244-248 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (5 lines × 3) colossalai/legacy/nn/layer/parallel_2d/layers.py:429 — colossalai/legacy/nn/layer/parallel_2d/layers.py:429-433 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:442-446 | colossalai/legacy/nn/layer/vanilla/layers.py:169-173 — `colossalai/legacy/nn/layer/parallel_2d/layers.py` and `colossalai/legacy/nn/layer/parallel_2p5d/layers.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 18 separate duplicated blocks between them, totalling at least 219 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2d/layers.py:429` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/legacy/nn/layer/parallel_2d/layers.py:427` calls `assert_summa_initialization`, `get_summa_dim_from_env` and `colossalai/legacy/nn/layer/vanilla/layers.py:168` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 3) colossalai/legacy/nn/loss/loss_1d.py:40 — colossalai/legacy/nn/loss/loss_1d.py:40-44 | examples/language/gpt/titans/model/embed.py:272-276 | examples/tutorial/sequence_parallel/loss_func/cross_entropy.py:25-29 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `examples/language/gpt/titans/model/embed.py:278` calls `all_reduce`, `get_group` and `examples/tutorial/sequence_parallel/loss_func/cross_entropy.py:32` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 3) colossalai/nn/optimizer/distributed_adafactor.py:172 — colossalai/nn/optimizer/distributed_adafactor.py:172-176 | colossalai/nn/optimizer/distributed_adafactor.py:212-216 | colossalai/nn/optimizer/distributed_adafactor.py:257-263 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/nn/optimizer/distributed_adafactor.py:172` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/nn/optimizer/distributed_adafactor.py:256` calls `_split`, `view` and `colossalai/nn/optimizer/distributed_adafactor.py:171` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 3) colossalai/nn/optimizer/distributed_adafactor.py:279 — colossalai/nn/optimizer/distributed_adafactor.py:279-283 | colossalai/nn/optimizer/distributed_came.py:273-277 | colossalai/nn/optimizer/distributed_came.py:326-330 — before extracting anything, compare `colossalai/nn/optimizer/distributed_adafactor.py` and `colossalai/nn/optimizer/distributed_came.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 201 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (5 lines × 3) colossalai/shardformer/layer/_operation.py:511 — colossalai/shardformer/layer/_operation.py:511-515 | colossalai/shardformer/layer/_operation.py:744-748 | colossalai/shardformer/layer/_operation.py:838-842 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (5 lines × 3) applications/ColossalChat/coati/trainer/dpo.py:358 — applications/ColossalChat/coati/trainer/dpo.py:358-362 | applications/ColossalChat/coati/trainer/kto.py:223-227 | applications/ColossalChat/coati/trainer/rm.py:157-162 — before extracting anything, compare `applications/ColossalChat/coati/trainer/dpo.py` and `applications/ColossalChat/coati/trainer/kto.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 60 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/trainer/dpo.py:358` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
X17 · Uncapped recursion over a caller-supplied document · Recursive walk over a caller-supplied document has no depth cap · ×7
  • Recursive walk over a caller-supplied document has no depth cap colossalai/testing/comparison.py:123 — `assert_hf_output_close` is public and takes `out1: Any` from its caller, and it calls itself at line 123 (`assert_hf_output_close`) with a piece of `out1` (and at line 136) — and nowhere in `assert_hf_output_close` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `assert_hf_output_close` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
  • Recursive walk over a caller-supplied document has no depth cap colossalai/pipeline/schedule/_utils.py:47 — `tree_flatten_hf` is public and takes `pytree: Any` from its caller, and it calls itself at line 47 (`tree_flatten_hf`) with a piece of `pytree` — and nowhere in `tree_flatten_hf` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `tree_flatten_hf` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
  • Recursive walk over a caller-supplied document has no depth cap colossalai/legacy/zero/sharded_model/_utils.py:63 — `apply_to_tensors` is public and takes `x: Any` from its caller, and it calls itself at line 63 (`apply_to_tensors`) with a piece of `x` (and at line 65, line 67) — and nowhere in `apply_to_tensors` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `apply_to_tensors` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
  • Recursive walk over a caller-supplied document has no depth cap colossalai/legacy/pipeline/rpc/utils.py:20 — `pyobj_map` is public and takes `obj: Any` from its caller, and it calls itself at line 20 (`pyobj_map`) with a piece of `obj` (and at line 22, line 24) — and nowhere in `pyobj_map` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `pyobj_map` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
  • Recursive walk over a caller-supplied document has no depth cap colossalai/legacy/pipeline/rpc/utils.py:42 — `pytree_map` is public and takes `obj: Any` from its caller, and it calls itself at line 42 (`pytree_map`) with a piece of `obj` (and at line 44, line 46) — and nowhere in `pytree_map` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `pytree_map` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
  • Recursive walk over a caller-supplied document has no depth cap colossalai/autochunk/utils.py:77 — `flat_list` is public and takes `inputs: Any` from its caller, and it calls itself at line 77 (`flat_list`) with a piece of `inputs` — and nowhere in `flat_list` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `flat_list` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
  • Recursive walk over a caller-supplied document has no depth cap colossalai/auto_parallel/tensor_shard/utils/misc.py:92 — `pytree_map` is public and takes `obj: Any` from its caller, and it calls itself at line 92 (`pytree_map`) with a piece of `obj` (and at line 94, line 96) — and nowhere in `pytree_map` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `pytree_map` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
D4 · Code Duplication · Members sharing a duplicated core (6 members, 50+ identical tokens) · ×6
  • Members sharing a duplicated core (6 members, 50+ identical tokens) applications/ColossalChat/coati/trainer/grpo.py:171 — applications/ColossalChat/coati/trainer/grpo.py:171-193 | applications/ColossalChat/coati/trainer/kto.py:96-117 | applications/ColossalChat/coati/trainer/orpo.py:86-107 | applications/ColossalChat/coati/trainer/ppo.py:162-184 | applications/ColossalChat/coati/trainer/rm.py:84-105 | applications/ColossalChat/coati/trainer/sft.py:72-96 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) colossalai/auto_parallel/tensor_shard/node_handler/permute_handler.py:28 — colossalai/auto_parallel/tensor_shard/node_handler/permute_handler.py:28-75 | colossalai/auto_parallel/tensor_shard/node_handler/softmax_handler.py:29-55 | colossalai/auto_parallel/tensor_shard/node_handler/split_handler.py:28-62 | colossalai/auto_parallel/tensor_shard/node_handler/sum_handler.py:28-81 | colossalai/auto_parallel/tensor_shard/node_handler/transpose_handler.py:28-64 | colossalai/auto_parallel/tensor_shard/node_handler/view_handler.py:32-52 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) colossalai/fx/profiler/experimental/profiler_module/convolution.py:18 — colossalai/fx/profiler/experimental/profiler_module/convolution.py:18-33 | colossalai/fx/profiler/experimental/profiler_module/convolution.py:40-59 | colossalai/fx/profiler/experimental/profiler_module/convolution.py:66-89 | colossalai/fx/tracer/meta_patch/patched_module/convolution.py:12-21 | colossalai/fx/tracer/meta_patch/patched_module/convolution.py:28-41 | colossalai/fx/tracer/meta_patch/patched_module/convolution.py:48-65 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) colossalai/fx/profiler/experimental/profiler_module/convolution.py:96 — colossalai/fx/profiler/experimental/profiler_module/convolution.py:96-117 | colossalai/fx/profiler/experimental/profiler_module/convolution.py:124-151 | colossalai/fx/profiler/experimental/profiler_module/convolution.py:158-193 | colossalai/fx/tracer/meta_patch/patched_module/convolution.py:72-85 | colossalai/fx/tracer/meta_patch/patched_module/convolution.py:92-113 | colossalai/fx/tracer/meta_patch/patched_module/convolution.py:120-149 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) colossalai/initialize.py:85 — colossalai/initialize.py:85-112 | colossalai/initialize.py:122-151 | colossalai/initialize.py:155-184 | colossalai/legacy/initialize.py:134-162 | colossalai/legacy/initialize.py:173-203 | colossalai/legacy/initialize.py:209-239 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:111 — colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:111-215 | colossalai/shardformer/modeling/bloom.py:1096-1156 | colossalai/shardformer/modeling/chatglm2.py:285-336 | colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py:1084-1128 | colossalai/shardformer/modeling/falcon.py:743-815 | colossalai/shardformer/modeling/gptj.py:282-353 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
D4 · Code Duplication · Duplicated block (37 lines × 2) · ×6
  • Duplicated block (37 lines × 2) applications/ColossalChat/coati/distributed/grpo_consumer.py:497 — applications/ColossalChat/coati/distributed/grpo_consumer.py:497-533 | applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py:418-454 — before extracting anything, compare `applications/ColossalChat/coati/distributed/grpo_consumer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 407 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/distributed/grpo_consumer.py:497` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py:417` calls `repeat_interleave`, `size` and `applications/ColossalChat/coati/distributed/grpo_consumer.py:496` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (37 lines × 2) applications/ColossalChat/coati/distributed/grpo_consumer.py:561 — applications/ColossalChat/coati/distributed/grpo_consumer.py:561-597 | applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py:484-520 — before extracting anything, compare `applications/ColossalChat/coati/distributed/grpo_consumer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 407 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py:521` calls `get`, `remote` and `applications/ColossalChat/coati/distributed/grpo_consumer.py:598` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (37 lines × 2) colossalai/kernel/triton/context_attn_unpad.py:51 — colossalai/kernel/triton/context_attn_unpad.py:51-87 | colossalai/kernel/triton/context_attn_unpad.py:229-265 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/kernel/triton/context_attn_unpad.py:51` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (37 lines × 2) colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:175 — colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:175-211 | colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py:1088-1124 — before extracting anything, compare `colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py` and `colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 176 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:175` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (37 lines × 2) colossalai/nn/init.py:80 — colossalai/nn/init.py:80-116 | colossalai/nn/init.py:124-160 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (37 lines × 2) colossalai/shardformer/policies/_bert_tf4.py:422 — colossalai/shardformer/policies/_bert_tf4.py:422-458 | colossalai/shardformer/policies/_bert_tf5.py:429-465 — before extracting anything, compare `colossalai/shardformer/policies/_bert_tf4.py` and `colossalai/shardformer/policies/_bert_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 475 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (33 lines × 2) · ×6
  • Duplicated block (33 lines × 2) REDACTED:412 — REDACTED:412-444 | REDACTED:295-327 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 157 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (33 lines × 2) colossalai/_analyzer/fx/codegen.py:161 — colossalai/_analyzer/fx/codegen.py:161-193 | colossalai/fx/codegen/activation_checkpoint_codegen.py:346-378 — before extracting anything, compare `colossalai/_analyzer/fx/codegen.py` and `colossalai/fx/codegen/activation_checkpoint_codegen.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 101 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (33 lines × 2) colossalai/shardformer/layer/linear.py:333 — colossalai/shardformer/layer/linear.py:333-365 | colossalai/shardformer/layer/qkv_fused_linear.py:957-989 — before extracting anything, compare `colossalai/shardformer/layer/linear.py` and `colossalai/shardformer/layer/qkv_fused_linear.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 261 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/layer/linear.py:333` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (33 lines × 2) colossalai/shardformer/policies/_whisper_tf4.py:53 — colossalai/shardformer/policies/_whisper_tf4.py:53-85 | colossalai/shardformer/policies/_whisper_tf5.py:51-83 — before extracting anything, compare `colossalai/shardformer/policies/_whisper_tf4.py` and `colossalai/shardformer/policies/_whisper_tf5.py` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/policies/_whisper_tf4.py:53` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (33 lines × 2) applications/ColossalChat/examples/inference/chatio.py:72 — applications/ColossalChat/examples/inference/chatio.py:72-104 | applications/ColossalChat/examples/inference/chatio.py:131-163 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (33 lines × 2) examples/images/resnet/train.py:152 — examples/images/resnet/train.py:152-184 | examples/tutorial/new_api/cifar_resnet/train.py:152-184 — before extracting anything, compare `examples/images/resnet/train.py` and `examples/tutorial/new_api/cifar_resnet/train.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 158 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (31 lines × 2) · ×6
  • Duplicated block (31 lines × 2) applications/Colossal-LLaMA/train.py:61 — applications/Colossal-LLaMA/train.py:61-91 | applications/ColossalChat/examples/training_scripts/lora_finetune.py:57-87 — before extracting anything, compare `applications/Colossal-LLaMA/train.py` and `applications/ColossalChat/examples/training_scripts/lora_finetune.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 132 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/Colossal-LLaMA/train.py:61` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (31 lines × 2) colossalai/legacy/inference/hybridengine/modeling/llama.py:352 — colossalai/legacy/inference/hybridengine/modeling/llama.py:352-382 | colossalai/legacy/inference/tensor_parallel/modeling/llama.py:272-302 — before extracting anything, compare `colossalai/legacy/inference/hybridengine/modeling/llama.py` and `colossalai/legacy/inference/tensor_parallel/modeling/llama.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 250 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (31 lines × 2) colossalai/pipeline/schedule/interleaved_pp.py:73 — colossalai/pipeline/schedule/interleaved_pp.py:73-103 | colossalai/pipeline/schedule/zero_bubble_pp.py:172-202 — before extracting anything, compare `colossalai/pipeline/schedule/interleaved_pp.py` and `colossalai/pipeline/schedule/zero_bubble_pp.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 82 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (31 lines × 2) colossalai/shardformer/modeling/_mixtral_tf4.py:278 — colossalai/shardformer/modeling/_mixtral_tf4.py:278-308 | colossalai/shardformer/modeling/deepseek.py:375-405 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/deepseek.py` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 427 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/shardformer/modeling/_mixtral_tf4.py:310` calls `rotary_emb` and `colossalai/shardformer/modeling/deepseek.py:408` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (31 lines × 2) colossalai/shardformer/modeling/_qwen2_tf4.py:330 — colossalai/shardformer/modeling/_qwen2_tf4.py:330-360 | colossalai/shardformer/modeling/_qwen3_tf4.py:328-358 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf4.py` and `colossalai/shardformer/modeling/_qwen3_tf4.py` as WHOLE FILES: this scan already matched 52 separate duplicated blocks between them, totalling at least 1214 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_qwen2_tf4.py:330` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (31 lines × 2) colossalai/shardformer/policies/_bert_tf4.py:461 — colossalai/shardformer/policies/_bert_tf4.py:461-491 | colossalai/shardformer/policies/_bert_tf5.py:468-498 — before extracting anything, compare `colossalai/shardformer/policies/_bert_tf4.py` and `colossalai/shardformer/policies/_bert_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 475 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (26 lines × 2) · ×6
  • Duplicated block (26 lines × 2) applications/ColossalEval/colossal_eval/models/chatglm.py:33 — applications/ColossalEval/colossal_eval/models/chatglm.py:33-58 | applications/ColossalEval/colossal_eval/models/chatglm.py:230-255 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (26 lines × 2) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:588 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:588-613 | colossalai/checkpoint_io/moe_checkpoint.py:488-513 — before extracting anything, compare `colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py` and `colossalai/checkpoint_io/moe_checkpoint.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 249 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/checkpoint_io/moe_checkpoint.py:515` calls `barrier` and `colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:615` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (26 lines × 2) colossalai/fx/tracer/experimental.py:307 — colossalai/fx/tracer/experimental.py:307-332 | colossalai/fx/tracer/tracer.py:449-474 — before extracting anything, compare `colossalai/fx/tracer/experimental.py` and `colossalai/fx/tracer/tracer.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 138 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (26 lines × 2) colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:930 — colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:930-955 | colossalai/legacy/moe/openmoe/model/openmoe_policy.py:499-524 — before extracting anything, compare `colossalai/legacy/moe/openmoe/model/modeling_openmoe.py` and `colossalai/legacy/moe/openmoe/model/openmoe_policy.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 95 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (26 lines × 2) colossalai/shardformer/modeling/_bert_tf4.py:313 — colossalai/shardformer/modeling/_bert_tf4.py:313-338 | colossalai/shardformer/modeling/_bert_tf5.py:326-351 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (26 lines × 2) examples/images/dreambooth/train_dreambooth_colossalai.py:601 — examples/images/dreambooth/train_dreambooth_colossalai.py:601-626 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:621-646 — before extracting anything, compare `examples/images/dreambooth/train_dreambooth_colossalai.py` and `examples/images/dreambooth/train_dreambooth_colossalai_lora.py` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 757 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (19–20 lines × 2) · ×6
  • Duplicated block (19–20 lines × 2) colossalai/checkpoint_io/moe_checkpoint.py:258 — colossalai/checkpoint_io/moe_checkpoint.py:258-276 | colossalai/checkpoint_io/moe_checkpoint.py:536-555 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/checkpoint_io/moe_checkpoint.py:258` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: `CheckpointIndexFile` names `colossalai.checkpoint_io` in one and `colossalai.checkpoint_io.index_file` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (19–20 lines × 2) colossalai/checkpoint_io/utils.py:875 — colossalai/checkpoint_io/utils.py:875-894 | colossalai/inference/utils.py:68-86 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (19–20 lines × 2) colossalai/nn/optimizer/came.py:65 — colossalai/nn/optimizer/came.py:65-83 | colossalai/nn/optimizer/distributed_came.py:334-353 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (19–20 lines × 2) colossalai/shardformer/modeling/_deepseek_v3_tf5.py:130 — colossalai/shardformer/modeling/_deepseek_v3_tf5.py:130-148 | colossalai/shardformer/modeling/_mixtral_tf5.py:485-504 — before extracting anything, compare `colossalai/shardformer/modeling/_deepseek_v3_tf5.py` and `colossalai/shardformer/modeling/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 62 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_deepseek_v3_tf5.py:130` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (19–20 lines × 2) colossalai/shardformer/modeling/bloom.py:590 — colossalai/shardformer/modeling/bloom.py:590-608 | colossalai/shardformer/modeling/falcon.py:607-626 — before extracting anything, compare `colossalai/shardformer/modeling/bloom.py` and `colossalai/shardformer/modeling/falcon.py` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 594 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/bloom.py:590` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/shardformer/modeling/bloom.py:610` calls `to` and `colossalai/shardformer/modeling/falcon.py:627` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (19–20 lines × 2) colossalai/shardformer/modeling/opt.py:383 — colossalai/shardformer/modeling/opt.py:383-402 | colossalai/shardformer/modeling/opt.py:483-501 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/modeling/opt.py:381` calls `get_logger` and `colossalai/shardformer/modeling/opt.py:481` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (18–19 lines × 2) · ×6
  • Duplicated block (18–19 lines × 2) applications/ColossalEval/colossal_eval/evaluate/gpt_evaluate.py:412 — applications/ColossalEval/colossal_eval/evaluate/gpt_evaluate.py:412-429 | applications/ColossalEval/colossal_eval/evaluate/gpt_evaluate.py:475-493 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalEval/colossal_eval/evaluate/gpt_evaluate.py:475` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (18–19 lines × 2) colossalai/auto_parallel/meta_profiler/meta_registry/conv.py:125 — colossalai/auto_parallel/meta_profiler/meta_registry/conv.py:125-143 | colossalai/auto_parallel/meta_profiler/meta_registry/linear.py:169-186 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/meta_profiler/meta_registry/conv.py:125` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (18–19 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:127 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:127-144 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py:159-177 — before extracting anything, compare `colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py` and `colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 143 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:127` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18–19 lines × 2) colossalai/kernel/triton/flash_decoding.py:50 — colossalai/kernel/triton/flash_decoding.py:50-67 | colossalai/kernel/triton/flash_decoding.py:168-186 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (18–19 lines × 2) colossalai/nn/optimizer/adafactor.py:156 — colossalai/nn/optimizer/adafactor.py:156-174 | colossalai/nn/optimizer/distributed_adafactor.py:379-396 — before extracting anything, compare `colossalai/nn/optimizer/adafactor.py` and `colossalai/nn/optimizer/distributed_adafactor.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 46 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/nn/optimizer/adafactor.py:156` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18–19 lines × 2) colossalai/nn/optimizer/distributed_galore.py:164 — colossalai/nn/optimizer/distributed_galore.py:164-181 | colossalai/nn/optimizer/galore.py:259-277 — before extracting anything, compare `colossalai/nn/optimizer/distributed_galore.py` and `colossalai/nn/optimizer/galore.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 52 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/nn/optimizer/galore.py:258` calls `save` and `colossalai/nn/optimizer/distributed_galore.py:163` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (17–18 lines × 2) · ×6
  • Duplicated block (17–18 lines × 2) colossalai/nn/optimizer/distributed_lamb.py:131 — colossalai/nn/optimizer/distributed_lamb.py:131-147 | colossalai/nn/optimizer/lamb.py:73-90 — before extracting anything, compare `colossalai/nn/optimizer/distributed_lamb.py` and `colossalai/nn/optimizer/lamb.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 49 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/nn/optimizer/lamb.py:94` calls `pow`, `sum`, `sqrt` and `colossalai/nn/optimizer/distributed_lamb.py:151` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (17–18 lines × 2) colossalai/shardformer/modeling/_llama_tf4.py:112 — colossalai/shardformer/modeling/_llama_tf4.py:112-128 | colossalai/shardformer/modeling/command.py:104-121 — before extracting anything, compare `colossalai/shardformer/modeling/_llama_tf4.py` and `colossalai/shardformer/modeling/command.py` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 210 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (17–18 lines × 2) colossalai/shardformer/modeling/bloom.py:243 — colossalai/shardformer/modeling/bloom.py:243-260 | colossalai/shardformer/modeling/falcon.py:289-305 — before extracting anything, compare `colossalai/shardformer/modeling/bloom.py` and `colossalai/shardformer/modeling/falcon.py` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 594 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/bloom.py:243` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17–18 lines × 2) colossalai/shardformer/modeling/gpt2.py:89 — colossalai/shardformer/modeling/gpt2.py:89-105 | colossalai/shardformer/modeling/gptj.py:53-70 — before extracting anything, compare `colossalai/shardformer/modeling/gpt2.py` and `colossalai/shardformer/modeling/gptj.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 321 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (17–18 lines × 2) examples/community/roberta/pretraining/model/bert.py:1228 — examples/community/roberta/pretraining/model/bert.py:1228-1244 | examples/community/roberta/pretraining/model/bert.py:1343-1360 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `examples/community/roberta/pretraining/model/bert.py:1228` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `examples/community/roberta/pretraining/model/bert.py:1246` calls `contiguous` and `examples/community/roberta/pretraining/model/bert.py:1361` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (17–18 lines × 2) examples/community/roberta/pretraining/model/bert.py:1839 — examples/community/roberta/pretraining/model/bert.py:1839-1855 | examples/community/roberta/pretraining/model/deberta_v2.py:1486-1503 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `examples/community/roberta/pretraining/model/bert.py:1839` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (17 lines × 3) · ×6
  • Duplicated block (17 lines × 3) colossalai/kernel/triton/context_attn_unpad.py:627 — colossalai/kernel/triton/context_attn_unpad.py:627-643 | colossalai/kernel/triton/context_attn_unpad.py:667-683 | colossalai/kernel/triton/context_attn_unpad.py:703-719 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (17 lines × 3) colossalai/legacy/inference/hybridengine/modeling/llama.py:444 — colossalai/legacy/inference/hybridengine/modeling/llama.py:444-460 | colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:496-512 | colossalai/legacy/inference/tensor_parallel/modeling/llama.py:364-380 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/inference/hybridengine/modeling/llama.py:444` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 3) colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:258 — colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:258-274 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:423-439 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:586-602 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (17 lines × 3) colossalai/shardformer/policies/_qwen2_tf4.py:236 — colossalai/shardformer/policies/_qwen2_tf4.py:236-253 | colossalai/shardformer/policies/_qwen3_tf4.py:236-253 | colossalai/shardformer/policies/command.py:256-272 — before extracting anything, compare `colossalai/shardformer/policies/_qwen2_tf4.py` and `colossalai/shardformer/policies/_qwen3_tf4.py` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 286 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/policies/_qwen2_tf4.py:236` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 3) examples/community/roberta/pretraining/model/bert.py:1539 — examples/community/roberta/pretraining/model/bert.py:1539-1557 | examples/community/roberta/pretraining/model/bert.py:1739-1755 | examples/community/roberta/pretraining/model/bert.py:1824-1846 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (17 lines × 3) REDACTED:28 — REDACTED:28-44 | examples/images/dreambooth/train_dreambooth_colossalai.py:34-50 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:37-53 — before extracting anything, compare `REDACTED` and `examples/images/dreambooth/train_dreambooth_colossalai.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 401 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (16–17 lines × 2) · ×6
  • Duplicated block (16–17 lines × 2) applications/ColossalChat/coati/trainer/dpo.py:366 — applications/ColossalChat/coati/trainer/dpo.py:366-382 | applications/ColossalChat/coati/trainer/orpo.py:196-211 — before extracting anything, compare `applications/ColossalChat/coati/trainer/dpo.py` and `applications/ColossalChat/coati/trainer/orpo.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 133 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/trainer/dpo.py:366` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16–17 lines × 2) applications/ColossalChat/coati/trainer/sft.py:104 — applications/ColossalChat/coati/trainer/sft.py:104-120 | applications/ColossalChat/coati/trainer/sft.py:192-207 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/trainer/sft.py:104` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16–17 lines × 2) colossalai/legacy/nn/layer/parallel_2d/_operation.py:319 — colossalai/legacy/nn/layer/parallel_2d/_operation.py:319-334 | colossalai/legacy/nn/layer/parallel_2d/_operation.py:633-649 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (16–17 lines × 2) colossalai/shardformer/modeling/bloom.py:394 — colossalai/shardformer/modeling/bloom.py:394-409 | colossalai/shardformer/modeling/falcon.py:434-450 — before extracting anything, compare `colossalai/shardformer/modeling/bloom.py` and `colossalai/shardformer/modeling/falcon.py` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 594 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/bloom.py:394` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (16–17 lines × 2) colossalai/shardformer/modeling/chatglm2.py:354 — colossalai/shardformer/modeling/chatglm2.py:354-370 | colossalai/shardformer/modeling/chatglm2.py:656-671 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/chatglm2.py:354` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (16–17 lines × 2) examples/community/roberta/pretraining/model/bert.py:1346 — examples/community/roberta/pretraining/model/bert.py:1346-1361 | examples/community/roberta/pretraining/model/bert.py:1463-1479 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `examples/community/roberta/pretraining/model/bert.py:1346` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (14–15 lines × 2) · ×6
  • Duplicated block (14–15 lines × 2) colossalai/auto_parallel/meta_profiler/meta_registry/activation.py:61 — colossalai/auto_parallel/meta_profiler/meta_registry/activation.py:61-75 | colossalai/auto_parallel/meta_profiler/meta_registry/tensor.py:43-56 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/meta_profiler/meta_registry/activation.py:61` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14–15 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:798 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:798-811 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:952-966 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (14–15 lines × 2) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:335 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:335-348 | colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:608-622 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (14–15 lines × 2) colossalai/legacy/pipeline/rpc/_pipeline_base.py:852 — colossalai/legacy/pipeline/rpc/_pipeline_base.py:852-865 | colossalai/legacy/pipeline/rpc/_pipeline_base.py:880-894 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (14–15 lines × 2) colossalai/shardformer/layer/utils.py:252 — colossalai/shardformer/layer/utils.py:252-265 | colossalai/shardformer/layer/utils.py:273-287 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (14–15 lines × 2) examples/images/vit/vit_benchmark.py:68 — examples/images/vit/vit_benchmark.py:68-81 | examples/images/vit/vit_train_demo.py:170-184 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `examples/images/vit/vit_train_demo.py:170` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (12 lines × 4) · ×6
  • Duplicated block (12 lines × 4) colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:330 — colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:330-341 | colossalai/shardformer/modeling/bloom.py:394-405 | colossalai/shardformer/modeling/falcon.py:434-445 | colossalai/shardformer/modeling/gpt2.py:417-428 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:330` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (12 lines × 4) colossalai/legacy/moe/openmoe/model/openmoe_policy.py:296 — colossalai/legacy/moe/openmoe/model/openmoe_policy.py:296-307 | colossalai/shardformer/modeling/_mixtral_tf4.py:275-286 | colossalai/shardformer/modeling/_mixtral_tf5.py:621-632 | colossalai/shardformer/modeling/deepseek.py:372-383 — before extracting anything, compare `colossalai/legacy/moe/openmoe/model/openmoe_policy.py` and `colossalai/shardformer/modeling/_mixtral_tf4.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 130 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (12 lines × 4) colossalai/legacy/nn/layer/parallel_1d/layers.py:261 — colossalai/legacy/nn/layer/parallel_1d/layers.py:261-272 | colossalai/legacy/nn/layer/parallel_1d/layers.py:398-409 | colossalai/legacy/nn/layer/parallel_1d/layers.py:533-544 | colossalai/legacy/nn/layer/parallel_1d/layers.py:676-687 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_1d/layers.py:261` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 4) applications/Colossal-LLaMA/setup.py:5 — applications/Colossal-LLaMA/setup.py:5-16 | applications/ColossalChat/setup.py:5-16 | applications/ColossalMoE/setup.py:5-16 | applications/ColossalQA/setup.py:5-16 — `applications/Colossal-LLaMA/setup.py` and `applications/ColossalChat/setup.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 2 separate duplicated blocks between them, totalling at least 24 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `applications/ColossalQA/setup.py:19` calls `find_packages` and `applications/Colossal-LLaMA/setup.py:19` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12 lines × 4) applications/ColossalChat/examples/training_scripts/train_dpo.py:161 — applications/ColossalChat/examples/training_scripts/train_dpo.py:161-172 | applications/ColossalChat/examples/training_scripts/train_kto.py:161-172 | applications/ColossalChat/examples/training_scripts/train_orpo.py:150-161 | applications/ColossalChat/examples/training_scripts/train_rm.py:160-171 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_dpo.py` and `applications/ColossalChat/examples/training_scripts/train_kto.py` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 289 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (12 lines × 4) applications/ColossalChat/examples/training_scripts/train_dpo.py:188 — applications/ColossalChat/examples/training_scripts/train_dpo.py:188-199 | applications/ColossalChat/examples/training_scripts/train_kto.py:210-221 | applications/ColossalChat/examples/training_scripts/train_orpo.py:177-188 | applications/ColossalChat/examples/training_scripts/train_rm.py:187-198 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_dpo.py` and `applications/ColossalChat/examples/training_scripts/train_kto.py` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 289 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `applications/ColossalChat/examples/training_scripts/train_rm.py:199` calls `ceil` and `applications/ColossalChat/examples/training_scripts/train_dpo.py:200` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D35 · Change Coupling · Change coupling · ×5
  • Change coupling: context_attn_unpad.py ↔ flash_decoding.py colossalai/kernel/triton/context_attn_unpad.py:1 — `colossalai/kernel/triton/context_attn_unpad.py` and `colossalai/kernel/triton/flash_decoding.py` change together 80% of the time (8 of the 10 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency between them. They sit in the same directory, but in this ecosystem each file is its own module — a sibling reference still needs an import — so the missing import edge is real: the coupling runs through shared behaviour, not a declared dependency. If they duplicate structure, extract the common part into one unit; otherwise the coupling is hidden and worth breaking. You can check this without leaving the row: of the 8 shared commits counted here, the most recent 3 are `537a3cbc` [kernel] Support New KCache Layout - Triton Kernel (#5677); `3c91e3f1` [Inference]Adapt to baichuan2 13B (#5614); `2a718c8b` Optimized the execution interval time between cuda kernels caused by … — run `git show` on any of them.
  • Change coupling: deepseek.py ↔ mixtral.py colossalai/shardformer/policies/deepseek.py:1 — `colossalai/shardformer/policies/deepseek.py` and `colossalai/shardformer/policies/mixtral.py` change together 60% of the time (6 of the 10 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency between them. They sit in the same directory, but in this ecosystem each file is its own module — a sibling reference still needs an import — so the missing import edge is real: the coupling runs through shared behaviour, not a declared dependency. If they duplicate structure, extract the common part into one unit; otherwise the coupling is hidden and worth breaking. You can check this without leaving the row: of the 6 shared commits counted here, the most recent 3 are `c54c4fcd` [hotfix] moe hybrid parallelism benchmark & follow-up fix (#6048); `f1a3a326` [fp8]Moe support fp8 communication (#5977); `cb01c0d5` [moe] refactor mesh assignment — run `git show` on any of them.
  • Change coupling: bert.py ↔ bloom.py colossalai/shardformer/policies/bert.py:1 — `colossalai/shardformer/policies/bert.py` and `colossalai/shardformer/policies/bloom.py` change together 59% of the time (10 of the 17 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency between them. They sit in the same directory, but in this ecosystem each file is its own module — a sibling reference still needs an import — so the missing import edge is real: the coupling runs through shared behaviour, not a declared dependency. If they duplicate structure, extract the common part into one unit; otherwise the coupling is hidden and worth breaking. You can check this without leaving the row: of the 10 shared commits counted here, the most recent 3 are `dc2cdaf3` [shardformer] optimize seq parallelism (#6086); `773d9f96` [shardformer]delete xformers (#5859); `d84d6860` change 'xxx if xxx else None' to 'xxx or None' — run `git show` on any of them.
  • Change coupling: engine.py ↔ nopadding_baichuan.py colossalai/inference/core/engine.py:1 — `colossalai/inference/core/engine.py` and `colossalai/inference/modeling/models/nopadding_baichuan.py` change together 58% of the time (7 of the 12 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 7 shared commits counted here, the most recent 3 are `3c7cda0c` [Inference]Lazy Init Support (#5785); `5f398fc0` Pass inference model shard configs for module init; `eec77e57` Fix tests and naming — run `git show` on any of them.
  • Change coupling: _operation.py ↔ mixtral.py colossalai/moe/_operation.py:1 — `colossalai/moe/_operation.py` and `colossalai/shardformer/policies/mixtral.py` change together 50% of the time (7 of the 14 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 7 shared commits counted here, the most recent 3 are `c54c4fcd` [hotfix] moe hybrid parallelism benchmark & follow-up fix (#6048); `f1a3a326` [fp8]Moe support fp8 communication (#5977); `803878b2` [moe] full test for deepseek and mixtral (pp + sp to fix) — run `git show` on any of them.
D4 · Code Duplication · Members sharing a duplicated core (9 members, 50+ identical tokens) · ×5
  • Members sharing a duplicated core (9 members, 50+ identical tokens) colossalai/auto_parallel/tensor_shard/node_handler/strategy/batch_norm_generator.py:74 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/batch_norm_generator.py:74-112 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:79-108 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py:55-80 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/getitem_generator.py:32-59 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/layer_norm_generator.py:65-97 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:36-63 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/softmax_generator.py:36-63 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/sum_generator.py:33-60 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/unary_elementwise_generator.py:24-51 — These 9 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 9 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 9 times.
  • Members sharing a duplicated core (9 members, 50+ identical tokens) colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:79 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:79-108 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py:55-80 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/getitem_generator.py:32-59 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/layer_norm_generator.py:65-97 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:36-63 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/softmax_generator.py:36-63 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/sum_generator.py:33-60 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/tensor_constructor_generator.py:24-41 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/unary_elementwise_generator.py:24-51 — These 9 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 9 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 9 times.
  • Members sharing a duplicated core (9 members, 50+ identical tokens) colossalai/shardformer/layer/linear.py:78 — colossalai/shardformer/layer/linear.py:78-120 | colossalai/shardformer/layer/linear.py:229-282 | colossalai/shardformer/layer/linear.py:422-478 | colossalai/shardformer/layer/qkv_fused_linear.py:241-307 | colossalai/shardformer/layer/qkv_fused_linear.py:458-515 | colossalai/shardformer/layer/qkv_fused_linear.py:674-717 | colossalai/shardformer/layer/qkv_fused_linear.py:836-902 | colossalai/shardformer/layer/qkv_fused_linear.py:1044-1106 | colossalai/shardformer/layer/qkv_fused_linear.py:1249-1292 — These 9 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 9 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 9 times.
  • Members sharing a duplicated core (9 members, 50+ identical tokens) colossalai/shardformer/modeling/_qwen2_tf4.py:764 — colossalai/shardformer/modeling/_qwen2_tf4.py:764-841 | colossalai/shardformer/modeling/_qwen2_tf5.py:537-618 | colossalai/shardformer/modeling/_qwen3_tf4.py:756-834 | colossalai/shardformer/modeling/_qwen3_tf5.py:538-620 | colossalai/shardformer/modeling/bloom.py:1096-1156 | colossalai/shardformer/modeling/command.py:573-664 | colossalai/shardformer/modeling/falcon.py:743-815 | colossalai/shardformer/modeling/mistral.py:558-637 | colossalai/shardformer/modeling/opt.py:847-970 — These 9 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 9 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 9 times.
  • Members sharing a duplicated core (9 members, 50+ identical tokens) colossalai/shardformer/policies/_llama_tf4.py:473 — colossalai/shardformer/policies/_llama_tf4.py:473-524 | colossalai/shardformer/policies/_llama_tf5.py:471-522 | colossalai/shardformer/policies/_mixtral_tf4.py:375-421 | colossalai/shardformer/policies/_mixtral_tf5.py:402-448 | colossalai/shardformer/policies/_qwen2_tf4.py:493-538 | colossalai/shardformer/policies/_qwen2_tf5.py:492-537 | colossalai/shardformer/policies/_qwen3_tf4.py:479-523 | colossalai/shardformer/policies/_qwen3_tf5.py:503-547 | colossalai/shardformer/policies/deepseek.py:382-430 — These 9 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 9 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 9 times.
D4 · Code Duplication · Duplicated block (40 lines × 2) · ×5
  • Duplicated block (40 lines × 2) colossalai/shardformer/modeling/_qwen2_tf5.py:191 — colossalai/shardformer/modeling/_qwen2_tf5.py:191-230 | colossalai/shardformer/modeling/_qwen3_tf5.py:192-231 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf5.py` and `colossalai/shardformer/modeling/_qwen3_tf5.py` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 628 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (40 lines × 2) colossalai/shardformer/modeling/_vit_tf4.py:294 — colossalai/shardformer/modeling/_vit_tf4.py:294-333 | colossalai/shardformer/modeling/_vit_tf5.py:223-262 — before extracting anything, compare `colossalai/shardformer/modeling/_vit_tf4.py` and `colossalai/shardformer/modeling/_vit_tf5.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 183 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_vit_tf4.py:294` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (40 lines × 2) colossalai/shardformer/modeling/bloom.py:462 — colossalai/shardformer/modeling/bloom.py:462-501 | colossalai/shardformer/modeling/falcon.py:491-530 — before extracting anything, compare `colossalai/shardformer/modeling/bloom.py` and `colossalai/shardformer/modeling/falcon.py` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 594 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/bloom.py:462` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (40 lines × 2) colossalai/shardformer/policies/_bert_tf4.py:363 — colossalai/shardformer/policies/_bert_tf4.py:363-402 | colossalai/shardformer/policies/_bert_tf5.py:370-409 — before extracting anything, compare `colossalai/shardformer/policies/_bert_tf4.py` and `colossalai/shardformer/policies/_bert_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 475 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (40 lines × 2) examples/language/gpt/titans/model/embed.py:126 — examples/language/gpt/titans/model/embed.py:126-165 | examples/language/gpt/titans/model/embed.py:471-510 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (27 lines × 2) · ×5
  • Duplicated block (27 lines × 2) colossalai/legacy/nn/layer/parallel_2d/_operation.py:322 — colossalai/legacy/nn/layer/parallel_2d/_operation.py:322-348 | colossalai/legacy/nn/layer/parallel_2d/_operation.py:480-506 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2d/_operation.py:322` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (27 lines × 2) colossalai/legacy/nn/layer/parallel_2d/layers.py:437 — colossalai/legacy/nn/layer/parallel_2d/layers.py:437-463 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:450-476 — `colossalai/legacy/nn/layer/parallel_2d/layers.py` and `colossalai/legacy/nn/layer/parallel_2p5d/layers.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 18 separate duplicated blocks between them, totalling at least 219 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (27 lines × 2) colossalai/shardformer/modeling/_bert_tf4.py:522 — colossalai/shardformer/modeling/_bert_tf4.py:522-548 | colossalai/shardformer/modeling/_bert_tf5.py:535-561 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_bert_tf4.py:522` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (27 lines × 2) colossalai/shardformer/modeling/t5.py:362 — colossalai/shardformer/modeling/t5.py:362-388 | colossalai/shardformer/modeling/t5.py:507-533 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/modeling/t5.py:504` calls `_shift_right` and `colossalai/shardformer/modeling/t5.py:359` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (27 lines × 2) colossalai/legacy/nn/layer/parallel_2d/layers.py:977 — colossalai/legacy/nn/layer/parallel_2d/layers.py:977-1003 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:992-1018 — `colossalai/legacy/nn/layer/parallel_2d/layers.py` and `colossalai/legacy/nn/layer/parallel_2p5d/layers.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 18 separate duplicated blocks between them, totalling at least 219 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (16–17 lines × 3) · ×5
  • Duplicated block (16–17 lines × 3) applications/ColossalMoE/train.py:68 — applications/ColossalMoE/train.py:68-83 | colossalai/legacy/moe/openmoe/train.py:101-116 | examples/images/vit/args.py:22-38 — before extracting anything, compare `applications/ColossalMoE/train.py` and `colossalai/legacy/moe/openmoe/train.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 125 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalMoE/train.py:68` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `examples/images/vit/args.py:21` calls `add_argument` and `applications/ColossalMoE/train.py:68` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (16–17 lines × 3) colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:136 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:136-152 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:295-311 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:366-381 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (16–17 lines × 3) colossalai/legacy/nn/parallel/layers/cache_embedding/cached_embedding.py:117 — colossalai/legacy/nn/parallel/layers/cache_embedding/cached_embedding.py:117-133 | colossalai/legacy/nn/parallel/layers/cache_embedding/parallel_cached_embedding.py:107-122 | colossalai/legacy/nn/parallel/layers/cache_embedding/parallel_cached_embedding_tablewise.py:122-137 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once.
  • Duplicated block (16–17 lines × 3) colossalai/shardformer/policies/bloom.py:283 — colossalai/shardformer/policies/bloom.py:283-298 | colossalai/shardformer/policies/falcon.py:223-238 | colossalai/shardformer/policies/gptj.py:301-317 — before extracting anything, compare `colossalai/shardformer/policies/bloom.py` and `colossalai/shardformer/policies/falcon.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 132 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (16–17 lines × 3) examples/community/roberta/pretraining/model/bert.py:1550 — examples/community/roberta/pretraining/model/bert.py:1550-1565 | examples/community/roberta/pretraining/model/bert.py:1748-1763 | examples/community/roberta/pretraining/model/deberta_v2.py:1403-1419 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `examples/community/roberta/pretraining/model/bert.py:1550` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (15–16 lines × 2) · ×5
  • Duplicated block (15–16 lines × 2) applications/ColossalQA/colossalqa/retrieval_conversation_en.py:24 — applications/ColossalQA/colossalqa/retrieval_conversation_en.py:24-38 | applications/ColossalQA/colossalqa/retrieval_conversation_zh.py:24-39 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalQA/colossalqa/retrieval_conversation_en.py:24` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15–16 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/embedding_handler.py:195 — colossalai/auto_parallel/tensor_shard/node_handler/embedding_handler.py:195-209 | colossalai/auto_parallel/tensor_shard/node_handler/linear_handler.py:242-257 — before extracting anything, compare `colossalai/auto_parallel/tensor_shard/node_handler/embedding_handler.py` and `colossalai/auto_parallel/tensor_shard/node_handler/linear_handler.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 68 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/tensor_shard/node_handler/embedding_handler.py:195` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (15–16 lines × 2) colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:72 — colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:72-87 | colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py:799-813 — before extracting anything, compare `colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py` and `colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 176 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (15–16 lines × 2) colossalai/legacy/nn/layer/parallel_2d/_operation.py:288 — colossalai/legacy/nn/layer/parallel_2d/_operation.py:288-302 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:245-260 — `colossalai/legacy/nn/layer/parallel_2d/_operation.py` and `colossalai/legacy/nn/layer/parallel_2p5d/_operation.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 185 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (15–16 lines × 2) colossalai/shardformer/modeling/bloom.py:302 — colossalai/shardformer/modeling/bloom.py:302-317 | colossalai/shardformer/modeling/falcon.py:337-351 — before extracting anything, compare `colossalai/shardformer/modeling/bloom.py` and `colossalai/shardformer/modeling/falcon.py` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 594 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/modeling/bloom.py:300` calls `to_legacy_cache` and `colossalai/shardformer/modeling/falcon.py:335` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (13 lines × 3) · ×5
  • Duplicated block (13 lines × 3) applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:63 — applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:63-75 | applications/Colossal-LLaMA/dataset/prepare_sft_dataset.py:61-73 | applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py:120-132 — before extracting anything, compare `applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py` and `applications/Colossal-LLaMA/dataset/prepare_sft_dataset.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 116 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (13 lines × 3) applications/ColossalChat/coati/trainer/kto.py:246 — applications/ColossalChat/coati/trainer/kto.py:246-258 | applications/ColossalChat/coati/trainer/orpo.py:221-233 | applications/ColossalChat/coati/trainer/rm.py:181-193 — before extracting anything, compare `applications/ColossalChat/coati/trainer/kto.py` and `applications/ColossalChat/coati/trainer/orpo.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 138 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/trainer/kto.py:246` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 3) colossalai/legacy/nn/layer/parallel_2d/layers.py:113 — colossalai/legacy/nn/layer/parallel_2d/layers.py:113-125 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:115-127 | colossalai/legacy/nn/layer/parallel_3d/layers.py:250-262 — `colossalai/legacy/nn/layer/parallel_2d/layers.py` and `colossalai/legacy/nn/layer/parallel_2p5d/layers.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 18 separate duplicated blocks between them, totalling at least 219 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (13 lines × 3) colossalai/shardformer/policies/gpt2.py:447 — colossalai/shardformer/policies/gpt2.py:447-459 | colossalai/shardformer/policies/gpt2.py:532-544 | colossalai/shardformer/policies/gptj.py:408-420 — before extracting anything, compare `colossalai/shardformer/policies/gpt2.py` and `colossalai/shardformer/policies/gptj.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 65 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (13 lines × 3) REDACTED:376 — REDACTED:376-388 | examples/images/dreambooth/train_dreambooth_colossalai.py:390-402 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:389-401 — before extracting anything, compare `REDACTED` and `examples/images/dreambooth/train_dreambooth_colossalai.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 401 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (12–13 lines × 2) · ×5
  • Duplicated block (12–13 lines × 2) .github/workflows/scripts/generate_leaderboard_and_send_to_lark.py:281 — .github/workflows/scripts/generate_leaderboard_and_send_to_lark.py:281-292 | .github/workflows/scripts/generate_leaderboard_and_send_to_lark.py:299-311 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (12–13 lines × 2) applications/ColossalChat/coati/distributed/consumer.py:238 — applications/ColossalChat/coati/distributed/consumer.py:238-249 | applications/ColossalChat/coati/distributed/zero_bubble/consumer.py:193-205 — before extracting anything, compare `applications/ColossalChat/coati/distributed/consumer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/consumer.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 73 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `applications/ColossalChat/coati/distributed/zero_bubble/consumer.py:207` calls `update` and `applications/ColossalChat/coati/distributed/consumer.py:250` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12–13 lines × 2) colossalai/nn/optimizer/distributed_adafactor.py:415 — colossalai/nn/optimizer/distributed_adafactor.py:415-427 | colossalai/nn/optimizer/distributed_came.py:492-503 — before extracting anything, compare `colossalai/nn/optimizer/distributed_adafactor.py` and `colossalai/nn/optimizer/distributed_came.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 201 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (12–13 lines × 2) REDACTED:663 — REDACTED:663-674 | REDACTED:702-714 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (12–13 lines × 2) applications/ColossalChat/examples/training_scripts/train_grpo.py:346 — applications/ColossalChat/examples/training_scripts/train_grpo.py:346-357 | REDACTED:397-409 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_grpo.py` and `REDACTED` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 469 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/examples/training_scripts/train_grpo.py:346` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `applications/ColossalChat/examples/training_scripts/train_grpo.py:345` calls `load_checkpoint`, `isinstance` and `REDACTED:397` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (12 lines × 3) · ×5
  • Duplicated block (12 lines × 3) colossalai/auto_parallel/meta_profiler/meta_registry/conv.py:128 — colossalai/auto_parallel/meta_profiler/meta_registry/conv.py:128-139 | colossalai/auto_parallel/meta_profiler/meta_registry/linear.py:171-182 | colossalai/auto_parallel/meta_profiler/meta_registry/norm.py:94-105 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/meta_profiler/meta_registry/conv.py:128` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 3) colossalai/auto_parallel/tensor_shard/node_handler/strategy/batch_norm_generator.py:74 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/batch_norm_generator.py:74-90 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:79-90 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/layer_norm_generator.py:68-79 — before extracting anything, compare `colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py` and `colossalai/auto_parallel/tensor_shard/node_handler/strategy/layer_norm_generator.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 37 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/tensor_shard/node_handler/strategy/batch_norm_generator.py:74` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (12 lines × 3) colossalai/checkpoint_io/utils.py:254 — colossalai/checkpoint_io/utils.py:254-265 | colossalai/checkpoint_io/utils.py:305-316 | colossalai/checkpoint_io/utils.py:368-379 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (12 lines × 3) colossalai/auto_parallel/tensor_shard/node_handler/strategy/batch_norm_generator.py:33 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/batch_norm_generator.py:33-44 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:25-36 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/normal_pooling_generator.py:24-35 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once.
  • Duplicated block (12 lines × 3) examples/language/deepseek/benchmark.py:111 — examples/language/deepseek/benchmark.py:111-122 | examples/language/llama/benchmark.py:97-108 | examples/language/mixtral/benchmark.py:91-102 — `examples/language/deepseek/benchmark.py` and `examples/language/llama/benchmark.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 10 separate duplicated blocks between them, totalling at least 150 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `examples/language/llama/benchmark.py:111` calls `add_argument` and `examples/language/deepseek/benchmark.py:125` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (10 lines × 4) · ×5
  • Duplicated block (10 lines × 4) colossalai/legacy/inference/hybridengine/modeling/llama.py:249 — colossalai/legacy/inference/hybridengine/modeling/llama.py:249-258 | colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:156-165 | colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:136-145 | colossalai/legacy/inference/tensor_parallel/modeling/llama.py:158-167 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/inference/hybridengine/modeling/llama.py:249` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 4) colossalai/shardformer/modeling/bloom.py:483 — colossalai/shardformer/modeling/bloom.py:483-492 | colossalai/shardformer/modeling/falcon.py:512-521 | colossalai/shardformer/modeling/gpt2.py:759-768 | colossalai/shardformer/modeling/gptj.py:422-431 — before extracting anything, compare `colossalai/shardformer/modeling/bloom.py` and `colossalai/shardformer/modeling/falcon.py` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 594 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/modeling/bloom.py:482` calls `ValueError` and `colossalai/shardformer/modeling/gptj.py:420` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 4) colossalai/shardformer/policies/_vit_tf4.py:382 — colossalai/shardformer/policies/_vit_tf4.py:382-391 | colossalai/shardformer/policies/_vit_tf4.py:418-427 | colossalai/shardformer/policies/_vit_tf5.py:232-241 | colossalai/shardformer/policies/_vit_tf5.py:268-277 — before extracting anything, compare `colossalai/shardformer/policies/_vit_tf4.py` and `colossalai/shardformer/policies/_vit_tf5.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 133 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 4) colossalai/shardformer/examples/data.py:69 — colossalai/shardformer/examples/data.py:69-78 | examples/language/bert/data.py:68-77 | examples/language/gpt/hybridparallelism/data.py:70-79 | examples/tutorial/new_api/glue_bert/data.py:68-77 — before extracting anything, compare `colossalai/shardformer/examples/data.py` and `examples/language/bert/data.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 41 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 4) REDACTED:416 — REDACTED:416-425 | examples/images/dreambooth/train_dreambooth_colossalai.py:430-439 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:429-438 | REDACTED:442-451 — before extracting anything, compare `REDACTED` and `examples/images/dreambooth/train_dreambooth_colossalai.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 401 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `examples/images/dreambooth/train_dreambooth_colossalai.py:440` calls `info` and `REDACTED:426` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (8 lines × 4) · ×5
  • Duplicated block (8 lines × 4) colossalai/legacy/inference/quant/smoothquant/models/llama.py:475 — colossalai/legacy/inference/quant/smoothquant/models/llama.py:475-482 | colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:403-410 | colossalai/shardformer/modeling/_qwen2_tf4.py:573-580 | colossalai/shardformer/modeling/_qwen3_tf4.py:565-572 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/inference/quant/smoothquant/models/llama.py:475` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:412` calls `clone`, `detach` and `colossalai/legacy/inference/quant/smoothquant/models/llama.py:483` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 4) colossalai/legacy/inference/quant/smoothquant/models/llama.py:624 — colossalai/legacy/inference/quant/smoothquant/models/llama.py:624-631 | colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:744-751 | colossalai/shardformer/modeling/_mixtral_tf4.py:726-733 | colossalai/shardformer/modeling/_mixtral_tf5.py:1125-1132 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times.
  • Duplicated block (8 lines × 4) colossalai/shardformer/modeling/_mixtral_tf4.py:677 — colossalai/shardformer/modeling/_mixtral_tf4.py:677-684 | colossalai/shardformer/modeling/_mixtral_tf5.py:1071-1078 | colossalai/shardformer/modeling/deepseek.py:712-719 | colossalai/shardformer/modeling/mistral.py:381-388 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 581 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (8 lines × 4) colossalai/shardformer/modeling/_qwen2_tf4.py:766 — colossalai/shardformer/modeling/_qwen2_tf4.py:766-773 | colossalai/shardformer/modeling/_qwen3_tf4.py:758-765 | colossalai/shardformer/modeling/command.py:577-584 | colossalai/shardformer/modeling/mistral.py:562-569 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf4.py` and `colossalai/shardformer/modeling/_qwen3_tf4.py` as WHOLE FILES: this scan already matched 52 separate duplicated blocks between them, totalling at least 1214 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (8 lines × 4) REDACTED:645 — REDACTED:645-652 | examples/images/dreambooth/train_dreambooth_colossalai.py:658-665 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:678-685 | REDACTED:693-700 — before extracting anything, compare `REDACTED` and `examples/images/dreambooth/train_dreambooth_colossalai.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 401 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
P7 · Outbound HTTP resilience · Outbound HTTP without resilience · ×5
  • Outbound HTTP without resilience applications/ColossalChat/coati/distributed/reward/code_reward/utils.py:65 — `requests.post(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience applications/ColossalQA/colossalqa/local/colossalcloud_llm.py:115 — `requests.post(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience REDACTED:107 — `requests.request(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience colossalai/legacy/inference/serving/ray_serve/send_request.py:7 — `requests.get(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience colossalai/legacy/inference/serving/ray_serve/send_requests.py:7 — `requests.get(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
D4 · Code Duplication · Members sharing a duplicated core (8 members, 50+ identical tokens) · ×4
  • Members sharing a duplicated core (8 members, 50+ identical tokens) colossalai/nn/optimizer/adafactor.py:87 — colossalai/nn/optimizer/adafactor.py:87-201 | colossalai/nn/optimizer/distributed_adafactor.py:159-188 | colossalai/nn/optimizer/distributed_adafactor.py:191-231 | colossalai/nn/optimizer/distributed_adafactor.py:234-283 | colossalai/nn/optimizer/distributed_came.py:152-181 | colossalai/nn/optimizer/distributed_came.py:184-224 | colossalai/nn/optimizer/distributed_came.py:227-277 | colossalai/nn/optimizer/distributed_came.py:281-330 — These 8 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 8 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 8 times.
  • Members sharing a duplicated core (8 members, 50+ identical tokens) colossalai/shardformer/policies/_llama_tf4.py:304 — colossalai/shardformer/policies/_llama_tf4.py:304-331 | colossalai/shardformer/policies/_llama_tf5.py:302-329 | colossalai/shardformer/policies/_qwen2_tf4.py:311-341 | colossalai/shardformer/policies/_qwen2_tf5.py:310-340 | colossalai/shardformer/policies/_qwen3_tf4.py:311-341 | colossalai/shardformer/policies/_qwen3_tf5.py:331-361 | colossalai/shardformer/policies/command.py:282-309 | colossalai/shardformer/policies/mistral.py:265-292 — These 8 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 8 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 8 times.
  • Members sharing a duplicated core (8 members, 50+ identical tokens) applications/ColossalChat/examples/training_scripts/train_dpo.py:26 — applications/ColossalChat/examples/training_scripts/train_dpo.py:26-301 | applications/ColossalChat/examples/training_scripts/train_grpo.py:42-424 | applications/ColossalChat/examples/training_scripts/train_kto.py:26-322 | applications/ColossalChat/examples/training_scripts/train_orpo.py:26-284 | REDACTED:51-497 | applications/ColossalChat/examples/training_scripts/train_rm.py:28-295 | applications/ColossalChat/examples/training_scripts/train_sft.py:27-301 | examples/language/gpt/hybridparallelism/benchmark.py:39-231 — These 8 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 8 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 8 times.
  • Members sharing a duplicated core (8 members, 50+ identical tokens) colossalai/shardformer/examples/data.py:96 — colossalai/shardformer/examples/data.py:96-104 | colossalai/shardformer/examples/data.py:107-115 | examples/language/bert/data.py:92-98 | examples/language/bert/data.py:101-107 | examples/language/gpt/hybridparallelism/data.py:93-99 | examples/language/gpt/hybridparallelism/data.py:102-108 | examples/tutorial/new_api/glue_bert/data.py:91-97 | examples/tutorial/new_api/glue_bert/data.py:100-106 — These 8 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 8 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 8 times.
D4 · Code Duplication · Members sharing a duplicated core (7 members, 50+ identical tokens) · ×4
  • Members sharing a duplicated core (7 members, 50+ identical tokens) applications/ColossalChat/coati/trainer/dpo.py:124 — applications/ColossalChat/coati/trainer/dpo.py:124-404 | applications/ColossalChat/coati/trainer/dpo.py:407-643 | applications/ColossalChat/coati/trainer/kto.py:120-263 | applications/ColossalChat/coati/trainer/kto.py:266-355 | applications/ColossalChat/coati/trainer/orpo.py:110-238 | applications/ColossalChat/coati/trainer/orpo.py:241-330 | applications/ColossalChat/coati/trainer/rm.py:108-197 — These 7 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 7 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 7 times.
  • Members sharing a duplicated core (7 members, 50+ identical tokens) colossalai/booster/plugin/dp_plugin_base.py:35 — colossalai/booster/plugin/dp_plugin_base.py:35-76 | colossalai/booster/plugin/gemini_plugin.py:603-653 | colossalai/booster/plugin/hybrid_parallel_plugin.py:1403-1449 | examples/language/data_utils.py:51-94 | examples/language/deepseek/data_utils.py:51-94 | examples/language/llama/data_utils.py:51-94 | examples/language/mixtral/data_utils.py:51-94 — These 7 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 7 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 7 times.
  • Members sharing a duplicated core (7 members, 50+ identical tokens) colossalai/inference/modeling/layers/baichuan_tp_linear.py:17 — colossalai/inference/modeling/layers/baichuan_tp_linear.py:17-56 | colossalai/shardformer/layer/linear.py:288-322 | colossalai/shardformer/layer/linear.py:484-519 | colossalai/shardformer/layer/qkv_fused_linear.py:317-359 | colossalai/shardformer/layer/qkv_fused_linear.py:521-557 | colossalai/shardformer/layer/qkv_fused_linear.py:912-946 | colossalai/shardformer/layer/qkv_fused_linear.py:1112-1139 — These 7 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 7 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 7 times.
  • Members sharing a duplicated core (7 members, 50+ identical tokens) colossalai/shardformer/layer/_operation.py:99 — colossalai/shardformer/layer/_operation.py:99-167 | colossalai/shardformer/layer/_operation.py:190-248 | colossalai/shardformer/layer/_operation.py:273-338 | colossalai/shardformer/layer/_operation.py:361-415 | colossalai/shardformer/layer/_operation.py:575-646 | colossalai/shardformer/layer/_operation.py:760-819 | colossalai/shardformer/layer/_operation.py:908-982 — These 7 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 7 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 7 times.
D4 · Code Duplication · Duplicated block (53 lines × 2) · ×4
  • Duplicated block (53 lines × 2) colossalai/shardformer/modeling/_llama_tf4.py:310 — colossalai/shardformer/modeling/_llama_tf4.py:310-362 | colossalai/shardformer/modeling/_llama_tf5.py:352-404 — before extracting anything, compare `colossalai/shardformer/modeling/_llama_tf4.py` and `colossalai/shardformer/modeling/_llama_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (53 lines × 2) colossalai/shardformer/modeling/_vit_tf4.py:241 — colossalai/shardformer/modeling/_vit_tf4.py:241-293 | colossalai/shardformer/modeling/_vit_tf5.py:168-220 — before extracting anything, compare `colossalai/shardformer/modeling/_vit_tf4.py` and `colossalai/shardformer/modeling/_vit_tf5.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 183 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_vit_tf4.py:241` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: `ImageClassifierOutput` names `transformers.modeling_outputs` in one and `transformers.models.vit.modeling_vit` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (53 lines × 2) colossalai/shardformer/policies/_qwen2_tf4.py:406 — colossalai/shardformer/policies/_qwen2_tf4.py:406-458 | colossalai/shardformer/policies/_qwen2_tf5.py:405-457 — before extracting anything, compare `colossalai/shardformer/policies/_qwen2_tf4.py` and `colossalai/shardformer/policies/_qwen2_tf5.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 399 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (53 lines × 2) examples/images/dreambooth/train_dreambooth_colossalai.py:546 — examples/images/dreambooth/train_dreambooth_colossalai.py:546-598 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:566-618 — before extracting anything, compare `examples/images/dreambooth/train_dreambooth_colossalai.py` and `examples/images/dreambooth/train_dreambooth_colossalai_lora.py` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 757 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/images/dreambooth/train_dreambooth_colossalai.py:546` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (48 lines × 2) · ×4
  • Duplicated block (48 lines × 2) applications/ColossalChat/coati/distributed/producer.py:313 — applications/ColossalChat/coati/distributed/producer.py:313-360 | applications/ColossalChat/coati/distributed/zero_bubble/producer.py:367-414 — before extracting anything, compare `applications/ColossalChat/coati/distributed/producer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/producer.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 234 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (48 lines × 2) colossalai/shardformer/modeling/_vit_tf4.py:175 — colossalai/shardformer/modeling/_vit_tf4.py:175-222 | colossalai/shardformer/modeling/_vit_tf5.py:100-147 — before extracting anything, compare `colossalai/shardformer/modeling/_vit_tf4.py` and `colossalai/shardformer/modeling/_vit_tf5.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 183 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_vit_tf4.py:175` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: `ImageClassifierOutput` names `transformers.modeling_outputs` in one and `transformers.models.vit.modeling_vit` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (48 lines × 2) colossalai/shardformer/modeling/gptj.py:675 — colossalai/shardformer/modeling/gptj.py:675-722 | colossalai/shardformer/modeling/gptj.py:850-897 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (48 lines × 2) colossalai/shardformer/policies/_llama_tf4.py:393 — colossalai/shardformer/policies/_llama_tf4.py:393-440 | colossalai/shardformer/policies/_llama_tf5.py:391-438 — before extracting anything, compare `colossalai/shardformer/policies/_llama_tf4.py` and `colossalai/shardformer/policies/_llama_tf5.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 404 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (35 lines × 2) · ×4
  • Duplicated block (35 lines × 2) applications/ColossalChat/coati/utils/reward_score/utils.py:21 — applications/ColossalChat/coati/distributed/reward/reward_utils.py:21-55 | applications/ColossalChat/coati/utils/reward_score/utils.py:21-55 — before extracting anything, compare `applications/ColossalChat/coati/distributed/reward/reward_utils.py` and `applications/ColossalChat/coati/utils/reward_score/utils.py` as WHOLE FILES: 100% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 2 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (35 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:336 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:336-370 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:415-449 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:336` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (35 lines × 2) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:428 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:428-462 | colossalai/inference/core/plugin.py:46-80 — before extracting anything, compare `colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py` and `colossalai/inference/core/plugin.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 60 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: `CheckpointIndexFile` names `.index_file` in one and `colossalai.checkpoint_io.index_file` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (35 lines × 2) colossalai/shardformer/modeling/gpt2.py:743 — colossalai/shardformer/modeling/gpt2.py:743-777 | colossalai/shardformer/modeling/gptj.py:406-440 — before extracting anything, compare `colossalai/shardformer/modeling/gpt2.py` and `colossalai/shardformer/modeling/gptj.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 321 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/gptj.py:406` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (19 lines × 3) · ×4
  • Duplicated block (19 lines × 3) colossalai/shardformer/layer/qkv_fused_linear.py:252 — colossalai/shardformer/layer/qkv_fused_linear.py:252-270 | colossalai/shardformer/layer/qkv_fused_linear.py:847-865 | colossalai/shardformer/layer/qkv_fused_linear.py:1055-1073 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/layer/qkv_fused_linear.py:1054` calls `get_world_size` and `colossalai/shardformer/layer/qkv_fused_linear.py:251` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (19 lines × 3) colossalai/shardformer/modeling/_bert_tf4.py:443 — colossalai/shardformer/modeling/_bert_tf4.py:443-461 | colossalai/shardformer/modeling/_bert_tf5.py:456-474 | examples/community/roberta/pretraining/model/bert.py:1240-1258 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_bert_tf4.py:443` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/modeling/_bert_tf4.py:442` calls `is_last_stage` and `examples/community/roberta/pretraining/model/bert.py:1238` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (19 lines × 3) REDACTED:144 — examples/images/diffusion/scripts/img2img.py:81-103 | REDACTED:144-162 | REDACTED:164-183 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 24 separate duplicated blocks between them, totalling at least 499 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/images/diffusion/scripts/img2img.py:81` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `REDACTED:143` calls `add_argument` and `REDACTED:164` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (19 lines × 3) examples/images/resnet/train.py:149 — examples/images/resnet/train.py:149-167 | examples/tutorial/new_api/cifar_resnet/train.py:149-167 | examples/tutorial/new_api/cifar_vit/train.py:169-187 — before extracting anything, compare `examples/images/resnet/train.py` and `examples/tutorial/new_api/cifar_resnet/train.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 158 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/images/resnet/train.py:149` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (18 lines × 3) · ×4
  • Duplicated block (18 lines × 3) applications/ColossalChat/coati/trainer/dpo.py:134 — applications/ColossalChat/coati/trainer/dpo.py:134-151 | applications/ColossalChat/coati/trainer/dpo.py:268-285 | applications/ColossalChat/coati/trainer/orpo.py:120-137 — before extracting anything, compare `applications/ColossalChat/coati/trainer/dpo.py` and `applications/ColossalChat/coati/trainer/orpo.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 133 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/trainer/dpo.py:134` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 3) applications/ColossalChat/coati/trainer/dpo.py:154 — applications/ColossalChat/coati/trainer/dpo.py:154-171 | applications/ColossalChat/coati/trainer/dpo.py:306-323 | applications/ColossalChat/coati/trainer/dpo.py:445-462 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (18 lines × 3) applications/ColossalChat/coati/trainer/kto.py:96 — applications/ColossalChat/coati/trainer/kto.py:96-113 | applications/ColossalChat/coati/trainer/orpo.py:86-103 | applications/ColossalChat/coati/trainer/rm.py:84-101 — before extracting anything, compare `applications/ColossalChat/coati/trainer/kto.py` and `applications/ColossalChat/coati/trainer/orpo.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 138 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (18 lines × 3) colossalai/shardformer/modeling/_bert_tf4.py:333 — colossalai/shardformer/modeling/_bert_tf4.py:333-350 | colossalai/shardformer/modeling/_bert_tf5.py:346-363 | examples/community/roberta/pretraining/model/bert.py:1124-1141 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_bert_tf4.py:333` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/modeling/_bert_tf4.py:332` calls `is_last_stage` and `examples/community/roberta/pretraining/model/bert.py:1122` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (15 lines × 4) · ×4
  • Duplicated block (15 lines × 4) colossalai/initialize.py:97 — colossalai/initialize.py:97-111 | colossalai/initialize.py:135-149 | colossalai/legacy/initialize.py:146-160 | colossalai/legacy/initialize.py:186-200 — before extracting anything, compare `colossalai/initialize.py` and `colossalai/legacy/initialize.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 107 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/initialize.py:97` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 4) colossalai/kernel/triton/context_attn_unpad.py:655 — colossalai/kernel/triton/context_attn_unpad.py:655-669 | colossalai/kernel/triton/flash_decoding.py:427-441 | colossalai/kernel/triton/no_pad_rotary_embedding.py:551-565 | colossalai/kernel/triton/no_pad_rotary_embedding.py:627-641 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (15 lines × 4) colossalai/shardformer/modeling/_bert_tf4.py:528 — colossalai/shardformer/modeling/_bert_tf4.py:528-542 | colossalai/shardformer/modeling/_bert_tf5.py:541-555 | examples/community/roberta/pretraining/model/bert.py:1356-1370 | examples/community/roberta/pretraining/model/deberta_v2.py:1165-1179 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_bert_tf4.py:528` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/modeling/_bert_tf4.py:527` calls `is_last_stage` and `examples/community/roberta/pretraining/model/bert.py:1354` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (15 lines × 4) examples/community/roberta/pretraining/model/bert.py:1459 — examples/community/roberta/pretraining/model/bert.py:1459-1473 | examples/community/roberta/pretraining/model/bert.py:1545-1559 | examples/community/roberta/pretraining/model/bert.py:1743-1757 | examples/community/roberta/pretraining/model/bert.py:1834-1848 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication · Duplicated block (15 lines × 3) · ×4
  • Duplicated block (15 lines × 3) colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:297 — colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:297-311 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:462-476 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:625-639 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:297` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (15 lines × 3) colossalai/shardformer/policies/_mixtral_tf4.py:288 — colossalai/shardformer/policies/_mixtral_tf4.py:288-302 | colossalai/shardformer/policies/_mixtral_tf5.py:315-329 | colossalai/shardformer/policies/deepseek.py:298-312 — before extracting anything, compare `colossalai/shardformer/policies/_mixtral_tf4.py` and `colossalai/shardformer/policies/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 408 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (15 lines × 3) examples/community/roberta/pretraining/model/bert.py:1230 — examples/community/roberta/pretraining/model/bert.py:1230-1244 | examples/community/roberta/pretraining/model/bert.py:1346-1360 | examples/community/roberta/pretraining/model/bert.py:1462-1478 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `examples/community/roberta/pretraining/model/bert.py:1230` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `examples/community/roberta/pretraining/model/bert.py:1246` calls `contiguous` and `examples/community/roberta/pretraining/model/bert.py:1361` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (15 lines × 3) examples/community/roberta/pretraining/model/bert.py:1347 — examples/community/roberta/pretraining/model/bert.py:1347-1361 | examples/community/roberta/pretraining/model/bert.py:1464-1479 | examples/community/roberta/pretraining/model/deberta_v2.py:1155-1170 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `examples/community/roberta/pretraining/model/bert.py:1347` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9 lines × 5) · ×4
  • Duplicated block (9 lines × 5) colossalai/kernel/triton/context_attn_unpad.py:626 — colossalai/kernel/triton/context_attn_unpad.py:626-634 | colossalai/kernel/triton/context_attn_unpad.py:666-674 | colossalai/kernel/triton/context_attn_unpad.py:702-710 | colossalai/kernel/triton/flash_decoding.py:444-452 | colossalai/kernel/triton/no_pad_rotary_embedding.py:637-645 — there are 5 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/kernel/triton/context_attn_unpad.py:624` calls `stride` and `colossalai/kernel/triton/no_pad_rotary_embedding.py:635` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 5) colossalai/shardformer/modeling/_whisper_tf4.py:186 — colossalai/shardformer/modeling/_whisper_tf4.py:186-194 | colossalai/shardformer/modeling/_whisper_tf4.py:709-717 | colossalai/shardformer/modeling/gpt2.py:161-169 | colossalai/shardformer/modeling/opt.py:99-107 | colossalai/shardformer/modeling/opt.py:638-646 — before extracting anything, compare `colossalai/shardformer/modeling/_whisper_tf4.py` and `colossalai/shardformer/modeling/opt.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 105 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/modeling/opt.py:97` calls `is_first_stage` and `colossalai/shardformer/modeling/_whisper_tf4.py:183` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 5) colossalai/shardformer/policies/_qwen2_tf4.py:464 — colossalai/shardformer/policies/_qwen2_tf4.py:464-472 | colossalai/shardformer/policies/_qwen2_tf5.py:463-471 | colossalai/shardformer/policies/_qwen3_tf4.py:450-458 | colossalai/shardformer/policies/_qwen3_tf5.py:474-482 | colossalai/shardformer/policies/command.py:426-434 — before extracting anything, compare `colossalai/shardformer/policies/_qwen2_tf4.py` and `colossalai/shardformer/policies/_qwen2_tf5.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 399 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (9 lines × 5) colossalai/shardformer/policies/bloom.py:406 — colossalai/shardformer/policies/bloom.py:406-414 | colossalai/shardformer/policies/deepseek.py:436-444 | colossalai/shardformer/policies/falcon.py:353-361 | colossalai/shardformer/policies/mistral.py:410-418 | colossalai/shardformer/policies/t5.py:726-734 — before extracting anything, compare `colossalai/shardformer/policies/bloom.py` and `colossalai/shardformer/policies/falcon.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 132 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (8–9 lines × 2) · ×4
  • Duplicated block (8–9 lines × 2) colossalai/inference/modeling/layers/attention.py:171 — colossalai/inference/modeling/layers/attention.py:171-179 | colossalai/inference/modeling/layers/attention.py:230-237 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (8–9 lines × 2) applications/ColossalChat/examples/training_scripts/train_kto.py:127 — applications/ColossalChat/examples/training_scripts/train_kto.py:127-135 | applications/ColossalChat/examples/training_scripts/train_orpo.py:118-125 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_kto.py` and `applications/ColossalChat/examples/training_scripts/train_orpo.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 343 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/examples/training_scripts/train_kto.py:127` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8–9 lines × 2) examples/community/roberta/pretraining/arguments.py:35 — examples/community/roberta/pretraining/arguments.py:35-42 | examples/community/roberta/pretraining/arguments.py:64-72 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `examples/community/roberta/pretraining/arguments.py:35` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (8–9 lines × 2) examples/language/gpt/hybridparallelism/finetune.py:134 — examples/language/gpt/hybridparallelism/finetune.py:134-142 | examples/language/opt/opt_train_demo.py:35-42 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `examples/language/gpt/hybridparallelism/finetune.py:134` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D6 · Cohesion (LCOM4) · Low cohesion · ×4
  • Low cohesion: WorkerBase (LCOM4 9) colossalai/legacy/pipeline/rpc/_pipeline_base.py:96 — WorkerBase's methods fall into 9 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 9 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: HybridParallelModule (LCOM4 7) colossalai/booster/plugin/hybrid_parallel_plugin.py:65 — HybridParallelModule's methods fall into 7 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 7 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: CheckpointIO (LCOM4 4) colossalai/checkpoint_io/checkpoint_io_base.py:18 — CheckpointIO's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: ZeroBubbleVPipeScheduler (LCOM4 4) colossalai/pipeline/schedule/zero_bubble_pp.py:41 — ZeroBubbleVPipeScheduler's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
D15 · Churn × Complexity Hotspots · Hotspot · ×3
  • Hotspot: colossalai/lazy/pretrained.py colossalai/lazy/pretrained.py:36 — colossalai/lazy/pretrained.py changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 50 in pretrained.new_from_pretrained at line 36. 1 of those changes was a fix/bug commit, and the other 2 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-24..2026-10-22, the 90 days ending at the analysed commit. Reproduce with `git REDACTED --since='2026-07-24 17:37:07 +08:00' --until='2026-10-22 17:37:07 +08:00' --full-history --no-merges -- colossalai/lazy/pretrained.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: colossalai/shardformer/policies/command.py colossalai/shardformer/policies/command.py:38 — colossalai/shardformer/policies/command.py changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 23 in CommandPolicy.module_policy at line 38. 1 of those changes was a fix/bug commit, and the other 2 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-24..2026-10-22, the 90 days ending at the analysed commit. Reproduce with `git REDACTED --since='2026-07-24 17:37:07 +08:00' --until='2026-10-22 17:37:07 +08:00' --full-history --no-merges -- colossalai/shardformer/policies/command.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:59 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py changed 2 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 15 in hybrid_parallel_checkpoint_io._route_padded_parameter_aliases at line 59. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-24..2026-10-22, the 90 days ending at the analysed commit. Reproduce with `git REDACTED --since='2026-07-24 17:37:07 +08:00' --until='2026-10-22 17:37:07 +08:00' --full-history --no-merges -- colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
D29 · Static Analysis (SAST) · REDACTED · ×3
  • REDACTED
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED · ×3
  • REDACTED
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED · ×3
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Duplicated block (46 lines × 2) · ×3
  • Duplicated block (46 lines × 2) colossalai/legacy/moe/layer/experts.py:44 — colossalai/legacy/moe/layer/experts.py:44-89 | colossalai/legacy/moe/layer/routers.py:44-89 — before extracting anything, compare `colossalai/legacy/moe/layer/experts.py` and `colossalai/legacy/moe/layer/routers.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 90 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (46 lines × 2) colossalai/shardformer/modeling/_bert_tf4.py:871 — colossalai/shardformer/modeling/_bert_tf4.py:871-916 | colossalai/shardformer/modeling/_bert_tf5.py:884-929 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (46 lines × 2) colossalai/shardformer/policies/_mixtral_tf4.py:376 — colossalai/shardformer/policies/_mixtral_tf4.py:376-421 | colossalai/shardformer/policies/_mixtral_tf5.py:403-448 — before extracting anything, compare `colossalai/shardformer/policies/_mixtral_tf4.py` and `colossalai/shardformer/policies/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 408 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (36 lines × 2) · ×3
  • Duplicated block (36 lines × 2) applications/ColossalChat/coati/distributed/producer.py:253 — applications/ColossalChat/coati/distributed/producer.py:253-288 | applications/ColossalChat/coati/distributed/zero_bubble/producer.py:301-336 — before extracting anything, compare `applications/ColossalChat/coati/distributed/producer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/producer.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 234 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (36 lines × 2) colossalai/legacy/communication/p2p_v2.py:116 — colossalai/legacy/communication/p2p_v2.py:116-151 | REDACTED:108-143 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/communication/p2p_v2.py:116` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (36 lines × 2) colossalai/shardformer/modeling/_llama_tf4.py:395 — colossalai/shardformer/modeling/_llama_tf4.py:395-430 | colossalai/shardformer/modeling/_llama_tf5.py:437-472 — before extracting anything, compare `colossalai/shardformer/modeling/_llama_tf4.py` and `colossalai/shardformer/modeling/_llama_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (28–29 lines × 2) · ×3
  • Duplicated block (28–29 lines × 2) applications/Colossal-LLaMA/train.py:208 — applications/Colossal-LLaMA/train.py:208-236 | applications/ColossalChat/examples/training_scripts/lora_finetune.py:232-259 — before extracting anything, compare `applications/Colossal-LLaMA/train.py` and `applications/ColossalChat/examples/training_scripts/lora_finetune.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 132 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/Colossal-LLaMA/train.py:208` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `applications/ColossalChat/examples/training_scripts/lora_finetune.py:260` calls `load_model` and `applications/Colossal-LLaMA/train.py:238` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (28–29 lines × 2) applications/ColossalChat/coati/trainer/grpo.py:332 — applications/ColossalChat/coati/trainer/grpo.py:332-359 | applications/ColossalChat/coati/trainer/ppo.py:341-369 — before extracting anything, compare `applications/ColossalChat/coati/trainer/grpo.py` and `applications/ColossalChat/coati/trainer/ppo.py` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 176 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (28–29 lines × 2) colossalai/booster/plugin/hybrid_parallel_plugin.py:1169 — colossalai/booster/plugin/hybrid_parallel_plugin.py:1169-1197 | colossalai/booster/plugin/moe_hybrid_parallel_plugin.py:384-411 — before extracting anything, compare `colossalai/booster/plugin/hybrid_parallel_plugin.py` and `colossalai/booster/plugin/moe_hybrid_parallel_plugin.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 100 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/booster/plugin/hybrid_parallel_plugin.py:1169` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (22–23 lines × 2) · ×3
  • Duplicated block (22–23 lines × 2) applications/ColossalChat/coati/trainer/kto.py:163 — applications/ColossalChat/coati/trainer/kto.py:163-184 | applications/ColossalChat/coati/trainer/kto.py:313-335 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (22–23 lines × 2) colossalai/shardformer/layer/_operation.py:589 — colossalai/shardformer/layer/_operation.py:589-610 | colossalai/shardformer/layer/_operation.py:924-946 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/layer/_operation.py:589` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (22–23 lines × 2) colossalai/shardformer/modeling/chatglm2.py:138 — colossalai/shardformer/modeling/chatglm2.py:138-160 | colossalai/shardformer/modeling/chatglm2.py:371-392 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/chatglm2.py:138` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (21–23 lines × 2) · ×3
  • Duplicated block (21–23 lines × 2) REDACTED:91 — REDACTED:91-113 | colossalai/fx/profiler/tensor.py:64-84 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (21–23 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/strategy/normal_pooling_generator.py:66 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/normal_pooling_generator.py:66-86 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/where_generator.py:32-54 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (21–23 lines × 2) colossalai/nn/optimizer/distributed_lamb.py:105 — colossalai/nn/optimizer/distributed_lamb.py:105-125 | colossalai/nn/optimizer/lamb.py:45-67 — before extracting anything, compare `colossalai/nn/optimizer/distributed_lamb.py` and `colossalai/nn/optimizer/lamb.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 49 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (16–18 lines × 2) · ×3
  • Duplicated block (16–18 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/embedding_handler.py:75 — colossalai/auto_parallel/tensor_shard/node_handler/embedding_handler.py:75-92 | colossalai/auto_parallel/tensor_shard/node_handler/linear_handler.py:112-127 — before extracting anything, compare `colossalai/auto_parallel/tensor_shard/node_handler/embedding_handler.py` and `colossalai/auto_parallel/tensor_shard/node_handler/linear_handler.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 68 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/tensor_shard/node_handler/embedding_handler.py:75` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16–18 lines × 2) colossalai/legacy/nn/layer/parallel_2d/_operation.py:428 — colossalai/legacy/nn/layer/parallel_2d/_operation.py:428-443 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:393-410 — `colossalai/legacy/nn/layer/parallel_2d/_operation.py` and `colossalai/legacy/nn/layer/parallel_2p5d/_operation.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 185 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (16–18 lines × 2) examples/images/vit/args.py:64 — examples/images/vit/args.py:64-79 | examples/language/opt/args.py:16-33 — before extracting anything, compare `examples/images/vit/args.py` and `examples/language/opt/args.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 115 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/images/vit/args.py:64` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (17 lines × 9) · ×3
  • Duplicated block (17 lines × 9) applications/Colossal-LLaMA/train.py:81 — applications/Colossal-LLaMA/train.py:81-97 | applications/ColossalChat/examples/training_scripts/lora_finetune.py:77-93 | applications/ColossalChat/examples/training_scripts/train_dpo.py:56-72 | applications/ColossalChat/examples/training_scripts/train_grpo.py:190-206 | applications/ColossalChat/examples/training_scripts/train_kto.py:66-82 | applications/ColossalChat/examples/training_scripts/train_orpo.py:66-82 | REDACTED:228-244 | applications/ColossalChat/examples/training_scripts/train_rm.py:94-110 | applications/ColossalChat/examples/training_scripts/train_sft.py:88-104 — before extracting anything, compare `applications/Colossal-LLaMA/train.py` and `applications/ColossalChat/examples/training_scripts/lora_finetune.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 132 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/Colossal-LLaMA/train.py:81` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `applications/Colossal-LLaMA/train.py:79` calls `get_accelerator`, `is_available` and `applications/ColossalChat/examples/training_scripts/train_kto.py:64` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (17 lines × 9) colossalai/shardformer/modeling/_bert_tf4.py:991 — colossalai/shardformer/modeling/_bert_tf4.py:991-1007 | colossalai/shardformer/modeling/_bert_tf5.py:1004-1020 | colossalai/shardformer/modeling/bloom.py:701-717 | colossalai/shardformer/modeling/falcon.py:717-733 | colossalai/shardformer/modeling/gpt2.py:596-612 | colossalai/shardformer/modeling/gptj.py:545-561 | colossalai/shardformer/modeling/opt.py:517-533 | examples/community/roberta/pretraining/model/bert.py:1863-1879 | examples/community/roberta/pretraining/model/deberta_v2.py:1511-1527 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_bert_tf4.py:991` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (17 lines × 9) colossalai/shardformer/policies/_llama_tf4.py:249 — colossalai/shardformer/policies/_llama_tf4.py:249-266 | colossalai/shardformer/policies/_llama_tf5.py:247-264 | colossalai/shardformer/policies/_mixtral_tf4.py:209-225 | colossalai/shardformer/policies/_mixtral_tf5.py:233-249 | colossalai/shardformer/policies/_qwen2_tf5.py:235-252 | colossalai/shardformer/policies/_qwen3_tf5.py:236-253 | colossalai/shardformer/policies/gptj.py:201-217 | colossalai/shardformer/policies/mistral.py:194-211 | colossalai/shardformer/policies/opt.py:206-222 — before extracting anything, compare `colossalai/shardformer/policies/_llama_tf4.py` and `colossalai/shardformer/policies/_llama_tf5.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 404 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/policies/_llama_tf4.py:249` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (15 lines × 6) · ×3
  • Duplicated block (15 lines × 6) colossalai/inference/modeling/models/nopadding_llama.py:216 — colossalai/inference/modeling/models/nopadding_llama.py:216-230 | colossalai/legacy/inference/dynamic_batching/infer_batch.py:114-128 | colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:122-136 | colossalai/shardformer/modeling/_whisper_tf4.py:1064-1078 | colossalai/shardformer/modeling/_whisper_tf5.py:579-593 | colossalai/shardformer/modeling/gptj.py:297-311 — before extracting anything, compare `colossalai/shardformer/modeling/_whisper_tf4.py` and `colossalai/shardformer/modeling/_whisper_tf5.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 257 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/inference/modeling/models/nopadding_llama.py:216` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 6) colossalai/legacy/moe/openmoe/model/openmoe_policy.py:470 — colossalai/legacy/moe/openmoe/model/openmoe_policy.py:470-484 | colossalai/shardformer/modeling/_llama_tf4.py:334-348 | colossalai/shardformer/modeling/_llama_tf5.py:376-390 | colossalai/shardformer/modeling/_mixtral_tf4.py:473-487 | colossalai/shardformer/modeling/_mixtral_tf5.py:839-853 | colossalai/shardformer/modeling/command.py:303-317 — before extracting anything, compare `colossalai/legacy/moe/openmoe/model/openmoe_policy.py` and `colossalai/shardformer/modeling/_mixtral_tf4.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 130 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (15 lines × 6) colossalai/shardformer/modeling/gpt2.py:377 — colossalai/shardformer/modeling/gpt2.py:377-391 | colossalai/shardformer/modeling/gpt2.py:472-486 | colossalai/shardformer/modeling/gpt2.py:649-663 | colossalai/shardformer/modeling/gpt2.py:734-748 | colossalai/shardformer/modeling/gptj.py:294-308 | colossalai/shardformer/modeling/gptj.py:397-411 — before extracting anything, compare `colossalai/shardformer/modeling/gpt2.py` and `colossalai/shardformer/modeling/gptj.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 321 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/modeling/gpt2.py:376` calls `gpt2_model_forward` and `colossalai/shardformer/modeling/gpt2.py:467` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (14 lines × 4) · ×3
  • Duplicated block (14 lines × 4) colossalai/legacy/moe/openmoe/model/openmoe_policy.py:93 — colossalai/legacy/moe/openmoe/model/openmoe_policy.py:93-106 | colossalai/shardformer/policies/_mixtral_tf4.py:295-308 | colossalai/shardformer/policies/_mixtral_tf5.py:322-335 | colossalai/shardformer/policies/deepseek.py:305-318 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/policies/_mixtral_tf4.py:294` calls `NotImplementedError` and `colossalai/legacy/moe/openmoe/model/openmoe_policy.py:92` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 4) colossalai/shardformer/modeling/_mixtral_tf4.py:695 — colossalai/shardformer/modeling/_mixtral_tf4.py:695-708 | colossalai/shardformer/modeling/_mixtral_tf5.py:1089-1102 | colossalai/shardformer/modeling/_qwen2_tf4.py:628-641 | colossalai/shardformer/modeling/_qwen3_tf4.py:620-633 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 581 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_mixtral_tf4.py:695` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 4) colossalai/shardformer/examples/data.py:119 — colossalai/shardformer/examples/data.py:119-132 | examples/language/bert/data.py:111-124 | examples/language/gpt/hybridparallelism/data.py:112-125 | examples/tutorial/new_api/glue_bert/data.py:110-123 — before extracting anything, compare `colossalai/shardformer/examples/data.py` and `examples/language/bert/data.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 41 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (12–14 lines × 2) · ×3
  • Duplicated block (12–14 lines × 2) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:216 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:216-229 | colossalai/checkpoint_io/moe_checkpoint.py:393-404 — before extracting anything, compare `colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py` and `colossalai/checkpoint_io/moe_checkpoint.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 249 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (12–14 lines × 2) colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:314 — colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:314-327 | colossalai/shardformer/modeling/falcon.py:407-418 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/modeling/falcon.py:406` calls `is_last_stage` and `colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:313` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12–14 lines × 2) colossalai/shardformer/layer/_operation.py:202 — colossalai/shardformer/layer/_operation.py:202-215 | colossalai/shardformer/layer/_operation.py:371-382 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/layer/_operation.py:202` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (11–13 lines × 2) · ×3
  • Duplicated block (11–13 lines × 2) applications/ColossalChat/coati/trainer/dpo.py:576 — applications/ColossalChat/coati/trainer/dpo.py:576-588 | applications/ColossalChat/coati/trainer/dpo.py:590-600 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/trainer/dpo.py:576` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11–13 lines × 2) colossalai/fx/tracer/meta_patch/patched_module/pooling.py:36 — colossalai/fx/tracer/meta_patch/patched_module/pooling.py:36-48 | colossalai/fx/tracer/meta_patch/patched_module/pooling.py:65-75 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/fx/tracer/meta_patch/patched_module/pooling.py:77` calls `floor` and `colossalai/fx/tracer/meta_patch/patched_module/pooling.py:51` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11–13 lines × 2) colossalai/shardformer/layer/_operation.py:634 — colossalai/shardformer/layer/_operation.py:634-646 | colossalai/shardformer/layer/_operation.py:970-980 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/layer/_operation.py:634` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (10–11 lines × 3) · ×3
  • Duplicated block (10–11 lines × 3) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:182 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:182-192 | colossalai/checkpoint_io/moe_checkpoint.py:126-136 | colossalai/zero/gemini/gemini_ddp.py:970-979 — before extracting anything, compare `colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py` and `colossalai/checkpoint_io/moe_checkpoint.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 249 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (10–11 lines × 3) colossalai/legacy/nn/loss/loss_2d.py:111 — colossalai/legacy/nn/loss/loss_2d.py:111-121 | colossalai/legacy/nn/loss/loss_2p5d.py:105-115 | colossalai/legacy/nn/loss/loss_3d.py:104-113 — before extracting anything, compare `colossalai/legacy/nn/loss/loss_2d.py` and `colossalai/legacy/nn/loss/loss_2p5d.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 39 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (10–11 lines × 3) colossalai/shardformer/modeling/_bert_tf4.py:97 — colossalai/shardformer/modeling/_bert_tf4.py:97-106 | colossalai/shardformer/modeling/_bert_tf5.py:99-108 | examples/community/roberta/pretraining/model/bert.py:956-966 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (10 lines × 6) · ×3
  • Duplicated block (10 lines × 6) colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py:55 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py:55-65 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/getitem_generator.py:35-44 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:39-48 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/softmax_generator.py:39-48 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/sum_generator.py:36-45 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/unary_elementwise_generator.py:27-36 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 6 call sites, so a change lands once.
  • Duplicated block (10 lines × 6) colossalai/fx/profiler/experimental/profiler_module/convolution.py:98 — colossalai/fx/profiler/experimental/profiler_module/convolution.py:98-107 | colossalai/fx/profiler/experimental/profiler_module/convolution.py:133-142 | colossalai/fx/profiler/experimental/profiler_module/convolution.py:174-183 | colossalai/fx/tracer/meta_patch/patched_module/convolution.py:74-83 | colossalai/fx/tracer/meta_patch/patched_module/convolution.py:101-110 | colossalai/fx/tracer/meta_patch/patched_module/convolution.py:136-145 — before extracting anything, compare `colossalai/fx/profiler/experimental/profiler_module/convolution.py` and `colossalai/fx/tracer/meta_patch/patched_module/convolution.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 83 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/fx/profiler/experimental/profiler_module/convolution.py:98` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `self` to `torch.nn.ConvTranspose1d` in one and `torch.nn.ConvTranspose2d` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (10 lines × 6) colossalai/shardformer/layer/linear.py:109 — colossalai/shardformer/layer/linear.py:109-118 | colossalai/shardformer/layer/linear.py:467-476 | colossalai/shardformer/layer/qkv_fused_linear.py:504-513 | colossalai/shardformer/layer/qkv_fused_linear.py:706-715 | colossalai/shardformer/layer/qkv_fused_linear.py:1095-1104 | colossalai/shardformer/layer/qkv_fused_linear.py:1281-1290 — before extracting anything, compare `colossalai/shardformer/layer/linear.py` and `colossalai/shardformer/layer/qkv_fused_linear.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 261 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/shardformer/layer/linear.py:477` calls `fork_rng` and `colossalai/shardformer/layer/linear.py:120` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (8–10 lines × 3) · ×3
  • Duplicated block (8–10 lines × 3) colossalai/legacy/pipeline/rpc/_pipeline_base.py:655 — colossalai/legacy/pipeline/rpc/_pipeline_base.py:655-662 | colossalai/legacy/pipeline/rpc/_pipeline_base.py:717-724 | colossalai/legacy/pipeline/rpc/utils.py:90-99 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (8–10 lines × 3) colossalai/nn/optimizer/distributed_adafactor.py:336 — colossalai/nn/optimizer/distributed_adafactor.py:336-343 | colossalai/nn/optimizer/distributed_adafactor.py:350-357 | colossalai/nn/optimizer/distributed_adafactor.py:364-373 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (8–10 lines × 3) colossalai/shardformer/modeling/_llama_tf5.py:640 — colossalai/shardformer/modeling/_llama_tf5.py:640-649 | colossalai/shardformer/modeling/_qwen2_tf5.py:449-456 | colossalai/shardformer/modeling/_qwen3_tf5.py:450-457 — before extracting anything, compare `colossalai/shardformer/modeling/_llama_tf5.py` and `colossalai/shardformer/modeling/_qwen2_tf5.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 104 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_llama_tf5.py:640` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (9 lines × 6) · ×3
  • Duplicated block (9 lines × 6) colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:86 — colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:86-94 | colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:287-297 | colossalai/shardformer/modeling/bloom.py:129-137 | colossalai/shardformer/modeling/bloom.py:346-354 | colossalai/shardformer/modeling/bloom.py:438-446 | colossalai/shardformer/modeling/bloom.py:564-572 — there are 6 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (9 lines × 6) colossalai/legacy/nn/layer/parallel_2d/_operation.py:243 — colossalai/legacy/nn/layer/parallel_2d/_operation.py:243-251 | colossalai/legacy/nn/layer/parallel_2d/_operation.py:392-400 | colossalai/legacy/nn/layer/parallel_2d/_operation.py:549-557 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:198-206 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:355-363 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:520-528 — `colossalai/legacy/nn/layer/parallel_2d/_operation.py` and `colossalai/legacy/nn/layer/parallel_2p5d/_operation.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 185 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (9 lines × 6) colossalai/shardformer/policies/_bert_tf4.py:666 — colossalai/shardformer/policies/_bert_tf4.py:666-674 | colossalai/shardformer/policies/_bert_tf4.py:710-718 | colossalai/shardformer/policies/_bert_tf4.py:784-792 | colossalai/shardformer/policies/_bert_tf5.py:673-681 | colossalai/shardformer/policies/_bert_tf5.py:717-725 | colossalai/shardformer/policies/_bert_tf5.py:791-799 — before extracting anything, compare `colossalai/shardformer/policies/_bert_tf4.py` and `colossalai/shardformer/policies/_bert_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 475 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (6 lines × 8) · ×3
  • Duplicated block (6 lines × 8) colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:89 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:89-94 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py:61-66 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/getitem_generator.py:40-45 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/layer_norm_generator.py:78-83 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:44-49 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/softmax_generator.py:44-49 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/sum_generator.py:41-46 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/unary_elementwise_generator.py:32-37 — before extracting anything, compare `colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py` and `colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 143 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:86` calls `_compute_size_in_bytes` and `colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py:59` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 8) colossalai/legacy/inference/quant/smoothquant/models/llama.py:571 — colossalai/legacy/inference/quant/smoothquant/models/llama.py:571-577 | colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:96-101 | colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:717-723 | colossalai/legacy/moe/openmoe/model/openmoe_policy.py:253-259 | colossalai/shardformer/modeling/_deepseek_v3_tf4.py:161-167 | colossalai/shardformer/modeling/_qwen2_tf4.py:62-68 | colossalai/shardformer/modeling/_qwen3_tf4.py:62-68 | colossalai/shardformer/modeling/bloom.py:139-144 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 8 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 8 times. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/legacy/moe/openmoe/model/openmoe_policy.py:262` calls `is_first_stage` and `colossalai/legacy/inference/quant/smoothquant/models/llama.py:580` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 8) colossalai/shardformer/examples/data.py:99 — colossalai/shardformer/examples/data.py:99-104 | colossalai/shardformer/examples/data.py:110-115 | examples/language/bert/data.py:93-98 | examples/language/bert/data.py:102-107 | examples/language/gpt/hybridparallelism/data.py:94-99 | examples/language/gpt/hybridparallelism/data.py:103-108 | examples/tutorial/new_api/glue_bert/data.py:92-97 | examples/tutorial/new_api/glue_bert/data.py:101-106 — before extracting anything, compare `colossalai/shardformer/examples/data.py` and `examples/language/bert/data.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 41 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/examples/data.py:108` calls `native_prepare_dataloader` and `examples/language/bert/data.py:100` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (6 lines × 7) · ×3
  • Duplicated block (6 lines × 7) colossalai/shardformer/modeling/_bert_tf4.py:451 — colossalai/shardformer/modeling/_bert_tf4.py:451-456 | colossalai/shardformer/modeling/_bert_tf4.py:533-538 | colossalai/shardformer/modeling/_bert_tf5.py:464-469 | colossalai/shardformer/modeling/_bert_tf5.py:546-551 | examples/community/roberta/pretraining/model/bert.py:1248-1253 | examples/community/roberta/pretraining/model/bert.py:1361-1366 | examples/community/roberta/pretraining/model/deberta_v2.py:1170-1175 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/modeling/_bert_tf4.py:449` calls `contiguous` and `colossalai/shardformer/modeling/_bert_tf4.py:532` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 7) colossalai/shardformer/modeling/_qwen2_tf4.py:625 — colossalai/shardformer/modeling/_qwen2_tf4.py:625-631 | colossalai/shardformer/modeling/_qwen3_tf4.py:617-623 | colossalai/shardformer/modeling/_whisper_tf4.py:178-183 | colossalai/shardformer/modeling/deepseek.py:722-728 | colossalai/shardformer/modeling/gptj.py:664-669 | colossalai/shardformer/modeling/gptj.py:840-845 | colossalai/shardformer/modeling/opt.py:629-635 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf4.py` and `colossalai/shardformer/modeling/_qwen3_tf4.py` as WHOLE FILES: this scan already matched 52 separate duplicated blocks between them, totalling at least 1214 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (6 lines × 7) colossalai/shardformer/modeling/_qwen2_tf4.py:770 — colossalai/shardformer/modeling/_qwen2_tf4.py:770-775 | colossalai/shardformer/modeling/_qwen2_tf5.py:543-548 | colossalai/shardformer/modeling/_qwen3_tf4.py:762-767 | colossalai/shardformer/modeling/_qwen3_tf5.py:544-549 | colossalai/shardformer/modeling/command.py:581-586 | colossalai/shardformer/modeling/mistral.py:566-571 | colossalai/shardformer/modeling/opt.py:853-858 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf4.py` and `colossalai/shardformer/modeling/_qwen2_tf5.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 242 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (14 lines × 5) · ×3
  • Duplicated block (14 lines × 5) examples/language/deepseek/performance_evaluator.py:127 — examples/language/deepseek/performance_evaluator.py:127-140 | examples/language/gpt/gemini/commons/performance_evaluator.py:127-140 | examples/language/llama/performance_evaluator.py:127-140 | examples/language/mixtral/performance_evaluator.py:127-140 | examples/language/performance_evaluator.py:127-140 — before extracting anything, compare `examples/language/deepseek/performance_evaluator.py` and `examples/language/gpt/gemini/commons/performance_evaluator.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 96 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (14 lines × 5) examples/language/deepseek/performance_evaluator.py:150 — examples/language/deepseek/performance_evaluator.py:150-163 | examples/language/gpt/gemini/commons/performance_evaluator.py:150-163 | examples/language/llama/performance_evaluator.py:150-163 | examples/language/mixtral/performance_evaluator.py:150-163 | examples/language/performance_evaluator.py:150-163 — before extracting anything, compare `examples/language/deepseek/performance_evaluator.py` and `examples/language/gpt/gemini/commons/performance_evaluator.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 96 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (14 lines × 5) examples/language/deepseek/performance_evaluator.py:23 — examples/language/deepseek/performance_evaluator.py:23-36 | examples/language/gpt/gemini/commons/performance_evaluator.py:23-36 | examples/language/llama/performance_evaluator.py:23-36 | examples/language/mixtral/performance_evaluator.py:23-36 | examples/language/performance_evaluator.py:23-36 — before extracting anything, compare `examples/language/deepseek/performance_evaluator.py` and `examples/language/gpt/gemini/commons/performance_evaluator.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 96 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D1 · Cyclomatic Complexity · p2p._communicate (cyclomatic 25) · ×2
  • p2p._communicate (cyclomatic 25) colossalai/legacy/communication/p2p.py:89 — p2p._communicate has cyclomatic complexity 25 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • p2p._communicate (cyclomatic 25) REDACTED:364 — p2p._communicate has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · WhisperPolicy.get_held_layers (cyclomatic 24) · ×2
  • WhisperPolicy.get_held_layers (cyclomatic 24) colossalai/shardformer/policies/_whisper_tf4.py:593 — WhisperPolicy.get_held_layers has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • WhisperPolicy.get_held_layers (cyclomatic 24) colossalai/shardformer/policies/_whisper_tf5.py:580 — WhisperPolicy.get_held_layers has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · LlamaPipelineForwards.llama_for_sequence_classification_forward (cyclomatic 23) · ×2
  • LlamaPipelineForwards.llama_for_sequence_classification_forward (cyclomatic 23) colossalai/shardformer/modeling/_llama_tf4.py:377 — LlamaPipelineForwards.llama_for_sequence_classification_forward has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • LlamaPipelineForwards.llama_for_sequence_classification_forward (cyclomatic 23) colossalai/shardformer/modeling/_llama_tf5.py:419 — LlamaPipelineForwards.llama_for_sequence_classification_forward has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Qwen2Policy.module_policy (cyclomatic 19) · ×2
  • Qwen2Policy.module_policy (cyclomatic 19) colossalai/shardformer/policies/_qwen2_tf4.py:55 — Qwen2Policy.module_policy has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Qwen2Policy.module_policy (cyclomatic 19) colossalai/shardformer/policies/_qwen2_tf5.py:55 — Qwen2Policy.module_policy has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Qwen3Policy.module_policy (cyclomatic 19) · ×2
  • Qwen3Policy.module_policy (cyclomatic 19) colossalai/shardformer/policies/_qwen3_tf4.py:55 — Qwen3Policy.module_policy has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Qwen3Policy.module_policy (cyclomatic 19) colossalai/shardformer/policies/_qwen3_tf5.py:56 — Qwen3Policy.module_policy has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · BertPipelineForwards.bert_for_sequence_classification_forward (cyclomatic 17) · ×2
  • BertPipelineForwards.bert_for_sequence_classification_forward (cyclomatic 17) colossalai/shardformer/modeling/_bert_tf4.py:659 — BertPipelineForwards.bert_for_sequence_classification_forward has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • BertPipelineForwards.bert_for_sequence_classification_forward (cyclomatic 17) colossalai/shardformer/modeling/_bert_tf5.py:672 — BertPipelineForwards.bert_for_sequence_classification_forward has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · BertPolicy.module_policy (cyclomatic 16) · ×2
  • BertPolicy.module_policy (cyclomatic 16) colossalai/shardformer/policies/_bert_tf4.py:45 — BertPolicy.module_policy has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • BertPolicy.module_policy (cyclomatic 16) colossalai/shardformer/policies/_bert_tf5.py:45 — BertPolicy.module_policy has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · WhisperPolicy.get_held_layers (cognitive 50) · ×2
  • WhisperPolicy.get_held_layers (cognitive 50) colossalai/shardformer/policies/_whisper_tf4.py:593 — WhisperPolicy.get_held_layers has cognitive complexity 50 (threshold 15). Drivers by points: if/else 20 (38 pts), boolean chains 6, loops 2 (6 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • WhisperPolicy.get_held_layers (cognitive 50) colossalai/shardformer/policies/_whisper_tf5.py:580 — WhisperPolicy.get_held_layers has cognitive complexity 50 (threshold 15). Drivers by points: if/else 20 (38 pts), boolean chains 6, loops 2 (6 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LlamaPipelineForwards.llama_for_sequence_classification_forward (cognitive 38) · ×2
  • LlamaPipelineForwards.llama_for_sequence_classification_forward (cognitive 38) colossalai/shardformer/modeling/_llama_tf4.py:377 — LlamaPipelineForwards.llama_for_sequence_classification_forward has cognitive complexity 38 (threshold 15). Drivers by points: if/else 17 (31 pts), ternaries 2 (4 pts), boolean chains 3 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • LlamaPipelineForwards.llama_for_sequence_classification_forward (cognitive 38) colossalai/shardformer/modeling/_llama_tf5.py:419 — LlamaPipelineForwards.llama_for_sequence_classification_forward has cognitive complexity 38 (threshold 15). Drivers by points: if/else 17 (31 pts), ternaries 2 (4 pts), boolean chains 3 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BertPipelineForwards.bert_for_sequence_classification_forward (cognitive 30) · ×2
  • BertPipelineForwards.bert_for_sequence_classification_forward (cognitive 30) colossalai/shardformer/modeling/_bert_tf4.py:659 — BertPipelineForwards.bert_for_sequence_classification_forward has cognitive complexity 30 (threshold 15). Drivers by points: if/else 12 (24 pts), ternaries 2 (4 pts), boolean chains 2 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • BertPipelineForwards.bert_for_sequence_classification_forward (cognitive 30) colossalai/shardformer/modeling/_bert_tf5.py:672 — BertPipelineForwards.bert_for_sequence_classification_forward has cognitive complexity 30 (threshold 15). Drivers by points: if/else 12 (24 pts), ternaries 2 (4 pts), boolean chains 2 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ColoTracer._post_check (cognitive 29) · ×2
  • ColoTracer._post_check (cognitive 29) colossalai/_analyzer/fx/tracer/tracer.py:306 — ColoTracer._post_check has cognitive complexity 29 (threshold 15). Drivers by points: if/else 6 (18 pts), loops 3 (11 pts) (nesting depth added 20). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • ColoTracer._post_check (cognitive 29) colossalai/fx/tracer/experimental.py:334 — ColoTracer._post_check has cognitive complexity 29 (threshold 15). Drivers by points: if/else 6 (18 pts), loops 3 (11 pts) (nesting depth added 20). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · train.main (cognitive 27) · ×2
  • train.main (cognitive 27) applications/ColossalMoE/train.py:142 — train.main has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 2 (3 pts), ternaries 2 (3 pts), boolean chains 2 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • train.main (cognitive 27) colossalai/legacy/moe/openmoe/train.py:205 — train.main has cognitive complexity 27 (threshold 15). Drivers by points: if/else 12 (21 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · WhisperPipelineForwards.whisper_model_forward (cognitive 27) · ×2
  • WhisperPipelineForwards.whisper_model_forward (cognitive 27) colossalai/shardformer/modeling/_whisper_tf4.py:845 — WhisperPipelineForwards.whisper_model_forward has cognitive complexity 27 (threshold 15). Drivers by points: if/else 12 (15 pts), ternaries 6 (10 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • WhisperPipelineForwards.whisper_model_forward (cognitive 27) colossalai/shardformer/modeling/_whisper_tf5.py:363 — WhisperPipelineForwards.whisper_model_forward has cognitive complexity 27 (threshold 15). Drivers by points: if/else 13 (18 pts), ternaries 3 (7 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Qwen2Policy.module_policy (cognitive 21) · ×2
  • Qwen2Policy.module_policy (cognitive 21) colossalai/shardformer/policies/_qwen2_tf4.py:55 — Qwen2Policy.module_policy has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 5, ternaries 2 (3 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Qwen2Policy.module_policy (cognitive 21) colossalai/shardformer/policies/_qwen2_tf5.py:55 — Qwen2Policy.module_policy has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 5, ternaries 2 (3 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Qwen3Policy.module_policy (cognitive 21) · ×2
  • Qwen3Policy.module_policy (cognitive 21) colossalai/shardformer/policies/_qwen3_tf4.py:55 — Qwen3Policy.module_policy has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 5, ternaries 2 (3 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Qwen3Policy.module_policy (cognitive 21) colossalai/shardformer/policies/_qwen3_tf5.py:56 — Qwen3Policy.module_policy has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 5, ternaries 2 (3 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BertPipelineForwards.bert_for_multiple_choice_forward (cognitive 20) · ×2
  • BertPipelineForwards.bert_for_multiple_choice_forward (cognitive 20) colossalai/shardformer/modeling/_bert_tf4.py:828 — BertPipelineForwards.bert_for_multiple_choice_forward has cognitive complexity 20 (threshold 15). Drivers by points: ternaries 8 (11 pts), if/else 7 (9 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • BertPipelineForwards.bert_for_multiple_choice_forward (cognitive 20) colossalai/shardformer/modeling/_bert_tf5.py:841 — BertPipelineForwards.bert_for_multiple_choice_forward has cognitive complexity 20 (threshold 15). Drivers by points: ternaries 8 (11 pts), if/else 7 (9 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LlamaPipelineForwards.llama_for_causal_lm_forward (cognitive 20) · ×2
  • LlamaPipelineForwards.llama_for_causal_lm_forward (cognitive 20) colossalai/shardformer/modeling/_llama_tf4.py:264 — LlamaPipelineForwards.llama_for_causal_lm_forward has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (12 pts), ternaries 4 (6 pts), boolean chains 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • LlamaPipelineForwards.llama_for_causal_lm_forward (cognitive 20) colossalai/shardformer/modeling/_llama_tf5.py:306 — LlamaPipelineForwards.llama_for_causal_lm_forward has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (12 pts), ternaries 4 (6 pts), boolean chains 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Qwen3PipelineForwards.qwen3_for_sequence_classification_forward (cognitive 20) · ×2
  • Qwen3PipelineForwards.qwen3_for_sequence_classification_forward (cognitive 20) colossalai/shardformer/modeling/_qwen3_tf4.py:366 — Qwen3PipelineForwards.qwen3_for_sequence_classification_forward has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11 (15 pts), ternaries 2 (4 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Qwen3PipelineForwards.qwen3_for_sequence_classification_forward (cognitive 20) colossalai/shardformer/modeling/_qwen3_tf5.py:279 — Qwen3PipelineForwards.qwen3_for_sequence_classification_forward has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11 (15 pts), ternaries 2 (4 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BertPipelineForwards.bert_for_question_answering_forward (cognitive 19) · ×2
  • BertPipelineForwards.bert_for_question_answering_forward (cognitive 19) colossalai/shardformer/modeling/_bert_tf4.py:919 — BertPipelineForwards.bert_for_question_answering_forward has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (14 pts), ternaries 2 (4 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • BertPipelineForwards.bert_for_question_answering_forward (cognitive 19) colossalai/shardformer/modeling/_bert_tf5.py:932 — BertPipelineForwards.bert_for_question_answering_forward has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (14 pts), ternaries 2 (4 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BertPolicy.module_policy (cognitive 17) · ×2
  • BertPolicy.module_policy (cognitive 17) colossalai/shardformer/policies/_bert_tf4.py:45 — BertPolicy.module_policy has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (13 pts), boolean chains 2, ternaries 1 (2 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • BertPolicy.module_policy (cognitive 17) colossalai/shardformer/policies/_bert_tf5.py:45 — BertPolicy.module_policy has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (13 pts), boolean chains 2, ternaries 1 (2 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · DeepseekV3Policy.get_held_layers (cognitive 17) · ×2
  • DeepseekV3Policy.get_held_layers (cognitive 17) colossalai/shardformer/policies/_deepseek_v3_tf4.py:102 — DeepseekV3Policy.get_held_layers has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • DeepseekV3Policy.get_held_layers (cognitive 17) colossalai/shardformer/policies/_deepseek_v3_tf5.py:107 — DeepseekV3Policy.get_held_layers has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LlamaPolicy.get_held_layers (cognitive 17) · ×2
  • LlamaPolicy.get_held_layers (cognitive 17) colossalai/shardformer/policies/_llama_tf4.py:333 — LlamaPolicy.get_held_layers has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • LlamaPolicy.get_held_layers (cognitive 17) colossalai/shardformer/policies/_llama_tf5.py:331 — LlamaPolicy.get_held_layers has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MixtralPolicy.get_held_layers (cognitive 17) · ×2
  • MixtralPolicy.get_held_layers (cognitive 17) colossalai/shardformer/policies/_mixtral_tf4.py:310 — MixtralPolicy.get_held_layers has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • MixtralPolicy.get_held_layers (cognitive 17) colossalai/shardformer/policies/_mixtral_tf5.py:337 — MixtralPolicy.get_held_layers has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Qwen2Policy.get_held_layers (cognitive 17) · ×2
  • Qwen2Policy.get_held_layers (cognitive 17) colossalai/shardformer/policies/_qwen2_tf4.py:343 — Qwen2Policy.get_held_layers has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Qwen2Policy.get_held_layers (cognitive 17) colossalai/shardformer/policies/_qwen2_tf5.py:342 — Qwen2Policy.get_held_layers has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Qwen3Policy.get_held_layers (cognitive 17) · ×2
  • Qwen3Policy.get_held_layers (cognitive 17) colossalai/shardformer/policies/_qwen3_tf4.py:343 — Qwen3Policy.get_held_layers has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Qwen3Policy.get_held_layers (cognitive 17) colossalai/shardformer/policies/_qwen3_tf5.py:363 — Qwen3Policy.get_held_layers has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D29 · Static Analysis (SAST) · REDACTED · ×2
  • REDACTED
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Near-duplicate member pair (109 shared lines) · ×2
  • Near-duplicate member pair (109 shared lines) applications/Colossal-LLaMA/train.py:44 — applications/Colossal-LLaMA/train.py:44-433 | applications/ColossalChat/examples/training_scripts/lora_finetune.py:50-366 — These two members are variants of one another: 109 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
  • Near-duplicate member pair (109 shared lines) examples/language/bert/finetune.py:175 — examples/language/bert/finetune.py:175-332 | examples/language/gpt/hybridparallelism/finetune.py:174-324 — These two members are variants of one another: 109 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (65 shared lines) · ×2
  • Near-duplicate member pair (65 shared lines) applications/ColossalChat/coati/distributed/launch.py:69 — applications/ColossalChat/coati/distributed/launch.py:69-190 | applications/ColossalChat/coati/distributed/launch_zero_bubble.py:64-305 — These two members are variants of one another: 65 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
  • Near-duplicate member pair (65 shared lines) applications/ColossalChat/coati/distributed/grpo_consumer.py:45 — applications/ColossalChat/coati/distributed/grpo_consumer.py:45-141 | applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py:46-132 — These two members are variants of one another: 65 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (51 shared lines) · ×2
  • Near-duplicate member pair (51 shared lines) colossalai/kernel/triton/context_attn_unpad.py:569 — colossalai/kernel/triton/context_attn_unpad.py:569-727 | colossalai/kernel/triton/flash_decoding.py:335-533 — These two members are variants of one another: 51 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
  • Near-duplicate member pair (51 shared lines) colossalai/shardformer/modeling/_deepseek_v3_tf4.py:298 — colossalai/shardformer/modeling/_deepseek_v3_tf4.py:298-370 | colossalai/shardformer/modeling/_deepseek_v3_tf5.py:325-408 — These two members are variants of one another: 51 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (47 shared lines) · ×2
  • Near-duplicate member pair (47 shared lines) applications/ColossalChat/coati/trainer/grpo.py:229 — applications/ColossalChat/coati/trainer/grpo.py:229-329 | applications/ColossalChat/coati/trainer/ppo.py:218-338 — These two members are variants of one another: 47 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
  • Near-duplicate member pair (47 shared lines) colossalai/kernel/triton/flash_decoding.py:50 — colossalai/kernel/triton/flash_decoding.py:50-130 | colossalai/kernel/triton/flash_decoding.py:168-253 — These two members are variants of one another: 47 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Members sharing a duplicated core (10 members, 50+ identical tokens) · ×2
  • Members sharing a duplicated core (10 members, 50+ identical tokens) colossalai/shardformer/modeling/_llama_tf4.py:494 — colossalai/shardformer/modeling/_llama_tf4.py:494-616 | colossalai/shardformer/modeling/_llama_tf5.py:536-658 | colossalai/shardformer/modeling/_mixtral_tf4.py:539-669 | colossalai/shardformer/modeling/_mixtral_tf5.py:917-1059 | colossalai/shardformer/modeling/_qwen2_tf4.py:484-605 | colossalai/shardformer/modeling/_qwen2_tf5.py:382-462 | colossalai/shardformer/modeling/_qwen3_tf4.py:470-597 | colossalai/shardformer/modeling/_qwen3_tf5.py:383-463 | colossalai/shardformer/modeling/command.py:349-426 | colossalai/shardformer/modeling/deepseek.py:589-704 — These 10 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 10 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 10 times.
  • Members sharing a duplicated core (10 members, 50+ identical tokens) colossalai/shardformer/policies/_llama_tf4.py:334 — colossalai/shardformer/policies/_llama_tf4.py:334-366 | colossalai/shardformer/policies/_llama_tf5.py:332-364 | colossalai/shardformer/policies/_mixtral_tf4.py:311-345 | colossalai/shardformer/policies/_mixtral_tf5.py:338-372 | colossalai/shardformer/policies/_qwen2_tf4.py:344-378 | colossalai/shardformer/policies/_qwen2_tf5.py:343-377 | colossalai/shardformer/policies/_qwen3_tf4.py:344-378 | colossalai/shardformer/policies/_qwen3_tf5.py:364-398 | colossalai/shardformer/policies/command.py:312-345 | colossalai/shardformer/policies/mistral.py:295-326 — These 10 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 10 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 10 times.
D4 · Code Duplication · Duplicated block (70 lines × 2) · ×2
  • Duplicated block (70 lines × 2) colossalai/shardformer/policies/_qwen2_tf4.py:236 — colossalai/shardformer/policies/_qwen2_tf4.py:236-305 | colossalai/shardformer/policies/_qwen2_tf5.py:235-304 — before extracting anything, compare `colossalai/shardformer/policies/_qwen2_tf4.py` and `colossalai/shardformer/policies/_qwen2_tf5.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 399 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/policies/_qwen2_tf4.py:236` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (70 lines × 2) colossalai/shardformer/policies/_qwen3_tf4.py:236 — colossalai/shardformer/policies/_qwen3_tf4.py:236-305 | colossalai/shardformer/policies/_qwen3_tf5.py:236-305 — before extracting anything, compare `colossalai/shardformer/policies/_qwen3_tf4.py` and `colossalai/shardformer/policies/_qwen3_tf5.py` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 345 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/policies/_qwen3_tf4.py:236` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (66 lines × 2) · ×2
  • Duplicated block (66 lines × 2) colossalai/shardformer/modeling/_bert_tf4.py:63 — colossalai/shardformer/modeling/_bert_tf4.py:63-128 | colossalai/shardformer/modeling/_bert_tf5.py:65-130 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (66 lines × 2) colossalai/shardformer/modeling/_qwen2_tf5.py:468 — colossalai/shardformer/modeling/_qwen2_tf5.py:468-533 | colossalai/shardformer/modeling/_qwen3_tf5.py:469-534 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf5.py` and `colossalai/shardformer/modeling/_qwen3_tf5.py` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 628 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (57 lines × 2) · ×2
  • Duplicated block (57 lines × 2) applications/ColossalChat/coati/distributed/grpo_consumer.py:406 — applications/ColossalChat/coati/distributed/grpo_consumer.py:406-462 | applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py:356-412 — before extracting anything, compare `applications/ColossalChat/coati/distributed/grpo_consumer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 407 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/distributed/grpo_consumer.py:406` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (57 lines × 2) colossalai/legacy/inference/hybridengine/modeling/llama.py:416 — colossalai/legacy/inference/hybridengine/modeling/llama.py:416-472 | colossalai/legacy/inference/tensor_parallel/modeling/llama.py:336-392 — before extracting anything, compare `colossalai/legacy/inference/hybridengine/modeling/llama.py` and `colossalai/legacy/inference/tensor_parallel/modeling/llama.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 250 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (52 lines × 2) · ×2
  • Duplicated block (52 lines × 2) colossalai/shardformer/modeling/_bert_tf4.py:570 — colossalai/shardformer/modeling/_bert_tf4.py:570-621 | colossalai/shardformer/modeling/_bert_tf5.py:583-634 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_bert_tf4.py:570` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (52 lines × 2) colossalai/shardformer/policies/_llama_tf4.py:473 — colossalai/shardformer/policies/_llama_tf4.py:473-524 | colossalai/shardformer/policies/_llama_tf5.py:471-522 — before extracting anything, compare `colossalai/shardformer/policies/_llama_tf4.py` and `colossalai/shardformer/policies/_llama_tf5.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 404 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (50 lines × 2) · ×2
  • Duplicated block (50 lines × 2) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:702 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:702-751 | colossalai/checkpoint_io/moe_checkpoint.py:586-635 — before extracting anything, compare `colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py` and `colossalai/checkpoint_io/moe_checkpoint.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 249 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: `CheckpointIndexFile` names `.index_file` in one and `colossalai.checkpoint_io` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (50 lines × 2) colossalai/shardformer/policies/_llama_tf4.py:249 — colossalai/shardformer/policies/_llama_tf4.py:249-298 | colossalai/shardformer/policies/_llama_tf5.py:247-296 — before extracting anything, compare `colossalai/shardformer/policies/_llama_tf4.py` and `colossalai/shardformer/policies/_llama_tf5.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 404 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/policies/_llama_tf4.py:249` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (49 lines × 2) · ×2
  • Duplicated block (49 lines × 2) applications/ColossalChat/coati/distributed/producer.py:148 — applications/ColossalChat/coati/distributed/producer.py:148-196 | applications/ColossalChat/coati/distributed/zero_bubble/producer.py:142-190 — before extracting anything, compare `applications/ColossalChat/coati/distributed/producer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/producer.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 234 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/distributed/producer.py:148` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: `BACKEND_MAP` names `.inference_backend` in one and `coati.distributed.inference_backend` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (49 lines × 2) colossalai/shardformer/policies/_vit_tf4.py:331 — colossalai/shardformer/policies/_vit_tf4.py:331-379 | colossalai/shardformer/policies/_vit_tf5.py:181-229 — before extracting anything, compare `colossalai/shardformer/policies/_vit_tf4.py` and `colossalai/shardformer/policies/_vit_tf5.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 133 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (43–44 lines × 2) · ×2
  • Duplicated block (43–44 lines × 2) colossalai/pipeline/schedule/interleaved_pp.py:350 — colossalai/pipeline/schedule/interleaved_pp.py:350-393 | colossalai/pipeline/schedule/one_f_one_b.py:291-333 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (43–44 lines × 2) colossalai/shardformer/modeling/_mixtral_tf4.py:613 — colossalai/shardformer/modeling/_mixtral_tf4.py:613-655 | colossalai/shardformer/modeling/_mixtral_tf5.py:1002-1045 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 581 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (42 lines × 2) · ×2
  • Duplicated block (42 lines × 2) colossalai/shardformer/modeling/gpt2.py:561 — colossalai/shardformer/modeling/gpt2.py:561-602 | colossalai/shardformer/modeling/gptj.py:510-551 — before extracting anything, compare `colossalai/shardformer/modeling/gpt2.py` and `colossalai/shardformer/modeling/gptj.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 321 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/gptj.py:510` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (42 lines × 2) examples/images/dreambooth/train_dreambooth_colossalai.py:144 — examples/images/dreambooth/train_dreambooth_colossalai.py:144-185 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:147-188 — before extracting anything, compare `examples/images/dreambooth/train_dreambooth_colossalai.py` and `examples/images/dreambooth/train_dreambooth_colossalai_lora.py` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 757 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/images/dreambooth/train_dreambooth_colossalai.py:144` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (38 lines × 2) · ×2
  • Duplicated block (38 lines × 2) colossalai/shardformer/modeling/_llama_tf4.py:70 — colossalai/shardformer/modeling/_llama_tf4.py:70-107 | colossalai/shardformer/modeling/_llama_tf5.py:107-144 — before extracting anything, compare `colossalai/shardformer/modeling/_llama_tf4.py` and `colossalai/shardformer/modeling/_llama_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (38 lines × 2) colossalai/shardformer/modeling/_mixtral_tf4.py:681 — colossalai/shardformer/modeling/_mixtral_tf4.py:681-718 | colossalai/shardformer/modeling/_mixtral_tf5.py:1075-1112 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 581 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_mixtral_tf4.py:681` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (34–35 lines × 2) · ×2
  • Duplicated block (34–35 lines × 2) applications/ColossalChat/coati/trainer/kto.py:129 — applications/ColossalChat/coati/trainer/kto.py:129-162 | applications/ColossalChat/coati/trainer/kto.py:278-312 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/trainer/kto.py:129` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (34–35 lines × 2) colossalai/shardformer/modeling/_llama_tf4.py:109 — colossalai/shardformer/modeling/_llama_tf4.py:109-143 | colossalai/shardformer/modeling/_llama_tf5.py:151-184 — before extracting anything, compare `colossalai/shardformer/modeling/_llama_tf4.py` and `colossalai/shardformer/modeling/_llama_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (34 lines × 2) · ×2
  • Duplicated block (34 lines × 2) applications/ColossalChat/coati/distributed/grpo_consumer.py:175 — applications/ColossalChat/coati/distributed/grpo_consumer.py:175-208 | applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py:165-198 — before extracting anything, compare `applications/ColossalChat/coati/distributed/grpo_consumer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 407 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (34 lines × 2) colossalai/shardformer/modeling/bloom.py:67 — colossalai/shardformer/modeling/bloom.py:67-100 | colossalai/shardformer/modeling/falcon.py:62-95 — before extracting anything, compare `colossalai/shardformer/modeling/bloom.py` and `colossalai/shardformer/modeling/falcon.py` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 594 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/bloom.py:67` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (33–34 lines × 2) · ×2
  • Duplicated block (33–34 lines × 2) colossalai/nn/optimizer/cpu_adam.py:160 — colossalai/nn/optimizer/cpu_adam.py:160-192 | colossalai/nn/optimizer/hybrid_adam.py:128-161 — before extracting anything, compare `colossalai/nn/optimizer/cpu_adam.py` and `colossalai/nn/optimizer/hybrid_adam.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (33–34 lines × 2) applications/ColossalChat/examples/training_scripts/train_grpo.py:242 — applications/ColossalChat/examples/training_scripts/train_grpo.py:242-275 | REDACTED:279-311 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_grpo.py` and `REDACTED` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 469 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (32 lines × 2) · ×2
  • Duplicated block (32 lines × 2) colossalai/_analyzer/fx/tracer/tracer.py:340 — colossalai/_analyzer/fx/tracer/tracer.py:340-371 | colossalai/fx/tracer/experimental.py:367-398 — before extracting anything, compare `colossalai/_analyzer/fx/tracer/tracer.py` and `colossalai/fx/tracer/experimental.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 93 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/_analyzer/fx/tracer/tracer.py:336` calls `getattr`, `_module_getattr` and `colossalai/fx/tracer/experimental.py:364` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (32 lines × 2) REDACTED:28 — REDACTED:28-59 | REDACTED:25-56 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 194 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (31–32 lines × 2) · ×2
  • Duplicated block (31–32 lines × 2) colossalai/auto_parallel/offload/training_simulator.py:129 — colossalai/auto_parallel/offload/training_simulator.py:129-159 | colossalai/auto_parallel/offload/training_simulator.py:389-420 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (31–32 lines × 2) colossalai/shardformer/modeling/_bert_tf4.py:215 — colossalai/shardformer/modeling/_bert_tf4.py:215-245 | examples/community/roberta/pretraining/model/bert.py:585-616 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `examples/community/roberta/pretraining/model/bert.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 255 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (28–31 lines × 2) · ×2
  • Duplicated block (28–31 lines × 2) applications/ColossalChat/coati/trainer/orpo.py:136 — applications/ColossalChat/coati/trainer/orpo.py:136-163 | applications/ColossalChat/coati/trainer/orpo.py:275-305 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/trainer/orpo.py:136` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (28–31 lines × 2) colossalai/fx/codegen/activation_checkpoint_codegen.py:451 — colossalai/fx/codegen/activation_checkpoint_codegen.py:451-478 | colossalai/fx/codegen/activation_checkpoint_codegen.py:537-567 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (27–29 lines × 2) · ×2
  • Duplicated block (27–29 lines × 2) colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:231 — colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:231-257 | colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py:928-956 — before extracting anything, compare `colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py` and `colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 176 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (27–29 lines × 2) colossalai/shardformer/modeling/gptj.py:796 — colossalai/shardformer/modeling/gptj.py:796-822 | colossalai/shardformer/modeling/gptj.py:986-1014 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/gptj.py:986` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (26–27 lines × 2) · ×2
  • Duplicated block (26–27 lines × 2) colossalai/legacy/inference/hybridengine/modeling/llama.py:99 — colossalai/legacy/inference/hybridengine/modeling/llama.py:99-124 | colossalai/legacy/inference/tensor_parallel/modeling/llama.py:82-108 — before extracting anything, compare `colossalai/legacy/inference/hybridengine/modeling/llama.py` and `colossalai/legacy/inference/tensor_parallel/modeling/llama.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 250 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (26–27 lines × 2) colossalai/shardformer/modeling/_llama_tf4.py:236 — colossalai/shardformer/modeling/_llama_tf4.py:236-261 | colossalai/shardformer/modeling/_llama_tf5.py:277-303 — before extracting anything, compare `colossalai/shardformer/modeling/_llama_tf4.py` and `colossalai/shardformer/modeling/_llama_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_llama_tf5.py:277` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (22 lines × 3) · ×2
  • Duplicated block (22 lines × 3) colossalai/legacy/nn/layer/parallel_2d/layers.py:480 — colossalai/legacy/nn/layer/parallel_2d/layers.py:480-501 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:493-514 | colossalai/legacy/nn/layer/parallel_3d/layers.py:773-794 — `colossalai/legacy/nn/layer/parallel_2d/layers.py` and `colossalai/legacy/nn/layer/parallel_2p5d/layers.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 18 separate duplicated blocks between them, totalling at least 219 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (22 lines × 3) applications/ColossalChat/examples/training_scripts/train_dpo.py:149 — applications/ColossalChat/examples/training_scripts/train_dpo.py:149-170 | applications/ColossalChat/examples/training_scripts/train_kto.py:149-170 | applications/ColossalChat/examples/training_scripts/train_orpo.py:138-159 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_dpo.py` and `applications/ColossalChat/examples/training_scripts/train_kto.py` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 289 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (21–22 lines × 3) · ×2
  • Duplicated block (21–22 lines × 3) colossalai/pipeline/schedule/interleaved_pp.py:615 — colossalai/pipeline/schedule/interleaved_pp.py:615-636 | colossalai/pipeline/schedule/one_f_one_b.py:460-480 | colossalai/pipeline/schedule/zero_bubble_pp.py:949-970 — before extracting anything, compare `colossalai/pipeline/schedule/interleaved_pp.py` and `colossalai/pipeline/schedule/zero_bubble_pp.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 82 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (21–22 lines × 3) colossalai/shardformer/layer/linear.py:96 — colossalai/shardformer/layer/linear.py:96-116 | colossalai/shardformer/layer/qkv_fused_linear.py:692-713 | colossalai/shardformer/layer/qkv_fused_linear.py:1267-1288 — before extracting anything, compare `colossalai/shardformer/layer/linear.py` and `colossalai/shardformer/layer/qkv_fused_linear.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 261 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (21–22 lines × 2) · ×2
  • Duplicated block (21–22 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/strategy/binary_elementwise_generator.py:69 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/binary_elementwise_generator.py:69-90 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/getattr_generator.py:49-69 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/tensor_shard/node_handler/strategy/binary_elementwise_generator.py:69` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (21–22 lines × 2) examples/community/roberta/pretraining/arguments.py:7 — examples/community/roberta/pretraining/arguments.py:7-28 | examples/language/gpt/gemini/train_gpt_demo.py:27-47 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `examples/community/roberta/pretraining/arguments.py:7` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (21 lines × 4) · ×2
  • Duplicated block (21 lines × 4) colossalai/shardformer/policies/_qwen2_tf4.py:79 — colossalai/shardformer/policies/_qwen2_tf4.py:79-99 | colossalai/shardformer/policies/_qwen2_tf5.py:79-99 | colossalai/shardformer/policies/_qwen3_tf4.py:79-99 | colossalai/shardformer/policies/_qwen3_tf5.py:80-100 — before extracting anything, compare `colossalai/shardformer/policies/_qwen2_tf4.py` and `colossalai/shardformer/policies/_qwen2_tf5.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 399 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/policies/_qwen2_tf4.py:79` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (21 lines × 4) applications/ColossalChat/examples/training_scripts/train_dpo.py:281 — applications/ColossalChat/examples/training_scripts/train_dpo.py:281-301 | applications/ColossalChat/examples/training_scripts/train_kto.py:302-322 | applications/ColossalChat/examples/training_scripts/train_orpo.py:264-284 | applications/ColossalChat/examples/training_scripts/train_rm.py:275-295 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_dpo.py` and `applications/ColossalChat/examples/training_scripts/train_kto.py` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 289 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/examples/training_scripts/train_dpo.py:281` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (20 lines × 5) · ×2
  • Duplicated block (20 lines × 5) colossalai/shardformer/modeling/_bert_tf4.py:964 — colossalai/shardformer/modeling/_bert_tf4.py:964-983 | colossalai/shardformer/modeling/_bert_tf5.py:977-996 | colossalai/shardformer/modeling/bloom.py:674-693 | colossalai/shardformer/modeling/falcon.py:690-709 | colossalai/shardformer/modeling/opt.py:490-509 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_bert_tf4.py:964` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 5) applications/ColossalChat/examples/training_scripts/train_grpo.py:181 — applications/ColossalChat/examples/training_scripts/train_grpo.py:181-200 | applications/ColossalChat/examples/training_scripts/train_kto.py:57-76 | applications/ColossalChat/examples/training_scripts/train_orpo.py:57-76 | REDACTED:219-238 | applications/ColossalChat/examples/training_scripts/train_sft.py:79-98 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_grpo.py` and `applications/ColossalChat/examples/training_scripts/train_kto.py` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 162 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/examples/training_scripts/train_grpo.py:181` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (20 lines × 4) · ×2
  • Duplicated block (20 lines × 4) colossalai/shardformer/policies/_bert_tf4.py:56 — colossalai/shardformer/policies/_bert_tf4.py:56-75 | colossalai/shardformer/policies/_bert_tf5.py:55-74 | colossalai/shardformer/policies/bloom.py:39-58 | colossalai/shardformer/policies/gpt2.py:41-60 — before extracting anything, compare `colossalai/shardformer/policies/_bert_tf4.py` and `colossalai/shardformer/policies/_bert_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 475 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (20 lines × 4) colossalai/shardformer/policies/_qwen2_tf4.py:57 — colossalai/shardformer/policies/_qwen2_tf4.py:57-76 | colossalai/shardformer/policies/_qwen2_tf5.py:57-76 | colossalai/shardformer/policies/_qwen3_tf4.py:57-76 | colossalai/shardformer/policies/_qwen3_tf5.py:58-77 — before extracting anything, compare `colossalai/shardformer/policies/_qwen2_tf4.py` and `colossalai/shardformer/policies/_qwen2_tf5.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 399 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (18–20 lines × 2) · ×2
  • Duplicated block (18–20 lines × 2) colossalai/shardformer/_utils.py:188 — colossalai/shardformer/_utils.py:188-207 | colossalai/shardformer/_utils.py:215-232 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (18–20 lines × 2) colossalai/shardformer/modeling/_whisper_tf4.py:233 — colossalai/shardformer/modeling/_whisper_tf4.py:233-250 | colossalai/shardformer/modeling/opt.py:691-710 — before extracting anything, compare `colossalai/shardformer/modeling/_whisper_tf4.py` and `colossalai/shardformer/modeling/opt.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 105 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_whisper_tf4.py:233` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (17–19 lines × 3) · ×2
  • Duplicated block (17–19 lines × 3) colossalai/nn/optimizer/cpu_adam.py:160 — colossalai/nn/optimizer/cpu_adam.py:160-176 | colossalai/nn/optimizer/cpu_adam.py:197-215 | colossalai/nn/optimizer/hybrid_adam.py:128-144 — before extracting anything, compare `colossalai/nn/optimizer/cpu_adam.py` and `colossalai/nn/optimizer/hybrid_adam.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/nn/optimizer/cpu_adam.py:157` calls `_pre_update` and `colossalai/nn/optimizer/cpu_adam.py:195` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (17–19 lines × 3) colossalai/shardformer/modeling/_llama_tf4.py:587 — colossalai/shardformer/modeling/_llama_tf4.py:587-605 | colossalai/shardformer/modeling/_qwen2_tf4.py:580-596 | colossalai/shardformer/modeling/_qwen3_tf4.py:572-588 — before extracting anything, compare `colossalai/shardformer/modeling/_llama_tf4.py` and `colossalai/shardformer/modeling/_qwen2_tf4.py` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 241 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_llama_tf4.py:587` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (17–18 lines × 4) · ×2
  • Duplicated block (17–18 lines × 4) colossalai/shardformer/modeling/_mixtral_tf4.py:480 — colossalai/shardformer/modeling/_mixtral_tf4.py:480-496 | colossalai/shardformer/modeling/_mixtral_tf5.py:846-862 | colossalai/shardformer/modeling/deepseek.py:541-558 | colossalai/shardformer/modeling/mistral.py:244-261 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 581 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_mixtral_tf4.py:480` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17–18 lines × 4) colossalai/shardformer/modeling/gpt2.py:140 — colossalai/shardformer/modeling/gpt2.py:140-157 | colossalai/shardformer/modeling/gptj.py:103-120 | colossalai/shardformer/modeling/t5.py:301-317 | colossalai/shardformer/modeling/t5.py:441-457 — before extracting anything, compare `colossalai/shardformer/modeling/gpt2.py` and `colossalai/shardformer/modeling/gptj.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 321 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (11–17 lines × 2) · ×2
  • Duplicated block (11–17 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/embedding_handler.py:143 — colossalai/auto_parallel/tensor_shard/node_handler/embedding_handler.py:143-159 | colossalai/auto_parallel/tensor_shard/node_handler/linear_handler.py:186-196 — before extracting anything, compare `colossalai/auto_parallel/tensor_shard/node_handler/embedding_handler.py` and `colossalai/auto_parallel/tensor_shard/node_handler/linear_handler.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 68 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/tensor_shard/node_handler/embedding_handler.py:143` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11–17 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/embedding_handler.py:210 — colossalai/auto_parallel/tensor_shard/node_handler/embedding_handler.py:210-226 | colossalai/auto_parallel/tensor_shard/node_handler/linear_handler.py:260-270 — before extracting anything, compare `colossalai/auto_parallel/tensor_shard/node_handler/embedding_handler.py` and `colossalai/auto_parallel/tensor_shard/node_handler/linear_handler.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 68 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/tensor_shard/node_handler/embedding_handler.py:210` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (16 lines × 6) · ×2
  • Duplicated block (16 lines × 6) colossalai/shardformer/modeling/_bert_tf4.py:510 — colossalai/shardformer/modeling/_bert_tf4.py:510-525 | colossalai/shardformer/modeling/_bert_tf5.py:523-538 | colossalai/shardformer/modeling/gpt2.py:473-488 | colossalai/shardformer/modeling/gpt2.py:650-665 | colossalai/shardformer/modeling/gpt2.py:735-750 | colossalai/shardformer/modeling/gptj.py:398-413 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_bert_tf4.py:510` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 6) colossalai/shardformer/modeling/bloom.py:366 — colossalai/shardformer/modeling/bloom.py:366-381 | colossalai/shardformer/modeling/bloom.py:459-474 | colossalai/shardformer/modeling/bloom.py:585-600 | colossalai/shardformer/modeling/falcon.py:389-405 | colossalai/shardformer/modeling/falcon.py:488-504 | colossalai/shardformer/modeling/falcon.py:602-618 — before extracting anything, compare `colossalai/shardformer/modeling/bloom.py` and `colossalai/shardformer/modeling/falcon.py` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 594 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/bloom.py:366` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (16 lines × 4) · ×2
  • Duplicated block (16 lines × 4) colossalai/kernel/triton/context_attn_unpad.py:80 — colossalai/kernel/triton/context_attn_unpad.py:80-95 | colossalai/kernel/triton/context_attn_unpad.py:258-273 | colossalai/kernel/triton/context_attn_unpad.py:435-450 | colossalai/kernel/triton/flash_decoding.py:201-216 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/kernel/triton/context_attn_unpad.py:80` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (16 lines × 4) colossalai/shardformer/modeling/_bert_tf4.py:895 — colossalai/shardformer/modeling/_bert_tf4.py:895-910 | colossalai/shardformer/modeling/_bert_tf5.py:908-923 | examples/community/roberta/pretraining/model/bert.py:1672-1687 | examples/community/roberta/pretraining/model/deberta_v2.py:1615-1630 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_bert_tf4.py:895` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/modeling/_bert_tf4.py:893` calls `is_last_stage` and `examples/community/roberta/pretraining/model/bert.py:1668` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (15–16 lines × 3) · ×2
  • Duplicated block (15–16 lines × 3) colossalai/shardformer/modeling/_bert_tf4.py:635 — colossalai/shardformer/modeling/_bert_tf4.py:635-649 | colossalai/shardformer/modeling/_bert_tf5.py:648-662 | examples/community/roberta/pretraining/model/bert.py:1473-1488 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_bert_tf4.py:635` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/modeling/_bert_tf4.py:634` calls `is_last_stage` and `examples/community/roberta/pretraining/model/bert.py:1471` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (15–16 lines × 3) applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py:71 — applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py:71-86 | examples/images/vit/args.py:6-20 | examples/language/opt/args.py:6-20 — before extracting anything, compare `applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py` and `examples/images/vit/args.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 59 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py:71` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (15 lines × 12) · ×2
  • Duplicated block (15 lines × 12) colossalai/shardformer/modeling/_bert_tf4.py:619 — colossalai/shardformer/modeling/_bert_tf4.py:619-634 | colossalai/shardformer/modeling/_bert_tf4.py:695-710 | colossalai/shardformer/modeling/_bert_tf4.py:787-802 | colossalai/shardformer/modeling/_bert_tf4.py:879-893 | colossalai/shardformer/modeling/_bert_tf4.py:961-975 | colossalai/shardformer/modeling/_bert_tf5.py:632-647 | colossalai/shardformer/modeling/_bert_tf5.py:708-723 | colossalai/shardformer/modeling/_bert_tf5.py:800-815 | colossalai/shardformer/modeling/_bert_tf5.py:892-906 | colossalai/shardformer/modeling/_bert_tf5.py:974-988 | colossalai/shardformer/modeling/opt.py:387-402 | colossalai/shardformer/modeling/opt.py:487-501 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_bert_tf4.py:619` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 12) colossalai/shardformer/modeling/_bert_tf4.py:718 — colossalai/shardformer/modeling/_bert_tf4.py:718-732 | colossalai/shardformer/modeling/_bert_tf5.py:731-745 | colossalai/shardformer/modeling/_llama_tf4.py:456-470 | colossalai/shardformer/modeling/_llama_tf5.py:498-512 | colossalai/shardformer/modeling/_qwen2_tf4.py:446-460 | colossalai/shardformer/modeling/bloom.py:502-516 | colossalai/shardformer/modeling/falcon.py:531-545 | colossalai/shardformer/modeling/gpt2.py:778-792 | colossalai/shardformer/modeling/gptj.py:442-456 | colossalai/shardformer/modeling/mistral.py:342-356 | colossalai/shardformer/modeling/opt.py:424-438 | examples/community/roberta/pretraining/model/bert.py:1566-1580 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/modeling/_llama_tf4.py:455` calls `to` and `colossalai/shardformer/modeling/_bert_tf4.py:717` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (15 lines × 5) · ×2
  • Duplicated block (15 lines × 5) colossalai/initialize.py:136 — colossalai/initialize.py:136-150 | colossalai/initialize.py:169-183 | colossalai/legacy/initialize.py:147-161 | colossalai/legacy/initialize.py:187-201 | colossalai/legacy/initialize.py:223-237 — before extracting anything, compare `colossalai/initialize.py` and `colossalai/legacy/initialize.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 107 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/initialize.py:136` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 5) colossalai/legacy/moe/openmoe/model/openmoe_policy.py:472 — colossalai/legacy/moe/openmoe/model/openmoe_policy.py:472-487 | colossalai/shardformer/modeling/_bert_tf4.py:512-527 | colossalai/shardformer/modeling/_bert_tf5.py:525-540 | colossalai/shardformer/modeling/opt.py:317-331 | colossalai/shardformer/modeling/t5.py:635-649 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/moe/openmoe/model/openmoe_policy.py:472` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (14–15 lines × 3) · ×2
  • Duplicated block (14–15 lines × 3) colossalai/shardformer/modeling/_qwen2_tf4.py:246 — colossalai/shardformer/modeling/_qwen2_tf4.py:246-259 | colossalai/shardformer/modeling/_qwen3_tf4.py:244-257 | colossalai/shardformer/modeling/deepseek.py:457-471 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf4.py` and `colossalai/shardformer/modeling/_qwen3_tf4.py` as WHOLE FILES: this scan already matched 52 separate duplicated blocks between them, totalling at least 1214 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/deepseek.py:457` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/modeling/_qwen2_tf4.py:242` calls `is_share_sp_tp`, `gather_sp_output` and `colossalai/shardformer/modeling/deepseek.py:454` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14–15 lines × 3) colossalai/shardformer/modeling/_qwen2_tf4.py:746 — colossalai/shardformer/modeling/_qwen2_tf4.py:746-760 | colossalai/shardformer/modeling/_qwen3_tf4.py:738-752 | colossalai/shardformer/modeling/opt.py:748-761 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf4.py` and `colossalai/shardformer/modeling/_qwen3_tf4.py` as WHOLE FILES: this scan already matched 52 separate duplicated blocks between them, totalling at least 1214 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (12–15 lines × 2) · ×2
  • Duplicated block (12–15 lines × 2) colossalai/auto_parallel/meta_profiler/meta_registry/norm.py:75 — colossalai/auto_parallel/meta_profiler/meta_registry/norm.py:75-89 | colossalai/auto_parallel/meta_profiler/meta_registry/norm.py:136-147 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/meta_profiler/meta_registry/norm.py:75` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12–15 lines × 2) colossalai/legacy/inference/dynamic_batching/ray_dist_init.py:109 — colossalai/legacy/inference/dynamic_batching/ray_dist_init.py:109-123 | colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py:112-123 — before extracting anything, compare `colossalai/legacy/inference/dynamic_batching/ray_dist_init.py` and `colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 42 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/inference/dynamic_batching/ray_dist_init.py:109` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (14 lines × 16) · ×2
  • Duplicated block (14 lines × 16) colossalai/shardformer/modeling/_bert_tf4.py:513 — colossalai/shardformer/modeling/_bert_tf4.py:513-527 | colossalai/shardformer/modeling/_bert_tf4.py:619-634 | colossalai/shardformer/modeling/_bert_tf4.py:695-710 | colossalai/shardformer/modeling/_bert_tf4.py:787-802 | colossalai/shardformer/modeling/_bert_tf4.py:879-893 | colossalai/shardformer/modeling/_bert_tf4.py:961-975 | colossalai/shardformer/modeling/_bert_tf5.py:526-540 | colossalai/shardformer/modeling/_bert_tf5.py:632-647 | colossalai/shardformer/modeling/_bert_tf5.py:708-723 | colossalai/shardformer/modeling/_bert_tf5.py:800-815 | colossalai/shardformer/modeling/_bert_tf5.py:892-906 | colossalai/shardformer/modeling/_bert_tf5.py:974-988 | colossalai/shardformer/modeling/opt.py:318-331 | colossalai/shardformer/modeling/opt.py:387-402 | colossalai/shardformer/modeling/opt.py:487-501 | colossalai/shardformer/modeling/t5.py:636-649 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_bert_tf4.py:513` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 16) colossalai/shardformer/modeling/_bert_tf4.py:514 — colossalai/shardformer/modeling/_bert_tf4.py:514-528 | colossalai/shardformer/modeling/_bert_tf4.py:621-635 | colossalai/shardformer/modeling/_bert_tf4.py:697-711 | colossalai/shardformer/modeling/_bert_tf4.py:789-803 | colossalai/shardformer/modeling/_bert_tf4.py:881-894 | colossalai/shardformer/modeling/_bert_tf4.py:963-976 | colossalai/shardformer/modeling/_bert_tf5.py:527-541 | colossalai/shardformer/modeling/_bert_tf5.py:634-648 | colossalai/shardformer/modeling/_bert_tf5.py:710-724 | colossalai/shardformer/modeling/_bert_tf5.py:802-816 | colossalai/shardformer/modeling/_bert_tf5.py:894-907 | colossalai/shardformer/modeling/_bert_tf5.py:976-989 | colossalai/shardformer/modeling/bloom.py:672-687 | colossalai/shardformer/modeling/opt.py:389-403 | colossalai/shardformer/modeling/opt.py:489-502 | colossalai/shardformer/modeling/t5.py:637-650 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_bert_tf4.py:514` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/shardformer/modeling/_bert_tf4.py:897` calls `view` and `colossalai/shardformer/modeling/_bert_tf4.py:716` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (13–14 lines × 9) · ×2
  • Duplicated block (13–14 lines × 9) colossalai/legacy/inference/hybridengine/modeling/llama.py:217 — colossalai/legacy/inference/hybridengine/modeling/llama.py:217-229 | colossalai/legacy/moe/openmoe/model/openmoe_policy.py:263-275 | colossalai/shardformer/modeling/_mixtral_tf4.py:242-254 | colossalai/shardformer/modeling/_mixtral_tf5.py:586-598 | colossalai/shardformer/modeling/_qwen2_tf4.py:72-85 | colossalai/shardformer/modeling/_qwen2_tf5.py:71-84 | colossalai/shardformer/modeling/_qwen3_tf4.py:72-85 | colossalai/shardformer/modeling/_qwen3_tf5.py:72-85 | colossalai/shardformer/modeling/deepseek.py:339-351 — before extracting anything, compare `colossalai/legacy/moe/openmoe/model/openmoe_policy.py` and `colossalai/shardformer/modeling/_mixtral_tf4.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 130 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (13–14 lines × 9) colossalai/shardformer/modeling/_llama_tf4.py:477 — colossalai/shardformer/modeling/_llama_tf4.py:477-490 | colossalai/shardformer/modeling/_llama_tf5.py:519-532 | colossalai/shardformer/modeling/_qwen2_tf4.py:467-480 | colossalai/shardformer/modeling/_qwen2_tf5.py:365-378 | colossalai/shardformer/modeling/_qwen3_tf4.py:453-466 | colossalai/shardformer/modeling/_qwen3_tf5.py:366-379 | colossalai/shardformer/modeling/bloom.py:523-535 | colossalai/shardformer/modeling/falcon.py:552-564 | colossalai/shardformer/modeling/opt.py:446-458 — before extracting anything, compare `colossalai/shardformer/modeling/_llama_tf4.py` and `colossalai/shardformer/modeling/_llama_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (13–14 lines × 4) · ×2
  • Duplicated block (13–14 lines × 4) applications/ColossalChat/coati/trainer/dpo.py:244 — applications/ColossalChat/coati/trainer/dpo.py:244-257 | applications/ColossalChat/coati/trainer/dpo.py:364-377 | applications/ColossalChat/coati/trainer/kto.py:229-241 | applications/ColossalChat/coati/trainer/orpo.py:194-206 — before extracting anything, compare `applications/ColossalChat/coati/trainer/dpo.py` and `applications/ColossalChat/coati/trainer/kto.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 60 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (13–14 lines × 4) colossalai/legacy/inference/hybridengine/modeling/llama.py:439 — colossalai/legacy/inference/hybridengine/modeling/llama.py:439-451 | colossalai/legacy/inference/quant/smoothquant/models/llama.py:187-200 | colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:490-503 | colossalai/legacy/inference/tensor_parallel/modeling/llama.py:359-371 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/inference/hybridengine/modeling/llama.py:439` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (13–14 lines × 3) · ×2
  • Duplicated block (13–14 lines × 3) colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:466 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:466-478 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:485-497 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py:209-222 — before extracting anything, compare `colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py` and `colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 143 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:466` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13–14 lines × 3) colossalai/shardformer/modeling/_llama_tf4.py:110 — colossalai/shardformer/modeling/_llama_tf4.py:110-122 | colossalai/shardformer/modeling/_llama_tf5.py:152-164 | colossalai/shardformer/modeling/command.py:102-115 — before extracting anything, compare `colossalai/shardformer/modeling/_llama_tf4.py` and `colossalai/shardformer/modeling/_llama_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/shardformer/modeling/_llama_tf4.py:124` calls `warning_once` and `colossalai/shardformer/modeling/_llama_tf5.py:168` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (12–14 lines × 3) · ×2
  • Duplicated block (12–14 lines × 3) colossalai/legacy/inference/hybridengine/modeling/llama.py:243 — colossalai/legacy/inference/hybridengine/modeling/llama.py:243-256 | colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:132-143 | colossalai/legacy/inference/tensor_parallel/modeling/llama.py:152-165 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
  • Duplicated block (12–14 lines × 3) colossalai/legacy/inference/quant/smoothquant/models/llama.py:574 — colossalai/legacy/inference/quant/smoothquant/models/llama.py:574-587 | colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:99-110 | colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:720-733 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/inference/quant/smoothquant/models/llama.py:574` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (12–13 lines × 7) · ×2
  • Duplicated block (12–13 lines × 7) colossalai/legacy/moe/openmoe/model/openmoe_policy.py:259 — colossalai/legacy/moe/openmoe/model/openmoe_policy.py:259-270 | colossalai/shardformer/modeling/_mixtral_tf4.py:237-249 | colossalai/shardformer/modeling/_mixtral_tf5.py:581-593 | colossalai/shardformer/modeling/_qwen2_tf4.py:68-79 | colossalai/shardformer/modeling/_qwen3_tf4.py:68-79 | colossalai/shardformer/modeling/deepseek.py:334-346 | colossalai/shardformer/modeling/falcon.py:222-233 — before extracting anything, compare `colossalai/legacy/moe/openmoe/model/openmoe_policy.py` and `colossalai/shardformer/modeling/_mixtral_tf4.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 130 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (12–13 lines × 7) colossalai/shardformer/layer/linear.py:96 — colossalai/shardformer/layer/linear.py:96-107 | colossalai/shardformer/layer/linear.py:251-262 | colossalai/shardformer/layer/linear.py:446-458 | colossalai/shardformer/layer/qkv_fused_linear.py:692-704 | colossalai/shardformer/layer/qkv_fused_linear.py:862-874 | colossalai/shardformer/layer/qkv_fused_linear.py:1070-1082 | colossalai/shardformer/layer/qkv_fused_linear.py:1267-1279 — before extracting anything, compare `colossalai/shardformer/layer/linear.py` and `colossalai/shardformer/layer/qkv_fused_linear.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 261 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/shardformer/layer/linear.py:264` calls `is_distributed_tensor`, `shard_rowwise`, `sharded_tensor_to_existing_param` and `colossalai/shardformer/layer/linear.py:109` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (13 lines × 5) · ×2
  • Duplicated block (13 lines × 5) applications/ColossalChat/coati/trainer/grpo.py:179 — applications/ColossalChat/coati/trainer/grpo.py:179-191 | applications/ColossalChat/coati/trainer/kto.py:103-115 | applications/ColossalChat/coati/trainer/orpo.py:93-105 | applications/ColossalChat/coati/trainer/ppo.py:170-182 | applications/ColossalChat/coati/trainer/rm.py:91-103 — before extracting anything, compare `applications/ColossalChat/coati/trainer/grpo.py` and `applications/ColossalChat/coati/trainer/ppo.py` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 176 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (13 lines × 5) colossalai/auto_parallel/tensor_shard/node_handler/strategy/getitem_generator.py:32 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/getitem_generator.py:32-44 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:36-48 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/softmax_generator.py:36-48 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/sum_generator.py:33-45 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/unary_elementwise_generator.py:24-36 — before extracting anything, compare `colossalai/auto_parallel/tensor_shard/node_handler/strategy/getitem_generator.py` and `colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 44 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (11–13 lines × 3) · ×2
  • Duplicated block (11–13 lines × 3) colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:203 — colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:203-213 | colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py:1116-1126 | colossalai/shardformer/modeling/gptj.py:339-351 — before extracting anything, compare `colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py` and `colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 176 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:203` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (11–13 lines × 3) REDACTED:186 — REDACTED:186-196 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:202-214 | REDACTED:207-217 — before extracting anything, compare `REDACTED` and `examples/images/dreambooth/train_dreambooth_colossalai_lora.py` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 425 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:186` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (12–13 lines × 3) · ×2
  • Duplicated block (12–13 lines × 3) colossalai/shardformer/modeling/_mixtral_tf4.py:129 — colossalai/shardformer/modeling/_mixtral_tf4.py:129-141 | colossalai/shardformer/modeling/_mixtral_tf5.py:477-489 | colossalai/shardformer/modeling/deepseek.py:163-174 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 581 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (12–13 lines × 3) colossalai/shardformer/modeling/_mixtral_tf4.py:155 — colossalai/shardformer/modeling/_mixtral_tf4.py:155-167 | colossalai/shardformer/modeling/_mixtral_tf5.py:500-512 | colossalai/shardformer/modeling/deepseek.py:185-196 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 581 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (10–13 lines × 2) · ×2
  • Duplicated block (10–13 lines × 2) colossalai/legacy/inference/quant/smoothquant/models/base_model.py:347 — colossalai/legacy/inference/quant/smoothquant/models/base_model.py:347-356 | colossalai/legacy/inference/quant/smoothquant/models/base_model.py:461-473 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/inference/quant/smoothquant/models/base_model.py:461` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (10–13 lines × 2) examples/community/roberta/preprocessing/tokenize_mask.py:64 — examples/community/roberta/preprocessing/tokenize_mask.py:64-76 | examples/community/roberta/preprocessing/tokenize_mask.py:131-140 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (11–12 lines × 5) · ×2
  • Duplicated block (11–12 lines × 5) colossalai/shardformer/modeling/_mixtral_tf4.py:693 — colossalai/shardformer/modeling/_mixtral_tf4.py:693-704 | colossalai/shardformer/modeling/_mixtral_tf5.py:1087-1098 | colossalai/shardformer/modeling/_qwen2_tf4.py:626-637 | colossalai/shardformer/modeling/_qwen3_tf4.py:618-629 | colossalai/shardformer/modeling/deepseek.py:723-733 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 581 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (11–12 lines × 5) applications/ColossalChat/examples/training_scripts/train_dpo.py:246 — applications/ColossalChat/examples/training_scripts/train_dpo.py:246-256 | applications/ColossalChat/examples/training_scripts/train_kto.py:267-277 | applications/ColossalChat/examples/training_scripts/train_orpo.py:232-242 | applications/ColossalChat/examples/training_scripts/train_rm.py:244-254 | applications/ColossalChat/examples/training_scripts/train_sft.py:250-261 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_dpo.py` and `applications/ColossalChat/examples/training_scripts/train_kto.py` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 289 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/examples/training_scripts/train_dpo.py:246` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `applications/ColossalChat/examples/training_scripts/train_dpo.py:245` calls `isinstance`, `set_start_index` and `applications/ColossalChat/examples/training_scripts/train_sft.py:250` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (10–12 lines × 4) · ×2
  • Duplicated block (10–12 lines × 4) colossalai/legacy/inference/quant/smoothquant/models/llama.py:572 — colossalai/legacy/inference/quant/smoothquant/models/llama.py:572-583 | colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:97-106 | colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:718-729 | colossalai/shardformer/modeling/_deepseek_v3_tf4.py:162-172 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (10–12 lines × 4) colossalai/shardformer/modeling/_whisper_tf4.py:178 — colossalai/shardformer/modeling/_whisper_tf4.py:178-188 | colossalai/shardformer/modeling/gptj.py:664-673 | colossalai/shardformer/modeling/gptj.py:840-849 | colossalai/shardformer/modeling/opt.py:629-640 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/shardformer/modeling/gptj.py:674` calls `warn_if_padding_and_no_attention_mask` and `colossalai/shardformer/modeling/_whisper_tf4.py:189` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (10–12 lines × 3) · ×2
  • Duplicated block (10–12 lines × 3) colossalai/fx/profiler/experimental/profiler_module/convolution.py:106 — colossalai/fx/profiler/experimental/profiler_module/convolution.py:106-117 | colossalai/fx/profiler/experimental/profiler_module/convolution.py:142-151 | colossalai/fx/profiler/experimental/profiler_module/convolution.py:184-193 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/fx/profiler/experimental/profiler_module/convolution.py:106` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note first that the copies are not typed on the same thing: the declarations holding them bind `self` to `torch.nn.ConvTranspose1d` in one and `torch.nn.ConvTranspose2d` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (10–12 lines × 3) colossalai/shardformer/policies/gpt2.py:565 — colossalai/shardformer/policies/gpt2.py:565-576 | colossalai/shardformer/policies/gptj.py:479-488 | colossalai/shardformer/policies/opt.py:495-504 — before extracting anything, compare `colossalai/shardformer/policies/gpt2.py` and `colossalai/shardformer/policies/gptj.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 65 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (10–12 lines × 2) · ×2
  • Duplicated block (10–12 lines × 2) colossalai/fx/tracer/meta_patch/patched_module/pooling.py:116 — colossalai/fx/tracer/meta_patch/patched_module/pooling.py:116-127 | colossalai/fx/tracer/meta_patch/patched_module/pooling.py:146-155 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/fx/tracer/meta_patch/patched_module/pooling.py:159` calls `floor` and `colossalai/fx/tracer/meta_patch/patched_module/pooling.py:132` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10–12 lines × 2) examples/language/bert/benchmark.py:62 — examples/language/bert/benchmark.py:62-73 | examples/tutorial/new_api/glue_bert/finetune.py:112-121 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `examples/language/bert/benchmark.py:62` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (11 lines × 11) · ×2
  • Duplicated block (11 lines × 11) colossalai/shardformer/modeling/_bert_tf4.py:727 — colossalai/shardformer/modeling/_bert_tf4.py:727-737 | colossalai/shardformer/modeling/_bert_tf5.py:740-750 | colossalai/shardformer/modeling/_llama_tf4.py:465-475 | colossalai/shardformer/modeling/_llama_tf5.py:507-517 | colossalai/shardformer/modeling/_qwen2_tf4.py:455-465 | colossalai/shardformer/modeling/gpt2.py:787-797 | colossalai/shardformer/modeling/gptj.py:451-461 | colossalai/shardformer/modeling/mistral.py:351-361 | colossalai/shardformer/modeling/opt.py:433-443 | examples/community/roberta/pretraining/model/bert.py:1575-1585 | examples/community/roberta/pretraining/model/deberta_v2.py:1335-1345 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (11 lines × 11) colossalai/shardformer/modeling/_llama_tf4.py:476 — colossalai/shardformer/modeling/_llama_tf4.py:476-486 | colossalai/shardformer/modeling/_llama_tf5.py:518-528 | colossalai/shardformer/modeling/_qwen2_tf4.py:466-476 | colossalai/shardformer/modeling/_qwen2_tf5.py:364-374 | colossalai/shardformer/modeling/_qwen3_tf4.py:452-462 | colossalai/shardformer/modeling/_qwen3_tf5.py:365-375 | colossalai/shardformer/modeling/bloom.py:522-532 | colossalai/shardformer/modeling/falcon.py:551-561 | colossalai/shardformer/modeling/gpt2.py:798-808 | colossalai/shardformer/modeling/gptj.py:462-472 | colossalai/shardformer/modeling/opt.py:445-455 — before extracting anything, compare `colossalai/shardformer/modeling/_llama_tf4.py` and `colossalai/shardformer/modeling/_llama_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (11 lines × 5) · ×2
  • Duplicated block (11 lines × 5) applications/Colossal-LLaMA/colossal_llama/utils/utils.py:26 — applications/Colossal-LLaMA/colossal_llama/utils/utils.py:26-36 | examples/language/deepseek/model_utils.py:22-32 | examples/language/llama/model_utils.py:22-32 | examples/language/mixtral/model_utils.py:22-32 | examples/language/model_utils.py:22-32 — `examples/language/deepseek/model_utils.py` and `examples/language/llama/model_utils.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 1 separate duplicated blocks between them, totalling at least 11 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (11 lines × 5) colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:84 — colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:84-94 | colossalai/shardformer/modeling/bloom.py:127-137 | colossalai/shardformer/modeling/bloom.py:344-354 | colossalai/shardformer/modeling/bloom.py:436-446 | colossalai/shardformer/modeling/bloom.py:562-572 — there are 5 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart.
D4 · Code Duplication · Duplicated block (9–11 lines × 2) · ×2
  • Duplicated block (9–11 lines × 2) colossalai/booster/plugin/torch_fsdp_plugin.py:129 — colossalai/booster/plugin/torch_fsdp_plugin.py:129-137 | colossalai/booster/plugin/torch_fsdp_plugin.py:291-301 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/booster/plugin/torch_fsdp_plugin.py:291` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9–11 lines × 2) colossalai/legacy/nn/layer/parallel_1d/layers.py:725 — colossalai/legacy/nn/layer/parallel_1d/layers.py:725-733 | colossalai/shardformer/layer/linear.py:559-569 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_1d/layers.py:725` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (10 lines × 7) · ×2
  • Duplicated block (10 lines × 7) colossalai/legacy/moe/openmoe/model/openmoe_policy.py:269 — colossalai/legacy/moe/openmoe/model/openmoe_policy.py:269-278 | colossalai/shardformer/modeling/_mixtral_tf4.py:248-257 | colossalai/shardformer/modeling/_mixtral_tf5.py:592-601 | colossalai/shardformer/modeling/_qwen2_tf4.py:78-88 | colossalai/shardformer/modeling/_qwen3_tf4.py:78-88 | colossalai/shardformer/modeling/command.py:80-89 | colossalai/shardformer/modeling/deepseek.py:345-354 — before extracting anything, compare `colossalai/legacy/moe/openmoe/model/openmoe_policy.py` and `colossalai/shardformer/modeling/_mixtral_tf4.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 130 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/moe/openmoe/model/openmoe_policy.py:269` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 7) applications/ColossalChat/examples/training_scripts/train_dpo.py:250 — applications/ColossalChat/examples/training_scripts/train_dpo.py:250-259 | applications/ColossalChat/examples/training_scripts/train_grpo.py:351-360 | applications/ColossalChat/examples/training_scripts/train_kto.py:271-280 | applications/ColossalChat/examples/training_scripts/train_orpo.py:236-245 | REDACTED:403-412 | applications/ColossalChat/examples/training_scripts/train_rm.py:248-257 | applications/ColossalChat/examples/training_scripts/train_sft.py:255-264 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_dpo.py` and `applications/ColossalChat/examples/training_scripts/train_grpo.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 88 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/examples/training_scripts/train_dpo.py:250` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (8–10 lines × 4) · ×2
  • Duplicated block (8–10 lines × 4) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:163 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:163-170 | colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:177-184 | colossalai/zero/gemini/gemini_ddp.py:947-956 | colossalai/zero/gemini/gemini_ddp.py:965-972 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (8–10 lines × 4) colossalai/shardformer/modeling/_llama_tf4.py:598 — colossalai/shardformer/modeling/_llama_tf4.py:598-607 | colossalai/shardformer/modeling/_qwen2_tf4.py:591-599 | colossalai/shardformer/modeling/_qwen3_tf4.py:583-591 | colossalai/shardformer/modeling/command.py:412-419 — before extracting anything, compare `colossalai/shardformer/modeling/_llama_tf4.py` and `colossalai/shardformer/modeling/_qwen2_tf4.py` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 241 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_llama_tf4.py:598` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (9–10 lines × 3) · ×2
  • Duplicated block (9–10 lines × 3) colossalai/nn/optimizer/distributed_adafactor.py:253 — colossalai/nn/optimizer/distributed_adafactor.py:253-261 | colossalai/nn/optimizer/distributed_came.py:247-256 | colossalai/nn/optimizer/distributed_came.py:300-309 — before extracting anything, compare `colossalai/nn/optimizer/distributed_adafactor.py` and `colossalai/nn/optimizer/distributed_came.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 201 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (9–10 lines × 3) applications/ColossalChat/examples/training_scripts/train_grpo.py:102 — applications/ColossalChat/examples/training_scripts/train_grpo.py:102-110 | applications/ColossalChat/examples/training_scripts/train_kto.py:136-145 | applications/ColossalChat/examples/training_scripts/train_orpo.py:125-134 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_grpo.py` and `applications/ColossalChat/examples/training_scripts/train_kto.py` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 162 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `applications/ColossalChat/examples/training_scripts/train_kto.py:135` calls `disable_dropout` and `applications/ColossalChat/examples/training_scripts/train_orpo.py:124` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (7–8 lines × 6) · ×2
  • Duplicated block (7–8 lines × 6) colossalai/legacy/nn/layer/parallel_2d/_operation.py:257 — colossalai/legacy/nn/layer/parallel_2d/_operation.py:257-263 | colossalai/legacy/nn/layer/parallel_2d/_operation.py:406-413 | colossalai/legacy/nn/layer/parallel_2d/_operation.py:563-569 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:212-218 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:369-376 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:534-540 — `colossalai/legacy/nn/layer/parallel_2d/_operation.py` and `colossalai/legacy/nn/layer/parallel_2p5d/_operation.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 185 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2d/_operation.py:257` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (7–8 lines × 6) colossalai/shardformer/modeling/_qwen2_tf4.py:624 — colossalai/shardformer/modeling/_qwen2_tf4.py:624-631 | colossalai/shardformer/modeling/_qwen3_tf4.py:616-623 | colossalai/shardformer/modeling/deepseek.py:721-728 | colossalai/shardformer/modeling/gptj.py:663-669 | colossalai/shardformer/modeling/gptj.py:839-845 | colossalai/shardformer/modeling/opt.py:628-635 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf4.py` and `colossalai/shardformer/modeling/_qwen3_tf4.py` as WHOLE FILES: this scan already matched 52 separate duplicated blocks between them, totalling at least 1214 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_qwen2_tf4.py:624` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (8 lines × 5) · ×2
  • Duplicated block (8 lines × 5) colossalai/shardformer/policies/bloom.py:575 — colossalai/shardformer/policies/bloom.py:575-582 | colossalai/shardformer/policies/falcon.py:550-557 | colossalai/shardformer/policies/gpt2.py:564-571 | colossalai/shardformer/policies/gptj.py:478-485 | colossalai/shardformer/policies/opt.py:494-501 — before extracting anything, compare `colossalai/shardformer/policies/bloom.py` and `colossalai/shardformer/policies/falcon.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 132 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (8 lines × 5) examples/language/deepseek/performance_evaluator.py:171 — examples/language/deepseek/performance_evaluator.py:171-178 | examples/language/gpt/gemini/commons/performance_evaluator.py:171-178 | examples/language/llama/performance_evaluator.py:171-178 | examples/language/mixtral/performance_evaluator.py:171-178 | examples/language/performance_evaluator.py:171-178 — before extracting anything, compare `examples/language/deepseek/performance_evaluator.py` and `examples/language/gpt/gemini/commons/performance_evaluator.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 96 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (5–8 lines × 2) · ×2
  • Duplicated block (5–8 lines × 2) applications/ColossalChat/coati/models/lora.py:303 — applications/ColossalChat/coati/models/lora.py:303-307 | applications/ColossalChat/coati/models/lora.py:310-317 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/models/lora.py:310` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (5–8 lines × 2) colossalai/legacy/nn/layer/parallel_3d/layers.py:728 — colossalai/legacy/nn/layer/parallel_3d/layers.py:728-735 | colossalai/legacy/nn/layer/vanilla/layers.py:181-185 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_3d/layers.py:728` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. Note first that the copies are not typed on the same thing: `Parameter` names `torch.nn` in one and `torch.nn.parameter` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (7–8 lines × 2) · ×2
  • Duplicated block (7–8 lines × 2) colossalai/kernel/triton/no_pad_rotary_embedding.py:73 — colossalai/kernel/triton/no_pad_rotary_embedding.py:73-80 | colossalai/kernel/triton/no_pad_rotary_embedding.py:110-116 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/kernel/triton/no_pad_rotary_embedding.py:73` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7–8 lines × 2) colossalai/nn/optimizer/distributed_adafactor.py:371 — colossalai/nn/optimizer/distributed_adafactor.py:371-378 | colossalai/nn/optimizer/distributed_came.py:427-433 — before extracting anything, compare `colossalai/nn/optimizer/distributed_adafactor.py` and `colossalai/nn/optimizer/distributed_came.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 201 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (7 lines × 6) · ×2
  • Duplicated block (7 lines × 6) colossalai/auto_parallel/tensor_shard/node_handler/permute_handler.py:28 — colossalai/auto_parallel/tensor_shard/node_handler/permute_handler.py:28-34 | colossalai/auto_parallel/tensor_shard/node_handler/softmax_handler.py:29-35 | colossalai/auto_parallel/tensor_shard/node_handler/split_handler.py:28-34 | colossalai/auto_parallel/tensor_shard/node_handler/sum_handler.py:28-34 | colossalai/auto_parallel/tensor_shard/node_handler/transpose_handler.py:28-34 | colossalai/auto_parallel/tensor_shard/node_handler/view_handler.py:32-38 — before extracting anything, compare `colossalai/auto_parallel/tensor_shard/node_handler/permute_handler.py` and `colossalai/auto_parallel/tensor_shard/node_handler/transpose_handler.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 32 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 6) colossalai/legacy/moe/openmoe/model/openmoe_policy.py:251 — colossalai/legacy/moe/openmoe/model/openmoe_policy.py:251-257 | colossalai/shardformer/modeling/_qwen2_tf4.py:60-66 | colossalai/shardformer/modeling/_qwen2_tf5.py:59-65 | colossalai/shardformer/modeling/_qwen3_tf4.py:60-66 | colossalai/shardformer/modeling/_qwen3_tf5.py:60-66 | colossalai/shardformer/modeling/opt.py:87-93 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 6 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 6 times.
D4 · Code Duplication · Duplicated block (7 lines × 5) · ×2
  • Duplicated block (7 lines × 5) colossalai/shardformer/policies/gpt2.py:432 — colossalai/shardformer/policies/gpt2.py:432-438 | colossalai/shardformer/policies/gpt2.py:509-515 | colossalai/shardformer/policies/gptj.py:395-401 | colossalai/shardformer/policies/opt.py:415-421 | colossalai/shardformer/policies/t5.py:724-730 — before extracting anything, compare `colossalai/shardformer/policies/gpt2.py` and `colossalai/shardformer/policies/gptj.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 65 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 5) applications/Colossal-LLaMA/setup.py:5 — applications/Colossal-LLaMA/setup.py:5-16 | applications/ColossalChat/setup.py:5-16 | applications/ColossalEval/setup.py:5-11 | applications/ColossalMoE/setup.py:5-16 | applications/ColossalQA/setup.py:5-16 — `applications/Colossal-LLaMA/setup.py` and `applications/ColossalChat/setup.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 2 separate duplicated blocks between them, totalling at least 24 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `applications/ColossalQA/setup.py:19` calls `find_packages` and `applications/Colossal-LLaMA/setup.py:19` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (6–7 lines × 2) · ×2
  • Duplicated block (6–7 lines × 2) applications/ColossalEval/colossal_eval/dataset/ceval.py:94 — applications/ColossalEval/colossal_eval/dataset/ceval.py:94-100 | applications/ColossalEval/colossal_eval/dataset/mmlu.py:35-40 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (6–7 lines × 2) colossalai/shardformer/examples/convergence_benchmark.py:78 — colossalai/shardformer/examples/convergence_benchmark.py:78-83 | examples/tutorial/new_api/glue_bert/finetune.py:202-208 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/examples/convergence_benchmark.py:78` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (6 lines × 6) · ×2
  • Duplicated block (6 lines × 6) colossalai/legacy/inference/quant/smoothquant/models/llama.py:624 — colossalai/legacy/inference/quant/smoothquant/models/llama.py:624-629 | colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:744-749 | colossalai/shardformer/modeling/_mixtral_tf4.py:726-731 | colossalai/shardformer/modeling/_mixtral_tf5.py:1125-1130 | colossalai/shardformer/modeling/_qwen2_tf4.py:655-660 | colossalai/shardformer/modeling/_qwen3_tf4.py:647-652 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 6 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 6 times.
  • Duplicated block (6 lines × 6) applications/Colossal-LLaMA/colossal_llama/dataset/dummy_dataset.py:9 — applications/Colossal-LLaMA/colossal_llama/dataset/dummy_dataset.py:9-14 | colossalai/legacy/moe/openmoe/train.py:61-66 | examples/language/data_utils.py:109-114 | examples/language/deepseek/data_utils.py:109-114 | examples/language/llama/data_utils.py:109-114 | examples/language/mixtral/data_utils.py:109-114 — before extracting anything, compare `applications/Colossal-LLaMA/colossal_llama/dataset/dummy_dataset.py` and `examples/language/data_utils.py` as WHOLE FILES: 82% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (5 lines × 6) · ×2
  • Duplicated block (5 lines × 6) colossalai/fx/profiler/experimental/profiler_module/convolution.py:21 — colossalai/fx/profiler/experimental/profiler_module/convolution.py:21-25 | colossalai/fx/profiler/experimental/profiler_module/convolution.py:46-50 | colossalai/fx/profiler/experimental/profiler_module/convolution.py:75-79 | colossalai/fx/tracer/meta_patch/patched_module/convolution.py:15-19 | colossalai/fx/tracer/meta_patch/patched_module/convolution.py:34-38 | colossalai/fx/tracer/meta_patch/patched_module/convolution.py:57-61 — before extracting anything, compare `colossalai/fx/profiler/experimental/profiler_module/convolution.py` and `colossalai/fx/tracer/meta_patch/patched_module/convolution.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 83 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/fx/profiler/experimental/profiler_module/convolution.py:21` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `self` to `torch.nn.Conv1d` in one and `torch.nn.Conv2d` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (5 lines × 6) colossalai/shardformer/layer/linear.py:147 — colossalai/shardformer/layer/linear.py:147-151 | colossalai/shardformer/layer/linear.py:325-329 | colossalai/shardformer/layer/qkv_fused_linear.py:362-366 | colossalai/shardformer/layer/qkv_fused_linear.py:753-757 | colossalai/shardformer/layer/qkv_fused_linear.py:949-953 | colossalai/shardformer/layer/qkv_fused_linear.py:1330-1334 — before extracting anything, compare `colossalai/shardformer/layer/linear.py` and `colossalai/shardformer/layer/qkv_fused_linear.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 261 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (5 lines × 5) · ×2
  • Duplicated block (5 lines × 5) applications/ColossalChat/coati/trainer/dpo.py:337 — applications/ColossalChat/coati/trainer/dpo.py:337-341 | applications/ColossalChat/coati/trainer/dpo.py:612-616 | applications/ColossalChat/coati/trainer/orpo.py:177-181 | applications/ColossalChat/coati/trainer/orpo.py:313-317 | applications/ColossalChat/coati/trainer/rm.py:144-148 — before extracting anything, compare `applications/ColossalChat/coati/trainer/dpo.py` and `applications/ColossalChat/coati/trainer/orpo.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 133 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (5 lines × 5) applications/ColossalChat/examples/training_scripts/train_dpo.py:222 — applications/ColossalChat/examples/training_scripts/train_dpo.py:222-227 | applications/ColossalChat/examples/training_scripts/train_grpo.py:310-315 | applications/ColossalChat/examples/training_scripts/train_kto.py:243-248 | REDACTED:355-360 | examples/language/gpt/hybridparallelism/benchmark.py:201-205 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_dpo.py` and `applications/ColossalChat/examples/training_scripts/train_grpo.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 88 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (59 lines × 2) · ×2
  • Duplicated block (59 lines × 2) examples/images/dreambooth/train_dreambooth_colossalai.py:56 — examples/images/dreambooth/train_dreambooth_colossalai.py:56-114 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:59-117 — before extracting anything, compare `examples/images/dreambooth/train_dreambooth_colossalai.py` and `examples/images/dreambooth/train_dreambooth_colossalai_lora.py` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 757 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/images/dreambooth/train_dreambooth_colossalai.py:56` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (59 lines × 2) examples/language/bert/finetune.py:274 — examples/language/bert/finetune.py:274-332 | examples/language/gpt/hybridparallelism/finetune.py:266-324 — before extracting anything, compare `examples/language/bert/finetune.py` and `examples/language/gpt/hybridparallelism/finetune.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 242 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (33 lines × 3) · ×2
  • Duplicated block (33 lines × 3) applications/ColossalChat/examples/training_scripts/train_dpo.py:165 — applications/ColossalChat/examples/training_scripts/train_dpo.py:165-197 | applications/ColossalChat/examples/training_scripts/train_orpo.py:154-186 | applications/ColossalChat/examples/training_scripts/train_rm.py:164-196 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_dpo.py` and `applications/ColossalChat/examples/training_scripts/train_orpo.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 293 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/examples/training_scripts/train_dpo.py:165` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `applications/ColossalChat/examples/training_scripts/train_rm.py:199` calls `ceil` and `applications/ColossalChat/examples/training_scripts/train_dpo.py:200` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (33 lines × 3) examples/images/resnet/train.py:115 — examples/images/resnet/train.py:115-147 | examples/tutorial/new_api/cifar_resnet/train.py:115-147 | examples/tutorial/new_api/cifar_vit/train.py:135-167 — before extracting anything, compare `examples/images/resnet/train.py` and `examples/tutorial/new_api/cifar_resnet/train.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 158 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (26 lines × 3) · ×2
  • Duplicated block (26 lines × 3) examples/language/bert/benchmark.py:125 — examples/language/bert/benchmark.py:125-150 | examples/language/bert/finetune.py:273-298 | examples/language/gpt/hybridparallelism/finetune.py:265-290 — before extracting anything, compare `examples/language/bert/finetune.py` and `examples/language/gpt/hybridparallelism/finetune.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 242 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/language/bert/benchmark.py:125` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (26 lines × 3) examples/language/deepseek/benchmark.py:233 — examples/language/deepseek/benchmark.py:233-258 | examples/language/llama/benchmark.py:330-355 | examples/language/mixtral/benchmark.py:222-247 — `examples/language/deepseek/benchmark.py` and `examples/language/llama/benchmark.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 10 separate duplicated blocks between them, totalling at least 150 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `examples/language/deepseek/benchmark.py:233` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (25 lines × 3) · ×2
  • Duplicated block (25 lines × 3) REDACTED:292 — REDACTED:292-316 | examples/images/dreambooth/train_dreambooth_colossalai.py:319-343 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:318-342 — before extracting anything, compare `REDACTED` and `examples/images/dreambooth/train_dreambooth_colossalai.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 401 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (25 lines × 3) REDACTED:608 — REDACTED:608-632 | examples/images/dreambooth/train_dreambooth_colossalai.py:621-645 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:641-665 — before extracting anything, compare `REDACTED` and `examples/images/dreambooth/train_dreambooth_colossalai.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 401 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (17–19 lines × 2) · ×2
  • Duplicated block (17–19 lines × 2) examples/images/dreambooth/train_dreambooth_colossalai.py:483 — examples/images/dreambooth/train_dreambooth_colossalai.py:483-501 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:506-522 — before extracting anything, compare `examples/images/dreambooth/train_dreambooth_colossalai.py` and `examples/images/dreambooth/train_dreambooth_colossalai_lora.py` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 757 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/images/dreambooth/train_dreambooth_colossalai.py:483` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17–19 lines × 2) examples/tutorial/sequence_parallel/data/datasets/dataset_utils.py:257 — examples/tutorial/sequence_parallel/data/datasets/dataset_utils.py:257-275 | examples/tutorial/sequence_parallel/data/datasets/dataset_utils.py:318-334 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `examples/tutorial/sequence_parallel/data/datasets/dataset_utils.py:257` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D1 · Cyclomatic Complexity · LlamaPipelineForwards.llama_model_forward (cyclomatic 61) · ×1
  • LlamaPipelineForwards.llama_model_forward (cyclomatic 61) colossalai/shardformer/modeling/_llama_tf5.py:79 — LlamaPipelineForwards.llama_model_forward has cyclomatic complexity 61 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · PipelineGraph.try_v_schedule (cyclomatic 60) · ×1
  • PipelineGraph.try_v_schedule (cyclomatic 60) colossalai/pipeline/schedule/v_schedule.py:81 — PipelineGraph.try_v_schedule has cyclomatic complexity 60 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · LlamaPipelineForwards.llama_model_forward (cyclomatic 60) · ×1
  • LlamaPipelineForwards.llama_model_forward (cyclomatic 60) colossalai/shardformer/modeling/_llama_tf4.py:44 — LlamaPipelineForwards.llama_model_forward has cyclomatic complexity 60 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · GPT2PipelineForwards.gpt2_model_forward (cyclomatic 57) · ×1
  • GPT2PipelineForwards.gpt2_model_forward (cyclomatic 57) colossalai/shardformer/modeling/gpt2.py:116 — GPT2PipelineForwards.gpt2_model_forward has cyclomatic complexity 57 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · BertPipelineForwards.bert_model_forward (cyclomatic 56) · ×1
  • BertPipelineForwards.bert_model_forward (cyclomatic 56) colossalai/shardformer/modeling/_bert_tf4.py:42 — BertPipelineForwards.bert_model_forward has cyclomatic complexity 56 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · OPTPipelineForwards.opt_model_forward (cyclomatic 55) · ×1
  • OPTPipelineForwards.opt_model_forward (cyclomatic 55) colossalai/shardformer/modeling/opt.py:64 — OPTPipelineForwards.opt_model_forward has cyclomatic complexity 55 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · train.train (cyclomatic 54) · ×1
  • train.train (cyclomatic 54) applications/Colossal-LLaMA/train.py:40 — train.train has cyclomatic complexity 54 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Qwen2PipelineForwards.qwen2_model_forward (cyclomatic 51) · ×1
  • Qwen2PipelineForwards.qwen2_model_forward (cyclomatic 51) colossalai/shardformer/modeling/_qwen2_tf4.py:42 — Qwen2PipelineForwards.qwen2_model_forward has cyclomatic complexity 51 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Qwen3PipelineForwards.qwen3_model_forward (cyclomatic 51) · ×1
  • Qwen3PipelineForwards.qwen3_model_forward (cyclomatic 51) colossalai/shardformer/modeling/_qwen3_tf4.py:42 — Qwen3PipelineForwards.qwen3_model_forward has cyclomatic complexity 51 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · pretrained.new_from_pretrained (cyclomatic 50) · ×1
  • pretrained.new_from_pretrained (cyclomatic 50) colossalai/lazy/pretrained.py:36 — pretrained.new_from_pretrained has cyclomatic complexity 50 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · BertPipelineForwards.bert_model_forward (cyclomatic 50) · ×1
  • BertPipelineForwards.bert_model_forward (cyclomatic 50) colossalai/shardformer/modeling/_bert_tf5.py:44 — BertPipelineForwards.bert_model_forward has cyclomatic complexity 50 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · CommandPipelineForwards.command_model_forward (cyclomatic 49) · ×1
  • CommandPipelineForwards.command_model_forward (cyclomatic 49) colossalai/shardformer/modeling/command.py:39 — CommandPipelineForwards.command_model_forward has cyclomatic complexity 49 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · BloomPipelineForwards.bloom_model_forward (cyclomatic 47) · ×1
  • BloomPipelineForwards.bloom_model_forward (cyclomatic 47) colossalai/shardformer/modeling/bloom.py:109 — BloomPipelineForwards.bloom_model_forward has cyclomatic complexity 47 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MixtralPipelineForwards.mixtral_model_forward (cyclomatic 46) · ×1
  • MixtralPipelineForwards.mixtral_model_forward (cyclomatic 46) colossalai/shardformer/modeling/_mixtral_tf4.py:183 — MixtralPipelineForwards.mixtral_model_forward has cyclomatic complexity 46 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · initialize.initialize (cyclomatic 44) · ×1
  • initialize.initialize (cyclomatic 44) colossalai/legacy/initialize.py:242 — initialize.initialize has cyclomatic complexity 44 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · WhisperPipelineForwards.whisper_decoder_forward (cyclomatic 44) · ×1
  • WhisperPipelineForwards.whisper_decoder_forward (cyclomatic 44) colossalai/shardformer/modeling/_whisper_tf4.py:601 — WhisperPipelineForwards.whisper_decoder_forward has cyclomatic complexity 44 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ChatGLMPipelineForwards.chatglm_model_forward (cyclomatic 44) · ×1
  • ChatGLMPipelineForwards.chatglm_model_forward (cyclomatic 44) colossalai/shardformer/modeling/chatglm2.py:93 — ChatGLMPipelineForwards.chatglm_model_forward has cyclomatic complexity 44 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · T5PipelineForwards.t5_stack_forward (cyclomatic 43) · ×1
  • T5PipelineForwards.t5_stack_forward (cyclomatic 43) colossalai/shardformer/modeling/t5.py:32 — T5PipelineForwards.t5_stack_forward has cyclomatic complexity 43 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · TraceIndice.trace_indice (cyclomatic 42) · ×1
  • TraceIndice.trace_indice (cyclomatic 42) colossalai/autochunk/trace_indice.py:838 — TraceIndice.trace_indice has cyclomatic complexity 42 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · InterleavedPipelineSchedule.forward_backward_step (cyclomatic 42) · ×1
  • InterleavedPipelineSchedule.forward_backward_step (cyclomatic 42) colossalai/legacy/engine/schedule/_pipeline_schedule.py:560 — InterleavedPipelineSchedule.forward_backward_step has cyclomatic complexity 42 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Solver._call_solver_serialized_args (cyclomatic 41) · ×1
  • Solver._call_solver_serialized_args (cyclomatic 41) colossalai/auto_parallel/tensor_shard/solver/solver.py:211 — Solver._call_solver_serialized_args has cyclomatic complexity 41 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · GRPOConsumer.step (cyclomatic 39) · ×1
  • GRPOConsumer.step (cyclomatic 39) applications/ColossalChat/coati/distributed/grpo_consumer.py:174 — GRPOConsumer.step has cyclomatic complexity 39 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · BaseProducer.loop (cyclomatic 39) · ×1
  • BaseProducer.loop (cyclomatic 39) applications/ColossalChat/coati/distributed/zero_bubble/producer.py:212 — BaseProducer.loop has cyclomatic complexity 39 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MixtralPipelineForwards.mixtral_model_forward (cyclomatic 39) · ×1
  • MixtralPipelineForwards.mixtral_model_forward (cyclomatic 39) colossalai/shardformer/modeling/_mixtral_tf5.py:528 — MixtralPipelineForwards.mixtral_model_forward has cyclomatic complexity 39 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · BaseProducer.loop (cyclomatic 38) · ×1
  • BaseProducer.loop (cyclomatic 38) applications/ColossalChat/coati/distributed/producer.py:218 — BaseProducer.loop has cyclomatic complexity 38 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · OpenMoePipelineForwards.openmoe_model_forward (cyclomatic 38) · ×1
  • OpenMoePipelineForwards.openmoe_model_forward (cyclomatic 38) colossalai/legacy/moe/openmoe/model/openmoe_policy.py:231 — OpenMoePipelineForwards.openmoe_model_forward has cyclomatic complexity 38 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · _deepseek_v3_tf4.deepseek_v3_model_forward (cyclomatic 38) · ×1
  • _deepseek_v3_tf4.deepseek_v3_model_forward (cyclomatic 38) colossalai/shardformer/modeling/_deepseek_v3_tf4.py:146 — _deepseek_v3_tf4.deepseek_v3_model_forward has cyclomatic complexity 38 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · DeepseekPipelineForwards.deepseek_model_forward (cyclomatic 38) · ×1
  • DeepseekPipelineForwards.deepseek_model_forward (cyclomatic 38) colossalai/shardformer/modeling/deepseek.py:286 — DeepseekPipelineForwards.deepseek_model_forward has cyclomatic complexity 38 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Qwen2PipelineForwards.qwen2_model_forward (cyclomatic 37) · ×1
  • Qwen2PipelineForwards.qwen2_model_forward (cyclomatic 37) colossalai/shardformer/modeling/_qwen2_tf5.py:41 — Qwen2PipelineForwards.qwen2_model_forward has cyclomatic complexity 37 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Qwen3PipelineForwards.qwen3_model_forward (cyclomatic 37) · ×1
  • Qwen3PipelineForwards.qwen3_model_forward (cyclomatic 37) colossalai/shardformer/modeling/_qwen3_tf5.py:42 — Qwen3PipelineForwards.qwen3_model_forward has cyclomatic complexity 37 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · BaseConsumer.loop (cyclomatic 36) · ×1
  • BaseConsumer.loop (cyclomatic 36) applications/ColossalChat/coati/distributed/consumer.py:149 — BaseConsumer.loop has cyclomatic complexity 36 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MistralForwards.mistral_model_forward (cyclomatic 36) · ×1
  • MistralForwards.mistral_model_forward (cyclomatic 36) colossalai/shardformer/modeling/mistral.py:25 — MistralForwards.mistral_model_forward has cyclomatic complexity 36 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · BloomInferenceForwards.bloom_model_forward (cyclomatic 35) · ×1
  • BloomInferenceForwards.bloom_model_forward (cyclomatic 35) colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:70 — BloomInferenceForwards.bloom_model_forward has cyclomatic complexity 35 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · GRPOConsumer.step (cyclomatic 34) · ×1
  • GRPOConsumer.step (cyclomatic 34) applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py:164 — GRPOConsumer.step has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · FalconPipelineForwards.falcon_model_forward (cyclomatic 34) · ×1
  • FalconPipelineForwards.falcon_model_forward (cyclomatic 34) colossalai/shardformer/modeling/falcon.py:188 — FalconPipelineForwards.falcon_model_forward has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · llama.llama_model_forward (cyclomatic 33) · ×1
  • llama.llama_model_forward (cyclomatic 33) colossalai/legacy/inference/quant/smoothquant/models/llama.py:559 — llama.llama_model_forward has cyclomatic complexity 33 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · PipelineGraph.get_v_schedule (cyclomatic 33) · ×1
  • PipelineGraph.get_v_schedule (cyclomatic 33) colossalai/pipeline/schedule/v_schedule.py:318 — PipelineGraph.get_v_schedule has cyclomatic complexity 33 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · GPTJPipelineForwards.gptj_model_forward (cyclomatic 33) · ×1
  • GPTJPipelineForwards.gptj_model_forward (cyclomatic 33) colossalai/shardformer/modeling/gptj.py:80 — GPTJPipelineForwards.gptj_model_forward has cyclomatic complexity 33 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · pixart_alpha.pixart_alpha_forward (cyclomatic 32) · ×1
  • pixart_alpha.pixart_alpha_forward (cyclomatic 32) colossalai/inference/modeling/models/pixart_alpha.py:23 — pixart_alpha.pixart_alpha_forward has cyclomatic complexity 32 (threshold 15). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D1 · Cyclomatic Complexity · OpenMoeModel.forward (cyclomatic 32) · ×1
  • OpenMoeModel.forward (cyclomatic 32) colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:705 — OpenMoeModel.forward has cyclomatic complexity 32 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · WorkerBase._consume_work_item_by_phase (cyclomatic 32) · ×1
  • WorkerBase._consume_work_item_by_phase (cyclomatic 32) colossalai/legacy/pipeline/rpc/_pipeline_base.py:804 — WorkerBase._consume_work_item_by_phase has cyclomatic complexity 32 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · utils.get_lora_state_dict (cyclomatic 31) · ×1
  • utils.get_lora_state_dict (cyclomatic 31) colossalai/checkpoint_io/utils.py:1049 — utils.get_lora_state_dict has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · split_module.split_module (cyclomatic 31) · ×1
  • split_module.split_module (cyclomatic 31) colossalai/fx/passes/split_module.py:40 — split_module.split_module has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · p2p._send_recv_serialization_object (cyclomatic 31) · ×1
  • p2p._send_recv_serialization_object (cyclomatic 31) REDACTED:273 — p2p._send_recv_serialization_object has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · GeminiDDP._load_from_state_dict (cyclomatic 30) · ×1
  • GeminiDDP._load_from_state_dict (cyclomatic 30) colossalai/zero/gemini/gemini_ddp.py:644 — GeminiDDP._load_from_state_dict has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · CheckpointSolverRotor._annotate_from_sequence (cyclomatic 29) · ×1
  • CheckpointSolverRotor._annotate_from_sequence (cyclomatic 29) colossalai/auto_parallel/checkpoint/ckpt_solver_rotor.py:361 — CheckpointSolverRotor._annotate_from_sequence has cyclomatic complexity 29 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D1 · Cyclomatic Complexity · BaseConsumer.loop (cyclomatic 28) · ×1
  • BaseConsumer.loop (cyclomatic 28) applications/ColossalChat/coati/distributed/zero_bubble/consumer.py:160 — BaseConsumer.loop has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · HybridParallelPlugin.__init__ (cyclomatic 28) · ×1
  • HybridParallelPlugin.__init__ (cyclomatic 28) colossalai/booster/plugin/hybrid_parallel_plugin.py:947 — HybridParallelPlugin.__init__ has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · activation_checkpoint_codegen.emit_code_with_activation_checkpoint (cyclomatic 28) · ×1
  • activation_checkpoint_codegen.emit_code_with_activation_checkpoint (cyclomatic 28) colossalai/fx/codegen/activation_checkpoint_codegen.py:490 — activation_checkpoint_codegen.emit_code_with_activation_checkpoint has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · GeminiOptimizer.collect_states (cyclomatic 28) · ×1
  • GeminiOptimizer.collect_states (cyclomatic 28) colossalai/zero/gemini/gemini_optimizer.py:421 — GeminiOptimizer.collect_states has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RegionManager._linearize_graph (cyclomatic 27) · ×1
  • RegionManager._linearize_graph (cyclomatic 27) colossalai/auto_parallel/offload/region_manager.py:271 — RegionManager._linearize_graph has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · common.clip_grad_norm_fp32 (cyclomatic 27) · ×1
  • common.clip_grad_norm_fp32 (cyclomatic 27) colossalai/legacy/utils/common.py:254 — common.clip_grad_norm_fp32 has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · DistGaloreAdamW.step (cyclomatic 27) · ×1
  • DistGaloreAdamW.step (cyclomatic 27) colossalai/nn/optimizer/distributed_galore.py:143 — DistGaloreAdamW.step has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · PaddingParallelModule._load_from_state_dict (cyclomatic 27) · ×1
  • PaddingParallelModule._load_from_state_dict (cyclomatic 27) colossalai/shardformer/layer/parallel_module.py:245 — PaddingParallelModule._load_from_state_dict has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · LlamaInferenceForwards.llama_model_forward (cyclomatic 26) · ×1
  • LlamaInferenceForwards.llama_model_forward (cyclomatic 26) colossalai/legacy/inference/tensor_parallel/modeling/llama.py:118 — LlamaInferenceForwards.llama_model_forward has cyclomatic complexity 26 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · DistributedCAME.step (cyclomatic 26) · ×1
  • DistributedCAME.step (cyclomatic 26) colossalai/nn/optimizer/distributed_came.py:333 — DistributedCAME.step has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ParallelModule._load_from_state_dict (cyclomatic 26) · ×1
  • ParallelModule._load_from_state_dict (cyclomatic 26) colossalai/shardformer/layer/parallel_module.py:70 — ParallelModule._load_from_state_dict has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · _deepseek_v3_tf5.deepseek_v3_model_forward (cyclomatic 26) · ×1
  • _deepseek_v3_tf5.deepseek_v3_model_forward (cyclomatic 26) colossalai/shardformer/modeling/_deepseek_v3_tf5.py:171 — _deepseek_v3_tf5.deepseek_v3_model_forward has cyclomatic complexity 26 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · NodeHandler.register_strategy (cyclomatic 25) · ×1
  • NodeHandler.register_strategy (cyclomatic 25) colossalai/auto_parallel/tensor_shard/node_handler/node_handler.py:162 — NodeHandler.register_strategy has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · TraceIndice._assign_view_reshape_indice (cyclomatic 25) · ×1
  • TraceIndice._assign_view_reshape_indice (cyclomatic 25) colossalai/autochunk/trace_indice.py:718 — TraceIndice._assign_view_reshape_indice has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ColoTracer._meta_data_computing (cyclomatic 25) · ×1
  • ColoTracer._meta_data_computing (cyclomatic 25) colossalai/fx/tracer/tracer.py:218 — ColoTracer._meta_data_computing has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ShardedModelV2._colo_load_from_state_dict (cyclomatic 25) · ×1
  • ShardedModelV2._colo_load_from_state_dict (cyclomatic 25) colossalai/legacy/zero/sharded_model/sharded_model_v2.py:481 — ShardedModelV2._colo_load_from_state_dict has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · DistributedAdaFactor.step (cyclomatic 25) · ×1
  • DistributedAdaFactor.step (cyclomatic 25) colossalai/nn/optimizer/distributed_adafactor.py:286 — DistributedAdaFactor.step has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · InterleavedSchedule.run_forward_backward (cyclomatic 25) · ×1
  • InterleavedSchedule.run_forward_backward (cyclomatic 25) colossalai/pipeline/schedule/interleaved_pp.py:441 — InterleavedSchedule.run_forward_backward has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · LowLevelZeroOptimizer.__init__ (cyclomatic 25) · ×1
  • LowLevelZeroOptimizer.__init__ (cyclomatic 25) colossalai/zero/low_level/low_level_optim.py:77 — LowLevelZeroOptimizer.__init__ has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · NaiveExperienceMaker.make_experience (cyclomatic 23) · ×1
  • NaiveExperienceMaker.make_experience (cyclomatic 23) applications/ColossalChat/coati/experience_maker/naive.py:87 — NaiveExperienceMaker.make_experience has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MoeHybridParallelPlugin.__init__ (cyclomatic 23) · ×1
  • MoeHybridParallelPlugin.__init__ (cyclomatic 23) colossalai/booster/plugin/moe_hybrid_parallel_plugin.py:178 — MoeHybridParallelPlugin.__init__ has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · glide_llama.glide_llama_model_forward (cyclomatic 23) · ×1
  • glide_llama.glide_llama_model_forward (cyclomatic 23) colossalai/inference/modeling/models/glide_llama.py:121 — glide_llama.glide_llama_model_forward has cyclomatic complexity 23 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · BnbQuantizationConfig.__post_init__ (cyclomatic 23) · ×1
  • BnbQuantizationConfig.__post_init__ (cyclomatic 23) colossalai/quantization/bnb_config.py:66 — BnbQuantizationConfig.__post_init__ has cyclomatic complexity 23 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · Qwen2PipelineForwards.qwen2_for_sequence_classification_forward (cyclomatic 23) · ×1
  • Qwen2PipelineForwards.qwen2_for_sequence_classification_forward (cyclomatic 23) colossalai/shardformer/modeling/_qwen2_tf4.py:368 — Qwen2PipelineForwards.qwen2_for_sequence_classification_forward has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · BloomPipelineForwards.bloom_for_sequence_classification_forward (cyclomatic 23) · ×1
  • BloomPipelineForwards.bloom_for_sequence_classification_forward (cyclomatic 23) colossalai/shardformer/modeling/bloom.py:412 — BloomPipelineForwards.bloom_for_sequence_classification_forward has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · T5PipelineForwards.t5_for_conditional_generation_forward (cyclomatic 23) · ×1
  • T5PipelineForwards.t5_for_conditional_generation_forward (cyclomatic 23) colossalai/shardformer/modeling/t5.py:403 — T5PipelineForwards.t5_for_conditional_generation_forward has cyclomatic complexity 23 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ChatGLMPolicy.module_policy (cyclomatic 23) · ×1
  • ChatGLMPolicy.module_policy (cyclomatic 23) colossalai/shardformer/policies/chatglm2.py:41 — ChatGLMPolicy.module_policy has cyclomatic complexity 23 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · CommandPolicy.module_policy (cyclomatic 23) · ×1
  • CommandPolicy.module_policy (cyclomatic 23) colossalai/shardformer/policies/command.py:38 — CommandPolicy.module_policy has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · spliced_and_tokenized_dataset.supervised_tokenize_sft (cyclomatic 22) · ×1
  • spliced_and_tokenized_dataset.supervised_tokenize_sft (cyclomatic 22) applications/Colossal-LLaMA/colossal_llama/dataset/spliced_and_tokenized_dataset.py:73 — spliced_and_tokenized_dataset.supervised_tokenize_sft has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · launch_zero_bubble.launch_distributed (cyclomatic 22) · ×1
  • launch_zero_bubble.launch_distributed (cyclomatic 22) applications/ColossalChat/coati/distributed/launch_zero_bubble.py:31 — launch_zero_bubble.launch_distributed has cyclomatic complexity 22 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D1 · Cyclomatic Complexity · HybridParallelCheckpointIO.save_sharded_optimizer (cyclomatic 22) · ×1
  • HybridParallelCheckpointIO.save_sharded_optimizer (cyclomatic 22) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:516 — HybridParallelCheckpointIO.save_sharded_optimizer has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run.launch_multi_processes (cyclomatic 22) · ×1
  • run.launch_multi_processes (cyclomatic 22) colossalai/cli/launcher/run.py:212 — run.launch_multi_processes has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · LlamaInferenceForwards.llama_model_forward (cyclomatic 22) · ×1
  • LlamaInferenceForwards.llama_model_forward (cyclomatic 22) colossalai/legacy/inference/hybridengine/modeling/llama.py:196 — LlamaInferenceForwards.llama_model_forward has cyclomatic complexity 22 (threshold 15). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D1 · Cyclomatic Complexity · WhisperPipelineForwards.whisper_encoder_forward (cyclomatic 22) · ×1
  • WhisperPipelineForwards.whisper_encoder_forward (cyclomatic 22) colossalai/shardformer/modeling/_whisper_tf4.py:472 — WhisperPipelineForwards.whisper_encoder_forward has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · WhisperPipelineForwards.whisper_model_forward (cyclomatic 22) · ×1
  • WhisperPipelineForwards.whisper_model_forward (cyclomatic 22) colossalai/shardformer/modeling/_whisper_tf4.py:845 — WhisperPipelineForwards.whisper_model_forward has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · LlamaPolicy.module_policy (cyclomatic 22) · ×1
  • LlamaPolicy.module_policy (cyclomatic 22) colossalai/shardformer/policies/_llama_tf4.py:35 — LlamaPolicy.module_policy has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · T5BasePolicy.get_held_layers (cyclomatic 22) · ×1
  • T5BasePolicy.get_held_layers (cyclomatic 22) colossalai/shardformer/policies/t5.py:501 — T5BasePolicy.get_held_layers has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · GeminiDDP.state_dict_shard (cyclomatic 22) · ×1
  • GeminiDDP.state_dict_shard (cyclomatic 22) colossalai/zero/gemini/gemini_ddp.py:900 — GeminiDDP.state_dict_shard has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · agieval.combine_prompt (cyclomatic 21) · ×1
  • agieval.combine_prompt (cyclomatic 21) applications/ColossalEval/colossal_eval/dataset/agieval.py:103 — agieval.combine_prompt has cyclomatic complexity 21 (threshold 15). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D1 · Cyclomatic Complexity · FusedLAMB.step (cyclomatic 21) · ×1
  • FusedLAMB.step (cyclomatic 21) colossalai/nn/optimizer/fused_lamb.py:105 — FusedLAMB.step has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · FalconPipelineForwards.falcon_for_sequence_classification_forward (cyclomatic 21) · ×1
  • FalconPipelineForwards.falcon_for_sequence_classification_forward (cyclomatic 21) colossalai/shardformer/modeling/falcon.py:453 — FalconPipelineForwards.falcon_for_sequence_classification_forward has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · LlamaPolicy.module_policy (cyclomatic 21) · ×1
  • LlamaPolicy.module_policy (cyclomatic 21) colossalai/shardformer/policies/_llama_tf5.py:35 — LlamaPolicy.module_policy has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · generation._sample_streaming (cyclomatic 20) · ×1
  • generation._sample_streaming (cyclomatic 20) applications/ColossalChat/coati/models/generation.py:262 — generation._sample_streaming has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Quantizer.find_params (cyclomatic 20) · ×1
  • Quantizer.find_params (cyclomatic 20) applications/ColossalChat/coati/quant/llama_gptq/quant.py:31 — Quantizer.find_params has cyclomatic complexity 20 (threshold 15). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D1 · Cyclomatic Complexity · GRPOTrainer._training_step (cyclomatic 20) · ×1
  • GRPOTrainer._training_step (cyclomatic 20) applications/ColossalChat/coati/trainer/grpo.py:228 — GRPOTrainer._training_step has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · PPOTrainer._training_step (cyclomatic 20) · ×1
  • PPOTrainer._training_step (cyclomatic 20) applications/ColossalChat/coati/trainer/ppo.py:217 — PPOTrainer._training_step has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · TraceFlow._get_prepose_nodes (cyclomatic 20) · ×1
  • TraceFlow._get_prepose_nodes (cyclomatic 20) colossalai/autochunk/trace_flow.py:245 — TraceFlow._get_prepose_nodes has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · HybridParallelCheckpointIO.save_sharded_model (cyclomatic 20) · ×1
  • HybridParallelCheckpointIO.save_sharded_model (cyclomatic 20) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:252 — HybridParallelCheckpointIO.save_sharded_model has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MoECheckpointIO.save_sharded_model (cyclomatic 20) · ×1
  • MoECheckpointIO.save_sharded_model (cyclomatic 20) colossalai/checkpoint_io/moe_checkpoint.py:145 — MoECheckpointIO.save_sharded_model has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · _meta_regist_12.meta_index_Tensor (cyclomatic 20) · ×1
  • _meta_regist_12.meta_index_Tensor (cyclomatic 20) colossalai/fx/_meta_regist_12.py:435 — _meta_regist_12.meta_index_Tensor has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · LLMEngine.add_request (cyclomatic 20) · ×1
  • LLMEngine.add_request (cyclomatic 20) colossalai/inference/core/llm_engine.py:580 — LLMEngine.add_request has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · stablediffusion3.sd3_forward (cyclomatic 20) · ×1
  • stablediffusion3.sd3_forward (cyclomatic 20) colossalai/inference/modeling/models/stablediffusion3.py:12 — stablediffusion3.sd3_forward has cyclomatic complexity 20 (threshold 15). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D1 · Cyclomatic Complexity · PipelineSchedule.forward_backward_step (cyclomatic 20) · ×1
  • PipelineSchedule.forward_backward_step (cyclomatic 20) colossalai/legacy/engine/schedule/_pipeline_schedule.py:321 — PipelineSchedule.forward_backward_step has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · WhisperPipelineForwards.whisper_model_forward (cyclomatic 20) · ×1
  • WhisperPipelineForwards.whisper_model_forward (cyclomatic 20) colossalai/shardformer/modeling/_whisper_tf5.py:363 — WhisperPipelineForwards.whisper_model_forward has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MixtralPolicy.module_policy (cyclomatic 20) · ×1
  • MixtralPolicy.module_policy (cyclomatic 20) colossalai/shardformer/policies/_mixtral_tf5.py:44 — MixtralPolicy.module_policy has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · LowLevelZeroOptimizer.step (cyclomatic 20) · ×1
  • LowLevelZeroOptimizer.step (cyclomatic 20) colossalai/zero/low_level/low_level_optim.py:537 — LowLevelZeroOptimizer.step has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · check_pr_runner_policy.validate_fork_workflow (cyclomatic 19) · ×1
  • check_pr_runner_policy.validate_fork_workflow (cyclomatic 19) .github/scripts/ci/check_pr_runner_policy.py:83 — check_pr_runner_policy.validate_fork_workflow has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · generate_leaderboard_and_send_to_lark.get_discussion_comments (cyclomatic 19) · ×1
  • generate_leaderboard_and_send_to_lark.get_discussion_comments (cyclomatic 19) .github/workflows/scripts/generate_leaderboard_and_send_to_lark.py:141 — generate_leaderboard_and_send_to_lark.get_discussion_comments has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · CostGraph.merge_node (cyclomatic 19) · ×1
  • CostGraph.merge_node (cyclomatic 19) colossalai/auto_parallel/tensor_shard/solver/cost_graph.py:101 — CostGraph.merge_node has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · StrategiesConstructor.build_strategies_and_cost (cyclomatic 19) · ×1
  • StrategiesConstructor.build_strategies_and_cost (cyclomatic 19) colossalai/auto_parallel/tensor_shard/solver/strategies_constructor.py:72 — StrategiesConstructor.build_strategies_and_cost has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ColoTracer.trace (cyclomatic 19) · ×1
  • ColoTracer.trace (cyclomatic 19) colossalai/fx/tracer/tracer.py:317 — ColoTracer.trace has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · PipelinableContext.to_layer_list (cyclomatic 19) · ×1
  • PipelinableContext.to_layer_list (cyclomatic 19) colossalai/legacy/pipeline/pipelinable.py:122 — PipelinableContext.to_layer_list has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · GenerateSchedule.generate_step_broadcast (cyclomatic 19) · ×1
  • GenerateSchedule.generate_step_broadcast (cyclomatic 19) colossalai/pipeline/schedule/generate.py:348 — GenerateSchedule.generate_step_broadcast has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · WhisperPipelineForwards.whisper_encoder_forward (cyclomatic 19) · ×1
  • WhisperPipelineForwards.whisper_encoder_forward (cyclomatic 19) colossalai/shardformer/modeling/_whisper_tf5.py:252 — WhisperPipelineForwards.whisper_encoder_forward has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · GPT2PipelineForwards.gpt2_for_sequence_classification_forward (cyclomatic 19) · ×1
  • GPT2PipelineForwards.gpt2_for_sequence_classification_forward (cyclomatic 19) colossalai/shardformer/modeling/gpt2.py:693 — GPT2PipelineForwards.gpt2_for_sequence_classification_forward has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · GPTJPipelineForwards.gptj_for_sequence_classification_forward (cyclomatic 19) · ×1
  • GPTJPipelineForwards.gptj_for_sequence_classification_forward (cyclomatic 19) colossalai/shardformer/modeling/gptj.py:356 — GPTJPipelineForwards.gptj_for_sequence_classification_forward has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MixtralPolicy.module_policy (cyclomatic 19) · ×1
  • MixtralPolicy.module_policy (cyclomatic 19) colossalai/shardformer/policies/_mixtral_tf4.py:42 — MixtralPolicy.module_policy has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · DeepseekPolicy.module_policy (cyclomatic 19) · ×1
  • DeepseekPolicy.module_policy (cyclomatic 19) colossalai/shardformer/policies/deepseek.py:47 — DeepseekPolicy.module_policy has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · TensorDetector.collect_tensors_state (cyclomatic 19) · ×1
  • TensorDetector.collect_tensors_state (cyclomatic 19) colossalai/utils/tensor_detector/tensor_detector.py:65 — TensorDetector.collect_tensors_state has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · LowLevelZeroOptimizer.state_dict_shard (cyclomatic 19) · ×1
  • LowLevelZeroOptimizer.state_dict_shard (cyclomatic 19) colossalai/zero/low_level/low_level_optim.py:836 — LowLevelZeroOptimizer.state_dict_shard has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · DPOTrainer._train (cyclomatic 18) · ×1
  • DPOTrainer._train (cyclomatic 18) applications/ColossalChat/coati/trainer/dpo.py:123 — DPOTrainer._train has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · HuggingFaceModel.inference (cyclomatic 18) · ×1
  • HuggingFaceModel.inference (cyclomatic 18) REDACTED:334 — HuggingFaceModel.inference has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · vLLMModel.inference (cyclomatic 18) · ×1
  • vLLMModel.inference (cyclomatic 18) REDACTED:217 — vLLMModel.inference has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · colossalai_suite.main (cyclomatic 18) · ×1
  • colossalai_suite.main (cyclomatic 18) .github/scripts/e1/colossalai_suite.py:28 — colossalai_suite.main has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · TraceFlow._assign_single_node_flow (cyclomatic 18) · ×1
  • TraceFlow._assign_single_node_flow (cyclomatic 18) colossalai/autochunk/trace_flow.py:66 — TraceFlow._assign_single_node_flow has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MoeHybridParallelPlugin.configure (cyclomatic 18) · ×1
  • MoeHybridParallelPlugin.configure (cyclomatic 18) colossalai/booster/plugin/moe_hybrid_parallel_plugin.py:427 — MoeHybridParallelPlugin.configure has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · HybridParallelCheckpointIO._model_sharder (cyclomatic 18) · ×1
  • HybridParallelCheckpointIO._model_sharder (cyclomatic 18) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:144 — HybridParallelCheckpointIO._model_sharder has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · experimental._meta_data_computing_v0 (cyclomatic 18) · ×1
  • experimental._meta_data_computing_v0 (cyclomatic 18) colossalai/fx/tracer/experimental.py:525 — experimental._meta_data_computing_v0 has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · module_utils.check_colo_module (cyclomatic 18) · ×1
  • module_utils.check_colo_module (cyclomatic 18) colossalai/legacy/nn/parallel/layers/module_utils.py:36 — module_utils.check_colo_module has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RingAttention.forward (cyclomatic 18) · ×1
  • RingAttention.forward (cyclomatic 18) colossalai/shardformer/layer/attn.py:623 — RingAttention.forward has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · loss.dist_cross_entropy (cyclomatic 18) · ×1
  • loss.dist_cross_entropy (cyclomatic 18) colossalai/shardformer/layer/loss.py:262 — loss.dist_cross_entropy has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MistralForwards.mistral_for_sequence_classification_forward (cyclomatic 18) · ×1
  • MistralForwards.mistral_for_sequence_classification_forward (cyclomatic 18) colossalai/shardformer/modeling/mistral.py:276 — MistralForwards.mistral_for_sequence_classification_forward has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · OPTPipelineForwards.opt_for_sequence_classification_forward (cyclomatic 18) · ×1
  • OPTPipelineForwards.opt_for_sequence_classification_forward (cyclomatic 18) colossalai/shardformer/modeling/opt.py:359 — OPTPipelineForwards.opt_for_sequence_classification_forward has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · T5PipelineForwards.t5_model_forward (cyclomatic 18) · ×1
  • T5PipelineForwards.t5_model_forward (cyclomatic 18) colossalai/shardformer/modeling/t5.py:264 — T5PipelineForwards.t5_model_forward has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · BlipPolicy.module_policy (cyclomatic 18) · ×1
  • BlipPolicy.module_policy (cyclomatic 18) colossalai/shardformer/policies/blip2.py:27 — BlipPolicy.module_policy has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · GeminiDDP.__init__ (cyclomatic 18) · ×1
  • GeminiDDP.__init__ (cyclomatic 18) colossalai/zero/gemini/gemini_ddp.py:75 — GeminiDDP.__init__ has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · generation._sample (cyclomatic 17) · ×1
  • generation._sample (cyclomatic 17) applications/ColossalChat/coati/models/generation.py:97 — generation._sample has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · QuantLinear.pack (cyclomatic 17) · ×1
  • QuantLinear.pack (cyclomatic 17) applications/ColossalChat/coati/quant/llama_gptq/quant.py:150 — QuantLinear.pack has cyclomatic complexity 17 (threshold 15). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D1 · Cyclomatic Complexity · DPOTrainer._eval (cyclomatic 17) · ×1
  • DPOTrainer._eval (cyclomatic 17) applications/ColossalChat/coati/trainer/dpo.py:406 — DPOTrainer._eval has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · linear.matmul_meta_info (cyclomatic 17) · ×1
  • linear.matmul_meta_info (cyclomatic 17) colossalai/auto_parallel/meta_profiler/meta_registry/linear.py:190 — linear.matmul_meta_info has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · SearchChunk._search_max_chunk_region (cyclomatic 17) · ×1
  • SearchChunk._search_max_chunk_region (cyclomatic 17) colossalai/autochunk/search_chunk.py:106 — SearchChunk._search_max_chunk_region has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · TraceIndice._assign_getitem_indice (cyclomatic 17) · ×1
  • TraceIndice._assign_getitem_indice (cyclomatic 17) colossalai/autochunk/trace_indice.py:647 — TraceIndice._assign_getitem_indice has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MoECheckpointIO._model_sharder (cyclomatic 17) · ×1
  • MoECheckpointIO._model_sharder (cyclomatic 17) colossalai/checkpoint_io/moe_checkpoint.py:73 — MoECheckpointIO._model_sharder has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · module_checkpoint.load_checkpoint (cyclomatic 17) · ×1
  • module_checkpoint.load_checkpoint (cyclomatic 17) colossalai/legacy/utils/checkpoint/module_checkpoint.py:79 — module_checkpoint.load_checkpoint has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · GaLoreAdamW8bit.step (cyclomatic 17) · ×1
  • GaLoreAdamW8bit.step (cyclomatic 17) colossalai/nn/optimizer/galore.py:235 — GaLoreAdamW8bit.step has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · p2p._broadcast_object_list (cyclomatic 17) · ×1
  • p2p._broadcast_object_list (cyclomatic 17) REDACTED:63 — p2p._broadcast_object_list has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MixtralPipelineForwards.mixtral_for_causal_lm_forward (cyclomatic 17) · ×1
  • MixtralPipelineForwards.mixtral_for_causal_lm_forward (cyclomatic 17) colossalai/shardformer/modeling/_mixtral_tf5.py:774 — MixtralPipelineForwards.mixtral_for_causal_lm_forward has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ChatGLMForConditionalGeneration.stream_generate (cyclomatic 17) · ×1
  • ChatGLMForConditionalGeneration.stream_generate (cyclomatic 17) colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py:1267 — ChatGLMForConditionalGeneration.stream_generate has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · GPT2Policy.module_policy (cyclomatic 17) · ×1
  • GPT2Policy.module_policy (cyclomatic 17) colossalai/shardformer/policies/gpt2.py:38 — GPT2Policy.module_policy has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · BaseProducer.__init__ (cyclomatic 16) · ×1
  • BaseProducer.__init__ (cyclomatic 16) applications/ColossalChat/coati/distributed/producer.py:35 — BaseProducer.__init__ has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · gpt_evaluate.evaluate (cyclomatic 16) · ×1
  • gpt_evaluate.evaluate (cyclomatic 16) applications/ColossalEval/colossal_eval/evaluate/gpt_evaluate.py:496 — gpt_evaluate.evaluate has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · CheckpointSolverBase._linearize_graph (cyclomatic 16) · ×1
  • CheckpointSolverBase._linearize_graph (cyclomatic 16) colossalai/auto_parallel/checkpoint/ckpt_solver_base.py:89 — CheckpointSolverBase._linearize_graph has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · runtime_apply_pass._comm_spec_apply (cyclomatic 16) · ×1
  • runtime_apply_pass._comm_spec_apply (cyclomatic 16) colossalai/auto_parallel/passes/runtime_apply_pass.py:151 — runtime_apply_pass._comm_spec_apply has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · CostGraph._build_cost_graph (cyclomatic 16) · ×1
  • CostGraph._build_cost_graph (cyclomatic 16) colossalai/auto_parallel/tensor_shard/solver/cost_graph.py:41 — CostGraph._build_cost_graph has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · HybridParallelModule.__init__ (cyclomatic 16) · ×1
  • HybridParallelModule.__init__ (cyclomatic 16) colossalai/booster/plugin/hybrid_parallel_plugin.py:66 — HybridParallelModule.__init__ has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · HybridParallelPlugin.configure (cyclomatic 16) · ×1
  • HybridParallelPlugin.configure (cyclomatic 16) colossalai/booster/plugin/hybrid_parallel_plugin.py:1239 — HybridParallelPlugin.configure has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MoECheckpointIO.gather_from_sharded_optimizer_state (cyclomatic 16) · ×1
  • MoECheckpointIO.gather_from_sharded_optimizer_state (cyclomatic 16) colossalai/checkpoint_io/moe_checkpoint.py:291 — MoECheckpointIO.gather_from_sharded_optimizer_state has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MoECheckpointIO.save_sharded_optimizer (cyclomatic 16) · ×1
  • MoECheckpointIO.save_sharded_optimizer (cyclomatic 16) colossalai/checkpoint_io/moe_checkpoint.py:431 — MoECheckpointIO.save_sharded_optimizer has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · calc_pipeline_strategy.alpa_dp_impl (cyclomatic 16) · ×1
  • calc_pipeline_strategy.alpa_dp_impl (cyclomatic 16) colossalai/device/calc_pipeline_strategy.py:29 — calc_pipeline_strategy.alpa_dp_impl has cyclomatic complexity 16 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D1 · Cyclomatic Complexity · InferCheckpoint_io.load_sharded_model (cyclomatic 16) · ×1
  • InferCheckpoint_io.load_sharded_model (cyclomatic 16) colossalai/inference/core/plugin.py:35 — InferCheckpoint_io.load_sharded_model has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ChatGLM2InferenceForwards.chatglm_for_conditional_generation_forward (cyclomatic 16) · ×1
  • ChatGLM2InferenceForwards.chatglm_for_conditional_generation_forward (cyclomatic 16) colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:97 — ChatGLM2InferenceForwards.chatglm_for_conditional_generation_forward has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · train.main (cyclomatic 16) · ×1
  • train.main (cyclomatic 16) colossalai/legacy/moe/openmoe/train.py:205 — train.main has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ZeroBubbleVPipeScheduler.schedule_f (cyclomatic 16) · ×1
  • ZeroBubbleVPipeScheduler.schedule_f (cyclomatic 16) colossalai/pipeline/schedule/zero_bubble_pp.py:638 — ZeroBubbleVPipeScheduler.schedule_f has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ColoAttention.prepare_attn_kwargs (cyclomatic 16) · ×1
  • ColoAttention.prepare_attn_kwargs (cyclomatic 16) colossalai/shardformer/layer/attn.py:139 — ColoAttention.prepare_attn_kwargs has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ChatGLMModel.forward (cyclomatic 16) · ×1
  • ChatGLMModel.forward (cyclomatic 16) colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py:916 — ChatGLMModel.forward has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ShapeConsistencyManager.get_all_all_to_all_spec (cyclomatic 16) · ×1
  • ShapeConsistencyManager.get_all_all_to_all_spec (cyclomatic 16) colossalai/tensor/shape_consistency.py:146 — ShapeConsistencyManager.get_all_all_to_all_spec has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · GeminiDDP.grad_handle (cyclomatic 16) · ×1
  • GeminiDDP.grad_handle (cyclomatic 16) colossalai/zero/gemini/gemini_ddp.py:358 — GeminiDDP.grad_handle has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · LowLevelZeroOptimizer.state_dict (cyclomatic 16) · ×1
  • LowLevelZeroOptimizer.state_dict (cyclomatic 16) colossalai/zero/low_level/low_level_optim.py:762 — LowLevelZeroOptimizer.state_dict has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D17 · Explicit Debt · TodoComment repeated across 15 files · ×1
  • TodoComment repeated across 15 files colossalai/shardformer/modeling/_bert_tf4.py:119 — The identical TodoComment appears in 15 files (31 occurrences) — almost certainly one boilerplate line from a single migration or decision, not 31 independent debts. Fix the systemic cause once rather than file-by-file. Text: "# TODO(jianghai): left the recording kv-value tensors as () or None type, this feature may be added in the future.". Source code is not a task system: track the cleanup where tasks live. (Every occurrence still counts toward the score and metrics.)
D17 · Explicit Debt · XxxComment · ×1
  • XxxComment colossalai/inference/modeling/models/glide_llama.py:322 — # XXX — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
D2 · Cognitive Complexity · BaseProducer.loop (cognitive 125) · ×1
  • BaseProducer.loop (cognitive 125) applications/ColossalChat/coati/distributed/zero_bubble/producer.py:212 — BaseProducer.loop has cognitive complexity 125 (threshold 15). Drivers by points: if/else 20 (78 pts), loops 8 (30 pts), boolean chains 10, ternaries 1 (7 pts) (nesting depth added 86). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BaseProducer.loop (cognitive 122) · ×1
  • BaseProducer.loop (cognitive 122) applications/ColossalChat/coati/distributed/producer.py:218 — BaseProducer.loop has cognitive complexity 122 (threshold 15). Drivers by points: if/else 23 (78 pts), loops 8 (29 pts), boolean chains 8, ternaries 1 (7 pts) (nesting depth added 82). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PipelineGraph.try_v_schedule (cognitive 114) · ×1
  • PipelineGraph.try_v_schedule (cognitive 114) colossalai/pipeline/schedule/v_schedule.py:81 — PipelineGraph.try_v_schedule has cognitive complexity 114 (threshold 15). Drivers by points: if/else 22 (60 pts), loops 21 (42 pts), boolean chains 12 (nesting depth added 59). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BaseConsumer.loop (cognitive 108) · ×1
  • BaseConsumer.loop (cognitive 108) applications/ColossalChat/coati/distributed/consumer.py:149 — BaseConsumer.loop has cognitive complexity 108 (threshold 15). Drivers by points: if/else 17 (64 pts), loops 7 (25 pts), ternaries 2 (11 pts), boolean chains 8 (nesting depth added 74). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · train.train (cognitive 106) · ×1
  • train.train (cognitive 106) applications/Colossal-LLaMA/train.py:40 — train.train has cognitive complexity 106 (threshold 15). Drivers by points: if/else 31 (78 pts), boolean chains 9, ternaries 6 (8 pts), loops 3 (7 pts), error handling 2 (4 pts) (nesting depth added 55). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DistributedAdaFactor.step (cognitive 104) · ×1
  • DistributedAdaFactor.step (cognitive 104) colossalai/nn/optimizer/distributed_adafactor.py:286 — DistributedAdaFactor.step has cognitive complexity 104 (threshold 15). Drivers by points: if/else 31 (101 pts), loops 2 (3 pts) (nesting depth added 71). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · DistributedCAME.step (cognitive 102) · ×1
  • DistributedCAME.step (cognitive 102) colossalai/nn/optimizer/distributed_came.py:333 — DistributedCAME.step has cognitive complexity 102 (threshold 15). Drivers by points: if/else 31 (99 pts), loops 2 (3 pts) (nesting depth added 69). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · InterleavedPipelineSchedule.forward_backward_step (cognitive 89) · ×1
  • InterleavedPipelineSchedule.forward_backward_step (cognitive 89) colossalai/legacy/engine/schedule/_pipeline_schedule.py:560 — InterleavedPipelineSchedule.forward_backward_step has cognitive complexity 89 (threshold 15). Drivers by points: if/else 35 (66 pts), ternaries 5 (12 pts), loops 4 (8 pts), boolean chains 3 (nesting depth added 42). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · generate_leaderboard_and_send_to_lark.get_discussion_comments (cognitive 87) · ×1
  • generate_leaderboard_and_send_to_lark.get_discussion_comments (cognitive 87) .github/workflows/scripts/generate_leaderboard_and_send_to_lark.py:141 — generate_leaderboard_and_send_to_lark.get_discussion_comments has cognitive complexity 87 (threshold 15). Drivers by points: if/else 19 (70 pts), loops 6 (17 pts) (nesting depth added 62). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · activation_checkpoint_codegen.emit_code_with_activation_checkpoint (cognitive 86) · ×1
  • activation_checkpoint_codegen.emit_code_with_activation_checkpoint (cognitive 86) colossalai/fx/codegen/activation_checkpoint_codegen.py:490 — activation_checkpoint_codegen.emit_code_with_activation_checkpoint has cognitive complexity 86 (threshold 15). Drivers by points: if/else 19 (67 pts), loops 7 (18 pts), boolean chains 1 (nesting depth added 59). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · GPT2PipelineForwards.gpt2_model_forward (cognitive 86) · ×1
  • GPT2PipelineForwards.gpt2_model_forward (cognitive 86) colossalai/shardformer/modeling/gpt2.py:116 — GPT2PipelineForwards.gpt2_model_forward has cognitive complexity 86 (threshold 15). Drivers by points: if/else 38 (60 pts), ternaries 8 (14 pts), boolean chains 11, loops 1 (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OPTPipelineForwards.opt_model_forward (cognitive 86) · ×1
  • OPTPipelineForwards.opt_model_forward (cognitive 86) colossalai/shardformer/modeling/opt.py:64 — OPTPipelineForwards.opt_model_forward has cognitive complexity 86 (threshold 15). Drivers by points: if/else 34 (53 pts), ternaries 16 (26 pts), boolean chains 5, loops 2 (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DistGaloreAdamW.step (cognitive 85) · ×1
  • DistGaloreAdamW.step (cognitive 85) colossalai/nn/optimizer/distributed_galore.py:143 — DistGaloreAdamW.step has cognitive complexity 85 (threshold 15). Drivers by points: if/else 21 (79 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 59). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · pretrained.new_from_pretrained (cognitive 84) · ×1
  • pretrained.new_from_pretrained (cognitive 84) colossalai/lazy/pretrained.py:36 — pretrained.new_from_pretrained has cognitive complexity 84 (threshold 15). Drivers by points: if/else 36 (63 pts), boolean chains 10, error handling 3 (8 pts), ternaries 2 (3 pts) (nesting depth added 33). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BertPipelineForwards.bert_model_forward (cognitive 84) · ×1
  • BertPipelineForwards.bert_model_forward (cognitive 84) colossalai/shardformer/modeling/_bert_tf4.py:42 — BertPipelineForwards.bert_model_forward has cognitive complexity 84 (threshold 15). Drivers by points: if/else 36 (54 pts), ternaries 16 (21 pts), boolean chains 8, loops 1 (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · WorkerBase._consume_work_item_by_phase (cognitive 82) · ×1
  • WorkerBase._consume_work_item_by_phase (cognitive 82) colossalai/legacy/pipeline/rpc/_pipeline_base.py:804 — WorkerBase._consume_work_item_by_phase has cognitive complexity 82 (threshold 15). Drivers by points: if/else 29 (66 pts), loops 4 (12 pts), boolean chains 4 (nesting depth added 45). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · LlamaPipelineForwards.llama_model_forward (cognitive 80) · ×1
  • LlamaPipelineForwards.llama_model_forward (cognitive 80) colossalai/shardformer/modeling/_llama_tf4.py:44 — LlamaPipelineForwards.llama_model_forward has cognitive complexity 80 (threshold 15). Drivers by points: if/else 36 (53 pts), ternaries 10 (14 pts), boolean chains 12, loops 1 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BaseConsumer.loop (cognitive 78) · ×1
  • BaseConsumer.loop (cognitive 78) applications/ColossalChat/coati/distributed/zero_bubble/consumer.py:160 — BaseConsumer.loop has cognitive complexity 78 (threshold 15). Drivers by points: if/else 10 (41 pts), loops 7 (23 pts), boolean chains 9, ternaries 1 (5 pts) (nesting depth added 51). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · LlamaPipelineForwards.llama_model_forward (cognitive 78) · ×1
  • LlamaPipelineForwards.llama_model_forward (cognitive 78) colossalai/shardformer/modeling/_llama_tf5.py:79 — LlamaPipelineForwards.llama_model_forward has cognitive complexity 78 (threshold 15). Drivers by points: if/else 32 (49 pts), boolean chains 15, ternaries 10 (13 pts), loops 1 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · WhisperPipelineForwards.whisper_decoder_forward (cognitive 77) · ×1
  • WhisperPipelineForwards.whisper_decoder_forward (cognitive 77) colossalai/shardformer/modeling/_whisper_tf4.py:601 — WhisperPipelineForwards.whisper_decoder_forward has cognitive complexity 77 (threshold 15). Drivers by points: if/else 23 (42 pts), ternaries 16 (28 pts), boolean chains 5, loops 2 (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GRPOConsumer.step (cognitive 75) · ×1
  • GRPOConsumer.step (cognitive 75) applications/ColossalChat/coati/distributed/grpo_consumer.py:174 — GRPOConsumer.step has cognitive complexity 75 (threshold 15). Drivers by points: if/else 27 (56 pts), boolean chains 11, ternaries 3 (7 pts), loops 1 (nesting depth added 33). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · initialize.initialize (cognitive 74) · ×1
  • initialize.initialize (cognitive 74) colossalai/legacy/initialize.py:242 — initialize.initialize has cognitive complexity 74 (threshold 15). Drivers by points: if/else 38 (66 pts), boolean chains 6, loops 1 (2 pts) (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Qwen2PipelineForwards.qwen2_model_forward (cognitive 73) · ×1
  • Qwen2PipelineForwards.qwen2_model_forward (cognitive 73) colossalai/shardformer/modeling/_qwen2_tf4.py:42 — Qwen2PipelineForwards.qwen2_model_forward has cognitive complexity 73 (threshold 15). Drivers by points: if/else 31 (47 pts), ternaries 12 (19 pts), boolean chains 6, loops 1 (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Qwen3PipelineForwards.qwen3_model_forward (cognitive 73) · ×1
  • Qwen3PipelineForwards.qwen3_model_forward (cognitive 73) colossalai/shardformer/modeling/_qwen3_tf4.py:42 — Qwen3PipelineForwards.qwen3_model_forward has cognitive complexity 73 (threshold 15). Drivers by points: if/else 31 (47 pts), ternaries 12 (19 pts), boolean chains 6, loops 1 (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GRPOConsumer.step (cognitive 70) · ×1
  • GRPOConsumer.step (cognitive 70) applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py:164 — GRPOConsumer.step has cognitive complexity 70 (threshold 15). Drivers by points: if/else 24 (52 pts), boolean chains 10, ternaries 3 (7 pts), loops 1 (nesting depth added 32). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · BertPipelineForwards.bert_model_forward (cognitive 70) · ×1
  • BertPipelineForwards.bert_model_forward (cognitive 70) colossalai/shardformer/modeling/_bert_tf5.py:44 — BertPipelineForwards.bert_model_forward has cognitive complexity 70 (threshold 15). Drivers by points: if/else 33 (46 pts), ternaries 13 (16 pts), boolean chains 7, loops 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BloomPipelineForwards.bloom_model_forward (cognitive 70) · ×1
  • BloomPipelineForwards.bloom_model_forward (cognitive 70) colossalai/shardformer/modeling/bloom.py:109 — BloomPipelineForwards.bloom_model_forward has cognitive complexity 70 (threshold 15). Drivers by points: if/else 34 (49 pts), ternaries 10 (14 pts), boolean chains 6, loops 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CommandPipelineForwards.command_model_forward (cognitive 68) · ×1
  • CommandPipelineForwards.command_model_forward (cognitive 68) colossalai/shardformer/modeling/command.py:39 — CommandPipelineForwards.command_model_forward has cognitive complexity 68 (threshold 15). Drivers by points: if/else 33 (47 pts), ternaries 9 (14 pts), boolean chains 6, loops 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · split_module.split_module (cognitive 67) · ×1
  • split_module.split_module (cognitive 67) colossalai/fx/passes/split_module.py:40 — split_module.split_module has cognitive complexity 67 (threshold 15). Drivers by points: if/else 19 (41 pts), loops 13 (20 pts), ternaries 2 (6 pts) (nesting depth added 33). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PipelineGraph.get_v_schedule (cognitive 67) · ×1
  • PipelineGraph.get_v_schedule (cognitive 67) colossalai/pipeline/schedule/v_schedule.py:318 — PipelineGraph.get_v_schedule has cognitive complexity 67 (threshold 15). Drivers by points: if/else 13 (36 pts), loops 11 (18 pts), boolean chains 7, ternaries 2 (6 pts) (nesting depth added 34). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PipelinableContext.to_layer_list (cognitive 66) · ×1
  • PipelinableContext.to_layer_list (cognitive 66) colossalai/legacy/pipeline/pipelinable.py:122 — PipelinableContext.to_layer_list has cognitive complexity 66 (threshold 15). Drivers by points: if/else 14 (43 pts), loops 6 (22 pts), boolean chains 1 (nesting depth added 45). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · CheckpointSolverRotor._annotate_from_sequence (cognitive 65) · ×1
  • CheckpointSolverRotor._annotate_from_sequence (cognitive 65) colossalai/auto_parallel/checkpoint/ckpt_solver_rotor.py:361 — CheckpointSolverRotor._annotate_from_sequence has cognitive complexity 65 (threshold 15). Drivers by points: loops 15 (51 pts), if/else 6 (14 pts) (nesting depth added 44). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · RegionManager._linearize_graph (cognitive 65) · ×1
  • RegionManager._linearize_graph (cognitive 65) colossalai/auto_parallel/offload/region_manager.py:271 — RegionManager._linearize_graph has cognitive complexity 65 (threshold 15). Drivers by points: if/else 18 (50 pts), boolean chains 6, loops 3 (6 pts), error handling 1 (3 pts) (nesting depth added 37). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MixtralPipelineForwards.mixtral_model_forward (cognitive 65) · ×1
  • MixtralPipelineForwards.mixtral_model_forward (cognitive 65) colossalai/shardformer/modeling/_mixtral_tf4.py:183 — MixtralPipelineForwards.mixtral_model_forward has cognitive complexity 65 (threshold 15). Drivers by points: if/else 29 (40 pts), ternaries 13 (19 pts), boolean chains 5, loops 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · T5PipelineForwards.t5_stack_forward (cognitive 64) · ×1
  • T5PipelineForwards.t5_stack_forward (cognitive 64) colossalai/shardformer/modeling/t5.py:32 — T5PipelineForwards.t5_stack_forward has cognitive complexity 64 (threshold 15). Drivers by points: if/else 29 (42 pts), ternaries 7 (13 pts), boolean chains 8, loops 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ChatGLMPipelineForwards.chatglm_model_forward (cognitive 63) · ×1
  • ChatGLMPipelineForwards.chatglm_model_forward (cognitive 63) colossalai/shardformer/modeling/chatglm2.py:93 — ChatGLMPipelineForwards.chatglm_model_forward has cognitive complexity 63 (threshold 15). Drivers by points: if/else 32 (50 pts), boolean chains 7, ternaries 5, loops 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · WorkerBase._get_real_args_kwargs_fwd (cognitive 59) · ×1
  • WorkerBase._get_real_args_kwargs_fwd (cognitive 59) colossalai/legacy/pipeline/rpc/_pipeline_base.py:653 — WorkerBase._get_real_args_kwargs_fwd has cognitive complexity 59 (threshold 15). Drivers by points: if/else 17 (47 pts), loops 2 (12 pts) (nesting depth added 40). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · Solver._call_solver_serialized_args (cognitive 58) · ×1
  • Solver._call_solver_serialized_args (cognitive 58) colossalai/auto_parallel/tensor_shard/solver/solver.py:211 — Solver._call_solver_serialized_args has cognitive complexity 58 (threshold 15). Drivers by points: if/else 17 (30 pts), loops 18 (24 pts), boolean chains 3, ternaries 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TraceFlow._get_prepose_nodes (cognitive 56) · ×1
  • TraceFlow._get_prepose_nodes (cognitive 56) colossalai/autochunk/trace_flow.py:245 — TraceFlow._get_prepose_nodes has cognitive complexity 56 (threshold 15). Drivers by points: if/else 13 (40 pts), loops 7 (15 pts), boolean chains 1 (nesting depth added 35). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DeepseekPipelineForwards.deepseek_model_forward (cognitive 55) · ×1
  • DeepseekPipelineForwards.deepseek_model_forward (cognitive 55) colossalai/shardformer/modeling/deepseek.py:286 — DeepseekPipelineForwards.deepseek_model_forward has cognitive complexity 55 (threshold 15). Drivers by points: if/else 25 (35 pts), ternaries 10 (15 pts), boolean chains 4, loops 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GeminiDDP.state_dict_shard (cognitive 55) · ×1
  • GeminiDDP.state_dict_shard (cognitive 55) colossalai/zero/gemini/gemini_ddp.py:900 — GeminiDDP.state_dict_shard has cognitive complexity 55 (threshold 15). Drivers by points: if/else 15 (40 pts), ternaries 3 (11 pts), loops 3, boolean chains 1 (nesting depth added 33). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GeminiOptimizer.collect_states (cognitive 55) · ×1
  • GeminiOptimizer.collect_states (cognitive 55) colossalai/zero/gemini/gemini_optimizer.py:421 — GeminiOptimizer.collect_states has cognitive complexity 55 (threshold 15). Drivers by points: if/else 18 (41 pts), loops 5 (10 pts), ternaries 3, boolean chains 1 (nesting depth added 28). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · TensorDetector.collect_tensors_state (cognitive 54) · ×1
  • TensorDetector.collect_tensors_state (cognitive 54) colossalai/utils/tensor_detector/tensor_detector.py:65 — TensorDetector.collect_tensors_state has cognitive complexity 54 (threshold 15). Drivers by points: if/else 11 (41 pts), loops 2 (7 pts), boolean chains 6 (nesting depth added 35). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · NodeHandler.register_strategy (cognitive 52) · ×1
  • NodeHandler.register_strategy (cognitive 52) colossalai/auto_parallel/tensor_shard/node_handler/node_handler.py:162 — NodeHandler.register_strategy has cognitive complexity 52 (threshold 15). Drivers by points: if/else 10 (27 pts), loops 9 (19 pts), boolean chains 6 (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · pixart_alpha.pixart_alpha_forward (cognitive 52) · ×1
  • pixart_alpha.pixart_alpha_forward (cognitive 52) colossalai/inference/modeling/models/pixart_alpha.py:23 — pixart_alpha.pixart_alpha_forward has cognitive complexity 52 (threshold 15). Drivers by points: if/else 22 (34 pts), ternaries 3 (10 pts), boolean chains 7, loops 1 (nesting depth added 19). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D2 · Cognitive Complexity · _deepseek_v3_tf4.deepseek_v3_model_forward (cognitive 52) · ×1
  • _deepseek_v3_tf4.deepseek_v3_model_forward (cognitive 52) colossalai/shardformer/modeling/_deepseek_v3_tf4.py:146 — _deepseek_v3_tf4.deepseek_v3_model_forward has cognitive complexity 52 (threshold 15). Drivers by points: if/else 23 (30 pts), ternaries 10 (15 pts), boolean chains 6, loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · utils.get_lora_state_dict (cognitive 51) · ×1
  • utils.get_lora_state_dict (cognitive 51) colossalai/checkpoint_io/utils.py:1049 — utils.get_lora_state_dict has cognitive complexity 51 (threshold 15). Drivers by points: if/else 19 (39 pts), boolean chains 8, loops 2 (4 pts) (nesting depth added 22). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · MistralForwards.mistral_model_forward (cognitive 51) · ×1
  • MistralForwards.mistral_model_forward (cognitive 51) colossalai/shardformer/modeling/mistral.py:25 — MistralForwards.mistral_model_forward has cognitive complexity 51 (threshold 15). Drivers by points: if/else 25 (33 pts), ternaries 7 (12 pts), boolean chains 5, loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OpenMoePipelineForwards.openmoe_model_forward (cognitive 50) · ×1
  • OpenMoePipelineForwards.openmoe_model_forward (cognitive 50) colossalai/legacy/moe/openmoe/model/openmoe_policy.py:231 — OpenMoePipelineForwards.openmoe_model_forward has cognitive complexity 50 (threshold 15). Drivers by points: if/else 23 (30 pts), ternaries 11 (15 pts), boolean chains 4, loops 1 (nesting depth added 11). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · ShapeConsistencyManager.get_all_all_to_all_spec (cognitive 50) · ×1
  • ShapeConsistencyManager.get_all_all_to_all_spec (cognitive 50) colossalai/tensor/shape_consistency.py:146 — ShapeConsistencyManager.get_all_all_to_all_spec has cognitive complexity 50 (threshold 15). Drivers by points: if/else 15 (39 pts), loops 3 (6 pts), error handling 1 (3 pts), boolean chains 2 (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MixtralPipelineForwards.mixtral_model_forward (cognitive 49) · ×1
  • MixtralPipelineForwards.mixtral_model_forward (cognitive 49) colossalai/shardformer/modeling/_mixtral_tf5.py:528 — MixtralPipelineForwards.mixtral_model_forward has cognitive complexity 49 (threshold 15). Drivers by points: if/else 23 (29 pts), ternaries 12 (15 pts), boolean chains 5 (nesting depth added 9). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · Qwen2PipelineForwards.qwen2_model_forward (cognitive 49) · ×1
  • Qwen2PipelineForwards.qwen2_model_forward (cognitive 49) colossalai/shardformer/modeling/_qwen2_tf5.py:41 — Qwen2PipelineForwards.qwen2_model_forward has cognitive complexity 49 (threshold 15). Drivers by points: if/else 21 (30 pts), ternaries 7 (11 pts), boolean chains 7, loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Qwen3PipelineForwards.qwen3_model_forward (cognitive 49) · ×1
  • Qwen3PipelineForwards.qwen3_model_forward (cognitive 49) colossalai/shardformer/modeling/_qwen3_tf5.py:42 — Qwen3PipelineForwards.qwen3_model_forward has cognitive complexity 49 (threshold 15). Drivers by points: if/else 21 (30 pts), ternaries 7 (11 pts), boolean chains 7, loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · p2p._send_recv_serialization_object (cognitive 48) · ×1
  • p2p._send_recv_serialization_object (cognitive 48) REDACTED:273 — p2p._send_recv_serialization_object has cognitive complexity 48 (threshold 15). Drivers by points: if/else 25 (39 pts), boolean chains 5, loops 2 (4 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FalconPipelineForwards.falcon_model_forward (cognitive 48) · ×1
  • FalconPipelineForwards.falcon_model_forward (cognitive 48) colossalai/shardformer/modeling/falcon.py:188 — FalconPipelineForwards.falcon_model_forward has cognitive complexity 48 (threshold 15). Drivers by points: if/else 22 (32 pts), ternaries 9 (12 pts), boolean chains 3, loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DPOTrainer._train (cognitive 47) · ×1
  • DPOTrainer._train (cognitive 47) applications/ColossalChat/coati/trainer/dpo.py:123 — DPOTrainer._train has cognitive complexity 47 (threshold 15). Drivers by points: if/else 13 (34 pts), ternaries 2 (6 pts), loops 2 (4 pts), boolean chains 3 (nesting depth added 27). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · BloomInferenceForwards.bloom_model_forward (cognitive 47) · ×1
  • BloomInferenceForwards.bloom_model_forward (cognitive 47) colossalai/legacy/inference/tensor_parallel/modeling/bloom.py:70 — BloomInferenceForwards.bloom_model_forward has cognitive complexity 47 (threshold 15). Drivers by points: if/else 25 (32 pts), ternaries 8 (10 pts), boolean chains 4, loops 1 (nesting depth added 9). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · module_utils.check_colo_module (cognitive 47) · ×1
  • module_utils.check_colo_module (cognitive 47) colossalai/legacy/nn/parallel/layers/module_utils.py:36 — module_utils.check_colo_module has cognitive complexity 47 (threshold 15). Drivers by points: if/else 12 (36 pts), loops 4 (11 pts) (nesting depth added 31). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · common.clip_grad_norm_fp32 (cognitive 47) · ×1
  • common.clip_grad_norm_fp32 (cognitive 47) colossalai/legacy/utils/common.py:254 — common.clip_grad_norm_fp32 has cognitive complexity 47 (threshold 15). Drivers by points: if/else 21 (35 pts), boolean chains 6, loops 3 (6 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · T5BasePolicy.get_held_layers (cognitive 47) · ×1
  • T5BasePolicy.get_held_layers (cognitive 47) colossalai/shardformer/policies/t5.py:501 — T5BasePolicy.get_held_layers has cognitive complexity 47 (threshold 15). Drivers by points: if/else 16 (34 pts), boolean chains 6, loops 2 (6 pts), ternaries 1 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LayoutConverter.all_to_all_transform_layout (cognitive 47) · ×1
  • LayoutConverter.all_to_all_transform_layout (cognitive 47) colossalai/tensor/d_tensor/layout_converter.py:149 — LayoutConverter.all_to_all_transform_layout has cognitive complexity 47 (threshold 15). Drivers by points: if/else 15 (39 pts), error handling 1 (3 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LowLevelZeroOptimizer.state_dict_shard (cognitive 47) · ×1
  • LowLevelZeroOptimizer.state_dict_shard (cognitive 47) colossalai/zero/low_level/low_level_optim.py:836 — LowLevelZeroOptimizer.state_dict_shard has cognitive complexity 47 (threshold 15). Drivers by points: if/else 9 (32 pts), loops 5 (9 pts), boolean chains 6 (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CheckpointSolverRotor._compute_table (cognitive 46) · ×1
  • CheckpointSolverRotor._compute_table (cognitive 46) colossalai/auto_parallel/checkpoint/ckpt_solver_rotor.py:209 — CheckpointSolverRotor._compute_table has cognitive complexity 46 (threshold 15). Drivers by points: if/else 12 (36 pts), loops 5 (9 pts), boolean chains 1 (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GenerateSchedule.generate_step_broadcast (cognitive 46) · ×1
  • GenerateSchedule.generate_step_broadcast (cognitive 46) colossalai/pipeline/schedule/generate.py:348 — GenerateSchedule.generate_step_broadcast has cognitive complexity 46 (threshold 15). Drivers by points: if/else 11 (35 pts), boolean chains 6, loops 2 (3 pts), ternaries 1 (2 pts) (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GPTJPipelineForwards.gptj_model_forward (cognitive 46) · ×1
  • GPTJPipelineForwards.gptj_model_forward (cognitive 46) colossalai/shardformer/modeling/gptj.py:80 — GPTJPipelineForwards.gptj_model_forward has cognitive complexity 46 (threshold 15). Drivers by points: if/else 27 (38 pts), ternaries 5 (6 pts), boolean chains 1, loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LowLevelZeroOptimizer.step (cognitive 46) · ×1
  • LowLevelZeroOptimizer.step (cognitive 46) colossalai/zero/low_level/low_level_optim.py:537 — LowLevelZeroOptimizer.step has cognitive complexity 46 (threshold 15). Drivers by points: if/else 12 (29 pts), loops 6 (9 pts), error handling 1 (4 pts), ternaries 1 (3 pts), boolean chains 1 (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · llama.llama_model_forward (cognitive 45) · ×1
  • llama.llama_model_forward (cognitive 45) colossalai/legacy/inference/quant/smoothquant/models/llama.py:559 — llama.llama_model_forward has cognitive complexity 45 (threshold 15). Drivers by points: if/else 22 (27 pts), ternaries 11 (15 pts), boolean chains 2, loops 1 (nesting depth added 9). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · NaiveExperienceMaker.make_experience (cognitive 44) · ×1
  • NaiveExperienceMaker.make_experience (cognitive 44) applications/ColossalChat/coati/experience_maker/naive.py:87 — NaiveExperienceMaker.make_experience has cognitive complexity 44 (threshold 15). Drivers by points: if/else 19 (32 pts), loops 5 (10 pts), boolean chains 2 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · HybridParallelPlugin.__init__ (cognitive 44) · ×1
  • HybridParallelPlugin.__init__ (cognitive 44) colossalai/booster/plugin/hybrid_parallel_plugin.py:947 — HybridParallelPlugin.__init__ has cognitive complexity 44 (threshold 15). Drivers by points: if/else 21 (31 pts), boolean chains 8, ternaries 2 (5 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · fx.find_output_in_partition (cognitive 44) · ×1
  • fx.find_output_in_partition (cognitive 44) colossalai/legacy/pipeline/middleware/adaptor/fx.py:57 — fx.find_output_in_partition has cognitive complexity 44 (threshold 15). Drivers by points: if/else 7 (28 pts), loops 5 (16 pts) (nesting depth added 32). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ShardedModelV2._colo_load_from_state_dict (cognitive 44) · ×1
  • ShardedModelV2._colo_load_from_state_dict (cognitive 44) colossalai/legacy/zero/sharded_model/sharded_model_v2.py:481 — ShardedModelV2._colo_load_from_state_dict has cognitive complexity 44 (threshold 15). Drivers by points: if/else 13 (31 pts), boolean chains 5, error handling 1 (4 pts), loops 3 (4 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · HybridParallelCheckpointIO.save_sharded_optimizer (cognitive 43) · ×1
  • HybridParallelCheckpointIO.save_sharded_optimizer (cognitive 43) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:516 — HybridParallelCheckpointIO.save_sharded_optimizer has cognitive complexity 43 (threshold 15). Drivers by points: if/else 19 (30 pts), loops 2 (7 pts), boolean chains 6 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GeminiDDP._load_from_state_dict (cognitive 43) · ×1
  • GeminiDDP._load_from_state_dict (cognitive 43) colossalai/zero/gemini/gemini_ddp.py:644 — GeminiDDP._load_from_state_dict has cognitive complexity 43 (threshold 15). Drivers by points: if/else 14 (26 pts), loops 8 (11 pts), ternaries 2 (4 pts), boolean chains 2 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LowLevelZeroOptimizer.state_dict (cognitive 43) · ×1
  • LowLevelZeroOptimizer.state_dict (cognitive 43) colossalai/zero/low_level/low_level_optim.py:762 — LowLevelZeroOptimizer.state_dict has cognitive complexity 43 (threshold 15). Drivers by points: if/else 9 (32 pts), loops 3 (6 pts), boolean chains 5 (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · HuggingFaceModel.inference (cognitive 42) · ×1
  • HuggingFaceModel.inference (cognitive 42) REDACTED:334 — HuggingFaceModel.inference has cognitive complexity 42 (threshold 15). Drivers by points: if/else 14 (37 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · vLLMModel.inference (cognitive 42) · ×1
  • vLLMModel.inference (cognitive 42) REDACTED:217 — vLLMModel.inference has cognitive complexity 42 (threshold 15). Drivers by points: if/else 14 (37 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ColoTracer.trace (cognitive 42) · ×1
  • ColoTracer.trace (cognitive 42) colossalai/fx/tracer/tracer.py:317 — ColoTracer.trace has cognitive complexity 42 (threshold 15). Drivers by points: if/else 13 (26 pts), loops 6 (15 pts), boolean chains 1 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OpenMoeModel.forward (cognitive 42) · ×1
  • OpenMoeModel.forward (cognitive 42) colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:705 — OpenMoeModel.forward has cognitive complexity 42 (threshold 15). Drivers by points: if/else 17 (23 pts), ternaries 11 (15 pts), boolean chains 3, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · WorkerBase._get_real_args_kwargs_bwd (cognitive 42) · ×1
  • WorkerBase._get_real_args_kwargs_bwd (cognitive 42) colossalai/legacy/pipeline/rpc/_pipeline_base.py:715 — WorkerBase._get_real_args_kwargs_bwd has cognitive complexity 42 (threshold 15). Drivers by points: if/else 11 (28 pts), loops 4 (14 pts) (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Adafactor.step (cognitive 42) · ×1
  • Adafactor.step (cognitive 42) colossalai/nn/optimizer/adafactor.py:86 — Adafactor.step has cognitive complexity 42 (threshold 15). Drivers by points: if/else 15 (39 pts), loops 2 (3 pts) (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PaddingParallelModule._load_from_state_dict (cognitive 42) · ×1
  • PaddingParallelModule._load_from_state_dict (cognitive 42) colossalai/shardformer/layer/parallel_module.py:245 — PaddingParallelModule._load_from_state_dict has cognitive complexity 42 (threshold 15). Drivers by points: if/else 13 (30 pts), boolean chains 5, loops 3 (4 pts), error handling 1 (3 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · _meta_regist_12.meta_index_Tensor (cognitive 41) · ×1
  • _meta_regist_12.meta_index_Tensor (cognitive 41) colossalai/fx/_meta_regist_12.py:435 — _meta_regist_12.meta_index_Tensor has cognitive complexity 41 (threshold 15). Drivers by points: if/else 14 (29 pts), loops 7 (12 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · WhisperPipelineForwards.whisper_encoder_forward (cognitive 41) · ×1
  • WhisperPipelineForwards.whisper_encoder_forward (cognitive 41) colossalai/shardformer/modeling/_whisper_tf4.py:472 — WhisperPipelineForwards.whisper_encoder_forward has cognitive complexity 41 (threshold 15). Drivers by points: if/else 13 (23 pts), ternaries 7 (15 pts), boolean chains 2, loops 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LowLevelZeroOptimizer._run_reduction (cognitive 41) · ×1
  • LowLevelZeroOptimizer._run_reduction (cognitive 41) colossalai/zero/low_level/low_level_optim.py:337 — LowLevelZeroOptimizer._run_reduction has cognitive complexity 41 (threshold 15). Drivers by points: if/else 12 (26 pts), ternaries 2 (8 pts), loops 3 (7 pts) (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ClosedToConstantLengthSplicedDataset.__iter__ (cognitive 40) · ×1
  • ClosedToConstantLengthSplicedDataset.__iter__ (cognitive 40) applications/Colossal-LLaMA/colossal_llama/dataset/spliced_and_tokenized_dataset.py:229 — ClosedToConstantLengthSplicedDataset.__iter__ has cognitive complexity 40 (threshold 15). Drivers by points: if/else 11 (29 pts), loops 4 (7 pts), error handling 1 (3 pts), boolean chains 1 (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CostGraph._build_cost_graph (cognitive 40) · ×1
  • CostGraph._build_cost_graph (cognitive 40) colossalai/auto_parallel/tensor_shard/solver/cost_graph.py:41 — CostGraph._build_cost_graph has cognitive complexity 40 (threshold 15). Drivers by points: if/else 8 (22 pts), loops 7 (17 pts), boolean chains 1 (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · HybridParallelCheckpointIO.save_unsharded_optimizer (cognitive 40) · ×1
  • HybridParallelCheckpointIO.save_unsharded_optimizer (cognitive 40) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:909 — HybridParallelCheckpointIO.save_unsharded_optimizer has cognitive complexity 40 (threshold 15). Drivers by points: if/else 14 (28 pts), loops 4 (12 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FusedLAMB.step (cognitive 40) · ×1
  • FusedLAMB.step (cognitive 40) colossalai/nn/optimizer/fused_lamb.py:105 — FusedLAMB.step has cognitive complexity 40 (threshold 15). Drivers by points: if/else 15 (30 pts), loops 4 (6 pts), ternaries 2 (4 pts) (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GaLoreAdamW8bit.step (cognitive 40) · ×1
  • GaLoreAdamW8bit.step (cognitive 40) colossalai/nn/optimizer/galore.py:235 — GaLoreAdamW8bit.step has cognitive complexity 40 (threshold 15). Drivers by points: if/else 13 (36 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Quantizer.find_params (cognitive 39) · ×1
  • Quantizer.find_params (cognitive 39) applications/ColossalChat/coati/quant/llama_gptq/quant.py:31 — Quantizer.find_params has cognitive complexity 39 (threshold 15). Drivers by points: if/else 20 (31 pts), ternaries 2 (6 pts), loops 1 (2 pts) (nesting depth added 16). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D2 · Cognitive Complexity · DPOTrainer._eval (cognitive 39) · ×1
  • DPOTrainer._eval (cognitive 39) applications/ColossalChat/coati/trainer/dpo.py:406 — DPOTrainer._eval has cognitive complexity 39 (threshold 15). Drivers by points: if/else 11 (23 pts), loops 4 (9 pts), ternaries 2 (6 pts), boolean chains 1 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AsynGreedySolver._call_solver (cognitive 39) · ×1
  • AsynGreedySolver._call_solver (cognitive 39) colossalai/auto_parallel/offload/solver.py:320 — AsynGreedySolver._call_solver has cognitive complexity 39 (threshold 15). Drivers by points: if/else 9 (30 pts), loops 3 (7 pts), boolean chains 2 (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · runtime_apply_pass._comm_spec_apply (cognitive 39) · ×1
  • runtime_apply_pass._comm_spec_apply (cognitive 39) colossalai/auto_parallel/passes/runtime_apply_pass.py:151 — runtime_apply_pass._comm_spec_apply has cognitive complexity 39 (threshold 15). Drivers by points: if/else 10 (31 pts), loops 3 (7 pts), boolean chains 1 (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · HybridParallelCheckpointIO.save_sharded_model (cognitive 39) · ×1
  • HybridParallelCheckpointIO.save_sharded_model (cognitive 39) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:252 — HybridParallelCheckpointIO.save_sharded_model has cognitive complexity 39 (threshold 15). Drivers by points: if/else 17 (27 pts), loops 2 (7 pts), boolean chains 5 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PipelineSchedule.forward_backward_step (cognitive 39) · ×1
  • PipelineSchedule.forward_backward_step (cognitive 39) colossalai/legacy/engine/schedule/_pipeline_schedule.py:321 — PipelineSchedule.forward_backward_step has cognitive complexity 39 (threshold 15). Drivers by points: if/else 18 (29 pts), loops 4 (8 pts), boolean chains 2 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PipelineGraph.print_details (cognitive 39) · ×1
  • PipelineGraph.print_details (cognitive 39) colossalai/pipeline/schedule/v_schedule.py:290 — PipelineGraph.print_details has cognitive complexity 39 (threshold 15). Drivers by points: if/else 5 (20 pts), loops 6 (17 pts), boolean chains 2 (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ParallelModule._load_from_state_dict (cognitive 39) · ×1
  • ParallelModule._load_from_state_dict (cognitive 39) colossalai/shardformer/layer/parallel_module.py:70 — ParallelModule._load_from_state_dict has cognitive complexity 39 (threshold 15). Drivers by points: if/else 12 (27 pts), boolean chains 5, loops 3 (4 pts), error handling 1 (3 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · gpt_evaluate.evaluate (cognitive 38) · ×1
  • gpt_evaluate.evaluate (cognitive 38) applications/ColossalEval/colossal_eval/evaluate/gpt_evaluate.py:496 — gpt_evaluate.evaluate has cognitive complexity 38 (threshold 15). Drivers by points: if/else 9 (20 pts), loops 6 (11 pts), ternaries 2 (7 pts) (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CostGraph.merge_node (cognitive 38) · ×1
  • CostGraph.merge_node (cognitive 38) colossalai/auto_parallel/tensor_shard/solver/cost_graph.py:101 — CostGraph.merge_node has cognitive complexity 38 (threshold 15). Drivers by points: if/else 13 (24 pts), loops 8 (14 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · HybridParallelNaiveOptimizer._compute_grad_norm (cognitive 38) · ×1
  • HybridParallelNaiveOptimizer._compute_grad_norm (cognitive 38) colossalai/booster/plugin/hybrid_parallel_plugin.py:386 — HybridParallelNaiveOptimizer._compute_grad_norm has cognitive complexity 38 (threshold 15). Drivers by points: if/else 12 (32 pts), loops 2 (6 pts) (nesting depth added 24). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function. This shape REPEATS in the file: one other method here (HybridParallelAMPOptimizer._compute_grad_norm) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · HybridParallelAMPOptimizer._compute_grad_norm (cognitive 38) · ×1
  • HybridParallelAMPOptimizer._compute_grad_norm (cognitive 38) colossalai/booster/plugin/hybrid_parallel_plugin.py:590 — HybridParallelAMPOptimizer._compute_grad_norm has cognitive complexity 38 (threshold 15). Drivers by points: if/else 12 (32 pts), loops 2 (6 pts) (nesting depth added 24). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function. This shape REPEATS in the file: one other method here (HybridParallelNaiveOptimizer._compute_grad_norm) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · Qwen2PipelineForwards.qwen2_for_sequence_classification_forward (cognitive 38) · ×1
  • Qwen2PipelineForwards.qwen2_for_sequence_classification_forward (cognitive 38) colossalai/shardformer/modeling/_qwen2_tf4.py:368 — Qwen2PipelineForwards.qwen2_for_sequence_classification_forward has cognitive complexity 38 (threshold 15). Drivers by points: if/else 17 (31 pts), ternaries 2 (4 pts), boolean chains 3 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BloomPipelineForwards.bloom_for_sequence_classification_forward (cognitive 38) · ×1
  • BloomPipelineForwards.bloom_for_sequence_classification_forward (cognitive 38) colossalai/shardformer/modeling/bloom.py:412 — BloomPipelineForwards.bloom_for_sequence_classification_forward has cognitive complexity 38 (threshold 15). Drivers by points: if/else 17 (31 pts), ternaries 2 (4 pts), boolean chains 3 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CheckpointSolverBase._linearize_graph (cognitive 37) · ×1
  • CheckpointSolverBase._linearize_graph (cognitive 37) colossalai/auto_parallel/checkpoint/ckpt_solver_base.py:89 — CheckpointSolverBase._linearize_graph has cognitive complexity 37 (threshold 15). Drivers by points: if/else 10 (25 pts), loops 3 (6 pts), boolean chains 3, error handling 1 (3 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · HybridParallelCheckpointIO._model_sharder (cognitive 37) · ×1
  • HybridParallelCheckpointIO._model_sharder (cognitive 37) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:144 — HybridParallelCheckpointIO._model_sharder has cognitive complexity 37 (threshold 15). Drivers by points: if/else 13 (31 pts), ternaries 1 (3 pts), loops 2, boolean chains 1 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · calc_pipeline_strategy.alpa_dp_impl (cognitive 37) · ×1
  • calc_pipeline_strategy.alpa_dp_impl (cognitive 37) colossalai/device/calc_pipeline_strategy.py:29 — calc_pipeline_strategy.alpa_dp_impl has cognitive complexity 37 (threshold 15). Drivers by points: loops 7 (18 pts), if/else 4 (15 pts), boolean chains 4 (nesting depth added 22). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · activation_checkpoint_codegen.emit_code_with_nested_activation_checkpoint (cognitive 37) · ×1
  • activation_checkpoint_codegen.emit_code_with_nested_activation_checkpoint (cognitive 37) colossalai/fx/codegen/activation_checkpoint_codegen.py:400 — activation_checkpoint_codegen.emit_code_with_nested_activation_checkpoint has cognitive complexity 37 (threshold 15). Drivers by points: if/else 10 (24 pts), loops 4 (12 pts), boolean chains 1 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TraceFlow._assign_single_node_flow (cognitive 36) · ×1
  • TraceFlow._assign_single_node_flow (cognitive 36) colossalai/autochunk/trace_flow.py:66 — TraceFlow._assign_single_node_flow has cognitive complexity 36 (threshold 15). Drivers by points: if/else 17 (33 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ColoTracer._meta_data_computing (cognitive 36) · ×1
  • ColoTracer._meta_data_computing (cognitive 36) colossalai/fx/tracer/tracer.py:218 — ColoTracer._meta_data_computing has cognitive complexity 36 (threshold 15). Drivers by points: if/else 19 (30 pts), boolean chains 3, loops 1 (2 pts), error handling 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LlamaInferenceForwards.llama_model_forward (cognitive 36) · ×1
  • LlamaInferenceForwards.llama_model_forward (cognitive 36) colossalai/legacy/inference/tensor_parallel/modeling/llama.py:118 — LlamaInferenceForwards.llama_model_forward has cognitive complexity 36 (threshold 15). Drivers by points: if/else 17 (20 pts), ternaries 9 (13 pts), boolean chains 2, loops 1 (nesting depth added 7). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · FalconPipelineForwards.falcon_for_sequence_classification_forward (cognitive 36) · ×1
  • FalconPipelineForwards.falcon_for_sequence_classification_forward (cognitive 36) colossalai/shardformer/modeling/falcon.py:453 — FalconPipelineForwards.falcon_for_sequence_classification_forward has cognitive complexity 36 (threshold 15). Drivers by points: if/else 15 (29 pts), ternaries 2 (4 pts), boolean chains 3 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ShapeConsistencyManager.get_all_mix_gather_spec (cognitive 36) · ×1
  • ShapeConsistencyManager.get_all_mix_gather_spec (cognitive 36) colossalai/tensor/shape_consistency.py:340 — ShapeConsistencyManager.get_all_mix_gather_spec has cognitive complexity 36 (threshold 15). Drivers by points: if/else 8 (24 pts), loops 3 (6 pts), boolean chains 3, error handling 1 (3 pts) (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GeminiOptimizer._maybe_move_fp32_params (cognitive 36) · ×1
  • GeminiOptimizer._maybe_move_fp32_params (cognitive 36) colossalai/zero/gemini/gemini_optimizer.py:313 — GeminiOptimizer._maybe_move_fp32_params has cognitive complexity 36 (threshold 15). Drivers by points: if/else 5 (19 pts), loops 5 (15 pts), boolean chains 2 (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · launch_zero_bubble.launch_distributed (cognitive 35) · ×1
  • launch_zero_bubble.launch_distributed (cognitive 35) applications/ColossalChat/coati/distributed/launch_zero_bubble.py:31 — launch_zero_bubble.launch_distributed has cognitive complexity 35 (threshold 15). Drivers by points: loops 14 (23 pts), if/else 7 (11 pts), boolean chains 1 (nesting depth added 13). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · ColoTracer.trace (cognitive 35) · ×1
  • ColoTracer.trace (cognitive 35) colossalai/_analyzer/fx/tracer/tracer.py:166 — ColoTracer.trace has cognitive complexity 35 (threshold 15). Drivers by points: if/else 9 (22 pts), loops 4 (12 pts), boolean chains 1 (nesting depth added 21). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · TraceFlow._get_input_nodes_dim (cognitive 35) · ×1
  • TraceFlow._get_input_nodes_dim (cognitive 35) colossalai/autochunk/trace_flow.py:197 — TraceFlow._get_input_nodes_dim has cognitive complexity 35 (threshold 15). Drivers by points: if/else 11 (31 pts), loops 3 (4 pts) (nesting depth added 21). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · TraceIndice._assign_view_reshape_indice (cognitive 35) · ×1
  • TraceIndice._assign_view_reshape_indice (cognitive 35) colossalai/autochunk/trace_indice.py:718 — TraceIndice._assign_view_reshape_indice has cognitive complexity 35 (threshold 15). Drivers by points: if/else 12 (20 pts), loops 9 (13 pts), boolean chains 2 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · HybridParallelCheckpointIO.save_unsharded_model (cognitive 35) · ×1
  • HybridParallelCheckpointIO.save_unsharded_model (cognitive 35) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:808 — HybridParallelCheckpointIO.save_unsharded_model has cognitive complexity 35 (threshold 15). Drivers by points: if/else 12 (24 pts), loops 3 (11 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MoECheckpointIO.save_sharded_model (cognitive 35) · ×1
  • MoECheckpointIO.save_sharded_model (cognitive 35) colossalai/checkpoint_io/moe_checkpoint.py:145 — MoECheckpointIO.save_sharded_model has cognitive complexity 35 (threshold 15). Drivers by points: if/else 13 (21 pts), boolean chains 7, loops 2 (7 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MoECheckpointIO.gather_from_sharded_optimizer_state (cognitive 35) · ×1
  • MoECheckpointIO.gather_from_sharded_optimizer_state (cognitive 35) colossalai/checkpoint_io/moe_checkpoint.py:291 — MoECheckpointIO.gather_from_sharded_optimizer_state has cognitive complexity 35 (threshold 15). Drivers by points: if/else 11 (29 pts), boolean chains 3, ternaries 2, loops 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · p2p._communicate (cognitive 35) · ×1
  • p2p._communicate (cognitive 35) colossalai/legacy/communication/p2p.py:89 — p2p._communicate has cognitive complexity 35 (threshold 15). Drivers by points: if/else 19 (23 pts), loops 3 (8 pts), boolean chains 4 (nesting depth added 9). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · generation._sample_streaming (cognitive 34) · ×1
  • generation._sample_streaming (cognitive 34) applications/ColossalChat/coati/models/generation.py:262 — generation._sample_streaming has cognitive complexity 34 (threshold 15). Drivers by points: if/else 12 (23 pts), loops 2 (5 pts), boolean chains 4, ternaries 1 (2 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · QuantLinear.pack (cognitive 34) · ×1
  • QuantLinear.pack (cognitive 34) applications/ColossalChat/coati/quant/llama_gptq/quant.py:150 — QuantLinear.pack has cognitive complexity 34 (threshold 15). Drivers by points: loops 11 (27 pts), if/else 5 (7 pts) (nesting depth added 18). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D2 · Cognitive Complexity · GraphAnalyser.liveness_analysis (cognitive 34) · ×1
  • GraphAnalyser.liveness_analysis (cognitive 34) colossalai/auto_parallel/tensor_shard/solver/graph_analysis.py:85 — GraphAnalyser.liveness_analysis has cognitive complexity 34 (threshold 15). Drivers by points: if/else 10 (26 pts), loops 4 (8 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MoECheckpointIO._model_sharder (cognitive 34) · ×1
  • MoECheckpointIO._model_sharder (cognitive 34) colossalai/checkpoint_io/moe_checkpoint.py:73 — MoECheckpointIO._model_sharder has cognitive complexity 34 (threshold 15). Drivers by points: if/else 10 (23 pts), ternaries 2 (7 pts), boolean chains 2, loops 2 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DistributedLamb.step (cognitive 34) · ×1
  • DistributedLamb.step (cognitive 34) colossalai/nn/optimizer/distributed_lamb.py:104 — DistributedLamb.step has cognitive complexity 34 (threshold 15). Drivers by points: if/else 10 (28 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LowLevelZeroOptimizer.__init__ (cognitive 34) · ×1
  • LowLevelZeroOptimizer.__init__ (cognitive 34) colossalai/zero/low_level/low_level_optim.py:77 — LowLevelZeroOptimizer.__init__ has cognitive complexity 34 (threshold 15). Drivers by points: if/else 11 (15 pts), loops 7 (13 pts), boolean chains 4, ternaries 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GRPOTrainer._training_step (cognitive 33) · ×1
  • GRPOTrainer._training_step (cognitive 33) applications/ColossalChat/coati/trainer/grpo.py:228 — GRPOTrainer._training_step has cognitive complexity 33 (threshold 15). Drivers by points: if/else 10 (17 pts), loops 2 (7 pts), error handling 1 (4 pts), boolean chains 3, ternaries 2 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · conversation.get_batch_prompt (cognitive 33) · ×1
  • conversation.get_batch_prompt (cognitive 33) applications/ColossalEval/colossal_eval/utils/conversation.py:153 — conversation.get_batch_prompt has cognitive complexity 33 (threshold 15). Drivers by points: if/else 8 (18 pts), ternaries 2 (9 pts), loops 2 (6 pts) (nesting depth added 21). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · module_checkpoint.save_checkpoint (cognitive 33) · ×1
  • module_checkpoint.save_checkpoint (cognitive 33) colossalai/legacy/utils/checkpoint/module_checkpoint.py:12 — module_checkpoint.save_checkpoint has cognitive complexity 33 (threshold 15). Drivers by points: if/else 7 (18 pts), loops 6 (15 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · module_checkpoint.load_checkpoint (cognitive 33) · ×1
  • module_checkpoint.load_checkpoint (cognitive 33) colossalai/legacy/utils/checkpoint/module_checkpoint.py:79 — module_checkpoint.load_checkpoint has cognitive complexity 33 (threshold 15). Drivers by points: if/else 10 (21 pts), loops 6 (12 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · p2p._communicate (cognitive 33) · ×1
  • p2p._communicate (cognitive 33) REDACTED:364 — p2p._communicate has cognitive complexity 33 (threshold 15). Drivers by points: ternaries 8 (14 pts), boolean chains 11, if/else 5 (6 pts), loops 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OPTPipelineForwards.opt_for_sequence_classification_forward (cognitive 33) · ×1
  • OPTPipelineForwards.opt_for_sequence_classification_forward (cognitive 33) colossalai/shardformer/modeling/opt.py:359 — OPTPipelineForwards.opt_for_sequence_classification_forward has cognitive complexity 33 (threshold 15). Drivers by points: if/else 12 (25 pts), ternaries 3 (6 pts), boolean chains 2 (nesting depth added 16). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · GeminiDDP.grad_handle (cognitive 33) · ×1
  • GeminiDDP.grad_handle (cognitive 33) colossalai/zero/gemini/gemini_ddp.py:358 — GeminiDDP.grad_handle has cognitive complexity 33 (threshold 15). Drivers by points: if/else 19 (32 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PPOTrainer._training_step (cognitive 32) · ×1
  • PPOTrainer._training_step (cognitive 32) applications/ColossalChat/coati/trainer/ppo.py:217 — PPOTrainer._training_step has cognitive complexity 32 (threshold 15). Drivers by points: if/else 9 (15 pts), loops 2 (7 pts), error handling 1 (4 pts), boolean chains 3, ternaries 3 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MoeHybridParallelPlugin.configure (cognitive 32) · ×1
  • MoeHybridParallelPlugin.configure (cognitive 32) colossalai/booster/plugin/moe_hybrid_parallel_plugin.py:427 — MoeHybridParallelPlugin.configure has cognitive complexity 32 (threshold 15). Drivers by points: if/else 10 (19 pts), boolean chains 7, ternaries 2 (6 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run.launch_multi_processes (cognitive 32) · ×1
  • run.launch_multi_processes (cognitive 32) colossalai/cli/launcher/run.py:212 — run.launch_multi_processes has cognitive complexity 32 (threshold 15). Drivers by points: if/else 13 (19 pts), loops 6 (9 pts), boolean chains 4 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InterleavedSchedule.run_forward_backward (cognitive 32) · ×1
  • InterleavedSchedule.run_forward_backward (cognitive 32) colossalai/pipeline/schedule/interleaved_pp.py:441 — InterleavedSchedule.run_forward_backward has cognitive complexity 32 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 10, loops 3, ternaries 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ColoAttention.prepare_attn_kwargs (cognitive 32) · ×1
  • ColoAttention.prepare_attn_kwargs (cognitive 32) colossalai/shardformer/layer/attn.py:139 — ColoAttention.prepare_attn_kwargs has cognitive complexity 32 (threshold 15). Drivers by points: if/else 15 (27 pts), boolean chains 5 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MetaInfoProp.node_handler (cognitive 31) · ×1
  • MetaInfoProp.node_handler (cognitive 31) colossalai/auto_parallel/passes/meta_info_prop.py:94 — MetaInfoProp.node_handler has cognitive complexity 31 (threshold 15). Drivers by points: loops 8 (17 pts), if/else 5 (13 pts), boolean chains 1 (nesting depth added 17). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · reshape.detect_reshape_mapping (cognitive 31) · ×1
  • reshape.detect_reshape_mapping (cognitive 31) colossalai/auto_parallel/tensor_shard/utils/reshape.py:19 — reshape.detect_reshape_mapping has cognitive complexity 31 (threshold 15). Drivers by points: if/else 13 (28 pts), boolean chains 2, loops 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MoeHybridParallelPlugin.__init__ (cognitive 31) · ×1
  • MoeHybridParallelPlugin.__init__ (cognitive 31) colossalai/booster/plugin/moe_hybrid_parallel_plugin.py:178 — MoeHybridParallelPlugin.__init__ has cognitive complexity 31 (threshold 15). Drivers by points: if/else 14 (18 pts), boolean chains 8, ternaries 2 (5 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · loss.dist_cross_entropy (cognitive 31) · ×1
  • loss.dist_cross_entropy (cognitive 31) colossalai/shardformer/layer/loss.py:262 — loss.dist_cross_entropy has cognitive complexity 31 (threshold 15). Drivers by points: if/else 12 (18 pts), ternaries 2 (8 pts), boolean chains 5 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · _deepseek_v3_tf5.deepseek_v3_model_forward (cognitive 31) · ×1
  • _deepseek_v3_tf5.deepseek_v3_model_forward (cognitive 31) colossalai/shardformer/modeling/_deepseek_v3_tf5.py:171 — _deepseek_v3_tf5.deepseek_v3_model_forward has cognitive complexity 31 (threshold 15). Drivers by points: if/else 17 (22 pts), boolean chains 4, ternaries 3 (4 pts), loops 1 (nesting depth added 6). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · MixtralPipelineForwards.mixtral_for_causal_lm_forward (cognitive 31) · ×1
  • MixtralPipelineForwards.mixtral_for_causal_lm_forward (cognitive 31) colossalai/shardformer/modeling/_mixtral_tf5.py:774 — MixtralPipelineForwards.mixtral_for_causal_lm_forward has cognitive complexity 31 (threshold 15). Drivers by points: if/else 12 (21 pts), ternaries 6 (10 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SFTTrainer._eval (cognitive 30) · ×1
  • SFTTrainer._eval (cognitive 30) applications/ColossalChat/coati/trainer/sft.py:181 — SFTTrainer._eval has cognitive complexity 30 (threshold 15). Drivers by points: if/else 8 (17 pts), loops 4 (9 pts), ternaries 1 (3 pts), boolean chains 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MoECheckpointIO.pre_save_model (cognitive 30) · ×1
  • MoECheckpointIO.pre_save_model (cognitive 30) colossalai/checkpoint_io/moe_checkpoint.py:805 — MoECheckpointIO.pre_save_model has cognitive complexity 30 (threshold 15). Drivers by points: if/else 10 (24 pts), loops 2 (5 pts), boolean chains 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · experimental.bias_addition_pass (cognitive 30) · ×1
  • experimental.bias_addition_pass (cognitive 30) colossalai/fx/tracer/experimental.py:595 — experimental.bias_addition_pass has cognitive complexity 30 (threshold 15). Drivers by points: if/else 9 (24 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 17). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · RequestHandler.schedule (cognitive 30) · ×1
  • RequestHandler.schedule (cognitive 30) colossalai/inference/core/request_handler.py:235 — RequestHandler.schedule has cognitive complexity 30 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 5 (15 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · stablediffusion3.sd3_forward (cognitive 30) · ×1
  • stablediffusion3.sd3_forward (cognitive 30) colossalai/inference/modeling/models/stablediffusion3.py:12 — stablediffusion3.sd3_forward has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (18 pts), boolean chains 6, loops 2 (4 pts), ternaries 1 (2 pts) (nesting depth added 10). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D2 · Cognitive Complexity · LlamaInferenceForwards.llama_model_forward (cognitive 30) · ×1
  • LlamaInferenceForwards.llama_model_forward (cognitive 30) colossalai/legacy/inference/hybridengine/modeling/llama.py:196 — LlamaInferenceForwards.llama_model_forward has cognitive complexity 30 (threshold 15). Drivers by points: if/else 18 (21 pts), boolean chains 4, ternaries 3 (4 pts), loops 1 (nesting depth added 4). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D2 · Cognitive Complexity · MistralForwards.mistral_for_sequence_classification_forward (cognitive 30) · ×1
  • MistralForwards.mistral_for_sequence_classification_forward (cognitive 30) colossalai/shardformer/modeling/mistral.py:276 — MistralForwards.mistral_for_sequence_classification_forward has cognitive complexity 30 (threshold 15). Drivers by points: if/else 14 (27 pts), boolean chains 3 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · factory.find_repeat_blocks (cognitive 29) · ×1
  • factory.find_repeat_blocks (cognitive 29) colossalai/auto_parallel/tensor_shard/utils/factory.py:101 — factory.find_repeat_blocks has cognitive complexity 29 (threshold 15). Drivers by points: if/else 9 (21 pts), loops 5 (8 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MoECheckpointIO.save_sharded_optimizer (cognitive 29) · ×1
  • MoECheckpointIO.save_sharded_optimizer (cognitive 29) colossalai/checkpoint_io/moe_checkpoint.py:431 — MoECheckpointIO.save_sharded_optimizer has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (17 pts), loops 2 (7 pts), boolean chains 5 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CAME.step (cognitive 29) · ×1
  • CAME.step (cognitive 29) colossalai/nn/optimizer/came.py:64 — CAME.step has cognitive complexity 29 (threshold 15). Drivers by points: if/else 11 (26 pts), loops 2 (3 pts) (nesting depth added 16). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D2 · Cognitive Complexity · HybridAdam.step (cognitive 29) · ×1
  • HybridAdam.step (cognitive 29) colossalai/nn/optimizer/hybrid_adam.py:93 — HybridAdam.step has cognitive complexity 29 (threshold 15). Drivers by points: if/else 8 (18 pts), ternaries 2 (6 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · bnb._replace_with_bnb_layers (cognitive 29) · ×1
  • bnb._replace_with_bnb_layers (cognitive 29) colossalai/quantization/bnb.py:141 — bnb._replace_with_bnb_layers has cognitive complexity 29 (threshold 15). Drivers by points: if/else 8 (22 pts), loops 2 (4 pts), boolean chains 3 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Distributor.loop (cognitive 28) · ×1
  • Distributor.loop (cognitive 28) applications/ColossalChat/coati/distributed/zero_bubble/distributor.py:44 — Distributor.loop has cognitive complexity 28 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 3 (9 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · runtime_apply_pass._shape_consistency_apply (cognitive 28) · ×1
  • runtime_apply_pass._shape_consistency_apply (cognitive 28) colossalai/auto_parallel/passes/runtime_apply_pass.py:85 — runtime_apply_pass._shape_consistency_apply has cognitive complexity 28 (threshold 15). Drivers by points: if/else 7 (20 pts), loops 3 (7 pts), boolean chains 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StrategiesConstructor.build_strategies_and_cost (cognitive 28) · ×1
  • StrategiesConstructor.build_strategies_and_cost (cognitive 28) colossalai/auto_parallel/tensor_shard/solver/strategies_constructor.py:72 — StrategiesConstructor.build_strategies_and_cost has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (25 pts), loops 3 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · activation_checkpoint_codegen.emit_ckpt_func (cognitive 28) · ×1
  • activation_checkpoint_codegen.emit_ckpt_func (cognitive 28) colossalai/fx/codegen/activation_checkpoint_codegen.py:302 — activation_checkpoint_codegen.emit_ckpt_func has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (20 pts), loops 3 (8 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · bnb.find_tied_parameters (cognitive 28) · ×1
  • bnb.find_tied_parameters (cognitive 28) colossalai/quantization/bnb.py:261 — bnb.find_tied_parameters has cognitive complexity 28 (threshold 15). Drivers by points: if/else 5 (16 pts), loops 3 (7 pts), ternaries 2 (5 pts) (nesting depth added 18). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · comparison.check_state_dict_equal (cognitive 28) · ×1
  • comparison.check_state_dict_equal (cognitive 28) colossalai/testing/comparison.py:41 — comparison.check_state_dict_equal has cognitive complexity 28 (threshold 15). Drivers by points: if/else 8 (24 pts), loops 2 (4 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GeminiDDP._save_to_state_dict (cognitive 28) · ×1
  • GeminiDDP._save_to_state_dict (cognitive 28) colossalai/zero/gemini/gemini_ddp.py:534 — GeminiDDP._save_to_state_dict has cognitive complexity 28 (threshold 15). Drivers by points: if/else 8 (15 pts), ternaries 3 (8 pts), loops 3 (4 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · spliced_and_tokenized_dataset.supervised_tokenize_sft (cognitive 27) · ×1
  • spliced_and_tokenized_dataset.supervised_tokenize_sft (cognitive 27) applications/Colossal-LLaMA/colossal_llama/dataset/spliced_and_tokenized_dataset.py:73 — spliced_and_tokenized_dataset.supervised_tokenize_sft has cognitive complexity 27 (threshold 15). Drivers by points: if/else 10 (17 pts), loops 4, boolean chains 3, ternaries 3 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KTOTrainer._train (cognitive 27) · ×1
  • KTOTrainer._train (cognitive 27) applications/ColossalChat/coati/trainer/kto.py:119 — KTOTrainer._train has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (20 pts), ternaries 2 (4 pts), boolean chains 2, loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SFTTrainer._train (cognitive 27) · ×1
  • SFTTrainer._train (cognitive 27) applications/ColossalChat/coati/trainer/sft.py:98 — SFTTrainer._train has cognitive complexity 27 (threshold 15). Drivers by points: if/else 7 (18 pts), loops 2 (4 pts), ternaries 1 (3 pts), boolean chains 2 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PermuteHandler.get_operation_data_mapping (cognitive 27) · ×1
  • PermuteHandler.get_operation_data_mapping (cognitive 27) colossalai/auto_parallel/tensor_shard/node_handler/permute_handler.py:26 — PermuteHandler.get_operation_data_mapping has cognitive complexity 27 (threshold 15). Drivers by points: if/else 11 (22 pts), loops 3 (5 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · HybridParallelPlugin.configure (cognitive 27) · ×1
  • HybridParallelPlugin.configure (cognitive 27) colossalai/booster/plugin/hybrid_parallel_plugin.py:1239 — HybridParallelPlugin.configure has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 6, ternaries 2 (6 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BaseSmoothForCausalLM.save_quantized (cognitive 27) · ×1
  • BaseSmoothForCausalLM.save_quantized (cognitive 27) colossalai/legacy/inference/quant/smoothquant/models/base_model.py:194 — BaseSmoothForCausalLM.save_quantized has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (18 pts), error handling 1 (5 pts), loops 1 (3 pts), boolean chains 1 (nesting depth added 16). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D2 · Cognitive Complexity · WorkerBase._subscribe_producer (cognitive 27) · ×1
  • WorkerBase._subscribe_producer (cognitive 27) colossalai/legacy/pipeline/rpc/_pipeline_base.py:378 — WorkerBase._subscribe_producer has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 3 (8 pts), boolean chains 2 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Lamb.step (cognitive 27) · ×1
  • Lamb.step (cognitive 27) colossalai/nn/optimizer/lamb.py:44 — Lamb.step has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (23 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · p2p._broadcast_object_list (cognitive 27) · ×1
  • p2p._broadcast_object_list (cognitive 27) REDACTED:63 — p2p._broadcast_object_list has cognitive complexity 27 (threshold 15). Drivers by points: if/else 16 (23 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RingAttention.forward (cognitive 27) · ×1
  • RingAttention.forward (cognitive 27) colossalai/shardformer/layer/attn.py:623 — RingAttention.forward has cognitive complexity 27 (threshold 15). Drivers by points: if/else 16 (21 pts), ternaries 3, boolean chains 2, loops 1 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · GeminiDDP.__init__ (cognitive 27) · ×1
  • GeminiDDP.__init__ (cognitive 27) colossalai/zero/gemini/gemini_ddp.py:75 — GeminiDDP.__init__ has cognitive complexity 27 (threshold 15). Drivers by points: if/else 11 (14 pts), loops 5 (7 pts), ternaries 2 (4 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AGIEvalDataset.load (cognitive 26) · ×1
  • AGIEvalDataset.load (cognitive 26) applications/ColossalEval/colossal_eval/dataset/agieval.py:200 — AGIEvalDataset.load has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (20 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 12). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D2 · Cognitive Complexity · Conversation.get_prompt (cognitive 26) · ×1
  • Conversation.get_prompt (cognitive 26) applications/ColossalEval/colossal_eval/utils/conversation.py:27 — Conversation.get_prompt has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (18 pts), loops 4 (8 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · runtime_preparation_pass.module_params_sharding_pass (cognitive 26) · ×1
  • runtime_preparation_pass.module_params_sharding_pass (cognitive 26) colossalai/auto_parallel/passes/runtime_preparation_pass.py:384 — runtime_preparation_pass.module_params_sharding_pass has cognitive complexity 26 (threshold 15). Drivers by points: loops 5 (14 pts), if/else 5 (11 pts), boolean chains 1 (nesting depth added 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · TraceFlow._get_all_node_info (cognitive 26) · ×1
  • TraceFlow._get_all_node_info (cognitive 26) colossalai/autochunk/trace_flow.py:152 — TraceFlow._get_all_node_info has cognitive complexity 26 (threshold 15). Drivers by points: if/else 6 (20 pts), loops 3 (6 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · HybridParallelCheckpointIO.load_sharded_optimizer (cognitive 26) · ×1
  • HybridParallelCheckpointIO.load_sharded_optimizer (cognitive 26) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:694 — HybridParallelCheckpointIO.load_sharded_optimizer has cognitive complexity 26 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 5 (7 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · glide_llama.glide_llama_model_forward (cognitive 26) · ×1
  • glide_llama.glide_llama_model_forward (cognitive 26) colossalai/inference/modeling/models/glide_llama.py:121 — glide_llama.glide_llama_model_forward has cognitive complexity 26 (threshold 15). Drivers by points: if/else 12 (15 pts), ternaries 7 (8 pts), boolean chains 2, loops 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · BlipPolicy.module_policy (cognitive 26) · ×1
  • BlipPolicy.module_policy (cognitive 26) colossalai/shardformer/policies/blip2.py:27 — BlipPolicy.module_policy has cognitive complexity 26 (threshold 15). Drivers by points: if/else 14 (21 pts), loops 1 (2 pts), ternaries 1 (2 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ChatGLMPolicy.module_policy (cognitive 26) · ×1
  • ChatGLMPolicy.module_policy (cognitive 26) colossalai/shardformer/policies/chatglm2.py:41 — ChatGLMPolicy.module_policy has cognitive complexity 26 (threshold 15). Drivers by points: if/else 16 (20 pts), boolean chains 4, ternaries 1 (2 pts) (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · conversation.setup_conversation_template (cognitive 25) · ×1
  • conversation.setup_conversation_template (cognitive 25) applications/ColossalChat/coati/dataset/conversation.py:96 — conversation.setup_conversation_template has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (17 pts), error handling 2 (6 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · comm.ray_broadcast_tensor_dict (cognitive 25) · ×1
  • comm.ray_broadcast_tensor_dict (cognitive 25) applications/ColossalChat/coati/distributed/comm.py:36 — comm.ray_broadcast_tensor_dict has cognitive complexity 25 (threshold 15). Drivers by points: if/else 12 (20 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · generation._sample (cognitive 25) · ×1
  • generation._sample (cognitive 25) applications/ColossalChat/coati/models/generation.py:97 — generation._sample has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (16 pts), loops 2 (4 pts), boolean chains 3, ternaries 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · agieval.combine_prompt (cognitive 25) · ×1
  • agieval.combine_prompt (cognitive 25) applications/ColossalEval/colossal_eval/dataset/agieval.py:103 — agieval.combine_prompt has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (11 pts), ternaries 4 (8 pts), boolean chains 4, loops 2 (nesting depth added 7). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D2 · Cognitive Complexity · GaoKaoBenchDataset.load (cognitive 25) · ×1
  • GaoKaoBenchDataset.load (cognitive 25) applications/ColossalEval/colossal_eval/dataset/gaokaobench.py:72 — GaoKaoBenchDataset.load has cognitive complexity 25 (threshold 15). Drivers by points: if/else 5 (17 pts), loops 3 (6 pts), boolean chains 2 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · check_pr_runner_policy.validate_fork_workflow (cognitive 25) · ×1
  • check_pr_runner_policy.validate_fork_workflow (cognitive 25) .github/scripts/ci/check_pr_runner_policy.py:83 — check_pr_runner_policy.validate_fork_workflow has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (18 pts), boolean chains 3, loops 2 (3 pts), error handling 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MatMulHandler.post_process (cognitive 25) · ×1
  • MatMulHandler.post_process (cognitive 25) colossalai/auto_parallel/tensor_shard/node_handler/matmul_handler.py:448 — MatMulHandler.post_process has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 3 (7 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MoECheckpointIO.shard_from_complete_optimizer_state (cognitive 25) · ×1
  • MoECheckpointIO.shard_from_complete_optimizer_state (cognitive 25) colossalai/checkpoint_io/moe_checkpoint.py:734 — MoECheckpointIO.shard_from_complete_optimizer_state has cognitive complexity 25 (threshold 15). Drivers by points: if/else 6 (19 pts), boolean chains 4, loops 1, ternaries 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · adding_split_node_pass.balanced_split_pass (cognitive 25) · ×1
  • adding_split_node_pass.balanced_split_pass (cognitive 25) colossalai/fx/passes/adding_split_node_pass.py:232 — adding_split_node_pass.balanced_split_pass has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (18 pts), loops 4 (7 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LLMEngine.add_request (cognitive 25) · ×1
  • LLMEngine.add_request (cognitive 25) colossalai/inference/core/llm_engine.py:580 — LLMEngine.add_request has cognitive complexity 25 (threshold 15). Drivers by points: if/else 13 (18 pts), boolean chains 6, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GradScaler._unscale_grads_ (cognitive 25) · ×1
  • GradScaler._unscale_grads_ (cognitive 25) colossalai/legacy/amp/torch_amp/_grad_scaler.py:207 — GradScaler._unscale_grads_ has cognitive complexity 25 (threshold 15). Drivers by points: if/else 6 (15 pts), loops 5 (8 pts), boolean chains 2 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PipelineScheduleV2.forward_backward_step (cognitive 25) · ×1
  • PipelineScheduleV2.forward_backward_step (cognitive 25) colossalai/legacy/engine/schedule/_pipeline_schedule_v2.py:62 — PipelineScheduleV2.forward_backward_step has cognitive complexity 25 (threshold 15). Drivers by points: if/else 13 (19 pts), loops 3 (4 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ShardedOptimizerV2._maybe_move_fp32_shards (cognitive 25) · ×1
  • ShardedOptimizerV2._maybe_move_fp32_shards (cognitive 25) colossalai/legacy/zero/sharded_optim/sharded_optim_v2.py:304 — ShardedOptimizerV2._maybe_move_fp32_shards has cognitive complexity 25 (threshold 15). Drivers by points: if/else 4 (15 pts), loops 3 (10 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ZeroBubbleVPipeScheduler.schedule_f (cognitive 25) · ×1
  • ZeroBubbleVPipeScheduler.schedule_f (cognitive 25) colossalai/pipeline/schedule/zero_bubble_pp.py:638 — ZeroBubbleVPipeScheduler.schedule_f has cognitive complexity 25 (threshold 15). Drivers by points: if/else 15 (17 pts), loops 2 (5 pts), boolean chains 3 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · utils.split_varlen_zigzag (cognitive 25) · ×1
  • utils.split_varlen_zigzag (cognitive 25) colossalai/shardformer/layer/utils.py:381 — utils.split_varlen_zigzag has cognitive complexity 25 (threshold 15). Drivers by points: if/else 12 (22 pts), loops 2 (3 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MixtralPipelineForwards.mixtral_for_causal_lm_forward (cognitive 25) · ×1
  • MixtralPipelineForwards.mixtral_for_causal_lm_forward (cognitive 25) colossalai/shardformer/modeling/_mixtral_tf4.py:408 — MixtralPipelineForwards.mixtral_for_causal_lm_forward has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (18 pts), ternaries 5 (7 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GPT2PipelineForwards.gpt2_for_sequence_classification_forward (cognitive 25) · ×1
  • GPT2PipelineForwards.gpt2_for_sequence_classification_forward (cognitive 25) colossalai/shardformer/modeling/gpt2.py:693 — GPT2PipelineForwards.gpt2_for_sequence_classification_forward has cognitive complexity 25 (threshold 15). Drivers by points: if/else 13 (19 pts), boolean chains 3, ternaries 2 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GPTJPipelineForwards.gptj_for_sequence_classification_forward (cognitive 25) · ×1
  • GPTJPipelineForwards.gptj_for_sequence_classification_forward (cognitive 25) colossalai/shardformer/modeling/gptj.py:356 — GPTJPipelineForwards.gptj_for_sequence_classification_forward has cognitive complexity 25 (threshold 15). Drivers by points: if/else 13 (19 pts), boolean chains 3, ternaries 2 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · T5PipelineForwards.t5_for_conditional_generation_forward (cognitive 25) · ×1
  • T5PipelineForwards.t5_for_conditional_generation_forward (cognitive 25) colossalai/shardformer/modeling/t5.py:403 — T5PipelineForwards.t5_for_conditional_generation_forward has cognitive complexity 25 (threshold 15). Drivers by points: if/else 16 (18 pts), ternaries 3 (4 pts), boolean chains 3 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · CommandPolicy.module_policy (cognitive 25) · ×1
  • CommandPolicy.module_policy (cognitive 25) colossalai/shardformer/policies/command.py:38 — CommandPolicy.module_policy has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (15 pts), boolean chains 8, ternaries 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ChineseTextSplitter.split_text (cognitive 24) · ×1
  • ChineseTextSplitter.split_text (cognitive 24) applications/ColossalQA/colossalqa/text_splitter/chinese_text_splitter.py:21 — ChineseTextSplitter.split_text has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 4 (5 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · runtime_preparation_pass.solution_annotation_pass (cognitive 24) · ×1
  • runtime_preparation_pass.solution_annotation_pass (cognitive 24) colossalai/auto_parallel/passes/runtime_preparation_pass.py:52 — runtime_preparation_pass.solution_annotation_pass has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (16 pts), loops 5 (7 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · runtime_preparation_pass.size_value_converting_pass (cognitive 24) · ×1
  • runtime_preparation_pass.size_value_converting_pass (cognitive 24) colossalai/auto_parallel/passes/runtime_preparation_pass.py:131 — runtime_preparation_pass.size_value_converting_pass has cognitive complexity 24 (threshold 15). Drivers by points: if/else 5 (16 pts), loops 3 (6 pts), boolean chains 2 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LowLevelZeroCheckpointIO.load_sharded_optimizer (cognitive 24) · ×1
  • LowLevelZeroCheckpointIO.load_sharded_optimizer (cognitive 24) colossalai/booster/plugin/low_level_zero_plugin.py:247 — LowLevelZeroCheckpointIO.load_sharded_optimizer has cognitive complexity 24 (threshold 15). Drivers by points: if/else 5 (17 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · HybridParallelCheckpointIO.gather_from_sharded_optimizer_state (cognitive 24) · ×1
  • HybridParallelCheckpointIO.gather_from_sharded_optimizer_state (cognitive 24) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:1065 — HybridParallelCheckpointIO.gather_from_sharded_optimizer_state has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (21 pts), boolean chains 1, loops 1, ternaries 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · hybrid_parallel_checkpoint_io._route_padded_parameter_aliases (cognitive 24) · ×1
  • hybrid_parallel_checkpoint_io._route_padded_parameter_aliases (cognitive 24) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:59 — hybrid_parallel_checkpoint_io._route_padded_parameter_aliases has cognitive complexity 24 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 6 (9 pts), boolean chains 2, ternaries 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MoECheckpointIO.load_sharded_optimizer (cognitive 24) · ×1
  • MoECheckpointIO.load_sharded_optimizer (cognitive 24) colossalai/checkpoint_io/moe_checkpoint.py:578 — MoECheckpointIO.load_sharded_optimizer has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (15 pts), loops 6 (8 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · experimental._meta_data_computing_v0 (cognitive 24) · ×1
  • experimental._meta_data_computing_v0 (cognitive 24) colossalai/fx/tracer/experimental.py:525 — experimental._meta_data_computing_v0 has cognitive complexity 24 (threshold 15). Drivers by points: if/else 14 (20 pts), loops 1 (2 pts), boolean chains 1, error handling 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · p2p_v2._broadcast_object_list (cognitive 24) · ×1
  • p2p_v2._broadcast_object_list (cognitive 24) colossalai/legacy/communication/p2p_v2.py:78 — p2p_v2._broadcast_object_list has cognitive complexity 24 (threshold 15). Drivers by points: if/else 14 (20 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BaseSmoothForCausalLM.from_quantized (cognitive 24) · ×1
  • BaseSmoothForCausalLM.from_quantized (cognitive 24) colossalai/legacy/inference/quant/smoothquant/models/base_model.py:363 — BaseSmoothForCausalLM.from_quantized has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (18 pts), loops 3 (6 pts) (nesting depth added 9). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D2 · Cognitive Complexity · GaLoreProjector.project (cognitive 24) · ×1
  • GaLoreProjector.project (cognitive 24) colossalai/nn/optimizer/galore.py:71 — GaLoreProjector.project has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (16 pts), ternaries 2 (6 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LlamaPolicy.module_policy (cognitive 24) · ×1
  • LlamaPolicy.module_policy (cognitive 24) colossalai/shardformer/policies/_llama_tf4.py:35 — LlamaPolicy.module_policy has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 7, ternaries 1 (2 pts) (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · verify_image.verify_lora_checkpoints (cognitive 24) · ×1
  • verify_image.verify_lora_checkpoints (cognitive 24) docker/torch213/verify_image.py:18 — verify_image.verify_lora_checkpoints has cognitive complexity 24 (threshold 15). Drivers by points: ternaries 3 (9 pts), if/else 3 (7 pts), loops 3 (6 pts), boolean chains 2 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GSMDataset.load (cognitive 23) · ×1
  • GSMDataset.load (cognitive 23) applications/ColossalEval/colossal_eval/dataset/gsm.py:96 — GSMDataset.load has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (10 pts), ternaries 3 (9 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · vLLMModel.get_loss (cognitive 23) · ×1
  • vLLMModel.get_loss (cognitive 23) REDACTED:366 — vLLMModel.get_loss has cognitive complexity 23 (threshold 15). Drivers by points: loops 6 (13 pts), if/else 6 (10 pts) (nesting depth added 11). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · run.get_launch_command (cognitive 23) · ×1
  • run.get_launch_command (cognitive 23) colossalai/cli/launcher/run.py:108 — run.get_launch_command has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (16 pts), loops 2 (4 pts), boolean chains 3 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SparseMLP._ep_process (cognitive 23) · ×1
  • SparseMLP._ep_process (cognitive 23) colossalai/legacy/moe/layer/layers.py:224 — SparseMLP._ep_process has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (20 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OpenMoeAttention.forward (cognitive 23) · ×1
  • OpenMoeAttention.forward (cognitive 23) colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:325 — OpenMoeAttention.forward has cognitive complexity 23 (threshold 15). Drivers by points: if/else 14 (20 pts), ternaries 2, boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CachedParamMgr._prepare_rows_on_cuda (cognitive 23) · ×1
  • CachedParamMgr._prepare_rows_on_cuda (cognitive 23) colossalai/legacy/nn/parallel/layers/cache_embedding/cache_mgr.py:386 — CachedParamMgr._prepare_rows_on_cuda has cognitive complexity 23 (threshold 15). Drivers by points: if/else 14 (23 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · fx.find_input_in_partition (cognitive 23) · ×1
  • fx.find_input_in_partition (cognitive 23) colossalai/legacy/pipeline/middleware/adaptor/fx.py:28 — fx.find_input_in_partition has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 4 (9 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ShardedModelV2.__init__ (cognitive 23) · ×1
  • ShardedModelV2.__init__ (cognitive 23) colossalai/legacy/zero/sharded_model/sharded_model_v2.py:81 — ShardedModelV2.__init__ has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (14 pts), loops 4 (5 pts), boolean chains 3, ternaries 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Lars.step (cognitive 23) · ×1
  • Lars.step (cognitive 23) colossalai/nn/optimizer/lars.py:40 — Lars.step has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (19 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · WhisperPipelineForwards.whisper_encoder_forward (cognitive 23) · ×1
  • WhisperPipelineForwards.whisper_encoder_forward (cognitive 23) colossalai/shardformer/modeling/_whisper_tf5.py:252 — WhisperPipelineForwards.whisper_encoder_forward has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (14 pts), ternaries 4 (6 pts), boolean chains 2, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ChatGLMPolicy.get_held_layers (cognitive 23) · ×1
  • ChatGLMPolicy.get_held_layers (cognitive 23) colossalai/shardformer/policies/chatglm2.py:284 — ChatGLMPolicy.get_held_layers has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (18 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · tokenization_utils.tokenize_sft (cognitive 22) · ×1
  • tokenization_utils.tokenize_sft (cognitive 22) applications/ColossalChat/coati/dataset/tokenization_utils.py:26 — tokenization_utils.tokenize_sft has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (18 pts), loops 3, ternaries 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · lora._convert_to_lora_recursively (cognitive 22) · ×1
  • lora._convert_to_lora_recursively (cognitive 22) applications/ColossalChat/coati/models/lora.py:287 — lora._convert_to_lora_recursively has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (17 pts), boolean chains 4, loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · metrics._fix_fracs (cognitive 22) · ×1
  • metrics._fix_fracs (cognitive 22) REDACTED:205 — metrics._fix_fracs has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (16 pts), error handling 1 (4 pts), loops 1 (2 pts) (nesting depth added 13). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D2 · Cognitive Complexity · TensorStrategyGenerator.collate_strategies (cognitive 22) · ×1
  • TensorStrategyGenerator.collate_strategies (cognitive 22) colossalai/auto_parallel/tensor_shard/node_handler/strategy/getitem_generator.py:67 — TensorStrategyGenerator.collate_strategies has cognitive complexity 22 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 5 (9 pts), error handling 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Solver._prepare_data_for_solver (cognitive 22) · ×1
  • Solver._prepare_data_for_solver (cognitive 22) colossalai/auto_parallel/tensor_shard/solver/solver.py:101 — Solver._prepare_data_for_solver has cognitive complexity 22 (threshold 15). Drivers by points: loops 8 (12 pts), if/else 5 (10 pts) (nesting depth added 9). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · SearchChunk._search_max_chunk_region (cognitive 22) · ×1
  • SearchChunk._search_max_chunk_region (cognitive 22) colossalai/autochunk/search_chunk.py:106 — SearchChunk._search_max_chunk_region has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 4 (6 pts), boolean chains 4 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TraceFlow._get_other_output_info (cognitive 22) · ×1
  • TraceFlow._get_other_output_info (cognitive 22) colossalai/autochunk/trace_flow.py:374 — TraceFlow._get_other_output_info has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (18 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · NopadLlamaAttention._load_from_state_dict (cognitive 22) · ×1
  • NopadLlamaAttention._load_from_state_dict (cognitive 22) colossalai/inference/modeling/models/nopadding_llama.py:592 — NopadLlamaAttention._load_from_state_dict has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (15 pts), error handling 1 (3 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 9). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D2 · Cognitive Complexity · lazy_init._apply_to_lazy_module (cognitive 22) · ×1
  • lazy_init._apply_to_lazy_module (cognitive 22) colossalai/lazy/lazy_init.py:638 — lazy_init._apply_to_lazy_module has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (18 pts), loops 2, ternaries 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PipelineSharedModuleGradientHandler.handle_gradient (cognitive 22) · ×1
  • PipelineSharedModuleGradientHandler.handle_gradient (cognitive 22) colossalai/legacy/engine/gradient_handler/_pipeline_parallel_gradient_handler.py:28 — PipelineSharedModuleGradientHandler.handle_gradient has cognitive complexity 22 (threshold 15). Drivers by points: loops 4 (11 pts), if/else 2 (4 pts), ternaries 1 (4 pts), boolean chains 3 (nesting depth added 12). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · FusedAdam.step (cognitive 22) · ×1
  • FusedAdam.step (cognitive 22) colossalai/nn/optimizer/fused_adam.py:91 — FusedAdam.step has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (17 pts), loops 2 (3 pts), ternaries 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ChatGLMForConditionalGeneration.stream_generate (cognitive 22) · ×1
  • ChatGLMForConditionalGeneration.stream_generate (cognitive 22) colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py:1267 — ChatGLMForConditionalGeneration.stream_generate has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (14 pts), ternaries 3 (4 pts), boolean chains 3, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LlamaPolicy.module_policy (cognitive 22) · ×1
  • LlamaPolicy.module_policy (cognitive 22) colossalai/shardformer/policies/_llama_tf5.py:35 — LlamaPolicy.module_policy has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (13 pts), boolean chains 7, ternaries 1 (2 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · prepare_sft_dataset.main (cognitive 21) · ×1
  • prepare_sft_dataset.main (cognitive 21) applications/Colossal-LLaMA/dataset/prepare_sft_dataset.py:23 — prepare_sft_dataset.main has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (16 pts), loops 4 (5 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · colossalai_suite.main (cognitive 21) · ×1
  • colossalai_suite.main (cognitive 21) .github/scripts/e1/colossalai_suite.py:28 — colossalai_suite.main has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 4, loops 1 (2 pts), ternaries 2 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · generate_leaderboard_and_send_to_lark.get_issue_pull_request_comments (cognitive 21) · ×1
  • generate_leaderboard_and_send_to_lark.get_issue_pull_request_comments (cognitive 21) .github/workflows/scripts/generate_leaderboard_and_send_to_lark.py:90 — generate_leaderboard_and_send_to_lark.get_issue_pull_request_comments has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (17 pts), loops 2 (4 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · runtime_apply_pass._act_annotation_pass (cognitive 21) · ×1
  • runtime_apply_pass._act_annotation_pass (cognitive 21) colossalai/auto_parallel/passes/runtime_apply_pass.py:225 — runtime_apply_pass._act_annotation_pass has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (13 pts), loops 3 (7 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TraceFlow._reassign_reshape_size (cognitive 21) · ×1
  • TraceFlow._reassign_reshape_size (cognitive 21) colossalai/autochunk/trace_flow.py:433 — TraceFlow._reassign_reshape_size has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · HybridParallelCheckpointIO.shard_from_complete_optimizer_state (cognitive 21) · ×1
  • HybridParallelCheckpointIO.shard_from_complete_optimizer_state (cognitive 21) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:1130 — HybridParallelCheckpointIO.shard_from_complete_optimizer_state has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (18 pts), boolean chains 1, loops 1, ternaries 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ColoTracer.create_proxy (cognitive 21) · ×1
  • ColoTracer.create_proxy (cognitive 21) colossalai/fx/tracer/tracer.py:83 — ColoTracer.create_proxy has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (19 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LLMEngine.init_model (cognitive 21) · ×1
  • LLMEngine.init_model (cognitive 21) colossalai/inference/core/llm_engine.py:107 — LLMEngine.init_model has cognitive complexity 21 (threshold 15). Drivers by points: if/else 12 (15 pts), error handling 2 (4 pts), ternaries 1 (2 pts) (nesting depth added 6). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · model.extract_lora_layers (cognitive 21) · ×1
  • model.extract_lora_layers (cognitive 21) colossalai/interface/model.py:9 — model.extract_lora_layers has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (16 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InterleavedSchedule.backward_step (cognitive 21) · ×1
  • InterleavedSchedule.backward_step (cognitive 21) colossalai/pipeline/schedule/interleaved_pp.py:343 — InterleavedSchedule.backward_step has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 3 (7 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OneForwardOneBackwardSchedule.backward_step (cognitive 21) · ×1
  • OneForwardOneBackwardSchedule.backward_step (cognitive 21) colossalai/pipeline/schedule/one_f_one_b.py:284 — OneForwardOneBackwardSchedule.backward_step has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 3 (7 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BnbQuantizationConfig.__post_init__ (cognitive 21) · ×1
  • BnbQuantizationConfig.__post_init__ (cognitive 21) colossalai/quantization/bnb_config.py:66 — BnbQuantizationConfig.__post_init__ has cognitive complexity 21 (threshold 15). Drivers by points: if/else 14 (16 pts), boolean chains 5 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · MixtralPolicy.module_policy (cognitive 21) · ×1
  • MixtralPolicy.module_policy (cognitive 21) colossalai/shardformer/policies/_mixtral_tf5.py:44 — MixtralPolicy.module_policy has cognitive complexity 21 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 4, ternaries 1 (2 pts) (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · BaseProducer.__init__ (cognitive 20) · ×1
  • BaseProducer.__init__ (cognitive 20) applications/ColossalChat/coati/distributed/producer.py:35 — BaseProducer.__init__ has cognitive complexity 20 (threshold 15). Drivers by points: if/else 16 (17 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · ExperienceMakerHolder.update_experience_maker (cognitive 20) · ×1
  • ExperienceMakerHolder.update_experience_maker (cognitive 20) applications/ColossalChat/coati/ray/experience_maker_holder.py:171 — ExperienceMakerHolder.update_experience_maker has cognitive complexity 20 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DatasetEvaluator._evaluate (cognitive 20) · ×1
  • DatasetEvaluator._evaluate (cognitive 20) REDACTED:245 — DatasetEvaluator._evaluate has cognitive complexity 20 (threshold 15). Drivers by points: loops 6 (16 pts), if/else 3 (4 pts) (nesting depth added 11). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · gpt_evaluate.get_gpt_evaluation_without_logprobs (cognitive 20) · ×1
  • gpt_evaluate.get_gpt_evaluation_without_logprobs (cognitive 20) applications/ColossalEval/colossal_eval/evaluate/gpt_evaluate.py:355 — gpt_evaluate.get_gpt_evaluation_without_logprobs has cognitive complexity 20 (threshold 15). Drivers by points: if/else 4 (8 pts), ternaries 2 (4 pts), error handling 1 (3 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_gpu_batch.find_idle (cognitive 20) · ×1
  • run_gpu_batch.find_idle (cognitive 20) .github/scripts/ci/run_gpu_batch.py:53 — run_gpu_batch.find_idle has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (15 pts), boolean chains 3, loops 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MixedPrecisionOptimizer.step (cognitive 20) · ×1
  • MixedPrecisionOptimizer.step (cognitive 20) colossalai/amp/naive_amp/mixed_precision_optimizer.py:169 — MixedPrecisionOptimizer.step has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 4 (6 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RegionManager._process_shared_region (cognitive 20) · ×1
  • RegionManager._process_shared_region (cognitive 20) colossalai/auto_parallel/offload/region_manager.py:241 — RegionManager._process_shared_region has cognitive complexity 20 (threshold 15). Drivers by points: loops 3 (9 pts), if/else 3 (7 pts), boolean chains 4 (nesting depth added 10). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · runtime.runtime_asyn_offload_apply_pass (cognitive 20) · ×1
  • runtime.runtime_asyn_offload_apply_pass (cognitive 20) colossalai/auto_parallel/offload/runtime.py:200 — runtime.runtime_asyn_offload_apply_pass has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (14 pts), boolean chains 5, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AsynTrainingSimulator._eval_bwd_mem_per_region (cognitive 20) · ×1
  • AsynTrainingSimulator._eval_bwd_mem_per_region (cognitive 20) colossalai/auto_parallel/offload/training_simulator.py:361 — AsynTrainingSimulator._eval_bwd_mem_per_region has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (16 pts), loops 3 (4 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PipelineSchedule._backward_step (cognitive 20) · ×1
  • PipelineSchedule._backward_step (cognitive 20) colossalai/legacy/engine/schedule/_pipeline_schedule.py:279 — PipelineSchedule._backward_step has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (14 pts), loops 2 (6 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ChatGLM2InferenceForwards.chatglm_for_conditional_generation_forward (cognitive 20) · ×1
  • ChatGLM2InferenceForwards.chatglm_for_conditional_generation_forward (cognitive 20) colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:97 — ChatGLM2InferenceForwards.chatglm_for_conditional_generation_forward has cognitive complexity 20 (threshold 15). Drivers by points: if/else 13 (14 pts), ternaries 3 (4 pts), boolean chains 2 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · SparseMLP._tp_process (cognitive 20) · ×1
  • SparseMLP._tp_process (cognitive 20) colossalai/legacy/moe/layer/layers.py:303 — SparseMLP._tp_process has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (17 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OpenMoePipelineForwards.llama_for_causal_lm_forward (cognitive 20) · ×1
  • OpenMoePipelineForwards.llama_for_causal_lm_forward (cognitive 20) colossalai/legacy/moe/openmoe/model/openmoe_policy.py:409 — OpenMoePipelineForwards.llama_for_causal_lm_forward has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (11 pts), ternaries 4 (6 pts), loops 1 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · module_utils.init_colo_module (cognitive 20) · ×1
  • module_utils.init_colo_module (cognitive 20) colossalai/legacy/nn/parallel/layers/module_utils.py:88 — module_utils.init_colo_module has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 4 (10 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · fx.get_topology (cognitive 20) · ×1
  • fx.get_topology (cognitive 20) colossalai/legacy/pipeline/middleware/adaptor/fx.py:94 — fx.get_topology has cognitive complexity 20 (threshold 15). Drivers by points: loops 7 (11 pts), if/else 5 (9 pts) (nesting depth added 8). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · checkpointing.partition_pipeline_parallel_state_dict (cognitive 20) · ×1
  • checkpointing.partition_pipeline_parallel_state_dict (cognitive 20) colossalai/legacy/utils/checkpointing.py:114 — checkpointing.partition_pipeline_parallel_state_dict has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 3 (6 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · p2p._batch_send_recv_tensor (cognitive 20) · ×1
  • p2p._batch_send_recv_tensor (cognitive 20) REDACTED:228 — p2p._batch_send_recv_tensor has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (15 pts), loops 1 (3 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Qwen2PipelineForwards.qwen2_for_sequence_classification_forward (cognitive 20) · ×1
  • Qwen2PipelineForwards.qwen2_for_sequence_classification_forward (cognitive 20) colossalai/shardformer/modeling/_qwen2_tf5.py:278 — Qwen2PipelineForwards.qwen2_for_sequence_classification_forward has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11 (15 pts), ternaries 2 (4 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ChatGLMModel.forward (cognitive 20) · ×1
  • ChatGLMModel.forward (cognitive 20) colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py:916 — ChatGLMModel.forward has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 3, ternaries 3 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · T5PipelineForwards.t5_model_forward (cognitive 20) · ×1
  • T5PipelineForwards.t5_model_forward (cognitive 20) colossalai/shardformer/modeling/t5.py:264 — T5PipelineForwards.t5_model_forward has cognitive complexity 20 (threshold 15). Drivers by points: if/else 14 (16 pts), boolean chains 2, ternaries 2 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · MixtralPolicy.module_policy (cognitive 20) · ×1
  • MixtralPolicy.module_policy (cognitive 20) colossalai/shardformer/policies/_mixtral_tf4.py:42 — MixtralPolicy.module_policy has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11 (14 pts), boolean chains 4, ternaries 1 (2 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DeepseekPolicy.module_policy (cognitive 20) · ×1
  • DeepseekPolicy.module_policy (cognitive 20) colossalai/shardformer/policies/deepseek.py:47 — DeepseekPolicy.module_policy has cognitive complexity 20 (threshold 15). Drivers by points: if/else 12 (16 pts), boolean chains 4 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · stream_chat_patch.stream_generate (cognitive 19) · ×1
  • stream_chat_patch.stream_generate (cognitive 19) applications/Colossal-LLaMA/colossal_llama/utils/stream_chat_patch.py:141 — stream_chat_patch.stream_generate has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (12 pts), ternaries 4 (5 pts), boolean chains 1, loops 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · gpt_judge.get_mtbench_judgements (cognitive 19) · ×1
  • gpt_judge.get_mtbench_judgements (cognitive 19) applications/ColossalEval/colossal_eval/evaluate/dataset_evaluator/gpt_judge.py:69 — gpt_judge.get_mtbench_judgements has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (14 pts), boolean chains 4, loops 1 (nesting depth added 7). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D2 · Cognitive Complexity · linear.matmul_meta_info (cognitive 19) · ×1
  • linear.matmul_meta_info (cognitive 19) colossalai/auto_parallel/meta_profiler/meta_registry/linear.py:190 — linear.matmul_meta_info has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (11 pts), boolean chains 5, loops 1 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · autochunk_codegen._add_node_slice (cognitive 19) · ×1
  • autochunk_codegen._add_node_slice (cognitive 19) colossalai/autochunk/autochunk_codegen.py:211 — autochunk_codegen._add_node_slice has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (10 pts), loops 3 (8 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · EstimateMemory._get_tmp_memory (cognitive 19) · ×1
  • EstimateMemory._get_tmp_memory (cognitive 19) colossalai/autochunk/estimate_memory.py:81 — EstimateMemory._get_tmp_memory has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · EstimateMemory.estimate_chunk_inference_mem (cognitive 19) · ×1
  • EstimateMemory.estimate_chunk_inference_mem (cognitive 19) colossalai/autochunk/estimate_memory.py:139 — EstimateMemory.estimate_chunk_inference_mem has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (11 pts), ternaries 3 (5 pts), boolean chains 2, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TraceIndice._assign_getitem_indice (cognitive 19) · ×1
  • TraceIndice._assign_getitem_indice (cognitive 19) colossalai/autochunk/trace_indice.py:647 — TraceIndice._assign_getitem_indice has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (13 pts), loops 4, ternaries 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FP16Optimizer.__init__ (cognitive 19) · ×1
  • FP16Optimizer.__init__ (cognitive 19) colossalai/legacy/amp/naive_amp/_fp16_optimizer.py:66 — FP16Optimizer.__init__ has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (16 pts), loops 2 (3 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CaiQuantLinear.pack (cognitive 19) · ×1
  • CaiQuantLinear.pack (cognitive 19) colossalai/legacy/inference/quant/gptq/cai_gptq/cai_quant_linear.py:73 — CaiQuantLinear.pack has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (9 pts), loops 5 (9 pts), ternaries 1 (nesting depth added 6). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D2 · Cognitive Complexity · CachedParamMgr.reorder (cognitive 19) · ×1
  • CachedParamMgr.reorder (cognitive 19) colossalai/legacy/nn/parallel/layers/cache_embedding/cache_mgr.py:208 — CachedParamMgr.reorder has cognitive complexity 19 (threshold 15). Drivers by points: if/else 11 (17 pts), boolean chains 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · WorkerBase._get_input_offsets_by_index (cognitive 19) · ×1
  • WorkerBase._get_input_offsets_by_index (cognitive 19) colossalai/legacy/pipeline/rpc/_pipeline_base.py:584 — WorkerBase._get_input_offsets_by_index has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (15 pts), loops 2 (4 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ColoInitContext._post_init_method (cognitive 19) · ×1
  • ColoInitContext._post_init_method (cognitive 19) colossalai/legacy/zero/gemini/colo_init_context.py:101 — ColoInitContext._post_init_method has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (11 pts), loops 5 (6 pts), boolean chains 2 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CPUAdam.step (cognitive 19) · ×1
  • CPUAdam.step (cognitive 19) colossalai/nn/optimizer/cpu_adam.py:127 — CPUAdam.step has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (16 pts), loops 2 (3 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ZeroBubbleVPipeScheduler.backward_b_step (cognitive 19) · ×1
  • ZeroBubbleVPipeScheduler.backward_b_step (cognitive 19) colossalai/pipeline/schedule/zero_bubble_pp.py:517 — ZeroBubbleVPipeScheduler.backward_b_step has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (11 pts), boolean chains 5, loops 1 (2 pts), error handling 1 (nesting depth added 3). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · RingAttention.backward (cognitive 19) · ×1
  • RingAttention.backward (cognitive 19) colossalai/shardformer/layer/attn.py:942 — RingAttention.backward has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12 (18 pts), loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SeqParallelUtils.allreduce_partial_data_grad (cognitive 19) · ×1
  • SeqParallelUtils.allreduce_partial_data_grad (cognitive 19) colossalai/shardformer/layer/utils.py:75 — SeqParallelUtils.allreduce_partial_data_grad has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 3 (6 pts), ternaries 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BloomPipelineForwards.bloom_for_question_answering_forward (cognitive 19) · ×1
  • BloomPipelineForwards.bloom_for_question_answering_forward (cognitive 19) colossalai/shardformer/modeling/bloom.py:632 — BloomPipelineForwards.bloom_for_question_answering_forward has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (14 pts), ternaries 2 (4 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FalconPipelineForwards.falcon_for_question_answering_forward (cognitive 19) · ×1
  • FalconPipelineForwards.falcon_for_question_answering_forward (cognitive 19) colossalai/shardformer/modeling/falcon.py:649 — FalconPipelineForwards.falcon_for_question_answering_forward has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (14 pts), ternaries 2 (4 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GeminiOptimizer.state_shard (cognitive 19) · ×1
  • GeminiOptimizer.state_shard (cognitive 19) colossalai/zero/gemini/gemini_optimizer.py:811 — GeminiOptimizer.state_shard has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (15 pts), loops 2 (4 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BaseProducer.__init__ (cognitive 18) · ×1
  • BaseProducer.__init__ (cognitive 18) applications/ColossalChat/coati/distributed/zero_bubble/producer.py:34 — BaseProducer.__init__ has cognitive complexity 18 (threshold 15). Drivers by points: if/else 14 (15 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · DatasetEvaluator._calculate_combined_metrics (cognitive 18) · ×1
  • DatasetEvaluator._calculate_combined_metrics (cognitive 18) REDACTED:93 — DatasetEvaluator._calculate_combined_metrics has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (8 pts), loops 4 (7 pts), ternaries 1 (3 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · gpt_evaluate.save_gpt_evaluation_statistics (cognitive 18) · ×1
  • gpt_evaluate.save_gpt_evaluation_statistics (cognitive 18) applications/ColossalEval/colossal_eval/evaluate/gpt_evaluate.py:716 — gpt_evaluate.save_gpt_evaluation_statistics has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 5 (9 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · check_pr_runner_policy.validate_private_pr_runners (cognitive 18) · ×1
  • check_pr_runner_policy.validate_private_pr_runners (cognitive 18) .github/scripts/ci/check_pr_runner_policy.py:55 — check_pr_runner_policy.validate_private_pr_runners has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (10 pts), boolean chains 3, loops 2 (3 pts), error handling 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · pr_gpu.select_idle (cognitive 18) · ×1
  • pr_gpu.select_idle (cognitive 18) .github/scripts/e1/pr_gpu.py:33 — pr_gpu.select_idle has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (14 pts), boolean chains 2, loops 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · util.compute_act_peak_mem (cognitive 18) · ×1
  • util.compute_act_peak_mem (cognitive 18) colossalai/auto_parallel/offload/util.py:46 — util.compute_act_peak_mem has cognitive complexity 18 (threshold 15). Drivers by points: if/else 2 (9 pts), loops 5 (9 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SumHandler.get_operation_data_mapping (cognitive 18) · ×1
  • SumHandler.get_operation_data_mapping (cognitive 18) colossalai/auto_parallel/tensor_shard/node_handler/sum_handler.py:26 — SumHandler.get_operation_data_mapping has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (12 pts), loops 3 (5 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · autochunk_codegen.emit_code_with_chunk (cognitive 18) · ×1
  • autochunk_codegen.emit_code_with_chunk (cognitive 18) colossalai/autochunk/autochunk_codegen.py:246 — autochunk_codegen.emit_code_with_chunk has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (17 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · HybridParallelModule.__init__ (cognitive 18) · ×1
  • HybridParallelModule.__init__ (cognitive 18) colossalai/booster/plugin/hybrid_parallel_plugin.py:66 — HybridParallelModule.__init__ has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (13 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · MoECheckpointIO.load_unsharded_optimizer (cognitive 18) · ×1
  • MoECheckpointIO.load_unsharded_optimizer (cognitive 18) colossalai/checkpoint_io/moe_checkpoint.py:930 — MoECheckpointIO.load_unsharded_optimizer has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (10 pts), loops 5 (7 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · utils.gather_state_dict_fast (cognitive 18) · ×1
  • utils.gather_state_dict_fast (cognitive 18) colossalai/checkpoint_io/utils.py:1145 — utils.gather_state_dict_fast has cognitive complexity 18 (threshold 15). Drivers by points: loops 5 (12 pts), if/else 4 (6 pts) (nesting depth added 9). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · dataflow.autograd_graph_analysis (cognitive 18) · ×1
  • dataflow.autograd_graph_analysis (cognitive 18) colossalai/fx/profiler/dataflow.py:76 — dataflow.autograd_graph_analysis has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (15 pts), loops 2 (3 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BatchInferState.init_from_batch (cognitive 18) · ×1
  • BatchInferState.init_from_batch (cognitive 18) colossalai/legacy/inference/tensor_parallel/batch_infer_state.py:63 — BatchInferState.init_from_batch has cognitive complexity 18 (threshold 15). Drivers by points: ternaries 3 (8 pts), if/else 6, loops 2 (4 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TPInferEngine.prepare_batch_state (cognitive 18) · ×1
  • TPInferEngine.prepare_batch_state (cognitive 18) colossalai/legacy/inference/tensor_parallel/engine.py:258 — TPInferEngine.prepare_batch_state has cognitive complexity 18 (threshold 15). Drivers by points: ternaries 3 (8 pts), if/else 6, loops 2 (4 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ChatGLM2InferenceForwards.chatglm_model_forward (cognitive 18) · ×1
  • ChatGLM2InferenceForwards.chatglm_model_forward (cognitive 18) colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:218 — ChatGLM2InferenceForwards.chatglm_model_forward has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 3, ternaries 3 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · WorkerBase._get_output_offsets_by_index (cognitive 18) · ×1
  • WorkerBase._get_output_offsets_by_index (cognitive 18) colossalai/legacy/pipeline/rpc/_pipeline_base.py:625 — WorkerBase._get_output_offsets_by_index has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 3 (6 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · checkpointing.partition_tensor_parallel_state_dict (cognitive 18) · ×1
  • checkpointing.partition_tensor_parallel_state_dict (cognitive 18) colossalai/legacy/utils/checkpointing.py:28 — checkpointing.partition_tensor_parallel_state_dict has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (15 pts), loops 2 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · bnb.quantize_model (cognitive 18) · ×1
  • bnb.quantize_model (cognitive 18) colossalai/quantization/bnb.py:30 — bnb.quantize_model has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 2, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CoreAttention.forward (cognitive 18) · ×1
  • CoreAttention.forward (cognitive 18) colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py:261 — CoreAttention.forward has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (16 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GLMTransformer.forward (cognitive 18) · ×1
  • GLMTransformer.forward (cognitive 18) colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py:719 — GLMTransformer.forward has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 2, ternaries 2, loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ChatGLMForConditionalGeneration.stream_chat (cognitive 18) · ×1
  • ChatGLMForConditionalGeneration.stream_chat (cognitive 18) colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py:1209 — ChatGLMForConditionalGeneration.stream_chat has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 2, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ViTPolicy.module_policy (cognitive 18) · ×1
  • ViTPolicy.module_policy (cognitive 18) colossalai/shardformer/policies/_vit_tf5.py:29 — ViTPolicy.module_policy has cognitive complexity 18 (threshold 15). Drivers by points: ternaries 3 (8 pts), if/else 5 (6 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GPT2Policy.module_policy (cognitive 18) · ×1
  • GPT2Policy.module_policy (cognitive 18) colossalai/shardformer/policies/gpt2.py:38 — GPT2Policy.module_policy has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (12 pts), boolean chains 4, ternaries 1 (2 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · ShapeConsistencyManager.get_all_shard_spec (cognitive 18) · ×1
  • ShapeConsistencyManager.get_all_shard_spec (cognitive 18) colossalai/tensor/shape_consistency.py:257 — ShapeConsistencyManager.get_all_shard_spec has cognitive complexity 18 (threshold 15). Drivers by points: loops 5 (9 pts), if/else 4 (6 pts), error handling 1 (3 pts) (nesting depth added 8). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · Chunk.shard_move (cognitive 18) · ×1
  • Chunk.shard_move (cognitive 18) colossalai/zero/gemini/chunk/chunk.py:321 — Chunk.shard_move has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 3 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · search_utils.search_chunk_configuration (cognitive 18) · ×1
  • search_utils.search_chunk_configuration (cognitive 18) colossalai/zero/gemini/chunk/search_utils.py:108 — search_utils.search_chunk_configuration has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (10 pts), loops 6 (8 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GeminiOptimizer.__init__ (cognitive 18) · ×1
  • GeminiOptimizer.__init__ (cognitive 18) colossalai/zero/gemini/gemini_optimizer.py:100 — GeminiOptimizer.__init__ has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 2, loops 2, ternaries 2 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · prepare_pretrain_dataset.main (cognitive 17) · ×1
  • prepare_pretrain_dataset.main (cognitive 17) applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:26 — prepare_pretrain_dataset.main has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), loops 4 (5 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · loader.apply_chat_template_and_mask (cognitive 17) · ×1
  • loader.apply_chat_template_and_mask (cognitive 17) applications/ColossalChat/coati/dataset/loader.py:351 — loader.apply_chat_template_and_mask has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 3, loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · metrics.classification_score (cognitive 17) · ×1
  • metrics.classification_score (cognitive 17) REDACTED:582 — metrics.classification_score has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 3 (4 pts), boolean chains 1 (nesting depth added 6). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D2 · Cognitive Complexity · MixedPrecisionOptimizer.__init__ (cognitive 17) · ×1
  • MixedPrecisionOptimizer.__init__ (cognitive 17) colossalai/amp/naive_amp/mixed_precision_optimizer.py:38 — MixedPrecisionOptimizer.__init__ has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (9 pts), loops 4 (8 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ViewGenerator.collate_strategies (cognitive 17) · ×1
  • ViewGenerator.collate_strategies (cognitive 17) colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:74 — ViewGenerator.collate_strategies has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 2 (4 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SearchChunk._search_possible_chunk_regions (cognitive 17) · ×1
  • SearchChunk._search_possible_chunk_regions (cognitive 17) colossalai/autochunk/search_chunk.py:196 — SearchChunk._search_possible_chunk_regions has cognitive complexity 17 (threshold 15). Drivers by points: if/else 3 (9 pts), loops 4 (6 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TraceIndice.trace_indice (cognitive 17) · ×1
  • TraceIndice.trace_indice (cognitive 17) colossalai/autochunk/trace_indice.py:838 — TraceIndice.trace_indice has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 1, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LowLevelZeroCheckpointIO.save_sharded_optimizer (cognitive 17) · ×1
  • LowLevelZeroCheckpointIO.save_sharded_optimizer (cognitive 17) colossalai/booster/plugin/low_level_zero_plugin.py:163 — LowLevelZeroCheckpointIO.save_sharded_optimizer has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (13 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MoECheckpointIO.save_unsharded_optimizer (cognitive 17) · ×1
  • MoECheckpointIO.save_unsharded_optimizer (cognitive 17) colossalai/checkpoint_io/moe_checkpoint.py:866 — MoECheckpointIO.save_unsharded_optimizer has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · utils.shard_optimizer_checkpoint (cognitive 17) · ×1
  • utils.shard_optimizer_checkpoint (cognitive 17) colossalai/checkpoint_io/utils.py:432 — utils.shard_optimizer_checkpoint has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 2 (5 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · activation_checkpoint_codegen._find_nested_ckpt_regions (cognitive 17) · ×1
  • activation_checkpoint_codegen._find_nested_ckpt_regions (cognitive 17) colossalai/fx/codegen/activation_checkpoint_codegen.py:253 — activation_checkpoint_codegen._find_nested_ckpt_regions has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (14 pts), boolean chains 2, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · arithmetic.torch_matmul (cognitive 17) · ×1
  • arithmetic.torch_matmul (cognitive 17) colossalai/fx/tracer/meta_patch/patched_function/arithmetic.py:8 — arithmetic.torch_matmul has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (11 pts), boolean chains 4, loops 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LLMEngine.steps_spec_dec (cognitive 17) · ×1
  • LLMEngine.steps_spec_dec (cognitive 17) colossalai/inference/core/llm_engine.py:388 — LLMEngine.steps_spec_dec has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (10 pts), ternaries 2 (4 pts), loops 2 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · NopadLlamaMLP._load_from_state_dict (cognitive 17) · ×1
  • NopadLlamaMLP._load_from_state_dict (cognitive 17) colossalai/inference/modeling/models/nopadding_llama.py:323 — NopadLlamaMLP._load_from_state_dict has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 2 (4 pts), error handling 1 (3 pts) (nesting depth added 9). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D2 · Cognitive Complexity · WorkerBase._get_output_all (cognitive 17) · ×1
  • WorkerBase._get_output_all (cognitive 17) colossalai/legacy/pipeline/rpc/_pipeline_base.py:185 — WorkerBase._get_output_all has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (14 pts), boolean chains 3 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · _mixtral_tf5._slice_fused_expert_param (cognitive 17) · ×1
  • _mixtral_tf5._slice_fused_expert_param (cognitive 17) colossalai/shardformer/modeling/_mixtral_tf5.py:52 — _mixtral_tf5._slice_fused_expert_param has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (17 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FalconPipelineForwards.falcon_for_causal_lm_forward (cognitive 17) · ×1
  • FalconPipelineForwards.falcon_for_causal_lm_forward (cognitive 17) colossalai/shardformer/modeling/falcon.py:354 — FalconPipelineForwards.falcon_for_causal_lm_forward has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), ternaries 2 (4 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OPTPipelineForwards.opt_for_question_answering_forward (cognitive 17) · ×1
  • OPTPipelineForwards.opt_for_question_answering_forward (cognitive 17) colossalai/shardformer/modeling/opt.py:461 — OPTPipelineForwards.opt_for_question_answering_forward has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (12 pts), ternaries 2 (4 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Qwen3Policy.postprocess (cognitive 17) · ×1
  • Qwen3Policy.postprocess (cognitive 17) colossalai/shardformer/policies/_qwen3_tf5.py:307 — Qwen3Policy.postprocess has cognitive complexity 17 (threshold 15). Drivers by points: if/else 3 (9 pts), loops 2 (6 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BloomPolicy.get_held_layers (cognitive 17) · ×1
  • BloomPolicy.get_held_layers (cognitive 17) colossalai/shardformer/policies/bloom.py:301 — BloomPolicy.get_held_layers has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CommandPolicy.get_held_layers (cognitive 17) · ×1
  • CommandPolicy.get_held_layers (cognitive 17) colossalai/shardformer/policies/command.py:311 — CommandPolicy.get_held_layers has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DeepseekPolicy.get_held_layers (cognitive 17) · ×1
  • DeepseekPolicy.get_held_layers (cognitive 17) colossalai/shardformer/policies/deepseek.py:320 — DeepseekPolicy.get_held_layers has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FalconPolicy.get_held_layers (cognitive 17) · ×1
  • FalconPolicy.get_held_layers (cognitive 17) colossalai/shardformer/policies/falcon.py:240 — FalconPolicy.get_held_layers has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GPTJPolicy.get_held_layers (cognitive 17) · ×1
  • GPTJPolicy.get_held_layers (cognitive 17) colossalai/shardformer/policies/gptj.py:263 — GPTJPolicy.get_held_layers has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MistralPolicy.get_held_layers (cognitive 17) · ×1
  • MistralPolicy.get_held_layers (cognitive 17) colossalai/shardformer/policies/mistral.py:294 — MistralPolicy.get_held_layers has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OPTPolicy.get_held_layers (cognitive 17) · ×1
  • OPTPolicy.get_held_layers (cognitive 17) colossalai/shardformer/policies/opt.py:287 — OPTPolicy.get_held_layers has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · gpt_evaluate.analyze_gpt_evaluation_statistics (cognitive 16) · ×1
  • gpt_evaluate.analyze_gpt_evaluation_statistics (cognitive 16) applications/ColossalEval/colossal_eval/evaluate/gpt_evaluate.py:771 — gpt_evaluate.analyze_gpt_evaluation_statistics has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (8 pts), loops 5 (8 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SynTrainingSimulator._eval_bwd_mem_per_region (cognitive 16) · ×1
  • SynTrainingSimulator._eval_bwd_mem_per_region (cognitive 16) colossalai/auto_parallel/offload/training_simulator.py:119 — SynTrainingSimulator._eval_bwd_mem_per_region has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 2 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · runtime_preparation_pass.size_processing (cognitive 16) · ×1
  • runtime_preparation_pass.size_processing (cognitive 16) colossalai/auto_parallel/passes/runtime_preparation_pass.py:21 — runtime_preparation_pass.size_processing has cognitive complexity 16 (threshold 15). Drivers by points: loops 3 (9 pts), if/else 4 (7 pts) (nesting depth added 9). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · GeneralCheckpointIO.load_sharded_model (cognitive 16) · ×1
  • GeneralCheckpointIO.load_sharded_model (cognitive 16) colossalai/checkpoint_io/general_checkpoint_io.py:271 — GeneralCheckpointIO.load_sharded_model has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (10 pts), loops 3 (5 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DeviceMesh._collate_global_ranks_in_same_process_group (cognitive 16) · ×1
  • DeviceMesh._collate_global_ranks_in_same_process_group (cognitive 16) colossalai/device/device_mesh.py:402 — DeviceMesh._collate_global_ranks_in_same_process_group has cognitive complexity 16 (threshold 15). Drivers by points: loops 5 (9 pts), if/else 2 (7 pts) (nesting depth added 9). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · InferCheckpoint_io.load_sharded_model (cognitive 16) · ×1
  • InferCheckpoint_io.load_sharded_model (cognitive 16) colossalai/inference/core/plugin.py:35 — InferCheckpoint_io.load_sharded_model has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (10 pts), boolean chains 3, loops 3 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · distrifusion.PixArtAlphaTransformer2DModel_forward (cognitive 16) · ×1
  • distrifusion.PixArtAlphaTransformer2DModel_forward (cognitive 16) colossalai/inference/modeling/layers/distrifusion.py:36 — distrifusion.PixArtAlphaTransformer2DModel_forward has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (11 pts), boolean chains 4, loops 1 (nesting depth added 3). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D2 · Cognitive Complexity · LoadBalancer._search_balance (cognitive 16) · ×1
  • LoadBalancer._search_balance (cognitive 16) colossalai/legacy/moe/load_balance.py:194 — LoadBalancer._search_balance has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 4 (7 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MoEManager.get_info (cognitive 16) · ×1
  • MoEManager.get_info (cognitive 16) colossalai/legacy/moe/manager.py:99 — MoEManager.get_info has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (11 pts), ternaries 2 (4 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ParallelCachedEmbeddingBagTablewise.split_along_rank (cognitive 16) · ×1
  • ParallelCachedEmbeddingBagTablewise.split_along_rank (cognitive 16) colossalai/legacy/nn/parallel/layers/cache_embedding/parallel_cached_embedding_tablewise.py:146 — ParallelCachedEmbeddingBagTablewise.split_along_rank has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 1, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ProcessGroup.__init__ (cognitive 16) · ×1
  • ProcessGroup.__init__ (cognitive 16) colossalai/legacy/tensor/process_group.py:52 — ProcessGroup.__init__ has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (11 pts), boolean chains 3, loops 2 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · CheckpointFunction.backward (cognitive 16) · ×1
  • CheckpointFunction.backward (cognitive 16) colossalai/legacy/utils/activation_checkpoint.py:79 — CheckpointFunction.backward has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (10 pts), loops 4, boolean chains 1, ternaries 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · common._clip_grad_norm (cognitive 16) · ×1
  • common._clip_grad_norm (cognitive 16) colossalai/legacy/utils/common.py:225 — common._clip_grad_norm has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 2 (4 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PcieProfiler.disable (cognitive 16) · ×1
  • PcieProfiler.disable (cognitive 16) colossalai/legacy/utils/profiler/legacy/pcie_profiler.py:81 — PcieProfiler.disable has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DistGaloreAdamW.setup_distributed (cognitive 16) · ×1
  • DistGaloreAdamW.setup_distributed (cognitive 16) colossalai/nn/optimizer/distributed_galore.py:94 — DistGaloreAdamW.setup_distributed has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 2 (3 pts), boolean chains 2, ternaries 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RingAttention.attention (cognitive 16) · ×1
  • RingAttention.attention (cognitive 16) colossalai/shardformer/layer/attn.py:498 — RingAttention.attention has cognitive complexity 16 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · Linear1D_Col.__init__ (cognitive 16) · ×1
  • Linear1D_Col.__init__ (cognitive 16) colossalai/shardformer/layer/linear.py:209 — Linear1D_Col.__init__ has cognitive complexity 16 (threshold 15). Drivers by points: if/else 12 (14 pts), boolean chains 2 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · GPT2FusedLinearConv1D_Col.__init__ (cognitive 16) · ×1
  • GPT2FusedLinearConv1D_Col.__init__ (cognitive 16) colossalai/shardformer/layer/qkv_fused_linear.py:222 — GPT2FusedLinearConv1D_Col.__init__ has cognitive complexity 16 (threshold 15). Drivers by points: if/else 12 (14 pts), boolean chains 2 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level. This shape REPEATS in the file: one other method here (FusedLinear1D_Col.__init__) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · FusedLinear1D_Col.__init__ (cognitive 16) · ×1
  • FusedLinear1D_Col.__init__ (cognitive 16) colossalai/shardformer/layer/qkv_fused_linear.py:816 — FusedLinear1D_Col.__init__ has cognitive complexity 16 (threshold 15). Drivers by points: if/else 12 (14 pts), boolean chains 2 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level. This shape REPEATS in the file: one other method here (GPT2FusedLinearConv1D_Col.__init__) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · Qwen2PipelineForwards.qwen2_for_causal_lm_forward (cognitive 16) · ×1
  • Qwen2PipelineForwards.qwen2_for_causal_lm_forward (cognitive 16) colossalai/shardformer/modeling/_qwen2_tf4.py:264 — Qwen2PipelineForwards.qwen2_for_causal_lm_forward has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (10 pts), ternaries 4 (6 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Qwen3PipelineForwards.qwen3_for_causal_lm_forward (cognitive 16) · ×1
  • Qwen3PipelineForwards.qwen3_for_causal_lm_forward (cognitive 16) colossalai/shardformer/modeling/_qwen3_tf4.py:262 — Qwen3PipelineForwards.qwen3_for_causal_lm_forward has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (10 pts), ternaries 4 (6 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · WhisperPipelineForwards.whisper_decoder_forward (cognitive 16) · ×1
  • WhisperPipelineForwards.whisper_decoder_forward (cognitive 16) colossalai/shardformer/modeling/_whisper_tf5.py:309 — WhisperPipelineForwards.whisper_decoder_forward has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 3, ternaries 2, loops 1 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · gpt2._get_attention_mask (cognitive 16) · ×1
  • gpt2._get_attention_mask (cognitive 16) colossalai/shardformer/modeling/gpt2.py:34 — gpt2._get_attention_mask has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Layout._sanity_check (cognitive 16) · ×1
  • Layout._sanity_check (cognitive 16) colossalai/tensor/d_tensor/layout.py:41 — Layout._sanity_check has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (8 pts), loops 4 (8 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ShapeConsistencyManager.shape_consistency (cognitive 16) · ×1
  • ShapeConsistencyManager.shape_consistency (cognitive 16) colossalai/tensor/shape_consistency.py:581 — ShapeConsistencyManager.shape_consistency has cognitive complexity 16 (threshold 15). Drivers by points: loops 4 (9 pts), if/else 3 (7 pts) (nesting depth added 9). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · utils.set_cuda_arch_list (cognitive 16) · ×1
  • utils.set_cuda_arch_list (cognitive 16) extensions/utils.py:153 — utils.set_cuda_arch_list has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (14 pts), ternaries 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D29 · Static Analysis (SAST) · REDACTED · ×1
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED · ×1
  • REDACTED
D35 · Change Coupling · Change-coupling hub · ×1
  • Change-coupling hub: mixtral.py → _operation.py, deepseek.py, deepseek.py, mixtral.py colossalai/shardformer/modeling/mixtral.py — `colossalai/shardformer/modeling/mixtral.py` changes together with 4 other files — `colossalai/moe/_operation.py`, `colossalai/shardformer/modeling/deepseek.py`, `colossalai/shardformer/policies/deepseek.py`, `colossalai/shardformer/policies/mixtral.py` — none of which declares a dependency on it: one file is the hub of 4 separate couplings, not 4 unrelated pairs. Read the hub first: if the others each duplicate a part of what it does, the shared concern belongs in ONE unit and extracting it clears every edge at once; if the hub is a registry, dispatcher or barrel that must name each of them, the coupling is structural and the question is whether that list can be discovered instead of enumerated. Fixing the hub is one change; breaking the couplings one pair at a time is 4.
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D4 · Code Duplication · Near-duplicate member family (9 members, 28 shared lines) · ×1
  • Near-duplicate member family (9 members, 28 shared lines) colossalai/shardformer/modeling/_bert_tf4.py:938 — colossalai/shardformer/modeling/_bert_tf4.py:938-1013 | colossalai/shardformer/modeling/_bert_tf5.py:951-1026 | colossalai/shardformer/modeling/bloom.py:649-723 | colossalai/shardformer/modeling/falcon.py:665-739 | colossalai/shardformer/modeling/gpt2.py:545-615 | colossalai/shardformer/modeling/gptj.py:493-564 | colossalai/shardformer/modeling/opt.py:479-539 | examples/community/roberta/pretraining/model/bert.py:1824-1882 | examples/community/roberta/pretraining/model/deberta_v2.py:1473-1530 — These 9 members are variants of one another: a block of 28 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 9 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 9 times.
D4 · Code Duplication · Near-duplicate member family (8 members, 30 shared lines) · ×1
  • Near-duplicate member family (8 members, 30 shared lines) colossalai/shardformer/modeling/_llama_tf4.py:395 — colossalai/shardformer/modeling/_llama_tf4.py:395-490 | colossalai/shardformer/modeling/_llama_tf5.py:437-532 | colossalai/shardformer/modeling/_qwen2_tf4.py:385-480 | colossalai/shardformer/modeling/bloom.py:430-535 | colossalai/shardformer/modeling/falcon.py:470-564 | colossalai/shardformer/modeling/gpt2.py:712-808 | colossalai/shardformer/modeling/gptj.py:375-472 | colossalai/shardformer/modeling/opt.py:376-458 — These 8 members are variants of one another: a block of 30 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 8 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 8 times.
D4 · Code Duplication · Near-duplicate member family (6 members, 43 shared lines) · ×1
  • Near-duplicate member family (6 members, 43 shared lines) colossalai/shardformer/modeling/_llama_tf4.py:395 — colossalai/shardformer/modeling/_llama_tf4.py:395-490 | colossalai/shardformer/modeling/_llama_tf5.py:437-532 | colossalai/shardformer/modeling/_qwen2_tf4.py:385-480 | colossalai/shardformer/modeling/_qwen2_tf5.py:295-378 | colossalai/shardformer/modeling/_qwen3_tf4.py:383-466 | colossalai/shardformer/modeling/_qwen3_tf5.py:296-379 — These 6 members are variants of one another: a block of 43 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
D4 · Code Duplication · Near-duplicate member family (6 members, 22 shared lines) · ×1
  • Near-duplicate member family (6 members, 22 shared lines) colossalai/legacy/nn/layer/parallel_2d/_operation.py:243 — colossalai/legacy/nn/layer/parallel_2d/_operation.py:243-314 | colossalai/legacy/nn/layer/parallel_2d/_operation.py:392-471 | colossalai/legacy/nn/layer/parallel_2d/_operation.py:549-628 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:198-274 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:355-439 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:520-602 — These 6 members are variants of one another: a block of 22 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
D4 · Code Duplication · Near-duplicate member family (5 members, 50 shared lines) · ×1
  • Near-duplicate member family (5 members, 50 shared lines) colossalai/shardformer/modeling/_llama_tf4.py:283 — colossalai/shardformer/modeling/_llama_tf4.py:283-374 | colossalai/shardformer/modeling/_llama_tf5.py:325-416 | colossalai/shardformer/modeling/_qwen2_tf4.py:282-365 | colossalai/shardformer/modeling/_qwen3_tf4.py:280-363 | colossalai/shardformer/modeling/command.py:261-345 — These 5 members are variants of one another: a block of 50 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication · Near-duplicate member family (5 members, 39 shared lines) · ×1
  • Near-duplicate member family (5 members, 39 shared lines) colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:112 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:112-175 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:179-235 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:239-305 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:310-381 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:386-460 — These 5 members are variants of one another: a block of 39 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication · Near-duplicate member family (5 members, 30 shared lines) · ×1
  • Near-duplicate member family (5 members, 30 shared lines) colossalai/shardformer/modeling/_qwen2_tf4.py:282 — colossalai/shardformer/modeling/_qwen2_tf4.py:282-365 | colossalai/shardformer/modeling/_qwen2_tf5.py:191-275 | colossalai/shardformer/modeling/_qwen3_tf4.py:280-363 | colossalai/shardformer/modeling/_qwen3_tf5.py:192-276 | colossalai/shardformer/modeling/command.py:261-345 — These 5 members are variants of one another: a block of 30 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 54 shared lines) · ×1
  • Near-duplicate member family (4 members, 54 shared lines) colossalai/legacy/moe/openmoe/model/openmoe_policy.py:428 — colossalai/legacy/moe/openmoe/model/openmoe_policy.py:428-565 | colossalai/shardformer/modeling/_llama_tf4.py:283-374 | colossalai/shardformer/modeling/_llama_tf5.py:325-416 | colossalai/shardformer/modeling/command.py:261-345 — These 4 members are variants of one another: a block of 54 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 48 shared lines) · ×1
  • Near-duplicate member family (4 members, 48 shared lines) colossalai/shardformer/modeling/_llama_tf4.py:395 — colossalai/shardformer/modeling/_llama_tf4.py:395-490 | colossalai/shardformer/modeling/_llama_tf5.py:437-532 | colossalai/shardformer/modeling/_qwen2_tf4.py:385-480 | colossalai/shardformer/modeling/mistral.py:292-372 — These 4 members are variants of one another: a block of 48 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 28 shared lines) · ×1
  • Near-duplicate member family (4 members, 28 shared lines) colossalai/shardformer/modeling/_bert_tf4.py:384 — colossalai/shardformer/modeling/_bert_tf4.py:384-469 | colossalai/shardformer/modeling/_bert_tf4.py:491-548 | colossalai/shardformer/modeling/_bert_tf5.py:397-482 | colossalai/shardformer/modeling/_bert_tf5.py:504-561 — These 4 members are variants of one another: a block of 28 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 22 shared lines) · ×1
  • Near-duplicate member family (4 members, 22 shared lines) colossalai/shardformer/modeling/_bert_tf4.py:845 — colossalai/shardformer/modeling/_bert_tf4.py:845-916 | colossalai/shardformer/modeling/_bert_tf5.py:858-929 | examples/community/roberta/pretraining/model/bert.py:1639-1690 | examples/community/roberta/pretraining/model/deberta_v2.py:1583-1633 — These 4 members are variants of one another: a block of 22 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (3 members, 73 shared lines) · ×1
  • Near-duplicate member family (3 members, 73 shared lines) colossalai/kernel/triton/context_attn_unpad.py:51 — colossalai/kernel/triton/context_attn_unpad.py:51-185 | colossalai/kernel/triton/context_attn_unpad.py:229-363 | colossalai/kernel/triton/context_attn_unpad.py:404-549 — These 3 members are variants of one another: a block of 73 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication · Near-duplicate member family (3 members, 49 shared lines) · ×1
  • Near-duplicate member family (3 members, 49 shared lines) applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:27 — applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:27-138 | applications/Colossal-LLaMA/dataset/prepare_sft_dataset.py:24-145 | applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py:53-268 — These 3 members are variants of one another: a block of 49 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication · Near-duplicate member family (3 members, 39 shared lines) · ×1
  • Near-duplicate member family (3 members, 39 shared lines) colossalai/shardformer/modeling/_mixtral_tf4.py:673 — colossalai/shardformer/modeling/_mixtral_tf4.py:673-866 | colossalai/shardformer/modeling/_mixtral_tf5.py:1063-1246 | colossalai/shardformer/modeling/deepseek.py:708-861 — These 3 members are variants of one another: a block of 39 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication · Near-duplicate member pair (319 shared lines) · ×1
  • Near-duplicate member pair (319 shared lines) applications/ColossalChat/coati/distributed/grpo_consumer.py:175 — applications/ColossalChat/coati/distributed/grpo_consumer.py:175-605 | applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py:165-529 — These two members are variants of one another: 319 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (169 shared lines) · ×1
  • Near-duplicate member pair (169 shared lines) colossalai/shardformer/policies/_whisper_tf4.py:45 — colossalai/shardformer/policies/_whisper_tf4.py:45-503 | colossalai/shardformer/policies/_whisper_tf5.py:45-490 — These two members are variants of one another: 169 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (153 shared lines) · ×1
  • Near-duplicate member pair (153 shared lines) colossalai/shardformer/modeling/gptj.py:650 — colossalai/shardformer/modeling/gptj.py:650-822 | colossalai/shardformer/modeling/gptj.py:826-1014 — These two members are variants of one another: 153 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (125 shared lines) · ×1
  • Near-duplicate member pair (125 shared lines) applications/ColossalChat/coati/distributed/producer.py:220 — applications/ColossalChat/coati/distributed/producer.py:220-415 | applications/ColossalChat/coati/distributed/zero_bubble/producer.py:213-439 — These two members are variants of one another: 125 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (113 shared lines) · ×1
  • Near-duplicate member pair (113 shared lines) colossalai/shardformer/modeling/_bert_tf4.py:63 — colossalai/shardformer/modeling/_bert_tf4.py:63-283 | colossalai/shardformer/modeling/_bert_tf5.py:65-296 — These two members are variants of one another: 113 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (88 shared lines) · ×1
  • Near-duplicate member pair (88 shared lines) applications/ColossalChat/coati/distributed/producer.py:61 — applications/ColossalChat/coati/distributed/producer.py:61-196 | applications/ColossalChat/coati/distributed/zero_bubble/producer.py:61-191 — These two members are variants of one another: 88 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (85 shared lines) · ×1
  • Near-duplicate member pair (85 shared lines) colossalai/shardformer/modeling/_mixtral_tf4.py:427 — colossalai/shardformer/modeling/_mixtral_tf4.py:427-535 | colossalai/shardformer/modeling/_mixtral_tf5.py:793-913 — These two members are variants of one another: 85 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (72 shared lines) · ×1
  • Near-duplicate member pair (72 shared lines) colossalai/booster/plugin/hybrid_parallel_plugin.py:996 — colossalai/booster/plugin/hybrid_parallel_plugin.py:996-1201 | colossalai/booster/plugin/moe_hybrid_parallel_plugin.py:227-414 — These two members are variants of one another: 72 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (64 shared lines) · ×1
  • Near-duplicate member pair (64 shared lines) colossalai/nn/optimizer/distributed_adafactor.py:287 — colossalai/nn/optimizer/distributed_adafactor.py:287-440 | colossalai/nn/optimizer/distributed_came.py:334-554 — These two members are variants of one another: 64 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (60 shared lines) · ×1
  • Near-duplicate member pair (60 shared lines) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:416 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:416-514 | colossalai/inference/core/plugin.py:36-129 — These two members are variants of one another: 60 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (50 shared lines) · ×1
  • Near-duplicate member pair (50 shared lines) colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:880 — colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:880-987 | colossalai/legacy/moe/openmoe/model/openmoe_policy.py:428-565 — These two members are variants of one another: 50 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (43 shared lines) · ×1
  • Near-duplicate member pair (43 shared lines) colossalai/shardformer/modeling/_deepseek_v3_tf4.py:161 — colossalai/shardformer/modeling/_deepseek_v3_tf4.py:161-279 | colossalai/shardformer/modeling/_deepseek_v3_tf5.py:190-304 — These two members are variants of one another: 43 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (37 shared lines) · ×1
  • Near-duplicate member pair (37 shared lines) colossalai/legacy/inference/quant/smoothquant/models/llama.py:427 — colossalai/legacy/inference/quant/smoothquant/models/llama.py:427-509 | colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:335-439 — These two members are variants of one another: 37 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (35 shared lines) · ×1
  • Near-duplicate member pair (35 shared lines) colossalai/inference/kv_cache/kvcache_manager.py:49 — colossalai/inference/kv_cache/kvcache_manager.py:49-124 | colossalai/inference/kv_cache/kvcache_manager.py:526-576 — These two members are variants of one another: 35 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Edited copy of a member (50 corresponding lines) · ×1
  • Edited copy of a member (50 corresponding lines) colossalai/legacy/moe/layer/experts.py:112 — colossalai/legacy/moe/layer/experts.py:112-161 | colossalai/legacy/moe/layer/routers.py:112-161 — These two members are one piece of code written twice and then edited apart: 50 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (75 corresponding lines) · ×1
  • Edited copy of a member (75 corresponding lines) colossalai/shardformer/modeling/_bert_tf4.py:676 — colossalai/shardformer/modeling/_bert_tf4.py:676-750 | colossalai/shardformer/modeling/_bert_tf5.py:689-763 — These two members are one piece of code written twice and then edited apart: 75 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (38 corresponding lines) · ×1
  • Edited copy of a member (38 corresponding lines) colossalai/legacy/inference/tensor_parallel/batch_infer_state.py:70 — colossalai/legacy/inference/tensor_parallel/batch_infer_state.py:70-119 | colossalai/legacy/inference/tensor_parallel/engine.py:259-326 — These two members are one piece of code written twice and then edited apart: 38 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (56 corresponding lines) · ×1
  • Edited copy of a member (56 corresponding lines) colossalai/shardformer/modeling/_bert_tf4.py:770 — colossalai/shardformer/modeling/_bert_tf4.py:770-825 | colossalai/shardformer/modeling/_bert_tf5.py:783-838 — These two members are one piece of code written twice and then edited apart: 56 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (22 corresponding lines) · ×1
  • Edited copy of a member (22 corresponding lines) colossalai/fx/tracer/meta_patch/patched_module/pooling.py:113 — colossalai/fx/tracer/meta_patch/patched_module/pooling.py:113-136 | colossalai/fx/tracer/meta_patch/patched_module/pooling.py:141-166 — These two members are one piece of code written twice and then edited apart: 22 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (16 corresponding lines) · ×1
  • Edited copy of a member (16 corresponding lines) colossalai/legacy/engine/schedule/_pipeline_schedule.py:53 — colossalai/legacy/engine/schedule/_pipeline_schedule.py:53-68 | colossalai/legacy/engine/schedule/_pipeline_schedule_v2.py:18-33 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (39 corresponding lines) · ×1
  • Edited copy of a member (39 corresponding lines) colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:395 — colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:395-545 | colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py:445-543 — These two members are one piece of code written twice and then edited apart: 39 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (21 corresponding lines) · ×1
  • Edited copy of a member (21 corresponding lines) colossalai/fx/tracer/meta_patch/patched_module/pooling.py:33 — colossalai/fx/tracer/meta_patch/patched_module/pooling.py:33-55 | colossalai/fx/tracer/meta_patch/patched_module/pooling.py:60-84 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (11 corresponding lines) · ×1
  • Edited copy of a member (11 corresponding lines) colossalai/legacy/moe/layer/experts.py:94 — colossalai/legacy/moe/layer/experts.py:94-104 | colossalai/legacy/moe/layer/routers.py:94-104 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (23 corresponding lines) · ×1
  • Edited copy of a member (23 corresponding lines) colossalai/legacy/nn/layer/parallel_2d/layers.py:146 — colossalai/legacy/nn/layer/parallel_2d/layers.py:146-171 | colossalai/legacy/nn/layer/parallel_2d/layers.py:1139-1166 — These two members are one piece of code written twice and then edited apart: 23 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (12 corresponding lines) · ×1
  • Edited copy of a member (12 corresponding lines) colossalai/fx/tracer/meta_patch/patched_function/convolution.py:134 — colossalai/fx/tracer/meta_patch/patched_function/convolution.py:134-155 | colossalai/fx/tracer/meta_patch/patched_function/convolution.py:160-185 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Members sharing a duplicated core (16 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (16 members, 50+ identical tokens) colossalai/legacy/context/process_group_initializer/initializer_1d.py:31 — colossalai/legacy/context/process_group_initializer/initializer_1d.py:31-57 | colossalai/legacy/context/process_group_initializer/initializer_2d.py:45-70 | colossalai/legacy/context/process_group_initializer/initializer_2d.py:93-119 | colossalai/legacy/context/process_group_initializer/initializer_2p5d.py:60-90 | colossalai/legacy/context/process_group_initializer/initializer_2p5d.py:114-144 | colossalai/legacy/context/process_group_initializer/initializer_2p5d.py:168-198 | colossalai/legacy/context/process_group_initializer/initializer_2p5d.py:223-253 | colossalai/legacy/context/process_group_initializer/initializer_3d.py:48-76 | colossalai/legacy/context/process_group_initializer/initializer_3d.py:99-127 | colossalai/legacy/context/process_group_initializer/initializer_3d.py:150-178 | colossalai/legacy/context/process_group_initializer/initializer_3d.py:201-232 | colossalai/legacy/context/process_group_initializer/initializer_3d.py:255-286 | colossalai/legacy/context/process_group_initializer/initializer_data.py:30-55 | colossalai/legacy/context/process_group_initializer/initializer_model.py:32-57 | colossalai/legacy/context/process_group_initializer/initializer_sequence.py:34-58 | colossalai/legacy/context/process_group_initializer/initializer_tensor.py:30-55 — These 16 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 16 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 16 times.
D4 · Code Duplication · Members sharing a duplicated core (12 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (12 members, 50+ identical tokens) colossalai/shardformer/policies/_llama_tf4.py:36 — colossalai/shardformer/policies/_llama_tf4.py:36-298 | colossalai/shardformer/policies/_llama_tf5.py:36-296 | colossalai/shardformer/policies/_mixtral_tf4.py:43-282 | colossalai/shardformer/policies/_mixtral_tf5.py:45-309 | colossalai/shardformer/policies/_qwen2_tf4.py:57-305 | colossalai/shardformer/policies/_qwen2_tf5.py:57-304 | colossalai/shardformer/policies/_qwen3_tf4.py:57-305 | colossalai/shardformer/policies/_qwen3_tf5.py:58-305 | colossalai/shardformer/policies/command.py:39-276 | colossalai/shardformer/policies/gptj.py:37-258 | colossalai/shardformer/policies/mistral.py:41-259 | colossalai/shardformer/policies/opt.py:53-282 — These 12 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 12 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 12 times.
D4 · Code Duplication · Duplicated block (123 lines × 2) · ×1
  • Duplicated block (123 lines × 2) colossalai/shardformer/modeling/_qwen2_tf4.py:634 — colossalai/shardformer/modeling/_qwen2_tf4.py:634-756 | colossalai/shardformer/modeling/_qwen3_tf4.py:626-748 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf4.py` and `colossalai/shardformer/modeling/_qwen3_tf4.py` as WHOLE FILES: this scan already matched 52 separate duplicated blocks between them, totalling at least 1214 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_qwen2_tf4.py:634` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (117 lines × 2) · ×1
  • Duplicated block (117 lines × 2) applications/ColossalChat/coati/distributed/grpo_consumer.py:260 — applications/ColossalChat/coati/distributed/grpo_consumer.py:260-376 | applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py:234-350 — before extracting anything, compare `applications/ColossalChat/coati/distributed/grpo_consumer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 407 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (110 lines × 2) · ×1
  • Duplicated block (110 lines × 2) colossalai/shardformer/modeling/_qwen2_tf5.py:61 — colossalai/shardformer/modeling/_qwen2_tf5.py:61-170 | colossalai/shardformer/modeling/_qwen3_tf5.py:62-171 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf5.py` and `colossalai/shardformer/modeling/_qwen3_tf5.py` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 628 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (96 lines × 2) · ×1
  • Duplicated block (96 lines × 2) colossalai/shardformer/policies/_bert_tf4.py:265 — colossalai/shardformer/policies/_bert_tf4.py:265-360 | colossalai/shardformer/policies/_bert_tf5.py:272-367 — before extracting anything, compare `colossalai/shardformer/policies/_bert_tf4.py` and `colossalai/shardformer/policies/_bert_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 475 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/policies/_bert_tf4.py:265` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (93–95 lines × 2) · ×1
  • Duplicated block (93–95 lines × 2) colossalai/shardformer/modeling/_qwen2_tf4.py:95 — colossalai/shardformer/modeling/_qwen2_tf4.py:95-189 | colossalai/shardformer/modeling/_qwen3_tf4.py:95-187 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf4.py` and `colossalai/shardformer/modeling/_qwen3_tf4.py` as WHOLE FILES: this scan already matched 52 separate duplicated blocks between them, totalling at least 1214 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (94 lines × 2) · ×1
  • Duplicated block (94 lines × 2) colossalai/shardformer/modeling/_whisper_tf4.py:1017 — colossalai/shardformer/modeling/_whisper_tf4.py:1017-1110 | colossalai/shardformer/modeling/_whisper_tf5.py:532-625 — before extracting anything, compare `colossalai/shardformer/modeling/_whisper_tf4.py` and `colossalai/shardformer/modeling/_whisper_tf5.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 257 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (89 lines × 2) · ×1
  • Duplicated block (89 lines × 2) colossalai/shardformer/policies/_whisper_tf4.py:372 — colossalai/shardformer/policies/_whisper_tf4.py:372-460 | colossalai/shardformer/policies/_whisper_tf5.py:373-461 — before extracting anything, compare `colossalai/shardformer/policies/_whisper_tf4.py` and `colossalai/shardformer/policies/_whisper_tf5.py` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/policies/_whisper_tf4.py:372` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (86 lines × 2) · ×1
  • Duplicated block (86 lines × 2) colossalai/shardformer/policies/_whisper_tf4.py:594 — colossalai/shardformer/policies/_whisper_tf4.py:594-679 | colossalai/shardformer/policies/_whisper_tf5.py:581-666 — before extracting anything, compare `colossalai/shardformer/policies/_whisper_tf4.py` and `colossalai/shardformer/policies/_whisper_tf5.py` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note first that the copies are not typed on the same thing: `WhisperForConditionalGeneration` names `transformers` in one and `transformers.models.whisper.modeling_whisper` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (16–84 lines × 6) · ×1
  • Duplicated block (16–84 lines × 6) colossalai/shardformer/modeling/_qwen2_tf4.py:772 — colossalai/shardformer/modeling/_qwen2_tf4.py:772-807 | colossalai/shardformer/modeling/_qwen3_tf4.py:764-799 | colossalai/shardformer/modeling/bloom.py:1106-1121 | colossalai/shardformer/modeling/falcon.py:753-768 | colossalai/shardformer/modeling/mistral.py:568-603 | colossalai/shardformer/modeling/opt.py:855-938 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf4.py` and `colossalai/shardformer/modeling/_qwen3_tf4.py` as WHOLE FILES: this scan already matched 52 separate duplicated blocks between them, totalling at least 1214 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_qwen2_tf4.py:772` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (74–77 lines × 2) · ×1
  • Duplicated block (74–77 lines × 2) colossalai/shardformer/policies/_mixtral_tf4.py:209 — colossalai/shardformer/policies/_mixtral_tf4.py:209-282 | colossalai/shardformer/policies/_mixtral_tf5.py:233-309 — before extracting anything, compare `colossalai/shardformer/policies/_mixtral_tf4.py` and `colossalai/shardformer/policies/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 408 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/policies/_mixtral_tf4.py:209` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (74 lines × 2) · ×1
  • Duplicated block (74 lines × 2) REDACTED:335 — REDACTED:335-408 | REDACTED:218-291 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 157 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (73–74 lines × 2) · ×1
  • Duplicated block (73–74 lines × 2) colossalai/shardformer/policies/_llama_tf4.py:36 — colossalai/shardformer/policies/_llama_tf4.py:36-108 | colossalai/shardformer/policies/_llama_tf5.py:36-109 — before extracting anything, compare `colossalai/shardformer/policies/_llama_tf4.py` and `colossalai/shardformer/policies/_llama_tf5.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 404 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/shardformer/policies/_llama_tf4.py:109` calls `getattr` and `colossalai/shardformer/policies/_llama_tf5.py:111` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (71 lines × 2) · ×1
  • Duplicated block (71 lines × 2) colossalai/shardformer/policies/_mixtral_tf4.py:51 — colossalai/shardformer/policies/_mixtral_tf4.py:51-121 | colossalai/shardformer/policies/_mixtral_tf5.py:57-127 — before extracting anything, compare `colossalai/shardformer/policies/_mixtral_tf4.py` and `colossalai/shardformer/policies/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 408 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/policies/_mixtral_tf4.py:51` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/policies/_mixtral_tf5.py:56` calls `NotImplementedError` and `colossalai/shardformer/policies/_mixtral_tf4.py:50` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (69–70 lines × 2) · ×1
  • Duplicated block (69–70 lines × 2) colossalai/shardformer/modeling/_qwen2_tf5.py:539 — colossalai/shardformer/modeling/_qwen2_tf5.py:539-607 | colossalai/shardformer/modeling/_qwen3_tf5.py:540-609 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf5.py` and `colossalai/shardformer/modeling/_qwen3_tf5.py` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 628 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_qwen2_tf5.py:539` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (68 lines × 2) · ×1
  • Duplicated block (68 lines × 2) colossalai/shardformer/modeling/_bert_tf4.py:384 — colossalai/shardformer/modeling/_bert_tf4.py:384-451 | colossalai/shardformer/modeling/_bert_tf5.py:397-464 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (67–68 lines × 2) · ×1
  • Duplicated block (67–68 lines × 2) colossalai/shardformer/modeling/t5.py:293 — colossalai/shardformer/modeling/t5.py:293-359 | colossalai/shardformer/modeling/t5.py:433-500 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/shardformer/modeling/t5.py:504` calls `_shift_right` and `colossalai/shardformer/modeling/t5.py:362` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (67 lines × 2) · ×1
  • Duplicated block (67 lines × 2) colossalai/shardformer/modeling/_whisper_tf4.py:913 — colossalai/shardformer/modeling/_whisper_tf4.py:913-979 | colossalai/shardformer/modeling/_whisper_tf5.py:428-494 — before extracting anything, compare `colossalai/shardformer/modeling/_whisper_tf4.py` and `colossalai/shardformer/modeling/_whisper_tf5.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 257 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (65 lines × 2) · ×1
  • Duplicated block (65 lines × 2) colossalai/shardformer/modeling/_qwen2_tf4.py:197 — colossalai/shardformer/modeling/_qwen2_tf4.py:197-261 | colossalai/shardformer/modeling/_qwen3_tf4.py:195-259 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf4.py` and `colossalai/shardformer/modeling/_qwen3_tf4.py` as WHOLE FILES: this scan already matched 52 separate duplicated blocks between them, totalling at least 1214 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_qwen2_tf4.py:197` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (64–65 lines × 2) · ×1
  • Duplicated block (64–65 lines × 2) colossalai/shardformer/modeling/_whisper_tf4.py:1130 — colossalai/shardformer/modeling/_whisper_tf4.py:1130-1193 | colossalai/shardformer/modeling/_whisper_tf5.py:645-709 — before extracting anything, compare `colossalai/shardformer/modeling/_whisper_tf4.py` and `colossalai/shardformer/modeling/_whisper_tf5.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 257 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (53–58 lines × 2) · ×1
  • Duplicated block (53–58 lines × 2) colossalai/shardformer/policies/_deepseek_v3_tf4.py:29 — colossalai/shardformer/policies/_deepseek_v3_tf4.py:29-81 | colossalai/shardformer/policies/_deepseek_v3_tf5.py:29-86 — before extracting anything, compare `colossalai/shardformer/policies/_deepseek_v3_tf4.py` and `colossalai/shardformer/policies/_deepseek_v3_tf5.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 150 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (54 lines × 2) · ×1
  • Duplicated block (54 lines × 2) colossalai/shardformer/modeling/gptj.py:740 — colossalai/shardformer/modeling/gptj.py:740-793 | colossalai/shardformer/modeling/gptj.py:924-977 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (38–51 lines × 4) · ×1
  • Duplicated block (38–51 lines × 4) colossalai/shardformer/policies/_qwen2_tf4.py:404 — colossalai/shardformer/policies/_qwen2_tf4.py:404-454 | colossalai/shardformer/policies/_qwen2_tf5.py:403-453 | colossalai/shardformer/policies/_qwen3_tf4.py:403-440 | colossalai/shardformer/policies/_qwen3_tf5.py:423-464 — before extracting anything, compare `colossalai/shardformer/policies/_qwen2_tf4.py` and `colossalai/shardformer/policies/_qwen2_tf5.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 399 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/policies/_qwen2_tf4.py:404` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (45–49 lines × 2) · ×1
  • Duplicated block (45–49 lines × 2) colossalai/shardformer/modeling/_qwen2_tf4.py:521 — colossalai/shardformer/modeling/_qwen2_tf4.py:521-565 | colossalai/shardformer/modeling/_qwen3_tf4.py:507-555 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf4.py` and `colossalai/shardformer/modeling/_qwen3_tf4.py` as WHOLE FILES: this scan already matched 52 separate duplicated blocks between them, totalling at least 1214 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_qwen3_tf4.py:507` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (46–48 lines × 2) · ×1
  • Duplicated block (46–48 lines × 2) applications/ColossalChat/coati/trainer/dpo.py:162 — applications/ColossalChat/coati/trainer/dpo.py:162-207 | applications/ColossalChat/coati/trainer/dpo.py:453-500 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/trainer/dpo.py:162` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (45–46 lines × 2) · ×1
  • Duplicated block (45–46 lines × 2) applications/Colossal-LLaMA/colossal_llama/dataset/loader.py:64 — applications/Colossal-LLaMA/colossal_llama/dataset/loader.py:64-109 | applications/ColossalChat/coati/dataset/loader.py:70-114 — before extracting anything, compare `applications/Colossal-LLaMA/colossal_llama/dataset/loader.py` and `applications/ColossalChat/coati/dataset/loader.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 90 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (40–45 lines × 9) · ×1
  • Duplicated block (40–45 lines × 9) colossalai/shardformer/policies/_llama_tf4.py:475 — colossalai/shardformer/policies/_llama_tf4.py:475-519 | colossalai/shardformer/policies/_llama_tf5.py:473-517 | colossalai/shardformer/policies/_mixtral_tf4.py:375-415 | colossalai/shardformer/policies/_mixtral_tf5.py:402-442 | colossalai/shardformer/policies/_qwen2_tf4.py:493-533 | colossalai/shardformer/policies/_qwen2_tf5.py:492-532 | colossalai/shardformer/policies/_qwen3_tf4.py:479-518 | colossalai/shardformer/policies/_qwen3_tf5.py:503-542 | colossalai/shardformer/policies/deepseek.py:382-424 — before extracting anything, compare `colossalai/shardformer/policies/_llama_tf4.py` and `colossalai/shardformer/policies/_llama_tf5.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 404 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/policies/_llama_tf4.py:475` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (44–45 lines × 3) · ×1
  • Duplicated block (44–45 lines × 3) colossalai/shardformer/modeling/bloom.py:338 — colossalai/shardformer/modeling/bloom.py:338-381 | colossalai/shardformer/modeling/bloom.py:430-474 | colossalai/shardformer/modeling/bloom.py:556-600 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication · Duplicated block (44 lines × 4) · ×1
  • Duplicated block (44 lines × 4) colossalai/shardformer/modeling/_qwen2_tf4.py:776 — colossalai/shardformer/modeling/_qwen2_tf4.py:776-819 | colossalai/shardformer/modeling/_qwen3_tf4.py:768-811 | colossalai/shardformer/modeling/command.py:588-631 | colossalai/shardformer/modeling/mistral.py:572-615 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf4.py` and `colossalai/shardformer/modeling/_qwen3_tf4.py` as WHOLE FILES: this scan already matched 52 separate duplicated blocks between them, totalling at least 1214 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_qwen2_tf4.py:776` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (44 lines × 2) · ×1
  • Duplicated block (44 lines × 2) applications/ColossalChat/coati/models/generation.py:143 — applications/ColossalChat/coati/models/generation.py:143-186 | applications/ColossalChat/coati/models/generation.py:310-353 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (40–43 lines × 2) · ×1
  • Duplicated block (40–43 lines × 2) applications/Colossal-LLaMA/colossal_llama/utils/stream_chat_patch.py:200 — applications/Colossal-LLaMA/colossal_llama/utils/stream_chat_patch.py:200-242 | colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py:1325-1364 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `applications/Colossal-LLaMA/colossal_llama/utils/stream_chat_patch.py:200` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (41 lines × 2) · ×1
  • Duplicated block (41 lines × 2) colossalai/shardformer/policies/_whisper_tf4.py:682 — colossalai/shardformer/policies/_whisper_tf4.py:682-722 | colossalai/shardformer/policies/_whisper_tf5.py:669-709 — before extracting anything, compare `colossalai/shardformer/policies/_whisper_tf4.py` and `colossalai/shardformer/policies/_whisper_tf5.py` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: `WhisperForConditionalGeneration` names `transformers` in one and `transformers.models.whisper.modeling_whisper` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (39–40 lines × 7) · ×1
  • Duplicated block (39–40 lines × 7) colossalai/legacy/moe/openmoe/model/openmoe_policy.py:428 — colossalai/legacy/moe/openmoe/model/openmoe_policy.py:428-466 | colossalai/shardformer/modeling/_llama_tf4.py:283-321 | colossalai/shardformer/modeling/_llama_tf5.py:325-363 | colossalai/shardformer/modeling/_qwen2_tf4.py:282-321 | colossalai/shardformer/modeling/_qwen3_tf4.py:280-319 | colossalai/shardformer/modeling/command.py:261-299 | colossalai/shardformer/modeling/deepseek.py:493-532 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 7 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 7 times.
D4 · Code Duplication · Duplicated block (36–40 lines × 2) · ×1
  • Duplicated block (36–40 lines × 2) colossalai/legacy/engine/schedule/_pipeline_schedule.py:322 — colossalai/legacy/engine/schedule/_pipeline_schedule.py:322-357 | colossalai/legacy/engine/schedule/_pipeline_schedule_v2.py:65-104 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
D4 · Code Duplication · Duplicated block (37–40 lines × 2) · ×1
  • Duplicated block (37–40 lines × 2) colossalai/legacy/inference/tensor_parallel/batch_infer_state.py:70 — colossalai/legacy/inference/tensor_parallel/batch_infer_state.py:70-106 | colossalai/legacy/inference/tensor_parallel/engine.py:275-314 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
D4 · Code Duplication · Duplicated block (39–40 lines × 2) · ×1
  • Duplicated block (39–40 lines × 2) colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:400 — colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:400-439 | colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py:445-483 — before extracting anything, compare `colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py` and `colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 176 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (36–39 lines × 2) · ×1
  • Duplicated block (36–39 lines × 2) colossalai/booster/plugin/hybrid_parallel_plugin.py:408 — colossalai/booster/plugin/hybrid_parallel_plugin.py:408-443 | colossalai/booster/plugin/hybrid_parallel_plugin.py:611-649 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (39 lines × 2) · ×1
  • Duplicated block (39 lines × 2) colossalai/tensor/d_tensor/layout_converter.py:195 — colossalai/tensor/d_tensor/layout_converter.py:195-233 | colossalai/tensor/shape_consistency.py:183-221 — before extracting anything, compare `colossalai/tensor/d_tensor/layout_converter.py` and `colossalai/tensor/shape_consistency.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 72 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/tensor/d_tensor/layout_converter.py:195` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (37–38 lines × 2) · ×1
  • Duplicated block (37–38 lines × 2) colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:777 — colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:777-814 | colossalai/legacy/moe/openmoe/model/openmoe_policy.py:338-374 — before extracting anything, compare `colossalai/legacy/moe/openmoe/model/modeling_openmoe.py` and `colossalai/legacy/moe/openmoe/model/openmoe_policy.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 95 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/legacy/moe/openmoe/model/openmoe_policy.py:376` calls `is_last_stage` and `colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:816` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (15–38 lines × 2) · ×1
  • Duplicated block (15–38 lines × 2) colossalai/shardformer/modeling/_vit_tf5.py:69 — colossalai/shardformer/modeling/_vit_tf5.py:69-83 | colossalai/shardformer/modeling/_vit_tf5.py:161-198 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_vit_tf5.py:69` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (37 lines × 3) · ×1
  • Duplicated block (37 lines × 3) colossalai/shardformer/policies/_deepseek_v3_tf4.py:39 — colossalai/shardformer/policies/_deepseek_v3_tf4.py:39-75 | colossalai/shardformer/policies/_deepseek_v3_tf5.py:44-80 | colossalai/shardformer/policies/deepseek.py:219-258 — before extracting anything, compare `colossalai/shardformer/policies/_deepseek_v3_tf4.py` and `colossalai/shardformer/policies/_deepseek_v3_tf5.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 150 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/policies/_deepseek_v3_tf4.py:39` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (34–37 lines × 2) · ×1
  • Duplicated block (34–37 lines × 2) colossalai/shardformer/modeling/_llama_tf4.py:198 — colossalai/shardformer/modeling/_llama_tf4.py:198-231 | colossalai/shardformer/modeling/command.py:183-219 — before extracting anything, compare `colossalai/shardformer/modeling/_llama_tf4.py` and `colossalai/shardformer/modeling/command.py` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 210 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_llama_tf4.py:198` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (33–36 lines × 6) · ×1
  • Duplicated block (33–36 lines × 6) colossalai/legacy/moe/openmoe/model/openmoe_policy.py:262 — colossalai/legacy/moe/openmoe/model/openmoe_policy.py:262-294 | colossalai/shardformer/modeling/_mixtral_tf4.py:240-273 | colossalai/shardformer/modeling/_mixtral_tf5.py:584-617 | colossalai/shardformer/modeling/_qwen2_tf4.py:71-106 | colossalai/shardformer/modeling/_qwen3_tf4.py:71-104 | colossalai/shardformer/modeling/deepseek.py:337-370 — before extracting anything, compare `colossalai/legacy/moe/openmoe/model/openmoe_policy.py` and `colossalai/shardformer/modeling/_mixtral_tf4.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 130 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (35–36 lines × 4) · ×1
  • Duplicated block (35–36 lines × 4) colossalai/shardformer/modeling/_mixtral_tf4.py:202 — colossalai/shardformer/modeling/_mixtral_tf4.py:202-237 | colossalai/shardformer/modeling/_mixtral_tf4.py:427-461 | colossalai/shardformer/modeling/_mixtral_tf5.py:547-581 | colossalai/shardformer/modeling/_mixtral_tf5.py:793-827 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 581 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (35–36 lines × 3) · ×1
  • Duplicated block (35–36 lines × 3) colossalai/shardformer/layer/_operation.py:127 — colossalai/shardformer/layer/_operation.py:127-161 | colossalai/shardformer/layer/_operation.py:209-244 | colossalai/shardformer/layer/_operation.py:941-975 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication · Duplicated block (36 lines × 3) · ×1
  • Duplicated block (36 lines × 3) colossalai/shardformer/modeling/_qwen2_tf5.py:337 — colossalai/shardformer/modeling/_qwen2_tf5.py:337-372 | colossalai/shardformer/modeling/_qwen3_tf4.py:425-460 | colossalai/shardformer/modeling/_qwen3_tf5.py:338-373 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf5.py` and `colossalai/shardformer/modeling/_qwen3_tf4.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 255 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_qwen2_tf5.py:337` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (13–36 lines × 2) · ×1
  • Duplicated block (13–36 lines × 2) colossalai/shardformer/modeling/_vit_tf4.py:148 — colossalai/shardformer/modeling/_vit_tf4.py:148-160 | colossalai/shardformer/modeling/_vit_tf4.py:236-271 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_vit_tf4.py:148` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (35 lines × 4) · ×1
  • Duplicated block (35 lines × 4) colossalai/shardformer/layer/_operation.py:298 — colossalai/shardformer/layer/_operation.py:298-332 | colossalai/shardformer/layer/_operation.py:377-411 | colossalai/shardformer/layer/_operation.py:605-639 | colossalai/shardformer/layer/_operation.py:780-814 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication · Duplicated block (30–35 lines × 4) · ×1
  • Duplicated block (30–35 lines × 4) colossalai/shardformer/modeling/falcon.py:371 — colossalai/shardformer/modeling/falcon.py:371-400 | colossalai/shardformer/modeling/falcon.py:470-499 | colossalai/shardformer/modeling/falcon.py:584-613 | colossalai/shardformer/modeling/falcon.py:665-699 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/falcon.py:371` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (4–35 lines × 5) · ×1
  • Duplicated block (4–35 lines × 5) colossalai/inference/modeling/models/nopadding_llama.py:329 — colossalai/inference/modeling/models/nopadding_llama.py:329-332 | colossalai/inference/modeling/models/nopadding_llama.py:595-598 | colossalai/legacy/zero/sharded_model/sharded_model_v2.py:484-519 | colossalai/shardformer/layer/parallel_module.py:73-107 | colossalai/shardformer/layer/parallel_module.py:248-282 — before extracting anything, compare `colossalai/legacy/zero/sharded_model/sharded_model_v2.py` and `colossalai/shardformer/layer/parallel_module.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 96 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/inference/modeling/models/nopadding_llama.py:328` calls `hasattr` and `colossalai/inference/modeling/models/nopadding_llama.py:594` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (32 lines × 5) · ×1
  • Duplicated block (32 lines × 5) colossalai/shardformer/modeling/_qwen2_tf4.py:776 — colossalai/shardformer/modeling/_qwen2_tf4.py:776-807 | colossalai/shardformer/modeling/_qwen3_tf4.py:768-799 | colossalai/shardformer/modeling/command.py:588-619 | colossalai/shardformer/modeling/mistral.py:572-603 | colossalai/shardformer/modeling/opt.py:859-938 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf4.py` and `colossalai/shardformer/modeling/_qwen3_tf4.py` as WHOLE FILES: this scan already matched 52 separate duplicated blocks between them, totalling at least 1214 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_qwen2_tf4.py:776` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (17–32 lines × 5) · ×1
  • Duplicated block (17–32 lines × 5) colossalai/shardformer/modeling/gpt2.py:365 — colossalai/shardformer/modeling/gpt2.py:365-390 | colossalai/shardformer/modeling/gpt2.py:454-485 | colossalai/shardformer/modeling/gpt2.py:545-574 | colossalai/shardformer/modeling/gpt2.py:637-662 | colossalai/shardformer/modeling/gpt2.py:731-747 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/gpt2.py:365` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (32 lines × 3) · ×1
  • Duplicated block (32 lines × 3) colossalai/shardformer/policies/_whisper_tf4.py:542 — colossalai/shardformer/policies/_whisper_tf4.py:542-573 | colossalai/shardformer/policies/_whisper_tf5.py:529-560 | colossalai/shardformer/policies/t5.py:451-482 — before extracting anything, compare `colossalai/shardformer/policies/_whisper_tf4.py` and `colossalai/shardformer/policies/_whisper_tf5.py` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (30–32 lines × 2) · ×1
  • Duplicated block (30–32 lines × 2) applications/ColossalMoE/train.py:61 — applications/ColossalMoE/train.py:61-90 | colossalai/legacy/moe/openmoe/train.py:94-125 — before extracting anything, compare `applications/ColossalMoE/train.py` and `colossalai/legacy/moe/openmoe/train.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 125 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalMoE/train.py:61` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (17–31 lines × 3) · ×1
  • Duplicated block (17–31 lines × 3) colossalai/shardformer/modeling/gptj.py:282 — colossalai/shardformer/modeling/gptj.py:282-307 | colossalai/shardformer/modeling/gptj.py:394-410 | colossalai/shardformer/modeling/gptj.py:493-523 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/gptj.py:282` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (29–31 lines × 2) · ×1
  • Duplicated block (29–31 lines × 2) applications/ColossalEval/colossal_eval/evaluate/gpt_evaluate.py:364 — applications/ColossalEval/colossal_eval/evaluate/gpt_evaluate.py:364-394 | applications/ColossalEval/colossal_eval/evaluate/gpt_evaluate.py:435-463 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (26–31 lines × 2) · ×1
  • Duplicated block (26–31 lines × 2) colossalai/shardformer/modeling/_deepseek_v3_tf4.py:317 — colossalai/shardformer/modeling/_deepseek_v3_tf4.py:317-342 | colossalai/shardformer/modeling/_deepseek_v3_tf5.py:348-378 — before extracting anything, compare `colossalai/shardformer/modeling/_deepseek_v3_tf4.py` and `colossalai/shardformer/modeling/_deepseek_v3_tf5.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 101 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/modeling/_deepseek_v3_tf5.py:346` calls `pop` and `colossalai/shardformer/modeling/_deepseek_v3_tf4.py:305` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (28–30 lines × 2) · ×1
  • Duplicated block (28–30 lines × 2) colossalai/_analyzer/fx/codegen.py:102 — colossalai/_analyzer/fx/codegen.py:102-131 | colossalai/fx/codegen/activation_checkpoint_codegen.py:272-299 — before extracting anything, compare `colossalai/_analyzer/fx/codegen.py` and `colossalai/fx/codegen/activation_checkpoint_codegen.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 101 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (22–30 lines × 2) · ×1
  • Duplicated block (22–30 lines × 2) colossalai/fx/tracer/experimental.py:622 — colossalai/fx/tracer/experimental.py:622-651 | colossalai/fx/tracer/tracer.py:102-123 — before extracting anything, compare `colossalai/fx/tracer/experimental.py` and `colossalai/fx/tracer/tracer.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 138 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (24–30 lines × 2) · ×1
  • Duplicated block (24–30 lines × 2) colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:361 — colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:361-384 | colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py:654-683 — before extracting anything, compare `colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py` and `colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 176 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:361` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (28–29 lines × 8) · ×1
  • Duplicated block (28–29 lines × 8) colossalai/shardformer/policies/_llama_tf4.py:304 — colossalai/shardformer/policies/_llama_tf4.py:304-331 | colossalai/shardformer/policies/_llama_tf5.py:302-329 | colossalai/shardformer/policies/_qwen2_tf4.py:311-339 | colossalai/shardformer/policies/_qwen2_tf5.py:310-338 | colossalai/shardformer/policies/_qwen3_tf4.py:311-339 | colossalai/shardformer/policies/_qwen3_tf5.py:331-359 | colossalai/shardformer/policies/command.py:282-309 | colossalai/shardformer/policies/mistral.py:265-292 — before extracting anything, compare `colossalai/shardformer/policies/_llama_tf4.py` and `colossalai/shardformer/policies/_llama_tf5.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 404 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (28–29 lines × 7) · ×1
  • Duplicated block (28–29 lines × 7) colossalai/shardformer/modeling/_llama_tf4.py:417 — colossalai/shardformer/modeling/_llama_tf4.py:417-444 | colossalai/shardformer/modeling/_llama_tf5.py:459-486 | colossalai/shardformer/modeling/_qwen2_tf4.py:407-434 | colossalai/shardformer/modeling/_qwen2_tf5.py:317-345 | colossalai/shardformer/modeling/_qwen3_tf4.py:405-433 | colossalai/shardformer/modeling/_qwen3_tf5.py:318-346 | colossalai/shardformer/modeling/mistral.py:301-328 — before extracting anything, compare `colossalai/shardformer/modeling/_llama_tf4.py` and `colossalai/shardformer/modeling/_llama_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_llama_tf4.py:417` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (26–28 lines × 3) · ×1
  • Duplicated block (26–28 lines × 3) colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:137 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:137-164 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:197-224 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:269-294 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:137` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (25–28 lines × 2) · ×1
  • Duplicated block (25–28 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:119 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:119-146 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:351-375 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:119` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:118` calls `list`, `keys` and `colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:350` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (26–28 lines × 2) · ×1
  • Duplicated block (26–28 lines × 2) colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:176 — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:176-203 | colossalai/zero/gemini/gemini_ddp.py:964-989 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
D4 · Code Duplication · Duplicated block (27–28 lines × 2) · ×1
  • Duplicated block (27–28 lines × 2) colossalai/nn/optimizer/distributed_adafactor.py:68 — colossalai/nn/optimizer/distributed_adafactor.py:68-95 | colossalai/nn/optimizer/distributed_came.py:76-102 — before extracting anything, compare `colossalai/nn/optimizer/distributed_adafactor.py` and `colossalai/nn/optimizer/distributed_came.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 201 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (25–27 lines × 4) · ×1
  • Duplicated block (25–27 lines × 4) colossalai/_analyzer/fx/tracer/tracer.py:206 — colossalai/_analyzer/fx/tracer/tracer.py:206-232 | colossalai/_analyzer/fx/tracer/tracer.py:309-333 | colossalai/fx/tracer/experimental.py:337-363 | colossalai/fx/tracer/tracer.py:417-443 — before extracting anything, compare `colossalai/_analyzer/fx/tracer/tracer.py` and `colossalai/fx/tracer/experimental.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 93 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/_analyzer/fx/tracer/tracer.py:336` calls `getattr`, `_module_getattr` and `colossalai/fx/tracer/experimental.py:366` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (26–27 lines × 3) · ×1
  • Duplicated block (26–27 lines × 3) colossalai/legacy/zero/sharded_model/sharded_model_v2.py:541 — colossalai/legacy/zero/sharded_model/sharded_model_v2.py:541-566 | colossalai/shardformer/layer/parallel_module.py:136-162 | colossalai/shardformer/layer/parallel_module.py:314-340 — before extracting anything, compare `colossalai/legacy/zero/sharded_model/sharded_model_v2.py` and `colossalai/shardformer/layer/parallel_module.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 96 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (18–25 lines × 4) · ×1
  • Duplicated block (18–25 lines × 4) colossalai/fx/profiler/experimental/profiler_module/convolution.py:126 — colossalai/fx/profiler/experimental/profiler_module/convolution.py:126-143 | colossalai/fx/profiler/experimental/profiler_module/convolution.py:160-184 | colossalai/fx/tracer/meta_patch/patched_module/convolution.py:94-111 | colossalai/fx/tracer/meta_patch/patched_module/convolution.py:122-146 — before extracting anything, compare `colossalai/fx/profiler/experimental/profiler_module/convolution.py` and `colossalai/fx/tracer/meta_patch/patched_module/convolution.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 83 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/fx/profiler/experimental/profiler_module/convolution.py:126` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `self` to `torch.nn.ConvTranspose2d` in one and `torch.nn.ConvTranspose3d` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (24–25 lines × 2) · ×1
  • Duplicated block (24–25 lines × 2) applications/ColossalChat/coati/trainer/kto.py:240 — applications/ColossalChat/coati/trainer/kto.py:240-263 | applications/ColossalChat/coati/trainer/orpo.py:214-238 — before extracting anything, compare `applications/ColossalChat/coati/trainer/kto.py` and `applications/ColossalChat/coati/trainer/orpo.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 138 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/trainer/kto.py:240` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (3–25 lines × 3) · ×1
  • Duplicated block (3–25 lines × 3) colossalai/kernel/triton/context_attn_unpad.py:95 — colossalai/kernel/triton/context_attn_unpad.py:95-119 | colossalai/kernel/triton/context_attn_unpad.py:273-297 | colossalai/kernel/triton/context_attn_unpad.py:473-475 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/kernel/triton/context_attn_unpad.py:95` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/kernel/triton/context_attn_unpad.py:119` calls `full` and `colossalai/kernel/triton/context_attn_unpad.py:475` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (23–24 lines × 4) · ×1
  • Duplicated block (23–24 lines × 4) colossalai/shardformer/modeling/bloom.py:356 — colossalai/shardformer/modeling/bloom.py:356-378 | colossalai/shardformer/modeling/bloom.py:448-471 | colossalai/shardformer/modeling/bloom.py:574-597 | colossalai/shardformer/modeling/bloom.py:661-683 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/bloom.py:356` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (2–24 lines × 5) · ×1
  • Duplicated block (2–24 lines × 5) colossalai/inference/utils.py:36 — colossalai/inference/utils.py:36-59 | colossalai/legacy/inference/hybridengine/modeling/_utils.py:40-63 | colossalai/legacy/inference/quant/smoothquant/models/llama.py:545-548 | colossalai/legacy/inference/tensor_parallel/modeling/_utils.py:40-63 | colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:59-60 — before extracting anything, compare `colossalai/legacy/inference/hybridengine/modeling/_utils.py` and `colossalai/legacy/inference/tensor_parallel/modeling/_utils.py` as WHOLE FILES: 100% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 2 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/inference/utils.py:59` calls `arange` and `colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:60` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (24 lines × 3) · ×1
  • Duplicated block (24 lines × 3) colossalai/shardformer/policies/t5.py:612 — colossalai/shardformer/policies/t5.py:612-635 | colossalai/shardformer/policies/t5.py:663-686 | colossalai/shardformer/policies/t5.py:766-789 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/policies/t5.py:612` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (21–24 lines × 2) · ×1
  • Duplicated block (21–24 lines × 2) applications/ColossalChat/coati/distributed/grpo_consumer.py:226 — applications/ColossalChat/coati/distributed/grpo_consumer.py:226-249 | applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py:205-225 — before extracting anything, compare `applications/ColossalChat/coati/distributed/grpo_consumer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/grpo_consumer.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 407 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/distributed/grpo_consumer.py:226` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (23 lines × 4) · ×1
  • Duplicated block (23 lines × 4) applications/ColossalChat/coati/trainer/dpo.py:270 — applications/ColossalChat/coati/trainer/dpo.py:270-292 | applications/ColossalChat/coati/trainer/dpo.py:553-575 | applications/ColossalChat/coati/trainer/orpo.py:122-144 | applications/ColossalChat/coati/trainer/orpo.py:261-283 — before extracting anything, compare `applications/ColossalChat/coati/trainer/dpo.py` and `applications/ColossalChat/coati/trainer/orpo.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 133 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/trainer/dpo.py:270` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `applications/ColossalChat/coati/trainer/dpo.py:551` calls `no_grad` and `applications/ColossalChat/coati/trainer/dpo.py:268` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (23 lines × 3) · ×1
  • Duplicated block (23 lines × 3) colossalai/kernel/triton/context_attn_unpad.py:137 — colossalai/kernel/triton/context_attn_unpad.py:137-159 | colossalai/kernel/triton/context_attn_unpad.py:315-337 | colossalai/kernel/triton/context_attn_unpad.py:501-523 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/kernel/triton/context_attn_unpad.py:498` calls `where` and `colossalai/kernel/triton/context_attn_unpad.py:135` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (22–23 lines × 3) · ×1
  • Duplicated block (22–23 lines × 3) colossalai/shardformer/modeling/_llama_tf4.py:205 — colossalai/shardformer/modeling/_llama_tf4.py:205-226 | colossalai/shardformer/modeling/command.py:192-214 | colossalai/shardformer/modeling/command.py:521-543 — before extracting anything, compare `colossalai/shardformer/modeling/_llama_tf4.py` and `colossalai/shardformer/modeling/command.py` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 210 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_llama_tf4.py:205` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (17–23 lines × 2) · ×1
  • Duplicated block (17–23 lines × 2) applications/ColossalQA/colossalqa/data_loader/document_loader.py:53 — applications/ColossalQA/colossalqa/data_loader/document_loader.py:53-75 | applications/ColossalQA/colossalqa/data_loader/table_dataloader.py:52-68 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (20–23 lines × 2) · ×1
  • Duplicated block (20–23 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:463 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:463-482 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py:204-226 — before extracting anything, compare `colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py` and `colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 143 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (22 lines × 5) · ×1
  • Duplicated block (22 lines × 5) colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:154 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:154-175 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:214-235 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:284-305 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:360-381 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:439-460 — before extracting anything, compare `colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py` and `colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 53 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (21–22 lines × 4) · ×1
  • Duplicated block (21–22 lines × 4) colossalai/shardformer/policies/_whisper_tf4.py:595 — colossalai/shardformer/policies/_whisper_tf4.py:595-616 | colossalai/shardformer/policies/_whisper_tf4.py:686-706 | colossalai/shardformer/policies/_whisper_tf5.py:582-603 | colossalai/shardformer/policies/_whisper_tf5.py:673-693 — before extracting anything, compare `colossalai/shardformer/policies/_whisper_tf4.py` and `colossalai/shardformer/policies/_whisper_tf5.py` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: `WhisperForConditionalGeneration` names `transformers` in one and `transformers.models.whisper.modeling_whisper` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (20–22 lines × 2) · ×1
  • Duplicated block (20–22 lines × 2) colossalai/shardformer/layer/loss.py:70 — colossalai/shardformer/layer/loss.py:70-89 | colossalai/shardformer/layer/loss.py:179-200 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (19–22 lines × 2) · ×1
  • Duplicated block (19–22 lines × 2) colossalai/shardformer/modeling/_mixtral_tf4.py:833 — colossalai/shardformer/modeling/_mixtral_tf4.py:833-854 | colossalai/shardformer/modeling/deepseek.py:834-852 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/deepseek.py` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 427 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_mixtral_tf4.py:833` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (17–21 lines × 3) · ×1
  • Duplicated block (17–21 lines × 3) applications/ColossalEval/colossal_eval/models/chatglm.py:90 — applications/ColossalEval/colossal_eval/models/chatglm.py:90-106 | applications/ColossalEval/colossal_eval/models/chatglm.py:283-299 | REDACTED:532-552 — before extracting anything, compare `applications/ColossalEval/colossal_eval/models/chatglm.py` and `REDACTED` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 72 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:532` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (18–21 lines × 2) · ×1
  • Duplicated block (18–21 lines × 2) applications/ColossalChat/coati/distributed/consumer.py:250 — applications/ColossalChat/coati/distributed/consumer.py:250-270 | applications/ColossalChat/coati/distributed/zero_bubble/consumer.py:208-225 — before extracting anything, compare `applications/ColossalChat/coati/distributed/consumer.py` and `applications/ColossalChat/coati/distributed/zero_bubble/consumer.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 73 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/distributed/consumer.py:250` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `applications/ColossalChat/coati/distributed/zero_bubble/consumer.py:207` calls `update` and `applications/ColossalChat/coati/distributed/consumer.py:249` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (20–21 lines × 2) · ×1
  • Duplicated block (20–21 lines × 2) colossalai/nn/optimizer/distributed_galore.py:144 — colossalai/nn/optimizer/distributed_galore.py:144-163 | colossalai/nn/optimizer/galore.py:236-256 — before extracting anything, compare `colossalai/nn/optimizer/distributed_galore.py` and `colossalai/nn/optimizer/galore.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 52 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/nn/optimizer/galore.py:258` calls `save` and `colossalai/nn/optimizer/distributed_galore.py:164` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (16–21 lines × 2) · ×1
  • Duplicated block (16–21 lines × 2) colossalai/shardformer/layer/qkv_fused_linear.py:317 — colossalai/shardformer/layer/qkv_fused_linear.py:317-337 | colossalai/shardformer/layer/qkv_fused_linear.py:521-536 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (19–20 lines × 7) · ×1
  • Duplicated block (19–20 lines × 7) colossalai/shardformer/modeling/gpt2.py:476 — colossalai/shardformer/modeling/gpt2.py:476-494 | colossalai/shardformer/modeling/gpt2.py:562-581 | colossalai/shardformer/modeling/gpt2.py:653-671 | colossalai/shardformer/modeling/gpt2.py:738-756 | colossalai/shardformer/modeling/gptj.py:299-317 | colossalai/shardformer/modeling/gptj.py:401-419 | colossalai/shardformer/modeling/gptj.py:511-530 — before extracting anything, compare `colossalai/shardformer/modeling/gpt2.py` and `colossalai/shardformer/modeling/gptj.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 321 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/gptj.py:299` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (20 lines × 3) · ×1
  • Duplicated block (20 lines × 3) colossalai/kernel/triton/context_attn_unpad.py:59 — colossalai/kernel/triton/context_attn_unpad.py:59-78 | colossalai/kernel/triton/context_attn_unpad.py:237-256 | colossalai/kernel/triton/context_attn_unpad.py:414-433 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/kernel/triton/context_attn_unpad.py:59` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (17–20 lines × 3) · ×1
  • Duplicated block (17–20 lines × 3) colossalai/shardformer/modeling/_mixtral_tf4.py:833 — colossalai/shardformer/modeling/_mixtral_tf4.py:833-849 | colossalai/shardformer/modeling/_mixtral_tf5.py:1214-1233 | colossalai/shardformer/modeling/deepseek.py:834-850 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 581 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (17–20 lines × 2) · ×1
  • Duplicated block (17–20 lines × 2) colossalai/fx/tracer/bias_addition_patch/patched_bias_addition_function/addbmm.py:52 — colossalai/fx/tracer/bias_addition_patch/patched_bias_addition_function/addbmm.py:52-71 | colossalai/fx/tracer/bias_addition_patch/patched_bias_addition_function/addmm.py:40-56 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (19 lines × 14) · ×1
  • Duplicated block (19 lines × 14) colossalai/shardformer/modeling/_bert_tf4.py:308 — colossalai/shardformer/modeling/_bert_tf4.py:308-326 | colossalai/shardformer/modeling/_bert_tf4.py:413-431 | colossalai/shardformer/modeling/_bert_tf4.py:501-519 | colossalai/shardformer/modeling/_bert_tf4.py:610-628 | colossalai/shardformer/modeling/_bert_tf4.py:686-704 | colossalai/shardformer/modeling/_bert_tf4.py:778-796 | colossalai/shardformer/modeling/_bert_tf4.py:952-970 | colossalai/shardformer/modeling/_bert_tf5.py:321-339 | colossalai/shardformer/modeling/_bert_tf5.py:426-444 | colossalai/shardformer/modeling/_bert_tf5.py:514-532 | colossalai/shardformer/modeling/_bert_tf5.py:623-641 | colossalai/shardformer/modeling/_bert_tf5.py:699-717 | colossalai/shardformer/modeling/_bert_tf5.py:791-809 | colossalai/shardformer/modeling/_bert_tf5.py:965-983 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_bert_tf4.py:308` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (19 lines × 7) · ×1
  • Duplicated block (19 lines × 7) applications/Colossal-LLaMA/train.py:86 — applications/Colossal-LLaMA/train.py:86-104 | applications/ColossalChat/examples/training_scripts/lora_finetune.py:82-100 | applications/ColossalChat/examples/training_scripts/train_dpo.py:61-79 | applications/ColossalChat/examples/training_scripts/train_kto.py:71-89 | applications/ColossalChat/examples/training_scripts/train_orpo.py:71-89 | applications/ColossalChat/examples/training_scripts/train_rm.py:99-117 | applications/ColossalChat/examples/training_scripts/train_sft.py:93-111 — before extracting anything, compare `applications/Colossal-LLaMA/train.py` and `applications/ColossalChat/examples/training_scripts/lora_finetune.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 132 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/Colossal-LLaMA/train.py:86` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `applications/Colossal-LLaMA/train.py:105` calls `get_accelerator`, `is_available` and `applications/ColossalChat/examples/training_scripts/train_dpo.py:80` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (16–19 lines × 7) · ×1
  • Duplicated block (16–19 lines × 7) colossalai/booster/plugin/dp_plugin_base.py:61 — colossalai/booster/plugin/dp_plugin_base.py:61-76 | colossalai/booster/plugin/gemini_plugin.py:635-653 | colossalai/booster/plugin/hybrid_parallel_plugin.py:1431-1449 | examples/language/data_utils.py:76-94 | examples/language/deepseek/data_utils.py:76-94 | examples/language/llama/data_utils.py:76-94 | examples/language/mixtral/data_utils.py:76-94 — before extracting anything, compare `examples/language/data_utils.py` and `examples/language/deepseek/data_utils.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 66 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/booster/plugin/gemini_plugin.py:635` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (17–19 lines × 5) · ×1
  • Duplicated block (17–19 lines × 5) colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:174 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:174-192 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:220-238 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/softmax_generator.py:78-95 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/sum_generator.py:86-103 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/unary_elementwise_generator.py:64-80 — before extracting anything, compare `colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py` and `colossalai/auto_parallel/tensor_shard/node_handler/strategy/softmax_generator.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 63 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/auto_parallel/tensor_shard/node_handler/strategy/softmax_generator.py:77` calls `deepcopy` and `colossalai/auto_parallel/tensor_shard/node_handler/strategy/sum_generator.py:84` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (19 lines × 5) · ×1
  • Duplicated block (19 lines × 5) colossalai/shardformer/modeling/_qwen2_tf4.py:326 — colossalai/shardformer/modeling/_qwen2_tf4.py:326-344 | colossalai/shardformer/modeling/_qwen2_tf5.py:235-253 | colossalai/shardformer/modeling/_qwen3_tf4.py:324-342 | colossalai/shardformer/modeling/_qwen3_tf5.py:236-254 | colossalai/shardformer/modeling/command.py:305-323 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf4.py` and `colossalai/shardformer/modeling/_qwen2_tf5.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 242 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_qwen2_tf4.py:326` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (12–19 lines × 4) · ×1
  • Duplicated block (12–19 lines × 4) colossalai/shardformer/layer/linear.py:288 — colossalai/shardformer/layer/linear.py:288-299 | colossalai/shardformer/layer/linear.py:484-496 | colossalai/shardformer/layer/qkv_fused_linear.py:912-930 | colossalai/shardformer/layer/qkv_fused_linear.py:1112-1124 — before extracting anything, compare `colossalai/shardformer/layer/linear.py` and `colossalai/shardformer/layer/qkv_fused_linear.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 261 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: the declarations holding them bind `module` to `nn.Linear` in one and `nn.Module` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (2–18 lines × 5) · ×1
  • Duplicated block (2–18 lines × 5) applications/ColossalMoE/train.py:105 — applications/ColossalMoE/train.py:105-121 | colossalai/legacy/moe/openmoe/train.py:150-167 | examples/language/deepseek/benchmark.py:106-107 | examples/language/llama/benchmark.py:92-93 | examples/language/mixtral/benchmark.py:86-87 — before extracting anything, compare `applications/ColossalMoE/train.py` and `colossalai/legacy/moe/openmoe/train.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 125 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalMoE/train.py:105` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (15–18 lines × 2) · ×1
  • Duplicated block (15–18 lines × 2) colossalai/auto_parallel/checkpoint/ckpt_solver_base.py:131 — colossalai/auto_parallel/checkpoint/ckpt_solver_base.py:131-145 | colossalai/auto_parallel/offload/region_manager.py:344-361 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
D4 · Code Duplication · Duplicated block (8–18 lines × 2) · ×1
  • Duplicated block (8–18 lines × 2) colossalai/nn/optimizer/distributed_galore.py:113 — colossalai/nn/optimizer/distributed_galore.py:113-120 | colossalai/nn/optimizer/distributed_lamb.py:73-90 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (16–17 lines × 10) · ×1
  • Duplicated block (16–17 lines × 10) colossalai/shardformer/modeling/_bert_tf4.py:618 — colossalai/shardformer/modeling/_bert_tf4.py:618-634 | colossalai/shardformer/modeling/_bert_tf4.py:694-710 | colossalai/shardformer/modeling/_bert_tf4.py:786-802 | colossalai/shardformer/modeling/_bert_tf4.py:878-893 | colossalai/shardformer/modeling/_bert_tf4.py:960-975 | colossalai/shardformer/modeling/_bert_tf5.py:631-647 | colossalai/shardformer/modeling/_bert_tf5.py:707-723 | colossalai/shardformer/modeling/_bert_tf5.py:799-815 | colossalai/shardformer/modeling/_bert_tf5.py:891-906 | colossalai/shardformer/modeling/_bert_tf5.py:973-988 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_bert_tf4.py:618` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (15–17 lines × 8) · ×1
  • Duplicated block (15–17 lines × 8) colossalai/shardformer/modeling/_mixtral_tf4.py:477 — colossalai/shardformer/modeling/_mixtral_tf4.py:477-492 | colossalai/shardformer/modeling/_mixtral_tf5.py:843-858 | colossalai/shardformer/modeling/bloom.py:369-383 | colossalai/shardformer/modeling/bloom.py:588-603 | colossalai/shardformer/modeling/deepseek.py:538-553 | colossalai/shardformer/modeling/falcon.py:392-407 | colossalai/shardformer/modeling/falcon.py:605-621 | colossalai/shardformer/modeling/mistral.py:241-257 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 581 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_mixtral_tf4.py:477` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (16–17 lines × 7) · ×1
  • Duplicated block (16–17 lines × 7) colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:135 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:135-151 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:195-211 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:267-282 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py:114-130 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py:168-184 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:339-354 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:418-433 — before extracting anything, compare `colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py` and `colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 143 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (17 lines × 7) · ×1
  • Duplicated block (17 lines × 7) colossalai/shardformer/layer/_operation.py:136 — colossalai/shardformer/layer/_operation.py:136-152 | colossalai/shardformer/layer/_operation.py:219-235 | colossalai/shardformer/layer/_operation.py:307-323 | colossalai/shardformer/layer/_operation.py:386-402 | colossalai/shardformer/layer/_operation.py:614-630 | colossalai/shardformer/layer/_operation.py:789-805 | colossalai/shardformer/layer/_operation.py:950-966 — all 7 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/layer/_operation.py:136` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (15–17 lines × 7) · ×1
  • Duplicated block (15–17 lines × 7) colossalai/shardformer/modeling/_bert_tf4.py:698 — colossalai/shardformer/modeling/_bert_tf4.py:698-714 | colossalai/shardformer/modeling/_bert_tf4.py:790-806 | colossalai/shardformer/modeling/_bert_tf4.py:882-896 | colossalai/shardformer/modeling/_bert_tf5.py:711-727 | colossalai/shardformer/modeling/_bert_tf5.py:803-819 | colossalai/shardformer/modeling/_bert_tf5.py:895-909 | colossalai/shardformer/modeling/t5.py:638-653 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_bert_tf4.py:698` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/shardformer/modeling/_bert_tf4.py:897` calls `view` and `colossalai/shardformer/modeling/_bert_tf4.py:716` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (16–17 lines × 5) · ×1
  • Duplicated block (16–17 lines × 5) colossalai/shardformer/layer/linear.py:243 — colossalai/shardformer/layer/linear.py:243-258 | colossalai/shardformer/layer/linear.py:438-454 | colossalai/shardformer/layer/qkv_fused_linear.py:259-275 | colossalai/shardformer/layer/qkv_fused_linear.py:854-870 | colossalai/shardformer/layer/qkv_fused_linear.py:1062-1078 — before extracting anything, compare `colossalai/shardformer/layer/linear.py` and `colossalai/shardformer/layer/qkv_fused_linear.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 261 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/layer/linear.py:434` calls `get_world_size` and `colossalai/shardformer/layer/linear.py:239` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (15–17 lines × 3) · ×1
  • Duplicated block (15–17 lines × 3) colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:846 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:846-860 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:888-902 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:929-945 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:846` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (15–17 lines × 2) · ×1
  • Duplicated block (15–17 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/permute_handler.py:61 — colossalai/auto_parallel/tensor_shard/node_handler/permute_handler.py:61-75 | colossalai/auto_parallel/tensor_shard/node_handler/transpose_handler.py:48-64 — before extracting anything, compare `colossalai/auto_parallel/tensor_shard/node_handler/permute_handler.py` and `colossalai/auto_parallel/tensor_shard/node_handler/transpose_handler.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 32 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (14–17 lines × 2) · ×1
  • Duplicated block (14–17 lines × 2) colossalai/shardformer/modeling/command.py:498 — colossalai/shardformer/modeling/command.py:498-511 | colossalai/shardformer/modeling/deepseek.py:784-800 — before extracting anything, compare `colossalai/shardformer/modeling/command.py` and `colossalai/shardformer/modeling/deepseek.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 93 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/deepseek.py:784` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/shardformer/modeling/command.py:514` calls `rotary_emb` and `colossalai/shardformer/modeling/deepseek.py:802` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (15–16 lines × 10) · ×1
  • Duplicated block (15–16 lines × 10) colossalai/shardformer/policies/_llama_tf4.py:334 — colossalai/shardformer/policies/_llama_tf4.py:334-348 | colossalai/shardformer/policies/_llama_tf5.py:332-346 | colossalai/shardformer/policies/_mixtral_tf4.py:311-325 | colossalai/shardformer/policies/_mixtral_tf5.py:338-352 | colossalai/shardformer/policies/_qwen2_tf4.py:344-359 | colossalai/shardformer/policies/_qwen2_tf5.py:343-358 | colossalai/shardformer/policies/_qwen3_tf4.py:344-359 | colossalai/shardformer/policies/_qwen3_tf5.py:364-379 | colossalai/shardformer/policies/command.py:312-326 | colossalai/shardformer/policies/mistral.py:295-309 — before extracting anything, compare `colossalai/shardformer/policies/_llama_tf4.py` and `colossalai/shardformer/policies/_llama_tf5.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 404 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (15–16 lines × 5) · ×1
  • Duplicated block (15–16 lines × 5) colossalai/inference/modeling/layers/baichuan_tp_linear.py:29 — colossalai/inference/modeling/layers/baichuan_tp_linear.py:29-43 | colossalai/shardformer/layer/linear.py:295-309 | colossalai/shardformer/layer/linear.py:491-506 | colossalai/shardformer/layer/qkv_fused_linear.py:329-344 | colossalai/shardformer/layer/qkv_fused_linear.py:528-543 — before extracting anything, compare `colossalai/shardformer/layer/linear.py` and `colossalai/shardformer/layer/qkv_fused_linear.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 261 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: `ParallelModule` names `.parallel_module` in one and `colossalai.shardformer.layer.parallel_module` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (4–16 lines × 6) · ×1
  • Duplicated block (4–16 lines × 6) colossalai/shardformer/modeling/_llama_tf4.py:536 — colossalai/shardformer/modeling/_llama_tf4.py:536-550 | colossalai/shardformer/modeling/_llama_tf5.py:580-583 | colossalai/shardformer/modeling/_mixtral_tf4.py:588-603 | colossalai/shardformer/modeling/_qwen2_tf4.py:518-531 | colossalai/shardformer/modeling/_qwen3_tf4.py:504-517 | colossalai/shardformer/modeling/mistral.py:523-536 — before extracting anything, compare `colossalai/shardformer/modeling/_llama_tf4.py` and `colossalai/shardformer/modeling/_llama_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (14–16 lines × 5) · ×1
  • Duplicated block (14–16 lines × 5) colossalai/shardformer/modeling/_qwen2_tf4.py:495 — colossalai/shardformer/modeling/_qwen2_tf4.py:495-508 | colossalai/shardformer/modeling/_qwen2_tf5.py:393-406 | colossalai/shardformer/modeling/_qwen3_tf4.py:481-494 | colossalai/shardformer/modeling/_qwen3_tf5.py:394-407 | colossalai/shardformer/modeling/command.py:360-375 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf4.py` and `colossalai/shardformer/modeling/_qwen2_tf5.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 242 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (15–16 lines × 4) · ×1
  • Duplicated block (15–16 lines × 4) colossalai/legacy/nn/layer/parallel_2d/_operation.py:110 — colossalai/legacy/nn/layer/parallel_2d/_operation.py:110-125 | colossalai/legacy/nn/layer/parallel_2d/_operation.py:300-314 | colossalai/legacy/nn/layer/parallel_2d/_operation.py:456-471 | colossalai/legacy/nn/layer/parallel_2d/_operation.py:613-628 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (13–16 lines × 4) · ×1
  • Duplicated block (13–16 lines × 4) colossalai/shardformer/modeling/_bert_tf4.py:813 — colossalai/shardformer/modeling/_bert_tf4.py:813-825 | colossalai/shardformer/modeling/_bert_tf5.py:826-838 | colossalai/shardformer/modeling/bloom.py:615-629 | colossalai/shardformer/modeling/falcon.py:631-646 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/bloom.py:615` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (14–16 lines × 3) · ×1
  • Duplicated block (14–16 lines × 3) colossalai/nn/optimizer/distributed_came.py:368 — colossalai/nn/optimizer/distributed_came.py:368-381 | colossalai/nn/optimizer/distributed_came.py:391-404 | colossalai/nn/optimizer/distributed_came.py:414-429 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication · Duplicated block (13–16 lines × 2) · ×1
  • Duplicated block (13–16 lines × 2) colossalai/auto_parallel/tensor_shard/node_handler/conv_handler.py:107 — colossalai/auto_parallel/tensor_shard/node_handler/conv_handler.py:107-119 | colossalai/auto_parallel/tensor_shard/node_handler/linear_handler.py:268-283 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/tensor_shard/node_handler/linear_handler.py:268` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (14–16 lines × 2) · ×1
  • Duplicated block (14–16 lines × 2) colossalai/legacy/inference/quant/smoothquant/models/llama.py:622 — colossalai/legacy/inference/quant/smoothquant/models/llama.py:622-635 | colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:742-757 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (15 lines × 14) · ×1
  • Duplicated block (15 lines × 14) colossalai/shardformer/modeling/_bert_tf4.py:420 — colossalai/shardformer/modeling/_bert_tf4.py:420-434 | colossalai/shardformer/modeling/_bert_tf4.py:508-522 | colossalai/shardformer/modeling/_bert_tf4.py:617-631 | colossalai/shardformer/modeling/_bert_tf4.py:693-707 | colossalai/shardformer/modeling/_bert_tf4.py:785-799 | colossalai/shardformer/modeling/_bert_tf4.py:877-891 | colossalai/shardformer/modeling/_bert_tf4.py:959-973 | colossalai/shardformer/modeling/_bert_tf5.py:433-447 | colossalai/shardformer/modeling/_bert_tf5.py:521-535 | colossalai/shardformer/modeling/_bert_tf5.py:630-644 | colossalai/shardformer/modeling/_bert_tf5.py:706-720 | colossalai/shardformer/modeling/_bert_tf5.py:798-812 | colossalai/shardformer/modeling/_bert_tf5.py:890-904 | colossalai/shardformer/modeling/_bert_tf5.py:972-986 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_bert_tf4.py:420` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (13–15 lines × 13) · ×1
  • Duplicated block (13–15 lines × 13) colossalai/shardformer/policies/_deepseek_v3_tf4.py:123 — colossalai/shardformer/policies/_deepseek_v3_tf4.py:123-137 | colossalai/shardformer/policies/_deepseek_v3_tf5.py:130-144 | colossalai/shardformer/policies/_llama_tf4.py:351-363 | colossalai/shardformer/policies/_llama_tf5.py:349-361 | colossalai/shardformer/policies/_mixtral_tf4.py:329-343 | colossalai/shardformer/policies/_mixtral_tf5.py:356-370 | colossalai/shardformer/policies/_qwen2_tf4.py:362-375 | colossalai/shardformer/policies/_qwen2_tf5.py:361-374 | colossalai/shardformer/policies/_qwen3_tf4.py:362-375 | colossalai/shardformer/policies/_qwen3_tf5.py:382-395 | colossalai/shardformer/policies/command.py:329-342 | colossalai/shardformer/policies/deepseek.py:337-349 | colossalai/shardformer/policies/mistral.py:312-324 — before extracting anything, compare `colossalai/shardformer/policies/_deepseek_v3_tf4.py` and `colossalai/shardformer/policies/_deepseek_v3_tf5.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 150 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (15 lines × 10) · ×1
  • Duplicated block (15 lines × 10) colossalai/shardformer/modeling/_mixtral_tf4.py:476 — colossalai/shardformer/modeling/_mixtral_tf4.py:476-491 | colossalai/shardformer/modeling/_mixtral_tf5.py:842-857 | colossalai/shardformer/modeling/bloom.py:368-382 | colossalai/shardformer/modeling/bloom.py:461-475 | colossalai/shardformer/modeling/bloom.py:587-602 | colossalai/shardformer/modeling/deepseek.py:537-552 | colossalai/shardformer/modeling/falcon.py:391-406 | colossalai/shardformer/modeling/falcon.py:490-505 | colossalai/shardformer/modeling/falcon.py:604-620 | colossalai/shardformer/modeling/mistral.py:240-256 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/_mixtral_tf5.py` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 581 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_mixtral_tf4.py:476` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (15 lines × 9) · ×1
  • Duplicated block (15 lines × 9) colossalai/shardformer/modeling/_bert_tf4.py:510 — colossalai/shardformer/modeling/_bert_tf4.py:510-525 | colossalai/shardformer/modeling/_bert_tf5.py:523-538 | colossalai/shardformer/modeling/_whisper_tf4.py:1064-1078 | colossalai/shardformer/modeling/_whisper_tf5.py:579-593 | colossalai/shardformer/modeling/gpt2.py:473-488 | colossalai/shardformer/modeling/gpt2.py:650-665 | colossalai/shardformer/modeling/gpt2.py:735-750 | colossalai/shardformer/modeling/gptj.py:297-311 | colossalai/shardformer/modeling/gptj.py:398-413 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_bert_tf4.py:510` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (14–15 lines × 8) · ×1
  • Duplicated block (14–15 lines × 8) colossalai/shardformer/modeling/_llama_tf4.py:187 — colossalai/shardformer/modeling/_llama_tf4.py:187-200 | colossalai/shardformer/modeling/_llama_tf5.py:237-250 | colossalai/shardformer/modeling/_qwen2_tf4.py:188-202 | colossalai/shardformer/modeling/_qwen2_tf5.py:131-145 | colossalai/shardformer/modeling/_qwen3_tf4.py:186-200 | colossalai/shardformer/modeling/_qwen3_tf5.py:132-146 | colossalai/shardformer/modeling/command.py:172-186 | colossalai/shardformer/modeling/mistral.py:118-132 — before extracting anything, compare `colossalai/shardformer/modeling/_llama_tf4.py` and `colossalai/shardformer/modeling/_llama_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (13–15 lines × 6) · ×1
  • Duplicated block (13–15 lines × 6) colossalai/shardformer/modeling/_qwen2_tf4.py:829 — colossalai/shardformer/modeling/_qwen2_tf4.py:829-841 | colossalai/shardformer/modeling/_qwen2_tf5.py:606-618 | colossalai/shardformer/modeling/_qwen3_tf4.py:822-834 | colossalai/shardformer/modeling/_qwen3_tf5.py:608-620 | colossalai/shardformer/modeling/command.py:650-664 | colossalai/shardformer/modeling/mistral.py:625-637 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf4.py` and `colossalai/shardformer/modeling/_qwen2_tf5.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 242 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/command.py:650` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (8–15 lines × 4) · ×1
  • Duplicated block (8–15 lines × 4) applications/ColossalChat/coati/trainer/dpo.py:263 — applications/ColossalChat/coati/trainer/dpo.py:263-277 | applications/ColossalChat/coati/trainer/kto.py:125-132 | applications/ColossalChat/coati/trainer/kto.py:274-281 | applications/ColossalChat/coati/trainer/orpo.py:115-129 — before extracting anything, compare `applications/ColossalChat/coati/trainer/dpo.py` and `applications/ColossalChat/coati/trainer/kto.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 60 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/trainer/dpo.py:263` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (14–15 lines × 4) · ×1
  • Duplicated block (14–15 lines × 4) colossalai/legacy/nn/layer/parallel_2d/_operation.py:419 — colossalai/legacy/nn/layer/parallel_2d/_operation.py:419-432 | colossalai/legacy/nn/layer/parallel_2d/_operation.py:575-589 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:384-397 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:549-562 — `colossalai/legacy/nn/layer/parallel_2d/_operation.py` and `colossalai/legacy/nn/layer/parallel_2p5d/_operation.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 185 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2d/_operation.py:419` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (11–15 lines × 3) · ×1
  • Duplicated block (11–15 lines × 3) colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:119 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:119-131 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:278-292 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:351-361 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:118` calls `list`, `keys` and `colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:277` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (9–15 lines × 2) · ×1
  • Duplicated block (9–15 lines × 2) REDACTED:276 — REDACTED:276-290 | REDACTED:424-432 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 157 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (13–14 lines × 12) · ×1
  • Duplicated block (13–14 lines × 12) colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:134 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:134-147 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:154-166 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:194-207 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:214-226 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:266-279 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:284-296 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py:113-126 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py:167-180 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:338-350 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:360-372 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:417-429 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:439-451 — before extracting anything, compare `colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py` and `colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 143 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:134` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (14 lines × 8) · ×1
  • Duplicated block (14 lines × 8) colossalai/legacy/nn/layer/parallel_1d/layers.py:255 — colossalai/legacy/nn/layer/parallel_1d/layers.py:255-268 | colossalai/legacy/nn/layer/parallel_1d/layers.py:392-405 | colossalai/legacy/nn/layer/parallel_2d/layers.py:943-956 | colossalai/legacy/nn/layer/parallel_2d/layers.py:1105-1118 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:958-971 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:1121-1134 | colossalai/legacy/nn/layer/parallel_3d/layers.py:425-438 | colossalai/legacy/nn/layer/parallel_3d/layers.py:581-594 — `colossalai/legacy/nn/layer/parallel_1d/layers.py` and `colossalai/legacy/nn/layer/parallel_2d/layers.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 56 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/legacy/nn/layer/parallel_2d/layers.py:959` calls `get_local_rank` and `colossalai/legacy/nn/layer/parallel_1d/layers.py:270` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (14 lines × 6) · ×1
  • Duplicated block (14 lines × 6) colossalai/kernel/triton/context_attn_unpad.py:616 — colossalai/kernel/triton/context_attn_unpad.py:616-629 | colossalai/kernel/triton/context_attn_unpad.py:656-669 | colossalai/kernel/triton/context_attn_unpad.py:692-705 | colossalai/kernel/triton/flash_decoding.py:428-441 | colossalai/kernel/triton/no_pad_rotary_embedding.py:552-565 | colossalai/kernel/triton/no_pad_rotary_embedding.py:628-641 — there are 6 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart.
D4 · Code Duplication · Duplicated block (13–14 lines × 5) · ×1
  • Duplicated block (13–14 lines × 5) colossalai/shardformer/modeling/_deepseek_v3_tf4.py:345 — colossalai/shardformer/modeling/_deepseek_v3_tf4.py:345-358 | colossalai/shardformer/modeling/_deepseek_v3_tf5.py:383-396 | colossalai/shardformer/modeling/_mixtral_tf4.py:494-506 | colossalai/shardformer/modeling/_mixtral_tf5.py:860-872 | colossalai/shardformer/modeling/deepseek.py:555-568 — before extracting anything, compare `colossalai/shardformer/modeling/_deepseek_v3_tf4.py` and `colossalai/shardformer/modeling/_deepseek_v3_tf5.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 101 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (11–14 lines × 3) · ×1
  • Duplicated block (11–14 lines × 3) applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:125 — applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:125-138 | applications/Colossal-LLaMA/dataset/prepare_sft_dataset.py:135-145 | applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py:256-268 — before extracting anything, compare `applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py` and `applications/Colossal-LLaMA/dataset/prepare_sft_dataset.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 116 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/Colossal-LLaMA/dataset/prepare_pretrain_dataset.py:125` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (11–14 lines × 2) · ×1
  • Duplicated block (11–14 lines × 2) colossalai/shardformer/policies/gpt2.py:650 — colossalai/shardformer/policies/gpt2.py:650-663 | colossalai/shardformer/policies/gptj.py:442-452 — before extracting anything, compare `colossalai/shardformer/policies/gpt2.py` and `colossalai/shardformer/policies/gptj.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 65 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (13 lines × 17) · ×1
  • Duplicated block (13 lines × 17) colossalai/shardformer/modeling/_bert_tf4.py:515 — colossalai/shardformer/modeling/_bert_tf4.py:515-528 | colossalai/shardformer/modeling/_bert_tf4.py:622-635 | colossalai/shardformer/modeling/_bert_tf4.py:698-711 | colossalai/shardformer/modeling/_bert_tf4.py:790-803 | colossalai/shardformer/modeling/_bert_tf4.py:882-894 | colossalai/shardformer/modeling/_bert_tf4.py:964-976 | colossalai/shardformer/modeling/_bert_tf5.py:528-541 | colossalai/shardformer/modeling/_bert_tf5.py:635-648 | colossalai/shardformer/modeling/_bert_tf5.py:711-724 | colossalai/shardformer/modeling/_bert_tf5.py:803-816 | colossalai/shardformer/modeling/_bert_tf5.py:895-907 | colossalai/shardformer/modeling/_bert_tf5.py:977-989 | colossalai/shardformer/modeling/bloom.py:674-687 | colossalai/shardformer/modeling/falcon.py:689-703 | colossalai/shardformer/modeling/opt.py:390-403 | colossalai/shardformer/modeling/opt.py:490-502 | colossalai/shardformer/modeling/t5.py:638-650 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_bert_tf4.py:515` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/shardformer/modeling/_bert_tf4.py:897` calls `view` and `colossalai/shardformer/modeling/_bert_tf4.py:716` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (11–13 lines × 11) · ×1
  • Duplicated block (11–13 lines × 11) colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:977 — colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:977-987 | colossalai/shardformer/modeling/_deepseek_v3_tf4.py:360-370 | colossalai/shardformer/modeling/_deepseek_v3_tf5.py:398-408 | colossalai/shardformer/modeling/_llama_tf4.py:361-371 | colossalai/shardformer/modeling/_llama_tf5.py:403-413 | colossalai/shardformer/modeling/_qwen2_tf4.py:352-362 | colossalai/shardformer/modeling/_qwen2_tf5.py:260-272 | colossalai/shardformer/modeling/_qwen3_tf4.py:350-360 | colossalai/shardformer/modeling/_qwen3_tf5.py:261-273 | colossalai/shardformer/modeling/command.py:332-342 | colossalai/shardformer/modeling/opt.py:341-353 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 11 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 11 times. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_qwen2_tf5.py:260` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (12–13 lines × 8) · ×1
  • Duplicated block (12–13 lines × 8) colossalai/shardformer/modeling/_llama_tf4.py:473 — colossalai/shardformer/modeling/_llama_tf4.py:473-484 | colossalai/shardformer/modeling/_llama_tf5.py:515-526 | colossalai/shardformer/modeling/_qwen2_tf4.py:463-474 | colossalai/shardformer/modeling/bloom.py:519-530 | colossalai/shardformer/modeling/falcon.py:548-559 | colossalai/shardformer/modeling/gpt2.py:795-806 | colossalai/shardformer/modeling/gptj.py:459-470 | colossalai/shardformer/modeling/opt.py:441-453 — before extracting anything, compare `colossalai/shardformer/modeling/_llama_tf4.py` and `colossalai/shardformer/modeling/_llama_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_llama_tf4.py:473` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (13 lines × 7) · ×1
  • Duplicated block (13 lines × 7) colossalai/kernel/triton/context_attn_unpad.py:618 — colossalai/kernel/triton/context_attn_unpad.py:618-630 | colossalai/kernel/triton/context_attn_unpad.py:658-670 | colossalai/kernel/triton/context_attn_unpad.py:694-706 | colossalai/kernel/triton/flash_decoding.py:430-442 | colossalai/kernel/triton/flash_decoding.py:513-525 | colossalai/kernel/triton/kvcache_copy.py:269-281 | colossalai/kernel/triton/no_pad_rotary_embedding.py:630-642 — there are 7 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 7 sites; resolving a subset leaves the remainder to drift apart. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/kernel/triton/context_attn_unpad.py:632` calls `stride` and `colossalai/kernel/triton/flash_decoding.py:527` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (11–13 lines × 7) · ×1
  • Duplicated block (11–13 lines × 7) colossalai/shardformer/modeling/_mixtral_tf4.py:568 — colossalai/shardformer/modeling/_mixtral_tf4.py:568-580 | colossalai/shardformer/modeling/_qwen2_tf4.py:499-509 | colossalai/shardformer/modeling/_qwen2_tf5.py:397-407 | colossalai/shardformer/modeling/_qwen3_tf4.py:485-495 | colossalai/shardformer/modeling/_qwen3_tf5.py:398-408 | colossalai/shardformer/modeling/command.py:364-376 | colossalai/shardformer/modeling/deepseek.py:618-630 — before extracting anything, compare `colossalai/shardformer/modeling/_mixtral_tf4.py` and `colossalai/shardformer/modeling/_qwen2_tf4.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 172 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (12–13 lines × 6) · ×1
  • Duplicated block (12–13 lines × 6) applications/ColossalChat/coati/trainer/dpo.py:279 — applications/ColossalChat/coati/trainer/dpo.py:279-290 | applications/ColossalChat/coati/trainer/dpo.py:562-573 | applications/ColossalChat/coati/trainer/kto.py:135-146 | applications/ColossalChat/coati/trainer/kto.py:284-296 | applications/ColossalChat/coati/trainer/orpo.py:131-143 | applications/ColossalChat/coati/trainer/orpo.py:270-282 — before extracting anything, compare `applications/ColossalChat/coati/trainer/dpo.py` and `applications/ColossalChat/coati/trainer/kto.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 60 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/trainer/dpo.py:279` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (12–13 lines × 4) · ×1
  • Duplicated block (12–13 lines × 4) colossalai/inference/utils.py:30 — colossalai/inference/utils.py:30-42 | colossalai/legacy/inference/hybridengine/modeling/_utils.py:34-46 | colossalai/legacy/inference/tensor_parallel/modeling/_utils.py:34-46 | colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:35-46 — before extracting anything, compare `colossalai/legacy/inference/hybridengine/modeling/_utils.py` and `colossalai/legacy/inference/tensor_parallel/modeling/_utils.py` as WHOLE FILES: 100% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 2 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (10–13 lines × 3) · ×1
  • Duplicated block (10–13 lines × 3) colossalai/shardformer/modeling/_llama_tf4.py:62 — colossalai/shardformer/modeling/_llama_tf4.py:62-73 | colossalai/shardformer/modeling/command.py:58-70 | colossalai/shardformer/modeling/falcon.py:208-217 — before extracting anything, compare `colossalai/shardformer/modeling/_llama_tf4.py` and `colossalai/shardformer/modeling/command.py` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 210 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/shardformer/modeling/falcon.py:219` calls `warning_once` and `colossalai/shardformer/modeling/command.py:73` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (8–13 lines × 2) · ×1
  • Duplicated block (8–13 lines × 2) colossalai/shardformer/layer/linear.py:156 — colossalai/shardformer/layer/linear.py:156-168 | colossalai/shardformer/layer/qkv_fused_linear.py:1339-1346 — before extracting anything, compare `colossalai/shardformer/layer/linear.py` and `colossalai/shardformer/layer/qkv_fused_linear.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 261 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/layer/linear.py:156` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (11–12 lines × 16) · ×1
  • Duplicated block (11–12 lines × 16) colossalai/legacy/context/process_group_initializer/initializer_1d.py:47 — colossalai/legacy/context/process_group_initializer/initializer_1d.py:47-57 | colossalai/legacy/context/process_group_initializer/initializer_2d.py:60-70 | colossalai/legacy/context/process_group_initializer/initializer_2d.py:109-119 | colossalai/legacy/context/process_group_initializer/initializer_2p5d.py:79-90 | colossalai/legacy/context/process_group_initializer/initializer_2p5d.py:133-144 | colossalai/legacy/context/process_group_initializer/initializer_2p5d.py:187-198 | colossalai/legacy/context/process_group_initializer/initializer_2p5d.py:242-253 | colossalai/legacy/context/process_group_initializer/initializer_3d.py:66-76 | colossalai/legacy/context/process_group_initializer/initializer_3d.py:117-127 | colossalai/legacy/context/process_group_initializer/initializer_3d.py:168-178 | colossalai/legacy/context/process_group_initializer/initializer_3d.py:221-232 | colossalai/legacy/context/process_group_initializer/initializer_3d.py:275-286 | colossalai/legacy/context/process_group_initializer/initializer_data.py:45-55 | colossalai/legacy/context/process_group_initializer/initializer_model.py:47-57 | colossalai/legacy/context/process_group_initializer/initializer_sequence.py:48-58 | colossalai/legacy/context/process_group_initializer/initializer_tensor.py:45-55 — there are 16 copies across 8 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 16 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/context/process_group_initializer/initializer_2p5d.py:79` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (11–12 lines × 10) · ×1
  • Duplicated block (11–12 lines × 10) colossalai/shardformer/modeling/_llama_tf4.py:519 — colossalai/shardformer/modeling/_llama_tf4.py:519-530 | colossalai/shardformer/modeling/_llama_tf5.py:566-577 | colossalai/shardformer/modeling/_mixtral_tf4.py:572-583 | colossalai/shardformer/modeling/_mixtral_tf5.py:957-968 | colossalai/shardformer/modeling/_qwen2_tf4.py:502-512 | colossalai/shardformer/modeling/_qwen2_tf5.py:400-410 | colossalai/shardformer/modeling/_qwen3_tf4.py:488-498 | colossalai/shardformer/modeling/_qwen3_tf5.py:401-411 | colossalai/shardformer/modeling/command.py:368-379 | colossalai/shardformer/modeling/deepseek.py:622-633 — before extracting anything, compare `colossalai/shardformer/modeling/_llama_tf4.py` and `colossalai/shardformer/modeling/_llama_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 483 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/modeling/_llama_tf5.py:563` calls `getattr` and `colossalai/shardformer/modeling/_llama_tf4.py:516` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (11–12 lines × 9) · ×1
  • Duplicated block (11–12 lines × 9) colossalai/shardformer/modeling/_bert_tf4.py:976 — colossalai/shardformer/modeling/_bert_tf4.py:976-987 | colossalai/shardformer/modeling/_bert_tf5.py:989-1000 | colossalai/shardformer/modeling/bloom.py:687-697 | colossalai/shardformer/modeling/falcon.py:703-713 | colossalai/shardformer/modeling/gpt2.py:581-591 | colossalai/shardformer/modeling/gptj.py:530-540 | colossalai/shardformer/modeling/opt.py:502-513 | examples/community/roberta/pretraining/model/bert.py:1848-1859 | examples/community/roberta/pretraining/model/deberta_v2.py:1496-1507 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/modeling/_bert_tf4.py:975` calls `is_last_stage` and `examples/community/roberta/pretraining/model/bert.py:1846` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (12 lines × 7) · ×1
  • Duplicated block (12 lines × 7) colossalai/shardformer/modeling/_qwen2_tf4.py:776 — colossalai/shardformer/modeling/_qwen2_tf4.py:776-807 | colossalai/shardformer/modeling/_qwen3_tf4.py:768-799 | colossalai/shardformer/modeling/bloom.py:1110-1121 | colossalai/shardformer/modeling/command.py:588-619 | colossalai/shardformer/modeling/falcon.py:757-768 | colossalai/shardformer/modeling/mistral.py:572-603 | colossalai/shardformer/modeling/opt.py:859-938 — before extracting anything, compare `colossalai/shardformer/modeling/_qwen2_tf4.py` and `colossalai/shardformer/modeling/_qwen3_tf4.py` as WHOLE FILES: this scan already matched 52 separate duplicated blocks between them, totalling at least 1214 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_qwen2_tf4.py:776` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9–12 lines × 6) · ×1
  • Duplicated block (9–12 lines × 6) applications/ColossalChat/coati/trainer/dpo.py:160 — applications/ColossalChat/coati/trainer/dpo.py:160-168 | applications/ColossalChat/coati/trainer/dpo.py:295-304 | applications/ColossalChat/coati/trainer/dpo.py:312-320 | applications/ColossalChat/coati/trainer/dpo.py:451-459 | applications/ColossalChat/coati/trainer/dpo.py:577-588 | applications/ColossalChat/coati/trainer/dpo.py:591-600 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/trainer/dpo.py:160` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (6–12 lines × 5) · ×1
  • Duplicated block (6–12 lines × 5) applications/ColossalChat/coati/trainer/dpo.py:265 — applications/ColossalChat/coati/trainer/dpo.py:265-275 | applications/ColossalChat/coati/trainer/kto.py:127-132 | applications/ColossalChat/coati/trainer/kto.py:276-281 | applications/ColossalChat/coati/trainer/orpo.py:117-127 | applications/ColossalChat/coati/trainer/rm.py:110-121 — before extracting anything, compare `applications/ColossalChat/coati/trainer/dpo.py` and `applications/ColossalChat/coati/trainer/kto.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 60 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/trainer/dpo.py:265` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (8–12 lines × 5) · ×1
  • Duplicated block (8–12 lines × 5) colossalai/inference/modeling/layers/baichuan_tp_linear.py:23 — colossalai/inference/modeling/layers/baichuan_tp_linear.py:23-34 | colossalai/shardformer/layer/linear.py:293-300 | colossalai/shardformer/layer/linear.py:489-497 | colossalai/shardformer/layer/qkv_fused_linear.py:923-931 | colossalai/shardformer/layer/qkv_fused_linear.py:1117-1125 — before extracting anything, compare `colossalai/shardformer/layer/linear.py` and `colossalai/shardformer/layer/qkv_fused_linear.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 261 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/inference/modeling/layers/baichuan_tp_linear.py:23` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: `ParallelModule` names `.parallel_module` in one and `colossalai.shardformer.layer.parallel_module` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (12 lines × 5) · ×1
  • Duplicated block (12 lines × 5) colossalai/shardformer/modeling/_bert_tf4.py:803 — colossalai/shardformer/modeling/_bert_tf4.py:803-814 | colossalai/shardformer/modeling/_bert_tf5.py:816-827 | colossalai/shardformer/modeling/t5.py:650-661 | examples/community/roberta/pretraining/model/bert.py:1757-1768 | examples/community/roberta/pretraining/model/deberta_v2.py:1413-1424 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/modeling/_bert_tf4.py:802` calls `is_last_stage` and `examples/community/roberta/pretraining/model/bert.py:1755` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (9–12 lines × 3) · ×1
  • Duplicated block (9–12 lines × 3) colossalai/fx/tracer/_tracer_utils.py:41 — colossalai/fx/tracer/_tracer_utils.py:41-49 | colossalai/fx/tracer/experimental.py:546-557 | colossalai/fx/tracer/tracer.py:247-257 — before extracting anything, compare `colossalai/fx/tracer/experimental.py` and `colossalai/fx/tracer/tracer.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 138 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (3–12 lines × 3) · ×1
  • Duplicated block (3–12 lines × 3) applications/ColossalChat/coati/ray/callbacks/performance_evaluator.py:111 — applications/ColossalChat/coati/ray/callbacks/performance_evaluator.py:111-122 | applications/ColossalChat/coati/ray/callbacks/performance_evaluator.py:203-212 | applications/ColossalChat/coati/trainer/callbacks/performance_evaluator.py:185-187 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/coati/ray/callbacks/performance_evaluator.py:111` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (11 lines × 8) · ×1
  • Duplicated block (11 lines × 8) colossalai/kernel/triton/context_attn_unpad.py:621 — colossalai/kernel/triton/context_attn_unpad.py:621-631 | colossalai/kernel/triton/context_attn_unpad.py:661-671 | colossalai/kernel/triton/context_attn_unpad.py:697-707 | colossalai/kernel/triton/flash_decoding.py:433-443 | colossalai/kernel/triton/flash_decoding.py:490-500 | colossalai/kernel/triton/flash_decoding.py:516-526 | colossalai/kernel/triton/kvcache_copy.py:272-282 | colossalai/kernel/triton/no_pad_rotary_embedding.py:633-643 — there are 8 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 8 sites; resolving a subset leaves the remainder to drift apart. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/kernel/triton/context_attn_unpad.py:632` calls `stride` and `colossalai/kernel/triton/flash_decoding.py:527` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (10–11 lines × 6) · ×1
  • Duplicated block (10–11 lines × 6) colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:205 — colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:205-215 | colossalai/shardformer/modeling/bloom.py:1144-1154 | colossalai/shardformer/modeling/chatglm2.py:325-334 | colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py:1118-1128 | colossalai/shardformer/modeling/falcon.py:803-813 | colossalai/shardformer/modeling/gptj.py:343-353 — before extracting anything, compare `colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py` and `colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 176 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/modeling/gptj.py:341` calls `to` and `colossalai/shardformer/modeling/falcon.py:801` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (11 lines × 6) · ×1
  • Duplicated block (11 lines × 6) colossalai/legacy/nn/layer/parallel_1d/layers.py:165 — colossalai/legacy/nn/layer/parallel_1d/layers.py:165-175 | colossalai/legacy/nn/layer/parallel_2d/layers.py:279-289 | colossalai/legacy/nn/layer/parallel_2d/layers.py:483-493 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:292-302 | colossalai/legacy/nn/layer/parallel_2p5d/layers.py:496-506 | colossalai/legacy/nn/layer/parallel_3d/layers.py:776-786 — `colossalai/legacy/nn/layer/parallel_1d/layers.py` and `colossalai/legacy/nn/layer/parallel_2d/layers.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 56 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (8–11 lines × 5) · ×1
  • Duplicated block (8–11 lines × 5) colossalai/auto_parallel/meta_profiler/meta_registry/activation.py:62 — colossalai/auto_parallel/meta_profiler/meta_registry/activation.py:62-72 | colossalai/auto_parallel/meta_profiler/meta_registry/linear.py:435-442 | colossalai/auto_parallel/meta_profiler/meta_registry/norm.py:152-161 | colossalai/auto_parallel/meta_profiler/meta_registry/tensor.py:44-53 | colossalai/auto_parallel/meta_profiler/meta_registry/where.py:49-58 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 5 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/auto_parallel/meta_profiler/meta_registry/activation.py:62` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/auto_parallel/meta_profiler/meta_registry/linear.py:432` calls `TrainCycleItem`, `MemoryCost` and `colossalai/auto_parallel/meta_profiler/meta_registry/norm.py:152` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (9–10 lines × 6) · ×1
  • Duplicated block (9–10 lines × 6) applications/ColossalChat/coati/trainer/grpo.py:185 — applications/ColossalChat/coati/trainer/grpo.py:185-193 | applications/ColossalChat/coati/trainer/kto.py:109-117 | applications/ColossalChat/coati/trainer/orpo.py:99-107 | applications/ColossalChat/coati/trainer/ppo.py:176-184 | applications/ColossalChat/coati/trainer/rm.py:97-105 | applications/ColossalChat/coati/trainer/sft.py:87-96 — before extracting anything, compare `applications/ColossalChat/coati/trainer/grpo.py` and `applications/ColossalChat/coati/trainer/ppo.py` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 176 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (8–10 lines × 6) · ×1
  • Duplicated block (8–10 lines × 6) colossalai/shardformer/modeling/_bert_tf4.py:810 — colossalai/shardformer/modeling/_bert_tf4.py:810-819 | colossalai/shardformer/modeling/_bert_tf5.py:823-832 | colossalai/shardformer/modeling/gpt2.py:678-687 | colossalai/shardformer/modeling/t5.py:657-666 | examples/community/roberta/pretraining/model/bert.py:1764-1773 | examples/community/roberta/pretraining/model/deberta_v2.py:1420-1427 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/modeling/_bert_tf4.py:810` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `examples/community/roberta/pretraining/model/deberta_v2.py:1397` calls `LongTensor` and `colossalai/shardformer/modeling/gpt2.py:641` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (10 lines × 5) · ×1
  • Duplicated block (10 lines × 5) colossalai/legacy/nn/layer/parallel_1d/layers.py:566 — colossalai/legacy/nn/layer/parallel_1d/layers.py:566-575 | colossalai/shardformer/layer/linear.py:154-164 | colossalai/shardformer/layer/linear.py:332-342 | colossalai/shardformer/layer/qkv_fused_linear.py:956-965 | colossalai/shardformer/layer/qkv_fused_linear.py:1337-1346 — there are 5 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart.
D4 · Code Duplication · Duplicated block (8–10 lines × 2) · ×1
  • Duplicated block (8–10 lines × 2) colossalai/legacy/moe/openmoe/train.py:133 — colossalai/legacy/moe/openmoe/train.py:133-142 | examples/language/opt/args.py:28-35 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/moe/openmoe/train.py:133` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (8–9 lines × 14) · ×1
  • Duplicated block (8–9 lines × 14) colossalai/legacy/moe/openmoe/model/openmoe_policy.py:119 — colossalai/legacy/moe/openmoe/model/openmoe_policy.py:119-127 | colossalai/shardformer/policies/_deepseek_v3_tf4.py:132-139 | colossalai/shardformer/policies/_deepseek_v3_tf5.py:139-146 | colossalai/shardformer/policies/_llama_tf4.py:358-366 | colossalai/shardformer/policies/_llama_tf5.py:356-364 | colossalai/shardformer/policies/_mixtral_tf4.py:338-345 | colossalai/shardformer/policies/_mixtral_tf5.py:365-372 | colossalai/shardformer/policies/_qwen2_tf4.py:370-378 | colossalai/shardformer/policies/_qwen2_tf5.py:369-377 | colossalai/shardformer/policies/_qwen3_tf4.py:370-378 | colossalai/shardformer/policies/_qwen3_tf5.py:390-398 | colossalai/shardformer/policies/command.py:337-345 | colossalai/shardformer/policies/deepseek.py:344-352 | colossalai/shardformer/policies/mistral.py:319-326 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 14 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 14 times. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (9 lines × 9) · ×1
  • Duplicated block (9 lines × 9) colossalai/legacy/moe/openmoe/model/openmoe_policy.py:262 — colossalai/legacy/moe/openmoe/model/openmoe_policy.py:262-270 | colossalai/shardformer/modeling/_mixtral_tf4.py:240-249 | colossalai/shardformer/modeling/_mixtral_tf5.py:584-593 | colossalai/shardformer/modeling/_qwen2_tf4.py:71-79 | colossalai/shardformer/modeling/_qwen2_tf5.py:70-78 | colossalai/shardformer/modeling/_qwen3_tf4.py:71-79 | colossalai/shardformer/modeling/_qwen3_tf5.py:71-79 | colossalai/shardformer/modeling/deepseek.py:337-346 | colossalai/shardformer/modeling/mistral.py:50-58 — before extracting anything, compare `colossalai/legacy/moe/openmoe/model/openmoe_policy.py` and `colossalai/shardformer/modeling/_mixtral_tf4.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 130 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (2–9 lines × 9) · ×1
  • Duplicated block (2–9 lines × 9) colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:100 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:100-108 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py:72-80 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/getitem_generator.py:51-59 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/layer_norm_generator.py:89-97 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:55-63 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/softmax_generator.py:55-63 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/sum_generator.py:52-60 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/tensor_constructor_generator.py:32-33 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/unary_elementwise_generator.py:43-51 — before extracting anything, compare `colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py` and `colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 143 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/auto_parallel/tensor_shard/node_handler/strategy/getitem_generator.py:62` calls `TensorStrategyGenerator` and `colossalai/auto_parallel/tensor_shard/node_handler/strategy/softmax_generator.py:65` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (9 lines × 7) · ×1
  • Duplicated block (9 lines × 7) colossalai/legacy/nn/layer/parallel_3d/layers.py:108 — colossalai/legacy/nn/layer/parallel_3d/layers.py:108-116 | colossalai/legacy/nn/layer/parallel_3d/layers.py:260-268 | colossalai/legacy/nn/layer/parallel_3d/layers.py:436-444 | colossalai/legacy/nn/layer/parallel_3d/layers.py:592-600 | colossalai/legacy/nn/layer/parallel_3d/layers.py:792-800 | colossalai/legacy/nn/layer/parallel_3d/layers.py:939-947 | colossalai/legacy/nn/layer/parallel_3d/layers.py:1077-1085 — all 7 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_3d/layers.py:108` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/legacy/nn/layer/parallel_3d/layers.py:104` calls `pop`, `transpose` and `colossalai/legacy/nn/layer/parallel_3d/layers.py:937` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (8–9 lines × 5) · ×1
  • Duplicated block (8–9 lines × 5) colossalai/nn/optimizer/distributed_adafactor.py:337 — colossalai/nn/optimizer/distributed_adafactor.py:337-344 | colossalai/nn/optimizer/distributed_adafactor.py:351-359 | colossalai/nn/optimizer/distributed_came.py:372-379 | colossalai/nn/optimizer/distributed_came.py:395-402 | colossalai/nn/optimizer/distributed_came.py:419-427 — before extracting anything, compare `colossalai/nn/optimizer/distributed_adafactor.py` and `colossalai/nn/optimizer/distributed_came.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 201 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/nn/optimizer/distributed_adafactor.py:337` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `colossalai/nn/optimizer/distributed_came.py:406` calls `zeros` and `colossalai/nn/optimizer/distributed_adafactor.py:345` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (8–9 lines × 3) · ×1
  • Duplicated block (8–9 lines × 3) colossalai/legacy/inference/hybridengine/modeling/llama.py:277 — colossalai/legacy/inference/hybridengine/modeling/llama.py:277-285 | colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:162-169 | colossalai/legacy/inference/tensor_parallel/modeling/llama.py:191-199 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/inference/hybridengine/modeling/llama.py:277` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (7–9 lines × 3) · ×1
  • Duplicated block (7–9 lines × 3) colossalai/shardformer/layer/attn.py:804 — colossalai/shardformer/layer/attn.py:804-812 | colossalai/shardformer/layer/attn.py:858-864 | colossalai/shardformer/layer/attn.py:874-880 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/layer/attn.py:804` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (8 lines × 10) · ×1
  • Duplicated block (8 lines × 10) colossalai/legacy/inference/hybridengine/modeling/llama.py:217 — colossalai/legacy/inference/hybridengine/modeling/llama.py:217-224 | colossalai/legacy/moe/openmoe/model/openmoe_policy.py:263-270 | colossalai/shardformer/modeling/_mixtral_tf4.py:242-249 | colossalai/shardformer/modeling/_mixtral_tf5.py:586-593 | colossalai/shardformer/modeling/_qwen2_tf4.py:72-79 | colossalai/shardformer/modeling/_qwen2_tf5.py:71-78 | colossalai/shardformer/modeling/_qwen3_tf4.py:72-79 | colossalai/shardformer/modeling/_qwen3_tf5.py:72-79 | colossalai/shardformer/modeling/deepseek.py:339-346 | colossalai/shardformer/modeling/mistral.py:51-58 — before extracting anything, compare `colossalai/legacy/moe/openmoe/model/openmoe_policy.py` and `colossalai/shardformer/modeling/_mixtral_tf4.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 130 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (8 lines × 9) · ×1
  • Duplicated block (8 lines × 9) colossalai/shardformer/policies/_qwen2_tf4.py:462 — colossalai/shardformer/policies/_qwen2_tf4.py:462-469 | colossalai/shardformer/policies/_qwen2_tf5.py:461-468 | colossalai/shardformer/policies/_qwen3_tf4.py:448-455 | colossalai/shardformer/policies/_qwen3_tf5.py:472-479 | colossalai/shardformer/policies/bloom.py:404-411 | colossalai/shardformer/policies/command.py:424-431 | colossalai/shardformer/policies/deepseek.py:434-441 | colossalai/shardformer/policies/falcon.py:351-358 | colossalai/shardformer/policies/mistral.py:408-415 — before extracting anything, compare `colossalai/shardformer/policies/_qwen2_tf4.py` and `colossalai/shardformer/policies/_qwen2_tf5.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 399 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (8 lines × 7) · ×1
  • Duplicated block (8 lines × 7) colossalai/shardformer/policies/_qwen2_tf4.py:542 — colossalai/shardformer/policies/_qwen2_tf4.py:542-549 | colossalai/shardformer/policies/_qwen2_tf5.py:541-548 | colossalai/shardformer/policies/_qwen3_tf4.py:527-534 | colossalai/shardformer/policies/_qwen3_tf5.py:551-558 | colossalai/shardformer/policies/bloom.py:470-477 | colossalai/shardformer/policies/falcon.py:418-425 | colossalai/shardformer/policies/mistral.py:470-477 — before extracting anything, compare `colossalai/shardformer/policies/_qwen2_tf4.py` and `colossalai/shardformer/policies/_qwen2_tf5.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 399 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (8 lines × 6) · ×1
  • Duplicated block (8 lines × 6) colossalai/fx/profiler/experimental/profiler_module/convolution.py:97 — colossalai/fx/profiler/experimental/profiler_module/convolution.py:97-104 | colossalai/fx/profiler/experimental/profiler_module/convolution.py:125-132 | colossalai/fx/profiler/experimental/profiler_module/convolution.py:159-166 | colossalai/fx/tracer/meta_patch/patched_module/convolution.py:73-80 | colossalai/fx/tracer/meta_patch/patched_module/convolution.py:93-100 | colossalai/fx/tracer/meta_patch/patched_module/convolution.py:121-128 — before extracting anything, compare `colossalai/fx/profiler/experimental/profiler_module/convolution.py` and `colossalai/fx/tracer/meta_patch/patched_module/convolution.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 83 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: the declarations holding them bind `self` to `torch.nn.ConvTranspose1d` in one and `torch.nn.ConvTranspose2d` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (7–8 lines × 3) · ×1
  • Duplicated block (7–8 lines × 3) colossalai/legacy/zero/sharded_model/sharded_model_v2.py:520 — colossalai/legacy/zero/sharded_model/sharded_model_v2.py:520-526 | colossalai/shardformer/layer/parallel_module.py:108-115 | colossalai/shardformer/layer/parallel_module.py:283-290 — before extracting anything, compare `colossalai/legacy/zero/sharded_model/sharded_model_v2.py` and `colossalai/shardformer/layer/parallel_module.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 96 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (6–8 lines × 3) · ×1
  • Duplicated block (6–8 lines × 3) colossalai/nn/optimizer/distributed_adafactor.py:267 — colossalai/nn/optimizer/distributed_adafactor.py:267-272 | colossalai/nn/optimizer/distributed_came.py:261-268 | colossalai/nn/optimizer/distributed_came.py:314-321 — before extracting anything, compare `colossalai/nn/optimizer/distributed_adafactor.py` and `colossalai/nn/optimizer/distributed_came.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 201 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (7 lines × 18) · ×1
  • Duplicated block (7 lines × 18) colossalai/shardformer/policies/_qwen2_tf4.py:461 — colossalai/shardformer/policies/_qwen2_tf4.py:461-467 | colossalai/shardformer/policies/_qwen2_tf4.py:541-547 | colossalai/shardformer/policies/_qwen2_tf5.py:460-466 | colossalai/shardformer/policies/_qwen2_tf5.py:540-546 | colossalai/shardformer/policies/_qwen3_tf4.py:447-453 | colossalai/shardformer/policies/_qwen3_tf4.py:526-532 | colossalai/shardformer/policies/_qwen3_tf5.py:471-477 | colossalai/shardformer/policies/_qwen3_tf5.py:550-556 | colossalai/shardformer/policies/bloom.py:403-409 | colossalai/shardformer/policies/bloom.py:469-475 | colossalai/shardformer/policies/bloom.py:539-545 | colossalai/shardformer/policies/command.py:423-429 | colossalai/shardformer/policies/deepseek.py:433-439 | colossalai/shardformer/policies/falcon.py:350-356 | colossalai/shardformer/policies/falcon.py:417-423 | colossalai/shardformer/policies/falcon.py:488-494 | colossalai/shardformer/policies/mistral.py:407-413 | colossalai/shardformer/policies/mistral.py:469-475 — before extracting anything, compare `colossalai/shardformer/policies/_qwen2_tf4.py` and `colossalai/shardformer/policies/_qwen2_tf5.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 399 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (7 lines × 14) · ×1
  • Duplicated block (7 lines × 14) colossalai/shardformer/policies/_deepseek_v3_tf4.py:121 — colossalai/shardformer/policies/_deepseek_v3_tf4.py:121-127 | colossalai/shardformer/policies/_deepseek_v3_tf5.py:128-134 | colossalai/shardformer/policies/_llama_tf4.py:349-355 | colossalai/shardformer/policies/_llama_tf5.py:347-353 | colossalai/shardformer/policies/_mixtral_tf4.py:327-333 | colossalai/shardformer/policies/_mixtral_tf5.py:354-360 | colossalai/shardformer/policies/_qwen2_tf4.py:360-366 | colossalai/shardformer/policies/_qwen2_tf5.py:359-365 | colossalai/shardformer/policies/_qwen3_tf4.py:360-366 | colossalai/shardformer/policies/_qwen3_tf5.py:380-386 | colossalai/shardformer/policies/chatglm2.py:298-304 | colossalai/shardformer/policies/command.py:327-333 | colossalai/shardformer/policies/deepseek.py:335-341 | colossalai/shardformer/policies/mistral.py:310-316 — before extracting anything, compare `colossalai/shardformer/policies/_deepseek_v3_tf4.py` and `colossalai/shardformer/policies/_deepseek_v3_tf5.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 150 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (7 lines × 13) · ×1
  • Duplicated block (7 lines × 13) colossalai/shardformer/modeling/_bert_tf4.py:727 — colossalai/shardformer/modeling/_bert_tf4.py:727-733 | colossalai/shardformer/modeling/_bert_tf5.py:740-746 | colossalai/shardformer/modeling/_llama_tf4.py:465-471 | colossalai/shardformer/modeling/_llama_tf5.py:507-513 | colossalai/shardformer/modeling/_qwen2_tf4.py:455-461 | colossalai/shardformer/modeling/bloom.py:511-517 | colossalai/shardformer/modeling/falcon.py:540-546 | colossalai/shardformer/modeling/gpt2.py:787-793 | colossalai/shardformer/modeling/gptj.py:451-457 | colossalai/shardformer/modeling/mistral.py:351-357 | colossalai/shardformer/modeling/opt.py:433-439 | examples/community/roberta/pretraining/model/bert.py:1575-1581 | examples/community/roberta/pretraining/model/deberta_v2.py:1335-1341 — before extracting anything, compare `colossalai/shardformer/modeling/_bert_tf4.py` and `colossalai/shardformer/modeling/_bert_tf5.py` as WHOLE FILES: this scan already matched 45 separate duplicated blocks between them, totalling at least 882 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (6–7 lines × 6) · ×1
  • Duplicated block (6–7 lines × 6) colossalai/legacy/nn/layer/parallel_2d/_operation.py:280 — colossalai/legacy/nn/layer/parallel_2d/_operation.py:280-285 | colossalai/legacy/nn/layer/parallel_2d/_operation.py:427-432 | colossalai/legacy/nn/layer/parallel_2d/_operation.py:584-589 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:237-242 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:392-398 | colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:557-562 — `colossalai/legacy/nn/layer/parallel_2d/_operation.py` and `colossalai/legacy/nn/layer/parallel_2p5d/_operation.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 185 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:392` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/legacy/nn/layer/parallel_2d/_operation.py:278` calls `copy_`, `broadcast` and `colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:391` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (5–7 lines × 3) · ×1
  • Duplicated block (5–7 lines × 3) colossalai/nn/optimizer/adafactor.py:180 — colossalai/nn/optimizer/adafactor.py:180-184 | colossalai/nn/optimizer/distributed_adafactor.py:169-174 | colossalai/nn/optimizer/distributed_came.py:162-168 — before extracting anything, compare `colossalai/nn/optimizer/adafactor.py` and `colossalai/nn/optimizer/distributed_adafactor.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 46 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (3–7 lines × 3) · ×1
  • Duplicated block (3–7 lines × 3) colossalai/shardformer/layer/_operation.py:518 — colossalai/shardformer/layer/_operation.py:518-524 | colossalai/shardformer/layer/_operation.py:750-752 | colossalai/shardformer/layer/_operation.py:844-850 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/shardformer/layer/_operation.py:518` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `colossalai/shardformer/layer/_operation.py:517` calls `contiguous`, `chunk`, `get_world_size` and `colossalai/shardformer/layer/_operation.py:750` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (6 lines × 5) · ×1
  • Duplicated block (6 lines × 5) colossalai/legacy/moe/openmoe/model/openmoe_policy.py:253 — colossalai/legacy/moe/openmoe/model/openmoe_policy.py:253-259 | colossalai/shardformer/modeling/_qwen2_tf4.py:62-68 | colossalai/shardformer/modeling/_qwen3_tf4.py:62-68 | colossalai/shardformer/modeling/_whisper_tf4.py:904-909 | colossalai/shardformer/modeling/opt.py:89-94 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times.
D4 · Code Duplication · Duplicated block (5–6 lines × 2) · ×1
  • Duplicated block (5–6 lines × 2) colossalai/cli/check/check_installation.py:61 — colossalai/cli/check/check_installation.py:61-65 | colossalai/cli/check/check_installation.py:73-78 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/cli/check/check_installation.py:73` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (5 lines × 8) · ×1
  • Duplicated block (5 lines × 8) colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:95 — colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py:95-99 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py:67-71 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/getitem_generator.py:46-50 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/layer_norm_generator.py:84-88 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py:50-54 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/softmax_generator.py:50-54 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/sum_generator.py:47-51 | colossalai/auto_parallel/tensor_shard/node_handler/strategy/unary_elementwise_generator.py:38-42 — before extracting anything, compare `colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py` and `colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 143 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (5 lines × 7) · ×1
  • Duplicated block (5 lines × 7) colossalai/legacy/moe/openmoe/model/openmoe_policy.py:253 — colossalai/legacy/moe/openmoe/model/openmoe_policy.py:253-257 | colossalai/shardformer/modeling/_qwen2_tf4.py:62-66 | colossalai/shardformer/modeling/_qwen2_tf5.py:61-65 | colossalai/shardformer/modeling/_qwen3_tf4.py:62-66 | colossalai/shardformer/modeling/_qwen3_tf5.py:62-66 | colossalai/shardformer/modeling/_whisper_tf4.py:902-908 | colossalai/shardformer/modeling/opt.py:89-93 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 7 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 7 times.
D4 · Code Duplication · Duplicated block (3–5 lines × 5) · ×1
  • Duplicated block (3–5 lines × 5) colossalai/fx/profiler/experimental/profiler_module/convolution.py:18 — colossalai/fx/profiler/experimental/profiler_module/convolution.py:18-20 | colossalai/fx/profiler/experimental/profiler_module/convolution.py:41-45 | colossalai/fx/profiler/experimental/profiler_module/convolution.py:67-71 | colossalai/fx/tracer/meta_patch/patched_module/convolution.py:29-33 | colossalai/fx/tracer/meta_patch/patched_module/convolution.py:49-53 — before extracting anything, compare `colossalai/fx/profiler/experimental/profiler_module/convolution.py` and `colossalai/fx/tracer/meta_patch/patched_module/convolution.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 83 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `colossalai/fx/profiler/experimental/profiler_module/convolution.py:18` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `self` to `torch.nn.Conv1d` in one and `torch.nn.Conv2d` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (14 lines × 10) · ×1
  • Duplicated block (14 lines × 10) colossalai/legacy/moe/openmoe/model/openmoe_policy.py:208 — colossalai/legacy/moe/openmoe/model/openmoe_policy.py:208-221 | colossalai/shardformer/policies/_mixtral_tf4.py:434-447 | colossalai/shardformer/policies/_mixtral_tf5.py:461-474 | colossalai/shardformer/policies/_qwen2_tf4.py:475-488 | colossalai/shardformer/policies/_qwen2_tf5.py:474-487 | colossalai/shardformer/policies/_qwen3_tf4.py:461-474 | colossalai/shardformer/policies/_qwen3_tf5.py:485-498 | colossalai/shardformer/policies/command.py:437-450 | colossalai/shardformer/policies/deepseek.py:447-460 | colossalai/shardformer/policies/mistral.py:421-434 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 10 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 10 times. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (7 lines × 8) · ×1
  • Duplicated block (7 lines × 8) colossalai/shardformer/policies/_bert_tf4.py:535 — colossalai/shardformer/policies/_bert_tf4.py:535-541 | colossalai/shardformer/policies/_bert_tf4.py:574-581 | colossalai/shardformer/policies/_bert_tf4.py:614-621 | colossalai/shardformer/policies/_bert_tf4.py:741-748 | colossalai/shardformer/policies/_bert_tf5.py:542-548 | colossalai/shardformer/policies/_bert_tf5.py:581-588 | colossalai/shardformer/policies/_bert_tf5.py:621-628 | colossalai/shardformer/policies/_bert_tf5.py:748-755 — before extracting anything, compare `colossalai/shardformer/policies/_bert_tf4.py` and `colossalai/shardformer/policies/_bert_tf5.py` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 475 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Near-duplicate member family (4 members, 108 shared lines) · ×1
  • Near-duplicate member family (4 members, 108 shared lines) REDACTED:48 — REDACTED:48-237 | examples/images/dreambooth/train_dreambooth_colossalai.py:54-261 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:57-263 | REDACTED:78-252 — These 4 members are variants of one another: a block of 108 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 44 shared lines) · ×1
  • Near-duplicate member family (4 members, 44 shared lines) REDACTED:347 — REDACTED:347-702 | examples/images/dreambooth/train_dreambooth_colossalai.py:374-697 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:373-717 | REDACTED:366-738 — These 4 members are variants of one another: a block of 44 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 13 shared lines) · ×1
  • Near-duplicate member family (4 members, 13 shared lines) REDACTED:292 — REDACTED:292-316 | examples/images/dreambooth/train_dreambooth_colossalai.py:319-343 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:318-342 | REDACTED:307-335 — These 4 members are variants of one another: a block of 13 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (3 members, 14 shared lines) · ×1
  • Near-duplicate member family (3 members, 14 shared lines) examples/images/resnet/train.py:55 — examples/images/resnet/train.py:55-70 | examples/tutorial/new_api/cifar_resnet/train.py:55-70 | examples/tutorial/new_api/cifar_vit/train.py:75-90 — These 3 members are variants of one another: a block of 14 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication · Near-duplicate member pair (135 shared lines) · ×1
  • Near-duplicate member pair (135 shared lines) REDACTED:88 — REDACTED:88-264 | REDACTED:84-247 — These two members are variants of one another: 135 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (79 shared lines) · ×1
  • Near-duplicate member pair (79 shared lines) examples/images/resnet/train.py:104 — examples/images/resnet/train.py:104-203 | examples/tutorial/new_api/cifar_vit/train.py:124-223 — These two members are variants of one another: 79 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Edited copy of a member (27 corresponding lines) · ×1
  • Edited copy of a member (27 corresponding lines) examples/community/roberta/pretraining/model/bert.py:1739 — examples/community/roberta/pretraining/model/bert.py:1739-1776 | examples/community/roberta/pretraining/model/deberta_v2.py:1396-1429 — These two members are one piece of code written twice and then edited apart: 27 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (29 corresponding lines) · ×1
  • Edited copy of a member (29 corresponding lines) examples/community/roberta/pretraining/model/bert.py:1333 — examples/community/roberta/pretraining/model/bert.py:1333-1373 | examples/community/roberta/pretraining/model/deberta_v2.py:1145-1182 — These two members are one piece of code written twice and then edited apart: 29 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (102 lines × 2) · ×1
  • Duplicated block (102 lines × 2) examples/images/dreambooth/train_dreambooth_colossalai.py:382 — examples/images/dreambooth/train_dreambooth_colossalai.py:382-483 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:381-482 — before extracting anything, compare `examples/images/dreambooth/train_dreambooth_colossalai.py` and `examples/images/dreambooth/train_dreambooth_colossalai_lora.py` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 757 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (74–75 lines × 2) · ×1
  • Duplicated block (74–75 lines × 2) REDACTED:120 — REDACTED:120-194 | REDACTED:111-184 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 194 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:120` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (60–61 lines × 2) · ×1
  • Duplicated block (60–61 lines × 2) examples/language/bert/finetune.py:62 — examples/language/bert/finetune.py:62-122 | examples/language/gpt/hybridparallelism/finetune.py:59-118 — before extracting anything, compare `examples/language/bert/finetune.py` and `examples/language/gpt/hybridparallelism/finetune.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 242 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (58 lines × 2) · ×1
  • Duplicated block (58 lines × 2) REDACTED:535 — REDACTED:535-592 | REDACTED:565-622 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 24 separate duplicated blocks between them, totalling at least 499 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:535` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (56 lines × 2) · ×1
  • Duplicated block (56 lines × 2) examples/tutorial/sequence_parallel/data/datasets/builder.py:121 — examples/tutorial/sequence_parallel/data/datasets/builder.py:121-176 | examples/tutorial/sequence_parallel/data/datasets/dataset_utils.py:406-461 — before extracting anything, compare `examples/tutorial/sequence_parallel/data/datasets/builder.py` and `examples/tutorial/sequence_parallel/data/datasets/dataset_utils.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 111 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (49–51 lines × 2) · ×1
  • Duplicated block (49–51 lines × 2) REDACTED:457 — REDACTED:457-507 | REDACTED:461-509 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 24 separate duplicated blocks between them, totalling at least 499 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:457` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (47 lines × 2) · ×1
  • Duplicated block (47 lines × 2) applications/ColossalChat/examples/training_scripts/train_grpo.py:106 — applications/ColossalChat/examples/training_scripts/train_grpo.py:106-152 | REDACTED:128-174 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_grpo.py` and `REDACTED` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 469 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `REDACTED:127` calls `gradient_checkpointing_enable` and `applications/ColossalChat/examples/training_scripts/train_grpo.py:105` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (46 lines × 5) · ×1
  • Duplicated block (46 lines × 5) examples/language/deepseek/performance_evaluator.py:40 — examples/language/deepseek/performance_evaluator.py:40-85 | examples/language/gpt/gemini/commons/performance_evaluator.py:40-85 | examples/language/llama/performance_evaluator.py:40-85 | examples/language/mixtral/performance_evaluator.py:40-85 | examples/language/performance_evaluator.py:40-85 — before extracting anything, compare `examples/language/deepseek/performance_evaluator.py` and `examples/language/gpt/gemini/commons/performance_evaluator.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 96 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (45 lines × 3) · ×1
  • Duplicated block (45 lines × 3) REDACTED:193 — REDACTED:193-237 | examples/images/dreambooth/train_dreambooth_colossalai.py:217-261 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:219-263 — before extracting anything, compare `REDACTED` and `examples/images/dreambooth/train_dreambooth_colossalai.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 401 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:193` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (41–45 lines × 2) · ×1
  • Duplicated block (41–45 lines × 2) applications/ColossalChat/examples/training_scripts/train_grpo.py:304 — applications/ColossalChat/examples/training_scripts/train_grpo.py:304-344 | REDACTED:349-393 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_grpo.py` and `REDACTED` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 469 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:349` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `REDACTED:348` calls `eval` and `applications/ColossalChat/examples/training_scripts/train_grpo.py:303` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (41–42 lines × 4) · ×1
  • Duplicated block (41–42 lines × 4) REDACTED:88 — REDACTED:88-128 | examples/images/dreambooth/train_dreambooth_colossalai.py:101-142 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:104-145 | REDACTED:110-150 — before extracting anything, compare `REDACTED` and `examples/images/dreambooth/train_dreambooth_colossalai.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 401 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:88` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (41 lines × 4) · ×1
  • Duplicated block (41 lines × 4) examples/language/data_utils.py:51 — examples/language/data_utils.py:51-91 | examples/language/deepseek/data_utils.py:51-91 | examples/language/llama/data_utils.py:51-91 | examples/language/mixtral/data_utils.py:51-91 — before extracting anything, compare `examples/language/data_utils.py` and `examples/language/deepseek/data_utils.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 66 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/language/data_utils.py:51` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (38–39 lines × 3) · ×1
  • Duplicated block (38–39 lines × 3) REDACTED:48 — REDACTED:48-86 | examples/images/dreambooth/train_dreambooth_colossalai.py:54-91 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:57-94 — before extracting anything, compare `REDACTED` and `examples/images/dreambooth/train_dreambooth_colossalai.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 401 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:48` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (32–39 lines × 2) · ×1
  • Duplicated block (32–39 lines × 2) applications/ColossalChat/examples/training_scripts/train_grpo.py:149 — applications/ColossalChat/examples/training_scripts/train_grpo.py:149-180 | REDACTED:180-218 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_grpo.py` and `REDACTED` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 469 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/examples/training_scripts/train_grpo.py:149` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (34 lines × 3) · ×1
  • Duplicated block (34 lines × 3) REDACTED:505 — REDACTED:505-538 | examples/images/dreambooth/train_dreambooth_colossalai.py:527-560 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:547-580 — before extracting anything, compare `REDACTED` and `examples/images/dreambooth/train_dreambooth_colossalai.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 401 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:505` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (2–33 lines × 7) · ×1
  • Duplicated block (2–33 lines × 7) REDACTED:149 — REDACTED:149-181 | examples/images/dreambooth/train_dreambooth_colossalai.py:168-199 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:171-202 | REDACTED:170-202 | examples/language/deepseek/benchmark.py:98-99 | examples/language/llama/benchmark.py:85-86 | examples/language/mixtral/benchmark.py:78-79 — before extracting anything, compare `REDACTED` and `examples/images/dreambooth/train_dreambooth_colossalai.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 401 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:149` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `examples/images/dreambooth/train_dreambooth_colossalai.py:167` calls `add_argument` and `REDACTED:149` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (25–30 lines × 4) · ×1
  • Duplicated block (25–30 lines × 4) applications/ColossalChat/examples/training_scripts/train_grpo.py:163 — applications/ColossalChat/examples/training_scripts/train_grpo.py:163-192 | applications/ColossalChat/examples/training_scripts/train_kto.py:44-68 | applications/ColossalChat/examples/training_scripts/train_orpo.py:44-68 | REDACTED:201-230 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_grpo.py` and `applications/ColossalChat/examples/training_scripts/train_kto.py` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 162 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/examples/training_scripts/train_grpo.py:163` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (25–27 lines × 2) · ×1
  • Duplicated block (25–27 lines × 2) REDACTED:90 — REDACTED:90-116 | REDACTED:85-109 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 194 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:90` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `REDACTED:89` calls `get_accelerator` and `REDACTED:84` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (19–25 lines × 4) · ×1
  • Duplicated block (19–25 lines × 4) examples/images/vit/args.py:24 — examples/images/diffusion/scripts/img2img.py:120-144 | examples/images/diffusion/scripts/txt2img.py:124-144 | examples/images/vit/args.py:24-43 | examples/tutorial/opt/opt/run_clm.py:122-140 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `examples/images/diffusion/scripts/img2img.py:120` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `examples/images/vit/args.py:43` calls `add_argument` and `examples/tutorial/opt/opt/run_clm.py:140` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (18–23 lines × 3) · ×1
  • Duplicated block (18–23 lines × 3) applications/ColossalChat/examples/training_scripts/train_grpo.py:48 — applications/ColossalChat/examples/training_scripts/train_grpo.py:48-70 | REDACTED:57-79 | applications/ColossalChat/examples/training_scripts/train_sft.py:32-49 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_grpo.py` and `REDACTED` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 469 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/examples/training_scripts/train_grpo.py:48` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (21–23 lines × 3) · ×1
  • Duplicated block (21–23 lines × 3) examples/language/bert/finetune.py:148 — examples/language/bert/finetune.py:148-168 | examples/language/gpt/hybridparallelism/finetune.py:145-167 | examples/language/opt/opt_train_demo.py:44-64 — before extracting anything, compare `examples/language/bert/finetune.py` and `examples/language/gpt/hybridparallelism/finetune.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 242 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/language/gpt/hybridparallelism/finetune.py:145` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (22 lines × 4) · ×1
  • Duplicated block (22 lines × 4) REDACTED:265 — REDACTED:265-286 | examples/images/dreambooth/train_dreambooth_colossalai.py:292-313 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:291-312 | REDACTED:280-301 — before extracting anything, compare `REDACTED` and `examples/images/dreambooth/train_dreambooth_colossalai.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 401 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (21 lines × 5) · ×1
  • Duplicated block (21 lines × 5) applications/ColossalChat/examples/training_scripts/train_dpo.py:224 — applications/ColossalChat/examples/training_scripts/train_dpo.py:224-244 | applications/ColossalChat/examples/training_scripts/train_kto.py:245-265 | applications/ColossalChat/examples/training_scripts/train_orpo.py:210-230 | applications/ColossalChat/examples/training_scripts/train_rm.py:222-242 | applications/ColossalChat/examples/training_scripts/train_sft.py:230-250 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_dpo.py` and `applications/ColossalChat/examples/training_scripts/train_kto.py` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 289 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `applications/ColossalChat/examples/training_scripts/train_dpo.py:220` calls `boost` and `applications/ColossalChat/examples/training_scripts/train_orpo.py:207` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (16–21 lines × 4) · ×1
  • Duplicated block (16–21 lines × 4) applications/ColossalChat/examples/training_scripts/train_grpo.py:47 — applications/ColossalChat/examples/training_scripts/train_grpo.py:47-67 | REDACTED:56-76 | applications/ColossalChat/examples/training_scripts/train_rm.py:32-52 | applications/ColossalChat/examples/training_scripts/train_sft.py:31-46 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_grpo.py` and `REDACTED` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 469 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (14–21 lines × 3) · ×1
  • Duplicated block (14–21 lines × 3) applications/ColossalChat/examples/training_scripts/train_dpo.py:101 — applications/ColossalChat/examples/training_scripts/train_dpo.py:101-114 | applications/ColossalChat/examples/training_scripts/train_kto.py:100-120 | applications/ColossalChat/examples/training_scripts/train_orpo.py:99-119 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_dpo.py` and `applications/ColossalChat/examples/training_scripts/train_kto.py` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 289 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/examples/training_scripts/train_dpo.py:101` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `applications/ColossalChat/examples/training_scripts/train_orpo.py:97` calls `ValueError`, `Booster` and `applications/ColossalChat/examples/training_scripts/train_dpo.py:101` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (21 lines × 3) · ×1
  • Duplicated block (21 lines × 3) examples/images/resnet/train.py:177 — examples/images/resnet/train.py:177-197 | examples/tutorial/new_api/cifar_resnet/train.py:177-197 | examples/tutorial/new_api/cifar_vit/train.py:197-217 — before extracting anything, compare `examples/images/resnet/train.py` and `examples/tutorial/new_api/cifar_resnet/train.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 158 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/images/resnet/train.py:177` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (13–21 lines × 2) · ×1
  • Duplicated block (13–21 lines × 2) examples/language/bert/finetune.py:247 — examples/language/bert/finetune.py:247-259 | examples/language/gpt/hybridparallelism/finetune.py:231-251 — before extracting anything, compare `examples/language/bert/finetune.py` and `examples/language/gpt/hybridparallelism/finetune.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 242 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/language/bert/finetune.py:247` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (19–20 lines × 5) · ×1
  • Duplicated block (19–20 lines × 5) applications/ColossalChat/examples/training_scripts/train_dpo.py:200 — applications/ColossalChat/examples/training_scripts/train_dpo.py:200-219 | applications/ColossalChat/examples/training_scripts/train_kto.py:222-240 | applications/ColossalChat/examples/training_scripts/train_orpo.py:189-207 | applications/ColossalChat/examples/training_scripts/train_rm.py:201-219 | applications/ColossalChat/examples/training_scripts/train_sft.py:207-226 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_dpo.py` and `applications/ColossalChat/examples/training_scripts/train_kto.py` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 289 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/examples/training_scripts/train_dpo.py:200` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `applications/ColossalChat/examples/training_scripts/train_dpo.py:220` calls `boost` and `applications/ColossalChat/examples/training_scripts/train_orpo.py:208` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (12–19 lines × 2) · ×1
  • Duplicated block (12–19 lines × 2) examples/community/roberta/preprocessing/get_mask.py:112 — examples/community/roberta/preprocessing/get_mask.py:112-123 | examples/community/roberta/preprocessing/get_mask.py:193-211 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (18 lines × 5) · ×1
  • Duplicated block (18 lines × 5) REDACTED:49 — REDACTED:49-66 | REDACTED:69-86 | examples/images/dreambooth/train_dreambooth_colossalai.py:55-72 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:58-75 | REDACTED:92-109 — before extracting anything, compare `REDACTED` and `examples/images/dreambooth/train_dreambooth_colossalai.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 401 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:49` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (18 lines × 4) · ×1
  • Duplicated block (18 lines × 4) examples/community/roberta/pretraining/model/deberta_v2.py:1145 — examples/community/roberta/pretraining/model/deberta_v2.py:1145-1165 | examples/community/roberta/pretraining/model/deberta_v2.py:1287-1306 | examples/community/roberta/pretraining/model/deberta_v2.py:1396-1413 | examples/community/roberta/pretraining/model/deberta_v2.py:1473-1496 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `examples/community/roberta/pretraining/model/deberta_v2.py:1474` calls `LongTensor` and `examples/community/roberta/pretraining/model/deberta_v2.py:1215` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (17 lines × 4) · ×1
  • Duplicated block (17 lines × 4) REDACTED:623 — REDACTED:623-639 | examples/images/dreambooth/train_dreambooth_colossalai.py:636-652 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:656-672 | REDACTED:671-687 — before extracting anything, compare `REDACTED` and `examples/images/dreambooth/train_dreambooth_colossalai.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 401 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `REDACTED:668` calls `cat` and `REDACTED:620` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (13–17 lines × 3) · ×1
  • Duplicated block (13–17 lines × 3) applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py:79 — applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py:79-91 | examples/images/vit/args.py:57-71 | examples/language/opt/args.py:43-59 — before extracting anything, compare `applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py` and `examples/images/vit/args.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 59 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/language/opt/args.py:43` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py:91` calls `add_argument` and `examples/language/opt/args.py:59` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (13–16 lines × 3) · ×1
  • Duplicated block (13–16 lines × 3) examples/images/resnet/train.py:38 — examples/images/resnet/train.py:38-50 | examples/tutorial/new_api/cifar_resnet/train.py:38-50 | examples/tutorial/new_api/cifar_vit/train.py:55-70 — before extracting anything, compare `examples/images/resnet/train.py` and `examples/tutorial/new_api/cifar_resnet/train.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 158 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/tutorial/new_api/cifar_vit/train.py:55` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (11–15 lines × 4) · ×1
  • Duplicated block (11–15 lines × 4) REDACTED:132 — REDACTED:132-142 | examples/images/dreambooth/train_dreambooth_colossalai.py:155-166 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:158-169 | REDACTED:154-168 — before extracting anything, compare `REDACTED` and `examples/images/dreambooth/train_dreambooth_colossalai.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 401 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/images/dreambooth/train_dreambooth_colossalai.py:155` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (13–15 lines × 4) · ×1
  • Duplicated block (13–15 lines × 4) REDACTED:296 — REDACTED:296-308 | examples/images/dreambooth/train_dreambooth_colossalai.py:323-335 | examples/images/dreambooth/train_dreambooth_colossalai_lora.py:322-334 | REDACTED:313-327 — before extracting anything, compare `REDACTED` and `examples/images/dreambooth/train_dreambooth_colossalai.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 401 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (13–14 lines × 6) · ×1
  • Duplicated block (13–14 lines × 6) applications/ColossalChat/examples/training_scripts/train_grpo.py:43 — applications/ColossalChat/examples/training_scripts/train_grpo.py:43-55 | applications/ColossalChat/examples/training_scripts/train_kto.py:26-39 | applications/ColossalChat/examples/training_scripts/train_orpo.py:26-39 | REDACTED:52-64 | applications/ColossalChat/examples/training_scripts/train_rm.py:28-40 | applications/ColossalChat/examples/training_scripts/train_sft.py:27-39 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_grpo.py` and `applications/ColossalChat/examples/training_scripts/train_kto.py` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 162 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (10–14 lines × 2) · ×1
  • Duplicated block (10–14 lines × 2) examples/tutorial/sequence_parallel/data/tokenizer/bert_tokenization.py:77 — examples/tutorial/sequence_parallel/data/tokenizer/bert_tokenization.py:77-86 | examples/tutorial/sequence_parallel/data/tokenizer/bert_tokenization.py:97-110 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (11–13 lines × 4) · ×1
  • Duplicated block (11–13 lines × 4) applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py:84 — applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py:84-94 | examples/images/vit/args.py:14-26 | examples/images/vit/args.py:62-74 | examples/language/opt/args.py:14-26 — before extracting anything, compare `applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py` and `examples/images/vit/args.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 59 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py:84` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `examples/images/vit/args.py:12` calls `add_argument` and `applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py:83` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (12 lines × 9) · ×1
  • Duplicated block (12 lines × 9) applications/ColossalChat/examples/training_scripts/train_dpo.py:73 — applications/ColossalChat/examples/training_scripts/train_dpo.py:73-84 | applications/ColossalChat/examples/training_scripts/train_grpo.py:210-221 | applications/ColossalChat/examples/training_scripts/train_grpo.py:224-235 | applications/ColossalChat/examples/training_scripts/train_kto.py:83-94 | applications/ColossalChat/examples/training_scripts/train_orpo.py:83-94 | REDACTED:248-259 | REDACTED:261-272 | applications/ColossalChat/examples/training_scripts/train_rm.py:111-122 | applications/ColossalChat/examples/training_scripts/train_sft.py:105-116 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_dpo.py` and `applications/ColossalChat/examples/training_scripts/train_grpo.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 88 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/examples/training_scripts/train_dpo.py:73` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `applications/ColossalChat/examples/training_scripts/train_grpo.py:208` calls `warning` and `applications/ColossalChat/examples/training_scripts/train_dpo.py:72` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (12 lines × 6) · ×1
  • Duplicated block (12 lines × 6) applications/ColossalChat/examples/training_scripts/train_dpo.py:147 — applications/ColossalChat/examples/training_scripts/train_dpo.py:147-158 | applications/ColossalChat/examples/training_scripts/train_grpo.py:125-136 | applications/ColossalChat/examples/training_scripts/train_kto.py:147-158 | applications/ColossalChat/examples/training_scripts/train_orpo.py:136-147 | REDACTED:147-158 | applications/ColossalChat/examples/training_scripts/train_sft.py:151-162 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_dpo.py` and `applications/ColossalChat/examples/training_scripts/train_grpo.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 88 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (11–12 lines × 3) · ×1
  • Duplicated block (11–12 lines × 3) examples/images/vit/vit_benchmark.py:75 — examples/images/vit/vit_benchmark.py:75-85 | examples/images/vit/vit_train_demo.py:178-188 | examples/language/opt/opt_train_demo.py:86-97 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `examples/images/vit/vit_benchmark.py:75` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9–12 lines × 2) · ×1
  • Duplicated block (9–12 lines × 2) examples/language/opt/args.py:57 — examples/language/opt/args.py:57-65 | examples/tutorial/opt/opt/run_clm.py:134-145 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `examples/language/opt/args.py:57` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (10–11 lines × 8) · ×1
  • Duplicated block (10–11 lines × 8) applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py:179 — applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py:179-189 | applications/ColossalChat/examples/training_scripts/train_dpo.py:146-155 | applications/ColossalChat/examples/training_scripts/train_grpo.py:124-133 | applications/ColossalChat/examples/training_scripts/train_kto.py:146-155 | applications/ColossalChat/examples/training_scripts/train_orpo.py:135-144 | REDACTED:146-155 | applications/ColossalChat/examples/training_scripts/train_rm.py:137-146 | applications/ColossalChat/examples/training_scripts/train_sft.py:149-159 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_dpo.py` and `applications/ColossalChat/examples/training_scripts/train_grpo.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 88 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py:179` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9–11 lines × 7) · ×1
  • Duplicated block (9–11 lines × 7) applications/ColossalChat/examples/training_scripts/train_dpo.py:222 — applications/ColossalChat/examples/training_scripts/train_dpo.py:222-230 | applications/ColossalChat/examples/training_scripts/train_grpo.py:310-318 | applications/ColossalChat/examples/training_scripts/train_kto.py:243-251 | applications/ColossalChat/examples/training_scripts/train_orpo.py:207-216 | REDACTED:355-363 | applications/ColossalChat/examples/training_scripts/train_rm.py:219-228 | applications/ColossalChat/examples/training_scripts/train_sft.py:226-236 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_dpo.py` and `applications/ColossalChat/examples/training_scripts/train_grpo.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 88 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `applications/ColossalChat/examples/training_scripts/train_orpo.py:207` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `applications/ColossalChat/examples/training_scripts/train_dpo.py:220` calls `boost`, `set_default_dtype` and `applications/ColossalChat/examples/training_scripts/train_orpo.py:207` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (9 lines × 8) · ×1
  • Duplicated block (9 lines × 8) applications/ColossalChat/examples/training_scripts/train_dpo.py:253 — applications/ColossalChat/examples/training_scripts/train_dpo.py:253-261 | applications/ColossalChat/examples/training_scripts/train_grpo.py:354-362 | applications/ColossalChat/examples/training_scripts/train_kto.py:274-282 | applications/ColossalChat/examples/training_scripts/train_orpo.py:239-247 | REDACTED:406-414 | REDACTED:428-436 | applications/ColossalChat/examples/training_scripts/train_rm.py:251-259 | applications/ColossalChat/examples/training_scripts/train_sft.py:258-266 — before extracting anything, compare `applications/ColossalChat/examples/training_scripts/train_dpo.py` and `applications/ColossalChat/examples/training_scripts/train_grpo.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 88 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Minor — 628 finding(s)
D34 · Knowledge Freshness · Orphaned file · ×538
  • Orphaned file colossalai/shardformer/layer/qkv_fused_linear.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file colossalai/shardformer/modeling/bloom.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file colossalai/shardformer/layer/_operation.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file colossalai/legacy/moe/openmoe/model/modeling_openmoe.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file colossalai/legacy/nn/layer/parallel_3d/layers.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file colossalai/legacy/nn/layer/parallel_2p5d/layers.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file colossalai/legacy/nn/layer/parallel_2d/layers.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file colossalai/zero/gemini/gemini_ddp.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file colossalai/fx/codegen/activation_checkpoint_codegen.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file colossalai/shardformer/modeling/gptj.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file colossalai/legacy/nn/layer/parallel_1d/layers.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file colossalai/shardformer/modeling/opt.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file colossalai/pipeline/schedule/zero_bubble_pp.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file colossalai/shardformer/modeling/gpt2.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file colossalai/shardformer/modeling/t5.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file colossalai/legacy/engine/schedule/_pipeline_schedule.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file colossalai/legacy/nn/layer/parallel_2p5d/_operation.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file colossalai/zero/gemini/gemini_optimizer.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file colossalai/shardformer/modeling/falcon.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file colossalai/shardformer/policies/t5.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file colossalai/tensor/shape_consistency.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file colossalai/legacy/nn/layer/parallel_2d/_operation.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file colossalai/autochunk/trace_indice.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file colossalai/legacy/inference/quant/smoothquant/models/llama.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • + 513 more in this group — see findings.md.
X4 · Structured logging · Interpolated REDACTED message defeats structured logging · ×40
  • Interpolated REDACTED message defeats structured logging colossalai/quantization/bnb.py:100 — `info` at line 100 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated REDACTED message defeats structured logging colossalai/legacy/inference/serving/torch_serve/Colossal_Inference_Handler.py:60 — `info` at line 60 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated REDACTED message defeats structured logging colossalai/legacy/inference/serving/torch_serve/Colossal_Inference_Handler.py:61 — `info` at line 61 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated REDACTED message defeats structured logging colossalai/legacy/inference/serving/torch_serve/Colossal_Inference_Handler.py:67 — `info` at line 67 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated REDACTED message defeats structured logging colossalai/legacy/inference/serving/torch_serve/Colossal_Inference_Handler.py:79 — `warning` at line 79 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.warning("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.warning("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated REDACTED message defeats structured logging colossalai/legacy/inference/serving/torch_serve/Colossal_Inference_Handler.py:92 — `info` at line 92 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated REDACTED message defeats structured logging colossalai/legacy/inference/serving/torch_serve/Colossal_Inference_Handler.py:182 — `info` at line 182 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated REDACTED message defeats structured logging colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py:33 — `info` at line 33 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated REDACTED message defeats structured logging colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py:34 — `info` at line 34 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated REDACTED message defeats structured logging colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py:38 — `info` at line 38 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated REDACTED message defeats structured logging colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py:42 — `info` at line 42 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated REDACTED message defeats structured logging colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py:60 — `info` at line 60 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated REDACTED message defeats structured logging colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py:83 — `info` at line 83 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated REDACTED message defeats structured logging colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py:86 — `info` at line 86 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated REDACTED message defeats structured logging colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py:91 — `info` at line 91 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated REDACTED message defeats structured logging colossalai/legacy/inference/serving/ray_serve/Colossal_Inference_rayserve.py:139 — `info` at line 139 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated REDACTED message defeats structured logging colossalai/legacy/inference/dynamic_batching/ray_dist_init.py:24 — `info` at line 24 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated REDACTED message defeats structured logging colossalai/legacy/inference/dynamic_batching/ray_dist_init.py:25 — `info` at line 25 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated REDACTED message defeats structured logging colossalai/legacy/inference/dynamic_batching/ray_dist_init.py:29 — `info` at line 29 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated REDACTED message defeats structured logging colossalai/legacy/inference/dynamic_batching/ray_dist_init.py:33 — `info` at line 33 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated REDACTED message defeats structured logging colossalai/legacy/inference/dynamic_batching/ray_dist_init.py:60 — `info` at line 60 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated REDACTED message defeats structured logging colossalai/legacy/inference/dynamic_batching/ray_init_config.py:51 — `error` at line 51 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.error("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated REDACTED message defeats structured logging colossalai/legacy/inference/dynamic_batching/ray_init_config.py:54 — `error` at line 54 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.error("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated REDACTED message defeats structured logging colossalai/legacy/inference/dynamic_batching/ray_init_config.py:57 — `error` at line 57 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.error("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated REDACTED message defeats structured logging colossalai/inference/logit_processors.py:184 — `warning` at line 184 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.warning("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `REDACTED.warning("order moved", order_id=order_id, status=status)` with structlog.
  • + 15 more in this group — see findings.md.
X10 · Duplicated predicate · Duplicated predicate · ×25
  • Duplicated predicate colossalai/fx/tracer/experimental.py:626 — `"bias" in kwargs and kwargs["bias"] is not None` appears character-identically in 2 files — colossalai/fx/tracer/experimental.py, colossalai/fx/tracer/tracer.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate colossalai/auto_parallel/tensor_shard/node_handler/conv_handler.py:109 — `"bias" in self.node.kwargs and self.node.kwargs["bias"] is not None` appears character-identically in 2 files — colossalai/auto_parallel/tensor_shard/node_handler/conv_handler.py, colossalai/auto_parallel/tensor_shard/node_handler/linear_handler.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate colossalai/nn/optimizer/distributed_galore.py:179 — `"weight_decay" in group and group["weight_decay"] > 0` appears character-identically in 2 files — colossalai/nn/optimizer/distributed_galore.py, colossalai/nn/optimizer/galore.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate colossalai/inference/modeling/models/pixart_alpha.py:200 — `(i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0` appears character-identically in 2 files — colossalai/inference/modeling/models/pixart_alpha.py, colossalai/inference/modeling/models/stablediffusion3.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate colossalai/legacy/nn/parallel/layers/cache_embedding/parallel_cached_embedding_tablewise.py:161 — `(not self.include_last_offset) and (batch_size * (handle_table + 1) >= indices.shape[0])` appears character-identically in 2 files — colossalai/legacy/nn/parallel/layers/cache_embedding/parallel_cached_embedding_tablewise.py, colossalai/legacy/nn/parallel/layers/cache_embedding/parallel_cached_embedding_tablewise_split_cache.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate colossalai/shardformer/modeling/_llama_tf4.py:235 — `(not shard_config.parallel_output) or force_sp_gather or is_share_sp_tp(sp_mode)` appears character-identically in 3 files — colossalai/shardformer/modeling/_llama_tf4.py, colossalai/shardformer/modeling/_llama_tf5.py, colossalai/shardformer/modeling/gpt2.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate colossalai/shardformer/modeling/_qwen2_tf4.py:242 — `(not shard_config.parallel_output) or force_sp_output_gather or is_share_sp_tp(sp_mode)` appears character-identically in 6 files — colossalai/shardformer/modeling/_qwen2_tf4.py, colossalai/shardformer/modeling/_qwen2_tf5.py, colossalai/shardformer/modeling/_qwen3_tf4.py, colossalai/shardformer/modeling/_qwen3_tf5.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate colossalai/shardformer/modeling/_llama_tf4.py:507 — `(sp_size is not None) and ( sp_group is not None )` appears character-identically in 11 files — colossalai/shardformer/modeling/_llama_tf4.py, colossalai/shardformer/modeling/_llama_tf5.py, colossalai/shardformer/modeling/_mixtral_tf4.py, colossalai/shardformer/modeling/_mixtral_tf5.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate colossalai/legacy/nn/layer/parallel_2d/layers.py:555 — `H == self.img_size[0] and W == self.img_size[1]` appears character-identically in 3 files — colossalai/legacy/nn/layer/parallel_2d/layers.py, colossalai/legacy/nn/layer/parallel_2p5d/layers.py, colossalai/legacy/nn/layer/vanilla/layers.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate colossalai/_analyzer/fx/codegen.py:264 — `_is_from_torch(obj) and obj != torch.device` appears character-identically in 3 files — colossalai/_analyzer/fx/codegen.py, colossalai/autochunk/autochunk_codegen.py, colossalai/fx/codegen/activation_checkpoint_codegen.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate colossalai/shardformer/modeling/_deepseek_v3_tf4.py:204 — `attention_mask is not None and 0 in attention_mask` appears character-identically in 8 files — colossalai/shardformer/modeling/_deepseek_v3_tf4.py, colossalai/shardformer/modeling/_mixtral_tf4.py, colossalai/shardformer/modeling/_mixtral_tf5.py, colossalai/shardformer/modeling/_qwen2_tf4.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py:257 — `attention_mask is not None and not attention_mask.all()` appears character-identically in 3 files — colossalai/legacy/inference/tensor_parallel/modeling/chatglm2.py, colossalai/shardformer/modeling/chatglm2.py, colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate colossalai/shardformer/modeling/_mixtral_tf4.py:736 — `attention_mask is not None and self.config._attn_implementation == "flash_attention_2" and use_cache` appears character-identically in 3 files — colossalai/shardformer/modeling/_mixtral_tf4.py, colossalai/shardformer/modeling/_mixtral_tf5.py, colossalai/shardformer/modeling/mistral.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate colossalai/fx/tracer/experimental.py:656 — `bias_addition_module.has(mod_type) and mod.bias is not None` appears character-identically in 2 files — colossalai/fx/tracer/experimental.py, colossalai/fx/tracer/tracer.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate colossalai/shardformer/modeling/_vit_tf4.py:273 — `bool_masked_pos is not None and (self.config.patch_size != self.config.encoder_stride)` appears character-identically in 2 files — colossalai/shardformer/modeling/_vit_tf4.py, colossalai/shardformer/modeling/_vit_tf5.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:478 — `buf is not None and name not in non_persistent_buffers` appears character-identically in 2 files — colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py, colossalai/inference/core/plugin.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate colossalai/shardformer/layer/parallel_module.py:64 — `buf is not None and name not in self._non_persistent_buffers_set` appears character-identically in 2 files — colossalai/shardformer/layer/parallel_module.py, colossalai/zero/gemini/gemini_ddp.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate colossalai/shardformer/modeling/_whisper_tf4.py:1049 — `decoder_input_ids is None and decoder_inputs_embeds is None` appears character-identically in 2 files — colossalai/shardformer/modeling/_whisper_tf4.py, colossalai/shardformer/modeling/_whisper_tf5.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate colossalai/shardformer/modeling/_llama_tf4.py:130 — `disable_pp or not stage_manager.is_first_stage()` appears character-identically in 2 files — colossalai/shardformer/modeling/_llama_tf4.py, colossalai/shardformer/modeling/_llama_tf5.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate colossalai/shardformer/modeling/_llama_tf4.py:79 — `disable_pp or stage_manager.is_first_stage()` appears character-identically in 3 files — colossalai/shardformer/modeling/_llama_tf4.py, colossalai/shardformer/modeling/_llama_tf5.py, colossalai/shardformer/modeling/gpt2.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate colossalai/shardformer/modeling/_llama_tf4.py:233 — `disable_pp or stage_manager.is_last_stage()` appears character-identically in 3 files — colossalai/shardformer/modeling/_llama_tf4.py, colossalai/shardformer/modeling/_llama_tf5.py, colossalai/shardformer/modeling/gpt2.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate colossalai/booster/plugin/dp_plugin_base.py:57 — `distributed_sampler_cls or DistributedSampler` appears character-identically in 3 files — colossalai/booster/plugin/dp_plugin_base.py, colossalai/booster/plugin/gemini_plugin.py, colossalai/booster/plugin/hybrid_parallel_plugin.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate applications/ColossalChat/coati/distributed/consumer.py:255 — `effective_group_mask is None or effective_group_mask[group_idx]` appears character-identically in 2 files — applications/ColossalChat/coati/distributed/consumer.py, applications/ColossalChat/coati/distributed/zero_bubble/consumer.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate applications/ColossalChat/coati/distributed/producer.py:368 — `episode != self.num_episodes - 1 or i != num_valid_microbatches - 1` appears character-identically in 2 files — applications/ColossalChat/coati/distributed/producer.py, applications/ColossalChat/coati/distributed/zero_bubble/producer.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate colossalai/tensor/d_tensor/layout_converter.py:198 — `f_index not in source_spec.dim_partition_dict and b_index not in source_spec.dim_partition_dict` appears character-identically in 2 files — colossalai/tensor/d_tensor/layout_converter.py, colossalai/tensor/shape_consistency.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
D34 · Knowledge Freshness · Most significant orphaned file · ×3
  • Most significant orphaned file colossalai/legacy/pipeline/rpc/_pipeline_base.py:1 — One of the orphaned files carrying the most lost knowledge — ranked by size weighted by the file's role in the codebase, the same weighting behind the score above, so core code outranks equally large plumbing. A reasonable place to start a read-through before the aggregate risk above bites.
  • Most significant orphaned file colossalai/checkpoint_io/hybrid_parallel_checkpoint_io.py:1 — One of the orphaned files carrying the most lost knowledge — ranked by size weighted by the file's role in the codebase, the same weighting behind the score above, so core code outranks equally large plumbing. A reasonable place to start a read-through before the aggregate risk above bites.
  • Most significant orphaned file colossalai/shardformer/layer/attn.py:1 — One of the orphaned files carrying the most lost knowledge — ranked by size weighted by the file's role in the codebase, the same weighting behind the score above, so core code outranks equally large plumbing. A reasonable place to start a read-through before the aggregate risk above bites.
D29 · Static Analysis (SAST) · REDACTED · ×2
  • REDACTED
  • REDACTED
C2 · Access Controls · Thin authorization enforcement · ×1
  • Thin authorization enforcement — Authorization rules exist but no route guard, auth middleware or handler that refuses a caller was found.
D16 · Bus Factor · Off-boarding risk · ×1
  • Off-boarding risk: anonymized user #1 — If anonymized user #1 becomes unavailable, 2 significant file(s) lose their only recent owner: colossalai/shardformer/modeling/chatglm2_6b/modeling_chatglm.py, colossalai/shardformer/modeling/chatglm2_6b/configuration_chatglm.py. Pair on, review, or document these before any departure.
D16 · Bus Factor · Further sole-owners (lower concentration) · ×1
  • Further sole-owners (lower concentration) — 1 other contributor(s) are each the sole owner of a small amount of code below the off-boarding threshold — folded into the bus-factor score and metrics (5 single-owned of 599 analysed files in total, counted over production source files of roughly 2,400 bytes or more, excluding vendored, generated, example/demo and scaffolding-template trees and test files identified by path convention, largest first; 599 of the 1024 production source files in this repository met that bar). They are anonymized user #2 (2 file(s)) — spread or document their files in the same way, at lower priority than the named off-boarding risks above. The files folded here: applications/ColossalChat/coati/distributed/zero_bubble/producer.py, applications/ColossalChat/rl_example_zero_bubble.py.
D20 · ADR Quality · No ADRs found · ×1
  • No ADRs found — No ADRs found. No recognised ADR directory (`docs/adr/`, `docs/decisions/`, `adr/`, `docs/rfcs/`, an `ADR0001/` folder, or their siblings) exists anywhere in this tree. What was searched, so you can tell an empty REDACTED from a search that missed one: every directory under the tree (build output, dependencies and VCS metadata excepted), for a document that is either any non-index page inside a recognised ADR directory, whatever its name and however deeply nested (`docs/adr/use-postgres.md`, `docs/adr/2024/0001-x.md`); or a file anywhere whose name is ADR-shaped (`0001-use-postgres.md`, `adr-012-caching.md`); or, when neither turned anything up, a document carrying the decision-record signature (an "Architecture Decision Record" heading, or Status / Context / Decision / Consequences as section headings). A decision REDACTED that clears none of these — unnumbered files outside any recognised directory, without those headings — is not seen by this check and this row is then wrong. If that is your case, say so rather than renaming anything; otherwise, consider recording architectural decisions in `docs/adr/`.
D26 · Project Cohesion · Projects may be oversized for their cohesion · ×1
  • Projects may be oversized for their cohesion — 2 of 8 project(s) overshoot their size bounds, lowering Project Cohesion to 5.0/10. The most over is `(repository root)` (149051 LoC, 1417 module-visible types across 180 directories). Review these for cohesion — draw the boundary inside the module first (group each responsibility into its own package or directory and keep the cross-boundary members non-public), since splitting a published package moves types between packages and breaks consumers.
D28 · Secrets (history) · Rotate the exposed credentials · ×1
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED · ×1
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED · ×1
  • REDACTED
D30 · Dependency Vulnerabilities · Low CVE · ×1
  • REDACTED
D34 · Knowledge Freshness · Concentrated knowledge decay · ×1
  • Concentrated knowledge decay — 541 of 599 significant files have no living knowledge, while the repository is still being changed at a low rate (63 commit(s) in the last 90 days) — so this is one repo-wide knowledge-decay state, not 541 separate risks. Counted over 599 of the 1024 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over. The code moved on without the people who understood these files: document them or schedule a read-through before the next change lands in them.
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
M2 · Architecture documentation · No ADRs · ×1
  • No ADRs — No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.
M3 · Folder & project structure · No src/ separation · ×1
  • No src/ separation — Production code isn't grouped under a src/ folder — it's spread across several top-level directories, so there's no one place that says 'this is the product'.
P2 · Observability · Logging is not universal · ×1
  • Logging is not universal — Only 5/7 runnable modules use logging (modules with no entry point or server are excluded — they are libraries a runnable module hosts). Silent: `applications/ColossalMoE`, `colossalai/legacy/moe/openmoe`.
P3 · Security & performance tooling · No SAST · ×1
  • No SAST — No static application security testing detected. For this repository's stack, add bandit, `semgrep --config=p/python`, or CodeQL's python pack as a CI step. What was searched, so you can tell an absence from a miss: the 78976 CI workflow file(s) in this repository, and the scanner and linter configuration checked in beside them. A scan that runs outside CI, one configured in your forge's web UI rather than in a committed file, or a tool whose name is none of those this check carries, is not seen — if that is your case the row is wrong, and saying so is more useful than adding a second scanner.
P6 · Release Hygiene · No changelog · ×1
  • No changelog — No CHANGELOG/HISTORY/RELEASES file — what shipped when isn't easy to reconstruct for support or audit. (Versioning/tagging makes releases traceable, but a changelog records the what.)
X7 · Silent fallback defaults · Silent fallback default in catch · ×1
  • Silent fallback default in catch REDACTED:612 — `rouge_score` swallows every exception into `return 0.0` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Minor — 49 finding(s)
D12 · Dependency Hygiene · Outdated · ×49
  • Outdated: autoflake — `autoflake` is pinned to 2.2.1, but 2.4.0 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 2.2.1 until the declaration is edited.
  • Outdated: black — `black` is pinned to 23.9.1, but 26.10.1 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 23.9.1 until the declaration is edited. This crosses a major version, so it is a migration rather than a bump.
  • Outdated: certifi — `certifi` is pinned to 2026.7.22, but 2026.10.23 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 2026.7.22 until the declaration is edited.
  • Outdated: chromadb — `chromadb` is pinned to 0.4.9, but 1.5.9 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 0.4.9 until the declaration is edited. This crosses a major version, so it is a migration rather than a bump.
  • Outdated: datasets — `datasets` is pinned to 2.14.7, but 5.1.0 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 2.14.7 until the declaration is edited. This crosses a major version, so it is a migration rather than a bump.
  • Outdated: diffusers — `diffusers` is pinned to 0.35.2, but 0.42.0 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 0.35.2 until the declaration is edited.
  • Outdated: filelock — `filelock` is pinned to 4.0.1, but 4.2.4 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 4.0.1 until the declaration is edited.
  • Outdated: gradio — `gradio` is pinned to 3.44.4, but 6.30.0 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 3.44.4 until the declaration is edited. This crosses a major version, so it is a migration rather than a bump.
  • Outdated: hf-xet — `hf-xet` is pinned to 1.6.0, but 1.7.0 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 1.6.0 until the declaration is edited.
  • Outdated: huggingface-hub — `huggingface-hub` is pinned to 1.32.0, but 2.3.0 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 1.32.0 until the declaration is edited. This crosses a major version, so it is a migration rather than a bump.
  • Outdated: iniconfig — `iniconfig` is pinned to 2.3.0, but 2.3.1 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 2.3.0 until the declaration is edited.
  • Outdated: jq — `jq` is pinned to 1.6.0, but 1.13.0 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 1.6.0 until the declaration is edited.
  • Outdated: langchain — `langchain` is pinned to 0.0.330, but 1.4.7 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 0.0.330 until the declaration is edited. This crosses a major version, so it is a migration rather than a bump.
  • Outdated: langchain-experimental — `langchain-experimental` is pinned to 0.0.37, but 0.4.2 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 0.0.37 until the declaration is edited.
  • Outdated: markupsafe — `markupsafe` is pinned to 3.0.3, but 3.0.4 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 3.0.3 until the declaration is edited.
  • Outdated: modelscope — `modelscope` is pinned to 1.9.0, but 1.40.2 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 1.9.0 until the declaration is edited.
  • Outdated: mpmath — `mpmath` is pinned to 1.3.0, but 1.4.1 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 1.3.0 until the declaration is edited.
  • Outdated: networkx — `networkx` is pinned to 3.6.1, but 3.7 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 3.6.1 until the declaration is edited.
  • Outdated: ninja — `ninja` is pinned to 1.11.1, but 1.13.2 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 1.11.1 until the declaration is edited.
  • Outdated: numpy — `numpy` is pinned to 2.4.6, but 2.5.4 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 2.4.6 until the declaration is edited.
  • Outdated: openai — `openai` is pinned to 0.28.0, but 3.37.0 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 0.28.0 until the declaration is edited. This crosses a major version, so it is a migration rather than a bump.
  • Outdated: packaging — `packaging` is pinned to 24.0, but 26.3 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 24.0 until the declaration is edited. This crosses a major version, so it is a migration rather than a bump.
  • Outdated: peft — `peft` is pinned to 0.19.1, but 0.21.2 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 0.19.1 until the declaration is edited.
  • Outdated: pillow — `pillow` is pinned to 12.3.0, but 13.0.0 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 12.3.0 until the declaration is edited. This crosses a major version, so it is a migration rather than a bump.
  • Outdated: pip — `pip` is pinned to 26.2.1, but 26.2.2 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 26.2.1 until the declaration is edited.
  • + 24 more in this group — see findings.md.

Appendix B — Reproduction & audit trail

Every external tool invocation behind a deep-scan dimension — the tool, its captured version, the exact command, how many findings it yielded, and a link to the retained raw output. To reproduce any finding: check out the same commit and run the command shown (repo-relative — never an absolute scratch path). The complete raw scanner output is retained verbatim under artifacts/raw/ (indexed in artifacts/raw/index.json); per-invocation exit codes and wall-clock durations are in sidecar.json — kept out of this table so the rendered report stays byte-identical across runs of the same commit.

DimensionToolVersionCommandFindingsRaw output
D28 · Secrets (history)gitleaks—gitleaks detect --no-banner --config /opt/gitleaks-rules/watchdog-gitleaks.toml --report-format json --report-path /tmp/watchdog-gitleaks-fa7f357416c4483291a54aec054052c2/history.json --exit-code 0 --source .5artifacts/raw/gitleaks-history.json
D28 · Secrets (history)gitleaks—gitleaks detect --no-git --no-banner --config /opt/gitleaks-rules/watchdog-gitleaks.toml --report-format json --report-path /tmp/watchdog-gitleaks-fa7f357416c4483291a54aec054052c2/tree.json --exit-code 0 --source .0artifacts/raw/gitleaks-tree.json
D29 · Static Analysis (SAST)semgrep—semgrep --config /opt/semgrep-rules/security-audit.yml --config /opt/semgrep-rules/owasp-top-ten.yml --config /opt/semgrep-rules/watchdog-sast.yml --json --quiet --timeout 10 --timeout-threshold 3 --metrics off --exclude *.arrow --exclude *.avro --exclude *.csv --exclude *.dat --exclude *.db --exclude *.feather --exclude *.geojson --exclude *.h5 --exclude *.hdf5 --exclude *.jsonl --exclude *.log --exclude *.ndjson --exclude *.npy --exclude *.npz --exclude *.orc --exclude *.parquet --exclude *.pickle --exclude *.pkl --exclude *.psv --exclude *.sqlite --exclude *.sqlite3 --exclude *.tfrecord --exclude *.tsv --exclude *.txt .126artifacts/raw/semgrep.json
D30 · Dependency Vulnerabilitiesosv-scanner—osv-scanner --format json --recursive --experimental-disable-plugins transitivedependency/requirements --experimental-disable-plugins dotnet/csproj --experimental-disable-plugins dotnet/nugetcpm .29artifacts/raw/osv-scanner.json
D31 · IaC & Container Securitytrivy—trivy config --format json --quiet .22artifacts/raw/trivy-config.json
D32 · Data Compliance (PII/GDPR)semgrep—semgrep: not applicable — No personal data was found crossing a boundary the PII/GDPR ruleset checks — nothing written to a REDACTED or console sink, placed in a URL or query string, or persisted to browser storage. That is a clean result for the LEAK surface only: this ruleset detects personal data escaping, it does not inventory the personal data a repository holds, so it is not evidence that this repository has no personal-data surface. The personal-data map (Appendix C) and the C1-C5 compliance cards are what speak to that.0—
D37 · Vulnerability-disclosure Policydisclosure—disclosure: not applicable — No vulnerability-disclosure policy file found (SECURITY.md/.markdown/.rst/.txt at root or under .github/.forgejo/.gitea/docs, .well-known/security.txt). A coordinated-disclosure policy may live off-repo, so this is not evidenced rather than failed.0—
D40 · Network Egress Confinementruntime-hardening—runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.0—
D41 · Kernel & Syscall Confinementruntime-hardening—runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.0—
D42 · Runtime Threat Enforcementruntime-hardening—runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.0—
D43 · Malicious Dependenciesosv-scanner—osv-scanner --format json --recursive --experimental-disable-plugins transitivedependency/requirements --experimental-disable-plugins dotnet/csproj --experimental-disable-plugins dotnet/nugetcpm .0artifacts/raw/osv-scanner.json

Run 01a171ff-2c03-7b02-82be-001cd4030dbf · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.

Downloadable artifacts

Machine-readable and reproducible from this commit + frozen rubric — drop them straight into a contract appendix, a CRA dossier, or a downstream SCA / VEX tool.

⬇ Findings, MITRE CWE-tagged .sarif⬇ Health changelog .md