Skip to content

ValueError: Input sequence ended with unclosed blocks: ['parallel', 'path', 'parallel'] while Training #5

Open

Description

@abse4411

I got "ValueError: Input sequence ended with unclosed blocks: ['parallel', 'path', 'parallel']" when I trained a new model using the following sh:

uid="$(date +%Y%m%d_%H%M%S)"
base_model="/home/myhome/models/Qwen2.5-7B-Instruct"
lr=1e-5
min_lr=0
epochs=1
weight_decay=1e-4 # -> the same training pipe as slurm_training
micro_batch_size=1 # -> batch_size will be 16 if 16 gpus
gradient_accumulation_steps=2 # requires more GPU memory
max_steps=-1
gpu_count=$(nvidia-smi -L | wc -l)
push_to_hub=false

torchrun --nproc-per-node ${gpu_count} --master_port 12345 \
    train/sft_multiverse.py \
    --block_size=32768 \
    --per_device_train_batch_size=${micro_batch_size} \
    --per_device_eval_batch_size=${micro_batch_size} \
    --gradient_accumulation_steps=${gradient_accumulation_steps} \
    --num_train_epochs=${epochs} \
    --train_file_path="/home/myhome/code/TMP/Multiverse-1K-mixed" \
    --model_name=${base_model} \
    --warmup_ratio=0.05 \
    --fsdp="full_shard auto_wrap" \
    --fsdp_config="train/fsdp_config_qwen_cpu.json" \
    --bf16=True \
    --eval_strategy="no" \
    --logging_steps=1 \
    --save_strategy="no" \
    --lr_scheduler_type="cosine" \
    --learning_rate=${lr} \
    --weight_decay=${weight_decay} \
    --adam_beta1=0.9 \
    --adam_beta2=0.95 \
    --output_dir="ckpts/Multiverse-7B-${uid}" \
    --push_to_hub=${push_to_hub} \
    --save_only_model=True \
    --gradient_checkpointing=True \
    --use-liger=True \
    --accelerator_config='train/accelerator_config.json' 

where train_file_path="/home/myhome/code/TMP/Multiverse-1K-mixed" is from official dataset Multiverse4FM/Multiverse-1K-mixed

Exception output:

