microsoft / hummingbird

Hummingbird compiles trained ML models into tensor computation for faster inference.
MIT License
3.34k stars 278 forks source link

Build is failing - SKL 1.3 release #720

Closed ksaur closed 1 year ago

ksaur commented 1 year ago

https://github.com/microsoft/hummingbird/actions/runs/5490659732/jobs/10006370962

self = <test_sklearn_decomposition.TestSklearnCrossDecomposition testMethod=test_pca_converter_two>

    def test_pca_converter_two(self):
>       self._fit_model_pls_regressor(PLSR(n_components=2))

tests/test_sklearn_decomposition.py:166: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_sklearn_decomposition.py:162: in _fit_model_pls_regressor
    np.testing.assert_allclose(model.predict(X), torch_model.predict(X), rtol=1e-6, atol=2 * 1e-5)
hummingbird/ml/containers/_sklearn_api_containers.py:122: in predict
    return self._run(self._predict, *inputs)
hummingbird/ml/containers/_sklearn_api_containers.py:[70](https://github.com/microsoft/hummingbird/actions/runs/5490659732/jobs/10006370962#step:9:71): in _run
    return function(*inputs)
hummingbird/ml/containers/sklearn/pytorch_containers.py:207: in _predict
    output = self.model.forward(*inputs).cpu().numpy()
hummingbird/ml/_executor.py:115: in forward
    outputs = operator(*(variable_map[input_name] for input_name in operator.inputs))
/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/torch/nn/modules/module.py:1501: in _call_impl
    return forward_call(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = CrossDecomposition()
x = tensor([[-1.3056, -0.[74](https://github.com/microsoft/hummingbird/actions/runs/5490659732/jobs/10006370962#step:9:75)06, -0.4392],
        [-0.2611, -0.7406, -1.0247],
        [ 0.7833,  0.1058,  0.1464],
        [ 0.7833,  1.3[75](https://github.com/microsoft/hummingbird/actions/runs/5490659732/jobs/10006370962#step:9:76)4,  1.3175]])

    def forward(self, x):
        x -= self.x_mean
        x /= self.x_std
>       y_pred = torch.mm(x, self.coefficients).float()
E       RuntimeError: mat1 and mat2 shapes cannot be multiplied (4x3 and 2x3)

hummingbird/ml/operator_converters/_decomposition_implementations.py:100: RuntimeError
________ TestSklearnCrossDecomposition.test_pca_converter_two_no_scale _________

self = <test_sklearn_decomposition.TestSklearnCrossDecomposition testMethod=test_pca_converter_two_no_scale>

    def test_pca_converter_two_no_scale(self):
>       self._fit_model_pls_regressor(PLSR(n_components=3, scale=False))

tests/test_sklearn_decomposition.py:170: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_sklearn_decomposition.py:162: in _fit_model_pls_regressor
    np.testing.assert_allclose(model.predict(X), torch_model.predict(X), rtol=1e-6, atol=2 * 1e-5)
hummingbird/ml/containers/_sklearn_api_containers.py:122: in predict
    return self._run(self._predict, *inputs)
hummingbird/ml/containers/_sklearn_api_containers.py:70: in _run
    return function(*inputs)
hummingbird/ml/containers/sklearn/pytorch_containers.py:207: in _predict
    output = self.model.forward(*inputs).cpu().numpy()
hummingbird/ml/_executor.py:115: in forward
    outputs = operator(*(variable_map[input_name] for input_name in operator.inputs))
/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/torch/nn/modules/module.py:1501: in _call_impl
    return forward_call(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = CrossDecomposition()
x = tensor([[-1.2500, -1.7500, -0.7500],
        [-0.2500, -1.7500, -1.7500],
        [ 0.7500,  0.2500,  0.2500],
        [ 0.7500,  3.2500,  2.2500]])

    def forward(self, x):
        x -= self.x_mean
        x /= self.x_std
>       y_pred = torch.mm(x, self.coefficients).float()
E       RuntimeError: mat1 and mat2 shapes cannot be multiplied (4x3 and 2x3)
ksaur commented 1 year ago

Release notes on Decomp

Specifically: https://github.com/scikit-learn/scikit-learn/pull/26016 where The shape of coef_ is now (n_targets, n_features) instead of (n_features, n_targets) which explains RuntimeError: mat1 and mat2 shapes cannot be multiplied (4x3 and 2x3).