Lightning Fabric Multi-Node Arg Builder: Modal Port
Background
The file lightning_spec.py builds Lightning Fabric CLI arguments for multi-node training.
In lightning/modal_train.py, the Modal launcher passes --main-address using IPv6 addresses
from container_ips (not IPv4 from container_ipv4_ips used by torchrun). This IPv4/IPv6
distinction is architecturally significant for wiring distributed training correctly.
Your Task
Port this to Modal so that run_case is a remote function that accepts a case dict with keys:
num_nodes, node_rank, main_address (IPv4 or IPv6 string), main_port, num_processes,
script_path, and strategy (default "ddp"). It should return the full spec dict including
the CLI args list and metadata.
The workflow should use a helper remote function to enrich or validate the generated spec.
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).
The solution must also use:
Staged helpers.
Output file
Write your solution to /app/solution/modal_app.py. Define a module-level app and run_case.