MCPcopy Create free account
hub / github.com/FastMAS/KVCOMM / evaluate

Function evaluate

experiments/benchmark_TTFT.py:86–116  ·  view source on GitHub ↗
(
        graph: Graph,
        *,
        samples: int,
        output_dir: str,
        **kwargs
        )

Source from the content-addressed store, hash-verified

84
85
86async def evaluate(
87 graph: Graph,
88 *,
89 samples: int,
90 output_dir: str,
91 **kwargs
92 ) -> List[Dict[str, Any]]:
93
94 graph.spatial_logits.requires_grad_ = False
95 graph.temporal_logits.requires_grad_ = False
96
97 data = [{"task": _make_random_token_sequence(1000)} for _ in range(samples)]
98
99 all_results: List[Dict[str, Any]] = []
100 for i, input_dict in enumerate(data):
101 print(80*'-')
102
103 realized_graph = copy.deepcopy(graph)
104 realized_graph.spatial_logits = graph.spatial_logits
105 realized_graph.temporal_logits = graph.temporal_logits
106 tasks = [asyncio.create_task(realized_graph.arun(input_dict, **kwargs))]
107 raw_results = await asyncio.gather(*tasks)
108 all_results.extend(raw_results)
109 print("Done!")
110
111 try:
112 _write_per_agent_latency(output_dir)
113 except Exception as e:
114 logger.warning("Failed to write per-agent latency JSONs: {}", e)
115
116 return all_results
117
118
119def _write_per_agent_latency(output_dir: str) -> None:

Callers 1

mainFunction · 0.70

Calls 3

_write_per_agent_latencyFunction · 0.85
arunMethod · 0.80

Tested by

no test coverage detected