Skip to content

Instantly share code, notes, and snippets.

View nihalpasham's full-sized avatar
🦂
regionaltantrums!

nihalpasham

🦂
regionaltantrums!
View GitHub Profile
@nihalpasham
nihalpasham / zst-in-mir-demo.md
Created April 7, 2026 07:50
ZSTs occupy zero bytes at runtime — the compiler strips it before generating machine code. But in MIR, it gets real operands, real types, and if you're building a backend that consumes MIR… real bugs.
@nihalpasham
nihalpasham / .md
Created April 3, 2026 05:01
Promoted Constants in Rust MIR
@nihalpasham
nihalpasham / .md
Created April 3, 2026 04:58
Your `for` Loop Is a Lie: How Rust Desugars Iterators in MIR
@nihalpasham
nihalpasham / .md
Last active April 3, 2026 04:57
Rust (mir) compiler bites: Closures — thou shalt not name this struct

Closures Are Just Structs: MIR's Closure Desugaring

When you write |x| x + factor, Rust creates an anonymous struct, implements a trait on it, and calls a method.

Table of Contents

  1. The Code
  2. Dumping the MIR
  3. The Desugaring Chain
@nihalpasham
nihalpasham / stable-mir.md
Last active March 20, 2026 07:16
stable-mir's goal is to provide a stable interface to the Rust compiler, enabling tool developers to perform advanced analyses with lower maintenance costs, without slowing compiler development.
@nihalpasham
nihalpasham / stable-mir-compile-errors.md
Created September 30, 2025 13:14
stable-mir-compile-errors
./x build
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.07s
$ cargo +nightly-aarch64-apple-darwin build --manifest-path /Users/nihalpasham/devspace/rust/compiler/rustc_public/rustc_public/Cargo.toml --all-targets
   Compiling rustc_public v0.1.0-preview (/Users/nihalpasham/devspace/rust/compiler/rustc_public/rustc_public)
error[E0412]: cannot find type `DynKind` in module `rustc_ty`
   --> rustc_public/src/unstable/convert/internal.rs:464:30
    |
464 |     type T<'tcx> = rustc_ty::DynKind;
    |                              ^^^^^^^
@nihalpasham
nihalpasham / gpgpu_programming.md
Created September 20, 2025 12:39
Making GP-GPU programming generally accessible

GP-GPU Programming Ramblings

#nvidia #cuda #gpu #arch #metal #rocm #triton

image
  • Tensor Cores and Tensor Memory Accelerator
  • Split Barriers (Ampere and above)
  • Thread Block Cluster (Hopper and above)
  • Producer-Consumer Queues
@nihalpasham
nihalpasham / WebGPU+WGML.md
Created September 10, 2025 02:07
The only true cross-platform GPGPU API —WebGPU (with WGML 🦀)

True cross-platform GPU compute —WebGPU + WGML

image 2 basic-webgpu-stack ![](image.png) image

WebGPU vs WebGL

@nihalpasham
nihalpasham / luminal_dl_framework.md
Created August 24, 2025 06:15
Luminal - a deep learning framework in Rust.
image

High-level overview focusing on graph structure, search-based compilation, and visualization:

Luminal Architecture Overview

1. Core Graph Structure

Luminal is built around a directed acyclic graph (DAG) representation where:

@nihalpasham
nihalpasham / crane lift_gist.md
Last active January 7, 2026 01:56
The Cranelift backend (stream notes)

Cranelift

#idempotent

sketch

Cranelift IR:

  • Functions are compiled individually
  • The instructions in the function body use and produce values in SSA form i.e. Single Static Assignment