feat: add disk-mode weight update flow to gateway#1237
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a disk-based weight update mechanism, allowing model weights to be transferred via shared storage as an alternative to the AWEX method. The changes include updates to the API structures, controllers, and the gateway to handle disk-specific parameters such as save paths and LoRA adapter names. The gateway now manages the update lifecycle by pausing inference, triggering saves from training workers, loading weights into inference workers, and resuming generation. Feedback focuses on optimizing the save process for distributed training to avoid redundant operations, validating mandatory fields for disk mode during the connection phase, and improving error logging with tracebacks.
| await asyncio.gather( | ||
| *[ | ||
| _post_json(session, f"{url}/save", timeout_s, json_data=save_payload) | ||
| for url in pair_info.train_worker_urls | ||
| ] | ||
| ) |
There was a problem hiding this comment.
Calling the /save endpoint on all training workers simultaneously can be problematic if the training engine (e.g., FSDP) performs a collective consolidated save. In such cases, the save operation should typically be triggered on only one rank (usually rank 0) to avoid redundant operations or race conditions when writing to shared storage. If the workers are expected to save shards, they would likely need distinct paths.
# Trigger save on the first training worker (typically rank 0).
# For distributed training like FSDP, a single trigger is usually sufficient
# for a consolidated checkpoint save to shared storage.
await _post_json(
session,
f"{pair_info.train_worker_urls[0]}/save",
timeout_s,
json_data=save_payload,
)| if body.mode == "disk": | ||
| pair_info = PairInfo( | ||
| pair_name=pair_name, | ||
| train_worker_urls=train_urls, | ||
| inference_worker_urls=inference_urls, | ||
| mode="disk", | ||
| save_path=body.save_path, | ||
| use_lora=body.use_lora, | ||
| lora_name=body.lora_name, | ||
| ) |
There was a problem hiding this comment.
When mode is set to "disk", the save_path is required for the weight update flow to function correctly. It should be validated during the connection phase to return a clear error to the client if it's missing, rather than failing later during the transfer operation.
| if body.mode == "disk": | |
| pair_info = PairInfo( | |
| pair_name=pair_name, | |
| train_worker_urls=train_urls, | |
| inference_worker_urls=inference_urls, | |
| mode="disk", | |
| save_path=body.save_path, | |
| use_lora=body.use_lora, | |
| lora_name=body.lora_name, | |
| ) | |
| if body.mode == "disk": | |
| if not body.save_path: | |
| return JSONResponse( | |
| status_code=400, | |
| content={"error": "save_path is required for disk mode"}, | |
| ) | |
| pair_info = PairInfo( | |
| pair_name=pair_name, | |
| train_worker_urls=train_urls, | |
| inference_worker_urls=inference_urls, | |
| mode="disk", | |
| save_path=body.save_path, | |
| use_lora=body.use_lora, | |
| lora_name=body.lora_name, | |
| ) |
| logger.error( | ||
| "Weight update failed for pair '%s': %s", | ||
| pair_info.pair_name, | ||
| e, | ||
| ) |
There was a problem hiding this comment.
aa0094a to
9e33ee0
Compare
Support disk-based weight transfer for weight-update pairs, including save-to-disk on train workers and load/update on inference workers. Ensure inference pause/continue is wrapped in a context manager so generation resumes even when updates fail. Key changes: - add disk mode fields to connect request and pair metadata - implement disk transfer path with save/update_weights_from_disk and LoRA loading - add controller and gateway tests for disk mode behavior
Fail fast on disk-mode misconfiguration so weight updates do not silently write to local relative paths instead of shared storage. Key changes: - reject empty disk-mode save_path values - require absolute save_path values for disk mode - require lora_name when disk-mode LoRA is enabled - add gateway tests for rejected connect requests
* feat: add disk-mode weight update flow to gateway Support disk-based weight transfer for weight-update pairs, including save-to-disk on train workers and load/update on inference workers. Ensure inference pause/continue is wrapped in a context manager so generation resumes even when updates fail. Key changes: - add disk mode fields to connect request and pair metadata - implement disk transfer path with save/update_weights_from_disk and LoRA loading - add controller and gateway tests for disk mode behavior * fix: validate disk-mode gateway connect inputs Fail fast on disk-mode misconfiguration so weight updates do not silently write to local relative paths instead of shared storage. Key changes: - reject empty disk-mode save_path values - require absolute save_path values for disk mode - require lora_name when disk-mode LoRA is enabled - add gateway tests for rejected connect requests --------- Co-authored-by: Wentai Zhang <rchardx@gmail.com>
Description
Add disk-mode weight updates to the experimental weight-update gateway so training workers can save checkpoints to shared storage and inference workers can load from disk. The update flow now consistently pauses and resumes inference around transfer operations, including error paths, and extends controller/gateway contracts for mode-specific fields.
Related Issue
Fixes #(issue)
Type of Change
Checklist
pre-commit run --all-files)./docs/build_all.sh)main/review-prcommand/create-prBreaking Change Details (if applicable):
N/A
Additional Context
Risk areas:
Test commands run:
uv run pytest tests/experimental/weight_update/test_wu_controller.pyuv run pytest tests/experimental/weight_update/test_disk_integration.py -k "not multi_gpu and not slow and not sglang"Skipped suites:
test_disk_integration.py(environment-dependent E2E coverage).