Skip to content

Fix browser init #797

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

Merged
merged 1 commit into from
May 14, 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
4 changes: 3 additions & 1 deletion chat_in_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def main():
except:
continue

if decoded.startswith("System Prompt") and decoded.endswith(": "):
if decoded.endswith("Do you want to enter a system prompt? Enter y for yes and anything else for no. \n"):
print(f"| {decoded}")
proc.stdin.write("\n".encode("utf-8"))
proc.stdin.flush()
Expand Down Expand Up @@ -93,6 +93,8 @@ def chat():
model_prefix = "Model: "
if output.startswith(model_prefix):
output = output[len(model_prefix) :]
else:
print("But output is", output)

global convo

Expand Down
5 changes: 1 addition & 4 deletions cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
from build.utils import allowable_dtype_names, allowable_params_table, get_device_str
from download import download_and_convert, is_model_downloaded

FORMAT = (
"%(levelname)s: %(asctime)-15s: %(filename)s: %(funcName)s: %(module)s: %(message)s"
)
logging.basicConfig(filename="/tmp/torchchat.log", level=logging.INFO, format=FORMAT)
logging.basicConfig(level=logging.INFO,format="%(message)s")
logger = logging.getLogger(__name__)

default_device = os.getenv("TORCHCHAT_DEVICE", "fast")
Expand Down
6 changes: 3 additions & 3 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,12 +752,12 @@ def callback(x):
# Don't continue here.... because we need to report and reset
# continue

print(
logging.info(
f"Time for inference {i + 1}: {t:.02f} sec total, {tokens_sec:.02f} tokens/sec"
)
print(f"Bandwidth achieved: {model_size * tokens_sec / 1e9:.02f} GB/s")
logging.info(f"Bandwidth achieved: {model_size * tokens_sec / 1e9:.02f} GB/s")
if i == 0:
print(
logging.info(
f"*** This first iteration will include cold start effects for dynamic import, hardware caches{', JIT compilation' if jit_compile else ''}. ***"
)
if start_pos >= max_seq_length:
Expand Down