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]: pythonic tool parser only accepts alphabetical tool names #14470

Open
1 task done
bjj opened this issue Mar 8, 2025 · 2 comments · May be fixed by #14474
Open
1 task done

[Bug]: pythonic tool parser only accepts alphabetical tool names #14470

bjj opened this issue Mar 8, 2025 · 2 comments · May be fixed by #14474
Labels
bug Something isn't working

Comments

@bjj
Copy link

bjj commented Mar 8, 2025

Your current environment

The output of `python collect_env.py`
Collecting environment information...
PyTorch version: 2.7.0.dev20250221+rocm6.3
Is debug build: False
CUDA used to build PyTorch: N/A
ROCM used to build PyTorch: 6.3.42131-fa1d09cbd

OS: Ubuntu 24.04.2 LTS (x86_64)
GCC version: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
Clang version: Could not collect
CMake version: version 3.31.4
Libc version: glibc-2.39

Python version: 3.12.3 (main, Feb  4 2025, 14:48:35) [GCC 13.3.0] (64-bit runtime)
Python platform: Linux-6.11.0-17-generic-x86_64-with-glibc2.39
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: AMD Instinct MI100 (gfx908:sramecc+:xnack-)
Nvidia driver version: Could not collect
cuDNN version: Could not collect
HIP runtime version: 6.3.42131
MIOpen runtime version: 3.3.0
Is XNNPACK available: True

CPU:
Architecture:                         x86_64
CPU op-mode(s):                       32-bit, 64-bit
Address sizes:                        39 bits physical, 48 bits virtual
Byte Order:                           Little Endian
CPU(s):                               4
On-line CPU(s) list:                  0-3
Vendor ID:                            GenuineIntel
Model name:                           Intel(R) Core(TM) i5-6600K CPU @ 3.50GHz
CPU family:                           6
Model:                                94
Thread(s) per core:                   1
Core(s) per socket:                   4
Socket(s):                            1
Stepping:                             3
CPU(s) scaling MHz:                   100%
CPU max MHz:                          3900.0000
CPU min MHz:                          800.0000
BogoMIPS:                             6999.82
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 est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault pti ssbd ibrs ibpb stibp tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp vnmi md_clear flush_l1d arch_capabilities
Virtualization:                       VT-x
L1d cache:                            128 KiB (4 instances)
L1i cache:                            128 KiB (4 instances)
L2 cache:                             1 MiB (4 instances)
L3 cache:                             6 MiB (1 instance)
NUMA node(s):                         1
NUMA node0 CPU(s):                    0-3
Vulnerability Gather data sampling:   Vulnerable: No microcode
Vulnerability Itlb multihit:          KVM: Mitigation: VMX disabled
Vulnerability L1tf:                   Mitigation; PTE Inversion; VMX conditional cache flushes, SMT disabled
Vulnerability Mds:                    Mitigation; Clear CPU buffers; SMT disabled
Vulnerability Meltdown:               Mitigation; PTI
Vulnerability Mmio stale data:        Mitigation; Clear CPU buffers; SMT disabled
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 disabled; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds:                  Mitigation; Microcode
Vulnerability Tsx async abort:        Mitigation; TSX disabled

Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] nvidia-ml-py==12.570.86
[pip3] pynvml==12.0.0
[pip3] pytorch-triton-rocm==3.2.0+git4b3bb1f8
[pip3] pyzmq==26.2.1
[pip3] torch==2.7.0.dev20250221+rocm6.3
[pip3] torchaudio==2.6.0.dev20250221+rocm6.3
[pip3] torchvision==0.22.0.dev20250221+rocm6.3
[pip3] transformers==4.49.0
[pip3] triton==3.2.0+gite5be006a
[conda] Could not collect
ROCM Version: 6.3.42134-a9a80e791
Neuron SDK Version: N/A
vLLM Version: 0.7.4.dev4+gbfbc0b32
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
============================ ROCm System Management Interface ============================
================================ Weight between two GPUs =================================
       GPU0
GPU0   0

================================= Hops between two GPUs ==================================
       GPU0
GPU0   0

=============================== Link Type between two GPUs ===============================
       GPU0
GPU0   0

======================================= Numa Nodes =======================================
GPU[0]          : (Topology) Numa Node: 0
GPU[0]          : (Topology) Numa Affinity: -1
================================== End of ROCm SMI Log ===================================

LD_LIBRARY_PATH=/home/bjj/vllm-rocm/lib/python3.12/site-packages/cv2/../../lib64:
NCCL_CUMEM_ENABLE=0
TORCHINDUCTOR_COMPILE_THREADS=1
CUDA_MODULE_LOADING=LAZY

🐛 Describe the bug

The PythonicToolParser TOOL_CALL_REGEX only supports alphanumeric tool names and parameter names. There are a couple of issues with this:

  1. snake_case is not supported. This is even used in OpenAI's API example get_weather.
  2. kebab-case is not supported. This is not valid Python at all, but the API is all specified in terms of JSON, and it's a perfectly valid string. n8n's builtin Wikipedia tool is named wikipedia-api
  3. Numbers not supported! Can't believe I didn't see this while staring at that regex

These issues are different in difficulty:

  1. I think snake_case is trivial to fix by changing TOOL_CALL_REGEX because ast.parse will be happy
  2. I can see a few ways to handle kebab-case, but none of them are ideal. The easiest thing seems to be to accept invalid Python with the regex, use the regex to remap to valid python variable names, then map back after parsing. All of the other things I can think of (like letting instances of TooLParser remap names) leak info to the model. There's still a risk that pythonic models are reluctant to make invalid name function calls (but I have been hitting the exact opposite!)
  3. Regex change

A good example of a tool calling model that strongly prefers python is watt-tool-8B or 70B (8B is based on llama3.1, but it still wants system message tools and pythonic output). It's a strong contender on the BFCL.

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.
@bjj bjj added the bug Something isn't working label Mar 8, 2025
@bjj bjj changed the title [Bug]: pythonic tool parser only accepts alphanumeric tool names [Bug]: pythonic tool parser only accepts alphabetical tool names Mar 8, 2025
@bjj
Copy link
Author

bjj commented Mar 8, 2025

I see this is more complicated because there are differences depending on whether you stream. The lack of some python-acceptable characters in the regex is only a factor in the non-streaming case, while kebab-case affects both streaming and non-streaming.

I'll submit a PR with a remap solution for people to comment on.

@bjj
Copy link
Author

bjj commented Mar 8, 2025

Ok, clearly I can't read [a-zA-Z]+\w*, although I suppose I get partial credit for leading underscores and full credit for kebab-case.

bjj added a commit to bjj/vllm that referenced this issue Mar 8, 2025
@bjj bjj linked a pull request Mar 8, 2025 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant