Open bsergean opened 1 year ago
(venv) sandbox$ python3 example.py
Parsing sentence tokens.
Downloading (…)okenizer_config.json: 100%|██████████████████████████████████████████████████████████████████████████████████████| 512/512 [00:00<00:00, 485kB/s]
Downloading (…)lve/main/config.json: 100%|██████████████████████████████████████████████████████████████████████████████████████| 710/710 [00:00<00:00, 737kB/s]
Downloading (…)solve/main/vocab.txt: 100%|████████████████████████████████████████████████████████████████████████████████████| 232k/232k [00:00<00:00, 838kB/s]
Downloading (…)/main/tokenizer.json: 100%|███████████████████████████████████████████████████████████████████████████████████| 466k/466k [00:00<00:00, 1.32MB/s]
Downloading (…)cial_tokens_map.json: 100%|█████████████████████████████████████████████████████████████████████████████████████| 112/112 [00:00<00:00, 96.8kB/s]
Instantiating model.
Downloading (…)"pytorch_model.bin";: 100%|██████████████████████████████████████████████████████████████████████████████████| 90.9M/90.9M [00:00<00:00, 131MB/s]
Compiling with Torch-MLIR
Compiling with IREE
Loading in IREE
Running on IREE
RESULT: tensor([[ 1.8574, -1.8036]])
I tried again today, on linux (ubuntu 18.04), with python-3.11 and it worked fine.
It felt like the 'downloading steps' (before the 'Compiling with Torch-MLIR' steps), never happens on macOS.
With the version that worked (on linux), the environment is:
(venv) sandbox$ pip freeze
certifi==2022.12.7
charset-normalizer==3.0.1
filelock==3.9.0
huggingface-hub==0.12.1
idna==3.4
iree-compiler==20230219.435
iree-runtime==20230219.435
iree-torch==0.0.1
mpmath==1.2.1
networkx==3.0
numpy==1.24.2
packaging==23.0
PyYAML==6.0
regex==2022.10.31
requests==2.28.2
sympy==1.11.1
tokenizers==0.13.2
torch==2.0.0.dev20230212+cpu
torch-mlir==20230219.754
tqdm==4.64.1
transformers==4.26.1
typing_extensions==4.5.0
urllib3==1.26.14
Note that on macOS this is running on an M1 processor (arm), while on linux I'm running on an Intel processor.
Likely due to that the model was compiled for x86_64 but we are expecting arm64 on M1 architecture. Need to use the proper --iree-llvm-target-cpu-features=
.
The doc for the function that looks applicable has no llvm-target cpu options (there's a cuda option though).
There's a TODO in the doc that hint at the sample place.
Help on function compile_to_vmfb in module iree_torch:
compile_to_vmfb(mlir_module, target_backend='llvm-cpu', cuda_llvm_target_arch: Optional[str] = None)
Compile an MLIR module to an IREE Flatbuffer.
The module is expected to be in the format produced by `torch_mlir.compile`
with `OutputType.LINALG_ON_TENSORS`.
TODO: Expose more compiler options.
Also everything works fine if I use vmvx for the iree_backend.
What happened?
I am trying to run the colab example but it fails.
Steps to reproduce your issue
Then I merged the 2 snippets of the colab notebook. (the class definition + the few invocations), calling it example.py.
What component(s) does this issue relate to?
Python
Version information
Python 3.10.9
And the modules are:
$ pip freeze certifi==2022.12.7 charset-normalizer==3.0.1 filelock==3.9.0 huggingface-hub==0.12.1 idna==3.4 iree-compiler==20230218.434 iree-runtime==20230218.434 iree-torch==0.0.1 mpmath==1.2.1 networkx==3.0 numpy==1.24.2 packaging==23.0 PyYAML==6.0 regex==2022.10.31 requests==2.28.2 sympy==1.11.1 tokenizers==0.13.2 torch==2.0.0.dev20230209 torch-mlir==20230210.745 tqdm==4.64.1 transformers==4.26.1 typing_extensions==4.5.0 urllib3==1.26.14
Additional context
No response