Skip to content

Commit 3818126

Browse files
authored
Merge branch 'main' into qwen3-moe-ep-v2
2 parents a29cc42 + 67fb8bb commit 3818126

3 files changed

Lines changed: 25 additions & 24 deletions

File tree

docker/transformers-pytorch-amd-gpu/Dockerfile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,25 @@ LABEL maintainer="Hugging Face"
44
ARG DEBIAN_FRONTEND=noninteractive
55

66
RUN apt update && \
7-
apt install -y --no-install-recommends git libsndfile1-dev tesseract-ocr espeak-ng python3 python3-dev python3-pip python3-dev ffmpeg git-lfs && \
7+
apt install -y --no-install-recommends git libsndfile1-dev tesseract-ocr espeak-ng python3 python3-dev python3-pip python3-dev ffmpeg git-lfs libjpeg-turbo8-dev libpng-dev zlib1g-dev && \
88
apt clean && \
99
rm -rf /var/lib/apt/lists/*
1010

1111
RUN git lfs install
1212

1313
RUN python3 -m pip install --no-cache-dir --upgrade pip numpy importlib-metadata setuptools wheel ninja pytesseract "itsdangerous<2.1.0"
14+
15+
# Rebuild torchvision so decode_image has libjpeg and ROCm image ops stay on GPU.
16+
RUN python3 -m pip install --no-cache-dir "setuptools<81" pybind11
17+
RUN TV_VERSION=$(python3 -c "import torchvision; print(torchvision.__version__.split('+')[0])") && \
18+
python3 -m pip uninstall -y torchvision && \
19+
git clone --depth 1 --branch "v${TV_VERSION}" https://github.com/pytorch/vision.git /tmp/vision && \
20+
cd /tmp/vision && \
21+
sed -i -E 's|list\(CSRS_DIR\.glob\("([^"]+\.cpp)"\)\)|[p for p in CSRS_DIR.glob("\1") if not p.name.endswith("_hip.cpp")]|g' setup.py && \
22+
FORCE_CUDA=1 TORCHVISION_USE_FFMPEG=0 TORCHVISION_USE_VIDEO_CODEC=0 \
23+
python3 -m pip install --no-cache-dir --no-build-isolation -v . && \
24+
cd / && rm -rf /tmp/vision
25+
1426
RUN python3 -m pip install --no-cache-dir --no-build-isolation git+https://github.com/facebookresearch/detectron2.git
1527

1628
ARG REF=main

tests/models/modernbert/test_modeling_modernbert.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,10 @@ def test_inference_masked_lm_flash_attention_2(self):
428428
[[[3.8203, -0.2125, 12.2812], [3.6055, 0.6797, 14.6875], [-5.1094, -3.8105, 11.9922]]],
429429
dtype=torch.float16,
430430
),
431+
("rocm", None): torch.tensor(
432+
[[[3.8223, -0.2045, 12.2891], [3.6328, 0.6875, 14.7031], [-5.1133, -3.8105, 11.9922]]],
433+
dtype=torch.float16,
434+
),
431435
("xpu", None): torch.tensor(
432436
[[[3.8555, -0.1993, 12.2969], [3.6387, 0.6943, 14.7109], [-5.1172, -3.8086, 11.9844]]],
433437
dtype=torch.float16,

tests/models/qwen2_5_vl/test_modeling_qwen2_5_vl.py

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -545,18 +545,10 @@ def test_small_model_integration_test_batch(self):
545545
# it should not matter whether two images are the same size or not
546546
output = model.generate(**inputs, max_new_tokens=30, do_sample=False)
547547

548-
expected_decoded_texts = Expectations(
549-
{
550-
(None, None): [
551-
'system\nYou are a helpful assistant.\nuser\nWhat kind of dog is this?\nassistant\nThe dog in the picture appears to be a Labrador Retriever. Labradors are known for their friendly and energetic nature, which is evident in',
552-
'system\nYou are a helpful assistant.\nuser\nWhat kind of dog is this?\nassistant\nThe dog in the picture appears to be a Labrador Retriever. Labradors are known for their friendly and energetic nature, which is evident in',
553-
],
554-
("rocm", (9, 4)): [
555-
'system\nYou are a helpful assistant.\nuser\nWhat kind of dog is this?\nassistant\nThe dog in the picture appears to be a Labrador Retriever. Labradors are known for their friendly and gentle nature, which is often reflected',
556-
'system\nYou are a helpful assistant.\nuser\nWhat kind of dog is this?\nassistant\nThe dog in the picture appears to be a Labrador Retriever. Labradors are known for their friendly and gentle nature, which is often reflected'
557-
],
558-
}
559-
).get_expectation() # fmt: skip
548+
expected_decoded_texts = [
549+
"system\nYou are a helpful assistant.\nuser\nWhat kind of dog is this?\nassistant\nThe dog in the picture appears to be a Labrador Retriever. Labradors are known for their friendly and energetic nature, which is evident in",
550+
"system\nYou are a helpful assistant.\nuser\nWhat kind of dog is this?\nassistant\nThe dog in the picture appears to be a Labrador Retriever. Labradors are known for their friendly and energetic nature, which is evident in",
551+
]
560552

561553
self.assertEqual(
562554
self.processor.batch_decode(output, skip_special_tokens=True),
@@ -609,7 +601,7 @@ def test_small_model_integration_test_batch_wo_image(self):
609601
'system\nYou are a helpful assistant.\nuser\nWho are you?\nassistant\nI am Qwen, an AI language model created by Alibaba Cloud. I am designed to assist with various tasks such as answering questions, providing information,'
610602
],
611603
("rocm", (9, 4)): [
612-
'system\nYou are a helpful assistant.\nuser\nWhat kind of dog is this?\nassistant\nThe dog in the picture appears to be a Labrador Retriever. Labradors are known for their friendly and gentle nature, which is evident in',
604+
'system\nYou are a helpful assistant.\nuser\nWhat kind of dog is this?\nassistant\nThe dog in the picture appears to be a Labrador Retriever. Labradors are known for their friendly and energetic nature, which is evident in',
613605
'system\nYou are a helpful assistant.\nuser\nWho are you?\nassistant\nI am Qwen, a large language model created by Alibaba Cloud. I am designed to assist with a wide range of tasks, from answering questions and'
614606
],
615607
("xpu", None): [
@@ -653,8 +645,8 @@ def test_small_model_integration_test_batch_different_resolutions(self):
653645
'system\nYou are a helpful assistant.\nuser\nWhat kind of dog is this?\nassistant\nThe dog in the picture appears to be a Labrador Retriever. Labradors are known for their friendly and gentle nature, which is evident in',
654646
],
655647
("rocm", None): [
656-
'system\nYou are a helpful assistant.\nuser\nWhat kind of dog is this?\nassistant\nThe dog in the picture appears to be a Labrador Retriever. Labradors are known for their friendly and gentle nature, which is often reflected',
657-
'system\nYou are a helpful assistant.\nuser\nWhat kind of dog is this?\nassistant\nThe dog in the picture appears to be a Labrador Retriever. Labradors are known for their friendly and gentle nature, which is evident in'
648+
'system\nYou are a helpful assistant.\nuser\nWhat kind of dog is this?\nassistant\nThe dog in the picture appears to be a Labrador Retriever. Labradors are known for their friendly and energetic nature, which is evident in',
649+
'system\nYou are a helpful assistant.\nuser\nWhat kind of dog is this?\nassistant\nThe dog in the picture appears to be a Labrador Retriever. Labradors are known for their friendly and gentle nature, which is evident in',
658650
],
659651
("xpu", None): [
660652
'system\nYou are a helpful assistant.\nuser\nWhat kind of dog is this?\nassistant\nThe dog in the picture appears to be a Labrador Retriever. Labradors are known for their friendly and energetic nature, which is evident in',
@@ -690,11 +682,7 @@ def test_small_model_integration_test_batch_flashatt2(self):
690682
# it should not matter whether two images are the same size or not
691683
output = model.generate(**inputs, max_new_tokens=30, do_sample=False)
692684

693-
expected_decoded_text = Expectations({
694-
("cuda", None): "system\nYou are a helpful assistant.\nuser\nWhat kind of dog is this?\nassistant\nThe dog in the picture appears to be a Labrador Retriever. Labradors are known for their friendly and energetic nature, which is evident in",
695-
("rocm", (9, 4)): "system\nYou are a helpful assistant.\nuser\nWhat kind of dog is this?\nassistant\nThe dog in the picture appears to be a Labrador Retriever. Labradors are known for their friendly and gentle nature, which is evident in",
696-
("xpu", None): "system\nYou are a helpful assistant.\nuser\nWhat kind of dog is this?\nassistant\nThe dog in the picture appears to be a Labrador Retriever. Labradors are known for their friendly and energetic nature, which is evident in",
697-
}).get_expectation() # fmt: skip
685+
expected_decoded_text = "system\nYou are a helpful assistant.\nuser\nWhat kind of dog is this?\nassistant\nThe dog in the picture appears to be a Labrador Retriever. Labradors are known for their friendly and energetic nature, which is evident in"
698686

699687
# Since the test is to generate twice the same text, we just test twice against the expected decoded text
700688
decoded_texts = self.processor.batch_decode(output, skip_special_tokens=True)
@@ -776,9 +764,6 @@ def test_small_model_integration_test_with_video(self):
776764
(None, None): [
777765
'system\nYou are a helpful assistant.\nuser\nWhat is shown in this video?\nassistant\nThe video shows two individuals playing tennis on an indoor court. The player in the foreground, dressed in a white shirt and black shorts, is preparing to',
778766
],
779-
("rocm", (9, 4)): [
780-
'system\nYou are a helpful assistant.\nuser\nWhat is shown in this video?\nassistant\nThe video shows an indoor tennis court with a person standing on the service line, preparing to serve. The individual appears to be practicing or warming up,',
781-
],
782767
("xpu", None): [
783768
'system\nYou are a helpful assistant.\nuser\nWhat is shown in this video?\nassistant\nThe video shows an indoor tennis court with a person standing on the service line, preparing to serve. The individual appears to be practicing or warming up,',
784769
],

0 commit comments

Comments
 (0)