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

Only run initial generate when compile=True #114

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
38 changes: 19 additions & 19 deletions fam/llm/fast_inference_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,27 +367,27 @@ def build_model(
dynamic=True,
)

encoded = encode_tokens(tokenizer, "Hello, what's up?", device=device)
spk_emb = torch.randn((1, 256), device=device, dtype=precision)

device_sync(device=device) # MKG
t0 = time.perf_counter()
y = generate(
model,
encoded,
spk_emb,
max_new_tokens=200,
callback=lambda x: x,
temperature=torch.tensor(1.0, device=device, dtype=precision),
top_k=None,
top_p=torch.tensor(0.95, device=device, dtype=precision),
guidance_scale=torch.tensor(3.0, device=device, dtype=precision),
end_of_audio_token=9999, # don't end early for compilation stage.
)
encoded = encode_tokens(tokenizer, "Hello, what's up?", device=device)
spk_emb = torch.randn((1, 256), device=device, dtype=precision)

device_sync(device=device) # MKG
t0 = time.perf_counter()
y = generate(
model,
encoded,
spk_emb,
max_new_tokens=200,
callback=lambda x: x,
temperature=torch.tensor(1.0, device=device, dtype=precision),
top_k=None,
top_p=torch.tensor(0.95, device=device, dtype=precision),
guidance_scale=torch.tensor(3.0, device=device, dtype=precision),
end_of_audio_token=9999, # don't end early for compilation stage.
)

device_sync(device=device) # MKG
device_sync(device=device) # MKG

print(f"Compilation time: {time.perf_counter() - t0:.2f} seconds")
print(f"Compilation time: {time.perf_counter() - t0:.2f} seconds")

return model, tokenizer, smodel, model_size

Expand Down
Loading