Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 8 additions & 18 deletions deepmd/pt/train/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,12 @@ def run(self) -> None:
prof.start()

def step(_step_id, task_key="Default") -> None:
if self.multi_task:
model_index = dp_random.choice(
np.arange(self.num_model, dtype=np.int_),
p=self.model_prob,
)
Comment thread
caic99 marked this conversation as resolved.
task_key = self.model_keys[model_index]
# PyTorch Profiler
if self.enable_profiler or self.profiling:
prof.step()
Expand Down Expand Up @@ -929,24 +935,8 @@ def log_loss_valid(_task_key="Default"):

self.t0 = time.time()
self.total_train_time = 0.0
for step_id in range(self.num_steps):
if step_id < self.start_step:
continue
if self.multi_task:
chosen_index_list = dp_random.choice(
np.arange(
self.num_model, dtype=np.int32
), # int32 should be enough for # models...
p=np.array(self.model_prob),
size=self.world_size,
replace=True,
)
assert chosen_index_list.size == self.world_size
model_index = chosen_index_list[self.rank]
model_key = self.model_keys[model_index]
else:
model_key = "Default"
step(step_id, model_key)
for step_id in range(self.start_step, self.num_steps):
step(step_id)
if JIT:
break

Expand Down
2 changes: 2 additions & 0 deletions deepmd/pt/utils/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
)

from deepmd.pt.utils import (
dp_random,
env,
)
from deepmd.pt.utils.dataset import (
Expand All @@ -50,6 +51,7 @@ def setup_seed(seed) -> None:
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
torch.backends.cudnn.deterministic = True
dp_random.seed(seed)
Comment thread
caic99 marked this conversation as resolved.


class DpLoaderSet(Dataset):
Expand Down