[PR #484] Add Intel® Gaudi® HPU Support #514

Open
opened 2026-10-31 21:15:39 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/openai/CLIP/pull/484
Author: @BartoszBLL
Created: 2/24/2025
Status: 🔄 Open

Base: main ← Head: main


📝 Commits (10+)

  • 5393fdd Add Intel Gaudi HPU device usage
  • deb2964 Add test - test_hpu_support
  • e8d6206 Add Dockerfile.hpu, requirements_hpu.txt and update README.md with HPU support information
  • d17b831 Fix JIT error
  • 859a140 fix: Remove incorrect code snippet from README-HPU section.
  • fc198e5 Add time execution on HPU vs CPU benchmark
  • af0f80c Add CLIP installation instruction to Dockerfile
  • 6d3570d Add info on how to run tests to README.md
  • 07c9771 Move image IO ops out of time measurements
  • 66f8c28 Merge pull request #1 from BlueLabelLabs/feat/Add-hpu-support

📊 Changes

6 files changed (+173 additions, -17 deletions)

View changed files

➕ Dockerfile.hpu (+26 -0)
📝 README.md (+38 -3)
📝 clip/clip.py (+55 -13)
➕ clip/utils.py (+30 -0)
➕ requirements_hpu.txt (+3 -0)
📝 tests/test_consistency.py (+21 -1)

📄 Description

This PR introduces support for Intel® Gaudi® HPUs, including necessary changes for seamless execution on HPU devices.

Key Changes

  • HPU Integration
    • get_device_initial() utility to select the best available device (HPU, CUDA, or CPU).
    • HPU-specific handling in clip.py (wrapping models with Habana optimizations).
  • Docker Support
    • New Dockerfile.hpu for building an environment supporting Intel® Gaudi® HPUs.
    • requirements_hpu.txt for HPU-specific dependencies.
  • Documentation Updates
    • README.md now includes HPU setup instructions (Docker build, run, and usage).
    • Steps to run benchmarks on HPUs.
  • Extended Testing
    • New tests in tests/test_consistency.py for HPU vs. CPU consistency checks.
    • Additional test cases for HPU support.

Benchmark Results

Average across 10 runs

Device Average Execution Time (s)
HPU 0.4225
CPU 199.0485

How to Test

# Build Docker image for HPU
docker build -t clip_hpu:latest -f Dockerfile.hpu .

# Run the container
docker run -it --runtime=habana clip_hpu:latest

# Inside the container, run tests
pytest

Notes


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/openai/CLIP/pull/484 **Author:** [@BartoszBLL](https://github.com/BartoszBLL) **Created:** 2/24/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (10+) - [`5393fdd`](https://github.com/openai/CLIP/commit/5393fdde9cc7d9db06bb2741c4d948aa321907ea) Add Intel Gaudi HPU device usage - [`deb2964`](https://github.com/openai/CLIP/commit/deb2964c2639c02644e724781ef231e4541780ec) Add test - `test_hpu_support` - [`e8d6206`](https://github.com/openai/CLIP/commit/e8d6206c164bf1f064cd3d36e06426aba9d845bd) Add Dockerfile.hpu, requirements_hpu.txt and update README.md with HPU support information - [`d17b831`](https://github.com/openai/CLIP/commit/d17b83174d11214edef78ef5bba5b0350394123c) Fix JIT error - [`859a140`](https://github.com/openai/CLIP/commit/859a140c046fd6b6858317398688cdfd65cb9779) fix: Remove incorrect code snippet from README-HPU section. - [`fc198e5`](https://github.com/openai/CLIP/commit/fc198e5172fb72d2e045348cdd674521606bdbc5) Add time execution on HPU vs CPU benchmark - [`af0f80c`](https://github.com/openai/CLIP/commit/af0f80c1e647b2ece79ea8cf99b2b3a3343ff410) Add CLIP installation instruction to Dockerfile - [`6d3570d`](https://github.com/openai/CLIP/commit/6d3570d0e2d9aa6af3d88a2f0640daed6fe6b433) Add info on how to run tests to README.md - [`07c9771`](https://github.com/openai/CLIP/commit/07c9771a30d70171a29357d9e959115f92b1749e) Move image IO ops out of time measurements - [`66f8c28`](https://github.com/openai/CLIP/commit/66f8c28c842e434fe166d8726211f93a199dfddc) Merge pull request #1 from BlueLabelLabs/feat/Add-hpu-support ### 📊 Changes **6 files changed** (+173 additions, -17 deletions) <details> <summary>View changed files</summary> ➕ `Dockerfile.hpu` (+26 -0) 📝 `README.md` (+38 -3) 📝 `clip/clip.py` (+55 -13) ➕ `clip/utils.py` (+30 -0) ➕ `requirements_hpu.txt` (+3 -0) 📝 `tests/test_consistency.py` (+21 -1) </details> ### 📄 Description This PR introduces support for Intel® Gaudi® HPUs, including necessary changes for seamless execution on HPU devices. ## Key Changes - HPU Integration - get_device_initial() utility to select the best available device (HPU, CUDA, or CPU). - HPU-specific handling in clip.py (wrapping models with Habana optimizations). - Docker Support - New Dockerfile.hpu for building an environment supporting Intel® Gaudi® HPUs. - requirements_hpu.txt for HPU-specific dependencies. - Documentation Updates - README.md now includes HPU setup instructions (Docker build, run, and usage). - Steps to run benchmarks on HPUs. - Extended Testing - New tests in tests/test_consistency.py for HPU vs. CPU consistency checks. - Additional test cases for HPU support. ## Benchmark Results Average across 10 runs Device | Average Execution Time (s) -- | -- HPU | 0.4225 CPU | 199.0485 ## How to Test ```bash # Build Docker image for HPU docker build -t clip_hpu:latest -f Dockerfile.hpu . # Run the container docker run -it --runtime=habana clip_hpu:latest # Inside the container, run tests pytest ``` ## Notes - Ensure [Intel® Gaudi® HPU drivers and runtime](https://docs.habana.ai/en/latest/Installation_Guide/index.html) are installed. - Tested with PyTorch 2.4.0 and optimum-habana==1.14.1. - Dramatic performance gains observed on HPU compared to CPU. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openai/CLIP#514
No description provided.