26/500 [03:10<09:16,  1.49s/it][{'type': 'parallel', 'start_marker_index': 523, 'path_spans': []}, {'type': 'path', 'start_marker_index': 645}, {'type': 'parallel', 'start_marker_index': 953, 'path_spans': []}]
[151644, 8948, 198, 2610, 525, 1207, 16948, 11, 3465, 553, 54364, 14817, 13, 1446, 525, 264, 10950, 17847, 13, 151645, 198, 151644, 872, 198, 2461, 264, 12720, 4633, 1992, 304, 264, 5476, 304, 55311, 448, 1181, 39090, 11, 279, 2456, 315, 9315, 389, 1181, 55311, 6783, 400, 42, 3, 304, 3793, 315, 2297, 304, 47502, 374, 7481, 553, 271, 22519, 60, 3085, 5263, 304, 9315, 11, 279, 897, 315, 400, 42, 3, 369, 505, 1575, 21220, 12720, 42054, 1576, 279, 47502, 2297, 315, 279, 1849, 374, 6785, 271, 32622, 60, 3085, 5263, 304, 9315, 11, 279, 897, 315, 400, 42, 3, 369, 835, 1575, 21220, 12720, 12703, 1576, 9474, 25998, 480, 2297, 304, 47502, 315, 279, 39090, 42054, 271, 43504, 60, 3085, 5263, 304, 9315, 11, 279, 897, 315, 400, 42, 3, 369, 835, 1575, 21220, 12720, 12703, 1576, 279, 47502, 2297, 315, 279, 1849, 374, 8225, 271, 64920, 60, 3085, 5263, 304, 9315, 11, 279, 897, 315, 400, 42, 3, 369, 505, 1575, 21220, 12720, 42054, 1576, 81185, 2297, 304, 47502, 315, 279, 39090, 42054, 151645, 198, 151644, 77091, 198, 151665, 198, 71486, 11, 1077, 752, 1430, 311, 975, 1526, 419, 3491, 911, 279, 2456, 315, 9315, 389, 279, 55311, 6783, 730, 304, 3793, 315, 47502, 4344, 624, 10061, 594, 1744, 304, 15279, 624, 151667, 198, 151669, 198, 151671, 198, 16, 25, 4067, 16740, 15811, 29845, 59902, 37906, 22527, 311, 55311, 18021, 11, 2670, 5242, 364, 83, 42722, 11, 83551, 1910, 4802, 11, 323, 279, 83551, 15843, 5025, 624, 151672, 198, 151671, 198, 17, 25, 22454, 5740, 279, 31130, 29845, 59902, 37906, 311, 3158, 481, 5350, 29390, 730, 304, 3793, 315, 1197, 11866, 3288, 323, 47502, 11, 1221, 55327, 8595, 311, 11625, 369, 29390, 730, 624, 151672, 198, 151670, 198, 151673, 198, 16, 25, 35439, 11, 773, 279, 3405, 374, 10161, 892, 315, 279, 2606, 508, 32, 60, 311, 508, 35, 60, 12440, 7512, 1246, 279, 55311, 6783, 4344, 448, 9315, 11, 12831, 279, 47502, 2297, 624, 5338, 11, 358, 1184, 311, 6099, 1045, 29845, 78911, 5435, 311, 55311, 18021, 624, 40, 19091, 429, 279, 5242, 364, 83, 42722, 23606, 35616, 279, 2297, 304, 279, 55311, 6783, 448, 9315, 311, 279, 1197, 11866, 3288, 2297, 315, 279, 12720, 624, 151674, 198, 151673, 198, 17, 25, 576, 23606, 374, 294, 94925, 730, 5620, 67, 7, 16, 16731, 8, 284, 481, 144665, 39, 11616, 14, 49, 624, 1986, 13230, 429, 279, 1841, 315, 279, 1197, 11866, 3288, 2297, 320, 48764, 279, 12720, 374, 505, 1575, 21220, 476, 835, 1575, 21220, 8, 686, 8253, 1246, 730, 4344, 448, 9315, 624, 151674, 198, 151675, 198, 1820, 220, 16, 31130, 15811, 29845, 59902, 37906, 9760, 311, 55311, 18021, 11, 11689, 279, 83551, 1910, 4802, 23606, 11, 279, 5025, 1948, 83551, 1910, 4802, 323, 279, 55311, 6783, 320, 42, 701, 323, 279, 5242, 364, 83, 42722, 23606, 892, 35616, 730, 594, 9315, 43293, 311, 1197, 11866, 3288, 2297, 624, 1820, 220, 17, 10982, 279, 5242, 364, 83, 42722, 23606, 20975, 323, 10342, 1181, 60536, 429, 279, 1841, 315, 81163, 39, 11616, 26569, 1246, 730, 4344, 448, 9315, 624, 151676, 198, 151668, 198, 10061, 594, 1744, 304, 15279, 624, 151667, 198, 151669, 198, 151671, 198, 16, 25, 66875, 4849, 429, 279, 3405, 11689, 17064, 369, 458, 16148, 315, 730, 594, 9315, 43293, 304, 3793, 315, 47502, 4344, 11, 8818, 279, 5242, 364, 83, 42722, 23606, 594, 24654, 389, 1197, 11866, 3288, 13, 1096, 17601, 20913, 83551, 1910, 4802, 11, 1181, 12687, 311, 730, 11, 323, 55327, 8595, 311, 633, 458, 7493, 369, 29390, 730, 304, 3793, 315, 2176, 81163, 39, 11616, 323, 81163, 50, 11616, 624, 151672, 198, 151671, 198, 17, 25, 55777, 1967, 12853, 67149, 594, 17508, 369, 505, 1575, 21220, 323, 835, 1575, 21220, 24473, 311, 7023, 1246, 730, 4344, 448, 9315, 11, 323, 26305, 1181, 28137, 448, 279, 5242, 364, 83, 42722, 23606, 624, 151672, 198, 151670, 198, 151673, 198, 16, 25, 1988, 279, 3405, 374, 10161, 911, 47502, 4344, 624, 10061, 594, 1744, 304, 15279, 624, 151667, 198, 151669, 198, 151671, 198, 16, 13, 16, 25, 50982, 50022, 3173, 279, 3405, 594, 5244, 389, 47502, 323, 12831, 279, 83551, 1910, 4802, 23606, 438, 264, 9760, 3633, 624, 151672, 198, 151671, 198, 16, 13, 17, 25, 794, 1095, 279, 83551, 1910, 4802, 23606, 320, 144665, 38, 11616, 284, 81163, 39, 11616, 481, 350, 144665, 50, 11616, 8, 323, 1181, 5025, 311, 279, 55311, 6783, 320, 144665, 38, 11616, 284, 481, 5350, 29390, 730, 4292, 151672, 198, 151670, 198, 151673, 198, 16, 13, 16, 25, 88190, 624, 21390, 358, 1184, 311, 4564, 279, 83551, 1910, 4802, 23606, 1588, 624, 151674, 198, 151673, 198, 16, 13, 17, 25, 576, 83551, 1910, 4802, 2297, 374, 81163, 38, 11616, 284, 81163, 39, 11616, 481, 350, 144665, 50, 11616, 11, 323, 518, 55311, 11, 81163, 38, 11616, 284, 481, 5350, 29390, 730, 624, 4416, 34171, 1493, 11, 582, 614, 481, 5350, 29390, 730, 284, 81163, 39, 11616, 481, 350, 144665, 50, 11616, 624, 10061, 752, 55327, 844, 419, 311, 633, 29390, 730, 284, 481, 144665, 39, 11616, 11884, 5350, 8, 488, 81163, 50, 11616, 14, 49, 624, 151674, 198, 151675, 198, 1820, 220, 16, 10342, 279, 3405, 594, 24654, 389, 47502, 323, 11827, 20913, 279, 83551, 1910, 4802, 23606, 624, 1820, 220, 17, 3897, 279, 83551, 1910, 4802, 23606, 323, 1181, 12687, 311, 730, 11, 10856, 1105, 11, 323, 55327, 3726, 311, 3158, 29390, 730, 304, 3793, 315, 81163, 39, 11616, 323, 81163, 50, 11616, 624, 151676, 198, 151668, 198, 4416, 11, 419, 7493, 10742, 601, 429, 29390, 730, 374, 264, 13482, 729, 315, 220, 16, 16731, 448, 264, 30232, 315, 481, 144665, 39, 11616, 14, 49, 323, 28639, 81163, 50, 11616, 14, 49, 624, 10061, 594, 1744, 304, 15279, 624, 151667, 198, 151669, 198, 151671, 198, 16, 13, 16, 25, 2806, 287, 429, 279, 14257, 7493, 369, 29390, 730, 33061, 432, 311, 2176, 1197, 11866, 3288, 323, 47502, 4344, 11, 714, 60608, 279, 5242, 364, 83, 42722, 23606, 15503, 23497, 389, 1197, 11866, 3288, 624, 151672, 198, 151671, 198, 16, 13, 17, 25, 5748, 50380, 4849, 429, 279, 3405, 594, 1319, 96478, 3489, 258, 3793, 315, 2297, 304, 47502, 899, 13230]
[rank6]: Traceback (most recent call last):
[rank6]:   File "/home/myhome/code/TMP/Multiverse/train/sft_multiverse.py", line 109, in <module>
[rank6]:     train()
[rank6]:   File "/home/myhome/code/TMP/Multiverse/train/sft_multiverse.py", line 102, in train
[rank6]:     trainer.train()
[rank6]:   File "/usr/local/lib/python3.10/dist-packages/transformers/trainer.py", line 2245, in train
[rank6]:     return inner_training_loop(
[rank6]:   File "/usr/local/lib/python3.10/dist-packages/transformers/trainer.py", line 2514, in _inner_training_loop
[rank6]:     batch_samples, num_items_in_batch = self.get_batch_samples(epoch_iterator, num_batches, args.device)
[rank6]:   File "/usr/local/lib/python3.10/dist-packages/transformers/trainer.py", line 5243, in get_batch_samples
[rank6]:     batch_samples.append(next(epoch_iterator))
[rank6]:   File "/usr/local/lib/python3.10/dist-packages/accelerate/data_loader.py", line 579, in __iter__
[rank6]:     next_batch = next(dataloader_iter)
[rank6]:   File "/usr/local/lib/python3.10/dist-packages/torch/utils/data/dataloader.py", line 631, in __next__
[rank6]:     data = self._next_data()
[rank6]:   File "/usr/local/lib/python3.10/dist-packages/torch/utils/data/dataloader.py", line 675, in _next_data
[rank6]:     data = self._dataset_fetcher.fetch(index)  # may raise StopIteration
[rank6]:   File "/usr/local/lib/python3.10/dist-packages/torch/utils/data/_utils/fetch.py", line 54, in fetch
[rank6]:     return self.collate_fn(data)
[rank6]:   File "/usr/local/lib/python3.10/dist-packages/transformers/data/data_collator.py", line 46, in __call__
[rank6]:     return self.torch_call(features)
[rank6]:   File "/home/myhome/code/TMP/Multiverse/train/utils.py", line 274, in torch_call
[rank6]:     attention_mask = generate_multiverse_attention_mask(input_ids, self.tokenizer)
[rank6]:   File "/home/myhome/code/TMP/Multiverse/train/utils.py", line 173, in generate_multiverse_attention_mask
[rank6]:     raise ValueError(f"Input sequence ended with unclosed blocks: {unclosed_types}")
[rank6]: ValueError: Input sequence ended with unclosed blocks: ['parallel', 'path', 'parallel']
{'loss': 4.8263, 'grad_norm': 11.077921867370605, 'learning_rate': 8.94570254698197e-06, 'num_tokens': -inf, 'epoch': 0.25} 

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions