Skip to content

Update Quark to use latest Onnx version. #6

@Zacchae

Description

@Zacchae

Following istallation instructions at: https://quark.docs.amd.com/latest/install.html I ensured I had build-essentials installed

apt list --installed | grep build-essentials
# prints "build-essential/jammy,now 12.9ubuntu3 amd64 [installed,automatic]"

and ran (I'm on Ubuntu 22.04)

python -m venv codes/quark
codes/quark/bin/pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
codes/quark/bin/pip install "cmake<4.0" amd-quark

Then, following instructions at https://quark.docs.amd.com/latest/supported_accelerators/ryzenai/tutorial_convert_fp32_or_fp16_to_bf16.html I ran:

codes/quark/bin/python -m quark.onnx.tools.convert_fp32_to_bf16 --input $FLOAT32_ONNX_MODEL_PATH --output $BFLOAT16_ONNX_MODEL_PATH --format with_cast

Which fails. Actually, it fails on import, so even the following fails:

codes/quark/bin/python -m quark.onnx.tools.convert_fp32_to_bf16
codes/quark/bin/python -c "import quark.onnx.tools.convert_fp32_to_bf16"

The traceback is:

Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 187, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.10/runpy.py", line 110, in _get_module_details
    __import__(pkg_name)
  File "/mnt/bpd_architecture/zacchae/codes/quark/lib/python3.10/site-packages/quark/onnx/__init__.py", line 8, in <module>
    from .calibrate import (create_calibrator_power_of_two, create_calibrator_float_scale)
  File "/mnt/bpd_architecture/zacchae/codes/quark/lib/python3.10/site-packages/quark/onnx/calibrate.py", line 27, in <module>
    from .quant_utils import (PowerOfTwoMethod, get_tensor_type_from_qType, quantize_data_pof2s, ExtendedQuantType)
  File "/mnt/bpd_architecture/zacchae/codes/quark/lib/python3.10/site-packages/quark/onnx/quant_utils.py", line 321, in <module>
    ONNX_INT_TYPE_RANGE = create_range_dict(dtype_ranges)
  File "/mnt/bpd_architecture/zacchae/codes/quark/lib/python3.10/site-packages/quark/onnx/quant_utils.py", line 286, in create_range_dict
    np_dtype = getattr(custom_element_types, dtype.lower())
NameError: name 'custom_element_types' is not defined

I have verified that I am on the latest quark version, i.e. the version that the linked docs (currently) point to

python -c "import quark; print(quark.__version__)"
# prints "0.9"

How can we proceed converting to bfloat16?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions