Skip to content

[Granite 4.0]: add Granite causal language model support#4766

Open
cf-icehzgzh wants to merge 11 commits into
PaddlePaddle:developfrom
cf-icehzgzh:feat/add-granite-model
Open

[Granite 4.0]: add Granite causal language model support#4766
cf-icehzgzh wants to merge 11 commits into
PaddlePaddle:developfrom
cf-icehzgzh:feat/add-granite-model

Conversation

@cf-icehzgzh

Copy link
Copy Markdown
Contributor

本 PR 完成 IBM Granite 4.0-350M-Base 从 Transformers 到 PaddleFormers 的迁移,包含组网、前向精度、生成、训练 loss 对齐和单测验证。

1. 前向精度对齐

  • 模型:ibm-granite/granite-4.0-350m-base
  • AutoConfigAutoModelForCausalLM 本地加载验证通过
  • PaddleFormers / Transformers logits:
    • mean abs diff:5.0285e-06
    • max abs diff:8.1062e-05

2. 模型生成

相同转换权重与 greedy 解码下验证通过:

Prompt: The capital of France is
Output: Paris, which is the capital of the

V100 不支持 BF16 GEMM,真实权重生成使用 FP32 验证。

3. 训练 loss 对齐

  • 数据:GSM8K 固定前 600 条
  • FP32,batch size=2,AdamW,300 steps,关闭 shuffle
  • 首步 loss:
    • ms-swift:1.17252529
    • PaddleFormers:1.1725
  • 300-step loss 曲线相关系数:0.97929

4. 模型单测

覆盖前向、attention mask、causal loss、-100 ignore label 和 greedy generation。

pytest tests/transformers/granite/test_modeling.py -q
21 passed, 3 skipped

compileallgit diff --check 已通过。

不包含转换权重、训练 checkpoint 或其它生成产物。

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

已复查当前提交,CI 显示通过,但仍有需要作者提交新 commit 修复的问题,详情见行级评论。修复后我会继续复查。

Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

