AI Slop Code RIsk Monitor

modelscope/ms-swift

Use PEFT or Full-parameter to CPT/SFT/DPO/GRPO 600+ LLMs (Qwen3.8, DeepSeek-V4, GLM-5.1, InternLM3, Llama4, ...) and 300+ MLLMs (Qwen3-VL, Qwen3-Omni, InternVL3.5, Ovis2.5, GLM5.3, Gemma4, Llava, Phi4, ...) (AAAI 2025).

19.6 Elevated pattern signal View on GitHub

Maintenance and Governance Review

This report summarizes scanner evidence for modelscope/ms-swift, a Python project with 15,808 GitHub stars. SynthScan examined 201,572 lines of code across 1446 source files, recording 3231 pattern matches distributed across 25 syntactic categories. The legacy adjusted pattern signal is 19.6 (Elevated pattern signal); it is not an authorship estimate.

Use the findings to ask whether maintainers can explain intent, verify dependencies, simplify unnecessary scaffolding, and focus review effort. Risk Payload v1 adds ownership, supply-chain, over-engineering, and review-effort vectors when available. These are prompts for human verification, not probabilities, security findings, or measured maintenance costs.

19.6
Adjusted Signal
19.6
Raw Pattern Score
100%
Time Factor
2026-10-10
Last Push
15.8K
Stars
Python
Language
201.6K
Lines of Code
1.4K
Files
3.2K
Pattern Hits
2026-10-12
Scan Date
0.08
HC Hit Rate

Risk Review · v3

Use each vector to guide manual verification of the underlying findings.

Cognitive Ownership Risk 39.8/100 · MEDIUM

Can maintainers explain intent, assumptions, and trade-offs? 1809 finding(s).

Hallucinated Dependency & Supply Chain Risk 19.4/100 · LOW

Are imports declared and package/API names verified? 983 finding(s).

Agent Over-Engineering Ratio 43.9/100 · MEDIUM

Are wrappers, guards, and repeated structures necessary? 1649 finding(s).

PR Review Velocity Impact 63.9/100 · HIGH

Which changes need focused human review? 3231 finding(s).

What These Metrics Mean

Adjusted Signal
Legacy pattern score normalized per 1,000 scanned lines and multiplied by the repository-level time factor. It is not an estimate of AI authorship.
Raw Pattern Score
Sum of severity- and context-weighted pattern findings before applying the time factor.
Time Factor
A coarse multiplier based on repository last-push metadata. It does not identify when individual code was written.
Pattern Hits
Count of configured pattern findings. Review each location and surrounding code before acting.
HC Hit Rate
High- and critical-severity findings per scanned file. Severity is a configured detector weight, not proof of a vulnerability or authorship.
Lines / Files
Scan coverage denominators used by the legacy normalized score.

Pattern-Signal History

This chart tracks the legacy adjusted pattern score across scan runs. Changes can reflect source changes, scan coverage, or detector/scoring versions; they do not measure AI adoption or prove that a team refactored code. Compare runs only when their scoring versions are compatible. The dashed line tracks the raw pattern-hit count.

Severity Breakdown

Groups findings by configured severity weight. Severity is not a confidence estimate, security rating, or proof that a package is missing. Verify imports against the project's manifests and inspect each finding in its local design context.

CRITICAL 0HIGH 117MEDIUM 148LOW 2966

Directory Score Breakdown

This horizontal bar chart shows where configured pattern scores accumulate across directories. Treat the bars as locations to inspect, not as evidence of authorship or code quality. Use the file-level findings to decide whether a directory needs a focused ownership, dependency, complexity, or review check.

Pattern Findings

The scanner identified 3231 distinct pattern matches across 25 syntactic categories. Each entry below represents a discrete location in the source code where the engine recorded a detector match to inspect in context. Expand any category row to inspect the individual file paths, line numbers, code snippets, and the lexical context (CODE, COMMENT, or STRING) in which each match was detected.

Reading the findings table: The Severity column indicates the configured finding weight (CRITICAL / HIGH / MEDIUM / LOW). The Context column identifies whether the match occurred inside executable code, an inline comment, or a string literal — legacy comment-context matches receive a ×1.5 score weight. The ⚡ bolt icon marks clustered matches: three or more patterns within a 10-line window, each receiving an additional ×1.5 density multiplier under the legacy scoring model.

