vllm_omni.diffusion.utils.tf_utils ¶
find_module_with_attr ¶
This function searches for a module in the model that has the specified attribute. If the model itself has the attribute, it returns the model. If none of the modules have the attribute, it returns None.
get_transformer_config_kwargs ¶
get_transformer_config_kwargs(
tf_model_config: TransformerConfig,
model_class: type[Any] | None = None,
) -> dict[str, Any]
This function extracts parameters from a TransformerConfig instance and filters out internal diffusers metadata keys (those starting with '_') that should not be passed to model initialization. Also filters out parameters that are not accepted by the model's init method (e.g., pooled_projection_dim for QwenImageTransformer2DModel).
This uses inspect.signature to dynamically detect accepted parameters, making it general for any model class. Similar to how diffusers' @register_to_config decorator works.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tf_model_config | TransformerConfig | TransformerConfig instance containing model parameters | required |
model_class | type[Any] | None | Optional model class to inspect for accepted init parameters. If None, all non-internal parameters are returned (backward compatibility). | None |
Returns:
| Name | Type | Description |
|---|---|---|
dict | dict[str, Any] | Filtered dictionary of parameters suitable for transformer model initialization |