Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destroy the generator at the end of the loop in python examples #404

Merged
merged 2 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions benchmark/python/benchmark_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ def main(args):
generator.generate_next_token()
if args.print_model_output: print(tokenizer.decode(generator.get_sequence(0)))

# Delete the generator to free the captured graph for the next generator, if graph capture is enabled
del generator

tokenize_times = []
prompt_times = []
token_gen_times = []
Expand Down Expand Up @@ -141,6 +144,9 @@ def main(args):
wall_clock_times.append(wall_clock_end_time - wall_clock_start_time)
if args.print_model_output: print(tokenizer.decode(generator.get_sequence(0)))

# Delete the generator to free the captured graph for the next generator, if graph capture is enabled
del generator

# Calculate tokenization metrics
avg_tokenization_latency_s = sum(tokenize_times) / len(tokenize_times)
avg_tokenization_latency_ms = avg_tokenization_latency_s * 1000
Expand Down
3 changes: 3 additions & 0 deletions examples/python/model-qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ def main(args):
print()
print()

# Delete the generator to free the captured graph for the next generator, if graph capture is enabled
del generator

if args.timings:
prompt_time = first_token_timestamp - started_timestamp
run_time = time.time() - first_token_timestamp
Expand Down
3 changes: 3 additions & 0 deletions examples/python/phi3-qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ def main(args):
print()
print()

# Delete the generator to free the captured graph for the next generator, if graph capture is enabled
del generator

if args.timings:
prompt_time = first_token_timestamp - started_timestamp
run_time = time.time() - first_token_timestamp
Expand Down
Loading