Hyper-Verbose Identifiers1171 hits · 1260 pts
SeverityFileLineSnippetContext
LOWtests/test_utils.py74def create_dummy_test_dataset(feat, label, num):CODE
LOW⚡tests/run.py27def deduplicate_preserve_order(items):CODE
LOW⚡tests/run.py31def get_available_npu_devices(visible_npus):CODE
LOWtests/run.py102def gather_test_suites_in_files(test_dir, case_file_list, list_tests):CODE
LOWtests/run.py157def async_run_command_with_popen(cmd, device_id):CODE
LOWtests/run.py347def run_non_parallelizable_test_suites(suites, result_dir):CODE
LOWtests/general/test_tool_schema_padding.py64 def test_arrow_aligned_tools_are_restored(self):CODE
LOWtests/general/test_tool_schema_padding.py77 def test_padding_is_removed_from_every_schema_position(self):CODE
LOWtests/general/test_tool_schema_padding.py162 def test_semantic_nulls_and_literal_objects_are_preserved(self):CODE
LOWtests/general/test_tool_schema_padding.py189 def test_dependencies_may_hold_property_names(self):CODE
LOWtests/general/test_tool_schema_padding.py202 def test_non_dict_values_are_returned_as_is(self):CODE
LOWtests/general/test_tool_schema_padding.py265 def test_loading_a_jsonl_keeps_every_tool_schema_intact(self):CODE
LOWtests/general/test_tool_schema_padding.py272 def test_the_tools_column_is_stored_as_json(self):CODE
LOWtests/general/test_tool_schema_padding.py284 def test_concatenating_datasets_keeps_both_tool_schemas(self):CODE
LOW⚡tests/general/test_tool_schema_padding.py295 def test_batched_cast_does_not_drop_tool_fields(self):CODE
LOW⚡tests/general/test_tool_schema_padding.py305 def test_a_json_string_column_is_parsed(self):CODE
LOW⚡tests/general/test_tool_schema_padding.py312 def test_a_single_tool_dict_becomes_a_list(self):CODE
LOW⚡tests/general/test_tool_schema_padding.py319 def test_non_dict_tools_are_left_untouched(self):CODE
LOW⚡tests/general/test_tool_schema_padding.py327 def test_a_bare_string_becomes_a_single_element_list(self):CODE
LOW⚡tests/general/test_tool_schema_padding.py334 def test_a_json_scalar_is_not_split_into_characters(self):CODE
LOWtests/general/test_tool_schema_padding.py345 def test_every_tool_column_is_normalized(self):CODE
LOWtests/general/test_tool_schema_padding.py353 def test_rows_without_tools_are_untouched(self):CODE
LOWtests/general/test_dataset_source.py11 def test_dataset_syntax_parses_explicit_hub_prefixes(self):CODE
LOWtests/general/test_dataset_source.py15 def test_explicit_ms_source_overrides_global_hf_default(self):CODE
LOWtests/general/test_dataset_list.py11 def test_builtin_named_dataset(self):CODE
LOWtests/general/test_dataset_list.py16 def test_named_and_unnamed_datasets_use_selected_hub(self):CODE
LOWtests/general/test_model.py83 def test_seq_cls_architectures_rewrite(self):CODE
LOWtests/general/test_model.py106 def test_seq_cls_architectures_unknown_suffix(self):CODE
LOWtests/general/test_model.py116 def test_seq_cls_architectures_saved_config(self):CODE
LOWtests/general/test_model.py155 def test_seq_cls_architectures_saved_config_deepcopy(self):CODE
LOWtests/general/test_model.py181 def test_seq_cls_architectures_saved_config_pickle(self):CODE
LOWtests/general/test_model.py196 def test_seq_cls_architectures_non_main_then_main(self):CODE
LOWtests/general/test_model.py211 def test_seq_cls_architectures_pickle_fresh_process(self):CODE
LOWtests/general/test_model.py246 def test_seq_cls_architectures_save_failure_cleanup(self):STRING
LOWtests/general/test_model.py262 def test_seq_cls_architectures_failure_before_config_save(self):STRING
LOWtests/general/test_model.py281 def test_seq_cls_architectures_existing_save_wrapper(self):STRING
LOWtests/general/test_model.py298 def test_seq_cls_architectures_none_keeps_class_name(self):STRING
LOWtests/general/test_model.py318 def test_seq_cls_architectures_post_patch_assignment_kept(self):STRING
LOWtests/general/test_model.py333 def test_seq_cls_architectures_unpatched_instance_unaffected(self):STRING
LOW⚡tests/general/test_protocol_tool_choice.py30 def test_selected_tool_keeps_only_that_tool(self):CODE
LOW⚡tests/general/test_protocol_tool_choice.py34 def test_unknown_tool_raises_value_error(self):CODE
LOW⚡tests/general/test_protocol_tool_choice.py38 def test_string_tool_choice_keeps_every_tool(self):CODE
LOWtests/general/test_qwen3_coder_agent_template.py41 def test_encode_tool_call_content(self):CODE
LOWtests/general/test_qwen3_coder_agent_template.py101 def test_plain_assistant_content_is_preserved(self):CODE
LOWtests/general/test_qwen3_coder_agent_template.py139 def test_non_assistant_prefix_is_unchanged(self):CODE
LOWtests/general/test_qwen3_5_fp32_weights.py219 def test_serializes_overlapping_policy_contexts(self):CODE
LOWtests/general/test_multimodal_optimizer.py30 def test_full_and_peft_parameter_coverage(self):CODE
LOWtests/general/test_lisa_callback.py54 def test_lisa_can_be_created_before_trainer_initialization(self):CODE
LOWtests/general/test_lisa_callback.py67 def test_lisa_does_not_freeze_layers_before_optimizer_creation(self):CODE
LOWtests/general/test_lisa_callback.py73 def test_newly_activated_lisa_layers_receive_optimizer_updates(self):CODE
LOWtests/general/test_lisa_callback.py108 def test_lisa_rejects_adapter_training(self):CODE
LOWtests/general/test_moss_vl.py48 def test_template_state_and_unsupported_modes(self):CODE
LOWtests/general/test_moss_vl.py64 def test_video_pixel_limits_are_routed_to_video_processor(self):CODE
LOWtests/general/test_moss_vl.py104 def test_video_environment_limits_are_supported(self):CODE
LOWtests/general/test_moss_vl.py137 def test_truncation_preserves_media_contract(self):CODE
LOWtests/general/test_moss_vl.py163 def test_cross_attention_masks_are_padded(self):CODE
LOWtests/general/test_moss_vl.py195 def test_inference_cross_attention_masks_are_left_padded(self):CODE
LOWtests/general/test_moss_vl.py228 def test_media_metadata_is_collated(self):CODE
LOWtests/general/test_moss_vl.py253 def test_mixed_media_and_text_only_batch_contract(self):CODE
LOWtests/general/test_moss_vl.py299 def test_non_module_aligner_parameter_is_not_scanned_for_lora(self):CODE
1111 more matches not shown…
Unused Imports975 hits · 832 pts
SeverityFileLineSnippetContext
LOWsetup.py7CODE
LOWtests/run.py37CODE
LOWtests/llm/test_template.py52CODE
LOWtests/deploy/test_rollout_auth_comprehensive.py11CODE
LOWtests/deploy/test_rollout_auth_comprehensive.py12CODE
LOWtests/models/test_mllm.py8CODE
LOWtests/models/test_mllm.py8CODE
LOWtests/rollout/test_server_exact_token_io.py215CODE
LOW…sts/sequence_parallel/test_zigzag_ring_attn_npu_e2e.py10CODE
LOW…sts/sequence_parallel/test_zigzag_ring_attn_npu_e2e.py73CODE
LOW…ts/sequence_parallel/test_zigzag_ring_attn_cuda_e2e.py73CODE
LOWtests/sequence_parallel/test_zigzag_ring_attn_npu.py12CODE
LOWtests/train/test_resume_from_checkpoint.py29CODE
LOWtests/train/test_resume_from_checkpoint.py29CODE
LOWtests/train/test_freeze.py18CODE
LOWtests/train/test_freeze.py18CODE
LOWtests/train/test_freeze.py36CODE
LOWtests/train/test_freeze.py36CODE
LOWtests/train/test_freeze.py54CODE
LOWtests/train/test_freeze.py54CODE
LOWtests/train/test_freeze.py72CODE
LOWtests/train/test_freeze.py72CODE
LOWtests/test_align/test_padding_side.py51CODE
LOWtests/megatron/test_megatron_args.py23CODE
LOWtests/megatron/test_megatron_args.py23CODE
LOWswift/__init__.py13CODE
LOWswift/__init__.py18CODE
LOWswift/__init__.py18CODE
LOWswift/__init__.py19CODE
LOWswift/__init__.py19CODE
LOWswift/__init__.py19CODE
LOWswift/__init__.py19CODE
LOWswift/__init__.py19CODE
LOWswift/__init__.py19CODE
LOWswift/__init__.py19CODE
LOWswift/__init__.py19CODE
LOWswift/__init__.py19CODE
LOWswift/__init__.py19CODE
LOWswift/__init__.py19CODE
LOWswift/__init__.py22CODE
LOWswift/__init__.py22CODE
LOWswift/__init__.py23CODE
LOWswift/__init__.py23CODE
LOWswift/__init__.py24CODE
LOWswift/__init__.py24CODE
LOWswift/__init__.py24CODE
LOWswift/__init__.py24CODE
LOWswift/__init__.py24CODE
LOWswift/__init__.py24CODE
LOWswift/__init__.py24CODE
LOWswift/__init__.py24CODE
LOWswift/__init__.py24CODE
LOWswift/__init__.py24CODE
LOWswift/__init__.py26CODE
LOWswift/__init__.py26CODE
LOWswift/__init__.py27CODE
LOWswift/__init__.py27CODE
LOWswift/__init__.py27CODE
LOWswift/__init__.py27CODE
LOWswift/__init__.py27CODE
915 more matches not shown…
Deep Nesting415 hits · 382 pts
SeverityFileLineSnippetContext
LOWsetup.py24CODE
LOWsetup.py44CODE
LOWsetup.py78CODE
LOWsetup.py96CODE
LOWtests/test_utils.py124CODE
LOWtests/run.py58CODE
LOWtests/run.py102CODE
LOWtests/run.py217CODE
LOWtests/run.py236CODE
LOWtests/run.py375CODE
LOWtests/run.py489CODE
LOWtests/general/test_model.py116CODE
LOWtests/general/test_model.py262CODE
LOWtests/general/test_qwen3_coder_agent_template.py41CODE
LOWtests/general/test_qwen3_5_fp32_weights.py24CODE
LOWtests/general/test_qwen3_5_fp32_weights.py219CODE
LOWtests/general/test_qwen3_5_fp32_weights.py291CODE
LOWtests/general/test_multimodal_optimizer.py30CODE
LOWtests/general/test_glm4_5_agent_template.py119CODE
LOWtests/general/test_glm4_5_agent_template.py135CODE
LOWtests/general/test_frozen_vision.py63CODE
LOWtests/general/test_arch.py1CODE
LOWtests/general/test_cls_generation_preprocessor.py10CODE
LOWtests/general/test_activation_offload_views.py39CODE
LOWtests/general/test_rejected_response.py124CODE
LOWtests/general/test_rejected_response.py181CODE
LOWtests/general/test_dataset_routing_tag.py80CODE
LOWtests/utils/test_multiturn_length_rewards.py32CODE
LOWtests/utils/test_tool_response_name.py41CODE
LOWtests/utils/test_gemma4_tool_responses.py21CODE
LOWtests/utils/test_gemma4_tool_responses.py44CODE
LOWtests/utils/test_reranker_metrics.py21CODE
LOWtests/utils/test_dpo_precompute.py32CODE
LOWtests/utils/test_embedding_metrics_dp.py28CODE
LOWtests/utils/test_reranker_loss.py17CODE
LOWtests/sequence_parallel/test_output_unpadding.py15CODE
LOWtests/sequence_parallel/test_seq_accuracy.py21CODE
LOWtests/sequence_parallel/test_custom_cross_entropy.py28CODE
LOWtests/train/test_vllm_importance_sampling_basic.py49CODE
LOWtests/train/test_cross_entropy_loss.py12CODE
LOWtests/train/test_gkd_loss.py11CODE
LOWtests/train/test_gkd_loss.py54CODE
LOWtests/train/test_gkd_loss.py86CODE
LOWtests/infer/test_transformers_worker.py62CODE
LOWtests/infer/test_transformers_worker.py83CODE
LOWtests/infer/test_transformers_worker.py158CODE
LOWtests/test_align/test_rlhf_loss.py280CODE
LOWtests/test_align/test_rlhf_loss.py330CODE
LOWtests/test_align/test_rlhf_loss.py357CODE
LOWtests/megatron/test_muon_lr.py365CODE
LOWswift/metrics/acc.py10CODE
LOWswift/ui/base.py268CODE
LOWswift/ui/base.py314CODE
LOWswift/ui/llm_export/llm_export.py101CODE
LOWswift/ui/llm_grpo/llm_grpo.py216CODE
LOWswift/ui/llm_grpo/external_rollout.py145CODE
LOWswift/ui/llm_grpo/tuner.py18CODE
LOWswift/ui/llm_rlhf/llm_rlhf.py232CODE
LOWswift/ui/llm_rlhf/tuner.py18CODE
LOWswift/ui/llm_sample/llm_sample.py166CODE
355 more matches not shown…
Empty Error Handlers74 hits · 370 pts
SeverityFileLineSnippetContext
HIGHtests/general/test_arch.py18except Exception:CODE
HIGHtests/infer/test_transformers_worker.py30except SystemExit:CODE
HIGHtests/test_align/test_template/test_agent.py852except ValueError:CODE
HIGHswift/ui/llm_infer/runtime.py146except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):CODE
HIGHswift/ui/llm_infer/runtime.py214except IOError:CODE
HIGHswift/ui/llm_infer/runtime.py231except IndexError:CODE
HIGHswift/ui/llm_train/runtime.py453except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):CODE
HIGHswift/ui/llm_train/runtime.py541except IOError:CODE
HIGHswift/dataset/preprocessor/core.py136except json.JSONDecodeError:CODE
HIGHswift/rlhf_trainers/utils.py126except ValueError:CODE
HIGHswift/rlhf_trainers/utils.py135except socket.gaierror:CODE
HIGHswift/rlhf_trainers/utils.py316except ImportError:CODE
HIGHswift/rlhf_trainers/utils.py1009except (ImportError, AttributeError, RuntimeError):CODE
HIGHswift/rlhf_trainers/utils.py1199except Exception:CODE
HIGHswift/rlhf_trainers/vllm_client.py119except Exception:CODE
HIGHswift/rlhf_trainers/grpo_trainer.py15except ImportError:CODE
HIGHswift/template/template_inputs.py49except json.JSONDecodeError:CODE
HIGHswift/template/utils.py95except ValueError:CODE
HIGHswift/template/vision_utils.py124except Exception:CODE
HIGHswift/template/vision_utils.py454except OSError:CODE
HIGHswift/template/vision_utils.py438except OSError:CODE
HIGHswift/pipelines/infer/rollout.py15except ImportError:CODE
HIGHswift/pipelines/infer/rollout.py70except ImportError:CODE
HIGHswift/pipelines/infer/rollout.py413except Exception: # noqa: BLE001CODE
HIGHswift/pipelines/infer/rollout.py560except BufferError:CODE
HIGHswift/pipelines/export/merge_lora.py23except Exception:CODE
HIGHswift/utils/hub_utils.py213except ImportError:CODE
HIGHswift/utils/utils.py308except OSError:CODE
HIGHswift/utils/hf_config.py177except AttributeError:CODE
HIGHswift/utils/url_utils.py148except ValueError:CODE
HIGHswift/utils/torch_utils.py242except Exception:CODE
HIGHswift/utils/torch_utils.py255except Exception:CODE
HIGHswift/optimizers/muonclip.py360except ValueError:CODE
HIGHswift/trainers/mixin.py967except (ImportError, AttributeError):CODE
HIGHswift/rollout/multi_turn.py259except AttributeError:CODE
HIGHswift/rollout/multi_turn.py861except Exception:CODE
HIGHswift/rollout/multi_turn.py974except Exception:CODE
HIGHswift/rollout/openenv_wrapper.py61except Exception:CODE
HIGHswift/sequence_parallel/sequence_parallel.py150except ImportError:CODE
HIGHswift/rl_core/data.py291except json.JSONDecodeError:CODE
HIGHswift/model/register.py116except Exception:CODE
HIGHswift/model/register.py297except ValueError:CODE
HIGHswift/model/patcher.py472except (AttributeError, TypeError):CODE
HIGHswift/model/models/moonshot.py20except AttributeError:CODE
HIGHswift/model/models/llama.py333except AttributeError:CODE
HIGHswift/model/models/qwen.py68except Exception:CODE
HIGHswift/model/models/qwen.py53except Exception:CODE
HIGHswift/model/models/qwen.py59except Exception:CODE
HIGHswift/model/models/qwen.py89except AttributeError:CODE
HIGHswift/model/models/qwen.py1572except Exception:CODE
HIGHswift/model/models/qwen.py2423except ImportError:CODE
HIGHswift/model/npu_patch/model.py282except Exception:CODE
HIGHswift/model/npu_patch/mindspeed.py298except Exception:CODE
HIGHswift/infer_engine/vllm_engine.py965except asyncio.exceptions.CancelledError:CODE
HIGHswift/infer_engine/infer_engine.py209except (TypeError, ValueError):CODE
HIGHswift/hub/hub.py223except HTTPError:CODE
HIGHswift/ray/megatron/resource_pool.py142except Exception: # noqa: BLE001CODE
HIGHswift/ray/megatron/rollout/replica.py282except Exception: # noqa: BLE001CODE
HIGHswift/ray/megatron/rollout/ray_vllm_engine.py225except Exception:CODE
HIGHswift/ray/megatron/rollout/weight_transfer.py171except OSError:CODE
14 more matches not shown…
Decorative Section Separators85 hits · 282 pts
SeverityFileLineSnippetContext
MEDIUMtests/utils/test_assemble_teacher_topk_logprobs.py10# ---------------------------------------------------------------------------COMMENT
MEDIUMtests/utils/test_assemble_teacher_topk_logprobs.py12# ---------------------------------------------------------------------------COMMENT
MEDIUMtests/utils/test_assemble_teacher_topk_logprobs.py30# ---------------------------------------------------------------------------COMMENT
MEDIUMtests/utils/test_assemble_teacher_topk_logprobs.py32# ---------------------------------------------------------------------------COMMENT
MEDIUMtests/utils/test_assemble_teacher_topk_logprobs.py76# ---------------------------------------------------------------------------COMMENT
MEDIUMtests/utils/test_assemble_teacher_topk_logprobs.py78# ---------------------------------------------------------------------------COMMENT
MEDIUMtests/test_align/test_mm_processor_align.py41# ---------------------------------------------------------------------------COMMENT
MEDIUMtests/test_align/test_mm_processor_align.py43# ---------------------------------------------------------------------------COMMENT
MEDIUMtests/test_align/test_mm_processor_align.py196# ---------------------------------------------------------------------------COMMENT
MEDIUMtests/test_align/test_mm_processor_align.py198# ---------------------------------------------------------------------------COMMENT
MEDIUMtests/test_align/test_mm_processor_align.py229# ---------------------------------------------------------------------------COMMENT
MEDIUMtests/test_align/test_mm_processor_align.py231# ---------------------------------------------------------------------------COMMENT
MEDIUMtests/test_align/test_mm_processor_align.py262# ---------------------------------------------------------------------------COMMENT
MEDIUMtests/test_align/test_mm_processor_align.py264# ---------------------------------------------------------------------------COMMENT
MEDIUMtests/test_align/test_mm_processor_align.py295# ---------------------------------------------------------------------------COMMENT
MEDIUMtests/test_align/test_mm_processor_align.py297# ---------------------------------------------------------------------------COMMENT
MEDIUMtests/test_align/test_mm_processor_align.py361# ---------------------------------------------------------------------------COMMENT
MEDIUMtests/test_align/test_mm_processor_align.py363# ---------------------------------------------------------------------------COMMENT
MEDIUMtests/test_align/test_mm_processor_align.py457# ---------------------------------------------------------------------------COMMENT
MEDIUMtests/test_align/test_mm_processor_align.py459# ---------------------------------------------------------------------------COMMENT
MEDIUMswift/rlhf_trainers/gkd_loss.py9# ---------------------------------------------------------------------------COMMENT
MEDIUMswift/rlhf_trainers/gkd_loss.py11# ---------------------------------------------------------------------------COMMENT
MEDIUM⚡swift/rlhf_trainers/gkd_loss.py71# ---------------------------------------------------------------------------COMMENT
MEDIUM⚡swift/rlhf_trainers/gkd_loss.py73# ---------------------------------------------------------------------------COMMENT
MEDIUM⚡swift/rlhf_trainers/gkd_loss.py89# ---------------------------------------------------------------------------COMMENT
MEDIUM⚡swift/rlhf_trainers/gkd_loss.py91# ---------------------------------------------------------------------------COMMENT
MEDIUMswift/rlhf_trainers/gkd_loss.py151# ---------------------------------------------------------------------------COMMENT
MEDIUMswift/rlhf_trainers/gkd_loss.py153# ---------------------------------------------------------------------------COMMENT
MEDIUMswift/rlhf_trainers/gkd_loss.py170# ---------------------------------------------------------------------------COMMENT
MEDIUMswift/rlhf_trainers/gkd_loss.py172# ---------------------------------------------------------------------------COMMENT
MEDIUMswift/rlhf_trainers/gkd_loss.py219# ---------------------------------------------------------------------------COMMENT
MEDIUMswift/rlhf_trainers/gkd_loss.py221# ---------------------------------------------------------------------------COMMENT
MEDIUM⚡swift/rlhf_trainers/utils.py1886# ============================================================================COMMENT
MEDIUM⚡swift/rlhf_trainers/utils.py1888# ============================================================================COMMENT
MEDIUMswift/rlhf_trainers/grpo_trainer.py454 # --------------------------------------------------COMMENT
MEDIUMswift/rlhf_trainers/grpo_trainer.py456 # --------------------------------------------------COMMENT
MEDIUMswift/rlhf_trainers/grpo_trainer.py489 # --------------------------------------------------COMMENT
MEDIUMswift/rlhf_trainers/grpo_trainer.py491 # --------------------------------------------------COMMENT
MEDIUMswift/pipelines/infer/rollout.py319 # ------------------------------------------------------------------COMMENT
MEDIUMswift/pipelines/infer/rollout.py321 # ------------------------------------------------------------------COMMENT
MEDIUMswift/pipelines/infer/rollout.py441 # ── Step 1: receive + rebuild IPC handle (with reuse) ────────COMMENT
MEDIUMswift/pipelines/infer/rollout.py479 # ── Step 2: stream buckets and load_weights per bucket ──────COMMENT
MEDIUM⚡swift/rollout/multi_turn.py867 # ------------------------------------------------------------------COMMENT
MEDIUM⚡swift/rollout/multi_turn.py869 # ------------------------------------------------------------------COMMENT
MEDIUM⚡swift/rollout/multi_turn.py919 # ------------------------------------------------------------------COMMENT
MEDIUM⚡swift/rollout/multi_turn.py921 # ------------------------------------------------------------------COMMENT
MEDIUM⚡swift/rollout/multi_turn.py931 # ------------------------------------------------------------------COMMENT
MEDIUM⚡swift/rollout/multi_turn.py933 # ------------------------------------------------------------------COMMENT
MEDIUMswift/rollout/multi_turn.py138 # ------------------------------------------------------------------COMMENT
MEDIUMswift/rollout/multi_turn.py147 # ------------------------------------------------------------------COMMENT
MEDIUMswift/rollout/openenv_wrapper.py38 # ------------------------------------------------------------------COMMENT
MEDIUMswift/rollout/openenv_wrapper.py40 # ------------------------------------------------------------------COMMENT
MEDIUM⚡swift/rollout/openenv_wrapper.py80 # ------------------------------------------------------------------COMMENT
MEDIUM⚡swift/rollout/openenv_wrapper.py83 # ------------------------------------------------------------------COMMENT
MEDIUM⚡swift/model/npu_patch/model.py210# ---------------------------------------------------------------------------COMMENT
MEDIUM⚡swift/model/npu_patch/model.py212# ---------------------------------------------------------------------------COMMENT
MEDIUM⚡swift/model/npu_patch/model.py220# ---------------------------------------------------------------------------COMMENT
MEDIUM⚡swift/model/npu_patch/model.py222# ---------------------------------------------------------------------------COMMENT
MEDIUMswift/model/npu_patch/model.py19# ---------------------------------------------------------------------------COMMENT
MEDIUMswift/model/npu_patch/model.py21# ---------------------------------------------------------------------------COMMENT
25 more matches not shown…
Excessive Try-Catch Wrapping233 hits · 252 pts
SeverityFileLineSnippetContext
LOW⚡tests/run.py39 except Exception as e:CODE
LOWtests/run.py383 except Exception:CODE
LOWtests/model_tag.py66 except Exception as e:CODE
LOWtests/model_tag.py94 except Exception as e:CODE
LOWtests/model_tag.py115 except Exception as e:CODE
LOWtests/model_tag.py131 except Exception as e:CODE
MEDIUMtests/model_tag.py53def _post_request(self, url, param):CODE
MEDIUMtests/model_tag.py72def batch_commit_result(self):CODE
MEDIUMtests/model_tag.py100def batch_refresh_stage(self):CODE
MEDIUMtests/model_tag.py121def query_model_stage(self):CODE
LOWtests/general/test_arch.py18 except Exception:CODE
LOWtests/general/test_packing_multiprocessing_context.py93 except Exception as exc:CODE
LOWtests/deploy/test_dataset.py12 except Exception:CODE
LOW…sts/sequence_parallel/test_zigzag_ring_attn_npu_e2e.py74 except Exception:CODE
LOW…ts/sequence_parallel/test_zigzag_ring_attn_cuda_e2e.py74 except Exception:CODE
LOWtests/sequence_parallel/test_zigzag_ring_attn_npu.py14 except Exception:CODE
MEDIUMtests/sequence_parallel/test_zigzag_ring_attn_npu.py10def _npu_available():CODE
LOWtests/train/test_vllm_importance_sampling_basic.py477 except Exception as e:CODE
LOWtests/test_align/test_mm_processor_align.py560 except Exception:CODE
LOWtests/megatron/test_ray_gkd.py195 except Exception as e: # noqa: megatron-core not installed in this envCODE
LOWtests/megatron/test_ray_gkd.py387 except Exception:CODE
LOWtests/megatron/test_ray_gkd.py400 except Exception as e: # noqaCODE
LOWtests/megatron/test_muon_lr.py16except Exception as e:CODE
LOWtests/megatron/test_checkpoint_symlink.py14except Exception as e:CODE
LOWdocs/source/BestPractices/GRPO.md78 except Exception as e:STRING
LOWdocs/source/BestPractices/GRPO-Multi-Modal-Training.md79 except Exception:CODE
LOWdocs/source/BestPractices/GRPO-Multi-Modal-Training.md96 except Exception:CODE
LOW…source/Instruction/GRPO/DeveloperGuide/reward_model.md118 except Exception as e:STRING
LOWdocs/source_en/BestPractices/GRPO.md82 except Exception as e:STRING
LOW…s/source_en/BestPractices/GRPO-Multi-Modal-Training.md85 except Exception:CODE
LOW…s/source_en/BestPractices/GRPO-Multi-Modal-Training.md102 except Exception:CODE
LOW…rce_en/Instruction/GRPO/DeveloperGuide/reward_model.md117 except Exception as e:CODE
LOWswift/ui/base.py347 except Exception as e:CODE
LOWswift/ui/base.py368 except Exception:CODE
LOWswift/ui/llm_grpo/external_runtime.py138 except Exception as e:CODE
LOWswift/ui/llm_eval/eval.py103 except Exception as e:CODE
LOWswift/ui/llm_infer/runtime.py135 except Exception:CODE
LOWswift/ui/llm_infer/runtime.py305 except Exception as e:CODE
LOWswift/ui/llm_infer/runtime.py315 except Exception:CODE
LOWswift/ui/llm_train/runtime.py383 except Exception:CODE
LOWswift/ui/llm_train/runtime.py428 except Exception:CODE
LOWswift/ui/llm_train/runtime.py688 except Exception as e:CODE
LOWswift/ui/llm_train/runtime.py702 except Exception:CODE
LOWswift/ui/llm_train/runtime.py726 except Exception:CODE
LOWswift/ui/llm_train/llm_train.py406 except Exception as e:CODE
LOWswift/ui/llm_train/llm_train.py530 except Exception as err:CODE
LOWswift/dataset/utils.py100 except Exception as e:CODE
LOWswift/dataset/packing.py30 except Exception:CODE
LOWswift/dataset/packing.py238 except Exception as e:CODE
LOWswift/dataset/loader.py117 except Exception as e:CODE
LOWswift/dataset/dataset/mllm.py797 except Exception:CODE
LOWswift/dataset/preprocessor/core.py233 except Exception as e:CODE
LOWswift/rewards/prm.py90 except Exception:STRING
LOWswift/rewards/prm.py148 except Exception:STRING
LOWswift/rewards/orm.py114 except Exception:CODE
LOWswift/rewards/orm.py251 except Exception:CODE
LOWswift/rewards/orm.py258 except Exception:CODE
LOWswift/rewards/orm.py300 except Exception:CODE
LOWswift/rewards/orm.py374 except Exception:CODE
LOWswift/rewards/orm.py422 except Exception:CODE
173 more matches not shown…
Cross-File Repetition20 hits · 100 pts
SeverityFileLineSnippetContext
HIGHtests/llm/test_custom.py0task: based on the given two sentences, provide a similarity score between 0.0 and 1.0. sentence 1: {text1} sentence 2: STRING
HIGHexamples/custom/dataset.py0task: based on the given two sentences, provide a similarity score between 0.0 and 1.0. sentence 1: {text1} sentence 2: STRING
HIGHswift/dataset/dataset/llm.py0task: based on the given two sentences, provide a similarity score between 0.0 and 1.0. sentence 1: {text1} sentence 2: STRING
HIGHdocs/source/BestPractices/GRPO.md0evaluates completions based on mathematical correctness of the answer args: completions (list[str]): generated outputs tSTRING
HIGHdocs/source_en/BestPractices/GRPO.md0evaluates completions based on mathematical correctness of the answer args: completions (list[str]): generated outputs tSTRING
HIGHexamples/train/grpo/plugin/plugin.py0evaluates completions based on mathematical correctness of the answer args: completions (list[str]): generated outputs tSTRING
HIGHdocs/source/BestPractices/GRPO-Multi-Modal-Training.md0reward function that checks if the completion is correct. args: completions (list[str]): generated outputs solution (lisSTRING
HIGH…s/source_en/BestPractices/GRPO-Multi-Modal-Training.md0reward function that checks if the completion is correct. args: completions (list[str]): generated outputs solution (lisSTRING
HIGHexamples/train/grpo/plugin/plugin.py0reward function that checks if the completion is correct. args: completions (list[str]): generated outputs solution (lisSTRING
HIGHdocs/source/BestPractices/AMD-support.md0you are a helpful math assistant. solve the problem step by step and put your final answer within \\boxed{}.STRING
HIGHdocs/source/BestPractices/Qwen3_8-Best-Practice.md0you are a helpful math assistant. solve the problem step by step and put your final answer within \\boxed{}.STRING
HIGHdocs/source_en/BestPractices/AMD-support.md0you are a helpful math assistant. solve the problem step by step and put your final answer within \\boxed{}.STRING
HIGHdocs/source_en/BestPractices/Qwen3_8-Best-Practice.md0you are a helpful math assistant. solve the problem step by step and put your final answer within \\boxed{}.STRING
HIGHexamples/models/qwen3_5/mcore_grpo_moe.sh0you are a helpful math assistant. solve the problem step by step and put your final answer within \\boxed{}.STRING
HIGHexamples/train/grpo/opd_rl.sh0you are a helpful math assistant. solve the problem step by step and put your final answer within \\boxed{}.STRING
HIGHexamples/train/grpo/plugin/gsm8k/gsm8k.sh0you are a helpful math assistant. solve the problem step by step and put your final answer within \\boxed{}.STRING
HIGHexamples/train/grpo/internal/fipo.sh0you are a helpful math assistant. solve the problem step by step and put your final answer within \\boxed{}.STRING
HIGHexamples/train/grpo/internal/real.sh0you are a helpful math assistant. solve the problem step by step and put your final answer within \\boxed{}.STRING
HIGHexamples/megatron/grpo/opd_rl.sh0you are a helpful math assistant. solve the problem step by step and put your final answer within \\boxed{}.STRING
HIGHexamples/megatron/grpo/real.sh0you are a helpful math assistant. solve the problem step by step and put your final answer within \\boxed{}.STRING
Docstring Block Structure13 hits · 65 pts
SeverityFileLineSnippetContext
HIGHdocs/README.md18Load data from json/yaml/pickle files. This method provides a unified api for loading data from serialized fileSTRING
HIGHswift/dataset/loader.py249Load and preprocess datasets. This function provides a unified interface to load datasets from various sources (HugSTRING
HIGHswift/rlhf_trainers/rollout_mixin.py536Split model parameters into batches for synchronized weight transfer. This method divides model parameters intoSTRING
HIGHswift/rlhf_trainers/rollout_mixin.py1821 Attempt to encode each input using the template. If encoding fails, resample from a backup iterator untSTRING
HIGHswift/template/register.py81Get or create a template instance for model input/output formatting. This function retrieves the appropriate templaSTRING
HIGHswift/loss_scale/mapping.py21Factory function to create a loss scale object from a string specification. The loss_scale string supports the follSTRING
HIGHswift/utils/hub_utils.py30Download model snapshot safely with DDP context protection. This function attempts to download a model from HuggingSTRING
HIGHswift/utils/torch_utils.py288 Get the last valid (non-padding) token position indices for each sample. This function correctly handles sequeSTRING
HIGHswift/rollout/multi_turn.py177 Perform asynchronous batched inference for multiple rollout requests. This method serves as the main eSTRING
HIGHswift/rollout/multi_turn.py330Execute multi-turn conversation rollout with built-in turn management logic. This implements the default multi-STRING
HIGHswift/rl_core/resample.py27Replace samples whose encode fails with fresh ones from ``data_iterator``. Caps the TOTAL encode attempts (fail-fasSTRING
HIGHswift/model/register.py569Load a pretrained model and its processor from a model hub or local path. Args: model_id_or_path: The modelSTRING
HIGHswift/megatron/trainers/grpo_trainer.py1291 Attempt to encode each input using the template. If encoding fails, resample from a backup iterator untSTRING
Self-Referential Comments23 hits · 64 pts
SeverityFileLineSnippetContext
MEDIUMtests/megatron/test_ray_gkd.py262 # Create a minimal mock trainer instance (bypass __init__)COMMENT
MEDIUMtests/megatron/test_ray_gkd.py327 # Create a minimal mock trainerCOMMENT
MEDIUMswift/callbacks/perf_log.py128 # This function is never used.COMMENT
MEDIUMswift/rewards/rm_plugin.py3# This module provides plugins for integrating external reward models,COMMENT
MEDIUMswift/rewards/rm_plugin.py170 # Define a mapping for role capitalization if neededSTRING
MEDIUMswift/rlhf_trainers/utils.py330 # Create a DeepSpeedPlugin with the processed configCOMMENT
MEDIUMswift/rlhf_trainers/grpo_trainer.py1919 # Create a copy to avoid modifying the original table used by other loggers.COMMENT
MEDIUMswift/template/base.py537 # This function is only used to handle scenarios where the model needsCOMMENT
MEDIUM⚡swift/template/base.py1719 """This function is important for multi-modal training, as it registers the post_encode methodSTRING
MEDIUMswift/pipelines/train/tuner.py155 """This function is only useful on the vera tuner"""STRING
MEDIUMswift/pipelines/infer/rollout.py151 # Create a stateless process group to manage communication between training processes and vLLM workers.COMMENT
MEDIUMswift/pipelines/eval/utils.py140 # Create a future to receive the result asynchronouslyCOMMENT
MEDIUMswift/utils/hf_config.py13 """This class is used to read config from config.json(maybe params.json also)"""STRING
MEDIUMswift/tuners/peft.py110 # Create a 1-element tensor then expand with stride-0: no real memory allocCOMMENT
MEDIUMswift/rollout/multi_turn.py638 # Create a RolloutOutput for the current roundCOMMENT
MEDIUMswift/rollout/multi_turn.py703 # Create a mock inputs object to use the template's _swift_prepare_inputs methodCOMMENT
MEDIUMexamples/models/qwen3_tts/prepare_data.py1# This file is used to generate `audio_codes` in the dataset.COMMENT
MEDIUM⚡examples/train/grpo/plugin/plugin.py72 # Define a regex pattern that only allows numbers, operators, parentheses, and whitespaceCOMMENT
MEDIUM⚡examples/train/grpo/plugin/plugin.py219 # Create the sandbox by hand, currently there's no context manager for this versionCOMMENT
MEDIUM⚡examples/train/grpo/plugin/plugin.py225 # Create a list of tasks for running scripts concurrentlyCOMMENT
MEDIUMexamples/train/grpo/plugin/plugin.py204 # Create a new event loop and set itCOMMENT
MEDIUMexamples/train/think_model/qwen3_demo1.sh3# This method is also applicable to the Deepseek-R1 series of models.COMMENT
MEDIUMexamples/custom/my_qwen2_5_omni/my_register.py306 """This function is typically used to solve the zero2/zero3 hanging issue in mixed model training,STRING
Over-Commented Block60 hits · 59 pts
SeverityFileLineSnippetContext
LOWtests/general/test_dataset.py21 'AI-ModelScope/LongAlpaca-12k#1000'COMMENT
LOWtests/general/test_dataset.py81COMMENT
LOWtests/train/test_sft.py481 # test_mllm_streaming_mp_ddp()COMMENT
LOWtests/test_align/test_vllm_vlm.py201 # test_qwen2_5_omni()COMMENT
LOWtests/test_align/test_template/test_agent.py901 return text.replace('\n', '')COMMENT
LOWtests/test_align/test_template/test_agent.py921 # test_llama4()COMMENT
LOWtests/test_align/test_template/test_llm.py801 assert ('Reasoning effort is set to' in text) is (reasoning_effort != 'medium'), reasoning_effortCOMMENT
LOWtests/test_align/test_template/test_llm.py821 # test_llama()COMMENT
LOWtests/test_align/test_template/test_llm.py841 # test_qwen3()COMMENT
LOWtests/test_align/test_template/test_llm.py861 # test_minicpm5()COMMENT
LOWtests/test_align/test_template/test_video.py401 logger = get_logger()COMMENT
LOW…sts/test_align/test_template/test_deepseek_v4_flash.py1import osCOMMENT
LOWtests/test_align/test_template/test_vision.py1321COMMENT
LOWtests/test_align/test_template/test_vision.py1341 # test_deepseek_janus()COMMENT
LOWtests/test_align/test_template/test_vision.py1361 # test_mplug_owl3()COMMENT
LOWtests/test_align/test_template/test_vision.py1381 # test_gemma3n()COMMENT
LOWtests/test_align/test_template/test_vision.py1401 # test_sensenova_si()COMMENT
LOWtests/test_align/test_template/test_template.py161COMMENT
LOWtests/eval/test_eval.py61 test_eval_llm()COMMENT
LOWtests/export/test_quant.py101 # test_bert()COMMENT
LOWdocs/source/conf.py1# Configuration file for the Sphinx documentation builder.COMMENT
LOWdocs/source/conf.py81COMMENT
LOWdocs/source_en/conf.py1# Configuration file for the Sphinx documentation builder.COMMENT
LOWdocs/source_en/conf.py81COMMENT
LOWdocs/source_en/Megatron-SWIFT/LoRA-Training.md141# swift exportCOMMENT
LOWswift/rlhf_trainers/grpo_trainer.py181COMMENT
LOWswift/pipelines/infer/rollout.py321 # ------------------------------------------------------------------COMMENT
LOWswift/model/models/xing4_0.py101 f'{previous_options}, but this load requests {patch_options}. 'COMMENT
LOWswift/model/models/deepseek.py281 # vocabulary, but this composite subclasses PreTrainedConfig directly andCOMMENT
LOWexamples/ascend/activation_cpu_offload/train.sh41# {'train_runtime': 79.7064, 'train_samples_per_second': 6.311, 'train_steps_per_second': 0.201, 'train_loss': 1.9164841COMMENT
LOWexamples/deploy/vllm_dp.sh1CUDA_VISIBLE_DEVICES=0,1 swift deploy \COMMENT
LOWexamples/deploy/vllm_dp.sh21# "temperature": 0COMMENT
LOWexamples/deploy/vllm.sh1CUDA_VISIBLE_DEVICES=0 swift deploy \COMMENT
LOWexamples/models/gpt_oss/internvl3_5_gpt.sh41 --padding_free false \COMMENT
LOWexamples/models/qwen3_next/mtp.sh41 --sequence_parallel true \COMMENT
LOWexamples/models/gemma4/gemma4_unified.sh41 --group_by_length true \COMMENT
LOWexamples/models/xing4_0/lora_sft_hf.sh1# Xing4.0-29B-A4B: trust_remote_code MoE (64 routed experts, top-4) + MLA + mHC.COMMENT
LOWexamples/models/deepseek_v41/megatron_sft.sh1#!/bin/bashCOMMENT
LOWexamples/models/deepseek_v41/megatron_grpo.sh1#!/bin/bashCOMMENT
LOWexamples/models/qwen3_5/mcore.sh61# CUDA_VISIBLE_DEVICES=0,1,2,3 \COMMENT
LOWexamples/models/qwen3_5/transformers.sh41# IMAGE_MAX_TOKEN_NUM=1024 \COMMENT
LOWexamples/models/qwen3_5/fp8.sh61# swift infer \COMMENT
LOWexamples/train/on_policy_distillation.sh1# On-Policy Distillation https://thinkingmachines.ai/blog/on-policy-distillation/COMMENT
LOW…mples/train/multimodal/lora_llm_full_vit/merge_lora.sh1CUDA_VISIBLE_DEVICES=0 \COMMENT
LOW…s/train/sequence_parallel/sequence_parallel_qwen3_5.sh21 --logging_steps 1 \COMMENT
LOWexamples/train/rlhf/opsd/opsd.sh1# OPSD Training ScriptCOMMENT
LOWexamples/train/grpo/plugin/run_external_scheduler.sh1# This script require main branch ms-swiftCOMMENT
LOW…es/train/grpo/plugin/openenv/run_grpo_sudoku_server.sh1# ============================================================COMMENT
LOW…es/train/grpo/plugin/openenv/run_grpo_sudoku_server.sh21#COMMENT
LOWexamples/train/grpo/plugin/openenv/run_grpo_sudoku.sh1# ============================================================COMMENT
LOWexamples/train/grpo/plugin/deepeyes/deepeyes.sh1# 8 * 80GCOMMENT
LOWexamples/train/grpo/internal/full_lmdeploy.sh1# The LMDeploy backend in GRPO has been deprecated in Swift 3.5.COMMENT
LOWexamples/train/grpo/external/vllm_multi_turn.sh1# Exp: https://github.com/modelscope/ms-swift/pull/5307#issuecomment-3219803922COMMENT
LOWexamples/megatron/mcore_bridge/full/dense.sh41# VIDEO_MAX_TOKEN_NUM=128 \COMMENT
LOWexamples/megatron/mcore_bridge/lora/seq_cls.sh41 --no_save_rng true \COMMENT
LOWexamples/megatron/multimodal/lora_llm_vit_full/sft.sh61# IMAGE_MAX_TOKEN_NUM=1024 \COMMENT
LOWexamples/megatron/grpo/dense_server.sh1# MAX_PIXELS=602112 \COMMENT
LOWexamples/megatron/grpo/deepseek_v41_colocate_lora.sh1# DeepSeek-V4.1-Flash LoRA GRPO (Megatron + vLLM colocate).COMMENT
LOWexamples/megatron/grpo/deepseek_v41_colocate_full.sh1# DeepSeek-V4.1-Flash full-parameter GRPO (Megatron + vLLM colocate).COMMENT
LOWexamples/megatron/lora/mtp.sh41 --dataloader_num_workers 8 \COMMENT
Structural Annotation Overuse25 hits · 44 pts
SeverityFileLineSnippetContext
LOW⚡tests/utils/test_rewards.py194 '### Step 1: Recall the formula\n\n'CODE
LOW⚡tests/utils/test_rewards.py196 '### Step 2: Use the given terms\n\n'CODE
LOW⚡tests/utils/test_rewards.py201 '### Step 3: Find $a_9$\n\n'CODE
LOW…s/source/Instruction/GRPO/DeveloperGuide/multi_turn.md118 'solution': "To solve the problem, we need to evaluate the expression \\(\\sqrt{36 \\times \\sqrt{16}}\\).\n\nWeSTRING
LOWdocs/source_en/Instruction/Distillation.md253# Step 1: Deploy teacher model (max_logprobs must be >= gkd_logits_topk)COMMENT
LOWdocs/source_en/Instruction/Distillation.md260# Step 2: Start GKD trainingCOMMENT
LOW…ource_en/Instruction/GRPO/DeveloperGuide/multi_turn.md121 'solution': "To solve the problem, we need to evaluate the expression \\(\\sqrt{36 \\times \\sqrt{16}}\\).\n\nWeSTRING
LOW⚡swift/metrics/reranker.py74 # Step 1: Find all positive sample indices (query boundaries)COMMENT
LOW⚡swift/metrics/reranker.py80 # Step 2: Split into groups (queries)COMMENT
LOWswift/metrics/reranker.py98 # Step 3: Calculate metrics for each query independentlyCOMMENT
LOWswift/metrics/reranker.py148 # Step 4: Return scores for averaging locally or across data-parallel ranks.COMMENT
LOWswift/template/templates/minicpm.py473 # Step 1: Base encode — produces input_ids with -100 for imagesCOMMENT
LOWswift/template/templates/minicpm.py487 # Step 2: Process images — replace -100 tokens with image placeholdersCOMMENT
LOWswift/template/templates/minicpm.py501 # Step 3: Process audios — expand audio_start/audio_end pairs with <unk> tokensCOMMENT
LOW⚡swift/template/templates/minicpm.py539 # Step 4: Compute image_bound using start/end token boundariesCOMMENT
LOWswift/template/templates/minicpm.py564 # Step 5: Compute audio_boundsCOMMENT
LOW⚡swift/sequence_parallel/sequence_parallel.py440 # Step 1: Gather from all sequence parallel ranksCOMMENT
LOW⚡swift/sequence_parallel/sequence_parallel.py448 # Step 2: Gather all rp chunksCOMMENT
LOW⚡swift/megatron/trainers/vocab_parallel_utils.py77 # Step 1: Find global max for numerical stability. This is a constant shift and isCOMMENT
LOW⚡swift/megatron/trainers/vocab_parallel_utils.py84 # Step 2: Compute exp(logits - max) and sum across all TP ranks. Every rank'sCOMMENT
LOW⚡swift/megatron/trainers/vocab_parallel_utils.py89 # Step 3: Compute log_softmaxCOMMENT
LOW⚡swift/megatron/trainers/grpo_trainer.py308 # Step 2: Compute KL from logps if kl_in_reward is enabledCOMMENT
LOW⚡swift/megatron/trainers/grpo_trainer.py313 # Step 3: Compute the per-sequence base advantage (with ref-KL penalty if kl_in_reward).COMMENT
LOW⚡swift/megatron/trainers/grpo_trainer.py317 # Step 4: Write the advantage onto each batch, expanding the per-sequence base advantage toCOMMENT
LOWswift/megatron/trainers/grpo_trainer.py279 # Step 1: Encode batches and compute logps first (unified flow like GRPOTrainer)COMMENT
Verbosity Indicators21 hits · 40 pts
SeverityFileLineSnippetContext
LOW⚡tests/utils/test_rewards.py194 '### Step 1: Recall the formula\n\n'CODE
LOW⚡tests/utils/test_rewards.py196 '### Step 2: Use the given terms\n\n'CODE
LOW⚡tests/utils/test_rewards.py201 '### Step 3: Find $a_9$\n\n'CODE
LOW⚡swift/metrics/reranker.py74 # Step 1: Find all positive sample indices (query boundaries)COMMENT
LOW⚡swift/metrics/reranker.py80 # Step 2: Split into groups (queries)COMMENT
LOWswift/metrics/reranker.py98 # Step 3: Calculate metrics for each query independentlyCOMMENT
LOWswift/metrics/reranker.py148 # Step 4: Return scores for averaging locally or across data-parallel ranks.COMMENT
LOWswift/template/templates/minicpm.py473 # Step 1: Base encode — produces input_ids with -100 for imagesCOMMENT
LOWswift/template/templates/minicpm.py487 # Step 2: Process images — replace -100 tokens with image placeholdersCOMMENT
LOWswift/template/templates/minicpm.py501 # Step 3: Process audios — expand audio_start/audio_end pairs with <unk> tokensCOMMENT
LOW⚡swift/template/templates/minicpm.py539 # Step 4: Compute image_bound using start/end token boundariesCOMMENT
LOWswift/template/templates/minicpm.py564 # Step 5: Compute audio_boundsCOMMENT
LOW⚡swift/sequence_parallel/sequence_parallel.py440 # Step 1: Gather from all sequence parallel ranksCOMMENT
LOW⚡swift/sequence_parallel/sequence_parallel.py448 # Step 2: Gather all rp chunksCOMMENT
LOW⚡swift/megatron/trainers/vocab_parallel_utils.py77 # Step 1: Find global max for numerical stability. This is a constant shift and isCOMMENT
LOW⚡swift/megatron/trainers/vocab_parallel_utils.py84 # Step 2: Compute exp(logits - max) and sum across all TP ranks. Every rank'sCOMMENT
LOW⚡swift/megatron/trainers/vocab_parallel_utils.py89 # Step 3: Compute log_softmaxCOMMENT
LOW⚡swift/megatron/trainers/grpo_trainer.py308 # Step 2: Compute KL from logps if kl_in_reward is enabledCOMMENT
LOW⚡swift/megatron/trainers/grpo_trainer.py313 # Step 3: Compute the per-sequence base advantage (with ref-KL penalty if kl_in_reward).COMMENT
LOW⚡swift/megatron/trainers/grpo_trainer.py317 # Step 4: Write the advantage onto each batch, expanding the per-sequence base advantage toCOMMENT
LOWswift/megatron/trainers/grpo_trainer.py279 # Step 1: Encode batches and compute logps first (unified flow like GRPOTrainer)COMMENT
AI Structural Patterns39 hits · 37 pts
SeverityFileLineSnippetContext
LOWtests/run.py486CODE
LOWtests/utils/test_async_rewards.py77CODE
LOWtests/train/test_opsd.py44CODE
LOWswift/dataset/loader.py226CODE
LOWswift/dataset/loader.py24CODE
LOWswift/dataset/preprocessor/core.py468CODE
LOWswift/template/register.py55CODE
LOWswift/template/base.py82CODE
LOWswift/template/base.py2102CODE
LOWswift/template/templates/llava.py132CODE
LOWswift/utils/torch_utils.py331CODE
LOWswift/tuners/lora_layers.py542CODE
LOWswift/optimizers/muonclip.py193CODE
LOWswift/optimizers/galore/adamw8bit.py11CODE
LOWswift/optimizers/galore/adafactor.py96CODE
LOWswift/sequence_parallel/ulysses.py71CODE
LOWswift/sequence_parallel/ulysses.py41CODE
LOWswift/sequence_parallel/ulysses.py88CODE
LOWswift/sequence_parallel/zigzag_ring_attn.py699CODE
LOWswift/model/register.py541CODE
LOWswift/model/register.py658CODE
LOWswift/model/register.py163CODE
LOWswift/model/model_meta.py251CODE
LOWswift/model/model_meta.py254CODE
LOWswift/model/models/mllm.py235CODE
LOWswift/model/models/qwen.py1034CODE
LOWswift/model/models/qwen.py1998CODE
LOWswift/model/models/qwen.py2234CODE
LOWswift/model/models/baichuan.py56CODE
LOWswift/model/models/gemma.py235CODE
LOWswift/infer_engine/vllm_engine.py123CODE
LOWswift/infer_engine/sglang_engine.py29CODE
LOWswift/infer_engine/lmdeploy_engine.py41CODE
LOWswift/infer_engine/lmdeploy_engine.py190CODE
LOWswift/infer_engine/transformers_engine.py53CODE
LOWswift/ray/megatron/rollout/ray_vllm_engine.py27CODE
LOWswift/ray/megatron/rollout/vllm_server.py82CODE
LOWswift/megatron/utils/convert_utils.py189CODE
LOWswift/megatron/model/utils.py109CODE
Redundant / Tautological Comments23 hits · 37 pts
SeverityFileLineSnippetContext
LOWswift/ui/llm_infer/runtime.py137 # Check if the process is still aliveCOMMENT
LOWswift/ui/llm_train/runtime.py430 # Check if the process is still aliveCOMMENT
LOWswift/callbacks/activation_cpu_offload.py601 # Check if model is wrapped with FSDPCOMMENT
LOWswift/callbacks/activation_cpu_offload.py605 # Check if fsdp_config is a dictionary and has activation_cpu_offload enabledCOMMENT
LOWswift/callbacks/lisa.py56 # Check if it's time to switch active layers, including at step 0COMMENT
LOWswift/rlhf_trainers/utils.py1029 # Check if already patched (idempotent). On NPU/vLLM-Ascend, sleep/wakeCOMMENT
LOWswift/rlhf_trainers/utils.py1063 # Check if inner_model has layers attributeCOMMENT
LOWswift/rlhf_trainers/grpo_trainer.py2251 # Set max_length to None to disable truncation, as the input length has already been truncated earlier.COMMENT
LOWswift/pipelines/eval/utils.py168 # Check if we've reached the desired batch sizeCOMMENT
LOWswift/trainers/mixin.py463 # Check if we should delete older checkpoint(s)COMMENT
LOWswift/trainers/reranker_trainer.py18 # Check if we have a custom loss functionCOMMENT
LOWswift/rollout/multi_turn.py442 # Check if the number of logprobs matches the number of loss_mask=1 tokensCOMMENT
LOWswift/infer_engine/utils.py533 # Check if we have a cached last_output from the previous iteration.COMMENT
LOWswift/infer_engine/utils.py600 # Check if need to run the usual non-async pathCOMMENT
LOW⚡swift/hub/hub.py351 # Write the file if it has changedCOMMENT
LOWswift/arguments/rlhf_args.py739 # Check if teacher_deepspeed is a predefined nameCOMMENT
LOWswift/megatron/utils/megatron_lm_utils.py684 # Set bucket_size to infinity if overlap_grad_reduce is False.COMMENT
LOWswift/agent_template/minimax_m2.py72 # Check if using react formatCOMMENT
LOW⚡examples/train/grpo/plugin/plugin.py68 # Check if all numbers are used exactly onceCOMMENT
LOW⚡examples/train/grpo/plugin/plugin.py80 # Check if the equation is correct and matches the ground truthCOMMENT
LOWexamples/train/grpo/plugin/plugin.py56 # Check if the format is correctCOMMENT
LOWexamples/train/grpo/plugin/openenv/sudoku_scheduler.py303 # Check if env says invalidCOMMENT
LOWexamples/train/grpo/plugin/openenv/sudoku_scheduler.py308 # Check if move targets an empty cellCOMMENT
Modern Structural Boilerplate26 hits · 27 pts
SeverityFileLineSnippetContext
LOWswift/rlhf_trainers/rollout_mixin.py199 def _setup_teacher(self) -> None:CODE
LOWswift/rlhf_trainers/rollout_mixin.py1596 def set_default_max_tokens(_self, request_config: RequestConfig, inputs: Dict[str, Any]) -> None:CODE
LOWswift/rlhf_trainers/utils.py1681def set_expandable_segments(enable: bool) -> None:CODE
LOWswift/rlhf_trainers/vllm_client.py41logger = logging.getLogger(__name__)CODE
LOW⚡swift/template/base.py1712 def set_mode(self, mode: Literal['transformers', 'vllm', 'lmdeploy', 'sglang', 'train', 'rlhf', 'kto']) -> None:CODE
LOWswift/pipelines/infer/deploy.py263 def _set_request_config(self, request_config) -> None:CODE
LOWswift/pipelines/infer/rollout.py172 def update_named_param(self, name: str, dtype: str, shape: Sequence[int]) -> None:CODE
LOWswift/pipelines/infer/rollout.py204 def update_adapter_flattened_param(self, peft_config: Dict, metadatas: list[Dict]) -> None:CODE
LOWswift/pipelines/infer/rollout.py233 def update_adapter_param(self, peft_config: Dict, lora_tensors_metadata: list[Dict]) -> None:CODE
LOWswift/pipelines/infer/rollout.py272 def update_flattened_params(self, metadatas: list[Dict]) -> None:CODE
LOW⚡swift/rollout/multi_turn.py89 def set_assistant_message_token_ids(self, infer_request: 'RolloutInferRequest', token_ids: List[int]) -> None:CODE
LOWswift/sequence_parallel/utils.py149 def set_epoch(self, epoch: int) -> None:CODE
LOWswift/model/npu_patcher.py8__all__ = ['NPUCastError', 'apply_all_patches', 'apply_mindspeed_patches', 'patch_mindspeed_fla_gdn_implementation']CODE
LOWswift/model/npu_patch/vllm_ascend_memory.py88__all__ = [CODE
LOWswift/model/npu_patch/vllm_ascend.py93__all__ = [CODE
LOWswift/model/npu_patch/__init__.py49__all__ = ['NPUCastError', 'apply_all_patches', 'apply_mindspeed_patches', 'patch_mindspeed_fla_gdn_implementation']CODE
LOWswift/model/npu_patch/megatron_checkpoint.py226__all__ = ['load_optimizer_state_dict', 'optimizer_sharded_state_dict']CODE
LOWswift/model/npu_patch/vllm_ascend_moe.py455__all__ = [CODE
LOWswift/model/npu_patch/vllm_ascend_lora.py226__all__ = [CODE
LOWswift/infer_engine/infer_engine.py235 def set_default_max_tokens(self, request_config: RequestConfig, inputs: Dict[str, Any]) -> None:CODE
LOWswift/ray/megatron/base_trainer.py42 def set_data_info(self, data_info: Dict[str, Any]) -> None:CODE
LOWswift/ray/megatron/rollout/adapter.py11logger = logging.getLogger(__name__)CODE
LOWswift/ray/megatron/checkpoint_engine/__init__.py8__all__ = [CODE
LOWswift/megatron/utils/megatron_fsdp_checkpoint.py15__all__ = [CODE
LOW⚡swift/megatron/utils/megatron_lm_utils.py611def _set_fsdp_tensor_parallel_attributes(param, partition_dim: int) -> None:CODE
LOWswift/megatron/trainers/rollout_mixin.py181 def _setup_teacher(self) -> None:CODE
Cross-Language Confusion5 hits · 24 pts
SeverityFileLineSnippetContext
HIGHtests/general/test_tool_schema_padding.py28# missing fields of each tool with null, which used to reach the prompt as foreignCOMMENT
HIGH⚡swift/rlhf_trainers/gkd_loss.py81 """KL(target || input), returns per-position scalar [N]."""STRING
HIGHswift/rlhf_trainers/grpo_trainer.py2451 - kl: Direct KL divergence estimator KL(π_rollout || π_training)STRING
HIGH⚡swift/hub/hub.py357 repo.push(commit_message)CODE
HIGHswift/megatron/trainers/vocab_parallel_utils.py151 KL(target || input) = sum(target_prob * (target_log_prob - input_log_prob))STRING
Modern AI Meta-Vocabulary7 hits · 16 pts
SeverityFileLineSnippetContext
MEDIUMdocs/source/Instruction/GRPO/DeveloperGuide/gym_env.md358- https://github.com/alibaba/ROLL/tree/main/roll/pipeline/agentic/env/frozen_lakeCODE
MEDIUMdocs/source_en/Instruction/Evaluation.md165├── example_dev.csv # (Optional) The filename should follow the format `{subset_name}_dev.csv` for few-shot evaluationCODE
MEDIUM…cs/source_en/Instruction/GRPO/AdvancedResearch/FIPO.md5[FIPO](https://arxiv.org/abs/2603.19835) is a value-free RL method for eliciting longer and deeper reasoning. It keeps tCODE
MEDIUM…s/source_en/Instruction/GRPO/DeveloperGuide/gym_env.md205- https://github.com/alibaba/ROLL/tree/main/roll/pipeline/agentic/env/frozen_lakeCODE
MEDIUMswift/template/templates/llm.py375 # reasoning_effort: "no_think", "low", "high" (deep chain-of-thought)COMMENT
MEDIUMswift/sequence_parallel/zigzag_ring_attn.py708 window_size=(-1, -1), # -1 means infinite context windowCODE
MEDIUMexamples/megatron/grpo/multi_turn/frozen_lake_plugin.py12# code borrowed from ROLL/roll/pipeline/agentic/env/frozen_lakeCOMMENT
AI Response Leakage2 hits · 15 pts
SeverityFileLineSnippetContext
HIGHexamples/megatron/fp8/vlm.sh2# In this example, FP8 training does not provide any speedup.COMMENT
HIGHexamples/megatron/fp8/llm.sh3# In this example, FP8 training does not provide any speedup.COMMENT
Slop Phrases5 hits · 13 pts
SeverityFileLineSnippetContext
LOWswift/model/models/qwen.py2128 loss.device) # make sure to reside in the same deviceCODE
MEDIUMexamples/train/multi-gpu/fsdp2_lora/train.sh2# NOTE: for swift>=3.12, you can use --fsdp fsdp2 instead of accelerate launchCOMMENT
MEDIUMexamples/train/multi-gpu/fsdp_qlora/train.sh2# NOTE: for swift>=3.12, you can use --fsdp fsdp2 instead of accelerate launchCOMMENT
MEDIUMexamples/megatron/fp8/lora.sh3# However, you can use BF16 weights to perform Merge-LoRA.COMMENT
MEDIUMexamples/megatron/fp8/lora.sh64# Alternatively, you can use BF16 base model + BF16 LoRA for inferenceCOMMENT
Magic Placeholder Names2 hits · 10 pts
SeverityFileLineSnippetContext
HIGHdocs/source/Instruction/Sample.md80OPENAI_API_KEY="your_api_key" \CODE
HIGHdocs/source_en/Instruction/Sample.md84OPENAI_API_KEY="your_api_key" \CODE
AI Slop Vocabulary3 hits · 8 pts
SeverityFileLineSnippetContext
LOWtests/train/test_vllm_importance_sampling_basic.py20 # In testing, just return the tensor as-isCOMMENT
MEDIUM⚡swift/template/templates/minicpm.py540 # This is more robust than finding consecutive <unk> tokens, especiallyCOMMENT
LOWexamples/megatron/export/lora.sh3# simply set `--merge_lora true`COMMENT
Synthetic Comment Markers1 hit · 5 pts
SeverityFileLineSnippetContext
HIGH…s/source_en/BestPractices/GRPO-Multi-Modal-Training.md278This task is based on the experiments in [open-r1-multimodal](https://github.com/EvolvingLMMs-Lab/open-r1-multimodal.gitCODE
Dead Code1 hit · 2 pts
SeverityFileLineSnippetContext
MEDIUMtests/infer/test_infer_engine.py24CODE
Fake / Example Data1 hit · 2 pts
SeverityFileLineSnippetContext
LOW⚡tests/utils/test_local_rank.py54 self.assert_levels('placeholder', 20)CODE
Overly Generic Function Names1 hit · 1 pts
SeverityFileLineSnippetContext
LOWswift/callbacks/activation_cpu_offload.py485 def my_function(*inputs):CODE