#!/usr/bin/env python3 """Serve isolated RoboTwin sessions through one shared A100 policy replica.""" import argparse import json from pathlib import Path from hybrid_concurrent_server import ConcurrentHybridPolicyServer from serve_eval_policy import serve_policy from eval_model_registry import MODEL_NAMES def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--model', choices=MODEL_NAMES, default='robotwin') parser.add_argument('--precision', choices=['bf16', 'fp32'], default='fp32') parser.add_argument('--output', type=Path, required=True) parser.add_argument('--port', type=int, default=9340) parser.add_argument('--max-clients', type=int, choices=range(1, 9), default=4) args = parser.parse_args() args.output = args.output.resolve() from deploy import websocket_policy_server original = websocket_policy_server.WebsocketPolicyServer class ConfiguredServer(ConcurrentHybridPolicyServer): def __init__(self, *positional, **kwargs): super().__init__(*positional, **kwargs, max_clients=args.max_clients, log_path=args.output / 'hybrid_server_requests.jsonl') (args.output / 'server_metadata.json').write_text( json.dumps(self.metadata, indent=2) + '\n') print(json.dumps({'event': 'hybrid_ready', **self.metadata}), flush=True) # Preserve the existing strict streaming loader, official FP32 semantics, # TF32 flags and exactly the same three offline warmup calls. websocket_policy_server.WebsocketPolicyServer = ConfiguredServer try: serve_policy(args) finally: websocket_policy_server.WebsocketPolicyServer = original if __name__ == '__main__': main()