TorchedUp
LearnBetaProblemsSystem DesignSoonPremium
TorchedUp
LearnBetaProblemsSystem DesignSoonPremium
←

190. Recompute vs Store Decision

Medium

Given an activation of size activation_bytes, decide whether to store it (and pay the HBM round-trip later) or recompute it from upstream (and pay extra FLOPs). Compare the two times and pick the cheaper option.

Signature: def recompute_vs_store(activation_bytes: int, recompute_flops: int, peak_flops: float, peak_bw: float) -> str

  • Fetch time = activation_bytes / peak_bw
  • Recompute time = recompute_flops / peak_flops

Return 'recompute' if recompute time ≤ fetch time, otherwise 'store'.

Math

recompute iff πF​≤βB​

Asked at

NumPy

import numpy as np

 

def recompute_vs_store(...):

    pass

🔒

Premium problem

Free accounts include problems #1–20. Upgrade to unlock the editor, hidden test cases, and reference solutions for every problem.

Upgrade to PremiumBack to problems

Already premium?