| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
feat: 新增 HiGPTQ 校准算法支持 Co-authored-by: zhangj1an<lanzhao944@gmail.com> Co-authored-by: zhangj1an<jianmusings@gmail.com> # message auto-generated for no-merge-commit merge: !252 merge higptq_cli into master feat: 新增 HiGPTQ 校准算法支持 Created-by: nancycyzl Commit-by: zl;Zhang Jian;ZL_PC;zhangj1an Merged-by: cann-robot Description: ## Description 本提议新增 HiGPTQ,把经典 GPTQ 的 Hessian 累积 + Cholesky 闭式求解思路引入 LLM PTQ 框架,并针对 HiFloat4(HiF4) 这个块浮点格式做适配。 AMCT PTQ 框架( amct_pytorch.ptq / LlmPtqWorkflow) 现有的算法(LAC、LWC、AutoRound、OmniQuant、FlatQuant)都是"可微分/可迭代"一类,以 weight/activation/structure 为 target 插件式串进 QuantLinear 正向传播,靠 BlockwiseSolver 反向传播+优化器多轮迭代求解。GPTQ / HiGPTQ 这种单次前向、闭式求解的路径,没有可学习参数,求解方式和上述算法不同。但只需要把求解过程中的中间结果罗盘,就可以复用框架现有的 BlockwiseSolver 和插件机制。 本提议延续框架现有的结构(CLI → LlmPtqWorkflow → Blockwise Solver → 具体算法),新增一个模块: - GPTQuant(amct_pytorch/algorithms/quant/gptq.py):继承 QuantAlgorithmBase,实现基于 INT 和 HiF4 的 GPTQ 算法。 ## How to Test 1. Unit test python -m pytest tests/unit_test/algorithms/test_higptq.py -v 结果: (amct) [ma-user amct]$python -m pytest tests/unit_test/algorithms/test_higptq.py -v ==================================================================================================== test session starts ===================================================================================================== platform linux -- Python 3.11.15, pytest-9.1.1, pluggy-1.6.0 -- /home/ma-user/.conda/envs/amct/bin/python cachedir: .pytest_cache rootdir: /home/ma-user/work/z84448474/amct configfile: pyproject.toml plugins: xdist-3.6.1, typeguard-4.5.2, anyio-4.14.1, env-1.7.0 collected 8 items tests/unit_test/algorithms/test_higptq.py::test_higptq_is_registered_as_a_calibrate_solver_algo PASSED [ 12%] tests/unit_test/algorithms/test_higptq.py::test_cal_scale_offset_static_has_no_external_quant_factors PASSED [ 25%] tests/unit_test/algorithms/test_higptq.py::test_cal_quant_weight_group_delegates_to_hifloat4_fake_quant PASSED [ 37%] tests/unit_test/algorithms/test_higptq.py::test_single_group_optimization_matches_direct_hifloat4_quant PASSED [ 50%] tests/unit_test/algorithms/test_higptq.py::test_dead_hessian_column_is_zeroed_before_quantization PASSED [ 62%] tests/unit_test/algorithms/test_higptq.py::test_optimization_handles_column_counts_not_aligned_to_group_or_block_size PASSED [ 75%] tests/unit_test/algorithms/test_higptq.py::test_fake_quant_forward_quantizes_once_and_reuses_cache PASSED [ 87%] tests/unit_test/algorithms/test_higptq.py::test_forward_updates_weight_after_batch_num_then_switches_to_fake_quant PASSED [100%] ===================================================================================================== 8 passed in 1.47s ====================================================================================================== 2. 端到端测试 a) 保存激活值 通过 amct_pytorch.extract_ptq_data 保存激活值,需对不同类型层分别运行,比如 --quant_target mlp 或者 --quant_target attn_linear python -m amct_pytorch.extract_ptq_data \ --model /home/ma-user/work/z84448474/models/Qwen3.5-9B \ --model_name qwen3_5 \ --seq_len 4096 \ --granularity block \ --device npu:0 \ --data_dir ptq_data/qwen3_5/mlp \ --quant_target mlp b) 运行 HiGPTQ 算法 需对不同类型层分别运行,比如 --quant_target mlp 或者 --quant_target attn_linear,以及配置对应的 --data_dir python -m amct_pytorch.ptq \ --model /home/ma-user/work/z84448474/models/Qwen3.5-9B \ --model_name qwen3_5 \ --seq_len 4096 \ --granularity block \ --device npu:0 \ --data_dir /data/z84448474/z84448474/ptq_data/qwen3_5/mlp \ --quant_dtype hifp \ --algos gptq \ --bit_config amct_pytorch/configs/hifloat4.yaml \ --quant_target mlp \ --moe_mlp_param_dir ptq_result/ptq_params/qwen3_5/mlp \ --output_dir ptq_result/ c) 进行 PPL 测评 配置 --attn_linear_param_dir 和 --moe_mlp_param_dir 等路径(第二步的结果) python -m amct_pytorch.eval \ --model /home/ma-user/work/z84448474/models/Qwen3.5-9B \ --model_name qwen3_5 \ --seq_len 4096 \ --granularity block \ --device npu:0 \ --eval_mode quant \ --quant_target mlp attn-linear \ --quant_dtype hifp \ --bit_config amct_pytorch/configs/hifloat4.yaml \ --attn_linear_param_dir ptq_result/ptq_params/qwen3_5/attn-linear \ --moe_mlp_param_dir ptq_result/ptq_params/qwen3_5/mlp 测试结果(PPL对比): HiF4 直转 (w4a16):9.948 HiGPTQ 校准后:8.401 ## Type Label <!-- [x] indicates selected --> - [ ] Bug fix - [x] New feature - [ ] Performance optimization - [ ] Documentation update - [ ] Code refactoring - [ ] Other, please describe: See merge request: cann/amct!252 | 20 天前 | |
fix: 修复 BCP 参数校验异常文案(#191) Co-authored-by: zhengpeiyang<zhengpeiyang@huawei.com> # message auto-generated for no-merge-commit merge: !298 merge fix/bcp-error-message into master fix: 修复 BCP 参数校验异常文案(#191) Created-by: zhengpeiyang Commit-by: zhengpeiyang Merged-by: cann-robot Description: ## 描述 本 PR 修复 BCP 剪枝参数校验中的错误异常文案。 该问题由日志规范复扫发现:上次扫描遗漏了以下位置中存在的问题: - amct_pytorch/classic/graph_based/amct_pytorch/custom_op/bcp/bcp_op.py:38 - amct_pytorch/classic/graph_based/amct_pytorch/custom_op/bcp/bcp_op.py:72 原异常文案包含日志规范黑名单词 Inner Error,且错误描述不够具体。 本次修改: - 将两处异常文案改为明确的英文参数校验失败描述; - 更新对应单元测试的异常匹配内容; - 这是对上次日志规范扫描遗漏问题的复扫补充修复; - 关联 Issue:#191(复扫遗漏补充修复)。 ## 如何测试 已执行 Python 语法检查和 git diff --check,均通过。 尝试执行目标单元测试: bash python3 -m pytest -q tests/amct_pytorch/testcase_python/custom_op/test_bcp.py -k "tensor_and_prune_axis_counts_must_match or channel_count_must_cover_prune_groups or prune_axis_must_be_within_tensor_rank" ## 文档更新 无。 ## 类型标签 - [x] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 代码重构 - [ ] 其他,请描述: See merge request: cann/amct!298 | 7 天前 | |
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 | 13 天前 | |
对既有MXFP8格式的模型权重转为BF16格式工具的功能补充 Co-authored-by: zhangj1an<jianmusings@gmail.com> Co-authored-by: Wujie_Fu<wujie_fu@u.nus.edu> # message auto-generated for no-merge-commit merge: !287 merge mxfp8_to_hif4 into master 对既有MXFP8格式的模型权重转为BF16格式工具的功能补充 Created-by: Wujie_Fu Commit-by: zhangj1an;Wujie_Fu Merged-by: cann-robot Description: ## 描述 主分支上目前暂不支持对于OCP格式的MXFP8解码到BF16功能。原因是代码会把uint8/int8的scale当浮点来还原(就是把scale直接转为bf16),但其实里面存储的是指数幂,需要用2^scale来还原。(参见 https://gitcode.com/cann/amct/issues/190) 这份PR按照OCP MXFP8( https://www.opencompute.org/documents/ocp-8-bit-floating-point-specification-ofp8-revision-1-0-2023-12-01-pdf-1 )的标准支持了解码功能。当输入的模型scale dtype是uint8/int8,而且weight dtype是float8_e4m3fn或者float8_e5m2时,就会检测为MXFP8格式,并路由到mxfp_impl.py做对应解码。经过调研,目前社区中没有其他的MXFP8格式需要支持。 ## 如何测试 首先去HF下载一份qwen3.5-9b的mxfp8模型权重, Lexter3000/Qwen3.5_9b_mxfp8。另外也下载好原版的BF16模型, Qwen/Qwen3.5-9B。 然后测试以下四种格式的精度: mxfp8 bf16 mxfp8反量化为bf16 mxfp8伪量化为hif4。在lm_eval框架上,测试结果显示mxfp8版本与mxfp8转bf16精度一致,符合预期。 | 任务 | bf16 | mxfp8 | mxfp8tobf16 | mxfp8tohif4 | |---|---|---|---|---| | boolq (acc) | 89.08 | 74.40 | 74.40 | 78.04 | | arc_easy (acc_norm) | 74.20 | 71.68 | 71.68 | 73.70 | | copa (acc) | 89.00 | 87.00 | 87.00 | 90.00 | | arc_challenge (acc_norm) | 55.89 | 53.92 | 53.92 | 54.78 | | piqa (acc_norm) | 80.09 | 80.20 | 80.20 | 78.62 | | sciq (acc_norm) | 96.00 | 93.90 | 93.90 | 94.10 | 可以用以下命令进行格式转换, ### 4.2 MXFP8 → bf16(tensorwise deploy) bash cd amct python -m amct_pytorch.cli.llm.deploy \ --granularity tensor --model_name qwen3_5 \ --model /<model_dir>/Qwen3.5-9B-MXFP8 \ --output_dir /<model_dir>/Qwen3.5-9B-mxfp8_to_bf16 ### 4.3 MXFP8 → HiF4 W4A4(两步 deploy) bash # step 1: mxfp8 -> bf16(和上一步相同) # step 2: blockwise bf16 -> hif4 python -m amct_pytorch.cli.llm.deploy \ --granularity block --model_name qwen3_5 \ --model /<model_dir>/Qwen3.5-9B-mxfp8_to_bf16 \ --output_dir /<model_dir>/Qwen3.5-9B-mxfp8_to_hif4 \ --eval_mode quant --quant_dtype hifp \ --quant_target mlp attn-linear \ --bit_config amct_pytorch/configs/w4a4.yaml ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 代码重构 - [ ] 其他,请描述: See merge request: cann/amct!287 | 6 天前 | |
[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 个月前 | |
fix: 完成日志易用性整改(#191) Co-authored-by: zhengpeiyang<zhengpeiyang@huawei.com> # message auto-generated for no-merge-commit merge: !284 merge fix/amct-log-usability-all into master fix: 完成日志易用性整改(#191) Created-by: zhengpeiyang Commit-by: zhengpeiyang Merged-by: cann-robot Description: ## 描述 本 PR 汇总统一修复日志文案英文规范、拼写错误、英文语法问题及日志级别错配问题。 关联 Issue:#191 ## 如何测试 已通过本地 pre-commit 检查。代码变更为日志文案、拼写、语法和日志级别调整,不改变业务逻辑。 ## 文档更新 无。 ## 类型标签 - [x] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 代码重构 - [ ] 其他,请描述 See merge request: cann/amct!284 | 10 天前 | |
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 个月前 | |
[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 | 17 天前 | |
对既有MXFP8格式的模型权重转为BF16格式工具的功能补充 Co-authored-by: zhangj1an<jianmusings@gmail.com> Co-authored-by: Wujie_Fu<wujie_fu@u.nus.edu> # message auto-generated for no-merge-commit merge: !287 merge mxfp8_to_hif4 into master 对既有MXFP8格式的模型权重转为BF16格式工具的功能补充 Created-by: Wujie_Fu Commit-by: zhangj1an;Wujie_Fu Merged-by: cann-robot Description: ## 描述 主分支上目前暂不支持对于OCP格式的MXFP8解码到BF16功能。原因是代码会把uint8/int8的scale当浮点来还原(就是把scale直接转为bf16),但其实里面存储的是指数幂,需要用2^scale来还原。(参见 https://gitcode.com/cann/amct/issues/190) 这份PR按照OCP MXFP8( https://www.opencompute.org/documents/ocp-8-bit-floating-point-specification-ofp8-revision-1-0-2023-12-01-pdf-1 )的标准支持了解码功能。当输入的模型scale dtype是uint8/int8,而且weight dtype是float8_e4m3fn或者float8_e5m2时,就会检测为MXFP8格式,并路由到mxfp_impl.py做对应解码。经过调研,目前社区中没有其他的MXFP8格式需要支持。 ## 如何测试 首先去HF下载一份qwen3.5-9b的mxfp8模型权重, Lexter3000/Qwen3.5_9b_mxfp8。另外也下载好原版的BF16模型, Qwen/Qwen3.5-9B。 然后测试以下四种格式的精度: mxfp8 bf16 mxfp8反量化为bf16 mxfp8伪量化为hif4。在lm_eval框架上,测试结果显示mxfp8版本与mxfp8转bf16精度一致,符合预期。 | 任务 | bf16 | mxfp8 | mxfp8tobf16 | mxfp8tohif4 | |---|---|---|---|---| | boolq (acc) | 89.08 | 74.40 | 74.40 | 78.04 | | arc_easy (acc_norm) | 74.20 | 71.68 | 71.68 | 73.70 | | copa (acc) | 89.00 | 87.00 | 87.00 | 90.00 | | arc_challenge (acc_norm) | 55.89 | 53.92 | 53.92 | 54.78 | | piqa (acc_norm) | 80.09 | 80.20 | 80.20 | 78.62 | | sciq (acc_norm) | 96.00 | 93.90 | 93.90 | 94.10 | 可以用以下命令进行格式转换, ### 4.2 MXFP8 → bf16(tensorwise deploy) bash cd amct python -m amct_pytorch.cli.llm.deploy \ --granularity tensor --model_name qwen3_5 \ --model /<model_dir>/Qwen3.5-9B-MXFP8 \ --output_dir /<model_dir>/Qwen3.5-9B-mxfp8_to_bf16 ### 4.3 MXFP8 → HiF4 W4A4(两步 deploy) bash # step 1: mxfp8 -> bf16(和上一步相同) # step 2: blockwise bf16 -> hif4 python -m amct_pytorch.cli.llm.deploy \ --granularity block --model_name qwen3_5 \ --model /<model_dir>/Qwen3.5-9B-mxfp8_to_bf16 \ --output_dir /<model_dir>/Qwen3.5-9B-mxfp8_to_hif4 \ --eval_mode quant --quant_dtype hifp \ --quant_target mlp attn-linear \ --bit_config amct_pytorch/configs/w4a4.yaml ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 代码重构 - [ ] 其他,请描述: See merge request: cann/amct!287 | 6 天前 | |
[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 个月前 | |
fix: 接通文档承诺的公开导入路径,保证文档示例可直接运行 Co-authored-by: fujun19<fujun19@hisilicon.com> # message auto-generated for no-merge-commit merge: !162 merge fix/doc-auto-calibration-import into master fix: 接通文档承诺的公开导入路径,保证文档示例可直接运行 Created-by: fujun19 Commit-by: fujun19 Merged-by: cann-robot Description: ## 描述 文档(README + 各 API 页)给出的多条公开导入路径在代码中并未接通:真实实现深埋在 amct_pytorch/classic/graph_based/amct_pytorch/... 下,而文档给的是简短公开路径,用户照文档 import 即报 ModuleNotFoundError。 以**文档用法为准**补建公开转发模块(均指向健康实现,不改动任何在用逻辑)。每条修复对应的文档出处如下: ### 1. amct_pytorch.common.auto_calibration(AutoCalibrationEvaluatorBase 等 6 个基类) 新建 amct_pytorch/common/auto_calibration/,接通以下文档用法: - docs/README.md:114 —— from amct_pytorch.common.auto_calibration import AutoCalibrationEvaluatorBase - docs/zh/api/accuracy_based_auto_calibration.md:140 —— 同上(自定义 evaluator 继承基类做基于精度的自动量化) ### 2. amct_pytorch.nn.module.quantization.*(5 个 QAT 类) 新建 amct_pytorch/nn/module/quantization/ 三层包 + 5 个转发子模块,接通: - docs/README.md:641-642, 695 —— Conv2dQAT / LinearQAT - docs/zh/api/Conv2dQAT.md:23,29,223,235 —— Conv2dQAT - docs/zh/api/Conv3dQAT.md:25,31,227 —— Conv3dQAT - docs/zh/api/ConvTranspose2dQAT.md —— ConvTranspose2dQAT - docs/zh/api/LinearQAT.md —— LinearQAT - docs/zh/api/QuantCalibrationOp.md —— QuantCalibrationOp ### 3. amct_pytorch.tensor_decompose(auto_decomposition / decompose_network) 新建 amct_pytorch/tensor_decompose/,接通: - docs/README.md:1912,1924,1937 —— auto_decomposition / decompose_network - docs/zh/api/auto_decomposition.md:71 —— from amct_pytorch.tensor_decompose import auto_decomposition - docs/zh/api/decompose_network.md:68 —— from amct_pytorch.tensor_decompose import decompose_network ### 4. amct_pytorch.common.auto_channel_prune(SensitivityBase / SearchChannelBase) 新建 amct_pytorch/common/auto_channel_prune/ 指向健康实现,并修正 README 笔误: - docs/README.md:1023 —— amct.common.auto_channel_prune.sensitivity_base → amct_pytorch.common.auto_channel_prune.sensitivity_base(包名 amct→amct_pytorch) - docs/README.md:1040 —— amct.common.auto_prune.search_channel_base → amct_pytorch.common.auto_channel_prune.search_channel_base(包名修正 + 目录名 auto_prune→auto_channel_prune) - docs/README.md:1037 —— prose 中默认实现路径 auto_prune → auto_channel_prune 同步修正 ## 如何测试 隔离环境(torch 2.7.1 + NPU)实测: - 文档全部 10 条 amct_pytorch 导入语句逐条按原文执行通过 - 顶层 25 个 amct.* API 仍全部可达(新增包未破坏现有导入) - setuptools.find_packages() 可发现 6 个新建转发包,打包进 wheel 不会遗漏 ## 文档更新 修正 docs/README.md:amct→amct_pytorch、auto_prune→auto_channel_prune(共 3 处,含 1 处 prose 路径)。其余 API 页(accuracy_based_auto_calibration / Conv2dQAT / Conv3dQAT / ConvTranspose2dQAT / LinearQAT / QuantCalibrationOp / auto_decomposition / decompose_network)一字未改,靠新增转发模块接通。 ## 类型标签 - [x] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 代码重构 - [ ] 其他,请描述: See merge request: cann/amct!162 | 2 个月前 | |
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 | 13 天前 | |
ofmr/hif8/fp8/fp4/mx Co-authored-by: RQL7<renqilin2@h-partners.com> # message auto-generated for no-merge-commit merge: !20 merge master into master ofmr/hif8/fp8/fp4/mx Created-by: RQL7 Commit-by: RQL7 Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> 支持OFMR算法,支持HIF8/FP8/FP4/MXFP8/MXFP4量化类型 ## 如何测试 <!--描述测试此改动的步骤和前提条件。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 代码重构 - [ ] 其他,请描述: See merge request: cann/amct!20 | 6 个月前 | |
feat: 新增 --experimental 构建选项以打包实验特性代码 Co-authored-by: fujun19<fujun19@hisilicon.com> # message auto-generated for no-merge-commit merge: !167 merge worktree-feat+experimental-pkg-option into master feat: 新增 --experimental 构建选项以打包实验特性代码 Created-by: fujun19 Commit-by: fujun19 Merged-by: cann-robot Description: ## 描述 默认的 --pkg / --torch 构建排除 amct_pytorch/experimental/ 目录,新增 --experimental 标志,使用时将实验特性纳入分发包。 用法示例: bash bash build.sh --torch --experimental bash build.sh --pkg --experimental ## 如何测试 - bash build.sh --help 确认 --experimental 选项出现在帮助输出中 - bash build.sh --torch 产物中不含 amct_pytorch/experimental - bash build.sh --torch --experimental 产物中包含 amct_pytorch/experimental - ruff check / bash -n 语法检查通过,CodeArts Check 0 defects ## 文档更新 - AGENTS.md:补充 --experimental 构建示例 - examples/README.md / README_en.md:FlatQuant 标注实验特性,说明需要 --experimental 构建 - examples/algorithms/flatquant/README_CN.md / README_en.md:顶部加实验特性前置说明 ## 类型标签 - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 代码重构 - [ ] 其他,请描述: See merge request: cann/amct!167 | 2 个月前 | |
[Feature] Added structured pruning (amct_pytorch.pruning) Co-authored-by: leedongkun30-arch<lee.dongkun30@gmail.com> # message auto-generated for no-merge-commit merge: !140 merge feat/pruning into master [Feature] Added structured pruning (amct_pytorch.pruning) Created-by: leedongkun30-arch Commit-by: leedongkun30-arch Merged-by: cann-robot Description: ## 描述 新增 eager 模式**结构化剪枝**子系统 amct_pytorch.pruning,接口风格与 amct.quantize 对齐:对已实例化并加载权重的 torch.nn.Module 原地剪枝。覆盖三个目标域——**dense FFN 中间维 / CNN 通道 / MoE 专家**,仅剪枝“生产者↔消费者接口可验证”的维度,其余保守跳过(注意力投影、残差宽度等自动排除)。 改动为**增量式**:仅在 amct_pytorch/__init__.py 中以 PEP 562 惰性方式暴露剪枝入口,不修改既有量化代码;与 classic/graph_based 剪枝器共存,并复用其精度抽象 AutoCalibrationEvaluatorBase,使 prune→quantize 在同一预算下串联。 公开接口(__all__,与量化 1:1 对齐): - amct.prune(model, config=None, *, data, tolerance, evaluator, size_budget, finetune_fn, report) —— 原地剪枝,返回 None;可选传入 report=PruneReport() 就地收集统计(不保留任何进程级状态)。 - amct.accuracy_based_auto_prune(...) —— 按可接受精度损失自动搜索并应用满足容差的最大剪枝率,返回 AutoTuneResult,对应量化侧 accuracy_based_auto_calibration。 - 预定义配置 *_PRUNE_CFG:CNN_RECONSTRUCT / CNN_VARIANCE / DENSE_LOWVAR / FULL_STRUCTURED / MOE_MASSVAR / MOE_OUTPUT_MERGE / SENSITIVITY_ALLOC。 size_budget_prune / prune_finetune / prune_diagnose 及菜单配置为高级接口,可从 amct_pytorch.pruning 导入,不进入 __all__。剪枝与量化为正交压缩维度:先 prune 改变形状,再 amct.quantize / amct.convert。 ### 实测参考 在 16 个从零训练模型(CNN@MNIST / Dense-LM·MoE-LM@WikiText)与真实预训练 HF 模型上测得,供评审参考: - **CNN 输出保持重建**:训练后 MNIST CNN @0.3,naive variance_channel 0.343 vs reconstruct 0.574(参数量相同)。 - **Dense-LM 1% 预算空间**:无 finetune ≈0%;单遍 finetune(lr 1e-5 + warmup)后中位 27%(最高 61%)。真实 MoE(granite-1b-a400m)同样需要 finetune(≈0% → 17%)。 - **MoE 专家判据依赖路由深度**:全局 variance 劣于 mass,仅深层用 variance(boundary=K)在多专家路由上胜过 mass(OLMoE held-ppl 46.9→35.3);小专家路由(granite,32 专家)下菜单守卫正确回退到 mass。 - **敏感度分配依赖深度**:浅层网络(<10 层)6/6 胜,深层(≥10 层)4/19;guard='calib_nll' 在更差时回退均匀分配。 - **prune→int8 串联**:经恢复菜单剪枝的 SmolLM-135M 走完整 prune→int8→convert 流水线,ppl 1.649 → 剪枝后 1.699 → 叠加 int8 1.704。 ## 如何测试 本地运行单元测试: python -m pytest tests/amct_pytorch/test_pruning_*.py 覆盖核心剪枝、容差自动搜索、跨层敏感度分配、尺寸预算模式、MoE 输出合并、prune→quantize 串联,以及真实 HF 模型(Mixtral / Qwen3Moe / GraniteMoe / DeepseekV3 / Ernie4_5_Moe 等),全部通过。 ## 文档更新 - 新增 docs/zh/api/:prune.md、accuracy_based_auto_prune.md、size_budget_prune.md、prune_finetune.md、prune_diagnose.md、pruning_configs.md,并在 docs/zh/api/README.md 索引中登记。 - 新增示例 examples/algorithms/pruning/(dense / CNN / MoE)。 - amct_pytorch/pruning/README.md / README_en.md 增补“工作原理”走查(打分 → 剪枝 → 恢复 →(可选)量化),并配 5 张流程图(总流程、三个可剪枝的域、容差二分搜索、菜单择优、prune→quantize 串联),图片位于 amct_pytorch/pruning/figures/。 ## 类型标签 - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 代码重构 - [ ] 其他,请描述: See merge request: cann/amct!140 | 25 天前 | |
[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 个月前 | |
[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 个月前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 20 天前 | ||
| 7 天前 | ||
| 13 天前 | ||
| 6 天前 | ||
| 3 个月前 | ||
| 10 天前 | ||
| 1 个月前 | ||
| 17 天前 | ||
| 6 天前 | ||
| 3 个月前 | ||
| 2 个月前 | ||
| 13 天前 | ||
| 6 个月前 | ||
| 2 个月前 | ||
| 25 天前 | ||
| 3 个月前 | ||
| 3 个月前 | ||
| 3 个月前 | ||
| 3 个月前 |