"vscode:/vscode.git/clone" did not exist on "2c5df5d2affc442f30a21ee628bfee89a3666cb5"
Unverified Commit a1766e4a authored by Neal Vaidya's avatar Neal Vaidya Committed by GitHub
Browse files

fix: use force_reasoning parser for nemotron_nano (#6288)


Signed-off-by: default avatarNeal Vaidya <nealv@nvidia.com>
parent e1078789
...@@ -39,6 +39,7 @@ Parser to Model Mapping ...@@ -39,6 +39,7 @@ Parser to Model Mapping
| llama3_json | meta-llama/Llama-3.1-*, meta-llama/Llama-3.2-* | | llama3_json | meta-llama/Llama-3.1-*, meta-llama/Llama-3.2-* |
| harmony | openai/gpt-oss-* | | harmony | openai/gpt-oss-* |
| nemotron_deci | nvidia/nemotron-* | | nemotron_deci | nvidia/nemotron-* |
| nemotron_nano | nvidia/NVIDIA-Nemotron-3-Nano-* |
| phi4 | Phi-4-* | | phi4 | Phi-4-* |
| deepseek_v3 | deepseek-ai/DeepSeek-V3, deepseek-ai/DeepSeek-R1, deepseek-ai/DeepSeek-R1-0528 | | deepseek_v3 | deepseek-ai/DeepSeek-V3, deepseek-ai/DeepSeek-R1, deepseek-ai/DeepSeek-R1-0528 |
| deepseek_v3_1 | deepseek-ai/DeepSeek-V3.1 | | deepseek_v3_1 | deepseek-ai/DeepSeek-V3.1 |
......
...@@ -949,6 +949,7 @@ impl OpenAIPreprocessor { ...@@ -949,6 +949,7 @@ impl OpenAIPreprocessor {
/// Check if reasoning parsing should be disabled based on per-request parameters. /// Check if reasoning parsing should be disabled based on per-request parameters.
/// For kimi_k25: disabled when chat_template_args contains "thinking": false. /// For kimi_k25: disabled when chat_template_args contains "thinking": false.
/// For nemotron_nano: disabled when chat_template_args contains "enable_thinking": false.
fn is_reasoning_disabled_by_request( fn is_reasoning_disabled_by_request(
reasoning_parser: Option<&str>, reasoning_parser: Option<&str>,
chat_template_args: Option<&std::collections::HashMap<String, serde_json::Value>>, chat_template_args: Option<&std::collections::HashMap<String, serde_json::Value>>,
...@@ -962,6 +963,14 @@ impl OpenAIPreprocessor { ...@@ -962,6 +963,14 @@ impl OpenAIPreprocessor {
} }
false false
} }
Some("nemotron_nano") => {
if let Some(args) = chat_template_args
&& let Some(enable_thinking) = args.get("enable_thinking")
{
return enable_thinking == &serde_json::Value::Bool(false);
}
false
}
_ => false, _ => false,
} }
} }
...@@ -1370,6 +1379,19 @@ mod tests { ...@@ -1370,6 +1379,19 @@ mod tests {
m.insert("thinking".to_string(), serde_json::Value::Bool(false)); m.insert("thinking".to_string(), serde_json::Value::Bool(false));
m m
}; };
let enable_thinking_true = {
let mut m = std::collections::HashMap::new();
m.insert("enable_thinking".to_string(), serde_json::Value::Bool(true));
m
};
let enable_thinking_false = {
let mut m = std::collections::HashMap::new();
m.insert(
"enable_thinking".to_string(),
serde_json::Value::Bool(false),
);
m
};
let empty_args = std::collections::HashMap::new(); let empty_args = std::collections::HashMap::new();
// (parser, args, expected_disabled, description) // (parser, args, expected_disabled, description)
...@@ -1416,6 +1438,31 @@ mod tests { ...@@ -1416,6 +1438,31 @@ mod tests {
false, false,
"no parser → never disabled", "no parser → never disabled",
), ),
// nemotron_nano uses "enable_thinking" key
(
Some("nemotron_nano"),
Some(&enable_thinking_false),
true,
"nemotron_nano + enable_thinking=false → disabled",
),
(
Some("nemotron_nano"),
Some(&enable_thinking_true),
false,
"nemotron_nano + enable_thinking=true → enabled",
),
(
Some("nemotron_nano"),
None,
false,
"nemotron_nano + no args → enabled",
),
(
Some("nemotron_nano"),
Some(&empty_args),
false,
"nemotron_nano + empty args → enabled",
),
]; ];
for (parser, args, expected, desc) in cases { for (parser, args, expected, desc) in cases {
......
...@@ -30,7 +30,7 @@ fn get_reasoning_parser_map() -> &'static HashMap<&'static str, ReasoningParserT ...@@ -30,7 +30,7 @@ fn get_reasoning_parser_map() -> &'static HashMap<&'static str, ReasoningParserT
map.insert("step3", ReasoningParserType::Step3); map.insert("step3", ReasoningParserType::Step3);
map.insert("mistral", ReasoningParserType::Mistral); map.insert("mistral", ReasoningParserType::Mistral);
map.insert("granite", ReasoningParserType::Granite); map.insert("granite", ReasoningParserType::Granite);
map.insert("nemotron_nano", ReasoningParserType::NemotronDeci); // nemotron nano is <think>...</think> map.insert("nemotron_nano", ReasoningParserType::DeepseekR1); // nemotron nano is ...</think>
map.insert("glm45", ReasoningParserType::NemotronDeci); // GLM-4.5/5 is <think>...</think>, no force_reasoning map.insert("glm45", ReasoningParserType::NemotronDeci); // GLM-4.5/5 is <think>...</think>, no force_reasoning
map.insert( map.insert(
"minimax_append_think", "minimax_append_think",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment