From b8ea22f9bb7cf79850b6a44265b5cea9c57666c3 Mon Sep 17 00:00:00 2001 From: Jack-Khuu Date: Wed, 2 Oct 2024 17:36:29 -0700 Subject: [PATCH] [Easy] Remove unused variable and comments --- torchchat/generate.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/torchchat/generate.py b/torchchat/generate.py index 349ee45c5..42abe664c 100644 --- a/torchchat/generate.py +++ b/torchchat/generate.py @@ -262,7 +262,6 @@ def __init__( """ )) # fmt: on - # raise RuntimeError("You need to use --is-chat-model to indicate model has chat support.") self.system_prompt = generator_args.prompt self.tokenizer = _initialize_tokenizer(self.tokenizer_args) @@ -493,7 +492,6 @@ def decode_n_tokens( next_prob.clone() if next_prob is not None else None ) - # return new_tokens, new_probs def model_forward(self, model, x, input_pos): return model(x, input_pos) @@ -593,8 +591,6 @@ def generate( is_speculative = draft_model is not None device, dtype = prompt.device, prompt.dtype - # create an empty tensor of the expected final shape and - # fill in the current tokens if len(prompt.shape) > 1: prompt = prompt.squeeze(0) T = prompt.size(0) @@ -620,11 +616,6 @@ def generate( if model.config.model_type == ModelType.Flamingo: model.reset_caches() - # create an empty tensor of the expected final shape and - # fill in the current tokens - empty = torch.empty(T_new, dtype=dtype, device=device) - empty[:T] = prompt - input_pos = torch.arange( start_pos, T + start_pos, device=device, dtype=torch.int )