| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
feat: 增加 QuantAlgorithmBase 算法基类; 优化 is_observe 通路控制开关 Co-authored-by: zchenbm<chenzhuo63@hisilicon.com> # message auto-generated for no-merge-commit merge: !245 merge master into master feat: 增加 QuantAlgorithmBase 算法基类; 优化 is_observe 通路控制开关 Created-by: zchenbm97 Commit-by: zchenbm Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> 1. 新增量化算法基类: QuantAlgorithmBase,默认包含is_observe开关和ptq_params加载和导出的公共接口,新增calib_forwad()接口,默认返回原始Tensor;2. 实际注册的量化算法需要重写forward()并实现量化通路,需要进行校准的量化算法需要重写calib_forward()并保证返回原始Tensor; 3. 当前已支持的Dtype同步新增is_observe 开关,True时返回原始Tensor,不注入量化误差; 4. 优化PTQ校准通路和注入量化误差通路控制,统一由amct_pytorch/common/models/llm/common/quant_apply.py 中 set_model_to_observe() 接口控制,去除了冗余set_*_quantizer() 控制接口; ## 如何测试 <!--描述测试此改动的步骤和前提条件。--> 已安装本项目所需依赖环境下: 1. python -m pytest tests/unit_test/algorithms 2. python -m pytest tests/unit_test/common/models/llm/common 3. python -m pytest tests/unit_test/quantization 4. python -m pytest tests/unit_test/workflows ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> 不涉及文档更新 ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [x] 代码重构 - [ ] 其他,请描述: See merge request: cann/amct!245 | 9 天前 | |
fix: 规范日志打印文案 Co-authored-by: fujun19<fujun19@hisilicon.com> # message auto-generated for no-merge-commit merge: !234 merge fix/log-message-wording into master fix: 规范日志打印文案 Created-by: fujun19 Commit-by: fujun19 Merged-by: cann-robot Description: ## 描述 修复 LOGGER/RuntimeError 相关日志文案规范问题: - 将非 LOGGER.loge 日志中的 fail/abnormal 等失败类词语调整为中性表达。 - 修复日志文案拼写错误,包括 fot、pune、fuison。 - 修复 RuntimeError 路径中的 .foramt 拼写错误,并优化不自然的错误文案。 - 新增静态回归测试,约束非 LOGGER.loge 日志失败类词语、已知日志拼写错误和 .format 拼写错误。 ## 如何测试 - python3 -m ruff check amct_pytorch/classic/graph_based/amct_pytorch/optimizer/conv_bn_fusion_pass.py amct_pytorch/classic/graph_based/amct_pytorch/optimizer/replace_avgpool_flatten_pass.py amct_pytorch/classic/graph_based/amct_pytorch/optimizer/replace_avgpool_reshape_pass.py amct_pytorch/classic/graph_based/amct_pytorch/prune/filter_prune_helper.py amct_pytorch/classic/graph_based/amct_pytorch/prune/find_prune_index.py amct_pytorch/classic/graph_based/amct_pytorch/prune/regular_prune_model.py amct_pytorch/classic/quantize_op/smooth_quant_module.py amct_pytorch/common/config/parser.py tests/unit_test/common/test_log_message_style.py - pre-commit run --files amct_pytorch/classic/graph_based/amct_pytorch/optimizer/conv_bn_fusion_pass.py amct_pytorch/classic/graph_based/amct_pytorch/optimizer/replace_avgpool_flatten_pass.py amct_pytorch/classic/graph_based/amct_pytorch/optimizer/replace_avgpool_reshape_pass.py amct_pytorch/classic/graph_based/amct_pytorch/prune/filter_prune_helper.py amct_pytorch/classic/graph_based/amct_pytorch/prune/find_prune_index.py amct_pytorch/classic/graph_based/amct_pytorch/prune/regular_prune_model.py amct_pytorch/classic/quantize_op/smooth_quant_module.py amct_pytorch/common/config/parser.py tests/unit_test/common/test_log_message_style.py - pytest tests/unit_test/common/test_log_message_style.py -q - bash build.sh -u(2589 passed, 4 skipped, 1 xfailed) ## 文档更新 不涉及文档更新。 ## 类型标签 <!-- [x] 表示选中 --> - [x] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 代码重构 - [ ] 其他,请描述: See merge request: cann/amct!234 | 14 天前 | |
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 | 24 天前 | |
feat: 增加 QuantAlgorithmBase 算法基类; 优化 is_observe 通路控制开关 Co-authored-by: zchenbm<chenzhuo63@hisilicon.com> # message auto-generated for no-merge-commit merge: !245 merge master into master feat: 增加 QuantAlgorithmBase 算法基类; 优化 is_observe 通路控制开关 Created-by: zchenbm97 Commit-by: zchenbm Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> 1. 新增量化算法基类: QuantAlgorithmBase,默认包含is_observe开关和ptq_params加载和导出的公共接口,新增calib_forwad()接口,默认返回原始Tensor;2. 实际注册的量化算法需要重写forward()并实现量化通路,需要进行校准的量化算法需要重写calib_forward()并保证返回原始Tensor; 3. 当前已支持的Dtype同步新增is_observe 开关,True时返回原始Tensor,不注入量化误差; 4. 优化PTQ校准通路和注入量化误差通路控制,统一由amct_pytorch/common/models/llm/common/quant_apply.py 中 set_model_to_observe() 接口控制,去除了冗余set_*_quantizer() 控制接口; ## 如何测试 <!--描述测试此改动的步骤和前提条件。--> 已安装本项目所需依赖环境下: 1. python -m pytest tests/unit_test/algorithms 2. python -m pytest tests/unit_test/common/models/llm/common 3. python -m pytest tests/unit_test/quantization 4. python -m pytest tests/unit_test/workflows ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> 不涉及文档更新 ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [x] 代码重构 - [ ] 其他,请描述: See merge request: cann/amct!245 | 9 天前 | |
新增HiF4-cast 直转工具 Co-authored-by: Zhang Jian<jianmusings@gmail.com> # message auto-generated for no-merge-commit merge: !201 merge jian/hifloat4-cast into master 新增HiF4-cast 直转工具 Created-by: zhangj1an Commit-by: Zhang Jian Merged-by: cann-robot Description: ## Latest Status [13 Aug 2026] Ready for review, CI已通过 --- ## Description <!--Describe your changes in detail, including the reasons for the changes and the methods adopted.--> 本PR希望把HiF4-cast工具集成到AMCT仓库中,需求编号为AR00002U9R。命令行调用、实现细节可以参见 https://gitcode.com/cann/amct/issues/163。 HiF4是一种4比特的层级缩放、块浮点格式。每64个元素为一个块,先用E6M2进行一级缩放,再以8个和4个数字为一组分别算出二、三级微指数,最后每个元素以S1P2表示(1个符号位+2个尾数位),可取{-1.75, -1.5, ... 0, ... 1.5, 1.75}共15个值。细节可参见HiF4技术报告 https://arxiv.org/abs/2602.11287。 ### 主要功能 | 输入 | 路径 | 命令 | 调用链 | 输出 | |---|---|---|---|---| | FP16/BF16 | 伪量化,仅注入HiF4误差,不输出新模型权重 | ptq --quant_dtype hifp --bit_config configs/hifloat4.yaml | fake_quant → hifloat4_fake_quant(NPU kernel / CPU fallback) | 注入HiF4误差,不产出文件 | | FP16/BF16 | 打包,输出HiF4打包字节 | deploy --quant_dtype hifp --granularity block | export_block_deploy → hif4_pack | HiF4 打包字节 | | HiF4 | 解码,输出FP32格式 | deploy --quant_dtype hifp --granularity tensor | convert_state_dict → hif4_unpack | FP32 | 其中,伪量化(BF16/FP16 → HiF4 → BF16/FP16)由NPU伪算子实现;打包和解码由PyTorch实现。打包格式为低位优先,元素0放在低4位,元素1放在高4位。当一个64元素块内出现NaN/+Inf/-Inf时,打包scale byte 0写入0xFF,解码时整块恢复为NaN。 ## Design (设计方案) ### 与开源HiF4仓库对比 本PR的HiF4-cast工具在 https://github.com/global-computing-consortium/HiFloat4 基础上,根据程禹最新的HiF4算子私仓内容,做了以下5点改进,已和程禹对齐。原本的github仓库中的伪量化(BF16/FP16 → HiF4 → BF16/FP16)是由NPU伪算子实现的。 1. 新增了打包函数,由PyTorch实现。存储格式为低位优先,元素 0 放在低 4 bit,元素 1 放在高 4 bit。 2. 在编解码函数中,在把元素除掉块scale,也做完二三级缩放后,在量化成S1P2之前,先做了一次round_to_bf16。 3. 在编解码函数中,当一个64元素块内出现NaN, +Inf, -Inf取值时,打包scale byte 0 写入0xFF, 解码时整块恢复为NaN。 4. 在编解码函数中,当对block max做规约时,从amax(dim=-1),改成了amax(dim=qdim, keepdim=True)。不再需要手动把qdim调整到-1维度。 5. 在伪量化算子中,在host 侧增加了一步处理:将 N 补零pad到 BATCH=512 的整数倍后再调用kernel,kernel不再需要处理当N不符合batch=512的整数的情况。 kernel 输出后裁剪回原长。 ### 适配AMCT仓库 为了将算法接入amct仓库,主要新增/修改以下模块: 1. 新增HiF4伪量化NPU算子文件夹:(amct_ops/hifloat4_cast/) ,做一次FP→HiF4→FP往返仿真。 2. 修改文件,新增HiF4 PyTorch实现的打包、解包、伪算子调度器(amct_pytorch/quantization/dtypes/hifp_impl.py) , 与HiF8并列存放。公开API: - hif4_pack(x) :打包算法, 浮点 → HiF4 uint8字节 - hif4_unpack(scale, value) :解包算法: HiF4 uint8字节 → FP32 - hifloat4_fake_quant(x, qdim=-1) : 伪算子调度器:NPU kernel优先,CPU fallback 内部共用一样的PyTorch算法, hif4_encode / hif4_decode(3级scale + S1P2 golden reference),保证PTQ和deploy路径数值一致。 3. 修改文件,在dtype和带有解码功能的deploy tensorwise函数中注册HiF4格式,(hifp.py、deploy_export.py)。 QuantDequantHifp 已支持 bits=4;convert_state_dict 新增HiF4检测与解码。 ## How to Test <!--Describe the steps and prerequisites for testing this change.--> ### 1. 单元测试 tests/amct_ops/test_hifloat4_cast.py, 里面包括了伪量化算子与golden参考的一致性和异常值处理的测试。 ### 2. CLI端到端的测试 bash # 伪量化:注入HiF4误差(ptq,不产出文件) python -m amct_pytorch.cli.llm.ptq \ --quant_dtype hifp --bit_config amct_pytorch/configs/w4a4.yaml \ --model <IN> --output_dir <OUT> # 打包:输出HiF4字节(deploy blockwise) python -m amct_pytorch.cli.llm.deploy \ --quant_dtype hifp --granularity block \ --model <IN> --output_dir <OUT> # 解码:输出FP32(deploy tensorwise) python -m amct_pytorch.cli.llm.deploy \ --quant_dtype hifp --granularity tensor \ --model <IN> --output_dir <OUT> 可以将模型权重打包又解码的产出和直接做伪量化的产出进行对比,如果达到逐比特一致说明算法正确。 ### 3. 看PPL是否符合预期 用amct仓库内的eval测试,比较BF16, MXFP4, HiF4在wikitext-2数据集上的PPL,看趋势是否符合预期。 <details> <summary> 调用命令</summary> # 1) BF16 baseline —— 不需要 quant_dtype / bit_config / quant_target python -m amct_pytorch.eval \ --model $MODEL --model_name Qwen3.5-9B \ --device npu:0 --eval_mode bf16 \ --seq_len 4096 --output_dir ./outputs # 2) MXFP4 W4A4 python -m amct_pytorch.eval \ --model $MODEL --model_name Qwen3.5-9B \ --device npu:0 --eval_mode quant \ --quant_dtype mxfp \ --bit_config amct_pytorch/configs/w4a4.yaml \ --quant_target mlp attn-linear \ --seq_len 4096 --output_dir ./outputs # 3) HiF4 W4A4 —— 只改 quant_dtype python -m amct_pytorch.eval \ --model $MODEL --model_name Qwen3.5-9B \ --device npu:0 --eval_mode quant \ --quant_dtype hifp \ --bit_config amct_pytorch/configs/w4a4.yaml \ --quant_target mlp attn-linear \ --seq_len 4096 --output_dir ./outputs 另外,当与github上的HiF4私仓github.com/ddddwee1/HiFloat-private (commit id: f511fdd)进行对比时,MXFP4的量化应调用hif4_gpu/quant_cy/base/cusrc/extended_quant_cuda.cu 里mx_shared_scale 函数的mxfp4_c725 分支,并且把round_to_decimal的阈值从1.8125改成1.75,就和amct仓库的实现是一致的。 </details> ## Test Result 在量化时,我们选择W4A4, 将模型的mlp和attn-linear部分进行量化,(其中也会量化linear attention)。 用Qwen3.5-9B和wikitext-2数据集,将HiF4在amct上进行了测试,结果与HiF4算子repo里的PPL趋势一致,HiF4的PPL比MXFP4会差0.5。 |量化选项|HiF4算子repo(程禹写的golden reference), 在A100上测试| amct, 该分支,在npu 910C上测试| |---|---|---| |BF16 baseline|8.202739840420143|8.176278114318848| |MXFP4 w4a4|9.664575071762391| 9.502161026000977| |HiF4 w4a4|10.020700353404631| 9.901074409484863| 由于该结果不太符合预期,HiF4并没有比MXFP4有优势,我们另外在下游数据集上进行了测试。结果显示在Qwen3.5-9B上,HiF4的精度比MXFP4好0.6. 作为对比,在Qwen3-8B上,HiF4的精度比MXFP4好1.7。这两个模型的主要差异在于千问3.5-9b的结构是(3层linear attention+1层full attention)x8,而千问3-8b的结构是36层full attention. ### Qwen3.5-9B上,HiF4的精度比MXFP4好0.6 | Dataset / Metric | FP16 | HiF4 (HiF4算子私仓的版本) | MXFP4 (AMCT实现的版本) | Δ HiF4 - MXFP4 | |---|---:|---:|---:|---:| | arc_challenge (acc_norm) | 55.9 | 55.0 | 54.8 | +0.2 | | arc_easy (acc_norm) | 74.2 | 76.2 | 76.8 | -0.6 | | boolq (acc) | 89.1 | 86.8 | 85.0 | +1.8 | | copa (acc) | 89.0 | 89.0 | 89.0 | 0.0 | | piqa (acc_norm) | 80.1 | 78.8 | 78.2 | +0.6 | | sciq (acc_norm) | 96.0 | 96.2 | 95.3 | +0.9 | | hellaswag (acc_norm) | 78.1 | 76.3 | 74.8 | +1.5 | | **Average** | **80.3** | **79.8** | **79.1** | **+0.6** | 其中表格最后一行,未四舍五入之前的平均值应该是 HiF4 = 79.75,MXFP4 AMCT = 79.11,差值 = +0.64,表格里展示成一位小数就是 +0.6。 ### Qwen3-8B上,HiF4的精度比MXFP4好1.7 | Dataset / Metric | FP16 | (HiF4算子私仓的版本) | MXFP4 (AMCT实现的版本) | Δ HiF4 - MXFP4 | |---|---:|---:|---:|---:| | arc_challenge (acc_norm) | 56.5 | 52.3 | 52.6 | -0.3 | | arc_easy (acc_norm) | 80.8 | 76.9 | 73.4 | +3.5 | | boolq (acc) | 86.6 | 85.9 | 84.5 | +1.4 | | copa (acc) | 85.0 | 84.0 | 82.0 | +2.0 | | piqa (acc_norm) | 77.7 | 76.3 | 75.2 | +1.0 | | sciq (acc_norm) | 95.6 | 95.8 | 94.3 | +1.5 | | hellaswag (acc_norm) | 75.0 | 73.9 | 71.3 | +2.6 | | **Average** | **79.6** | **77.9** | **76.2** | **+1.7** | 另外我们也将Qwen3.5-9b每一层W4A4量化后的SQNR进行了对比。HiF4在每一层的SQNR都比MXFP4高。 ### Qwen3.5-9B上,对权重作比较时,HiF4所有层的SQNR都优于MXFP4 | Layer | HiF4 (dB) | MXFP4 (dB) | Δ HiF4 − MXFP4 | |---|---:|---:|---:| | linear_attn/in_proj_a | 21.40 | 18.56 | +2.84 | | linear_attn/in_proj_b | 21.28 | 18.36 | +2.92 | | linear_attn/in_proj_qkv | 21.56 | 18.94 | +2.62 | | linear_attn/in_proj_z | 21.57 | 18.96 | +2.61 | | linear_attn/out_proj | 21.54 | 18.92 | +2.62 | | mlp/down_proj | 21.55 | 18.88 | +2.67 | | mlp/gate_proj | 21.56 | 18.91 | +2.65 | | mlp/up_proj | 21.56 | 18.91 | +2.65 | | self_attn/k_proj | 21.40 | 18.63 | +2.77 | | self_attn/o_proj | 21.51 | 18.88 | +2.63 | | self_attn/q_proj | 21.54 | 18.91 | +2.63 | | self_attn/v_proj | 21.43 | 18.71 | +2.72 | ### Qwen3.5-9B上,对激活作比较时,HiF4所有层的SQNR都优于MXFP4 | Activation / Layer | HiF4 (dB) | MXFP4 (dB) | Δ HiF4 − MXFP4 | |---|---:|---:|---:| | linear_attn/in_proj_{a,b,qkv,z} | 21.21 | 18.05 | +3.16 | | linear_attn/out_proj | 20.81 | 17.28 | +3.53 | | mlp/down_proj | 20.73 | 17.09 | +3.64 | | mlp/{gate,up}_proj | 20.72 | 17.79 | +2.93 | | self_attn/{q,k,v}_proj | 21.10 | 17.90 | +3.20 | | self_attn/o_proj | 20.72 | 17.21 | +3.51 | <details><summary> 单元测试9项通过 </summary> $ python -m pytest tests/amct_ops/test_hifloat4_cast.py -v tests/amct_ops/test_hifloat4_cast.py::TestHiFloat4Kernel::test_kernel_bf16 PASSED [ 11%] tests/amct_ops/test_hifloat4_cast.py::TestHiFloat4Kernel::test_kernel_fp16 PASSED [ 22%] tests/amct_ops/test_hifloat4_cast.py::TestHiFloat4Kernel::test_kernel_padded PASSED [ 33%] tests/amct_ops/test_hifloat4_cast.py::TestHiFloat4Kernel::test_kernel_zero_is_nan_free PASSED [ 44%] tests/amct_ops/test_hifloat4_cast.py::TestHiFloat4CastShapes::test_dequant_shape_2x128 PASSED [ 55%] tests/amct_ops/test_hifloat4_cast.py::TestHiFloat4CastShapes::test_dequant_shape_3x512 PASSED [ 66%] tests/amct_ops/test_hifloat4_cast.py::TestHiFloat4CastShapes::test_packed_shape_1x64 PASSED [ 77%] tests/amct_ops/test_hifloat4_cast.py::TestHiFloat4CastShapes::test_packed_shape_2x128 PASSED [ 88%] tests/amct_ops/test_hifloat4_cast.py::TestHiFloat4CastShapes::test_packed_shape_3x512 PASSED [100%] ======================== 9 passed, 15 warnings in 1.98s ======================== </details> <details><summary> 以下两种方案达到了逐比特一致:1. NPU 伪算子(hifloat4_fake_quant) 和 2. PyTorch 打包再解包(hif4_pack + hif4_unpack)</summary> 以 Qwen3.5-9B MLP 权重形状(2560×10240, 10240×2560)的合成 BF16 张量在 NPU 上验证: python import torch from amct_pytorch.quantization.dtypes.hifp_impl import hifloat4_fake_quant, hif4_pack, hif4_unpack shapes = [(2560, 10240), (10240, 2560), (2560, 10240)] for M, N in shapes: x = torch.randn(M, N, dtype=torch.bfloat16).npu() npu_out = hifloat4_fake_quant(x).cpu() # NPU AscendC kernel scale, value = hif4_pack(x.cpu()) # CPU 打包 decoded = torch.from_numpy(hif4_unpack(scale, value)).to(torch.bfloat16) diff = (npu_out.to(torch.float32) - decoded.to(torch.float32)).abs().max().item() print(f' [{M}x{N}] diff={diff:.2e}', '✓' if diff < 1e-4 else '✗') 得到了以下输出内容: [2560x10240] diff=0.00e+00 ✓ [10240x2560] diff=0.00e+00 ✓ [2560x10240] diff=0.00e+00 ✓ All bit-identical ✓ </details> ## Documentation Updates <!--If this PR includes documentation updates, please indicate them here. For example: Updated the README.md file.--> 更新了HiF4伪算子的文档,amct_ops/hifloat4_cast/README.md 和 README_en.md。 ## Type Label <!-- [x] indicates selected --> - [ ] Bug fix - [x] New feature - [ ] Performance optimization - [ ] Documentation update - [x] Code refactoring - [ ] Other, please describe: See merge request: cann/amct!201 | 23 小时前 | |
feat: 增加 QuantAlgorithmBase 算法基类; 优化 is_observe 通路控制开关 Co-authored-by: zchenbm<chenzhuo63@hisilicon.com> # message auto-generated for no-merge-commit merge: !245 merge master into master feat: 增加 QuantAlgorithmBase 算法基类; 优化 is_observe 通路控制开关 Created-by: zchenbm97 Commit-by: zchenbm Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> 1. 新增量化算法基类: QuantAlgorithmBase,默认包含is_observe开关和ptq_params加载和导出的公共接口,新增calib_forwad()接口,默认返回原始Tensor;2. 实际注册的量化算法需要重写forward()并实现量化通路,需要进行校准的量化算法需要重写calib_forward()并保证返回原始Tensor; 3. 当前已支持的Dtype同步新增is_observe 开关,True时返回原始Tensor,不注入量化误差; 4. 优化PTQ校准通路和注入量化误差通路控制,统一由amct_pytorch/common/models/llm/common/quant_apply.py 中 set_model_to_observe() 接口控制,去除了冗余set_*_quantizer() 控制接口; ## 如何测试 <!--描述测试此改动的步骤和前提条件。--> 已安装本项目所需依赖环境下: 1. python -m pytest tests/unit_test/algorithms 2. python -m pytest tests/unit_test/common/models/llm/common 3. python -m pytest tests/unit_test/quantization 4. python -m pytest tests/unit_test/workflows ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> 不涉及文档更新 ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [x] 代码重构 - [ ] 其他,请描述: See merge request: cann/amct!245 | 9 天前 | |
[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 | 2 个月前 | |
[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 | 2 个月前 | |
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 | 24 天前 | |
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 | 24 天前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 9 天前 | ||
| 14 天前 | ||
| 24 天前 | ||
| 9 天前 | ||
| 23 小时前 | ||
| 9 天前 | ||
| 2 个月前 | ||
| 2 个月前 | ||
| 24 天前 | ||
| 24 天前 |