Skip to content

Commit 8941533

Browse files
committed
bautification
1 parent 28058d1 commit 8941533

File tree

2 files changed

+33
-15
lines changed

2 files changed

+33
-15
lines changed

examples/llama_3.2_1b/inference.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,24 @@
3131

3232

3333
_iron_chat = r"""
34-
_____ _____ ____ _ _ _____ _ _
35-
|_ _| __ \ / __ \| \ | | / ____| | | |
36-
______ | | | |__) | | | | \| | | | | |__ __ _| |_ ______
37-
|______| | | | _ /| | | | . ` | | | | '_ \ / _` | __| |______|
38-
_| |_| | \ \| |__| | |\ | | |____| | | | (_| | |_
39-
|_____|_| \_\\____/|_| \_| \_____|_| |_|\__,_|\__|
40-
41-
___ _ _ _ _ _ __ __ ___ ___ _ ___
42-
| _ \_ _ _____ _(_)__| |___ __| | | |__ _ _ /_\ | \/ | \ | _ \ /_\ | \
43-
| _/ '_/ _ \ V / / _` / -_) _` | | '_ \ || | / _ \| |\/| | |) | | / / _ \| |) |
44-
|_| |_| \___/\_/|_\__,_\___\__,_| |_.__/\_, | /_/ \_\_| |_|___/ |_|_\/_/ \_\___/
45-
|__/
34+
/$$$$$$ /$$$$$$$ /$$$$$$ /$$ /$$
35+
|_ $$_/| $$__ $$ /$$__ $$| $$$ | $$
36+
| $$ | $$ \ $$| $$ \ $$| $$$$| $$
37+
| $$ | $$$$$$$/| $$ | $$| $$ $$ $$
38+
| $$ | $$__ $$| $$ | $$| $$ $$$$
39+
| $$ | $$ \ $$| $$ | $$| $$\ $$$
40+
/$$$$$$| $$ | $$| $$$$$$/| $$ \ $$
41+
|______/|__/ |__/ \______/ |__/ \__/
42+
43+
44+
/$$ /$$ /$$$$$$ /$$ /$$ /$$$$$$
45+
| $$ | $$ /$$__ $$| $$$ /$$$ /$$__ $$
46+
| $$ | $$ | $$ \ $$| $$$$ /$$$$| $$ \ $$
47+
| $$ | $$ | $$$$$$$$| $$ $$/$$ $$| $$$$$$$$
48+
| $$ | $$ | $$__ $$| $$ $$$| $$| $$__ $$
49+
| $$ | $$ | $$ | $$| $$\ $ | $$| $$ | $$
50+
| $$$$$$$$| $$$$$$$$| $$ | $$| $$ \/ | $$| $$ | $$
51+
|________/|________/|__/ |__/|__/ |__/|__/ |__/
4652
"""
4753

4854

@@ -191,7 +197,7 @@ def inference(
191197

192198
print(f"Starting text generation...")
193199
print(f"Generating {num_tokens} tokens...")
194-
print("=" * 60)
200+
print("=" * 55)
195201

196202
prefill_end_time = None
197203

@@ -222,7 +228,7 @@ def set_prefill_time():
222228
tokens_per_second = (num_tokens - 1) / post_prefill_time if num_tokens > 1 else 0
223229
time_per_token = total_time / (num_tokens - 1) if num_tokens > 1 else prefill_time
224230

225-
print("=" * 60)
231+
print("=" * 55)
226232
print(" TIMING RESULTS:")
227233
print(f" Total time: {total_time:.4f} seconds")
228234
print(f" Prefill time: {prefill_time:.4f} seconds")
@@ -233,7 +239,7 @@ def set_prefill_time():
233239
if num_tokens > 0
234240
else " Time per token: N/A"
235241
)
236-
print("=" * 60)
242+
print("=" * 55)
237243

238244
logging.info(f"Generation time: {total_time:.4f} sec")
239245
logging.info(f"Total wall clock time: {total_time:.4f} sec")

examples/llama_3.2_1b/src/model_with_json.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,23 @@ def format_option(name, value):
7272
return f"{name} {checkmark}"
7373
return f"{name}: {value}"
7474

75+
dont_print = {"dtype"}
76+
# The following options are mutually exclusive, e.g. regular and fused MHA
77+
# cannot be enabled at the same time. But it looks bad to have red Xs,
78+
# indicating things are running on the CPU when they are not. So, we only
79+
# print one of these mutually exclusive options.
80+
if cfg["use_aie_fused_mha"]:
81+
dont_print |= {"use_aie_regular_mha"}
82+
else:
83+
dont_print |= {"use_aie_fused_mha"}
84+
7585
console.print(
7686
"AIE Configuration ([green]✔[/green] = AIE NPU / [red]✘[/red] = CPU):",
7787
style="bold underline",
7888
)
7989
for option_key, (option_ty, option_default, option_name) in config_options.items():
90+
if option_key in dont_print:
91+
continue
8092
console.print(format_option(option_name, cfg.get(option_key, option_default)))
8193
console.print("")
8294

0 commit comments

Comments
 (0)