FederatedAI / FATE

An Industrial Grade Federated Learning Framework
Apache License 2.0
5.72k stars 1.55k forks source link

模型预测时,model_loader 加载其他模型组件的model异常 #4340

Closed momingzhi0303 closed 4 months ago

momingzhi0303 commented 2 years ago

Describe the bug 有两个job, job-A:包含DataTransform、Intersection、HeteroFeatureSelection三个组件,job完成后进行deploy job-B: 包含HeteroSecureBoost,input_data是job-A的output_data, job-B成功,自定义dsl(包含job-A和job-B的组件)进行deploy

基于job-B deploy的mode进行预测任务时,model_loader 异常,目前发起的是所有的model_loader 加载其他模型组件的model都会异常,在1.8版本是正常的,1.9版本异常 异常信息如下

[ERROR] [2022-09-22 14:53:22,058] [202209221452420715180] [12081:139734406686528] - [task_executor._run_] [line:265]: 'NoneType' object is not iterable
Traceback (most recent call last):
  File "/data/projects/fate/fateflow/python/fate_flow/worker/task_executor.py", line 209, in _run_
    cpn_output = run_object.run(cpn_input)
  File "/data/projects/fate/fate/python/federatedml/model_base.py", line 239, in run
    self._run(cpn_input=cpn_input)
  File "/data/projects/fate/fate/python/federatedml/model_base.py", line 315, in _run
    this_data_output = func(*real_param)
  File "/data/projects/fate/fate/python/federatedml/util/data_transform.py", line 1053, in transform
    data_inst = self.transformer.read_data(data, "transform")
  File "/data/projects/fate/fate/python/federatedml/util/data_transform.py", line 164, in read_data
    if (set(self.header) & set(header)) != set(self.header):
TypeError: 'NoneType' object is not iterable

job-A dsl如下:

{
    "components":{
        "reader_0":{
            "module":"Reader",
            "output":{
                "data":[
                    "data"
                ]
            }
        },
        "data_transformer_0":{
            "module":"DataTransform",
            "output":{
                "data":[
                    "data"
                ],
                "model": [
                    "model"
                ]
            },
            "input":{
                "data":{
                    "data":[
                        "reader_0.data"
                    ]
                }
            }
        },
        "intersect_0":{
            "output":{
                "data":[
                    "data"
                ]
            },
            "input":{
                "data":{
                    "data":[
                        "data_transformer_0.data"
                    ]
                }
            },
            "module":"Intersection"
        },
        "hetero_feature_selection_0": {
            "module": "HeteroFeatureSelection",
            "output": {
                "data": [
                    "data"
                ],
                "model": [
                    "model"
                ]
            },
            "input": {
                "data": {
                    "data": [
                        "intersect_0.data"
                    ]
                }
            }
        }
    }
}

job-A conf如下:

{
  "dsl_version": 2,
  "initiator": {
    "role": "guest",
    "party_id": 10000
  },
  "role": {
    "host": [
      10000
    ],
    "guest": [
      10000
    ]
  },
  "component_parameters": {
    "common": {
      "hetero_feature_selection_0": {
        "manually_param": {
          "filter_out_indexes": [
            1,
            2
          ]
        },
        "filter_methods": [
          "manually"
        ]
      }
    },
    "role": {
      "host": {
        "0": {
          "reader_0": {
            "table": {
              "name": "credit_hetero_host",
              "namespace": "experiment"
            }
          },
          "data_transformer_0": {
            "output_format": "dense",
            "with_label": false,
            "missing_fill": true,
            "missing_fill_method": "mean"
          }
        }
      },
      "guest": {
        "0": {
          "reader_0": {
            "table": {
              "name": "credit_hetero_guest",
              "namespace": "experiment"
            }
          },
          "data_transformer_0": {
            "output_format": "dense",
            "missing_fill": true,
            "missing_fill_method": "mean",
            "with_label": true,
            "label_name": "y"
          }
        }
      }
    }
  }
}

job-B dsl如下:

{
  "components": {
    "reader_0": {
      "module": "Reader",
      "output": {
        "data": [
          "data"
        ]
      }
    },
    "hetero_secure_boost_0": {
      "module": "HeteroSecureBoost",
      "input": {
        "data": {
          "train_data": [
            "reader_0.data"
          ]
        }
      },
      "output": {
        "data": [
          "data"
        ],
        "model": [
          "model"
        ]
      }
    }
  }
}

job-B conf如下:

{
  "dsl_version": 2,
  "initiator": {
    "role": "guest",
    "party_id": 10000
  },
  "role": {
    "host": [
      10000
    ],
    "guest": [
      10000
    ]
  },
  "component_parameters": {
    "common": {
      "hetero_secure_boost_0": {
        "task_type": "classification",
        "objective_param": {
          "objective": "cross_entropy"
        },
        "num_trees": 3,
        "validation_freqs": [1,4],
        "encrypt_param": {
          "method": "Paillier"
        },
        "tree_param": {
          "max_depth": 3
        },
        "use_missing": true
      }
    },
    "role": {
      "host": {
        "0": {
          "reader_0": {
            "table": {
              "name": "48327d4c3a4211eda000024213a70164",
              "namespace": "output_data_202209221445395991530_hetero_feature_selection_0_0"
            }
          }
        }
      },
      "guest": {
        "0": {
          "reader_0": {
            "table": {
              "name": "484f0d683a4211edae4f024213a70164",
              "namespace": "output_data_202209221445395991530_hetero_feature_selection_0_0"
            }
          }
        }
      }
    }
  }
}

job-B deploy 自定义DSL如下:

{
  "components": {
    "reader_0": {
      "module": "Reader",
      "output": {
        "data": [
          "data"
        ]
      }
    },
    "data_transform_0": {
      "module": "DataTransform",
      "input": {
        "data": {
          "data": [
            "reader_0.data"
          ]
        },
        "model": [
          "model_loader_0.model"
        ]
      },
      "output": {
        "data": [
          "data"
        ],
        "model": [
          "model"
        ]
      }
    },
    "intersection_0": {
      "module": "Intersection",
      "input": {
        "data": {
          "data": [
            "data_transform_0.data"
          ]
        }
      },
      "output": {
        "data": [
          "data"
        ]
      }
    },
    "feature_selection_0": {
      "module": "HeteroFeatureSelection",
      "input": {
        "data": {
          "data": [
            "intersection_0.data"
          ]
        },
        "model": ["model_loader_1.model"]
      },
      "output": {
        "data": [
          "data"
        ],
        "model": [
          "model"
        ]
      }
    },
    "hetero_secure_boost_0": {
      "module": "HeteroSecureBoost",
      "input": {
        "data": {
          "train_data": [
            "feature_selection_0.data"
          ]
        },
        "model": ["pipeline.hetero_secure_boost_0.model"]
      },
      "output": {
        "data": [
          "data"
        ],
        "model": [
          "model"
        ]
      }
    },
    "model_loader_0":{
      "output":{
        "model":[
          "model"
        ]
      },
      "module":"ModelLoader"
    },
    "model_loader_1":{
      "output":{
        "model":[
          "model"
        ]
      },
      "module":"ModelLoader"
    }
  }
}

预测任务conf如下

{
  "dsl_version": 2,
  "initiator": {
    "role": "guest",
    "party_id": 10000
  },
  "role": {
    "host": [
      10000
    ],
    "guest": [
      10000
    ]
  },
  "job_parameters": {
    "common": {
      "model_id": "guest-10000#host-10000#model",
      "model_version": "202209221451386401720",
      "job_type": "predict"
    }
  },
  "component_parameters": {
    "common": {
      "model_loader_0":{
        "model_version":"202209221448595402410",
        "component_name":"data_transformer_0",
        "model_alias":"model",
        "model_id":"guest-10000#host-10000#model"
      },
      "model_loader_1":{
        "model_version":"202209221448595402410",
        "component_name":"hetero_feature_selection_0",
        "model_alias":"model",
        "model_id":"guest-10000#host-10000#model"
      }
    },
    "role": {
      "guest": {
        "0": {
          "reader_0": {
            "table": {
              "name": "credit_hetero_guest",
              "namespace": "experiment"
            }
          }
        }
      },
      "host": {
        "0": {
          "reader_0": {
            "table": {
              "name": "credit_hetero_host",
              "namespace": "experiment"
            }
          }
        }
      }
    }
  }
}
mgqa34 commented 2 years ago

感谢反馈,我们跟进下

github-actions[bot] commented 4 months ago

This issue has been marked as stale because it has been open for 365 days with no activity. If this issue is still relevant or if there is new information, please feel free to update or reopen it.