-
Notifications
You must be signed in to change notification settings - Fork 228
Convert job to recipe for LLM_HF example #3888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR converts the LLM HuggingFace example from using the imperative Job API to the declarative Recipe API, aligning with NVFLARE's preferred pattern for job configuration. The refactoring encapsulates the job configuration logic into a reusable LLMHFRecipe class while maintaining the same functional behavior.
Key changes:
- Introduced
LLMHFRecipeclass that wraps the existing job configuration logic - Refactored
main()function to instantiate the recipe and delegate execution - Streamlined argument parser help text for consistency
- Fixed spelling error in client_ids help text
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Greptile OverviewGreptile SummaryRefactored LLM HuggingFace example from imperative job API to Recipe pattern, wrapping the FedJob configuration logic in a Key changes:
Functional equivalence:
Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User as User/main()
participant Recipe as LLMHFRecipe
participant FedJob as FedJob
participant Env as ExecEnv (SimEnv/ProdEnv)
participant Run as Run
User->>User: Parse arguments
User->>User: Split GPUs & validate
User->>Recipe: __init__(client_ids, num_rounds, etc.)
activate Recipe
Recipe->>FedJob: Create FedJob(name, min_clients)
Recipe->>FedJob: to(FedAvg controller, "server")
alt quantize_mode specified
Recipe->>FedJob: to(ModelQuantizer, "server")
Recipe->>FedJob: to(ModelDequantizer, "server")
end
Recipe->>FedJob: to(model_file, "server")
Recipe->>FedJob: to(PTFileModelPersistor, "server")
Recipe->>FedJob: to(IntimeModelSelector, "server")
loop for each client
Recipe->>FedJob: to(ScriptRunner, client_site)
alt quantize_mode
Recipe->>FedJob: to(quantizer/dequantizer, client_site)
end
Recipe->>FedJob: to(client_params, client_site)
end
Recipe->>Recipe: super().__init__(job)
deactivate Recipe
User->>FedJob: export_job(job_dir)
alt startup_kit_location provided
User->>Env: Create ProdEnv
else simulation mode
User->>Env: Create SimEnv
end
User->>Recipe: execute(env)
Recipe->>Env: deploy(job)
Env-->>Recipe: job_id
Recipe->>Run: Create Run(env, job_id)
Recipe-->>User: run
User->>Run: get_status()
Run-->>User: status
User->>Run: get_result()
Run-->>User: result
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file reviewed, no comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file reviewed, no comments
Fixes # .
Description
From job api to recipe
Types of changes
./runtest.sh.