Support PaddlePaddle with compatible API#1642
Closed
SigureMo wants to merge 8 commits intoflashinfer-ai:mainfrom
Closed
Support PaddlePaddle with compatible API#1642SigureMo wants to merge 8 commits intoflashinfer-ai:mainfrom
SigureMo wants to merge 8 commits intoflashinfer-ai:mainfrom
Conversation
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.
We are PaddlePaddle contributors working on a PyTorch compatibility layer aimed at making it significantly easier for PyTorch ecosystem libraries to run on Paddle. See context: #1563
Summary
Design
import paddle as torchand run with minimal or no source changes.paddle.compat.enable_torch_proxy()2 which makesimport torchactually loadpaddle. This removes the need forimport paddle as torchin most cases and keeps changes non-invasive.Usage (example)
Install (build with compatibility enabled)
PADDLE_COMPATIBLE_API=1 pip install -v --no-build-isolation .Runtime example
Why this is opt-in
PADDLE_COMPATIBLE_API. When set, the compatibility hooks and small source adjustments are enabled. This keeps the default behavior unchanged for regular PyTorch or Paddle users.Small changes requested in flashinfer
setup.py/ AOT build: during AOT compilationsetup.pycurrently doesimport torch. For compatibility builds we need the build to performpaddle.compat.enable_torch_proxy()early (beforeimport torch), or otherwise provide a small hook so the build imports loadpaddleinstead.PADDLE_COMPATIBLE_API) inside flashinfer; if present, we enable the compatibility adjustments only in that mode.Would these minimal, environment-gated changes be acceptable to the flashinfer maintainers?
What we tested
flashinfer.fused_moe.cutlass_fused_moeinterface. With the compatibility mode enabled and some additional Python-side compatibility work in progress, we successfully ran fp16 unit tests for that interface.Next steps (proposed)
PADDLE_COMPATIBLE_API=1) and gradually increase coverage.Thank you for reviewing this PR — we welcome your feedback on the minimal integration approach and are ready to iterate on the branch or make any changes you prefer.
Footnotes
https://github.com/PaddlePaddle/Paddle/tree/develop/paddle/phi/api/include/compat ↩
https://github.com/PaddlePaddle/Paddle/blob/b38a9503d4f3f7c84af44a6399bb76ee043e7616/python/paddle/compat.py#L110 ↩