[Bug]: always returns invalid tokens in FP8 static mode
Your current environment
Collecting environment information...
PyTorch version: 2.3.0+cu121
Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A
OS: Ubuntu 22.04.3 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: version 3.29.2
Libc version: glibc-2.35
Python version: 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (64-bit runtime)
Python platform: Linux-6.5.0-27-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 4090
Nvidia driver version: 550.54.14
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
CPU:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 43 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 64
On-line CPU(s) list: 0-63
Vendor ID: AuthenticAMD
Model name: AMD EPYC 7542 32-Core Processor
CPU family: 23
Model: 49
Thread(s) per core: 1
Core(s) per socket: 32
Socket(s): 2
Stepping: 0
Frequency boost: enabled
CPU max MHz: 2900.0000
CPU min MHz: 1500.0000
BogoMIPS: 5799.89
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinvd amd_ppin arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip rdpid overflow_recov succor smca sev sev_es
Virtualization: AMD-V
L1d cache: 2 MiB (64 instances)
L1i cache: 2 MiB (64 instances)
L2 cache: 32 MiB (64 instances)
L3 cache: 256 MiB (16 instances)
NUMA node(s): 8
NUMA node0 CPU(s): 0-7
NUMA node1 CPU(s): 8-15
NUMA node2 CPU(s): 16-23
NUMA node3 CPU(s): 24-31
NUMA node4 CPU(s): 32-39
NUMA node5 CPU(s): 40-47
NUMA node6 CPU(s): 48-55
NUMA node7 CPU(s): 56-63
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Not affected
Vulnerability Retbleed: Mitigation; untrained return thunk; SMT disabled
Vulnerability Spec rstack overflow: Mitigation; SMT disabled
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Retpolines, IBPB conditional, STIBP disabled, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected
Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] nvidia-nccl-cu12==2.20.5
[pip3] torch==2.3.0
[pip3] triton==2.3.0
[pip3] vllm-nccl-cu12==2.18.1.0.4.0
[conda] Could not collectROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.4.2
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
GPU0 NIC0 CPU Affinity NUMA Affinity GPU NUMA ID
GPU0 X SYS 3 N/A
NIC0 SYS X
Legend:
X = Self
SYS = Connection traversing PCIe as well as the SMP interconnect between NUMA nodes (e.g., QPI/UPI)
NODE = Connection traversing PCIe as well as the interconnect between PCIe Host Bridges within a NUMA node
PHB = Connection traversing PCIe as well as a PCIe Host Bridge (typically the CPU)
PXB = Connection traversing multiple PCIe bridges (without traversing the PCIe Host Bridge)
PIX = Connection traversing at most a single PCIe bridge
NV# = Connection traversing a bonded set of # NVLinks
NIC Legend:
NIC0: mlx5_bond_0```
🐛 Describe the bug
when we use FP8 static mode that always return ! symbol BTW it is works fine on FP8 dynamic mode
>>> from vllm import LLM, SamplingParams
>>>
>>> prompts = [
... "tell me a long story",
... ]
>>>
>>> llm = LLM(model="nm-testing/Meta-Llama-3-8B-Instruct-FP8")
>>> sampling_params = SamplingParams(temperature=0.8, top_p=0.95, max_tokens=512)
>>> outputs = llm.generate(prompts, sampling_params)
Processed prompts: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:08<00:00, 8.75s/it]
>>>
>>> # Print the outputs.
>>> for output in outputs:
... prompt = output.prompt
... generated_text = output.outputs[0].text
... print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
...
Prompt: 'tell me a long story', Generated text: ' about a character named "Blueberry"\nBlueberry, or Berry as she was known to her friends, was a young girl with a wild heart and a passion for adventure. She lived in a small village
on!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
This model may not have been calibrated well. We are currently using this model to test the flow.
cc @robertgshaw2-neuralmagic
@comaniac Thank you for your reply, I will try to manually calibrate it later.
Will take a look
Hi @AnyISalIn thank you for reporting this issue! Yes, this does seem to be an issue with static activation scales producing NaNs if we aren't clamping the values to an FP8 representable space. It seems this issue is more common when using non-deterministic sampling params like top_p, so this is why you uncovered it so easily and it did not appear in our smoke tests.
I have confirmed that applying the PR @robertgshaw2-neuralmagic just linked (https://github.com/vllm-project/vllm/pull/4570) fixes the issue:
>>> from vllm import LLM, SamplingParams
>>> model = LLM("nm-testing/Meta-Llama-3-8B-Instruct-FP8")
>>> sampling_params = SamplingParams(temperature=0.8, top_p=0.95, max_tokens=512)
>>> outputs = model.generate("Once upon a time,", sampling_params)
Processed prompts: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:09<00:00, 9.81s/it]
>>> outputs[0].outputs[0].text
' there was a man who lived in a small village nestled in the mountains. He was a kind and gentle soul, loved by all who knew him. One day, he decided to go on a journey to find a cure for his ailing wife, who was bedridden with a terrible illness. He searched far and wide, visiting many wise men and women, but none could help him. Just when he was about to give up hope, he stumbled upon a wise old man who lived in a cave deep in the mountains. The old man told the man that he had heard of a magical flower that only bloomed once a year, and that it had the power to cure any illness. The man was overjoyed and asked the old man how he could find the flower. The old man told him that he could only find the flower by following the path of the setting sun, and that he would know it when he saw it. The man set off immediately, following the path of the setting sun. He walked for many days, facing many challenges and dangers along the way. But he did not give up, and finally, he saw the magical flower blooming in the distance. He rushed towards it, picked it, and brought it back to his wife. She was instantly cured, and they lived happily ever after. The man realized that he had learned a valuable lesson on his journey, that even in the darkest of times, there is always hope, and that with perseverance and determination, anything is possible. The story of the magical flower spread throughout the land, and people began to call the man the "Flower Seeker." He became known for his bravery and his ability to find the impossible, and people would come from far and wide to seek his advice and guidance. And so, the man lived a long and happy life, surrounded by the love and respect of his community. The story of the magical flower was passed down from generation to generation, and it became a reminder to always keep hope alive, and to never give up on our dreams. The story of the magical flower was a reminder that even in the darkest of times, there is always hope, and that with perseverance and determination, anything is possible. The story of the magical flower was a reminder to always keep hope alive, and to never give up on our dreams. The story of the magical flower was a reminder that even in the darkest of times, there is always hope, and that with perseverance and determination, anything is possible. The story of the magical flower was a'
@mgoin Thank you for resolving this issue quickly.