refactor(paralell): 优化并行设备指定方法

This commit is contained in:
2025-12-26 20:54:33 +08:00
parent cfa3cf7daa
commit fd7ee2895a
6 changed files with 65 additions and 130 deletions
+2 -2
View File
@@ -88,13 +88,13 @@ class TrainContextBuilder:
)
return self
def with_parallel_fn(self) -> Self:
def with_parallel(self) -> Self:
device = get_current_device()
self._context.model = self._context.model.to(device=device)
if self.config.nprocs > 1:
fn = self.config.parallel_fn
fn = self.config.parallel_wrapper
optimizer_fn = self.config.optimizer_factory
scheduler_fn = self.config.scheduler_factory
+1 -1
View File
@@ -38,7 +38,7 @@ class Trainer:
.with_checkpoint(checkpoint)
.with_dataloader()
.with_strategy()
.with_parallel_fn()
.with_parallel()
.build())
def _call_callbacks(self, method_name: str, context: TrainContext):