Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[compile_fixture] Scale must be a constant tensor in quantize / dequantize op. #102

Open
markkraay opened this issue Aug 14, 2024 · 2 comments

Comments

@markkraay
Copy link
Collaborator

markkraay commented Aug 14, 2024

Related to compile_fixture (#37). test_dequantize and test_quantize fail compiler.compile with the following:
Example Code:

        data = [4, 8]
        input_tp = tp.Tensor(data, dtype=tp.int8)
        scale = torch.tensor(0.5, dtype=TORCH_DTYPES[dtype])
        scale_tp = tp.Tensor(scale, dtype=dtype)
        dequantized = compile_fixture(tp.dequantize, input_tp, scale_tp, dtype)

Error Msg:

E       tripy.common.exception.TripyException: 
E       
E       --> /tripy/tests/integration/conftest.py:36 in wrapper()
E             |
E          36 |             compiled_func = compiler.compile(*compile_args, **compile_kwargs)
E             | 
E       
E       Scale must be a constant tensor in dequantize op.

tripy/common/exception.py:195: TripyException
@yizhuoz004
Copy link
Collaborator

@markkraay Please provide more information to debug this issue.

  • Your PR is not merged, can it be reproduced by existing code?
  • What is dtype here?
  • Scale must be a constant tensor in dequantize op. Then what is the op instead?

@yizhuoz004
Copy link
Collaborator

The root cause is in tripy/tripy/backend/compiler_api.py:L515, compiler uses full to create dummy input values for intial compilation. The fixes could be:

  1. implement const fold optimization for Fill op when shape is constant.
  2. The compile_fixture should add an argument to specify which tensors are inputs, while others are Parameters.

@markkraay markkraay changed the title Scale must be a constant tensor in quantize / dequantize op. [compile_fixture] Scale must be a constant tensor in quantize / dequantize op. Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants