⚡ Bolt: Optimize rebuild_padding with lazy platform resolution#6486
⚡ Bolt: Optimize rebuild_padding with lazy platform resolution#6486
Conversation
Co-authored-by: ZeyuChen <1371212+ZeyuChen@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
|
|
Thanks for your contribution! |
Co-authored-by: ZeyuChen <1371212+ZeyuChen@users.noreply.github.com>
Co-authored-by: ZeyuChen <1371212+ZeyuChen@users.noreply.github.com>
Co-authored-by: ZeyuChen <1371212+ZeyuChen@users.noreply.github.com>
Co-authored-by: ZeyuChen <1371212+ZeyuChen@users.noreply.github.com>
Co-authored-by: ZeyuChen <1371212+ZeyuChen@users.noreply.github.com>
Co-authored-by: ZeyuChen <1371212+ZeyuChen@users.noreply.github.com>
Motivation
The
rebuild_paddingfunction infastdeploy/model_executor/pre_and_post_process.pyis called frequently during inference (potentially per token or batch step). The previous implementation performed platform checks (current_platform.is_cuda(), etc.) and imported the corresponding implementation on every call. This introduced unnecessary overhead.Modifications
_rebuild_padding_implto cache the resolved implementation.rebuild_padding. On the first call, it resolves the platform-specific function and assigns it to_rebuild_padding_impl.Usage or Command
No changes to usage. The optimization is internal.
Accuracy Tests
tests/test_rebuild_padding_opt.py(created and then deleted) which mockedfastdeploy.platforms.current_platformand the underlying ops modules.RuntimeError.Checklist
flake8andblack).PR created automatically by Jules for task 6475191789834059648 started by @ZeyuChen