[bugfix][npugraph_ex]duplicate pattern issue (#6513)
### What this PR does / why we need it? When the draft model also uses vllmbackend for graph compilation, the fusion pass registration occurs again, resulting in errors due to duplicate patterns. ### Does this PR introduce _any_ user-facing change? ### How was this patch tested? - vLLM version: v0.15.0 - vLLM main: https://github.com/vllm-project/vllm/commit/v0.15.0 --------- Signed-off-by: chencangtao <chencangtao@huawei.com> Co-authored-by: chencangtao <chencangtao@huawei.com>
This commit is contained in:
@@ -51,3 +51,25 @@ def extra_stream_scope_check(match: Match) -> bool:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
_register_patterns = set()
|
||||
|
||||
|
||||
def check_and_register_fusion_pass(pattern_class: type, **kwargs):
|
||||
global _register_patterns
|
||||
eps = kwargs.get("eps", 1e-6)
|
||||
pattern_key = str(pattern_class.__name__) + str(eps)
|
||||
if pattern_key in _register_patterns:
|
||||
return
|
||||
|
||||
pattern = pattern_class(**kwargs)
|
||||
try:
|
||||
pattern.register()
|
||||
_register_patterns.add(pattern_key)
|
||||
except RuntimeError as e:
|
||||
if "Duplicate pattern" in str(e):
|
||||
logger.warning(f"Pattern {pattern_class.__name__} eps {eps} has been registered")
|
||||
_register_patterns.add(pattern_key)
|
||||
else:
|
||||
raise e
|
||||
|
||||
Reference in New Issue
Block a user