# Error using deepspeed for sftconfig

**URL:** <https://discuss.huggingface.co/t/error-using-deepspeed-for-sftconfig/151433>\
**Category:** DeepSpeed\
**Created:** [April 20, 2025, 1:26pm UTC](https://discuss.huggingface.co/t/error-using-deepspeed-for-sftconfig/151433 "2025-04-20T13:26:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sai-santhosh](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@sai-santhosh](https://discuss.huggingface.co/u/sai-santhosh)\
**Post date:** [April 20, 2025, 1:26pm UTC](https://discuss.huggingface.co/t/error-using-deepspeed-for-sftconfig/151433/1 "2025-04-20T13:26:32Z")

</div>

```python
from trl import SFTConfig
import wandb
wandb.init(mode="disabled")

# Configure training arguments
training_args = SFTConfig(
    output_dir="qwen_sign_language_interpretation", # Directory to save the model
    max_steps=250,
    per_device_train_batch_size=1, # Batch size for training
    per_device_eval_batch_size=1, # Batch size for evaluation
    gradient_accumulation_steps=16, # Steps to accumulate gradients
    gradient_checkpointing=True, # Enable gradient checkpointing for memory efficiency
    # Optimizer and scheduler settings
    optim="adamw_torch_fused", # Optimizer type
    learning_rate=2e-4, # Learning rate for training
    lr_scheduler_type="constant", # Type of learning rate scheduler
    # Logging and evaluation
    logging_steps=10, # Steps interval for logging
    # eval_steps=10, # Steps interval for evaluation
    # eval_strategy="steps", # Strategy for evaluation
    save_strategy="steps", # Strategy for saving the model
    save_steps=20, # Steps interval for saving
    metric_for_best_model="train_loss", # Metric to evaluate the best model
    greater_is_better=False, # Whether higher metric values are better
    # Mixed precision and gradient settings
    bf16=True, # Use bfloat16 precision
    deepspeed = "/content/zero_stage3_offload_config.json",
    max_grad_norm=0.3, # Maximum norm for gradient clipping
    warmup_ratio=0.03, # Ratio of total steps for warmup
    report_to="none", # Reporting tool for tracking metrics
    # Gradient checkpointing settings
    # gradient_checkpointing_kwargs={"use_reentrant": False}, # Options for gradient checkpointing
    # Dataset configuration
    dataset_text_field="", # Text field in dataset
    dataset_kwargs={"skip_prepare_dataset": True}, # Additional dataset options
    max_seq_length=1024 # Maximum sequence length for input
)

training_args.remove_unused_columns = False # Keep unused columns in dataset

```

this is my code , im getting the below error.please help me resolve it

 ![image](https://us1.discourse-cdn.com/hellohellohello/original/3X/a/4/a41c96b3c0a90f420f872fa565e3503e89f71e56.png)

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [April 21, 2025, 5:50am UTC](https://discuss.huggingface.co/t/error-using-deepspeed-for-sftconfig/151433/2 "2025-04-21T05:50:15Z")

</div>

Perhaps unresolved issue…

> <https://github.com/huggingface/transformers/issues/25739#issuecomment-2567925200>
>
> \### System Info
> \`\`\`python
> 2023-08-24 17:23:17.908613: W tensorflow/compiler/tf…2tensorrt/utils/py\_utils.cc:38\] TF-TRT Warning: Could not find TensorRT
> \[2023-08-24 17:23:20,478\] \[INFO\] \[real\_accelerator.py:158:get\_accelerator\] Setting ds\_accelerator to cuda (auto detect)
> WARNING:tensorflow:From /usr/local/lib/python3.10/dist-packages/transformers/commands/env.py:100: is\_gpu\_available (from tensorflow.python.framework.test\_util) is deprecated and will be removed in a future version.
> Instructions for updating:
> Use \`tf.config.list\_physical\_devices('GPU')\` instead.
> 2023-08-24 17:23:29.664543: W tensorflow/core/common\_runtime/gpu/gpu\_bfc\_allocator.cc:47\] Overriding orig\_value setting because the TF\_FORCE\_GPU\_ALLOW\_GROWTH environment variable is set. Original config value was 0.
> \`\`\`
> Copy-and-paste the text below in your GitHub issue and FILL OUT the two last points.
> 
> \- \`transformers\` version: 4.32.0
> \- Platform: Linux-5.15.109+-x86\_64-with-glibc2.35
> \- Python version: 3.10.12
> \- Huggingface\_hub version: 0.16.4
> \- Safetensors version: 0.3.3
> \- Accelerate version: 0.22.0
> \- Accelerate config: not found
> \- PyTorch version (GPU?): 2.0.1+cu118 (True)
> \- Tensorflow version (GPU?): 2.12.0 (True)
> \- Flax version (CPU?/GPU?/TPU?): 0.7.2 (gpu)
> \- Jax version: 0.4.14
> \- JaxLib version: 0.4.14
> \- Using GPU in script?: \<fill in\>
> \- Using distributed or parallel set-up in script?: \<fill in\>
> 
> \### Who can help?
> 
> @pacman
> 
> \### Information
> 
> \- \[\] The official example scripts
> \- \[X\] My own modified scripts
> 
> \### Tasks
> 
> \- \[\] An officially supported task in the \`examples\` folder (such as GLUE/SQuAD, ...)
> \- \[X\] My own task or dataset (give details below)
> 
> \### Reproduction
> 
> 1. Load deepspeed config into json file
> 2. Pass into TrainingArguments
> 3. Get error
> 
> Here is my code:
> \`\`\`python
> import json
> 
> deepspeed\_config = {
> "fp16": {
> "enabled": True,
> "loss\_scale": 0,
> "loss\_scale\_window": 1000,
> "initial\_scale\_power": 16,
> "hysteresis": 2,
> "min\_loss\_scale": 1
> },
> "optimizer": {
> "type": "AdamW",
> "params": {
> "lr": "auto",
> "betas": "auto",
> "eps": "auto",
> "weight\_decay": "auto"
> }
> },
> "scheduler": {
> "type": "WarmupLR",
> "params": {
> "warmup\_min\_lr": "auto",
> "warmup\_max\_lr": "auto",
> "warmup\_num\_steps": "auto"
> }
> },
> "zero\_optimization": {
> "stage": 2,
> "offload\_optimizer": {
> "device": "cpu",
> "pin\_memory": True
> },
> "allgather\_partitions": True,
> "allgather\_bucket\_size": 2e8,
> "overlap\_comm": True,
> "reduce\_scatter": True,
> "reduce\_bucket\_size": 2e8,
> "contiguous\_gradients": True
> },
> "steps\_per\_print": 100,
> "gradient\_accumulation\_steps": "auto",
> "gradient\_clipping": "auto",
> "train\_batch\_size": "auto",
> "train\_micro\_batch\_size\_per\_gpu": "auto",
> "activation\_checkpointing": {
> "partition\_activations": True,
> "contiguous\_memory\_optimization": True
> },
> "wall\_clock\_breakdown": False
> }
> 
> 
> config\_filename = "deepspeed\_config.json"
> 
> with open(config\_filename, 'w') as f:
> json.dump(deepspeed\_config, f)
> 
> trainer = Trainer(
> model=model,
> train\_dataset=train\_data,
> eval\_dataset=val\_data,
> args=TrainingArguments(
> num\_train\_epochs=num\_epochs,
> evaluation\_strategy='steps' if val\_set\_size \> 0 else 'no',
> save\_strategy='steps',
> eval\_steps=eval\_steps if val\_set\_size \> 0 else None,
> save\_steps=save\_steps,
> output\_dir=output\_dir,
> save\_total\_limit=save\_total\_limit,
> load\_best\_model\_at\_end=True if val\_set\_size \> 0 else False,
> deepspeed='./deepspeed\_config.json',
> ),
> data\_collator=DataCollatorForSeq2Seq(tokenizer, pad\_to\_multiple\_of=8, return\_tensors='pt', padding=True),
> callbacks=\[print\_callback\]
> )
> model.config.use\_cache = False
> trainer.train(resume\_from\_checkpoint=resume\_from\_checkpoint)
> model.save\_pretrained(output\_dir)
> \`\`\`
> Here is my error:
> \`\`\`
> \---------------------------------------------------------------------------
> TypeError Traceback (most recent call last)
> \[\<ipython-input-55-5c7ff182bcf8\>\](https://localhost:8080/#) in \<cell line: 1\>()
> 3 train\_dataset=train\_data,
> 4 eval\_dataset=val\_data,
> \----\> 5 args=TrainingArguments(
> 6 num\_train\_epochs=num\_epochs,
> 7 evaluation\_strategy='steps' if val\_set\_size \> 0 else 'no',
> 
> 3 frames
> \[/usr/local/lib/python3.10/dist-packages/transformers/deepspeed.py\](https://localhost:8080/#) in \_\_init\_\_(self, config\_file\_or\_dict)
> 64 dep\_version\_check("accelerate")
> 65 dep\_version\_check("deepspeed")
> \---\> 66 super().\_\_init\_\_(config\_file\_or\_dict)
> 67 
> 68 
> 
> TypeError: object.\_\_init\_\_() takes exactly one argument (the instance to initialize)
> \`\`\`
> \### Expected behavior
> 
> Trainer loads and runs.
> 
> PS. This is my first ever issue reported, I'm a domain scientist sorry if this isn't the normal way to report things.

> I’m don’t have a fix, but you could use 0.15.x version of deepspeed. I don’t get this error in that version
