Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: Add Intel Gaudi HPU Support to Semantic Kernel #11064

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

BartoszBLL
Copy link

Summary

This PR introduces support for Intel Gaudi HPUs (Habana Processing Units) to Semantic Kernel, enabling optimized AI workloads on specialized hardware.

Changes

  • Makefile: Added install-gaudi target to handle installation on Gaudi HPU instances, excluding PyTorch.
  • README.md: Documented Gaudi HPU features, installation methods, and performance tuning guidelines.
  • pyproject.toml: Included optimum-habana dependency for Gaudi optimization.
  • Sample Setup: Added Gaudi-specific text completion and embedding services to the Semantic Kernel.
  • Connectors: Extended Hugging Face connectors to support Gaudi HPU inference.
  • Utilities & Pipeline: Introduced configuration utilities (config.py), a Gaudi-specific pipeline (pipeline.py), and helper functions (utils.py) to streamline integration and performance optimization.
  • Tests: Provided unit tests for Gaudi text completion services.

How to Test

  1. Clone the repository and switch to the feature branch.
  2. Execute installation via Makefile:
make install-gaudi
  1. Verify Gaudi functionality by running examples provided in the updated README.

Notes

  • Ensure Gaudi HPU instances have pre-installed PyTorch (version 2.4.0a0+git74cd574).
  • Optimal performance tuning parameters are documented for further adjustments.

Contribution Checklist

@BartoszBLL BartoszBLL requested a review from a team as a code owner March 19, 2025 11:36
@markwallace-microsoft markwallace-microsoft added python Pull requests for the Python Semantic Kernel documentation labels Mar 19, 2025
@github-actions github-actions bot changed the title Add Intel Gaudi HPU Support to Semantic Kernel Python: Add Intel Gaudi HPU Support to Semantic Kernel Mar 19, 2025
@BartoszBLL
Copy link
Author

@microsoft-github-policy-service agree

Copy link
Member

Choose a reason for hiding this comment

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

We're starting to move towards maintaining less files, so please put all this stuff into a single _gaudi.py file inside the hugging_face services folder.



@dataclass
class Config:
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better to split this into, a settings setup, similar to what we use for a bunch of stuff, like OpenAISettings, this would be for thing like model_names and auth tokens, those can be passed in or read from the ENV. And other stuff seems like execution settings, but I guess more of this is needed in the constructor, correct? We also use pydantic for a lot of things, and considering what happens in the init, I would use that, so you can just call model_validate with kwargs in the setup.

# Update config with model_kwargs if provided
if model_kwargs:
# Extract Gaudi-specific parameters from model_kwargs
for key, value in model_kwargs.items():
Copy link
Member

Choose a reason for hiding this comment

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

leveraging pydantic features here would make this much simpler.

from .config import Config

SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.dirname(SCRIPT_DIR))
Copy link
Member

Choose a reason for hiding this comment

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

what is this for?

cd semantic-kernel

# Run the Gaudi installation script
./install_for_gaudi.sh
Copy link
Member

Choose a reason for hiding this comment

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

this isn't in here...


## Files

- `config.py`: Contains the `Config` dataclass that defines all configuration options
Copy link
Member

Choose a reason for hiding this comment

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

this seems ai generated and we do not use .py files for config anywhere!


For optimal performance on Gaudi HPUs:

1. Use the `optimum-habana` package (automatically installed with the `gaudi` extras)
Copy link
Member

Choose a reason for hiding this comment

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

add the install command

**pipeline_kwargs or {},
)
resolved_device = f"cuda:{device}" if device >= 0 and torch.cuda.is_available() else "cpu"
if use_hpu:
Copy link
Member

Choose a reason for hiding this comment

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

considering the number of parameters, I think it would be better to allow people to pass in the pipeline, and then they can construct their own GaudiPipeline with the parameters of that, instead of this very hard to discover set of configs

Copy link
Member

Choose a reason for hiding this comment

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

that has been something I wanted to do anyway, since that also gives extra capabilities for just HF settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation python Pull requests for the Python Semantic Kernel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants