Publish item b shared-mode budget and wait-accounting delta for review
This commit is contained in:
1 parent
482c490afb
commit
5bfef6a61a
16 files changed
+16580
No files matched your search
@@ -0,0 +1,59 @@
|
||||
"""CPU-only checks for the b wrapper's wait and measured-cost delta."""
|
||||
|
||||
from unittest import TestCase, main
|
||||
|
||||
from phase3_item_b_shared_budget import full_fold_bound, project
|
||||
|
||||
|
||||
class SharedBudgetTests(TestCase):
|
||||
def setUp(self):
|
||||
self.contract = dict(
|
||||
jobs=[dict(shared_epoch_seconds_bound=100, validation_seconds_bound=10,
|
||||
full_training_gpu_seconds_bound=full_fold_bound(100, 10)) for _ in range(5)],
|
||||
gpu_cap=170000, preparation_charge_gpu_seconds=600, postfit_gpu_reserve=7200,
|
||||
runaway_gpu_seconds=60000,
|
||||
)
|
||||
|
||||
def test_wait_changes_total_but_not_training_projection(self):
|
||||
base = dict.fromkeys(range(5), 60)
|
||||
waits = dict.fromkeys(range(5), 0)
|
||||
measured = {0: [dict(epoch=1, train_epoch_seconds=103)]}
|
||||
baseline = project(self.contract, base | {0: 185}, waits, measured, {})
|
||||
result = project(self.contract, base | {0: 17185}, waits | {0: 17000}, measured, {})
|
||||
self.assertEqual(baseline['folds']['0']['projected_training_gpu_seconds'],
|
||||
result['folds']['0']['projected_training_gpu_seconds'])
|
||||
self.assertEqual(result['projected_gpu_seconds']-baseline['projected_gpu_seconds'], 17000)
|
||||
self.assertEqual(result['actual_waiting_gpu_seconds'], 17000)
|
||||
|
||||
def test_pending_wait_is_charged_once(self):
|
||||
cost = dict.fromkeys(range(5), 3060)
|
||||
wait = dict.fromkeys(range(5), 3000)
|
||||
result = project(self.contract, cost, wait, {}, {})
|
||||
bound = full_fold_bound(100, 10)
|
||||
self.assertEqual(result['folds']['2']['projected_training_gpu_seconds'], bound)
|
||||
self.assertEqual(result['projected_gpu_seconds'], 7800 + 5*(bound+3000))
|
||||
|
||||
def test_terminal_uses_actual_charge(self):
|
||||
result = project(self.contract, dict.fromkeys(range(5), 60) | {4: 5000},
|
||||
dict.fromkeys(range(5), 0) | {4: 2500}, {}, {4: {}})
|
||||
self.assertEqual(result['folds']['4']['projected_training_gpu_seconds'], 2500)
|
||||
self.assertEqual(result['folds']['4']['projected'], 5000)
|
||||
|
||||
def test_long_wait_does_not_hit_actual_training_runaway_limit(self):
|
||||
costs = dict.fromkeys(range(5), 60)
|
||||
waits = dict.fromkeys(range(5), 0)
|
||||
contract = dict(self.contract, gpu_cap=1000000)
|
||||
self.assertEqual(project(contract, costs | {0: 80000}, waits | {0: 79940}, {}, {})['status'], 'PASS')
|
||||
self.assertEqual(project(contract, costs | {0: 80000}, waits, {}, {})['status'], 'STOP_BUDGET')
|
||||
self.assertEqual(project(self.contract, costs | {0: 80000}, waits | {0: 79940}, {}, {})['status'], 'STOP_BUDGET')
|
||||
|
||||
def test_observed_b_epoch_can_raise_shared_bound(self):
|
||||
costs = dict.fromkeys(range(5), 60) | {0: 220}
|
||||
waits = dict.fromkeys(range(5), 0)
|
||||
faster = project(self.contract, costs, waits, {0: [dict(epoch=1, train_epoch_seconds=90)]}, {})
|
||||
slower = project(self.contract, costs, waits, {0: [dict(epoch=1, train_epoch_seconds=130)]}, {})
|
||||
self.assertEqual(slower['projected_gpu_seconds']-faster['projected_gpu_seconds'], 1.25*199*30)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in new issue
Block a user