From f6420f9bde1c9abaf1bceffd2b9ef10aed4a99cf Mon Sep 17 00:00:00 2001 From: Akash Santra Date: Wed, 15 Apr 2026 00:06:30 +0530 Subject: [PATCH 1/2] fix(profiling): preserve instance isolation when decorating methods --- examples/profiling/profiling_utils.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/examples/profiling/profiling_utils.py b/examples/profiling/profiling_utils.py index 1c7d59d42fde..df3667479f42 100644 --- a/examples/profiling/profiling_utils.py +++ b/examples/profiling/profiling_utils.py @@ -45,7 +45,18 @@ def annotate_pipeline(pipe): method = getattr(component, method_name, None) if method is None: continue - setattr(component, method_name, annotate(method, label)) + + # Extract underlying function (avoid bound-method issue) + func = getattr(method, "__func__", method) + + # Wrap function + wrapped = annotate(func, label) + + # Rebind to THIS instance only (preserve descriptor behavior) + bound_method = wrapped.__get__(component, type(component)) + + # Set back + setattr(component, method_name, bound_method) # Annotate pipeline-level methods if hasattr(pipe, "encode_prompt"): From e248ffd966d884df1ea57c8e81e4a2b40ad3ef46 Mon Sep 17 00:00:00 2001 From: Akash Santra Date: Wed, 15 Apr 2026 07:37:47 +0530 Subject: [PATCH 2/2] fix(profiling): scope instance isolation fix to LTX2 pipelines --- examples/profiling/profiling_utils.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/examples/profiling/profiling_utils.py b/examples/profiling/profiling_utils.py index df3667479f42..1150ad5ae24d 100644 --- a/examples/profiling/profiling_utils.py +++ b/examples/profiling/profiling_utils.py @@ -46,17 +46,15 @@ def annotate_pipeline(pipe): if method is None: continue - # Extract underlying function (avoid bound-method issue) - func = getattr(method, "__func__", method) - - # Wrap function - wrapped = annotate(func, label) - - # Rebind to THIS instance only (preserve descriptor behavior) - bound_method = wrapped.__get__(component, type(component)) - - # Set back - setattr(component, method_name, bound_method) + # Apply fix ONLY for LTX2 pipelines + if "LTX2" in pipe.__class__.__name__: + func = getattr(method, "__func__", method) + wrapped = annotate(func, label) + bound_method = wrapped.__get__(component, type(component)) + setattr(component, method_name, bound_method) + else: + # keep original behavior for other pipelines + setattr(component, method_name, annotate(method, label)) # Annotate pipeline-level methods if hasattr(pipe, "encode_prompt"):