Skip to content

supports hpu backend in main branch#1

Draft
rsshaik1 wants to merge 5 commits intomainfrom
Gaudi_support
Draft

supports hpu backend in main branch#1
rsshaik1 wants to merge 5 commits intomainfrom
Gaudi_support

Conversation

@rsshaik1
Copy link
Copy Markdown
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
Copy Markdown

@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.

Comment thread bitsandbytes/backends/utils.py Outdated
CODE = {"nf4": _NF4_QUANT_TABLE, "fp4": _FP4_QUANT_TABLE}


def get_habana_frameworks_version():
Copy link
Copy Markdown

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".

Comment thread bitsandbytes/backends/utils.py Outdated

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

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.

Comment thread bitsandbytes/backends/utils.py Outdated
return version.parse(output.stdout.split("\n")[0].split()[-1])


HABANA_VERSION = get_habana_frameworks_version()
Copy link
Copy Markdown

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

Comment thread bitsandbytes/backends/hpu/ops.py Outdated
) -> 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}")
Copy link
Copy Markdown

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).

Comment thread bitsandbytes/__init__.py
if torch.xpu.is_available():
from .backends.xpu import ops as xpu_ops

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

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.

3 participants