Models · Semantic segmentation
OneFormer
OneFormer (SHI Labs): one network for several segmentation tasks, used here for ADE20K scene segmentation.
stable Fork of huggingface/transformers@c4c4605 · backends: portable, kernels
- Paper OneFormer: One Transformer to Rule Universal Image Segmentation CVPR 2023 · first released 10 Nov 2022
- Authors’ code SHI-Labs/OneFormer (PyTorch), not the code forked here: The Hugging Face transformers port loads the authors' ADE20K Swin-L checkpoint without detectron2 or custom CUDA ops.
Checkpoint oneformer-swinl-ade20k
Paper 2022 Added in 0.1.0 Evaluated with 0.2.0
Use it
pip install fastforks Lean install with only what this model needs: pip install "fastforks-core[transformers]"
from fastforks import segmentation
model = segmentation.load("oneformer-swinl-ade20k") # kernels on a supported GPU, else portable PyTorch
result = model(image)
result.logits
result.backend # what ran: mode, device, dtype, kernels fastforks bench oneformer-swinl-ade20k Times the model on this machine. load(…, mode="portable") or mode="kernels" picks a backend; usage guide.
Speed and memory
Every backend on one GPU (RTX 5060 Ti 16 GB) and the same input, the authors’ code included. Kernels runs fp16. Portable runs fp16 on CUDA.
| Backend | dtype | Time per call (ms) | vs original fp16 | Peak memory allocated / reserved | Load (s) | First call (s) |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 307 | 0.67× | 6,853 MiB/7,808 MiB | – | – |
| Original fp16torch.autocast(fp16) around the forward | fp16 | 205 | – | 7,395 MiB/7,792 MiB | – | – |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | fp16 | 139 | 1.5× | 2,054 MiB/2,476 MiB | 4.1 | 0.15 |
| Kernels | fp16 | 100.0 | 2.1× | 2,054 MiB/2,476 MiB | 3.3 | 0.11 |
| Portable + torch.compileInductor: Triton kernel does not compile (torch bug) | fails | – | – | – | – | |
| TensorRT fp16 | fp16 | 83.3 | 2.5× | 3,258 MiBenginenot comparable | 140 (build) | – |
Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-03 to 2026-11-04. First call, 3 warm-up, peak reset, median of 3 rounds x median of 5 (tools/speed_check.py), synthetic CUDA input (bench_inputs); peak = max over the first call and the timed calls. Ratios divide two
times of this table (same GPU, same input). Original fp16 is the authors’ own precision option, else torch.autocast. torch.compile and TensorRT: build time instead of load time. TensorRT memory (engine, not comparable) is the GPU memory the engine took, read from the driver because TensorRT allocates outside PyTorch, so it can't be compared with the PyTorch peaks of the other rows.
Other devices
| Device | Backend | dtype | ms / call | Peak memory | Output vs reference | Input |
|---|---|---|---|---|---|---|
| Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-12 | Original | fp32 | out of memory | – | 1024x2048 | |
| Portable | fp16 | 1161 | 5,559 MiB process | matches | 1024x2048 | |
| Portable | fp32 | 1127 | 9,492 MiB process | matches | 1024x2048 | |
| Kernels | fp16 | not implemented | – | 1024x2048 | ||
| NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 174 | 2,022 MiB/2,454 MiB | – | 1024x2048 |
| Kernels | fp16 | 134 | 2,022 MiB/2,434 MiB | – | 1024x2048 | |
| NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 61.9 | 2,022 MiB/2,454 MiB | – | 1024x2048 |
| Kernels | fp16 | 47.2 | 2,022 MiB/2,434 MiB | – | 1024x2048 | |
| NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 133 | 2,022 MiB/2,454 MiB | – | 1024x2048 |
| Kernels | fp16 | 109 | 2,022 MiB/2,434 MiB | – | 1024x2048 | |
| NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 71.6 | 2,022 MiB/2,454 MiB | – | 1024x2048 |
| Kernels | fp16 | 58.9 | 2,022 MiB/2,434 MiB | – | 1024x2048 | |
| NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08 | Portable | fp16 | 37.7 | 2,046 MiB/2,474 MiB | – | 1024x2048 |
| Kernels | fp16 | 31.4 | 2,046 MiB/2,454 MiB | – | 1024x2048 | |
CUDA memory is torch’s peak allocated / reserved; Apple has no such counter, so the Mac rows show the process footprint (weights, Python and torch included). “Output vs reference” compares the device’s output with the stored golden output under the card’s tolerance; – = not checked on that device. Kernels “not implemented” = no kernels for this model on that backend yet: it runs portable there.
Licence and weights
Commercial use allowed
- Code
- Apache-2.0
- Weights
- MIT source
- Training data
-
- ImageNet-21k / ImageNet-22k (full ImageNet, fall 2011 release) noncommercial, non-commercial
- ADE20K (SceneParsing, 150 classes) noncommercial, non-commercial
Our reading of the licences, not legal advice.
Accuracy
The test set through the authors’ code and through ours: same checkpoint, same protocol. The distance between the original’s fp32 and fp16 runs is what half precision alone costs; our runs should stay within it.
ADE20K val
every 4th image, mIoU / aAcc %
| Run | dtype | mIoU % ↑ | aAcc % ↑ | Δ mIoU % vs fp32 original | images | ms / image |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 54.49 | 85.06 | reference | 500 | 191 |
| Original fp16 | fp16 | 54.26 | 85.05 | −0.23 | 500 | 123 |
| Portable fp32 | fp32 | 54.46 | 85.05 | −0.03 | 500 | 188 |
| Portable | fp16 | 54.37 | 85.05 | −0.12 | 500 | 85.3 |
| Kernels | fp16 | 54.38 | 85.14 | −0.11 | 500 | 58.6 |
Each image at its own size, argmax of the logits. Original = the authors’ code, same checkpoint and protocol. Measured on original fp32, original fp16: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-06; portable fp32: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 44640884, 2026-11-17; portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06.
Closeness to the original
Beyond the test-set scores: the raw output of ours against the original’s fp32 output on the same input, pixel by pixel. CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.001 and p99 <= 0.01 (absolute error of the output logits).
| Check | Tolerance | Measured |
|---|---|---|
| CPU fp32, max |diff| | ≤ 0.002 | not recorded |
| GPU default dtypes, mean |diff| | ≤ 0.001 | 0.00004 |
| GPU default dtypes, p99 |diff| | ≤ 0.01 | 0.00197 |
Recorded for oneformer-swinl-ade20k on RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-04, with these kernels: fvm_segseg_up
Details
OneFormer (Jain et al. 2023): Mask2Former-style universal segmentation conditioned on a task token; Swin backbone, run here for the semantic task.
- Input / output
- Input: one RGB image. Output: per-pixel class labels (logits with
logits=True). - Input size
- any H x W >= 1, resized or padded inside the model; tested up to 1988x2880 (8,614 MiB allocated)
- Outputs
logits- CUDA kernels
fvm_segfused kernels for Mask2Former and OneFormerseg_upfused resize and argmax of segmentation scores
- Apple (MPS)
- fp32, fp16
Full reference, generated from the repository
OneFormer (SHI Labs): one network for several segmentation tasks, used here for ADE20K scene segmentation.
Commercial use: yes.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
oneformer-swinl-ade20k | synthetic (1024x2048) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 307 205 139 100 fails: Inductor: Triton kernel does not compile (torch bug) 83.3 | 6853 / 7808 7395 / 7792 2054 / 2476 2054 / 2476 – 4524 / 4576 |
Details
- Original code: https://github.com/huggingface/transformers at
c4c4605f9618 - Code licence: Apache-2.0 (permissive); files:
- Weights licence: MIT
- Licence evidence: https://huggingface.co/shi-labs/oneformer_ade20k_swin_large/blob/4a5bac8e64f82681a12db2e151a4c2f4ce6092b2/README.md
- Training data: ImageNet-21k / ImageNet-22k (full ImageNet, fall 2011 release), ADE20K (SceneParsing, 150 classes)
- Kernel libraries:
fvm_seg,seg_up - Variants:
oneformer-swinl-ade20k - Outputs: logits; label_set:
ade20k-150 - Input size: any H x W >= 1, resized or padded inside the model
- Tested up to (portable, fp16, RTX 5060 Ti 16 GB):
oneformer-swinl-ade20k1988x2880 (8.4 GiB peak allocated, 14.9 reserved) oneformer-swinl-ade20k1024x2048, first call: TensorRT fp16 140 s (ONNX + engine).oneformer-swinl-ade20koriginal 1024x2048: torch.autocast(fp16) around the forwardoneformer-swinl-ade20kload / first call: original 5.08 s / 0.805 s (512x512), portable 4.1 s / 0.147† s, kernels 3.27† s / 0.109† s- † measured in the speed sweep after the portable load (or an earlier size) in the same process: file cache and kernels are warm, so the time is lower than a fresh start.
- Protocol, first call, 3 warm-up, peak reset, median of 3 rounds x median of 5 (tools/speed_check.py), synthetic CUDA input (bench_inputs); peak = max over the first call and the timed calls
Measured
Each image at its own size, argmax of the logits. Original = the original code named under Details, same checkpoint and protocol.
| variant | dataset | original fp32 | original fp16 | portable | portable fp32 | kernels | note |
|---|---|---|---|---|---|---|---|
oneformer-swinl-ade20k | ADE20K val, every 4th image, mIoU / aAcc % | 54.49 / 85.06 | 54.26 / 85.05 | 54.37 / 85.05 | 54.46 / 85.05 | 54.38 / 85.14 |
Measured on portable: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06; portable32: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 44640884, 2026-11-17; kernels: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06.
Parity
CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.001 and p99 <= 0.01 (absolute error of the output logits).
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
oneformer-swinl-ade20k | 4e-05 / 0.00197 | RTX 5060 Ti, torch 2.14.1+cu130 | fvm_seg@739693dff3b4:sm_120, seg_up@3e44e71200cd:sm_120 |
Example output
One fixed input through this checkpoint, the same for every model of the task (kernels · float16 · NVIDIA GeForce RTX 5060 Ti).
- table 62%
- plate 26%
- book 8.6%
- wall 3.4%
Input: A cup of coffee, Rachel Michetti (CC0).