"image_processing": ["get_image_processor_config", "AutoImageProcessor", "IMAGE_PROCESSOR_MAPPING"],
"processing": ["AutoProcessor", "PROCESSOR_MAPPING"],
"video_processing": ["AutoVideoProcessor", "VIDEO_PROCESSOR_MAPPING"],
"diff_transformer": [

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 优先级:P1

问题: 这里把 diff_transformer 加到了 paddleformers.transformers.auto 包的 lazy import 结构里,但仓库里没有 paddleformers/transformers/auto/diff_transformer.py 或同名子包;实际模块是 paddleformers.transformers.diff_transformer

影响: _LazyModule 会按当前包名解析为 paddleformers.transformers.auto.diff_transformer,因此 from paddleformers.transformers.auto import DiffTransformerConfig 会触发不存在模块的导入错误,也会让 TYPE_CHECKING 分支里的 from .diff_transformer import ... 失效。

处理要求:请针对该评论修复并提交新的 commit。 建议删除这个 import_structure 条目以及下方 TYPE_CHECKING 中的 .diff_transformer 导入;如果确实需要顶层导出 DiffTransformer,请放到 paddleformers/transformers/__init__.py 对应的 lazy import 结构里。

参考修改形态:

# 删除 import_structure 中的 "diff_transformer": [...] 块
# 删除 TYPE_CHECKING 分支中的 from .diff_transformer import (...) 块

Comment on lines +553 to +559
valid = shift_labels != -100
safe_labels = paddle.where(valid, shift_labels, paddle.zeros_like(shift_labels))
selected_log_probs = paddle.take_along_axis(
F.log_softmax(shift_logits, axis=-1), safe_labels.unsqueeze(-1), axis=-1
).squeeze(-1)
valid_count = paddle.cast(valid, selected_log_probs.dtype).sum()
loss = -(selected_log_probs * paddle.cast(valid, selected_log_probs.dtype)).sum() / valid_count

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 优先级:P1

问题: forward 接收了 loss_mask,但这里手写 loss 只按 labels != -100 过滤,没有把调用方传入的 loss_mask 合并进有效 token 集合。

影响: 训练/评估侧如果用 loss_mask 额外屏蔽 prompt、padding 或 packed sample 中不参与监督的 token,这些 token 仍会被计入 Granite loss。仓库里同类模型通常把 loss_mask 传给 CriterionLayer(例如 MiniCPM/Phi4),CriterionLayer 的 SFT loss 也会用该 mask 做逐 token 加权;Granite 这里因为需要 logits_scaling 改成手写 loss 后丢掉了这个语义。另外,当所有 token 都被 mask/ignore 时,当前 valid_count 可能为 0,loss 会变成 NaN/Inf。

处理要求:请针对该评论修复并提交新的 commit。 请在计算 loss 时合并 shifted loss_mask,并对全空 mask 做保护。参考实现形态:

valid = shift_labels != -100
if loss_mask is not None:
    shift_loss_mask = loss_mask[:, 1:].reshape([-1]).astype("bool")
    valid = valid & shift_loss_mask
safe_labels = paddle.where(valid, shift_labels, paddle.zeros_like(shift_labels))
selected_log_probs = paddle.take_along_axis(
    F.log_softmax(shift_logits, axis=-1), safe_labels.unsqueeze(-1), axis=-1
).squeeze(-1)
valid_float = paddle.cast(valid, selected_log_probs.dtype)
valid_count = valid_float.sum()
loss = -(selected_log_probs * valid_float).sum() / paddle.clip(valid_count, min=1.0)

@CLAassistant

CLAassistant commented Jul 13, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

已复查新提交,之前两条 P1 代码问题均已通过后续 commit 修复,并补充了 loss_mask 相关测试。代码层面未发现需要继续阻塞合入的问题。

当前 CLA 检查仍处于 pending/not signed 状态,这不是代码实现问题,但合入前仍需要作者处理。

Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

@cf-icehzgzh cf-icehzgzh force-pushed the feat/add-granite-model branch from a3a6677 to 0bd8244 Compare July 13, 2026 16:56

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

已复查当前 head:这次 force-push 后的代码内容与上次已批准的提交一致,之前两条 P1 问题仍保持修复状态,loss_mask 回归测试也仍在。当前检查已通过,CLA 也已显示签署完成;代码层面未发现新的阻塞问题。

GitHub 页面目前仍提示 mergeability conflict,合入前还需要按仓库最新 base 解决冲突状态。

Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

已复查当前 head:本次合并 develop 后的 tree 与上次已批准的 head 完全一致,之前两条 P1 问题仍保持修复状态,当前检查也已通过。代码层面未发现新的阻塞问题。

Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

@liuhao2638 liuhao2638 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

已复查当前 head。此前 Granite 相关 P1 问题仍保持修复状态,但 DiffTransformer 的 CausalLM 路径发现一个需要提交新 commit 修复的阻塞问题,详情见行级评论。

  • P3 优先级:P3
    非行级:PR 标题/描述。当前 diff 同时新增了 DiffTransformer 模型、测试和 Auto 映射,但标题、描述和测试计划只说明 Granite 4.0。建议将 DiffTransformer 拆到单独 PR;如果必须同 PR 合入,请更新标题/描述,明确 DiffTransformer 的验证范围、测试命令和风险说明。
    处理要求:请针对该评论进行回复(同意并已修改请回复 Done,不同意请说明理由)。
Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

Comment on lines +69 to +70
attn1 = F.scaled_dot_product_attention(q1, k1, v, attn_mask=attention_mask)
attn2 = F.scaled_dot_product_attention(q2, k2, v, attn_mask=attention_mask)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 优先级:P1

问题: DiffTransformerForCausalLM 的默认训练/前向路径没有生成 causal mask,这里调用 SDPA 时也没有设置 is_causal=True。因此 model(input_ids, labels=input_ids) 计算每个位置 logits 时可以看到未来 token,CausalLM loss 会发生信息泄漏。

影响: 这会让训练 loss 和生成前的 logits 都不符合自回归语言模型语义;当前新增测试只校验 output/loss 非空,无法捕获该问题。

处理要求:请针对该评论修复并提交新的 commit。 请确保无外部 mask 的默认路径启用因果注意力;如果后续支持 padding mask,也需要先把 padding mask 与 causal mask 合并后再传给 SDPA。最小修复可以先按当前仓库其他 SDPA 实现的模式处理无 mask 路径:

Suggested change
attn1 = F.scaled_dot_product_attention(q1, k1, v, attn_mask=attention_mask)
attn2 = F.scaled_dot_product_attention(q2, k2, v, attn_mask=attention_mask)
is_causal = attention_mask is None and seq_len > 1
attn1 = F.scaled_dot_product_attention(q1, k1, v, attn_mask=attention_mask, is_causal=is_causal)
attn2 = F.scaled_dot_product_attention(q2, k2, v, attn_mask=attention_mask, is_causal=is_causal)

@cf-icehzgzh cf-icehzgzh force-pushed the feat/add-granite-model branch from 9328199 to a41534e Compare July 14, 2026 13:45

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

已复查当前 head:此前 Granite 相关 P1 问题均保持修复;当前新增/保留的 DiffTransformer 与格式变更里还有需要提交 commit 处理的问题,详情见行级评论。

  • P3 优先级:P3
    非行级:PR 标题/描述。当前 diff 里仍同时包含 DiffTransformer 模型/测试以及 XPU 脚本格式改动,但标题和描述主要只写了 Granite。建议把非 Granite 内容拆到单独 PR;如果继续放在同一个 PR,请更新标题、描述和测试计划,把 DiffTransformer 与 XPU 变更范围说清楚。
    处理要求:请针对该评论进行回复(同意并已修改请回复 Done,不同意请说明理由)。

当前 CLA 检查仍为 pending,合入前也需要处理。

Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

@@ -0,0 +1,40 @@
# Copyright (c) 2026 PaddlePaddle Authors. All Rights Reserved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 优先级:P1

问题: 当前 head 的新增 DiffTransformer 文件仍是 CRLF 行尾,另外 tests/transformers/granite/test_modeling.py 末尾还有一个多余空行。git diff --check origin/develop...HEAD 现在会直接报 trailing whitespace / EOF blank line。

影响: 这会让提交在常见的格式/检查流程里失败,也和仓库里其他 Python / shell 文件的 LF 规范不一致。

处理要求:请针对该评论修复并提交新的 commit。 请把 DiffTransformer 相关新增文件统一转换为 LF,去掉 XPU 脚本里的 # 尾空白,并删除 Granite 测试文件末尾的多余空行;修完后再跑一次 git diff --check origin/develop...HEAD

self.model = DiffTransformerModel(config)
self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias_attr=False)

def forward(self, input_ids, labels=None, attention_mask=None, **kwargs):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 优先级:P1

问题: DiffTransformerForCausalLM.forward 现在虽然出现在 AutoModelForCausalLM 路径里,但仍然把 return_dict=True 吞进 **kwargs 后直接返回裸 Tensor(loss, logits)。这和仓库里其他 CausalLM 的标准 API 不一致,outputs = model(input_ids, return_dict=True) 读不到 .logits / .loss

影响: 通用调用方、生成辅助代码和后续扩展如果按 CausalLMOutputWithPast 读取输出,会在 DiffTransformer 上失效。当前测试只校验“非空”,没有覆盖这个标准调用形态。

处理要求:请针对该评论修复并提交新的 commit。 请显式接收 return_dict,并在 return_dict=True 时返回 CausalLMOutputWithPast;同时补一条 return_dict=True 的单测。实现形态可以参考下面的结构:

from ..model_outputs import CausalLMOutputWithPast

def forward(self, input_ids, labels=None, attention_mask=None, return_dict=None, **kwargs):
    return_dict = return_dict if return_dict is not None else self.config.use_return_dict
    hidden_states = self.model(input_ids, attention_mask=attention_mask)
    logits = self.lm_head(hidden_states)
    ...
    if return_dict:
        return CausalLMOutputWithPast(loss=loss, logits=logits)
    return (loss, logits) if loss is not None else logits

