Skip to content
Merged
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
12 changes: 2 additions & 10 deletions tutorials/examples/train_hypergrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ def _model_builder() -> Tuple[GFlowNet, torch.optim.Optimizer]:
gflownet = gflownet.to(device)

n_iterations = ceil(args.n_trajectories / args.batch_size)
per_node_batch_size = args.batch_size // distributed_context.world_size
per_node_batch_size = args.batch_size // distributed_context.num_training_ranks
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

modes_found = set()
# n_pixels_per_mode = round(env.height / 10) ** env.ndim
# Note: on/off-policy depends on the current strategy; recomputed inside the loop.
Expand All @@ -828,14 +828,6 @@ def _model_builder() -> Tuple[GFlowNet, torch.optim.Optimizer]:
)
prof.start()

if args.distributed:
# Create and start error handler.
def cleanup():
logger.info("Process %d: Cleaning up...", rank)

rank = torch.distributed.get_rank()
torch.distributed.get_world_size()

# Initialize some variables before the training loop.
timing = {}
time_start = time.time()
Expand Down Expand Up @@ -897,7 +889,7 @@ def cleanup():
)
trajectories = gflownet.sample_trajectories(
env,
n=args.batch_size,
n=per_node_batch_size,
save_logprobs=is_on_policy_iter, # Reuse on-policy log-probs.
save_estimator_outputs=not is_on_policy_iter, # Off-policy caches estimator outputs.
epsilon=float(getattr(args, "agent_epsilon", 0.0)),
Expand Down
Loading