Skip to content

ValueError: dictionary update sequence element #0 has length 1; 2 is required #2

@OttoTim

Description

@OttoTim

Hey,

I followed your steps and executed

python finetune.py  --accelerator 'gpu' --devices 1  --num_nodes 1 --strategy 'ddp' \
           --max_epochs 50 \
           --task_type ${TASK_TYPE} \
           --default_root_dir ${LOG_FOLDER} \
           --data_dir ${PROCESSED_DATA_DIR}  \
           --dataset ${SPLIT_FILE} \
           --train_batch_size 32  \
           --val_batch_size 32  \
           --model_name_or_path ${PRETRAIN_MODEL_PATH} \
           --num_labels ${NUM_LABELS} \
           --random_seed 0

but I encountered the following error:

[rank0]: Traceback (most recent call last):
[rank0]: File "/data/otto/table-union-search-benchmark/approaches/tabsketchfm/finetune.py", line 188, in
[rank0]: cli_main()
[rank0]: ~~~~~~~~^^
[rank0]: File "/data/otto/table-union-search-benchmark/approaches/tabsketchfm/finetune.py", line 174, in cli_main
[rank0]: trainer_ddp.fit(model, data_module)
[rank0]: ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
[rank0]: File "/home/otto/.conda/envs/latest/lib/python3.13/site-packages/pytorch_lightning/trainer/trainer.py", line 603, in fit
[rank0]: call._call_and_handle_interrupt(
[rank0]: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
[rank0]: self, self._fit_impl, model, train_dataloaders, val_dataloaders, datamodule, ckpt_path
[rank0]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]: )
[rank0]: ^
[rank0]: File "/home/otto/.conda/envs/latest/lib/python3.13/site-packages/pytorch_lightning/trainer/call.py", line 36, in _call_and_handle_interrupt
[rank0]: return trainer.strategy.launcher.launch(trainer_fn, *args, trainer=trainer, **kwargs)
[rank0]: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]: File "/home/otto/.conda/envs/latest/lib/python3.13/site-packages/pytorch_lightning/strategies/launchers/subprocess_script.py", line 90, in launch
[rank0]: return function(*args, **kwargs)
[rank0]: File "/home/otto/.conda/envs/latest/lib/python3.13/site-packages/pytorch_lightning/trainer/trainer.py", line 645, in _fit_impl
[rank0]: self._run(model, ckpt_path=self.ckpt_path)
[rank0]: ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]: File "/home/otto/.conda/envs/latest/lib/python3.13/site-packages/pytorch_lightning/trainer/trainer.py", line 1086, in _run
[rank0]: self._log_hyperparams()
[rank0]: ~~~~~~~~~~~~~~~~~~~~~^^
[rank0]: File "/home/otto/.conda/envs/latest/lib/python3.13/site-packages/pytorch_lightning/trainer/trainer.py", line 1156, in _log_hyperparams
[rank0]: logger.save()
[rank0]: ~~~~~~~~~~~^^
[rank0]: File "/home/otto/.conda/envs/latest/lib/python3.13/site-packages/lightning_utilities/core/rank_zero.py", line 42, in wrapped_fn
[rank0]: return fn(*args, **kwargs)
[rank0]: File "/home/otto/.conda/envs/latest/lib/python3.13/site-packages/pytorch_lightning/loggers/tensorboard.py", line 287, in save
[rank0]: save_hparams_to_yaml(hparams_file, self.hparams)
[rank0]: ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]: File "/home/otto/.conda/envs/latest/lib/python3.13/site-packages/pytorch_lightning/core/saving.py", line 407, in save_hparams_to_yaml
[rank0]: yaml.dump(v)
[rank0]: ~~~~~~~~~^^^
[rank0]: File "/home/otto/.conda/envs/latest/lib/python3.13/site-packages/yaml/init.py", line 253, in dump
[rank0]: return dump_all([data], stream, Dumper=Dumper, **kwds)
[rank0]: File "/home/otto/.conda/envs/latest/lib/python3.13/site-packages/yaml/init.py", line 241, in dump_all
[rank0]: dumper.represent(data)
[rank0]: ~~~~~~~~~~~~~~~~^^^^^^
[rank0]: File "/home/otto/.conda/envs/latest/lib/python3.13/site-packages/yaml/representer.py", line 27, in represent
[rank0]: node = self.represent_data(data)
[rank0]: File "/home/otto/.conda/envs/latest/lib/python3.13/site-packages/yaml/representer.py", line 52, in represent_data
[rank0]: node = self.yaml_multi_representers[data_type](self, data)
[rank0]: File "/home/otto/.conda/envs/latest/lib/python3.13/site-packages/yaml/representer.py", line 342, in represent_object
[rank0]: return self.represent_mapping(
[rank0]: ~~~~~~~~~~~~~~~~~~~~~~^
[rank0]: 'tag:yaml.org,2002:python/object:'+function_name, state)
[rank0]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]: File "/home/otto/.conda/envs/latest/lib/python3.13/site-packages/yaml/representer.py", line 118, in represent_mapping
[rank0]: node_value = self.represent_data(item_value)
[rank0]: File "/home/otto/.conda/envs/latest/lib/python3.13/site-packages/yaml/representer.py", line 52, in represent_data
[rank0]: node = self.yaml_multi_representers[data_type](self, data)
[rank0]: File "/home/otto/.conda/envs/latest/lib/python3.13/site-packages/yaml/representer.py", line 330, in represent_object
[rank0]: dictitems = dict(dictitems)
[rank0]: ValueError: dictionary update sequence element #0 has length 1; 2 is required

Based on the discussion in Lightning-AI/pytorch-lightning#9318, it seems that the issue might be related to the save_hyperparameters line.

Could you let me know which Python version you're using? Also, is the requirements.txt file up to date?

Thanks in advance for your help!

Best,
Tim Otto

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions