Skip to content

[Test] Add KV pool hit watch to A3 multi-nodes nightly cases - #23069

Open
Shelleyaaa wants to merge 1 commit into
vllm-project:mainfrom
Shelleyaaa:kv_pool_pd
Open

Shelleyaaa wants to merge 1 commit into
vllm-project:mainfrom
Shelleyaaa:kv_pool_pd

Conversation

@Shelleyaaa

@Shelleyaaa Shelleyaaa commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does / why we need it?

Adds a PD-only KV-pool A/B hit-watch file for the two-node A3 PD setup, plus one
deployment YAML per case. Single-node Nightly cases in test_pool_nightly.py are
left untouched; this PR is tests only and needs no product-code change.

New cases in tests/SIT/cases/features/kv_pool/test_pool_nightly_pd.py:

  • test_dsv41_pd_memcache_128k — DSV4.1-Flash-w8a8, Prefill DP4/TP1/PCP4,
    Decode DP16/TP1/PCP1, single 128K prefix (8 x 16384 + 4), memcache pool
    (layerwise producer / block consumer), A/B throughput gate.
  • test_dsv41_pd_mooncake_128k — same topology on the Mooncake pool backend
    (P2PHANDSHAKE / ascend / 20GB, non-layerwise), 128K prompt, throughput
    recorded only.
  • test_glm53_flash_pd_mooncake_130k — GLM-5.3-Flash-w8a8, Prefill
    DP2/TP1/PCP8 and Decode DP8/TP2 following GLM5.3-Flash.md §5.3 "A3 series",
    with the §5.4 pool requirements (prefix caching on both roles, hybrid KV cache
    manager kept, non-layerwise), MTP3, INT8 KV cache and HCCS device
    communication. 130K prompt (113 x 1152 + 4), Mooncake pool, A/B throughput
    gate.

How the cases run:

  • Deployment and roles follow the existing multi-node e2e path: cluster IPs come
    from LWS DNS in CI (or cluster_hosts for local non-Kubernetes runs), the node
    index from LWS_WORKER_INDEX, and the HCCL/GLOO NIC is derived from the node
    IP. No hard-coded node IP or NIC in the test.
  • Every vllm serve argument lives in the per-role YAML template. The B leg is
    derived at runtime from the A leg: drop the AscendStoreConnector and switch
    prefill to local prefix caching, keeping the B group a bare PD deployment.
  • Each leg starts both nodes through ExternalDPServerManager and the cluster
    pool service through create_kv_pool_manager, so the pool service is started
    exactly once per leg on the prefill node.
  • Pool counters are scraped from every prefill engine /metrics and summed, and
    only the counter value is kept (_created samples are filtered out). The exact
    hit-token assertion uses the model lcm: 16384 for DSV4.1 and 1152 for
    GLM-5.3-Flash.
  • GLM engines get one lookup_rpc_port each (37000+rank on Prefill,
    37100+rank on Decode) through a small ServerCommandBuilder subclass, since
    AscendStoreConnector requires a unique lookup port per engine.
  • Within a leg: secret-number accuracy, then R1 cold write / R2-R3 hits / R4
    isolation, then 3 timed perf samples at concurrency 4 with a batch of 8; the B
    leg runs cold + one local-hit round + the same perf sampling.

Notes and known limits:

  • DSpark cases record H3 only, the same class as the existing P3 case; the
    GLM-5.3-Flash case keeps the H3 assertion.
  • The 128K Mooncake case records throughput only; the memcache and GLM cases gate
    throughput_A >= throughput_B * 0.85.
  • nightly_config.yaml / estimated_times.yaml entries are intentionally not
    part of this change; the two-node runner registration will follow separately.

Does this PR introduce any user-facing change?

No. Tests only.

How was this patch tested?

  • Static validation on the two-node containers: py_compile, and
    pytest --collect-only collects the three cases. Each YAML was loaded with a
    temporary cluster_hosts copy to verify rank expansion, device slicing, port
    mapping and per-engine lookup ports for both roles.

  • Two-node E2E on the 133/135 PD setup with the local cluster_hosts YAML:
    pytest -s -k <case> on both nodes; [kv_pool] / [kv_pool_ab] lines and
    pool_ab_report.json are attached to the PR.

  • vLLM main: vllm-project/vllm@c410543

@github-actions

Copy link
Copy Markdown
Contributor

👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:‌‌

  • A PR should do only one thing, smaller PRs enable faster reviews.
  • Every PR should include unit tests and end-to-end tests ‌to ensure it works and is not broken by other future PRs.
  • Write the commit message by fulfilling the PR description to help reviewer and future developers understand.

If CI fails, you can run linting and testing checks locally according Contributing and Testing.

🤖 How to trigger CI

CI runs automatically when the PR is opened or reopened. Pushing a new commit no longer re-runs the E2E CI (to save NPU runner resources), so use the comment commands below when needed. They are available to the PR author and users with triage permission or above:

  • /run — run the full PR CI gate on the latest commit.
  • /rerun — re-run the failed CI jobs (e.g. after a flaky failure).
  • /e2e — run selected E2E tests instead of the full gate.
  • /nightly / /presmoke / /weekly — run the corresponding large-scale tests (triage permission or above; blocked during the nightly maintenance window).
  • /cancel — cancel a running CI on this PR.

Note

Until the CI gate has run on a commit, the required ci-gate check stays pending and the PR cannot merge — remember to comment /run after pushing.

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

Copy link
Copy Markdown
Contributor

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 introduces new SIT test cases for KV pool watch in a two-node PD setup, adding configurations for DSv4.1 and GLM5.3 models, and updates the nightly test suite. The review comments provide actionable improvements for resource management in the control server, error handling for the decode node to facilitate debugging, and more robust exception handling during teardown.

Comment on lines +265 to +280
def __enter__(self) -> _ControlServer:
listener = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
listener.bind(("0.0.0.0", self.port))
listener.listen(1)
listener.settimeout(float(self.timeout))
self._listener = listener
print(f"[kv_pool_pd] wait decode node on control port {self.port}", flush=True)
try:
connection, peer = listener.accept()
except socket.timeout as exc:
raise TimeoutError(f"decode node did not connect on port {self.port} in {self.timeout}s") from exc
connection.settimeout(None)
print(f"[kv_pool_pd] decode node connected from {peer}", flush=True)
self.channel = _ControlChannel(connection)
return self

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

In _ControlServer.__enter__, if listener.accept() raises an exception (such as socket.timeout), the listener socket is leaked because __exit__ is never called. This can lead to resource leaks and 'Address already in use' errors on subsequent test runs. Wrap the connection acceptance in a try...except block to ensure the listener is closed if an exception occurs before returning.

    def __enter__(self) -> _ControlServer:
        listener = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        listener.bind(("0.0.0.0", self.port))
        listener.listen(1)
        listener.settimeout(float(self.timeout))
        self._listener = listener
        print(f"[kv_pool_pd] wait decode node on control port {self.port}", flush=True)
        try:
            connection, peer = listener.accept()
        except socket.timeout as exc:
            listener.close()
            self._listener = None
            raise TimeoutError(f"decode node did not connect on port {self.port} in {self.timeout}s") from exc
        except Exception:
            listener.close()
            self._listener = None
            raise
        connection.settimeout(None)
        print(f"[kv_pool_pd] decode node connected from {peer}", flush=True)
        self.channel = _ControlChannel(connection)
        return self

Comment on lines +454 to +490
def _run_decode_legs(base: ExternalDPConfig, ranks: list[RankInfo], node_index: int, case: PDCase) -> None:
"""Serve decode legs until the P node sends exit."""
channel = _connect_control(base.cluster_ips[0], case.control_port)
try:
while True:
message = channel.recv()
command = message.get("cmd")
if command == "start":
use_pool = bool(message.get("use_pool"))
leg = str(message["leg"])
config = _config_for_node(_leg_config(base, use_pool=use_pool), node_index)
log_root = LOG_ROOT / leg
with create_kv_pool_manager(
config=config, current_node_index=node_index, log_root=log_root
) as pool_manager:
with _KVPoolServerManager(
config=config,
ranks=ranks,
current_node_index=node_index,
log_root=log_root,
extra_envs=pool_manager.server_envs,
):
wait_ranks_ready(ranks, timeout=READY_TIMEOUT_SECONDS)
channel.send({"event": "ready"})
stop = channel.recv()
if stop.get("cmd") != "stop":
raise RuntimeError(f"expected stop, got {stop!r}")
channel.send({"event": "stopped"})
elif command == "exit":
with contextlib.suppress(Exception):
channel.send({"event": "closed"})
return
else:
raise RuntimeError(f"unknown control command: {command!r}")
finally:
channel.close()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

In _run_decode_legs, if an exception occurs during command execution (e.g., wait_ranks_ready times out), the decode node crashes and closes the channel. The prefill node only receives a generic ConnectionError instead of the actual error traceback, making debugging in CI extremely difficult. Wrap the command loop body in a try...except block to send the error event back to the prefill node before re-raising.

def _run_decode_legs(base: ExternalDPConfig, ranks: list[RankInfo], node_index: int, case: PDCase) -> None:
    """Serve decode legs until the P node sends exit."""
    channel = _connect_control(base.cluster_ips[0], case.control_port)
    try:
        while True:
            try:
                message = channel.recv()
                command = message.get("cmd")
                if command == "start":
                    use_pool = bool(message.get("use_pool"))
                    leg = str(message["leg"])
                    config = _config_for_node(_leg_config(base, use_pool=use_pool), node_index)
                    log_root = LOG_ROOT / leg
                    with create_kv_pool_manager(
                        config=config, current_node_index=node_index, log_root=log_root
                    ) as pool_manager:
                        with _KVPoolServerManager(
                            config=config,
                            ranks=ranks,
                            current_node_index=node_index,
                            log_root=log_root,
                            extra_envs=pool_manager.server_envs,
                        ):
                            wait_ranks_ready(ranks, timeout=READY_TIMEOUT_SECONDS)
                            channel.send({"event": "ready"})
                            stop = channel.recv()
                            if stop.get("cmd") != "stop":
                                raise RuntimeError(f"expected stop, got {stop!r}")
                    channel.send({"event": "stopped"})
                elif command == "exit":
                    with contextlib.suppress(Exception):
                        channel.send({"event": "closed"})
                    return
                else:
                    raise RuntimeError(f"unknown control command: {command!r}")
            except Exception as exc:
                with contextlib.suppress(Exception):
                    channel.send({"event": "error", "error": str(exc)})
                raise
    finally:
        channel.close()

Comment on lines +424 to +452
try:
with pool_manager:
channel.send({"cmd": "start", "leg": case_name, "use_pool": use_pool})
with _KVPoolServerManager(
config=config,
ranks=ranks,
current_node_index=node_index,
log_root=log_root,
extra_envs=pool_manager.server_envs,
):
wait_ranks_ready(ranks, timeout=READY_TIMEOUT_SECONDS)
channel.recv() # {"event": "ready"} from the decode node
print(f"[kv_pool_pd] leg={case_name} pool={int(use_pool)} both nodes ready", flush=True)
yield _PDWatchClient(
_ranks_by_role(ranks, "prefiller"),
_ranks_by_role(ranks, "decoder"),
served_model_name,
)
finally:
body_failed = sys.exc_info()[0] is not None
teardown_error: Exception | None = None
try:
channel.send({"cmd": "stop"})
channel.recv() # {"event": "stopped"} from the decode node
except Exception as exc: # noqa: BLE001 - keep the body error as the diagnosis
teardown_error = exc
if teardown_error is not None and not body_failed:
raise RuntimeError(f"decode node did not stop cleanly: {teardown_error}") from teardown_error

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Using sys.exc_info() inside a finally block to detect if the body failed is fragile and discouraged in modern Python. It is much cleaner and more robust to use an explicit try...except block around the yield statement to set a body_failed flag.

    body_failed = False
    try:
        with pool_manager:
            channel.send({"cmd": "start", "leg": case_name, "use_pool": use_pool})
            with _KVPoolServerManager(
                config=config,
                ranks=ranks,
                current_node_index=node_index,
                log_root=log_root,
                extra_envs=pool_manager.server_envs,
            ):
                wait_ranks_ready(ranks, timeout=READY_TIMEOUT_SECONDS)
                channel.recv()  # {"event": "ready"} from the decode node
                print(f"[kv_pool_pd] leg={case_name} pool={int(use_pool)} both nodes ready", flush=True)
                yield _PDWatchClient(
                    _ranks_by_role(ranks, "prefiller"),
                    _ranks_by_role(ranks, "decoder"),
                    served_model_name,
                )
    except Exception:
        body_failed = True
        raise
    finally:
        teardown_error: Exception | None = None
        try:
            channel.send({"cmd": "stop"})
            channel.recv()  # {"event": "stopped"} from the decode node
        except Exception as exc:  # noqa: BLE001 - keep the body error as the diagnosis
            teardown_error = exc
        if teardown_error is not None and not body_failed:
            raise RuntimeError(f"decode node did not stop cleanly: {teardown_error}") from teardown_error

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Last updated: 2026-11-25 14:59 UTC+8 for commit 8b9205a.

ci-gate failed. Reason:

pre-commit failed (lint / markdownlint / mypy / gitleaks). Open the failed 'pre-commit' job above, fix the reported issues in your PR, and push again. No test label is needed for this failure.

See the workflow run for full logs. This comment is updated in place on each new failure and marked as passed once the gate passes (it is kept for history, not deleted).

wenjun91 pushed a commit that referenced this pull request Nov 25, 2026
…kflow (#23112)

### What this PR does / why we need it?

Nightly multi-node cases are launched by a single generic pytest entry
(`tests/e2e/common/multi_node/test_multi_node.py` ->
`test_external_dp()`), so a
case YAML cannot currently choose a different test runner.

The companion case PR
#23069
adds the KV pool A/B hit-watch cases for the A3 PD multi-node jobs. Each
of those
cases keeps its own A/B parameters in the case YAML (`pool_ab:` block)
and has to
run `tests/SIT/cases/features/kv_pool/test_pool_ab.py::test_pool_ab`
instead of
the generic entry. Without a way to select the entry from the case
config, those
cases would silently run `test_external_dp()` and do nothing useful.

This PR only adds that plumbing; it contains no case YAML, no test logic
and no
runtime change.

It adds an optional `tests` field end to end:

- `.github/workflows/_e2e_nightly_multi_node.yaml`: new optional `tests`
input
  (default empty), forwarded to the LWS template as `-D tests=...`.
- `.github/workflows/schedule_nightly_test_a3.yaml`: pass
`matrix.test_config.tests` for the `multi-node-tests` and
`double-node-tests`
  jobs.
- `tests/e2e/common/multi_node/lws.yaml.jinja2`: when `tests` is
non-empty,
export `MULTI_NODE_TEST_PATH` in both the leader and the worker
containers, so
  every pod in the LWS group runs the same pytest entry.

The change is fully backward compatible: with the default empty value
the
template emits no `MULTI_NODE_TEST_PATH`, and `run.sh` keeps its current
default
(`tests/e2e/common/multi_node/test_multi_node.py`). No existing nightly
entry
sets `tests`.

Reviewer note / merge order:

- This plumbing must land before
#23069 (or any case PR
that
sets `tests`). Without it the pod silently falls back to the generic
entry,
  which is a no-op for YAMLs that declare `benchmarks: {}`.
- #23069 was branched from the same work and currently carries identical
copies
of these three files. Once this PR is on `main`, #23069 will rebase and
drop
  them, leaving only the case files.

### Does this PR introduce _any_ user-facing change?

No. It only changes how nightly CI pods select the pytest entry; the
test
content and the runtime path are untouched.

### How was this patch tested?

- Static verification of the template guard (`{% if tests | default('')
%}`):
`MULTI_NODE_TEST_PATH` is emitted only for a non-empty value, in both
the
  leader and worker container specs.
- Verified the fallback in `tests/e2e/common/multi_node/run.sh`:
  `MULTI_NODE_TEST_PATH` defaults to
`tests/e2e/common/multi_node/test_multi_node.py` when the variable is
unset,
  so all current multi-node cases keep exactly the old behavior.
- Checked the input plumbing across the three files
(`inputs.tests` -> `-D tests=` -> pod env) and confirmed the matrix jobs
pass
  the per-case value for both two-node and four-node groups.
- No engine or NPU run is required for this change. The companion case
PR
#23069 exercises the new
entry
  through `/nightly <case-name>` once this PR is on `main`.

- vLLM main:
vllm-project/vllm@c410543

---------

Signed-off-by: songyang <songyang719@163.com>
@lizy124 lizy124 added the ready-precise run selected e2e test for pr label Nov 25, 2026
@lizy124

lizy124 commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

/nightly dsv41-pd-memcache-128k,dsv41-pd-mooncake-128k
nightly command triggered.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

2 similar comments
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@lizy124

lizy124 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

/nightly dsv41-pd-memcache-128k
nightly command triggered.

@zhenwenqi2024 zhenwenqi2024 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The description says this is tests-only, but the diff also includes #23195's NPUModelRunner.update_requests() stream synchronization, its unit test, and release_notes/fragments/23195.yaml. Is that temporary stacking for the nightly run? If so, could this PR depend on #23195 explicitly and drop those three hunks from the PR against main after the dependency lands? The nightly result would then be clearly attributable to the combined branch without landing the MRV2 runtime change through the test PR.

@Shelleyaaa

Copy link
Copy Markdown
Contributor Author

The description says this is tests-only, but the diff also includes #23195's NPUModelRunner.update_requests() stream synchronization, its unit test, and release_notes/fragments/23195.yaml. Is that temporary stacking for the nightly run? If so, could this PR depend on #23195 explicitly and drop those three hunks from the PR against main after the dependency lands? The nightly result would then be clearly attributable to the combined branch without landing the MRV2 runtime change through the test PR.

Yes, that's temporary stacking for the nightly accuracy validation. We pulled #23195 in only to confirm that the layerwise tail-block fix keeps the A-leg answer correct on the rebased branch. Once #23195 lands, we will rebase this PR, drop those three hunks (update_requests() , its unit test, andrelease_notes/fragments/23195.yaml ), and keep this PR tests-only. We do not intend to land the MRV2 runtime change through the test PR; until then the nightly result should be read as the combined branch.

@lizy124

lizy124 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

/nightly dsv4-mooncake-dp4-colocation
nightly command triggered.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@Shelleyaaa Shelleyaaa closed this Nov 26, 2026
@github-actions github-actions Bot removed the ready-precise run selected e2e test for pr label Nov 26, 2026
@Shelleyaaa Shelleyaaa reopened this Nov 26, 2026
@lizy124

lizy124 commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

/nightly dsv41-pd-memcache-128k,dsv41-pd-mooncake-128k,dsv4-mooncake-dp4-colocation
nightly command triggered.

@lizy124

lizy124 commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

/nightly dsv41-pd-memcache-128k,dsv41-pd-mooncake-128k,dsv4-mooncake-dp4-colocation
nightly command triggered.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@Shelleyaaa

Shelleyaaa commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

/e2e tests/e2e/pull_request/four_card/model_runner_v2/test_spec_decode_data_parallel.py::test_deepseek_v4_dspark_spec_decoding_dp4_full_graph
[Bot]: e2e command triggered. See workflow run for details.
[Bot]: e2e command failed.

Signed-off-by: songyang <songyang719@163.com>
@Shelleyaaa

Shelleyaaa commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

/e2e tests/e2e/pull_request/four_card/model_runner_v2/test_spec_decode_data_parallel.py::test_deepseek_v4_dspark_spec_decoding_dp4_full_graph
[Bot]: e2e command triggered. See workflow run for details.
[Bot]: e2e command completed successfully.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants