MCPcopy Create free account
hub / github.com/ScalingIntelligence/tokasaurus / preprocess

Function preprocess

tokasaurus/model/basic_worker.py:57–99  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

55 output_tensors_cpu: ModelOutputTensors | None = None
56
57 def preprocess():
58 command: CommandFromManager = state.input_q.get()
59
60 match command:
61 case ModelInput():
62 inp = command
63 case NoMoreInputs():
64 return None
65 case _:
66 raise ValueError(f"Unknown command: {type(command)}")
67
68 batch_indices = torch.tensor(
69 inp.batch_indices,
70 dtype=torch.long,
71 )
72
73 num_total_padding, num_lm_head_padding = model_runner.calc_padding(
74 num_prefill_tokens=inp.num_prefill_tokens(),
75 num_decode_tokens=inp.num_decode_tokens(),
76 num_lm_head_tokens=inp.num_lm_head_tokens(),
77 )
78
79 input_batch_state = make_input_batch_state(
80 inp,
81 tp_rank=tp_rank,
82 tp_size=tp_size,
83 num_total_padding=num_total_padding,
84 num_lm_head_padding=num_lm_head_padding,
85 )
86
87 model_runner.plan(input_batch_state, non_blocking=non_blocking)
88
89 move_batch_state(
90 input_batch_state=input_batch_state,
91 device=state.device,
92 non_blocking=non_blocking,
93 )
94
95 return Work(
96 model_input=inp,
97 input_batch_state=input_batch_state,
98 batch_indices=batch_indices.to(state.device, non_blocking=non_blocking),
99 )
100
101 def run_model(work: Work):
102 decoding_batch_indices = work.batch_indices[

Callers 1

run_overlapped_loopFunction · 0.70

Calls 10

make_input_batch_stateFunction · 0.90
move_batch_stateFunction · 0.90
getMethod · 0.80
calc_paddingMethod · 0.80
num_decode_tokensMethod · 0.80
num_lm_head_tokensMethod · 0.80
WorkClass · 0.70
num_prefill_tokensMethod · 0.45
planMethod · 0.45
toMethod · 0.45

Tested by

no test coverage detected