Skip to content

[AMD] Fix AttributeError in GeneratedSharedPrefixDataset.from_args for in-process callers - #27580

Merged
HaiShaw merged 1 commit into
sgl-project:mainfrom
michaelzhang-ai:fix/gsp-from-args-missing-attr
Jun 9, 2026
Merged

HaiShaw merged 1 commit into
sgl-project:mainfrom
michaelzhang-ai:fix/gsp-from-args-missing-attr

Conversation

@michaelzhang-ai

@michaelzhang-ai michaelzhang-ai commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Restore-only fix — no new logic and no behavior change. It reverts two fields back to the pre-existing getattr(args, ..., default) convention used everywhere else in this file; see Modifications.

Motivation

The 1-GPU nightly tests fail in test/registered/bench_fn/test_bench_serving_functionality.py::test_gsp_multi_turn with:

File ".../sglang/benchmark/datasets/generated_shared_prefix.py", line 58, in from_args
    group_distribution = args.gsp_group_distribution
AttributeError: 'types.SimpleNamespace' object has no attribute 'gsp_group_distribution'

GeneratedSharedPrefixDataset.from_args reads args.gsp_group_distribution and args.gsp_zipf_alpha via direct attribute access. These options have argparse defaults ("uniform" / None) on the bench_serving.py CLI, but in-process callers that build a SimpleNamespace through get_benchmark_args (e.g. test_gsp_multi_turn) never set them, so the access raises before the method's own defensive validation can run. Every other optional gsp_* field in from_args already uses getattr(args, ..., default), and the method's comment states it is meant to tolerate hand-built Namespaces.

This is shared benchmark-client code and the test is registered for both suites (register_cuda_ci + register_amd_ci), so it breaks both 1-GPU nightlies:

Nightly suite Job Failing run Result
Nightly Test (AMD) nightly-test-1-gpu-unit https://github.com/sgl-project/sglang/actions/runs/27100228380/job/80040799251 9/10 ✗
Nightly Test (Nvidia) nightly-test-general-1-gpu-h100 https://github.com/sgl-project/sglang/actions/runs/27110545438/job/80007477055 19/20 ✗

Regression

Introduced by #26378 (commit f838adb, merged 2026-05-28), which added the gsp_group_distribution / gsp_zipf_alpha feature. That PR added the argparse options (with defaults) and the hard attribute access in from_args, but did not update get_benchmark_args in python/sglang/test/test_utils.py. Because test_gsp_multi_turn is registered nightly-only, it does not run in pre-merge PR CI, so the break only surfaced in the scheduled nightlies after the merge. cc @Jiminator

Modifications

Restore-only — not a new code change. This puts the two GSP fields back on the getattr(args, ..., default) convention that the rest of from_args (and #19363, "remove args dependency") already use. #26378 was the only place that deviated to direct attribute access; this reverts that one deviation:

-        group_distribution = args.gsp_group_distribution
-        zipf_alpha = args.gsp_zipf_alpha
+        group_distribution = getattr(args, "gsp_group_distribution", "uniform")
+        zipf_alpha = getattr(args, "gsp_zipf_alpha", None)

No behavior change for existing usage: the CLI/argparse path always supplies these attributes, so getattr returns exactly the same values, and the defaults ("uniform" / None) match both the argparse defaults and the feature's own test helper (make_args). The only difference is that an in-process Namespace that omits the fields now defaults (as the sibling fields already do) instead of raising AttributeError.

Accuracy Tests

N/A — does not affect model outputs (benchmark-client arg handling only).

Speed Tests and Profiling

N/A — pure arg-handling bugfix.

Verification

  • Local repro with the exact SimpleNamespace that test_gsp_multi_turn builds via get_benchmark_args(...): before → AttributeError: ... 'gsp_group_distribution'; after → GeneratedSharedPrefixDataset(..., group_distribution='uniform', zipf_alpha=None).
  • AMD CI dispatch on this branch (nightly-test-amd.yml, nightly-test-1-gpu-unit): https://github.com/sgl-project/sglang/actions/runs/27150321984/job/8013931314910/10 passed (test_bench_serving_functionality.py now passes; previously 9/10).

Checklist


CI States

Latest PR Test (Base): ❌ Run #27149657199
Latest PR Test (Extra): 🚫 Run #27153205907

…for in-process callers

`from_args` read `args.gsp_group_distribution` and `args.gsp_zipf_alpha` via
direct attribute access. These have argparse defaults ("uniform" / None) on the
CLI, but in-process callers that build a SimpleNamespace via `get_benchmark_args`
(e.g. test_gsp_multi_turn) do not set them, so the access raised:

    AttributeError: 'types.SimpleNamespace' object has no attribute
    'gsp_group_distribution'

This broke the nightly `test_bench_serving_functionality.py::test_gsp_multi_turn`
on both the AMD and CUDA nightly suites. Every other optional gsp_* field in the
same method already uses getattr() with a default, and the method's own comment
states it is meant to tolerate hand-built Namespaces.

Read the two fields with getattr() using the argparse defaults, matching the
sibling fields and the documented intent.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@michaelzhang-ai michaelzhang-ai changed the title [bench] Fix AttributeError in GeneratedSharedPrefixDataset.from_args for in-process callers [AMD] Fix AttributeError in GeneratedSharedPrefixDataset.from_args for in-process callers Jun 8, 2026
@michaelzhang-ai

Copy link
Copy Markdown
Collaborator Author

Heads-up @Jiminator: this fixes a regression from #26378. That PR added gsp_group_distribution / gsp_zipf_alpha and reads them in GeneratedSharedPrefixDataset.from_args via direct attribute access, but get_benchmark_args in python/sglang/test/test_utils.py was not updated to provide them. As a result the nightly-only test_gsp_multi_turn has been failing on both the AMD and NVIDIA 1-GPU nightlies since 2026-05-28 (it doesn't run in pre-merge PR CI).

Fix here switches the two reads to getattr(..., default) matching the argparse defaults and the other gsp_* fields. Verified on an AMD nightly dispatch (10/10). Could you take a look?

@Jiminator

Copy link
Copy Markdown
Collaborator

/tag-and-rerun-ci

@Jiminator

Jiminator commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

/rerun-test test/registered/bench_fn/test_bench_serving_functionality.py::TestBenchServingFunctionality.test_gsp_multi_turn

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Results for /rerun-test test/registered/bench_fn/test_bench_serving_functionality.py::TestBenchServingFunctionality.test_gsp_multi_turn:

🚀 1-gpu-h100 (1 test): ✅ View workflow run

cd test/ && python3 registered/bench_fn/test_bench_serving_functionality.py TestBenchServingFunctionality.test_gsp_multi_turn

@Jiminator Jiminator self-assigned this Jun 8, 2026

@Jiminator Jiminator left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, thank you for catching this @michaelzhang-ai

@alisonshao

Copy link
Copy Markdown
Collaborator

closing other pr #27623, same fix

@HaiShaw
HaiShaw merged commit a32aeb6 into sgl-project:main Jun 9, 2026
474 of 581 checks passed
@michaelzhang-ai
michaelzhang-ai deleted the fix/gsp-from-args-missing-attr branch June 9, 2026 05:26
Fridge003 pushed a commit that referenced this pull request Jun 10, 2026
…dSharedPrefixDataset.from_args for in-process callers (#27580) (#27754)

Co-authored-by: Michael <13900043+michaelzhang-ai@users.noreply.github.com>
Chronostasys pushed a commit to MindLab-Research/sglang that referenced this pull request Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants