sgl-project/sglang · error · ValueError
{} did not declare component use: {}
Error message
{} did not declare component use: {} What it means
Stages must declare component usage (e.g. transformer/text-encoder use sites) up front via declared component-use records; _declared_component_use looks up a declared use by component_name (+optional phase, target_dtype) and raises if none matches.
Source
Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/base.py:217
def _declared_component_use(
self,
*,
component_name: str,
phase: str | None = None,
target_dtype: torch.dtype | None = None,
) -> ComponentUse:
manager = self._component_residency_manager
stage_name = self._active_component_stage_name()
server_args = manager.server_args if manager is not None else self.server_args
for use in self.component_uses(server_args, stage_name):
if use.component_name != component_name:
continue
if phase is not None and use.phase != phase:
continue
if target_dtype is not None:
return replace(use, target_dtype=target_dtype)
return use
raise ValueError(
f"{self.__class__.__name__} did not declare component use: "
f"{component_name}"
)
@contextmanager
def use_declared_component(
self,
*,
component_name: str,
module=None,
phase: str | None = None,
target_dtype: torch.dtype | None = None,
) -> Iterator[object | None]:
"""reference a component already declared in `component_uses`"""
use = self._declared_component_use(
component_name=component_name,
phase=phase,
target_dtype=target_dtype,View on GitHub (pinned to 0132848349)
Solutions
- Declare the component use in the stage (add to its declared component-use list/property) with the same name and phase
- Fix the component_name string/typo to match the declaration
- Check phase and target_dtype arguments match a declared entry
Defensive patterns
Strategy: validation
Validate before calling
uses = stage.declared_component_uses() if hasattr(stage, 'declared_component_uses') else []
names = {u.component_name for u in uses}
assert 'transformer' in names Prevention
- Declare component uses in __init_declared_uses__-style hooks of every Stage subclass
- Add a unit test asserting each use_declared_component call has a declaration
When it happens
Trigger: Calling stage.use_declared_component('transformer') (or begin_declared_component_use / internal transform use-site helpers) when the stage class never declared that component, or declared it under a different phase.
Common situations: Subclassing a Stage and overriding declarations; renaming a component or phase constant between versions; calling the context manager with a typo in the component name.
Related errors
- pipeline_cls must inherit from ComposedPipelineBase
- Pipeline '{pipeline_name}' is already registered; pass overw
- Grouped pipeline returned fewer outputs than requests.
- Expected {len(reqs)} grouped outputs, got {len(output_batch.
- Unknown image_vae_encoding_position: {image_vae_encoding_pos
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/7a0d9323facbaa34.
Report an issue: GitHub.