Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: lazyllm.save_pipeline_result() 导致的输出不符合预期 #346

Open
Yuang-Deng opened this issue Nov 14, 2024 · 2 comments
Open

Comments

@Yuang-Deng
Copy link

import lazyllm
from lazyllm.module import ModuleBase
from lazyllm import pipeline, warp, bind

import time
import random

class ChildPipeline(ModuleBase):

    def __init__(self, return_trace: bool = False, **kwargs):
        super().__init__(return_trace=return_trace, **kwargs)
        self.pipeline = self._build_pipeline(**kwargs)

    def _build_pipeline(self, **kwargs):
        with lazyllm.save_pipeline_result():
            with pipeline() as ppl:
                ppl.bug = lambda x: time.sleep(random.randint(0, 30))
                ppl.for_output = lazyllm.ifs(lambda x, y: y is None, lambda x, y: x, lambda x, y: y) | bind(ppl.input["idx"], lazyllm._0)
        return ppl
    
    def forward(self, test_data: dict, **kwargs):
        res = self.pipeline(test_data)
        return res
    
class ParentPipeline(ModuleBase):

    childpipeline = ChildPipeline()

    def __init__(self, return_trace: bool = False, **kwargs):
        super().__init__(return_trace=return_trace, **kwargs)
        self.pipeline = self._build_pipeline(**kwargs)

    def _build_pipeline(self, **kwargs):
        with pipeline() as ppl:
            ppl.bug = warp(self.childpipeline).aslist
        return ppl
    
    def forward(self, test_data, **kwargs):
        res = self.pipeline(test_data)
        return res
    

if __name__ == "__main__":
    ppl = ParentPipeline()
    test_data = []
    for i in range(30):
        test_data.append({"idx": i})
    res = ppl.forward(test_data)
    print("期望:", list(range(30)))
    print("实际:", res)

image
第一位出现不符合预期的情况(每次随机出现,应该与randint有关)
image
倒数第三位不符合预期

去掉save_pipeline_result后输出符合预期
image

lazyllm 0.2.3
Python 3.10.14

@wzh1994
Copy link
Contributor

wzh1994 commented Dec 3, 2024

此问题是save_pipeline_result和warp不兼容所致,会尽快修复

@wzh1994
Copy link
Contributor

wzh1994 commented Dec 3, 2024

临时方案: #378
能支持warp里面套pipeline,但多套几次就不行了,比如warp(pipeline(warp(pipeline)))。之后给出系统的方案解决

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants