MCPcopy Create free account
hub / github.com/MoonshotAI/checkpoint-engine / checker_proc_with_error

Function checker_proc_with_error

tests/test_update.py:52–85  ·  view source on GitHub ↗
(
    rank: int, device_uuid: str, named_tensors: dict[str, torch.Tensor], queue: Queue
)

Source from the content-addressed store, hash-verified

50
51
52def checker_proc_with_error(
53 rank: int, device_uuid: str, named_tensors: dict[str, torch.Tensor], queue: Queue
54):
55 device_manager.device_module.set_device(rank)
56 named_tensors = {
57 name: tensor.to(device_manager.device_type) for name, tensor in named_tensors.items()
58 }
59 _ = named_tensors
60 _zmq_ctx = zmq.Context()
61
62 def trigger_error(socket_paths: list[tuple[str, str]]):
63 socket_paths = dict(socket_paths)
64 update_weights_from_ipc(
65 _zmq_ctx,
66 socket_paths[device_uuid],
67 device_id=rank,
68 run=error_run,
69 post_hook=lambda: device_manager.device_module.synchronize(),
70 )
71
72 def error_run(weights: list[tuple[str, torch.Tensor]]):
73 _ = weights # Do some fake processing
74 time.sleep(random.uniform(0.1, 0.5))
75 if rank == 0:
76 raise RuntimeError("Intentional Error for testing.")
77
78 while True:
79 socket_paths: list[tuple[str, str]] = queue.get()
80 if socket_paths is None:
81 break
82 try:
83 trigger_error(socket_paths)
84 except RuntimeError as e:
85 assert str(e) == "Some workers failed to update weights"
86
87
88def checker_proc(rank: int, device_uuid: str, named_tensors: dict[str, torch.Tensor], queue: Queue):

Callers

nothing calls this directly

Calls 1

trigger_errorFunction · 0.85

Tested by

no test coverage detected