DeepSeekV4 Full-para train: Resource temporarily unavailable。

Open
#10,432 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python, pytorch

Research direction

The report provides a Megatron SFT launch script and says each rank starts many pthreads until LLVM reports pthread_create failed. Start by reproducing with the supplied environment variables and parallelism settings, then inspect the training startup and thread creation paths involved. Done means identifying why threads multiply across ranks and confirming training can start without the resource error; the payload names no source files or tests.

Written by the indexing model from the issue text.

Description

bug
Checklist / 检查清单
  • I have searched existing issues, and this is a new bug report. / 我已经搜索过现有的 issues,确认这是一个新的 bug report。
Bug Description / Bug 描述

进行deepseek v4的训练时发现,每个rank都会启动特别多的pthread,最后会导致LLVM ERROR: pthread_create failed: Resource temporarily unavailable。

How to Reproduce / 如何复现

训练的脚本:
if [ -z "$NODE_RANK" ]; then
echo "ERROR: NODE_RANK is not set"
exit 1
fi

CACHE=/mnt/storage/zhq/dsv4/cache/rank_${NODE_RANK}
mkdir -p "$CACHE"/{modelscope,hf,tmp}

OMP_NUM_THREADS=1
MKL_NUM_THREADS=1
OPENBLAS_NUM_THREADS=1
NUMEXPR_NUM_THREADS=1
TOKENIZERS_PARALLELISM=false
MAX_JOBS=1
TORCHINDUCTOR_COMPILE_THREADS=1
PYTORCH_CUDA_ALLOC_CONF='expandable_segments:True'
NPROC_PER_NODE=8
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
MODELSCOPE_CACHE="$CACHE/modelscope"
HF_HOME="$CACHE/hf"
HF_DATASETS_CACHE="$CACHE/hf/datasets"
TMPDIR="$CACHE/tmp"
megatron sft
--model /mnt/storage/models/deepseek-ai/DeepSeek-V4-Flash-Base
--save_safetensors true
--dataset /mnt/storage/zhq/dsv4/scripts/merged.jsonl
--model_author swift
--model_name swift-robot
--load_from_cache_file true
--add_non_thinking_prefix true
--split_dataset_ratio 0.001
--tensor_model_parallel_size 1
--expert_model_parallel_size 8
--pipeline_model_parallel_size 12
--pipeline_model_parallel_layout 'Et3|t3|t4|t4|t4|t4|t4|t4|t4|t4|t4|t1mL'
--fp8_recipe blockwise
--fp8_format e4m3
--fp8_param_gather true
--micro_batch_size 1
--global_batch_size 128
--recompute_granularity full
--recompute_method uniform
--recompute_num_layers 1
--save_total_limit 3
--moe_permute_fusion true
--moe_grouped_gemm true
--moe_shared_expert_overlap true
--moe_aux_loss_coeff 1e-3
--num_train_epochs 1
--finetune true
--cross_entropy_loss_fusion true
--lr 3e-5
--lr_warmup_fraction 0.05
--min_lr 1e-7
--output_dir /mnt/storage/zhq/dsv4/model/megatron_output/DeepSeek-V4-Flash/0924
--eval_steps 3000
--save_steps 1000
--max_length 16384
--dataloader_num_workers 2
--dataset_num_proc 8
--no_save_optim false
--no_save_rng false
--sequence_parallel true
--mtp_num_layers 1
--attention_backend flash
--use_chat_template false
--context_parallel_size 8
--cp_partition_mode contiguous
--sequence_packing_scheduler dp_balanced
--loss_scale all
--packing true

Additional Information / 补充信息
Image
Dominant language
Python
Stars
16.2k
Forks
1.8k
Avg merge
1d 14h
Merged PRs (30d)
68

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from modelscope/ms-swift

All issues in modelscope/ms-swift

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.