SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2108.06152 · ICCV · 2021

Conditional DETR for Fast Training Convergence

Houqiang Li, Chen, Jingdong Wang, Zejia Fan, Lei Sun, Yuhui Yuan, Gang Zeng, Depu Meng

arXiv · PDF · Open in the Atlas

Code that ran

6 of 9 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (1 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 1 violated it and 1 has no contract verdict; 3 failures of our instrument; 3 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2108.06152.json · badge: /api/ran/2108.06152.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
atten4vis/conditionaldetr canonical (classifier label)
classifier basis: census
5 ran · 2 no recorded run
IDEA-Research/detrex community
Papers with Code archive
1 ran · 0 no recorded run
Atten4Vis/ConditionalDETR community
Papers with Code archive
0 ran · 1 no recorded run
FunctionStatusWhere it lives
ConditionalCrossAttention Ran
ran on a synthesized input · constructed an object; no result was computed
IDEA-Research/detrex/detrex/layers/attention.py
code served (permissive licence) · get_code("47b02db49bdfd76e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, ConditionalCrossAttention: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Parameters for ConditionalCrossAttention
embed_dim = 8
num_heads = 2
attn_drop = 0.1
proj_drop = 0.1
batch_first = False

# Create the model
model = nn.Module()

# Create tensors with distinct sizes for different dimensions
# batch_size = 2, num_query = 3, num_key = 5, embed_dim = 8
batch_size = 2
num_query = 3
num_key = 5

# When batch_first=False: (seq_len, batch, embed_dim)
query = torch.randn(num_query, batch_size, embed_dim)
key = torch.randn(num_key, batch_size, embed_dim)
value = torch.randn(num_key, batch_size, embed_dim)
identity = torch.randn(num_query, batch_size, embed_dim)

# Position embeddings with same shapes as query/key
query_pos = torch.randn(num_query, batch_size, embed_dim)
key_pos = torch.randn(num_key, batch_size, embed_dim)

# Query sine embedding for later layers
query_sine_embed = torch.randn(num_query, batch_size, embed_dim)

# Attention mask: (num_query, num_key)
attn_mask = None

# Key padding mask: (batch_size, num_key)
key_padding_mask = None

# Control flags
is_first_layer = True

ARGS = {
    'embed_dim': embed_dim,
    'num_heads': num_heads,
    'attn_drop': attn_drop,
    'proj_drop': proj_drop,
    'batch_first': batch_first,
    'query': query,
    'key': key,
    'value': value,
    'identity': identity,
    'query_pos': query_pos,
    'key_pos': key_pos,
    'query_sine_embed': query_sine_embed,
    'is_first_layer': is_first_layer,
    'attn_mask': attn_mask,
    'key_padding_mask': key_padding_mask,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ConditionalCrossAttention — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a ConditionalCrossAttention output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
convert_to_xywh Ran
ran, honoured the contract we drafted
atten4vis/conditionaldetr/datasets/coco_eval.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from yuhangzang/contextdet, is pointer only (licence: NOASSERTION) · get_code("f31a58bf6457ced5")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from yuhangzang/contextdet, and GitHub could not classify the licence of that repository (NOASSERTION). The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

dice_loss Ran
ran, violated the contract we drafted
atten4vis/conditionaldetr/models/segmentation.py
code served (permissive licence) · get_code("ac8fe530cdad4d8c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Create sample inputs and targets tensors
# The function expects tensors that can be flattened and have sigmoid applied
# Shape: batch_size=2, spatial_dims flattened to create predictions
batch_size = 2
num_spatial = 4

# inputs: predictions before sigmoid, shape (batch_size, num_spatial)
inputs = torch.randn(batch_size, num_spatial)

# targets: binary labels matching inputs shape, values 0 or 1
targets = torch.randint(0, 2, (batch_size, num_spatial), dtype=torch.float32)

# num_boxes: number of boxes for normalization
num_boxes = 2

ARGS = {
    "inputs": inputs,
    "targets": targets,
    "num_boxes": num_boxes,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
evaluate Ran
ran; our contract draft was wrong, not the code
atten4vis/conditionaldetr/datasets/coco_eval.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from yuhangzang/contextdet, is pointer only (licence: NOASSERTION) · get_code("fe0ddcc2d420c9a0")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from yuhangzang/contextdet, and GitHub could not classify the licence of that repository (NOASSERTION). The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

gen_sineembed_for_position Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
atten4vis/conditionaldetr/models/transformer.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from merlresearch/radar-detection-transformer, is pointer only (licence: AGPL-3.0) · get_code("d573d92393e20123")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from merlresearch/radar-detection-transformer, and AGPL-3.0, as GitHub detects it on that repository, is not in the permissive set Syntology serves inline. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

sigmoid_focal_loss Ran
ran; our contract draft was wrong, not the code
atten4vis/conditionaldetr/models/segmentation.py
code served (permissive licence) · get_code("5c0711aada67957e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn.functional as F

torch.manual_seed(0)

# Create small tensors for inputs and targets
# inputs: predictions (logits) - shape (2, 4) for batch_size=2, num_predictions=4
inputs = torch.randn(2, 4, requires_grad=True)

# targets: binary labels - shape (2, 4) matching inputs
targets = torch.randint(0, 2, (2, 4), dtype=torch.float32)

# num_boxes: number of boxes for normalization
num_boxes = 2

# alpha and gamma are already float parameters with defaults
alpha = 0.25
gamma = 2.0

ARGS = {
    "inputs": inputs,
    "targets": targets,
    "num_boxes": num_boxes,
    "alpha": alpha,
    "gamma": gamma,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
ConditionalDETR Not yet run
unverified (harvested, no recorded run)
Atten4Vis/ConditionalDETR/models/conditional_detr.py
code served (permissive licence) · get_code("630f5aa14fbee6c6")
How it ran

no invocation recorded.

build_transformer Not yet run
unverified (harvested, no recorded run)
atten4vis/conditionaldetr/models/transformer.py
code served (permissive licence) · get_code("bf149877606cbfba")
How it ran

no invocation recorded.

multi_head_attention_forward Not yet run
unverified (harvested, no recorded run)
atten4vis/conditionaldetr/models/attention.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from dvlab-research/mask-attention-free-transformer, is pointer only (licence: NONE) · get_code("f09175b0f39f0ad0")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from dvlab-research/mask-attention-free-transformer, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 7 are also present in other papers whose code we hold (4 with at least one paper dated earlier, 1 the same month, 7 later) and 2 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
sigmoid_focal_loss 56 other papers
6 dated earlier, 1 the same month, 49 later · 1 only as an assembly brick
2005.12872 (2020-05)
End-to-End Object Detection with Transformers
2010.04159 (2020-10)
Deformable DETR: Deformable Transformers for End-to-End Object Detection
2103.11731 (2021-03)
Meta-DETR: Image-Level Few-Shot Object Detection with Inter-Class Correlation Exploitation
and 53 more not named here
dice_loss 40 other papers
6 dated earlier, 34 later · 1 only as an assembly brick
2005.12872 (2020-05)
End-to-End Object Detection with Transformers
2010.04159 (2020-10)
Deformable DETR: Deformable Transformers for End-to-End Object Detection
2103.12115 (2021-03)
End-to-End Trainable Multi-Instance Pose Estimation with Transformers
and 37 more not named here
convert_to_xywh 24 other papers
5 dated earlier, 19 later
1512.02325 (2015-12)
SSD: Single Shot MultiBox Detector
2010.04159 (2020-10)
Deformable DETR: Deformable Transformers for End-to-End Object Detection
2103.11731 (2021-03)
Meta-DETR: Image-Level Few-Shot Object Detection with Inter-Class Correlation Exploitation
and 21 more not named here
evaluate 23 other papers
5 dated earlier, 18 later
1512.02325 (2015-12)
SSD: Single Shot MultiBox Detector
2010.04159 (2020-10)
Deformable DETR: Deformable Transformers for End-to-End Object Detection
2103.11731 (2021-03)
Meta-DETR: Image-Level Few-Shot Object Detection with Inter-Class Correlation Exploitation
and 20 more not named here
multi_head_attention_forward 4 other papers
4 later
Tang_Progressive_Attention_on_Multi-Level_Dense_Difference_Maps_for_Generic_Event_CVPR_2022_paper (2022 (year only))
Progressive Attention on Multi-Level Dense Difference Maps for Generic Event Boundary Detection
2307.12239 (2023-07)
Learning Dynamic Query Combinations for Transformer-based Object Detection and Segmentation
2309.01692 (2023-09)
Mask-Attention-Free Transformer for 3D Instance Segmentation
and 1 more not named here
gen_sineembed_for_position 3 other papers
3 later
2307.12239 (2023-07)
Learning Dynamic Query Combinations for Transformer-based Object Detection and Segmentation
2403.17709 (2024-03)
Groupwise Query Specialization and Quality-Aware Multi-Assignment for Transformer-based Visual Relationship Detection
2411.10293 (2024-11)
RETR: Multi-View Radar Detection Transformer for Indoor Perception
build_transformer 2 other papers
2 later
2307.12239 (2023-07)
Learning Dynamic Query Combinations for Transformer-based Object Detection and Segmentation
2309.01692 (2023-09)
Mask-Attention-Free Transformer for 3D Instance Segmentation

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

The recently-developed DETR approach applies the transformer encoder and decoder architecture to object detection and achieves promising performance. In this paper, we handle the critical issue, slow training convergence, and present a conditional cross-attention mechanism for fast DETR training. Our approach is motivated by that the cross-attention in DETR relies highly on the content embeddings for localizing the four extremities and predicting the box, which increases the need for high-quality content embeddings and thus the training difficulty. Our approach, named conditional DETR, learns a conditional spatial query from the decoder embedding for decoder multi-head cross-attention. The benefit is that through the conditional spatial query, each cross-attention head is able to attend to a band containing a distinct region, e.g., one object extremity or a region inside the object box. This narrows down the spatial range for localizing the distinct regions for object classification and box regression, thus relaxing the dependence on the content embeddings and easing the training. Empirical results show that conditional DETR converges 6.7× faster for the backbones R50 and R101 and 10× faster for stronger backbones DC5-R50 and DC5-R101. Code is available at https: //github.com/Atten4Vis/ConditionalDETR.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2108.06152")
get_code_for_paper("2108.06152")
have("2108.06152")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2108.06152.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2108.06152.svg)](https://syntology.ai/paper/2108.06152)

Connect an agent — have() is free.