nvflare-convert-lightning
Skill1k starsChanged 12 days agoApache-2.0View on GitHub
Convert existing PyTorch Lightning training code into an NVFLARE federated job using the Lightning Client API patch, local validation, and job export; use only when the request names federated/NVFLARE conversion or asks multiple sites to train collaboratively while keeping each site's data local, and either names PyTorch Lightning or preliminary source inspection identifies one Lightning owner; do not use for non-federated Lightning work such as DDP, profiling, inference serving, or training-loop changes, nor for plain PyTorch, TensorFlow/Keras, other frameworks, deployment, POC/production lifecycle, or experiment workflows.
1 other project uses a version of this.
Trending
Less talk lately.about the whole repository
Most recently taken up by
- NVIDIA/skillsword for word, first seen Oct 1, 2026
Who's talking about NVIDIA/NVFlare
- Kaggle/kaggle-sdk-python“kagglesdk 0.1.31 and 0.1.32 import a missing competitions.legacy package”GitHub · Jun 30, 2026 · 1 reactions
- londonaicentre/FLIP“docs: call the NVIDIA framework FLARE, its short official name”GitHub · Oct 17, 2026
- NVIDIA/SkillEvaluator“[BUG]: Generated BENCHMARK.md does not faithfully explain a passing gate and splits canonical case IDs”GitHub · Oct 9, 2026
- Denimworld12/Hospital-Chain“feat: run hospital nodes on separate machines with provisioning kits and a cross-address verifier”GitHub · Oct 2, 2026
- ai4os/ai4os-nvflare“Update NVFlare version to 2.8”GitHub · Jul 16, 2026
The biggest 5 of 25 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 25
Talked about on GitHub (25 times).
On GitHub · 25
- Jun 30, 2026kagglesdk 0.1.31 and 0.1.32 import a missing competitions.legacy package — Kaggle/kaggle-sdk-python1 reaction · 2 comments
- Oct 17, 2026docs: call the NVIDIA framework FLARE, its short official name — londonaicentre/FLIP0 reactions · 1 comment
- Oct 9, 2026[BUG]: Generated BENCHMARK.md does not faithfully explain a passing gate and splits canonical case IDs — NVIDIA/SkillEvaluatorsays it tested it0 reactions · 1 comment
- Oct 2, 2026feat: run hospital nodes on separate machines with provisioning kits and a cross-address verifier — Denimworld12/Hospital-Chain0 reactions
- Jul 16, 2026Update NVFlare version to 2.8 — ai4os/ai4os-nvflare0 reactions
20 more on GitHub
- Jul 6, 2026Upgrade NVFlare backbone 2.7.2 → 2.8.0 (deferred until a clean 2.7.2 run) — KatherLab/MediSwarm0 reactions · 3 comments
- Jun 26, 2026Upgrade NVFLARE backend 2.7.2 → 2.8.0 — londonaicentre/FLIP0 reactions
- Jun 22, 2026Add step-ca ephemeral admin certs — pcnudde/NVFlare0 reactions · 1 comment
- May 7, 2026feat(privacy): federated learning architecture-ready (Horizon Europe / EU4Health alignment) — Yanstart/VarunaPoC0 reactions · 1 comment
- Jan 7, 2026T3: Model fitting (deploying GWAS tool / model on every client) [Enamul, ++] — collaborativebioinformatics/FedGen0 reactions
- Sep 10, 2025[Feature]: From Vertical FL feasibility (#363) to first example — londonaicentre/FLIP0 reactions · 1 comment
- Jun 23, 2025Secure xgboost example — RhinoHealth/user-resources0 reactions · 3 comments
- May 14, 2025NVFlare backbone upgrade for better connection performance — KatherLab/MediSwarm0 reactions · 2 comments
- Mar 24, 2025NVFlare Integration — KCL-BMEIS/UltraFlwr0 reactions
- Jul 14, 2024Try to fix experiment already exist issue in `MLFlowHandler` — Project-MONAI/MONAI0 reactions · 11 comments
- Sep 13, 2023Add stats_sender to MonaiAlgo for FL stats — Project-MONAI/MONAI0 reactions · 1 comment
- Aug 9, 2023【CS-part3】New submissions for Wed, 9 Aug 23 — Yukeaaa/arxiv-daily0 reactions
- Jul 12, 2023New learner cifar10 — yanchengnv/NVFlare0 reactions
- May 6, 2023Bump nvflare from 2.0.10 to 2.3.0 in /federated_learning — NVIDIA/fsi-samples0 reactions · 1 comment
- Mar 22, 2023[WIP] add `FLStatsHandler` — Project-MONAI/MONAI0 reactions · 3 comments
- Mar 21, 2023Try NVFlare cifar10 example — KatherLab/swarm-learning-hpe0 reactions
- Mar 21, 2023Apply the new data split strategies — KatherLab/swarm-learning-hpe0 reactions
- Dec 6, 2022How to use bst.eval_set() and bst.update() with xgboost_ray — ray-project/xgboost_ray0 reactions · 3 comments
- May 18, 2022713 Update nvflare example for 2.1 — Project-MONAI/tutorials0 reactions · 2 comments
- Mar 22, 2022Bump nvflare from 2.0.2 to 2.0.16 in /federated_learning/nvflare/nvflare_spleen_example — Project-MONAI/tutorials0 reactions · 4 comments
Other versions1 project uses a version of this.
Word for word · 1
- NVIDIA/skills★ 3.9k100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository16 other files it gives its agents.
- AGENTS.mdAGENTS.md
- examples/tutorials/self-paced-training/AGENTS.mdAGENTS.md
- research/auto-fl-research/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- research/auto-fl-research/CLAUDE.mdCLAUDE.md
- autofl-nvflare-reportSkill
- autofl-nvflareSkill
- nvflare-autofl-reportSkill
- nvflare-autoflSkill
- nvflare-convert-huggingfaceSkill
- nvflare-convert-pytorchSkill
- nvflare-diagnose-jobSkill
- nvflare-fed-statsSkill
- nvflare-orientSkill
- nvflare-sharedSkill
- nvflare-example-skillSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
13 rules. About 0 are common, 3 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 30
Always read this converter SKILL.md with ../nvflare-shared/references/conversion-common.md.
- Very specific: line 41
Only after generated files exist, ../nvflare-shared/references/validation-evidence.md, then references/lightning-validation.md.
- Distinctive: line 52
Do not use for non-federated Lightning changes such as DDP-only configuration, profiling, inference serving, callbacks, early stopping, or …
- Very specific: line 66
If a request combines federated statistics and model-training conversion, treat it as two independent jobs and workflows: do not merge or …
- Very specific: line 115
Add or update job.py under the shared constructor-serialization rule.
- Distinctive: line 132
If the selected full-run target fails, diagnose it, apply a scoped fix, and rerun that same target.
- Very specific: line 164
Must integrate through flare.patch(trainer) and let the patched trainer own model exchange.
- Very specific: line 168
Must treat flare.receive() inside the patched loop as optional metadata or task-progression access only, not as a second model-load path.
- Very specific: line 170
Must keep evaluation inside Lightning (trainer.validate/trainer.test, validation_step, self.log).
- Very specific: line 178
Must audit model constructor arguments before writing job.py by reading the LightningModule.__init__ signature and the selected recipe's …
- Very specific: line 186
Must use the PyTorch recipe family.
- Distinctive: line 190
Must preserve local-only callbacks and logger behavior where safe.
- Very specific: line 195
Must not make non-PyTorch-family skills load ../nvflare-shared/references/pytorch-model-exchange.md.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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.
- for a requested local or first-run simulation without an export claim, run
- 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.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

