【Hackathon 9th No.31】add test_gptq_marlin_repack [cf]#7707
【Hackathon 9th No.31】add test_gptq_marlin_repack [cf]#7707ghost wants to merge 1 commit intoPaddlePaddle:developfrom
Conversation
|
Thanks for your contribution! |
CI报告基于以下代码生成(30分钟更新一次): 1 任务总览当前已执行的 CI 任务均已通过 ✅。另有 7 个 Workflow 处于
2 任务状态汇总2.1 Required 任务:0/0 通过
2.2 可选任务 — 2/2 通过
3 失败详情(仅 required)无 required 失败任务。 |
PaddlePaddle-bot
left a comment
There was a problem hiding this comment.
🤖 Paddle-CI-Agent | pr_review |
2026-05-03 22:09:28
📋 Review 摘要
PR 概述:为 gptq_marlin_repack 算子新增单元测试,覆盖 4-bit/8-bit × 有/无 act_order 排列共四种场景
变更范围:tests/operators/
影响面 Tag:[OP]
📝 PR 规范检查
标题不符合规范格式(使用了中文括号 【】 和非官方 [cf] 后缀);PR 描述所有章节均为 TODO 占位符,需按模板填写。
标题建议(可直接复制):
[OP] Add unit test for gptq_marlin_repack operator
PR 描述建议(可直接复制,必须复刻 checklist §D2 模板的完整结构):
## Motivation
为 `gptq_marlin_repack` CUDA 算子补充单元测试(Hackathon 9th No.31),验证 4-bit 和 8-bit 量化权重在 GPTQ-Marlin 格式重排前后的值守恒性。
## Modifications
- 新增 `tests/operators/test_gptq_marlin_repack.py`
- `test_4bit_no_perm`:测试 4-bit 无 act_order 排列,覆盖 size_k∈{16,64,128} × size_n∈{64,128,256} 三组尺寸
- `test_8bit_no_perm`:测试 8-bit 无 act_order 排列,同上尺寸组合
- `test_4bit_with_perm`:测试 4-bit 有 act_order 排列,覆盖 (64,128)、(128,256) 两组尺寸
- `test_8bit_with_perm`:测试 8-bit 有 act_order 排列,同上尺寸组合
- 验证输出 shape 及 dtype 正确性,以及重排前后量化值多集合守恒
## Usage or Command
```bash
python -m pytest tests/operators/test_gptq_marlin_repack.py -v
```
## Accuracy Tests
N/A(本 PR 为算子功能正确性测试,不涉及精度对比)
## Checklist
- [x] 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.
- [x] 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.问题
| 级别 | 文件 | 概述 |
|---|---|---|
| 🟡 建议 | tests/operators/test_gptq_marlin_repack.py:22 |
模块级别全局 seed 影响测试隔离性 |
| ❓ 疑问 | tests/operators/test_gptq_marlin_repack.py:40 |
np.random.randint(0, 2**32, dtype=np.uint32) 存在 NumPy 版本兼容性风险 |
总体评价
测试结构清晰,四类用例覆盖了主要量化位宽和排列场景;PR 标题与描述需要规范化,另有两处代码细节建议修改以提升测试健壮性。
|
|
||
| from fastdeploy.model_executor.ops.gpu import gptq_marlin_repack | ||
|
|
||
| paddle.seed(42) |
There was a problem hiding this comment.
🟡 建议 模块级别全局 seed 影响测试隔离性
paddle.seed(42) 和 np.random.seed(42) 在模块 import 时即执行,会影响同进程内其他测试的随机状态。建议将 seed 设置移入 setUp() 方法中,限制影响范围:
def setUp(self):
paddle.set_device("gpu")
paddle.seed(42)
np.random.seed(42)| def _make_random_packed_weights(size_k, size_n, num_bits): | ||
| """Create random int32-packed quantized weight tensor on GPU.""" | ||
| pack_factor = 32 // num_bits | ||
| data = np.random.randint(0, 2**32, size=(size_k // pack_factor, size_n), dtype=np.uint32).view(np.int32) |
There was a problem hiding this comment.
❓ 疑问 np.random.randint 传入 high=2**32 与 dtype=np.uint32 存在兼容性风险
2**32 = 4294967296 超出 uint32 最大值(2**32 - 1 = 4294967295),high 参数为 exclusive 上界,但部分 NumPy 版本(尤其 <1.17 的 legacy API)在处理 uint32 dtype 时会触发 OverflowError 或静默截断。建议改为:
data = np.random.randint(
np.iinfo(np.int32).min, np.iinfo(np.int32).max + 1,
size=(size_k // pack_factor, size_n),
dtype=np.int32
)或使用新式 Generator API:
rng = np.random.default_rng(42)
data = rng.integers(0, 2**32, size=(size_k // pack_factor, size_n), dtype=np.uint32).view(np.int32)
Motivation
Modifications
Usage or Command
Accuracy Tests
Checklist