Fix missing optimize/fp16/external-data handling in PIR exporter#1640
Open
982945902 wants to merge 1 commit intoPaddlePaddle:developfrom
Open
Fix missing optimize/fp16/external-data handling in PIR exporter#1640982945902 wants to merge 1 commit intoPaddlePaddle:developfrom
982945902 wants to merge 1 commit intoPaddlePaddle:developfrom
Conversation
|
|
3c711be to
3f96025
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ModelExporter::Run(const PaddlePirParser& ...)currently diverges from the legacyPaddleParserpath in a critical way: it builds the ONNX graph and immediately callsSerializeToString(&out)without applying:enable_optimizeexport_fp16_modelSaveExternalData(...)For large PIR-exported models, that means Paddle2ONNX still tries to serialize a single in-memory
ModelProto, which can exceed the protobuf 2GB limit and produce an unusable ONNX export.This change brings the PIR exporter path back in line with the legacy exporter path by applying the same post-export steps before checker/serialization.
What this patch changes
Inside
ModelExporter::Run(const PaddlePirParser& ...), this PR adds:enable_optimizeis enabledexport_fp16_modelis enabledonnx_model_.ByteSizeLong() > INT_MAXThe logic mirrors the existing implementation already used in
ModelExporter::Run(const PaddleParser& ...).Why this matters
Without this parity, PIR-exported large models can fail even though the codebase already has a supported external-data flow for large ONNX graphs.
In local validation with a real PIR-exported
uie-m-largemodel:model.onnxplusmodel.onnx.dataonnx.checker.check_model(model_path)validationScope
This PR intentionally keeps the change minimal:
If helpful, I can follow up with a focused regression test once there is an agreed-upon large-model fixture strategy for CI.