[rank6]: pydantic_core._pydantic_core.ValidationError: 1 validation error for DeepSpeedZeroConfig
[rank6]: stage3_prefetch_bucket_size
[rank6]: Input should be a valid integer, got a number with a fractional part [type=int_from_float,input_value=11560550.4,in put_type=float]
[rank6]: For further information visit https://errors.pydantic.dev/2.8/v/int_fro_float
Lower the deepspeed version to 0.14.*.
Q14: Is there a complete tutorial and command line for fine-tuning qwen-2-vl?
Qwen2-VL Best Practices.
Q15: Are there any supported tricks for fine-tuning multi-modal large models, similar to neftune for llm?
piassa/olora/dora Variants of these lora or fourierft can all be tried. Refer to various tricks in the sft parameter. Some may not necessarily be applicable to multimodality.
Q16: The accuracy (acc) obtained during the evaluation (eval) in the training process and the accuracy calculated by re-inferencing with the corresponding saved checkpoint (ckpt) are not consistent.
The calculation methods of eval_acc during training and acc during inference are different. acc_strategy: The default is 'token', and the available values include: 'token', 'sentence'.
Q17: ModelScope official image and swift environment
Use the docker run command to start the container. For example: docker run --gpus all -p 8000:8000 -it -d --name ms registry.cn-beijing.aliyuncs.com/modelscope-repo/modelscope:ubuntu22.04-cuda12.1.0-py310-torch2.3.0-tf2.16.1-1.16.0 /bin/bash. After starting the container, pull the latest code and install swift.
Q18: Multi-machine multi-GPU training command line
For details, see Multi-machine and Multi-GPU Example
Q19: How to choose a template?
See issue.
Q20: How to use torchrun and swift sft for multi - GPU training?
swift sft follows torchrun.
Q21: I have a problem. Since my sft dataset is too large, it takes a long time to tokenize each time. Is there a solution?
Use lazy_tokenize. For details, see Command Line Arguments.
Q22: During training, if two datasets are directly appended together and placed in the training set, will there be a shuffling process inside the model during training? Or will the data be fetched in order for training?
It will be random in the trainer.
Q23: If the model uses two cards and data parallelism is not enabled, DeepSpeed will report an error. How to handle this?
deepspeed and device_map are incompatible. You can only choose one of them.
Q24: Why does the dataset that has already been downloaded during online training need to be downloaded again for offline retraining?
There are URLs in the data file, and offline training is not supported.
Q25: How to reduce the use of video memory during the training of the vlm model?
Configure --freeze_vit true.
Q26: Why are there fewer models supported on the WEB-UI interface than in the documentation?
Upgrade ms-swift.
Q27: There is no model adapted to model_type. Can special_tokens and chat_template be customized during sft?
Yes. Refer to the PR of the access model and the documentation of the custom model dataset.
Q28: Can DPO be used to train qwen2-vl in a Python script?
Yes. Import rlhf_main and RLHFArguments from swift.llm.
Q29: When training an MLLM, can we first perform pre-training on pure text and then connect to a VQA dataset for fine-tuning?
Yes. You can also train them together.
Q30: When conducting DPO training using the SFT model based on Qwen2 on a V100 machine, why are the values all NaN during training?
The V100 machine should be used to train qwen2 with fp32.
Q31: I would like to ask, can swift support distillation?
Not supported. It is recommended to quantify, which has a better effect.
Q32: cannot import name 'ftp_head' from 'datasets.utils.file_utils'. Have you encountered this problem?
pip install datasets==2.*。
Q33: Currently, by default, at most two checkpoints are saved after training. How should I modify it if I want to save more?
--save_total_limit, see Command Line Arguments for details.
Q34: Does the general data format in the Grounding task support multiple instances for one category?
Currently, it supports multiple bounding boxes (bbox) for one object. Refer to the document Custom Dataset.
Q35: Why does this error appear here and where can't numpy.object be found?
numpy==1.26.3, Give it a try.
Q36: Can the swift framework support sequential parallelism?
Support. Now it is achieved by introducing xtuner.
Q37: When fine-tuning qwen2-1.5B with v100, the values are 'loss': 0.0, 'acc': 0.0, 'grad_norm': nan. What's the problem?
Try using fp32.
Q38: Can the GPTQ quantized model be fine-tuned with all parameters?
No. The int-type parameters of the gptq model cannot participate in the derivative calculation. They can only be attached to additional structures such as lora to participate in the update.
Q39: How should the parameters be set if you want to fine-tune in the qlora way? glm4-chat
Refer to the qlora example.
Q40: When training my own dataset with qwen2-vl-7b, I always encounter the problem "AdamW' object has no attribute 'train".
accelerate 0.34.0Try it.
Q41: I have a question. How should I expand my vocabulary under the swift framework?
Swift does not currently support vocabulary expansion.
Q42: Can models with the same name be directly used from Hugging Face?
Set the environment variable USE_HF=1.
Q43: Can Qwen2-VL-2B be incrementally pre-trained? Is there any guidance document? There are both graphic and text versions, as well as pure text versions.
It is supported. If you continue with pre-training, you can put all the content in the response.
Q44: When using videos for training, how can I control the frame extraction rate in the parameters? Setting frame_rate doesn't work. minicpmv
Set the environment variable MAX_NUM_FRAMES.
Q45: Can the inference results of the validation set be saved during the training of swift?
After the training is completed, run swift infer and it will be saved.
Q46: I used the full parameter dpo for the full amount. Why is the saved checkpoint larger than the original model file? It is exactly twice as large
Fine-tune with V100 and save in fp32 format.
Q47: The multi-machine training speed is slow. When using the swift framework for LLM training, it is found that there is a serious speed degradation problem when using deepspeed zero3 for training
See issue for details.
Q48: Does swift currently support the multi-stage pre-training of qwen2-vl? I noticed that in the official best practices, the sft seems to be trained with vit+llm together. I'm not sure if it supports separate fine-tuning.
See issue for details.
Q49: Does qwen2-vl not support mixed plain text data?
Supports图文and plain text.
Q50: Can the loss curves of different datasets be plotted during fine-tuning?
Not supported. The dataset is trained with a mix.
Q51: After model training, the response repeats a lot of content
Refer to Pre-training and Fine-tuning. If there are repetitions during the training process, train for a few more epochs, clean the data, perform full-parameter training, and adopt the RLHF method to alleviate the situation.
Q52: I would like to ask if swift currently supports prompt tuning or prefix tuning?
Not supported. There is a relatively serious knowledge gap regarding these two methods, and they are not recommended for use at present.
Q53: Two A10s report the following training errors:
[rank0]: torch.distributed.DistBackendError: NCCL error in:../torch/csrc/distributed/c10d/ProcessGroupNCCL.cpp:1970, unhandled system error (run with NCCL_DEBUG=INFO for details),NCCL version 2.20.5
[rank0]:ncclSystemError: System call (e.g. socket,malloc) or external library call failed or device error.
Please check if the shared memory is too small. NCCL requires shared memory.
Q54: How to solve the problem that some parameters do not participate in the gradient backpropagation when freezing some layers during the fine-tuning training with DDP?
Configure the parameter --ddp_find_unused_parameters true.
Q55: Does swift have a dataset quality inspection tool?
data-juicer。
Q55: Where can I start model parallelism on the web端? I only found the checkbox for data parallelism and couldn't find where model parallelism is.
Just specify the visible graphics card.
Q56: How to disable auto-shuffle? I want to turn it off.
Currently, only the transformers code can be modified.
Q57: What is the 'num_items_in_batch' parameter? I can't find where it is.
Upgrade ms-swift==2.5.2 or downgrade transformers<4.46.
Inference
Q1: Is there any documentation for swift inference?
Swift supports Python scripts, command line, and UI interface inference. For details, see Reasoning and Deployment.
Q2: How to use the dataset for inference with the trained model?
The parameter --load_dataset_config true or --val_dataset . See the document Command Line Arguments.
Q3: Can a downloaded model be specified during swift inference?
--model Just configure the local path. For details, see Command Line Arguments.
Q4: I want to perform inference on a dataset without labels. How can I do that? I see that the dataset formats in the documentation are all for the training set
Configure the parameter --val_dataset .
Q5: How to solve the error ValueError: Input length of input_ids is 35, but max_length is set to 20?
raise ValueError(
ValueError: Input length of input_ids is 35, but `max_length` is set to 20. This can lead to unexpected behavior. You should consider increasing `max_length` or, better yet, setting `max_new_tokens`.
Set model.generation_config.max_new_tokens.
Q6: qwen2-vl inference runs out of GPU memory
Set environment variables, SIZE_FACTOR=8 MAX_PIXELS=602112. See the document Qwen2-VL Best Practices.
Q7: For the v100 graphics card, in the Python virtual environment, refer to https://swift2x.readthedocs.io/zh-cn/latest/Multi-Modal/qwen2-vl%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5.html to complete the environment preparation. When testing the inference command: CUDA_VISIBLE_DEVICES=0,1,2,3 swift infer --model_type qwen2-vl-7b-instruct, an error is reported: RuntimeError: probability tensor contains either inf, nan or element < 0
Try to use A10 or 3090 machines for inference.
Q8: Run the following command. Where can you predict the subsequent results will be? CUDA_VISIBLE_DEVICES=0 swift infer --ckpt_dir output/glm4v-9b-chat/vx-xxx/checkpoint-xxx-merged --load_dataset_config true
The path will be printed in the log.
Q9: When performing inference and calling inference, how can I obtain the output logits?
Refer to test_logprobs.py.
Q10: The latest version of swift. When I was loading the qwen2-32b-instruct-awq quantization model and its lora, vllm prompted me to add merge lore true. But when I added it, an error occurred. When I removed the vllm acceleration, normal inference could be carried out, but the speed was very slow.
The model trained by QLoRA does not support merge-lora. It is recommended to perform merge-lora and then quantization after fine-tuning with LoRA.
Q11: vllm will report an error, assert factor in rope_scaling
pip install git+https://github.com/huggingface/transformers@21fac7abba2a37fae86106f87fcf9974fd1e3830, see qwen2-vl issue#96 for details.
Q12: If vllm is used as the inference backend, does the model have to be merged before it can be called?
It can be not merged. For details, see the document Command Line Arguments.
Q13: Can only the inference_client function be used to obtain the inference return prob? Can the inference function in the single-sample inference demo retrieve the results?
generation_config.output_logits Modify it. model.generation_config.output_logits = True
model.generation_config.return_dict_in_generate = True
Q14: Has anyone encountered this problem? RuntimeError: "triu_tril_cuda_template" not implemented for 'BFloat16'
Upgrade torch. This operator is not implemented in this version of torch.
Q15: Does qwen2-audio support streaming inference?
Supported. See issue for details.
Q16: When the inference client performs multi-modal inference, where is do_sample set?
Set temperature=0.
Q17: Does ms-swift support large model batch processing?
Supported. See demo for details.
Q18: When quantizing the ms-swift model, it shows insufficient memory. Can it occupy less resources during quantization? It doesn't matter if it's a bit slower.
Try to set --device_map cpu.
Q19: Does swift support quantization of multi-modal models?
Support.
Q20: When using GPTQ, the following error occurs. What is the reason?
if llm_config['architectures'][0] == 'LlamaForCausalLM':
KeyError: 'architectures'
Try the transformers==4.44.* version.
Q21: How does swift infer save the evaluation results to a specified file? I don't know where it saves every time.
Set --result_path your_path, see InferArguments for details.
Q22: When quantizing yi-vl-6b with AWQ, the following error occurs:
TypeError: swift.llm.utils.model.get_model_tokenizer_with_flash_attn() got multiple values for keyword argument 'automodel_class'.
Please use GPTQ quantization.
Q23: I would like to ask that when using swift export to perform GPTQ int4 quantization on the Qwen2.5 72B model, the max model length = 32768 uses the default value, and the calibration dataset provided has 128 samples. However, an error occurred during quantization. The error log is: factorization could not be completed because the input is not positive-definite (the leading minor of order 18145 is not pisitive-definite). What is the reason?
For the problem that the Hessian matrix is not positive definite, try other datasets.
Deployment
Q1: How to deploy the trained model?
swift deploy --ckpt_dir xxx, see the document Reasoning and Deployment.
Q2: How to perform multi-GPU deployment using vllm deployment?
See example for details.
Q3: When deploying with vllm, how does the client pass in images?
For details, see Client Example.
Q4: I have a question. When using the client after deploying qwen2-7b, to call the openai api, you need to use client.completions.create instead of client.chat.completions.create. However, when using qwen2-7b-instruct-q5_k_m.gguf, you can use client.chat.completions.create. Why is this?
The base model can be used with client.chat.completions.create, but this is a compatibility behavior.
Q5: After starting the server with swift deploy using two cards and exiting with Ctrl+C, there will always be a python process that continuously occupies the video memory of one card. Is this a normal phenomenon?
It is necessary to kill it. This is a problem with vllm.
Q6: Where can I check if the model supports lmdeploy or vllm acceleration?
vllm and lmdeploy each have their own model support ranges. Please refer to their respective official documents to determine availability.
Q7: Tongyi Qianwen 2.5 - Mathematics - 7B - Instruct sometimes keeps returning garbled characters like this. What's the problem? Deployed with vllm, fp16.
Try bf16.
Q8: After the swift inference service is started, how do I set configurations such as the temperature for interactive settings?
Inference can only be set before startup. Deployment can set a default at startup and then continue to be set on the client side to override the default.
Q9: When deploying the qwen2vl model locally and using vllm as the inference backend, how can local videos be passed in? Can they be passed in using base64? How can videos be loaded when making a curl call?
base64, see mllm client example for details
Q10: When deploying qwen2-vl, the following error occurs. Is the version of vllm incorrect?
Unrecognized keys in `rope_scaling`for 'rope_type'='default': {'mrope_section'} Unrecognized keys in `rope_scaling`for 'rope_type'='default': {'mrope_section'}
See issue for details.
Q11: Can swift inference output prediction probabilities? How to set it up during deployment?
Refer to test_logprobs.py.
Evaluation
Q1: What evaluation datasets does swift support?
Plain text evaluation:
'obqa', 'cmb', 'AX_b', 'siqa', 'nq', 'mbpp', 'winogrande', 'mmlu', 'BoolQ', 'cluewsc', 'ocnli', 'lambada',
'CMRC', 'ceval', 'csl', 'cmnli', 'bbh', 'ReCoRD', 'math', 'humaneval', 'eprstmt', 'WSC', 'storycloze',
'MultiRC', 'RTE', 'chid', 'gsm8k', 'AX_g', 'bustm', 'afqmc', 'piqa', 'lcsts', 'strategyqa', 'Xsum', 'agieval',
'ocnli_fc', 'C3', 'tnews', 'race', 'triviaqa', 'CB', 'WiC', 'hellaswag', 'summedits', 'GaokaoBench',
'ARC_e', 'COPA', 'ARC_c', 'DRCD'
Multimodal Evaluation:
'COCO_VAL', 'MME', 'HallusionBench', 'POPE', 'MMBench_DEV_EN', 'MMBench_TEST_EN', 'MMBench_DEV_CN', 'MMBench_TEST_CN',
'MMBench', 'MMBench_CN', 'MMBench_DEV_EN_V11', 'MMBench_TEST_EN_V11', 'MMBench_DEV_CN_V11',
'MMBench_TEST_CN_V11', 'MMBench_V11', 'MMBench_CN_V11', 'SEEDBench_IMG', 'SEEDBench2',
'SEEDBench2_Plus', 'ScienceQA_VAL', 'ScienceQA_TEST', 'MMT-Bench_ALL_MI', 'MMT-Bench_ALL',
'MMT-Bench_VAL_MI', 'MMT-Bench_VAL', 'AesBench_VAL', 'AesBench_TEST', 'CCBench', 'AI2D_TEST', 'MMStar',
'RealWorldQA', 'MLLMGuard_DS', 'BLINK', 'OCRVQA_TEST', 'OCRVQA_TESTCORE', 'TextVQA_VAL', 'DocVQA_VAL',
'DocVQA_TEST', 'InfoVQA_VAL', 'InfoVQA_TEST', 'ChartQA_TEST', 'MathVision', 'MathVision_MINI',
'MMMU_DEV_VAL', 'MMMU_TEST', 'OCRBench', 'MathVista_MINI', 'LLaVABench', 'MMVet', 'MTVQA_TEST',
'MMLongBench_DOC', 'VCR_EN_EASY_500', 'VCR_EN_EASY_100', 'VCR_EN_EASY_ALL', 'VCR_EN_HARD_500',
'VCR_EN_HARD_100', 'VCR_EN_HARD_ALL', 'VCR_ZH_EASY_500', 'VCR_ZH_EASY_100', 'VCR_ZH_EASY_ALL',
'VCR_ZH_HARD_500', 'VCR_ZH_HARD_100', 'VCR_ZH_HARD_ALL', 'MMDU', 'MMBench-Video', 'Video-MME'
See the document Evaluation for details.
Q2: How to use a custom evaluation set?
Plain text and multi-modal custom evaluation sets must be consistent with the data format (pattern) of a certain official evaluation set. See the document Evaluation.
Q3: In the python3.11 environment, mmengine reports an error during evaluation
Try the python3.10 environment. Or install all dependencies first: pip3 install evalscope[all], and then apply the patch: pip3 install https://modelscope-open.oss-cn-hangzhou.aliyuncs.com/package/evalscope-0.5.3.post1-py3-none-any.whl.
Q4: After manually downloading the officially supported evaluation dataset, can swift eval be configured to evaluate with a local path?
First, download the evaluation dataset eval.zip. After decompression, put the contents inside into the ~/.cache/modelscope/media_resources/evalscope/data folder. Then execute the swift eval command to use local data.
Q5: Is there a bug in the custom evaluation? When I change the standard example to English, it always fails to run?
swift eval --model_type 'qwen2_5-1_5b-instruct' --eval_dataset no --custom_eval_config '/mnt/workspace/test_data/config_eval.json'
This depends on the nltk package. Then, the tokenizer of nltk requires downloading a zip file named punkt_tab. In some domestic environments, the download may be unstable or fail directly. I have tried to modify the code as a fallback to avoid this problem; refer to issue.
Q6: The fine-tuned model of eval always stops at a fixed percentage, but the vllm service seems to be running normally all the time. The larger the model, the earlier the disconnection.
TIMEOUT environment variable is set to -1.
Q7: Does evalscope support multi-model comparison?
For details, see the document.
Q8: Is there any custom evaluation for the multi-modal dataset?
For multimodal custom evaluation, you can refer to the documentation.
Q9: Does ms-swift have a method to test QPS, latency, and tokens/s?
You can try to use the Model Inference Performance Stress Testing of evalscope.
Q10: Can the number of data set entries be controlled during evaluation? Evaluating an mmlu takes over an hour, which is too slow.
Configure the parameter --eval_limit. Here, --eval_limit controls the number of items in each subset. For example, mmlu has more than 50 subsets. If each subset has a limit of 10 items, then there are more than 500 items in total.