Skip to content

Commit 44172ae

Browse files
committed
test(esm2): update perf_logger tests for split _attn_work_*_accum buffers
The single self._attn_work_accum was split into _attn_work_unpadded_accum and _attn_work_padded_accum to support the unpadded/padded MFU distinction, but two tests in esm2_native_te still referenced the old single name, failing in CI with AttributeError. Update the assertions to check both buffers. With no attention_mask and no cu_seq_lens on the test batch, both paths fall through to shape-synthesis and hold the same value, so each test now asserts both accumulators hold the expected amount. No changes needed in llama3 / opengenome2_llama / codonfm: their test files don't exercise _attn_work_accum lifecycle directly. Signed-off-by: Gagan Kaushik <gkaushik@nvidia.com>
1 parent b979eed commit 44172ae

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

bionemo-recipes/recipes/esm2_native_te/tests/test_perf_logger.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def test_num_tokens_accumulates_across_grad_acc(self, mock_wandb, mock_tqdm):
213213
assert perf_logger.running_loss.item() == pytest.approx(4.0)
214214

215215
def test_attn_work_accumulates_across_grad_acc(self, mock_wandb, mock_tqdm):
216-
"""_attn_work_accum sums Σ(Lᵢ²) over all micro-batches when log_mfu=True."""
216+
"""Both _attn_work_*_accum buffers sum Σ(Lᵢ²) over all micro-batches when log_mfu=True."""
217217
dist_config = DistributedConfig()
218218
args = _make_args(logging_frequency=1, log_mfu=True, max_seq_length=128)
219219
perf_logger = PerfLogger(dist_config, args, model_config_dict=_esm_cfg())
@@ -230,8 +230,11 @@ def test_attn_work_accumulates_across_grad_acc(self, mock_wandb, mock_tqdm):
230230
outputs.logits = torch.randn(2, 64, ESM2_VOCAB, device=device)
231231
perf_logger.log_micro_step(step=1, batch=batch, outputs=outputs)
232232

233-
# Accumulator should hold 3 * 2 * 64² = 24576
234-
assert perf_logger._attn_work_accum.item() == 3 * 2 * 64 * 64
233+
# With no attention_mask and no cu_seq_lens, both unpadded and padded paths fall
234+
# through to the shape-synthesis branch, so both accumulators hold 3 * 2 * 64² = 24576.
235+
expected = 3 * 2 * 64 * 64
236+
assert perf_logger._attn_work_unpadded_accum.item() == expected
237+
assert perf_logger._attn_work_padded_accum.item() == expected
235238

236239
def test_reset_on_log_boundary(self, mock_wandb, mock_tqdm):
237240
"""Calling log_step on a logging-boundary step drains all accumulators."""
@@ -248,5 +251,6 @@ def test_reset_on_log_boundary(self, mock_wandb, mock_tqdm):
248251
assert perf_logger.grad_acc_step_count == 0
249252
assert perf_logger.num_tokens == 0
250253
assert perf_logger.num_unpadded_tokens.item() == 0
251-
assert perf_logger._attn_work_accum.item() == 0
254+
assert perf_logger._attn_work_unpadded_accum.item() == 0
255+
assert perf_logger._attn_work_padded_accum.item() == 0
252256
assert perf_logger.running_loss.item() == pytest.approx(0.0)

0 commit comments

Comments
 (0)