Views
No views yet


vllm serve RedHatAI/Voxtral-Mini-3B-2507-FP8-dynamic --tokenizer_mode mistral --config_format mistral --load_format mistral1from mistral_common.protocol.instruct.messages import TextChunk, AudioChunk, UserMessage, AssistantMessage, RawAudio
2from mistral_common.audio import Audio
3from huggingface_hub import hf_hub_download
4
5from openai import OpenAI
6
7# Modify OpenAI's API key and API base to use vLLM's API server.
8openai_api_key = "EMPTY"
9openai_api_base = "http://<your-server-host>:8000/v1"
10
11client = OpenAI(
12 api_key=openai_api_key,
13 base_url=openai_api_base,
14)
15
16models = client.models.list()
17model = models.data[0].id
18
19obama_file = hf_hub_download("patrickvonplaten/audio_samples", "obama.mp3", repo_type="dataset")
20bcn_file = hf_hub_download("patrickvonplaten/audio_samples", "bcn_weather.mp3", repo_type="dataset")
21
22def file_to_chunk(file: str) -> AudioChunk:
23 audio = Audio.from_file(file, strict=False)
24 return AudioChunk.from_audio(audio)
25
26text_chunk = TextChunk(text="Which speaker is more inspiring? Why? How are they different from each other?")
27user_msg = UserMessage(content=[file_to_chunk(obama_file), file_to_chunk(bcn_file), text_chunk]).to_openai()
28
29print(30 * "=" + "USER 1" + 30 * "=")
30print(text_chunk.text)
31print("\n\n")
32
33response = client.chat.completions.create(
34 model=model,
35 messages=[user_msg],
36 temperature=0.2,
37 top_p=0.95,
38)
39content = response.choices[0].message.content
40
41print(30 * "=" + "BOT 1" + 30 * "=")
42print(content)
43print("\n\n")
44# The speaker who is more inspiring is the one who delivered the farewell address, as they express
45# gratitude, optimism, and a strong commitment to the nation and its citizens. They emphasize the importance of
46# self-government and active citizenship, encouraging everyone to participate in the democratic process. In contrast,
47# the other speaker provides a factual update on the weather in Barcelona, which is less inspiring as it
48# lacks the emotional and motivational content of the farewell address.
49
50# **Differences:**
51# - The farewell address speaker focuses on the values and responsibilities of citizenship, encouraging active participation in democracy.
52# - The weather update speaker provides factual information about the temperature in Barcelona, without any emotional or motivational content.
53
54
55messages = [
56 user_msg,
57 AssistantMessage(content=content).to_openai(),
58 UserMessage(content="Ok, now please summarize the content of the first audio.").to_openai()
59]
60print(30 * "=" + "USER 2" + 30 * "=")
61print(messages[-1]["content"])
62print("\n\n")
63
64response = client.chat.completions.create(
65 model=model,
66 messages=messages,
67 temperature=0.2,
68 top_p=0.95,
69)
70content = response.choices[0].message.content
71print(30 * "=" + "BOT 2" + 30 * "=")
72print(content)1from mistral_common.protocol.transcription.request import TranscriptionRequest
2from mistral_common.protocol.instruct.messages import RawAudio
3from mistral_common.audio import Audio
4from huggingface_hub import hf_hub_download
5
6from openai import OpenAI
7
8# Modify OpenAI's API key and API base to use vLLM's API server.
9openai_api_key = "EMPTY"
10openai_api_base = "http://<your-server-host>:8000/v1"
11
12client = OpenAI(
13 api_key=openai_api_key,
14 base_url=openai_api_base,
15)
16
17models = client.models.list()
18model = models.data[0].id
19
20obama_file = hf_hub_download("patrickvonplaten/audio_samples", "obama.mp3", repo_type="dataset")
21audio = Audio.from_file(obama_file, strict=False)
22
23audio = RawAudio.from_audio(audio)
24req = TranscriptionRequest(model=model, audio=audio, language="en", temperature=0.0).to_openai(exclude=("top_p", "seed"))
25
26response = client.audio.transcriptions.create(**req)
27print(response)1podman run --rm -it --device nvidia.com/gpu=all -p 8000:8000 \
2 --ipc=host \
3--env "HUGGING_FACE_HUB_TOKEN=$HF_TOKEN" \
4--env "HF_HUB_OFFLINE=0" -v ~/.cache/vllm:/home/vllm/.cache \
5--name=vllm \
6registry.access.redhat.com/rhaiis/rh-vllm-cuda \
7vllm serve \
8--tensor-parallel-size 8 \
9--max-model-len 32768 \
10--enforce-eager --model RedHatAI/Voxtral-Mini-3B-2507-FP8-dynamic1# Setting up vllm server with ServingRuntime
2# Save as: vllm-servingruntime.yaml
3apiVersion: serving.kserve.io/v1alpha1
4kind: ServingRuntime
5metadata:
6 name: vllm-cuda-runtime # OPTIONAL CHANGE: set a unique name
7 annotations:
8 openshift.io/display-name: vLLM NVIDIA GPU ServingRuntime for KServe
9 opendatahub.io/recommended-accelerators: '["nvidia.com/gpu"]'
10 labels:
11 opendatahub.io/dashboard: 'true'
12spec:
13 annotations:
14 prometheus.io/port: '8080'
15 prometheus.io/path: '/metrics'
16 multiModel: false
17 supportedModelFormats:
18 - autoSelect: true
19 name: vLLM
20 containers:
21 - name: kserve-container
22 image: quay.io/modh/vllm:rhoai-2.25-cuda # CHANGE if needed. If AMD: quay.io/modh/vllm:rhoai-2.25-rocm
23 command:
24 - python
25 - -m
26 - vllm.entrypoints.openai.api_server
27 args:
28 - "--port=8080"
29 - "--model=/mnt/models"
30 - "--served-model-name={{.Name}}"
31 env:
32 - name: HF_HOME
33 value: /tmp/hf_home
34 ports:
35 - containerPort: 8080
36 protocol: TCP1# Attach model to vllm server. This is an NVIDIA template
2# Save as: inferenceservice.yaml
3apiVersion: serving.kserve.io/v1beta1
4kind: InferenceService
5metadata:
6 annotations:
7 openshift.io/display-name: Voxtral-Mini-3B-2507-FP8-dynamic # OPTIONAL CHANGE
8 serving.kserve.io/deploymentMode: RawDeployment
9 name: Voxtral-Mini-3B-2507-FP8-dynamic # specify model name. This value will be used to invoke the model in the payload
10 labels:
11 opendatahub.io/dashboard: 'true'
12spec:
13 predictor:
14 maxReplicas: 1
15 minReplicas: 1
16 model:
17 modelFormat:
18 name: vLLM
19 name: ''
20 resources:
21 limits:
22 cpu: '2' # this is model specific
23 memory: 8Gi # this is model specific
24 nvidia.com/gpu: '1' # this is accelerator specific
25 requests: # same comment for this block
26 cpu: '1'
27 memory: 4Gi
28 nvidia.com/gpu: '1'
29 runtime: vllm-cuda-runtime # must match the ServingRuntime name above
30 storageUri: oci://registry.stage.redhat.io/rhelai1/modelcar-voxtral-mini-3b-2507-fp8-dynamic:1.5
31 tolerations:
32 - effect: NoSchedule
33 key: nvidia.com/gpu
34 operator: Exists1# make sure first to be in the project where you want to deploy the model
2# oc project <project-name>
3
4# apply both resources to run model
5
6# Apply the ServingRuntime
7oc apply -f vllm-servingruntime.yaml
81# Replace <inference-service-name> and <cluster-ingress-domain> below:
2# - Run `oc get inferenceservice` to find your URL if unsure.
3
4# Call the server using curl:
5curl https://<inference-service-name>-predictor-default.<domain>/v1/chat/completions
6 -H "Content-Type: application/json" \
7 -d '{
8 "model": "Voxtral-Mini-3B-2507-FP8-dynamic",
9 "stream": true,
10 "stream_options": {
11 "include_usage": true
12 },
13 "max_tokens": 1,
14 "messages": [
15 {
16 "role": "user",
17 "content": "How can a bee fly when its wings are so small?"
18 }
19 ]
20}'
211import torch
2from transformers import VoxtralForConditionalGeneration, AutoProcessor
3from llmcompressor import oneshot
4from llmcompressor.modifiers.quantization import QuantizationModifier
5
6# Select model and load it.
7MODEL_ID = "mistralai/Voxtral-Mini-3B-2507"
8
9model = VoxtralForConditionalGeneration.from_pretrained(MODEL_ID, torch_dtype=torch.bfloat16)
10processor = AutoProcessor.from_pretrained(MODEL_ID)
11
12# Recipe
13recipe = QuantizationModifier(
14 targets="Linear",
15 scheme="FP8_DYNAMIC",
16 ignore=["language_model.lm_head", "re:audio_tower.*" ,"re:multi_modal_projector.*"],
17)
18
19# Apply algorithms.
20oneshot(
21 model=model,
22 recipe=recipe,
23 processor=processor,
24)
25
26SAVE_DIR = MODEL_ID.rstrip("/").split("/")[-1] + "-FP8-dynamic"
27model.save_pretrained(SAVE_DIR, save_compressed=True)
28processor.save_pretrained(SAVE_DIR)convert_voxtral_hf_to_mistral.py script included with the model.| Benchmark | Language | Voxtral-Mini-3B-2507 | Voxtral-Mini-3B-2507-FP8-dynamic (this model) | Recovery |
|---|---|---|---|---|
| Fleurs WER | English | 3.89% | 3.95% | 99.9% |
| French | 5.07% | 4.86% | 100.2% | |
| Spanish | 3.63% | 3.55% | 100.1% | |
| German | 5.00% | 5.01% | 100.0% | |
| Italian | 2.54% | 2.57% | 100.0% | |
| Portuguese | 3.85% | 4.03% | 99.8% | |
| Dutch | 7.01% | 7.20% | 99.8% |