Skip to content

Commit

Permalink
Update test_train_spmd_linear_model.py to show clear loss value (#8481)
Browse files Browse the repository at this point in the history
  • Loading branch information
ManfeiBai authored Dec 11, 2024
1 parent 7261c79 commit c05de86
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/spmd/test_train_spmd_linear_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ def __init__(self):
super(SimpleLinear, self).__init__()
self.fc1 = nn.Linear(FLAGS.input_dim, FLAGS.input_dim // 2)
self.relu = nn.ReLU()
self.fc2 = nn.Linear(FLAGS.input_dim // 2, 1)
# Add an additional 1x1 layer at the end to ensure the final layer
self.fc2 = nn.Linear(FLAGS.input_dim // 2, 3)
# Add an additional 3x3 layer at the end to ensure the final layer
# is not sharded.
self.fc3 = nn.Linear(1, 1)
self.fc3 = nn.Linear(3, 3)

def forward(self, x):
y = self.relu(self.fc1(x))
Expand Down Expand Up @@ -121,6 +121,7 @@ def train_loop_fn(loader, epoch):
optimizer.step()
xm.mark_step()
if step % 10 == 0:
assert loss != 0, "Loss should not 0 here"
print(f"Epoch {epoch} step {step} loss {loss}")

for epoch in range(FLAGS.num_epochs):
Expand Down

0 comments on commit c05de86

Please sign in to comment.