Skip to content
Machine Learning
Skill

/nvflare-convert-huggingface

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,

From plugin
nvflare
1k11 skills

Claude Code

$ npx -y skills add nvidia/nvflare --skill nvflare-convert-huggingface --agent claude-code

SKILL.md

nvflare-convert-huggingface.SKILL.md
name: nvflare-convert-huggingface
description: "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."
license: Apache-2.0
metadata:
  version: "0.1.0"
  author: "NVIDIA FLARE Team <federatedlearning@nvidia.com>"
  min-flare-version: "2.9.0"
  blast-radius: runs_simulator
  category: Conversion
  tags: "nvflare, federated-learning, huggingface, transformers, trl, peft, conversion"
  languages: "python"
  frameworks: "huggingface, transformers, trl, pytorch, nvflare"
  domain: ml

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

1. Load `../nvflare-shared/references/conversion-common.md` and apply it for the whole conversion; this SKILL.md states only the framework-specific deltas. Load `../nvflare-shared/references/conversion-workflow.md` only for a non-standard rerun, authorization, or missing-semantics case; it no longer holds the data-location or partitioning contracts, whose invariants `conversion-common.md` owns. Load `../nvflare-shared/references/site-data-and-paths.md` for generated partitions, relative paths, or per-site data locations. 2. Inspect before editing with `nvflare agent inspect source <path> --format json` plus direct source reading. Load `references/huggingface-detection.md` during this phase. If inspect recommends `nvflare-orient` for 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. 3. Apply the dependency-install ordering rule in `../nvflare-shared/references/conversion-common.md` before 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. 4. 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.md` and use the returned module, class, and parameters with the required construction and execution shape in `assets/job.py`. Import `FedAvgRecipe` from `nvflare.app_opt.pt.recipes.fedavg`, never from `nvflare.recipe`. Treat `class_path` as the public recipe key and `path` as 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.md` only for ambiguous, evaluation-only, or non-FedAvg requests. 5. Convert with `references/huggingface-conversion.md` and adapt `assets/client_with_eva

Read more
@nvidia
Ships withnvflare

Build federated computing applications that collaborate across organizational and geographic boundaries while each site keeps control of its data and local execution.

Stars on GitHub

Momentum

stars in total
1.0k
Star history of nvidia/nvflare on GitHub, a chart by star-history.com

Other skills on nvflare.

autofl-nvflare-report

autofl-nvflare-report

Generate and commit a markdown report after an Auto-FL NVFlare autoresearch experiment has been manually stopped. Use when the…

@nvidia@nvidiaInstall Skill
autofl-nvflare

autofl-nvflare

Help coding agents work on an NVFlare-based Auto-FL harness that follows an autoresearch-style loop. Use when the user wants to…

@nvidia@nvidiaInstall Skill
nvflare-autofl-report

nvflare-autofl-report

Generate a reproducible final report, literature-outcome synthesis, JSON summary, and refreshed progress plot for a stopped or…

@nvidia@nvidiaInstall Skill
nvflare-autofl

nvflare-autofl

Use for agent-assisted Auto-FL optimization of an existing NVFLARE job in simulation, POC, or production. Do not use for code…

@nvidia@nvidiaInstall Skill
nvflare-convert-lightning

nvflare-convert-lightn…

Convert existing PyTorch Lightning training code into an NVFLARE federated job using the Lightning Client API patch, local…

@nvidia@nvidiaInstall Skill
nvflare-convert-pytorch

nvflare-convert-pytorc…

Convert existing plain or manual PyTorch training code into an NVFLARE federated job using Client API model exchange, local…

@nvidia@nvidiaInstall Skill

More skills from other plugins.

analyze-ci

analyze-ci

Analyze failed GitHub Action jobs. Takes one or more GitHub URLs (job, workflow-run, or PR) and summarizes each failure with root…

mlflow6d29k
@mlflow@mlflowInstall Skill
hf-cli

hf-cli

Hugging Face Hub CLI (`hf`) for downloading, uploading, and managing models, datasets, spaces, buckets, repos, papers, jobs, and…

skills3w11k
@huggingface@huggingfaceInstall Skill
feast-architecture

feast-architecture

Internals of the Feast codebase — how each component works, where the key abstractions live, and the data flow through the…

feast10d7.4k
@feast-dev@feast-devInstall Skill
add-ecosystem

add-ecosystem

Add a new ecosystem and base model to basemodel.constants.ts. Use when onboarding a new model family from providers like Baidu,…

civitai7d7.3k
@civitai@civitaiInstall Skill

Questions about nvflare-convert-huggingface.

Which coding agents can use nvflare-convert-huggingface?
nvflare-convert-huggingface installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.