Skip to content

Simplify the Config code #2770

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 25 commits into from
Jul 14, 2025
Merged

Conversation

YuanRisheng
Copy link
Collaborator

@YuanRisheng YuanRisheng commented Jul 9, 2025

该PR做了如下工作:

  • 简化所有Config创建,去除字段二次映射,支持外部模型配置文件中的字段自动映射到ModelConfig中
  • 命名规范化,Config中的字段名称与外部传参,外部配置文件中的字段保持一致
  • 模型端的Config使用统一,去除多模configuration文件

Copy link

paddle-bot bot commented Jul 9, 2025

Thanks for your contribution!

@yuanlehome yuanlehome requested a review from Copilot July 9, 2025 13:05
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR simplifies and standardizes configuration handling by:

  • Renaming configuration fields (e.g., max_lengthmax_model_len, tensor_parallel_degreetensor_parallel_size, num_layersnum_hidden_layers)
  • Consolidating many per‐config dataclasses into __init__(args)‐based classes
  • Updating all references across runners, models, and layers to use the new field names

Reviewed Changes

Copilot reviewed 28 out of 29 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
fastdeploy/worker/xpu_model_runner.py Updated max token length and layer count references
fastdeploy/worker/worker_process.py Switched all TP/EP degree names; overhauled initialize_fd_config
fastdeploy/worker/vl_gpu_model_runner.py Aligned VL runner to new config constructors and naming
fastdeploy/worker/gpu_model_runner.py Mirror updates from XPU runner for GPU runner
fastdeploy/spec_decode/mtp.py Replaced num_layers with num_hidden_layers in MTP proposer
fastdeploy/rl/rollout_model.py Aligned MoE config references to new model_config fields
fastdeploy/model_executor/models/tp_utils.py Renamed TP degree check
fastdeploy/model_executor/models/*.py Bulk replace of tensor_parallel_degree, num_layers, and model config checks across all model implementations
fastdeploy/config.py Major rewrite: removed dataclasses, introduced args‐driven inits
Comments suppressed due to low confidence (1)

fastdeploy/model_executor/models/model_base.py:56

  • The docstring mentions 'vocab_size, use_topp_sampling, etc.' but the initializer only takes a single 'configs' dict. Update the doc to reflect the actual signature, e.g., 'configs (dict): configuration parameters including ...'.
                vocab_size, use_topp_sampling, etc.

# Set default block num for profile run
self.max_block_num: int = 2000
# block size
self.block_size: int = 64
Copy link
Preview

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ParallelConfig.__init__ sets block_size twice (first to 16, then to 64), leading to conflicting defaults. Remove the redundant assignment to ensure a single authoritative default.

Copilot uses AI. Check for mistakes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

yuanlehome
yuanlehome previously approved these changes Jul 10, 2025
Copy link
Collaborator

@yuanlehome yuanlehome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

#
eos_tokens_lens: int = 2
# Enable chunked prefill
enable_chunked_prefill: str = "store_true"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么不是个bool

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是bool,你看我修改后的代码是改为bool的

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image 这里还是str

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

谢谢指出,之前处理冲突的时候覆盖掉bool了

Comment on lines +335 to 342
for key, value in args.items():
if hasattr(self, key):
setattr(self, key, value)
capture_size = [i for i in range(1, max_capture_batch_size + 1)]
self.init_with_cudagrpah_size(cudagraph_capture_sizes=capture_size)
self.use_cudagraph = use_cudagraph
#TODO(wangmingkai02): change graph_opt_level=2 when using static mode with cinn
if enable_static_graph_inference:
self.graph_opt_level = 1
Copy link
Collaborator

@gongshaotian gongshaotian Jul 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. args 传入的参数来自 config.json 还是启动参数
  2. 把参数默认值统一放在 init() 里的目的是什么,原本的写法相当于把参数的声明、默认值设置和根据用户配置( config.json、 启动参数)设置分开了,代码看起来比较好区分

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1,args来自启动参数,2,主要满足config全局统一管理的特性,比如rl有些场景不需要args传参,会自己传一些参数,如果缺乏默认值,会没有对应的字段,后续执行代码会有问题

Copy link
Collaborator

@gongshaotian gongshaotian Jul 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. done 2.是为了满足 hasattr() 对吗

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的

self.args.max_capture_batch_size)
self.args.enable_static_graph_inference,
self.args.max_capture_batch_size,
vars(self.args))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

类似use_cudagraph 的参数都通过 args 传递了,当用户配置参数名和config 参数名不一致,会有风险

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里我们必须是传参的参数名要和config里的字段名一致,不一致就用不了,这也是修改后通过代码来做的强制规范

@YuanRisheng YuanRisheng merged commit 4c7b8bc into PaddlePaddle:develop Jul 14, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants