Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Granite 3.0 disconnect between parser and example template #10379

Open
1 task done
wilbry opened this issue Nov 15, 2024 · 0 comments
Open
1 task done

[Bug]: Granite 3.0 disconnect between parser and example template #10379

wilbry opened this issue Nov 15, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@wilbry
Copy link

wilbry commented Nov 15, 2024

Your current environment

The output of `python collect_env.py`
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration:
GPU 0: NVIDIA RTX A4000
GPU 1: NVIDIA RTX A4000
GPU 2: NVIDIA RTX A6000

Nvidia driver version: 535.183.01
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:                        46 bits physical, 48 bits virtual
Byte Order:                           Little Endian
CPU(s):                               112
On-line CPU(s) list:                  0-111
Vendor ID:                            GenuineIntel
Model name:                           Intel(R) Xeon(R) Platinum 8176 CPU @ 2.10GHz
CPU family:                           6
Model:                                85
Thread(s) per core:                   2
Core(s) per socket:                   28
Socket(s):                            2
Stepping:                             4
CPU(s) scaling MHz:                   32%
CPU max MHz:                          3800.0000
CPU min MHz:                          1000.0000
BogoMIPS:                             4200.00
Flags:                                fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 pti intel_ppin ssbd mba ibrs ibpb stibp tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req vnmi pku ospke md_clear flush_l1d arch_capabilities
Virtualization:                       VT-x
L1d cache:                            1.8 MiB (56 instances)
L1i cache:                            1.8 MiB (56 instances)
L2 cache:                             56 MiB (56 instances)
L3 cache:                             77 MiB (2 instances)
NUMA node(s):                         2
NUMA node0 CPU(s):                    0-27,56-83
NUMA node1 CPU(s):                    28-55,84-111
Vulnerability Gather data sampling:   Mitigation; Microcode
Vulnerability Itlb multihit:          KVM: Mitigation: VMX disabled
Vulnerability L1tf:                   Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable
Vulnerability Mds:                    Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Meltdown:               Mitigation; PTI
Vulnerability Mmio stale data:        Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed:               Mitigation; IBRS
Vulnerability Spec rstack overflow:   Not affected
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; IBRS; IBPB conditional; STIBP conditional; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Mitigation; Clear CPU buffers; SMT vulnerable

Versions of relevant libraries:
[pip3] mypy==1.13.0
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.26.4
[pip3] nvidia-cublas-cu12==12.4.5.8
[pip3] nvidia-cuda-cupti-cu12==12.4.127
[pip3] nvidia-cuda-nvrtc-cu12==12.4.127
[pip3] nvidia-cuda-runtime-cu12==12.4.127
[pip3] nvidia-cudnn-cu12==9.1.0.70
[pip3] nvidia-cufft-cu12==11.2.1.3
[pip3] nvidia-curand-cu12==10.3.5.147
[pip3] nvidia-cusolver-cu12==11.6.1.9
[pip3] nvidia-cusparse-cu12==12.3.1.170
[pip3] nvidia-ml-py==12.560.30
[pip3] nvidia-nccl-cu12==2.21.5
[pip3] nvidia-nvjitlink-cu12==12.4.127
[pip3] nvidia-nvtx-cu12==12.4.127
[pip3] onnx==1.17.0
[pip3] onnxruntime==1.20.0
[pip3] pyzmq==26.2.0
[pip3] sentence-transformers==3.0.1
[pip3] torch==2.5.1
[pip3] torchaudio==2.4.1+cu121
[pip3] torchvision==0.20.1
[pip3] transformers==4.46.1
[pip3] triton==3.1.0
[conda] Could not collect
ROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.6.4.post1
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
GPU0    GPU1    GPU2    CPU Affinity    NUMA Affinity   GPU NUMA ID
GPU0     X      NODE    SYS     0-27,56-83      0               N/A
GPU1    NODE     X      SYS     0-27,56-83      0               N/A
GPU2    SYS     SYS      X      28-55,84-111    1               N/A

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

Model Input Dumps

No response

🐛 Describe the bug

Using the example template found at examples/tool_chat_template_granite.jinja will produce a different format than the parser as implemented at vllm/entrypoints/openai/tool_parsers/granite_tool_parser.py. The template loops over the tool calling list, thus removing any [ characters from the input, while the parse explicitly uses the [ symbol to determine if a response should be parsed. This has the effect of requiring a different format on input than on output, making fine-tuning a model using this format very difficult. It appears to me the only change made from the original tokenizer as found at https://huggingface.co/ibm-granite/granite-3.0-2b-instruct/blob/main/tokenizer_config.json#L188 and the one found in this repo is this looping over the tools rather than representing the entire list at once.

This difference is demonstrated by the following code snippet.

from vllm.entrypoints.openai.tool_parsers.granite_tool_parser import GraniteToolParser
from vllm.entrypoints.chat_utils import apply_hf_chat_template
from transformers import AutoTokenizer
from vllm.entrypoints.openai.protocol import ChatCompletionRequest

tokenizer = AutoTokenizer.from_pretrained("ibm-granite/granite-3.0-2b-instruct")
chat_template = open("./examples/tool_chat_template_granite.jinja").read()
tool_call_example = [{"role": "assistant", "tool_calls": [{"function": {"name": "get_weather", "arguments": {"location": "San Fransisco"}}}]}]

#<|start_of_role|>assistant<|end_of_role|>\n<|tool_call|> {"name": "get_weather", "arguments": {"location": "San Fransisco"}}\n<|end_of_text|>\n
full_assistant_turn_with_tool_call= apply_hf_chat_template(tokenizer=tokenizer, conversation=tool_call_example, chat_template=chat_template)

#Remove the start of the string to emulate what would come out of the LLM, tokenize and untokenize to get rid of special tokens faithfully
#\n {"name": "get_weather", "arguments": {"location": "San Fransisco"}}\n\n
emulated_output =tokenizer.decode(tokenizer(full_assistant_turn_with_tool_call.removeprefix("<|start_of_role|>assistant<|end_of_role|>")).input_ids, skip_special_tokens=True)

# Attempt to parse
tool_parser = GraniteToolParser(tokenizer)
tool_info = tool_parser.extract_tool_calls(emulated_output, ChatCompletionRequest(messages=[], model=''))
print(tool_info)
assert tool_info.tool_calls

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.
@wilbry wilbry added the bug Something isn't working label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant