mars
mars copied to clipboard
[BUG] ParallelPostFit raises AttributeError: 'GradientBoostingClassifier' object has no attribute '_loss'
Describe the bug A clear and concise description of what the bug is.
mars/learn/tests/test_wrappers.py:25 (test_parallel_post_fit_basic)
setup = <mars.deploy.oscar.session.SyncSession object at 0x288b48430>
def test_parallel_post_fit_basic(setup):
raw_x, raw_y = make_classification(n_samples=1000)
X, y = mt.tensor(raw_x, chunk_size=100), mt.tensor(raw_y, chunk_size=100)
clf = ParallelPostFit(GradientBoostingClassifier())
clf.fit(X, y)
> assert isinstance(clf.predict(X), mt.Tensor)
mars/learn/tests/test_wrappers.py:32:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
mars/learn/wrappers.py:285: in predict
result.execute()
mars/core/entity/tileables.py:462: in execute
result = self.data.execute(session=session, **kw)
mars/core/entity/executable.py:144: in execute
return execute(self, session=session, **kw)
mars/deploy/oscar/session.py:1871: in execute
return session.execute(
mars/deploy/oscar/session.py:1665: in execute
execution_info: ExecutionInfo = fut.result(
../../.pyenv/versions/3.8.13/lib/python3.8/concurrent/futures/_base.py:444: in result
return self.__get_result()
../../.pyenv/versions/3.8.13/lib/python3.8/concurrent/futures/_base.py:389: in __get_result
raise self._exception
mars/deploy/oscar/session.py:1851: in _execute
await execution_info
../../.pyenv/versions/3.8.13/lib/python3.8/asyncio/tasks.py:695: in _wrap_awaitable
return (yield from awaitable.__await__())
mars/deploy/oscar/session.py:106: in wait
return await self._aio_task
mars/deploy/oscar/session.py:954: in _run_in_background
raise task_result.error.with_traceback(task_result.traceback)
mars/services/task/supervisor/processor.py:372: in run
await self._process_stage_chunk_graph(*stage_args)
mars/services/task/supervisor/processor.py:250: in _process_stage_chunk_graph
chunk_to_result = await self._executor.execute_subtask_graph(
mars/services/task/execution/ray/executor.py:551: in execute_subtask_graph
meta_list = await asyncio.gather(*output_meta_object_refs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
awaitable = ObjectRef(ae46b8beecd25f3affffffffffffffffffffffff0100000001000000)
@types.coroutine
def _wrap_awaitable(awaitable):
"""Helper for asyncio.ensure_future().
Wraps awaitable (an object with __await__) into a coroutine
that will later be wrapped in a Task by ensure_future().
"""
> return (yield from awaitable.__await__())
E ray.exceptions.RayTaskError(AttributeError): ray::execute_subtask() (pid=19006, ip=127.0.0.1)
E File "/home/admin/mars/mars/services/task/execution/ray/executor.py", line 185, in execute_subtask
E execute(context, chunk.op)
E File "/home/admin/mars/mars/core/operand/core.py", line 491, in execute
E result = executor(results, op)
E File "/home/admin/mars/mars/core/custom_log.py", line 94, in wrap
E return func(cls, ctx, op)
E File "/home/admin/mars/mars/utils.py", line 1186, in wrapped
E return func(cls, ctx, op)
E File "/home/admin/mars/mars/tensor/base/map_chunk.py", line 170, in execute
E ctx[op.outputs[0].key] = op.func(in_data, *args, **kwargs)
E File "/home/admin/.pyenv/versions/3.8.13/lib/python3.8/site-packages/sklearn/ensemble/_gb.py", line 1449, in predict
E raw_predictions = self.decision_function(X)
E File "/home/admin/.pyenv/versions/3.8.13/lib/python3.8/site-packages/sklearn/ensemble/_gb.py", line 1405, in decision_function
E raw_predictions = self._raw_predict(X)
E File "/home/admin/.pyenv/versions/3.8.13/lib/python3.8/site-packages/sklearn/ensemble/_gb.py", line 817, in _raw_predict
E raw_predictions = self._raw_predict_init(X)
E File "/home/admin/.pyenv/versions/3.8.13/lib/python3.8/site-packages/sklearn/ensemble/_gb.py", line 810, in _raw_predict_init
E raw_predictions = self._loss.get_init_raw_predictions(X, self.init_).astype(
E AttributeError: 'GradientBoostingClassifier' object has no attribute '_loss'
../../.pyenv/versions/3.8.13/lib/python3.8/asyncio/tasks.py:695: RayTaskError(AttributeError)
The problem is that the estimator is returned from a remote function operand, copy_learned_attributes does not copy the _loss attribute. Mars CI passes tests is because it runs the estimator fit in threads, so the estimator is the same object in client and operand.
To Reproduce To help us reproducing this bug, please provide information below:
- Your Python version
- The version of Mars you use
- Versions of crucial packages, such as numpy, scipy and pandas
- Full stack of the error.
- Minimized code to reproduce the error.
Expected behavior A clear and concise description of what you expected to happen.
Additional context Add any other context about the problem here.