MCPcopy Create free account
hub / github.com/TextGeneratorio/text-generator.io / profile_text_generation

Function profile_text_generation

tests/profile_inference.py:33–72  ·  view source on GitHub ↗

Profile text generation inference.

()

Source from the content-addressed store, hash-verified

31
32
33def profile_text_generation():
34 """Profile text generation inference."""
35 import torch
36
37 from questions.inference_server.model_cache import ModelCache
38 from questions.models import GenerateParams
39 from questions.text_generator_inference import fast_inference
40
41 print("Setting up profiling environment...")
42
43 model_cache = ModelCache()
44
45 # Test parameters
46 params = GenerateParams(
47 text="Once upon a time in a galaxy far, far away",
48 max_length=100,
49 temperature=0.7,
50 top_p=0.9,
51 top_k=40,
52 number_of_results=1,
53 model="any",
54 )
55
56 # Warmup
57 print("Running warmup...")
58 for _ in range(2):
59 fast_inference(params, model_cache)
60 if torch.cuda.is_available():
61 torch.cuda.synchronize()
62
63 print("Starting profiled runs...")
64
65 # Profile multiple runs
66 for i in range(5):
67 result = fast_inference(params, model_cache)
68 if torch.cuda.is_available():
69 torch.cuda.synchronize()
70 print(f" Run {i+1}/5 complete")
71
72 return result
73
74
75def main():

Callers 1

mainFunction · 0.85

Calls 4

ModelCacheClass · 0.90
GenerateParamsClass · 0.90
fast_inferenceFunction · 0.90
printFunction · 0.50

Tested by

no test coverage detected