MCPcopy Create free account
hub / github.com/LukeBailey181/sgs / __call__

Method __call__

sgs/models/query_local.py:373–531  ·  view source on GitHub ↗
(
        self,
        model_config: ModelConfig,
        buffer_size: int = 128,
        gpu_id: Optional[int] = None,
    )

Source from the content-addressed store, hash-verified

371 sys.exit(1)
372
373 def __call__(
374 self,
375 model_config: ModelConfig,
376 buffer_size: int = 128,
377 gpu_id: Optional[int] = None,
378 ) -> None:
379 self.exit_reason = "Unkown"
380
381 if gpu_id is not None:
382 # Set CUDA_VISIBLE_DEVICES to only show the specific GPU for this subprocess
383 os.environ["CUDA_VISIBLE_DEVICES"] = str(gpu_id)
384 # Set the GPU for this process
385 torch.cuda.set_device(
386 0
387 ) # Use GPU 0 since CUDA_VISIBLE_DEVICES makes it the only visible GPU
388
389 try:
390 self.monitor = ResourceMonitor(
391 interval_sec=10,
392 track_children=False,
393 track_cgroup=False,
394 profile_gpu=False,
395 timings_only=not self.do_in_depth_monitoring,
396 )
397 self.monitor.start()
398
399 vllm_model = LLM(
400 model=model_config.model_name,
401 dtype=model_config.dtype,
402 max_model_len=model_config.max_tokens,
403 )
404
405 sampling_params = SamplingParams(
406 temperature=model_config.temperature,
407 max_tokens=model_config.max_tokens,
408 top_p=model_config.top_p,
409 top_k=model_config.top_k,
410 # skip_special_tokens=False,
411 # include_stop_str_in_output=True,
412 logprobs=10,
413 )
414
415 # We keep going while there are still things in the buffer or we are still processing
416 status_check_interval = 2
417 last_status_check = time.time()
418 report_util_interval = 20
419 last_report_util = time.time()
420
421 print("=" * 100)
422 print("BEGINNING GENERATION LOOP WITH THE SERVER")
423 print("=" * 100)
424
425 # We keep going while there are still things in the buffer or we are still processing
426 while True:
427 # First we do some reporting to the server
428 time.sleep(random.uniform(0.5, 1.5))
429 now = time.time()
430 if now - last_status_check > status_check_interval:

Callers

nothing calls this directly

Calls 12

graceful_exitMethod · 0.95
ResourceMonitorClass · 0.90
QueryResultClass · 0.90
SubmitResultClass · 0.90
SubmitResultsClass · 0.90
vllm_result_to_entropyFunction · 0.85
get_doneMethod · 0.80
reportMethod · 0.80
get_tasksMethod · 0.80
submit_resultsMethod · 0.80
startMethod · 0.45
submit_util_reportMethod · 0.45

Tested by

no test coverage detected