Skip to content

[BugFix] fix dynamic c8 in v1 loader#5562

Merged
yuanlehome merged 1 commit intoPaddlePaddle:developfrom
yuanlehome:fix_dynamic_c8_v1_loader
Dec 15, 2025
Merged

[BugFix] fix dynamic c8 in v1 loader#5562
yuanlehome merged 1 commit intoPaddlePaddle:developfrom
yuanlehome:fix_dynamic_c8_v1_loader

Conversation

@yuanlehome
Copy link
Collaborator

@yuanlehome yuanlehome commented Dec 15, 2025

Motivation

fix dynamic c8 in v1 loader

💡 If this PR is a Cherry Pick, the PR title needs to follow the format by adding the [Cherry-Pick] label at the very beginning and appending the original PR ID at the end. For example, [Cherry-Pick][CI] Add check trigger and logic(#5191)

💡 如若此PR是Cherry Pick,PR标题需遵循格式,在最开始加上[Cherry-Pick]标签,以及最后面加上原PR ID,例如[Cherry-Pick][CI] Add check trigger and logic(#5191)

Modifications

Usage or Command

Accuracy Tests

Checklist

  • Add at least a tag in the PR title.
    • Tag list: [[FDConfig],[APIServer],[Engine], [Scheduler], [PD Disaggregation], [Executor], [Graph Optimization], [Speculative Decoding], [RL], [Models], [Quantization], [Loader], [OP], [KVCache], [DataProcessor], [BugFix], [Docs], [CI], [Optimization], [Feature], [Benchmark], [Others], [XPU], [HPU], [GCU], [DCU], [Iluvatar], [Metax]]
    • You can add new tags based on the PR content, but the semantics must be clear.
  • Format your code, run pre-commit before commit.
  • Add unit tests. Please write the reason in this PR if no unit tests.
  • Provide accuracy results.
  • If the current PR is submitting to the release branch, make sure the PR has been submitted to the develop branch, then cherry-pick it to the release branch with the [Cherry-Pick] PR tag.

Copilot AI review requested due to automatic review settings December 15, 2025 09:40
@paddle-bot
Copy link

paddle-bot bot commented Dec 15, 2025

Thanks for your contribution!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

该 PR 修复了 v1 loader 中处理动态 c8(cache 量化)的一个 bug。具体来说,修复了在使用 block_wise_fp8 量化类型时,process_weights_after_loading 方法错误地尝试访问不存在的 scale 参数的问题。

关键改动

  • process_weights_after_loading 方法中添加条件检查,仅在非 block_wise 量化类型时才处理 cache scale 参数
  • 该修复使 v1 loader 的行为与 v0 loader(process_loaded_weights 方法)保持一致

Comment on lines +266 to +270
if "block_wise" not in layer.cache_quant_type_str:
if layer.cache_k_scale._is_initialized():
layer.cache_k_out_scale.set_value(1 / layer.cache_k_scale)
if layer.cache_v_scale._is_initialized():
layer.cache_v_out_scale.set_value(1 / layer.cache_v_scale)
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

新增的针对 block_wise_fp8 量化类型的条件分支缺少测试覆盖。建议在 tests/quantization/test_kv_cache.py 中添加测试用例,验证:

  1. 当 cache_quant_type_str 包含 "block_wise" 时,process_weights_after_loading 不会尝试访问或设置 cache_k_out_scale 和 cache_v_out_scale
  2. 当 cache_quant_type_str 不包含 "block_wise" 时,正常执行现有逻辑

这将确保该修复在未来的代码变更中保持正确性。

Copilot uses AI. Check for mistakes.
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@722de5a). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...loy/model_executor/layers/quantization/kv_cache.py 40.00% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #5562   +/-   ##
==========================================
  Coverage           ?   60.87%           
==========================================
  Files              ?      329           
  Lines              ?    41161           
  Branches           ?     6275           
==========================================
  Hits               ?    25055           
  Misses             ?    14213           
  Partials           ?     1893           
Flag Coverage Δ
GPU 60.87% <40.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@gongshaotian gongshaotian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yuanlehome yuanlehome merged commit b8e4828 into PaddlePaddle:develop Dec 15, 2025
20 of 23 checks passed
yuanlehome added a commit that referenced this pull request Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants