fix: use torchrun for distributed training, load model on CPU
This commit is contained in:
@@ -68,7 +68,8 @@ echo "Training will take 6-24 hours depending on GPU."
|
|||||||
echo "Press Ctrl+C to stop (model will be saved at checkpoint)."
|
echo "Press Ctrl+C to stop (model will be saved at checkpoint)."
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
python3 training/scripts/train.py --config training/configs/llama2-7b-lora.yaml
|
# Use torchrun for distributed training (2 GPUs)
|
||||||
|
torchrun --nproc_per_node=2 training/scripts/train.py --config training/configs/llama2-7b-lora.yaml
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "=== Training Complete ==="
|
echo "=== Training Complete ==="
|
||||||
|
|||||||
@@ -36,10 +36,11 @@ def train(config_path):
|
|||||||
|
|
||||||
# Load model - let the model's own quantization config handle it
|
# Load model - let the model's own quantization config handle it
|
||||||
# (Ornith uses CompressedTensors, not BitsAndBytes)
|
# (Ornith uses CompressedTensors, not BitsAndBytes)
|
||||||
|
# Load on CPU first, then DeepSpeed will distribute
|
||||||
model = AutoModelForCausalLM.from_pretrained(
|
model = AutoModelForCausalLM.from_pretrained(
|
||||||
config["base_model"],
|
config["base_model"],
|
||||||
torch_dtype=torch.bfloat16,
|
dtype=torch.bfloat16,
|
||||||
device_map="auto", # Let transformers distribute across GPUs
|
device_map="cpu", # Load on CPU, DeepSpeed distributes
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add LoRA
|
# Add LoRA
|
||||||
|
|||||||
Reference in New Issue
Block a user