Skip to content

Conversation

@ChenCangtao
Copy link

@ChenCangtao ChenCangtao commented Nov 27, 2025

What this PR does / why we need it?

Does this PR introduce any user-facing change?

How was this patch tested?

chencangtao added 4 commits November 27, 2025 14:50
# Conflicts:
#	vllm_ascend/worker/model_runner_v1.py
Signed-off-by: chencangtao <[email protected]>
@github-actions
Copy link

👋 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.

Copy link
Contributor

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

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 support for a new NPU backend optimization path, enabled by the enable_npugraph_ex_optimize configuration. It patches vllm.compilation.compiler_interface.EagerAdaptor to use torchair for graph compilation, adds corresponding tests, and includes necessary adjustments in the model runner and rotary embedding operations. The changes appear to correctly implement the new compilation path. My main feedback is regarding code duplication in vllm_ascend/worker/model_runner_v1.py, where a workaround for handling model output is repeated. Refactoring this into a helper function would improve maintainability.

Comment on lines 2388 to 2393
# Sometimes, after the model is compiled through the AOT backend,
# the model output may become a list containing only one Tensor object.
if isinstance(hidden_states, list) and \
len(hidden_states) == 1 and \
isinstance(hidden_states[0], torch.Tensor):
hidden_states = hidden_states[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

high

This logic to unwrap a singleton list from hidden_states is also present in profile_run on lines 3102-3107. Duplicating this workaround for AOT backend output inconsistencies increases maintenance overhead and risk of future bugs if one location is updated and the other is missed. To improve maintainability, this logic should be extracted into a private helper method.
For example:

def _unwrap_singleton_list(self, output: Any) -> Any:
    """Unwraps the output if it is a list containing a single tensor."""
    if isinstance(output, list) and len(output) == 1 and isinstance(output[0], torch.Tensor):
        return output[0]
    return output

You could then replace the duplicated blocks with a call to self._unwrap_singleton_list(hidden_states).

chencangtao added 7 commits November 27, 2025 17:24
Signed-off-by: chencangtao <[email protected]>
Signed-off-by: chencangtao <[email protected]>
Signed-off-by: chencangtao <[email protected]>
Signed-off-by: chencangtao <[email protected]>
Signed-off-by: chencangtao <[email protected]>
Signed-off-by: chencangtao <[email protected]>
@ChenCangtao ChenCangtao changed the title Npubackend npugraph_ex Nov 27, 2025
@ChenCangtao ChenCangtao changed the title npugraph_ex [feature]npugraph_ex Nov 27, 2025
config = torchair.CompilerConfig()
config.debug.run_eagerly = True
config.experimental_config.aclgraph._aclnn_static_shape_kernel = True
config.debug.aclgraph.disable_mempool_reuse_in_same_fx = True
Copy link
Contributor

Choose a reason for hiding this comment

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

delete this

get_flashcomm2_oproj_tp_size_and_validate_config
self.flashcomm2_oproj_tensor_parallel_size = get_flashcomm2_oproj_tp_size_and_validate_config(
self, vllm_config)
self.enable_npugraph_ex_optimize = additional_config.get(
Copy link
Contributor

Choose a reason for hiding this comment

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

Verification is added. This function can be enabled only in fullgraph and full_decode_only scenarios.

@github-actions
Copy link

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

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.

2 participants