KEMBAR78
[https://nvbugs/5369366] [fix] Report failing requests by arekay · Pull Request #7060 · NVIDIA/TensorRT-LLM · GitHub
Skip to content

Conversation

@arekay
Copy link
Contributor

@arekay arekay commented Aug 19, 2025

This PR makes failures in benchmark_serving.py more verbose. Prior to this change, the benchmark serving script would quietly consume the errors and the only indication is that the successful requests does not equal the total requests. This masks some key issues, one of which is the connection exhaustion when serving models. For instance, on llama2, running 64K requests on the client and server on the same node leads to around 30K failures - all due to the client not able to connect to the server due to port exhaustion.

Summary by CodeRabbit

  • New Features / Enhancements
    • Request outputs now include exception type for clearer error context.
    • Benchmarks record and display per-exception counts and total error count.
    • Progress bar labeled “Benchmarking” for clarity.
    • Benchmark summary shows total, successful, and failed request counts.
    • Prominent failure banners emitted when failures occur to aid troubleshooting.
    • Added debug printing for non-200 HTTP responses to assist diagnosis.

Description

Test Coverage

GitHub Bot Help

/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...

Provide a user friendly way for developers to interact with a Jenkins server.

Run /bot [-h|--help] to print this help message.

See details below for each supported subcommand.

run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental)]

Launch build/test pipelines. All previously running jobs will be killed.

--reuse-test (optional)pipeline-id (OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.

--disable-reuse-test (OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.

--disable-fail-fast (OPTIONAL) : Disable fail fast on build/tests/infra failures.

--skip-test (OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.

--stage-list "A10-PyTorch-1, xxx" (OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.

--gpu-type "A30, H100_PCIe" (OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.

--test-backend "pytorch, cpp" (OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.

--only-multi-gpu-test (OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.

--disable-multi-gpu-test (OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.

--add-multi-gpu-test (OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.

--post-merge (OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.

--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" (OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".

--detailed-log (OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.

--debug (OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in the stage-list parameter to access the appropriate container environment. Note: Does NOT update GitHub check status.

For guidance on mapping tests to stage names, see docs/source/reference/ci-overview.md
and the scripts/test_to_stage_mapping.py helper.

kill

kill

Kill all running builds associated with pull request.

skip

skip --comment COMMENT

Skip testing for latest commit on pull request. --comment "Reason for skipping build/test" is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

reuse-pipeline

reuse-pipeline

Reuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

Signed-off-by: Rashid Kaleem <4079439+arekay@users.noreply.github.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 19, 2025

📝 Walkthrough

Walkthrough

Adds an exception_type field to RequestFuncOutput and populates it when exceptions occur in async request functions. Adds a debug print for OpenAI non-200 responses and a TODO comment. Enhances benchmark metrics to count failures by exception type, shows per-exception and total failed counts, and sets a progress description.

Changes

Cohort / File(s) Summary of Changes
Backend request error reporting
tensorrt_llm/serve/scripts/backend_request_func.py
Added exception_type: str = None to RequestFuncOutput. In async_request_trt_llm, async_request_openai_completions, and async_request_openai_chat_completions catch exceptions as e and set output.exception_type = e.__class__.__name__. Added a debug print for non-200 OpenAI completions responses and a TODO comment about storing status code.
Benchmark metrics and logging
tensorrt_llm/serve/scripts/benchmark_serving.py
calculate_metrics now accumulates error_counts keyed by exception_type and logs per-exception counts plus total failed requests. benchmark() sets tqdm description desc="Benchmarking". Result summary output expanded to show total/success/failed and prints banners when failures exist. No public API changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Caller
  participant RequestFunc as async_request_*
  participant Backend

  Caller->>RequestFunc: invoke async request
  alt Success
    RequestFunc->>Backend: perform HTTP/SDK call
    Backend-->>RequestFunc: 200 + payload
    RequestFunc-->>Caller: RequestFuncOutput(result, exception_type=None)
  else Non-200 (OpenAI completions)
    RequestFunc->>RequestFunc: print "HTTP Error <status>: <response>"
    RequestFunc-->>Caller: RequestFuncOutput(result=None, exception_type=None)
  else Exception
    RequestFunc->>RequestFunc: catch Exception as e
    RequestFunc->>RequestFunc: set output.exception_type = e.__class__.__name__
    RequestFunc-->>Caller: RequestFuncOutput(result=None, exception_type)
  end
  note right of RequestFunc: TODO: store status code for debugging (chat completions)
Loading
sequenceDiagram
  autonumber
  participant Benchmark
  participant Progress as tqdm
  participant Metrics as calculate_metrics
  participant Outputs

  Benchmark->>Progress: create progress (desc="Benchmarking")
  Benchmark->>Metrics: compute metrics from outputs
  loop per output
    Metrics->>Outputs: read output[i]
    alt output.exception_type present
      Metrics->>Metrics: increment error_counts[exception_type]
    else
      Metrics->>Metrics: count success/completed
    end
  end
  Metrics-->>Benchmark: return metrics (completed, latencies, error_counts)
  Benchmark->>Benchmark: print totals, per-exception counts, and failed count
  alt failures exist
    Benchmark->>Benchmark: print failure banners and guidance
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • qiaoxj07

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d023f7f and 9ba5da2.

📒 Files selected for processing (2)
  • tensorrt_llm/serve/scripts/backend_request_func.py (4 hunks)
  • tensorrt_llm/serve/scripts/benchmark_serving.py (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • tensorrt_llm/serve/scripts/backend_request_func.py
  • tensorrt_llm/serve/scripts/benchmark_serving.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Pre-commit Check
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@arekay arekay requested a review from Tabrizian August 19, 2025 19:26
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
tensorrt_llm/serve/scripts/backend_request_func.py (2)

1-4: Add NVIDIA copyright header (2025) and consider postponed annotations for Py3.8.

Per coding guidelines, prepend the NVIDIA copyright header. Also, this file uses PEP 585 generics (e.g., list[float]) which require Python 3.9+, or from future import annotations for 3.8. Add the future import to avoid runtime issues on 3.8.

Example header and future import to add at the very top of the file (outside the selected lines):

# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
from __future__ import annotations

264-271: Populate exception_type on HTTP errors and in the exception path; include response details.

  • Non-200 branch only prints but does not set exception_type, so HTTP failures won’t be counted downstream.
  • The except clause does not bind the exception and thus cannot set exception_type. This also contradicts the PR summary.
-            else:
-                print(f"HTTP Error {response.status}: {response}")
-                output.error = response.reason or ""
-                output.success = False
-    except Exception:
+            else:
+                # Log and capture HTTP failure type and reason/body (truncated).
+                body = await response.text()
+                print(f"HTTP Error {response.status}: {response.reason or ''} | Body: {body[:512]}")
+                output.error = f"{response.status} {response.reason or ''}"
+                output.exception_type = f"HTTP_{response.status}"
+                output.success = False
+    except Exception as e:
         output.success = False
         exc_info = sys.exc_info()
         output.error = "".join(traceback.format_exception(*exc_info))
+        output.exception_type = e.__class__.__name__
tensorrt_llm/serve/scripts/benchmark_serving.py (1)

1-4: Add NVIDIA copyright header (2025) and consider postponed annotations for Py3.8.

Same as the other file: prepend the NVIDIA header and add from future import annotations to keep Python 3.8 compatibility with PEP 585 generics used throughout.

Example to add at the very top:

# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
from __future__ import annotations
🧹 Nitpick comments (5)
tensorrt_llm/serve/scripts/backend_request_func.py (2)

49-49: Make exception_type Optional[str] to reflect None default.

The field defaults to None but is typed as str. Use Optional[str] for correctness and clarity.

-    exception_type: str = None  # unset
+    exception_type: Optional[str] = None  # Unset unless a failure occurs

136-141: Consider narrowing exception handling to aiohttp/asyncio/JSON errors.

Catching Exception is pragmatic here, but for better signal and to avoid swallowing unexpected bugs, consider catching narrower exceptions (e.g., aiohttp.ClientError, asyncio.TimeoutError, json.JSONDecodeError) and re-raising unexpected ones.

If you want, I can prep a follow-up patch that narrows the exceptions and adds structured logging hooks.

Also applies to: 268-271, 401-406

tensorrt_llm/serve/scripts/benchmark_serving.py (3)

186-195: Remove duplicated logging and print once (optionally sorted).

This block is repeated twice verbatim. Consolidate into a single section and consider sorting by count for readability.

-    total_error_count = sum(error_counts.values())
-    for exception_type, count in error_counts.items():
-        print(f"Error type: {exception_type}, Count: {count} requests")
-    print(f"Total failed requests: {total_error_count}")
-
-    total_error_count = sum(error_counts.values())
-    for exception_type, count in error_counts.items():
-        print(f"Error type: {exception_type}, Count: {count} requests")
-    print(f"Total failed requests: {total_error_count}")
+    if error_counts:
+        total_error_count = sum(error_counts.values())
+        for exception_type, count in sorted(error_counts.items(),
+                                            key=lambda kv: kv[1],
+                                            reverse=True):
+            print(f"Error type: {exception_type}, Count: {count} requests")
+        print(f"Total failed requests: {total_error_count}")

451-455: Nice addition of totals; consider reusing failed_count.

These prints are helpful. You can compute failed_count once here and reuse it below for the banner section to avoid recalculating.

-    print("{:<40} {:<10}".format("Total requests:", len(outputs)))
-    print("{:<40} {:<10}".format("Successful requests:", metrics.completed))
-    print("{:<40} {:<10}".format("Failed requests:",
-                                 len(outputs) - metrics.completed))
+    failed_count = len(outputs) - metrics.completed
+    print("{:<40} {:<10}".format("Total requests:", len(outputs)))
+    print("{:<40} {:<10}".format("Successful requests:", metrics.completed))
+    print("{:<40} {:<10}".format("Failed requests:", failed_count))

476-482: Failure banners are helpful; consider printing the per-type counts here too.

The banners draw attention to failures (good). Consider also emitting the per-type summary here (or return it in the result dict) to avoid scrolling back. This pairs well with setting exception_type for HTTP failures in the request functions.

If you want, I can wire error_counts into the returned result (e.g., errors_by_type) and add conditional printing here.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0e30fe4 and 0ac5ccc.

📒 Files selected for processing (2)
  • tensorrt_llm/serve/scripts/backend_request_func.py (4 hunks)
  • tensorrt_llm/serve/scripts/benchmark_serving.py (5 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)

**/*.py: Python code must target Python 3.8+
Python indentation: 4 spaces, no tabs
Maintain module namespace in imports (from package.subpackage import foo; then use foo.SomeClass())
Python file names use snake_case
Python class names use PascalCase
Python functions/methods and local variables use snake_case; variables starting with a number get k_ prefix (e.g., k_99th_percentile)
Global variables use G_ prefixed UPPER_SNAKE_CASE (e.g., G_MY_GLOBAL)
Constants use UPPER_SNAKE_CASE in Python
Avoid shadowing variables from outer scopes in Python
Initialize all externally visible members of a Python class in init
Prefer docstrings for interfaces used outside a file; comments for local code
Use Google-style docstrings for classes and functions (Sphinx-parsable)
Document attributes/variables inline with short docstrings
Avoid reflection when simple alternatives exist (e.g., prefer explicit parameters over dict(**locals()))
In try/except, catch the narrowest exceptions possible
For duck-typing with try/except, keep try body minimal and put logic in else

Files:

  • tensorrt_llm/serve/scripts/benchmark_serving.py
  • tensorrt_llm/serve/scripts/backend_request_func.py
**/*.{cpp,cxx,cc,cu,h,hpp,hxx,hh,cuh,py}

📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)

Prepend NVIDIA copyright header (current year) to all source files

Files:

  • tensorrt_llm/serve/scripts/benchmark_serving.py
  • tensorrt_llm/serve/scripts/backend_request_func.py
🔇 Additional comments (1)
tensorrt_llm/serve/scripts/benchmark_serving.py (1)

353-355: Progress bar description addition looks good.

Adding desc="Benchmarking" improves UX without affecting logic.

@Tabrizian
Copy link
Member

@arekay Can you share an example output in the PR description too?

@kaiyux Do you mind reviewing these changes too if possible?

Signed-off-by: Rashid Kaleem <4079439+arekay@users.noreply.github.com>
@arekay
Copy link
Contributor Author

arekay commented Aug 27, 2025

@arekay Can you share an example output in the PR description too?

@kaiyux Do you mind reviewing these changes too if possible?

@Tabrizian Here is what the output looks like with failing requests:

Benchmarking: 100%|████████████████████████████████████████████████████████████████████████████████████████████| 64000/64000 [23:55<00:00, 44.59it/s]
Error type: ClientConnectorError, Count: 35787 requests
Total failed requests: 35787
============ Serving Benchmark Result ============
Total requests:                          64000     
Successful requests:                     28213     
Failed requests:                         35787     
Benchmark duration (s):                  1435.15   
Total input tokens:                      28890112  
Total generated tokens:                  3479543   
Request throughput (req/s):              19.66     
Output token throughput (tok/s):         2424.51   
Total Token throughput (tok/s):          22554.84  
User throughput (tok/s):                 0.23      
Avg Decoded Tokens per Iter:             1.00      
=======================!FAILED REQUESTS!=======================
Total failed requests: 35787
=====================!CHECK LOG FOR ERRORS!====================
---------------Time to First Token----------------
Mean TTFT (ms):                          767304.75 
Median TTFT (ms):                        767938.88 
P99 TTFT (ms):                           1411342.85
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          139.10    
Median TPOT (ms):                        145.14    
P99 TPOT (ms):                           159.47    
---------------Inter-token Latency----------------
Mean ITL (ms):                           137.96    
Median ITL (ms):                         144.34    
P99 ITL (ms):                            408.32    

arekay added 2 commits August 26, 2025 22:48
Signed-off-by: Rashid Kaleem <4079439+arekay@users.noreply.github.com>
@arekay arekay changed the title [https://nvbugs/5369366] [Visibility] Report failing requests [https://nvbugs/5369366] [fix] Report failing requests Aug 27, 2025
@arekay
Copy link
Contributor Author

arekay commented Aug 27, 2025

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #16727 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #16727 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #12555 completed with status: 'SUCCESS'
Pipeline passed with automatic retried tests. Check the rerun report for details.

@arekay arekay requested a review from kaiyux September 3, 2025 02:31
@Tabrizian Tabrizian merged commit 89889fb into NVIDIA:main Sep 4, 2025
5 of 6 checks passed
Wong4j pushed a commit to Wong4j/TensorRT-LLM that referenced this pull request Sep 20, 2025
Signed-off-by: Rashid Kaleem <4079439+arekay@users.noreply.github.com>
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.

3 participants