Auto Scheduler (Ansor) XGBoost cost model import error

Hi Community,

I am new to TVM and am trying to use Auto Scheduler (Ansor) with XGBoost Cost Model, but, am facing the below given error:

---------------------------------------------------------------------------
TVMError                                  Traceback (most recent call last)
/tmp/ipykernel_95843/4116945355.py in <module>
----> 1 run_tuning()

/tmp/ipykernel_95843/2215320932.py in run_tuning()
     22         tuner.tune(tune_option, search_policy=search_policy)
     23     else:
---> 24         tuner.tune(tune_option)

~/.conda/envs/autosegENV/lib/python3.7/site-packages/tvm/auto_scheduler/task_scheduler.py in tune(self, tune_option, search_policy, search_policy_params, adapative_training, per_task_early_stopping)
    355             # skip warming up this task if it has been tuned before (restored from the log file)
    356             if not self.task_cts[idx]:
--> 357                 self._tune_task(idx)
    358         self.best_ct = self.ct
    359         self.best_score = self.cur_score

~/.conda/envs/autosegENV/lib/python3.7/site-packages/tvm/auto_scheduler/task_scheduler.py in _tune_task(self, task_idx)
    451 
    452         measure_inputs, measure_results = self.search_policies[task_idx].continue_search_one_round(
--> 453             self.num_measures_per_round, self.measurer
    454         )
    455 

~/.conda/envs/autosegENV/lib/python3.7/site-packages/tvm/auto_scheduler/search_policy.py in continue_search_one_round(self, num_measure, measurer)
    117             The results of measurments in this search round
    118         """
--> 119         return _ffi_api.SearchPolicyContinueSearchOneRound(self, num_measure, measurer)
    120 
    121     def set_verbose(self, verbose):

tvm/_ffi/_cython/./packed_func.pxi in tvm._ffi._cy3.core.PackedFuncBase.__call__()

tvm/_ffi/_cython/./packed_func.pxi in tvm._ffi._cy3.core.FuncCall()

tvm/_ffi/_cython/./packed_func.pxi in tvm._ffi._cy3.core.FuncCall3()

tvm/_ffi/_cython/./base.pxi in tvm._ffi._cy3.core.CALL()

TVMError: Traceback (most recent call last):
  4: TVMFuncCall
  3: std::_Function_handler<void (tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*), tvm::runtime::TypedPackedFunc<tvm::runtime::Array<tvm::runtime::ObjectRef, void> (tvm::auto_scheduler::SearchPolicy, int, tvm::auto_scheduler::ProgramMeasurer)>::AssignTypedLambda<tvm::auto_scheduler::{lambda(tvm::auto_scheduler::SearchPolicy, int, tvm::auto_scheduler::ProgramMeasurer)#2}>(tvm::auto_scheduler::{lambda(tvm::auto_scheduler::SearchPolicy, int, tvm::auto_scheduler::ProgramMeasurer)#2}, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::{lambda(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*)#1}>::_M_invoke(std::_Any_data const&, tvm::runtime::TVMArgs&&, tvm::runtime::TVMRetValue*&&)
  2: tvm::auto_scheduler::SketchPolicyNode::ContinueSearchOneRound(int, tvm::auto_scheduler::ProgramMeasurer)
  1: tvm::auto_scheduler::PythonBasedModelNode::Update(tvm::runtime::Array<tvm::auto_scheduler::MeasureInput, void> const&, tvm::runtime::Array<tvm::auto_scheduler::MeasureResult, void> const&)
  0: std::_Function_handler<void (tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*), TVMFuncCreateFromCFunc::{lambda(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)#2}>::_M_invoke(std::_Any_data const&, tvm::runtime::TVMArgs&&, tvm::runtime::TVMRetValue*&&) [clone .cold]
  File "tvm/_ffi/_cython/./packed_func.pxi", line 56, in tvm._ffi._cy3.core.tvm_callback
  File "/home/ec2-user/.conda/envs/autosegENV/lib/python3.7/site-packages/tvm/auto_scheduler/cost_model/cost_model.py", line 93, in update_func
    self.update(inputs, results)
  File "/home/ec2-user/.conda/envs/autosegENV/lib/python3.7/site-packages/tvm/auto_scheduler/cost_model/xgb_model.py", line 210, in update
    verbose_eval=self.verbose_eval,
  File "/home/ec2-user/.conda/envs/autosegENV/lib/python3.7/site-packages/tvm/auto_scheduler/cost_model/xgb_model.py", line 554, in custom_callback
    from xgboost.core import EarlyStopException
ImportError: cannot import name 'EarlyStopException' from 'xgboost.core' (/home/ec2-user/.conda/envs/autosegENV/lib/python3.7/site-packages/xgboost/core.py)

I installed TVM python api using conda-build from source. As there are no xgboost versions specified for compatibilty, I installed the latest version - 1.6.0.

Is the issue with the xgboost version I have installed? or how I built the source package, I followed the exact steps for installing TVM in a conda enviroment specified in the installation guide.

Thanks!

1 Like

Can you try a previous version e.g., 1.5.0?

Hi @Lyken17 ,

I tried all the version specifed in the gen_requirements.py - from 1.1.0 (all 1.x.0). All worked except 1.6.0.

It seems from 1.6.0 onwards, EarlyStopException has been moved or removed.