Interview, Fireside Chat, Webinar, Conference Presentation
The Uncertain Art of Accelerating ML Models with Sylvain Gugger
Jane StreetSylvain Gugger, Ron Minsky, Jeremy Howard, Mark Mandelmann, Mark Mirchandani, Francesc Campoy, Gabriel Sanchez
Speaker Background & Career Trajectory
- Originally a math teacher in France for university-level students for 10 years.
- Moved to the U.S. in 2015; became interested in AI after reading a 2017 New York Times article and taking the fast.ai course.
- Co-authored the book Deep Learning for Coders with Jeremy Howard and was a core maintainer of the Hugging Face Transformers library.
- Wrote Hugging Face Accelerate to address the "black box" nature of existing training frameworks.
- Joined Jane Street as a machine learning engineer to focus on optimizing model performance and training infrastructure.
The Top Bench Competition & Technical Breakthroughs
- Participated in the "Top Bench Competition" (ancestor of the MLPath benchmark) with a fast.ai team.
- The team held first place until Google publicly released TPUs, which outperformed their best entry due to massive compute power.
- Winning Optimization 1: Learning Rate Schedules
- Replaced inefficient, low-rate training with a "warm-up" schedule (low to high to low).
- This approach allows the model to descend steep "canyons" in the loss landscape quickly without exploding, then refine convergence at the end.
- This schedule is now standard in open-source large language models (e.g., GPT variants).
- Winning Optimization 2: Gradual Image Resizing
- Trained Convolutional Neural Networks (CNNs) on small images (e.g., 128x128) and gradually increased resolution.
- Reduced initial compute cost by processing fewer pixels while the model was untrained.
- This technique remains less widely adopted than the learning rate schedule.
Fast.ai Mission & Philosophy
- Operates as a non-profit dedicated to democratizing deep learning education.
- Mission emphasizes training domain experts (e.g., radiologists) in ML principles rather than just coders.
- Goal is to ensure domain experts can effectively collaborate with engineers to build high-performing models.
Hugging Face & The "Accelerate" Library
- Joined Hugging Face in June 2020 after the pandemic disrupted Fast.ai plans.
- Problem with Hugging Face Trainer: The standard trainer had become "spaghetti code" with excessive flags, making it hard for researchers to customize training loops.
- Solution (Accelerate): Created a lightweight library allowing researchers to run training loops on diverse hardware with minimal code changes (originally 6 lines, reduced to 5).
- Targeted Hardware Diversity: Abstractions handle data parallelism and mixed-precision training across GPUs, TPUs, and CPUs without manual boilerplate.
- Handles the complexity of detecting hardware environments and injecting necessary distributed training logic automatically.
Hardware & Networking Architecture
- CPU vs. GPU vs. TPU:
- CPUs are sequential interpreters; GPUs and TPUs are built for highly parallel, regular computations.
- Modern training requires massive parallelism (data, pipeline, and tensor parallelism).
- Networking Criticality:
- Tensor parallelism requires extremely low-latency, high-bandwidth communication (InfiniBand, NVLink).
- Physical stacking of GPUs (e.g., NVIDIA HGX cabinets with 72 GPUs) minimizes network distance.
- Kernel bypass and RDMA (Remote Direct Memory Access) are essential to avoid CPU bottlenecks during data transfer.
- Precision Trends:
- Shift from float32 to float16/bfloat16 for 2x–4x speedups via specialized tensor cores.
- Newer Blackwell GPUs introduce support for float8 and potentially float4 for further efficiency.
- CPU vs. GPU vs. TPU:
Programming Ecosystem & PyTorch Dominance
- Why PyTorch Won:
- Prioritizes flexibility and ease of iteration (eager execution) over static compilation graphs.
- Allows researchers to "fool around" with ideas quickly; optimization can be applied later if the idea proves viable.
- Torch.compile & Triton:
- PyTorch 2.0 introduced
Torch.compileto address the "CPU scheduling GPU" bottleneck. - Uses Triton (a Python-based DSL) to fuse multiple kernels into single, efficient CUDA kernels.
- Kernel fusion avoids intermediate memory writes/reads and reduces kernel launch overhead.
- PyTorch 2.0 introduced
- CUDA Graphs: Record kernel execution graphs to eliminate CPU overhead on replay.
- CUDA Streams: Allow overlapping data transfers and computation to hide latency, provided operations are independent.
- Why PyTorch Won:
Jane Street Specifics: Data & Performance Challenges
- Data Characteristics:
- Financial data is significantly noisier than text or images; signals are weak and self-destructing (market adaptation).
- Massive data volume (terabytes per day) requires efficient data loading pipelines.
- Performance Constraints:
- Inference latency requirements range from nanoseconds (HFT) to milliseconds, dictating model size and architecture.
- Need to keep up with high-frequency event rates (e.g., 1 million events/day per stock).
- Tooling Gaps:
- Internal training infrastructure historically suffered from "ossified" spaghetti code.
- Jane Street is moving toward modular, configurable training loops (similar to
Accelerate) to empower researchers.
- Custom Models:
- Must invent new architectures adapted to financial time series rather than relying solely on LLM or vision models.
- Data Characteristics:
Education & Research Discipline
- Training Program: Jane Street runs bootcamps for traders and researchers to build ML literacy and domain expertise.
- Key Educational Hurdles:
- Reproducibility: Beginners often fail to document hyperparameters, code revisions, and environment versions, making experiments non-reproducible.
- Non-Determinism: GPU parallelism and floating-point arithmetic order can lead to slight result variations.
- Philosophy: ML is often described as a "cooking science"; generalization theory is incomplete, requiring empirical iteration.
- Best Practices:
- Enforce strict version control for code and dependencies.
- Log all hyperparameters and random seeds.
- Avoid Python notebook execution ordering issues by migrating to scripted workflows early.