Skip to content

Add dynamo ONNX export with fallback#212

Merged
1985312383 merged 2 commits intodatawhalechina:mainfrom
1985312383:main
Apr 5, 2026
Merged

Add dynamo ONNX export with fallback#212
1985312383 merged 2 commits intodatawhalechina:mainfrom
1985312383:main

Conversation

@1985312383
Copy link
Copy Markdown
Collaborator

Pull Request / 拉取请求

What does this PR do? / 这个PR做了什么?

Enable Dynamo-based ONNX export with support for torch.export dynamic_shapes and automatic fallback to the legacy exporter. Adds _build_dynamic_shapes to construct dynamo-friendly dynamic_shapes for sequence and sparse features, updates ONNX export logic to prefer dynamo (injecting dynamic_shapes when dynamic_batch=True), and retries with the legacy exporter on failure. Also updates trainer docstrings to document the new "dynamo" onnx_export_kwargs, adds tests for DIN ONNX export covering sequence features and dynamic-batch behavior, and updates pyproject.toml to include ml-dtypes and onnxscript in the onnx extras.

Type of Change / 变更类型

  • 🐛 Bug fix / Bug修复
  • ✨ New model/feature / 新模型/功能
  • 📝 Documentation / 文档
  • 🔧 Maintenance / 维护

Related Issues / 相关Issues

Fixes #211

How to Test / 如何测试

# Example of how to test your changes / 如何测试您的更改的示例

Checklist / 检查清单

  • Code follows project style (ran python config/format_code.py) / 代码遵循项目风格(运行了格式化脚本)
  • Added tests for new functionality / 为新功能添加了测试
  • Updated documentation if needed / 如需要已更新文档
  • All tests pass locally / 所有测试在本地通过

Additional Notes / 附加说明

Any other information for reviewers / 给审查者的其他信息

Enable Dynamo-based ONNX export with support for torch.export dynamic_shapes and automatic fallback to the legacy exporter. Adds _build_dynamic_shapes to construct dynamo-friendly dynamic_shapes for sequence and sparse features, updates ONNX export logic to prefer dynamo (injecting dynamic_shapes when dynamic_batch=True), and retries with the legacy exporter on failure. Also updates trainer docstrings to document the new "dynamo" onnx_export_kwargs, adds tests for DIN ONNX export covering sequence features and dynamic-batch behavior, and updates pyproject.toml to include ml-dtypes and onnxscript in the onnx extras.
@github-actions github-actions bot added enhancement New feature or request | 新功能 dependencies Dependency updates | 依赖更新 labels Apr 5, 2026
Add `from __future__ import annotations` to config/generate_api_md.py and expand/clarify API documentation in both English and Chinese. Docs changes clarify the ONNX exporter behavior (dynamo vs legacy fallback and how to force a path), translate and expand SeqTrainer docs (parameters, loss options, logger, eval_step), and add RQVAE-specific methods and return-value details. These updates improve clarity and consistency across the generated API docs.
@1985312383 1985312383 marked this pull request as ready for review April 5, 2026 17:00
@1985312383 1985312383 merged commit a599782 into datawhalechina:main Apr 5, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Dependency updates | 依赖更新 enhancement New feature or request | 新功能

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] DIN模型导出onnx失败

1 participant