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

fix: Avoid ZeroDivisionError if output_tokens is 0 #54

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ccamacho
Copy link
Contributor

@ccamacho ccamacho commented Aug 19, 2024

This commit validates that when calculating the results if output_tokens is 0 then both itl and tpot must be None.

@ccamacho ccamacho force-pushed the 0div branch 4 times, most recently from 42cd346 to fcc944c Compare August 19, 2024 06:35
@ccamacho
Copy link
Contributor Author

When testing HF TGIS im hitting

Traceback (most recent call last):
  File "/usr/lib64/python3.9/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/usr/lib64/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/var/mnt/data/sw/llm-load-test/user.py", line 83, in run_user_process
    result = self.make_request(test_end_time)
  File "/var/mnt/data/sw/llm-load-test/user.py", line 50, in make_request
    result = self.plugin.request_func(query, self.user_id, test_end_time)
  File "/var/mnt/data/sw/llm-load-test/plugins/hf_tgi_plugin.py", line 117, in streaming_request_http
    result.calculate_results()
  File "/var/mnt/data/sw/llm-load-test/result.py", line 49, in calculate_results
    self.itl = (1000 * (self.end_time - self.first_token_time)) / (
ZeroDivisionError: float division by zero
2024-08-18 21:48:10,576 INFO     root MainProcess Adding 1 entries to dataset queue

result.py Outdated
self.tpot = (
self.response_time / self.output_tokens
) # Time per output token in ms
if self.output_tokens is not None and self.output_tokens > 0:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks quite like

Suggested change
if self.output_tokens is not None and self.output_tokens > 0:
if self.output_tokens:

as output_tokens cannot be negative.
Not sure what's better...

(same below)

Copy link
Contributor Author

@ccamacho ccamacho Aug 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ouuhhh I got the actual error self.output_tokens is 1 and self.output_token exists

This commit validates that when calculating the results
if output_tokens is 0 then both itl and tpot must be None.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants