低内存模式下设备不一致问题#179
Merged
Merged
Conversation
确保缩放因子与权重在同一设备上 恢复权重时使用正确的设备变量
该文件包含对Claude Code的指导说明,现已不再需要
yghstill
approved these changes
Dec 19, 2025
dawnranger
pushed a commit
to dawnranger/AngelSlim
that referenced
this pull request
Mar 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题概述
在 AWQ (Activation-aware Weight Quantization) 量化模块中发现了两个关键的设备管理问题,这些问题在低内存设备上会导致性能下降和运行时错误。
修复的问题
问题描述:
修复内容:
在 search_by_block 方法中添加
dev = get_best_device()
block.to(dev) # 新增:确保 block 在最佳设备上执行
问题描述:
修复内容:
修复1:确保缩放因子与权重在同一设备
layer.weight.mul_(scales.to(layer.weight.device).view(1, -1))
修复2:恢复权重时使用正确的设备变量(dev 而不是 act.device)
layer.weight.data = w.to(dev)
技术细节
影响范围:
修复原理:
修复效果
测试建议
建议在以下场景中测试修复效果:
这些修复确保了 AngelSlim 在资源受限环境下的稳定运行,提升了量化过程的可靠性。