Nvflare Convert Lightning
NVIDIAOfficialCreated by NVIDIA FLARE Team
- Skill
- Workflow
- Software development
- Apache-2.0
- Medium risk
- Has scripts
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured procedure for transforming existing PyTorch Lightning training scripts into NVFLARE-compatible federated learning jobs. It focuses on integrating the Lightning Client API to enable collaborative training across multiple sites while ensuring data remains local. The process involves patching the Lightning Trainer, configuring the federated recipe, and validating the resulting job to ensure it meets the requirements for federated model exchange.
What it does
- Inspects source code to confirm PyTorch Lightning usage and federated intent.
- Patches the Lightning Trainer using the NVFLARE Client API for model exchange.
- Constructs a federated job using the PyTorch recipe family.
- Configures local validation and training loops for federated execution.
- Supports DDP-based distributed training within the federated context.
- Exports the final federated job for deployment or simulation.
When to use it
- When you need to convert a PyTorch Lightning project into a federated learning job.
- When multiple sites need to train collaboratively without sharing raw data.
- When the project uses LightningModule, LightningDataModule, or standard Trainer loops.
- When you require a validated, exportable federated training artifact.
Advantages
- Maintains native PyTorch Lightning training logic and evaluation workflows.
- Automates the integration of federated model exchange via patching.
- Ensures consistent recipe construction using established PyTorch-family patterns.
- Provides clear validation paths for both local simulation and deployment.
Usage examples
- “Convert my PyTorch Lightning image classification script to run in an NVFLARE federated environment.”
- The agent will inspect the code, apply the Lightning Client API patch, configure a FedAvg recipe, and generate a validated federated job.
- “I have a multi-site project using Lightning; how do I set up federated training?”
- The agent will guide you through the conversion process, ensuring the trainer is patched and the job is structured for collaborative training.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/nvidia/nvflare-convert-lightning/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip nvflare-convert-lightning.zip -d .agents/skills
Documentation by NVIDIA FLARE Team
NVFLARE Convert PyTorch Lightning
Use When
Use only when the user asks to convert PyTorch Lightning code into an NVFLARE federated training job; require both federation intent and Lightning ownership. Treat requests for multiple sites or institutions to train collaboratively while each site's data remains local as federation intent, even when the request does not say "federated" or "NVFLARE."
Lightning source evidence alone is not sufficient. Relevant source may contain a LightningModule, LightningDataModule, a Trainer fit/validate/test loop,
Lightning callbacks, checkpointing, or loggers.
Supported: the PyTorch recipe family with flare.patch(trainer) as the model
exchange integration, Lightning-native evaluation, custom aggregation through
the same recipe aggregator= hook, and local validation and export.
Standard Path
Always read this converter SKILL.md with
../nvflare-shared/references/conversion-common.md. For an explicit-FedAvg
conversion, load only these references, in workflow order:
During inspection,
references/lightning-detection.md.For generated splits, relative paths, or per-site data locations,
../nvflare-shared/references/site-data-and-paths.md.After
nvflare recipe show fedavg-pt --format json,../nvflare-shared/references/pytorch-family-recipe-construction.md.During conversion,
references/lightning-conversion.md, then../nvflare-shared/references/pytorch-model-exchange.md.Only after generated files exist,
../nvflare-shared/references/validation-evidence.md, thenreferences/lightning-validation.md.
Complete each workflow phase before loading the next phase's reference. Do not enumerate reference directories or preload validation, DDP/tracking, broad workflow, dependency, runtime-output, or reporting references. Do not depend on NVFLARE repository examples.
Do Not Use When
Do not use for non-federated Lightning changes such as DDP-only configuration, profiling, inference serving, callbacks, early stopping, or schedulers; or for plain torch.nn.Module manual training loops without Lightning
(route to nvflare-convert-pytorch), Hugging Face Trainer (route to nvflare-convert-huggingface), TensorFlow,
XGBoost, scikit-learn, a failed job (route to nvflare-diagnose-job),
federated statistics without training (route to nvflare-fed-stats), or
generic Lightning debugging without FLARE intent; when the inspected project
actively contains both Lightning and Hugging Face Trainer entrypoints, route to
nvflare-orient. Out of conversion scope: production deployment, Kubernetes,
POC lifecycle, deployment privacy/security policy design, custom distributed
launch policies not expressible by product APIs, experiment tracking redesign,
and experiment search across recipes. Privacy-protection requests — homomorphic encryption (HE) /
encrypted aggregation, differential privacy, and privacy filters — are not
supported: they require provisioning or deployment policy beyond conversion
scope, so report such a request as unsupported and route it to
provisioning/deployment, never substituting an unprotected recipe or disclaimer.
If a request combines federated statistics and model-training conversion,
treat it as two independent jobs and workflows: do not merge or automatically
chain them, do not route the combination to nvflare-orient, and ask which
workflow to run first before generating or running either job. Recommend
nvflare-fed-stats first only when the user's purpose is to understand data
distribution; handle conversion later as a separate request.
Workflow
Apply
../nvflare-shared/references/conversion-common.mdfor the whole conversion; this SKILL.md states only the framework-specific deltas.Inspect before editing with
nvflare agent inspect source <path> --format jsonplus direct reading; fact extraction is static. Confirm Lightning versus plain PyTorch and hand off tonvflare-convert-pytorchwhen no Lightning evidence exists. If inspection recommendsnvflare-orientfor active Lightning and Hugging Face Trainer owners, stop and hand off before editing.Apply the dependency-install ordering rule in
../nvflare-shared/references/conversion-common.mdbefore any Python command imports user, Lightning, NVFLARE, or declared dependency modules. Determine applicable dependencies from the selected execution path first. If required data artifacts already exist and static inspection shows that the selected path will not reach a download helper or its imports, treat its download-only requirements as inapplicable: do not install or import-probe them. Probe only modules the generated conversion and selected validation path will execute, and keep an optional probe separate and exit-zero when unavailable.Identify the existing
LightningModule,LightningDataModule, trainer construction, callbacks, checkpointing,validation_step/test_stepand dataloaders, metrics, logger usage, source partition evidence, distributed process-spawning evidence, custom aggregation intent, and the concrete model constructor values that server and clients must share.Reuse the PyTorch recipe family; Lightning is not a separate recipe family. For the standard case — the user explicitly requests FedAvg and inspection identifies Lightning — run
nvflare recipe show fedavg-pt --format jsondirectly and construct it. Forfedavg-pt, importFedAvgRecipeonly fromnvflare.app_opt.pt.recipes.fedavg, never fromnvflare.recipe. Use FedEval for evaluation-only. After everyrecipe show, derive construction capabilities from the construction reference. Then use that documented path: do not run exploratory NVFLARE imports or useinspect,hasattr, constant discovery, SDK source/docstring reads, or lifecycle probes. If a required detail is absent, report a skill gap or fail closed instead of guessing. Callrecipe.execute(SimEnv(...)).Convert the training entry point to the Lightning Client API: build the
Trainer, callflare.patch(trainer), and let the patched trainer own model exchange. Keep evaluation inside Lightning perreferences/lightning-conversion.mdand useself.log. Deriveevaluate_only=Trueonly for FedEval; omit it for training recipes so its default staysFalse. Deriveevaluate_before_train = recipe_algorithm != "cyclic": Cyclic persists only its final sequential model; every other algorithm uses explicit validation for server metrics and, for training, best-model selection. Verify the key in server evidence or fail closed.Add or update
job.pyunder the shared constructor-serialization rule. Use the recipe'sclass_pathorpathkey plus completeargswhen values are needed; a permitted zero-argument instance is the complete module. Add requestedaggregator=wiring and the metric, tensor-transport, server offload, and execution settings derived from the shared PyTorch-family construction profile. If sites need distincttrain_args, make every site override the complete argument string; never split shared arguments and a site-specific data path across recipe-level and per-site values expecting a merge.Immediately after generated files exist and before any preflight, smoke test, cleanup, validation, or execution command, load the two validation references in Standard Path order. Before executing a full run, select and record exactly one final validation target:
for a requested local or first-run simulation without an export claim, run
python job.pyand do not export or run the exported simulator afterward;for a requested exported/deployable artifact, export first and run only the exported folder with the simulator CLI; do not first run
python job.py. If the selected full-run target fails, diagnose it, apply a scoped fix, and rerun that same target. Change targets only when evidence shows the original target does not represent the requested artifact, and record that reason. Export inspection belongs only to the exported path. Keep cleanup, export, and simulation as separate tool calls; never combine recursive cleanup with execution. Stop at the first failed validation rung before diagnosing it; do not add speculative recovery probes. Use the environment and permission mechanisms supplied by the agent host; do not inspect or enforce its security boundary.
Report the recipe, changed files, selected validation target, validation status, metrics, and exact artifact paths.
Non-standard Cases
Load only the reference matching an encountered case:
../nvflare-shared/references/conversion-workflow.mdfor an unresolved non-standard rerun, authorization, or missing-semantics case; it no longer holds the data-location or partitioning contracts.../nvflare-shared/references/pytorch-family-recipe-selection.mdfor an ambiguous or non-FedAvg algorithm; use its catalog for FedAvg, FedOpt, FedProx, SCAFFOLD, Cyclic, Swarm, or FedEval, and reservenvflare recipe listfor these cases.../nvflare-shared/references/dependency-install.mdwhen an applicable dependency is missing.../nvflare-shared/references/runtime-output-guidance.mdfor a read-only source root or user-chosen output destination.references/lightning-ddp-and-tracking.mdwhen inspection finds its trigger.../nvflare-shared/references/metrics-and-artifact-reporting.mdwhen normal metric artifacts are absent or inconsistent.
Requirements
Must integrate through
flare.patch(trainer)and let the patched trainer own model exchange. Must not generate a manualFLModelsend/receive path as the default Lightning exchange, and must not pass the receivedinput_modelinto theTrainer.Must treat
flare.receive()inside the patched loop as optional metadata or task-progression access only, not as a second model-load path.Must keep evaluation inside Lightning (
trainer.validate/trainer.test,validation_step,self.log); must not generate a raw PyTorchmodel.eval()loop for ordinary Lightning conversion.Except for Cyclic, must run an explicit standalone
trainer.validate(...)beforetrainer.fit(...)and rely on the patched callback to attach its finite scalar metrics; never populatemodel.__fl_meta__[MetaKey.INITIAL_METRICS]. Validation insidetrainer.fit(...)is not a received-global-model metric. Cyclic must skip the pre-fit call and report its persisted final model, not a best model.Must audit model constructor arguments before writing
job.pyby reading theLightningModule.__init__signature and the selected recipe'smodelparameter fromnvflare recipe show <recipe-name> --format json, not by reading NVFLARE library source. Emit the recipe-documentedclass_pathorpathkey plus completeargsfor every required or overridden value. DirectLightningModuleuse is allowed only when unchanged zero-argument defaults reconstruct it. Values must be clear from source, configuration, or supplied metadata. Otherwise ask one semantic question when an answer channel exists or fail closed.Must use the PyTorch recipe family; must not invent a Lightning-only recipe. Apply the construction reference after
recipe show; it is canonical for optional recipe parameters, model selection, tensor transport, server disk offload, and execution mode.Must preserve local-only callbacks and logger behavior where safe. Existing network-connected tracking, upload callbacks, and custom/unknown loggers are evidence, not a user request: keep them disabled during validation unless explicitly requested, and do not ask solely to enable them. This narrows
references/lightning-conversion.md.Must not make non-PyTorch-family skills load
../nvflare-shared/references/pytorch-model-exchange.md.Site partitioning, custom aggregation, the Source Of Truth Boundary, and user input/authorization follow
../nvflare-shared/references/conversion-common.md.
Files
- ATTRIBUTION.mdAdded by AutoGineer944 B
- BENCHMARK.md11.7 KiB
- LICENSELicence file added by AutoGineer11.2 KiB
- SKILL.md12.9 KiB
- assets/lightning_client.pyScript5.4 KiB
- evals/config.yml295 B
- evals/evals.json66.0 KiB
- evals/files/SOURCE.md2.2 KiB
- evals/files/external-data-lightning/model.pyScript1.7 KiB
- evals/files/external-data-lightning/train.pyScript2.4 KiB
- evals/files/factory-lightning/train.pyScript1.3 KiB
- evals/files/gpu-device-lightning/model.pyScript1.2 KiB
- evals/files/gpu-device-lightning/train.pyScript1.1 KiB
- evals/files/hello-lightning/model.pyScript1.7 KiB
- evals/files/hello-lightning/train.pyScript1.1 KiB
- evals/files/routing-dual/train_huggingface.pyScript787 B
- evals/files/routing-dual/train_lightning.pyScript743 B
- evals/files/vocab-lightning/model.pyScript1.8 KiB
- evals/files/vocab-lightning/train.pyScript1.9 KiB
- references/lightning-conversion.md16.3 KiB
- references/lightning-ddp-and-tracking.md5.7 KiB
- references/lightning-detection.md3.0 KiB
- references/lightning-validation.md5.4 KiB
- skill-card.md4.1 KiB
- skill.oms.sig8.9 KiB
references/lightning-conversion.md
Lightning Client API Conversion
This reference covers converting a PyTorch Lightning Trainer workflow to the
NVFLARE Lightning Client API. Load ../../nvflare-shared/references/pytorch-model-exchange.md for
PyTorch-family tensor/state-dict rules before changing model exchange code.
The Lightning integration owns model load and send through callbacks installed
by flare.patch(trainer). Do not generate a manual FLModel send/receive path
for normal Lightning training.
Canonical Path
Use this path for Lightning conversion:
Confirm Lightning routing with
nvflare agent inspect source.Select a PyTorch-family recipe with
nvflare recipe list/show.Generate
client.pywithflare.patch(trainer)as the model exchange path.Generate
job.pythat builds the selected recipe and callsrecipe.execute(SimEnv(...)).Select exactly one final target per
lightning-validation.md: runpython job.pyfor local simulation without an export claim, or export and run the exported folder with the simulator CLI for a requested deployable artifact. Never run the local target and then export after it succeeds.
HE is not supported at steps 4–5: follow the HE-not-supported rule in
../../nvflare-shared/references/pytorch-family-recipe-selection.md.
Follow the Source Of Truth Boundary and the generated-entry rule in
../../nvflare-shared/references/conversion-workflow.md: client.py is an
FL-only Client API entry point, not a standalone/FL auto-detecting launcher.
Conversion Pattern
Import the Lightning client API:
import nvflare.client.lightning as flare.Build the
LightningModule,LightningDataModule, andTraineras the source code already does.Call
flare.patch(trainer)once, after the trainer is constructed.Loop while
flare.is_running()and calltrainer.fit/trainer.validate/trainer.testas the workflow requires.
import nvflare.client.lightning as flare
flare.init() # required before get_site_name(), get_config(), receive(), or other pre-patch context
trainer = Trainer(...)
flare.patch(trainer)
while flare.is_running():
# Optional: call receive() only when round/site/task metadata is needed.
# The patched trainer loads the global model internally.
flare.receive()
validate_global_model(trainer, model, datamodule=datamodule)
trainer.fit(model, datamodule=datamodule)
trainer.test(ckpt_path="best", datamodule=datamodule) # when test evidence is requested/availableAdapt validate_global_model from ../assets/lightning_client.py; it keeps
evaluation Lightning-native and preserves training-result metrics on the
patched exchange.
For evaluation-only / FedEval conversions, run trainer.validate(...) (the
patched trainer sends the validation metrics) and do not call
trainer.fit(...) — training was not requested, and fitting after the metrics
are sent can train an unwanted round or block the task. The packaged
../assets/lightning_client.py
main(..., evaluate_only=True, recipe_algorithm="fedeval") skips fit.
Pass that complete pair only when the resolved recipe algorithm is FedEval.
For every workflow that also trains, omit the argument so its default remains
False and the received training task completes through trainer.fit(...).
Patch Ownership Rules
flare.patch(trainer)installs callbacks that receive the global model into the Lightning model and send the updated model after fit. Let it own the exchange.Do not pass the received
input_modelintoTrainermethods. The patched trainer loads the global model internally.Do not add a second manual
flare.send(FLModel(...))for normal training; the patched trainer already sends the trained model.Use
flare.get_site_name()orflare.get_config()only when the code needs pre-patch context such as site-specific logging or data paths, and callflare.init()before the first such Client API context access.Use
flare.receive()in the patched loop only for FL task progression, round/site logging, or task metadata, never for manual model loading.During export inspection, verify generated or project-local modules referenced by server-side
class_pathconfig are packaged into the server app withrecipe.add_server_file(...)or an equivalent server-targeted API. Thetrain_scriptimport closure packages client apps and is not enough for per-site exports that createapp_serverseparately. Installed NVFLARE, framework, and third-party class paths stay runtime dependencies and are validated through requirements installation plus import/preflight checks.
Lightning Evaluation Template
Keep evaluation inside Lightning; do not reuse the raw PyTorch
model.eval() / torch.no_grad() loop for normal Lightning conversion:
Require or preserve
validation_step()/test_step()and a validation/test dataloader orLightningDataModule.Log validation metrics from the
LightningModulewithself.log(...)so they are visible in the trainer callback metrics.After
flare.patch(trainer)andflare.receive(), calltrainer.validate(model, datamodule=...)beforetrainer.fit(...)when server-side model selection or round metrics need validation; keep this inside thewhile flare.is_running()loop.Use
trainer.test(...)only when the source workflow already has test semantics or the user requests test reporting.Rely on Lightning's validate/test loops to set evaluation mode and disable gradients; generate a manual
model.eval()loop only when the conversion intentionally routes to plain PyTorch.If the source project lacks validation/test steps or dataloaders, ask in interactive mode or fail closed in unattended mode instead of inventing metric semantics.
Training-result metric delivery
For a training task, derive
evaluate_before_train = recipe_algorithm != "cyclic" from the normalized
algorithm returned by nvflare recipe show. When it is true, call an explicit
standalone trainer.validate(...) after flare.patch(trainer) and before
trainer.fit(...). The patched callback captures finite scalar callback metrics
from that validation and attaches them to the outgoing training result,
regardless of whether the executor's train_with_evaluation setting is False
or unavailable through the selected recipe. That setting controls whether
missing pre-training metrics are an error: True requires them; False makes
them optional rather than suppressing metrics that Lightning supplies.
Only that explicit pre-fit validation scores the received global model.
Lightning sanity checks and validation performed inside trainer.fit(...) run
in the fitting lifecycle and are deliberately excluded from the global-model
score.
Best-model selection therefore depends on the pre-fit call. Omitting it from a
non-Cyclic recipe leaves the received global model unscored, so the selector has
nothing to compare and no best global model is persisted; with
train_with_evaluation=True the round fails on the missing required metrics.
Do not expose an independent skip flag: derive the value from the recipe
algorithm so selection and evaluation cannot silently diverge.
Cyclic is the intentional exception. Its clients update the model sequentially, so their pre-fit validations would score different intermediate models rather than one round-global candidate. Skip the standalone pre-fit call, preserve any ordinary in-fit validation as local behavior, and report the persisted final model without claiming a best-model artifact. For a non-Cyclic source without validation semantics, ask or fail closed rather than silently disabling its selector. When an application must keep explicit pre-fit metrics local, report the need for an authorized custom task-result filter.
Use ../assets/lightning_client.py as the copyable validate-before-fit loop.
Its finite-scalar check validates the values returned by trainer.validate,
while the patched callback owns delivery. Do not copy validation metrics into
model.__fl_meta__[MetaKey.INITIAL_METRICS]: that reserved metadata bypasses
the automatic capture contract and can replace the freshly captured callback
metrics. Other source-owned __fl_meta__ entries remain unrelated custom
metadata.
Metric names are not remapped by NVFLARE. The key emitted through self.log,
the recipe's key_metric, and artifact reporting must match exactly. Prove the
key in client and aggregated FLModel.metrics or server artifacts before
claiming server-side model selection; local callback metrics alone remain
insufficient end-to-end validation evidence.
Metric names are selected with an explicit direction. When the source
establishes that lower val_loss is better, preserve its existing epoch-level
log:
self.log("val_loss", loss, on_step=False, on_epoch=True)The recipe then selects key_metric="val_loss", key_metric_mode="min".
For DDP, preserve the source-backed distributed reduction behavior on the log.
Only choose a direction the source establishes; do not invent one. Use a
negated companion only when the resolved recipe lacks key_metric_mode; name
and document that compatibility metric explicitly. A val_loss-only module is
never a reason to fail closed or to skip requested best-model selection.
If a custom ModelAggregator is selected, it must also aggregate supported
client FLModel.metrics values and return them in the aggregated
FLModel.metrics. Follow the Custom Aggregation contract in
../../nvflare-shared/references/conversion-workflow.md and adapt
../../nvflare-shared/assets/aggregator.py; a parameters-only aggregate loses
the server-level metric even when clients delivered it.
This template is self-contained packaged guidance; do not depend on NVFLARE
repository examples/ being present in the user's environment. The runnable
form ships at ../assets/lightning_client.py; adapt it rather than inventing a
new structure.
Preserve Lightning Behavior
Preserve user callbacks, loggers, and checkpoint callbacks unless the user asks to change them.
Repo-shipped checkpoint files (
.ckptpassed toload_from_checkpoint,Trainer.fit(ckpt_path=...), or resume logic) are untrusted executable input per../../nvflare-shared/references/conversion-workflow.md: full-unpickle loading of a repo-supplied checkpoint is ask/fail. Checkpoints produced by the current validation run (for exampleckpt_path="best"from this run's checkpoint callback) may follow normal Lightning handling.Keep the
LightningModule/LightningDataModulearchitecture and data logic; do not rewrite training_step/validation_step semantics.Avoid repeated expensive setup (model build, dataset download) inside the FL round loop; construct the model, datamodule, and trainer once before the loop when the source code allows it.
Local Data And Loss Policy
Follow the training-policy distinction in
../../nvflare-shared/references/pytorch-model-exchange.md and the site split guidance in
../../nvflare-shared/references/conversion-workflow.md. Lightning-specific implication:
label/site-derived values that affect training_step, LightningDataModule
sampling, or validation/test decision logic remain local to each site partition
unless the user explicitly requests one global training policy. Do not move
those values into recipe model args just because architecture args must be
shared.
If such a local value is a persistent model parameter or buffer, recomputing it
before the round loop does not keep it local: the patched trainer sends its full
state_dict() and the received model can overwrite the value. The FedAvg recipe
exclude_vars argument is only an aggregation rule; it is not a bidirectional
payload filter and is not a locality or privacy control.
For a FedAvg train task, keep an explicitly named state key local only by
filtering both network directions with separate filters:
from nvflare.app_common.filters import ExcludeVars
recipe.add_server_output_filter(ExcludeVars([local_key]), tasks=["train"])
recipe.add_client_output_filter(ExcludeVars([local_key]), tasks=["train"])Pair those filters with
flare.patch(trainer, load_state_dict_strict=False), because each received
global model intentionally omits the local key. Non-strict loading does not
suppress outbound state by itself. Apply the same two-direction rule to every
model-bearing task selected by a different recipe. Verify exported server and
client filter configuration, then verify that the exact key is absent from both
directions—including the initial and later server-to-client payloads—and the
site-computed value is not overwritten in the first or later rounds. If the
selected recipe does not expose supported filters for every
model-bearing direction, ask or fail closed. Do not substitute aggregation-only
exclude_vars or silently exchange the value.
Report the split policy, seed, and where local training-policy values are computed.
For multi-site conversion from a single-node Lightning source, the generated
client or LightningDataModule must filter the local training split by site.
Do not let every simulated site train on the full source training set unless
the user explicitly asks for shared training data or the source already provides
site-specific data that resolves to that behavior. Validation/test splits may
remain shared only when that matches the source's validation/test semantics.
Model Construction Consistency
Follow the shared model-config and construction-consistency rule in
../../nvflare-shared/references/conversion-workflow.md ("Recipe Model Config"):
same class and constructor args on server and client, explicit config whenever
reconstruction needs a constructor value, and derive-or-ask/fail-closed for it.
Lightning-specific delta: the exchanged unit is the whole LightningModule
managed by the patched trainer, so construct the identical LightningModule on
the server and on the client in client.py, not just the inner
torch.nn.Module. For explicit config, express shared arguments as a
model_args dict (prefer class_path; path is the normalized job-config
key).
Source Layout
Use the canonical FLARE source layout defined in
../../nvflare-shared/references/conversion-workflow.md ("Generated Job Layout").
Lightning-specific delta: client.py patches the trainer as the model-exchange
path, and model.py holds the LightningModule (and LightningDataModule)
definition when a new file is needed. Avoid ad hoc names such as fl_train.py
unless the user requests them, and use
../../nvflare-shared/references/runtime-output-guidance.md for runtime
workspaces, exported job directories, and validation output locations.
If the Lightning entry point imports a model module or source file — whatever
its filename, for example model.py, simple_model.py, or a module loaded
through explicit import machinery — or defines the
LightningModule/LightningDataModule in train.py, preserve that source
structure. Generate client.py, job.py, and optional aggregators.py; do not
generate a new replacement model implementation that recreates the full
Lightning/data stack. If the generated package needs the canonical model.py
name, use a mechanical copy/rename or thin wrapper around the detected source
module rather than re-authoring it.
Recipe Reuse
Lightning reuses the PyTorch recipe family. Follow
../../nvflare-shared/references/pytorch-family-recipe-selection.md for recipe
discovery, the algorithm guide, catalog-based selection rules, and the
HE-not-supported rule — the same catalog and rules apply to Lightning, including
non-FedAvg workflows such as FedOpt, FedProx, SCAFFOLD, Cyclic, Swarm, and
FedEval. Use FedAvg for standard horizontal training and FedEval for
evaluation-only.
The generated job.py should use the selected recipe's public parameters from
recipe show, construct the model through explicit class_path (or path) plus
args when constructor arguments are required, and call
recipe.execute(SimEnv(...)). HE is not supported: homomorphic-encryption
recipes reject SimEnv and require provisioned PocEnv/ProdEnv outside
conversion scope — follow the HE-not-supported rule in
../../nvflare-shared/references/pytorch-family-recipe-selection.md (report
unsupported, route to provisioning/deployment, ask or fail closed; do not
generate an HE job). Do not replace this with ad
hoc SDK-internal APIs based on local source or docstring inspection. Follow
../../nvflare-shared/references/conversion-workflow.md for export and
command-line behavior.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs Python
Security
What our scanner noticed· Medium risk
- Large base64-encoded blobs
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- NVIDIA FLARE Team
- Publisher
- NVIDIA (Official)
- Source
- NVIDIA/skills · skills/nvflare-convert-lightning · commit fce3cca
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE-APACHE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by NVIDIA FLARE Team or NVIDIA.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download nvflare-convert-lightning.zip