feat: adding support for torch xpu device#9470
Merged
davidsbatista merged 11 commits intodeepset-ai:mainfrom Jun 17, 2025
Merged
feat: adding support for torch xpu device#9470davidsbatista merged 11 commits intodeepset-ai:mainfrom
davidsbatista merged 11 commits intodeepset-ai:mainfrom
Conversation
f64bddf to
52160c1
Compare
52160c1 to
7b8346b
Compare
Collaborator
Pull Request Test Coverage Report for Build 15703017100Details
💛 - Coveralls |
Contributor
|
Failing unit test fixed by this PR #9475 |
Contributor
Author
Contributor
|
@srini047 any chance you have to run this script on XPU hardware? from typing import Dict, Any
from haystack.components.embedders import SentenceTransformersTextEmbedder
from haystack.utils.device import ComponentDevice, Device
def test_device(device: ComponentDevice, device_name: str) -> Dict[str, Any]:
result = {
"device_name": device_name,
"device_str": str(device.to_torch_str() if hasattr(device, '_single_device') and device._single_device else device),
"success": False,
"error": None,
"embedding_shape": None
}
try:
embedder = SentenceTransformersTextEmbedder(
model="sentence-transformers/all-MiniLM-L6-v2",
device=device,
progress_bar=False
)
embedder.warm_up()
test_text = "Hello world"
embedding_result = embedder.run(text=test_text)
result["success"] = True
result["embedding_shape"] = len(embedding_result["embedding"]) if embedding_result["embedding"] else None
except Exception as e:
result["error"] = str(e)
return result
def main():
test_cases = [
# (ComponentDevice.from_single(Device.cpu()), "CPU"),
# (ComponentDevice.from_single(Device.gpu(0)), "GPU (CUDA:0)"),
# (ComponentDevice.from_single(Device.gpu(1)), "GPU (CUDA:1)"),
# (ComponentDevice.from_single(Device.mps()), "MPS (Apple Metal)"),
(ComponentDevice.from_single(Device.xpu()), "XPU (Intel)")
]
results = []
for device, device_name in test_cases:
print(f"\nTesting {device_name}...")
result = test_device(device, device_name)
results.append(result)
if result["success"]:
print(f"{device_name}: SUCCESS")
print(result)
else:
print(f"{device_name}: FAILED")
print(f"Error: {result['error']}")
print("\n\n")
successful = [r for r in results if r["success"]]
failed = [r for r in results if not r["success"]]
print(f"Successful devices")
for result in successful:
print(f"{result['device_name']}")
if failed:
print(f"\nFailed devices")
for result in failed:
print(f"{result['device_name']}: {result['error']}")
if __name__ == "__main__":
main() |
Contributor
Author
@davidsbatista I don't have a XPU hardware. I have only MPS. So that's why unable to test it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issues
Proposed Changes:
Add support for Intel
xpudeviceHow did you test it?
Notes for the reviewer
I don't have a Intel XPU device. So unable to test it 😔
Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.