-
Notifications
You must be signed in to change notification settings - Fork 635
[Bugfix] fix custom op GmmSwigluQuantWeightNzTensorList #4593
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
Conversation
Signed-off-by: QianChenxi <[email protected]>
There was a problem hiding this 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 includes a bug fix and a performance optimization. In vllm_ascend/platform.py, a duplicated path segment in the construction of CUSTOM_OPP_PATH is corrected, which is a necessary fix. In csrc/torch_binding.cpp, at::zeros is replaced with at::empty for output tensor allocation, which is a good performance improvement. However, I've identified a related critical issue that should be addressed.
| at::Tensor output = at::empty({m, n/2}, x.options().dtype(at::kChar)); | ||
| at::Tensor output_scale = at::empty({m}, x.options().dtype(at::kFloat)); | ||
| at::Tensor output_offset = at::empty({m}, x.options().dtype(at::kFloat)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The size of these output tensors depends on n, which is calculated on line 567 from the weight TensorList (weight[0].sizes()[1]). This is unsafe because if the weight TensorList is empty, accessing weight[0] will cause a crash. It's crucial to add a check to ensure weight is not empty before its elements are accessed.
For example, you could add the following check before line 567:
TORCH_CHECK(!weight.empty(), "weight tensor list cannot be empty");|
👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:
If CI fails, you can run linting and testing checks locally according Contributing and Testing. |
a34ddcf to
71cf0c4
Compare
b1c3922 to
29191fb
Compare
Signed-off-by: QianChenxi <[email protected]>
29191fb to
5486458
Compare
| global _CUSTOM_OP_ENABLED | ||
|
|
||
| # set custom ops path | ||
| CUR_DIR = os.path.dirname(os.path.realpath(__file__)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wangxiyuan This line causes the test tests/e2e/multicard/test_offline_inference_distributed.py::test_models_distributed_QwQ to fail.
os.path.realpath involves system calls that are not supported by torch.compile (Dynamo) during graph capture. This triggers a runtime crash when graph mode is enabled.
Maybe move the CUR_DIR calculation to the module level (global scope) to avoid this trace error and unnecessary re-calculation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I found it. Thanks for reminding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…-project#4593)" This reverts commit 4588cda.
…#4593) ### What this PR does / why we need it? 1. Fixes the environment path used to locate custom op shared libraries. 2. Uses empty tensor initialization for op outputs instead of zero-initialization for better efficiency. - vLLM version: v0.11.2 - vLLM main: https://github.com/vllm-project/vllm/commit/v0.11.2 --------- Signed-off-by: QianChenxi <[email protected]>
…#4593) ### What this PR does / why we need it? 1. Fixes the environment path used to locate custom op shared libraries. 2. Uses empty tensor initialization for op outputs instead of zero-initialization for better efficiency. - vLLM version: v0.11.2 - vLLM main: https://github.com/vllm-project/vllm/commit/v0.11.2 --------- Signed-off-by: QianChenxi <[email protected]> Signed-off-by: Che Ruan <[email protected]>
…#4593) ### What this PR does / why we need it? 1. Fixes the environment path used to locate custom op shared libraries. 2. Uses empty tensor initialization for op outputs instead of zero-initialization for better efficiency. - vLLM version: v0.11.2 - vLLM main: https://github.com/vllm-project/vllm/commit/v0.11.2 --------- Signed-off-by: QianChenxi <[email protected]> Signed-off-by: Che Ruan <[email protected]>
…#4593) ### What this PR does / why we need it? 1. Fixes the environment path used to locate custom op shared libraries. 2. Uses empty tensor initialization for op outputs instead of zero-initialization for better efficiency. - vLLM version: v0.11.2 - vLLM main: https://github.com/vllm-project/vllm/commit/v0.11.2 --------- Signed-off-by: QianChenxi <[email protected]>
What this PR does / why we need it?
Does this PR introduce any user-facing change?
How was this patch tested?