Skip to content

【Hackathon 9th No.31】add test_gptq_marlin_repack [cf]#7707

Open
ghost wants to merge 1 commit intoPaddlePaddle:developfrom
CloudForge-Solutions:task/031-gptq-marlin-repack-unit-test-v3
Open

【Hackathon 9th No.31】add test_gptq_marlin_repack [cf]#7707
ghost wants to merge 1 commit intoPaddlePaddle:developfrom
CloudForge-Solutions:task/031-gptq-marlin-repack-unit-test-v3

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented May 2, 2026

Motivation

Modifications

Usage or Command

Accuracy Tests

Checklist

  • I have submitted the CLA (only first PR)
  • My PR title follows the convention
  • My changes pass all tests

@ghost ghost temporarily deployed to Metax_ci May 2, 2026 17:15 — with GitHub Actions Inactive
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 2, 2026

CLA assistant check
All committers have signed the CLA.

@ghost ghost temporarily deployed to Metax_ci May 2, 2026 17:15 — with GitHub Actions Inactive
@ghost ghost temporarily deployed to Metax_ci May 2, 2026 17:15 — with GitHub Actions Inactive
@ghost ghost temporarily deployed to Metax_ci May 2, 2026 17:15 — with GitHub Actions Inactive
@ghost ghost temporarily deployed to Metax_ci May 2, 2026 17:15 — with GitHub Actions Inactive
@ghost ghost temporarily deployed to Metax_ci May 2, 2026 17:15 — with GitHub Actions Inactive
@ghost ghost temporarily deployed to Metax_ci May 2, 2026 17:15 — with GitHub Actions Inactive
@paddle-bot
Copy link
Copy Markdown

paddle-bot Bot commented May 2, 2026

Thanks for your contribution!

@paddle-bot paddle-bot Bot added the contributor External developers label May 2, 2026
PaddlePaddle-bot

This comment was marked as outdated.

@PaddlePaddle-bot
Copy link
Copy Markdown

PaddlePaddle-bot commented May 2, 2026

🤖 Paddle-CI-Agent | ci_status_monitor | 2026-05-03 22:03:14

CI报告基于以下代码生成(30分钟更新一次):


1 任务总览

当前已执行的 CI 任务均已通过 ✅。另有 7 个 Workflow 处于 action_required 状态,等待人工审批后才会执行,建议确认是否需要触发。

总执行(rerun次数) 总任务 ✅ 通过 ❌ 失败 ⏳ 运行中 ⏸️ 等待中 跳过
2(0) 2 2 0 0 0 0

⚠️ 注意:以下 7 个 Workflow 处于 action_required 状态(等待审批后才会执行):CI_XPUPR Build and TestILUVATAR-CICodestyle-CheckCheck PR TemplateApprovalCI_HPU。这些 Workflow 需人工审批触发。

注意:action_required workflows 不计入上表的任务统计。


2 任务状态汇总

2.1 Required 任务:0/0 通过

当前仓库未配置必选(Required)CI 检查(或 Branch Protection Rules 未开启),无 Required 任务阻塞合并。

2.2 可选任务 — 2/2 通过

可选任务不阻塞合并,失败仅供参考。

状态 任务 耗时 日志 重跑
其余 2 个可选任务通过 - - -

3 失败详情(仅 required)

无 required 失败任务。

Copy link
Copy Markdown

@PaddlePaddle-bot PaddlePaddle-bot left a comment

Choose a reason for hiding this comment

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

🤖 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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 建议 模块级别全局 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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

❓ 疑问 np.random.randint 传入 high=2**32dtype=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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants