TensorRT-LLM icon indicating copy to clipboard operation
TensorRT-LLM copied to clipboard

[Bug]: Structured Output with DSpark Speculative Drafter

Open chungen04 opened this issue 4 months ago • 0 comments

System Info

v1.3.0rc22 release container

Who can help?

No response

Information

  • [ ] The official example scripts
  • [x] My own modified scripts

Tasks

  • [ ] An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • [x] My own task or dataset (give details below)

Reproduction

Launch trtllm with (replace with your weight dir) :

docker run -d --name dspark --gpus '"device=0"' --ipc=host --ulimit memlock=-1 --shm-size=16g -v /data:/data -p 8000:8000 nvcr.io/nvidia/tensorrt-llm/release:1.3.0rc22 trtllm-serve serve <weight_dir> --served_model_name=deepseek-ai/DeepSeek-V4-Flash --backend=pytorch --tp_size=1 --ep_size=1 --max_seq_len=163840 --max_num_tokens=16384 --max_batch_size=72 --enable_chunked_prefill --trust_remote_code --custom_tokenizer=deepseek_v4 --host=0.0.0.0 --port=8000 --extra_llm_api_options dspark.json

with dspark.json:

{"print_iter_log":true,"kv_cache_config":{"tokens_per_block":128,"host_cache_size":0,"dtype":"fp8","free_gpu_memory_fraction":0.85,"enable_block_reuse":true,"enable_partial_reuse":false},"sampler_type":"auto","scheduler_config":{"capacity_scheduler_policy":"MAX_UTILIZATION","waiting_queue_policy":"priority"},"speculative_config":{"decoding_type":"DSpark","max_draft_len":5,"speculative_model":"<weight_dir>"},"cuda_graph_config":{"enable_padding":true},"moe_config":{"backend":"TRTLLM"},"guided_decoding_backend":"xgrammar","disable_overlap_scheduler":true}

After the engine launch, request the engine with:

curl -s -X POST http://localhost:8000/v1/chat/completions -H 'Content-Type: application/json' -d '{"model":"deepseek-ai/DeepSeek-V4-Flash","messages":[{"role":"user","content":"Describe machine learning in one paragraph, then rate its difficulty."}],"response_format":{"type":"json_schema","json_schema":{"name":"desc","strict":true,"schema":{"type":"object","additionalProperties":false,"properties":{"topic":{"type":"string"},"level":{"type":"string","enum":["beginner","intermediate","advanced"]},"score":{"type":"integer"}},"required":["topic","level","score"]}}},"max_tokens":160,"temperature":0.7}'

Response (this can be stochastic since the 0.7 temperature):

{"id":"chatcmpl-57439ca490474f97a0f3f366217c28fc","object":"chat.completion","created":1785260834,"model":"deepseek-ai/DeepSeek-V4-Flash","choices":[{"index":0,"message":{"role":"assistant","content":"{\n  \"topic\": \"Machine learning\",\n  \"level\": \"intermediate\"\n}\n\nMachine learning is a subset of artificial intelligence that enables computers to learn patterns and make decisions from data without being explicitly programmed for every task. Instead of following rigid, hand-coded rules, algorithms are trained on large datasets, adjusting their internal parameters to minimize errors in predictions or classifications. This process allows systems to improve over time, powering applications like spam filters, recommendation engines, and self-driving cars.\n\n**Difficulty rating:** Intermediate. Understanding the core concept is straightforward, but mastering the underlying mathematics (linear algebra, calculus, probability), algorithm selection, and practical implementation requires significant study and experience.","reasoning_content":"","reasoning":null,"tool_calls":[]},"logprobs":null,"finish_reason":"stop","stop_reason":null,"mm_embedding_handle":null,"disaggregated_params":null,"avg_decoded_tokens_per_iter":2.914893627166748}],"usage":{"prompt_tokens":16,"total_tokens":153,"completion_tokens":137,"prompt_tokens_details":{"cached_tokens":0}},"prompt_token_ids":null,"prompt_token_ids_b64":null}

Expected behavior

Following the schema indicated in the request.

actual behavior

In the above example, the score field in the response is not present and violating the schema.

additional notes

N/A

Before submitting a new issue...

  • [x] Make sure you already searched for relevant issues, and checked the documentation and examples for answers to frequently asked questions.

chungen04 avatar Jul 28 '26 18:07 chungen04