Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Environment:AI4Finance Foundation FinGPT DeepSpeed

From Leeroopedia
Knowledge Sources
Domains Deep_Learning, Distributed_Training
Last Updated 2026-10-18 00:00 GMT

Overview

DeepSpeed distributed training framework with ZeRO optimization, mixed-precision (`fp16`), and CPU offloading support for supervised fine-tuning of large language models.

Description

This environment provides the DeepSpeed library used by the RAG supervised fine-tuning (`main.py`) and benchmark/forecaster training scripts. It handles distributed process group initialization (`deepspeed.init_distributed`), ZeRO stage configuration, optimizer selection (`FusedAdam`, `DeepSpeedCPUAdam`, `ZeroOneAdam`), and gradient offloading. DeepSpeed configs are provided as JSON files (e.g., `config_new.json`, `config.json`) with `"auto"` values that are filled at runtime from `TrainingArguments`.

Usage

Use this environment for multi-GPU or multi-node distributed training of LLMs via DeepSpeed-Chat SFT. Required by `deepspeed_sft_main`, `create_hf_model`, and `convert_linear_layer_to_lora` implementations. Also used by HuggingFace `Trainer` via `deepspeed=args.ds_config`.

System Requirements

Category Requirement Notes
OS Linux Required for NCCL backend
Hardware Multi-GPU NVIDIA 1-8+ GPUs; V100-32G, A100-40G/80G recommended
Network NCCL-compatible Multi-node requires low-latency interconnect

Dependencies

Python Packages

  • `deepspeed` >= 0.10.0
  • `torch` >= 2.0.1
  • `transformers` >= 4.32.0
  • `accelerate` >= 0.23.0

DeepSpeed Config Files

  • `config_new.json`: AdamW optimizer, WarmupDecayLR scheduler, ZeRO stage 0, fp16 enabled
  • `config.json`: ZeroOneAdam optimizer, WarmupLR scheduler, NCCL backend, fp16 enabled

Credentials

No additional credentials required beyond HuggingFace Hub access for model weights.

Quick Install

pip install deepspeed torch>=2.0.1 transformers>=4.32.0 accelerate>=0.23.0

Code Evidence

Distributed initialization from `fingpt/FinGPT_RAG/instruct-FinGPT/training/supervised_finetuning/main.py:181-188`:

if args.local_rank == -1:
    device = torch.device("cuda")
else:
    torch.cuda.set_device(args.local_rank)
    device = torch.device("cuda", args.local_rank)
    deepspeed.init_distributed()

Optimizer selection with offload from `fingpt/FinGPT_RAG/instruct-FinGPT/training/supervised_finetuning/main.py:307`:

AdamOptimizer = DeepSpeedCPUAdam if args.offload else FusedAdam

Gradient checkpointing assertion from `fingpt/FinGPT_RAG/instruct-FinGPT/training/supervised_finetuning/main.py:169-172`:

if args.gradient_checkpointing and args.lora_dim > 0:
    assert (
        not args.only_optimize_lora
    ), "--gradient_checkpointing and --only_optimizer_lora cannot be enabled at the same time."

Common Errors

Error Message Cause Solution
`zero-offload is not currently supported` Offload not yet implemented Assertion in `main.py:203`; disable `--offload`
`--gradient_checkpointing and --only_optimizer_lora cannot be enabled` Mutually exclusive flags Disable one of the two options
`NCCL connection refused` Multi-node network issue Ensure `MASTER_ADDR` and `MASTER_PORT` are set correctly

Compatibility Notes

  • ZeRO Stage 0: Default configs use stage 0 (no partitioning); set `zero_stage` for multi-GPU partitioning.
  • CPU Offload: Uses `DeepSpeedCPUAdam`; assertion blocks it in current SFT code (`assert not args.offload`).
  • ZeRO Stage 3: LoRA layer conversion handles `ds_id`/`ds_shape` via `try/except` fallback in `lora.py:32-35`.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment