Skip to content

Conversation

@rsshaik1
Copy link
Owner

@rsshaik1 rsshaik1 commented May 28, 2025

This PR enables the support of bitsandbytes for HPU (Intel Gaudi) devices.

  • Adds HPU as the supported device.
  • Creates a backend for HPU devices (bitsandbytes/backends/hpu).
    These changes add support for single and double NF4 quantization/dequantization using Intel Gaudi hardware.

Copy link

@vivekgoe vivekgoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Requested few minor changes, please take care of those and then raise PR on upstream. Please also add a short description when raising upstream PR.

CODE = {"nf4": _NF4_QUANT_TABLE, "fp4": _FP4_QUANT_TABLE}


def get_habana_frameworks_version():

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better to change this to "get_gaudi_sw_version".


def get_habana_frameworks_version():
"""
Returns the installed version of SynapseAI.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returns the installed version of Gaudi SW.

return version.parse(output.stdout.split("\n")[0].split()[-1])


HABANA_VERSION = get_habana_frameworks_version()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace HABANA_VERSION by GAUDI_SW_VER

) -> torch.Tensor:
torch._check_is_size(blocksize)
torch._check(quant_type == "nf4", lambda: f"quant_type must be nf4 or fp4, got {quant_type}")
torch._check(dtype == torch.bfloat16, lambda: f"4bit dequantization only supports bf16, but got {dtype}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We support torch.float32 also, better to include that also in this check).

if torch.xpu.is_available():
from .backends.xpu import ops as xpu_ops

if hasattr(torch, "hpu") and torch.hpu.is_available():

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Line-29 above, can we make it "Intel Gaudi".

@rsshaik1 rsshaik1 force-pushed the Gaudi_support branch 2 times, most recently from 9fb71c1 to 068f0e1 Compare June 3, 2025 09:11
rsshaik1 and others added 4 commits June 5, 2025 10:27
updates the assertion message

Co-authored-by: Matthew Douglas <38992547+matthewdouglas@users.noreply.github.com>
Co-authored-by: Matthew Douglas <38992547+matthewdouglas@users.noreply.github.com>
Fix lint issue
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

Successfully merging this pull request may close these issues.

4 participants