Skip to content

Refactor DSpark disagg - #645

Merged
zhangxiaolei123456 merged 2 commits into
deepseev_v4_dpsark_pd_devfrom
fix/dspark-review-dedupe-current
Jul 20, 2026
Merged

zhangxiaolei123456 merged 2 commits into
deepseev_v4_dpsark_pd_devfrom
fix/dspark-review-dedupe-current

Conversation

@zhangxiaolei123456

@zhangxiaolei123456 zhangxiaolei123456 commented Jul 20, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Modifications

Accuracy Tests

Speed Tests and Profiling

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test (Base): ❌ Run #29752805296
Latest PR Test (Extra): ❌ Run #29752805120

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the disaggregation metadata configuration and hidden bootstrap plan resolution by extracting the logic into a new module, 'dspark_disaggregation.py', and renaming several 'DSpark' prefixed classes to 'PD' equivalents. The review feedback suggests improving robustness in the new module by converting string enum values to lowercase before comparison and using 'or []' or 'or 0' instead of '.get(..., [])' or '.get(..., 0)' to safely handle cases where dictionary values might be explicitly set to 'None'.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +85 to +87
mode_value = getattr(disaggregation_mode, "value", disaggregation_mode)
if mode_value not in ("decode", "prefill"):
return DSparkDisaggMetadataConfig()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

To ensure robustness against case-sensitivity issues, it is recommended to convert mode_value to lowercase before checking if it is in the allowed set of modes. This prevents potential runtime issues if the enum values or strings are passed in uppercase or mixed-case.

    mode_value = getattr(disaggregation_mode, "value", disaggregation_mode)
    if isinstance(mode_value, str):
        mode_value = mode_value.lower()
    if mode_value not in ("decode", "prefill"):
        return DSparkDisaggMetadataConfig()

Comment on lines +101 to +106
backend_value = getattr(transfer_backend, "value", transfer_backend)
if backend_value not in ("mooncake", "fake"):
raise NotImplementedError(
"DSpark PD hidden transfer is implemented only for Mooncake/Fake "
f"backends, got {backend_value}."
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Similarly, backend_value should be converted to lowercase to handle potential case mismatches robustly.

Suggested change
backend_value = getattr(transfer_backend, "value", transfer_backend)
if backend_value not in ("mooncake", "fake"):
raise NotImplementedError(
"DSpark PD hidden transfer is implemented only for Mooncake/Fake "
f"backends, got {backend_value}."
)
backend_value = getattr(transfer_backend, "value", transfer_backend)
if isinstance(backend_value, str):
backend_value = backend_value.lower()
if backend_value not in ("mooncake", "fake"):
raise NotImplementedError(
"DSpark PD hidden transfer is implemented only for Mooncake/Fake "
f"backends, got {backend_value}."
)

Comment on lines +179 to +192
local_layer_ids = (
[int(x) for x in local_pp_slice.get("layer_ids", [])]
if local_pp_slice
else (
[]
if pp_slices
else [int(x) for x in metadata.get("target_layer_ids", [])]
)
)
local_slice_len = (
int(local_pp_slice.get("slice_len", 0))
if local_pp_slice
else len(local_layer_ids) * int(model_config.hidden_size)
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using .get(..., []) or .get(..., 0) can return None if the key exists in the dictionary but its value is explicitly set to None (e.g., from a parsed JSON null). To prevent a TypeError during iteration or type conversion, use or [] and or 0 instead.

Suggested change
local_layer_ids = (
[int(x) for x in local_pp_slice.get("layer_ids", [])]
if local_pp_slice
else (
[]
if pp_slices
else [int(x) for x in metadata.get("target_layer_ids", [])]
)
)
local_slice_len = (
int(local_pp_slice.get("slice_len", 0))
if local_pp_slice
else len(local_layer_ids) * int(model_config.hidden_size)
)
local_layer_ids = (
[int(x) for x in (local_pp_slice.get("layer_ids") or [])]
if local_pp_slice
else (
[]
if pp_slices
else [int(x) for x in (metadata.get("target_layer_ids") or [])]
)
)
local_slice_len = (
int(local_pp_slice.get("slice_len") or 0)
if local_pp_slice
else len(local_layer_ids) * int(model_config.hidden_size)
)

Comment on lines +231 to +238
dst_indices = [
int(x)
for x in (
local_pp_slice.get("dst_indices", [])
if local_pp_slice
else metadata.get("dst_indices", [])
)
]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Similarly, use or [] instead of .get(..., []) to safely handle cases where dst_indices might be explicitly set to None in the metadata.

Suggested change
dst_indices = [
int(x)
for x in (
local_pp_slice.get("dst_indices", [])
if local_pp_slice
else metadata.get("dst_indices", [])
)
]
dst_indices = [
int(x)
for x in (
local_pp_slice.get("dst_indices") or []
if local_pp_slice
else metadata.get("dst_indices") or []
)
]

@zhangxiaolei123456 zhangxiaolei123456 changed the title Refactor DSpark disagg metadata setup Refactor DSpark disagg Jul 20, 2026
@zhangxiaolei123456
zhangxiaolei123456 force-pushed the fix/dspark-review-dedupe-current branch 2 times, most recently from 035e308 to 10e6a6a Compare July 20, 2026 13:14
@zhangxiaolei123456
zhangxiaolei123456 force-pushed the fix/dspark-review-dedupe-current branch from 10e6a6a to f65f7ad Compare July 20, 2026 14:32
@zhangxiaolei123456
zhangxiaolei123456 merged commit 28b0747 into deepseev_v4_dpsark_pd_dev Jul 20, 2026
72 of 82 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant