Skip to content

Conversation

@Echo-Nie
Copy link
Contributor

Objective

  1. guided_json: Verify whether the JSON schema is compatible with XGrammar.
  2. guided_grammar: Verify the validity of custom grammar strings.
  3. guided_json_object: Verify that the simplified JSON object pattern { "type": "object" } can be correctly generated.
  4. guided_choice: Verify whether a list of choices can be correctly transformed into grammar rules.
  5. structural_tag: Verify that structured tags can be correctly parsed.
  6. regex: Verify that regular expressions are passed through without validation errors.

Test Results

/opt/conda/envs/python35-paddle120-env/lib/python3.10/site-packages/paddle/utils/cpp_extension/extension_utils.py:717: UserWarning: No ccache found. Please be aware that recompiling all source files may be required. You can download and install ccache from: https://github.com/ccache/ccache/blob/master/doc/INSTALL.md
  warnings.warn(warning_message)
/opt/conda/envs/python35-paddle120-env/lib/python3.10/site-packages/_distutils_hack/__init__.py:30: UserWarning: Setuptools is replacing distutils. Support for replacing an already imported distutils is deprecated. In the future, this condition will fail. Register concerns at https://github.com/pypa/setuptools/issues/new?template=distutils-deprecation.yml
  warnings.warn(
test_guided_choice_invalid (__main__.TestXGrammarChecker) ... ok
test_guided_choice_valid (__main__.TestXGrammarChecker) ... ok
test_guided_grammar_invalid (__main__.TestXGrammarChecker) ... ok
test_guided_grammar_valid (__main__.TestXGrammarChecker) ... ok
test_guided_json_invalid (__main__.TestXGrammarChecker) ... ok
test_guided_json_object (__main__.TestXGrammarChecker) ... ok
test_guided_json_valid (__main__.TestXGrammarChecker) ... ok
test_regex_passthrough (__main__.TestXGrammarChecker) ... ok
test_structural_tag_invalid (__main__.TestXGrammarChecker) ... ok
test_structural_tag_valid (__main__.TestXGrammarChecker) ... ok

----------------------------------------------------------------------
Ran 10 tests in 0.002s

OK

Analysis

guided_json: Valid schemas pass correctly. Invalid schemas correctly return an error.

guided_grammar: Valid grammar strings generate the corresponding Grammar object. Invalid grammar strings return errors as expected.

guided_json_object: Simplified JSON object patterns are generated correctly.

guided_choice: Valid choice lists are correctly converted into grammar rules. Invalid choices (e.g., containing None) trigger exceptions.

structural_tag: Correct structured tags are parsed successfully. Missing trigger fields trigger a KeyError.

regex: Regular expressions are passed through directly without validation errors.

@paddle-bot
Copy link

paddle-bot bot commented Aug 22, 2025

Thanks for your contribution!

@luotao1
Copy link
Collaborator

luotao1 commented Aug 26, 2025

@kevincheng2

@kevincheng2 kevincheng2 self-requested a review August 29, 2025 02:28
@luotao1
Copy link
Collaborator

luotao1 commented Aug 29, 2025

___
ERROR
collecting
model_executor/guided_decoding/test_xgrammar_checker.py
model_executor/guided_decoding/test_xgrammar_checker.py
Error: Process completed with exit code 8.

@Echo-Nie
Copy link
Contributor Author

___
ERROR
collecting
model_executor/guided_decoding/test_xgrammar_checker.py

刚刚检查了一下log,原因如下:

model_executor/guided_decoding/test_xgrammar_checker.py:20: in <module>
    from fastdeploy.model_executor.guided_decoding.xgrammar_backend import XGrammarChecker
/usr/local/lib/python3.10/site-packages/fastdeploy/model_executor/guided_decoding/xgrammar_backend.py:23: in <module>
    import torch
E   ModuleNotFoundError: No module named 'torch'

原因发生在xgrammar_backend.py源码里面的 import torch,与单测无关。
https://github.com/PaddlePaddle/FastDeploy/blob/develop/fastdeploy/model_executor/guided_decoding/xgrammar_backend.py#L23

好像是CI在安装的时候没有torch?

在AIStudio上,安装好xgrammertorch 之后能够通过

image

@luotao1 @kevincheng2

@kevincheng2
Copy link
Collaborator

___
ERROR
collecting
model_executor/guided_decoding/test_xgrammar_checker.py

刚刚检查了一下log,原因如下:

model_executor/guided_decoding/test_xgrammar_checker.py:20: in <module>
    from fastdeploy.model_executor.guided_decoding.xgrammar_backend import XGrammarChecker
/usr/local/lib/python3.10/site-packages/fastdeploy/model_executor/guided_decoding/xgrammar_backend.py:23: in <module>
    import torch
E   ModuleNotFoundError: No module named 'torch'

原因发生在xgrammar_backend.py源码里面的 import torch,与单测无关。 https://github.com/PaddlePaddle/FastDeploy/blob/develop/fastdeploy/model_executor/guided_decoding/xgrammar_backend.py#L23

好像是CI在安装的时候没有torch?

在AIStudio上,安装好xgrammertorch 之后能够通过

image @luotao1 @kevincheng2

可以在 .github/workflows/_unit_test_coverage.yml 文件中增加 python -m pip install xgrammar==0.1.19 torch==2.6.0,用于在单测镜像环境中安装 torch 和 xgrammar

@Echo-Nie
Copy link
Contributor Author

Echo-Nie commented Sep 2, 2025

可以在 .github/workflows/_unit_test_coverage.yml 文件中增加 python -m pip install xgrammar==0.1.19 torch==2.6.0,用于在单测镜像环境中安装 torch 和 xgrammar

Thx. Done

@luotao1
Copy link
Collaborator

luotao1 commented Sep 3, 2025

单侧失败
image

@kevincheng2
Copy link
Collaborator

image 看起来tokenizers 的版本又冲突了,麻烦在`.github/workflows/_unit_test_coverage.yml` 所有pip包安装完成后指定 `python -m pip install tokenizers==0.22.0`吧

@Echo-Nie
Copy link
Contributor Author

Echo-Nie commented Sep 3, 2025

看起来tokenizers 的版本又冲突了,麻烦在.github/workflows/_unit_test_coverage.yml 所有pip包安装完成后指定 python -m pip install tokenizers==0.22.0

Thx, Done

@kevincheng2
Copy link
Collaborator

9baff2769fa778a8179d1c99abe843af 看起来 qwen3 启动时挂掉了,另外 fp8 的精度也受了影响,等晚点我找个环境复现一下找一下问题哈,晚点再合入

@Echo-Nie
Copy link
Contributor Author

Echo-Nie commented Sep 3, 2025

看起来 qwen3 启动时挂掉了,另外 fp8 的精度也受了影响,等晚点我找个环境复现一下找一下问题哈,晚点再合入

Get ! Thx

@kevincheng2
Copy link
Collaborator

可以取消 .github/workflows/_unit_test_coverage.yml 文件中的修改,在 scripts/unittest_requirement.txt 中增加 xgrammar==0.1.19,这种情况下可以通过ci,有时间辛苦修改一下

@Echo-Nie
Copy link
Contributor Author

可以取消 .github/workflows/_unit_test_coverage.yml 文件中的修改,在 scripts/unittest_requirement.txt 中增加 xgrammar==0.1.19,这种情况下可以通过ci,有时间辛苦修改一下

好的老师,因为这个PR目前有点乱了,所以我重新提交一个,辛苦老师!

@Echo-Nie Echo-Nie changed the title 【Hackathon 9th No.76】supplementary unit test for XGrammarChecker Closed: supplementary unit test for XGrammarChecker Sep 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants