Skip to content

Conversation

@liyonghua0910
Copy link
Collaborator

@liyonghua0910 liyonghua0910 commented Dec 6, 2025

Motivation

该 PR 旨在实现两个目标:

  1. 简化 PD 分离的部署流程和参数,包括端口号配置、RDMA 网卡检测、相关环境变量设置等等工序,实现【启动 Router】→【启动 P&D 实例】→【部署完成】的简易部署流程。其中启动参数的简化也期望适用于集中式部署和多 TP/DP 部署,并兼容通过 APIServer 和 MultiAPIServer 多 DP 服务的启动方式。
  2. 重构当前代码中与端口号相关的配置处理和使用逻辑。在参数初始化时,若用户未指定端口号,自动寻找可用端口,需要支持在线服务和离线接口;在多 DP 部署场景,在配置初始化时切分好各 DP 所需的端口号,而不是在使用时才临时切分。尽量实现配置的静态化、只读化,减少运行时的配置更改。

Modifications

Usage or Command

Accuracy Tests

Checklist

  • Add at least a tag in the PR title.
    • Tag list: [[FDConfig],[APIServer],[Engine], [Scheduler], [PD Disaggregation], [Executor], [Graph Optimization], [Speculative Decoding], [RL], [Models], [Quantization], [Loader], [OP], [KVCache], [DataProcessor], [BugFix], [Docs], [CI], [Optimization], [Feature], [Benchmark], [Others], [XPU], [HPU], [GCU], [DCU], [Iluvatar], [Metax]]
    • You can add new tags based on the PR content, but the semantics must be clear.
  • Format your code, run pre-commit before commit.
  • Add unit tests. Please write the reason in this PR if no unit tests.
  • Provide accuracy results.
  • If the current PR is submitting to the release branch, make sure the PR has been submitted to the develop branch, then cherry-pick it to the release branch with the [Cherry-Pick] PR tag.

@paddle-bot
Copy link

paddle-bot bot commented Dec 6, 2025

Thanks for your contribution!

@codecov-commenter
Copy link

codecov-commenter commented Dec 6, 2025

Codecov Report

❌ Patch coverage is 50.63291% with 117 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@83ea964). Learn more about missing BASE report.

Files with missing lines Patch % Lines
fastdeploy/engine/common_engine.py 27.65% 31 Missing and 3 partials ⚠️
fastdeploy/entrypoints/openai/multi_api_server.py 52.45% 14 Missing and 15 partials ⚠️
...he_manager/transfer_factory/rdma_cache_transfer.py 3.84% 25 Missing ⚠️
fastdeploy/engine/expert_service.py 8.33% 11 Missing ⚠️
fastdeploy/utils.py 64.51% 5 Missing and 6 partials ⚠️
fastdeploy/engine/engine.py 25.00% 2 Missing and 1 partial ⚠️
fastdeploy/engine/args_utils.py 92.30% 1 Missing and 1 partial ⚠️
fastdeploy/worker/worker_process.py 0.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #5415   +/-   ##
==========================================
  Coverage           ?   59.39%           
==========================================
  Files              ?      329           
  Lines              ?    41214           
  Branches           ?     6277           
==========================================
  Hits               ?    24478           
  Misses             ?    14837           
  Partials           ?     1899           
Flag Coverage Δ
GPU 59.39% <50.63%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

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 refactors port configuration for PD-disaggregated deployments by introducing automatic port allocation and consolidating port management logic. The changes aim to simplify configuration by removing the need for users to manually specify multiple ports per service.

Key Changes

  • Introduced automatic port discovery via find_free_ports() function with validation in post_init_all_ports()
  • Centralized port extraction logic in FDConfig.postprocess() to set per-DP ports (local_engine_worker_queue_port, etc.)
  • Added RDMA environment auto-detection via new get_rdma_nics.sh script

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
fastdeploy/utils.py Added parse_ports(), find_free_ports(), and modified is_port_available() for port management
fastdeploy/engine/args_utils.py Added post_init_all_ports() to automatically allocate ports; changed default cache_transfer_protocol to "ipc,rdma"
fastdeploy/config.py Moved port extraction logic to postprocess() method; added local_engine_worker_queue_port attribute
fastdeploy/worker/worker_process.py Moved port assignment from pre-config to post-config initialization
fastdeploy/engine/engine.py Updated to use local_engine_worker_queue_port for DP queue services
fastdeploy/engine/common_engine.py Simplified port handling by using local_engine_worker_queue_port directly
fastdeploy/engine/expert_service.py Removed local port/device ID extraction logic (now handled in config)
fastdeploy/splitwise/splitwise_connector.py Changed to use scalar pd_comm_port and local_device_ids
fastdeploy/cache_manager/prefix_cache_manager.py Renamed pid_suffix to ipc_suffix; updated RDMA port usage
fastdeploy/cache_manager/cache_transfer_manager.py Renamed engine_pid to ipc_suffix for clarity
fastdeploy/cache_manager/cache_messager.py Renamed engine_pid to ipc_suffix for consistency
fastdeploy/cache_manager/transfer_factory/rdma_cache_transfer.py Added automatic RDMA environment setup and NIC detection
fastdeploy/cache_manager/transfer_factory/get_rdma_nics.sh New script for detecting RDMA-capable network interfaces
examples/splitwise/utils.sh Improved health check display with UDP port checking
examples/splitwise/start_v1_tp1.sh Simplified example by removing manual port specifications

Copy link
Contributor

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

Copilot reviewed 25 out of 25 changed files in this pull request and generated 16 comments.

Comments suppressed due to low confidence (1)

fastdeploy/engine/args_utils.py:557

  • This comment appears to contain commented-out code.
            # for port in ports:
            #     assert is_port_available("0.0.0.0", port), f"Parameter `{name}`:{port} is already in use."

Comment on lines +556 to +558
# for port in ports:
# assert is_port_available("0.0.0.0", port), f"Parameter `{name}`:{port} is already in use."

Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

The commented-out assertion for port availability check has been removed. This check was important to ensure that the specified ports are not already in use before starting the service. Without this validation, the server might fail to start with cryptic error messages, making debugging more difficult.

Consider keeping this validation, especially since the PR aims to simplify deployment. Early detection of port conflicts improves user experience.

Copilot uses AI. Check for mistakes.
Comment on lines +140 to +143
engine_worker_queue_ports = [random.randint(8000, 65535) for _ in range(data_parallel_size)]
cache_queue_ports = [random.randint(8000, 65535) for _ in range(data_parallel_size)]
pd_comm_ports = [random.randint(8000, 65535) for _ in range(data_parallel_size)]
rdma_comm_ports = [random.randint(8000, 65535) for _ in range(data_parallel_size * tensor_parallel_size)]
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

The test uses random port numbers which could lead to flaky tests. If a randomly selected port happens to be in use or reserved, the test might fail unpredictably. Additionally, using random.randint(8000, 65535) can generate duplicate port numbers across the different lists.

Consider using a deterministic sequence of ports for testing, such as:

engine_worker_queue_ports = list(range(10000, 10000 + data_parallel_size))
cache_queue_ports = list(range(11000, 11000 + data_parallel_size))
pd_comm_ports = list(range(12000, 12000 + data_parallel_size))
rdma_comm_ports = list(range(13000, 13000 + data_parallel_size * tensor_parallel_size))

This ensures deterministic, non-overlapping ports for unit tests.

Copilot uses AI. Check for mistakes.
)
except Exception as e:
logger.error(f"Failed to extract local devices or ports. Servers may not be able to start properly. {e}")

Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

The error handling in postprocess_devices_and_ports catches all exceptions and logs an error, but then continues execution. This could lead to the system running with incorrectly configured ports/devices, causing cryptic failures later.

Consider either:

  1. Re-raising the exception after logging to prevent the system from starting in a broken state
  2. Returning a boolean success indicator that callers can check
  3. Setting the config to a safe default state rather than leaving it partially configured
Suggested change
raise

Copilot uses AI. Check for mistakes.
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.

2 participants