compute_roofline: argparse --trace, fix stale default path (D4)
The hardcoded traces/sampled_1000req_seed42.jsonl no longer exists; switch the default to the current sampled trace file w600_r0.0015_st30.jsonl and let users override via --trace. Skip Part 4 cleanly when the file is missing instead of relying on os.path.exists.
This commit is contained in:
@@ -12,6 +12,7 @@ GPU: NVIDIA H20
|
||||
- Roofline ridge point: 148/4.0 = 37 FLOP/byte
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import math
|
||||
|
||||
@@ -161,16 +162,25 @@ print(" PART 4: Agentic Workload Real Distribution")
|
||||
print("-" * 80)
|
||||
|
||||
# Use actual trace data
|
||||
import os
|
||||
trace_path = "traces/sampled_1000req_seed42.jsonl"
|
||||
if os.path.exists(trace_path):
|
||||
_parser = argparse.ArgumentParser(description=__doc__)
|
||||
_parser.add_argument("--trace", type=str,
|
||||
default="traces/w600_r0.0015_st30.jsonl",
|
||||
help="Sampled trace JSONL for empirical workload roofline (Part 4)")
|
||||
_args, _ = _parser.parse_known_args()
|
||||
trace_path = _args.trace
|
||||
try:
|
||||
_trace_fh = open(trace_path)
|
||||
except FileNotFoundError:
|
||||
print(f" (skipped: trace file not found: {trace_path})")
|
||||
_trace_fh = None
|
||||
if _trace_fh is not None:
|
||||
BLOCK_SIZE = 512
|
||||
seen = set()
|
||||
compute_bound = 0
|
||||
memory_bound = 0
|
||||
total = 0
|
||||
|
||||
for line in open(trace_path):
|
||||
for line in _trace_fh:
|
||||
d = json.loads(line)
|
||||
seq_len = d["input_length"]
|
||||
if seq_len < 1: continue
|
||||
@@ -201,6 +211,8 @@ if os.path.exists(trace_path):
|
||||
else:
|
||||
memory_bound += 1
|
||||
|
||||
_trace_fh.close()
|
||||
if total > 0:
|
||||
print(f" With actual trace prefix cache pattern:")
|
||||
print(f" Compute-bound prefills: {compute_bound} ({compute_bound*100//total}%)")
|
||||
print(f" Memory-bound prefills: {memory_bound} ({memory_bound*100//total}%)")
|
||||
|
||||
Reference in New Issue
Block a user