mindspore-ai / mindspore-ai/hyper-parallel

[Clean Code] 整改非 Linear Attention 模块的代码扫描告警

Open
#863 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
53
Forks
63
Avg merge
23h 45m
Merged PRs (30d)
63

Description

背景

代码扫描表中分配给作者的非 Linear Attention 告警,需要在不改变训练语义的前提下逐项整改。此前的“代码风格规范修改”Issue #243 对应 1.0 发布检查,现已关闭;本 Issue 只跟踪本批剩余范围。

范围

  • hyper_parallel/components/losses/chunked_cross_entropy.py
  • hyper_parallel/distributed/context_parallel/attention.py
  • hyper_parallel/models/deepseek_v3/adapter/replacements.py
  • hyper_parallel/models/qwen3_moe/adapter/chunk_loss.py
  • hyper_parallel/models/qwen3_moe/adapter/distributed/context_parallel.py
  • hyper_parallel/models/qwen3_moe/adapter/distributed/context_parallel_async.py
  • hyper_parallel/models/qwen3_moe/adapter/replacements.py

本批不包括 GDN/KDA 融合算子、其他 Linear Attention 模块、第三方依赖切换或性能优化;不为迎合扫描规则而修改必须保留的行为。

验收

  • 对本批扫描项逐处修复,无法安全修改的项说明原因并申请豁免。
  • 保持现有接口、CP 通信与训练行为不变。
  • 完成相关已有 CPU 测试、diff 检查,并记录仍需的多卡 NPU 验证。

对应 PR:#860。

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the listed Python files, beginning with the code-scanning findings in chunked_cross_entropy.py and the context-parallel attention and adapter modules. Run the existing CPU tests and perform a diff check before recording any required multi-card NPU validation. Done means each in-scope warning is safely fixed or its exemption reason is documented, with interfaces, CP communication, and training behavior unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
distributed-systems, machine-learning, testing-qa
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.