| 42 | namespace lbann { |
| 43 | |
| 44 | void LTFB::apply(ExecutionContext& context, |
| 45 | model& m, |
| 46 | data_coordinator& dc, |
| 47 | execution_mode /*mode*/) |
| 48 | { |
| 49 | LBANN_CALIPER_MARK_FUNCTION; |
| 50 | TimerMap ltfb_timer(build_string("LTFB::", |
| 51 | this->get_name(), |
| 52 | " (trainer:", |
| 53 | get_trainer().get_comm()->get_trainer_rank(), |
| 54 | ")")); |
| 55 | |
| 56 | auto const& ltfb_term = m_termination_criteria; |
| 57 | auto& ltfb_ctxt = dynamic_cast<ExeContextType&>(context); |
| 58 | |
| 59 | // Sync trainers (Assumption: all trainers in this lbann_comm are |
| 60 | // participating in this training algorithm) |
| 61 | m.get_comm()->intertrainer_barrier(); |
| 62 | |
| 63 | // LTFB likely has different stopping criteria than SGD (e.g., K |
| 64 | // tournament rounds; some specified relative or absolute |
| 65 | // reduction in objective function value; etc.), or its stopping |
| 66 | // criteria might be defined in terms of the SGD stopping criteria |
| 67 | // (e.g., N total sgd batches). That complexity lives in the |
| 68 | // ltfb::TerminationCriteria class. |
| 69 | while (!ltfb_term(ltfb_ctxt)) { |
| 70 | { |
| 71 | ScopeTimer _(ltfb_timer, "local apply"); |
| 72 | m_local_algo->apply(m, dc); |
| 73 | } |
| 74 | { |
| 75 | ScopeTimer _(ltfb_timer, "metalearning strategy"); |
| 76 | if (m.get_comm()->get_grid_type() == GridType::NO_GRID or |
| 77 | m.get_comm()->get_grid_type() == GridType::PRIMARY_GRID or |
| 78 | m.get_comm()->get_KFAC_subgrid_create_two_models()) { |
| 79 | m_meta_learning_strategy->select_next(m, ltfb_ctxt, dc); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | ltfb_ctxt.inc_step(); |
| 84 | } |
| 85 | |
| 86 | // Final sweep of local training. The timer is looped into the inner |
| 87 | // loop "local apply" timer. |
| 88 | { |
| 89 | ScopeTimer _(ltfb_timer, "local apply"); |
| 90 | m_local_algo->apply(m, dc); |
| 91 | } |
| 92 | |
| 93 | if (!m_suppress_timer && m.get_comm()->am_trainer_master()) |
| 94 | ltfb_timer.print(std::cout); |
| 95 | |
| 96 | // TODO: How do we support aggregate outputs? What does "output" |
| 97 | // mean here? Do we communicate among all trainers and just write |
| 98 | // some interesting subset to disk? Top-k best models, e.g. |
| 99 | // |
| 100 | // maybe: |
| 101 | // |
nothing calls this directly
no test coverage detected