-
Notifications
You must be signed in to change notification settings - Fork 612
【Feature】add fd plugins && rm model_classes #3123
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
Merged
Conversation
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
Thanks for your contribution! |
yuanlehome
reviewed
Aug 1, 2025
qingqing01
reviewed
Aug 1, 2025
PR描述详细一下,并且添加文档,这个PR属于新增plugins特性,最好添加方案和规范指导 |
32a0bd6
to
98979f7
Compare
ming1753
reviewed
Aug 1, 2025
yuanlehome
approved these changes
Aug 4, 2025
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.
PR: Add FastDeploy Plugin Mechanism Support
Overview
This PR introduces the FastDeploy plugin mechanism, which allows users to extend functionality without modifying the core code. The key changes include:
mode_classed
FastDeploy Plugin Mechanism Documentation
FastDeploy supports a plugin mechanism that allows users to extend functionality without modifying the core code. Plugins are automatically discovered and loaded through Python's
entry_points
mechanism.How Plugins Work
Plugins are essentially registration functions that are automatically called when FastDeploy starts. The system uses the
load_plugins_by_group
function to ensure that all processes (including child processes in distributed training scenarios) have loaded the required plugins before official operations begin.Plugin Discovery Mechanism
FastDeploy uses Python's
entry_points
mechanism to discover and load plugins. Developers need to register their plugins in the specified entry point group in their project.Example: Creating a Plugin
1. Write Plugin Logic
Assuming you have a custom model class
MyModelForCasualLM
and a pretrained classMyPretrainedModel
, you can write the following registration function:2. Register Plugin in
setup.py
Plugin Structure
Plugins consist of three components:
-
fastdeploy.model_register_plugins
: for model registration-
fastdeploy.model_runner_plugins
: for model runner registrationUsers can customize groups as needed.
fd_add_dummy_model
), which can be controlled via theFD_PLUGINS
environment variable to determine whether to load the plugin.module_name:function_name
, pointing to the entry function that executes the registration logic.Controlling Plugin Loading Behavior
By default, FastDeploy loads all registered plugins. To load only specific plugins, you can set the environment variable:
export FD_PLUGINS=fastdeploy-plugins
Multiple plugin names can be separated by commas:
export FD_PLUGINS=plugin_a,plugin_b
Reference Example
Please refer to the example plugin implementation in the project directory:
It contains a complete plugin structure and
setup.py
configuration example.Summary
Through the plugin mechanism, users can easily add custom models or functional modules to FastDeploy without modifying the core source code. This not only enhances system extensibility but also facilitates third-party developers in extending functionality.
For further plugin development, please refer to the
model_registry
andplugin_loader
modules in the FastDeploy source code.