| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
docs: 优化tests/amct_ops测试运行说明(#185) Co-authored-by: fujun19<fujun19@hisilicon.com> # message auto-generated for no-merge-commit merge: !268 merge fix/issue-185-svdquant-docs into master docs: 优化tests/amct_ops测试运行说明(#185) Created-by: fujun19 Commit-by: fujun19 Merged-by: cann-robot Description: ## 描述 将 tests/amct_ops 测试说明调整为通用单算子构建/运行模板,避免后续每新增一个算子都要在顶层测试 README 中补一组固定命令。 同时以 SVDQuant 作为需要特殊 SOC 参数的示例,说明 svd_quant 需使用 --soc ascend950 构建,并给出 staging 与 wheel 两种方式下运行 tests.amct_ops.test_svd_quant 的命令。中文和英文配套文档已同步更新。 关联 issue:#185 ## 如何测试 - rg -n "<op_name>|<test_module>|test_svd_quant|--soc ascend950 svd_quant|SVDQuant|ascend950" tests/amct_ops/README.md tests/amct_ops/README_en.md - git diff --check upstream/master..HEAD -- tests/amct_ops/README.md tests/amct_ops/README_en.md - bash -n amct_ops/ops_build.sh 未运行真实 SVDQuant 单元测试;该测试依赖 CANN、NPU 和 ascend950 SVDQuant 自定义算子环境。 ## 文档更新 更新 tests/amct_ops/README.md 和 tests/amct_ops/README_en.md。 ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 代码重构 - [ ] 其他,请描述: See merge request: cann/amct!268 | 27 天前 | |
[Feature] Measure pruning search trials by masking instead of copying the model Co-authored-by: leedongkun30-arch<lee.dongkun30@gmail.com> # message auto-generated for no-merge-commit merge: !258 merge feat/masked-search into master [Feature] Measure pruning search trials by masking instead of copying the model Created-by: leedongkun30-arch Commit-by: leedongkun30-arch Merged-by: cann-robot Description: ## Description An accuracy search ( tolerance= / size_budget=) tried every candidate ratio on a full copy of the model, so a search needed room for two models. That copy is only required by methods that **rewrite weights**; methods that merely select what to keep are now measured in place: the cut is masked into the model, measured, and rolled back. - Dense/CNN: out = Σ_i W[:, i] · x_i, so zeroing x_i at the consumer's input removes channel i's contribution exactly as deleting it would, regardless of the BatchNorm or activation in between. - MoE: the dropped experts' logits go to -inf at the module that produces them, so the router's own forward recomputes its top-k, scores and dispatch from the surviving experts. Equivalence against a real cut is pinned by unit tests across four router families (Mixtral, Qwen3Moe, GraniteMoe, Qwen3.5-MoE incl. the multimodal wrapper). No public interface changes: prune's signature is untouched. BasePruningMethod.supports_masked_trial records which methods qualify — low_variance, variance_channel, activation_count, mass_variance do; reconstruct and output_merge rewrite weights and keep copying, as do searches passing finetune_fn / quant_fn. Measured on Qwen3.6-35B-A3B (34.66B, 64.56 GiB BF16) sharded across **two** Atlas 910B3 cards, tolerance=0.1 on the in-tree autoregressive NLL (calib_nll; exp(NLL) is the walkthrough's Wikitext2-ppl), ratio_grid=(0.1, 0.2, 0.3): | search | outcome | device peak | | --- | --- | --- | | copy | every trial OOMs, no ratio chosen, model unchanged | OOM past 87 GiB | | masked | completes in 52 s, prunes 34.66B -> 24.97B | 67.4 GiB (1.04x weights) | The pruned model (46.5 GiB) fits a single 61 GiB card — the search that produces it now runs on the same two cards that merely hold the model. This also fixes prune_batchnorm2d returning the rebuilt module in training mode: pruning an eval model left its BatchNorms normalising by batch statistics and overwriting the running stats that had just been copied over. The masked-vs-real equivalence test is what exposed it. ## How to Test Prerequisites: torch 2.7.1+cpu (NPU cases skip without torch_npu), transformers for the real-architecture cases (verified on 5.5.4 and 5.15.0). pytest tests/amct_pytorch/test_pruning_simulate.py -q pytest tests/amct_pytorch/test_pruning_real_hf_models.py -q -k "Qwen or RouterFamilies" pytest tests/amct_pytorch/test_pruning_*.py -q - test_pruning_simulate.py — a masked trial and a real prune report the same parameter count and outputs equal up to float reassociation; the model, its config and its router attributes are bit-identical after rollback; the mask demonstrably changes the forward (a no-op mask fails); trials do not contaminate each other; the tolerance search picks the same mid-grid ratio as the copy search under a tolerance calibrated to discriminate. - TestMaskedTrialAcrossRouterFamilies — the equivalence check on every HF top-k router family in reach, each of which hands a different shape downstream. - TestQwen3_5MoeFusedExperts — the A3B architecture end to end: fused experts, non-Linear router, config.text_config sync, cuts below num_experts_per_tok. ## Documentation Updates amct_pytorch/pruning/README.md / README_en.md: the peak-memory note now states which methods still copy and which are measured by masking. No API page changes. ## Type Label - [x] Bug fix - [ ] New feature - [x] Performance optimization - [x] Documentation update - [ ] Code refactoring - [ ] Other, please describe: See merge request: cann/amct!258 | 30 天前 | |
style: 执行 pre-commit 格式化(#161) Co-authored-by: fujun19<fujun19@hisilicon.com> # message auto-generated for no-merge-commit merge: !228 merge chore/precommit-format-161 into master style: 执行 pre-commit 格式化(#161) Created-by: fujun19 Commit-by: fujun19 Merged-by: cann-robot Description: ## 描述 按照 issue #161 提到的 pre-commit 本地格式化方法,对仓内 tracked C/C++ 和 Python 文件执行格式化。本 PR 仅包含 clang-format / ruff-format 自动格式化结果,不包含 ruff 历史例外配置。 ## 如何测试 - pre-commit run clang-format --all-files:Passed - pre-commit run ruff-format --all-files:Passed - 未运行完整 pre-commit run --all-files;ruff-check 的历史例外按要求未纳入本次提交。 ## 文档更新 无。 ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 代码重构 - [x] 其他,请描述:pre-commit 格式化 See merge request: cann/amct!228 | 1 个月前 | |
fix:修复trust remote code默认为True的安全性问题 以及去除PureWindowsPath带来的判断错误bug Co-authored-by: SwaggyAlex<zhangyi601@huawei.com> # message auto-generated for no-merge-commit merge: !266 merge master into master fix:修复trust remote code默认为True的安全性问题 以及去除PureWindowsPath带来的判断错误bug Created-by: SwaggyAlex Commit-by: SwaggyAlex Merged-by: cann-robot Description: ## 描述 ### 1. trust_remote_code 参数调整 新增统一的 --trust_remote_code 命令行开关,使用 argparse 的 action="store_true": - 默认值为 False,未传入该开关时不信任且不执行模型仓中的自定义代码。 - 在命令中传入 --trust_remote_code 后,该参数值为 True。 - 该开关不接收额外参数,因此 --trust_remote_code True、--trust_remote_code False 等写法会被 argparse 拒绝。 BaseModel 将该参数统一传递给 HuggingFace 的配置、分词器和模型加载接口,包括: - AutoConfig.from_pretrained - AutoTokenizer.from_pretrained - AutoModelForCausalLM.from_pretrained - AutoModelForCausalLM.from_config 当普通模型未传入 --trust_remote_code 时,程序仅记录 Warning,说明部分模型可能需要该参数才能加载自定义模型代码,不会阻止模型继续运行。 对于依赖仓内本地自定义模型代码的 DeepSeek V3.2 和 DeepSeek V4,在模型初始化阶段进行强制校验。如果未传入 --trust_remote_code,直接抛出 ValueError,提示当前模型需要通过该开关允许加载自定义代码,避免模型进入后续流程后再因配置或模型类型不匹配而失败。 ### 2. safetensors 权重路径校验调整 新增统一的 safetensors 文件收集与白名单校验逻辑。 #### 文件白名单收集 初始化权重加载流程时,扫描模型目录,收集满足以下条件的文件: - 文件必须位于模型目录的直接子层级,不递归收集子目录中的文件。 - 文件必须是普通文件,不接受目录。 - 不跟随符号链接,避免通过软链接访问模型目录外的文件。 - 文件后缀必须严格为 .safetensors。 收集结果以 frozenset 保存,并通过 safetensors_files 字段进行懒加载缓存,供同一模型加载过程重复使用。如果模型路径不是目录,或者目录下不存在符合要求的 .safetensors 文件,立即报错。 #### 权重路径解析 resolve_safetensors_path 接收模型路径、待加载文件名和已收集的文件白名单,并执行以下校验: - 文件名必须是非空字符串。 - 文件名不得包含 NUL 字符。 - 权重文件后缀必须为 .safetensors。 - 相对路径以模型目录为基准解析;绝对路径直接解析。 - 解析后的真实路径必须存在于预先收集的模型目录文件白名单中。 因此,即使传入的文件名包含 ../、绝对路径或其他路径跳转形式,只要最终文件不在模型目录白名单中,就会被拒绝。合法的绝对路径和相对路径在解析后指向白名单内的同一个权重文件时均可正常加载。 #### 权重索引校验 对于 model.safetensors.index.json 中的 weight_map,新增统一校验: - weight_map 必须为字典。 - 权重名称必须是非空字符串。 - 每个权重分片路径都必须通过 .safetensors 后缀和文件白名单校验。 该校验逻辑已接入通用模型权重加载、DeepSeek V4 分片加载以及 deploy 导出流程,防止从模型目录之外读取未授权文件。 ## 如何测试 已安装本项目所需依赖的环境下,在仓库根目录执行: bash python -m pytest tests/unit_test/cli/test_llm_args.py python -m pytest tests/unit_test/common/models/llm/common/test_weight_path_validation.py python -m pytest tests/unit_test/common/models/llm/common/test_base.py python -m pytest tests/unit_test/common/models/llm/deepseek/test_deepseek_v4.py python -m pytest tests/unit_test/quantization/test_dtypes.py ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [x] Bug修复 - [x] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 代码重构 - [ ] 其他,请描述: See merge request: cann/amct!266 | 26 天前 | |
build: use cann third party protobuf Co-authored-by: fujun19<fujun19@hisilicon.com> # message auto-generated for no-merge-commit merge: !124 merge fix/use-add-cann-third-party into master build: use cann third party protobuf Created-by: fujun19 Commit-by: fujun19 Merged-by: cann-robot Description: 关联 Issue:#121 ## 描述 将本仓 protobuf 三方依赖迁移到 cann-cmake 统一入口: - 使用 add_cann_third_party(protobuf) 替换本地 cmake/third_party/protobuf.cmake。 - 开启 ENABLE_OPEN_SRC,确保统一 protobuf 脚本创建 host_protoc、ascend_protobuf_static 等目标。 - 将 proto 编译路径从旧的 build/protobuf_host/bin/protoc 切换为 $<TARGET_FILE:host_protoc>。 - 删除迁移后不再需要的本地 protobuf 脚本和 patch 文件。 ## 如何测试 - git diff --check - cmake -S . -B build_add_cann_third_party_default_check -DENABLE_TEST=OFF - cmake -S . -B build_add_cann_third_party_test_check -DENABLE_TEST=ON 说明:ENABLE_TEST=ON 配置过程中当前环境会打印已有的 torch_npu 后端符号错误 traceback,但 CMake 退出码为 0 并完成配置生成。 ## 文档更新 不涉及文档更新。 ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 代码重构 - [x] 其他,请描述:构建依赖迁移 See merge request: cann/amct!124 | 3 个月前 | |
[feat]: add amct llm Co-authored-by: w00852777<wanghui432@huawei.com> Co-authored-by: fujun19<fujun19@hisilicon.com> Co-authored-by: SwaggyAlex<zhangyi601@huawei.com> Co-authored-by: li_ting<liting73@hisilicon.com> # message auto-generated for no-merge-commit merge: !102 merge master into master [feat]: add amct llm Created-by: fujun19 Commit-by: SwaggyAlex;fujun19;wuranxx;li_ting;l00968832;lianghengyi;sophia1213;Hengyi Liang;w00852777 Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> 本 PR 新增LLM量化工具模块,用于面向大语言模型的后训练量化、精度评估和部署产物导出,主要包括: 1. 新增并整理 LLM 量化工作流能力 - 新增 amct_pytorch/workflows 与 amct_pytorch/cli/llm,覆盖 PTQ、PTQ 数据提取、部署导出、评估等流程。 - 新增通用配置解析、数据处理、模型适配、量化应用、优化器等公共模块。 - 补充 Qwen、LongCat、DeepSeek、GLM 等 LLM 模型适配与量化模块。 2. 调整 AMCT PyTorch 包结构 - 引入 algorithms、common、quantization、workflows 等更清晰的模块划分。 - 将 classic 图量化相关实现收敛到 amct_pytorch/classic/graph_based,保持历史能力可用。 - 修正安装包数据路径,确保 classic graph-based 相关 proto、so、配置等资源能正确打包。 3. 完善构建与测试能力 - build.sh -u 默认开启覆盖率采集。 - 新增 pyproject.toml,统一 pytest 与 coverage 配置。 - 调整 CMake UT 入口,使用 pytest 执行 tests/unit_test 与 tests/amct_pytorch。 - 大幅补充算法、配置、LLM 模型适配、量化模块、workflow 等单元测试。 4. 更新依赖、文档和样例 - 补充 LLM 相关运行依赖,如 datasets、accelerate、compressed_tensors、torchao、einops 等。 - 更新 README、算法说明、LLM 文档、快速安装和 PTQ 配置说明。 - 新增/整理一站式平台样例,包括 Qwen3.6-MoE、DeepSeek-V4 Flash,以及 PTQ、部署、评估、数据提取脚本。 - 将算法样例统一整理到 examples/algorithms 目录,提升样例可发现性和可维护性。 ## 如何测试 <!--描述测试此改动的步骤和前提条件。--> 已进行以下验证: 1. UT 与覆盖率验证 bash build.sh -u 结果: 1911 passed, 2 skipped, 1 xfailed, 371 warnings Coverage XML written to build/coverage.xml ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> - 更新根目录 README.md,补充 AMCT PyTorch 当前包结构、核心能力、一站式平台快速体验入口,并修正 amct_ops 文档链接。 - 更新 docs/AMCT_Pytorch_LLM.md,补充 LLM 量化流程说明,包括 PTQ 数据提取、PTQ 执行、部署导出和评估流程。 - 更新 docs/algorithm_brief.md,同步当前支持的量化算法说明。 - 更新 docs/context/ptq_config_param.md,修正配置示例引用路径,避免文档中的样例路径不可用。 - 更新 docs/quick_install.md 与 docs/README.md,同步依赖安装、构建验证和特性说明。 - 更新 examples/README.md,重新整理样例入口,明确算法样例与模型端到端样例的使用路径。 - 新增/完善 Qwen3.6-MoE 与 DeepSeek-V4 Flash 一站式平台样例文档,降低用户在 Atlas A3 环境中完成 NPU 推理体验的上手成本。 ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 代码重构 - [ ] 其他,请描述: See merge request: cann/amct!102 | 3 个月前 | |
[feat]: add amct llm Co-authored-by: w00852777<wanghui432@huawei.com> Co-authored-by: fujun19<fujun19@hisilicon.com> Co-authored-by: SwaggyAlex<zhangyi601@huawei.com> Co-authored-by: li_ting<liting73@hisilicon.com> # message auto-generated for no-merge-commit merge: !102 merge master into master [feat]: add amct llm Created-by: fujun19 Commit-by: SwaggyAlex;fujun19;wuranxx;li_ting;l00968832;lianghengyi;sophia1213;Hengyi Liang;w00852777 Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> 本 PR 新增LLM量化工具模块,用于面向大语言模型的后训练量化、精度评估和部署产物导出,主要包括: 1. 新增并整理 LLM 量化工作流能力 - 新增 amct_pytorch/workflows 与 amct_pytorch/cli/llm,覆盖 PTQ、PTQ 数据提取、部署导出、评估等流程。 - 新增通用配置解析、数据处理、模型适配、量化应用、优化器等公共模块。 - 补充 Qwen、LongCat、DeepSeek、GLM 等 LLM 模型适配与量化模块。 2. 调整 AMCT PyTorch 包结构 - 引入 algorithms、common、quantization、workflows 等更清晰的模块划分。 - 将 classic 图量化相关实现收敛到 amct_pytorch/classic/graph_based,保持历史能力可用。 - 修正安装包数据路径,确保 classic graph-based 相关 proto、so、配置等资源能正确打包。 3. 完善构建与测试能力 - build.sh -u 默认开启覆盖率采集。 - 新增 pyproject.toml,统一 pytest 与 coverage 配置。 - 调整 CMake UT 入口,使用 pytest 执行 tests/unit_test 与 tests/amct_pytorch。 - 大幅补充算法、配置、LLM 模型适配、量化模块、workflow 等单元测试。 4. 更新依赖、文档和样例 - 补充 LLM 相关运行依赖,如 datasets、accelerate、compressed_tensors、torchao、einops 等。 - 更新 README、算法说明、LLM 文档、快速安装和 PTQ 配置说明。 - 新增/整理一站式平台样例,包括 Qwen3.6-MoE、DeepSeek-V4 Flash,以及 PTQ、部署、评估、数据提取脚本。 - 将算法样例统一整理到 examples/algorithms 目录,提升样例可发现性和可维护性。 ## 如何测试 <!--描述测试此改动的步骤和前提条件。--> 已进行以下验证: 1. UT 与覆盖率验证 bash build.sh -u 结果: 1911 passed, 2 skipped, 1 xfailed, 371 warnings Coverage XML written to build/coverage.xml ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> - 更新根目录 README.md,补充 AMCT PyTorch 当前包结构、核心能力、一站式平台快速体验入口,并修正 amct_ops 文档链接。 - 更新 docs/AMCT_Pytorch_LLM.md,补充 LLM 量化流程说明,包括 PTQ 数据提取、PTQ 执行、部署导出和评估流程。 - 更新 docs/algorithm_brief.md,同步当前支持的量化算法说明。 - 更新 docs/context/ptq_config_param.md,修正配置示例引用路径,避免文档中的样例路径不可用。 - 更新 docs/quick_install.md 与 docs/README.md,同步依赖安装、构建验证和特性说明。 - 更新 examples/README.md,重新整理样例入口,明确算法样例与模型端到端样例的使用路径。 - 新增/完善 Qwen3.6-MoE 与 DeepSeek-V4 Flash 一站式平台样例文档,降低用户在 Atlas A3 环境中完成 NPU 推理体验的上手成本。 ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 代码重构 - [ ] 其他,请描述: See merge request: cann/amct!102 | 3 个月前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 27 天前 | ||
| 30 天前 | ||
| 1 个月前 | ||
| 26 天前 | ||
| 3 个月前 | ||
| 3 个月前 | ||
| 3 个月前 |