Posts

Showing posts with the label GPU Compute

Post-training GPT Neo 1B with Rust & PyTorch Pt. 1 | ML Engineering

Image
 Hi All  Today we have an example of post-training a small model (GPT Neo 1B) in pure Rust. This example focuses of the training loop and model updates, assuming you've already loaded the model weights. Key Areas : 1.      Model Loading : We'll use the rust-bert crate for model loading. (supports GPT-Neo) 2.      Training Loop : Pure Rust implementation with tch-rs (Torch bindings) for tensor operations. 3.      Optimizer : AdamW optimizer for training.   View full code example below: The following is a block-by-block breakdown of the Rust post-training code above.   1. Dependencies and Imports use tch::{nn, Device, Tensor, Kind}; // Torch bindings for Rust use rust_bert::pipelines::common::ModelType; // Model types (GPT-Neo/Llama) use rust_bert::pipelines::text_generation::TextGenerationModel; // Model pipeline use anyhow::Result; // Error handling *      tch - Rust binding for PyTorch *  ...

Training TinyLlama 1.1B with PyTorch in Google Colab | ML Engineering

Image
Hi All Today we'll be loading a pre-trained model and train it on Colab. Here's a minimal example using Huggingface for transformers and accelerate for memory efficiency. View source below. Let's break down the above code. Block by block. I'm assuming you're using a notebook for this example. However in the full example in my GitHub I've included the Ops files too (Docker and k8s for GKE or AKS). I don't go into those here, I'll have a series of articles tacking MLOps in depth, this is about fine-tuning a pre-trained small LLM in Colab.  Prep: Setup Environment   !pip install -q transformers accelerate datasets peft bitsandbytes   *     transformers provides pre-trained models and training utilities *      peft enables LoRA (low-rank Adaptation), reducing memory usage *        bitsandbytes allows 8-bit precision to shrink model size *        accelerate helps manage GPU memory and multi-GPU setups ...