MCPcopy Create free account
hub / github.com/Pints-AI/1.5-Pints / measure_flops

Function measure_flops

lit_gpt/speed_monitor.py:459–467  ·  view source on GitHub ↗

Measures real FLOPs for HFU

(model: GPT, x: torch.Tensor)

Source from the content-addressed store, hash-verified

457
458
459def measure_flops(model: GPT, x: torch.Tensor) -> int:
460 """Measures real FLOPs for HFU"""
461 flop_counter = FlopCounterMode(model, display=False)
462 ctx = nullcontext() if model.training else torch.no_grad()
463 with ctx, flop_counter:
464 y = model(x)
465 if model.training:
466 y.sum().backward()
467 return flop_counter.get_total_flops()

Callers

nothing calls this directly

Calls 1

backwardMethod · 0.45

Tested by

no test coverage detected