multinode.py is a torchrun-driven distributed trainer that relies on rank, world-size, and rendezvous environment variables set by an outer launcher. A Modal multinode port has to take a cluster spec and produce the exact torchrun argument list that gets executed on each node.
launcher.py shows the canonical assembly: read nnodes, nproc_per_node, node_rank, rdzv_endpoint, rdzv_id, rdzv_backend, training script path, and optional script args. Compose them into the standard argv form. Also report derived facts: total world_size = nnodes * nproc_per_node and whether this node is the rank-0 host.
Task
run_case receives a cluster spec dict and must return {"argv": list[str], "world_size": int, "is_rank0_host": bool} matching the reference assembly exactly, including ordering of --nnodes, --nproc_per_node, --node_rank, --rdzv_id, --rdzv_backend, --rdzv_endpoint, then script path, then script args.
Required output
Write /app/solution/modal_app.py with module-level app and run_case Modal Function.
Capability contract
Expose the workflow as a single Modal remote function: define run_case as an @app.function so the harness can invoke it with run_case.remote(case).