[Ascend]Support of piecewise graph compilation for prefill on NPU (#12287)

Co-authored-by: ronnie_zheng <zl19940307@163.com>
This commit is contained in:
Vladimir221
2025-12-11 16:10:07 +03:00
committed by GitHub
parent 5d804a3767
commit 27032cecd9
10 changed files with 289 additions and 40 deletions

View File

@@ -1201,21 +1201,20 @@ def run_bench_one_batch(model, other_args):
try:
stdout, stderr = process.communicate()
output = stdout.decode()
error = stderr.decode()
output = stdout.decode(errors="backslashreplace")
error = stderr.decode(errors="backslashreplace")
print(f"Output: {output}", flush=True)
print(f"Error: {error}", flush=True)
# Return prefill_latency, decode_throughput, decode_latency
prefill_line = output.split("\n")[-9]
decode_line = output.split("\n")[-3]
pattern = (
r"latency: (?P<latency>\d+\.\d+).*?throughput:\s*(?P<throughput>\d+\.\d+)"
)
match = re.search(pattern, prefill_line)
pattern = r"Benchmark[\s\S]*Total"
match = re.search(pattern, output)
bench_output = match[0] if match else ""
pattern = r".*?latency: (?P<latency>\d+\.\d+).*?throughput:\s*(?P<throughput>\d+\.\d+)"
match = re.search(r"Prefill." + pattern, bench_output)
if match:
prefill_latency = float(match.group("latency"))
match = re.search(pattern, decode_line)
match = re.search(r"Decode." + pattern, bench_output)
if match:
decode_latency = float(match.group("latency"))
decode_throughput = float(match.group("throughput"))