| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
【REFACTOR】【TESTS】重构 tests 目录并补充 smoke 测试 Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !266 merge refactor-tests into develop 【REFACTOR】【TESTS】重构 tests 目录并补充 smoke 测试 Created-by: AvadaKedavrua Commit-by: liujiawang;AvadaKedavrua Merged-by: ascend-robot Description: # PR Template Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers. 感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。 **PR Type / PR类型** - [x] Feature(功能新增) - [x] Bugfix(Bug 修复) - [x] Docs(文档更新) - [x] CI/CD(持续集成/持续部署) - [x] Refactor(代码重构) - [x] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 现有 UT 目录混合了 smoke、regression、benchmark、模型配置资产和脚本测试,导致本地执行入口不统一、CI 无法稳定做增量选择,nightly 也缺少统一的 test_map 刷新和报告链路。旧的 tests/run_ut.sh 入口难以表达“快速 smoke / 完整 regression / benchmark / PR gate / nightly”这些不同场景,新增或删除源码时也缺少基于 test_map 的覆盖检查。 本 PR 目标是把测试体系拆成清晰分层,并补齐 CI gate、nightly、coverage gate、test_map 构建和文档,让开发者和流水线都能按同一套目录与脚本执行测试。同时修复整理过程中暴露出的少量模型配置、serving 输出文本和文档问题。 ------ ## 📝 Modification / 修改内容 本次按 hunk/主题重新整理为 17 个提交,主要修改如下: - 重构测试目录:将旧 tests/test_tensor_cast、serving_cast/tests、web_ui/tests、tests/tools、tests/perf_database、tests/st 拆分到 tests/smoke/、tests/regression/、tests/benchmark/。 - 统一测试资产:将模型配置移动到 tests/assets/model_config/,同步更新 pre-commit exclude、缓存目录和文档说明。 - 新增共享测试 helper:补充断言、配置工厂、fake subprocess、模型构造、op registry 等公共测试工具,减少测试重复代码。 - 新增 CI gate helper:增加 diff 分类、test_map 读取、AST 符号映射、coverage gate、增量测试选择和 gate policy 配置。 - 新增 nightly helper:增加 pytest 结果解析、报告模型、报告构建、Feishu webhook 通知、test_map 刷新和 benchmark 调度入口。 - 新增统一脚本入口:新增 scripts/run_smoke.sh、scripts/run_regression.sh、scripts/run_benchmark.sh、scripts/run_ci_gate.sh、scripts/run_nightly.sh,替换旧 tests/run_ut.sh。 - 更新配置与文档:补充 pyproject.toml 的 pytest marker/testpaths/filterwarnings,更新 README.md、tests/README.md、docs/en/web_ui.md、web_ui/README.md、tools/perf_data_collection/README.md。 - 修复模型/输出细节:为 DeepseekV32DecoderLayer 注册 config_class;规范 serving_cast optimizer summary 的冒号和 runner 日志文案。 ### 后续 UT 怎么上 - 新增快速兜底用例放到 tests/smoke/:覆盖导入、基础 compile path、轻量 config resolver、轻量 serving/tensor_cast 主路径,要求无 NPU、无大模型权重、反馈快,适合每个 PR 先跑。 - 新增功能回归用例放到 tests/regression/<domain>/:按 tensor_cast、serving_cast、cli、web_ui、scripts/helpers 等领域归档,覆盖具体 bugfix、边界条件、行为契约和工具脚本逻辑。 - 新增长耗时或性能相关用例放到 tests/benchmark/:模型基准、perf_database、trace/CSV 性能数据处理等不阻塞普通 PR gate 的测试归到 benchmark 层。 - 新增模型配置、fixture、样例数据优先放到 tests/assets/ 或就近 fixtures/,避免继续散落在测试包内部;大文件或生成缓存走 .msmodeling_cache/、tests/assets/cache/,不直接进入源码目录。 - 新测试默认使用 tests/helpers/ 的公共构造器和断言工具;需要 fake subprocess、模型配置、op registry 时复用已有 helper,减少每个测试重复 mock 和手写配置。 - 需要 NPU 的用例必须打 @pytest.mark.npu;只应 nightly 跑的大模型/长耗时 compile 用例打 @pytest.mark.nightly,避免进入默认本地和 PR 快速路径。 ### 怎么根据语义上 UT - 测试不再只按文件名机械归类,而是按“被测语义”挂到对应源码符号:产品源码的函数、类、方法、顶层行为需要在 test_map 中映射到验证它的测试 nodeid。 - 新增产品源码时,如果是可执行逻辑,应新增对应 smoke 或 regression 用例,并让 test_map 能找到该源码/符号;确实不需要测试的符号需要在 exemption 中写明原因。 - 修改已有源码时,CI gate 会用 AST 定位变更行落在哪个 top-level definition 或 class/method span,再通过 test_map 选择关联测试;如果符号没有映射,会阻断或扩大测试范围,避免“改了逻辑但没跑语义相关 UT”。 - 删除源码时,CI gate 会检查 test_map 中是否仍有引用该源码的测试,防止遗留无效映射;删除测试时也会检查是否破坏已有源码覆盖关系。 - 跨层依赖变更会按语义优先选择所属 regression layer,无法明确归属或配置变更时升级为更完整的套件,保证增量选择不会漏测。 - test_map 由 nightly 在完整测试通过后刷新,PR gate 消费稳定版本;这样避免每个 PR 临时生成不可信映射,同时让语义映射随主干测试演进。 ### 流水线做了什么调整 - 本地与 CI 统一入口:run_smoke.sh 跑快速 smoke,run_regression.sh 跑完整 regression,run_benchmark.sh 跑 benchmark,run_ci_gate.sh 跑 PR 增量门禁,run_nightly.sh 跑夜间全流程。 - PR gate 从“固定跑一批 UT”改为“diff -> classify changes -> load test_map -> apply gate rules -> run selected pytest -> coverage gate”。配置变更、源码新增/删除、测试新增/删除、源码修改会走不同 gate 规则。 - coverage gate 统一读取 MSMODELING_TEST_LINE_THRESHOLD 和 MSMODELING_TEST_BRANCH_THRESHOLD,默认 line 70、branch 50;pytest 默认排除 npu,PR gate 额外排除 nightly。 - nightly 分两阶段:先跑非 NPU、非 nightly 的 smoke/regression 并在通过后刷新 test_map;再跑 nightly 标记用例与 benchmark,并构建结构化报告。 - 流水线统一支持 MSMODELING_OFFLINE、MSMODELING_TEST_WEIGHTS_PRUNE、MSMODELING_TEST_MAP_PATH 等环境变量,减少不同脚本各自处理缓存、离线和权重清理的差异。 - benchmark 不纳入普通 coverage gate,避免性能/长耗时用例拖慢 PR 门禁;必要时可通过独立 benchmark pipeline 或 nightly 验证。 - pre-commit exclude 同步到新目录,模型配置资产和 fixtures 不再被无意义格式化或误报。 已处理问题清单: - 旧 UT 入口单一,无法区分 smoke、regression、benchmark、nightly 和 PR gate。 - 模型配置资产散落在测试用例目录下,pre-commit 与测试引用路径容易漂移。 - 新增/删除源码缺少 test_map 覆盖检查,CI 不能精准阻断未补测试的变更。 - coverage 阈值、pytest marker、离线模式、权重缓存清理等 CI 参数缺少统一入口。 - nightly 缺少结构化报告、失败摘要和 Feishu 通知链路。 - web UI 测试仍在模块内,未纳入统一 regression 层级。 - DeepseekV32DecoderLayer 缺少 config_class,影响配置类识别一致性。 - serving_cast 部分日志/summary 文案有多余空格或表达不统一。 ------ ## 📐 Associated Test Results / 关联测试结果 提交过程中每个 commit 均触发 pre-commit hook,已通过已检查文件的 trailing whitespace、EOF、YAML/JSON、大文件、merge conflict、private key、ruff、ruff-format、codespell、pylint、bandit、typos 等检查。 本地未额外执行完整 smoke/regression/benchmark 全量测试;推送后以 GitCode CI 结果为准。建议重点关注: - bash ./scripts/run_smoke.sh - bash ./scripts/run_regression.sh - bash ./scripts/run_ci_gate.sh(需设置 MSMODELING_TEST_MAP_PATH) - bash ./scripts/run_nightly.sh(需设置 MSMODELING_TEST_MAP_PATH) ------ ## 🌟 Use cases (Optional) / 使用案例(可选) - 本地快速验证:开发者运行 bash ./scripts/run_smoke.sh 获取快速反馈。 - 本地完整回归:开发者运行 bash ./scripts/run_regression.sh 覆盖主要回归用例。 - PR 增量门禁:CI 设置 MSMODELING_TEST_MAP_PATH 后运行 bash ./scripts/run_ci_gate.sh,按 diff 与 test_map 选择用例并执行 coverage gate。 - 夜间任务:nightly 先跑非 nightly 的 smoke/regression 并刷新 test_map,再执行 nightly/benchmark 并生成报告,可选 Feishu 通知。 ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [ ] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [x] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 ------ See merge request: Ascend/msmodeling!266 | 27 天前 | |
feat(serving_cast): support chunked prefill modeling Co-authored-by: jia_ya_nan<jiayanan3@h-partners.com> # message auto-generated for no-merge-commit merge: !250 merge feat/chunked-prefill-impl into develop feat(serving_cast): support chunked prefill modeling Created-by: jia_ya_nan Commit-by: jia_ya_nan Merged-by: ascend-robot Description: # PR Template Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers. 感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。 **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [ ] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 **Please describe the motivation of this PR and the goal you want to achieve through this PR.** **请描述您的拉取请求的动机和您希望通过此拉取请求实现的目标。** 当前 throughput_optimizer 在混部模式下使用 max_prefill_tokens 作为 prefill token budget,并要求有效输入长度不超过该值。当长上下文请求的 effective_input_length 大于 token budget 时,工具会直接报错,无法模拟实际服务中常见的 chunked prefill 场景。 本 PR 旨在补齐 msmodeling 对 chunked prefill 的建模能力,使吞吐优化器可以在长 prompt 或较小 batch token budget 场景下,自动将 prefill 拆分为多个 chunk 进行估算,并更合理地建模 prefill 与 decode 混部执行对 TTFT、TPOT 和吞吐的影响。 ------ ## 📝 Modification / 修改内容 **Please briefly describe what modification is made in this PR.** **请简要描述此拉取请求中进行的修改。** - 将 CLI 参数 --max-prefill-tokens 重命名为 --max-batched-tokens,用于表达单个 prefill / mixed step 的 token budget。 - 新增 prefill chunk plan 生成逻辑,当 effective_input_length > max_batched_tokens 时自动按 max_batched_tokens 切分 prefill。 - 新增默认调度策略 DecodeFirstWithSlack,支持 decode-first 调度,并允许 15% slack 以避免 decode token 占用导致 prefill chunk 无法调度。 - 聚合模式中新增 chunked prefill 轻量级时间模拟,支持已完成 prefill 的请求提前进入 decode,不再要求所有请求完成 prefill 后统一 decode。 - PD 分离模式中 prefill 阶段支持 chunked prefill,decode 阶段保持原有逻辑。 - 优化 latency cache key,使其区分不同的 query_len、seq_len 和并发形态。 - 输出结果新增 effective_input_length、max_batched_tokens、prefill_num_chunks,便于分析 chunked prefill 配置影响。 - 更新 Web UI 参数生成、表单校验、相关文档和单元测试。 ------ ## 📐 Associated Test Results / 关联测试结果 **Please provide the related test results, such as test reports, etc.** **请提供相关测试结果,例如测试报告等。** 以32条 32k请求为例,无chunk改动前: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-prefill-tokens 32000 --log-level info  无chunk改动后: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 32000 --log-level info  结果不变,不影响之前的调度逻辑 chunk为2000: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 2000 --log-level info  chunk为4000: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 4000 --log-level info  chunk为8000: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 4000 --log-level info  从趋势上看,chunk size越小,对tpot越友好;同时chunk 越小,prefill阶段调度越多,ttft会增加,符合预期; 另外,由于开启chunk prefill后,prefill会增加多次计算,导致耗时呈线性增长;可以考虑并行一次性跑完所有切分的prefill,但对资源消耗巨大,考虑在下个PR内提升性能 ------ ## 🌟 Use cases (Optional) / 使用案例(可选) **If this PR introduces a new feature, it is better to list some use cases here and update the documentation.** **如果此拉取请求引入了新功能,最好在此处列出一些用例并更新文档。** ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [x] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 ------ See merge request: Ascend/msmodeling!250 | 24 天前 | |
feat(serving_cast): support chunked prefill modeling Co-authored-by: jia_ya_nan<jiayanan3@h-partners.com> # message auto-generated for no-merge-commit merge: !250 merge feat/chunked-prefill-impl into develop feat(serving_cast): support chunked prefill modeling Created-by: jia_ya_nan Commit-by: jia_ya_nan Merged-by: ascend-robot Description: # PR Template Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers. 感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。 **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [ ] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 **Please describe the motivation of this PR and the goal you want to achieve through this PR.** **请描述您的拉取请求的动机和您希望通过此拉取请求实现的目标。** 当前 throughput_optimizer 在混部模式下使用 max_prefill_tokens 作为 prefill token budget,并要求有效输入长度不超过该值。当长上下文请求的 effective_input_length 大于 token budget 时,工具会直接报错,无法模拟实际服务中常见的 chunked prefill 场景。 本 PR 旨在补齐 msmodeling 对 chunked prefill 的建模能力,使吞吐优化器可以在长 prompt 或较小 batch token budget 场景下,自动将 prefill 拆分为多个 chunk 进行估算,并更合理地建模 prefill 与 decode 混部执行对 TTFT、TPOT 和吞吐的影响。 ------ ## 📝 Modification / 修改内容 **Please briefly describe what modification is made in this PR.** **请简要描述此拉取请求中进行的修改。** - 将 CLI 参数 --max-prefill-tokens 重命名为 --max-batched-tokens,用于表达单个 prefill / mixed step 的 token budget。 - 新增 prefill chunk plan 生成逻辑,当 effective_input_length > max_batched_tokens 时自动按 max_batched_tokens 切分 prefill。 - 新增默认调度策略 DecodeFirstWithSlack,支持 decode-first 调度,并允许 15% slack 以避免 decode token 占用导致 prefill chunk 无法调度。 - 聚合模式中新增 chunked prefill 轻量级时间模拟,支持已完成 prefill 的请求提前进入 decode,不再要求所有请求完成 prefill 后统一 decode。 - PD 分离模式中 prefill 阶段支持 chunked prefill,decode 阶段保持原有逻辑。 - 优化 latency cache key,使其区分不同的 query_len、seq_len 和并发形态。 - 输出结果新增 effective_input_length、max_batched_tokens、prefill_num_chunks,便于分析 chunked prefill 配置影响。 - 更新 Web UI 参数生成、表单校验、相关文档和单元测试。 ------ ## 📐 Associated Test Results / 关联测试结果 **Please provide the related test results, such as test reports, etc.** **请提供相关测试结果,例如测试报告等。** 以32条 32k请求为例,无chunk改动前: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-prefill-tokens 32000 --log-level info  无chunk改动后: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 32000 --log-level info  结果不变,不影响之前的调度逻辑 chunk为2000: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 2000 --log-level info  chunk为4000: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 4000 --log-level info  chunk为8000: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 4000 --log-level info  从趋势上看,chunk size越小,对tpot越友好;同时chunk 越小,prefill阶段调度越多,ttft会增加,符合预期; 另外,由于开启chunk prefill后,prefill会增加多次计算,导致耗时呈线性增长;可以考虑并行一次性跑完所有切分的prefill,但对资源消耗巨大,考虑在下个PR内提升性能 ------ ## 🌟 Use cases (Optional) / 使用案例(可选) **If this PR introduces a new feature, it is better to list some use cases here and update the documentation.** **如果此拉取请求引入了新功能,最好在此处列出一些用例并更新文档。** ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [x] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 ------ See merge request: Ascend/msmodeling!250 | 24 天前 | |
feat(serving_cast): support chunked prefill modeling Co-authored-by: jia_ya_nan<jiayanan3@h-partners.com> # message auto-generated for no-merge-commit merge: !250 merge feat/chunked-prefill-impl into develop feat(serving_cast): support chunked prefill modeling Created-by: jia_ya_nan Commit-by: jia_ya_nan Merged-by: ascend-robot Description: # PR Template Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers. 感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。 **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [ ] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 **Please describe the motivation of this PR and the goal you want to achieve through this PR.** **请描述您的拉取请求的动机和您希望通过此拉取请求实现的目标。** 当前 throughput_optimizer 在混部模式下使用 max_prefill_tokens 作为 prefill token budget,并要求有效输入长度不超过该值。当长上下文请求的 effective_input_length 大于 token budget 时,工具会直接报错,无法模拟实际服务中常见的 chunked prefill 场景。 本 PR 旨在补齐 msmodeling 对 chunked prefill 的建模能力,使吞吐优化器可以在长 prompt 或较小 batch token budget 场景下,自动将 prefill 拆分为多个 chunk 进行估算,并更合理地建模 prefill 与 decode 混部执行对 TTFT、TPOT 和吞吐的影响。 ------ ## 📝 Modification / 修改内容 **Please briefly describe what modification is made in this PR.** **请简要描述此拉取请求中进行的修改。** - 将 CLI 参数 --max-prefill-tokens 重命名为 --max-batched-tokens,用于表达单个 prefill / mixed step 的 token budget。 - 新增 prefill chunk plan 生成逻辑,当 effective_input_length > max_batched_tokens 时自动按 max_batched_tokens 切分 prefill。 - 新增默认调度策略 DecodeFirstWithSlack,支持 decode-first 调度,并允许 15% slack 以避免 decode token 占用导致 prefill chunk 无法调度。 - 聚合模式中新增 chunked prefill 轻量级时间模拟,支持已完成 prefill 的请求提前进入 decode,不再要求所有请求完成 prefill 后统一 decode。 - PD 分离模式中 prefill 阶段支持 chunked prefill,decode 阶段保持原有逻辑。 - 优化 latency cache key,使其区分不同的 query_len、seq_len 和并发形态。 - 输出结果新增 effective_input_length、max_batched_tokens、prefill_num_chunks,便于分析 chunked prefill 配置影响。 - 更新 Web UI 参数生成、表单校验、相关文档和单元测试。 ------ ## 📐 Associated Test Results / 关联测试结果 **Please provide the related test results, such as test reports, etc.** **请提供相关测试结果,例如测试报告等。** 以32条 32k请求为例,无chunk改动前: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-prefill-tokens 32000 --log-level info  无chunk改动后: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 32000 --log-level info  结果不变,不影响之前的调度逻辑 chunk为2000: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 2000 --log-level info  chunk为4000: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 4000 --log-level info  chunk为8000: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 4000 --log-level info  从趋势上看,chunk size越小,对tpot越友好;同时chunk 越小,prefill阶段调度越多,ttft会增加,符合预期; 另外,由于开启chunk prefill后,prefill会增加多次计算,导致耗时呈线性增长;可以考虑并行一次性跑完所有切分的prefill,但对资源消耗巨大,考虑在下个PR内提升性能 ------ ## 🌟 Use cases (Optional) / 使用案例(可选) **If this PR introduces a new feature, it is better to list some use cases here and update the documentation.** **如果此拉取请求引入了新功能,最好在此处列出一些用例并更新文档。** ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [x] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 ------ See merge request: Ascend/msmodeling!250 | 24 天前 | |
feat(serving_cast): support chunked prefill modeling Co-authored-by: jia_ya_nan<jiayanan3@h-partners.com> # message auto-generated for no-merge-commit merge: !250 merge feat/chunked-prefill-impl into develop feat(serving_cast): support chunked prefill modeling Created-by: jia_ya_nan Commit-by: jia_ya_nan Merged-by: ascend-robot Description: # PR Template Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers. 感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。 **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [ ] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 **Please describe the motivation of this PR and the goal you want to achieve through this PR.** **请描述您的拉取请求的动机和您希望通过此拉取请求实现的目标。** 当前 throughput_optimizer 在混部模式下使用 max_prefill_tokens 作为 prefill token budget,并要求有效输入长度不超过该值。当长上下文请求的 effective_input_length 大于 token budget 时,工具会直接报错,无法模拟实际服务中常见的 chunked prefill 场景。 本 PR 旨在补齐 msmodeling 对 chunked prefill 的建模能力,使吞吐优化器可以在长 prompt 或较小 batch token budget 场景下,自动将 prefill 拆分为多个 chunk 进行估算,并更合理地建模 prefill 与 decode 混部执行对 TTFT、TPOT 和吞吐的影响。 ------ ## 📝 Modification / 修改内容 **Please briefly describe what modification is made in this PR.** **请简要描述此拉取请求中进行的修改。** - 将 CLI 参数 --max-prefill-tokens 重命名为 --max-batched-tokens,用于表达单个 prefill / mixed step 的 token budget。 - 新增 prefill chunk plan 生成逻辑,当 effective_input_length > max_batched_tokens 时自动按 max_batched_tokens 切分 prefill。 - 新增默认调度策略 DecodeFirstWithSlack,支持 decode-first 调度,并允许 15% slack 以避免 decode token 占用导致 prefill chunk 无法调度。 - 聚合模式中新增 chunked prefill 轻量级时间模拟,支持已完成 prefill 的请求提前进入 decode,不再要求所有请求完成 prefill 后统一 decode。 - PD 分离模式中 prefill 阶段支持 chunked prefill,decode 阶段保持原有逻辑。 - 优化 latency cache key,使其区分不同的 query_len、seq_len 和并发形态。 - 输出结果新增 effective_input_length、max_batched_tokens、prefill_num_chunks,便于分析 chunked prefill 配置影响。 - 更新 Web UI 参数生成、表单校验、相关文档和单元测试。 ------ ## 📐 Associated Test Results / 关联测试结果 **Please provide the related test results, such as test reports, etc.** **请提供相关测试结果,例如测试报告等。** 以32条 32k请求为例,无chunk改动前: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-prefill-tokens 32000 --log-level info  无chunk改动后: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 32000 --log-level info  结果不变,不影响之前的调度逻辑 chunk为2000: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 2000 --log-level info  chunk为4000: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 4000 --log-level info  chunk为8000: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 4000 --log-level info  从趋势上看,chunk size越小,对tpot越友好;同时chunk 越小,prefill阶段调度越多,ttft会增加,符合预期; 另外,由于开启chunk prefill后,prefill会增加多次计算,导致耗时呈线性增长;可以考虑并行一次性跑完所有切分的prefill,但对资源消耗巨大,考虑在下个PR内提升性能 ------ ## 🌟 Use cases (Optional) / 使用案例(可选) **If this PR introduces a new feature, it is better to list some use cases here and update the documentation.** **如果此拉取请求引入了新功能,最好在此处列出一些用例并更新文档。** ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [x] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 ------ See merge request: Ascend/msmodeling!250 | 24 天前 | |
【REFACTOR】【TESTS】重构 tests 目录并补充 smoke 测试 Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !266 merge refactor-tests into develop 【REFACTOR】【TESTS】重构 tests 目录并补充 smoke 测试 Created-by: AvadaKedavrua Commit-by: liujiawang;AvadaKedavrua Merged-by: ascend-robot Description: # PR Template Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers. 感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。 **PR Type / PR类型** - [x] Feature(功能新增) - [x] Bugfix(Bug 修复) - [x] Docs(文档更新) - [x] CI/CD(持续集成/持续部署) - [x] Refactor(代码重构) - [x] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 现有 UT 目录混合了 smoke、regression、benchmark、模型配置资产和脚本测试,导致本地执行入口不统一、CI 无法稳定做增量选择,nightly 也缺少统一的 test_map 刷新和报告链路。旧的 tests/run_ut.sh 入口难以表达“快速 smoke / 完整 regression / benchmark / PR gate / nightly”这些不同场景,新增或删除源码时也缺少基于 test_map 的覆盖检查。 本 PR 目标是把测试体系拆成清晰分层,并补齐 CI gate、nightly、coverage gate、test_map 构建和文档,让开发者和流水线都能按同一套目录与脚本执行测试。同时修复整理过程中暴露出的少量模型配置、serving 输出文本和文档问题。 ------ ## 📝 Modification / 修改内容 本次按 hunk/主题重新整理为 17 个提交,主要修改如下: - 重构测试目录:将旧 tests/test_tensor_cast、serving_cast/tests、web_ui/tests、tests/tools、tests/perf_database、tests/st 拆分到 tests/smoke/、tests/regression/、tests/benchmark/。 - 统一测试资产:将模型配置移动到 tests/assets/model_config/,同步更新 pre-commit exclude、缓存目录和文档说明。 - 新增共享测试 helper:补充断言、配置工厂、fake subprocess、模型构造、op registry 等公共测试工具,减少测试重复代码。 - 新增 CI gate helper:增加 diff 分类、test_map 读取、AST 符号映射、coverage gate、增量测试选择和 gate policy 配置。 - 新增 nightly helper:增加 pytest 结果解析、报告模型、报告构建、Feishu webhook 通知、test_map 刷新和 benchmark 调度入口。 - 新增统一脚本入口:新增 scripts/run_smoke.sh、scripts/run_regression.sh、scripts/run_benchmark.sh、scripts/run_ci_gate.sh、scripts/run_nightly.sh,替换旧 tests/run_ut.sh。 - 更新配置与文档:补充 pyproject.toml 的 pytest marker/testpaths/filterwarnings,更新 README.md、tests/README.md、docs/en/web_ui.md、web_ui/README.md、tools/perf_data_collection/README.md。 - 修复模型/输出细节:为 DeepseekV32DecoderLayer 注册 config_class;规范 serving_cast optimizer summary 的冒号和 runner 日志文案。 ### 后续 UT 怎么上 - 新增快速兜底用例放到 tests/smoke/:覆盖导入、基础 compile path、轻量 config resolver、轻量 serving/tensor_cast 主路径,要求无 NPU、无大模型权重、反馈快,适合每个 PR 先跑。 - 新增功能回归用例放到 tests/regression/<domain>/:按 tensor_cast、serving_cast、cli、web_ui、scripts/helpers 等领域归档,覆盖具体 bugfix、边界条件、行为契约和工具脚本逻辑。 - 新增长耗时或性能相关用例放到 tests/benchmark/:模型基准、perf_database、trace/CSV 性能数据处理等不阻塞普通 PR gate 的测试归到 benchmark 层。 - 新增模型配置、fixture、样例数据优先放到 tests/assets/ 或就近 fixtures/,避免继续散落在测试包内部;大文件或生成缓存走 .msmodeling_cache/、tests/assets/cache/,不直接进入源码目录。 - 新测试默认使用 tests/helpers/ 的公共构造器和断言工具;需要 fake subprocess、模型配置、op registry 时复用已有 helper,减少每个测试重复 mock 和手写配置。 - 需要 NPU 的用例必须打 @pytest.mark.npu;只应 nightly 跑的大模型/长耗时 compile 用例打 @pytest.mark.nightly,避免进入默认本地和 PR 快速路径。 ### 怎么根据语义上 UT - 测试不再只按文件名机械归类,而是按“被测语义”挂到对应源码符号:产品源码的函数、类、方法、顶层行为需要在 test_map 中映射到验证它的测试 nodeid。 - 新增产品源码时,如果是可执行逻辑,应新增对应 smoke 或 regression 用例,并让 test_map 能找到该源码/符号;确实不需要测试的符号需要在 exemption 中写明原因。 - 修改已有源码时,CI gate 会用 AST 定位变更行落在哪个 top-level definition 或 class/method span,再通过 test_map 选择关联测试;如果符号没有映射,会阻断或扩大测试范围,避免“改了逻辑但没跑语义相关 UT”。 - 删除源码时,CI gate 会检查 test_map 中是否仍有引用该源码的测试,防止遗留无效映射;删除测试时也会检查是否破坏已有源码覆盖关系。 - 跨层依赖变更会按语义优先选择所属 regression layer,无法明确归属或配置变更时升级为更完整的套件,保证增量选择不会漏测。 - test_map 由 nightly 在完整测试通过后刷新,PR gate 消费稳定版本;这样避免每个 PR 临时生成不可信映射,同时让语义映射随主干测试演进。 ### 流水线做了什么调整 - 本地与 CI 统一入口:run_smoke.sh 跑快速 smoke,run_regression.sh 跑完整 regression,run_benchmark.sh 跑 benchmark,run_ci_gate.sh 跑 PR 增量门禁,run_nightly.sh 跑夜间全流程。 - PR gate 从“固定跑一批 UT”改为“diff -> classify changes -> load test_map -> apply gate rules -> run selected pytest -> coverage gate”。配置变更、源码新增/删除、测试新增/删除、源码修改会走不同 gate 规则。 - coverage gate 统一读取 MSMODELING_TEST_LINE_THRESHOLD 和 MSMODELING_TEST_BRANCH_THRESHOLD,默认 line 70、branch 50;pytest 默认排除 npu,PR gate 额外排除 nightly。 - nightly 分两阶段:先跑非 NPU、非 nightly 的 smoke/regression 并在通过后刷新 test_map;再跑 nightly 标记用例与 benchmark,并构建结构化报告。 - 流水线统一支持 MSMODELING_OFFLINE、MSMODELING_TEST_WEIGHTS_PRUNE、MSMODELING_TEST_MAP_PATH 等环境变量,减少不同脚本各自处理缓存、离线和权重清理的差异。 - benchmark 不纳入普通 coverage gate,避免性能/长耗时用例拖慢 PR 门禁;必要时可通过独立 benchmark pipeline 或 nightly 验证。 - pre-commit exclude 同步到新目录,模型配置资产和 fixtures 不再被无意义格式化或误报。 已处理问题清单: - 旧 UT 入口单一,无法区分 smoke、regression、benchmark、nightly 和 PR gate。 - 模型配置资产散落在测试用例目录下,pre-commit 与测试引用路径容易漂移。 - 新增/删除源码缺少 test_map 覆盖检查,CI 不能精准阻断未补测试的变更。 - coverage 阈值、pytest marker、离线模式、权重缓存清理等 CI 参数缺少统一入口。 - nightly 缺少结构化报告、失败摘要和 Feishu 通知链路。 - web UI 测试仍在模块内,未纳入统一 regression 层级。 - DeepseekV32DecoderLayer 缺少 config_class,影响配置类识别一致性。 - serving_cast 部分日志/summary 文案有多余空格或表达不统一。 ------ ## 📐 Associated Test Results / 关联测试结果 提交过程中每个 commit 均触发 pre-commit hook,已通过已检查文件的 trailing whitespace、EOF、YAML/JSON、大文件、merge conflict、private key、ruff、ruff-format、codespell、pylint、bandit、typos 等检查。 本地未额外执行完整 smoke/regression/benchmark 全量测试;推送后以 GitCode CI 结果为准。建议重点关注: - bash ./scripts/run_smoke.sh - bash ./scripts/run_regression.sh - bash ./scripts/run_ci_gate.sh(需设置 MSMODELING_TEST_MAP_PATH) - bash ./scripts/run_nightly.sh(需设置 MSMODELING_TEST_MAP_PATH) ------ ## 🌟 Use cases (Optional) / 使用案例(可选) - 本地快速验证:开发者运行 bash ./scripts/run_smoke.sh 获取快速反馈。 - 本地完整回归:开发者运行 bash ./scripts/run_regression.sh 覆盖主要回归用例。 - PR 增量门禁:CI 设置 MSMODELING_TEST_MAP_PATH 后运行 bash ./scripts/run_ci_gate.sh,按 diff 与 test_map 选择用例并执行 coverage gate。 - 夜间任务:nightly 先跑非 nightly 的 smoke/regression 并刷新 test_map,再执行 nightly/benchmark 并生成报告,可选 Feishu 通知。 ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [ ] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [x] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 ------ See merge request: Ascend/msmodeling!266 | 27 天前 | |
【REFACTOR】【TESTS】重构 tests 目录并补充 smoke 测试 Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !266 merge refactor-tests into develop 【REFACTOR】【TESTS】重构 tests 目录并补充 smoke 测试 Created-by: AvadaKedavrua Commit-by: liujiawang;AvadaKedavrua Merged-by: ascend-robot Description: # PR Template Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers. 感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。 **PR Type / PR类型** - [x] Feature(功能新增) - [x] Bugfix(Bug 修复) - [x] Docs(文档更新) - [x] CI/CD(持续集成/持续部署) - [x] Refactor(代码重构) - [x] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 现有 UT 目录混合了 smoke、regression、benchmark、模型配置资产和脚本测试,导致本地执行入口不统一、CI 无法稳定做增量选择,nightly 也缺少统一的 test_map 刷新和报告链路。旧的 tests/run_ut.sh 入口难以表达“快速 smoke / 完整 regression / benchmark / PR gate / nightly”这些不同场景,新增或删除源码时也缺少基于 test_map 的覆盖检查。 本 PR 目标是把测试体系拆成清晰分层,并补齐 CI gate、nightly、coverage gate、test_map 构建和文档,让开发者和流水线都能按同一套目录与脚本执行测试。同时修复整理过程中暴露出的少量模型配置、serving 输出文本和文档问题。 ------ ## 📝 Modification / 修改内容 本次按 hunk/主题重新整理为 17 个提交,主要修改如下: - 重构测试目录:将旧 tests/test_tensor_cast、serving_cast/tests、web_ui/tests、tests/tools、tests/perf_database、tests/st 拆分到 tests/smoke/、tests/regression/、tests/benchmark/。 - 统一测试资产:将模型配置移动到 tests/assets/model_config/,同步更新 pre-commit exclude、缓存目录和文档说明。 - 新增共享测试 helper:补充断言、配置工厂、fake subprocess、模型构造、op registry 等公共测试工具,减少测试重复代码。 - 新增 CI gate helper:增加 diff 分类、test_map 读取、AST 符号映射、coverage gate、增量测试选择和 gate policy 配置。 - 新增 nightly helper:增加 pytest 结果解析、报告模型、报告构建、Feishu webhook 通知、test_map 刷新和 benchmark 调度入口。 - 新增统一脚本入口:新增 scripts/run_smoke.sh、scripts/run_regression.sh、scripts/run_benchmark.sh、scripts/run_ci_gate.sh、scripts/run_nightly.sh,替换旧 tests/run_ut.sh。 - 更新配置与文档:补充 pyproject.toml 的 pytest marker/testpaths/filterwarnings,更新 README.md、tests/README.md、docs/en/web_ui.md、web_ui/README.md、tools/perf_data_collection/README.md。 - 修复模型/输出细节:为 DeepseekV32DecoderLayer 注册 config_class;规范 serving_cast optimizer summary 的冒号和 runner 日志文案。 ### 后续 UT 怎么上 - 新增快速兜底用例放到 tests/smoke/:覆盖导入、基础 compile path、轻量 config resolver、轻量 serving/tensor_cast 主路径,要求无 NPU、无大模型权重、反馈快,适合每个 PR 先跑。 - 新增功能回归用例放到 tests/regression/<domain>/:按 tensor_cast、serving_cast、cli、web_ui、scripts/helpers 等领域归档,覆盖具体 bugfix、边界条件、行为契约和工具脚本逻辑。 - 新增长耗时或性能相关用例放到 tests/benchmark/:模型基准、perf_database、trace/CSV 性能数据处理等不阻塞普通 PR gate 的测试归到 benchmark 层。 - 新增模型配置、fixture、样例数据优先放到 tests/assets/ 或就近 fixtures/,避免继续散落在测试包内部;大文件或生成缓存走 .msmodeling_cache/、tests/assets/cache/,不直接进入源码目录。 - 新测试默认使用 tests/helpers/ 的公共构造器和断言工具;需要 fake subprocess、模型配置、op registry 时复用已有 helper,减少每个测试重复 mock 和手写配置。 - 需要 NPU 的用例必须打 @pytest.mark.npu;只应 nightly 跑的大模型/长耗时 compile 用例打 @pytest.mark.nightly,避免进入默认本地和 PR 快速路径。 ### 怎么根据语义上 UT - 测试不再只按文件名机械归类,而是按“被测语义”挂到对应源码符号:产品源码的函数、类、方法、顶层行为需要在 test_map 中映射到验证它的测试 nodeid。 - 新增产品源码时,如果是可执行逻辑,应新增对应 smoke 或 regression 用例,并让 test_map 能找到该源码/符号;确实不需要测试的符号需要在 exemption 中写明原因。 - 修改已有源码时,CI gate 会用 AST 定位变更行落在哪个 top-level definition 或 class/method span,再通过 test_map 选择关联测试;如果符号没有映射,会阻断或扩大测试范围,避免“改了逻辑但没跑语义相关 UT”。 - 删除源码时,CI gate 会检查 test_map 中是否仍有引用该源码的测试,防止遗留无效映射;删除测试时也会检查是否破坏已有源码覆盖关系。 - 跨层依赖变更会按语义优先选择所属 regression layer,无法明确归属或配置变更时升级为更完整的套件,保证增量选择不会漏测。 - test_map 由 nightly 在完整测试通过后刷新,PR gate 消费稳定版本;这样避免每个 PR 临时生成不可信映射,同时让语义映射随主干测试演进。 ### 流水线做了什么调整 - 本地与 CI 统一入口:run_smoke.sh 跑快速 smoke,run_regression.sh 跑完整 regression,run_benchmark.sh 跑 benchmark,run_ci_gate.sh 跑 PR 增量门禁,run_nightly.sh 跑夜间全流程。 - PR gate 从“固定跑一批 UT”改为“diff -> classify changes -> load test_map -> apply gate rules -> run selected pytest -> coverage gate”。配置变更、源码新增/删除、测试新增/删除、源码修改会走不同 gate 规则。 - coverage gate 统一读取 MSMODELING_TEST_LINE_THRESHOLD 和 MSMODELING_TEST_BRANCH_THRESHOLD,默认 line 70、branch 50;pytest 默认排除 npu,PR gate 额外排除 nightly。 - nightly 分两阶段:先跑非 NPU、非 nightly 的 smoke/regression 并在通过后刷新 test_map;再跑 nightly 标记用例与 benchmark,并构建结构化报告。 - 流水线统一支持 MSMODELING_OFFLINE、MSMODELING_TEST_WEIGHTS_PRUNE、MSMODELING_TEST_MAP_PATH 等环境变量,减少不同脚本各自处理缓存、离线和权重清理的差异。 - benchmark 不纳入普通 coverage gate,避免性能/长耗时用例拖慢 PR 门禁;必要时可通过独立 benchmark pipeline 或 nightly 验证。 - pre-commit exclude 同步到新目录,模型配置资产和 fixtures 不再被无意义格式化或误报。 已处理问题清单: - 旧 UT 入口单一,无法区分 smoke、regression、benchmark、nightly 和 PR gate。 - 模型配置资产散落在测试用例目录下,pre-commit 与测试引用路径容易漂移。 - 新增/删除源码缺少 test_map 覆盖检查,CI 不能精准阻断未补测试的变更。 - coverage 阈值、pytest marker、离线模式、权重缓存清理等 CI 参数缺少统一入口。 - nightly 缺少结构化报告、失败摘要和 Feishu 通知链路。 - web UI 测试仍在模块内,未纳入统一 regression 层级。 - DeepseekV32DecoderLayer 缺少 config_class,影响配置类识别一致性。 - serving_cast 部分日志/summary 文案有多余空格或表达不统一。 ------ ## 📐 Associated Test Results / 关联测试结果 提交过程中每个 commit 均触发 pre-commit hook,已通过已检查文件的 trailing whitespace、EOF、YAML/JSON、大文件、merge conflict、private key、ruff、ruff-format、codespell、pylint、bandit、typos 等检查。 本地未额外执行完整 smoke/regression/benchmark 全量测试;推送后以 GitCode CI 结果为准。建议重点关注: - bash ./scripts/run_smoke.sh - bash ./scripts/run_regression.sh - bash ./scripts/run_ci_gate.sh(需设置 MSMODELING_TEST_MAP_PATH) - bash ./scripts/run_nightly.sh(需设置 MSMODELING_TEST_MAP_PATH) ------ ## 🌟 Use cases (Optional) / 使用案例(可选) - 本地快速验证:开发者运行 bash ./scripts/run_smoke.sh 获取快速反馈。 - 本地完整回归:开发者运行 bash ./scripts/run_regression.sh 覆盖主要回归用例。 - PR 增量门禁:CI 设置 MSMODELING_TEST_MAP_PATH 后运行 bash ./scripts/run_ci_gate.sh,按 diff 与 test_map 选择用例并执行 coverage gate。 - 夜间任务:nightly 先跑非 nightly 的 smoke/regression 并刷新 test_map,再执行 nightly/benchmark 并生成报告,可选 Feishu 通知。 ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [ ] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [x] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 ------ See merge request: Ascend/msmodeling!266 | 27 天前 | |
【REFACTOR】【TESTS】重构 tests 目录并补充 smoke 测试 Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !266 merge refactor-tests into develop 【REFACTOR】【TESTS】重构 tests 目录并补充 smoke 测试 Created-by: AvadaKedavrua Commit-by: liujiawang;AvadaKedavrua Merged-by: ascend-robot Description: # PR Template Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers. 感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。 **PR Type / PR类型** - [x] Feature(功能新增) - [x] Bugfix(Bug 修复) - [x] Docs(文档更新) - [x] CI/CD(持续集成/持续部署) - [x] Refactor(代码重构) - [x] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 现有 UT 目录混合了 smoke、regression、benchmark、模型配置资产和脚本测试,导致本地执行入口不统一、CI 无法稳定做增量选择,nightly 也缺少统一的 test_map 刷新和报告链路。旧的 tests/run_ut.sh 入口难以表达“快速 smoke / 完整 regression / benchmark / PR gate / nightly”这些不同场景,新增或删除源码时也缺少基于 test_map 的覆盖检查。 本 PR 目标是把测试体系拆成清晰分层,并补齐 CI gate、nightly、coverage gate、test_map 构建和文档,让开发者和流水线都能按同一套目录与脚本执行测试。同时修复整理过程中暴露出的少量模型配置、serving 输出文本和文档问题。 ------ ## 📝 Modification / 修改内容 本次按 hunk/主题重新整理为 17 个提交,主要修改如下: - 重构测试目录:将旧 tests/test_tensor_cast、serving_cast/tests、web_ui/tests、tests/tools、tests/perf_database、tests/st 拆分到 tests/smoke/、tests/regression/、tests/benchmark/。 - 统一测试资产:将模型配置移动到 tests/assets/model_config/,同步更新 pre-commit exclude、缓存目录和文档说明。 - 新增共享测试 helper:补充断言、配置工厂、fake subprocess、模型构造、op registry 等公共测试工具,减少测试重复代码。 - 新增 CI gate helper:增加 diff 分类、test_map 读取、AST 符号映射、coverage gate、增量测试选择和 gate policy 配置。 - 新增 nightly helper:增加 pytest 结果解析、报告模型、报告构建、Feishu webhook 通知、test_map 刷新和 benchmark 调度入口。 - 新增统一脚本入口:新增 scripts/run_smoke.sh、scripts/run_regression.sh、scripts/run_benchmark.sh、scripts/run_ci_gate.sh、scripts/run_nightly.sh,替换旧 tests/run_ut.sh。 - 更新配置与文档:补充 pyproject.toml 的 pytest marker/testpaths/filterwarnings,更新 README.md、tests/README.md、docs/en/web_ui.md、web_ui/README.md、tools/perf_data_collection/README.md。 - 修复模型/输出细节:为 DeepseekV32DecoderLayer 注册 config_class;规范 serving_cast optimizer summary 的冒号和 runner 日志文案。 ### 后续 UT 怎么上 - 新增快速兜底用例放到 tests/smoke/:覆盖导入、基础 compile path、轻量 config resolver、轻量 serving/tensor_cast 主路径,要求无 NPU、无大模型权重、反馈快,适合每个 PR 先跑。 - 新增功能回归用例放到 tests/regression/<domain>/:按 tensor_cast、serving_cast、cli、web_ui、scripts/helpers 等领域归档,覆盖具体 bugfix、边界条件、行为契约和工具脚本逻辑。 - 新增长耗时或性能相关用例放到 tests/benchmark/:模型基准、perf_database、trace/CSV 性能数据处理等不阻塞普通 PR gate 的测试归到 benchmark 层。 - 新增模型配置、fixture、样例数据优先放到 tests/assets/ 或就近 fixtures/,避免继续散落在测试包内部;大文件或生成缓存走 .msmodeling_cache/、tests/assets/cache/,不直接进入源码目录。 - 新测试默认使用 tests/helpers/ 的公共构造器和断言工具;需要 fake subprocess、模型配置、op registry 时复用已有 helper,减少每个测试重复 mock 和手写配置。 - 需要 NPU 的用例必须打 @pytest.mark.npu;只应 nightly 跑的大模型/长耗时 compile 用例打 @pytest.mark.nightly,避免进入默认本地和 PR 快速路径。 ### 怎么根据语义上 UT - 测试不再只按文件名机械归类,而是按“被测语义”挂到对应源码符号:产品源码的函数、类、方法、顶层行为需要在 test_map 中映射到验证它的测试 nodeid。 - 新增产品源码时,如果是可执行逻辑,应新增对应 smoke 或 regression 用例,并让 test_map 能找到该源码/符号;确实不需要测试的符号需要在 exemption 中写明原因。 - 修改已有源码时,CI gate 会用 AST 定位变更行落在哪个 top-level definition 或 class/method span,再通过 test_map 选择关联测试;如果符号没有映射,会阻断或扩大测试范围,避免“改了逻辑但没跑语义相关 UT”。 - 删除源码时,CI gate 会检查 test_map 中是否仍有引用该源码的测试,防止遗留无效映射;删除测试时也会检查是否破坏已有源码覆盖关系。 - 跨层依赖变更会按语义优先选择所属 regression layer,无法明确归属或配置变更时升级为更完整的套件,保证增量选择不会漏测。 - test_map 由 nightly 在完整测试通过后刷新,PR gate 消费稳定版本;这样避免每个 PR 临时生成不可信映射,同时让语义映射随主干测试演进。 ### 流水线做了什么调整 - 本地与 CI 统一入口:run_smoke.sh 跑快速 smoke,run_regression.sh 跑完整 regression,run_benchmark.sh 跑 benchmark,run_ci_gate.sh 跑 PR 增量门禁,run_nightly.sh 跑夜间全流程。 - PR gate 从“固定跑一批 UT”改为“diff -> classify changes -> load test_map -> apply gate rules -> run selected pytest -> coverage gate”。配置变更、源码新增/删除、测试新增/删除、源码修改会走不同 gate 规则。 - coverage gate 统一读取 MSMODELING_TEST_LINE_THRESHOLD 和 MSMODELING_TEST_BRANCH_THRESHOLD,默认 line 70、branch 50;pytest 默认排除 npu,PR gate 额外排除 nightly。 - nightly 分两阶段:先跑非 NPU、非 nightly 的 smoke/regression 并在通过后刷新 test_map;再跑 nightly 标记用例与 benchmark,并构建结构化报告。 - 流水线统一支持 MSMODELING_OFFLINE、MSMODELING_TEST_WEIGHTS_PRUNE、MSMODELING_TEST_MAP_PATH 等环境变量,减少不同脚本各自处理缓存、离线和权重清理的差异。 - benchmark 不纳入普通 coverage gate,避免性能/长耗时用例拖慢 PR 门禁;必要时可通过独立 benchmark pipeline 或 nightly 验证。 - pre-commit exclude 同步到新目录,模型配置资产和 fixtures 不再被无意义格式化或误报。 已处理问题清单: - 旧 UT 入口单一,无法区分 smoke、regression、benchmark、nightly 和 PR gate。 - 模型配置资产散落在测试用例目录下,pre-commit 与测试引用路径容易漂移。 - 新增/删除源码缺少 test_map 覆盖检查,CI 不能精准阻断未补测试的变更。 - coverage 阈值、pytest marker、离线模式、权重缓存清理等 CI 参数缺少统一入口。 - nightly 缺少结构化报告、失败摘要和 Feishu 通知链路。 - web UI 测试仍在模块内,未纳入统一 regression 层级。 - DeepseekV32DecoderLayer 缺少 config_class,影响配置类识别一致性。 - serving_cast 部分日志/summary 文案有多余空格或表达不统一。 ------ ## 📐 Associated Test Results / 关联测试结果 提交过程中每个 commit 均触发 pre-commit hook,已通过已检查文件的 trailing whitespace、EOF、YAML/JSON、大文件、merge conflict、private key、ruff、ruff-format、codespell、pylint、bandit、typos 等检查。 本地未额外执行完整 smoke/regression/benchmark 全量测试;推送后以 GitCode CI 结果为准。建议重点关注: - bash ./scripts/run_smoke.sh - bash ./scripts/run_regression.sh - bash ./scripts/run_ci_gate.sh(需设置 MSMODELING_TEST_MAP_PATH) - bash ./scripts/run_nightly.sh(需设置 MSMODELING_TEST_MAP_PATH) ------ ## 🌟 Use cases (Optional) / 使用案例(可选) - 本地快速验证:开发者运行 bash ./scripts/run_smoke.sh 获取快速反馈。 - 本地完整回归:开发者运行 bash ./scripts/run_regression.sh 覆盖主要回归用例。 - PR 增量门禁:CI 设置 MSMODELING_TEST_MAP_PATH 后运行 bash ./scripts/run_ci_gate.sh,按 diff 与 test_map 选择用例并执行 coverage gate。 - 夜间任务:nightly 先跑非 nightly 的 smoke/regression 并刷新 test_map,再执行 nightly/benchmark 并生成报告,可选 Feishu 通知。 ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [ ] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [x] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 ------ See merge request: Ascend/msmodeling!266 | 27 天前 | |
【REFACTOR】【TESTS】重构 tests 目录并补充 smoke 测试 Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !266 merge refactor-tests into develop 【REFACTOR】【TESTS】重构 tests 目录并补充 smoke 测试 Created-by: AvadaKedavrua Commit-by: liujiawang;AvadaKedavrua Merged-by: ascend-robot Description: # PR Template Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers. 感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。 **PR Type / PR类型** - [x] Feature(功能新增) - [x] Bugfix(Bug 修复) - [x] Docs(文档更新) - [x] CI/CD(持续集成/持续部署) - [x] Refactor(代码重构) - [x] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 现有 UT 目录混合了 smoke、regression、benchmark、模型配置资产和脚本测试,导致本地执行入口不统一、CI 无法稳定做增量选择,nightly 也缺少统一的 test_map 刷新和报告链路。旧的 tests/run_ut.sh 入口难以表达“快速 smoke / 完整 regression / benchmark / PR gate / nightly”这些不同场景,新增或删除源码时也缺少基于 test_map 的覆盖检查。 本 PR 目标是把测试体系拆成清晰分层,并补齐 CI gate、nightly、coverage gate、test_map 构建和文档,让开发者和流水线都能按同一套目录与脚本执行测试。同时修复整理过程中暴露出的少量模型配置、serving 输出文本和文档问题。 ------ ## 📝 Modification / 修改内容 本次按 hunk/主题重新整理为 17 个提交,主要修改如下: - 重构测试目录:将旧 tests/test_tensor_cast、serving_cast/tests、web_ui/tests、tests/tools、tests/perf_database、tests/st 拆分到 tests/smoke/、tests/regression/、tests/benchmark/。 - 统一测试资产:将模型配置移动到 tests/assets/model_config/,同步更新 pre-commit exclude、缓存目录和文档说明。 - 新增共享测试 helper:补充断言、配置工厂、fake subprocess、模型构造、op registry 等公共测试工具,减少测试重复代码。 - 新增 CI gate helper:增加 diff 分类、test_map 读取、AST 符号映射、coverage gate、增量测试选择和 gate policy 配置。 - 新增 nightly helper:增加 pytest 结果解析、报告模型、报告构建、Feishu webhook 通知、test_map 刷新和 benchmark 调度入口。 - 新增统一脚本入口:新增 scripts/run_smoke.sh、scripts/run_regression.sh、scripts/run_benchmark.sh、scripts/run_ci_gate.sh、scripts/run_nightly.sh,替换旧 tests/run_ut.sh。 - 更新配置与文档:补充 pyproject.toml 的 pytest marker/testpaths/filterwarnings,更新 README.md、tests/README.md、docs/en/web_ui.md、web_ui/README.md、tools/perf_data_collection/README.md。 - 修复模型/输出细节:为 DeepseekV32DecoderLayer 注册 config_class;规范 serving_cast optimizer summary 的冒号和 runner 日志文案。 ### 后续 UT 怎么上 - 新增快速兜底用例放到 tests/smoke/:覆盖导入、基础 compile path、轻量 config resolver、轻量 serving/tensor_cast 主路径,要求无 NPU、无大模型权重、反馈快,适合每个 PR 先跑。 - 新增功能回归用例放到 tests/regression/<domain>/:按 tensor_cast、serving_cast、cli、web_ui、scripts/helpers 等领域归档,覆盖具体 bugfix、边界条件、行为契约和工具脚本逻辑。 - 新增长耗时或性能相关用例放到 tests/benchmark/:模型基准、perf_database、trace/CSV 性能数据处理等不阻塞普通 PR gate 的测试归到 benchmark 层。 - 新增模型配置、fixture、样例数据优先放到 tests/assets/ 或就近 fixtures/,避免继续散落在测试包内部;大文件或生成缓存走 .msmodeling_cache/、tests/assets/cache/,不直接进入源码目录。 - 新测试默认使用 tests/helpers/ 的公共构造器和断言工具;需要 fake subprocess、模型配置、op registry 时复用已有 helper,减少每个测试重复 mock 和手写配置。 - 需要 NPU 的用例必须打 @pytest.mark.npu;只应 nightly 跑的大模型/长耗时 compile 用例打 @pytest.mark.nightly,避免进入默认本地和 PR 快速路径。 ### 怎么根据语义上 UT - 测试不再只按文件名机械归类,而是按“被测语义”挂到对应源码符号:产品源码的函数、类、方法、顶层行为需要在 test_map 中映射到验证它的测试 nodeid。 - 新增产品源码时,如果是可执行逻辑,应新增对应 smoke 或 regression 用例,并让 test_map 能找到该源码/符号;确实不需要测试的符号需要在 exemption 中写明原因。 - 修改已有源码时,CI gate 会用 AST 定位变更行落在哪个 top-level definition 或 class/method span,再通过 test_map 选择关联测试;如果符号没有映射,会阻断或扩大测试范围,避免“改了逻辑但没跑语义相关 UT”。 - 删除源码时,CI gate 会检查 test_map 中是否仍有引用该源码的测试,防止遗留无效映射;删除测试时也会检查是否破坏已有源码覆盖关系。 - 跨层依赖变更会按语义优先选择所属 regression layer,无法明确归属或配置变更时升级为更完整的套件,保证增量选择不会漏测。 - test_map 由 nightly 在完整测试通过后刷新,PR gate 消费稳定版本;这样避免每个 PR 临时生成不可信映射,同时让语义映射随主干测试演进。 ### 流水线做了什么调整 - 本地与 CI 统一入口:run_smoke.sh 跑快速 smoke,run_regression.sh 跑完整 regression,run_benchmark.sh 跑 benchmark,run_ci_gate.sh 跑 PR 增量门禁,run_nightly.sh 跑夜间全流程。 - PR gate 从“固定跑一批 UT”改为“diff -> classify changes -> load test_map -> apply gate rules -> run selected pytest -> coverage gate”。配置变更、源码新增/删除、测试新增/删除、源码修改会走不同 gate 规则。 - coverage gate 统一读取 MSMODELING_TEST_LINE_THRESHOLD 和 MSMODELING_TEST_BRANCH_THRESHOLD,默认 line 70、branch 50;pytest 默认排除 npu,PR gate 额外排除 nightly。 - nightly 分两阶段:先跑非 NPU、非 nightly 的 smoke/regression 并在通过后刷新 test_map;再跑 nightly 标记用例与 benchmark,并构建结构化报告。 - 流水线统一支持 MSMODELING_OFFLINE、MSMODELING_TEST_WEIGHTS_PRUNE、MSMODELING_TEST_MAP_PATH 等环境变量,减少不同脚本各自处理缓存、离线和权重清理的差异。 - benchmark 不纳入普通 coverage gate,避免性能/长耗时用例拖慢 PR 门禁;必要时可通过独立 benchmark pipeline 或 nightly 验证。 - pre-commit exclude 同步到新目录,模型配置资产和 fixtures 不再被无意义格式化或误报。 已处理问题清单: - 旧 UT 入口单一,无法区分 smoke、regression、benchmark、nightly 和 PR gate。 - 模型配置资产散落在测试用例目录下,pre-commit 与测试引用路径容易漂移。 - 新增/删除源码缺少 test_map 覆盖检查,CI 不能精准阻断未补测试的变更。 - coverage 阈值、pytest marker、离线模式、权重缓存清理等 CI 参数缺少统一入口。 - nightly 缺少结构化报告、失败摘要和 Feishu 通知链路。 - web UI 测试仍在模块内,未纳入统一 regression 层级。 - DeepseekV32DecoderLayer 缺少 config_class,影响配置类识别一致性。 - serving_cast 部分日志/summary 文案有多余空格或表达不统一。 ------ ## 📐 Associated Test Results / 关联测试结果 提交过程中每个 commit 均触发 pre-commit hook,已通过已检查文件的 trailing whitespace、EOF、YAML/JSON、大文件、merge conflict、private key、ruff、ruff-format、codespell、pylint、bandit、typos 等检查。 本地未额外执行完整 smoke/regression/benchmark 全量测试;推送后以 GitCode CI 结果为准。建议重点关注: - bash ./scripts/run_smoke.sh - bash ./scripts/run_regression.sh - bash ./scripts/run_ci_gate.sh(需设置 MSMODELING_TEST_MAP_PATH) - bash ./scripts/run_nightly.sh(需设置 MSMODELING_TEST_MAP_PATH) ------ ## 🌟 Use cases (Optional) / 使用案例(可选) - 本地快速验证:开发者运行 bash ./scripts/run_smoke.sh 获取快速反馈。 - 本地完整回归:开发者运行 bash ./scripts/run_regression.sh 覆盖主要回归用例。 - PR 增量门禁:CI 设置 MSMODELING_TEST_MAP_PATH 后运行 bash ./scripts/run_ci_gate.sh,按 diff 与 test_map 选择用例并执行 coverage gate。 - 夜间任务:nightly 先跑非 nightly 的 smoke/regression 并刷新 test_map,再执行 nightly/benchmark 并生成报告,可选 Feishu 通知。 ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [ ] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [x] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 ------ See merge request: Ascend/msmodeling!266 | 27 天前 | |
【REFACTOR】【TESTS】重构 tests 目录并补充 smoke 测试 Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !266 merge refactor-tests into develop 【REFACTOR】【TESTS】重构 tests 目录并补充 smoke 测试 Created-by: AvadaKedavrua Commit-by: liujiawang;AvadaKedavrua Merged-by: ascend-robot Description: # PR Template Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers. 感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。 **PR Type / PR类型** - [x] Feature(功能新增) - [x] Bugfix(Bug 修复) - [x] Docs(文档更新) - [x] CI/CD(持续集成/持续部署) - [x] Refactor(代码重构) - [x] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 现有 UT 目录混合了 smoke、regression、benchmark、模型配置资产和脚本测试,导致本地执行入口不统一、CI 无法稳定做增量选择,nightly 也缺少统一的 test_map 刷新和报告链路。旧的 tests/run_ut.sh 入口难以表达“快速 smoke / 完整 regression / benchmark / PR gate / nightly”这些不同场景,新增或删除源码时也缺少基于 test_map 的覆盖检查。 本 PR 目标是把测试体系拆成清晰分层,并补齐 CI gate、nightly、coverage gate、test_map 构建和文档,让开发者和流水线都能按同一套目录与脚本执行测试。同时修复整理过程中暴露出的少量模型配置、serving 输出文本和文档问题。 ------ ## 📝 Modification / 修改内容 本次按 hunk/主题重新整理为 17 个提交,主要修改如下: - 重构测试目录:将旧 tests/test_tensor_cast、serving_cast/tests、web_ui/tests、tests/tools、tests/perf_database、tests/st 拆分到 tests/smoke/、tests/regression/、tests/benchmark/。 - 统一测试资产:将模型配置移动到 tests/assets/model_config/,同步更新 pre-commit exclude、缓存目录和文档说明。 - 新增共享测试 helper:补充断言、配置工厂、fake subprocess、模型构造、op registry 等公共测试工具,减少测试重复代码。 - 新增 CI gate helper:增加 diff 分类、test_map 读取、AST 符号映射、coverage gate、增量测试选择和 gate policy 配置。 - 新增 nightly helper:增加 pytest 结果解析、报告模型、报告构建、Feishu webhook 通知、test_map 刷新和 benchmark 调度入口。 - 新增统一脚本入口:新增 scripts/run_smoke.sh、scripts/run_regression.sh、scripts/run_benchmark.sh、scripts/run_ci_gate.sh、scripts/run_nightly.sh,替换旧 tests/run_ut.sh。 - 更新配置与文档:补充 pyproject.toml 的 pytest marker/testpaths/filterwarnings,更新 README.md、tests/README.md、docs/en/web_ui.md、web_ui/README.md、tools/perf_data_collection/README.md。 - 修复模型/输出细节:为 DeepseekV32DecoderLayer 注册 config_class;规范 serving_cast optimizer summary 的冒号和 runner 日志文案。 ### 后续 UT 怎么上 - 新增快速兜底用例放到 tests/smoke/:覆盖导入、基础 compile path、轻量 config resolver、轻量 serving/tensor_cast 主路径,要求无 NPU、无大模型权重、反馈快,适合每个 PR 先跑。 - 新增功能回归用例放到 tests/regression/<domain>/:按 tensor_cast、serving_cast、cli、web_ui、scripts/helpers 等领域归档,覆盖具体 bugfix、边界条件、行为契约和工具脚本逻辑。 - 新增长耗时或性能相关用例放到 tests/benchmark/:模型基准、perf_database、trace/CSV 性能数据处理等不阻塞普通 PR gate 的测试归到 benchmark 层。 - 新增模型配置、fixture、样例数据优先放到 tests/assets/ 或就近 fixtures/,避免继续散落在测试包内部;大文件或生成缓存走 .msmodeling_cache/、tests/assets/cache/,不直接进入源码目录。 - 新测试默认使用 tests/helpers/ 的公共构造器和断言工具;需要 fake subprocess、模型配置、op registry 时复用已有 helper,减少每个测试重复 mock 和手写配置。 - 需要 NPU 的用例必须打 @pytest.mark.npu;只应 nightly 跑的大模型/长耗时 compile 用例打 @pytest.mark.nightly,避免进入默认本地和 PR 快速路径。 ### 怎么根据语义上 UT - 测试不再只按文件名机械归类,而是按“被测语义”挂到对应源码符号:产品源码的函数、类、方法、顶层行为需要在 test_map 中映射到验证它的测试 nodeid。 - 新增产品源码时,如果是可执行逻辑,应新增对应 smoke 或 regression 用例,并让 test_map 能找到该源码/符号;确实不需要测试的符号需要在 exemption 中写明原因。 - 修改已有源码时,CI gate 会用 AST 定位变更行落在哪个 top-level definition 或 class/method span,再通过 test_map 选择关联测试;如果符号没有映射,会阻断或扩大测试范围,避免“改了逻辑但没跑语义相关 UT”。 - 删除源码时,CI gate 会检查 test_map 中是否仍有引用该源码的测试,防止遗留无效映射;删除测试时也会检查是否破坏已有源码覆盖关系。 - 跨层依赖变更会按语义优先选择所属 regression layer,无法明确归属或配置变更时升级为更完整的套件,保证增量选择不会漏测。 - test_map 由 nightly 在完整测试通过后刷新,PR gate 消费稳定版本;这样避免每个 PR 临时生成不可信映射,同时让语义映射随主干测试演进。 ### 流水线做了什么调整 - 本地与 CI 统一入口:run_smoke.sh 跑快速 smoke,run_regression.sh 跑完整 regression,run_benchmark.sh 跑 benchmark,run_ci_gate.sh 跑 PR 增量门禁,run_nightly.sh 跑夜间全流程。 - PR gate 从“固定跑一批 UT”改为“diff -> classify changes -> load test_map -> apply gate rules -> run selected pytest -> coverage gate”。配置变更、源码新增/删除、测试新增/删除、源码修改会走不同 gate 规则。 - coverage gate 统一读取 MSMODELING_TEST_LINE_THRESHOLD 和 MSMODELING_TEST_BRANCH_THRESHOLD,默认 line 70、branch 50;pytest 默认排除 npu,PR gate 额外排除 nightly。 - nightly 分两阶段:先跑非 NPU、非 nightly 的 smoke/regression 并在通过后刷新 test_map;再跑 nightly 标记用例与 benchmark,并构建结构化报告。 - 流水线统一支持 MSMODELING_OFFLINE、MSMODELING_TEST_WEIGHTS_PRUNE、MSMODELING_TEST_MAP_PATH 等环境变量,减少不同脚本各自处理缓存、离线和权重清理的差异。 - benchmark 不纳入普通 coverage gate,避免性能/长耗时用例拖慢 PR 门禁;必要时可通过独立 benchmark pipeline 或 nightly 验证。 - pre-commit exclude 同步到新目录,模型配置资产和 fixtures 不再被无意义格式化或误报。 已处理问题清单: - 旧 UT 入口单一,无法区分 smoke、regression、benchmark、nightly 和 PR gate。 - 模型配置资产散落在测试用例目录下,pre-commit 与测试引用路径容易漂移。 - 新增/删除源码缺少 test_map 覆盖检查,CI 不能精准阻断未补测试的变更。 - coverage 阈值、pytest marker、离线模式、权重缓存清理等 CI 参数缺少统一入口。 - nightly 缺少结构化报告、失败摘要和 Feishu 通知链路。 - web UI 测试仍在模块内,未纳入统一 regression 层级。 - DeepseekV32DecoderLayer 缺少 config_class,影响配置类识别一致性。 - serving_cast 部分日志/summary 文案有多余空格或表达不统一。 ------ ## 📐 Associated Test Results / 关联测试结果 提交过程中每个 commit 均触发 pre-commit hook,已通过已检查文件的 trailing whitespace、EOF、YAML/JSON、大文件、merge conflict、private key、ruff、ruff-format、codespell、pylint、bandit、typos 等检查。 本地未额外执行完整 smoke/regression/benchmark 全量测试;推送后以 GitCode CI 结果为准。建议重点关注: - bash ./scripts/run_smoke.sh - bash ./scripts/run_regression.sh - bash ./scripts/run_ci_gate.sh(需设置 MSMODELING_TEST_MAP_PATH) - bash ./scripts/run_nightly.sh(需设置 MSMODELING_TEST_MAP_PATH) ------ ## 🌟 Use cases (Optional) / 使用案例(可选) - 本地快速验证:开发者运行 bash ./scripts/run_smoke.sh 获取快速反馈。 - 本地完整回归:开发者运行 bash ./scripts/run_regression.sh 覆盖主要回归用例。 - PR 增量门禁:CI 设置 MSMODELING_TEST_MAP_PATH 后运行 bash ./scripts/run_ci_gate.sh,按 diff 与 test_map 选择用例并执行 coverage gate。 - 夜间任务:nightly 先跑非 nightly 的 smoke/regression 并刷新 test_map,再执行 nightly/benchmark 并生成报告,可选 Feishu 通知。 ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [ ] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [x] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 ------ See merge request: Ascend/msmodeling!266 | 27 天前 | |
feat(serving_cast): support chunked prefill modeling Co-authored-by: jia_ya_nan<jiayanan3@h-partners.com> # message auto-generated for no-merge-commit merge: !250 merge feat/chunked-prefill-impl into develop feat(serving_cast): support chunked prefill modeling Created-by: jia_ya_nan Commit-by: jia_ya_nan Merged-by: ascend-robot Description: # PR Template Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers. 感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。 **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [ ] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 **Please describe the motivation of this PR and the goal you want to achieve through this PR.** **请描述您的拉取请求的动机和您希望通过此拉取请求实现的目标。** 当前 throughput_optimizer 在混部模式下使用 max_prefill_tokens 作为 prefill token budget,并要求有效输入长度不超过该值。当长上下文请求的 effective_input_length 大于 token budget 时,工具会直接报错,无法模拟实际服务中常见的 chunked prefill 场景。 本 PR 旨在补齐 msmodeling 对 chunked prefill 的建模能力,使吞吐优化器可以在长 prompt 或较小 batch token budget 场景下,自动将 prefill 拆分为多个 chunk 进行估算,并更合理地建模 prefill 与 decode 混部执行对 TTFT、TPOT 和吞吐的影响。 ------ ## 📝 Modification / 修改内容 **Please briefly describe what modification is made in this PR.** **请简要描述此拉取请求中进行的修改。** - 将 CLI 参数 --max-prefill-tokens 重命名为 --max-batched-tokens,用于表达单个 prefill / mixed step 的 token budget。 - 新增 prefill chunk plan 生成逻辑,当 effective_input_length > max_batched_tokens 时自动按 max_batched_tokens 切分 prefill。 - 新增默认调度策略 DecodeFirstWithSlack,支持 decode-first 调度,并允许 15% slack 以避免 decode token 占用导致 prefill chunk 无法调度。 - 聚合模式中新增 chunked prefill 轻量级时间模拟,支持已完成 prefill 的请求提前进入 decode,不再要求所有请求完成 prefill 后统一 decode。 - PD 分离模式中 prefill 阶段支持 chunked prefill,decode 阶段保持原有逻辑。 - 优化 latency cache key,使其区分不同的 query_len、seq_len 和并发形态。 - 输出结果新增 effective_input_length、max_batched_tokens、prefill_num_chunks,便于分析 chunked prefill 配置影响。 - 更新 Web UI 参数生成、表单校验、相关文档和单元测试。 ------ ## 📐 Associated Test Results / 关联测试结果 **Please provide the related test results, such as test reports, etc.** **请提供相关测试结果,例如测试报告等。** 以32条 32k请求为例,无chunk改动前: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-prefill-tokens 32000 --log-level info  无chunk改动后: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 32000 --log-level info  结果不变,不影响之前的调度逻辑 chunk为2000: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 2000 --log-level info  chunk为4000: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 4000 --log-level info  chunk为8000: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 4000 --log-level info  从趋势上看,chunk size越小,对tpot越友好;同时chunk 越小,prefill阶段调度越多,ttft会增加,符合预期; 另外,由于开启chunk prefill后,prefill会增加多次计算,导致耗时呈线性增长;可以考虑并行一次性跑完所有切分的prefill,但对资源消耗巨大,考虑在下个PR内提升性能 ------ ## 🌟 Use cases (Optional) / 使用案例(可选) **If this PR introduces a new feature, it is better to list some use cases here and update the documentation.** **如果此拉取请求引入了新功能,最好在此处列出一些用例并更新文档。** ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [x] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 ------ See merge request: Ascend/msmodeling!250 | 24 天前 | |
feat(serving_cast): support chunked prefill modeling Co-authored-by: jia_ya_nan<jiayanan3@h-partners.com> # message auto-generated for no-merge-commit merge: !250 merge feat/chunked-prefill-impl into develop feat(serving_cast): support chunked prefill modeling Created-by: jia_ya_nan Commit-by: jia_ya_nan Merged-by: ascend-robot Description: # PR Template Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers. 感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。 **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [ ] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 **Please describe the motivation of this PR and the goal you want to achieve through this PR.** **请描述您的拉取请求的动机和您希望通过此拉取请求实现的目标。** 当前 throughput_optimizer 在混部模式下使用 max_prefill_tokens 作为 prefill token budget,并要求有效输入长度不超过该值。当长上下文请求的 effective_input_length 大于 token budget 时,工具会直接报错,无法模拟实际服务中常见的 chunked prefill 场景。 本 PR 旨在补齐 msmodeling 对 chunked prefill 的建模能力,使吞吐优化器可以在长 prompt 或较小 batch token budget 场景下,自动将 prefill 拆分为多个 chunk 进行估算,并更合理地建模 prefill 与 decode 混部执行对 TTFT、TPOT 和吞吐的影响。 ------ ## 📝 Modification / 修改内容 **Please briefly describe what modification is made in this PR.** **请简要描述此拉取请求中进行的修改。** - 将 CLI 参数 --max-prefill-tokens 重命名为 --max-batched-tokens,用于表达单个 prefill / mixed step 的 token budget。 - 新增 prefill chunk plan 生成逻辑,当 effective_input_length > max_batched_tokens 时自动按 max_batched_tokens 切分 prefill。 - 新增默认调度策略 DecodeFirstWithSlack,支持 decode-first 调度,并允许 15% slack 以避免 decode token 占用导致 prefill chunk 无法调度。 - 聚合模式中新增 chunked prefill 轻量级时间模拟,支持已完成 prefill 的请求提前进入 decode,不再要求所有请求完成 prefill 后统一 decode。 - PD 分离模式中 prefill 阶段支持 chunked prefill,decode 阶段保持原有逻辑。 - 优化 latency cache key,使其区分不同的 query_len、seq_len 和并发形态。 - 输出结果新增 effective_input_length、max_batched_tokens、prefill_num_chunks,便于分析 chunked prefill 配置影响。 - 更新 Web UI 参数生成、表单校验、相关文档和单元测试。 ------ ## 📐 Associated Test Results / 关联测试结果 **Please provide the related test results, such as test reports, etc.** **请提供相关测试结果,例如测试报告等。** 以32条 32k请求为例,无chunk改动前: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-prefill-tokens 32000 --log-level info  无chunk改动后: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 32000 --log-level info  结果不变,不影响之前的调度逻辑 chunk为2000: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 2000 --log-level info  chunk为4000: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 4000 --log-level info  chunk为8000: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 4000 --log-level info  从趋势上看,chunk size越小,对tpot越友好;同时chunk 越小,prefill阶段调度越多,ttft会增加,符合预期; 另外,由于开启chunk prefill后,prefill会增加多次计算,导致耗时呈线性增长;可以考虑并行一次性跑完所有切分的prefill,但对资源消耗巨大,考虑在下个PR内提升性能 ------ ## 🌟 Use cases (Optional) / 使用案例(可选) **If this PR introduces a new feature, it is better to list some use cases here and update the documentation.** **如果此拉取请求引入了新功能,最好在此处列出一些用例并更新文档。** ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [x] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 ------ See merge request: Ascend/msmodeling!250 | 24 天前 | |
feat(serving_cast): support chunked prefill modeling Co-authored-by: jia_ya_nan<jiayanan3@h-partners.com> # message auto-generated for no-merge-commit merge: !250 merge feat/chunked-prefill-impl into develop feat(serving_cast): support chunked prefill modeling Created-by: jia_ya_nan Commit-by: jia_ya_nan Merged-by: ascend-robot Description: # PR Template Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers. 感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。 **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [ ] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 **Please describe the motivation of this PR and the goal you want to achieve through this PR.** **请描述您的拉取请求的动机和您希望通过此拉取请求实现的目标。** 当前 throughput_optimizer 在混部模式下使用 max_prefill_tokens 作为 prefill token budget,并要求有效输入长度不超过该值。当长上下文请求的 effective_input_length 大于 token budget 时,工具会直接报错,无法模拟实际服务中常见的 chunked prefill 场景。 本 PR 旨在补齐 msmodeling 对 chunked prefill 的建模能力,使吞吐优化器可以在长 prompt 或较小 batch token budget 场景下,自动将 prefill 拆分为多个 chunk 进行估算,并更合理地建模 prefill 与 decode 混部执行对 TTFT、TPOT 和吞吐的影响。 ------ ## 📝 Modification / 修改内容 **Please briefly describe what modification is made in this PR.** **请简要描述此拉取请求中进行的修改。** - 将 CLI 参数 --max-prefill-tokens 重命名为 --max-batched-tokens,用于表达单个 prefill / mixed step 的 token budget。 - 新增 prefill chunk plan 生成逻辑,当 effective_input_length > max_batched_tokens 时自动按 max_batched_tokens 切分 prefill。 - 新增默认调度策略 DecodeFirstWithSlack,支持 decode-first 调度,并允许 15% slack 以避免 decode token 占用导致 prefill chunk 无法调度。 - 聚合模式中新增 chunked prefill 轻量级时间模拟,支持已完成 prefill 的请求提前进入 decode,不再要求所有请求完成 prefill 后统一 decode。 - PD 分离模式中 prefill 阶段支持 chunked prefill,decode 阶段保持原有逻辑。 - 优化 latency cache key,使其区分不同的 query_len、seq_len 和并发形态。 - 输出结果新增 effective_input_length、max_batched_tokens、prefill_num_chunks,便于分析 chunked prefill 配置影响。 - 更新 Web UI 参数生成、表单校验、相关文档和单元测试。 ------ ## 📐 Associated Test Results / 关联测试结果 **Please provide the related test results, such as test reports, etc.** **请提供相关测试结果,例如测试报告等。** 以32条 32k请求为例,无chunk改动前: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-prefill-tokens 32000 --log-level info  无chunk改动后: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 32000 --log-level info  结果不变,不影响之前的调度逻辑 chunk为2000: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 2000 --log-level info  chunk为4000: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 4000 --log-level info  chunk为8000: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 4000 --log-level info  从趋势上看,chunk size越小,对tpot越友好;同时chunk 越小,prefill阶段调度越多,ttft会增加,符合预期; 另外,由于开启chunk prefill后,prefill会增加多次计算,导致耗时呈线性增长;可以考虑并行一次性跑完所有切分的prefill,但对资源消耗巨大,考虑在下个PR内提升性能 ------ ## 🌟 Use cases (Optional) / 使用案例(可选) **If this PR introduces a new feature, it is better to list some use cases here and update the documentation.** **如果此拉取请求引入了新功能,最好在此处列出一些用例并更新文档。** ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [x] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 ------ See merge request: Ascend/msmodeling!250 | 24 天前 | |
feat(serving_cast): support chunked prefill modeling Co-authored-by: jia_ya_nan<jiayanan3@h-partners.com> # message auto-generated for no-merge-commit merge: !250 merge feat/chunked-prefill-impl into develop feat(serving_cast): support chunked prefill modeling Created-by: jia_ya_nan Commit-by: jia_ya_nan Merged-by: ascend-robot Description: # PR Template Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers. 感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。 **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [ ] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 **Please describe the motivation of this PR and the goal you want to achieve through this PR.** **请描述您的拉取请求的动机和您希望通过此拉取请求实现的目标。** 当前 throughput_optimizer 在混部模式下使用 max_prefill_tokens 作为 prefill token budget,并要求有效输入长度不超过该值。当长上下文请求的 effective_input_length 大于 token budget 时,工具会直接报错,无法模拟实际服务中常见的 chunked prefill 场景。 本 PR 旨在补齐 msmodeling 对 chunked prefill 的建模能力,使吞吐优化器可以在长 prompt 或较小 batch token budget 场景下,自动将 prefill 拆分为多个 chunk 进行估算,并更合理地建模 prefill 与 decode 混部执行对 TTFT、TPOT 和吞吐的影响。 ------ ## 📝 Modification / 修改内容 **Please briefly describe what modification is made in this PR.** **请简要描述此拉取请求中进行的修改。** - 将 CLI 参数 --max-prefill-tokens 重命名为 --max-batched-tokens,用于表达单个 prefill / mixed step 的 token budget。 - 新增 prefill chunk plan 生成逻辑,当 effective_input_length > max_batched_tokens 时自动按 max_batched_tokens 切分 prefill。 - 新增默认调度策略 DecodeFirstWithSlack,支持 decode-first 调度,并允许 15% slack 以避免 decode token 占用导致 prefill chunk 无法调度。 - 聚合模式中新增 chunked prefill 轻量级时间模拟,支持已完成 prefill 的请求提前进入 decode,不再要求所有请求完成 prefill 后统一 decode。 - PD 分离模式中 prefill 阶段支持 chunked prefill,decode 阶段保持原有逻辑。 - 优化 latency cache key,使其区分不同的 query_len、seq_len 和并发形态。 - 输出结果新增 effective_input_length、max_batched_tokens、prefill_num_chunks,便于分析 chunked prefill 配置影响。 - 更新 Web UI 参数生成、表单校验、相关文档和单元测试。 ------ ## 📐 Associated Test Results / 关联测试结果 **Please provide the related test results, such as test reports, etc.** **请提供相关测试结果,例如测试报告等。** 以32条 32k请求为例,无chunk改动前: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-prefill-tokens 32000 --log-level info  无chunk改动后: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 32000 --log-level info  结果不变,不影响之前的调度逻辑 chunk为2000: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 2000 --log-level info  chunk为4000: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 4000 --log-level info  chunk为8000: python -m cli.inference.throughput_optimizer Qwen/Qwen3-32B --device ATLAS_800_A2_280T_64G --quantize-linear-action DISABLED --input-length 32000 --output-length 1024 --tp-sizes 8 --compile --batch-range 32 32 --num-devices 8 --max-batched-tokens 4000 --log-level info  从趋势上看,chunk size越小,对tpot越友好;同时chunk 越小,prefill阶段调度越多,ttft会增加,符合预期; 另外,由于开启chunk prefill后,prefill会增加多次计算,导致耗时呈线性增长;可以考虑并行一次性跑完所有切分的prefill,但对资源消耗巨大,考虑在下个PR内提升性能 ------ ## 🌟 Use cases (Optional) / 使用案例(可选) **If this PR introduces a new feature, it is better to list some use cases here and update the documentation.** **如果此拉取请求引入了新功能,最好在此处列出一些用例并更新文档。** ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [x] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 ------ See merge request: Ascend/msmodeling!250 | 24 天前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 27 天前 | ||
| 24 天前 | ||
| 24 天前 | ||
| 24 天前 | ||
| 24 天前 | ||
| 27 天前 | ||
| 27 天前 | ||
| 27 天前 | ||
| 27 天前 | ||
| 27 天前 | ||
| 24 天前 | ||
| 24 天前 | ||
| 24 天前 | ||
| 24 天前 |