The file rdma_env_builder.py in your workspace produces the environment
variables a torchrun-launched distributed training process needs to use
EFA + GPU Direct RDMA on AWS (or fall back to plain TCP when EFA is
unavailable). It exposes three stages:
parse_topology(spec) validates n_nodes, gpus_per_node, provider,
and EFA/RDMA flags, returning a normalized topology dict.
select_nccl_env(topology) chooses the NCCL/FI environment based on
whether EFA and device RDMA should be used.
build_launch_env(spec) glues them together.
This is the same family of NCCL/FI settings pinned in
nanoGPT/modal_train.py and health-checks/modal_bw_efa.py when those
launchers configure RDMA training.
Your task
Create /app/solution/modal_app.py that:
Defines a module-level app.
Implements the same three stages (parse_topology, select_nccl_env,
build_launch_env) as separate Modal Functions; each stage is a named
step in a typed call graph.
Provides run_case(case) accepting {"spec": dict} that orchestrates
the three stages and returns {"parsed": ..., "env": ..., "full": ...}.
The verifier will compare your output against the original module for the
same spec.
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:
Staged helpers.
Output file
Write your solution to /app/solution/modal_app.py.