Skip to content

fix(sglang): add enable_trace to diffusion worker ServerArgs stub#8332

Merged
KrishnanPrash merged 2 commits into
mainfrom
kprashanth/dyn-2711
Apr 20, 2026
Merged

fix(sglang): add enable_trace to diffusion worker ServerArgs stub#8332
KrishnanPrash merged 2 commits into
mainfrom
kprashanth/dyn-2711

Conversation

@KrishnanPrash
Copy link
Copy Markdown
Contributor

@KrishnanPrash KrishnanPrash commented Apr 17, 2026

Overview:

The SimpleNamespace stub created for image/video diffusion workers omitted enable_trace, causing BaseGenerativeHandler() to crash with AttributeError before health check. Add the field to the stub and use getattr() defensively in both BaseGenerativeHandler and BaseWorkerHandler.

Details:

  • Fixes text-to-video and image diffusion worker startup crash (AttributeError on enable_trace)
  • Adds enable_trace to the SimpleNamespace stub in args.py for diffusion workers
  • Uses defensive getattr() in both BaseGenerativeHandler.__init__ and BaseWorkerHandler.__init__

Where should the reviewer start?

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

  • closes GitHub issue: #xxx

Fixes DYN-2711


Open with Devin

Summary by CodeRabbit

  • Bug Fixes
    • Fixed potential errors in trace configuration handling to ensure stable operation when trace settings are unavailable.
    • Improved robustness of trace flag initialization during worker startup to prevent missing attribute errors.

worker ServerArgs stub

Signed-off-by: Krishnan Prashanth <kprashanth@nvidia.com>
@KrishnanPrash KrishnanPrash requested review from a team as code owners April 17, 2026 23:07
@github-actions github-actions Bot added fix backend::sglang Relates to the sglang backend labels Apr 17, 2026
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 17, 2026

Walkthrough

Two files modified to handle the enable_trace configuration attribute more defensively. The first file now sets enable_trace when constructing minimal ServerArgs stubs for diffusion/video workers. The second file uses getattr with default values to safely access enable_trace in handler classes, preventing AttributeError exceptions.

Changes

Cohort / File(s) Summary
Enable Trace Configuration
components/src/dynamo/sglang/args.py, components/src/dynamo/sglang/request_handlers/handler_base.py
Sets enable_trace attribute when initializing ServerArgs and uses defensive getattr access with False default in BaseGenerativeHandler and BaseWorkerHandler init methods to safely handle missing attribute.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding enable_trace to the diffusion worker ServerArgs stub, which directly aligns with the primary fix in the changeset.
Description check ✅ Passed The description comprehensively addresses the template sections, clearly explaining the problem, the changes made, and the impact, though it does not specify which files reviewers should prioritize.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
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.

🧹 Nitpick comments (1)
components/src/dynamo/sglang/request_handlers/handler_base.py (1)

147-147: Keep the enable_trace fallback in one documented place.

BaseWorkerHandler.__init__ already calls BaseGenerativeHandler.__init__, so Line 702 repeats the same assignment. Since this defensive getattr() is intentionally handling partial ServerArgs stubs, add the rationale once near Line 147 and remove the duplicate.

♻️ Proposed cleanup
         """
         self.config = config
+        # Some diffusion/video workers pass a minimal ServerArgs-like stub, so
+        # enable_trace may be absent even though real ServerArgs defines it.
         self.enable_trace = getattr(config.server_args, "enable_trace", False)
         self.serving_mode = config.serving_mode
         self.use_sglang_tokenizer = config.dynamo_args.use_sglang_tokenizer
-        self.enable_trace = getattr(config.server_args, "enable_trace", False)
 
         if engine is not None:

As per coding guidelines, “NO defensive getattr() on known types” should be generally avoided, but is likely justified here because the repository uses minimal/partial ServerArgs stubs; ensure the code comment or surrounding logic makes that rationale explicit.

Also applies to: 702-702

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/src/dynamo/sglang/request_handlers/handler_base.py` at line 147,
The duplicate defensive getattr assignment for enable_trace should be
centralized and documented: remove the repeated assignment in
BaseWorkerHandler.__init__ (the line at/around where enable_trace is set again)
and keep the single getattr(config.server_args, "enable_trace", False) in
BaseGenerativeHandler.__init__ (around the existing assignment at Line 147),
adding a short comment explaining that this defensive getattr is intentional to
support partial ServerArgs stubs; ensure all callers rely on the single
documented assignment and run tests to confirm no regressions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@components/src/dynamo/sglang/request_handlers/handler_base.py`:
- Line 147: The duplicate defensive getattr assignment for enable_trace should
be centralized and documented: remove the repeated assignment in
BaseWorkerHandler.__init__ (the line at/around where enable_trace is set again)
and keep the single getattr(config.server_args, "enable_trace", False) in
BaseGenerativeHandler.__init__ (around the existing assignment at Line 147),
adding a short comment explaining that this defensive getattr is intentional to
support partial ServerArgs stubs; ensure all callers rely on the single
documented assignment and run tests to confirm no regressions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: eb7ea119-3dd7-4a9d-a2cb-a055627f46ce

📥 Commits

Reviewing files that changed from the base of the PR and between d94b350 and ffdc2a3.

📒 Files selected for processing (2)
  • components/src/dynamo/sglang/args.py
  • components/src/dynamo/sglang/request_handlers/handler_base.py

Copy link
Copy Markdown
Contributor

@furionw furionw left a comment

Choose a reason for hiding this comment

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

Thank you.

@KrishnanPrash KrishnanPrash merged commit 1d154dc into main Apr 20, 2026
75 checks passed
@KrishnanPrash KrishnanPrash deleted the kprashanth/dyn-2711 branch April 20, 2026 10:02
KrishnanPrash added a commit that referenced this pull request Apr 20, 2026
)

Signed-off-by: Krishnan Prashanth <kprashanth@nvidia.com>
nv-nmailhot pushed a commit that referenced this pull request Apr 21, 2026
) (#8361)

Signed-off-by: Krishnan Prashanth <kprashanth@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend::sglang Relates to the sglang backend fix size/XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants