timm-to-lux

Converts PyTorch timm models into numerically-equivalent Lux.jl implementations with parity-tested weight loading.

12|1|Updated May 18, 2026
One-click install
npx skills add https://github.com/csvance/Luximm.jl --skill timm-to-lux-csvance
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: timm-to-lux
Source: https://github.com/csvance/Luximm.jl/tree/main/skills/timm-to-lux
Command: npx skills add https://github.com/csvance/Luximm.jl --skill timm-to-lux-csvance

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Porting a PyTorch timm model to Lux.jl by hand is error-prone: cross-correlation vs convolution, padding semantics, norm epsilon defaults, variance corrections, and NCHW vs WHCN axis order all silently break numerical equivalence. This Skill encodes a seven-phase workflow that produces a parity-verified Lux port with pretrained weight loading from HuggingFace. ## Core Features & Use Cases - Parity fixture capture: Guides creation of HDF5 fixtures from timm via Python sidecars, including per-stage and per-block intermediates for localizing divergence. - Numeric convention checklist: Enforces cross_correlation=true, explicit epsilon/affine on norms, corrected=false variance, zero-padded pooling, and Lux.testmode for parity tests. - Weight loading pipeline: Wires .safetensors downloads from HuggingFace Hub through apply_state_dict mappings, with axis-order normalization between SafeTensors and HDF5 layouts. - Use Case: Port ResNet-50 from timm to Lux.jl: dump fixtures, implement @compact layers, load pretrained weights, and verify end-to-end parity within 1e-3 tolerance before adding more variants. ## Quick Start Ask the agent to port a specific timm model such as resnet50 to Lux.jl with parity tests and HuggingFace weight loading, and it will follow the seven-phase workflow.

Frequently Asked Questions about timm-to-lux

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I port a PyTorch timm model to Lux.jl?

Follow the seven-phase workflow: capture HDF5 parity fixtures from timm in Python, stub the Julia package layout, implement layers with @compact, keep the forward autodiff-safe, wire .safetensors loading from HuggingFace, verify parity end-to-end, then iterate with Revise.

Why does my Lux Conv output differ from PyTorch Conv2d?

PyTorch Conv2d performs cross-correlation while Lux Conv defaults to true convolution with a flipped kernel. Pass cross_correlation = true to every Conv, or flipkernel = true on NNlib.DenseConvDims when calling NNlib.conv directly.

How do I load timm pretrained weights into a Lux model?

Download the model.safetensors file from the timm HuggingFace repo, load it with SafeTensors.jl, normalize the axis order to the HDF5-natural reversed layout, then apply it with apply_state_dict using the model's mapping function.

Why does my parity test pass sometimes and fail other times?

The usual cause is forgetting Lux.testmode(st), which lets BatchNorm running stats update and dropout activate during the test. Mismatched norm epsilon defaults or missing corrected = false on variance also cause flaky-looking numeric drift.

Should I port all model variants at once or one at a time?

Port one variant first, typically the smallest, and land parity before adding others. Adding untested variants to the dispatcher early creates code paths that a failed parity test cannot localize.