AI generated

Confident
Model stylome-1.2-large
stylo.me/8fc1b5185d4ac02f

Hey llamas! First off, I have been working on a 30M-token multimodal dataset (mostly high-res anime images up to 4 MP with reasoning and super detailed descriptions) to fine-tune Qwen4-35B-A3B (well, honestly I didn't even know which model to use at first, if Qwen4 hadn't dropped two days ago this post would probably be about Inkling 2 Mini lol) on a single 80 GB A100, and I really did not want to spend 40+ hours waiting on PCIe block swapping.

Well, today I spent the whole day directing a team of bots (Gemini 4 Neon, GLM 5.3, and Gemini 4 Hydrogen) to cook a custom SFT engine specifically for the Qwen4 MoE architecture, and I wanted to share this ""masterpiece"" of artisanal AI slop with you! (fair warning: please do not ask me to explain the Triton pointer math or the QSA bitmasks on a whiteboard, I was literally just the guy holding the clipboard while the bots cooked <3)

How it fits the 57B model (35B MoE + 20.5B Engram + 0.83 GiB ViT) in ~36.2 GiB of base VRAM without block swapping:

  • The 256 stacked routed experts are quantized on the fly to symmetric per-channel INT8 (30.1 GiB across 40 layers) using a custom Triton Grouped GEMM that only computes dX in backward (no dW on frozen base weights and no duplicate transposed weights).
  • All sensitive layers stay in pure BF16 (30 Gated DeltaNet layers, 10 QSA layers, routers, 4-stream HyperConnections, shared experts, embeddings, lm_head, and the 27-layer ViT + merger).
  • The 20.48B Engram table (layers.1.ple) stays in system RAM as per-row INT8 (~19.1 GiB + 305 MiB fp16 scales, 0 GiB VRAM) with an async prefetch thread overlapped on a dedicated CUDA stream.
  • Hermetic sequence packing up to 16K tokens for mixed text and high-res images, isolating document boundaries across 3D MRoPE, Engram n-grams, causal conv1d, Gated DeltaNet cu_seqlens (with an automatic SM80 autotune patch for fla 0.6.1), and per-document QSA (SDPA FlashAttention-2 bypass for docs <= 2048 tokens and an L2-resident int32 bitmask with flex_attention for longer docs).
  • Streaming shard-by-shard loader and BF16 merger: downloads, quantizes, and deletes one shard at a time so peak disk usage stays under 4 GiB instead of 114 GB.

Benchmarks on a single A100 SXM 80GB (RunPod, torch 2.11+cu128, triton 3.6, transformers 5.26.0, full gradient checkpointing):

Workload Preset Step Time Throughput Peak VRAM (Alloc / Reserved)
Text-only (T=1024, bs=1) A 0.792 s 1,292 tok/s 38.06 GiB
Multimodal (T=8192, ~2K img) A 4.225 s 1,939 tok/s 46.53 / 47.53 GiB
Multimodal (T=16384, ~2K img) A 7.318 s 2,239 tok/s 54.26 / 56.24 GiB
Multimodal (T=8192, ~2K img) B (+ViT LoRA) 5.589 s 1,466 tok/s 48.17 / 49.47 GiB
Multimodal (T=16384, ~2K img) B (+ViT LoRA) 9.947 s 1,647 tok/s 56.68 / 58.90 GiB

Preset A trains visual.merger (full) + Attention LoRA (r=32) + shared_expert (full) (189M trainable params, 378 MB checkpoint). Preset B adds LoRA (r=16) across all 27 ViT layers (196.7M params, 393 MB).

We just finished a full end-to-end pipeline sanity check on the A100 with a 100-sample smoke test (5 anime images with varied captions) using Preset B: packed into tar + bin shards, trained with eval (val_loss per token dropped cleanly from 0.4171 -> 0.2842 -> 0.2133 across a checkpoint resume), merged all 33/33 shards back to a clean BF16 checkpoint, and ran inference on the merged model in standard Qwen4MoeForConditionalGeneration.

Requirements and current limitations: requires an NVIDIA GPU with >= 48 GB VRAM (tested on 80 GB A100 SM80; 24-32 GB GPUs cannot fit the 36.2 GiB base weights) and >= 32 GB host RAM for the INT8 Engram table; video is not supported yet.

I still need to test the setup inside actual Google Colab (my credits reset on December 10th, which is when I will run the full 30M-token job), but the whole pipeline is working end to end on RunPod and passing 56/56 parity and packing tests locally. Check it out if you can <3

https://github.com/SrPakura/q4forge