TorchLean

7. Examples and Applications🔗

The final section shows TorchLean in use. Earlier chapters described the semantic pieces: typed tensors, graph IR, runtime execution, floating point models, CUDA boundaries, autograd proofs, and verification checkers. The examples show how those pieces behave when they meet real ML shapes.

By the end of the guide, the system should not feel like a collection of isolated formalizations. The examples range from small MLPs to GPT-style models, Mamba, ResNet, ViT, FNOs, diffusion, and reinforcement learning because those models bring in the details that matter in practice: masks, positions, residual branches, scan state, spectral convolutions, sampling schedules, environment transitions, and GPU execution.

The examples are small enough to inspect, but they touch real sources of complexity. A causal language model is not only a tensor program; it has token ids, positions, masks, and sometimes a cache. An FNO is not only a supervised model; it has spectral structure and scientific data. An RL example is not only a loss function; it has an environment boundary and trajectory data. BugZoo then takes the same idea one step further by showing how common ML bugs can be turned into explicit contracts.

The question to ask of each example is not only "did it run?" The better question is: what object did it produce, what can we inspect, and what claim could this object support?

  1. 7.1. Modern Models and Training
  2. 7.2. Model Zoo Deep Dive
  3. 7.3. Generative Models and ML Theory
  4. 7.4. Reinforcement Learning Stack
  5. 7.5. Widgets
  6. 7.6. BugZoo Catalog
  7. 7.7. Example Walkthroughs
  8. 7.8. Command-Line Tools
  9. 7.9. Conclusion