All Toolsโ€บLLM Training Optimizer
๐Ÿ’ฌ Open-Source LLM DevelopmentJuly 26, 2026โœ… Tests passing

LLM Training Optimizer

A CLI tool to automatically generate optimized training configurations for open-source LLMs based on hardware specs and dataset size. This helps developers fine-tune models efficiently without manually tweaking settings, maximizing hardware utilization and training performance.

What It Does

  • Autodetect hardware specifications (RAM and CPU cores).
  • Generate YAML configuration files for training.
  • Supports multiple open-source LLM frameworks.
  • Suggests batch size, number of workers, and precision settings based on hardware.

Installation

  • Python 3.7+
  • psutil==5.9.5
  • PyYAML==6.0

Usage

python llm_training_optimizer.py --model gpt-j --dataset_size 10GB

Example with Hardware File

python llm_training_optimizer.py --model llama --dataset_size 500MB --hardware_specs hardware.yaml

Output

The tool generates a YAML configuration file (default: config.yaml) containing optimized training settings.

Source Code

import argparse
import yaml
import psutil

def autodetect_hardware():
    """Autodetects hardware specifications."""
    memory = psutil.virtual_memory().total // (1024 ** 3)  # Convert bytes to GB
    cpu_count = psutil.cpu_count()
    return {
        "memory_gb": memory,
        "cpu_cores": cpu_count
    }

def generate_config(hardware_specs, model, dataset_size):
    """Generates optimized training configuration based on inputs."""
    config = {
        "model": model,
        "dataset_size": dataset_size,
        "hardware": hardware_specs,
        "training": {
            "batch_size": min(64, hardware_specs["memory_gb"] * 2),
            "num_workers": max(1, hardware_specs["cpu_cores"] // 2),
            "precision": "fp16" if hardware_specs["memory_gb"] >= 16 else "fp32"
        }
    }
    return config

def main():
    parser = argparse.ArgumentParser(description="LLM Training Optimizer")
    parser.add_argument("--model", required=True, help="Model type (e.g., gpt-j, llama, etc.)")
    parser.add_argument("--dataset_size", required=True, help="Dataset size (e.g., 10GB, 500MB)")
    parser.add_argument("--hardware_specs", help="Hardware specs as a YAML file")
    parser.add_argument("--output", default="config.yaml", help="Output configuration file")

    args = parser.parse_args()

    if args.hardware_specs:
        try:
            with open(args.hardware_specs, "r") as file:
                hardware_specs = yaml.safe_load(file)
        except FileNotFoundError:
            print("Error: Hardware specs file not found.")
            return
        except yaml.YAMLError:
            print("Error: Invalid YAML format in hardware specs file.")
            return
    else:
        hardware_specs = autodetect_hardware()

    dataset_size = args.dataset_size
    model = args.model

    config = generate_config(hardware_specs, model, dataset_size)

    try:
        with open(args.output, "w") as file:
            yaml.dump(config, file)
        print(f"Configuration saved to {args.output}")
    except Exception as e:
        print(f"Error: Unable to save configuration file. {e}")

if __name__ == "__main__":
    main()

Community

Downloads

ยทยทยท

Rate this tool

No ratings yet โ€” be the first!

Details

Tool Name
llm_training_optimizer
Category
Open-Source LLM Development
Generated
July 26, 2026
Tests
Passing โœ…

Quick Install

Clone just this tool:

git clone --depth 1 --filter=blob:none --sparse \
  https://github.com/ptulin/autoaiforge.git
cd autoaiforge
git sparse-checkout set generated_tools/2026-07-26/llm_training_optimizer
cd generated_tools/2026-07-26/llm_training_optimizer
pip install -r requirements.txt 2>/dev/null || true
python llm_training_optimizer.py
LLM Training Optimizer โ€” AI Tools by AutoAIForge