### Install Oumi with Optional Dependencies Source: https://www.oumi.ai/docs/en/latest/_sources/get_started/installation Installs Oumi with specific optional dependencies. Examples include 'gpu' for GPU support, 'dev' for development tools, and cloud-specific packages like 'aws', 'azure', 'gcp', 'lambda', and 'runpod'. Multiple dependencies can be installed simultaneously. ```bash pip install "oumi[gpu]" ``` ```bash pip install "oumi[dev]" ``` ```bash pip install "oumi[aws]" ``` ```bash pip install "oumi[azure]" ``` ```bash pip install "oumi[gcp]" ``` ```bash pip install "oumi[lambda]" ``` ```bash pip install "oumi[runpod]" ``` ```bash pip install "oumi[aws,azure,gcp]" ``` -------------------------------- ### Oumi CLI Training Command Example Source: https://www.oumi.ai/docs/en/latest/get_started/quickstart An example of how to start training a model using a specified YAML configuration file with the Oumi CLI. This command utilizes a configuration file for training the SmolLM 135M Instruct model. ```bash # FFT config for SmolLM 135M Instruct. # # Usage: # oumi train -c configs/recipes/smollm/sft/135m/quickstart_train.yaml # # See Also: # - Documentation: https://oumi.ai/docs/en/latest/user_guides/train/train.html # - Config class: oumi.core.configs.TrainingConfig # - Config source: https://github.com/oumi-ai/oumi/blob/main/src/oumi/core/configs/training_config.py ``` -------------------------------- ### Oumi Training Configuration Example Source: https://www.oumi.ai/docs/en/latest/_sources/get_started/quickstart A YAML configuration file snippet used for training a SmolLM 135M model in a quickstart scenario. It defines parameters for the training process, data, and model. ```yaml recipe: smollm/sft/135m/quickstart_train.yaml ``` -------------------------------- ### Install Google Cloud SDK and Libraries Source: https://www.oumi.ai/docs/en/latest/get_started/quickstart Installs necessary Google Cloud SDK and Python client libraries using Conda. These are required for interacting with GCP services. ```bash conda install -c conda-forge google-cloud-sdk -y conda install -c conda-forge google-api-python-client -y conda install -c conda-forge google-cloud-storage -y ``` -------------------------------- ### Install Oumi with GCP Support Source: https://www.oumi.ai/docs/en/latest/get_started/quickstart Installs Oumi with specific support for Google Cloud Platform (GCP). This is a prerequisite for launching cloud jobs on GCP. ```bash pip install oumi[gcp] ``` -------------------------------- ### Install Oumi AI and GPU Dependencies Source: https://www.oumi.ai/docs/en/latest/_sources/get_started/quickstart Installs the Oumi AI library using pip. Includes an optional step to install GPU dependencies for systems with Nvidia or AMD GPUs. Assumes Python and pip are already set up. ```bash pip install oumi # Optional: If you have an Nvidia or AMD GPU, you can install the GPU dependencies pip install oumi[gpu] ``` -------------------------------- ### Installation Instructions Source: https://www.oumi.ai/docs/en/latest/_sources/user_guides/quantization Shows the pip commands to install the Oumi quantization package, with options for installing AWQ or BitsAndBytes separately. ```bash pip install oumi[quantization] # Alternatively, for AWQ quantization only pip install autoawq # Alternatively, for BitsAndBytes quantization only pip install bitsandbytes ``` -------------------------------- ### Train Model with Default Recipe Source: https://www.oumi.ai/docs/en/latest/_sources/get_started/quickstart Starts model training using a specified YAML configuration file. Assumes the configuration file exists and is correctly formatted for Oumi's training process. ```bash oumi train -c configs/recipes/smollm/sft/135m/quickstart_train.yaml ``` -------------------------------- ### Basic vLLM Remote Server Setup Source: https://www.oumi.ai/docs/en/latest/_sources/user_guides/infer/inference_engines Set up a basic vLLM server for development and testing purposes. This command starts an OpenAI-compatible API server for the specified model on a given port. ```bash python -m vllm.entrypoints.openai.api_server \ --model meta-llama/Llama-3.1-8B-Instruct \ --port 6864 ``` -------------------------------- ### Full Fine-tuning Example Configuration (YAML) Source: https://www.oumi.ai/docs/en/latest/_sources/user_guides/train/configuration Example YAML configuration for performing full fine-tuning on a small model ('SmolLM2-135M') without using any parameter-efficient methods. This file is intended for quickstart training scenarios. ```yaml include: ../../base.yaml training: output_dir: "/mnt/models/smollm2-135m-sft" run_name: "smollm2-135m-sft-quickstart" model: model_name_or_path: "hf-internal-testing/SmolLM2-135M" # LoRA configuration is disabled for full fine-tuning peft: null # GRPO configuration is typically not used for standard SFT grpo: null ``` -------------------------------- ### Install and Set Up Pre-Commit Hooks Source: https://www.oumi.ai/docs/en/latest/_sources/development/style_guide Installs pre-commit and sets up the hooks for the project. This ensures consistent code style and quality before committing changes. Run this command after cloning the repository. ```shell pip install '.[dev]' pre-commit install ``` -------------------------------- ### Install Oumi from PyPI Source: https://www.oumi.ai/docs/en/latest/_sources/get_started/installation Installs the latest stable version of the Oumi library from the Python Package Index (PyPI). This is the recommended installation method for most users. ```bash pip install oumi ``` -------------------------------- ### Setup Script for Package Installation Source: https://www.oumi.ai/docs/en/latest/user_guides/evaluate/leaderboards Defines the setup script executed before the main run command. It installs `uv` and then uses `uv` to install the `oumi` package with GPU and evaluation dependencies. ```bash setup: | set -e pip install uv && uv pip install --system oumi[gpu,evaluation] ``` -------------------------------- ### Configure GCP Account for Oumi Cloud Jobs (Bash) Source: https://www.oumi.ai/docs/en/latest/_sources/get_started/quickstart Set up your Google Cloud Platform (GCP) account to launch jobs with Oumi. This involves installing necessary Oumi dependencies with GCP support, installing Google Cloud SDK components, and configuring authentication and project settings using environment variables and gcloud commands. ```bash pip install oumi[gcp] ``` ```bash conda install -c conda-forge google-cloud-sdk -y conda install -c conda-forge google-api-python-client -y conda install -c conda-forge google-cloud-storage -y ``` ```bash export GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json gcloud auth activate-service-account --key-file=$GOOGLE_APPLICATION_CREDENTIALS gcloud config set project ``` -------------------------------- ### AWQ Quantization Examples (4-bit & 8-bit) Source: https://www.oumi.ai/docs/en/latest/_sources/user_guides/quantization Provides examples of performing 4-bit and 8-bit AWQ quantization on different models. AWQ is recommended for its quality-to-size ratio. ```bash # 4-bit AWQ quantization oumi quantize --method awq_q4_0 --model "TinyLlama/TinyLlama-1.1B-Chat-v1.0" --output tinyllama_awq4bit oumi quantize --method awq_q4_0 --model "oumi-ai/HallOumi-8B" --output halloumi_awq4bit # Higher precision 8-bit AWQ oumi quantize --method awq_q8_0 --model "TinyLlama/TinyLlama-1.1B-Chat-v1.0" --output tinyllama_awq8bit ``` -------------------------------- ### Quick Start: Quantize TinyLlama Model Source: https://www.oumi.ai/docs/en/latest/_sources/user_guides/quantization Demonstrates the basic command to quantize the TinyLlama model to 4-bit using the AWQ method. This is a quick way to start using the quantization feature. ```bash oumi quantize --method awq_q4_0 --model "TinyLlama/TinyLlama-1.1B-Chat-v1.0" --output quantized_model ``` -------------------------------- ### Specify Package Dependencies for Remote Execution Source: https://www.oumi.ai/docs/en/latest/_sources/user_guides/evaluate/leaderboards Example YAML `setup` block for installing necessary Python packages, such as Oumi's evaluation packages, on the remote machine. These packages are installed via a setup script executed before the main job starts. ```yaml setup: | pip install oumi[evaluation] ``` -------------------------------- ### Quick Start Training Command and Script Source: https://www.oumi.ai/docs/en/latest/_sources/user_guides/train/train Demonstrates how to initiate a training run using Oumi's CLI command and a Python script. It shows how to specify a configuration file for training a small model on a sample dataset. The process includes downloading a pre-trained model, loading a dataset, performing supervised fine-tuning, and saving the results. ```bash # Train a small model (SmolLM-135M) oumi train -c configs/recipes/smollm/sft/135m/quickstart_train.yaml ``` ```python from oumi import train from oumi.core.configs import TrainingConfig # Load config from file config = TrainingConfig.from_yaml("configs/recipes/smollm/sft/135m/quickstart_train.yaml") # Start training train(config) ``` -------------------------------- ### Oumi Core Configuration Example Source: https://www.oumi.ai/docs/en/latest/api/oumi.core.configs Demonstrates how to instantiate and combine configuration objects for model parameters, training parameters, and overall training configuration within the Oumi framework. These configurations are essential for setting up training pipelines. ```python >>> from oumi.core.configs import ModelParams, TrainingConfig, TrainingParams >>> model_params = ModelParams(model_name="gpt2") >>> training_params = TrainingParams(num_train_epochs=3) >>> training_config = TrainingConfig( ... model=model_params, ... training=training_params, ... ) >>> # Use the training_config in your training pipeline ``` -------------------------------- ### Oumi CLI Basic Usage and Help Source: https://www.oumi.ai/docs/en/latest/_sources/get_started/quickstart Demonstrates the general structure of Oumi CLI commands and how to access general or command-specific help using the --help flag. Lists the primary available commands. ```bash oumi [options] oumi --help # for general help oumi --help # for command-specific help ``` -------------------------------- ### Basic Setup and Run in Oumi AI Source: https://www.oumi.ai/docs/en/latest/user_guides/launch/deploy Defines the `setup` command to be executed once on cluster creation and the `run` command for the main job execution. The `setup` command here simply echoes a message, while the `run` command echoes an environment variable. ```shell setup: | echo "Running setup..." run: | set -e # Exit if any command failed. echo "$TEST_ENV_VARIABLE" ``` -------------------------------- ### Running Quantization with a Configuration File Source: https://www.oumi.ai/docs/en/latest/_sources/user_guides/quantization Demonstrates how to execute the quantization process using a previously defined configuration file. This ensures consistency and reusability. ```bash oumi quantize --config quantization_config.yaml ``` -------------------------------- ### Evaluate Newly Trained Model Source: https://www.oumi.ai/docs/en/latest/_sources/get_started/quickstart Evaluates a model using a specified configuration file. This example points to a model that has been newly trained and saved locally to a specific directory on disk. ```bash oumi evaluate -c configs/recipes/smollm/evaluation/135m/quickstart_eval.yaml \ --model.model_name output/smollm135m.fft ``` -------------------------------- ### Oumi Evaluation Configuration Example Source: https://www.oumi.ai/docs/en/latest/_sources/get_started/quickstart A YAML configuration file snippet for evaluating a SmolLM 135M model. It specifies the recipe to be used for evaluation, likely including details about benchmarks and metrics. ```yaml recipe: smollm/evaluation/135m/quickstart_eval.yaml ``` -------------------------------- ### Example hello_world_gcp_job.yaml Source: https://www.oumi.ai/docs/en/latest/_sources/user_guides/launch/deploy An example YAML configuration file for a 'hello world' job intended for deployment on GCP. This file specifies job parameters like resources and environment variables. ```yaml name: hello-world-gcp resources: cloud: gcp accelerators: A100 working_dir: "gs://oumi-public/examples/misc/hello_world" envs: OUMI_LOGGING_DIR: "deploy_tutorial/logs" setup: | echo "Running setup for hello world job..." run: | set -e echo "Hello, world from GCP!" ls -la cat /proc/cpuinfo ``` -------------------------------- ### Evaluate Model using HuggingFace Hub Model Source: https://www.oumi.ai/docs/en/latest/_sources/get_started/quickstart Evaluates a model using a specified evaluation configuration file. This example uses a model directly from the HuggingFace Hub by its model name. ```bash oumi evaluate -c configs/recipes/smollm/evaluation/135m/quickstart_eval.yaml \ --model.model_name HuggingFaceTB/SmolLM2-135M-Instruct ``` -------------------------------- ### Oumi Tuner Usage Example Source: https://www.oumi.ai/docs/en/latest/api/oumi.core.tuners Demonstrates how to initialize and run a Tuner from the oumi.core.trainers module. This example requires a model, dataset, and tuning parameters to be defined beforehand. ```python >>> from oumi.core.trainers import Tuner >>> tuner = Tuner(model=my_model, dataset=my_dataset, tuning_params=params) >>> trainer.optimize() ``` -------------------------------- ### Standalone Distributed Training with Torchrun Source: https://www.oumi.ai/docs/en/latest/_sources/get_started/quickstart Executes a distributed training run directly using `torchrun` in standalone mode. This command specifies the number of processes per node and a directory for logs, suitable for multi-GPU setups. ```bash torchrun --standalone --nproc-per-node 4 --log-dir ./logs \ -m oumi train -c configs/recipes/smollm/sft/135m/quickstart_train.yaml --training.output_dir output/smollm-135m-sft-dist ``` -------------------------------- ### Training Configuration Example Source: https://www.oumi.ai/docs/en/latest/_sources/user_guides/train/train Provides an example of a YAML configuration file for Oumi training. It details key parameters such as the base model, data sources, training precision, output directory, number of epochs, learning rate, and checkpoint frequency. This structure allows for reproducible and version-controlled training setups. ```yaml model: model_name: "HuggingFaceTB/SmolLM2-135M-Instruct" # Base model to fine-tune trust_remote_code: true # Required for some model architectures dtype: "bfloat16" # Training precision (float32, float16, or bfloat16) data: train: # Training dataset mixture datasets: - dataset_name: "tatsu-lab/alpaca" # Training dataset split: "train" # Dataset split to use training: output_dir: "output/my_training_run" # Where to save outputs num_train_epochs: 3 # Number of training epochs learning_rate: 5e-5 # Learning rate save_steps: 100 # Checkpoint frequency ``` -------------------------------- ### Oumi AI QuantizationConfig Example Source: https://www.oumi.ai/docs/en/latest/api/oumi.core.configs Demonstrates how to initialize and configure the QuantizationConfig class in Oumi AI. This example shows setting the model, quantization method, and output path for creating a quantized model. It assumes the ModelParams class is available for specifying the model to be quantized. ```python config = QuantizationConfig( model=ModelParams(model_name="meta-llama/Llama-2-7b-hf"), method="awq_q4_0", output_path="llama2-7b-q4.gguf" ) ``` -------------------------------- ### Set Oumi Install Editable Source: https://www.oumi.ai/docs/en/latest/api/oumi.utils Attempts to replace Oumi PyPi installs with editable installations from source by modifying a bash setup script. ```APIDOC ## POST /set_oumi_install_editable ### Description Tries to replace Oumi PyPi installs with editable installation from source. ### Method POST ### Endpoint /set_oumi_install_editable ### Parameters #### Request Body - **setup** (str) - The bash setup script to modify. May be multi-line. ### Request Example ```json { "setup": "pip install oumi[gpu]" } ``` ### Response #### Success Response (200) - **modified_setup** (str) - The modified setup script. ### Response Example ```json { "modified_setup": "pip install -e \'.[gpu]\'" } ``` ``` -------------------------------- ### CLI Reference: Basic and Config File Usage Source: https://www.oumi.ai/docs/en/latest/_sources/user_guides/quantization Provides command-line examples for basic quantization and using configuration files. It covers overriding configuration options directly via the CLI. ```bash # Basic usage oumi quantize --method METHOD --model MODEL --output OUTPUT # With configuration file oumi quantize --config CONFIG_FILE # Override config options oumi quantize --config CONFIG_FILE --method awq_q8_0 ``` -------------------------------- ### Launch Cloud Training Job Source: https://www.oumi.ai/docs/en/latest/get_started/quickstart Launches a training job on GCP using a specified configuration file. This command initiates the Oumi training process on a cloud instance. ```bash oumi launch up -c configs/recipes/smollm/sft/135m/quickstart_gcp_job.yaml ``` -------------------------------- ### Install vLLM Engine for Oumi Source: https://www.oumi.ai/docs/en/latest/_sources/user_guides/infer/inference_engines Provides instructions for installing the vLLM package, which is necessary for using the vLLM inference engine. Alternatively, installing `oumi[gpu]` handles compatible vLLM installation. ```bash pip install vllm # Alternatively, install all Oumi GPU dependencies, which takes care of installing a # vLLM version compatible with your current Oumi version. pip install oumi[gpu] ``` -------------------------------- ### Full Fine-tuning Example Configuration Source: https://www.oumi.ai/docs/en/latest/user_guides/train/configuration Example configuration file for performing full fine-tuning (SFT) on a small model (SmolLM2-135M) without parameter-efficient methods. This YAML file specifies training parameters and usage instructions. ```yaml # FFT config for SmolLM 135M Instruct. # # Usage: # oumi train -c configs/recipes/smollm/sft/135m/quickstart_train.yaml # # See Also: # - Documentation: https://oumi.ai/docs/en/latest/user_guides/train/train.html # - Config class: oumi.core.configs.TrainingConfig # - Config source: https://github.com/oumi-ai/oumi/blob/main/src/oumi/core/configs/training_config.py ``` -------------------------------- ### Verify Oumi Installation Source: https://www.oumi.ai/docs/en/latest/_sources/get_started/installation Verifies the successful installation of Oumi by executing the command-line interface and checking for the help message output. This confirms that the Oumi executable is available and working. ```bash oumi --help ``` -------------------------------- ### Configure and Run Oumi Evaluation Job (Shell) Source: https://www.oumi.ai/docs/en/latest/get_started/quickstart This snippet configures and runs an Oumi evaluation job using a YAML configuration file. It sets up the environment by installing necessary packages via 'uv' and then executes the evaluation command. The script ensures that any command failure will halt execution. ```shell set -e pip install uv && uv pip install --system oumi[gpu,evaluation] set -e # Exit if any command failed. source ./configs/examples/misc/sky_init.sh set -x oumi evaluate -c configs/recipes/smollm/evaluation/135m/quickstart_eval.yaml echo "Evaluation complete!" ``` -------------------------------- ### Install Jupyter and Oumi Separately (Bash) Source: https://www.oumi.ai/docs/en/latest/_sources/user_guides/train/environments/notebooks Installs Jupyter Lab and the Oumi library independently using pip. This option provides more granular control over the installation process. ```bash pip install jupyterlab ipykernel pip install oumi ``` -------------------------------- ### Install Oumi with Jupyter Dependencies Source: https://www.oumi.ai/docs/en/latest/user_guides/train/environments/notebooks Installs the Oumi library along with development dependencies, including Jupyter, for a comprehensive setup. ```shell # Install Oumi with development dependencies (includes Jupyter) pip install oumi[dev] ``` -------------------------------- ### FSDP Distributed Training Example Configuration (YAML) Source: https://www.oumi.ai/docs/en/latest/_sources/user_guides/train/configuration Example YAML configuration for fine-tuning a medium-sized model ('Llama-3.1-8b') using Fully Sharded Data Parallel (FSDP) for distributed training. This setup enables efficient training across multiple GPUs. ```yaml include: ../../base.yaml training: output_dir: "/mnt/models/llama3_1-8b-sft-fsdp" run_name: "llama3_1-8b-sft-fsdp" model: model_name_or_path: "meta-llama/Llama-3.1-8b-hf" # Enable FSDP for distributed training fsdp: enable_fsdp: true sharding_strategy: "FULL_SHARD" cpu_offload: false mixed_precision: "bf16" backward_prefetch: "BACKWARD_PRE" forward_prefetch: false use_orig_params: false state_dict_type: "FULL_STATE_DICT" auto_wrap_policy: "TRANSFORMER_BASED" min_num_params: 100000 transformer_layer_cls: "LlamaDecoderLayer" sync_module_states: true # LoRA configuration is typically not used for standard FSDP full fine-tuning peft: null # GRPO configuration is typically not used for standard SFT grpo: null ``` -------------------------------- ### Install boto3 for AWS Bedrock (Bash) Source: https://www.oumi.ai/docs/en/latest/_sources/user_guides/infer/inference_engines This command installs the AWS SDK for Python (boto3), which is required to interact with AWS Bedrock. Ensure you have pip installed to run this command. ```bash pip install boto3 ``` -------------------------------- ### LlamaCpp Inference Engine Setup and Usage (Python) Source: https://www.oumi.ai/docs/en/latest/api/oumi.inference Demonstrates how to initialize and use the LlamaCppInferenceEngine for local inference. This engine requires the 'llama-cpp-python' package. It takes ModelParams, including the model path and optional model arguments, to set up the local inference environment. ```Python from oumi.core.configs import ModelParams from oumi.inference import LlamaCppInferenceEngine model_params = ModelParams( model_name="path/to/model.gguf", model_kwargs={ "n_gpu_layers": -1, "n_threads": 8, "flash_attn": True } ) engine = LlamaCppInferenceEngine(model_params) # Use the engine for inference ``` -------------------------------- ### Install Oumi from GitHub Repository (HTTPS) Source: https://www.oumi.ai/docs/en/latest/_sources/get_started/installation Installs the latest development version of Oumi directly from its GitHub repository using HTTPS. This is an alternative to SSH for users who prefer HTTPS connections. ```shell pip install git+https://github.com/oumi-ai/oumi.git ``` -------------------------------- ### Install LlamaCPP Python Library Source: https://www.oumi.ai/docs/en/latest/user_guides/infer/inference_engines Provides the command to install the llama-cpp-python library, which is necessary for using the LlamaCPP inference engine. ```bash pip install llama-cpp-python ``` -------------------------------- ### SGLang Server Setup and Client Configuration Source: https://www.oumi.ai/docs/en/latest/user_guides/infer/inference_engines Instructions for setting up an SGLang inference server and configuring a client to connect to it. ```APIDOC ## Remote SGLang SGLang provides high-performance LLM inference capabilities through its model server. ### Server Setup Start the SGLang server using the following command: ```bash python -m sglang.launch_server \ --model-path meta-llama/Llama-3.1-8B-Instruct \ --port 6864 \ --disable-cuda-graph \ --mem-fraction-static=0.99 ``` For more advanced configuration options, consult the SGLang documentation. ### Client Configuration Clients can connect to the SGLang server with various performance and reliability settings. ```python from oumi.inference import SGLangInferenceEngine from oumi.core.configs import ModelParams, RemoteParams engine = SGLangInferenceEngine( model_params=ModelParams( model_name="meta-llama/Llama-3.1-8B-Instruct" ), remote_params=RemoteParams( api_url="http://localhost:6864" ) ) ``` **Interactive Inference:** To run inference interactively, use the `oumi infer` command with the `-i` flag: ```bash oumi infer -c configs/recipes/llama3_1/inference/8b_sglang_infer.yaml -i ``` ``` -------------------------------- ### Install vLLM and Oumi GPU Dependencies Source: https://www.oumi.ai/docs/en/latest/user_guides/infer/inference_engines Instructions for installing the vLLM package directly or installing Oumi with GPU support, which includes a compatible vLLM version. These commands are run using pip. ```bash pip install vllm # Alternatively, install all Oumi GPU dependencies, which takes care of installing a # vLLM version compatible with your current Oumi version. pip install oumi[gpu] ``` -------------------------------- ### Quantization Configuration File Example (YAML) Source: https://www.oumi.ai/docs/en/latest/_sources/user_guides/quantization Illustrates a YAML configuration file for reproducible quantization workflows. It specifies model, method, output path, and quantization-specific parameters. ```yaml # quantization_config.yaml model: model_name: "TinyLlama/TinyLlama-1.1B-Chat-v1.0" trust_remote_code: false method: "awq_q4_0" output_path: "tinyllama_quantized" output_format: "safetensors" # Options: safetensors awq_group_size: 128 # AWQ-specific: weight grouping size calibration_samples: 512 # AWQ-specific: calibration dataset size ``` -------------------------------- ### Defining Inline Few-Shot Examples (YAML) Source: https://www.oumi.ai/docs/en/latest/_sources/user_guides/synth Sets up inline examples for few-shot learning. This allows providing direct examples within the configuration to guide the model's behavior for specific tasks. ```yaml input_examples: - examples: - attribute1: "value1" attribute2: "value2" - attribute1: "value3" attribute2: "value4" ```