Skip to content

Commit b7ef6c8

Browse files
committed
test: Fix tests
1 parent 615c2c7 commit b7ef6c8

3 files changed

Lines changed: 4 additions & 6 deletions

File tree

‎src/modalities/trainer.py‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,7 @@ def _train_batch(
161161
"""
162162
if scheduled_pipeline is not None:
163163
if isinstance(loss_fun, ChunkedLMHeadCrossEntropyLoss):
164-
raise NotImplementedError(
165-
"ChunkedLMHeadCrossEntropyLoss is not supported with pipeline parallelism."
166-
)
164+
raise NotImplementedError("ChunkedLMHeadCrossEntropyLoss is not supported with pipeline parallelism.")
167165
pp_schedule = scheduled_pipeline.pp_schedule
168166
# Pipeline Parallel forward / backward inside step() call
169167
# with self.train_context(optional_context_parallel_ctx):
@@ -250,10 +248,10 @@ def train(
250248
m.train()
251249

252250
local_num_seen_samples = 0
253-
cumulated_losses = torch.zeros(3).cuda()
254251

255252
# throughput
256253
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
254+
cumulated_losses = torch.zeros(3, device=device)
257255

258256
# batch loop
259257
batch: DatasetBatch

‎tests/conftest.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def gradient_clipper_mock() -> GradientClipperIF:
197197

198198
@pytest.fixture(scope="function")
199199
def loss_mock() -> Loss:
200-
return MagicMock(spec=Loss, return_value=torch.rand(1, requires_grad=True))
200+
return MagicMock(spec=Loss, return_value=torch.rand((), requires_grad=True))
201201

202202

203203
@pytest.fixture(scope="function")

‎tests/test_weight_tying.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def _make_norm_config() -> LayerNormWrapperConfig:
9797

9898
def create_device_mesh_stub(*mesh_dim_names: str) -> DeviceMesh:
9999
device_mesh = DeviceMesh.__new__(DeviceMesh)
100-
device_mesh.mesh_dim_names = mesh_dim_names
100+
device_mesh._mesh_dim_names = mesh_dim_names
101101
return device_mesh
102102

103103

0 commit comments

Comments
 (0)