Comment on lines +473 to +478
if not return_dict:
outputs = []
outputs.append(hidden_states)
if output_hidden_states:
outputs.append(all_hidden_states)
return tuple(outputs)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 优先级:P2

问题: GraniteModel 已经构造了 past_key_values,但 return_dict=False 时只返回了 hidden_states / all_hidden_states,没有按 BaseModelOutputWithPast 的字段顺序把 cache 带回去。对照仓库里同类模型(例如 Qwen2Model / LlamaModel),这里的 tuple API 少了 past_key_values

影响: 直接调用 base model 且开启 use_cache=True 时,通用代码无法从 outputs[1] 取到缓存,增量推理会退化成全量前向。建议补一条 use_cache=True, return_dict=False 的单测确认 tuple 语义。

处理要求:请针对该评论进行回复(同意并已修改请回复 Done,不同意请说明理由)。 如果保留当前 API 设计,建议至少说明为何 base model 不返回 cache;否则请按下面的顺序补齐:

Suggested change
if not return_dict:
outputs = []
outputs.append(hidden_states)
if output_hidden_states:
outputs.append(all_hidden_states)
return tuple(outputs)
if not return_dict:
outputs = [hidden_states, past_key_values]
if output_hidden_states:
outputs.append(all_hidden_states)
return tuple(v for v in outputs if v is not None)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

新提交已经把 GraniteModelreturn_dict=False tuple 输出补成了 hidden_states / past_key_values / all_hidden_states 的顺序,并新增了 test_model_cache_with_return_dict_false 覆盖 use_cache=True 的复用路径。代码层面的 concern 已经补齐;按这个线程的流程,还需要作者在这里回复 Done,我再把它收口。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@cf-icehzgzh cf-icehzgzh force-pushed the feat/add-granite-model branch from cc66ee9 to 651e862 Compare July 14, 2026 14:08
Use shifted labels for causal loss and strengthen Granite loss and generation coverage.
Remove the invalid auto lazy import and preserve loss mask semantics in causal loss.
@cf-icehzgzh cf-icehzgzh force-pushed the feat/add-granite-model branch from a58c5f2 to 6af1890 Compare July 14, 2026 16:30

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

已复查新提交:DiffTransformer 与 XPU 脚本改动已经移出本 PR,git diff --check origin/develop...HEAD 也已通过,因此此前两条 P1 阻塞问题已由新提交处理/不再适用。本次没有新增行级评论。

剩余事项:Granite base model 在 return_dict=False, use_cache=True 时的 tuple cache 语义仍在原有行级线程中等待作者回复。这是 P2,请按该线程的处理要求回复 Done 或说明保留当前 API 的理由。PR 标题和描述现在已经回到 Granite 范围,之前的范围说明问题不再适用。

Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

@paddle-bot

paddle-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

Thanks for your contribution!

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

已复查作者在 Granite cache 线程里的回复:return_dict=False, use_cache=True 的 tuple cache 语义已经通过新提交和测试补齐,原 P2 可以收口。

不过当前 Lint 检查失败,且失败点来自本 PR 的 Granite 新增文件;我已在相关行留下新的 P1 行级评论。请修复并提交新的 commit 后再复查。

Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

Comment on lines +120 to +121
q_shape = (batch_size, seq_len, -1, self.head_dim)
kv_shape = (batch_size, seq_len, -1, self.head_dim)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 优先级:P1

问题: 当前 head 的 Lint 已经失败:flake8 报出这里的 q_shape / kv_shape 是未使用变量(F841)。同一轮 Lint 日志还显示 black 会重排 paddleformers/transformers/granite/configuration.pypaddleformers/transformers/granite/modeling.pytests/transformers/granite/test_modeling.pyisort 会修改 modeling.py 和测试文件。

影响: 这是当前 CI 的失败项,会阻塞合入;即使 cache 语义已经修好,Lint 仍需要通过。

处理要求:请针对该评论修复并提交新的 commit。 请先删除这两个未使用变量,再按仓库 Lint 流程运行 make lint 或对应的 pre-commit hooks,把 black/isort 的格式化结果一起提交。

Suggested change
q_shape = (batch_size, seq_len, -1, self.head_dim)
kv_shape = (batch_size, seq_len, -1, self.head_dim)

@Paddle-CI-Bot

Copy link
Copy Markdown

PaddleFormers Log Analysis

Run #29407331659 · Attempt 1

日志分析报告

流水线名称 问题标签 修复建议 日志片段
Unittest GPU CI 其他(pytest collect error) tests/transformers/granite/ 下添加缺失的 __init__.py,消除与 kimi_k2/test_modeling.py 的模块名冲突 报错代码

失败的测试case:

ERROR tests/transformers/kimi_k2/test_modeling.py
  import file mismatch:
    imported module 'test_modeling' has __file__:
      /workspace/PaddleFormers/tests/transformers/granite/test_modeling.py
    but we want to collect:
      /workspace/PaddleFormers/tests/transformers/kimi_k2/test_modeling.py

总计:4322 passed, 328 skipped, 1 error

根本原因分析:
PR 新增了 tests/transformers/granite/test_modeling.py 但未添加 __init__.py,导致 pytest 以非包模式收集时将 granite/test_modeling.pykimi_k2/test_modeling.py 视为同名模块 test_modeling,产生 import 冲突,kimi_k2 的测试整体被跳过并上报 ERROR。

修复建议:
在本 PR 的 tests/transformers/granite/ 目录下新增空文件 __init__.py

touch tests/transformers/granite/__init__.py

提交后推送,CI 会自动重跑。


🔍 准确性记录:请点击评论底部 😊 图标,选择 👍(准确)或 👎(有误),将自动记录到 CI 监控系统

🔄 每次 Re-run 后自动更新

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

已复查当前 head:之前 Granite cache、loss mask 和旧 lint 相关问题看起来已经收口;这次合并后又出现两处会阻塞 CI 的问题,具体已放在行级评论里。请修复并提交新的 commit 后再复查。

Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

Comment thread paddleformers/transformers/__init__.py Outdated
Comment on lines 458 to 494
from .deepseek_v4 import *
from .ernie4_5 import *
from .ernie4_5_moe import *
from .ernie4_5_moe_vl import *
from .kimi_k25 import *
from .gemma3_text import *
from .gemma4_moe import *
from .glm4_moe import *
from .glm4v_moe import *
from .glm_moe_dsa import *
from .glm_ocr import *
from .gpt_oss import *
from .granite import *
from .intern import *
from .intern_lm2 import InternLM2Tokenizer
from .intern_lm2_5 import *
from .kimi_k2 import *
from .paddleocr_vl import *
from .kimi_k25 import *
from .llama import *
from .minicpm import *
from .minimax_m2 import *
from .optimization import *
from .paddleocr_vl import *
from .phi3 import *
from .phi4 import *
from .qwen2 import *
from .qwen2_5_vl import *
from .qwen2_moe import *
from .qwen2_vl import *
from .qwen3 import *
from .qwen3_5 import *
from .qwen3_moe import *
from .qwen3_next import *
from .qwen3_omni_moe import *
from .qwen3_vl import *
from .qwen3_5 import *
from .qwen3_vl_moe import *
from .qwen3_omni_moe import *
from .glm4_moe import *

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 优先级:P1

问题: 这段 TYPE_CHECKING 导入把后面已有的一批模块又提前导入了一次,当前 Lint 已经报出多条 F811 redefinition of unused ...。例如 deepseek_v4gemma3_textintern_lm2_5 等在后面的同一分支中还会再出现一次。

影响: pre-commit / flake8 会直接失败,当前 CI 的 Lint 失败就是由这里的重复导入触发的,阻塞合入。

处理要求:请针对该评论修复并提交新的 commit。 请让每个模块只在 TYPE_CHECKING 分支导入一次;下面的替换保留 Granite 以及本段中不在后续块重复的条目:

Suggested change
from .deepseek_v4 import *
from .ernie4_5 import *
from .ernie4_5_moe import *
from .ernie4_5_moe_vl import *
from .kimi_k25 import *
from .gemma3_text import *
from .gemma4_moe import *
from .glm4_moe import *
from .glm4v_moe import *
from .glm_moe_dsa import *
from .glm_ocr import *
from .gpt_oss import *
from .granite import *
from .intern import *
from .intern_lm2 import InternLM2Tokenizer
from .intern_lm2_5 import *
from .kimi_k2 import *
from .paddleocr_vl import *
from .kimi_k25 import *
from .llama import *
from .minicpm import *
from .minimax_m2 import *
from .optimization import *
from .paddleocr_vl import *
from .phi3 import *
from .phi4 import *
from .qwen2 import *
from .qwen2_5_vl import *
from .qwen2_moe import *
from .qwen2_vl import *
from .qwen3 import *
from .qwen3_5 import *
from .qwen3_moe import *
from .qwen3_next import *
from .qwen3_omni_moe import *
from .qwen3_vl import *
from .qwen3_5 import *
from .qwen3_vl_moe import *
from .qwen3_omni_moe import *
from .glm4_moe import *
from .ernie4_5 import *
from .ernie4_5_moe import *
from .ernie4_5_moe_vl import *
from .granite import *
from .kimi_k2 import *
from .kimi_k25 import *
from .llama import *
from .optimization import *
from .paddleocr_vl import *
from .qwen2 import *
from .qwen2_5_vl import *
from .qwen2_moe import *
from .qwen2_vl import *
from .qwen3 import *
from .qwen3_5 import *
from .qwen3_moe import *
from .qwen3_next import *
from .qwen3_omni_moe import *
from .qwen3_vl import *
from .qwen3_vl_moe import *
from .glm4_moe import *

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

已复查新提交:测试目录打包问题已经修复,但本线程里的 TYPE_CHECKING 重复导入仍然存在。当前 head 的 Lint 仍在 paddleformers/transformers/__init__.pyF811 redefinition,例如 493/494 行仍分别重复了 490/464 行的导入。这个 P1 还需要通过新的 commit 修复后才能收口。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

已复查新提交:TYPE_CHECKING 分支里的重复导入已经删除,flake8 也已通过;本线程对应的 P1 可以收口。

@@ -0,0 +1,327 @@
# Copyright (c) 2026 PaddlePaddle Authors. All Rights Reserved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 优先级:P1

问题: 这里新增了 tests/transformers/granite/test_modeling.py,但同目录下还没有 __init__.py。CI Bot 已经报出 pytest 收集时会把它和 tests/transformers/kimi_k2/test_modeling.py 识别成同名模块,触发 import file mismatch

影响: unittest-gpu-ci 会在收集阶段直接失败,阻塞合入;当前 worktree 中 tests/transformers/granite/ 也确实只有这个 test_modeling.py

处理要求:请针对该评论修复并提交新的 commit。 请新增空文件 tests/transformers/granite/__init__.py,让 Granite 测试目录作为包被收集,避免同名模块冲突。

touch tests/transformers/granite/__init__.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

已复查新提交:tests/transformers/granite/__init__.py 已新增,pytest 同名 test_modeling.py 收集冲突这条问题可以收口。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

已复查新提交:tests/transformers/granite/__init__.py 已补上标准版权头,当前 Lint 也已通过;本线程对应的 P1 可以收口。

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

已复查新提交:Granite 测试包初始化文件已补,原 pytest 收集冲突这条问题已经收口;但当前 Lint 仍被 paddleformers/transformers/__init__.py 的重复导入阻塞,详细情况见行级评论。请修复后再提交新的 commit。

Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

已复查这轮提交:前一个 Lint 阻塞已经收口,但 Granite 测试包的 __init__.py 仍然是空文件,copyright_checker 会改动它,导致当前 Lint 继续失败。细节已在对应线程里说明,请补上标准版权头后再提交新的 commit。

Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

已复查新提交:之前的导入重复、Granite 测试包初始化和版权头问题都已收口,Lint 也已通过。当前未发现需要继续阻塞合入的问题,详细说明见对应行级评论。

Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants