Clika / clika_compression_examples

CLIKA Compression Examples to use with the SDK!
Apache License 2.0
4 stars 0 forks source link

ValueError: Unsupported data structure #3

Closed yoohyewony closed 1 month ago

yoohyewony commented 2 months ago

Is NestedTensor not supported in clika? I applied clika as below but I got unsupported data structure error in below code. The input data type is NestedTensor({tensors, mask}). FYI, x[0], x.tensors, and x did not work.

clika_model: ClikaModule = torch.compile(
        model,
        backend="clika",
        options={
            "settings": "clika_config.yaml", #args.clika_config,
            "train_dataloader": data_loader_train,
            "discard_input_model": True,
            "logs_dir": os.path.join(os.getcwd(), "logs"),
            "apply_on_data_fn": lambda x: x,
        }
    )

Error Traceback (most recent call last): File "/home/hyewon/DINO/main_clika.py", line 424, in <module> main(args) File "/home/hyewon/DINO/main_clika.py", line 196, in main clika_model: ClikaModule = torch.compile( File "/usr/local/lib/python3.10/dist-packages/clika_ace/functional/torch_dynamo_register_backend.py", line 127, in _clika_custom_compile_override example_inputs, _ = clika_data_loader_get_data(next(iter(train_dataloader)), apply_on_data_fn, _device) File "/usr/local/lib/python3.10/dist-packages/clika_ace/functional/functional_utils.py", line 52, in clika_data_loader_get_data element = clika_move_to_device(element=element, device=device) File "/usr/local/lib/python3.10/dist-packages/clika_ace/functional/functional_utils.py", line 47, in clika_move_to_device element = clika_generic_apply_on_data(data=element, apply_fn=apply_fn) File "/usr/local/lib/python3.10/dist-packages/clika_ace/functional/functional_utils.py", line 33, in clika_generic_apply_on_data applied[i] = clika_generic_apply_on_data(data=data[i], apply_fn=apply_fn) File "/usr/local/lib/python3.10/dist-packages/clika_ace/functional/functional_utils.py", line 41, in clika_generic_apply_on_data raise ValueError("Unsupported data structure") ValueError: Unsupported data structure

BenAsaf commented 1 month ago

Hello!

There isn't any real restriction to using a Nested Tensor. We'll make sure it's supported next release (this end of month / beginning of next month). If however you already wanted to work I'd suggest not using Nested Tensor for now, just using separate tensor for the inputs and the masks.

Best regards, Ben