microsoft/qlib · error · ValueError

unknown base model name `%s`

Error message

unknown base model name `%s`

What it means

Like HISTModel, IGMTFModel.fit builds a pretrained base model from self.base_model and only 'LSTM' and 'GRU' are recognized. Any other string raises ValueError before the training loop starts, because weight transfer into the IGMTF graph depends on one of those two architectures.

Source

Thrown at qlib/contrib/model/pytorch_igmtf.py:279

        x_train, y_train = df_train["feature"], df_train["label"]
        x_valid, y_valid = df_valid["feature"], df_valid["label"]

        save_path = get_or_create_path(save_path)
        stop_steps = 0
        train_loss = 0
        best_score = -np.inf
        best_epoch = 0
        evals_result["train"] = []
        evals_result["valid"] = []

        # load pretrained base_model
        if self.base_model == "LSTM":
            pretrained_model = LSTMModel()
        elif self.base_model == "GRU":
            pretrained_model = GRUModel()
        else:
            raise ValueError("unknown base model name `%s`" % self.base_model)

        if self.model_path is not None:
            self.logger.info("Loading pretrained model...")
            pretrained_model.load_state_dict(torch.load(self.model_path, map_location=self.device))

        model_dict = self.igmtf_model.state_dict()
        pretrained_dict = {
            k: v for k, v in pretrained_model.state_dict().items() if k in model_dict  # pylint: disable=E1135
        }
        model_dict.update(pretrained_dict)
        self.igmtf_model.load_state_dict(model_dict)
        self.logger.info("Loading pretrained model Done...")

        # train
        self.logger.info("training...")
        self.fitted = True

        for step in range(self.n_epochs):

View on GitHub (pinned to 79633dd950)

Solutions

  1. Set base_model='LSTM' or base_model='GRU' exactly
  2. Check task -> model -> kwargs -> base_model in workflow YAML

Example fix

# before
IGMTFModel(base_model="lstm")

# after
IGMTFModel(base_model="LSTM")
Defensive patterns

Strategy: validation

Validate before calling

assert model.base_model in ("LSTM", "GRU"), "IGMTFModel base_model must be LSTM or GRU"

Type guard

def is_valid_base_model(name: str) -> bool:
    return name in ("LSTM", "GRU")

Prevention

When it happens

Trigger: Constructing IGMTFModel(base_model='Transformer') or any string other than 'LSTM'/'GRU' (case-sensitive), then calling fit().

Common situations: Config copied from a Transformer-family model; lowercase 'lstm'; typo in the YAML kwargs.

Related errors


AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15). Data as JSON: /api/errors/f4437f9797cf4d9f. Report an issue: GitHub.