Skip to content

fix(trt): replace STRONGLY_TYPED with BuilderFlag.FP8/INT8 to restore throughput#56

Closed
ivanbasov wants to merge 5 commits into
NVIDIA:mainfrom
ivanbasov:fix/trt-strongly-typed-perf-regression
Closed

fix(trt): replace STRONGLY_TYPED with BuilderFlag.FP8/INT8 to restore throughput#56
ivanbasov wants to merge 5 commits into
NVIDIA:mainfrom
ivanbasov:fix/trt-strongly-typed-perf-regression

Conversation

@ivanbasov
Copy link
Copy Markdown
Member

@ivanbasov ivanbasov commented Apr 8, 2026

Summary

  • Root cause: commit d7b8217 (Ising-Decoding, squash-merged as 993e797 here) added STRONGLY_TYPED to TRT network flags alongside Conv-only FP8 QDQ nodes, causing a ~25–35% throughput regression (66 µs → 90 µs at d=13, T=104).
  • Why it regresses: Under STRONGLY_TYPED, TRT enforces every FP16↔FP8 cast boundary inserted by modelopt around Conv layers — preventing Conv+BN+ReLU fusion and adding ~7–11 extra cast kernels per forward pass, each touching the full activation tensor.
  • Fix: Remove STRONGLY_TYPED from net_flags; use BuilderFlag.FP8/BuilderFlag.INT8 instead. QDQ nodes become calibration hints (TRT still selects FP8 kernels for Conv), but TRT is free to fuse across layer boundaries. BuilderFlag.FP16 is always enabled as fallback precision.

Note: PR #52 (fix export of fp8 ONNX files) addressed a different bug (calibration data dtype) and did not fix this regression.

Changes

  • code/evaluation/logical_error_rate.py: remove STRONGLY_TYPED bit; add BuilderFlag.FP8/INT8/FP16 per quant path with explanatory comment
  • code/tests/test_tensorrt_fallback.py: add TestTrtBuilderPrecisionFlags (6 tests)
    • source-code grep guard — asserts STRONGLY_TYPED is never OR'd into net_flags
    • mock-based flag tests for fp8, int8, and unquantized paths
    • net_flags bit tests confirming STRONGLY_TYPED absent for fp8 and int8

Test plan

  • All 13 CPU tests in test_tensorrt_fallback.py pass (verified locally)
  • Regenerate FP8 TRT engine at d=13, T=104 (ONNX_WORKFLOW=2 QUANT_FORMAT=fp8) and benchmark latency — target ≤ 66 µs
  • Check [LER] TensorRT engine layer precisions: log — expect higher FP8 layer count vs pre-fix
  • Verify on both reported models (consistent regression on two models per the issue)

🤖 Generated with Claude Code

ivanbasov and others added 5 commits March 30, 2026 11:54
…fault

torch.compile=on combined with DataLoader spawn workers during LER
validation causes a segfault (20 leaked semaphores, core dumped).
Set PREDECODER_TORCH_COMPILE=0 for the Train all orientations step.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… throughput

STRONGLY_TYPED + Conv-only FP8 QDQ nodes (introduced in d7b8217/993e797)
caused a ~25-35% throughput regression (66 µs → 90 µs at d=13, T=104).

Under STRONGLY_TYPED TRT must honour every explicit FP16↔FP8 cast boundary
inserted by modelopt around Conv layers, which:
  - prevents Conv+BN+ReLU fusion across layer boundaries
  - adds ~7-11 extra cast kernels per forward pass (one pair per Conv layer)
  - each cast touches the full (B×C×T×D×D) activation tensor

Fix: remove STRONGLY_TYPED from net_flags; replace with BuilderFlag.FP8/INT8.
QDQ nodes now act as calibration hints rather than hard type constraints,
restoring TRT's freedom to fuse across precision boundaries.
FP16 is always set as fallback precision for all paths.

Add TestTrtBuilderPrecisionFlags in test_tensorrt_fallback.py:
  - source-code grep guard: asserts STRONGLY_TYPED is never OR'd into net_flags
  - mock-based tests: fp8→FP8+FP16, int8→INT8+FP16, unquantized→FP16 only
  - net_flags bit tests: STRONGLY_TYPED bit absent for both fp8 and int8

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add background, fix rationale, and tradeoff note to the inline comment
so reviewers and future readers understand why STRONGLY_TYPED is absent
and what to check when verifying the fix (layer precision log).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bmhowe23
Copy link
Copy Markdown
Collaborator

We tried this out, and I don't think it helped, so I am closing this for now. We can reopen if necessary.

@bmhowe23 bmhowe23 closed this Apr 13, 2026
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