(
graph: Graph,
*,
samples: int,
output_dir: str,
**kwargs
)
| 84 | |
| 85 | |
| 86 | async 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 | |
| 119 | def _write_per_agent_latency(output_dir: str) -> None: |
no test coverage detected