Skip to content

Commit

Permalink
Remove if statement preventing tps stats from being printed when runn…
Browse files Browse the repository at this point in the history
…ing generate with compile (pytorch#1330)

Co-authored-by: vmpuri <[email protected]>
  • Loading branch information
vmpuri and vmpuri authored Oct 25, 2024
1 parent 70260eb commit 77774d2
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions torchchat/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@

from PIL import Image

# torchtune model definition dependencies
from torchtune.data import Message, padded_collate_tiled_images_and_mask

from torchtune.generation import sample as tune_sample
from torchtune.models.llama3 import llama3_tokenizer

from torchtune.models.llama3_2_vision._model_builders import llama3_2_vision_transform
from torchtune.training import set_default_dtype

from torchchat.cli.builder import (
_initialize_model,
_initialize_tokenizer,
Expand All @@ -35,15 +44,6 @@
from torchchat.utils.build_utils import device_sync, set_precision
from torchchat.utils.device_info import get_device_info

# torchtune model definition dependencies
from torchtune.data import Message, padded_collate_tiled_images_and_mask

from torchtune.generation import sample as tune_sample
from torchtune.models.llama3 import llama3_tokenizer

from torchtune.models.llama3_2_vision._model_builders import llama3_2_vision_transform
from torchtune.training import set_default_dtype


class _ChatFormatter(ABC):
def __init__(self, tokenizer):
Expand Down Expand Up @@ -1155,13 +1155,9 @@ def callback(x, *, done_generating=False):
print(
f"just-in-time compilation time (incl run time): {compilation_time:.2} seconds"
)
aggregate_metrics["tokens_per_sec_jit_compile"] = tokens_sec
# Don't continue here.... because we need to report and reset
# continue
else:
aggregate_metrics["tokens_per_sec"].append(tokens_sec)
aggregate_metrics["first_token_per_sec"].append(first_token_sec)
aggregate_metrics["next_tokens_per_sec"].append(next_tokens_sec)
aggregate_metrics["tokens_per_sec"].append(tokens_sec)
aggregate_metrics["first_token_per_sec"].append(first_token_sec)
aggregate_metrics["next_tokens_per_sec"].append(next_tokens_sec)

logging.info(
f"\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\
Expand Down

0 comments on commit 77774d2

Please sign in to comment.