[0.18.0][BugFix]: order acl graph updates before model forward for ENPU (#8317)
<!-- Thanks for sending a pull request! BEFORE SUBMITTING, PLEASE READ https://docs.vllm.ai/en/latest/contributing/overview.html --> ### What this PR does / why we need it? <!-- - Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. If possible, please consider writing useful notes for better and faster reviews in your PR. - Please clarify why the changes are needed. For instance, the use case and bug description. - Fixes # --> For the ENPU scenario, it is required that device events follow the principle of "record first, wait later", otherwise the inference process may become stuck. However, in the current model_forward function, event.wait precedes event.record. Therefore, for the ENPU scenario, graph parameter updates should be performed before model execution. ### Does this PR introduce _any_ user-facing change? <!-- Note that it means *any* user-facing change including all aspects such as API, interface or other behavior changes. Documentation-only updates are not considered user-facing changes. --> N/A ### How was this patch tested? <!-- CI passed with new added/existing test. If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future. If tests were not added, please describe why they were not added and/or why it was difficult to add. --> --------- Signed-off-by: 1zzk <785396250@qq.com> Signed-off-by: 1kzk <785396250@qq.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1353,3 +1353,21 @@ def parse_layer_idx(prefix: str) -> int | None:
|
||||
"""Extract the layer index from a module prefix string like 'model.layers.0.self_attn'."""
|
||||
match = re.search(r"layers\.(\d+)", prefix)
|
||||
return int(match.group(1)) if match else None
|
||||
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
def _libc_getenv():
|
||||
import ctypes
|
||||
|
||||
libc = ctypes.CDLL(None)
|
||||
libc.getenv.argtypes = [ctypes.c_char_p]
|
||||
libc.getenv.restype = ctypes.c_char_p
|
||||
return libc.getenv
|
||||
|
||||
|
||||
def get_c_env(name: str, encoding: str = "utf-8") -> str | None:
|
||||
"""Read env via C getenv; returns None if unset."""
|
||||
raw = _libc_getenv()(name.encode(encoding))
|
||||
if raw is None:
|
||||
return None
|
||||
return raw.decode(encoding)
|
||||
|
||||
Reference in New Issue
Block a user