Job Configuration

Recipes and the Job API generate job folders for you, but every job ends up in the same on-disk format: a meta.json plus one folder per app, each with JSON configuration. Knowing this format helps when you read exported jobs (--export), write jobs by hand, or need settings a recipe does not expose. This page also covers the site-side resources.json that decides how jobs are scheduled and launched.

Job Folder Layout

my_job/
├── meta.json
├── app_server/
│   ├── config/
│   │   └── config_fed_server.json
│   └── custom/              # optional Python code shipped with the job (needs BYOC)
├── app_site-1/
│   ├── config/
│   │   └── config_fed_client.json
│   └── custom/
└── app_site-2/
    └── config/
        └── config_fed_client.json

A server app must contain config/config_fed_server.json; a client app must contain config/config_fed_client.json. An app may contain both and be deployed to several participants. For backward compatibility, a single app folder submitted as a job gets a generated meta.json that deploys it to all participants.

meta.json

{
  "name": "try_algo1",
  "resource_spec": {
    "@default": {"num_of_gpus": 0, "num_of_cpus": 4, "memory": "8Gi"},
    "site-1": {"num_of_gpus": 1, "mem_per_gpu_in_GiB": 16}
  },
  "deploy_map": {
    "app_server": ["server"],
    "app_site-1": ["site-1"],
    "app_site-2": ["site-2"]
  },
  "min_clients": 2,
  "mandatory_clients": ["site-1"]
}
Key Description
name Job name shown in nvflare job list.
deploy_map Which app goes to which sites. See Deploy map.
resource_spec Per-site resource requirements. See Resources.
min_clients Minimum number of clients that must be able to run the job.
mandatory_clients Clients that must be among them.
scope Privacy scope at each site (see Security).
study Set by the server from the session context at submit time; not something you normally write.
launcher_spec Docker, Kubernetes, or Slurm execution settings. See launcher_spec.
stats_pool_config Saving of statistics pools for post-job analysis.

The server adds bookkeeping fields such as job_id, submitter_name, submitter_org, submitter_role, status, submit_time, and job_deploy_detail; these show up in nvflare job meta.

Deploy map

  • Every app named in deploy_map must exist as a folder in the job.
  • "server" may appear only once: there is one server app per job.
  • The map cannot be empty: "deploy_map": {} is rejected.
  • "@ALL" means every site. If one app uses @ALL, no other app may target sites: {"app1": ["@ALL"], "app2": ["site-1"]} is rejected.
  • An empty list deploys the app nowhere and is allowed: {"app1": ["@ALL"], "app2": []}.
  • In a named study, @ALL is narrowed to the study's enrolled sites, and every named site must be enrolled or the submission is rejected.

Resources

Three portable fields are defined centrally:

Field Type Meaning
num_of_gpus integer ≥ 0 GPUs per job worker.
num_of_cpus integer ≥ 1 Whole schedulable CPU units (not physical cores).
memory positive integer + Mi, Gi, or Ti Host memory per job worker.

resource_spec["@default"] applies to every targeted site, including the server. A named site block (or server) overrides individual fields; omitted fields keep inheriting the default, and an inherited field can be replaced but not removed. @default accepts only the three portable fields. Site-specific fields such as mem_per_gpu_in_GiB (used by GPUResourceManager) are allowed only in per-site blocks.

How launchers enforce them: Docker uses GPU device requests, a CPU quota, and a memory limit; Kubernetes sets equal requests and limits; Slurm maps them to --gres, --cpus-per-task, and --mem. CPU and memory are enforced by the launcher, not reserved by the site's resource manager; positive GPU requests and site-specific fields go through resource-manager admission.

Omitting resource_spec makes a resource-less job, which every client accepts (typical in POC).

launcher_spec

Which launcher a site uses is site policy (set when preparing its kit with nvflare deploy prepare). A job can carry settings for several modes at once:

{
  "launcher_spec": {
    "default": {
      "docker": {"image": "registry.example.com/nvflare-job:2.8"},
      "k8s": {"image": "registry.example.com/nvflare-job:2.8"},
      "slurm": {"image": "/shared/images/nvflare-job.sif", "time": "02:00:00", "pending_timeout": 300}
    },
    "site-1": {
      "docker": {"shm_size": "8g"},
      "k8s": {"ephemeral_storage": "8Gi"},
      "slurm": {"nodes": 2, "gpus_per_node": 4}
    }
  }
}

launcher_spec["default"][mode] applies to every site using that mode, including the server; launcher_spec[site][mode] overrides per site. Keep portable resource requests in resource_spec.

