nvflare-convert-huggingface
Skill1k starsChanged 12 days agoApache-2.0View on GitHub
Convert existing Hugging Face Transformers Trainer or TRL SFTTrainer training code into an NVFLARE federated job using flare.patch(trainer), local validation, and job export; use when the user names Hugging Face or preliminary source inspection identifies one Hugging Face owner, and not for manual PyTorch loops, Lightning, inference-only pipelines, deployment, or experiment workflows.
1 other project uses a version of this, 1 of them edited.
Trending
Less talk lately.about the whole repository
Most recently taken up by
- NVIDIA/skillsedited, 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 · 0
None found.
Edited · 1
- NVIDIA/skills★ 3.9k100% same
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-lightningSkill
- 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
20 rules. About 0 are common, 3 are distinctive, and 17 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.
17
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 21
Use when converting training code built around transformers.Trainer, Seq2SeqTrainer, TRL SFTTrainer, or another Trainer subclass.
- Very specific: line 28
Do not use for an AutoModel driven by a manual PyTorch loop without a Hugging Face Trainer (route to nvflare-convert-pytorch), PyTorch …
- Very specific: line 41
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 52
Use run_script() only during the validation phase after loading references/huggingface-validation.md.
- Very specific: line 116
Only after generated files exist, load ../nvflare-shared/references/validation-evidence.md and references/huggingface-validation.md.
- Very specific: line 135
Must use flare.patch(trainer) as the sole model-exchange owner.
- Very specific: line 138
Must follow the Client API initialization and conditional rank contract in ../nvflare-shared/references/conversion-common.md.
- Very specific: line 143
Must preserve source evaluation.
- Very specific: line 145
Do not invent compute_metrics, label mappings, averaging denominators, or metric direction.
- Very specific: line 147
Must follow the Best-Model Metric policy in ../nvflare-shared/references/pytorch-family-recipe-construction.md.
- Distinctive: line 158
Must preserve PEFT configuration exactly and verify adapter key compatibility between the server model and patched Trainer.
- Very specific: line 162
Must verify that trainer.model owns all federated trainable state for Trainer subclasses with reference, reward, value-head, or other …
- Very specific: line 166
Must preserve model constructor values needed on both server and clients per ../nvflare-shared/references/pytorch-model-exchange.md …
- Very specific: line 170
Must patch only one Trainer per Python process.
- Very specific: line 172
Must use a positive TrainingArguments.max_steps budget for a length-less iterable training dataset and let flare.patch(trainer) infer it.
- Very specific: line 174
Must reject or report DeepSpeed, FSDP, save_only_model=True with restore_state=True, load_best_model_at_end=True, prebuilt …
- Very specific: line 182
Must initialize torch.distributed before patching when rank environment variables declare multiple ranks.
- Distinctive: line 185
Must use the maintained HF validation resolver with an explicit local/Hub source.
- Very specific: line 195
Always read this converter SKILL.md together with ../nvflare-shared/references/conversion-common.md.
- Distinctive: line 196
Do not preload validation, state/DDP, broad workflow, dependency, or reporting references.
≈ “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 Hugging Face
Use When
Use when converting training code built around transformers.Trainer, Seq2SeqTrainer,
TRL SFTTrainer, or another Trainer subclass. Support full-model and PEFT/LoRA
fine-tuning, datasets/tokenizers, Trainer callbacks and metrics, checkpoint continuity,
and replicated torch.distributed training.
Do Not Use When
Do not use for an AutoModel driven by a manual PyTorch loop without a
Hugging Face Trainer (route to nvflare-convert-pytorch), PyTorch Lightning
(route to nvflare-convert-lightning, including Lightning modules that contain
Transformers models), inference-only pipelines, model serving, failed jobs
(route to nvflare-diagnose-job), or federated statistics without training
(route to nvflare-fed-stats). Route a project with active Lightning and
Hugging Face Trainer entrypoints to nvflare-orient to select one training-loop
owner or separate jobs. Route unresolved Trainer ownership, such as a Trainer
factory without a bound owner call, to nvflare-orient; do not patch either Trainer.
Out of scope: DeepSpeed, FSDP, production/POC deployment, controller rewrites,
experiment search, and privacy-protection requests such as HE, encrypted
aggregation, differential privacy, or privacy filters; never substitute an
unprotected recipe or present a disclaimer as implementation.
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.
Available Scripts
| Script | Purpose | Arguments |
scripts/resolve_model_snapshot.py | Resolve a local or Hub model/dataset snapshot and emit JSON evidence. | Identifier; required --source; optional source-root, download, revision, cache, and repository-type flags. |
Use run_script() only during the validation phase after loading references/huggingface-validation.md. For example:
run_script("scripts/resolve_model_snapshot.py", ["--source", "local", "--source-root", "<absolute-source-root>", "<configured-path>"])run_script("scripts/resolve_model_snapshot.py", ["--source", "hub", "<org/model>"])
Workflow
- Load
../nvflare-shared/references/conversion-common.mdand apply it for the whole conversion; this SKILL.md states only the framework-specific deltas. Load../nvflare-shared/references/conversion-workflow.mdonly for a non-standard rerun, authorization, or missing-semantics case; it no longer holds the data-location or partitioning contracts, whose invariantsconversion-common.mdowns. Load../nvflare-shared/references/site-data-and-paths.mdfor generated partitions, relative paths, or per-site data locations. - Inspect before editing with
nvflare agent inspect source <path> --format jsonplus direct source reading. Loadreferences/huggingface-detection.mdduring this phase. If inspect recommendsnvflare-orientfor unresolved Trainer ownership or active Lightning/Hugging Face owners, stop before editing. Extract the entrypoint, Trainer subclass, model constructor, tokenizer or processor, datasets and collator, Trainer arguments,compute_metrics, callbacks, checkpoint and PEFT settings, precision, local budget, distributed launcher, site/round counts, data location, and aggregation intent. Do not import or execute user training modules to discover them. - Apply the dependency-install ordering rule in
../nvflare-shared/references/conversion-common.mdbefore any Python command imports user, framework, NVFLARE, or declared dependencies. Keep dependency inventory single-purpose: check NVFLARE separately, inventory non-product packages separately, and do not append Hugging Face cache or filesystem discovery. Defer model and dataset availability checks to the maintained resolver during validation. If an optional path must be inspected, run it separately and report a missing directory with exit code zero. - Select the recipe from FL intent. For explicit FedAvg, run
nvflare recipe show fedavg-pt --format json, then immediately load../nvflare-shared/references/pytorch-family-recipe-construction.mdand use the returned module, class, and parameters with the required construction and execution shape inassets/job.py. ImportFedAvgRecipefromnvflare.app_opt.pt.recipes.fedavg, never fromnvflare.recipe. Treatclass_pathas the public recipe key andpathas its normalized exported representation; do not inspect Recipe source or signatures to reconcile them. Do not guess adjacent symbols or add per-site recipe config unless sites genuinely differ. Load../nvflare-shared/references/pytorch-family-recipe-selection.mdonly for ambiguous, evaluation-only, or non-FedAvg requests. - Convert with
references/huggingface-conversion.mdand adaptassets/client_with_eval.pyrather than drafting a new round loop. Preserve model, tokenizer/processor, datasets, collator, Trainer arguments, callbacks, and metrics. Apply the step-1 data-location rules to the client's data argument. Import the Client API asimport nvflare.client.hf as flare, soflare.init(),flare.patch(), andflare.is_running()resolve tonvflare.client.hf. Keepflare.patch(trainer)simple with inferredparams_scope="auto"and encode one per-round budget in Trainer arguments: requested steps usemax_steps, requested epochs usenum_train_epochs, and a silent prompt uses the reported defaultmax_steps=10unless source-budget preservation was requested. Do not duplicate the budget in patchlocal_steps/local_epochs. When the client usesHfArgumentParser, construct it withallow_abbrev=False. - Adapt
assets/server_model.pyandassets/job.pyinstead of inventing server-model, packaging, export, orSimEnvwiring. Keep generated and packaged project-local modules in the same writable source directory. Never use..intrain_script,add_server_file(), oradd_client_file(); use an existing resolved absolute path when co-location is impossible. Keep the server and Trainer model factory and exchange keyspace identical. Use the recipe's documentedclass_pathorpathkey plus completeargsfor required or overridden values; a direct zero-argument instance must not usefrom_pretrained(), downloads, or checkpoint loading during job construction. Apply only options confirmed by the construction reference. Preserve the job asset's recipe-before-parser ordering,ArgumentParser(allow_abbrev=False), and strictparse_args(); do not useparse_known_args(). - Only after generated files exist, load
../nvflare-shared/references/validation-evidence.mdandreferences/huggingface-validation.md. Follow the shared compile, construction, simulation, and terminal-evidence ladder. Inspect export/package evidence only for an exported final target; inspect a local target's materialized evidence after its run. Apply only the standard HF Trainer checks and stop at the first failed rung. Review and exercise the maintained assets directly; do not inspect NVFLARE implementation source, improvise Recipe API probes, or write one-off AST programs to re-prove them. Usereferences/huggingface-state-and-distributed.mdonly when inspection found PEFT, DDP, checkpoint/restore overrides, auxiliary trainable models, or another non-default patch setting. - Report the recipe, source facts, parameter scope, data partition, changed
files, validation status, and exact artifact paths. When validation produces
metrics, load
../nvflare-shared/references/metrics-and-artifact-reporting.mdbefore the final response and report each observed primary scalar with its metric name, numeric value, and artifact or bounded-log source.
Requirements
- Must use
flare.patch(trainer)as the sole model-exchange owner.receive()inside a patched loop may inspect task metadata only; it must not load a second copy of the global model. - Must follow the Client API initialization and conditional rank contract in
../nvflare-shared/references/conversion-common.md. Keep the generated client rankless; the public Client API owns distributed-rank resolution and rejection. Loadreferences/huggingface-state-and-distributed.mdonly for a distributed multi-process source path. - Must preserve source evaluation. When per-round global-model evaluation is
required, call
trainer.evaluate()beforetrainer.train()on every rank. Do not inventcompute_metrics, label mappings, averaging denominators, or metric direction. - Must follow the Best-Model Metric policy in
../nvflare-shared/references/pytorch-family-recipe-construction.md; the Hugging Face delta is only how the delivered key is named and produced. Must preserve source metric names when practical: if the generatedtrainer.evaluate()emitsaccuracy, setkey_metric="accuracy"; if Trainer emits a prefixed key such aseval_accuracy, set the server to that exact key and report the source-to-server mapping. When best-model selection is requested, every lower-is-better metric, including Trainer-generatedeval_loss, is delivered as an explicitly negated companion and selected by that key — never as raw loss. When selection is not requested, usekey_metric=""; do not omit it and accidentally activate the recipe default. - Must preserve PEFT configuration exactly and verify adapter key compatibility between the server model and patched Trainer. Do not infer LoRA target modules, silently switch adapter/full-model scope, or solve key mismatches with non-strict loading.
- Must verify that
trainer.modelowns all federated trainable state for Trainer subclasses with reference, reward, value-head, or other auxiliary models. Ask or fail closed whenparams_scope="auto"would omit trainable state required by the algorithm. - Must preserve model constructor values needed on both server and clients per
../nvflare-shared/references/pytorch-model-exchange.md(State-Dict Compatibility). Ask one semantic question or fail closed when required values are not statically available. - Must patch only one Trainer per Python process. Preserve a single Trainer
lifecycle across rounds when
restore_state=True. - Must use a positive
TrainingArguments.max_stepsbudget for a length-less iterable training dataset and letflare.patch(trainer)infer it. - Must reject or report DeepSpeed, FSDP,
save_only_model=Truewithrestore_state=True,load_best_model_at_end=True, prebuilt optimizer/scheduler instances withrestore_state=False, and checkpoint paths not visible to every distributed rank. Do not rewrite these settings silently.launch_onceis a framework-neutral recipe parameter owned by../nvflare-shared/references/pytorch-family-recipe-construction.md; the Hugging Face delta is only that the product rejects explicitlaunch_once=Falsetogether withrestore_state=True. - Must initialize
torch.distributedbefore patching when rank environment variables declare multiple ranks. All ranks must call patched Trainer methods in identical order. - Must use the maintained HF validation resolver with an explicit local/Hub
source. For authorized downloads it obtains or validates a full commit-SHA
revision before downloading. Must not copy it into
generated job code, set
trust_remote_code=True, download model/data artifacts unless requested, or recover from a cache-only miss by going online. Cache misses, remote identifiers, and validation requests do not authorize online retries; see../nvflare-shared/references/conversion-common.md. - Site partitioning, custom aggregation, the Source Of Truth Boundary, and user
input/authorization follow
../nvflare-shared/references/conversion-common.md.
Always read this converter SKILL.md together with ../nvflare-shared/references/conversion-common.md. Complete each workflow phase before loading the next phase's reference.
Do not preload validation, state/DDP, broad workflow, dependency, or reporting references. The standard FedAvg path loads, in order:
../nvflare-shared/references/conversion-common.md, references/huggingface-detection.md, and ../nvflare-shared/references/site-data-and-paths.md only for its stated triggers;
../nvflare-shared/references/pytorch-family-recipe-construction.md, references/huggingface-conversion.md, and ../nvflare-shared/references/pytorch-model-exchange.md;
then ../nvflare-shared/references/validation-evidence.md and references/huggingface-validation.md; load references/huggingface-state-and-distributed.md and other shared references only under the triggers above. Do not depend on repository examples.
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.

