The file rank_planner.py in your workspace computes per-process distributed
launch parameters for a multinode torchrun-style launcher. Given a cluster
shape (n_nodes, nproc_per_node), a container_rank, and the list of
container IPv4 addresses (as Modal multinode launchers see them), it returns
the global rank range, local rank range, world size, and selected master
address used to wire torch.distributed.init_process_group.
In Modal's multinode training examples, this exact math is what turns the
cluster info available inside each container into the --node-rank,
--master-addr, and world-size arguments handed to torchrun.
Your task
Create /app/solution/modal_app.py that:
Defines a module-level app.
Provides run_case(case) that receives {"cluster_configs": list[dict]},
where each dict has fields container_rank, n_nodes, nproc_per_node,
container_ipv4_ips.
Returns the list of per-config plans (dicts produced by plan_to_dict)
computed by reusing the logic in rank_planner.py.
The cluster configurations are independent: many configs may need to be
planned in one call, and the workflow should fan them out as independent
shards rather than running them sequentially.
The verifier will compare your output against the original rank_planner
module for the same input.
Capability contract
Implement run_case as a local orchestrator: a plain Python function (not itself a Modal Function) that the harness calls directly and that dispatches work to one or more Modal Functions via .remote(...), .map(...), or .starmap(...).
The solution must also use:
Fan-out.
Staged helpers.
Output file
Write your solution to /app/solution/modal_app.py.