Skip to content

[Evals] Fix issue with reading from system prompt in file#104

Merged
SumanthRH merged 2 commits intomainfrom
sumanthrh/fix-system-prompt-in-file
Mar 31, 2025
Merged

[Evals] Fix issue with reading from system prompt in file#104
SumanthRH merged 2 commits intomainfrom
sumanthrh/fix-system-prompt-in-file

Conversation

@SumanthRH
Copy link
Member

What does this PR do?

Fixes an issue when reading from system prompt in file:

[rank0]: Traceback (most recent call last):
[rank0]:   File "/home/ray/anaconda3/bin/skythought", line 10, in <module>
[rank0]:     sys.exit(main())
[rank0]:              ^^^^^^
[rank0]:   File "/home/ray/default/SkyThought/skythought/evals/cli.py", line 586, in main
[rank0]:     app()
[rank0]:   File "/home/ray/anaconda3/lib/python3.12/site-packages/typer/main.py", line 339, in __call__
[rank0]:     raise e
[rank0]:   File "/home/ray/anaconda3/lib/python3.12/site-packages/typer/main.py", line 322, in __call__
[rank0]:     return get_command(self)(*args, **kwargs)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/home/ray/anaconda3/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
[rank0]:     return self.main(*args, **kwargs)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/home/ray/anaconda3/lib/python3.12/site-packages/typer/core.py", line 740, in main
[rank0]:     return _main(
[rank0]:            ^^^^^^
[rank0]:   File "/home/ray/anaconda3/lib/python3.12/site-packages/typer/core.py", line 195, in _main
[rank0]:     rv = self.invoke(ctx)
[rank0]:          ^^^^^^^^^^^^^^^^
[rank0]:   File "/home/ray/anaconda3/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
[rank0]:     return _process_result(sub_ctx.command.invoke(sub_ctx))
[rank0]:                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/home/ray/anaconda3/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
[rank0]:     return ctx.invoke(self.callback, **ctx.params)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/home/ray/anaconda3/lib/python3.12/site-packages/click/core.py", line 783, in invoke
[rank0]:     return __callback(*args, **kwargs)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/home/ray/anaconda3/lib/python3.12/site-packages/typer/main.py", line 697, in wrapper
[rank0]:     return callback(**use_params)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/home/ray/default/SkyThought/skythought/evals/cli.py", line 332, in evaluate
[rank0]:     generate_and_score(
[rank0]:   File "/home/ray/default/SkyThought/skythought/evals/inference_and_check.py", line 409, in generate_and_score
[rank0]:     id_to_results, prompt_tokens, completion_tokens = generate_responses_for_dataset(
[rank0]:                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/home/ray/default/SkyThought/skythought/evals/inference_and_check.py", line 250, in generate_responses_for_dataset
[rank0]:     responses = inference(
[rank0]:                 ^^^^^^^^^^
[rank0]:   File "/home/ray/default/SkyThought/skythought/evals/inference_and_check.py", line 193, in inference
[rank0]:     llm.chat(
[rank0]:   File "/home/ray/anaconda3/lib/python3.12/site-packages/vllm/entrypoints/llm.py", line 702, in chat
[rank0]:     conversation, mm_data = parse_chat_messages(
[rank0]:                             ^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/home/ray/anaconda3/lib/python3.12/site-packages/vllm/entrypoints/chat_utils.py", line 1030, in parse_chat_messages
[rank0]:     sub_messages = _parse_chat_message_content(
[rank0]:                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/home/ray/anaconda3/lib/python3.12/site-packages/vllm/entrypoints/chat_utils.py", line 981, in _parse_chat_message_content
[rank0]:     result = _parse_chat_message_content_parts(
[rank0]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/home/ray/anaconda3/lib/python3.12/site-packages/vllm/entrypoints/chat_utils.py", line 881, in _parse_chat_message_content_parts
[rank0]:     parse_res = _parse_chat_message_content_part(
[rank0]:                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/home/ray/anaconda3/lib/python3.12/site-packages/vllm/entrypoints/chat_utils.py", line 919, in _parse_chat_message_content_part
[rank0]:     part_type, content = _parse_chat_message_content_mm_part(part)
[rank0]:                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/home/ray/anaconda3/lib/python3.12/site-packages/vllm/entrypoints/chat_utils.py", line 823, in _parse_chat_message_content_mm_part
[rank0]:     assert isinstance(
[rank0]:            ^^^^^^^^^^^
[rank0]: AssertionError

The error itself is hard to read but the root cause is that model_config.system_prompt can be a string or a StringInFile object...Before passing it to the task handler, we need to read the string from the file/ get the underlying _string atttribute from StringInFile .

Signed-off-by: SumanthRH <sumanthrh@anyscale.com>
Signed-off-by: SumanthRH <sumanthrh@anyscale.com>
@SumanthRH SumanthRH marked this pull request as ready for review March 31, 2025 18:56
@SumanthRH SumanthRH requested a review from erictang000 March 31, 2025 18:57
@SumanthRH SumanthRH merged commit 2aa5847 into main Mar 31, 2025
2 checks passed
SumanthRH added a commit that referenced this pull request Apr 17, 2025
# What does this PR do?

Fixes an issue with null system prompt introduced in #104
yllkryeziu pushed a commit to yllkryeziu/adaptive-compute-rewrite that referenced this pull request Dec 12, 2025
…#104)

`model_config.system_prompt` can be a string or a `StringInFile` object...Before passing it to the task handler, we need to read the string from the file/ get the underlying `_string` atttribute from StringInFile
yllkryeziu pushed a commit to yllkryeziu/adaptive-compute-rewrite that referenced this pull request Dec 12, 2025
# What does this PR do?

Fixes an issue with null system prompt introduced in NovaSky-AI#104
lru0612 pushed a commit to lru0612/SkyThought that referenced this pull request Feb 24, 2026
…ult behavior on thinking tokens accumulation (#178)

In `ppo_base_config`, add `generator.chat_template` to allow users to
define custom chat template. This is particularly helpful for Qwen3
models, where you might want to keep the thinking tokens or remove them.

```.yaml
  chat_template:
    source: "name"  # "name" or "file"
    name_or_path: null  # e.g., "qwen3_with_thinking" or "/path/to/template.j2"
```

You can either specify a chat template defined in
`skyrl_train.generators.utils.CUSTOM_CHAT_TEMPLATES` (we currently have
`qwen3_with_thinking` and `qwen3_without_thinking`) or load from a file.

Before this PR, the behavior for Qwen3 models are that, they will not
keep the non-last turn thinking tokens and we always retokenize (every
turn and at the end of the trajectory).

After this PR, Qwen3 models by default will accumulate in a TI/TO
manner, just like any other models. Users can modify this behavior by
setting `name_or_path` to `qwen3_without_thinking` to keep the old
behavior.

Related to #179 and address NovaSky-AI#104

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Tyler Griggs <tgriggs@berkeley.edu>
Co-authored-by: Charlie Ruan <charlieruan@berkeley.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants