MCPcopy Create free account
hub / github.com/InternLM/InternBootcamp / test

Function test

verl/tests/single_controller/test_driverfunc_to_worker.py:55–85  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

53
54
55def test():
56 # construct model
57 ray.init()
58
59 # create 2 workers, each hold a GPU
60 resource_pool = RayResourcePool([2], use_gpu=True, name_prefix="a")
61
62 class_with_args = RayClassWithInitArgs(cls=ModelActor)
63 shard_wg = RayWorkerGroup(resource_pool, class_with_args, device_name=get_device_name())
64
65 test_bs = 8
66 test_proto = DataProto(
67 TensorDict(
68 {
69 "sequence_ids": torch.ones([test_bs, 2048], dtype=torch.int64),
70 },
71 batch_size=test_bs,
72 ),
73 meta_info={"query_length": 1536},
74 )
75
76 # Sharding among different ranks
77 ret_proto1 = shard_wg.execute_with_func_generator(get_aux_metrics, test_proto)
78
79 # compare execute on driver
80 hs = HackSelf()
81 ret_proto2 = get_aux_metrics(hs, test_proto)
82
83 torch.testing.assert_close(ret_proto1.batch["decode_count"], ret_proto2.batch["decode_count"])
84
85 ray.shutdown()

Callers

nothing calls this directly

Calls 10

RayResourcePoolClass · 0.90
RayWorkerGroupClass · 0.90
get_device_nameFunction · 0.90
DataProtoClass · 0.90
HackSelfClass · 0.85
get_aux_metricsFunction · 0.85
initMethod · 0.45
shutdownMethod · 0.45

Tested by

no test coverage detected