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

fix: add missing bos_token to example templates #11432

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

toslunar
Copy link
Contributor

@toslunar toslunar commented Dec 23, 2024

This PR updates chat template examples to align with the latest (>=0.4.3) /v1/chat/completions spec on BOS.

Some chat templates don't contain bos_token, especially when it's written before v0.4.3. According to the excellent investigation #9519, the chat serving does not add BOS again, while awkwardness remains in the offline chat interface (to be fixed).

Copy link

👋 Hi! Thank you for contributing to the vLLM project.
Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can do one of these:

  • Add ready label to the PR
  • Enable auto-merge.

🚀

Signed-off-by: Toshiki Kataoka <kataoka@pelements.jp>
@DarkLight1337
Copy link
Member

Thanks for fixing, can you add some unit tests to ensure that the BOS token isn't added twice in this case?

@toslunar
Copy link
Contributor Author

Added a test.

Is it OK to place it to a new directory (tests/examples_tests) because it seems the first time to test files in examples? I named it examples_tests because it shouldn't be confused with data directories like tests/data and tests/prompts.

Signed-off-by: Toshiki Kataoka <kataoka@pelements.jp>
@DarkLight1337
Copy link
Member

I would just name the directory tests/examples. Can you add the tests to CI by editing this file?

Signed-off-by: Toshiki Kataoka <kataoka@pelements.jp>
Signed-off-by: Toshiki Kataoka <kataoka@pelements.jp>
@mergify mergify bot added the ci/build label Dec 24, 2024
Signed-off-by: Toshiki Kataoka <kataoka@pelements.jp>
@DarkLight1337
Copy link
Member

Please update the failing tests to consider the BOS token.

@toslunar
Copy link
Contributor Author

Oops, this is unexpected to me. I'll fix the enumeration of Jinja files.

https://buildkite.com/vllm/fastcheck/builds/10539#0193fc47-aa1b-4af4-8c53-a27c0af8deb1

[2024-12-25T06:56:26Z] ============================= test session starts ==============================
[2024-12-25T06:56:26Z] platform linux -- Python 3.12.8, pytest-8.3.3, pluggy-1.5.0 -- /usr/bin/python3
[2024-12-25T06:56:26Z] cachedir: .pytest_cache
[2024-12-25T06:56:26Z] rootdir: /vllm-workspace
[2024-12-25T06:56:26Z] configfile: pyproject.toml
[2024-12-25T06:56:26Z] plugins: anyio-4.6.2.post1, buildkite-test-collector-0.1.9, asyncio-0.24.0, forked-1.6.0, rerunfailures-14.0, shard-0.1.2
[2024-12-25T06:56:26Z] asyncio: mode=Mode.STRICT, default_loop_scope=None
collected 2 items                                                              
[2024-12-25T06:56:26Z] Running 2 items in this shard: tests/examples/test_jinja.py::test_bos[1-path0], tests/examples/test_jinja.py::test_bos[3-path0]
[2024-12-25T06:56:26Z]
[2024-12-25T06:56:26Z] examples/test_jinja.py::test_bos[1-path0] SKIPPED (got empty paramet...)
[2024-12-25T06:56:26Z] examples/test_jinja.py::test_bos[3-path0] SKIPPED (got empty paramet...)
[2024-12-25T06:56:26Z]
[2024-12-25T06:56:26Z] ============================== 2 skipped in 0.03s ==============================

Signed-off-by: Toshiki Kataoka <kataoka@pelements.jp>
Signed-off-by: Toshiki Kataoka <kataoka@pelements.jp>
@DarkLight1337
Copy link
Member

I think you also need to update the entrypoints tests to consider the BOS token.

@DarkLight1337
Copy link
Member

Actually now that I think more about it... wouldn't it be better to instead update LLM.chat to automatically add BOS tokens? That way our chat templates would remain consistent with HF.

Signed-off-by: Toshiki Kataoka <kataoka@pelements.jp>
Copy link

mergify bot commented Dec 25, 2024

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @toslunar.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Dec 25, 2024
Signed-off-by: Toshiki Kataoka <kataoka@pelements.jp>
@mergify mergify bot removed the needs-rebase label Dec 25, 2024
Signed-off-by: Toshiki Kataoka <kataoka@pelements.jp>
@toslunar
Copy link
Contributor Author

I suppose this PR could be incremental and it only resolves the inconsistency among example templates.

Actually now that I think more about it... wouldn't it be better to instead update LLM.chat to automatically add BOS tokens? That way our chat templates would remain consistent with HF.

Sorry. I didn't get the concrete suggestion. Do you mean making LLM.chat add a BOS token if there's not (for backward compatibility)?

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.

2 participants