Skip to content

[channel loss]support packing & padding free #4666

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

kevssim
Copy link
Collaborator

@kevssim kevssim commented Jun 23, 2025

PR type

  • Bug Fix
  • New Feature
  • Document Updates
  • More Models or Datasets Support

PR information

Write the detail information belongs to this PR.

Experiment results

Paste your experiment result here(if needed).

@kevssim kevssim changed the title [channel loss]support packing padding free [channel loss]support packing & padding free Jun 23, 2025
mask = flat_labels != -100

if position_ids is not None and logits.size(0) == 1:
pos = position_ids[..., :-1].view(-1).tolist()
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个可以向量化嘛

参考这里:

def get_cu_seqlens(self, position_ids, logits_to_keep) -> torch.Tensor:

方便加个 trainer.template.padding_free的检测不

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

向量化:已修改。
检测:因为packing和padding_free都需要走这部分处理逻辑,所以改为用trainer.template._packing判断,ok不

@Jintao-Huang Jintao-Huang merged commit bfb0705 into modelscope:main Jun 23, 2025
2 checks passed
@kevssim kevssim deleted the feat/ch_loss_support_packing_padding_free branch June 24, 2025 01:12
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.

2 participants