Slurm job blocks accept image, nodes, gpus_per_node, cpus_per_node, mem_per_node (MiB), time, and pending_timeout:

  • Partition, account, QOS, sandbox, setup commands, and raw scheduler flags are site-owned and cannot be set by a job.
  • A job image requires BYOC authorization, must be an absolute, existing, site-visible file, and overrides study and site defaults.
  • pending_timeout can only be lowered below the site's value.
  • Multi-node jobs require sandbox: none and must omit image; a positive num_of_gpus then needs gpus_per_node, and num_of_gpus must equal nodes * gpus_per_node.
  • Put client-only topology such as nodes in client-site blocks, because the server job also inherits default.

App Configuration

config_fed_server.json

{
  "format_version": 2,
  "server": {"heart_beat_timeout": 600},
  "task_data_filters": [],
  "task_result_filters": [],
  "components": [
    {"id": "persistor", "path": "np_model_persistor.NPModelPersistor", "args": {}},
    {
      "id": "aggregator",
      "path": "nvflare.app_common.aggregators.intime_accumulate_model_aggregator.InTimeAccumulateWeightedAggregator",
      "args": {}
    }
  ],
  "workflows": [
    {
      "id": "fed_avg_ctl",
      "path": "nvflare.app_common.workflows.fed_avg.fed_avg_ctl.FedAvgController",
      "args": {"min_clients": 2, "num_rounds": 10, "persistor_id": "persistor", "aggregator_id": "aggregator"}
    }
  ]
}

config_fed_client.json

{
  "format_version": 2,
  "executors": [
    {
      "tasks": ["*"],
      "executor": {
        "path": "nvflare.app_common.executors.client_api_executor.ClientAPIExecutor",
        "args": {}
      }
    }
  ],
  "components": [],
  "task_data_filters": [],
  "task_result_filters": []
}
Section Description
format_version Always 2.
components Objects created at job start, each with an id (referenced by other components' *_id args), a path (or class_path) and args.
workflows Server only. Controllers run in order.
executors Client only. Maps task names ("*" matches all) to an executor.
task_data_filters / task_result_filters Filters on task data and results; site privacy-scope filters run before these.

Component paths are checked against the site's allow list unless the job has BYOC rights (see Security). Classes in the app's custom/ folder are referenced by module path, as with np_model_persistor.NPModelPersistor above.

Site resources.json

local/resources.json.default (override with local/resources.json) holds settings that each site decides. The client default includes:

{
  "format_version": 2,
  "class_list_enforcement_mode": "enforce",
  "client": {"retry_timeout": 30, "compression": "Gzip"},
  "components": [
    {
      "id": "resource_manager",
      "path": "nvflare.app_common.resource_managers.gpu_resource_manager.GPUResourceManager",
      "args": {"num_of_gpus": 0, "mem_per_gpu_in_GiB": 0, "expiration_period": 300}
    },
    {
      "id": "resource_consumer",
      "path": "nvflare.app_common.resource_consumers.gpu_resource_consumer.GPUResourceConsumer",
      "args": {}
    },
    {
      "id": "process_launcher",
      "path": "nvflare.app_common.job_launcher.client_process_launcher.ClientProcessJobLauncher",
      "args": {}
    }
  ]
}

The GPU numbers come from the client's capacity (num_of_gpus, mem_per_gpu_in_GiB) in project.yml, and default to 0. The provisioned file also contains class_allow_list, allow_log_streaming, and a site_log_streamer component.

The server default configures:

Setting Default Notes
servers[0].max_num_clients 100
servers[0].heart_beat_timeout 600 Seconds before a silent client is considered gone.
servers[0].admin_timeout 10.0
snapshot_persistor storage root_dir /tmp/nvflare/snapshot-storage Job snapshots for recovery.
job_manager uri_root /tmp/nvflare/jobs-storage Submitted jobs and results.
job_scheduler max_jobs 4 Concurrent jobs (the class default is 1).

Warning: The server's job store and snapshot storage default to /tmp/nvflare/.... On many systems /tmp is cleared on reboot, which loses job history and results. Point both at persistent storage in local/resources.json for production.

Scheduling and resource managers

The job scheduler on the server periodically tries queued jobs. For each one it asks target clients' resource managers check_resources; if the clients that can run it satisfy min_clients and mandatory_clients, it dispatches the job and the clients allocate_resources; otherwise it calls cancel_resources for any reservations. The client's resource consumer consumes the allocation when the job starts, and free_resources is called when the job ends. DefaultJobScheduler also takes max_schedule_count (10), min_schedule_interval (10.0 s), and max_schedule_interval (600.0 s); a job that cannot be scheduled within its tries ends as FINISHED:CAN_NOT_SCHEDULE.

See Also